ethernet: use switch instead of 'else if'

This patch uses a switch instead of a 'else if' series. It also
adds a debug message for unsupported ethernet type.
remotes/origin/master-1.0.x
Eric Leblond 16 years ago committed by Victor Julien
parent 6cf00d6204
commit c96586446b

@ -23,18 +23,30 @@ void DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *p
SCLogDebug("p %p pkt %p ether type %04x", p, pkt, ntohs(ethh->eth_type)); SCLogDebug("p %p pkt %p ether type %04x", p, pkt, ntohs(ethh->eth_type));
if (ntohs(ethh->eth_type) == ETHERNET_TYPE_IP) { switch (ntohs(ethh->eth_type)) {
case ETHERNET_TYPE_IP:
//printf("DecodeEthernet ip4\n"); //printf("DecodeEthernet ip4\n");
DecodeIPV4(tv, dtv, p, pkt + ETHERNET_HEADER_LEN, len - ETHERNET_HEADER_LEN, pq); DecodeIPV4(tv, dtv, p, pkt + ETHERNET_HEADER_LEN,
} else if(ntohs(ethh->eth_type) == ETHERNET_TYPE_IPV6) { len - ETHERNET_HEADER_LEN, pq);
break;
case ETHERNET_TYPE_IPV6:
//printf("DecodeEthernet ip6\n"); //printf("DecodeEthernet ip6\n");
DecodeIPV6(tv, dtv, p, pkt + ETHERNET_HEADER_LEN, len - ETHERNET_HEADER_LEN, pq); DecodeIPV6(tv, dtv, p, pkt + ETHERNET_HEADER_LEN,
} else if(ntohs(ethh->eth_type) == ETHERNET_TYPE_PPPOE_SESS) { len - ETHERNET_HEADER_LEN, pq);
break;
case ETHERNET_TYPE_PPPOE_SESS:
//printf("DecodeEthernet PPPOE Session\n"); //printf("DecodeEthernet PPPOE Session\n");
DecodePPPOESession(tv, dtv, p, pkt + ETHERNET_HEADER_LEN, len - ETHERNET_HEADER_LEN, pq); DecodePPPOESession(tv, dtv, p, pkt + ETHERNET_HEADER_LEN,
} else if(ntohs(ethh->eth_type) == ETHERNET_TYPE_PPPOE_DISC) { len - ETHERNET_HEADER_LEN, pq);
break;
case ETHERNET_TYPE_PPPOE_DISC:
//printf("DecodeEthernet PPPOE Discovery\n"); //printf("DecodeEthernet PPPOE Discovery\n");
DecodePPPOEDiscovery(tv, dtv, p, pkt + ETHERNET_HEADER_LEN, len - ETHERNET_HEADER_LEN, pq); DecodePPPOEDiscovery(tv, dtv, p, pkt + ETHERNET_HEADER_LEN,
len - ETHERNET_HEADER_LEN, pq);
break;
default:
SCLogDebug("p %p pkt %p ether type %04x not supported", p,
pkt, ntohs(ethh->eth_type));
} }
return; return;

Loading…
Cancel
Save