ProjetoBB
Dependencies: F7_Ethernet WebSocketClient mbed mcp3008
Fork of Nucleo_F746ZG_Ethernet by
F7_Ethernet/lwip/include/lwip/netif.h@0:f9b6112278fe, 2016-06-18 (annotated)
- Committer:
- DieterGraef
- Date:
- Sat Jun 18 10:49:12 2016 +0000
- Revision:
- 0:f9b6112278fe
Ethernet for the NUCLEO STM32F746 Board Testprogram uses DHCP and NTP to set the clock
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DieterGraef | 0:f9b6112278fe | 1 | /* |
DieterGraef | 0:f9b6112278fe | 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. |
DieterGraef | 0:f9b6112278fe | 3 | * All rights reserved. |
DieterGraef | 0:f9b6112278fe | 4 | * |
DieterGraef | 0:f9b6112278fe | 5 | * Redistribution and use in source and binary forms, with or without modification, |
DieterGraef | 0:f9b6112278fe | 6 | * are permitted provided that the following conditions are met: |
DieterGraef | 0:f9b6112278fe | 7 | * |
DieterGraef | 0:f9b6112278fe | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
DieterGraef | 0:f9b6112278fe | 9 | * this list of conditions and the following disclaimer. |
DieterGraef | 0:f9b6112278fe | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
DieterGraef | 0:f9b6112278fe | 11 | * this list of conditions and the following disclaimer in the documentation |
DieterGraef | 0:f9b6112278fe | 12 | * and/or other materials provided with the distribution. |
DieterGraef | 0:f9b6112278fe | 13 | * 3. The name of the author may not be used to endorse or promote products |
DieterGraef | 0:f9b6112278fe | 14 | * derived from this software without specific prior written permission. |
DieterGraef | 0:f9b6112278fe | 15 | * |
DieterGraef | 0:f9b6112278fe | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
DieterGraef | 0:f9b6112278fe | 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
DieterGraef | 0:f9b6112278fe | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
DieterGraef | 0:f9b6112278fe | 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
DieterGraef | 0:f9b6112278fe | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
DieterGraef | 0:f9b6112278fe | 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
DieterGraef | 0:f9b6112278fe | 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
DieterGraef | 0:f9b6112278fe | 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
DieterGraef | 0:f9b6112278fe | 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
DieterGraef | 0:f9b6112278fe | 25 | * OF SUCH DAMAGE. |
DieterGraef | 0:f9b6112278fe | 26 | * |
DieterGraef | 0:f9b6112278fe | 27 | * This file is part of the lwIP TCP/IP stack. |
DieterGraef | 0:f9b6112278fe | 28 | * |
DieterGraef | 0:f9b6112278fe | 29 | * Author: Adam Dunkels <adam@sics.se> |
DieterGraef | 0:f9b6112278fe | 30 | * |
DieterGraef | 0:f9b6112278fe | 31 | */ |
DieterGraef | 0:f9b6112278fe | 32 | #ifndef __LWIP_NETIF_H__ |
DieterGraef | 0:f9b6112278fe | 33 | #define __LWIP_NETIF_H__ |
DieterGraef | 0:f9b6112278fe | 34 | |
DieterGraef | 0:f9b6112278fe | 35 | #include "lwip/opt.h" |
DieterGraef | 0:f9b6112278fe | 36 | |
DieterGraef | 0:f9b6112278fe | 37 | #define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) |
DieterGraef | 0:f9b6112278fe | 38 | |
DieterGraef | 0:f9b6112278fe | 39 | #include "lwip/err.h" |
DieterGraef | 0:f9b6112278fe | 40 | |
DieterGraef | 0:f9b6112278fe | 41 | #include "lwip/ip_addr.h" |
DieterGraef | 0:f9b6112278fe | 42 | |
DieterGraef | 0:f9b6112278fe | 43 | #include "lwip/def.h" |
DieterGraef | 0:f9b6112278fe | 44 | #include "lwip/pbuf.h" |
DieterGraef | 0:f9b6112278fe | 45 | #if LWIP_DHCP |
DieterGraef | 0:f9b6112278fe | 46 | struct dhcp; |
DieterGraef | 0:f9b6112278fe | 47 | #endif |
DieterGraef | 0:f9b6112278fe | 48 | #if LWIP_AUTOIP |
DieterGraef | 0:f9b6112278fe | 49 | struct autoip; |
DieterGraef | 0:f9b6112278fe | 50 | #endif |
DieterGraef | 0:f9b6112278fe | 51 | |
DieterGraef | 0:f9b6112278fe | 52 | #ifdef __cplusplus |
DieterGraef | 0:f9b6112278fe | 53 | extern "C" { |
DieterGraef | 0:f9b6112278fe | 54 | #endif |
DieterGraef | 0:f9b6112278fe | 55 | |
DieterGraef | 0:f9b6112278fe | 56 | /* Throughout this file, IP addresses are expected to be in |
DieterGraef | 0:f9b6112278fe | 57 | * the same byte order as in IP_PCB. */ |
DieterGraef | 0:f9b6112278fe | 58 | |
DieterGraef | 0:f9b6112278fe | 59 | /** must be the maximum of all used hardware address lengths |
DieterGraef | 0:f9b6112278fe | 60 | across all types of interfaces in use */ |
DieterGraef | 0:f9b6112278fe | 61 | #define NETIF_MAX_HWADDR_LEN 6U |
DieterGraef | 0:f9b6112278fe | 62 | |
DieterGraef | 0:f9b6112278fe | 63 | /** Whether the network interface is 'up'. This is |
DieterGraef | 0:f9b6112278fe | 64 | * a software flag used to control whether this network |
DieterGraef | 0:f9b6112278fe | 65 | * interface is enabled and processes traffic. |
DieterGraef | 0:f9b6112278fe | 66 | * It is set by the startup code (for static IP configuration) or |
DieterGraef | 0:f9b6112278fe | 67 | * by dhcp/autoip when an address has been assigned. |
DieterGraef | 0:f9b6112278fe | 68 | */ |
DieterGraef | 0:f9b6112278fe | 69 | #define NETIF_FLAG_UP 0x01U |
DieterGraef | 0:f9b6112278fe | 70 | /** If set, the netif has broadcast capability. |
DieterGraef | 0:f9b6112278fe | 71 | * Set by the netif driver in its init function. */ |
DieterGraef | 0:f9b6112278fe | 72 | #define NETIF_FLAG_BROADCAST 0x02U |
DieterGraef | 0:f9b6112278fe | 73 | /** If set, the netif is one end of a point-to-point connection. |
DieterGraef | 0:f9b6112278fe | 74 | * Set by the netif driver in its init function. */ |
DieterGraef | 0:f9b6112278fe | 75 | #define NETIF_FLAG_POINTTOPOINT 0x04U |
DieterGraef | 0:f9b6112278fe | 76 | /** If set, the interface is configured using DHCP. |
DieterGraef | 0:f9b6112278fe | 77 | * Set by the DHCP code when starting or stopping DHCP. */ |
DieterGraef | 0:f9b6112278fe | 78 | #define NETIF_FLAG_DHCP 0x08U |
DieterGraef | 0:f9b6112278fe | 79 | /** If set, the interface has an active link |
DieterGraef | 0:f9b6112278fe | 80 | * (set by the network interface driver). |
DieterGraef | 0:f9b6112278fe | 81 | * Either set by the netif driver in its init function (if the link |
DieterGraef | 0:f9b6112278fe | 82 | * is up at that time) or at a later point once the link comes up |
DieterGraef | 0:f9b6112278fe | 83 | * (if link detection is supported by the hardware). */ |
DieterGraef | 0:f9b6112278fe | 84 | #define NETIF_FLAG_LINK_UP 0x10U |
DieterGraef | 0:f9b6112278fe | 85 | /** If set, the netif is an ethernet device using ARP. |
DieterGraef | 0:f9b6112278fe | 86 | * Set by the netif driver in its init function. |
DieterGraef | 0:f9b6112278fe | 87 | * Used to check input packet types and use of DHCP. */ |
DieterGraef | 0:f9b6112278fe | 88 | #define NETIF_FLAG_ETHARP 0x20U |
DieterGraef | 0:f9b6112278fe | 89 | /** If set, the netif is an ethernet device. It might not use |
DieterGraef | 0:f9b6112278fe | 90 | * ARP or TCP/IP if it is used for PPPoE only. |
DieterGraef | 0:f9b6112278fe | 91 | */ |
DieterGraef | 0:f9b6112278fe | 92 | #define NETIF_FLAG_ETHERNET 0x40U |
DieterGraef | 0:f9b6112278fe | 93 | /** If set, the netif has IGMP capability. |
DieterGraef | 0:f9b6112278fe | 94 | * Set by the netif driver in its init function. */ |
DieterGraef | 0:f9b6112278fe | 95 | #define NETIF_FLAG_IGMP 0x80U |
DieterGraef | 0:f9b6112278fe | 96 | |
DieterGraef | 0:f9b6112278fe | 97 | /** Function prototype for netif init functions. Set up flags and output/linkoutput |
DieterGraef | 0:f9b6112278fe | 98 | * callback functions in this function. |
DieterGraef | 0:f9b6112278fe | 99 | * |
DieterGraef | 0:f9b6112278fe | 100 | * @param netif The netif to initialize |
DieterGraef | 0:f9b6112278fe | 101 | */ |
DieterGraef | 0:f9b6112278fe | 102 | typedef err_t (*netif_init_fn)(struct netif *netif); |
DieterGraef | 0:f9b6112278fe | 103 | /** Function prototype for netif->input functions. This function is saved as 'input' |
DieterGraef | 0:f9b6112278fe | 104 | * callback function in the netif struct. Call it when a packet has been received. |
DieterGraef | 0:f9b6112278fe | 105 | * |
DieterGraef | 0:f9b6112278fe | 106 | * @param p The received packet, copied into a pbuf |
DieterGraef | 0:f9b6112278fe | 107 | * @param inp The netif which received the packet |
DieterGraef | 0:f9b6112278fe | 108 | */ |
DieterGraef | 0:f9b6112278fe | 109 | typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp); |
DieterGraef | 0:f9b6112278fe | 110 | /** Function prototype for netif->output functions. Called by lwIP when a packet |
DieterGraef | 0:f9b6112278fe | 111 | * shall be sent. For ethernet netif, set this to 'etharp_output' and set |
DieterGraef | 0:f9b6112278fe | 112 | * 'linkoutput'. |
DieterGraef | 0:f9b6112278fe | 113 | * |
DieterGraef | 0:f9b6112278fe | 114 | * @param netif The netif which shall send a packet |
DieterGraef | 0:f9b6112278fe | 115 | * @param p The packet to send (p->payload points to IP header) |
DieterGraef | 0:f9b6112278fe | 116 | * @param ipaddr The IP address to which the packet shall be sent |
DieterGraef | 0:f9b6112278fe | 117 | */ |
DieterGraef | 0:f9b6112278fe | 118 | typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p, |
DieterGraef | 0:f9b6112278fe | 119 | ip_addr_t *ipaddr); |
DieterGraef | 0:f9b6112278fe | 120 | /** Function prototype for netif->linkoutput functions. Only used for ethernet |
DieterGraef | 0:f9b6112278fe | 121 | * netifs. This function is called by ARP when a packet shall be sent. |
DieterGraef | 0:f9b6112278fe | 122 | * |
DieterGraef | 0:f9b6112278fe | 123 | * @param netif The netif which shall send a packet |
DieterGraef | 0:f9b6112278fe | 124 | * @param p The packet to send (raw ethernet packet) |
DieterGraef | 0:f9b6112278fe | 125 | */ |
DieterGraef | 0:f9b6112278fe | 126 | typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p); |
DieterGraef | 0:f9b6112278fe | 127 | /** Function prototype for netif status- or link-callback functions. */ |
DieterGraef | 0:f9b6112278fe | 128 | typedef void (*netif_status_callback_fn)(struct netif *netif); |
DieterGraef | 0:f9b6112278fe | 129 | /** Function prototype for netif igmp_mac_filter functions */ |
DieterGraef | 0:f9b6112278fe | 130 | typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif, |
DieterGraef | 0:f9b6112278fe | 131 | ip_addr_t *group, u8_t action); |
DieterGraef | 0:f9b6112278fe | 132 | |
DieterGraef | 0:f9b6112278fe | 133 | /** Generic data structure used for all lwIP network interfaces. |
DieterGraef | 0:f9b6112278fe | 134 | * The following fields should be filled in by the initialization |
DieterGraef | 0:f9b6112278fe | 135 | * function for the device driver: hwaddr_len, hwaddr[], mtu, flags */ |
DieterGraef | 0:f9b6112278fe | 136 | struct netif { |
DieterGraef | 0:f9b6112278fe | 137 | /** pointer to next in linked list */ |
DieterGraef | 0:f9b6112278fe | 138 | struct netif *next; |
DieterGraef | 0:f9b6112278fe | 139 | |
DieterGraef | 0:f9b6112278fe | 140 | /** IP address configuration in network byte order */ |
DieterGraef | 0:f9b6112278fe | 141 | ip_addr_t ip_addr; |
DieterGraef | 0:f9b6112278fe | 142 | ip_addr_t netmask; |
DieterGraef | 0:f9b6112278fe | 143 | ip_addr_t gw; |
DieterGraef | 0:f9b6112278fe | 144 | |
DieterGraef | 0:f9b6112278fe | 145 | /** This function is called by the network device driver |
DieterGraef | 0:f9b6112278fe | 146 | * to pass a packet up the TCP/IP stack. */ |
DieterGraef | 0:f9b6112278fe | 147 | netif_input_fn input; |
DieterGraef | 0:f9b6112278fe | 148 | /** This function is called by the IP module when it wants |
DieterGraef | 0:f9b6112278fe | 149 | * to send a packet on the interface. This function typically |
DieterGraef | 0:f9b6112278fe | 150 | * first resolves the hardware address, then sends the packet. */ |
DieterGraef | 0:f9b6112278fe | 151 | netif_output_fn output; |
DieterGraef | 0:f9b6112278fe | 152 | /** This function is called by the ARP module when it wants |
DieterGraef | 0:f9b6112278fe | 153 | * to send a packet on the interface. This function outputs |
DieterGraef | 0:f9b6112278fe | 154 | * the pbuf as-is on the link medium. */ |
DieterGraef | 0:f9b6112278fe | 155 | netif_linkoutput_fn linkoutput; |
DieterGraef | 0:f9b6112278fe | 156 | #if LWIP_NETIF_STATUS_CALLBACK |
DieterGraef | 0:f9b6112278fe | 157 | /** This function is called when the netif state is set to up or down |
DieterGraef | 0:f9b6112278fe | 158 | */ |
DieterGraef | 0:f9b6112278fe | 159 | netif_status_callback_fn status_callback; |
DieterGraef | 0:f9b6112278fe | 160 | #endif /* LWIP_NETIF_STATUS_CALLBACK */ |
DieterGraef | 0:f9b6112278fe | 161 | #if LWIP_NETIF_LINK_CALLBACK |
DieterGraef | 0:f9b6112278fe | 162 | /** This function is called when the netif link is set to up or down |
DieterGraef | 0:f9b6112278fe | 163 | */ |
DieterGraef | 0:f9b6112278fe | 164 | netif_status_callback_fn link_callback; |
DieterGraef | 0:f9b6112278fe | 165 | #endif /* LWIP_NETIF_LINK_CALLBACK */ |
DieterGraef | 0:f9b6112278fe | 166 | #if LWIP_NETIF_REMOVE_CALLBACK |
DieterGraef | 0:f9b6112278fe | 167 | /** This function is called when the netif has been removed */ |
DieterGraef | 0:f9b6112278fe | 168 | netif_status_callback_fn remove_callback; |
DieterGraef | 0:f9b6112278fe | 169 | #endif /* LWIP_NETIF_REMOVE_CALLBACK */ |
DieterGraef | 0:f9b6112278fe | 170 | /** This field can be set by the device driver and could point |
DieterGraef | 0:f9b6112278fe | 171 | * to state information for the device. */ |
DieterGraef | 0:f9b6112278fe | 172 | void *state; |
DieterGraef | 0:f9b6112278fe | 173 | #if LWIP_DHCP |
DieterGraef | 0:f9b6112278fe | 174 | /** the DHCP client state information for this netif */ |
DieterGraef | 0:f9b6112278fe | 175 | struct dhcp *dhcp; |
DieterGraef | 0:f9b6112278fe | 176 | #endif /* LWIP_DHCP */ |
DieterGraef | 0:f9b6112278fe | 177 | #if LWIP_AUTOIP |
DieterGraef | 0:f9b6112278fe | 178 | /** the AutoIP client state information for this netif */ |
DieterGraef | 0:f9b6112278fe | 179 | struct autoip *autoip; |
DieterGraef | 0:f9b6112278fe | 180 | #endif |
DieterGraef | 0:f9b6112278fe | 181 | #if LWIP_NETIF_HOSTNAME |
DieterGraef | 0:f9b6112278fe | 182 | /* the hostname for this netif, NULL is a valid value */ |
DieterGraef | 0:f9b6112278fe | 183 | char* hostname; |
DieterGraef | 0:f9b6112278fe | 184 | #endif /* LWIP_NETIF_HOSTNAME */ |
DieterGraef | 0:f9b6112278fe | 185 | /** maximum transfer unit (in bytes) */ |
DieterGraef | 0:f9b6112278fe | 186 | u16_t mtu; |
DieterGraef | 0:f9b6112278fe | 187 | /** number of bytes used in hwaddr */ |
DieterGraef | 0:f9b6112278fe | 188 | u8_t hwaddr_len; |
DieterGraef | 0:f9b6112278fe | 189 | /** link level hardware address of this interface */ |
DieterGraef | 0:f9b6112278fe | 190 | u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; |
DieterGraef | 0:f9b6112278fe | 191 | /** flags (see NETIF_FLAG_ above) */ |
DieterGraef | 0:f9b6112278fe | 192 | u8_t flags; |
DieterGraef | 0:f9b6112278fe | 193 | /** descriptive abbreviation */ |
DieterGraef | 0:f9b6112278fe | 194 | char name[2]; |
DieterGraef | 0:f9b6112278fe | 195 | /** number of this interface */ |
DieterGraef | 0:f9b6112278fe | 196 | u8_t num; |
DieterGraef | 0:f9b6112278fe | 197 | #if LWIP_SNMP |
DieterGraef | 0:f9b6112278fe | 198 | /** link type (from "snmp_ifType" enum from snmp.h) */ |
DieterGraef | 0:f9b6112278fe | 199 | u8_t link_type; |
DieterGraef | 0:f9b6112278fe | 200 | /** (estimate) link speed */ |
DieterGraef | 0:f9b6112278fe | 201 | u32_t link_speed; |
DieterGraef | 0:f9b6112278fe | 202 | /** timestamp at last change made (up/down) */ |
DieterGraef | 0:f9b6112278fe | 203 | u32_t ts; |
DieterGraef | 0:f9b6112278fe | 204 | /** counters */ |
DieterGraef | 0:f9b6112278fe | 205 | u32_t ifinoctets; |
DieterGraef | 0:f9b6112278fe | 206 | u32_t ifinucastpkts; |
DieterGraef | 0:f9b6112278fe | 207 | u32_t ifinnucastpkts; |
DieterGraef | 0:f9b6112278fe | 208 | u32_t ifindiscards; |
DieterGraef | 0:f9b6112278fe | 209 | u32_t ifoutoctets; |
DieterGraef | 0:f9b6112278fe | 210 | u32_t ifoutucastpkts; |
DieterGraef | 0:f9b6112278fe | 211 | u32_t ifoutnucastpkts; |
DieterGraef | 0:f9b6112278fe | 212 | u32_t ifoutdiscards; |
DieterGraef | 0:f9b6112278fe | 213 | #endif /* LWIP_SNMP */ |
DieterGraef | 0:f9b6112278fe | 214 | #if LWIP_IGMP |
DieterGraef | 0:f9b6112278fe | 215 | /** This function could be called to add or delete a entry in the multicast |
DieterGraef | 0:f9b6112278fe | 216 | filter table of the ethernet MAC.*/ |
DieterGraef | 0:f9b6112278fe | 217 | netif_igmp_mac_filter_fn igmp_mac_filter; |
DieterGraef | 0:f9b6112278fe | 218 | #endif /* LWIP_IGMP */ |
DieterGraef | 0:f9b6112278fe | 219 | #if LWIP_NETIF_HWADDRHINT |
DieterGraef | 0:f9b6112278fe | 220 | u8_t *addr_hint; |
DieterGraef | 0:f9b6112278fe | 221 | #endif /* LWIP_NETIF_HWADDRHINT */ |
DieterGraef | 0:f9b6112278fe | 222 | #if ENABLE_LOOPBACK |
DieterGraef | 0:f9b6112278fe | 223 | /* List of packets to be queued for ourselves. */ |
DieterGraef | 0:f9b6112278fe | 224 | struct pbuf *loop_first; |
DieterGraef | 0:f9b6112278fe | 225 | struct pbuf *loop_last; |
DieterGraef | 0:f9b6112278fe | 226 | #if LWIP_LOOPBACK_MAX_PBUFS |
DieterGraef | 0:f9b6112278fe | 227 | u16_t loop_cnt_current; |
DieterGraef | 0:f9b6112278fe | 228 | #endif /* LWIP_LOOPBACK_MAX_PBUFS */ |
DieterGraef | 0:f9b6112278fe | 229 | #endif /* ENABLE_LOOPBACK */ |
DieterGraef | 0:f9b6112278fe | 230 | }; |
DieterGraef | 0:f9b6112278fe | 231 | |
DieterGraef | 0:f9b6112278fe | 232 | #if LWIP_SNMP |
DieterGraef | 0:f9b6112278fe | 233 | #define NETIF_INIT_SNMP(netif, type, speed) \ |
DieterGraef | 0:f9b6112278fe | 234 | /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ |
DieterGraef | 0:f9b6112278fe | 235 | (netif)->link_type = (type); \ |
DieterGraef | 0:f9b6112278fe | 236 | /* your link speed here (units: bits per second) */ \ |
DieterGraef | 0:f9b6112278fe | 237 | (netif)->link_speed = (speed); \ |
DieterGraef | 0:f9b6112278fe | 238 | (netif)->ts = 0; \ |
DieterGraef | 0:f9b6112278fe | 239 | (netif)->ifinoctets = 0; \ |
DieterGraef | 0:f9b6112278fe | 240 | (netif)->ifinucastpkts = 0; \ |
DieterGraef | 0:f9b6112278fe | 241 | (netif)->ifinnucastpkts = 0; \ |
DieterGraef | 0:f9b6112278fe | 242 | (netif)->ifindiscards = 0; \ |
DieterGraef | 0:f9b6112278fe | 243 | (netif)->ifoutoctets = 0; \ |
DieterGraef | 0:f9b6112278fe | 244 | (netif)->ifoutucastpkts = 0; \ |
DieterGraef | 0:f9b6112278fe | 245 | (netif)->ifoutnucastpkts = 0; \ |
DieterGraef | 0:f9b6112278fe | 246 | (netif)->ifoutdiscards = 0 |
DieterGraef | 0:f9b6112278fe | 247 | #else /* LWIP_SNMP */ |
DieterGraef | 0:f9b6112278fe | 248 | #define NETIF_INIT_SNMP(netif, type, speed) |
DieterGraef | 0:f9b6112278fe | 249 | #endif /* LWIP_SNMP */ |
DieterGraef | 0:f9b6112278fe | 250 | |
DieterGraef | 0:f9b6112278fe | 251 | |
DieterGraef | 0:f9b6112278fe | 252 | /** The list of network interfaces. */ |
DieterGraef | 0:f9b6112278fe | 253 | extern struct netif *netif_list; |
DieterGraef | 0:f9b6112278fe | 254 | /** The default network interface. */ |
DieterGraef | 0:f9b6112278fe | 255 | extern struct netif *netif_default; |
DieterGraef | 0:f9b6112278fe | 256 | |
DieterGraef | 0:f9b6112278fe | 257 | void netif_init(void); |
DieterGraef | 0:f9b6112278fe | 258 | |
DieterGraef | 0:f9b6112278fe | 259 | struct netif *netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, |
DieterGraef | 0:f9b6112278fe | 260 | ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input); |
DieterGraef | 0:f9b6112278fe | 261 | |
DieterGraef | 0:f9b6112278fe | 262 | void |
DieterGraef | 0:f9b6112278fe | 263 | netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, |
DieterGraef | 0:f9b6112278fe | 264 | ip_addr_t *gw); |
DieterGraef | 0:f9b6112278fe | 265 | void netif_remove(struct netif * netif); |
DieterGraef | 0:f9b6112278fe | 266 | |
DieterGraef | 0:f9b6112278fe | 267 | /* Returns a network interface given its name. The name is of the form |
DieterGraef | 0:f9b6112278fe | 268 | "et0", where the first two letters are the "name" field in the |
DieterGraef | 0:f9b6112278fe | 269 | netif structure, and the digit is in the num field in the same |
DieterGraef | 0:f9b6112278fe | 270 | structure. */ |
DieterGraef | 0:f9b6112278fe | 271 | struct netif *netif_find(char *name); |
DieterGraef | 0:f9b6112278fe | 272 | |
DieterGraef | 0:f9b6112278fe | 273 | void netif_set_default(struct netif *netif); |
DieterGraef | 0:f9b6112278fe | 274 | |
DieterGraef | 0:f9b6112278fe | 275 | void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr); |
DieterGraef | 0:f9b6112278fe | 276 | void netif_set_netmask(struct netif *netif, ip_addr_t *netmask); |
DieterGraef | 0:f9b6112278fe | 277 | void netif_set_gw(struct netif *netif, ip_addr_t *gw); |
DieterGraef | 0:f9b6112278fe | 278 | |
DieterGraef | 0:f9b6112278fe | 279 | void netif_set_up(struct netif *netif); |
DieterGraef | 0:f9b6112278fe | 280 | void netif_set_down(struct netif *netif); |
DieterGraef | 0:f9b6112278fe | 281 | /** Ask if an interface is up */ |
DieterGraef | 0:f9b6112278fe | 282 | #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) |
DieterGraef | 0:f9b6112278fe | 283 | |
DieterGraef | 0:f9b6112278fe | 284 | #if LWIP_NETIF_STATUS_CALLBACK |
DieterGraef | 0:f9b6112278fe | 285 | void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback); |
DieterGraef | 0:f9b6112278fe | 286 | #endif /* LWIP_NETIF_STATUS_CALLBACK */ |
DieterGraef | 0:f9b6112278fe | 287 | #if LWIP_NETIF_REMOVE_CALLBACK |
DieterGraef | 0:f9b6112278fe | 288 | void netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback); |
DieterGraef | 0:f9b6112278fe | 289 | #endif /* LWIP_NETIF_REMOVE_CALLBACK */ |
DieterGraef | 0:f9b6112278fe | 290 | |
DieterGraef | 0:f9b6112278fe | 291 | void netif_set_link_up(struct netif *netif); |
DieterGraef | 0:f9b6112278fe | 292 | void netif_set_link_down(struct netif *netif); |
DieterGraef | 0:f9b6112278fe | 293 | /** Ask if a link is up */ |
DieterGraef | 0:f9b6112278fe | 294 | #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) |
DieterGraef | 0:f9b6112278fe | 295 | |
DieterGraef | 0:f9b6112278fe | 296 | #if LWIP_NETIF_LINK_CALLBACK |
DieterGraef | 0:f9b6112278fe | 297 | void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback); |
DieterGraef | 0:f9b6112278fe | 298 | #endif /* LWIP_NETIF_LINK_CALLBACK */ |
DieterGraef | 0:f9b6112278fe | 299 | |
DieterGraef | 0:f9b6112278fe | 300 | #if LWIP_NETIF_HOSTNAME |
DieterGraef | 0:f9b6112278fe | 301 | #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) |
DieterGraef | 0:f9b6112278fe | 302 | #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) |
DieterGraef | 0:f9b6112278fe | 303 | #endif /* LWIP_NETIF_HOSTNAME */ |
DieterGraef | 0:f9b6112278fe | 304 | |
DieterGraef | 0:f9b6112278fe | 305 | #if LWIP_IGMP |
DieterGraef | 0:f9b6112278fe | 306 | #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) |
DieterGraef | 0:f9b6112278fe | 307 | #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) |
DieterGraef | 0:f9b6112278fe | 308 | #endif /* LWIP_IGMP */ |
DieterGraef | 0:f9b6112278fe | 309 | |
DieterGraef | 0:f9b6112278fe | 310 | #if ENABLE_LOOPBACK |
DieterGraef | 0:f9b6112278fe | 311 | err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip); |
DieterGraef | 0:f9b6112278fe | 312 | void netif_poll(struct netif *netif); |
DieterGraef | 0:f9b6112278fe | 313 | #if !LWIP_NETIF_LOOPBACK_MULTITHREADING |
DieterGraef | 0:f9b6112278fe | 314 | void netif_poll_all(void); |
DieterGraef | 0:f9b6112278fe | 315 | #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ |
DieterGraef | 0:f9b6112278fe | 316 | #endif /* ENABLE_LOOPBACK */ |
DieterGraef | 0:f9b6112278fe | 317 | |
DieterGraef | 0:f9b6112278fe | 318 | #if LWIP_NETIF_HWADDRHINT |
DieterGraef | 0:f9b6112278fe | 319 | #define NETIF_SET_HWADDRHINT(netif, hint) ((netif)->addr_hint = (hint)) |
DieterGraef | 0:f9b6112278fe | 320 | #else /* LWIP_NETIF_HWADDRHINT */ |
DieterGraef | 0:f9b6112278fe | 321 | #define NETIF_SET_HWADDRHINT(netif, hint) |
DieterGraef | 0:f9b6112278fe | 322 | #endif /* LWIP_NETIF_HWADDRHINT */ |
DieterGraef | 0:f9b6112278fe | 323 | |
DieterGraef | 0:f9b6112278fe | 324 | #ifdef __cplusplus |
DieterGraef | 0:f9b6112278fe | 325 | } |
DieterGraef | 0:f9b6112278fe | 326 | #endif |
DieterGraef | 0:f9b6112278fe | 327 | |
DieterGraef | 0:f9b6112278fe | 328 | #endif /* __LWIP_NETIF_H__ */ |