xref: /netbsd-src/external/bsd/tcpdump/dist/print-calm-fast.c (revision 181254a7b1bdde6873432bffef2d2decc4b5c22f)
1 /*
2  * Copyright (c) 2013 The TCPDUMP project
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that: (1) source code
6  * distributions retain the above copyright notice and this paragraph
7  * in its entirety, and (2) distributions including binary code include
8  * the above copyright notice and this paragraph in its entirety in
9  * the documentation or other materials provided with the distribution.
10  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
11  * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
12  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13  * FOR A PARTICULAR PURPOSE.
14  *
15  * Original code by Ola Martin Lykkja (ola.lykkja@q-free.com)
16  */
17 
18 #include <sys/cdefs.h>
19 #ifndef lint
20 __RCSID("$NetBSD: print-calm-fast.c,v 1.3 2017/02/05 04:05:05 spz Exp $");
21 #endif
22 
23 /* \summary: Communication access for land mobiles (CALM) printer */
24 
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28 
29 #include <netdissect-stdinc.h>
30 
31 #include "netdissect.h"
32 #include "addrtoname.h"
33 
34 /*
35    ISO 29281:2009
36    Intelligent Transport Systems . Communications access for land mobiles (CALM)
37    CALM non-IP networking
38 */
39 
40 /*
41  * This is the top level routine of the printer.  'bp' points
42  * to the calm header of the packet.
43  */
44 void
45 calm_fast_print(netdissect_options *ndo, const u_char *bp, u_int length, const struct lladdr_info *src)
46 {
47 	int srcNwref;
48 	int dstNwref;
49 
50 	ND_TCHECK2(*bp, 2);
51 	if (length < 2)
52 		goto trunc;
53 	srcNwref = bp[0];
54 	dstNwref = bp[1];
55 	length -= 2;
56 	bp += 2;
57 
58 	ND_PRINT((ndo, "CALM FAST"));
59 	if (src != NULL)
60 		ND_PRINT((ndo, " src:%s", (src->addr_string)(ndo, src->addr)));
61 	ND_PRINT((ndo, "; "));
62 	ND_PRINT((ndo, "SrcNwref:%d; ", srcNwref));
63 	ND_PRINT((ndo, "DstNwref:%d; ", dstNwref));
64 
65 	if (ndo->ndo_vflag)
66 		ND_DEFAULTPRINT(bp, length);
67 	return;
68 
69 trunc:
70 	ND_PRINT((ndo, "[|calm fast]"));
71 	return;
72 }
73 
74 
75 /*
76  * Local Variables:
77  * c-style: whitesmith
78  * c-basic-offset: 8
79  * End:
80  */
81