]> The Tcpdump Group git mirrors - tcpdump/commitdiff
add basic support for MPCP 802.3ah frame printer
authorhannes <hannes>
Fri, 10 Feb 2006 04:52:25 +0000 (04:52 +0000)
committerhannes <hannes>
Fri, 10 Feb 2006 04:52:25 +0000 (04:52 +0000)
FILES
Makefile.in
ethertype.h
interface.h
print-ether.c
print-mpcp.c [new file with mode: 0644]
win32/prj/GNUmakefile
win32/prj/WinDump.dsp

diff --git a/FILES b/FILES
index b011a3cebdafa7832fa4a495e80b36c8afe80b7f..b57291ca52649ad7ba350ba9ed529a5d24b0d8fa 100644 (file)
--- a/FILES
+++ b/FILES
@@ -166,6 +166,7 @@ print-lspping.c
 print-lwres.c
 print-mobile.c
 print-mobility.c
+print-mpcp.c
 print-mpls.c
 print-msdp.c
 print-netbios.c
index 44df15652568005b0fd17c32b7c88ff25e3b0ec2..b605ed6a7a4828f0e112a2982afb87dca48bc256 100644 (file)
@@ -17,7 +17,7 @@
 #  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 #
-# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.297 2006-02-09 21:17:28 hannes Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.298 2006-02-10 04:52:25 hannes Exp $ (LBL)
 
 #
 # Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -79,7 +79,7 @@ CSRC =        addrtoname.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \
        print-ipx.c print-isakmp.c print-isoclns.c print-juniper.c print-krb.c \
        print-l2tp.c print-lane.c print-ldp.c print-llc.c \
         print-lmp.c print-lspping.c \
-       print-lwres.c print-mobile.c print-mpls.c print-msdp.c \
+       print-lwres.c print-mobile.c print-mpcp.c print-mpls.c print-msdp.c \
        print-nfs.c print-ntp.c print-null.c print-ospf.c \
        print-pflog.c print-pgm.c print-pim.c print-ppp.c print-pppoe.c \
        print-pptp.c print-radius.c print-raw.c print-rip.c \
