OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [ethernet/] [lwIP_132/] [src/] [include/] [lwip/] [netif.h] - Blame information for rev 606

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 606 jeremybenn
/*
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
#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)
38
 
39
#include "lwip/err.h"
40
 
41
#include "lwip/ip_addr.h"
42
 
43
#include "lwip/inet.h"
44
#include "lwip/pbuf.h"
45
#if LWIP_DHCP
46
struct dhcp;
47
#endif
48
#if LWIP_AUTOIP
49
struct autoip;
50
#endif
51
 
52
#ifdef __cplusplus
53
extern "C" {
54
#endif
55
 
56
/* Throughout this file, IP addresses are expected to be in
57
 * the same byte order as in IP_PCB. */
58
 
59
/** must be the maximum of all used hardware address lengths
60
    across all types of interfaces in use */
61
#define NETIF_MAX_HWADDR_LEN 6U
62
 
63
/** TODO: define the use (where, when, whom) of netif flags */
64
 
65
/** whether the network interface is 'up'. this is
66
 * a software flag used to control whether this network
67
 * interface is enabled and processes traffic.
68
 */
69
#define NETIF_FLAG_UP           0x01U
70
/** if set, the netif has broadcast capability */
71
#define NETIF_FLAG_BROADCAST    0x02U
72
/** if set, the netif is one end of a point-to-point connection */
73
#define NETIF_FLAG_POINTTOPOINT 0x04U
74
/** if set, the interface is configured using DHCP */
75
#define NETIF_FLAG_DHCP         0x08U
76
/** if set, the interface has an active link
77
 *  (set by the network interface driver) */
78
#define NETIF_FLAG_LINK_UP      0x10U
79
/** if set, the netif is an device using ARP */
80
#define NETIF_FLAG_ETHARP       0x20U
81
/** if set, the netif has IGMP capability */
82
#define NETIF_FLAG_IGMP         0x40U
83
 
84
/** Generic data structure used for all lwIP network interfaces.
85
 *  The following fields should be filled in by the initialization
86
 *  function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
87
 
88
struct netif {
89
  /** pointer to next in linked list */
90
  struct netif *next;
91
 
92
  /** IP address configuration in network byte order */
93
  struct ip_addr ip_addr;
94
  struct ip_addr netmask;
95
  struct ip_addr gw;
96
 
97
  /** This function is called by the network device driver
98
   *  to pass a packet up the TCP/IP stack. */
99
  err_t (* input)(struct pbuf *p, struct netif *inp);
100
  /** This function is called by the IP module when it wants
101
   *  to send a packet on the interface. This function typically
102
   *  first resolves the hardware address, then sends the packet. */
103
  err_t (* output)(struct netif *netif, struct pbuf *p,
104
       struct ip_addr *ipaddr);
105
  /** This function is called by the ARP module when it wants
106
   *  to send a packet on the interface. This function outputs
107
   *  the pbuf as-is on the link medium. */
108
  err_t (* linkoutput)(struct netif *netif, struct pbuf *p);
109
#if LWIP_NETIF_STATUS_CALLBACK
110
  /** This function is called when the netif state is set to up or down
111
   */
112
  void (* status_callback)(struct netif *netif);
113
#endif /* LWIP_NETIF_STATUS_CALLBACK */
114
#if LWIP_NETIF_LINK_CALLBACK
115
  /** This function is called when the netif link is set to up or down
116
   */
117
  void (* link_callback)(struct netif *netif);
118
#endif /* LWIP_NETIF_LINK_CALLBACK */
119
  /** This field can be set by the device driver and could point
120
   *  to state information for the device. */
121
  void *state;
122
#if LWIP_DHCP
123
  /** the DHCP client state information for this netif */
124
  struct dhcp *dhcp;
125
#endif /* LWIP_DHCP */
126
#if LWIP_AUTOIP
127
  /** the AutoIP client state information for this netif */
128
  struct autoip *autoip;
129
#endif
130
#if LWIP_NETIF_HOSTNAME
131
  /* the hostname for this netif, NULL is a valid value */
132
  char*  hostname;
133
#endif /* LWIP_NETIF_HOSTNAME */
134
  /** maximum transfer unit (in bytes) */
135
  u16_t mtu;
136
  /** number of bytes used in hwaddr */
137
  u8_t hwaddr_len;
138
  /** link level hardware address of this interface */
139
  u8_t hwaddr[NETIF_MAX_HWADDR_LEN];
140
  /** flags (see NETIF_FLAG_ above) */
141
  u8_t flags;
142
  /** descriptive abbreviation */
143
  char name[2];
144
  /** number of this interface */
145
  u8_t num;
146
#if LWIP_SNMP
147
  /** link type (from "snmp_ifType" enum from snmp.h) */
148
  u8_t link_type;
