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