get IP address and port by socketaddr structure information */
| 619 | |
| 620 | /* get IP address and port by socketaddr structure information */ |
| 621 | static int socketaddr_to_ipaddr_port(const struct sockaddr *sockaddr, ip_addr_t *addr, uint16_t *port) |
| 622 | { |
| 623 | const struct sockaddr_in* sin = (const struct sockaddr_in*) (const void *) sockaddr; |
| 624 | |
| 625 | #if NETDEV_IPV4 && NETDEV_IPV6 |
| 626 | addr->u_addr.ip4.addr = sin->sin_addr.s_addr; |
| 627 | addr->type = IPADDR_TYPE_V4; |
| 628 | #elif NETDEV_IPV4 |
| 629 | addr->addr = sin->sin_addr.s_addr; |
| 630 | #elif NETDEV_IPV6 |
| 631 | #error "not support IPV6." |
| 632 | #endif /* NETDEV_IPV4 && NETDEV_IPV6 */ |
| 633 | |
| 634 | *port = (uint16_t) HTONS_PORT(sin->sin_port); |
| 635 | |
| 636 | return 0; |
| 637 | } |
| 638 | |
| 639 | #ifdef AT_USING_SOCKET_SERVER |
| 640 | /* set socketaddr structure information by IP address and port */ |
no outgoing calls
no test coverage detected