1999-11-21 11:52:11 +08:00
|
|
|
/*
|
2002-06-12 01:08:37 +08:00
|
|
|
* Marko Kiiskila carnil@cs.tut.fi
|
|
|
|
*
|
1999-11-21 11:52:11 +08:00
|
|
|
* Tampere University of Technology - Telecommunications Laboratory
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this
|
|
|
|
* software and its documentation is hereby granted,
|
|
|
|
* provided that both the copyright notice and this
|
|
|
|
* permission notice appear in all copies of the software,
|
|
|
|
* derivative works or modified versions, and any portions
|
|
|
|
* thereof, that both notices appear in supporting
|
|
|
|
* documentation, and that the use of this software is
|
|
|
|
* acknowledged in any publications resulting from using
|
|
|
|
* the software.
|
2002-06-12 01:08:37 +08:00
|
|
|
*
|
1999-11-21 11:52:11 +08:00
|
|
|
* TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR
|
|
|
|
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
|
|
|
|
* SOFTWARE.
|
2002-06-12 01:08:37 +08:00
|
|
|
*
|
1999-11-21 11:52:11 +08:00
|
|
|
*/
|
|
|
|
|
2020-03-13 06:39:51 +08:00
|
|
|
/* \summary: Linux Classical IP over ATM printer */
|
2016-08-14 21:42:19 +08:00
|
|
|
|
2018-01-22 04:27:08 +08:00
|
|
|
#include <config.h>
|
1999-11-21 11:52:11 +08:00
|
|
|
|
2001-03-19 11:58:10 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2018-01-20 22:59:49 +08:00
|
|
|
#include "netdissect-stdinc.h"
|
1999-11-21 11:52:11 +08:00
|
|
|
|
2020-10-16 23:57:01 +08:00
|
|
|
#define ND_LONGJMP_FROM_TCHECK
|
2015-09-06 05:35:58 +08:00
|
|
|
#include "netdissect.h"
|
1999-11-21 11:52:11 +08:00
|
|
|
#include "addrtoname.h"
|
|
|
|
|
2013-12-19 18:05:59 +08:00
|
|
|
static const unsigned char rfcllc[] = {
|
2000-04-28 19:34:12 +08:00
|
|
|
0xaa, /* DSAP: non-ISO */
|
|
|
|
0xaa, /* SSAP: non-ISO */
|
|
|
|
0x03, /* Ctrl: Unnumbered Information Command PDU */
|
|
|
|
0x00, /* OUI: EtherType */
|
|
|
|
0x00,
|
|
|
|
0x00 };
|
1999-11-21 11:52:11 +08:00
|
|
|
|
|
|
|
/*
|
2002-09-06 05:25:34 +08:00
|
|
|
* This is the top level routine of the printer. 'p' points
|
|
|
|
* to the LLC/SNAP or raw header of the packet, 'h->ts' is the timestamp,
|
2004-03-18 07:24:35 +08:00
|
|
|
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
|
1999-11-21 11:52:11 +08:00
|
|
|
* is the number of bytes actually captured.
|
|
|
|
*/
|
2020-08-02 17:50:35 +08:00
|
|
|
void
|
2014-02-28 17:42:37 +08:00
|
|
|
cip_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
|
1999-11-21 11:52:11 +08:00
|
|
|
{
|
2001-09-18 05:57:50 +08:00
|
|
|
u_int caplen = h->caplen;
|
|
|
|
u_int length = h->len;
|
2015-04-18 14:42:22 +08:00
|
|
|
int llc_hdrlen;
|
1999-11-21 11:52:11 +08:00
|
|
|
|
2020-08-02 17:50:35 +08:00
|
|
|
ndo->ndo_protocol = "cip";
|
1999-11-21 11:52:11 +08:00
|
|
|
|
2014-02-28 17:42:37 +08:00
|
|
|
if (ndo->ndo_eflag)
|
2020-10-16 23:57:01 +08:00
|
|
|
/*
|
|
|
|
* There is no MAC-layer header, so just print the length.
|
|
|
|
*/
|
|
|
|
ND_PRINT("%u: ", length);
|
1999-11-21 11:52:11 +08:00
|
|
|
|
2020-10-16 23:57:01 +08:00
|
|
|
ND_TCHECK_LEN(p, sizeof(rfcllc));
|
|
|
|
if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) {
|
2001-09-24 05:52:38 +08:00
|
|
|
/*
|
|
|
|
* LLC header is present. Try to print it & higher layers.
|
|
|
|
*/
|
2015-04-18 14:42:22 +08:00
|
|
|
llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
|
|
|
|
if (llc_hdrlen < 0) {
|
|
|
|
/* packet type not known, print raw packet */
|
2014-02-28 17:42:37 +08:00
|
|
|
if (!ndo->ndo_suppress_default_print)
|
2014-03-26 22:52:40 +08:00
|
|
|
ND_DEFAULTPRINT(p, caplen);
|
2015-04-18 14:42:22 +08:00
|
|
|
llc_hdrlen = -llc_hdrlen;
|
1999-11-21 11:52:11 +08:00
|
|
|
}
|
2001-09-24 05:52:38 +08:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* LLC header is absent; treat it as just IP.
|
|
|
|
*/
|
2015-04-18 14:42:22 +08:00
|
|
|
llc_hdrlen = 0;
|
2014-02-28 17:42:37 +08:00
|
|
|
ip_print(ndo, p, length);
|
1999-11-21 11:52:11 +08:00
|
|
|
}
|
2001-09-24 05:52:38 +08:00
|
|
|
|
2020-08-02 17:50:35 +08:00
|
|
|
ndo->ndo_ll_hdr_len += llc_hdrlen;
|
1999-11-21 11:52:11 +08:00
|
|
|
}
|