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