Warning, cross-references for /kernel/include/netif/etharp.h need to be fixed.
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef __NETIF_ETHARP_H__
0036 #define __NETIF_ETHARP_H__
0037
0038 #include "lwip/opt.h"
0039
0040 #if LWIP_ARP
0041
0042 #include "lwip/pbuf.h"
0043 #include "lwip/ip_addr.h"
0044 #include "lwip/netif.h"
0045 #include "lwip/ip.h"
0046
0047 #ifdef __cplusplus
0048 extern "C" {
0049 #endif
0050
0051 #ifndef ETH_PAD_SIZE
0052 #define ETH_PAD_SIZE 0
0053 #endif
0054
0055 #ifndef ETHARP_HWADDR_LEN
0056 #define ETHARP_HWADDR_LEN 6
0057 #endif
0058
0059 #ifdef PACK_STRUCT_USE_INCLUDES
0060 # include "arch/bpstruct.h"
0061 #endif
0062 PACK_STRUCT_BEGIN
0063 struct eth_addr {
0064 PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]);
0065 } PACK_STRUCT_STRUCT;
0066 PACK_STRUCT_END
0067 #ifdef PACK_STRUCT_USE_INCLUDES
0068 # include "arch/epstruct.h"
0069 #endif
0070
0071 #ifdef PACK_STRUCT_USE_INCLUDES
0072 # include "arch/bpstruct.h"
0073 #endif
0074 PACK_STRUCT_BEGIN
0075 struct eth_hdr {
0076 #if ETH_PAD_SIZE
0077 PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
0078 #endif
0079 PACK_STRUCT_FIELD(struct eth_addr dest);
0080 PACK_STRUCT_FIELD(struct eth_addr src);
0081 PACK_STRUCT_FIELD(u16_t type);
0082 } PACK_STRUCT_STRUCT;
0083 PACK_STRUCT_END
0084 #ifdef PACK_STRUCT_USE_INCLUDES
0085 # include "arch/epstruct.h"
0086 #endif
0087
0088 #define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE)
0089
0090 #if ETHARP_SUPPORT_VLAN
0091
0092 #ifdef PACK_STRUCT_USE_INCLUDES
0093 # include "arch/bpstruct.h"
0094 #endif
0095 PACK_STRUCT_BEGIN
0096 struct eth_vlan_hdr {
0097 PACK_STRUCT_FIELD(u16_t tpid);
0098 PACK_STRUCT_FIELD(u16_t prio_vid);
0099 } PACK_STRUCT_STRUCT;
0100 PACK_STRUCT_END
0101 #ifdef PACK_STRUCT_USE_INCLUDES
0102 # include "arch/epstruct.h"
0103 #endif
0104
0105 #define SIZEOF_VLAN_HDR 4
0106 #define VLAN_ID(vlan_hdr) (htons((vlan_hdr)->prio_vid) & 0xFFF)
0107
0108 #endif
0109
0110 #ifdef PACK_STRUCT_USE_INCLUDES
0111 # include "arch/bpstruct.h"
0112 #endif
0113 PACK_STRUCT_BEGIN
0114
0115 struct etharp_hdr {
0116 PACK_STRUCT_FIELD(u16_t hwtype);
0117 PACK_STRUCT_FIELD(u16_t proto);
0118 PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
0119 PACK_STRUCT_FIELD(u16_t opcode);
0120 PACK_STRUCT_FIELD(struct eth_addr shwaddr);
0121 PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
0122 PACK_STRUCT_FIELD(struct eth_addr dhwaddr);
0123 PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);
0124 } PACK_STRUCT_STRUCT;
0125 PACK_STRUCT_END
0126 #ifdef PACK_STRUCT_USE_INCLUDES
0127 # include "arch/epstruct.h"
0128 #endif
0129
0130 #define SIZEOF_ETHARP_HDR 28
0131 #define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR)
0132
0133
0134 #define ARP_TMR_INTERVAL 5000
0135
0136 #define ETHTYPE_ARP 0x0806
0137 #define ETHTYPE_IP 0x0800
0138 #define ETHTYPE_VLAN 0x8100
0139 #define ETHTYPE_PPPOEDISC 0x8863
0140 #define ETHTYPE_PPPOE 0x8864
0141
0142
0143 #define ARP_REQUEST 1
0144 #define ARP_REPLY 2
0145
0146 #if ARP_QUEUEING
0147
0148
0149
0150 struct etharp_q_entry {
0151 struct etharp_q_entry *next;
0152 struct pbuf *p;
0153 };
0154 #endif
0155
0156 #define etharp_init()
0157 void etharp_tmr(void);
0158 s8_t etharp_find_addr(struct netif *netif, struct ip_addr *ipaddr,
0159 struct eth_addr **eth_ret, struct ip_addr **ip_ret);
0160 void etharp_ip_input(struct netif *netif, struct pbuf *p);
0161 void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,
0162 struct pbuf *p);
0163 err_t etharp_output(struct netif *netif, struct pbuf *q, struct ip_addr *ipaddr);
0164 err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
0165 err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr);
0166
0167
0168
0169
0170 #define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr)
0171
0172 err_t ethernet_input(struct pbuf *p, struct netif *netif);
0173
0174 #if LWIP_AUTOIP
0175 err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
0176 const struct eth_addr *ethdst_addr,
0177 const struct eth_addr *hwsrc_addr, const struct ip_addr *ipsrc_addr,
0178 const struct eth_addr *hwdst_addr, const struct ip_addr *ipdst_addr,
0179 const u16_t opcode);
0180 #endif
0181
0182 #define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0)
0183
0184 extern const struct eth_addr ethbroadcast, ethzero;
0185
0186 #ifdef __cplusplus
0187 }
0188 #endif
0189
0190 #endif
0191
0192 #endif