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