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