decode-teredo.c decode-teredo.h \
decode-udp.c decode-udp.h \
decode-vlan.c decode-vlan.h \
+decode-mpls.c decode-mpls.h \
defrag-config.c defrag-config.h \
defrag.c defrag.h \
defrag-hash.c defrag-hash.h \
DecodeVLAN(tv, dtv, p, pkt + ETHERNET_HEADER_LEN,
len - ETHERNET_HEADER_LEN, pq);
break;
+ case ETHERNET_TYPE_MPLS_UNICAST:
+ case ETHERNET_TYPE_MPLS_MULTICAST:
+ DecodeMPLS(tv, dtv, p, pkt + ETHERNET_HEADER_LEN,
+ len - ETHERNET_HEADER_LEN, pq);
+ break;
default:
SCLogDebug("p %p pkt %p ether type %04x not supported", p,
pkt, ntohs(p->ethh->eth_type));
--- /dev/null
+/* Copyright (C) 2014 Open Information Security Foundation
+ *
+ * You can copy, redistribute or modify this Program under the terms of
+ * the GNU General Public License version 2 as published by the Free
+ * Software Foundation.
+ *
+ * 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
+ * version 2 along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+/**
+ * \file
+ *
+ * \author Jason Ish <jason.ish@emulex.com>
+ *
+ * MPLS decoder.
+ */
+
+#include "suricata-common.h"
+#include "decode.h"
+
+#define MPLS_HEADER_LEN 4
+#define MPLS_BOTTOM(shim) ((ntohl(shim) >> 8) & 0x1)
+#define MPLS_PROTO_IPV4 4
+#define MPLS_PROTO_IPV6 6
+
+int DecodeMPLS(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt,
+ uint16_t len, PacketQueue *pq)
+{
+ if (len < MPLS_HEADER_LEN) {
+ return TM_ECODE_FAILED;
+ }
+
+ uint32_t shim;
+ do {
+ shim = *(uint32_t *)pkt;
+ pkt += MPLS_HEADER_LEN;
+ len -= MPLS_HEADER_LEN;
+ } while (MPLS_BOTTOM(shim) == 0);
+
+ /* Best guess at inner packet. */
+ uint8_t ip_ver = pkt[0] >> 4;
+
+ switch (ip_ver) {
+ case MPLS_PROTO_IPV4:
+ return DecodeIPV4(tv, dtv, p, pkt, len, pq);
+ break;
+ case MPLS_PROTO_IPV6:
+ return DecodeIPV6(tv, dtv, p, pkt, len, pq);
+ break;
+ default:
+ break;
+ }
+
+ return TM_ECODE_FAILED;
+}
--- /dev/null
+/* Copyright (C) 2014 Open Information Security Foundation
+ *
+ * You can copy, redistribute or modify this Program under the terms of
+ * the GNU General Public License version 2 as published by the Free
+ * Software Foundation.
+ *
+ * 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
+ * version 2 along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+/**
+ * \file
+ *
+ * \author Jason Ish <jason.ish@emulex.com>
+ *
+ * MPLS decoder.
+ */
+
+#ifndef __DECODE_MPLS_H__
+#define __DECODE_MPLS_H__
+
+#define ETHERNET_TYPE_MPLS_UNICAST 0x8847
+#define ETHERNET_TYPE_MPLS_MULTICAST 0x8848
+
+#endif /* !__DECODE_MPLS_H__ */
#include "decode-sctp.h"
#include "decode-raw.h"
#include "decode-vlan.h"
+#include "decode-mpls.h"
#include "detect-reference.h"
int DecodeSCTP(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *);
int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *);
int DecodeVLAN(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *);
+int DecodeMPLS(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *);
void AddressDebugPrint(Address *);