xref: /freebsd/contrib/tcpdump/print-calm-fast.c (revision 3340d77368116708ab5b5b95acf6c9c710528300)
13c602fabSXin LI /*
23c602fabSXin LI  * Copyright (c) 2013 The TCPDUMP project
33c602fabSXin LI  *
43c602fabSXin LI  * Redistribution and use in source and binary forms, with or without
53c602fabSXin LI  * modification, are permitted provided that: (1) source code
63c602fabSXin LI  * distributions retain the above copyright notice and this paragraph
73c602fabSXin LI  * in its entirety, and (2) distributions including binary code include
83c602fabSXin LI  * the above copyright notice and this paragraph in its entirety in
93c602fabSXin LI  * the documentation or other materials provided with the distribution.
103c602fabSXin LI  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
113c602fabSXin LI  * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
123c602fabSXin LI  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
133c602fabSXin LI  * FOR A PARTICULAR PURPOSE.
143c602fabSXin LI  *
153c602fabSXin LI  * Original code by Ola Martin Lykkja (ola.lykkja@q-free.com)
163c602fabSXin LI  */
173c602fabSXin LI 
18*3340d773SGleb Smirnoff /* \summary: Communication access for land mobiles (CALM) printer */
19*3340d773SGleb Smirnoff 
203c602fabSXin LI #ifdef HAVE_CONFIG_H
213c602fabSXin LI #include "config.h"
223c602fabSXin LI #endif
233c602fabSXin LI 
24*3340d773SGleb Smirnoff #include <netdissect-stdinc.h>
253c602fabSXin LI 
26*3340d773SGleb Smirnoff #include "netdissect.h"
273c602fabSXin LI #include "addrtoname.h"
283c602fabSXin LI 
293c602fabSXin LI /*
303c602fabSXin LI    ISO 29281:2009
313c602fabSXin LI    Intelligent Transport Systems . Communications access for land mobiles (CALM)
323c602fabSXin LI    CALM non-IP networking
333c602fabSXin LI */
343c602fabSXin LI 
353c602fabSXin LI /*
363c602fabSXin LI  * This is the top level routine of the printer.  'bp' points
373c602fabSXin LI  * to the calm header of the packet.
383c602fabSXin LI  */
393c602fabSXin LI void
40*3340d773SGleb Smirnoff calm_fast_print(netdissect_options *ndo, const u_char *bp, u_int length, const struct lladdr_info *src)
413c602fabSXin LI {
42*3340d773SGleb Smirnoff 	int srcNwref;
43*3340d773SGleb Smirnoff 	int dstNwref;
44*3340d773SGleb Smirnoff 
45*3340d773SGleb Smirnoff 	ND_TCHECK2(*bp, 2);
46*3340d773SGleb Smirnoff 	if (length < 2)
47*3340d773SGleb Smirnoff 		goto trunc;
48*3340d773SGleb Smirnoff 	srcNwref = bp[0];
49*3340d773SGleb Smirnoff 	dstNwref = bp[1];
503c602fabSXin LI 	length -= 2;
513c602fabSXin LI 	bp += 2;
523c602fabSXin LI 
53*3340d773SGleb Smirnoff 	ND_PRINT((ndo, "CALM FAST"));
54*3340d773SGleb Smirnoff 	if (src != NULL)
55*3340d773SGleb Smirnoff 		ND_PRINT((ndo, " src:%s", (src->addr_string)(ndo, src->addr)));
56*3340d773SGleb Smirnoff 	ND_PRINT((ndo, "; "));
573c602fabSXin LI 	ND_PRINT((ndo, "SrcNwref:%d; ", srcNwref));
583c602fabSXin LI 	ND_PRINT((ndo, "DstNwref:%d; ", dstNwref));
593c602fabSXin LI 
603c602fabSXin LI 	if (ndo->ndo_vflag)
613c602fabSXin LI 		ND_DEFAULTPRINT(bp, length);
62*3340d773SGleb Smirnoff 	return;
63*3340d773SGleb Smirnoff 
64*3340d773SGleb Smirnoff trunc:
65*3340d773SGleb Smirnoff 	ND_PRINT((ndo, "[|calm fast]"));
66*3340d773SGleb Smirnoff 	return;
673c602fabSXin LI }
683c602fabSXin LI 
693c602fabSXin LI 
703c602fabSXin LI /*
713c602fabSXin LI  * Local Variables:
723c602fabSXin LI  * c-style: whitesmith
733c602fabSXin LI  * c-basic-offset: 8
743c602fabSXin LI  * End:
753c602fabSXin LI  */
76