149
  /** (estimate) link speed */
150
  u32_t link_speed;
151
  /** timestamp at last change made (up/down) */
152
  u32_t ts;
153
  /** counters */
154
  u32_t ifinoctets;
155
  u32_t ifinucastpkts;
156
  u32_t ifinnucastpkts;
157
  u32_t ifindiscards;
158
  u32_t ifoutoctets;
159
  u32_t ifoutucastpkts;
160
  u32_t ifoutnucastpkts;
161
  u32_t ifoutdiscards;
162
#endif /* LWIP_SNMP */
163
#if LWIP_IGMP
164
  /* This function could be called to add or delete a entry in the multicast filter table of the ethernet MAC.*/
165
  err_t (*igmp_mac_filter)( struct netif *netif, struct ip_addr *group, u8_t action);
166
#endif /* LWIP_IGMP */
167
#if LWIP_NETIF_HWADDRHINT
168
  u8_t *addr_hint;
169
#endif /* LWIP_NETIF_HWADDRHINT */
170
#if ENABLE_LOOPBACK
171
  /* List of packets to be queued for ourselves. */
172
  struct pbuf *loop_first;
173
  struct pbuf *loop_last;
174
#if LWIP_LOOPBACK_MAX_PBUFS
175
  u16_t loop_cnt_current;
176
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
177
#endif /* ENABLE_LOOPBACK */
178
};
179
 
180
#if LWIP_SNMP
181
#define NETIF_INIT_SNMP(netif, type, speed) \
182
  /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \
183
  netif->link_type = type;    \
184
  /* your link speed here (units: bits per second) */  \
185
  netif->link_speed = speed;  \
186
  netif->ts = 0;              \
187
  netif->ifinoctets = 0;      \
188
  netif->ifinucastpkts = 0;   \
189
  netif->ifinnucastpkts = 0;  \
190
  netif->ifindiscards = 0;    \
191
  netif->ifoutoctets = 0;     \
192
  netif->ifoutucastpkts = 0;  \
193
  netif->ifoutnucastpkts = 0; \
194
  netif->ifoutdiscards = 0
195
#else /* LWIP_SNMP */
196
#define NETIF_INIT_SNMP(netif, type, speed)
197
#endif /* LWIP_SNMP */
198
 
199
 
200
/** The list of network interfaces. */
201
extern struct netif *netif_list;
202
/** The default network interface. */
203
extern struct netif *netif_default;
204
 
205
#define netif_init() /* Compatibility define, not init needed. */
206
 
207
struct netif *netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
208
      struct ip_addr *gw,
209
      void *state,
210
      err_t (* init)(struct netif *netif),
211
      err_t (* input)(struct pbuf *p, struct netif *netif));
212
 
213
void
214
netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
215
    struct ip_addr *gw);
216
void netif_remove(struct netif * netif);
217
 
218
/* Returns a network interface given its name. The name is of the form
219
   "et0", where the first two letters are the "name" field in the
220
   netif structure, and the digit is in the num field in the same
221
   structure. */
222
struct netif *netif_find(char *name);
223
 
224
void netif_set_default(struct netif *netif);
225
 
226
void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr);
227
void netif_set_netmask(struct netif *netif, struct ip_addr *netmask);
228
void netif_set_gw(struct netif *netif, struct ip_addr *gw);
229
 
230
void netif_set_up(struct netif *netif);
231
void netif_set_down(struct netif *netif);
232
u8_t netif_is_up(struct netif *netif);
233
 
234
#if LWIP_NETIF_STATUS_CALLBACK
235
/*
236
 * Set callback to be called when interface is brought up/down
237
 */
238
void netif_set_status_callback(struct netif *netif, void (* status_callback)(struct netif *netif));
239
#endif /* LWIP_NETIF_STATUS_CALLBACK */
240
 
241
#if LWIP_NETIF_LINK_CALLBACK
242
void netif_set_link_up(struct netif *netif);
243
void netif_set_link_down(struct netif *netif);
244
u8_t netif_is_link_up(struct netif *netif);
245
/*
246
 * Set callback to be called when link is brought up/down
247
 */
248
void netif_set_link_callback(struct netif *netif, void (* link_callback)(struct netif *netif));
249
#endif /* LWIP_NETIF_LINK_CALLBACK */
250
 
251
#ifdef __cplusplus
252
}
253
#endif
254
 
255
#if ENABLE_LOOPBACK
256
err_t netif_loop_output(struct netif *netif, struct pbuf *p, struct ip_addr *dest_ip);
257
void netif_poll(struct netif *netif);
258
#if !LWIP_NETIF_LOOPBACK_MULTITHREADING
259
void netif_poll_all(void);
260
#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
261
#endif /* ENABLE_LOOPBACK */
262
 
263
#endif /* __LWIP_NETIF_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.