2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
27 * This file is part of the lwIP TCP/IP stack.
29 * Author: Adam Dunkels <adam@sics.se>
32 #ifndef __LWIP_NETIF_H__
33 #define __LWIP_NETIF_H__
39 #include "lwip/ip_addr.h"
41 #include "lwip/inet.h"
42 #include "lwip/pbuf.h"
44 # include "lwip/dhcp.h"
47 /** must be the maximum of all used hardware address lengths
48 across all types of interfaces in use */
49 #define NETIF_MAX_HWADDR_LEN 6U
51 /** TODO: define the use (where, when, whom) of netif flags */
53 /** whether the network interface is 'up'. this is
54 * a software flag used to control whether this network
55 * interface is enabled and processes traffic */
56 #define NETIF_FLAG_UP 0x1U
57 /** if set, the netif has broadcast capability */
58 #define NETIF_FLAG_BROADCAST 0x2U
59 /** if set, the netif is one end of a point-to-point connection */
60 #define NETIF_FLAG_POINTTOPOINT 0x4U
61 /** if set, the interface is configured using DHCP */
62 #define NETIF_FLAG_DHCP 0x08U
63 /** if set, the interface has an active link
64 * (set by the interface) */
65 #define NETIF_FLAG_LINK_UP 0x10U
67 /** generic data structure used for all lwIP network interfaces */
69 /** pointer to next in linked list */
71 /** The following fields should be filled in by the
72 initialization function for the device driver. */
74 /** IP address configuration in network byte order */
75 struct ip_addr ip_addr;
76 struct ip_addr netmask;
79 /** This function is called by the network device driver
80 to pass a packet up the TCP/IP stack. */
81 err_t (* input)(struct pbuf *p, struct netif *inp);
82 /** This function is called by the IP module when it wants
83 to send a packet on the interface. This function typically
84 first resolves the hardware address, then sends the packet. */
85 err_t (* output)(struct netif *netif, struct pbuf *p,
86 struct ip_addr *ipaddr);
87 /** This function is called by the ARP module when it wants
88 to send a packet on the interface. This function outputs
89 the pbuf as-is on the link medium. */
90 err_t (* linkoutput)(struct netif *netif, struct pbuf *p);
91 /** This field can be set by the device driver and could point
92 to state information for the device. */
95 /** the DHCP client state information for this netif */
98 /** number of bytes used in hwaddr */
99 unsigned char hwaddr_len;
100 /** link level hardware address of this interface */
101 unsigned char hwaddr[NETIF_MAX_HWADDR_LEN];
102 /** maximum transfer unit (in bytes) */
104 /** descriptive abbreviation */
106 /** number of this interface */
112 /** The list of network interfaces. */
113 extern struct netif *netif_list;
114 /** The default network interface. */
115 extern struct netif *netif_default;
117 /* netif_init() must be called first. */
118 void netif_init(void);
120 struct netif *netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
123 err_t (* init)(struct netif *netif),
124 err_t (* input)(struct pbuf *p, struct netif *netif));
127 netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
129 void netif_remove(struct netif * netif);
131 /* Returns a network interface given its name. The name is of the form
132 "et0", where the first two letters are the "name" field in the
133 netif structure, and the digit is in the num field in the same
135 struct netif *netif_find(char *name);
137 void netif_set_default(struct netif *netif);
139 void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr);
140 void netif_set_netmask(struct netif *netif, struct ip_addr *netmast);
141 void netif_set_gw(struct netif *netif, struct ip_addr *gw);
143 #endif /* __LWIP_NETIF_H__ */