|
| 1 | +/* |
| 2 | + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 |
| 3 | + * The Regents of the University of California. All rights reserved. |
| 4 | + * |
| 5 | + * Redistribution and use in source and binary forms, with or without |
| 6 | + * modification, are permitted provided that: (1) source code distributions |
| 7 | + * retain the above copyright notice and this paragraph in its entirety, (2) |
| 8 | + * distributions including binary code include the above copyright notice and |
| 9 | + * this paragraph in its entirety in the documentation or other materials |
| 10 | + * provided with the distribution, and (3) all advertising materials mentioning |
| 11 | + * features or use of this software display the following acknowledgement: |
| 12 | + * ``This product includes software developed by the University of California, |
| 13 | + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of |
| 14 | + * the University nor the names of its contributors may be used to endorse |
| 15 | + * or promote products derived from this software without specific prior |
| 16 | + * written permission. |
| 17 | + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
| 18 | + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
| 19 | + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 20 | + */ |
| 21 | + |
| 22 | +/* based on print-dsa.c */ |
| 23 | + |
| 24 | +/* \summary: MaxLinear (Ethertype) Distributed Switch Architecture */ |
| 25 | + |
| 26 | +#ifdef HAVE_CONFIG_H |
| 27 | +#include <config.h> |
| 28 | +#endif |
| 29 | + |
| 30 | +#include "netdissect-stdinc.h" |
| 31 | + |
| 32 | +#include "netdissect.h" |
| 33 | +#include "ethertype.h" |
| 34 | +#include "addrtoname.h" |
| 35 | +#include "extract.h" |
| 36 | + |
| 37 | +/* |
| 38 | + * Ingress and Egress have different formats. |
| 39 | + * |
| 40 | + * Format of (Ethertyped) Ingress tagged frames: |
| 41 | + * |
| 42 | + * 0 +----+----+----+----+----+----+----+----+ |
| 43 | + * | Ether Destination Address | |
| 44 | + * +6 +----+----+----+----+----+----+----+----+ |
| 45 | + * | Ether Source Address | |
| 46 | + * +6 +----+----+----+----+----+----+----+----+ +- |
| 47 | + * | Prog. DSA Ether Type [15:8] | | (8-byte) Special Tag |
| 48 | + * +1 +----+----+----+----+----+----+----+----+ | Contains a programmable Ether type. |
| 49 | + * | Prog. DSA Ether Type [7:0] | | + |
| 50 | + * +1 +----+----+----+----+----+----+----+----+ | | (6-byte) Special Tag Content |
| 51 | + * |PME[7] TCE[6] TSE[5] FNL[4] TTC[3:0] | | | |
| 52 | + * +1 +----+----+----+----+----+----+----+----+ | | |
| 53 | + * | TEPML [7:0] | | | |
| 54 | + * +1 +----+----+----+----+----+----+----+----+ | | |
| 55 | + * | TEPMH [7:0] | | | |
| 56 | + * +1 +----+----+----+----+----+----+----+----+ | | |
| 57 | + * | Res[7:5] IE[4] SP[3:0] | | | |
| 58 | + * +1 +----+----+----+----+----+----+----+----+ | | |
| 59 | + * | Res [7:0] all zero | | | |
| 60 | + * +1 +----+----+----+----+----+----+----+----+ | | |
| 61 | + * | Res [7:0] all zero | | | |
| 62 | + * +1 +----+----+----+----+----+----+----+----+ +- +- |
| 63 | + * |
| 64 | + * Format of (Ethertyped) Egress tagged frames: |
| 65 | + * |
| 66 | + * 0 +----+----+----+----+----+----+----+----+ |
| 67 | + * | Ether Destination Address | |
| 68 | + * +6 +----+----+----+----+----+----+----+----+ |
| 69 | + * | Ether Source Address | |
| 70 | + * +6 +----+----+----+----+----+----+----+----+ +- |
| 71 | + * | Prog. DSA Ether Type [15:8] | | (8-byte) Special Tag |
| 72 | + * +1 +----+----+----+----+----+----+----+----+ | Contains a programmable Ether type. |
| 73 | + * | Prog. DSA Ether Type [7:0] | | + |
| 74 | + * +1 +----+----+----+----+----+----+----+----+ | | (6-byte) Special Tag Content |
| 75 | + * | TC[7:4] IPN [3:0] | | | |
| 76 | + * +1 +----+----+----+----+----+----+----+----+ | | |
| 77 | + * | PPPOE[7] IPV[6] IPO[5:0] | | | |
| 78 | + * +1 +----+----+----+----+----+----+----+----+ | | |
| 79 | + * | DLPML [7:0] | | | |
| 80 | + * +1 +----+----+----+----+----+----+----+----+ | | |
| 81 | + * | DLPMR [7:0] | | | |
| 82 | + * +1 +----+----+----+----+----+----+----+----+ | | |
| 83 | + * | MI[7] KL2UM[6] PLHB[5:0] | | | |
| 84 | + * +1 +----+----+----+----+----+----+----+----+ | | |
| 85 | + * | PLLB [7:0] | | | |
| 86 | + * +2 +----+----+----+----+----+----+----+----+ +- +- |
| 87 | + * . . . . . . . . . |
| 88 | + * |
| 89 | + * PME: Port map enable |
| 90 | + * IPN: Ingress port number |
| 91 | + * TCE: Traffic class enable |
| 92 | + * TSE: Time stamp enable |
| 93 | + * FNL: Force no learning |
| 94 | + * TC: Traffic class |
| 95 | + * IPV: IPv4 packet |
| 96 | + * IPO: IP offset |
| 97 | + * SP: Source port |
| 98 | + * IE: Interrupt enable |
| 99 | + * PPPOE: ppp-over-ethernet |
| 100 | + * DLPML: Destination logical port map low bits. |
| 101 | + * DLPMR: Destination logical port map high (reserved) |
| 102 | + * MI: Mirror indication |
| 103 | + * KL2UM Known l2 unicast/multicast mac. |
| 104 | + * PLHB: Packet Length High Bits |
| 105 | + * PLLB: Packet Length Low Bits. |
| 106 | + * TEPML: Target egress port maps low bits |
| 107 | + * TEPMH: Target egress port maps high bits (reserved) |
| 108 | + * Res: Reserved |
| 109 | + */ |
| 110 | + |
| 111 | +#define TOK(tag, byte, mask, shift) ((GET_U_1(&(((const u_char *) tag)[byte])) & (mask)) >> (shift)) |
| 112 | + |
| 113 | +#define GSW1XX_ET1(tag) TOK(tag, 0, 0xFF, 0) |
| 114 | +#define GSW1XX_ET2(tag) TOK(tag, 1, 0xFF, 0) |
| 115 | +#define GSW1XX_TTC(tag) TOK(tag, 2, 0x08, 0) |
| 116 | +#define GSW1XX_IG_PME(tag) TOK(tag, 2, 0x80, 7) |
| 117 | +#define GSW1XX_IG_TCE(tag) TOK(tag, 2, 0x40, 6) |
| 118 | +#define GSW1XX_IG_TSE(tag) TOK(tag, 2, 0x20, 5) |
| 119 | +#define GSW1XX_IG_FNL(tag) TOK(tag, 2, 0x10, 4) |
| 120 | +#define GSW1XX_IG_SP(tag) TOK(tag, 2, 0x0F, 0) |
| 121 | +#define GSW1XX_IG_IE(tag) TOK(tag, 5, 0x10, 3) |
| 122 | +#define GSW1XX_EG_IPN(tag) TOK(tag, 2, 0x0F, 0) |
| 123 | +#define GSW1XX_EG_TC(tag) TOK(tag, 2, 0xF0, 4) |
| 124 | +#define GSW1XX_EG_POE(tag) TOK(tag, 2, 0x80, 7) |
| 125 | +#define GSW1XX_EG_IV4(tag) TOK(tag, 2, 0x40, 6) |
| 126 | +#define GSW1XX_EG_IPO(tag) TOK(tag, 3, 0x3F, 0) |
| 127 | + |
| 128 | +#define GSW1XX_MAP_LOW(tag) TOK(tag, 3, 0xFF, 0) |
| 129 | +#define GSW1XX_MAP_HIGH(tag) TOK(tag, 4, 0xFF, 0) |
| 130 | +#define GSW1XX_MAP(tag) ((GSW1XX_MAP_HIGH(tag) << 8) + GSW1XX_MAP_LOW(tag)) |
| 131 | +#define GSW1XX_LEN_LOW(tag) TOK(tag, 7, 0xFF, 0) |
| 132 | +#define GSW1XX_LEN_HIGH(tag) TOK(tag, 6, 0x3F, 0) |
| 133 | +#define GSW1XX_LEN(tag) ((GSW1XX_LEN_HIGH(tag) << 8) + GSW1XX_LEN_LOW(tag)) |
| 134 | + |
| 135 | +#define SPTAG_LEN 8 |
| 136 | + |
| 137 | +static void |
| 138 | +tag_common_print(netdissect_options *ndo, const u_char *p) |
| 139 | +{ |
| 140 | + if (ndo->ndo_eflag ) { |
| 141 | + int egress = !!GSW1XX_LEN(p); |
| 142 | + |
| 143 | + if (egress) { |
| 144 | + ND_PRINT("Egress Port %d,", GSW1XX_EG_IPN(p)); |
| 145 | + if (ndo->ndo_eflag > 1) { |
| 146 | + ND_PRINT("TTC %d,", GSW1XX_TTC(p)); |
| 147 | + ND_PRINT("TC %d,", GSW1XX_EG_TC(p)); |
| 148 | + ND_PRINT("IPN %d,", GSW1XX_EG_IPN(p)); |
| 149 | + ND_PRINT("POE %d,", GSW1XX_EG_POE(p)); |
| 150 | + if (GSW1XX_EG_IPO(p)) { |
| 151 | + ND_PRINT("IV4 %d,", GSW1XX_EG_IV4(p)); |
| 152 | + ND_PRINT("IPO %d,", GSW1XX_EG_IPO(p)); |
| 153 | + } |
| 154 | + ND_PRINT("Len %d,", GSW1XX_LEN(p)); |
| 155 | + } |
| 156 | + } else { |
| 157 | + ND_PRINT("Ingress Port %d,", GSW1XX_IG_SP(p)); |
| 158 | + ND_PRINT("MAP %d,", GSW1XX_MAP(p)); |
| 159 | + if (ndo->ndo_eflag > 1) { |
| 160 | + ND_PRINT("PME %d,", GSW1XX_IG_PME(p)); |
| 161 | + ND_PRINT("TCE %d,", GSW1XX_IG_TCE(p)); |
| 162 | + ND_PRINT("TTC %d,", GSW1XX_TTC(p)); |
| 163 | + ND_PRINT("FNL %d,", GSW1XX_IG_FNL(p)); |
| 164 | + ND_PRINT("IE %d,", GSW1XX_IG_IE(p)); |
| 165 | + ND_PRINT("TSE %d,", GSW1XX_IG_TSE(p)); |
| 166 | + } |
| 167 | + } |
| 168 | + } |
| 169 | +} |
| 170 | + |
| 171 | +static void |
| 172 | +gsw1xx_tag_print(netdissect_options *ndo, const u_char *bp) |
| 173 | +{ |
| 174 | + const u_char *p = bp; |
| 175 | + uint16_t sptag_etype; |
| 176 | + |
| 177 | + sptag_etype = GET_BE_U_2(p); |
| 178 | + if (ndo->ndo_eflag > 2) { |
| 179 | + ND_PRINT("MaxLinear ethertype 0x%04x (%s), ", sptag_etype, |
| 180 | + tok2str(ethertype_values, "Unknown", sptag_etype)); |
| 181 | + } else { |
| 182 | + if (sptag_etype == ETHERTYPE_GSW1XX) |
| 183 | + ND_PRINT("GSW1XX "); |
| 184 | + else |
| 185 | + ND_PRINT("GSW1XX Unknown 0x%04x, ", sptag_etype); |
| 186 | + } |
| 187 | + tag_common_print(ndo, p); |
| 188 | +} |
| 189 | + |
| 190 | +void |
| 191 | +gsw1xx_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) |
| 192 | +{ |
| 193 | + u_int caplen = h->caplen; |
| 194 | + u_int length = h->len; |
| 195 | + |
| 196 | + ndo->ndo_protocol = "gsw1xx"; |
| 197 | + ndo->ndo_ll_hdr_len += |
| 198 | + ether_switch_tag_print(ndo, p, length, caplen, gsw1xx_tag_print, SPTAG_LEN); |
| 199 | +} |
0 commit comments