32 |
#ifndef __LWIP_NETIF_H__ |
#ifndef __LWIP_NETIF_H__ |
33 |
#define __LWIP_NETIF_H__ |
#define __LWIP_NETIF_H__ |
34 |
|
|
35 |
|
#include "lwipopts.h" |
36 |
#include "lwip/opt.h" |
#include "lwip/opt.h" |
37 |
|
|
38 |
#include "lwip/err.h" |
#include "lwip/err.h" |
41 |
|
|
42 |
#include "lwip/inet.h" |
#include "lwip/inet.h" |
43 |
#include "lwip/pbuf.h" |
#include "lwip/pbuf.h" |
44 |
|
#include "lwip/dhcp.h" |
45 |
|
|
46 |
/** must be the maximum of all used hardware address lengths */ |
/** must be the maximum of all used hardware address lengths */ |
47 |
#define NETIF_HWADDR_LEN 6 |
#define NETIF_HWADDR_LEN 6 |
48 |
|
|
49 |
|
/** whether the network interface is 'up'. this is |
50 |
|
* a software flag used to control whether this network |
51 |
|
* interface is enabled. */ |
52 |
|
#define NETIFF_UP 1 |
53 |
|
/** if set, the netif has broadcast capability */ |
54 |
|
#define NETIFF_BROADCAST 2 |
55 |
|
/** if set, the netif is one end of a point-to-point connection */ |
56 |
|
#define NETIFF_POINTTOPOINT 4 |
57 |
|
/** if set, the interface is configured using DHCP */ |
58 |
|
#define NETIFF_DHCP 8 |
59 |
|
|
60 |
|
/** |
61 |
|
* generic data structure used for all lwIP network interfaces */ |
62 |
struct netif { |
struct netif { |
63 |
|
/** pointer to next in linked list */ |
64 |
struct netif *next; |
struct netif *next; |
65 |
|
/** The following two fields should be filled in by the |
66 |
|
initialization function for the device driver. */ |
67 |
|
char name[2]; |
68 |
|
/** number of this interface */ |
69 |
u8_t num; |
u8_t num; |
70 |
|
u8_t flags; |
71 |
|
/** maximum transfer unit (in bytes) */ |
72 |
u16_t mtu; |
u16_t mtu; |
73 |
|
|
74 |
struct ip_addr ip_addr; |
struct ip_addr ip_addr; |
75 |
struct ip_addr netmask; /* netmask in network byte order */ |
/** netmask in network byte order */ |
76 |
|
struct ip_addr netmask; |
77 |
struct ip_addr gw; |
struct ip_addr gw; |
|
unsigned char hwaddr[NETIF_HWADDR_LEN]; |
|
78 |
|
|
79 |
/* This function is called by the network device driver |
/** This function is called by the network device driver |
80 |
when it wants to pass a packet to the TCP/IP stack. */ |
to pass a packet up the TCP/IP stack. */ |
81 |
err_t (* input)(struct pbuf *p, struct netif *inp); |
err_t (* input)(struct pbuf *p, struct netif *inp); |
82 |
|
|
|
/** The following two fields should be filled in by the |
|
|
initialization function for the device driver. */ |
|
|
char name[2]; |
|
83 |
/** This function is called by the IP module when it wants |
/** This function is called by the IP module when it wants |
84 |
to send a packet on the interface. This function typically |
to send a packet on the interface. This function typically |
85 |
first resolves the hardware address, then sends the packet. */ |
first resolves the hardware address, then sends the packet. */ |
86 |
err_t (* output)(struct netif *netif, struct pbuf *p, |
err_t (* output)(struct netif *netif, struct pbuf *p, |
87 |
struct ip_addr *ipaddr); |
struct ip_addr *ipaddr); |
88 |
/** This function is called by the ARP module when it wants |
/** This function is called by the ARP module when it wants |
89 |
to send a packet on the interface. This function outputs |
to send a packet on the interface. This function outputs |
90 |
the pbuf on the link medium. */ |
the pbuf as-is on the link medium. */ |
91 |
err_t (* linkoutput)(struct netif *netif, struct pbuf *p); |
err_t (* linkoutput)(struct netif *netif, struct pbuf *p); |
|
|
|
92 |
/** This field can be set by the device driver and could point |
/** This field can be set by the device driver and could point |
93 |
to state information for the device. */ |
to state information for the device. */ |
94 |
void *state; |
void *state; |
95 |
|
struct dhcp_state *dhcp; |
96 |
|
/** link level hardware address of this interface */ |
97 |
|
unsigned char hwaddr[NETIF_HWADDR_LEN]; |
98 |
}; |
}; |
99 |
|
|
100 |
/** The list of network interfaces. */ |
/** The list of network interfaces. */ |