Rik Van Dyck / Mbed 2 deprecated Project_Embedded_C

Dependencies:   mbed DS1307 Servo TextLCD

Committer:
rikvandyck
Date:
Thu Dec 18 10:43:07 2014 +0000
Revision:
2:55b6fd49b738
Parent:
0:e1edd52b1ee2
Project_Embedded_C

Who changed what in which revision?

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