00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __LWIP_NETIF_H__
00033 #define __LWIP_NETIF_H__
00034
00035 #include "lwip/opt.h"
00036
00037 #include "lwip/err.h"
00038
00039 #include "lwip/ip_addr.h"
00040
00041 #include "lwip/inet.h"
00042 #include "lwip/pbuf.h"
00043 #include "lwip/dhcp.h"
00044
00047 #define NETIF_MAX_HWADDR_LEN 6
00048
00052 #define NETIF_FLAG_UP 1U
00053
00054 #define NETIF_FLAG_BROADCAST 2U
00055
00056 #define NETIF_FLAG_POINTTOPOINT 4U
00057
00058 #define NETIF_FLAG_DHCP 8U
00059
00061 struct netif {
00063 struct netif *next;
00068 struct ip_addr ip_addr;
00069 struct ip_addr netmask;
00070 struct ip_addr gw;
00071
00074 err_t (* input)(struct pbuf *p, struct netif *inp);
00078 err_t (* output)(struct netif *netif, struct pbuf *p,
00079 struct ip_addr *ipaddr);
00083 err_t (* linkoutput)(struct netif *netif, struct pbuf *p);
00086 void *state;
00087 #if LWIP_DHCP
00088
00089 struct dhcp *dhcp;
00090 #endif
00091
00092 unsigned char hwaddr_len;
00094 unsigned char hwaddr[NETIF_MAX_HWADDR_LEN];
00096 u16_t mtu;
00098 char name[2];
00100 u8_t num;
00102 u8_t flags;
00103 };
00104
00106 extern struct netif *netif_list;
00108 extern struct netif *netif_default;
00109
00110
00111 void netif_init(void);
00112
00113 struct netif *netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
00114 struct ip_addr *gw,
00115 void *state,
00116 err_t (* init)(struct netif *netif),
00117 err_t (* input)(struct pbuf *p, struct netif *netif));
00118
00119 void
00120 netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
00121 struct ip_addr *gw);
00122 void netif_remove(struct netif * netif);
00123
00124
00125
00126
00127
00128 struct netif *netif_find(char *name);
00129
00130 void netif_set_default(struct netif *netif);
00131
00132 void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr);
00133 void netif_set_netmask(struct netif *netif, struct ip_addr *netmast);
00134 void netif_set_gw(struct netif *netif, struct ip_addr *gw);
00135
00136 #endif