xref: /dflybsd-src/contrib/tcpdump/print-fddi.c (revision 59c07fbdf8168fa08c76c515186d561b5a92690c)
141c99275SPeter Avalos /*
241c99275SPeter Avalos  * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997
341c99275SPeter Avalos  *	The Regents of the University of California.  All rights reserved.
441c99275SPeter Avalos  *
541c99275SPeter Avalos  * Redistribution and use in source and binary forms, with or without
641c99275SPeter Avalos  * modification, are permitted provided that: (1) source code distributions
741c99275SPeter Avalos  * retain the above copyright notice and this paragraph in its entirety, (2)
841c99275SPeter Avalos  * distributions including binary code include the above copyright notice and
941c99275SPeter Avalos  * this paragraph in its entirety in the documentation or other materials
1041c99275SPeter Avalos  * provided with the distribution, and (3) all advertising materials mentioning
1141c99275SPeter Avalos  * features or use of this software display the following acknowledgement:
1241c99275SPeter Avalos  * ``This product includes software developed by the University of California,
1341c99275SPeter Avalos  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
1441c99275SPeter Avalos  * the University nor the names of its contributors may be used to endorse
1541c99275SPeter Avalos  * or promote products derived from this software without specific prior
1641c99275SPeter Avalos  * written permission.
1741c99275SPeter Avalos  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
1841c99275SPeter Avalos  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
1941c99275SPeter Avalos  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2041c99275SPeter Avalos  */
2141c99275SPeter Avalos 
22411677aeSAaron LI /* \summary: Fiber Distributed Data Interface (FDDI) printer */
2341c99275SPeter Avalos 
2441c99275SPeter Avalos #ifdef HAVE_CONFIG_H
25*ed775ee7SAntonio Huete Jimenez #include <config.h>
2641c99275SPeter Avalos #endif
2741c99275SPeter Avalos 
28*ed775ee7SAntonio Huete Jimenez #include "netdissect-stdinc.h"
2941c99275SPeter Avalos 
3041c99275SPeter Avalos #include <string.h>
3141c99275SPeter Avalos 
32411677aeSAaron LI #include "netdissect.h"
33*ed775ee7SAntonio Huete Jimenez #include "extract.h"
3441c99275SPeter Avalos #include "addrtoname.h"
35411677aeSAaron LI 
36411677aeSAaron LI /*
37411677aeSAaron LI  * Based on Ultrix if_fddi.h
38411677aeSAaron LI  */
39411677aeSAaron LI 
40411677aeSAaron LI struct fddi_header {
41*ed775ee7SAntonio Huete Jimenez 	nd_uint8_t  fddi_fc;		/* frame control */
42*ed775ee7SAntonio Huete Jimenez 	nd_mac_addr fddi_dhost;
43*ed775ee7SAntonio Huete Jimenez 	nd_mac_addr fddi_shost;
44411677aeSAaron LI };
45411677aeSAaron LI 
46411677aeSAaron LI /*
47411677aeSAaron LI  * Length of an FDDI header; note that some compilers may pad
48411677aeSAaron LI  * "struct fddi_header" to a multiple of 4 bytes, for example, so
49411677aeSAaron LI  * "sizeof (struct fddi_header)" may not give the right
50411677aeSAaron LI  * answer.
51411677aeSAaron LI  */
52411677aeSAaron LI #define FDDI_HDRLEN 13
53411677aeSAaron LI 
54411677aeSAaron LI /* Useful values for fddi_fc (frame control) field */
55411677aeSAaron LI 
56411677aeSAaron LI /*
57411677aeSAaron LI  * FDDI Frame Control bits
58411677aeSAaron LI  */
59411677aeSAaron LI #define	FDDIFC_C		0x80		/* Class bit */
60411677aeSAaron LI #define	FDDIFC_L		0x40		/* Address length bit */
61411677aeSAaron LI #define	FDDIFC_F		0x30		/* Frame format bits */
62411677aeSAaron LI #define	FDDIFC_Z		0x0f		/* Control bits */
63411677aeSAaron LI 
64411677aeSAaron LI /*
65411677aeSAaron LI  * FDDI Frame Control values. (48-bit addressing only).
66411677aeSAaron LI  */
67411677aeSAaron LI #define	FDDIFC_VOID		0x40		/* Void frame */
68411677aeSAaron LI #define	FDDIFC_NRT		0x80		/* Nonrestricted token */
69411677aeSAaron LI #define	FDDIFC_RT		0xc0		/* Restricted token */
70411677aeSAaron LI #define	FDDIFC_SMT_INFO		0x41		/* SMT Info */
71411677aeSAaron LI #define	FDDIFC_SMT_NSA		0x4F		/* SMT Next station adrs */
72411677aeSAaron LI #define	FDDIFC_MAC_BEACON	0xc2		/* MAC Beacon frame */
73411677aeSAaron LI #define	FDDIFC_MAC_CLAIM	0xc3		/* MAC Claim frame */
74411677aeSAaron LI #define	FDDIFC_LLC_ASYNC	0x50		/* Async. LLC frame */
75411677aeSAaron LI #define	FDDIFC_LLC_SYNC		0xd0		/* Sync. LLC frame */
76411677aeSAaron LI #define	FDDIFC_IMP_ASYNC	0x60		/* Implementor Async. */
77411677aeSAaron LI #define	FDDIFC_IMP_SYNC		0xe0		/* Implementor Synch. */
78411677aeSAaron LI #define FDDIFC_SMT		0x40		/* SMT frame */
79411677aeSAaron LI #define FDDIFC_MAC		0xc0		/* MAC frame */
80411677aeSAaron LI 
81411677aeSAaron LI #define	FDDIFC_CLFF		0xF0		/* Class/Length/Format bits */
82411677aeSAaron LI #define	FDDIFC_ZZZZ		0x0F		/* Control bits */
8341c99275SPeter Avalos 
8441c99275SPeter Avalos /*
8541c99275SPeter Avalos  * Some FDDI interfaces use bit-swapped addresses.
8641c99275SPeter Avalos  */
8741c99275SPeter Avalos #if defined(ultrix) || defined(__alpha) || defined(__bsdi) || defined(__NetBSD__) || defined(__linux__)
88411677aeSAaron LI static int fddi_bitswap = 0;
8941c99275SPeter Avalos #else
90411677aeSAaron LI static int fddi_bitswap = 1;
9141c99275SPeter Avalos #endif
9241c99275SPeter Avalos 
9341c99275SPeter Avalos /*
9441c99275SPeter Avalos  * FDDI support for tcpdump, by Jeffrey Mogul [DECWRL], June 1992
9541c99275SPeter Avalos  *
9641c99275SPeter Avalos  * Based in part on code by Van Jacobson, which bears this note:
9741c99275SPeter Avalos  *
9841c99275SPeter Avalos  * NOTE:  This is a very preliminary hack for FDDI support.
9941c99275SPeter Avalos  * There are all sorts of wired in constants & nothing (yet)
10041c99275SPeter Avalos  * to print SMT packets as anything other than hex dumps.
10141c99275SPeter Avalos  * Most of the necessary changes are waiting on my redoing
10241c99275SPeter Avalos  * the "header" that a kernel fddi driver supplies to bpf:  I
10341c99275SPeter Avalos  * want it to look like one byte of 'direction' (0 or 1
10441c99275SPeter Avalos  * depending on whether the packet was inbound or outbound),
10541c99275SPeter Avalos  * two bytes of system/driver dependent data (anything an
10641c99275SPeter Avalos  * implementor thinks would be useful to filter on and/or
10741c99275SPeter Avalos  * save per-packet, then the real 21-byte FDDI header.
10841c99275SPeter Avalos  * Steve McCanne & I have also talked about adding the
10941c99275SPeter Avalos  * 'direction' byte to all bpf headers (e.g., in the two
11041c99275SPeter Avalos  * bytes of padding on an ethernet header).  It's not clear
11141c99275SPeter Avalos  * we could do this in a backwards compatible way & we hate
11241c99275SPeter Avalos  * the idea of an incompatible bpf change.  Discussions are
11341c99275SPeter Avalos  * proceeding.
11441c99275SPeter Avalos  *
11541c99275SPeter Avalos  * Also, to really support FDDI (and better support 802.2
11641c99275SPeter Avalos  * over ethernet) we really need to re-think the rather simple
11741c99275SPeter Avalos  * minded assumptions about fixed length & fixed format link
11841c99275SPeter Avalos  * level headers made in gencode.c.  One day...
11941c99275SPeter Avalos  *
12041c99275SPeter Avalos  *  - vj
12141c99275SPeter Avalos  */
12241c99275SPeter Avalos 
123411677aeSAaron LI static const u_char fddi_bit_swap[] = {
12441c99275SPeter Avalos 	0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
12541c99275SPeter Avalos 	0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
12641c99275SPeter Avalos 	0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
12741c99275SPeter Avalos 	0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
12841c99275SPeter Avalos 	0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
12941c99275SPeter Avalos 	0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
13041c99275SPeter Avalos 	0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
13141c99275SPeter Avalos 	0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
13241c99275SPeter Avalos 	0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
13341c99275SPeter Avalos 	0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
13441c99275SPeter Avalos 	0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
13541c99275SPeter Avalos 	0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
13641c99275SPeter Avalos 	0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
13741c99275SPeter Avalos 	0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
13841c99275SPeter Avalos 	0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
13941c99275SPeter Avalos 	0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
14041c99275SPeter Avalos 	0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
14141c99275SPeter Avalos 	0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
14241c99275SPeter Avalos 	0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
14341c99275SPeter Avalos 	0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
14441c99275SPeter Avalos 	0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
14541c99275SPeter Avalos 	0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
14641c99275SPeter Avalos 	0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
14741c99275SPeter Avalos 	0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
14841c99275SPeter Avalos 	0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
14941c99275SPeter Avalos 	0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
15041c99275SPeter Avalos 	0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
15141c99275SPeter Avalos 	0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
15241c99275SPeter Avalos 	0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
15341c99275SPeter Avalos 	0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
15441c99275SPeter Avalos 	0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
15541c99275SPeter Avalos 	0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
15641c99275SPeter Avalos };
15741c99275SPeter Avalos 
15841c99275SPeter Avalos /*
15941c99275SPeter Avalos  * Print FDDI frame-control bits
16041c99275SPeter Avalos  */
161*ed775ee7SAntonio Huete Jimenez static void
print_fddi_fc(netdissect_options * ndo,u_char fc)162411677aeSAaron LI print_fddi_fc(netdissect_options *ndo, u_char fc)
16341c99275SPeter Avalos {
16441c99275SPeter Avalos 	switch (fc) {
16541c99275SPeter Avalos 
16641c99275SPeter Avalos 	case FDDIFC_VOID:                         /* Void frame */
167*ed775ee7SAntonio Huete Jimenez 		ND_PRINT("void ");
16841c99275SPeter Avalos 		break;
16941c99275SPeter Avalos 
17041c99275SPeter Avalos 	case FDDIFC_NRT:                          /* Nonrestricted token */
171*ed775ee7SAntonio Huete Jimenez 		ND_PRINT("nrt ");
17241c99275SPeter Avalos 		break;
17341c99275SPeter Avalos 
17441c99275SPeter Avalos 	case FDDIFC_RT:                           /* Restricted token */
175*ed775ee7SAntonio Huete Jimenez 		ND_PRINT("rt ");
17641c99275SPeter Avalos 		break;
17741c99275SPeter Avalos 
17841c99275SPeter Avalos 	case FDDIFC_SMT_INFO:                     /* SMT Info */
179*ed775ee7SAntonio Huete Jimenez 		ND_PRINT("info ");
18041c99275SPeter Avalos 		break;
18141c99275SPeter Avalos 
18241c99275SPeter Avalos 	case FDDIFC_SMT_NSA:                      /* SMT Next station adrs */
183*ed775ee7SAntonio Huete Jimenez 		ND_PRINT("nsa ");
18441c99275SPeter Avalos 		break;
18541c99275SPeter Avalos 
18641c99275SPeter Avalos 	case FDDIFC_MAC_BEACON:                   /* MAC Beacon frame */
187*ed775ee7SAntonio Huete Jimenez 		ND_PRINT("beacon ");
18841c99275SPeter Avalos 		break;
18941c99275SPeter Avalos 
19041c99275SPeter Avalos 	case FDDIFC_MAC_CLAIM:                    /* MAC Claim frame */
191*ed775ee7SAntonio Huete Jimenez 		ND_PRINT("claim ");
19241c99275SPeter Avalos 		break;
19341c99275SPeter Avalos 
19441c99275SPeter Avalos 	default:
19541c99275SPeter Avalos 		switch (fc & FDDIFC_CLFF) {
19641c99275SPeter Avalos 
19741c99275SPeter Avalos 		case FDDIFC_MAC:
198*ed775ee7SAntonio Huete Jimenez 			ND_PRINT("mac%1x ", fc & FDDIFC_ZZZZ);
19941c99275SPeter Avalos 			break;
20041c99275SPeter Avalos 
20141c99275SPeter Avalos 		case FDDIFC_SMT:
202*ed775ee7SAntonio Huete Jimenez 			ND_PRINT("smt%1x ", fc & FDDIFC_ZZZZ);
20341c99275SPeter Avalos 			break;
20441c99275SPeter Avalos 
20541c99275SPeter Avalos 		case FDDIFC_LLC_ASYNC:
206*ed775ee7SAntonio Huete Jimenez 			ND_PRINT("async%1x ", fc & FDDIFC_ZZZZ);
20741c99275SPeter Avalos 			break;
20841c99275SPeter Avalos 
20941c99275SPeter Avalos 		case FDDIFC_LLC_SYNC:
210*ed775ee7SAntonio Huete Jimenez 			ND_PRINT("sync%1x ", fc & FDDIFC_ZZZZ);
21141c99275SPeter Avalos 			break;
21241c99275SPeter Avalos 
21341c99275SPeter Avalos 		case FDDIFC_IMP_ASYNC:
214*ed775ee7SAntonio Huete Jimenez 			ND_PRINT("imp_async%1x ", fc & FDDIFC_ZZZZ);
21541c99275SPeter Avalos 			break;
21641c99275SPeter Avalos 
21741c99275SPeter Avalos 		case FDDIFC_IMP_SYNC:
218*ed775ee7SAntonio Huete Jimenez 			ND_PRINT("imp_sync%1x ", fc & FDDIFC_ZZZZ);
21941c99275SPeter Avalos 			break;
22041c99275SPeter Avalos 
22141c99275SPeter Avalos 		default:
222*ed775ee7SAntonio Huete Jimenez 			ND_PRINT("%02x ", fc);
22341c99275SPeter Avalos 			break;
22441c99275SPeter Avalos 		}
22541c99275SPeter Avalos 	}
22641c99275SPeter Avalos }
22741c99275SPeter Avalos 
22841c99275SPeter Avalos /* Extract src, dst addresses */
229*ed775ee7SAntonio Huete Jimenez static void
extract_fddi_addrs(const struct fddi_header * fddip,char * fsrc,char * fdst)23041c99275SPeter Avalos extract_fddi_addrs(const struct fddi_header *fddip, char *fsrc, char *fdst)
23141c99275SPeter Avalos {
232*ed775ee7SAntonio Huete Jimenez 	int i;
23341c99275SPeter Avalos 
23441c99275SPeter Avalos 	if (fddi_bitswap) {
23541c99275SPeter Avalos 		/*
23641c99275SPeter Avalos 		 * bit-swap the fddi addresses (isn't the IEEE standards
23741c99275SPeter Avalos 		 * process wonderful!) then convert them to names.
23841c99275SPeter Avalos 		 */
23941c99275SPeter Avalos 		for (i = 0; i < 6; ++i)
24041c99275SPeter Avalos 			fdst[i] = fddi_bit_swap[fddip->fddi_dhost[i]];
24141c99275SPeter Avalos 		for (i = 0; i < 6; ++i)
24241c99275SPeter Avalos 			fsrc[i] = fddi_bit_swap[fddip->fddi_shost[i]];
24341c99275SPeter Avalos 	}
24441c99275SPeter Avalos 	else {
24541c99275SPeter Avalos 		memcpy(fdst, (const char *)fddip->fddi_dhost, 6);
24641c99275SPeter Avalos 		memcpy(fsrc, (const char *)fddip->fddi_shost, 6);
24741c99275SPeter Avalos 	}
24841c99275SPeter Avalos }
24941c99275SPeter Avalos 
25041c99275SPeter Avalos /*
25141c99275SPeter Avalos  * Print the FDDI MAC header
25241c99275SPeter Avalos  */
253*ed775ee7SAntonio Huete Jimenez static void
fddi_hdr_print(netdissect_options * ndo,const struct fddi_header * fddip,u_int length,const u_char * fsrc,const u_char * fdst)254411677aeSAaron LI fddi_hdr_print(netdissect_options *ndo,
255*ed775ee7SAntonio Huete Jimenez                const struct fddi_header *fddip, u_int length,
256*ed775ee7SAntonio Huete Jimenez                const u_char *fsrc, const u_char *fdst)
25741c99275SPeter Avalos {
25841c99275SPeter Avalos 	const char *srcname, *dstname;
25941c99275SPeter Avalos 
260411677aeSAaron LI 	srcname = etheraddr_string(ndo, fsrc);
261411677aeSAaron LI 	dstname = etheraddr_string(ndo, fdst);
26241c99275SPeter Avalos 
263411677aeSAaron LI 	if (!ndo->ndo_qflag)
264*ed775ee7SAntonio Huete Jimenez 		print_fddi_fc(ndo, GET_U_1(fddip->fddi_fc));
265*ed775ee7SAntonio Huete Jimenez 	ND_PRINT("%s > %s, length %u: ",
26641c99275SPeter Avalos 	       srcname, dstname,
267*ed775ee7SAntonio Huete Jimenez 	       length);
26841c99275SPeter Avalos }
26941c99275SPeter Avalos 
270*ed775ee7SAntonio Huete Jimenez static void
fddi_smt_print(netdissect_options * ndo,const u_char * p _U_,u_int length _U_)271411677aeSAaron LI fddi_smt_print(netdissect_options *ndo, const u_char *p _U_, u_int length _U_)
27241c99275SPeter Avalos {
273*ed775ee7SAntonio Huete Jimenez 	ND_PRINT("<SMT printer not yet implemented>");
27441c99275SPeter Avalos }
27541c99275SPeter Avalos 
276411677aeSAaron LI u_int
fddi_print(netdissect_options * ndo,const u_char * p,u_int length,u_int caplen)277411677aeSAaron LI fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
27841c99275SPeter Avalos {
27941c99275SPeter Avalos 	const struct fddi_header *fddip = (const struct fddi_header *)p;
280*ed775ee7SAntonio Huete Jimenez 	uint8_t fc;
281*ed775ee7SAntonio Huete Jimenez 	nd_mac_addr srcmac, dstmac;
282411677aeSAaron LI 	struct lladdr_info src, dst;
283411677aeSAaron LI 	int llc_hdrlen;
28441c99275SPeter Avalos 
285*ed775ee7SAntonio Huete Jimenez 	ndo->ndo_protocol = "fddi";
28641c99275SPeter Avalos 	if (caplen < FDDI_HDRLEN) {
287*ed775ee7SAntonio Huete Jimenez 		nd_print_trunc(ndo);
288411677aeSAaron LI 		return (caplen);
28941c99275SPeter Avalos 	}
29041c99275SPeter Avalos 
291*ed775ee7SAntonio Huete Jimenez 	fc = GET_U_1(fddip->fddi_fc);
292*ed775ee7SAntonio Huete Jimenez 
29341c99275SPeter Avalos 	/*
29441c99275SPeter Avalos 	 * Get the FDDI addresses into a canonical form
29541c99275SPeter Avalos 	 */
296*ed775ee7SAntonio Huete Jimenez 	extract_fddi_addrs(fddip, (char *)srcmac, (char *)dstmac);
29741c99275SPeter Avalos 
298411677aeSAaron LI 	if (ndo->ndo_eflag)
299*ed775ee7SAntonio Huete Jimenez 		fddi_hdr_print(ndo, fddip, length, srcmac, dstmac);
300411677aeSAaron LI 
301*ed775ee7SAntonio Huete Jimenez 	src.addr = srcmac;
302411677aeSAaron LI 	src.addr_string = etheraddr_string;
303*ed775ee7SAntonio Huete Jimenez 	dst.addr = dstmac;
304411677aeSAaron LI 	dst.addr_string = etheraddr_string;
30541c99275SPeter Avalos 
30641c99275SPeter Avalos 	/* Skip over FDDI MAC header */
30741c99275SPeter Avalos 	length -= FDDI_HDRLEN;
30841c99275SPeter Avalos 	p += FDDI_HDRLEN;
30941c99275SPeter Avalos 	caplen -= FDDI_HDRLEN;
31041c99275SPeter Avalos 
31141c99275SPeter Avalos 	/* Frame Control field determines interpretation of packet */
312*ed775ee7SAntonio Huete Jimenez 	if ((fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
31341c99275SPeter Avalos 		/* Try to print the LLC-layer header & higher layers */
314411677aeSAaron LI 		llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
315411677aeSAaron LI 		if (llc_hdrlen < 0) {
31641c99275SPeter Avalos 			/*
31741c99275SPeter Avalos 			 * Some kinds of LLC packet we cannot
31841c99275SPeter Avalos 			 * handle intelligently
31941c99275SPeter Avalos 			 */
320411677aeSAaron LI 			if (!ndo->ndo_suppress_default_print)
321411677aeSAaron LI 				ND_DEFAULTPRINT(p, caplen);
322411677aeSAaron LI 			llc_hdrlen = -llc_hdrlen;
32341c99275SPeter Avalos 		}
324*ed775ee7SAntonio Huete Jimenez 	} else if ((fc & FDDIFC_CLFF) == FDDIFC_SMT) {
325411677aeSAaron LI 		fddi_smt_print(ndo, p, caplen);
326411677aeSAaron LI 		llc_hdrlen = 0;
327411677aeSAaron LI 	} else {
32841c99275SPeter Avalos 		/* Some kinds of FDDI packet we cannot handle intelligently */
329411677aeSAaron LI 		if (!ndo->ndo_eflag)
330*ed775ee7SAntonio Huete Jimenez 			fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, srcmac,
331*ed775ee7SAntonio Huete Jimenez 			    dstmac);
332411677aeSAaron LI 		if (!ndo->ndo_suppress_default_print)
333411677aeSAaron LI 			ND_DEFAULTPRINT(p, caplen);
334411677aeSAaron LI 		llc_hdrlen = 0;
33541c99275SPeter Avalos 	}
336411677aeSAaron LI 	return (FDDI_HDRLEN + llc_hdrlen);
33741c99275SPeter Avalos }
33841c99275SPeter Avalos 
33941c99275SPeter Avalos /*
34041c99275SPeter Avalos  * This is the top level routine of the printer.  'p' points
34141c99275SPeter Avalos  * to the FDDI header of the packet, 'h->ts' is the timestamp,
34241c99275SPeter Avalos  * 'h->len' is the length of the packet off the wire, and 'h->caplen'
34341c99275SPeter Avalos  * is the number of bytes actually captured.
34441c99275SPeter Avalos  */
345*ed775ee7SAntonio Huete Jimenez void
fddi_if_print(netdissect_options * ndo,const struct pcap_pkthdr * h,const u_char * p)346*ed775ee7SAntonio Huete Jimenez fddi_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
34741c99275SPeter Avalos {
348*ed775ee7SAntonio Huete Jimenez 	ndo->ndo_protocol = "fddi";
349*ed775ee7SAntonio Huete Jimenez 	ndo->ndo_ll_hdr_len += fddi_print(ndo, p, h->len, h->caplen);
35041c99275SPeter Avalos }
351