* 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
| 266 | * ERR_OK if the information was retrieved |
| 267 | */ |
| 268 | err_t |
| 269 | netconn_getaddr(struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local) |
| 270 | { |
| 271 | API_MSG_VAR_DECLARE(msg); |
| 272 | err_t err; |
| 273 | |
| 274 | LWIP_ERROR("netconn_getaddr: invalid conn", (conn != NULL), return ERR_ARG;); |
| 275 | LWIP_ERROR("netconn_getaddr: invalid addr", (addr != NULL), return ERR_ARG;); |
| 276 | LWIP_ERROR("netconn_getaddr: invalid port", (port != NULL), return ERR_ARG;); |
| 277 | |
| 278 | API_MSG_VAR_ALLOC(msg); |
| 279 | API_MSG_VAR_REF(msg).conn = conn; |
| 280 | API_MSG_VAR_REF(msg).msg.ad.local = local; |
| 281 | #if LWIP_MPU_COMPATIBLE |
| 282 | err = netconn_apimsg(lwip_netconn_do_getaddr, &API_MSG_VAR_REF(msg)); |
| 283 | *addr = msg->msg.ad.ipaddr; |
| 284 | *port = msg->msg.ad.port; |
| 285 | #else /* LWIP_MPU_COMPATIBLE */ |
| 286 | msg.msg.ad.ipaddr = addr; |
| 287 | msg.msg.ad.port = port; |
| 288 | err = netconn_apimsg(lwip_netconn_do_getaddr, &msg); |
| 289 | #endif /* LWIP_MPU_COMPATIBLE */ |
| 290 | API_MSG_VAR_FREE(msg); |
| 291 | |
| 292 | return err; |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * @ingroup netconn_common |
no test coverage detected