Explicitly request literal mode after .Xr.
[netbsd-mini2440.git] / dist / tcpdump / print-ipfc.c
blobe766b52021b54b1699f5b221dbacaf78bcf01e61
1 /* $NetBSD$ */
3 /*
4 * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
18 * written permission.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 #include <sys/cdefs.h>
25 #ifndef lint
26 #if 0
27 static const char rcsid[] _U_ =
28 "@(#) Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.7.2.2 2005/11/13 12:12:59 guy Exp (LBL)";
29 #else
30 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
31 #endif
32 #endif
34 #ifdef HAVE_CONFIG_H
35 #include "config.h"
36 #endif
38 #include <tcpdump-stdinc.h>
40 #include <pcap.h>
41 #include <stdio.h>
42 #include <string.h>
44 #include "interface.h"
45 #include "addrtoname.h"
46 #include "ethertype.h"
48 #include "ether.h"
49 #include "ipfc.h"
52 * RFC 2625 IP-over-Fibre Channel.
55 /* Extract src, dst addresses */
56 static inline void
57 extract_ipfc_addrs(const struct ipfc_header *ipfcp, char *ipfcsrc,
58 char *ipfcdst)
61 * We assume that, as per RFC 2625, the lower 48 bits of the
62 * source and destination addresses are MAC addresses.
64 memcpy(ipfcdst, (const char *)&ipfcp->ipfc_dhost[2], 6);
65 memcpy(ipfcsrc, (const char *)&ipfcp->ipfc_shost[2], 6);
69 * Print the Network_Header
71 static inline void
72 ipfc_hdr_print(register const struct ipfc_header *ipfcp _U_,
73 register u_int length, register const u_char *ipfcsrc,
74 register const u_char *ipfcdst)
76 const char *srcname, *dstname;
78 srcname = etheraddr_string(ipfcsrc);
79 dstname = etheraddr_string(ipfcdst);
82 * XXX - show the upper 16 bits? Do so only if "vflag" is set?
84 (void) printf("%s %s %d: ", srcname, dstname, length);
87 static void
88 ipfc_print(const u_char *p, u_int length, u_int caplen)
90 const struct ipfc_header *ipfcp = (const struct ipfc_header *)p;
91 struct ether_header ehdr;
92 u_short extracted_ethertype;
94 if (caplen < IPFC_HDRLEN) {
95 printf("[|ipfc]");
96 return;
99 * Get the network addresses into a canonical form
101 extract_ipfc_addrs(ipfcp, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
103 if (eflag)
104 ipfc_hdr_print(ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
106 /* Skip over Network_Header */
107 length -= IPFC_HDRLEN;
108 p += IPFC_HDRLEN;
109 caplen -= IPFC_HDRLEN;
111 /* Try to print the LLC-layer header & higher layers */
112 if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
113 &extracted_ethertype) == 0) {
115 * Some kinds of LLC packet we cannot
116 * handle intelligently
118 if (!eflag)
119 ipfc_hdr_print(ipfcp, length + IPFC_HDRLEN,
120 ESRC(&ehdr), EDST(&ehdr));
121 if (extracted_ethertype) {
122 printf("(LLC %s) ",
123 etherproto_string(htons(extracted_ethertype)));
125 if (!suppress_default_print)
126 default_print(p, caplen);
131 * This is the top level routine of the printer. 'p' points
132 * to the Network_Header of the packet, 'h->ts' is the timestamp,
133 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
134 * is the number of bytes actually captured.
136 u_int
137 ipfc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
139 ipfc_print(p, h->len, h->caplen);
141 return (IPFC_HDRLEN);