cd_teredo.cc
cd_gtp.cc
cd_vlan.cc
+ cd_ah.cc
)
#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)
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
NULL, // tterm
ctor, // ctor
dtor, // dtor
+ sum, // sum
+ stats // stats
};
+
+++ /dev/null
-/* $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,
-};
-
-
-
+++ /dev/null
-/*
-** 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
-