From: Josh Date: Thu, 17 Apr 2014 22:00:50 +0000 (-0400) Subject: Moving around some files. Adding AH X-Git-Tag: 3.0.0-233~1559^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6f41d95381efbdec3bf409112227a464dc1eca6;p=thirdparty%2Fsnort3.git Moving around some files. Adding AH --- diff --git a/src/codecs/plugins/CMakeLists.txt b/src/codecs/plugins/CMakeLists.txt index 49a0b717c..d638237a5 100644 --- a/src/codecs/plugins/CMakeLists.txt +++ b/src/codecs/plugins/CMakeLists.txt @@ -4,6 +4,7 @@ add_library( codec_plugins STATIC cd_teredo.cc cd_gtp.cc cd_vlan.cc + cd_ah.cc ) diff --git a/src/codecs/plugins/cd_ah.cc b/src/codecs/plugins/cd_ah.cc index 2043d945a..b4ccea9a1 100644 --- a/src/codecs/plugins/cd_ah.cc +++ b/src/codecs/plugins/cd_ah.cc @@ -25,51 +25,61 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#if 0 -#ifdef HAVE_DUMBNET_H -#include -#else -#include -#endif -#endif #include "framework/codec.h" #include "codecs/codec_events.h" - +#include "protocols/ipv4.h" namespace { -class NameCodec : public Codec +class AhCodec : public Codec { public: - NameCodec() : Codec("NAME"){}; - ~NameCodec(); + AhCodec() : Codec("ah"){}; + ~AhCodec(); virtual bool decode(const uint8_t *raw_pkt, const uint32_t len, Packet *, uint16_t &p_hdr_len, int &next_prot_id); virtual void get_protocol_ids(std::vector&); - virtual void get_data_link_type(std::vector&){}; }; +static const uint16_t AH_PROT_ID = 51; // RFC 4302 + } // anonymous namespace +bool AhCodec::decode(const uint8_t *raw_pkt, const uint32_t len, + Packet *p, uint16_t &p_hdr_len, int &next_prot_id) +{ + + IP6Extension *ah = (IP6Extension *)raw_pkt; + p_hdr_len = sizeof(*ah) + (ah->ip6e_len << 2); + + if (p_hdr_len > len) + { + return false; + } + + next_prot_id = ah->ip6e_nxt; + return true; +} + + -void NameCodec::get_protocol_ids(std::vector& v) +void AhCodec::get_protocol_ids(std::vector& v) { - v.push_back(ipv6::ethertype()); - v.push_back(IPPROTO_IPV6); + v.push_back(AH_PROT_ID); } static Codec* ctor() { - return new NameCodec(); + return new AhCodec(); } static void dtor(Codec *cd) @@ -77,9 +87,23 @@ static void dtor(Codec *cd) delete cd; } -static const char* name = "name_codec"; +static void sum() +{ +// sum_stats((PegCount*)&gdc, (PegCount*)&dc, array_size(dc_pegs)); +// memset(&dc, 0, sizeof(dc)); +} + +static void stats() +{ +// show_percent_stats((PegCount*)&gdc, dc_pegs, array_size(dc_pegs), +// "decoder"); +} + + -static const CodecApi ipv6_api = +static const char* name = "ah_decode"; + +static const CodecApi ah_api = { { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, NULL, // pinit @@ -88,5 +112,8 @@ static const CodecApi ipv6_api = NULL, // tterm ctor, // ctor dtor, // dtor + sum, // sum + stats // stats }; + diff --git a/src/codecs/chained/eap/prot_eap.cc b/src/codecs/root/eap/prot_eap.cc similarity index 100% rename from src/codecs/chained/eap/prot_eap.cc rename to src/codecs/root/eap/prot_eap.cc diff --git a/src/codecs/chained/eap/prot_eap.h b/src/codecs/root/eap/prot_eap.h similarity index 100% rename from src/codecs/chained/eap/prot_eap.h rename to src/codecs/root/eap/prot_eap.h diff --git a/src/codecs/chained/eap/prot_eapol.cc b/src/codecs/root/eap/prot_eapol.cc similarity index 100% rename from src/codecs/chained/eap/prot_eapol.cc rename to src/codecs/root/eap/prot_eapol.cc diff --git a/src/codecs/chained/eap/prot_eapol.h b/src/codecs/root/eap/prot_eapol.h similarity index 100% rename from src/codecs/chained/eap/prot_eapol.h rename to src/codecs/root/eap/prot_eapol.h diff --git a/src/codecs/chained/eap/prot_eapolkey.cc b/src/codecs/root/eap/prot_eapolkey.cc similarity index 100% rename from src/codecs/chained/eap/prot_eapolkey.cc rename to src/codecs/root/eap/prot_eapolkey.cc diff --git a/src/codecs/chained/eap/prot_eapolkey.h b/src/codecs/root/eap/prot_eapolkey.h similarity index 100% rename from src/codecs/chained/eap/prot_eapolkey.h rename to src/codecs/root/eap/prot_eapolkey.h diff --git a/src/codecs/tmp/prot_ipx.cc b/src/codecs/root/prot_ipx.cc similarity index 100% rename from src/codecs/tmp/prot_ipx.cc rename to src/codecs/root/prot_ipx.cc diff --git a/src/codecs/tmp/prot_ah.cc b/src/codecs/tmp/prot_ah.cc deleted file mode 100644 index 18f6635d3..000000000 --- a/src/codecs/tmp/prot_ah.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* $Id: decode.c,v 1.285 2013-06-29 03:03:00 rcombs Exp $ */ - -/* -** Copyright (C) 2002-2013 Sourcefire, Inc. -** Copyright (C) 1998-2002 Martin Roesch -** -** 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. -*/ - - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "generators.h" -#include "decode.h" -#include "static_include.h" -#include "prot_ah.h" - -#include "prot_ipv4.h" - - -//-------------------------------------------------------------------- -// decode.c::ESP -//-------------------------------------------------------------------- - -/* Function: DecodeAH - * - * Purpose: Decode Authentication Header - * - * NOTE: This is for IPv4 Auth Headers, we leave IPv6 to do its own - * work. - * - */ -void DecodeAH(const uint8_t *pkt, uint32_t len, Packet *p) -{ - IP6Extension *ah = (IP6Extension *)pkt; - uint8_t extlen = sizeof(*ah) + (ah->ip6e_len << 2); - - if (extlen > len) - { - return; - } - - PushLayer(PROTO_AH, p, pkt, extlen); - - DecodeIPv4Proto(ah->ip6e_nxt, pkt+extlen, len-extlen, p); -} - - -static const char* name = "ah_decode"; - -static const CodecApi ah_api = -{ - { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 }, - {IPPROTO_AH}, - NULL, // pinit - NULL, // pterm - NULL, // tinit - NULL, // tterm - NULL, // ctor - NULL, // dtor - AH::DecodeAH, -}; - - - diff --git a/src/codecs/tmp/prot_ah.h b/src/codecs/tmp/prot_ah.h deleted file mode 100644 index 14e22dc44..000000000 --- a/src/codecs/tmp/prot_ah.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -** Copyright (C) 2002-2013 Sourcefire, Inc. -** Copyright (C) 1998-2002 Martin Roesch -** -** 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 PROT_AH_H -#define PROT_AH_H - -void DecodeAH(const uint8_t *, uint32_t, Packet *); - - -#endif -