2 * Marko Kiiskila carnil@cs.tut.fi
4 * Tampere University of Technology - Telecommunications Laboratory
6 * Permission to use, copy, modify and distribute this
7 * software and its documentation is hereby granted,
8 * provided that both the copyright notice and this
9 * permission notice appear in all copies of the software,
10 * derivative works or modified versions, and any portions
11 * thereof, that both notices appear in supporting
12 * documentation, and that the use of this software is
13 * acknowledged in any publications resulting from using
16 * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR
18 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
23 /* \summary: Linux Classical IP over ATM printer */
29 #include "netdissect-stdinc.h"
31 #define ND_LONGJMP_FROM_TCHECK
32 #include "netdissect.h"
33 #include "addrtoname.h"
35 static const unsigned char rfcllc
[] = {
36 0xaa, /* DSAP: non-ISO */
37 0xaa, /* SSAP: non-ISO */
38 0x03, /* Ctrl: Unnumbered Information Command PDU */
39 0x00, /* OUI: EtherType */
44 * This is the top level routine of the printer. 'p' points
45 * to the LLC/SNAP or raw header of the packet, 'h->ts' is the timestamp,
46 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
47 * is the number of bytes actually captured.
50 cip_if_print(netdissect_options
*ndo
, const struct pcap_pkthdr
*h
, const u_char
*p
)
52 u_int caplen
= h
->caplen
;
53 u_int length
= h
->len
;
56 ndo
->ndo_protocol
= "cip";
60 * There is no MAC-layer header, so just print the length.
62 ND_PRINT("%u: ", length
);
64 ND_TCHECK_LEN(p
, sizeof(rfcllc
));
65 if (memcmp(rfcllc
, p
, sizeof(rfcllc
)) == 0) {
67 * LLC header is present. Try to print it & higher layers.
69 llc_hdrlen
= llc_print(ndo
, p
, length
, caplen
, NULL
, NULL
);
71 /* packet type not known, print raw packet */
72 if (!ndo
->ndo_suppress_default_print
)
73 ND_DEFAULTPRINT(p
, caplen
);
74 llc_hdrlen
= -llc_hdrlen
;
78 * LLC header is absent; treat it as just IP.
81 ip_print(ndo
, p
, length
);
84 ndo
->ndo_ll_hdr_len
+= llc_hdrlen
;