You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
suricata/src/decode-ethernet.c

39 lines
1.2 KiB
C

/* Copyright (c) 2009 Victor Julien <victor@inliniac.net> */
#include "decode.h"
#include "decode-ethernet.h"
#include "decode-events.h"
void DecodeEthernet(ThreadVars *t, Packet *p, u_int8_t *pkt, u_int16_t len, PacketQueue *pq)
{
PerfCounterIncr(COUNTER_DECODER_ETH, t->pca);
if (len < ETHERNET_HEADER_LEN) {
DECODER_SET_EVENT(p,ETHERNET_PKT_TOO_SMALL);
return;
}
EthernetHdr *ethh = (EthernetHdr *)pkt;
if (ethh == NULL)
return;
#ifdef DEBUG
printf("DecodeEthernet: p %p pkt %p ether type %04x\n", p, pkt, ntohs(ethh->eth_type));
#endif
if (ntohs(ethh->eth_type) == ETHERNET_TYPE_IP) {
//printf("DecodeEthernet ip4\n");
DecodeIPV4(t, p, pkt + ETHERNET_HEADER_LEN, len - ETHERNET_HEADER_LEN, pq);
} else if(ntohs(ethh->eth_type) == ETHERNET_TYPE_IPV6) {
//printf("DecodeEthernet ip6\n");
DecodeIPV6(t, p, pkt + ETHERNET_HEADER_LEN, len - ETHERNET_HEADER_LEN);
} else if(ntohs(ethh->eth_type) == ETHERNET_TYPE_PPPoE_SESS) {
//printf("DecodeEthernet PPPoE\n");
PerfCounterIncr(COUNTER_DECODER_PPPOE, t->pca);
DecodePPPoE(t, p, pkt + PPPOE_HEADER_LEN, len - PPPOE_HEADER_LEN, pq);
}
return;
}