index 4f85202b292588d7c2aba78219c1d69ab4faaab9..17d81965fa41a0c37b046d82b4f9f7b37a4143bb 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.25 2005-07-10 14:49:48 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.26 2006-02-10 04:52:25 hannes Exp $ (LBL)
  */
 
 /*
 #ifndef ETHERTYPE_PPP
 #define        ETHERTYPE_PPP           0x880b
 #endif
+#ifndef ETHERTYPE_MPCP
+#define        ETHERTYPE_MPCP          0x8808
+#endif
 #ifndef ETHERTYPE_SLOW
 #define        ETHERTYPE_SLOW          0x8809
 #endif
index f2a371d1485c230371013e8dbc9f07b45f9eaf5b..43590deae8e7ba68b6e93b598302056cde0d1479 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.266 2006-02-09 21:16:47 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.267 2006-02-10 04:52:25 hannes Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -296,6 +296,7 @@ extern void print_data(const unsigned char *, int);
 extern void l2tp_print(const u_char *, u_int);
 extern void vrrp_print(const u_char *, u_int, int);
 extern void slow_print(const u_char *, u_int);
+extern void mpcp_print(const u_char *, u_int);
 extern void pgm_print(const u_char *, u_int, const u_char *);
 extern void cdp_print(const u_char *, u_int, u_int);
 extern void stp_print(const u_char *, u_int);
index 6766faba6ba8ae2fdea1c48b26fdf3981cc30406..ecd5ba873a4800391fd85eedcfbed6a4d238eaa9 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.100 2005-11-13 12:12:41 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.101 2006-02-10 04:52:25 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -65,6 +65,7 @@ const struct tok ethertype_values[] = {
     { ETHERTYPE_AARP,           "Appletalk ARP" },
     { ETHERTYPE_IPX,            "IPX" },
     { ETHERTYPE_PPP,            "PPP" },
+    { ETHERTYPE_MPCP,           "MPCP" },
     { ETHERTYPE_SLOW,           "Slow Protocols" },
     { ETHERTYPE_PPPOED,         "PPPoE D" },
     { ETHERTYPE_PPPOES,         "PPPoE S" },
@@ -295,6 +296,10 @@ ether_encap_print(u_short ether_type, const u_char *p,
                }
                return (1);
 
+       case ETHERTYPE_MPCP:
+               mpcp_print(p, length);
+               return (1);
+
        case ETHERTYPE_SLOW:
                slow_print(p, length);
                return (1);
diff --git a/print-mpcp.c b/print-mpcp.c
new file mode 100644 (file)
index 0000000..97b5d66
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 1998-2006 The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ *
+ * support for the IEEE MPCP protocol as per 802.3ah
+ *
+ * Original code by Hannes Gredler ([email protected])
+ */
+
+#ifndef lint
+static const char rcsid[] _U_ =
+    "@(#) $Header: /tcpdump/master/tcpdump/print-mpcp.c,v 1.1 2006-02-10 04:52:25 hannes Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+#include "ether.h"
+
+struct mpcp_common_header_t {
+    u_int8_t opcode[2];
+    u_int8_t timestamp[4];
+};
+
+#define        MPCP_OPCODE_PAUSE        0x0001
+#define        MPCP_OPCODE_GATE         0x0002
+#define        MPCP_OPCODE_REPORT       0x0003
+#define        MPCP_OPCODE_REGISTER_REQ 0x0004
+#define        MPCP_OPCODE_REGISTER     0x0005
+#define        MPCP_OPCODE_REGISTER_ACK 0x0006
+
+static const struct tok mpcp_opcode_values[] = {
+    { MPCP_OPCODE_PAUSE, "Pause" },
+    { MPCP_OPCODE_GATE, "Gate" },
+    { MPCP_OPCODE_REPORT, "Report" },
+    { MPCP_OPCODE_REGISTER_REQ, "Register Request" },
+    { MPCP_OPCODE_REGISTER, "Register" },
+    { MPCP_OPCODE_REGISTER_ACK, "Register ACK" },
+    { 0, NULL}
+};
+
+#define        MPCP_GRANT_NUMBER_MASK 0x7 
+static const struct tok mpcp_grant_flag_values[] = {
+    { 0x08, "Discovery" },
+    { 0x10, "Force Grant #1" },
+    { 0x20, "Force Grant #2" },
+    { 0x40, "Force Grant #3" },
+    { 0x80, "Force Grant #4" },
+    { 0, NULL}
+};
+
+struct mpcp_grant_t {
+    u_int8_t starttime[4];
+    u_int8_t length[2];
+};
+
+static const struct tok mpcp_register_req_flag_values[] = {
+    { 1, "Register" },
+    { 3, "De-Register" },
+    { 0, NULL}
+};
+
+static const struct tok mpcp_register_flag_values[] = {
+    { 1, "Re-Register" },
+    { 2, "De-Register" },
+    { 3, "ACK" },
+    { 4, "NACK" },
+    { 0, NULL}
+};
+
+static const struct tok mpcp_register_ack_flag_values[] = {
+    { 0, "NACK" },
+    { 1, "ACK" },
+    { 0, NULL}
+};
+
+void
+mpcp_print(register const u_char *pptr, register u_int length) {
+
+    union {
+        const struct mpcp_common_header_t *common_header;
+        const struct mpcp_grant_t *grant;
+    } mpcp;
+
+
+    const u_char *tptr;
+    u_int16_t opcode;
+    u_int8_t grant_numbers, grant;
+
+    tptr=pptr;
+    mpcp.common_header = (const struct mpcp_common_header_t *)pptr;
+    TCHECK(*mpcp.common_header);
+
+    opcode = EXTRACT_16BITS(mpcp.common_header->opcode);
+
+    printf("MPCP, Opcode %s", tok2str(mpcp_opcode_values, "Unknown (%u)", opcode));
+    if (opcode != MPCP_OPCODE_PAUSE) {
+        printf(", Timestamp %u", EXTRACT_32BITS(mpcp.common_header->timestamp));
+    }
+    printf(", length %u", length);
+
+    if (!vflag)
+        return;
+
+    tptr += sizeof(const struct mpcp_common_header_t);
+
+    switch (opcode) {
+    case MPCP_OPCODE_PAUSE:
+        break;
+
+    case MPCP_OPCODE_GATE:
+        grant_numbers = *tptr & MPCP_GRANT_NUMBER_MASK;
+        printf("\n\tGrant Numbers %u, Flags [ %s ]",
+               grant_numbers,
+               bittok2str(mpcp_grant_flag_values,
+                          "?",
+                          *tptr &~ MPCP_GRANT_NUMBER_MASK));
+        tptr++;
+
+        for (grant = 1; grant <= grant_numbers; grant++) {
+            mpcp.grant = (const struct mpcp_grant_t *)tptr;        
+            printf("\n\tGrant #%u, Start-Time %u, length %u",
+                   grant,
+                   EXTRACT_32BITS(mpcp.grant->starttime),
+                   EXTRACT_16BITS(mpcp.grant->length));
+            tptr += sizeof(const struct mpcp_grant_t);
+        }
+
+        printf("\n\tSync-Time %u", EXTRACT_16BITS(tptr));
+        break;
+
+        /* FIXME */
+    case MPCP_OPCODE_REPORT:
+    case MPCP_OPCODE_REGISTER_REQ:
+    case MPCP_OPCODE_REGISTER:
+    case MPCP_OPCODE_REGISTER_ACK:
+    default:
+        break;
+    }
+
+    return;
+trunc:
+    printf("\n\t[|MPCP]");
+}
index 75be0ac496c522025766b8b97e932716fb608614..dbbd32ebe964d2c0e1f9ddbc247ab141353d4e84 100644 (file)
@@ -92,6 +92,7 @@ OBJS = \
        ../../print-lwres.o \
        ../../print-mobile.o \
        ../../print-mobility.o \
+       ../../print-mpcp.o \
        ../../print-mpls.o \
        ../../print-msdp.o \
        ../../print-nfs.o \
index 17770326da8fd95089b475012514db7af94666be..9b7a75b09e30ab20ce818ce587fe0f1a1cb37a97 100644 (file)
@@ -381,6 +381,10 @@ SOURCE="..\..\print-mobility.c"
 # End Source File
 # Begin Source File
 
+SOURCE="..\..\print-mpcp.c"
+# End Source File
+# Begin Source File
+
 SOURCE="..\..\print-mpls.c"
 # End Source File
 # Begin Source File