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

Function lwip_getaddrname

components/net/lwip/lwip-1.4.1/src/api/sockets.c:1420–1453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1418}
1419
1420static int
1421lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local)
1422{
1423 struct lwip_sock *sock;
1424 struct sockaddr_in sin;
1425 ip_addr_t naddr;
1426
1427 sock = get_socket(s);
1428 if (!sock) {
1429 return -1;
1430 }
1431
1432 memset(&sin, 0, sizeof(sin));
1433 sin.sin_len = sizeof(sin);
1434 sin.sin_family = AF_INET;
1435
1436 /* get the IP address and port */
1437 netconn_getaddr(sock->conn, &naddr, &sin.sin_port, local);
1438
1439 LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getaddrname(%d, addr=", s));
1440 ip_addr_debug_print(SOCKETS_DEBUG, &naddr);
1441 LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", sin.sin_port));
1442
1443 sin.sin_port = htons(sin.sin_port);
1444 inet_addr_from_ipaddr(&sin.sin_addr, &naddr);
1445
1446 if (*namelen > sizeof(sin)) {
1447 *namelen = sizeof(sin);
1448 }
1449
1450 MEMCPY(name, &sin, *namelen);
1451 sock_set_errno(sock, 0);
1452 return 0;
1453}
1454
1455int
1456lwip_getpeername(int s, struct sockaddr *name, socklen_t *namelen)

Callers 2

lwip_getpeernameFunction · 0.70
lwip_getsocknameFunction · 0.70

Calls 2

get_socketFunction · 0.70
netconn_getaddrFunction · 0.70

Tested by

no test coverage detected