root/webserver/example/freeRTOSexample/EnergyMeters/Common/ethernet/lwIP/include/lwip/netif.h

Revision 14, 6.0 kB (checked in by phil, 15 years ago)

added unmodified FreeRTOS package V5.4.1 with only web srv demo source for LPC2368 for CrossWorks?

Line 
1 /*
2  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
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.
15  *
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
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Adam Dunkels <adam@sics.se>
30  *
31  */
32 #ifndef __LWIP_NETIF_H__
33 #define __LWIP_NETIF_H__
34
35 #include "lwip/opt.h"
36
37 #include "lwip/err.h"
38
39 #include "lwip/ip_addr.h"
40
41 #include "lwip/inet.h"
42 #include "lwip/pbuf.h"
43 #if LWIP_DHCP
44 #  include "lwip/dhcp.h"
45 #endif
46
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
50
51 /** TODO: define the use (where, when, whom) of netif flags */
52
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  */
57 #define NETIF_FLAG_UP 0x1U
58 /** if set, the netif has broadcast capability */
59 #define NETIF_FLAG_BROADCAST 0x2U
60 /** if set, the netif is one end of a point-to-point connection */
61 #define NETIF_FLAG_POINTTOPOINT 0x4U
62 /** if set, the interface is configured using DHCP */
63 #define NETIF_FLAG_DHCP 0x08U
64 /** if set, the interface has an active link
65  *  (set by the network interface driver) */
66 #define NETIF_FLAG_LINK_UP 0x10U
67
68 /** Generic data structure used for all lwIP network interfaces.
69  *  The following fields should be filled in by the initialization
70  *  function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
71
72 struct netif {
73   /** pointer to next in linked list */
74   struct netif *next;
75
76   /** IP address configuration in network byte order */
77   struct ip_addr ip_addr;
78   struct ip_addr netmask;
79   struct ip_addr gw;
80
81   /** This function is called by the network device driver
82    *  to pass a packet up the TCP/IP stack. */
83   err_t (* input)(struct pbuf *p, struct netif *inp);
84   /** This function is called by the IP module when it wants
85    *  to send a packet on the interface. This function typically
86    *  first resolves the hardware address, then sends the packet. */
87   err_t (* output)(struct netif *netif, struct pbuf *p,
88        struct ip_addr *ipaddr);
89   /** This function is called by the ARP module when it wants
90    *  to send a packet on the interface. This function outputs
91    *  the pbuf as-is on the link medium. */
92   err_t (* linkoutput)(struct netif *netif, struct pbuf *p);
93   /** This field can be set by the device driver and could point
94    *  to state information for the device. */
95   void *state;
96 #if LWIP_DHCP
97   /** the DHCP client state information for this netif */
98   struct dhcp *dhcp;
99 #endif
100   /** number of bytes used in hwaddr */
101   u8_t hwaddr_len;
102   /** link level hardware address of this interface */
103   u8_t hwaddr[NETIF_MAX_HWADDR_LEN];
104   /** maximum transfer unit (in bytes) */
105   u16_t mtu;
106   /** flags (see NETIF_FLAG_ above) */
107   u8_t flags;
108   /** descriptive abbreviation */
109   char name[2];
110   /** number of this interface */
111   u8_t num;
112 #if LWIP_SNMP
113   /** link type (ifType values per RFC1213) */
114   u8_t link_type;
115   /** (estimate) link speed */
116   u32_t link_speed;
117   /** timestamp at last change made (up/down) */
118   u32_t ts;
119   /** counters */
120   u32_t ifinoctets;
121   u32_t ifinucastpkts;
122   u32_t ifinnucastpkts;
123   u32_t ifindiscards;
124   u32_t ifoutoctets;
125   u32_t ifoutucastpkts;
126   u32_t ifoutnucastpkts;
127   u32_t ifoutdiscards;
128 #endif
129 };
130
131 /** The list of network interfaces. */
132 extern struct netif *netif_list;
133 /** The default network interface. */
134 extern struct netif *netif_default;
135
136 /* netif_init() must be called first. */
137 void netif_init(void);
138
139 struct netif *netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
140       struct ip_addr *gw,
141       void *state,
142       err_t (* init)(struct netif *netif),
143       err_t (* input)(struct pbuf *p, struct netif *netif));
144
145 void
146 netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
147     struct ip_addr *gw);
148 void netif_remove(struct netif * netif);
149
150 /* Returns a network interface given its name. The name is of the form
151    "et0", where the first two letters are the "name" field in the
152    netif structure, and the digit is in the num field in the same
153    structure. */
154 struct netif *netif_find(char *name);
155
156 void netif_set_default(struct netif *netif);
157
158 void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr);
159 void netif_set_netmask(struct netif *netif, struct ip_addr *netmast);
160 void netif_set_gw(struct netif *netif, struct ip_addr *gw);
161 void netif_set_up(struct netif *netif);
162 void netif_set_down(struct netif *netif);
163 u8_t netif_is_up(struct netif *netif);
164
165 #endif /* __LWIP_NETIF_H__ */
Note: See TracBrowser for help on using the browser.