tcpdump mailing list archives

[PATCH] surport the IEEE 802.1ah Mac in Mac


From: "Liuyongqiang(A)" <liu.liuyongqiang () huawei com>
Date: Fri, 17 Oct 2014 14:08:22 +0800

From: liuyongqiang <liu.liuyongqiang () huawei com>

Signed-off-by: liuyongqiang <liu.liuyongqiang () huawei com>
---
 Makefile.in   |  2 ++
 ethertype.h   |  3 +++
 pbb.h         | 44 ++++++++++++++++++++++++++++++++++++
 print-chdlc.c |  3 +++
 print-ether.c | 11 ++++++++-
 print-gre.c   |  3 +++
 print-pbb.c   | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 137 insertions(+), 1 deletion(-)
 create mode 100644 pbb.h
 create mode 100644 print-pbb.c

diff --git a/Makefile.in b/Makefile.in
index 5879b93..fc61e7c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -209,6 +209,7 @@ LIBNETDISSECT_SRC=\
        print-wb.c \
        print-zephyr.c \
        print-zeromq.c \
+       print-pbb.c \
        signature.c \
        util.c
 
@@ -269,6 +270,7 @@ HDR = \
        smb.h \
        tcp.h \
        tcpdump-stdinc.h \
+       pbb.h \
        udp.h
 
 TAGHDR = \
diff --git a/ethertype.h b/ethertype.h
index 8039917..b10847e 100644
--- a/ethertype.h
+++ b/ethertype.h
@@ -136,6 +136,9 @@
 #ifndef        ETHERTYPE_MPLS
 #define        ETHERTYPE_MPLS          0x8847
 #endif
+#ifndef ETHERTYPE_PBB
+#define ETHERTYPE_PBB      0x88e7
+#endif
 #ifndef        ETHERTYPE_MPLS_MULTI
 #define        ETHERTYPE_MPLS_MULTI    0x8848
 #endif
diff --git a/pbb.h b/pbb.h
new file mode 100644
index 0000000..9db7db6
--- /dev/null
+++ b/pbb.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2001 WIDE Project.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#define PBB_ISID_MASK       0x00ffffff
+#define PBB_ISID_SHIFT      0
+#define PBB_RES_MASK       0x7000000
+#define PBB_RES_SHIFT      24
+#define PBB_UCA_MASK        0x8000000
+#define PBB_UCA_SHIFT        27
+#define PBB_DEL_MASK     0x10000000
+#define PBB_DEL_SHIFT     28
+#define PBB_PCP_MASK     0xe0000000
+#define PBB_PCP_SHIFT    29
+
+#define PBB_ISID(x)    (((x) & PBB_ISID_MASK) >> PBB_ISID_SHIFT)
+#define PBB_RES(x)     (((x) & PBB_RES_MASK) >> PBB_RES_SHIFT)
+#define PBB_UCA(x)     (((x) & PBB_UCA_MASK) >> PBB_UCA_SHIFT)
+#define PBB_DEL(x)     (((x) & PBB_DEL_MASK) >> PBB_DEL_SHIFT)
+#define PBB_PCP(x)   (((x)& PBB_PCP_MASK) >> PBB_PCP_SHIFT)
diff --git a/print-chdlc.c b/print-chdlc.c
index 8230c87..c32f8f5 100644
--- a/print-chdlc.c
+++ b/print-chdlc.c
@@ -90,6 +90,9 @@ chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length) {
         case ETHERTYPE_MPLS_MULTI:
                 mpls_print(ndo, p, length);
                break;
+        case ETHERTYPE_PBB:
+                pbb_print(ndo, p, length);
+        break;
         case ETHERTYPE_ISO:
                 /* is the fudge byte set ? lets verify by spotting ISO headers */
                 if (*(p+1) == 0x81 ||
diff --git a/print-ether.c b/print-ether.c
index 49e7803..4f17c13 100644
--- a/print-ether.c
+++ b/print-ether.c
@@ -83,6 +83,7 @@ const struct tok ethertype_values[] = {
     { ETHERTYPE_GEONET,         "GeoNet"},
     { ETHERTYPE_CALM_FAST,      "CALM FAST"},
     { ETHERTYPE_AOE,            "AoE" },
+    { ETHERTYPE_PBB,       "802.1ah-Mac-in-Mac" },
     { 0, NULL}
 };
 
@@ -95,7 +96,7 @@ ether_hdr_print(netdissect_options *ndo,
 
        ep = (const struct ether_header *)bp;
 
-       ND_PRINT((ndo, "%s > %s",
+       ND_PRINT((ndo, " %s > %s",
                     etheraddr_string(ndo, ESRC(ep)),
                     etheraddr_string(ndo, EDST(ep))));
 
@@ -232,6 +233,10 @@ recurse:
 
                        if (!ndo->ndo_suppress_default_print)
                                ND_DEFAULTPRINT(p, caplen);
+               } else {
+                   if (ether_type == ETHERTYPE_PBB){
+                       ether_hdr_print(ndo, (u_char *)ep, orig_length);
+                   }
                }
        }
 }
@@ -406,6 +411,10 @@ ethertype_print(netdissect_options *ndo,
                mpls_print(ndo, p, length);
                return (1);
 
+       case ETHERTYPE_PBB:
+           pbb_print(ndo, p, length);
+           return(1);
+
        case ETHERTYPE_TIPC:
                tipc_print(ndo, p, length, caplen);
                return (1);
diff --git a/print-gre.c b/print-gre.c
index 4d7705f..ab750ce 100644
--- a/print-gre.c
+++ b/print-gre.c
@@ -206,6 +206,9 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
        case ETHERTYPE_MPLS:
                mpls_print(ndo, bp, len);
                break;
+       case ETHERTYPE_PBB:
+           pbb_print(ndo, bp, len);
+           break;
        case ETHERTYPE_IPX:
                ipx_print(ndo, bp, len);
                break;
diff --git a/print-pbb.c b/print-pbb.c
new file mode 100644
index 0000000..df4e430
--- /dev/null
+++ b/print-pbb.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2001 WIDE Project.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"            /* must come after interface.h */
+#include "pbb.h"
+
+/*
+ * RFC3032: PBB stack encoding
+ */
+void
+pbb_print(netdissect_options *ndo, const u_char *bp, u_int length)
+{
+    const u_char *p;
+    uint32_t pbb_entry;
+    uint16_t pbb_stack_depth = 0;
+
+    p = bp;
+    ND_PRINT((ndo, "PBB,"));
+    ND_TCHECK2(*p, sizeof(pbb_entry));
+    pbb_entry = EXTRACT_32BITS(p);
+    ND_PRINT((ndo, "I-SID %u", PBB_ISID(pbb_entry)));
+    ND_PRINT((ndo, ", RES %u", PBB_RES(pbb_entry)));
+    ND_PRINT((ndo, ", UCA %u", PBB_UCA(pbb_entry)));
+    ND_PRINT((ndo, ", DEL %u", PBB_DEL(pbb_entry)));
+    ND_PRINT((ndo, ", PCP %u ", PBB_PCP(pbb_entry)));
+
+    return;
+
+trunc:
+    ND_PRINT((ndo, "[|PBB]"));
+}
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
-- 
1.9.4.msysgit.1


_______________________________________________
tcpdump-workers mailing list
tcpdump-workers () lists tcpdump org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers


Current thread: