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
00033
00034
00035 #ifndef __NETIF_ETHARP_H__
00036 #define __NETIF_ETHARP_H__
00037
00038 #include "lwip/opt.h"
00039
00040 #if LWIP_ARP || LWIP_ETHERNET
00041
00042 #include "lwip/pbuf.h"
00043 #include "lwip/ip_addr.h"
00044 #include "lwip/netif.h"
00045 #include "lwip/ip.h"
00046
00047 #ifdef __cplusplus
00048 extern "C" {
00049 #endif
00050
00051 #ifndef ETHARP_HWADDR_LEN
00052 #define ETHARP_HWADDR_LEN 6
00053 #endif
00054
00055 #ifdef PACK_STRUCT_USE_INCLUDES
00056 # include "arch/bpstruct.h"
00057 #endif
00058 PACK_STRUCT_BEGIN
00059 struct eth_addr {
00060 PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]);
00061 } PACK_STRUCT_STRUCT;
00062 PACK_STRUCT_END
00063 #ifdef PACK_STRUCT_USE_INCLUDES
00064 # include "arch/epstruct.h"
00065 #endif
00066
00067 #ifdef PACK_STRUCT_USE_INCLUDES
00068 # include "arch/bpstruct.h"
00069 #endif
00070 PACK_STRUCT_BEGIN
00071
00072 struct eth_hdr {
00073 #if ETH_PAD_SIZE
00074 PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
00075 #endif
00076 PACK_STRUCT_FIELD(struct eth_addr dest);
00077 PACK_STRUCT_FIELD(struct eth_addr src);
00078 PACK_STRUCT_FIELD(u16_t type);
00079 } PACK_STRUCT_STRUCT;
00080 PACK_STRUCT_END
00081 #ifdef PACK_STRUCT_USE_INCLUDES
00082 # include "arch/epstruct.h"
00083 #endif
00084
00085 #define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE)
00086
00087 #if ETHARP_SUPPORT_VLAN
00088
00089 #ifdef PACK_STRUCT_USE_INCLUDES
00090 # include "arch/bpstruct.h"
00091 #endif
00092 PACK_STRUCT_BEGIN
00093
00094
00095
00096 struct eth_vlan_hdr {
00097 PACK_STRUCT_FIELD(u16_t prio_vid);
00098 PACK_STRUCT_FIELD(u16_t tpid);
00099 } PACK_STRUCT_STRUCT;
00100 PACK_STRUCT_END
00101 #ifdef PACK_STRUCT_USE_INCLUDES
00102 # include "arch/epstruct.h"
00103 #endif
00104
00105 #define SIZEOF_VLAN_HDR 4
00106 #define VLAN_ID(vlan_hdr) (htons((vlan_hdr)->prio_vid) & 0xFFF)
00107
00108 #endif
00109
00110 #ifdef PACK_STRUCT_USE_INCLUDES
00111 # include "arch/bpstruct.h"
00112 #endif
00113 PACK_STRUCT_BEGIN
00114
00115 struct etharp_hdr {
00116 PACK_STRUCT_FIELD(u16_t hwtype);
00117 PACK_STRUCT_FIELD(u16_t proto);
00118 PACK_STRUCT_FIELD(u8_t hwlen);
00119 PACK_STRUCT_FIELD(u8_t protolen);
00120 PACK_STRUCT_FIELD(u16_t opcode);
00121 PACK_STRUCT_FIELD(struct eth_addr shwaddr);
00122 PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
00123 PACK_STRUCT_FIELD(struct eth_addr dhwaddr);
00124 PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);
00125 } PACK_STRUCT_STRUCT;
00126 PACK_STRUCT_END
00127 #ifdef PACK_STRUCT_USE_INCLUDES
00128 # include "arch/epstruct.h"
00129 #endif
00130
00131 #define SIZEOF_ETHARP_HDR 28
00132 #define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR)
00133
00134
00135 #define ARP_TMR_INTERVAL 5000
00136
00137 #define ETHTYPE_ARP 0x0806U
00138 #define ETHTYPE_IP 0x0800U
00139 #define ETHTYPE_VLAN 0x8100U
00140 #define ETHTYPE_PPPOEDISC 0x8863U
00141 #define ETHTYPE_PPPOE 0x8864U
00142
00143
00144
00145 #ifndef ETHADDR32_COPY
00146 #define ETHADDR32_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN)
00147 #endif
00148
00149
00150
00151 #ifndef ETHADDR16_COPY
00152 #define ETHADDR16_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN)
00153 #endif
00154
00155 #if LWIP_ARP
00156
00157
00158 #define ARP_REQUEST 1
00159 #define ARP_REPLY 2
00160
00161
00162
00163
00164
00165
00166
00167 #ifndef LWIP_ARP_FILTER_NETIF
00168 #define LWIP_ARP_FILTER_NETIF 0
00169 #endif
00170
00171 #if ARP_QUEUEING
00172
00173
00174
00175 struct etharp_q_entry {
00176 struct etharp_q_entry *next;
00177 struct pbuf *p;
00178 };
00179 #endif
00180
00181 #define etharp_init()
00182 void etharp_tmr(void);
00183 s8_t etharp_find_addr(struct netif *netif, ip_addr_t *ipaddr,
00184 struct eth_addr **eth_ret, ip_addr_t **ip_ret);
00185 err_t etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr);
00186 err_t etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q);
00187 err_t etharp_request(struct netif *netif, ip_addr_t *ipaddr);
00188
00189
00190
00191
00192 #define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr)
00193 void etharp_cleanup_netif(struct netif *netif);
00194
00195 #if ETHARP_SUPPORT_STATIC_ENTRIES
00196 err_t etharp_add_static_entry(ip_addr_t *ipaddr, struct eth_addr *ethaddr);
00197 err_t etharp_remove_static_entry(ip_addr_t *ipaddr);
00198 #endif
00199
00200 #if LWIP_AUTOIP
00201 err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
00202 const struct eth_addr *ethdst_addr,
00203 const struct eth_addr *hwsrc_addr, const ip_addr_t *ipsrc_addr,
00204 const struct eth_addr *hwdst_addr, const ip_addr_t *ipdst_addr,
00205 const u16_t opcode);
00206 #endif
00207
00208 #endif
00209
00210 err_t ethernet_input(struct pbuf *p, struct netif *netif);
00211
00212 #define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0)
00213
00214 extern const struct eth_addr ethbroadcast, ethzero;
00215
00216 #endif
00217
00218 #ifdef __cplusplus
00219 }
00220 #endif
00221
00222 #endif