set(CODEC_INCLUDES
decode_module.h
codec_events.h
- sf_protocols.h
)
add_library( codecs STATIC
x_include_HEADERS = \
codec_events.h \
-decode_module.h \
-sf_protocols.h
+decode_module.h
libcodecs_a_SOURCES = \
codec_api.cc \
-codec_api.h \
-sf_protocols.h
+codec_api.h
SUBDIRS = \
#include "framework/codec.h"
#include "codecs/codec_events.h"
#include "protocols/protocol_ids.h"
-#include "codecs/sf_protocols.h"
#include "protocols/ipv6.h"
#include "protocols/packet.h"
#include "codecs/ip/ip_util.h"
AuthCodec() : Codec(CD_AUTH_NAME){};
~AuthCodec(){};
-
- virtual PROTO_ID get_proto_id() { return PROTO_AH; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
};
#include "codecs/codec_events.h"
#include "protocols/packet.h"
#include "protocols/protocol_ids.h"
-#include "codecs/sf_protocols.h"
#include "protocols/gre.h"
#include "log/text_log.h"
#include "protocols/packet_manager.h"
GreCodec() : Codec(CD_GRE_NAME){};
~GreCodec(){};
- virtual PROTO_ID get_proto_id() { return PROTO_GRE; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
void log(TextLog* const, const uint8_t* /*raw_pkt*/,
const Packet* const);
-
-
};
static const uint32_t GRE_HEADER_LEN = 4;
//-------------------------------------------------------------------------
static Codec* ctor(Module*)
-{
- return new Ipv6HopOptsCodec();
-}
+{ return new Ipv6HopOptsCodec(); }
static void dtor(Codec *cd)
-{
- delete cd;
-}
+{ delete cd; }
static const CodecApi ipv6_hopopts_api =
{
#include "codecs/codec_events.h"
#include "codecs/ip/checksum.h"
#include "codecs/decode_module.h"
-#include "codecs/sf_protocols.h"
#include "codecs/ip/ip_util.h"
#include "protocols/protocol_ids.h"
#include "protocols/packet.h"
Icmp4Codec() : Codec(CD_ICMP4_NAME){};
~Icmp4Codec() {};
- virtual PROTO_ID get_proto_id() { return PROTO_ICMP4; };
virtual void get_protocol_ids(std::vector<uint16_t>&);
virtual bool decode(const RawData&, CodecData&, SnortData&);
virtual bool encode(EncState*, Buffer* out, const uint8_t* raw_in);
#include "protocols/icmp6.h"
#include "protocols/icmp4.h"
#include "codecs/decode_module.h"
-#include "codecs/sf_protocols.h"
#include "codecs/decode_module.h"
#include "codecs/codec_events.h"
#include "codecs/ip/checksum.h"
~Icmp6Codec(){};
- virtual PROTO_ID get_proto_id() { return PROTO_ICMP6; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
virtual bool encode(EncState*, Buffer* out, const uint8_t* raw_in);
} // anonymous namespace
-
void Icmp6Codec::get_protocol_ids(std::vector<uint16_t>& v)
-{
- v.push_back(IPPROTO_ICMPV6);
-}
+{ v.push_back(IPPROTO_ID_ICMPV6); }
//--------------------------------------------------------------------
// decode.c::ICMP6
#include "main/thread.h"
#include "stream/stream_api.h"
#include "codecs/decode_module.h"
-#include "codecs/sf_protocols.h"
#include "protocols/ip.h"
#include "protocols/ipv4_options.h"
#include "log/text_log.h"
Ipv4Codec() : Codec(CD_IPV4_NAME){};
~Ipv4Codec(){};
- virtual PROTO_ID get_proto_id() { return PROTO_IP4; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
virtual void log(TextLog* const, const uint8_t* /*raw_pkt*/,
#include "main/snort.h"
#include "packet_io/active.h"
#include "codecs/decode_module.h"
-#include "codecs/sf_protocols.h"
#include "protocols/protocol_ids.h"
#include "protocols/packet_manager.h"
#include "log/text_log.h"
Ipv6Codec() : Codec(CD_IPV6_NAME){};
~Ipv6Codec(){};
- virtual PROTO_ID get_proto_id() { return PROTO_IP6; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
virtual bool encode(EncState*, Buffer* out, const uint8_t* raw_in);
#include "framework/codec.h"
#include "codecs/decode_module.h"
#include "codecs/ip/checksum.h"
-#include "codecs/sf_protocols.h"
#include "protocols/tcp.h"
#include "protocols/tcp_options.h"
#include "protocols/ipv6.h"
};
virtual ~TcpCodec(){};
-
- virtual PROTO_ID get_proto_id() { return PROTO_TCP; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual void log(TextLog* const, const uint8_t* /*raw_pkt*/,
const Packet* const);
void TcpCodec::get_protocol_ids(std::vector<uint16_t>& v)
{
- v.push_back(IPPROTO_TCP);
+ v.push_back(IPPROTO_ID_TCP);
}
bool TcpCodec::decode(const RawData& raw, CodecData& codec, SnortData& snort)
#include "framework/codec.h"
#include "packet_io/active.h"
#include "codecs/codec_events.h"
-#include "codecs/sf_protocols.h"
#include "snort_config.h"
#include "parser/config_file.h"
#include "codecs/ip/ip_util.h"
~UdpCodec(){};
- virtual PROTO_ID get_proto_id() { return PROTO_UDP; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
#include "codecs/decode_module.h"
#include "codecs/codec_events.h"
#include "protocols/protocol_ids.h"
-#include "codecs/sf_protocols.h"
#include "protocols/arp.h"
#include "protocols/packet.h"
#include "log/text_log.h"
ArpCodec() : Codec(CD_ARP_NAME){};
~ArpCodec(){};
-
- virtual PROTO_ID get_proto_id() { return PROTO_ARP; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
};
#include "codecs/decode_module.h"
#include "codecs/codec_events.h"
#include "protocols/protocol_ids.h"
-#include "codecs/sf_protocols.h"
#include "protocols/packet.h"
#define CD_ERSPAN2_NAME "erspan2"
Erspan2Codec() : Codec(CD_ERSPAN2_NAME){};
~Erspan2Codec(){};
- virtual PROTO_ID get_proto_id() { return PROTO_ERSPAN; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
#include "codecs/decode_module.h"
#include "codecs/codec_events.h"
#include "protocols/protocol_ids.h"
-#include "codecs/sf_protocols.h"
#include "protocols/packet.h"
#define CD_ERSPAN3_NAME "erspan3"
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
-
- virtual PROTO_ID get_proto_id() { return PROTO_ERSPAN; };
};
#include "packet_io/active.h"
#include "protocols/protocol_ids.h"
#include "protocols/mpls.h"
-#include "codecs/sf_protocols.h"
#include "main/snort_config.h"
#include "main/snort.h"
#include "log/text_log.h"
MplsCodec() : Codec(CD_MPLS_NAME){};
~MplsCodec(){};
- virtual PROTO_ID get_proto_id() { return PROTO_MPLS; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
virtual void log(TextLog* const, const uint8_t* /*raw_pkt*/,
#include "framework/codec.h"
#include "protocols/protocol_ids.h"
#include "snort.h"
-#include "codecs/sf_protocols.h"
#include "main/snort_debug.h"
#define CD_PPPENCAP_NAME "ppp_encap"
PppEncap() : Codec(CD_PPPENCAP_NAME){};
~PppEncap(){};
- virtual PROTO_ID get_proto_id() { return PROTO_PPP_ENCAP; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
-
};
const static uint16_t PPP_IP = 0x0021; /* Internet Protocol */
#include "codecs/decode_module.h"
#include "codecs/codec_events.h"
#include "protocols/packet.h"
-#include "codecs/sf_protocols.h"
#include "protocols/layer.h"
#include "main/snort_debug.h"
~PPPoEDiscCodec() {};
- virtual PROTO_ID get_proto_id() { return PROTO_PPPOE; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
virtual bool encode(EncState*, Buffer* out, const uint8_t* raw_in);
~PPPoESessCodec() {};
- virtual PROTO_ID get_proto_id() { return PROTO_PPPOE; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
virtual bool encode(EncState*, Buffer* out, const uint8_t* raw_in);
#include "protocols/vlan.h"
#include "protocols/eth.h"
#include "protocols/protocol_ids.h"
-#include "codecs/sf_protocols.h"
#include "protocols/packet_manager.h"
#include "log/text_log.h"
VlanCodec() : Codec(CD_VLAN_NAME){};
~VlanCodec(){};
- virtual PROTO_ID get_proto_id() { return PROTO_VLAN; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
virtual void log(TextLog* const, const uint8_t* /*raw_pkt*/,
#include "protocols/packet.h"
#include "codecs/codec_events.h"
#include "packet_io/active.h"
-#include "codecs/sf_protocols.h"
#include "protocols/protocol_ids.h"
#include "codecs/decode_module.h"
GtpCodec() : Codec(CD_GTP_NAME){};
~GtpCodec(){};
- virtual PROTO_ID get_proto_id() { return PROTO_GTP; };
virtual void get_protocol_ids(std::vector<uint16_t>& v);
virtual bool decode(const RawData&, CodecData&, SnortData&);
virtual bool encode(EncState*, Buffer* out, const uint8_t* raw_in);
#include "protocols/eth.h"
#include "codecs/codec_events.h"
#include "protocols/packet_manager.h"
-#include "codecs/sf_protocols.h"
#include "log/text_log.h"
#define CD_ETH_NAME "eth"
EthCodec() : Codec(CD_ETH_NAME){};
~EthCodec(){};
-
- virtual PROTO_ID get_proto_id() { return PROTO_ETH; };
virtual void get_protocol_ids(std::vector<uint16_t>&);
virtual void get_data_link_type(std::vector<int>&);
virtual void log(TextLog* const, const uint8_t* /*raw_pkt*/,
+++ /dev/null
-/* $Id: sf_protocols.h,v 1.10 2013-02-07 17:51:29 ssturges Exp $ */
-/****************************************************************************
- *
- * Copyright (C) 2005-2013 Sourcefire, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License Version 2 as
- * published by the Free Software Foundation. You may not use, modify or
- * distribute this program under any other version of the GNU General
- * Public License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- ****************************************************************************/
-
-#ifndef SF_PROTOCOLS_H
-#define SF_PROTOCOLS_H
-
-typedef enum {
- PROTO_ETH, // DecodeEthPkt
-
- PROTO_IP4, // DecodeIP
- // DecodeIPOptions - handled with IP4
- PROTO_ICMP4, // DecodeICMP
- PROTO_ICMP_IP4, // DecodeICMPEmbeddedIP
-
- PROTO_UDP, // DecodeUDP
- PROTO_TCP, // DecodeTCP
- // DecodeTCPOptions - handled with TCP
-
- PROTO_IP6, // DecodeIPV6
- // DecodeIPV6Extensions - nothing to do here, calls below
- PROTO_IP6_HOP_OPTS, // DecodeIPV6Options - ip6 hop, dst, rte, and frag exts
- PROTO_IP6_DST_OPTS,
- PROTO_ICMP6, // DecodeICMP6
- PROTO_ICMP_IP6, // DecodeICMPEmbeddedIP6
- PROTO_VLAN, // DecodeVlan
- PROTO_GRE, // DecodeGRE
- // DecodeTransBridging - basically same as DecodeEthPkt
- PROTO_ERSPAN, // DecodeERSPANType2 and DecodeERSPANType3
- PROTO_PPPOE, // DecodePPPoEPkt
- PROTO_PPP_ENCAP, // DecodePppPktEncapsulated
- PROTO_MPLS, // DecodeMPLS - decoder changes pkth len/caplen!
- // DecodeEthOverMPLS - basically same as straight eth
- PROTO_ARP, // DecodeARP
- PROTO_GTP, // DecodeGTP
- PROTO_AH, // DecodeAH - Authentication Header (IPSec stuff)
-
- PROTO_TR, // DecodeTRPkt
- PROTO_FDDI, // DecodeFDDIPkt
- PROTO_LSLL, // DecodeLinuxSLLPkt sockaddr_ll for "any" device and
- // certain misbehaving link layer encapsulations
- PROTO_80211, // DecodeIEEE80211Pkt
- PROTO_SLIP, // DecodeSlipPkt - actually, based on header size, this
- // must be CSLIP (TCP/IP header compression) but all it
- // does is skip over the presumed header w/o expanding
- // and then jumps into IP4 decoding only; also, the actual
- // esc/end sequences must already have been removed because
- // there is no attempt to do that.
- PROTO_L2I4, // DecodeI4LRawIPPkt - always skips 2 bytes and then does
- // IP4 decoding only
- PROTO_L2I4C, // DecodeI4LCiscoIPPkt -always skips 4 bytes and then does
- // IP4 decoding only
- PROTO_CHDLC, // DecodeChdlcPkt - skips 4 bytes and decodes IP4 only.
- PROTO_PFLOG, // DecodePflog
- PROTO_OLD_PFLOG, // DecodeOldPflog
- PROTO_PPP, // DecodePppPkt - weird - optionally skips addr and cntl
- // bytes; what about flag and protocol?
- // calls only DecodePppPktEncapsulated.
- PROTO_PPP_SERIAL, // DecodePppSerialPkt - also weird - requires addr, cntl,
- // and proto (no flag) but optionally skips only 2 bytes
- // (presumably the trailer w/chksum is already stripped)
- // Calls either DecodePppPktEncapsulated or DecodeChdlcPkt.
- PROTO_ENC, // DecodeEncPkt - skips 12 bytes and decodes IP4 only.
- // (add family + "spi" + "flags" - don't know what this is)
- PROTO_EAP, // DecodeEAP
- PROTO_EAPOL, // DecodeEapol - leaf decoder
- PROTO_EAPOL_KEY, // DecodeEapolKey - leaf decoder
-
- PROTO_MAX
-} PROTO_ID;
-
- // DecodeIPX - just counts; no decoding
- // DecodeEthLoopback - same as ipx
- // DecodeRawPkt - jumps straight into IP4 decoding
- // there is nothing to do
- // DecodeNullPkt - same as DecodeRawPkt
-
-
-#endif // __PROTOCOLS_H__
-
#include "main/snort_types.h"
#include "framework/base_api.h"
-#include "codecs/sf_protocols.h"
// unfortunately necessary due to use of Ipapi in struct
#include "protocols/ip.h"
// Get the codec's name
inline const char* get_name() const {return name; };
- // used for backwards compatability.
- virtual PROTO_ID get_proto_id() { return PROTO_AH; };
// Registers this Codec's data link type (as defined by libpcap)
virtual void get_data_link_type(std::vector<int>&) {};
// Register the code's protocol ID's and Ethertypes
#include "protocols/eapol.h"
#include "protocols/ipv4_options.h"
#include "protocols/tcp_options.h"
+#include "protocols/packet_manager.h"
/*--------------------------------------------------------------------
* utility functions
const uint8_t* pb = data;
const uint8_t* end = data + len;
+ const uint8_t ipv4_id = PacketManager::proto_id(IPPROTO_ID_IPIP);
+ const uint8_t ipv6_id = PacketManager::proto_id(IPPROTO_ID_IPV6);
+
int offset = 0;
char conv[] = "0123456789ABCDEF"; /* xlation lookup table */
int ip_ob_start, ip_ob_end, byte_pos, char_pos;
if(p && ScObfuscate() )
{
int num_layers = p->num_layers;
+ uint8_t lyr_proto = 0;
+
for ( i = 0; i < num_layers; i++ )
{
- if ( p->layers[i].proto == PROTO_IP4
- || p->layers[i].proto == PROTO_IP6
- )
+ lyr_proto = PacketManager::proto_id(p->layers[i].prot_id);
+
+ if ( lyr_proto == ipv4_id || lyr_proto == ipv6_id)
{
if(p->layers[i].length && p->layers[i].start)
break;
if(ip_start > 0 )
{
ip_ob_start = ip_start + 10;
- if(p->layers[i].proto == PROTO_IP4)
+ if(lyr_proto == ipv4_id)
ip_ob_end = ip_ob_start + 2 + 2*(sizeof(struct in_addr));
else
ip_ob_end = ip_ob_start + 2 + 2*(sizeof(struct in6_addr));
{ nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
};
-static const char* _help =
+static const char* xxx_help =
"configure ";
class XXXModule : public Module
// print all of the codec plugins
static void dump_plugins();
-
private:
struct CodecApiWrapper;
while ( lyr > 0 )
{
- PROTO_ID proto = p->layers[--lyr].proto;
- NormalFunc n = c->normalizers[proto];
+ uint16_t proto = p->layers[--lyr].prot_id;
+ NormalFunc n = c->normalizers[PacketManager::proto_id(proto)];
if ( n ) changes = n(c, p, lyr, changes);
}
}
if ( Norm_IsEnabled(nc, NORM_IP4) )
{
- nc->normalizers[PROTO_IP4] = Norm_IP4;
+ nc->normalizers[PacketManager::proto_id(ETHERTYPE_IPV4)] = Norm_IP4;
}
if ( Norm_IsEnabled(nc, NORM_IP4_TRIM) )
{
}
if ( Norm_IsEnabled(nc, NORM_ICMP4) )
{
- nc->normalizers[PROTO_ICMP4] = Norm_ICMP4;
+ nc->normalizers[PacketManager::proto_id(IPPROTO_ID_ICMPV4)] = Norm_ICMP4;
}
if ( Norm_IsEnabled(nc, NORM_IP6) )
{
- nc->normalizers[PROTO_IP6] = Norm_IP6;
- nc->normalizers[PROTO_IP6_HOP_OPTS] = Norm_IP6_Opts;
- nc->normalizers[PROTO_IP6_DST_OPTS] = Norm_IP6_Opts;
+ nc->normalizers[PacketManager::proto_id(IPPROTO_ID_IPV6)] = Norm_IP6;
+ nc->normalizers[PacketManager::proto_id(IPPROTO_ID_HOPOPTS)] = Norm_IP6_Opts;
+ nc->normalizers[PacketManager::proto_id(IPPROTO_ID_DSTOPTS)] = Norm_IP6_Opts;
}
if ( Norm_IsEnabled(nc, NORM_ICMP6) )
{
- nc->normalizers[PROTO_ICMP6] = Norm_ICMP6;
+ nc->normalizers[PacketManager::proto_id(IPPROTO_ID_ICMPV6)] = Norm_ICMP6;
}
if ( Norm_IsEnabled(nc, NORM_TCP) )
{
- nc->normalizers[PROTO_TCP] = Norm_TCP;
+ nc->normalizers[PacketManager::proto_id(IPPROTO_ID_TCP)] = Norm_TCP;
}
return 0;
}
-
#ifndef NORM_H
#define NORM_H
-#include "protocols/packet.h"
#include "snort.h"
#include "normalize.h"
+#include "protocols/packet_manager.h"
struct NormalizerConfig;
+struct Packet;
// all normalizers look like this:
// the return is 1 if packet was changed, else 0
// these must be in the same order PROTO_IDs are defined!
// if entry is NULL, proto doesn't have normalization or it is disabled
- NormalFunc normalizers[PROTO_MAX];
+ NormalFunc normalizers[PacketManager::max_protocols()];
};
int Norm_SetConfig(NormalizerConfig*);
#include "protocols/packet_manager.h"
#include "packet_io/sfdaq.h"
#include "protocols/tcp.h"
+#include "protocols/protocol_ids.h"
#define MAX_ATTEMPTS 20
static int Active_SendEth(const DAQ_PktHdr_t*, int, const uint8_t*, uint32_t);
static int Active_SendIp(const DAQ_PktHdr_t*, int, const uint8_t*, uint32_t);
-static inline PROTO_ID GetInnerProto (const Packet* p)
+static inline uint16_t GetInnerProto (const Packet* p)
{
- if ( !p->num_layers ) return PROTO_MAX;
- return ( p->layers[p->num_layers-1].proto );
+ if ( !p->num_layers )
+ return FINISHED_DECODE;
+
+ return ( p->layers[p->num_layers-1].prot_id );
}
//--------------------------------------------------------------------
int Active_IsRSTCandidate(const Packet* p)
{
- if ( GetInnerProto(p) != PROTO_TCP )
+ if ( GetInnerProto(p) != IPPROTO_ID_TCP )
return 0;
if ( !p->ptrs.tcph )
int Active_IsUNRCandidate(const Packet* p)
{
// FIXIT-J allow unr to tcp/udp/icmp4/icmp6 only or for all
- switch ( GetInnerProto(p) ) {
- case PROTO_UDP:
- case PROTO_TCP:
- case PROTO_ICMP4:
- case PROTO_ICMP6:
- return 1;
+ switch ( GetInnerProto(p) )
+ {
+ case IPPROTO_ID_UDP:
+ case IPPROTO_ID_TCP:
+ case IPPROTO_ID_ICMPV4:
+ case IPPROTO_ID_ICMPV6:
+ return 1;
- default:
- break;
+ default:
+ break;
}
return 0;
}
#include <cstdint>
#include "main/snort_types.h"
-#include "codecs/sf_protocols.h"
struct Layer {
* (layers_entire_length) - length;
* (ip::IP4Hdr*) ip4h->get_hlen() * 4 - length;
*/
- PROTO_ID proto;
};
static inline void push_layer(Packet *p,
uint16_t prot_id,
const uint8_t *hdr_start,
- uint32_t len,
- Codec *const cd)
+ uint32_t len)
{
// We check to ensure num_layer < MAX_LAYERS before this function call
Layer& lyr = p->layers[p->num_layers++];
- lyr.proto = cd->get_proto_id();
lyr.prot_id = prot_id;
lyr.start = hdr_start;
lyr.length = (uint16_t)len;
// internal statistics and record keeping
- push_layer(p, prev_prot_id, pkt, codec_data.lyr_len, CodecManager::s_protocols[mapped_prot]);
+ push_layer(p, prev_prot_id, pkt, codec_data.lyr_len);
s_stats[mapped_prot + stat_offset]++; // add correct decode for previous layer
mapped_prot = CodecManager::s_proto_map[codec_data.next_prot_id];
prev_prot_id = codec_data.next_prot_id;
const uint8_t* b = c->pkt + (p->layers[i].start - p->pkt); // == c->pkt + p->layers[i].len
lyr = c->layers + i;
- lyr->proto = p->layers[i].proto;
lyr->prot_id = p->layers[i].prot_id;
lyr->length = p->layers[i].length;
lyr->start = (uint8_t*)b;
#include "main/snort_types.h"
#include "framework/codec.h"
-#include "protocols/packet.h"
+#include "protocols/packet.h" // FIXIT-L remove
#include "framework/counts.h"
#include "managers/codec_manager.h"
#include "main/thread.h"
// print this packets information, layer by layer
static void log_protocols(TextLog* const, const Packet* const);
+
+
+
+ /* Accessor functions -- any object in Snort++ can now convert a
+ * protocol to its mapped value.
+ *
+ * The equivelant of Snort's PROTO_ID */
+ static constexpr std::size_t max_protocols() // compile time constant
+ { return CodecManager::s_protocols.size(); }
+
+ /* If a proto was registered in a Codec's get_protocol_ids() function,
+ * this function will return the 'ID' of the Codec to which the proto belongs.
+ * If none of the loaded Codecs registered that proto, this function will
+ * return zero. */
+ static inline uint8_t proto_id(uint16_t proto)
+ { return CodecManager::s_proto_map[proto]; }
+
private:
// STATISTICS!!
/*
-** Copyright (C) 2002-2013 Sourcefire, Inc.
-** Copyright (C) 1998-2002 Martin Roesch <roesch@sourcefire.com>
+** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License Version 2 as
constexpr uint16_t IPPROTO_ID_HOPOPTS = 0;
constexpr uint16_t IPPROTO_ID_ICMPV4 = 1;
constexpr uint16_t IPPROTO_ID_IPIP = 4;
+constexpr uint16_t IPPROTO_ID_TCP = 6;
+constexpr uint16_t IPPROTO_ID_UDP = 17;
constexpr uint16_t IPPROTO_ID_IPV6 = 41;
constexpr uint16_t IPPROTO_ID_ROUTING = 43;
constexpr uint16_t IPPROTO_ID_FRAGMENT = 44;