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.
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
features/FEATURE_LWIP/lwip-interface/lwip/src/include/lwip/netif.h@0:098463de4c5d, 2017-01-25 (annotated)
- Committer:
- group-onsemi
- Date:
- Wed Jan 25 20:34:15 2017 +0000
- Revision:
- 0:098463de4c5d
Initial commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| group-onsemi | 0:098463de4c5d | 1 | /** | 
| group-onsemi | 0:098463de4c5d | 2 | * @file | 
| group-onsemi | 0:098463de4c5d | 3 | * netif API (to be used from TCPIP thread) | 
| group-onsemi | 0:098463de4c5d | 4 | */ | 
| group-onsemi | 0:098463de4c5d | 5 | |
| group-onsemi | 0:098463de4c5d | 6 | /* | 
| group-onsemi | 0:098463de4c5d | 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. | 
| group-onsemi | 0:098463de4c5d | 8 | * All rights reserved. | 
| group-onsemi | 0:098463de4c5d | 9 | * | 
| group-onsemi | 0:098463de4c5d | 10 | * Redistribution and use in source and binary forms, with or without modification, | 
| group-onsemi | 0:098463de4c5d | 11 | * are permitted provided that the following conditions are met: | 
| group-onsemi | 0:098463de4c5d | 12 | * | 
| group-onsemi | 0:098463de4c5d | 13 | * 1. Redistributions of source code must retain the above copyright notice, | 
| group-onsemi | 0:098463de4c5d | 14 | * this list of conditions and the following disclaimer. | 
| group-onsemi | 0:098463de4c5d | 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, | 
| group-onsemi | 0:098463de4c5d | 16 | * this list of conditions and the following disclaimer in the documentation | 
| group-onsemi | 0:098463de4c5d | 17 | * and/or other materials provided with the distribution. | 
| group-onsemi | 0:098463de4c5d | 18 | * 3. The name of the author may not be used to endorse or promote products | 
| group-onsemi | 0:098463de4c5d | 19 | * derived from this software without specific prior written permission. | 
| group-onsemi | 0:098463de4c5d | 20 | * | 
| group-onsemi | 0:098463de4c5d | 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 
| group-onsemi | 0:098463de4c5d | 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 
| group-onsemi | 0:098463de4c5d | 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | 
| group-onsemi | 0:098463de4c5d | 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 
| group-onsemi | 0:098463de4c5d | 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | 
| group-onsemi | 0:098463de4c5d | 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 
| group-onsemi | 0:098463de4c5d | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 
| group-onsemi | 0:098463de4c5d | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 
| group-onsemi | 0:098463de4c5d | 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | 
| group-onsemi | 0:098463de4c5d | 30 | * OF SUCH DAMAGE. | 
| group-onsemi | 0:098463de4c5d | 31 | * | 
| group-onsemi | 0:098463de4c5d | 32 | * This file is part of the lwIP TCP/IP stack. | 
| group-onsemi | 0:098463de4c5d | 33 | * | 
| group-onsemi | 0:098463de4c5d | 34 | * Author: Adam Dunkels <adam@sics.se> | 
| group-onsemi | 0:098463de4c5d | 35 | * | 
| group-onsemi | 0:098463de4c5d | 36 | */ | 
| group-onsemi | 0:098463de4c5d | 37 | #ifndef LWIP_HDR_NETIF_H | 
| group-onsemi | 0:098463de4c5d | 38 | #define LWIP_HDR_NETIF_H | 
| group-onsemi | 0:098463de4c5d | 39 | |
| group-onsemi | 0:098463de4c5d | 40 | #include "lwip/opt.h" | 
| group-onsemi | 0:098463de4c5d | 41 | |
| group-onsemi | 0:098463de4c5d | 42 | #define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) | 
| group-onsemi | 0:098463de4c5d | 43 | |
| group-onsemi | 0:098463de4c5d | 44 | #include "lwip/err.h" | 
| group-onsemi | 0:098463de4c5d | 45 | |
| group-onsemi | 0:098463de4c5d | 46 | #include "lwip/ip_addr.h" | 
| group-onsemi | 0:098463de4c5d | 47 | |
| group-onsemi | 0:098463de4c5d | 48 | #include "lwip/def.h" | 
| group-onsemi | 0:098463de4c5d | 49 | #include "lwip/pbuf.h" | 
| group-onsemi | 0:098463de4c5d | 50 | #include "lwip/stats.h" | 
| group-onsemi | 0:098463de4c5d | 51 | |
| group-onsemi | 0:098463de4c5d | 52 | #if LWIP_DHCP | 
| group-onsemi | 0:098463de4c5d | 53 | struct dhcp; | 
| group-onsemi | 0:098463de4c5d | 54 | #endif | 
| group-onsemi | 0:098463de4c5d | 55 | #if LWIP_AUTOIP | 
| group-onsemi | 0:098463de4c5d | 56 | struct autoip; | 
| group-onsemi | 0:098463de4c5d | 57 | #endif | 
| group-onsemi | 0:098463de4c5d | 58 | #if LWIP_IPV6_DHCP6 | 
| group-onsemi | 0:098463de4c5d | 59 | struct dhcp6; | 
| group-onsemi | 0:098463de4c5d | 60 | #endif /* LWIP_IPV6_DHCP6 */ | 
| group-onsemi | 0:098463de4c5d | 61 | |
| group-onsemi | 0:098463de4c5d | 62 | #ifdef __cplusplus | 
| group-onsemi | 0:098463de4c5d | 63 | extern "C" { | 
| group-onsemi | 0:098463de4c5d | 64 | #endif | 
| group-onsemi | 0:098463de4c5d | 65 | |
| group-onsemi | 0:098463de4c5d | 66 | /* Throughout this file, IP addresses are expected to be in | 
| group-onsemi | 0:098463de4c5d | 67 | * the same byte order as in IP_PCB. */ | 
| group-onsemi | 0:098463de4c5d | 68 | |
| group-onsemi | 0:098463de4c5d | 69 | /** Must be the maximum of all used hardware address lengths | 
| group-onsemi | 0:098463de4c5d | 70 | across all types of interfaces in use. | 
| group-onsemi | 0:098463de4c5d | 71 | This does not have to be changed, normally. */ | 
| group-onsemi | 0:098463de4c5d | 72 | #ifndef NETIF_MAX_HWADDR_LEN | 
| group-onsemi | 0:098463de4c5d | 73 | #define NETIF_MAX_HWADDR_LEN 6U | 
| group-onsemi | 0:098463de4c5d | 74 | #endif | 
| group-onsemi | 0:098463de4c5d | 75 | |
| group-onsemi | 0:098463de4c5d | 76 | /** | 
| group-onsemi | 0:098463de4c5d | 77 | * @defgroup netif_flags Flags | 
| group-onsemi | 0:098463de4c5d | 78 | * @ingroup netif | 
| group-onsemi | 0:098463de4c5d | 79 | * @{ | 
| group-onsemi | 0:098463de4c5d | 80 | */ | 
| group-onsemi | 0:098463de4c5d | 81 | |
| group-onsemi | 0:098463de4c5d | 82 | /** Whether the network interface is 'up'. This is | 
| group-onsemi | 0:098463de4c5d | 83 | * a software flag used to control whether this network | 
| group-onsemi | 0:098463de4c5d | 84 | * interface is enabled and processes traffic. | 
| group-onsemi | 0:098463de4c5d | 85 | * It must be set by the startup code before this netif can be used | 
| group-onsemi | 0:098463de4c5d | 86 | * (also for dhcp/autoip). | 
| group-onsemi | 0:098463de4c5d | 87 | */ | 
| group-onsemi | 0:098463de4c5d | 88 | #define NETIF_FLAG_UP 0x01U | 
| group-onsemi | 0:098463de4c5d | 89 | /** If set, the netif has broadcast capability. | 
| group-onsemi | 0:098463de4c5d | 90 | * Set by the netif driver in its init function. */ | 
| group-onsemi | 0:098463de4c5d | 91 | #define NETIF_FLAG_BROADCAST 0x02U | 
| group-onsemi | 0:098463de4c5d | 92 | /** If set, the interface has an active link | 
| group-onsemi | 0:098463de4c5d | 93 | * (set by the network interface driver). | 
| group-onsemi | 0:098463de4c5d | 94 | * Either set by the netif driver in its init function (if the link | 
| group-onsemi | 0:098463de4c5d | 95 | * is up at that time) or at a later point once the link comes up | 
| group-onsemi | 0:098463de4c5d | 96 | * (if link detection is supported by the hardware). */ | 
| group-onsemi | 0:098463de4c5d | 97 | #define NETIF_FLAG_LINK_UP 0x04U | 
| group-onsemi | 0:098463de4c5d | 98 | /** If set, the netif is an ethernet device using ARP. | 
| group-onsemi | 0:098463de4c5d | 99 | * Set by the netif driver in its init function. | 
| group-onsemi | 0:098463de4c5d | 100 | * Used to check input packet types and use of DHCP. */ | 
| group-onsemi | 0:098463de4c5d | 101 | #define NETIF_FLAG_ETHARP 0x08U | 
| group-onsemi | 0:098463de4c5d | 102 | /** If set, the netif is an ethernet device. It might not use | 
| group-onsemi | 0:098463de4c5d | 103 | * ARP or TCP/IP if it is used for PPPoE only. | 
| group-onsemi | 0:098463de4c5d | 104 | */ | 
| group-onsemi | 0:098463de4c5d | 105 | #define NETIF_FLAG_ETHERNET 0x10U | 
| group-onsemi | 0:098463de4c5d | 106 | /** If set, the netif has IGMP capability. | 
| group-onsemi | 0:098463de4c5d | 107 | * Set by the netif driver in its init function. */ | 
| group-onsemi | 0:098463de4c5d | 108 | #define NETIF_FLAG_IGMP 0x20U | 
| group-onsemi | 0:098463de4c5d | 109 | /** If set, the netif has MLD6 capability. | 
| group-onsemi | 0:098463de4c5d | 110 | * Set by the netif driver in its init function. */ | 
| group-onsemi | 0:098463de4c5d | 111 | #define NETIF_FLAG_MLD6 0x40U | 
| group-onsemi | 0:098463de4c5d | 112 | |
| group-onsemi | 0:098463de4c5d | 113 | /** | 
| group-onsemi | 0:098463de4c5d | 114 | * @} | 
| group-onsemi | 0:098463de4c5d | 115 | */ | 
| group-onsemi | 0:098463de4c5d | 116 | |
| group-onsemi | 0:098463de4c5d | 117 | #if LWIP_CHECKSUM_CTRL_PER_NETIF | 
| group-onsemi | 0:098463de4c5d | 118 | #define NETIF_CHECKSUM_GEN_IP 0x0001 | 
| group-onsemi | 0:098463de4c5d | 119 | #define NETIF_CHECKSUM_GEN_UDP 0x0002 | 
| group-onsemi | 0:098463de4c5d | 120 | #define NETIF_CHECKSUM_GEN_TCP 0x0004 | 
| group-onsemi | 0:098463de4c5d | 121 | #define NETIF_CHECKSUM_GEN_ICMP 0x0008 | 
| group-onsemi | 0:098463de4c5d | 122 | #define NETIF_CHECKSUM_GEN_ICMP6 0x0010 | 
| group-onsemi | 0:098463de4c5d | 123 | #define NETIF_CHECKSUM_CHECK_IP 0x0100 | 
| group-onsemi | 0:098463de4c5d | 124 | #define NETIF_CHECKSUM_CHECK_UDP 0x0200 | 
| group-onsemi | 0:098463de4c5d | 125 | #define NETIF_CHECKSUM_CHECK_TCP 0x0400 | 
| group-onsemi | 0:098463de4c5d | 126 | #define NETIF_CHECKSUM_CHECK_ICMP 0x0800 | 
| group-onsemi | 0:098463de4c5d | 127 | #define NETIF_CHECKSUM_CHECK_ICMP6 0x1000 | 
| group-onsemi | 0:098463de4c5d | 128 | #define NETIF_CHECKSUM_ENABLE_ALL 0xFFFF | 
| group-onsemi | 0:098463de4c5d | 129 | #define NETIF_CHECKSUM_DISABLE_ALL 0x0000 | 
| group-onsemi | 0:098463de4c5d | 130 | #endif /* LWIP_CHECKSUM_CTRL_PER_NETIF */ | 
| group-onsemi | 0:098463de4c5d | 131 | |
| group-onsemi | 0:098463de4c5d | 132 | struct netif; | 
| group-onsemi | 0:098463de4c5d | 133 | |
| group-onsemi | 0:098463de4c5d | 134 | /** Function prototype for netif init functions. Set up flags and output/linkoutput | 
| group-onsemi | 0:098463de4c5d | 135 | * callback functions in this function. | 
| group-onsemi | 0:098463de4c5d | 136 | * | 
| group-onsemi | 0:098463de4c5d | 137 | * @param netif The netif to initialize | 
| group-onsemi | 0:098463de4c5d | 138 | */ | 
| group-onsemi | 0:098463de4c5d | 139 | typedef err_t (*netif_init_fn)(struct netif *netif); | 
| group-onsemi | 0:098463de4c5d | 140 | /** Function prototype for netif->input functions. This function is saved as 'input' | 
| group-onsemi | 0:098463de4c5d | 141 | * callback function in the netif struct. Call it when a packet has been received. | 
| group-onsemi | 0:098463de4c5d | 142 | * | 
| group-onsemi | 0:098463de4c5d | 143 | * @param p The received packet, copied into a pbuf | 
| group-onsemi | 0:098463de4c5d | 144 | * @param inp The netif which received the packet | 
| group-onsemi | 0:098463de4c5d | 145 | */ | 
| group-onsemi | 0:098463de4c5d | 146 | typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp); | 
| group-onsemi | 0:098463de4c5d | 147 | |
| group-onsemi | 0:098463de4c5d | 148 | #if LWIP_IPV4 | 
| group-onsemi | 0:098463de4c5d | 149 | /** Function prototype for netif->output functions. Called by lwIP when a packet | 
| group-onsemi | 0:098463de4c5d | 150 | * shall be sent. For ethernet netif, set this to 'etharp_output' and set | 
| group-onsemi | 0:098463de4c5d | 151 | * 'linkoutput'. | 
| group-onsemi | 0:098463de4c5d | 152 | * | 
| group-onsemi | 0:098463de4c5d | 153 | * @param netif The netif which shall send a packet | 
| group-onsemi | 0:098463de4c5d | 154 | * @param p The packet to send (p->payload points to IP header) | 
| group-onsemi | 0:098463de4c5d | 155 | * @param ipaddr The IP address to which the packet shall be sent | 
| group-onsemi | 0:098463de4c5d | 156 | */ | 
| group-onsemi | 0:098463de4c5d | 157 | typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p, | 
| group-onsemi | 0:098463de4c5d | 158 | const ip4_addr_t *ipaddr); | 
| group-onsemi | 0:098463de4c5d | 159 | #endif /* LWIP_IPV4*/ | 
| group-onsemi | 0:098463de4c5d | 160 | |
| group-onsemi | 0:098463de4c5d | 161 | #if LWIP_IPV6 | 
| group-onsemi | 0:098463de4c5d | 162 | /** Function prototype for netif->output_ip6 functions. Called by lwIP when a packet | 
| group-onsemi | 0:098463de4c5d | 163 | * shall be sent. For ethernet netif, set this to 'ethip6_output' and set | 
| group-onsemi | 0:098463de4c5d | 164 | * 'linkoutput'. | 
| group-onsemi | 0:098463de4c5d | 165 | * | 
| group-onsemi | 0:098463de4c5d | 166 | * @param netif The netif which shall send a packet | 
| group-onsemi | 0:098463de4c5d | 167 | * @param p The packet to send (p->payload points to IP header) | 
| group-onsemi | 0:098463de4c5d | 168 | * @param ipaddr The IPv6 address to which the packet shall be sent | 
| group-onsemi | 0:098463de4c5d | 169 | */ | 
| group-onsemi | 0:098463de4c5d | 170 | typedef err_t (*netif_output_ip6_fn)(struct netif *netif, struct pbuf *p, | 
| group-onsemi | 0:098463de4c5d | 171 | const ip6_addr_t *ipaddr); | 
| group-onsemi | 0:098463de4c5d | 172 | #endif /* LWIP_IPV6 */ | 
| group-onsemi | 0:098463de4c5d | 173 | |
| group-onsemi | 0:098463de4c5d | 174 | /** Function prototype for netif->linkoutput functions. Only used for ethernet | 
| group-onsemi | 0:098463de4c5d | 175 | * netifs. This function is called by ARP when a packet shall be sent. | 
| group-onsemi | 0:098463de4c5d | 176 | * | 
| group-onsemi | 0:098463de4c5d | 177 | * @param netif The netif which shall send a packet | 
| group-onsemi | 0:098463de4c5d | 178 | * @param p The packet to send (raw ethernet packet) | 
| group-onsemi | 0:098463de4c5d | 179 | */ | 
| group-onsemi | 0:098463de4c5d | 180 | typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p); | 
| group-onsemi | 0:098463de4c5d | 181 | /** Function prototype for netif status- or link-callback functions. */ | 
| group-onsemi | 0:098463de4c5d | 182 | typedef void (*netif_status_callback_fn)(struct netif *netif); | 
| group-onsemi | 0:098463de4c5d | 183 | #if LWIP_IPV4 && LWIP_IGMP | 
| group-onsemi | 0:098463de4c5d | 184 | /** Function prototype for netif igmp_mac_filter functions */ | 
| group-onsemi | 0:098463de4c5d | 185 | typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif, | 
| group-onsemi | 0:098463de4c5d | 186 | const ip4_addr_t *group, u8_t action); | 
| group-onsemi | 0:098463de4c5d | 187 | #endif /* LWIP_IPV4 && LWIP_IGMP */ | 
| group-onsemi | 0:098463de4c5d | 188 | #if LWIP_IPV6 && LWIP_IPV6_MLD | 
| group-onsemi | 0:098463de4c5d | 189 | /** Function prototype for netif mld_mac_filter functions */ | 
| group-onsemi | 0:098463de4c5d | 190 | typedef err_t (*netif_mld_mac_filter_fn)(struct netif *netif, | 
| group-onsemi | 0:098463de4c5d | 191 | const ip6_addr_t *group, u8_t action); | 
| group-onsemi | 0:098463de4c5d | 192 | #endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ | 
| group-onsemi | 0:098463de4c5d | 193 | |
| group-onsemi | 0:098463de4c5d | 194 | /** Generic data structure used for all lwIP network interfaces. | 
| group-onsemi | 0:098463de4c5d | 195 | * The following fields should be filled in by the initialization | 
| group-onsemi | 0:098463de4c5d | 196 | * function for the device driver: hwaddr_len, hwaddr[], mtu, flags */ | 
| group-onsemi | 0:098463de4c5d | 197 | struct netif { | 
| group-onsemi | 0:098463de4c5d | 198 | /** pointer to next in linked list */ | 
| group-onsemi | 0:098463de4c5d | 199 | struct netif *next; | 
| group-onsemi | 0:098463de4c5d | 200 | |
| group-onsemi | 0:098463de4c5d | 201 | #if LWIP_IPV4 | 
| group-onsemi | 0:098463de4c5d | 202 | /** IP address configuration in network byte order */ | 
| group-onsemi | 0:098463de4c5d | 203 | ip_addr_t ip_addr; | 
| group-onsemi | 0:098463de4c5d | 204 | ip_addr_t netmask; | 
| group-onsemi | 0:098463de4c5d | 205 | ip_addr_t gw; | 
| group-onsemi | 0:098463de4c5d | 206 | #endif /* LWIP_IPV4 */ | 
| group-onsemi | 0:098463de4c5d | 207 | #if LWIP_IPV6 | 
| group-onsemi | 0:098463de4c5d | 208 | /** Array of IPv6 addresses for this netif. */ | 
| group-onsemi | 0:098463de4c5d | 209 | ip_addr_t ip6_addr[LWIP_IPV6_NUM_ADDRESSES]; | 
| group-onsemi | 0:098463de4c5d | 210 | /** The state of each IPv6 address (Tentative, Preferred, etc). | 
| group-onsemi | 0:098463de4c5d | 211 | * @see ip6_addr.h */ | 
| group-onsemi | 0:098463de4c5d | 212 | u8_t ip6_addr_state[LWIP_IPV6_NUM_ADDRESSES]; | 
| group-onsemi | 0:098463de4c5d | 213 | #endif /* LWIP_IPV6 */ | 
| group-onsemi | 0:098463de4c5d | 214 | /** This function is called by the network device driver | 
| group-onsemi | 0:098463de4c5d | 215 | * to pass a packet up the TCP/IP stack. */ | 
| group-onsemi | 0:098463de4c5d | 216 | netif_input_fn input; | 
| group-onsemi | 0:098463de4c5d | 217 | #if LWIP_IPV4 | 
| group-onsemi | 0:098463de4c5d | 218 | /** This function is called by the IP module when it wants | 
| group-onsemi | 0:098463de4c5d | 219 | * to send a packet on the interface. This function typically | 
| group-onsemi | 0:098463de4c5d | 220 | * first resolves the hardware address, then sends the packet. */ | 
| group-onsemi | 0:098463de4c5d | 221 | netif_output_fn output; | 
| group-onsemi | 0:098463de4c5d | 222 | #endif /* LWIP_IPV4 */ | 
| group-onsemi | 0:098463de4c5d | 223 | /** This function is called by the ARP module when it wants | 
| group-onsemi | 0:098463de4c5d | 224 | * to send a packet on the interface. This function outputs | 
| group-onsemi | 0:098463de4c5d | 225 | * the pbuf as-is on the link medium. */ | 
| group-onsemi | 0:098463de4c5d | 226 | netif_linkoutput_fn linkoutput; | 
| group-onsemi | 0:098463de4c5d | 227 | #if LWIP_IPV6 | 
| group-onsemi | 0:098463de4c5d | 228 | /** This function is called by the IPv6 module when it wants | 
| group-onsemi | 0:098463de4c5d | 229 | * to send a packet on the interface. This function typically | 
| group-onsemi | 0:098463de4c5d | 230 | * first resolves the hardware address, then sends the packet. */ | 
| group-onsemi | 0:098463de4c5d | 231 | netif_output_ip6_fn output_ip6; | 
| group-onsemi | 0:098463de4c5d | 232 | #endif /* LWIP_IPV6 */ | 
| group-onsemi | 0:098463de4c5d | 233 | #if LWIP_NETIF_STATUS_CALLBACK | 
| group-onsemi | 0:098463de4c5d | 234 | /** This function is called when the netif state is set to up or down | 
| group-onsemi | 0:098463de4c5d | 235 | */ | 
| group-onsemi | 0:098463de4c5d | 236 | netif_status_callback_fn status_callback; | 
| group-onsemi | 0:098463de4c5d | 237 | #endif /* LWIP_NETIF_STATUS_CALLBACK */ | 
| group-onsemi | 0:098463de4c5d | 238 | #if LWIP_NETIF_LINK_CALLBACK | 
| group-onsemi | 0:098463de4c5d | 239 | /** This function is called when the netif link is set to up or down | 
| group-onsemi | 0:098463de4c5d | 240 | */ | 
| group-onsemi | 0:098463de4c5d | 241 | netif_status_callback_fn link_callback; | 
| group-onsemi | 0:098463de4c5d | 242 | #endif /* LWIP_NETIF_LINK_CALLBACK */ | 
| group-onsemi | 0:098463de4c5d | 243 | #if LWIP_NETIF_REMOVE_CALLBACK | 
| group-onsemi | 0:098463de4c5d | 244 | /** This function is called when the netif has been removed */ | 
| group-onsemi | 0:098463de4c5d | 245 | netif_status_callback_fn remove_callback; | 
| group-onsemi | 0:098463de4c5d | 246 | #endif /* LWIP_NETIF_REMOVE_CALLBACK */ | 
| group-onsemi | 0:098463de4c5d | 247 | /** This field can be set by the device driver and could point | 
| group-onsemi | 0:098463de4c5d | 248 | * to state information for the device. */ | 
| group-onsemi | 0:098463de4c5d | 249 | void *state; | 
| group-onsemi | 0:098463de4c5d | 250 | #if LWIP_DHCP | 
| group-onsemi | 0:098463de4c5d | 251 | /** the DHCP client state information for this netif */ | 
| group-onsemi | 0:098463de4c5d | 252 | struct dhcp *dhcp; | 
| group-onsemi | 0:098463de4c5d | 253 | #endif /* LWIP_DHCP */ | 
| group-onsemi | 0:098463de4c5d | 254 | #if LWIP_AUTOIP | 
| group-onsemi | 0:098463de4c5d | 255 | /** the AutoIP client state information for this netif */ | 
| group-onsemi | 0:098463de4c5d | 256 | struct autoip *autoip; | 
| group-onsemi | 0:098463de4c5d | 257 | #endif | 
| group-onsemi | 0:098463de4c5d | 258 | #if LWIP_IPV6_AUTOCONFIG | 
| group-onsemi | 0:098463de4c5d | 259 | /** is this netif enabled for IPv6 autoconfiguration */ | 
| group-onsemi | 0:098463de4c5d | 260 | u8_t ip6_autoconfig_enabled; | 
| group-onsemi | 0:098463de4c5d | 261 | #endif /* LWIP_IPV6_AUTOCONFIG */ | 
| group-onsemi | 0:098463de4c5d | 262 | #if LWIP_IPV6_SEND_ROUTER_SOLICIT | 
| group-onsemi | 0:098463de4c5d | 263 | /** Number of Router Solicitation messages that remain to be sent. */ | 
| group-onsemi | 0:098463de4c5d | 264 | u8_t rs_count; | 
| group-onsemi | 0:098463de4c5d | 265 | #endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */ | 
| group-onsemi | 0:098463de4c5d | 266 | #if LWIP_IPV6_DHCP6 | 
| group-onsemi | 0:098463de4c5d | 267 | /** the DHCPv6 client state information for this netif */ | 
| group-onsemi | 0:098463de4c5d | 268 | struct dhcp6 *dhcp6; | 
| group-onsemi | 0:098463de4c5d | 269 | #endif /* LWIP_IPV6_DHCP6 */ | 
| group-onsemi | 0:098463de4c5d | 270 | #if LWIP_NETIF_HOSTNAME | 
| group-onsemi | 0:098463de4c5d | 271 | /* the hostname for this netif, NULL is a valid value */ | 
| group-onsemi | 0:098463de4c5d | 272 | const char* hostname; | 
| group-onsemi | 0:098463de4c5d | 273 | #endif /* LWIP_NETIF_HOSTNAME */ | 
| group-onsemi | 0:098463de4c5d | 274 | #if LWIP_CHECKSUM_CTRL_PER_NETIF | 
| group-onsemi | 0:098463de4c5d | 275 | u16_t chksum_flags; | 
| group-onsemi | 0:098463de4c5d | 276 | #endif /* LWIP_CHECKSUM_CTRL_PER_NETIF*/ | 
| group-onsemi | 0:098463de4c5d | 277 | /** maximum transfer unit (in bytes) */ | 
| group-onsemi | 0:098463de4c5d | 278 | u16_t mtu; | 
| group-onsemi | 0:098463de4c5d | 279 | /** number of bytes used in hwaddr */ | 
| group-onsemi | 0:098463de4c5d | 280 | u8_t hwaddr_len; | 
| group-onsemi | 0:098463de4c5d | 281 | /** link level hardware address of this interface */ | 
| group-onsemi | 0:098463de4c5d | 282 | u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; | 
| group-onsemi | 0:098463de4c5d | 283 | /** flags (@see @ref netif_flags) */ | 
| group-onsemi | 0:098463de4c5d | 284 | u8_t flags; | 
| group-onsemi | 0:098463de4c5d | 285 | /** descriptive abbreviation */ | 
| group-onsemi | 0:098463de4c5d | 286 | char name[2]; | 
| group-onsemi | 0:098463de4c5d | 287 | /** number of this interface */ | 
| group-onsemi | 0:098463de4c5d | 288 | u8_t num; | 
| group-onsemi | 0:098463de4c5d | 289 | #if MIB2_STATS | 
| group-onsemi | 0:098463de4c5d | 290 | /** link type (from "snmp_ifType" enum from snmp_mib2.h) */ | 
| group-onsemi | 0:098463de4c5d | 291 | u8_t link_type; | 
| group-onsemi | 0:098463de4c5d | 292 | /** (estimate) link speed */ | 
| group-onsemi | 0:098463de4c5d | 293 | u32_t link_speed; | 
| group-onsemi | 0:098463de4c5d | 294 | /** timestamp at last change made (up/down) */ | 
| group-onsemi | 0:098463de4c5d | 295 | u32_t ts; | 
| group-onsemi | 0:098463de4c5d | 296 | /** counters */ | 
| group-onsemi | 0:098463de4c5d | 297 | struct stats_mib2_netif_ctrs mib2_counters; | 
| group-onsemi | 0:098463de4c5d | 298 | #endif /* MIB2_STATS */ | 
| group-onsemi | 0:098463de4c5d | 299 | #if LWIP_IPV4 && LWIP_IGMP | 
| group-onsemi | 0:098463de4c5d | 300 | /** This function could be called to add or delete an entry in the multicast | 
| group-onsemi | 0:098463de4c5d | 301 | filter table of the ethernet MAC.*/ | 
| group-onsemi | 0:098463de4c5d | 302 | netif_igmp_mac_filter_fn igmp_mac_filter; | 
| group-onsemi | 0:098463de4c5d | 303 | #endif /* LWIP_IPV4 && LWIP_IGMP */ | 
| group-onsemi | 0:098463de4c5d | 304 | #if LWIP_IPV6 && LWIP_IPV6_MLD | 
| group-onsemi | 0:098463de4c5d | 305 | /** This function could be called to add or delete an entry in the IPv6 multicast | 
| group-onsemi | 0:098463de4c5d | 306 | filter table of the ethernet MAC. */ | 
| group-onsemi | 0:098463de4c5d | 307 | netif_mld_mac_filter_fn mld_mac_filter; | 
| group-onsemi | 0:098463de4c5d | 308 | #endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ | 
| group-onsemi | 0:098463de4c5d | 309 | #if LWIP_NETIF_HWADDRHINT | 
| group-onsemi | 0:098463de4c5d | 310 | u8_t *addr_hint; | 
| group-onsemi | 0:098463de4c5d | 311 | #endif /* LWIP_NETIF_HWADDRHINT */ | 
| group-onsemi | 0:098463de4c5d | 312 | #if ENABLE_LOOPBACK | 
| group-onsemi | 0:098463de4c5d | 313 | /* List of packets to be queued for ourselves. */ | 
| group-onsemi | 0:098463de4c5d | 314 | struct pbuf *loop_first; | 
| group-onsemi | 0:098463de4c5d | 315 | struct pbuf *loop_last; | 
| group-onsemi | 0:098463de4c5d | 316 | #if LWIP_LOOPBACK_MAX_PBUFS | 
| group-onsemi | 0:098463de4c5d | 317 | u16_t loop_cnt_current; | 
| group-onsemi | 0:098463de4c5d | 318 | #endif /* LWIP_LOOPBACK_MAX_PBUFS */ | 
| group-onsemi | 0:098463de4c5d | 319 | #endif /* ENABLE_LOOPBACK */ | 
| group-onsemi | 0:098463de4c5d | 320 | }; | 
| group-onsemi | 0:098463de4c5d | 321 | |
| group-onsemi | 0:098463de4c5d | 322 | #if LWIP_CHECKSUM_CTRL_PER_NETIF | 
| group-onsemi | 0:098463de4c5d | 323 | #define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) do { \ | 
| group-onsemi | 0:098463de4c5d | 324 | (netif)->chksum_flags = chksumflags; } while(0) | 
| group-onsemi | 0:098463de4c5d | 325 | #define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) if (((netif) == NULL) || (((netif)->chksum_flags & (chksumflag)) != 0)) | 
| group-onsemi | 0:098463de4c5d | 326 | #else /* LWIP_CHECKSUM_CTRL_PER_NETIF */ | 
| group-onsemi | 0:098463de4c5d | 327 | #define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) | 
| group-onsemi | 0:098463de4c5d | 328 | #define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) | 
| group-onsemi | 0:098463de4c5d | 329 | #endif /* LWIP_CHECKSUM_CTRL_PER_NETIF */ | 
| group-onsemi | 0:098463de4c5d | 330 | |
| group-onsemi | 0:098463de4c5d | 331 | /** The list of network interfaces. */ | 
| group-onsemi | 0:098463de4c5d | 332 | extern struct netif *netif_list; | 
| group-onsemi | 0:098463de4c5d | 333 | /** The default network interface. */ | 
| group-onsemi | 0:098463de4c5d | 334 | extern struct netif *netif_default; | 
| group-onsemi | 0:098463de4c5d | 335 | |
| group-onsemi | 0:098463de4c5d | 336 | void netif_init(void); | 
| group-onsemi | 0:098463de4c5d | 337 | |
| group-onsemi | 0:098463de4c5d | 338 | struct netif *netif_add(struct netif *netif, | 
| group-onsemi | 0:098463de4c5d | 339 | #if LWIP_IPV4 | 
| group-onsemi | 0:098463de4c5d | 340 | const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw, | 
| group-onsemi | 0:098463de4c5d | 341 | #endif /* LWIP_IPV4 */ | 
| group-onsemi | 0:098463de4c5d | 342 | void *state, netif_init_fn init, netif_input_fn input); | 
| group-onsemi | 0:098463de4c5d | 343 | #if LWIP_IPV4 | 
| group-onsemi | 0:098463de4c5d | 344 | void netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, | 
| group-onsemi | 0:098463de4c5d | 345 | const ip4_addr_t *gw); | 
| group-onsemi | 0:098463de4c5d | 346 | #endif /* LWIP_IPV4 */ | 
| group-onsemi | 0:098463de4c5d | 347 | void netif_remove(struct netif * netif); | 
| group-onsemi | 0:098463de4c5d | 348 | |
| group-onsemi | 0:098463de4c5d | 349 | /* Returns a network interface given its name. The name is of the form | 
| group-onsemi | 0:098463de4c5d | 350 | "et0", where the first two letters are the "name" field in the | 
| group-onsemi | 0:098463de4c5d | 351 | netif structure, and the digit is in the num field in the same | 
| group-onsemi | 0:098463de4c5d | 352 | structure. */ | 
| group-onsemi | 0:098463de4c5d | 353 | struct netif *netif_find(const char *name); | 
| group-onsemi | 0:098463de4c5d | 354 | |
| group-onsemi | 0:098463de4c5d | 355 | void netif_set_default(struct netif *netif); | 
| group-onsemi | 0:098463de4c5d | 356 | |
| group-onsemi | 0:098463de4c5d | 357 | #if LWIP_IPV4 | 
| group-onsemi | 0:098463de4c5d | 358 | void netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr); | 
| group-onsemi | 0:098463de4c5d | 359 | void netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask); | 
| group-onsemi | 0:098463de4c5d | 360 | void netif_set_gw(struct netif *netif, const ip4_addr_t *gw); | 
| group-onsemi | 0:098463de4c5d | 361 | #define netif_ip4_addr(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->ip_addr))) | 
| group-onsemi | 0:098463de4c5d | 362 | #define netif_ip4_netmask(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->netmask))) | 
| group-onsemi | 0:098463de4c5d | 363 | #define netif_ip4_gw(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->gw))) | 
| group-onsemi | 0:098463de4c5d | 364 | #define netif_ip_addr4(netif) ((const ip_addr_t*)&((netif)->ip_addr)) | 
| group-onsemi | 0:098463de4c5d | 365 | #define netif_ip_netmask4(netif) ((const ip_addr_t*)&((netif)->netmask)) | 
| group-onsemi | 0:098463de4c5d | 366 | #define netif_ip_gw4(netif) ((const ip_addr_t*)&((netif)->gw)) | 
| group-onsemi | 0:098463de4c5d | 367 | #endif /* LWIP_IPV4 */ | 
| group-onsemi | 0:098463de4c5d | 368 | |
| group-onsemi | 0:098463de4c5d | 369 | void netif_set_up(struct netif *netif); | 
| group-onsemi | 0:098463de4c5d | 370 | void netif_set_down(struct netif *netif); | 
| group-onsemi | 0:098463de4c5d | 371 | /** @ingroup netif | 
| group-onsemi | 0:098463de4c5d | 372 | * Ask if an interface is up | 
| group-onsemi | 0:098463de4c5d | 373 | */ | 
| group-onsemi | 0:098463de4c5d | 374 | #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) | 
| group-onsemi | 0:098463de4c5d | 375 | |
| group-onsemi | 0:098463de4c5d | 376 | #if LWIP_NETIF_STATUS_CALLBACK | 
| group-onsemi | 0:098463de4c5d | 377 | void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback); | 
| group-onsemi | 0:098463de4c5d | 378 | #endif /* LWIP_NETIF_STATUS_CALLBACK */ | 
| group-onsemi | 0:098463de4c5d | 379 | #if LWIP_NETIF_REMOVE_CALLBACK | 
| group-onsemi | 0:098463de4c5d | 380 | void netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback); | 
| group-onsemi | 0:098463de4c5d | 381 | #endif /* LWIP_NETIF_REMOVE_CALLBACK */ | 
| group-onsemi | 0:098463de4c5d | 382 | |
| group-onsemi | 0:098463de4c5d | 383 | void netif_set_link_up(struct netif *netif); | 
| group-onsemi | 0:098463de4c5d | 384 | void netif_set_link_down(struct netif *netif); | 
| group-onsemi | 0:098463de4c5d | 385 | /** Ask if a link is up */ | 
| group-onsemi | 0:098463de4c5d | 386 | #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) | 
| group-onsemi | 0:098463de4c5d | 387 | |
| group-onsemi | 0:098463de4c5d | 388 | #if LWIP_NETIF_LINK_CALLBACK | 
| group-onsemi | 0:098463de4c5d | 389 | void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback); | 
| group-onsemi | 0:098463de4c5d | 390 | #endif /* LWIP_NETIF_LINK_CALLBACK */ | 
| group-onsemi | 0:098463de4c5d | 391 | |
| group-onsemi | 0:098463de4c5d | 392 | #if LWIP_NETIF_HOSTNAME | 
| group-onsemi | 0:098463de4c5d | 393 | #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) | 
| group-onsemi | 0:098463de4c5d | 394 | #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) | 
| group-onsemi | 0:098463de4c5d | 395 | #endif /* LWIP_NETIF_HOSTNAME */ | 
| group-onsemi | 0:098463de4c5d | 396 | |
| group-onsemi | 0:098463de4c5d | 397 | #if LWIP_IGMP | 
| group-onsemi | 0:098463de4c5d | 398 | #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) | 
| group-onsemi | 0:098463de4c5d | 399 | #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) | 
| group-onsemi | 0:098463de4c5d | 400 | #endif /* LWIP_IGMP */ | 
| group-onsemi | 0:098463de4c5d | 401 | |
| group-onsemi | 0:098463de4c5d | 402 | #if LWIP_IPV6 && LWIP_IPV6_MLD | 
| group-onsemi | 0:098463de4c5d | 403 | #define netif_set_mld_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->mld_mac_filter = function; }}while(0) | 
| group-onsemi | 0:098463de4c5d | 404 | #define netif_get_mld_mac_filter(netif) (((netif) != NULL) ? ((netif)->mld_mac_filter) : NULL) | 
| group-onsemi | 0:098463de4c5d | 405 | #define netif_mld_mac_filter(netif, addr, action) do { if((netif) && (netif)->mld_mac_filter) { (netif)->mld_mac_filter((netif), (addr), (action)); }}while(0) | 
| group-onsemi | 0:098463de4c5d | 406 | #endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ | 
| group-onsemi | 0:098463de4c5d | 407 | |
| group-onsemi | 0:098463de4c5d | 408 | #if ENABLE_LOOPBACK | 
| group-onsemi | 0:098463de4c5d | 409 | err_t netif_loop_output(struct netif *netif, struct pbuf *p); | 
| group-onsemi | 0:098463de4c5d | 410 | void netif_poll(struct netif *netif); | 
| group-onsemi | 0:098463de4c5d | 411 | #if !LWIP_NETIF_LOOPBACK_MULTITHREADING | 
| group-onsemi | 0:098463de4c5d | 412 | void netif_poll_all(void); | 
| group-onsemi | 0:098463de4c5d | 413 | #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ | 
| group-onsemi | 0:098463de4c5d | 414 | #endif /* ENABLE_LOOPBACK */ | 
| group-onsemi | 0:098463de4c5d | 415 | |
| group-onsemi | 0:098463de4c5d | 416 | err_t netif_input(struct pbuf *p, struct netif *inp); | 
| group-onsemi | 0:098463de4c5d | 417 | |
| group-onsemi | 0:098463de4c5d | 418 | #if LWIP_IPV6 | 
| group-onsemi | 0:098463de4c5d | 419 | /** @ingroup netif */ | 
| group-onsemi | 0:098463de4c5d | 420 | #define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i]))) | 
| group-onsemi | 0:098463de4c5d | 421 | /** @ingroup netif */ | 
| group-onsemi | 0:098463de4c5d | 422 | #define netif_ip6_addr(netif, i) ((const ip6_addr_t*)ip_2_ip6(&((netif)->ip6_addr[i]))) | 
| group-onsemi | 0:098463de4c5d | 423 | void netif_ip6_addr_set(struct netif *netif, s8_t addr_idx, ip6_addr_t *addr6); | 
| group-onsemi | 0:098463de4c5d | 424 | 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); | 
| group-onsemi | 0:098463de4c5d | 425 | #define netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[i]) | 
| group-onsemi | 0:098463de4c5d | 426 | void netif_ip6_addr_set_state(struct netif* netif, s8_t addr_idx, u8_t state); | 
| group-onsemi | 0:098463de4c5d | 427 | s8_t netif_get_ip6_addr_match(struct netif *netif, const ip6_addr_t *ip6addr); | 
| group-onsemi | 0:098463de4c5d | 428 | void netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit); | 
| group-onsemi | 0:098463de4c5d | 429 | err_t netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chosen_idx); | 
| group-onsemi | 0:098463de4c5d | 430 | #define netif_set_ip6_autoconfig_enabled(netif, action) do { if(netif) { (netif)->ip6_autoconfig_enabled = (action); }}while(0) | 
| group-onsemi | 0:098463de4c5d | 431 | #endif /* LWIP_IPV6 */ | 
| group-onsemi | 0:098463de4c5d | 432 | |
| group-onsemi | 0:098463de4c5d | 433 | #if LWIP_NETIF_HWADDRHINT | 
| group-onsemi | 0:098463de4c5d | 434 | #define NETIF_SET_HWADDRHINT(netif, hint) ((netif)->addr_hint = (hint)) | 
| group-onsemi | 0:098463de4c5d | 435 | #else /* LWIP_NETIF_HWADDRHINT */ | 
| group-onsemi | 0:098463de4c5d | 436 | #define NETIF_SET_HWADDRHINT(netif, hint) | 
| group-onsemi | 0:098463de4c5d | 437 | #endif /* LWIP_NETIF_HWADDRHINT */ | 
| group-onsemi | 0:098463de4c5d | 438 | |
| group-onsemi | 0:098463de4c5d | 439 | #ifdef __cplusplus | 
| group-onsemi | 0:098463de4c5d | 440 | } | 
| group-onsemi | 0:098463de4c5d | 441 | #endif | 
| group-onsemi | 0:098463de4c5d | 442 | |
| group-onsemi | 0:098463de4c5d | 443 | #endif /* LWIP_HDR_NETIF_H */ |