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

Function netconn_getaddr

components/net/lwip/lwip-1.4.1/src/api/api_lib.c:134–153  ·  view source on GitHub ↗

* Get the local or remote IP address and port of a netconn. * For RAW netconns, this returns the protocol instead of a port! * * @param conn the netconn to query * @param addr a pointer to which to save the IP address * @param port a pointer to which to save the port (or protocol for RAW) * @param local 1 to get the local IP address, 0 to get the remote one * @return ERR_CONN for invalid co

Source from the content-addressed store, hash-verified

132 * ERR_OK if the information was retrieved
133 */
134err_t
135netconn_getaddr(struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local)
136{
137 struct api_msg msg;
138 err_t err;
139
140 LWIP_ERROR("netconn_getaddr: invalid conn", (conn != NULL), return ERR_ARG;);
141 LWIP_ERROR("netconn_getaddr: invalid addr", (addr != NULL), return ERR_ARG;);
142 LWIP_ERROR("netconn_getaddr: invalid port", (port != NULL), return ERR_ARG;);
143
144 msg.function = do_getaddr;
145 msg.msg.conn = conn;
146 msg.msg.msg.ad.ipaddr = addr;
147 msg.msg.msg.ad.port = port;
148 msg.msg.msg.ad.local = local;
149 err = TCPIP_APIMSG(&msg);
150
151 NETCONN_SET_SAFE_ERR(conn, err);
152 return err;
153}
154
155/**
156 * Bind a netconn to a specific local IP address and port.

Callers 2

lwip_recvfromFunction · 0.70
lwip_getaddrnameFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected