1 /** 2 * @file 3 * netif API (to be used from non-TCPIP threads) 4 */ 5 6 /* 7 * Redistribution and use in source and binary forms, with or without modification, 8 * are permitted provided that the following conditions are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 3. The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 * OF SUCH DAMAGE. 28 * 29 * This file is part of the lwIP TCP/IP stack. 30 * 31 */ 32 #ifndef LWIP_HDR_NETIFAPI_H 33 #define LWIP_HDR_NETIFAPI_H 34 35 #include "lwip/opt.h" 36 37 #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ 38 39 #include "lwip/sys.h" 40 #include "lwip/netif.h" 41 #include "lwip/dhcp.h" 42 #if LWIP_IPV6_DHCP6 43 #include "lwip/dhcp6.h" 44 #endif /* LWIP_IPV6_DHCP6 */ 45 #include "lwip/autoip.h" 46 #include "lwip/priv/tcpip_priv.h" 47 #include "lwip/priv/api_msg.h" 48 #include "lwip/prot/ethernet.h" 49 50 #define netifapi_netif_find netifapi_netif_find_by_name 51 52 #ifdef __cplusplus 53 extern "C" { 54 #endif 55 56 #if LWIP_IPV6 && LWIP_NETIF_NBR_CACHE_API 57 struct ipv6_neighbor { 58 struct ip6_addr nbripaddr; 59 u32_t reachabletime; 60 u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; 61 u8_t hwlen; 62 u8_t curstate; 63 }; 64 #endif 65 66 /* User can add neighbors with below states */ 67 #define ND6_STATE_REACHABLE 2 68 #if LWIP_ND6_STATIC_NBR 69 #define ND6_STATE_PERMANENT 6 70 #endif 71 72 /* API for application */ 73 #if LWIP_ARP && LWIP_IPV4 74 /* Used for netfiapi_arp_* APIs */ 75 enum netifapi_arp_entry { 76 NETIFAPI_ARP_PERM /* Permanent entry */ 77 /* Other entry types can be added here */ 78 }; 79 80 /** @ingroup netifapi_arp */ 81 err_t netifapi_arp_add(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr, enum netifapi_arp_entry type); 82 /** @ingroup netifapi_arp */ 83 err_t netifapi_arp_remove(const ip4_addr_t *ipaddr, enum netifapi_arp_entry type); 84 #endif /* LWIP_ARP && LWIP_IPV4 */ 85 86 err_t netifapi_netif_add(struct netif *netif 87 #if LWIP_IPV4 88 , const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw 89 #endif /* LWIP_IPV4 */ 90 ); 91 92 #if LWIP_IPV4 93 err_t netifapi_netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, 94 const ip4_addr_t *netmask, const ip4_addr_t *gw); 95 #endif /* LWIP_IPV4*/ 96 97 /* 98 Func Name: netifapi_netif_find_by_name 99 */ 100 /** 101 * @ingroup netifapi_netif 102 * 103 * @brief 104 * This is a thread safe API, used to get the netif pointer whoes name was the input argument. 105 * It is recommended to use this API instead of netif_find_by_name(). 106 * Call netif_find() in a thread-safe way by running that function inside the tcpip_thread 107 * context. 108 * 109 * @param[in] name Name of the netif. 110 * 111 * @returns 112 * The netif pointer : On success \n 113 * NULL : the netif was NOT exist \n 114 * 115 * @par Related Topics 116 * netif_find_by_name() 117 * 118 */ 119 120 struct netif *netifapi_netif_find_by_name(const char *name); 121 122 /* 123 Func Name: netifapi_netif_find_by_ifindex 124 */ 125 /** 126 * @ingroup netifapi_netif 127 * 128 * @brief 129 * This is a thread safe API, used to get the netif pointer whoes index equals the input argument. 130 * It is recommended to use this API instead of netif_find_by_ifindex(). 131 * Call netif_find_by_ifindex() in a thread-safe way by running that function inside the 132 * tcpip_thread context. 133 * 134 * @param[in] ifindex Index of the netif. 135 * 136 * @returns 137 * The netif pointer : On success \n 138 * NULL : the netif was NOT exist \n 139 * 140 * @par Related Topics 141 * netif_find_by_ifindex() 142 */ 143 144 struct netif *netifapi_netif_find_by_ifindex(unsigned ifindex); 145 146 /* 147 Func Name: netifapi_netif_find_by_ipaddr 148 */ 149 /** 150 * @ingroup netifapi_netif 151 * 152 * @brief 153 * This is a thread safe API, used to get the netif pointer whoes address equals the input argument. 154 * It is recommended to use this API instead of netif_find_by_ipaddr(). 155 * Call netif_find_by_ipaddr() in a thread-safe way by running that function inside the tcpip_thread 156 * context. 157 * 158 * @param[in] ipaddr The IP address. 159 * 160 * @returns 161 * The netif pointer : On success \n 162 * NULL : the netif was NOT exist \n 163 * 164 * @par Related Topics 165 * netif_find_by_ipaddr() 166 */ 167 struct netif *netifapi_netif_find_by_ipaddr(const ip_addr_t *ipaddr); 168 169 #if LWIP_IPV4 170 /* 171 Func Name: netifapi_netif_get_addr 172 */ 173 /** 174 * @ingroup netifapi_netif 175 * 176 * @brief 177 * 178 * This is a thread safe API, used to get IP_add configuration for a network interface 179 (including netmask and default gateway). 180 * It is recommended to use this API instead of netif_get_addr(). 181 * Call netif_get_addr() in a thread-safe way by running that function inside the 182 * tcpip_thread context. 183 * 184 * @param[in] netif Indicates the network interface to get. 185 * @param[in] ipaddr Indicates the IP address. 186 * @param[in] netmask Indicates the network mask. 187 * @param[in] gw Indicates the default gateway IP address. 188 * 189 * @returns 190 * 0 : On success \n 191 * Negative value : On failure \n 192 * 193 * @par Related Topics 194 * netif_get_addr() 195 * 196 * @note 197 * - netmask and/or gw can be passed NULL, if these details about the netif are not needed 198 */ 199 err_t netifapi_netif_get_addr(struct netif *netif, 200 ip4_addr_t *ipaddr, 201 ip4_addr_t *netmask, 202 ip4_addr_t *gw); 203 204 #endif /* LWIP_IPV4 */ 205 err_t netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc, 206 netifapi_errt_fn errtfunc); 207 /* 208 * @ingroup netifapi_netif 209 * @brief 210 * Call the "argfunc" with argument arg in a thread-safe way by running that function inside the tcpip_thread context. 211 * @note Use this function only for functions where there is only "netif" parameter. 212 */ 213 err_t netifapi_netif_call_argcb(struct netif *netif, netifapi_arg_fn argfunc, void *arg); 214 215 /* 216 * @ingroup netifapi_netif 217 * @brief 218 * Call the "argfunc" with argument arg in a thread-safe way by running that function inside the tcpip_thread context. 219 */ 220 err_t netifapi_call_argcb(netifapi_arg_fn argfunc, void *arg); 221 222 #if LWIP_IPV6 223 /** 224 * @ingroup netifapi_netif 225 * @brief 226 * This function allows for the addition of a new IPv6 address to an interface. 227 * It takes care of finding an empty slot and then sets the address tentative 228 * (to make sure that all the subsequent processing happens). 229 * 230 * 231 * @param[in] netif Indicates the netif to add the address on. 232 * @param[in] ip6addr Indicates the address to add. 233 * 234 * @returns 235 * 0 : On success. \n 236 * Negative value : On failure. 237 * ERR_BUF : If there is no space to add new IPv6 Address. 238 */ 239 err_t netifapi_netif_add_ip6_address(struct netif *netif, ip_addr_t *ipaddr); 240 241 /** 242 * @ingroup netifapi_netif 243 * @brief 244 * This function allows for the easy removal of an existing IPv6 address from an interface. 245 * 246 * 247 * @param[in] netif Indicates the netif to remove the address from. 248 * @param[in] ip6addr Indicates the address to remove. 249 * @note 250 * - This interface may force any blocking accept() to return failure with errno ECONNABORTED. 251 */ 252 void netifapi_netif_rmv_ip6_address(struct netif *netif, ip_addr_t *ipaddr); 253 254 /** 255 * @ingroup netifapi_netif 256 * @brief 257 * This function allows to join a group without sending out MLD6 Report message. 258 * This function is not RFC 2710 compliant and is a custom function 259 * 260 * 261 * @param[in] netif Indicates the netif which want to join a group. 262 * @param[in] ip6addr Indicates the group address. 263 */ 264 err_t netifapi_netif_join_ip6_multicastgroup(struct netif *netif, ip6_addr_t *ip6addr); 265 266 /* 267 * @ingroup netifapi_netif 268 * This function allows for the easy addition of a new IPv6 link local address to an interface. 269 * It uses slot fixed for link local address and then sets the address tentative 270 * (to make sure that all the subsequent processing happens). 271 * This Interface MUST be called to configure link local IP address, after addition of netif. 272 * 273 * @param netif netif to add the address on 274 * @param ip6addr address to add 275 * @param from_mac_48bit specifies whether mac address is 48 bit for 64 bit format */ 276 err_t netifapi_netif_add_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit); 277 278 err_t netif_create_ip6_linklocal_address_wrapper(struct netif *netif, void *arg); 279 280 /* 281 Func Name: netifapi_netif_get_default 282 */ 283 /** 284 * @ingroup netifapi_netif 285 286 * @brief 287 * This API is used to get the default network interface. 288 * It is used to output all packets for which no specific route is found. 289 * 290 * @return 291 * NULL: if either the default netif was NOT exist or the default netif was down \n 292 * Others: the default netif \n 293 */ 294 struct netif *netifapi_netif_get_default(void); 295 296 #if LWIP_IPV6_AUTOCONFIG 297 /** 298 * @ingroup netifapi_netif 299 * @brief 300 * This function is used to enable autoconfig for IPv6 address in a thread-safe way. 301 * That is, the indicated network interface will send out an RS packet immediately to obtain RA. 302 * 303 * @param[in] netif Indicates the lwIP network interface. 304 * 305 * @note 306 * 307 * For netifapi_set_ip6_autoconfig_enabled(): 308 * - It enables stateless autoconfiguration. 309 * - It requires the router/default-gateway to understand and implement RFC-4862, but requires no DHCPv6 server. 310 * - No server keeps track of what has or hasn't been assigned, and no server approves the use of the address, 311 * or pass it out. 312 * - Once called: send out an RS packet immediately to obtain RA. 313 * - When receiving an RA, lwIP can generate an IPv6 address (DAD first) and update routing information. 314 * 315 * For netifapi_dhcp6_enable_stateful(): 316 * - It enables stateful DHCPv6 client autoconfiguration (stateless disabled). 317 * - It requires the DHCPv6 server(s) to provide addressing and service information. 318 * - The DHCP server and the client both maintain state information to keep addresses from conflicting, 319 * to handle leases, and to renew addresses over time. 320 * - Once called: disable autoconfig for IPv6 address (clean autoconfig generated addresses), 321 * and start DHCPv6 procedure to create a stateful DHCPv6 client (if no stateful DHCPv6 client). 322 * 323 * For netifapi_dhcp6_enable_stateless(): 324 * - It is used to get "Other configuration" in RFC-4861. 325 * - It requires the DHCPv6 server(s) to provide service information (like DNS servers and NTP servers), 326 * but no addressing information. 327 * - Once called: no effect to current IPv6 addresses, 328 * and start DHCPv6 procedure to create a stateless DHCPv6 client (if no DHCPv6 client). 329 * 330 * @par Related Topics 331 * netifapi_dhcp6_enable_stateful() 332 * netifapi_dhcp6_enable_stateless() 333 */ 334 err_t netifapi_set_ip6_autoconfig_enabled(struct netif *netif); 335 336 /** 337 * @ingroup netifapi_netif 338 * @brief 339 * This function is used to disable autoconfig for IPv6 address in a thread-safe way. 340 * That is, autoconfig generated addresses on the indicated network interface will be invalid. 341 * 342 * @param[in] netif Indicates the lwIP network interface. 343 * 344 * @note 345 * For now, since only prefixes have the autoconfig generated flag, while IPv6 addresses don't have, 346 * lwIP can only invalid addresses by prefixes rather than addresses. So, when a network interface has 347 * a manually configured IPv6 address, and an autoconfig generated IPv6 address which have the same 348 * prefix, calling netifapi_set_ip6_autoconfig_disabled() will invalid both addresses. 349 * 350 * @par Related Topics 351 * netifapi_dhcp6_disable() 352 * netifapi_dhcp6_release_stateful() 353 */ 354 err_t netifapi_set_ip6_autoconfig_disabled(struct netif *netif); 355 #endif 356 357 #endif /* LWIP_IPV6 */ 358 359 #if DRIVER_STATUS_CHECK 360 /** 361 * @ingroup netifapi_netif 362 * @brief 363 * This API is used to set the netif driver status to the "Driver Not Ready" state. the driver must call this API 364 * to intimate the stack that the send buffer in the driver is full. 365 * 366 * @param[in] netif Indicates the lwIP network interface. 367 * 368 * @returns 369 * ERR_OK: On success \n 370 * ERR_ARG: On passing invalid arguments. \n 371 */ 372 err_t netifapi_stop_queue(struct netif *netif); 373 374 /** 375 * @ingroup netifapi_netif 376 * @brief 377 * This API is used to set the netif driver status to the "Driver Ready" state. This API is called by the driver to 378 * inform the stack that the driver send buffer is available to send after netifapi_stop_queue() was called 379 * previously. 380 * 381 * @param[in] netif Indicates the lwIP network interface. 382 * 383 * @returns 384 * ERR_OK: On success \n 385 * ERR_ARG: On passing invalid arguments. \n 386 */ 387 err_t netifapi_wake_queue(struct netif *netif); 388 #endif 389 390 /** @ingroup netifapi_netif */ 391 err_t netifapi_netif_name_to_index(const char *name, u8_t *index); 392 /** @ingroup netifapi_netif */ 393 err_t netifapi_netif_index_to_name(u8_t index, char *name); 394 395 /** @ingroup netifapi_netif 396 * @brief 397 * This API is used to remove a network interface from the list of lwIP netifs 398 * in a thread-safe manner. 399 * The Ethernet driver calls this API in a thread-safe manner to remove a network 400 * interface from the list of lwIP netifs. 401 * 402 * @param[in] n Indicates the network interface to be removed. 403 * 404 * @returns 405 * ERR_OK: On success. \n 406 * ERR_VAL: On failure due to illegal value. \n 407 * ERR_ARG: On passing invalid arguments. 408 * 409 * @note 410 - Any data sent by the application will return success, 411 but the data will not be sent if only netifapi_netif_remove() API is called and not the sockets. 412 - The adaptor must close all the connections on socket before netifapi_netif_remove() 413 API is called, as netifapi_netif_remove() does not close established connections. 414 * @see netif_remove() 415 */ 416 err_t netifapi_netif_remove(struct netif *netif); 417 418 /** @ingroup netifapi_netif 419 * @brief 420 * This interface is used to bring an interface up in a thread-safe way. 421 * That is, the interface is available for processing traffic. 422 * 423 * @param[in] n Indicates the network interface. 424 * 425 * @note 426 * Enabling DHCP on a down interface will make it come up once configured. 427 * 428 * @par Related Topics 429 * netifapi_dhcp_start() 430 * 431 * @see netif_set_up() 432 */ 433 err_t netifapi_netif_set_up(struct netif *netif); 434 435 /** @ingroup netifapi_netif 436 * @brief 437 * This interface is used to bring an interface down in a thread-safe way. 438 * That is, the interface disables any traffic processing. 439 * 440 * @param[in] n Indicates the network interface. 441 * 442 * @note 443 * Enabling DHCP on a down interface will make it come up once configured. 444 * 445 * @par Related Topics 446 * netifapi_dhcp_start() 447 * 448 * @see netif_set_down() 449 */ 450 err_t netifapi_netif_set_down(struct netif *netif); 451 452 /** @ingroup netifapi_netif 453 * 454 * @param[in] netif Indicates the network interface to be set as default. 455 * 456 * @brief 457 * This interface is used to set a network interface as the default network interface. 458 * It is used to output all packets for which no specific route is found. 459 * 460 * @param[in] netif Indicates the lwIP network interface. 461 * 462 * @see netif_set_default() 463 */ 464 err_t netifapi_netif_set_default(struct netif *netif); 465 466 /** @ingroup netifapi_netif 467 * 468 * @brief 469 * This thread-safe interface is called by the driver when its link goes up. 470 * 471 * @param[in] netif Indicates the lwIP network interface. 472 * 473 * @see netif_set_link_up() 474 */ 475 err_t netifapi_netif_set_link_up(struct netif *netif); 476 477 /** @ingroup netifapi_netif 478 * 479 * @brief 480 * This thread-safe interface is called by the driver when its link goes down. 481 * 482 * @param[in] netif Indicates the lwIP network interface. 483 * 484 * @see netif_set_link_down() 485 */ 486 err_t netifapi_netif_set_link_down(struct netif *netif); 487 488 /** 489 * @defgroup netifapi_dhcp4 DHCPv4 490 * @ingroup netifapi 491 * To be called from non-TCPIP threads 492 */ 493 /** @ingroup netifapi_dhcp4 494 * 495 * @brief 496 * This interface is used to start DHCP negotiation for a network interface. If no DHCP client instance 497 * is attached to this interface, a new client is created first. If a DHCP client instance is already 498 * present, it restarts negotiation. It is the thread-safe way for calling dhcp_start in the user space. 499 * 500 * @param[in] netif Indicates the lwIP network interface. 501 * 502 * @see dhcp_start() 503 */ 504 err_t netifapi_dhcp_start(struct netif *netif); 505 506 /** 507 * @ingroup netifapi_dhcp4 508 * 509 * @brief 510 * This interface is used to remove the DHCP client from the interface. It stops DHCP configuration. 511 * It is the thread-safe way for calling dhcp_stop in the user space. 512 * 513 * @param[in] netif Indicates the lwIP network interface. 514 * 515 * @deprecated Use netifapi_dhcp_release_and_stop() instead. 516 */ 517 err_t netifapi_dhcp_stop(struct netif *netif); 518 519 /** @ingroup netifapi_dhcp4 520 * 521 * @brief 522 * This interface is used to make the DHCP client inform the DHCP server regarding its manual(static) 523 * IP configuration. 524 * This is done by sending a DHCP_INFORM message from the client to the server. 525 * It is the thread-safe way for calling dhcp_inform in the user space. 526 * 527 * @param[in] netif Indicates the lwIP network interface. 528 * 529 * @see dhcp_inform() 530 */ 531 err_t netifapi_dhcp_inform(struct netif *netif); 532 533 /** @ingroup netifapi_dhcp4 534 * 535 * @brief 536 * This interface is used to make the DHCP client running on the interface to renew its existing 537 * IP configuration to the DHCP server from whom it has leased the IP Configuration. 538 * This is done by sending a DHCP_REQUEST message from the client to the server after T1-Timer Expiry. 539 * It is the thread-safe way for calling dhcp_renew in the user space. 540 * 541 * @param[in] netif Indicates the lwIP network interface. 542 * 543 * @see dhcp_renew() 544 */ 545 err_t netifapi_dhcp_renew(struct netif *netif); 546 547 /** 548 * @ingroup netifapi_dhcp4 549 * 550 * @brief 551 * This interface is used to release the IP Configuration on a network interface that it has leased 552 * from the DHCP Server and informs the DHCP server that this IP Configuration is no longer needed by the client. 553 * This is done by sending a DHCP_RELEASE message from the client to the server. 554 * It is the thread-safe way for calling dhcp_release in the user space. 555 * 556 * @param[in] netif Indicates the lwIP network interface. 557 * 558 * @deprecated Use netifapi_dhcp_release_and_stop() instead. 559 */ 560 err_t netifapi_dhcp_release(struct netif *netif); 561 562 /** @ingroup netifapi_dhcp4 563 * @see dhcp_release_and_stop() 564 */ 565 err_t netifapi_dhcp_release_and_stop(struct netif *netif); 566 567 /** @ingroup netifapi_dhcp4 568 * 569 * @brief 570 * This interface is used to get the DHCP negotiation status for a network interface. 571 * It is the thread-safe way for calling dhcp_is_bound() in the user space. 572 * 573 * @param[in] netif Indicates the lwIP network interface. 574 * 575 * @see dhcp_is_bound() 576 */ 577 err_t netifapi_dhcp_is_bound(struct netif *netif); 578 579 /** @ingroup netifapi_dhcp4 580 * 581 * @brief 582 * This interface is used to free the memory allocated for DHCP during DHCP start. 583 * It is the thread-safe way for calling dhcp_cleanup in the user space. 584 * 585 * @param[in] netif Indicates the lwIP network interface. 586 * 587 * @see dhcp_cleanup() 588 */ 589 err_t netifapi_dhcp_cleanup(struct netif *netif); 590 591 /** 592 * @defgroup netifapi_autoip AUTOIP 593 * @ingroup netifapi 594 * To be called from non-TCPIP threads 595 */ 596 /** @ingroup netifapi_autoip 597 * 598 * Call autoip_start() in a thread-safe way by running that function inside the tcpip_thread context. 599 * 600 * @param[in] n Indicates the lwIP network interface. 601 * 602 * @returns 603 * ERR_OK: On success \n 604 * ERR_MEM: On failure due to memory \n 605 * ERR_VAL: On failure due to Illegal value. 606 * 607 * @see autoip_start() 608 */ 609 err_t netifapi_autoip_start(struct netif *netif); 610 611 /** @ingroup netifapi_autoip 612 * 613 * @brief 614 * Thread-safe API to stop the AutoIP client. 615 * 616 * @param[in] n Indicates the lwIP network interface. 617 * 618 * @returns 619 * ERR_OK: On success. \n 620 * ERR_ARG: On passing invalid arguments. 621 * 622 * @note 623 * - Call the autoip_stop API to stop the AutoIP service. 624 * - Use only for functions where there is only "netif" parameter. 625 * 626 * @see autoip_stop() 627 */ 628 err_t netifapi_autoip_stop(struct netif *netif); 629 630 #if LWIP_NETIF_LINK_CALLBACK 631 /* 632 Func Name: netifapi_netif_set_link_callback 633 */ 634 /** 635 * @ingroup netifapi_netif 636 * @brief 637 * This API is used to set callback to netif. This API is called whenever a link is brought up or down. 638 * 639 * @param[in] netif Indicates the lwIP network interface. 640 * @param[in] link_callback The callback pointer. 641 * 642 * @returns 643 * ERR_OK: This API always returns this value. \n 644 */ 645 err_t netifapi_netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback); 646 #endif /* LWIP_NETIF_LINK_CALLBACK */ 647 648 #if LWIP_NETIF_EXT_STATUS_CALLBACK 649 /* 650 Func Name: netifapi_netif_add_ext_callback 651 */ 652 /** 653 * @ingroup netifapi_netif 654 * @brief 655 * This API is used to add an extended netif status callback (NSC). 656 * 657 * @param[in] callback Indicates the NSC data structure. 658 * @param[in] fn The callback function pointer. 659 * 660 * @returns 661 * ERR_OK: On success. \n 662 * ERR_ARG: On passing invalid arguments. 663 */ 664 err_t netifapi_netif_add_ext_callback(netif_ext_callback_t *callback, netif_ext_callback_fn fn); 665 666 /* 667 Func Name: netifapi_netif_remove_ext_callback 668 */ 669 /** 670 * @ingroup netifapi_netif 671 * @brief 672 * This API is used to remove an extended netif status callback (NSC). 673 * 674 * @param[in] callback Indicates the NSC data structure. 675 * 676 * @returns 677 * ERR_OK: On success. \n 678 * ERR_VAL: On passing invalid arguments. 679 */ 680 err_t netifapi_netif_remove_ext_callback(netif_ext_callback_t *callback); 681 #endif /* LWIP_NETIF_EXT_STATUS_CALLBACK */ 682 683 /* 684 Func Name: netifapi_netif_set_mtu 685 */ 686 /** 687 * @ingroup netifapi_netif 688 * @brief 689 * This API is used to set the MTU of the netif. Call this API whenever the MTU needs to be changed. 690 * @param[in] netif Indicates the lwIP network interface. 691 * @param[in] mtu Indicates the new MTU of the network interface. Valid values are 68 to 1500. 692 * 693 * @returns 694 * ERR_OK: On success. \n 695 * ERR_ARG: On passing invalid arguments. 696 * 697 * @note 698 * - The value of the new mtu which is passed should be in the range 68 to 1500. 699 * - On modifying the MTU, the MTU change comes into effect immediately. 700 * - IP packets for existing connections are also sent according to new MTU. 701 * - Ideally, the application must ensure that connections are terminated before MTU modification or at 702 * init time to avoid side effects, since peer might be expecting a different MTU. 703 * - Effective MSS for existing connection will not change, it might remain same. It is not 704 * suggested to change the MTU at runtime. 705 * - Only for new connections, effective MSS is used for connection setup. \n 706 * 707 */ 708 err_t netifapi_netif_set_mtu(struct netif *netif, u16_t mtu); 709 710 #if LWIP_DHCPS 711 712 /* 713 Func Name: netifapi_dhcps_start 714 */ 715 /** 716 * @ingroup netifapi_dhcp4 717 * @brief 718 * This API is used to start DHCPv4 Server on the netif. This should be be called only 719 once when the DHCPv4 Server needs to be started on the netif. 720 * 721 * @param[in] netif Indicates the lwIP network interface. 722 * @param[in] start_ip Indicates the starting IP address of the DHCPv4 address pool. 723 * @param[in] ip_num Indicates the number of IP addresses that need to be in the pool. 724 * 725 * @par Return values 726 * ERR_OK: On success \n 727 * ERR_ARG: On passing invalid arguments. \n 728 * ERR_MEM: On trying to start a DHCPv4 server on a netif where DHCPv4 server is already running \n 729 * 730 * @par Note 731 * - If the DHCPv4 scope (Address Pool) must have the default configuration, then both 732 * start_ip and ip_num must be NULL. 733 * - If the DHCPv4 scope (Address Pool) must be manually configured, then both start_ip And 734 * ip_num must not be NULL. 735 * - In case Of default DHCPv4 scope (Address Pool) configuration, the total number of addresses 736 * available in the pool for clients will be one less 737 * than that of total addresses available in the pool, since one of the addresses in the pool 738 * will be taken up by the DHCPv4 Server and only others will be available to the DHCPv4 Clients. 739 * - In case of manual DHCPv4 scope(Address Pool) configuration, start_ip should be in the same subnet of the netif. 740 * - In case of manual DHCPv4 scope configuration, if the IP address of the DHCPv4 server lies in the range of 741 * - [ip_start, ip_start + ip_num], then the total number of addresses available in the pool for clients will be one 742 * - less than ip_num, since one of the addresses in the pool will be taken up by the DHCPv4 Server and only others 743 * - will be available to the DHCPv4 Clients. \n 744 * - The total number of addresses in the DHCPv4 Scope will be the minimum of non-zero ip_num & LWIP_DHCPS_MAX_LEASE. 745 * - In case of manual DHCPv4 scope configuration, if ip_start+ip_num goes beyond x.y.z.254, then the total number 746 * of addresses in the pool will be from [ip_start, x.y.z.254] only. 747 */ 748 err_t netifapi_dhcps_start(struct netif *netif, char *start_ip, u16_t ip_num); 749 750 751 /* 752 Func Name: netifapi_dhcps_stop 753 */ 754 /** 755 756 * @ingroup netifapi_dhcp4 757 * 758 * @brief 759 * This API is used to stop DHCPv4 Server on the netif where a DHCPv4 server is running. 760 * 761 762 * @param[in] netif Indicates the lwIP network interface. 763 * @par Return values 764 * ERR_OK: On success \n 765 766 * 767 * @par Note 768 * The DHCPv4 server can be restarted on a netif only after it is stopped on that netif. 769 * 770 */ 771 err_t netifapi_dhcps_stop(struct netif *netif); 772 err_t netifapi_dhcps_get_client_ip(struct netif *netif, u8_t *mac, u8_t maclen, ip_addr_t *ip); 773 #endif /* LWIP_DHCPS */ 774 775 #if LWIP_DHCP 776 /** @ingroup netifapi_dhcp4 777 * @brief 778 * This API is used to set a static DHCP structure to the netif. 779 * @note 780 * If this API is used before netifapi_dhcp_start(), the application needs to use 781 * netifapi_dhcp_remove_struct() instead of netifapi_dhcp_cleanup() to remove 782 * the struct dhcp. */ 783 err_t netifapi_dhcp_set_struct(struct netif *netif, struct dhcp *dhcp); 784 785 /** @ingroup netifapi_dhcp4 786 * @brief 787 * This interface is used to remove the static DHCP structure from netif, which was set 788 * using the netifapi_dhcp_set_struct() API. 789 * @note 790 * The application needs to use this API instead of netifapi_dhcp_cleanup() if the 791 * DHCP structure is previously set on netif using netifapi_dhcp_set_struct(). */ 792 err_t netifapi_dhcp_remove_struct(struct netif *netif); 793 794 #if LWIP_DHCP_SUBSTITUTE 795 /** @ingroup netifapi_dhcp4 796 * @brief 797 * This API is used to get MAC of all the dhcp clients to the netif. 798 * 799 * @param[in] netif Indicates the netif structure on which DHCPC start. 800 * @param[out] clis_info To get the dhcp clients information. 801 * 802 * @returns 803 * ERR_OK : On success. \n 804 * Negative value : On failure. \n 805 * 806 * @note 807 * The clis_info got from this API must be freed by netifapi_dhcp_clients_info_free(). 808 * If the last got clis_info not freed, this API will fail with return value ERR_INPROGRESS. */ 809 err_t netifapi_dhcp_clients_info_get(struct netif *netif, struct dhcp_clients_info **clis_info); 810 811 /** @ingroup netifapi_dhcp4 812 * @brief 813 * This API is used to free clis_info to the netif. 814 * 815 * @param[in] netif Indicates the netif structure on which DHCPC start. 816 * @param[in] clis_info To clis_info got from netifapi_dhcp_clients_info_get(). 817 * 818 * @returns 819 * ERR_OK : On success. \n 820 * Negative value : On failure. \n 821 * 822 * @note 823 * The clis_info must be got from netifapi_dhcp_clients_info_get(). */ 824 err_t netifapi_dhcp_clients_info_free(struct netif *netif, struct dhcp_clients_info **clis_info); 825 826 /** @ingroup netifapi_dhcp4 827 * @brief 828 * This API is used to get IPv4 and IPv6 address of a dhcp client to the netif. 829 * The client is represented by mac address. 830 * 831 * @param[in] netif Indicates the netif structure on which DHCPC start. 832 * @param[in/out] cli_info Caller fillup mac and mac_len fields of cli_info to get ip4addr and ip6addr. 833 * 834 * @returns 835 * ERR_OK : On success. \n 836 * Negative value : On failure. \n 837 * 838 * @note 839 * The mac and mac_len information can be got through netifapi_dhcp_clients_info_get(). */ 840 err_t netifapi_dhcp_client_info_find(struct netif *netif, struct dhcp_client_info *cli_info); 841 842 #if LWIP_DHCP_LIMIT_CONCURRENT_REQUESTS 843 /** @ingroup netifapi_dhcp4 844 * @brief 845 * This API is used to set the maximum of concurrent DHCP clients. 846 * 847 * @param[in] netif Indicates the netif structure on which DHCPC start. 848 * @param[in] dhcp_max_concurrent_num The maximum of concurrent DHCP clients. 849 * 850 * @returns 851 * ERR_OK : On success. \n 852 * Negative value : On failure. \n 853 * 854 * @note 855 * If dhcp_max_concurrent_num setting to be 0, it means not set limitation. */ 856 err_t netifapi_dhcp_set_max_concurrent_num(struct netif *netif, u16_t dhcp_max_concurrent_num); 857 #endif /* LWIP_DHCP_LIMIT_CONCURRENT_REQUESTS */ 858 #endif /* LWIP_DHCP_SUBSTITUTE */ 859 #endif /* LWIP_DHCP */ 860 861 /** 862 * @defgroup netifapi_dhcp6 DHCPv6 863 * @ingroup netifapi 864 * To be called from non-TCPIP threads 865 */ 866 #if LWIP_IPV6_DHCP6 867 /* 868 Func Name: netifapi_dhcp6_enable_stateful 869 */ 870 /** 871 * @ingroup netifapi_dhcp6 872 * 873 * @brief 874 * This interface is used to enable stateful DHCPv6 client negotiation for a network interface (stateless disabled). 875 * If no DHCPv6 client instance is attached to this interface, a new client is created first. If a DHCPv6 client 876 * instance is already present and stateful DHCPv6 client has been enabled, it will return without doing anything. 877 * It is the thread-safe way for calling dhcp6_enable_stateful in the user space. 878 * 879 * @param[in] netif Indicates the lwIP network interface. 880 * 881 * @return 882 * ERR_OK: On success \n 883 * ERR_MEM: On failure due to memory \n 884 * ERR_VAL: On failure due to Illegal value or linklocal address is not preferred \n 885 * ERR_NOADDR: No available address 886 887 888 * @note 889 * \n 890 * - Only one addr of IA_NA is supported. Multiple addresses is not supported yet. 891 * - Not supported options : IA_TA/Relay/Authentication/Rapid Commit/User Class/Vendor Class/Vendor-specific 892 * Information/Interface-Id/Reconfigure Message/Reconfigure Accept/DOMAIN_LIST/IA_PD/IAPREFIX 893 * - First SOLICIT will not be sent until linklocal IPv6 address is REFERRED 894 * 895 * @par Related Topics 896 * netifapi_set_ip6_autoconfig_enabled() 897 * netifapi_dhcp6_release_stateful() 898 * netifapi_dhcp6_disable() 899 */ 900 err_t netifapi_dhcp6_enable_stateful(struct netif *netif); 901 902 /* 903 Func Name: netifapi_dhcp6_enable_stateless 904 */ 905 /** 906 * @ingroup netifapi_dhcp6 907 908 * 909 * @brief 910 * This interface is used to enable stateless DHCPv6 client negotiation for a network interface (stateful disabled). 911 * If no DHCPv6 client instance is attached to this interface, a new client is created first. If a DHCPv6 client 912 * instance is already present and stateless DHCPv6 client has been enabled, it will return without doing anything. 913 * This interface only enables other config for DHCPv6. Autoconfig for IPv6 address will not be enabled by this 914 * interface. 915 * It is the thread-safe way for calling dhcp6_enable_stateless in the user space. 916 * 917 * @param[in] netif Indicates the lwIP network interface. 918 * 919 * @return 920 * ERR_OK: On success \n 921 * ERR_MEM: On failure due to memory \n 922 * ERR_VAL: On failure due to Illegal value 923 924 * @note 925 * \n 926 * - Only RA from one Router will be handled correctly. RAs from multi Routers will cause unexpected problem. 927 * - Device will send INFORM-REQUEST after every receved RA. 928 * 929 * @par Related Topics 930 * netifapi_dhcp6_disable() 931 */ 932 err_t netifapi_dhcp6_enable_stateless(struct netif *netif); 933 934 /* 935 Func Name: netifapi_dhcp6_disable 936 */ 937 /** 938 * @ingroup netifapi_dhcp6 939 * 940 * @brief 941 * This interface is used to disable stateful or stateless DHCPv6 on a network interface. 942 * If no DHCPv6 client instance is attached to this interface, it will return without doing anything. 943 * If stateful DHCPv6 is enabled, it will try to send a RELEASE, but won't handle the REPLY of this RELEASE. 944 * It is the thread-safe way for calling dhcp6_disable in the user space. 945 * 946 * @param[in] netif Indicates the lwIP network interface. 947 * 948 * @return 949 * ERR_OK: On success \n 950 * ERR_VAL: On failure due to Illegal value 951 * 952 953 * @note 954 * \n 955 * - To disable stateful DHCPv6, call after netifapi_dhcp6_release_stateful. 956 */ 957 err_t netifapi_dhcp6_disable(struct netif *netif); 958 959 /* 960 Func Name: netifapi_dhcp6_release_stateful 961 */ 962 /** 963 * @ingroup netifapi_dhcp6 964 965 * 966 * @brief 967 * This interface is used to try to send a RELEASE when stateful DHCPv6 is enabled on a network interface. 968 * If stateful DHCPv6 client is doing RELEASE, it will return without doing anything. 969 * If stateless DHCPv6 is enabled on a network interface, it will return ERR_VAL and do nothing else. 970 * If no DHCPv6 client instance is attached to this interface, it will return ERR_VAL and do nothing else. 971 * If stateful DHCPv6 is enabled and a valid IPv6 address is using, it will try to send a RELEASE and will 972 * handle the REPLY of this RELEASE. It will stop using the IPv6 address to be released as soon as the client 973 * begins the Release message exchange process. 974 * It is the thread-safe way for calling dhcp6_release_stateful in the user space. 975 * 976 * @param[in] netif Indicates the lwIP network interface. 977 * 978 * @return 979 * ERR_OK: On success \n 980 * ERR_VAL: On failure due to Illegal value 981 982 */ 983 err_t netifapi_dhcp6_release_stateful(struct netif *netif); 984 985 /* 986 Func Name: netifapi_dhcp6_cleanup 987 */ 988 /** 989 * @ingroup netifapi_dhcp6 990 * 991 * @brief 992 * This interface is used to free the memory allocated for DHCPv6 during DHCPv6 enable. 993 * It is the thread-safe way for calling dhcp_cleanup in the user space. 994 * 995 * @param[in] netif Indicates the lwIP network interface. 996 * 997 * @return 998 * ERR_OK: On success \n 999 * ERR_VAL: On failure due to Illegal value 1000 * 1001 1002 * @note 1003 * \n 1004 * - Call after DHCPv6 client is disabled. 1005 * - Call netifapi_dhcp6_disable() before calling netifapi_dhcp6_cleanup. 1006 */ 1007 err_t netifapi_dhcp6_cleanup(struct netif *netif); 1008 #endif /* LWIP_IPV6_DHCP6 */ 1009 1010 /* @ingroup netifapi_netif */ 1011 err_t netifapi_netif_nameindex_all(void *arg); 1012 1013 #if LWIP_NETIF_HOSTNAME 1014 /* 1015 Func Name: netifapi_set_hostname 1016 */ 1017 /** 1018 * @ingroup netifapi_dhcp4 1019 1020 * 1021 * @brief 1022 * This API is used to set the hostname of the netif, which is using in DHCP 1023 * message. The hostname string lenght should be less than NETIF_HOSTNAME_MAX_LEN, 1024 * otherwise the hostname will truncate to (NETIF_HOSTNAME_MAX_LEN-1). 1025 * 1026 * @param[in] netif Indicates the lwIP network interface. 1027 * @param[in] hostname The new hostname to use. 1028 * @param[in] namelen The hostname string length, should be within the scope of 0~NETIF_HOSTNAME_MAX_LEN-1. 1029 * 1030 * @return 1031 * ERR_OK: On success \n 1032 * ERR_ARG: On passing invalid arguments. \n 1033 * 1034 */ 1035 err_t netifapi_set_hostname(struct netif *netif, char *hostname, u8_t namelen); 1036 1037 /* 1038 Func Name: netifapi_get_hostname 1039 */ 1040 /** 1041 * @ingroup netifapi_dhcp4 1042 1043 * 1044 * @brief 1045 * This API is used to get the hostname of the netif, which is using in DHCP 1046 * message. the hostname buffer length shoud not smaller than NETIF_HOSTNAME_MAX_LEN, 1047 * otherwise it will get a truncated hostname. 1048 * 1049 * @param[in] netif Indicates the lwIP network interface. 1050 * @param[out] hostname The buffer to stroe hostname string of the netif. 1051 * @param[in] namelen The hostname string buffer length. 1052 * 1053 * @return 1054 * ERR_OK: On success \n 1055 * ERR_ARG: On passing invalid arguments. \n 1056 * 1057 */ 1058 err_t netifapi_get_hostname(struct netif *netif, char *hostname, u8_t namelen); 1059 1060 #endif /* LWIP_NETIF_HOSTNAME */ 1061 1062 #if LWIP_IP_FILTER 1063 /* 1064 Func Name: netifapi_set_ip_filter 1065 */ 1066 /** 1067 * @ingroup netifapi_netif 1068 1069 * 1070 1071 * 1072 * @brief 1073 * This API is used to set an ip filter for ip packets. The filter function will be called when 1074 * a packet pass to ip_input. User can define rules to accept or drop a packet in filter_fn, 1075 * returning 0 means accept, -1 means drop. 1076 * 1077 * @param[in] filter_fn The filter function which user implement. Prototype for filter_fn 1078 * is err_t (*ip_filter_fn)(const struct pbuf *p, struct netif *inp); 1079 * NULL indicate to disable the filter. 1080 * @param[in] type IP address type as IPv4 or IPv6. IPADDR_TYPE_V4 is for IPv4 and IPADDR_TYPE_V6 1081 * is for IPv6. 1082 * 1083 * @return 1084 * ERR_OK: On success \n 1085 * ERR_VAL: On failure due to Illegal value 1086 * 1087 1088 * 1089 * @note 1090 * 1. User can access pbuf in filter_fn, modify pbuf data and access pbuf after filter_fn return are 1091 * not allowed. \n 1092 * 2. User can define rules to accept or drop a packet in filter_fn, return 0 means accept the 1093 * packet, -1 means drop the packet and user no need to care about free pbuf. \n 1094 * 3. Rules in filter_fn which user implement should be light and not complex, sleep and other block 1095 * function must not be called, or it will have a negative influence to TCP/IP stack. \n 1096 * 4. Filter only effect to IP packet. 1097 * 1098 * 1099 */ 1100 err_t netifapi_set_ip_filter(ip_filter_fn filter_fn, int type); 1101 #endif /* LWIP_IP_FILTER */ 1102 1103 #if LWIP_IPV6 1104 #if LWIP_NETIF_NBR_CACHE_API 1105 1106 /* 1107 Func Name: netifapi_add_ipv6_neighbor 1108 */ 1109 /** 1110 * @ingroup netifapi_netif 1111 1112 * 1113 * @brief 1114 * This API is used to add a neighbor entry to the neighbor cache table. User 1115 * can use this to add both static and non-sttaic neighbor. The neighbor state 1116 * passed to the API will determine if the neighbor to be added is static or 1117 * dynamic. To add static neighbor using this API user must set the confiburation 1118 * LWIP_ND6_STATIC_NBR to 1 1119 1120 * 1121 * @param[in] netif Indicates the network interface object through which this neighbor can be 1122 reached. 1123 * @param[in] nbr Provides information about the neighbor to be added. It includes 1124 * IPv6 address of the neighbor, Its hardware 1125 * address and its length, current state of the 1126 neighbor, and Initial reachable duration of the neighbor. 1127 * 1128 * @return 1129 * ERR_OK: On success \n 1130 * ERR_ARG: If any parameter is invalid \n 1131 * ERR_VAL: On failure due to illegal value \n 1132 * ERR_MEM: If no more space available \n 1133 * ERR_NBR_OVERWRITEFORBIDDEN: If try to add a neighbor that already exists 1134 * 1135 1136 * 1137 * @note 1138 * 1. The allowed states for the neighbor are ND6_STATE_REACHABLE(2) for non 1139 * static neighbor and ND6_STATE_PERMANENT(6) for static neighbor \n 1140 * 2. For static neighbor user must set the reachable time to 0. \n 1141 * 3. For non static neighbors the initial reachable time cannot be greater than 1142 * the LWIP_ND6_REACHABLE_TIME configured. Once the rechable time set by the 1143 * user expires, neighbor will move to stale state. When it again moves to the 1144 * reachable state, the rechable time will be set to LWIP_ND6_REACHABLE_TIME. \n 1145 * 4. If you try to add a neighbor that already exists and it is not a static 1146 * neighbor we do not allow it to be overwritten. For static neighbor we will 1147 * update the new hw address. \n 1148 * 5. To use this API user MUST set LWIP_NETIF_NBR_CACHE_API configuration to 1. 1149 * \n 1150 1151 */ 1152 err_t netifapi_add_ipv6_neighbor(struct netif *netif, struct ipv6_neighbor *nbr); 1153 1154 /* 1155 Func Name: netifapi_del_ipv6_neighbor 1156 */ 1157 /** 1158 * @ingroup netifapi_netif 1159 1160 * @brief 1161 * This API is used to delete a neighbor entry to the neighbor cache table. User 1162 * can use this to delete both static and non-sttaic neighbor. 1163 * 1164 * @param[in] netif Indicates the network interface object which the neighbor is part of. 1165 * @param[in] ipaddr Indicates the IP address of the neighbor to remove. 1166 * 1167 * @return 1168 * ERR_OK: On success \n 1169 * ERR_ARG: If any parameter is invalid \n 1170 * ERR_NBR_NOTFOUND: If the neighbor does not exist 1171 1172 * @note 1173 * 1. If the neighbor to be deleted has an associated default router entry we 1174 * will remove the default route also. \n 1175 * 1176 * 2. To use this API user MUST set LWIP_NETIF_NBR_CACHE_API configuration to 1 1177 * \n 1178 */ 1179 err_t netifapi_del_ipv6_neighbor(struct netif *netif, struct ip6_addr *ipaddr); 1180 1181 /* 1182 Func Name: netifapi_query_ipv6_neighbor 1183 */ 1184 /** 1185 * @ingroup netifapi_netif 1186 1187 * @brief 1188 * This API is used to query a neighbor entry from the neighbor cache table. User 1189 * can use this to query both static and non-static neighbor. 1190 * 1191 * @param[in] netif Indicates the network interface object which the neighbor is part of. 1192 * @param[in] ipaddr Indicates the IP address of the neighbor to be queried. 1193 * @param[out] nbrinfo Indicates information about the neighbor. 1194 * 1195 * @return 1196 * ERR_OK: On success \n 1197 * ERR_ARG: If any parameter is invalid \n 1198 * ERR_NBR_NOTFOUND: If the neighbor does not exist 1199 1200 * 1201 * @note 1202 * 1. The nbrinfo parameter must be a valid memory of type struct ipv6_neighbor. \n 1203 * 1204 * 2. To use this API user must set LWIP_NETIF_NBR_CACHE_API configuration to 1 1205 * \n 1206 */ 1207 err_t netifapi_query_ipv6_neighbor(struct netif *netif, struct ip6_addr *ipaddr, 1208 struct ipv6_neighbor *nbrinfo); 1209 #endif /* LWIP_NETIF_NBR_CACHE_API */ 1210 1211 #if LWIP_ND6_ROUTER 1212 err_t netifapi_set_ra_enable(struct netif *netif, u8_t ra_enable); 1213 err_t netifapi_set_ipv6_forwarding(struct netif *netif, u8_t forwarding); 1214 err_t netifapi_set_accept_ra(struct netif *netif, u8_t accept_ra); 1215 #endif /* LWIP_ND6_ROUTER */ 1216 #endif /* LWIP_IPV6 */ 1217 1218 1219 #if LWIP_LOWPOWER 1220 err_t netifapi_enable_lowpower(void); 1221 err_t netifapi_disable_lowpower(void); 1222 #endif 1223 1224 #if LWIP_IPV4 && LWIP_ARP 1225 /* 1226 Func Name: netifapi_ip_to_mac 1227 */ 1228 /** @ingroup netifapi_netif 1229 * @brief 1230 * This API is used to get MAC address through IPv4 address. 1231 * 1232 * @param[in] ip Indicates the IPv4 address to find related MAC address. 1233 * @param[out] mac The buffer to record the related MAC address. 1234 * @param[in/out] maclen As in parameter, indicates the length of mac buffer. 1235 * As out parameter, indicates the length of related MAC address. 1236 * 1237 * @returns 1238 * ERR_OK : On success. \n 1239 * Negative value : On failure. \n 1240 */ 1241 err_t netifapi_ip_to_mac(const ip4_addr_t *ip, u8_t *mac, u8_t *maclen); 1242 #endif 1243 1244 #ifdef __cplusplus 1245 } 1246 #endif 1247 1248 #endif /* LWIP_NETIF_API */ 1249 1250 #endif /* LWIP_HDR_NETIFAPI_H */ 1251