mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
ethernetif.c: implement SNMP counters, simplify input function: no need to check ethType, ethernet_input() already does this
This commit is contained in:
parent
8e8571da6a
commit
f09dec5fb7
@ -154,6 +154,16 @@ low_level_output(struct netif *netif, struct pbuf *p)
|
|||||||
|
|
||||||
signal that packet should be sent();
|
signal that packet should be sent();
|
||||||
|
|
||||||
|
MIB2_STATS_NETIF_ADD(netif, ifoutoctets, p->tot_len);
|
||||||
|
if (((u8_t*)p->payload)[0] & 1) {
|
||||||
|
/* broadcast or multicast packet*/
|
||||||
|
MIB2_STATS_NETIF_INC(netif, ifoutnucastpkts);
|
||||||
|
} else {
|
||||||
|
/* unicast packet */
|
||||||
|
MIB2_STATS_NETIF_INC(netif, ifoutucastpkts);
|
||||||
|
}
|
||||||
|
/* increase ifoutdiscards or ifouterrors on error */
|
||||||
|
|
||||||
#if ETH_PAD_SIZE
|
#if ETH_PAD_SIZE
|
||||||
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
|
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
|
||||||
#endif
|
#endif
|
||||||
@ -210,6 +220,14 @@ low_level_input(struct netif *netif)
|
|||||||
}
|
}
|
||||||
acknowledge that packet has been read();
|
acknowledge that packet has been read();
|
||||||
|
|
||||||
|
MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len);
|
||||||
|
if (((u8_t*)p->payload)[0] & 1) {
|
||||||
|
/* broadcast or multicast packet*/
|
||||||
|
MIB2_STATS_NETIF_INC(netif, ifinnucastpkts);
|
||||||
|
} else {
|
||||||
|
/* unicast packet*/
|
||||||
|
MIB2_STATS_NETIF_INC(netif, ifinucastpkts);
|
||||||
|
}
|
||||||
#if ETH_PAD_SIZE
|
#if ETH_PAD_SIZE
|
||||||
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
|
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
|
||||||
#endif
|
#endif
|
||||||
@ -219,6 +237,7 @@ low_level_input(struct netif *netif)
|
|||||||
drop packet();
|
drop packet();
|
||||||
LINK_STATS_INC(link.memerr);
|
LINK_STATS_INC(link.memerr);
|
||||||
LINK_STATS_INC(link.drop);
|
LINK_STATS_INC(link.drop);
|
||||||
|
MIB2_STATS_NETIF_INC(netif, ifindiscards);
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
@ -244,33 +263,14 @@ ethernetif_input(struct netif *netif)
|
|||||||
|
|
||||||
/* move received packet into a new pbuf */
|
/* move received packet into a new pbuf */
|
||||||
p = low_level_input(netif);
|
p = low_level_input(netif);
|
||||||
/* no packet could be read, silently ignore this */
|
/* if no packet could be read, silently ignore this */
|
||||||
if (p == NULL) return;
|
if (p != NULL) {
|
||||||
/* points to packet payload, which starts with an Ethernet header */
|
/* pass all packets to ethernet_input, which decides what packets it supports */
|
||||||
ethhdr = p->payload;
|
if (netif->input(p, netif) != ERR_OK) {
|
||||||
|
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
|
||||||
switch (htons(ethhdr->type)) {
|
pbuf_free(p);
|
||||||
/* IP or ARP packet? */
|
p = NULL;
|
||||||
case ETHTYPE_IP:
|
}
|
||||||
case ETHTYPE_IPV6:
|
|
||||||
case ETHTYPE_ARP:
|
|
||||||
#if PPPOE_SUPPORT
|
|
||||||
/* PPPoE packet? */
|
|
||||||
case ETHTYPE_PPPOEDISC:
|
|
||||||
case ETHTYPE_PPPOE:
|
|
||||||
#endif /* PPPOE_SUPPORT */
|
|
||||||
/* full packet send to tcpip_thread to process */
|
|
||||||
if (netif->input(p, netif)!=ERR_OK)
|
|
||||||
{ LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
|
|
||||||
pbuf_free(p);
|
|
||||||
p = NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
pbuf_free(p);
|
|
||||||
p = NULL;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user