MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / socketaddr_to_ipaddr_port

Function socketaddr_to_ipaddr_port

components/net/at/at_socket/at_socket.c:621–637  ·  view source on GitHub ↗

get IP address and port by socketaddr structure information */

Source from the content-addressed store, hash-verified

619
620/* get IP address and port by socketaddr structure information */
621static 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 */

Callers 4

at_bindFunction · 0.85
at_connectFunction · 0.85
at_recvfromFunction · 0.85
at_sendtoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected