From: Josh Date: Wed, 25 Jun 2014 20:38:32 +0000 (-0400) Subject: updating token ring example X-Git-Tag: 3.0.0-233~1459^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc6202a93337ddff63288d280937072b232d5963;p=thirdparty%2Fsnort3.git updating token ring example --- diff --git a/extra/src/codecs/token_ring.cc b/extra/src/codecs/token_ring.cc index 19efed20e..fd3280786 100644 --- a/extra/src/codecs/token_ring.cc +++ b/extra/src/codecs/token_ring.cc @@ -89,18 +89,8 @@ bool TrCodec::decode(const uint8_t *raw_pkt, const uint32_t raw_len, uint32_t cap_len = raw_len; uint32_t dataoff; /* data offset is variable here */ - - DEBUG_WRAP(DebugMessage(DEBUG_DECODE, "Packet!\n"); - DebugMessage(DEBUG_DECODE, "caplen: %lu pktlen: %lu\n", - (unsigned long)cap_len,(unsigned long) raw_len); - ); - if(cap_len < sizeof(token_ring::Trh_hdr)) { - DEBUG_WRAP(DebugMessage(DEBUG_DECODE, - "Captured data length < Token Ring header length! " - "(%d < %d bytes)\n", cap_len, TR_HLEN);); - codec_events::decoder_event(p, DECODE_BAD_TRH); return false; } @@ -127,11 +117,6 @@ bool TrCodec::decode(const uint8_t *raw_pkt, const uint32_t raw_len, */ if(cap_len < (sizeof(token_ring::Trh_hdr) + sizeof(token_ring::Trh_llc))) { - DEBUG_WRAP(DebugMessage(DEBUG_DECODE, - "Captured data length < Token Ring header length! " - "(%d < %d bytes)\n", cap_len, - (sizeof(token_ring::Trh_hdr) + sizeof(token_ring::Trh_llc)));); - codec_events::decoder_event(p, DECODE_BAD_TR_ETHLLC); return false; } @@ -149,11 +134,6 @@ bool TrCodec::decode(const uint8_t *raw_pkt, const uint32_t raw_len, if(cap_len < (sizeof(token_ring::Trh_hdr) + sizeof(token_ring::Trh_llc) + sizeof(token_ring::Trh_mr))) { - DEBUG_WRAP(DebugMessage(DEBUG_DECODE, - "Captured data length < Token Ring header length! " - "(%d < %d bytes)\n", cap_len, - (sizeof(token_ring::Trh_hdr) + sizeof(token_ring::Trh_llc) + sizeof(token_ring::Trh_mr)));); - codec_events::decoder_event(p, DECODE_BAD_TRHMR); return false; } @@ -165,11 +145,6 @@ bool TrCodec::decode(const uint8_t *raw_pkt, const uint32_t raw_len, if(cap_len < (sizeof(token_ring::Trh_hdr) + sizeof(token_ring::Trh_llc) + sizeof(token_ring::Trh_mr) + TRH_MR_LEN(trhmr))) { - DEBUG_WRAP(DebugMessage(DEBUG_DECODE, - "Captured data length < Token Ring header length! " - "(%d < %d bytes)\n", cap_len, - (sizeof(token_ring::Trh_hdr) + sizeof(token_ring::Trh_llc) + sizeof(token_ring::Trh_mr)));); - codec_events::decoder_event(p, DECODE_BAD_TR_MR_LEN); return false; } @@ -194,9 +169,6 @@ bool TrCodec::decode(const uint8_t *raw_pkt, const uint32_t raw_len, */ if(trhllc->dsap != IPARP_SAP && trhllc->ssap != IPARP_SAP) { - DEBUG_WRAP( - DebugMessage(DEBUG_DECODE, "DSAP and SSAP arent set to SNAP\n"); - ); return false; } diff --git a/src/codecs/root/CMakeLists.txt b/src/codecs/root/CMakeLists.txt index b6d4c7edb..c03632700 100644 --- a/src/codecs/root/CMakeLists.txt +++ b/src/codecs/root/CMakeLists.txt @@ -26,8 +26,11 @@ if (STATIC_CODECS) endif (ENABLE_NON_ETHER_DECODERS) else() - add_shared_library(cd_wlan codecs cd_wlan.cc cd_wlan_module.h cd_wlan_module.cc) - add_shared_library(cd_linux_sll codecs cd_linux_sll.cc) + + if (ENABLE_NON_ETHER_DECODERS) + add_shared_library(cd_wlan codecs cd_wlan.cc cd_wlan_module.h cd_wlan_module.cc) + add_shared_library(cd_linux_sll codecs cd_linux_sll.cc) + endif() endif() diff --git a/src/codecs/root/cd_linux_sll.cc b/src/codecs/root/cd_linux_sll.cc index 951704b56..ac852702e 100644 --- a/src/codecs/root/cd_linux_sll.cc +++ b/src/codecs/root/cd_linux_sll.cc @@ -70,7 +70,7 @@ bool LinuxSllCodec::decode(const uint8_t *raw_pkt, const uint32_t raw_len, Packet* /*p*/, uint16_t &lyr_len, uint16_t &next_prot_id) { /* do a little validation */ - if(raw_len < SLL_HDR_LEN) + if(raw_len < linux_sll::SLL_HDR_LEN) { if (ScLogVerbose()) { @@ -84,7 +84,7 @@ bool LinuxSllCodec::decode(const uint8_t *raw_pkt, const uint32_t raw_len, /* grab out the network type */ next_prot_id = ntohs(sllh->sll_protocol); - lyr_len = SLL_HDR_LEN; + lyr_len = linux_sll::SLL_HDR_LEN; return true; } diff --git a/src/protocols/linux_sll.h b/src/protocols/linux_sll.h index 092237fce..d66ad5d07 100644 --- a/src/protocols/linux_sll.h +++ b/src/protocols/linux_sll.h @@ -32,8 +32,9 @@ namespace linux_sll * (taken from tcpdump source). */ -#define SLL_HDR_LEN 16 /* total header length */ -#define SLL_ADDRLEN 8 /* length of address field */ +const uint8_t SLL_HDR_LEN = 16; +const uint8_t SLL_ADDRLEN = 8; + typedef struct _SLLHdr { uint16_t sll_pkttype; /* packet type */ uint16_t sll_hatype; /* link-layer address type */