Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
netif.h
00001 /** 00002 * @file 00003 * netif API (to be used from TCPIP thread) 00004 */ 00005 00006 /* 00007 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * This file is part of the lwIP TCP/IP stack. 00033 * 00034 * Author: Adam Dunkels <adam@sics.se> 00035 * 00036 */ 00037 #ifndef LWIP_HDR_NETIF_H 00038 #define LWIP_HDR_NETIF_H 00039 00040 #include "lwip/opt.h" 00041 00042 #define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) 00043 00044 #include "lwip/err.h" 00045 00046 #include "lwip/ip_addr.h" 00047 00048 #include "lwip/def.h" 00049 #include "lwip/pbuf.h" 00050 #include "lwip/stats.h" 00051 00052 #ifdef __cplusplus 00053 extern "C" { 00054 #endif 00055 00056 /* Throughout this file, IP addresses are expected to be in 00057 * the same byte order as in IP_PCB. */ 00058 00059 /** Must be the maximum of all used hardware address lengths 00060 across all types of interfaces in use. 00061 This does not have to be changed, normally. */ 00062 #ifndef NETIF_MAX_HWADDR_LEN 00063 #define NETIF_MAX_HWADDR_LEN 6U 00064 #endif 00065 00066 /** 00067 * @defgroup netif_flags Flags 00068 * @ingroup netif 00069 * @{ 00070 */ 00071 00072 /** Whether the network interface is 'up'. This is 00073 * a software flag used to control whether this network 00074 * interface is enabled and processes traffic. 00075 * It must be set by the startup code before this netif can be used 00076 * (also for dhcp/autoip). 00077 */ 00078 #define NETIF_FLAG_UP 0x01U 00079 /** If set, the netif has broadcast capability. 00080 * Set by the netif driver in its init function. */ 00081 #define NETIF_FLAG_BROADCAST 0x02U 00082 /** If set, the interface has an active link 00083 * (set by the network interface driver). 00084 * Either set by the netif driver in its init function (if the link 00085 * is up at that time) or at a later point once the link comes up 00086 * (if link detection is supported by the hardware). */ 00087 #define NETIF_FLAG_LINK_UP 0x04U 00088 /** If set, the netif is an ethernet device using ARP. 00089 * Set by the netif driver in its init function. 00090 * Used to check input packet types and use of DHCP. */ 00091 #define NETIF_FLAG_ETHARP 0x08U 00092 /** If set, the netif is an ethernet device. It might not use 00093 * ARP or TCP/IP if it is used for PPPoE only. 00094 */ 00095 #define NETIF_FLAG_ETHERNET 0x10U 00096 /** If set, the netif has IGMP capability. 00097 * Set by the netif driver in its init function. */ 00098 #define NETIF_FLAG_IGMP 0x20U 00099 /** If set, the netif has MLD6 capability. 00100 * Set by the netif driver in its init function. */ 00101 #define NETIF_FLAG_MLD6 0x40U 00102 00103 /** 00104 * @} 00105 */ 00106 00107 enum lwip_internal_netif_client_data_index 00108 { 00109 #if LWIP_DHCP 00110 LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, 00111 #endif 00112 #if LWIP_AUTOIP 00113 LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP, 00114 #endif 00115 #if LWIP_IGMP 00116 LWIP_NETIF_CLIENT_DATA_INDEX_IGMP, 00117 #endif 00118 #if LWIP_IPV6_MLD 00119 LWIP_NETIF_CLIENT_DATA_INDEX_MLD6, 00120 #endif 00121 LWIP_NETIF_CLIENT_DATA_INDEX_MAX 00122 }; 00123 00124 #if LWIP_CHECKSUM_CTRL_PER_NETIF 00125 #define NETIF_CHECKSUM_GEN_IP 0x0001 00126 #define NETIF_CHECKSUM_GEN_UDP 0x0002 00127 #define NETIF_CHECKSUM_GEN_TCP 0x0004 00128 #define NETIF_CHECKSUM_GEN_ICMP 0x0008 00129 #define NETIF_CHECKSUM_GEN_ICMP6 0x0010 00130 #define NETIF_CHECKSUM_CHECK_IP 0x0100 00131 #define NETIF_CHECKSUM_CHECK_UDP 0x0200 00132 #define NETIF_CHECKSUM_CHECK_TCP 0x0400 00133 #define NETIF_CHECKSUM_CHECK_ICMP 0x0800 00134 #define NETIF_CHECKSUM_CHECK_ICMP6 0x1000 00135 #define NETIF_CHECKSUM_ENABLE_ALL 0xFFFF 00136 #define NETIF_CHECKSUM_DISABLE_ALL 0x0000 00137 #endif /* LWIP_CHECKSUM_CTRL_PER_NETIF */ 00138 00139 struct netif; 00140 00141 /** MAC Filter Actions, these are passed to a netif's igmp_mac_filter or 00142 * mld_mac_filter callback function. */ 00143 enum netif_mac_filter_action { 00144 /** Delete a filter entry */ 00145 NETIF_DEL_MAC_FILTER = 0, 00146 /** Add a filter entry */ 00147 NETIF_ADD_MAC_FILTER = 1 00148 }; 00149 00150 /** Function prototype for netif init functions. Set up flags and output/linkoutput 00151 * callback functions in this function. 00152 * 00153 * @param netif The netif to initialize 00154 */ 00155 typedef err_t (*netif_init_fn)(struct netif *netif); 00156 /** Function prototype for netif->input functions. This function is saved as 'input' 00157 * callback function in the netif struct. Call it when a packet has been received. 00158 * 00159 * @param p The received packet, copied into a pbuf 00160 * @param inp The netif which received the packet 00161 */ 00162 typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp); 00163 00164 #if LWIP_IPV4 00165 /** Function prototype for netif->output functions. Called by lwIP when a packet 00166 * shall be sent. For ethernet netif, set this to 'etharp_output' and set 00167 * 'linkoutput'. 00168 * 00169 * @param netif The netif which shall send a packet 00170 * @param p The packet to send (p->payload points to IP header) 00171 * @param ipaddr The IP address to which the packet shall be sent 00172 */ 00173 typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p, 00174 const ip4_addr_t *ipaddr); 00175 #endif /* LWIP_IPV4*/ 00176 00177 #if LWIP_IPV6 00178 /** Function prototype for netif->output_ip6 functions. Called by lwIP when a packet 00179 * shall be sent. For ethernet netif, set this to 'ethip6_output' and set 00180 * 'linkoutput'. 00181 * 00182 * @param netif The netif which shall send a packet 00183 * @param p The packet to send (p->payload points to IP header) 00184 * @param ipaddr The IPv6 address to which the packet shall be sent 00185 */ 00186 typedef err_t (*netif_output_ip6_fn)(struct netif *netif, struct pbuf *p, 00187 const ip6_addr_t *ipaddr); 00188 #endif /* LWIP_IPV6 */ 00189 00190 /** Function prototype for netif->linkoutput functions. Only used for ethernet 00191 * netifs. This function is called by ARP when a packet shall be sent. 00192 * 00193 * @param netif The netif which shall send a packet 00194 * @param p The packet to send (raw ethernet packet) 00195 */ 00196 typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p); 00197 /** Function prototype for netif status- or link-callback functions. */ 00198 typedef void (*netif_status_callback_fn)(struct netif *netif); 00199 #if LWIP_IPV4 && LWIP_IGMP 00200 /** Function prototype for netif igmp_mac_filter functions */ 00201 typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif, 00202 const ip4_addr_t *group, enum netif_mac_filter_action action); 00203 #endif /* LWIP_IPV4 && LWIP_IGMP */ 00204 #if LWIP_IPV6 && LWIP_IPV6_MLD 00205 /** Function prototype for netif mld_mac_filter functions */ 00206 typedef err_t (*netif_mld_mac_filter_fn)(struct netif *netif, 00207 const ip6_addr_t *group, enum netif_mac_filter_action action); 00208 #endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ 00209 00210 #if LWIP_DHCP || LWIP_AUTOIP || LWIP_IGMP || LWIP_IPV6_MLD || (LWIP_NUM_NETIF_CLIENT_DATA > 0) 00211 u8_t netif_alloc_client_data_id(void); 00212 /** @ingroup netif_cd 00213 * Set client data. Obtain ID from netif_alloc_client_data_id(). 00214 */ 00215 #define netif_set_client_data(netif, id, data) netif_get_client_data(netif, id) = (data) 00216 /** @ingroup netif_cd 00217 * Get client data. Obtain ID from netif_alloc_client_data_id(). 00218 */ 00219 #define netif_get_client_data(netif, id) (netif)->client_data[(id)] 00220 #endif /* LWIP_DHCP || LWIP_AUTOIP || (LWIP_NUM_NETIF_CLIENT_DATA > 0) */ 00221 00222 /** Generic data structure used for all lwIP network interfaces. 00223 * The following fields should be filled in by the initialization 00224 * function for the device driver: hwaddr_len, hwaddr[], mtu, flags */ 00225 struct netif { 00226 /** pointer to next in linked list */ 00227 struct netif *next; 00228 00229 #if LWIP_IPV4 00230 /** IP address configuration in network byte order */ 00231 ip_addr_t ip_addr; 00232 ip_addr_t netmask; 00233 ip_addr_t gw; 00234 #endif /* LWIP_IPV4 */ 00235 #if LWIP_IPV6 00236 /** Array of IPv6 addresses for this netif. */ 00237 ip_addr_t ip6_addr[LWIP_IPV6_NUM_ADDRESSES]; 00238 /** The state of each IPv6 address (Tentative, Preferred, etc). 00239 * @see ip6_addr.h */ 00240 u8_t ip6_addr_state[LWIP_IPV6_NUM_ADDRESSES]; 00241 #if LWIP_IPV6_ADDRESS_LIFETIMES 00242 /** Remaining valid and preferred lifetime of each IPv6 address, in seconds. 00243 * For valid lifetimes, the special value of IP6_ADDR_LIFE_STATIC (0) 00244 * indicates the address is static and has no lifetimes. */ 00245 u32_t ip6_addr_valid_life[LWIP_IPV6_NUM_ADDRESSES]; 00246 u32_t ip6_addr_pref_life[LWIP_IPV6_NUM_ADDRESSES]; 00247 #endif /* LWIP_IPV6_ADDRESS_LIFETIMES */ 00248 #endif /* LWIP_IPV6 */ 00249 /** This function is called by the network device driver 00250 * to pass a packet up the TCP/IP stack. */ 00251 netif_input_fn input; 00252 #if LWIP_IPV4 00253 /** This function is called by the IP module when it wants 00254 * to send a packet on the interface. This function typically 00255 * first resolves the hardware address, then sends the packet. 00256 * For ethernet physical layer, this is usually etharp_output() */ 00257 netif_output_fn output; 00258 #endif /* LWIP_IPV4 */ 00259 /** This function is called by ethernet_output() when it wants 00260 * to send a packet on the interface. This function outputs 00261 * the pbuf as-is on the link medium. */ 00262 netif_linkoutput_fn linkoutput; 00263 #if LWIP_IPV6 00264 /** This function is called by the IPv6 module when it wants 00265 * to send a packet on the interface. This function typically 00266 * first resolves the hardware address, then sends the packet. 00267 * For ethernet physical layer, this is usually ethip6_output() */ 00268 netif_output_ip6_fn output_ip6; 00269 #endif /* LWIP_IPV6 */ 00270 #if LWIP_NETIF_STATUS_CALLBACK 00271 /** This function is called when the netif state is set to up or down 00272 */ 00273 netif_status_callback_fn status_callback; 00274 #endif /* LWIP_NETIF_STATUS_CALLBACK */ 00275 #if LWIP_NETIF_LINK_CALLBACK 00276 /** This function is called when the netif link is set to up or down 00277 */ 00278 netif_status_callback_fn link_callback; 00279 #endif /* LWIP_NETIF_LINK_CALLBACK */ 00280 #if LWIP_NETIF_REMOVE_CALLBACK 00281 /** This function is called when the netif has been removed */ 00282 netif_status_callback_fn remove_callback; 00283 #endif /* LWIP_NETIF_REMOVE_CALLBACK */ 00284 /** This field can be set by the device driver and could point 00285 * to state information for the device. */ 00286 void *state; 00287 #ifdef netif_get_client_data 00288 void* client_data[LWIP_NETIF_CLIENT_DATA_INDEX_MAX + LWIP_NUM_NETIF_CLIENT_DATA]; 00289 #endif 00290 #if LWIP_IPV6_AUTOCONFIG 00291 /** is this netif enabled for IPv6 autoconfiguration */ 00292 u8_t ip6_autoconfig_enabled; 00293 #endif /* LWIP_IPV6_AUTOCONFIG */ 00294 #if LWIP_IPV6_SEND_ROUTER_SOLICIT 00295 /** Number of Router Solicitation messages that remain to be sent. */ 00296 u8_t rs_count; 00297 #endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */ 00298 #if LWIP_NETIF_HOSTNAME 00299 /* the hostname for this netif, NULL is a valid value */ 00300 const char* hostname; 00301 #endif /* LWIP_NETIF_HOSTNAME */ 00302 #if LWIP_CHECKSUM_CTRL_PER_NETIF 00303 u16_t chksum_flags; 00304 #endif /* LWIP_CHECKSUM_CTRL_PER_NETIF*/ 00305 /** maximum transfer unit (in bytes) */ 00306 u16_t mtu; 00307 /** number of bytes used in hwaddr */ 00308 u8_t hwaddr_len; 00309 /** link level hardware address of this interface */ 00310 u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; 00311 /** flags (@see @ref netif_flags) */ 00312 u8_t flags; 00313 /** descriptive abbreviation */ 00314 char name[2]; 00315 /** number of this interface */ 00316 u8_t num; 00317 #if MIB2_STATS 00318 /** link type (from "snmp_ifType" enum from snmp_mib2.h) */ 00319 u8_t link_type; 00320 /** (estimate) link speed */ 00321 u32_t link_speed; 00322 /** timestamp at last change made (up/down) */ 00323 u32_t ts; 00324 /** counters */ 00325 struct stats_mib2_netif_ctrs mib2_counters; 00326 #endif /* MIB2_STATS */ 00327 #if LWIP_IPV4 && LWIP_IGMP 00328 /** This function could be called to add or delete an entry in the multicast 00329 filter table of the ethernet MAC.*/ 00330 netif_igmp_mac_filter_fn igmp_mac_filter; 00331 #endif /* LWIP_IPV4 && LWIP_IGMP */ 00332 #if LWIP_IPV6 && LWIP_IPV6_MLD 00333 /** This function could be called to add or delete an entry in the IPv6 multicast 00334 filter table of the ethernet MAC. */ 00335 netif_mld_mac_filter_fn mld_mac_filter; 00336 #endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ 00337 #if LWIP_NETIF_HWADDRHINT 00338 u8_t *addr_hint; 00339 #endif /* LWIP_NETIF_HWADDRHINT */ 00340 #if ENABLE_LOOPBACK 00341 /* List of packets to be queued for ourselves. */ 00342 struct pbuf *loop_first; 00343 struct pbuf *loop_last; 00344 #if LWIP_LOOPBACK_MAX_PBUFS 00345 u16_t loop_cnt_current; 00346 #endif /* LWIP_LOOPBACK_MAX_PBUFS */ 00347 #endif /* ENABLE_LOOPBACK */ 00348 }; 00349 00350 #if LWIP_CHECKSUM_CTRL_PER_NETIF 00351 #define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) do { \ 00352 (netif)->chksum_flags = chksumflags; } while(0) 00353 #define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) if (((netif) == NULL) || (((netif)->chksum_flags & (chksumflag)) != 0)) 00354 #else /* LWIP_CHECKSUM_CTRL_PER_NETIF */ 00355 #define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) 00356 #define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) 00357 #endif /* LWIP_CHECKSUM_CTRL_PER_NETIF */ 00358 00359 /** The list of network interfaces. */ 00360 extern struct netif *netif_list; 00361 /** The default network interface. */ 00362 extern struct netif *netif_default; 00363 00364 void netif_init(void); 00365 00366 struct netif *netif_add(struct netif *netif, 00367 #if LWIP_IPV4 00368 const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw, 00369 #endif /* LWIP_IPV4 */ 00370 void *state, netif_init_fn init, netif_input_fn input); 00371 #if LWIP_IPV4 00372 void netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, 00373 const ip4_addr_t *gw); 00374 #endif /* LWIP_IPV4 */ 00375 void netif_remove(struct netif * netif); 00376 00377 /* Returns a network interface given its name. The name is of the form 00378 "et0", where the first two letters are the "name" field in the 00379 netif structure, and the digit is in the num field in the same 00380 structure. */ 00381 struct netif *netif_find(const char *name); 00382 00383 void netif_set_default(struct netif *netif); 00384 00385 #if LWIP_IPV4 00386 void netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr); 00387 void netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask); 00388 void netif_set_gw(struct netif *netif, const ip4_addr_t *gw); 00389 /** @ingroup netif_ip4 */ 00390 #define netif_ip4_addr(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->ip_addr))) 00391 /** @ingroup netif_ip4 */ 00392 #define netif_ip4_netmask(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->netmask))) 00393 /** @ingroup netif_ip4 */ 00394 #define netif_ip4_gw(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->gw))) 00395 /** @ingroup netif_ip4 */ 00396 #define netif_ip_addr4(netif) ((const ip_addr_t*)&((netif)->ip_addr)) 00397 /** @ingroup netif_ip4 */ 00398 #define netif_ip_netmask4(netif) ((const ip_addr_t*)&((netif)->netmask)) 00399 /** @ingroup netif_ip4 */ 00400 #define netif_ip_gw4(netif) ((const ip_addr_t*)&((netif)->gw)) 00401 #endif /* LWIP_IPV4 */ 00402 00403 void netif_set_up(struct netif *netif); 00404 void netif_set_down(struct netif *netif); 00405 /** @ingroup netif 00406 * Ask if an interface is up 00407 */ 00408 #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) 00409 00410 #if LWIP_NETIF_STATUS_CALLBACK 00411 void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback); 00412 #endif /* LWIP_NETIF_STATUS_CALLBACK */ 00413 #if LWIP_NETIF_REMOVE_CALLBACK 00414 void netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback); 00415 #endif /* LWIP_NETIF_REMOVE_CALLBACK */ 00416 00417 void netif_set_link_up(struct netif *netif); 00418 void netif_set_link_down(struct netif *netif); 00419 /** Ask if a link is up */ 00420 #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) 00421 00422 #if LWIP_NETIF_LINK_CALLBACK 00423 void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback); 00424 #endif /* LWIP_NETIF_LINK_CALLBACK */ 00425 00426 #if LWIP_NETIF_HOSTNAME 00427 /** @ingroup netif */ 00428 #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) 00429 /** @ingroup netif */ 00430 #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) 00431 #endif /* LWIP_NETIF_HOSTNAME */ 00432 00433 #if LWIP_IGMP 00434 /** @ingroup netif */ 00435 #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) 00436 #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) 00437 #endif /* LWIP_IGMP */ 00438 00439 #if LWIP_IPV6 && LWIP_IPV6_MLD 00440 /** @ingroup netif */ 00441 #define netif_set_mld_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->mld_mac_filter = function; }}while(0) 00442 #define netif_get_mld_mac_filter(netif) (((netif) != NULL) ? ((netif)->mld_mac_filter) : NULL) 00443 #define netif_mld_mac_filter(netif, addr, action) do { if((netif) && (netif)->mld_mac_filter) { (netif)->mld_mac_filter((netif), (addr), (action)); }}while(0) 00444 #endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ 00445 00446 #if ENABLE_LOOPBACK 00447 err_t netif_loop_output(struct netif *netif, struct pbuf *p); 00448 void netif_poll(struct netif *netif); 00449 #if !LWIP_NETIF_LOOPBACK_MULTITHREADING 00450 void netif_poll_all(void); 00451 #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ 00452 #endif /* ENABLE_LOOPBACK */ 00453 00454 err_t netif_input(struct pbuf *p, struct netif *inp); 00455 00456 #if LWIP_IPV6 00457 /** @ingroup netif_ip6 */ 00458 #define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i]))) 00459 /** @ingroup netif_ip6 */ 00460 #define netif_ip6_addr(netif, i) ((const ip6_addr_t*)ip_2_ip6(&((netif)->ip6_addr[i]))) 00461 void netif_ip6_addr_set(struct netif *netif, s8_t addr_idx, const ip6_addr_t *addr6); 00462 void netif_ip6_addr_set_parts(struct netif *netif, s8_t addr_idx, u32_t i0, u32_t i1, u32_t i2, u32_t i3); 00463 #define netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[i]) 00464 void netif_ip6_addr_set_state(struct netif* netif, s8_t addr_idx, u8_t state); 00465 s8_t netif_get_ip6_addr_match(struct netif *netif, const ip6_addr_t *ip6addr); 00466 void netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit); 00467 err_t netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chosen_idx); 00468 #define netif_set_ip6_autoconfig_enabled(netif, action) do { if(netif) { (netif)->ip6_autoconfig_enabled = (action); }}while(0) 00469 #if LWIP_IPV6_ADDRESS_LIFETIMES 00470 #define netif_ip6_addr_valid_life(netif, i) \ 00471 (((netif) != NULL) ? ((netif)->ip6_addr_valid_life[i]) : IP6_ADDR_LIFE_STATIC) 00472 #define netif_ip6_addr_set_valid_life(netif, i, secs) \ 00473 do { if (netif != NULL) { (netif)->ip6_addr_valid_life[i] = (secs); }} while (0) 00474 #define netif_ip6_addr_pref_life(netif, i) \ 00475 (((netif) != NULL) ? ((netif)->ip6_addr_pref_life[i]) : IP6_ADDR_LIFE_STATIC) 00476 #define netif_ip6_addr_set_pref_life(netif, i, secs) \ 00477 do { if (netif != NULL) { (netif)->ip6_addr_pref_life[i] = (secs); }} while (0) 00478 #define netif_ip6_addr_isstatic(netif, i) \ 00479 (netif_ip6_addr_valid_life((netif), (i)) == IP6_ADDR_LIFE_STATIC) 00480 #else /* !LWIP_IPV6_ADDRESS_LIFETIMES */ 00481 #define netif_ip6_addr_isstatic(netif, i) (1) /* all addresses are static */ 00482 #endif /* !LWIP_IPV6_ADDRESS_LIFETIMES */ 00483 #endif /* LWIP_IPV6 */ 00484 00485 #if LWIP_NETIF_HWADDRHINT 00486 #define NETIF_SET_HWADDRHINT(netif, hint) ((netif)->addr_hint = (hint)) 00487 #else /* LWIP_NETIF_HWADDRHINT */ 00488 #define NETIF_SET_HWADDRHINT(netif, hint) 00489 #endif /* LWIP_NETIF_HWADDRHINT */ 00490 00491 #ifdef __cplusplus 00492 } 00493 #endif 00494 00495 #endif /* LWIP_HDR_NETIF_H */
Generated on Tue Jul 12 2022 14:24:29 by
