3 |
* Address Resolution Protocol module for IP over Ethernet |
* Address Resolution Protocol module for IP over Ethernet |
4 |
* |
* |
5 |
* $Log$ |
* $Log$ |
6 |
|
* Revision 1.5 2002/11/08 22:14:24 likewise |
7 |
|
* Fixed numerous bugs. Re-used etharp_query() in etharp_output(). Added comments and JavaDoc documentation. |
8 |
|
* |
9 |
* Revision 1.4 2002/11/08 12:54:43 proff_fs |
* Revision 1.4 2002/11/08 12:54:43 proff_fs |
10 |
* Added includeds for bpstruct and epstruct. |
* Added includeds for bpstruct and epstruct. |
11 |
* Ports should update from using PACK_STRUCT_BEGIN and PACK_STRUCT_END to use these includes. |
* Ports should update from using PACK_STRUCT_BEGIN and PACK_STRUCT_END to use these includes. |
58 |
#include "lwip/ip.h" |
#include "lwip/ip.h" |
59 |
#include "lwip/stats.h" |
#include "lwip/stats.h" |
60 |
|
|
61 |
#if LWIP_DHCP |
/* ARP needs to inform DHCP of any ARP replies? */ |
62 |
|
#if (LWIP_DHCP && DHPC_DOES_ARP_CHECK) |
63 |
# include "lwip/dhcp.h" |
# include "lwip/dhcp.h" |
64 |
#endif |
#endif |
65 |
|
|
66 |
|
/** the time an ARP entry stays valid after its last update */ |
67 |
#define ARP_MAXAGE 120 /* 120 * 10 seconds = 20 minutes. */ |
#define ARP_MAXAGE 120 /* 120 * 10 seconds = 20 minutes. */ |
68 |
|
/** the maximum time waiting for ARP reply to a ARP request */ |
69 |
#define ARP_MAXPENDING 2 /* 2 * 10 seconds = 20 seconds. */ |
#define ARP_MAXPENDING 2 /* 2 * 10 seconds = 20 seconds. */ |
70 |
|
|
71 |
#define HWTYPE_ETHERNET 1 |
#define HWTYPE_ETHERNET 1 |
72 |
|
|
73 |
|
/** ARP message types */ |
74 |
#define ARP_REQUEST 1 |
#define ARP_REQUEST 1 |
75 |
#define ARP_REPLY 2 |
#define ARP_REPLY 2 |
76 |
|
|
77 |
/* MUST be compiled with "pack structs" or equivalent! */ |
/* MUST be compiled with "pack structs" or equivalent! */ |
78 |
#include "arch/bpstruct.h" |
#ifdef PACK_STRUCT_USE_INCLUDES |
79 |
|
# include "arch/bpstruct.h" |
80 |
|
#endif |
81 |
PACK_STRUCT_BEGIN |
PACK_STRUCT_BEGIN |
82 |
|
/** the ARP message */ |
83 |
struct etharp_hdr { |
struct etharp_hdr { |
84 |
PACK_STRUCT_FIELD(struct eth_hdr ethhdr); |
PACK_STRUCT_FIELD(struct eth_hdr ethhdr); |
85 |
PACK_STRUCT_FIELD(u16_t hwtype); |
PACK_STRUCT_FIELD(u16_t hwtype); |
92 |
PACK_STRUCT_FIELD(struct ip_addr dipaddr); |
PACK_STRUCT_FIELD(struct ip_addr dipaddr); |
93 |
} PACK_STRUCT_STRUCT; |
} PACK_STRUCT_STRUCT; |
94 |
PACK_STRUCT_END |
PACK_STRUCT_END |
95 |
#include "arch/epstruct.h" |
#ifdef PACK_STRUCT_USE_INCLUDES |
96 |
|
# include "arch/epstruct.h" |
97 |
|
#endif |
98 |
|
|
99 |
#define ARPH_HWLEN(hdr) (NTOHS((hdr)->_hwlen_protolen) >> 8) |
#define ARPH_HWLEN(hdr) (NTOHS((hdr)->_hwlen_protolen) >> 8) |
100 |
#define ARPH_PROTOLEN(hdr) (NTOHS((hdr)->_hwlen_protolen) & 0xff) |
#define ARPH_PROTOLEN(hdr) (NTOHS((hdr)->_hwlen_protolen) & 0xff) |
101 |
|
|
|
|
|
102 |
#define ARPH_HWLEN_SET(hdr, len) (hdr)->_hwlen_protolen = HTONS(ARPH_PROTOLEN(hdr) | ((len) << 8)) |
#define ARPH_HWLEN_SET(hdr, len) (hdr)->_hwlen_protolen = HTONS(ARPH_PROTOLEN(hdr) | ((len) << 8)) |
103 |
#define ARPH_PROTOLEN_SET(hdr, len) (hdr)->_hwlen_protolen = HTONS((len) | (ARPH_HWLEN(hdr) << 8)) |
#define ARPH_PROTOLEN_SET(hdr, len) (hdr)->_hwlen_protolen = HTONS((len) | (ARPH_HWLEN(hdr) << 8)) |
104 |
|
|
105 |
#include "arch/bpstruct.h" |
/* MUST be compiled with "pack structs" or equivalent! */ |
106 |
|
#ifdef PACK_STRUCT_USE_INCLUDES |
107 |
|
# include "arch/bpstruct.h" |
108 |
|
#endif |
109 |
PACK_STRUCT_BEGIN |
PACK_STRUCT_BEGIN |
110 |
struct ethip_hdr { |
struct ethip_hdr { |
111 |
PACK_STRUCT_FIELD(struct eth_hdr eth); |
PACK_STRUCT_FIELD(struct eth_hdr eth); |
112 |
PACK_STRUCT_FIELD(struct ip_hdr ip); |
PACK_STRUCT_FIELD(struct ip_hdr ip); |
113 |
}; |
}; |
114 |
PACK_STRUCT_END |
PACK_STRUCT_END |
115 |
#include "arch/epstruct.h" |
#ifdef PACK_STRUCT_USE_INCLUDES |
116 |
|
# include "arch/epstruct.h" |
117 |
|
#endif |
118 |
|
|
119 |
enum etharp_state { |
enum etharp_state { |
120 |
ETHARP_STATE_EMPTY, |
ETHARP_STATE_EMPTY, |
127 |
struct eth_addr ethaddr; |
struct eth_addr ethaddr; |
128 |
enum etharp_state state; |
enum etharp_state state; |
129 |
struct pbuf *p; |
struct pbuf *p; |
|
void *payload; |
|
|
u16_t len, tot_len; |
|
130 |
u8_t ctime; |
u8_t ctime; |
131 |
}; |
}; |
132 |
|
|