]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Adding MPLS codec. Changing EtherType prefix name. Removing ethOverMpls (using...
authorJosh <jrosenba@cisco.com>
Fri, 18 Apr 2014 15:40:15 +0000 (11:40 -0400)
committerJosh <jrosenba@cisco.com>
Fri, 18 Apr 2014 15:40:15 +0000 (11:40 -0400)
17 files changed:
src/codecs/basic/cd_udp.cc
src/codecs/decode.h
src/codecs/plugins/CMakeLists.txt
src/codecs/plugins/TODO
src/codecs/plugins/cd_gre.cc
src/codecs/plugins/cd_gtp.cc
src/codecs/plugins/cd_mpls.cc [moved from src/codecs/tmp/prot_mpls.cc with 64% similarity]
src/codecs/plugins/cd_teredo.cc
src/codecs/plugins/cd_transbridge.cc
src/codecs/tmp/prot_ethovermpls.cc [deleted file]
src/protocols/CMakeLists.txt
src/protocols/ethertypes.h
src/protocols/gtp.h
src/protocols/mpls.h [moved from src/codecs/tmp/prot_mpls.h with 81% similarity]
src/protocols/packet.h
src/protocols/teredo.h
src/protocols/undefined_protocols.h [moved from src/codecs/tmp/prot_ethovermpls.h with 71% similarity]

index 295e2cf295a74f424fe4bbc8dc1635436d777e1d..35651ef643f9566eafbf21e82dcd811c9dca6437 100644 (file)
@@ -39,6 +39,7 @@
 #include "protocols/udp.h"
 #include "protocols/teredo.h"
 #include "protocols/gtp.h"
+#include "protocols/undefined_protocols.h"
 
 #include "framework/codec.h"
 #include "codecs/codec_events.h"
@@ -253,14 +254,14 @@ bool decode(const uint8_t *raw_pkt, const uint32_t len,
         ScDeepTeredoInspection())
     {
         if ( !p->frag_flag )
-            next_prot_id = teredo::teredo_id();
+            next_prot_id = PROTOCOL_TEREDO;
     }
 
     if (ScGTPDecoding() &&
          (ScIsGTPPort(p->sp)||ScIsGTPPort(p->dp)))
     {
         if ( !p->frag_flag )
-            next_prot_id = gtp::gtp_id();
+            next_prot_id = PROTOCOL_GTP;
     }
     
     return true;
index cc12d331d869ee10771d9158e68f49a168cc2681..5747b4da1510345aac2303b58429cf6b29e76f33 100644 (file)
@@ -49,7 +49,7 @@ extern "C" {
 #include "snort_types.h"
 #include "protocols/packet.h"
 #include "profiler.h"
-#include "codecs/tmp/prot_mpls.h"
+#include "protocols/mpls.h"
 
 
 
index 3e048512c5f8ee6aa9dadd98f95428ecd395a2af..c759d204613f1bbe884065d0958299b86ab71409 100644 (file)
@@ -8,6 +8,8 @@ add_library( codec_plugins STATIC
     cd_arp.cc
     cd_ethloopback.cc
     cd_gre.cc
+    cd_mpls.cc
+    cd_transbridge.cc
 )
 
 
index 896aa58bfff17d143370e2099ba428cbf0e20eea..7604fae5285bffcbbdfe0d072cdc497676f6aa67 100644 (file)
@@ -6,6 +6,15 @@ REMOVE:
     "protocols/encode.h"
 
 
+MPLS:
+    "Remove protocols/mpls.h"
+    Pull in default_mpls to cd_mpls.  Remove it from the snort_config.
+    Create MPLS module which creates the default mpls
+
+Trans Bridge:
+    Is no longer solely GRE.  Switcht he docer name?
+
+
 *****************************************************************************
 ********************************  *******************************************
 ****************************          ***************************************
@@ -99,8 +108,6 @@ ________________________________________________________________________________
 
 RUSS
 
-
--- Do we change the typedef factor for structs?
 __________________________________________________________________________________________________________
 
 
index 23796942efcb238d3e8c9b0377e0c181f32e2fdd..74ee495bfdf124088dc0094631028ea8da6abc90 100644 (file)
@@ -194,7 +194,7 @@ bool GreCodec::decode(const uint8_t *raw_pkt, const uint32_t len,
             }
 
             /* protocol must be 0x880B - PPP */
-            if (GRE_PROTO(p->greh) != PPP_ETHERTYPE)
+            if (GRE_PROTO(p->greh) != ETHERTYPE_PPP)
             {
                 CodecEvents::decoder_alert_encapsulated(p, DECODE_GRE_V1_INVALID_HEADER,
                                 raw_pkt, len);
index d5aa3d8542b76d903710a7c346f72a243d4f383e..e159dbb31cb966afc343d9f23f408258e5c63b77 100644 (file)
 #include "protocols/ipv6.h"
 #include "packet_io/active.h"
 
+#include "protocols/undefined_protocols.h"
+
 namespace
 {
 
 class GtpCodec : public Codec
 {
 public:
-    GtpCodec() : Codec("gtp"){};
+    GtpCodec() : Codec("GTP"){};
     ~GtpCodec();
 
 
@@ -274,7 +276,7 @@ EncStatus GTP_Update (Packet*, Layer* lyr, uint32_t* len)
 
 void GtpCodec::get_protocol_ids(std::vector<uint16_t>& v)
 {
-    v.push_back(gtp::gtp_id());
+    v.push_back(PROTOCOL_GTP);
 }
 
 static Codec* ctor()
similarity index 64%
rename from src/codecs/tmp/prot_mpls.cc
rename to src/codecs/plugins/cd_mpls.cc
index ad3a36cc6d29f07de538bca1ced1f009c1630bf1..43e60685a046baa81f67b8ec195ab8525d90c30a 100644 (file)
 ** 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
+** You should have received a copy of the GNU General Public LicenseUpdateMPLSStats
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
 
 
+#include "framework/codec.h"
+#include "codecs/codec_events.h"
+#include "codecs/decode_module.h"
+#include "network_inspectors/perf_monitor/perf_base.h"
+#include "network_inspectors/perf_monitor/perf.h"
+#include "snort.h"
+#include "protocols/mpls.h"
+#include "protocols/undefined_protocols.h"
+#include "codecs/codec_events.h"
+#include "packet_io/active.h"
+#include "protocols/ethertypes.h"
+#include "protocols/mpls.h"
+
+namespace
+{
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+class MplsCodec : public Codec
+{
+public:
+    MplsCodec() : Codec("MPLS"){};
+    ~MplsCodec();
+
+
+    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>&);
+    
+};
+
+
+const uint16_t ETHERNET_TYPE_MPLS_UNICAST = 0x8847;
+const uint16_t ETHERNET_TYPE_MPLS_MULTICAST = 0x8848;
+
+const static uint32_t MPLS_HEADER_LEN = 4;
+const static uint32_t NUM_RESERVED_LABELS = 16;
 
-#include "generators.h"
-#include "decode.h"  
-#include "static_include.h"
+} // anonymous namespace
 
-#include "network_inspectors/perfmonitor/perf.h"
-#include  "network_inspectors/perfmonitor/perf_base.h"
 
-#include "prot_mpls.h"
-#include "prot_ipv6.h"
-#include "prot_ipv4.h"
-#include "prot_ethloopback.h"
-#include "prot_ethovermpls.h"
 
 static int checkMplsHdr(uint32_t, uint8_t, uint8_t, uint8_t, Packet *);
 
-void DecodeMPLS(const uint8_t* pkt, const uint32_t len, Packet* p)
+
+
+bool MplsCodec::decode(const uint8_t *raw_pkt, const uint32_t len, 
+        Packet *p, uint16_t &p_hdr_len, int &next_prot_id)
 {
     uint32_t* tmpMplsHdr;
     uint32_t mpls_h;
     uint32_t label;
-    uint32_t mlen = 0;
+    p_hdr_len= 0;
 
     uint8_t exp;
     uint8_t bos = 0;
@@ -56,30 +82,21 @@ void DecodeMPLS(const uint8_t* pkt, const uint32_t len, Packet* p)
 
     int iRet = 0;
 
-
-    if(!ScMplsMulticast())
-    {
-        DecoderEvent(p, DECODE_BAD_MPLS,
-                        DECODE_MULTICAST_MPLS_STR);
-//        SnortEventqAdd(GENERATOR_SNORT_DECODE, DECODE_BAD_MPLS, 1, DECODE_CLASS, 3, DECODE_MULTICAST_MPLS_STR, 0);
-    }
-
-
-    dc.mpls++;
+//    dc.mpls++;
     UpdateMPLSStats(&sfBase, len, Active_PacketWasDropped());
-    tmpMplsHdr = (uint32_t *) pkt;
+    tmpMplsHdr = (uint32_t *) raw_pkt;
     p->mpls = NULL;
 
     while (!bos)
     {
         if(stack_len < MPLS_HEADER_LEN)
         {
-            DecoderEvent(p, DECODE_BAD_MPLS, DECODE_BAD_MPLS_STR);
+            DecoderEvent(p, DECODE_BAD_MPLS);
 
-            dc.discards++;
+//            dc.discards++;
             p->iph = NULL;
             p->family = NO_IP;
-            return;
+            return false;
         }
 
         mpls_h  = ntohl(*tmpMplsHdr);
@@ -90,7 +107,7 @@ void DecodeMPLS(const uint8_t* pkt, const uint32_t len, Packet* p)
         label = (mpls_h>>4) & 0x000FFFFF;
 
         if((label<NUM_RESERVED_LABELS)&&((iRet = checkMplsHdr(label, exp, bos, ttl, p)) < 0))
-            return;
+            return false;
 
         if( bos )
         {
@@ -100,7 +117,7 @@ void DecodeMPLS(const uint8_t* pkt, const uint32_t len, Packet* p)
             p->mplsHdr.ttl = ttl;
             /**
             p->mpls = &(p->mplsHdr);
-                       **/
+      **/
             p->mpls = tmpMplsHdr;
             if(!iRet)
             {
@@ -112,38 +129,37 @@ void DecodeMPLS(const uint8_t* pkt, const uint32_t len, Packet* p)
 
         if ((ScMplsStackDepth() != -1) && (chainLen++ >= ScMplsStackDepth()))
         {
-            DecoderEvent(p, DECODE_MPLS_LABEL_STACK,
-                            DECODE_MPLS_LABEL_STACK_STR);
+            DecoderEvent(p, DECODE_MPLS_LABEL_STACK);
 
-            dc.discards++;
+//            dc.discards++;
             p->iph = NULL;
             p->family = NO_IP;
-            return;
+            return false;
         }
     }   /* while bos not 1, peel off more labels */
 
-    mlen = (uint8_t*)tmpMplsHdr - pkt;
-    PushLayer(PROTO_MPLS, p, pkt, mlen);
-    mlen = len - mlen;
+    p_hdr_len = (uint8_t*)tmpMplsHdr - raw_pkt;
 
     switch (iRet)
     {
         case MPLS_PAYLOADTYPE_IPV4:
-            DecodeIP((uint8_t *)tmpMplsHdr, mlen, p);
+            next_prot_id = ETHERTYPE_IPV4;
             break;
 
         case MPLS_PAYLOADTYPE_IPV6:
-            DecodeIPV6((uint8_t *)tmpMplsHdr, mlen, p);
+            next_prot_id = ETHERTYPE_IPV6;
             break;
 
         case MPLS_PAYLOADTYPE_ETHERNET:
-            DecodeEthOverMPLS((uint8_t *)tmpMplsHdr, mlen, p);
+            next_prot_id = ETHERTYPE_TRANS_ETHER_BRIDGING;
             break;
 
         default:
+            next_prot_id = -1;
             break;
     }
-    return;
+
+    return true;
 }
 
 
@@ -173,11 +189,9 @@ static int checkMplsHdr(
                        ||((!label)&&(ScMplsPayloadType() != MPLS_PAYLOADTYPE_IPV4)))
                    {
                         if( !label )
-                            DecoderEvent(p, DECODE_BAD_MPLS_LABEL0,
-                                            DECODE_BAD_MPLS_LABEL0_STR);
+                            DecoderEvent(p, DECODE_BAD_MPLS_LABEL0);
                         else
-                            DecoderEvent(p, DECODE_BAD_MPLS_LABEL2,
-                                            DECODE_BAD_MPLS_LABEL2_STR);
+                            DecoderEvent(p, DECODE_BAD_MPLS_LABEL2);
                    }
                    break;
                }
@@ -187,11 +201,9 @@ static int checkMplsHdr(
                 * and move on to the next one.
                 */
                if( !label )
-                   DecoderEvent(p, DECODE_BAD_MPLS_LABEL0,
-                                   DECODE_BAD_MPLS_LABEL0_STR);
+                   DecoderEvent(p, DECODE_BAD_MPLS_LABEL0);
                else
-                   DecoderEvent(p, DECODE_BAD_MPLS_LABEL2,
-                                   DECODE_BAD_MPLS_LABEL2_STR);
+                   DecoderEvent(p, DECODE_BAD_MPLS_LABEL2);
 
                dc.discards++;
                p->iph = NULL;
@@ -202,20 +214,18 @@ static int checkMplsHdr(
         case 1:
                if(!bos) break;
 
-                      DecoderEvent(p, DECODE_BAD_MPLS_LABEL1,
-                               DECODE_BAD_MPLS_LABEL1_STR);
+               DecoderEvent(p, DECODE_BAD_MPLS_LABEL1);
 
-               dc.discards++;
+//               dc.discards++;
                p->iph = NULL;
                p->family = NO_IP;
                iRet = MPLS_PAYLOADTYPE_ERROR;
                break;
 
-           case 3:
-               DecoderEvent(p, DECODE_BAD_MPLS_LABEL3,
-                               DECODE_BAD_MPLS_LABEL3_STR);
+      case 3:
+               DecoderEvent(p, DECODE_BAD_MPLS_LABEL3);
 
-               dc.discards++;
+//               dc.discards++;
                p->iph = NULL;
                p->family = NO_IP;
                iRet = MPLS_PAYLOADTYPE_ERROR;
@@ -232,8 +242,7 @@ static int checkMplsHdr(
         case 13:
         case 14:
         case 15:
-                DecoderEvent(p, DECODE_MPLS_RESERVED_LABEL,
-                                DECODE_MPLS_RESERVEDLABEL_STR);
+                DecoderEvent(p, DECODE_MPLS_RESERVED_LABEL);
                 break;
         default:
                 break;
@@ -246,20 +255,51 @@ static int checkMplsHdr(
 }
 
 
-static const char* name = "mpls_decode";
+void MplsCodec::get_protocol_ids(std::vector<uint16_t>& v)
+{
+    v.push_back(ETHERNET_TYPE_MPLS_UNICAST);
+    v.push_back(ETHERNET_TYPE_MPLS_MULTICAST);
+}
+
+static Codec* ctor()
+{
+    return new MplsCodec();
+}
+
+static void dtor(Codec *cd)
+{
+    delete cd;
+}
 
-static const CodecApi mpls_api =
+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 char* name = "mpls_codec";
+
+static const CodecApi codec_api =
 {
     { PT_CODEC, name, CDAPI_PLUGIN_V0, 0 },
-    {ETHERNET_TYPE_MPLS_UNICAST, ETHERNET_TYPE_MPLS_MULTICAST},  
     NULL, // pinit
     NULL, // pterm
     NULL, // tinit
     NULL, // tterm
-    NULL, // ctor
-    NULL, // dtor
-    ErspanType2::DecodeTCP,
+    ctor, // ctor
+    dtor, // dtor
+    sum, // sum
+    stats  // stats
 };
 
 
 
+
index 9b2ef99075a467eb118ee7e1c9f5e7fb2120f1ea..18bff15e8f93a12346a75bae59b9f9c5b39289ad 100644 (file)
@@ -39,6 +39,7 @@
 #include "packet_io/active.h"
 #include "protocols/ipv6.h"
 #include "protocols/teredo.h"
+#include "protocols/undefined_protocols.h"
 
 namespace
 {
@@ -118,7 +119,7 @@ bool TeredoCodec::decode(const uint8_t *raw_pkt, const uint32_t len,
 
 void TeredoCodec::get_protocol_ids(std::vector<uint16_t>& v)
 {
-    v.push_back(teredo::teredo_id());
+    v.push_back(PROTOCOL_TEREDO);
 }
 
 static Codec* ctor()
index 225150060d2ea8ed48af67731e5ca0bac22c4f17..068726f44aad0403c1bb7216f654561f71c25b97 100644 (file)
@@ -99,7 +99,7 @@ bool TransbridgeCodec::decode(const uint8_t *raw_pkt, const uint32_t len,
 
 void TransbridgeCodec::get_protocol_ids(std::vector<uint16_t>& v)
 {
-    v.push_back(TRANS_ETHER_BRIDGING_ETHERTYPE); // defined in ethertypes.h"
+    v.push_back(ETHERTYPE_TRANS_ETHER_BRIDGING); // defined in ethertypes.h"
 }
 
 static Codec* ctor()
diff --git a/src/codecs/tmp/prot_ethovermpls.cc b/src/codecs/tmp/prot_ethovermpls.cc
deleted file mode 100644 (file)
index 9515abb..0000000
+++ /dev/null
@@ -1,129 +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_ethovermpls.h"
-
-
-#include "decoder_includes.h"
-#include "prot_arp.h"
-#include "prot_ethloopback.h"
-#include "prot_pppoepkt.h"
-
-//--------------------------------------------------------------------
-// decode.c::MPLS
-//--------------------------------------------------------------------
-
-void DecodeEthOverMPLS(const uint8_t* pkt, const uint32_t len, Packet* p)
-{
-    /* do a little validation */
-    if(len < ETHERNET_HEADER_LEN)
-    {
-        if (ScLogVerbose())
-        {
-            ErrorMessage("Captured data length < Ethernet header length!"
-                         " (%d bytes)\n", len);
-        }
-
-        p->iph = NULL;
-        p->family = NO_IP;
-        // TBD add decoder drop event for eth over MPLS cap len issue
-        dc.discards++;
-        dc.ethdisc++;
-        return;
-    }
-
-    /* lay the ethernet structure over the packet data */
-    p->eh = (eth::EtherHdr *) pkt; // FIXTHIS squashes outer eth!
-    PushLayer(PROTO_ETH, p, pkt, sizeof(*p->eh));
-
-    DEBUG_WRAP(
-            DebugMessage(DEBUG_DECODE, "%X   %X\n",
-                *p->eh->ether_src, *p->eh->ether_dst);
-            );
-
-    /* grab out the network type */
-    switch(ntohs(p->eh->ether_type))
-    {
-        case ETHERNET_TYPE_IP:
-            DEBUG_WRAP(
-                    DebugMessage(DEBUG_DECODE,
-                        "IP datagram size calculated to be %lu bytes\n",
-                        (unsigned long)(len - ETHERNET_HEADER_LEN));
-                    );
-
-            DecodeIP(p->pkt + ETHERNET_HEADER_LEN,
-                    len - ETHERNET_HEADER_LEN, p);
-
-            return;
-
-        case ETHERNET_TYPE_ARP:
-        case ETHERNET_TYPE_REVARP:
-            DecodeARP(p->pkt + ETHERNET_HEADER_LEN,
-                    len - ETHERNET_HEADER_LEN, p);
-            return;
-
-        case ETHERNET_TYPE_IPV6:
-            DecodeIPV6(p->pkt + ETHERNET_HEADER_LEN,
-                    (len - ETHERNET_HEADER_LEN), p);
-            return;
-
-        case ETHERNET_TYPE_PPPoE_DISC:
-        case ETHERNET_TYPE_PPPoE_SESS:
-            DecodePPPoEPkt(p->pkt + ETHERNET_HEADER_LEN,
-                    (len - ETHERNET_HEADER_LEN), p);
-            return;
-
-#ifndef NO_NON_ETHER_DECODER
-        case ETHERNET_TYPE_IPX:
-            DecodeIPX(p->pkt + ETHERNET_HEADER_LEN,
-                    (len - ETHERNET_HEADER_LEN), p);
-            return;
-#endif
-
-        case ETHERNET_TYPE_LOOP:
-            DecodeEthLoopback(p->pkt + ETHERNET_HEADER_LEN,
-                    (len - ETHERNET_HEADER_LEN), p);
-            return;
-
-        case ETHERNET_TYPE_8021Q:
-            DecodeVlan(p->pkt + ETHERNET_HEADER_LEN,
-                    len - ETHERNET_HEADER_LEN, p);
-            return;
-
-        default:
-            // TBD add decoder drop event for unknown mpls/eth type
-            dc.other++;
-            return;
-    }
-
-    return;
-}
-
index 1bbfe46e296d5b34d233d551aa211e22742c1366..9e32c6167145f81e6ba42a9889609857f8fdc9d5 100644 (file)
@@ -14,7 +14,9 @@ add_library (protocols
     arp.h
     wlan.h
     teredo.h
+    mpls.h
     ethertypes.h
     protocol_numbers.h
+    undefined_protocols.h
 )
 
index 918915c2b0d707dc748919be940fadfd47e46090..a4afe4a504f89649bcb09ca8bbe596d87f37a0c1 100644 (file)
@@ -25,7 +25,7 @@
 /*
  * this file contained the ethertypes for all of the various protocols.
  * 
- * This is ONLY useful when protocols are chained and specificy the next
+ * This is ONLY used when protocols are chained and specificy the next
  * protocol by name rather than by an ID.  MOST protocols do NOT need to
  * entered into this file.
  *
@@ -34,7 +34,9 @@
  */
 
 
-const uint16_t TRANS_ETHER_BRIDGING_ETHERTYPE = 0x6558;
-const uint16_t PPP_ETHERTYPE = 0x880B;
+const uint16_t ETHERTYPE_TRANS_ETHER_BRIDGING = 0x6558;
+const uint16_t ETHERTYPE_IPV4 = 0x0800;
+const uint16_t ETHERTYPE_IPV6 = 0x86dd;
+const uint16_t ETHERTYPE_PPP = 0x880B;
 
 #endif
index a9c45123bb70667eebedb4ada80cd8bf661cb9ba..bf023c7b7da8825403a5084f6f51a0cd3ce86a9f 100644 (file)
@@ -25,8 +25,6 @@
 namespace gtp{
 
 namespace detail{
-
-const uint32_t GTP_ID = 0x0101;
 const uint32_t GTP_MIN_LEN = 8;
 const uint32_t GTP_V0_HEADER_LEN = 20;
 const uint32_t GTP_V1_HEADER_LEN = 12;
@@ -45,11 +43,6 @@ struct GTPHdr
 
 };
 
-inline uint16_t gtp_id()
-{
-    return detail::GTP_ID;
-}
-
 inline uint32_t min_hdr_len()
 {
     return detail::GTP_MIN_LEN;
similarity index 81%
rename from src/codecs/tmp/prot_mpls.h
rename to src/protocols/mpls.h
index 8cf9a2ce8b8025c547b1e571efbc0c4b2e2127f7..6d0040e1d40adca400b313d6f652d256109b94e4 100644 (file)
 */
 
 
-#ifndef PROT_MPLS_H
-#define PROT_MPLS_H
+#ifndef MPLS_H
+#define MPLS_H
 
+namespace mpls{
 
-#define ETHERNET_TYPE_MPLS_UNICAST    0x8847
-#define ETHERNET_TYPE_MPLS_MULTICAST  0x8848
+namespace detail{
 
+} // namespace detail
+
+
+struct MplsHdr
+{
+    uint32_t label;
+    uint8_t  exp;
+    uint8_t  bos;
+    uint8_t  ttl;
+} ;
+
+
+
+
+
+} // namespace mpls
+
+typedef mpls::MplsHdr MplsHdr;
 
 #define MPLS_PAYLOADTYPE_ETHERNET     1
 #define MPLS_PAYLOADTYPE_IPV4         2
 #define MPLS_PAYLOADTYPE_IPV6         3
 #define MPLS_PAYLOADTYPE_ERROR       -1
 
-void DecodeMPLS(const uint8_t*, const uint32_t, Packet*);
-
 
 #endif
+
index ccaa6bc6e16545ff2840dce6a4bc4639a48512e9..874778b40c7e45aa168d61b52463e901449e63da 100644 (file)
@@ -61,7 +61,7 @@ extern "C" {
 #include "protocols/icmp6.h"
 #include "protocols/arp.h"
 #include "protocols/gre.h"
-
+#include "protocols/mpls.h"
 
 /*  D E F I N E S  ************************************************************/
 
@@ -625,16 +625,6 @@ typedef struct _PPPoE_Tag
                             /* payload follows */
 } PPPoE_Tag;
 
-#define MPLS_HEADER_LEN    4
-#define NUM_RESERVED_LABELS    16
-
-typedef struct _MplsHdr
-{
-    uint32_t label;
-    uint8_t  exp;
-    uint8_t  bos;
-    uint8_t  ttl;
-} MplsHdr;
 
 #define PGM_NAK_ERR -1
 #define PGM_NAK_OK 0
index a5fb3badc6a0d029574517289b3caaa1b11940a0..894e67938fce17fcad5c9b926a0d73aa0c99681a 100644 (file)
@@ -32,7 +32,6 @@ namespace teredo
 namespace detail
 {
 
-const uint16_t TEREDO_ID = 0x0100;
 const uint32_t TEREDO_PORT = 3544;
 const uint32_t TEREDO_INDICATOR_ORIGIN = 0x00;
 const uint32_t TEREDO_INDICATOR_ORIGIN_LEN = 8;
@@ -44,10 +43,6 @@ const uint32_t TEREDO_MIN_LEN = 2;
 } // namespace detail
 
 
-inline uint16_t teredo_id()
-{
-    return detail::TEREDO_ID;
-}
 
 inline bool is_teredo_port(uint16_t port)
 {
similarity index 71%
rename from src/codecs/tmp/prot_ethovermpls.h
rename to src/protocols/undefined_protocols.h
index a481785984c094e5031abaab6e87b47608ac4b37..1f856e7c92640042c5244baa75527dc83071ac1e 100644 (file)
 */
 
 
-#ifndef PROT_ETHOVERMPLS_H
-#define PROT_ETHOVERMPLS_H
-
-void DecodeEthOverMPLS(const uint8_t*, const uint32_t, Packet*);
+#ifndef UNDEFINED_PROTOCOLS_H
+#define UNDEFINED_PROTOCOLS_H
 
+/*
+ *  PROTOCOL ID'S By Range
+ *   0    (0x0000) -   255  (0x00FF)  --> Ip protocols
+ *   256  (0x0100) -  1535  (0x05FF)  -->  random protocols (teredo, gtp)
+ *  1536  (0x6000) -  65536 (0xFFFF)  --> Ethertypes
+ */
+const uint16_t PROTOCOL_TEREDO = 0x0100;
+const uint16_t PROTOCOL_GTP = 0x0101;
 
 #endif
-