62 #if LWIP_ARP || LWIP_ETHERNET 73 #include "netif/ppp/ppp_opts.h" 75 #include "netif/ppp/pppoe.h" 78 #ifdef LWIP_HOOK_FILENAME 79 #include LWIP_HOOK_FILENAME 82 const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}};
83 const struct eth_addr ethzero = {{0,0,0,0,0,0}};
104 #if LWIP_ARP || ETHARP_SUPPORT_VLAN || LWIP_IPV6 105 s16_t ip_hdr_offset = SIZEOF_ETH_HDR;
108 if (p->
len <= SIZEOF_ETH_HDR) {
110 ETHARP_STATS_INC(etharp.proterr);
111 ETHARP_STATS_INC(etharp.drop);
112 MIB2_STATS_NETIF_INC(netif, ifinerrors);
113 goto free_and_return;
119 (
"ethernet_input: dest:%"X8_F
":%"X8_F
":%"X8_F
":%"X8_F
":%"X8_F
":%"X8_F
", src:%"X8_F
":%"X8_F
":%"X8_F
":%"X8_F
":%"X8_F
":%"X8_F
", type:%"X16_F
"\n",
120 (
unsigned)ethhdr->dest.addr[0], (
unsigned)ethhdr->dest.addr[1], (
unsigned)ethhdr->dest.addr[2],
121 (
unsigned)ethhdr->dest.addr[3], (
unsigned)ethhdr->dest.addr[4], (
unsigned)ethhdr->dest.addr[5],
122 (
unsigned)ethhdr->src.addr[0], (
unsigned)ethhdr->src.addr[1], (
unsigned)ethhdr->src.addr[2],
123 (
unsigned)ethhdr->src.addr[3], (
unsigned)ethhdr->src.addr[4], (
unsigned)ethhdr->src.addr[5],
124 lwip_htons(ethhdr->type)));
127 #if ETHARP_SUPPORT_VLAN 130 if (p->
len <= SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR) {
132 ETHARP_STATS_INC(etharp.proterr);
133 ETHARP_STATS_INC(etharp.drop);
134 MIB2_STATS_NETIF_INC(netif, ifinerrors);
135 goto free_and_return;
137 #if defined(LWIP_HOOK_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK_FN) 138 #ifdef LWIP_HOOK_VLAN_CHECK 139 if (!LWIP_HOOK_VLAN_CHECK(netif, ethhdr, vlan)) {
140 #elif defined(ETHARP_VLAN_CHECK_FN) 141 if (!ETHARP_VLAN_CHECK_FN(ethhdr, vlan)) {
142 #elif defined(ETHARP_VLAN_CHECK) 143 if (VLAN_ID(vlan) != ETHARP_VLAN_CHECK) {
151 ip_hdr_offset = SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR;
155 #if LWIP_ARP_FILTER_NETIF 156 netif = LWIP_ARP_FILTER_NETIF_FN(p, netif, lwip_htons(type));
159 if (ethhdr->dest.addr[0] & 1) {
163 if ((ethhdr->dest.addr[1] == LL_IP4_MULTICAST_ADDR_1) &&
164 (ethhdr->dest.addr[2] == LL_IP4_MULTICAST_ADDR_2)) {
172 (ethhdr->dest.addr[1] == LL_IP6_MULTICAST_ADDR_1)) {
177 else if (eth_addr_cmp(ðhdr->dest, ðbroadcast)) {
184 #if LWIP_IPV4 && LWIP_ARP 188 goto free_and_return;
191 if ((p->
len < ip_hdr_offset) ||
pbuf_header(p, (s16_t)-ip_hdr_offset)) {
193 (
"ethernet_input: IPv4 packet dropped, too short (%"S16_F
"/%"S16_F
")\n",
196 goto free_and_return;
205 goto free_and_return;
208 if ((p->
len < ip_hdr_offset) ||
pbuf_header(p, (s16_t)-ip_hdr_offset)) {
210 (
"ethernet_input: ARP response packet dropped, too short (%"S16_F
"/%"S16_F
")\n",
213 ETHARP_STATS_INC(etharp.lenerr);
214 ETHARP_STATS_INC(etharp.drop);
215 goto free_and_return;
218 etharp_input(p, netif);
224 pppoe_disc_input(netif, p);
228 pppoe_data_input(netif, p);
235 if ((p->len < ip_hdr_offset) ||
pbuf_header(p, (s16_t)-ip_hdr_offset)) {
237 (
"ethernet_input: IPv6 packet dropped, too short (%"S16_F
"/%"S16_F
")\n",
239 goto free_and_return;
248 #ifdef LWIP_HOOK_UNKNOWN_ETH_PROTOCOL 249 if(LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(p, netif) ==
ERR_OK) {
253 ETHARP_STATS_INC(etharp.proterr);
254 ETHARP_STATS_INC(etharp.drop);
255 MIB2_STATS_NETIF_INC(netif, ifinunknownprotos);
256 goto free_and_return;
283 ethernet_output(
struct netif* netif,
struct pbuf* p,
288 u16_t eth_type_be = lwip_htons(eth_type);
290 #if ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) 291 s32_t vlan_prio_vid = LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type);
292 if (vlan_prio_vid >= 0) {
295 LWIP_ASSERT(
"prio_vid must be <= 0xFFFF", vlan_prio_vid <= 0xFFFF);
297 if (
pbuf_header(p, SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR) != 0) {
298 goto pbuf_header_failed;
301 vlanhdr->tpid = eth_type_be;
302 vlanhdr->prio_vid = lwip_htons((u16_t)vlan_prio_vid);
309 goto pbuf_header_failed;
314 ethhdr->type = eth_type_be;
318 LWIP_ASSERT(
"netif->hwaddr_len must be 6 for ethernet_output!",
321 (
"ethernet_output: sending packet %p\n", (
void *)p));
328 (
"ethernet_output: could not allocate room for header.\n"));
329 LINK_STATS_INC(link.lenerr);
u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment)
#define PBUF_FLAG_LLBCAST
#define LWIP_DBG_LEVEL_SERIOUS
#define ETHADDR32_COPY(dst, src)
#define PBUF_FLAG_LLMCAST
#define LWIP_DEBUGF(debug, message)
#define LWIP_DBG_LEVEL_WARNING
#define LL_IP4_MULTICAST_ADDR_0
#define NETIF_FLAG_ETHARP
u8_t pbuf_free(struct pbuf *p)
netif_linkoutput_fn linkoutput
#define LL_IP6_MULTICAST_ADDR_0
#define ETHADDR16_COPY(dst, src)