1*05b00f60SXin Li /*
2*05b00f60SXin Li * Copyright (c) 2013 The TCPDUMP project
3*05b00f60SXin Li *
4*05b00f60SXin Li * Redistribution and use in source and binary forms, with or without
5*05b00f60SXin Li * modification, are permitted provided that: (1) source code
6*05b00f60SXin Li * distributions retain the above copyright notice and this paragraph
7*05b00f60SXin Li * in its entirety, and (2) distributions including binary code include
8*05b00f60SXin Li * the above copyright notice and this paragraph in its entirety in
9*05b00f60SXin Li * the documentation or other materials provided with the distribution.
10*05b00f60SXin Li * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
11*05b00f60SXin Li * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
12*05b00f60SXin Li * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13*05b00f60SXin Li * FOR A PARTICULAR PURPOSE.
14*05b00f60SXin Li *
15*05b00f60SXin Li * Original code by Ola Martin Lykkja ([email protected])
16*05b00f60SXin Li */
17*05b00f60SXin Li
18*05b00f60SXin Li /* \summary: Communication access for land mobiles (CALM) printer */
19*05b00f60SXin Li
20*05b00f60SXin Li #ifdef HAVE_CONFIG_H
21*05b00f60SXin Li #include <config.h>
22*05b00f60SXin Li #endif
23*05b00f60SXin Li
24*05b00f60SXin Li #include "netdissect-stdinc.h"
25*05b00f60SXin Li
26*05b00f60SXin Li #define ND_LONGJMP_FROM_TCHECK
27*05b00f60SXin Li #include "netdissect.h"
28*05b00f60SXin Li #include "extract.h"
29*05b00f60SXin Li #include "addrtoname.h"
30*05b00f60SXin Li
31*05b00f60SXin Li /*
32*05b00f60SXin Li ISO 29281:2009
33*05b00f60SXin Li Intelligent Transport Systems . Communications access for land mobiles (CALM)
34*05b00f60SXin Li CALM non-IP networking
35*05b00f60SXin Li */
36*05b00f60SXin Li
37*05b00f60SXin Li /*
38*05b00f60SXin Li * This is the top level routine of the printer. 'bp' points
39*05b00f60SXin Li * to the calm header of the packet.
40*05b00f60SXin Li */
41*05b00f60SXin Li void
calm_fast_print(netdissect_options * ndo,const u_char * bp,u_int length,const struct lladdr_info * src)42*05b00f60SXin Li calm_fast_print(netdissect_options *ndo, const u_char *bp, u_int length, const struct lladdr_info *src)
43*05b00f60SXin Li {
44*05b00f60SXin Li ndo->ndo_protocol = "calm_fast";
45*05b00f60SXin Li
46*05b00f60SXin Li ND_PRINT("CALM FAST");
47*05b00f60SXin Li if (src != NULL)
48*05b00f60SXin Li ND_PRINT(" src:%s", (src->addr_string)(ndo, src->addr));
49*05b00f60SXin Li ND_PRINT("; ");
50*05b00f60SXin Li
51*05b00f60SXin Li if (length < 2) {
52*05b00f60SXin Li ND_PRINT(" (length %u < 2)", length);
53*05b00f60SXin Li goto invalid;
54*05b00f60SXin Li }
55*05b00f60SXin Li
56*05b00f60SXin Li ND_PRINT("SrcNwref:%u; ", GET_U_1(bp));
57*05b00f60SXin Li length -= 1;
58*05b00f60SXin Li bp += 1;
59*05b00f60SXin Li
60*05b00f60SXin Li ND_PRINT("DstNwref:%u; ", GET_U_1(bp));
61*05b00f60SXin Li length -= 1;
62*05b00f60SXin Li bp += 1;
63*05b00f60SXin Li
64*05b00f60SXin Li if (ndo->ndo_vflag)
65*05b00f60SXin Li ND_DEFAULTPRINT(bp, length);
66*05b00f60SXin Li return;
67*05b00f60SXin Li
68*05b00f60SXin Li invalid:
69*05b00f60SXin Li nd_print_invalid(ndo);
70*05b00f60SXin Li ND_TCHECK_LEN(bp, length);
71*05b00f60SXin Li }
72