From: hannes Date: Fri, 10 Feb 2006 04:52:25 +0000 (+0000) Subject: add basic support for MPCP 802.3ah frame printer X-Git-Tag: tcpdump-4.0.0~257 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/0860434f38178598fff25ede38436ff55ffedce5 add basic support for MPCP 802.3ah frame printer --- diff --git a/FILES b/FILES index b011a3ce..b57291ca 100644 --- 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 diff --git a/Makefile.in b/Makefile.in index 44df1565..b605ed6a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 \ diff --git a/ethertype.h b/ethertype.h index 4f85202b..17d81965 100644 --- a/ethertype.h +++ b/ethertype.h @@ -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) */ /* @@ -109,6 +109,9 @@ #ifndef ETHERTYPE_PPP #define ETHERTYPE_PPP 0x880b #endif +#ifndef ETHERTYPE_MPCP +#define ETHERTYPE_MPCP 0x8808 +#endif #ifndef ETHERTYPE_SLOW #define ETHERTYPE_SLOW 0x8809 #endif diff --git a/interface.h b/interface.h index f2a371d1..43590dea 100644 --- a/interface.h +++ b/interface.h @@ -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); diff --git a/print-ether.c b/print-ether.c index 6766faba..ecd5ba87 100644 --- a/print-ether.c +++ b/print-ether.c @@ -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 index 00000000..97b5d66d --- /dev/null +++ b/print-mpcp.c @@ -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 (hannes@juniper.net) + */ + +#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 + +#include +#include +#include + +#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]"); +} diff --git a/win32/prj/GNUmakefile b/win32/prj/GNUmakefile index 75be0ac4..dbbd32eb 100644 --- a/win32/prj/GNUmakefile +++ b/win32/prj/GNUmakefile @@ -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 \ diff --git a/win32/prj/WinDump.dsp b/win32/prj/WinDump.dsp index 17770326..9b7a75b0 100644 --- a/win32/prj/WinDump.dsp +++ b/win32/prj/WinDump.dsp @@ -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