]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Moving around some files. Adding AH
authorJosh <jrosenba@cisco.com>
Thu, 17 Apr 2014 22:00:50 +0000 (18:00 -0400)
committerJosh <jrosenba@cisco.com>
Thu, 17 Apr 2014 22:00:50 +0000 (18:00 -0400)
src/codecs/plugins/CMakeLists.txt
src/codecs/plugins/cd_ah.cc
src/codecs/root/eap/prot_eap.cc [moved from src/codecs/chained/eap/prot_eap.cc with 100% similarity]
src/codecs/root/eap/prot_eap.h [moved from src/codecs/chained/eap/prot_eap.h with 100% similarity]
src/codecs/root/eap/prot_eapol.cc [moved from src/codecs/chained/eap/prot_eapol.cc with 100% similarity]
src/codecs/root/eap/prot_eapol.h [moved from src/codecs/chained/eap/prot_eapol.h with 100% similarity]
src/codecs/root/eap/prot_eapolkey.cc [moved from src/codecs/chained/eap/prot_eapolkey.cc with 100% similarity]
src/codecs/root/eap/prot_eapolkey.h [moved from src/codecs/chained/eap/prot_eapolkey.h with 100% similarity]
src/codecs/root/prot_ipx.cc [moved from src/codecs/tmp/prot_ipx.cc with 100% similarity]
src/codecs/tmp/prot_ah.cc [deleted file]
src/codecs/tmp/prot_ah.h [deleted file]

index 49a0b717c5663445aceaad4cc80fff9e22a8c045..d638237a50120f40a9c90346d236ac2f73b59b6e 100644 (file)
@@ -4,6 +4,7 @@ add_library( codec_plugins STATIC
     cd_teredo.cc
     cd_gtp.cc
     cd_vlan.cc
+    cd_ah.cc
 )
 
 
index 2043d945afb21a700a05bd253db0d20b33793ba4..b4ccea9a1f53be8e9f53c3d96374e09fe2cbba45 100644 (file)
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
-#if 0
 
-#ifdef HAVE_DUMBNET_H
-#include <dumbnet.h>
-#else
-#include <dnet.h>
-#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<uint16_t>&);
-    virtual void get_data_link_type(std::vector<int>&){};
     
 };
 
+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<uint16_t>& v)
+void AhCodec::get_protocol_ids(std::vector<uint16_t>& 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/tmp/prot_ah.cc b/src/codecs/tmp/prot_ah.cc
deleted file mode 100644 (file)
index 18f6635..0000000
+++ /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 <roesch@sourcefire.com>
-**
-** 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 (file)
index 14e22dc..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-** Copyright (C) 2002-2013 Sourcefire, Inc.
-** Copyright (C) 1998-2002 Martin Roesch <roesch@sourcefire.com>
-**
-** 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
-