print-lwapp.c \
print-lwres.c \
print-m3ua.c \
+ print-medsa.c \
print-mobile.c \
print-mpcp.c \
print-mpls.c \
#ifndef ETHERTYPE_GEONET
#define ETHERTYPE_GEONET 0x8947 /* ETSI GeoNetworking (Official IEEE registration from Jan 2013) */
#endif
+#ifndef ETHERTYPE_MEDSA
+#define ETHERTYPE_MEDSA 0xdada /* Marvel Distributed Switch Architecture */
+#endif
extern const struct tok ethertype_values[];
const u_char *bp, const int length, const u_char *bp2,
int *nhdr, int *padlen);
extern void arp_print(netdissect_options *,const u_char *, u_int, u_int);
+extern void medsa_print(netdissect_options *, const u_char *, u_int, u_int);
extern void tipc_print(netdissect_options *, const u_char *, u_int, u_int);
extern void msnlb_print(netdissect_options *, const u_char *);
extern void icmp6_print(netdissect_options *ndo, const u_char *,
{ ETHERTYPE_GEONET, "GeoNet"},
{ ETHERTYPE_CALM_FAST, "CALM FAST"},
{ ETHERTYPE_AOE, "AoE" },
+ { ETHERTYPE_MEDSA, "MEDSA" },
{ 0, NULL}
};
aoe_print(ndo, p, length);
return (1);
+ case ETHERTYPE_MEDSA:
+ medsa_print(ndo, p, length, caplen);
+ return (1);
+
case ETHERTYPE_LAT:
case ETHERTYPE_SCA:
case ETHERTYPE_MOPRC:
--- /dev/null
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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, (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, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "ether.h"
+#include "ethertype.h"
+#include "extract.h" /* must come after interface.h */
+
+static const char tstr[] = "[|MEDSA]";
+
+/*
+ * Marvell Extended Distributed Switch Archiecture.
+ *
+ * A Marvell propriatary header used for passing packets to/from
+ * specific ports of a switch. There is no open specification of this
+ * header, but is documented in the Marvell Switch data sheets. For
+ * background, see:
+ *
+ * https://lwn.net/Articles/302333/
+ */
+struct medsa_pkthdr {
+ u_char bytes[6];
+ u_short ether_type;
+};
+
+/* Bytes 0 and 1 are reserved and should contain 0 */
+#define TAG(medsa) (medsa->bytes[2] >> 6)
+#define TAG_TO_CPU 0
+#define TAG_FROM_CPU 1
+#define TAG_FORWARD 3
+#define SRC_TAG(medsa) ((medsa->bytes[2] >> 5) & 0x01)
+#define SRC_DEV(medsa) (medsa->bytes[2] & 0x1f)
+#define SRC_PORT(medsa) ((medsa->bytes[3] >> 3) & 0x01f)
+#define TRUNK(medsa) ((medsa->bytes[3] >> 2) & 0x01)
+#define CODE(medsa) ((medsa->bytes[3] & 0x06) | \
+ ((medsa->bytes[4] >> 4) & 0x01))
+#define CODE_BDPU 0
+#define CODE_IGMP_MLD 2
+#define CODE_ARP_MIRROR 4
+#define CFI(medsa) (medsa->bytes[3] & 0x01)
+#define PRI(medsa) (medsa->bytes[4] >> 5)
+#define VID(medsa) (((u_short)(medsa->bytes[4] & 0xf) << 8 | \
+ medsa->bytes[5]))
+
+static const struct tok tag_values[] = {
+ { TAG_TO_CPU, "To_CPU" },
+ { TAG_FROM_CPU, "From_CPU" },
+ { TAG_FORWARD, "Forward" },
+ { 0, NULL },
+};
+
+static const struct tok code_values[] = {
+ { CODE_BDPU, "BDPU" },
+ { CODE_IGMP_MLD, "IGMP/MLD" },
+ { CODE_ARP_MIRROR, "APR_Mirror" },
+ { 0, NULL },
+};
+
+static void medsa_print_full(netdissect_options *ndo,
+ const struct medsa_pkthdr *medsa,
+ u_int caplen)
+{
+ u_char tag = TAG(medsa);
+
+ ND_PRINT((ndo, "%s",
+ tok2str(tag_values, "Unknown (%u)", tag)));
+
+ switch (tag) {
+ case TAG_TO_CPU:
+ ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
+ ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
+ SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
+
+ ND_PRINT((ndo, ", %s",
+ tok2str(code_values, "Unknown (%u)", CODE(medsa))));
+ if (CFI(medsa))
+ ND_PRINT((ndo, ", CFI"));
+
+ ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
+ break;
+ case TAG_FROM_CPU:
+ ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
+ ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
+ SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
+
+ if (CFI(medsa))
+ ND_PRINT((ndo, ", CFI"));
+
+ ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
+ break;
+ case TAG_FORWARD:
+ ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
+ if (TRUNK(medsa))
+ ND_PRINT((ndo, ", dev.trunk:vlan %d.%d:%d",
+ SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
+ else
+ ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
+ SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
+
+ if (CFI(medsa))
+ ND_PRINT((ndo, ", CFI"));
+
+ ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
+ break;
+ default:
+ ND_DEFAULTPRINT((const u_char *)medsa, caplen);
+ return;
+ }
+}
+
+void
+medsa_print(netdissect_options *ndo,
+ const u_char *bp, u_int length, u_int caplen)
+{
+ register const struct ether_header *ep;
+ const struct medsa_pkthdr *medsa;
+ u_short ether_type;
+
+ medsa = (const struct medsa_pkthdr *)bp;
+ ep = (const struct ether_header *)(bp - sizeof(*ep));
+ ND_TCHECK(*medsa);
+
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "MEDSA %d.%d:%d: ",
+ SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
+ else
+ medsa_print_full(ndo, medsa, caplen);
+
+ bp += 8;
+ length -= 8;
+ caplen -= 8;
+
+ ether_type = EXTRACT_16BITS(&medsa->ether_type);
+ if (ether_type <= ETHERMTU) {
+ /* Try to print the LLC-layer header & higher layers */
+ if (llc_print(ndo, bp, length, caplen, ESRC(ep), EDST(ep)) < 0)
+ /* ether_type not known, print raw packet */
+ ND_DEFAULTPRINT(bp, caplen);
+ } else {
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "ethertype %s (0x%04x) ",
+ tok2str(ethertype_values, "Unknown",
+ ether_type),
+ ether_type));
+
+ ethertype_print(ndo, ether_type, bp, length, caplen);
+ }
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+/*
+ * Local Variables:
+ * c-style: bsd
+ * End:
+ */
+
dhcp-rfc3004 dhcp-rfc3004.pcap dhcp-rfc3004-v.out -t -v
dhcp-rfc5859 dhcp-rfc5859.pcap dhcp-rfc5859-v.out -t -v
+# MEDSA tests
+
+medsa medsa.pcap medsa.out -t
+medsa-e medsa.pcap medsa-e.out -t -e
+
# bad packets from Kevin Day
# cve-2015-2155 -- futz testing on FORCES printer
kday1 kday1.pcap kday1.out -t -v
--- /dev/null
+26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+94:10:3e:80:bc:f3 > 00:22:02:00:18:44, ethertype MEDSA (0xdada), length 98: From_CPU, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.12.59483 > 198.110.48.12.123: NTPv4, Client, length 48
+00:22:02:00:18:44 > 94:10:3e:80:bc:f3, ethertype MEDSA (0xdada), length 98: Forward, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 198.110.48.12.123 > 10.0.0.12.59483: NTPv4, Server, length 48
+26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+94:10:3e:80:bc:f3 > 00:22:02:00:18:44, ethertype MEDSA (0xdada), length 98: From_CPU, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.12.59809 > 66.228.42.59.123: NTPv4, Client, length 48
+94:10:3e:80:bc:f3 > 00:22:02:00:18:44, ethertype MEDSA (0xdada), length 98: From_CPU, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.12.58880 > 199.102.46.76.123: NTPv4, Client, length 48
+00:22:02:00:18:44 > 94:10:3e:80:bc:f3, ethertype MEDSA (0xdada), length 98: Forward, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 199.102.46.76.123 > 10.0.0.12.58880: NTPv4, Server, length 48
+00:22:02:00:18:44 > 94:10:3e:80:bc:f3, ethertype MEDSA (0xdada), length 98: Forward, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 66.228.42.59.123 > 10.0.0.12.59809: NTPv4, Server, length 48
+26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+94:10:3e:80:bc:f3 > 00:22:02:00:18:44, ethertype MEDSA (0xdada), length 98: From_CPU, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.12.41068 > 208.97.140.69.123: NTPv4, Client, length 48
+00:22:02:00:18:44 > 94:10:3e:80:bc:f3, ethertype MEDSA (0xdada), length 98: Forward, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 208.97.140.69.123 > 10.0.0.12.41068: NTPv4, Server, length 48
+26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+94:10:3e:80:bc:f3 > 00:22:02:00:18:44, ethertype MEDSA (0xdada), length 350: From_CPU, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.12.68 > 10.0.0.1.67: BOOTP/DHCP, Request from 94:10:3e:80:bc:f3, length 300
+00:22:02:00:18:44 > 94:10:3e:80:bc:f3, ethertype MEDSA (0xdada), length 350: Forward, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.1.67 > 10.0.0.12.68: BOOTP/DHCP, Reply, length 300
+26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+94:10:3e:80:bc:f3 > 00:22:02:00:18:44, ethertype MEDSA (0xdada), length 98: From_CPU, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.12.45651 > 171.66.97.126.123: NTPv4, Client, length 48
+00:22:02:00:18:44 > 94:10:3e:80:bc:f3, ethertype MEDSA (0xdada), length 98: Forward, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 171.66.97.126.123 > 10.0.0.12.45651: NTPv4, Server, length 48
--- /dev/null
+MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+MEDSA 0.3:0: IP 10.0.0.12.59483 > 198.110.48.12.123: NTPv4, Client, length 48
+MEDSA 0.3:0: IP 198.110.48.12.123 > 10.0.0.12.59483: NTPv4, Server, length 48
+MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+MEDSA 0.3:0: IP 10.0.0.12.59809 > 66.228.42.59.123: NTPv4, Client, length 48
+MEDSA 0.3:0: IP 10.0.0.12.58880 > 199.102.46.76.123: NTPv4, Client, length 48
+MEDSA 0.3:0: IP 199.102.46.76.123 > 10.0.0.12.58880: NTPv4, Server, length 48
+MEDSA 0.3:0: IP 66.228.42.59.123 > 10.0.0.12.59809: NTPv4, Server, length 48
+MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+MEDSA 0.3:0: IP 10.0.0.12.41068 > 208.97.140.69.123: NTPv4, Client, length 48
+MEDSA 0.3:0: IP 208.97.140.69.123 > 10.0.0.12.41068: NTPv4, Server, length 48
+MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+MEDSA 0.3:0: IP 10.0.0.12.68 > 10.0.0.1.67: BOOTP/DHCP, Request from 94:10:3e:80:bc:f3, length 300
+MEDSA 0.3:0: IP 10.0.0.1.67 > 10.0.0.12.68: BOOTP/DHCP, Reply, length 300
+MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43
+MEDSA 0.3:0: IP 10.0.0.12.45651 > 171.66.97.126.123: NTPv4, Client, length 48
+MEDSA 0.3:0: IP 171.66.97.126.123 > 10.0.0.12.45651: NTPv4, Server, length 48