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.5 2024/09/02 16:15:30 christos Exp $");
21 #endif
22
23 /* \summary: Communication access for land mobiles (CALM) printer */
24
25 #include <config.h>
26
27 #include "netdissect-stdinc.h"
28
29 #define ND_LONGJMP_FROM_TCHECK
30 #include "netdissect.h"
31 #include "extract.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
calm_fast_print(netdissect_options * ndo,const u_char * bp,u_int length,const struct lladdr_info * src)45 calm_fast_print(netdissect_options *ndo, const u_char *bp, u_int length, const struct lladdr_info *src)
46 {
47 ndo->ndo_protocol = "calm_fast";
48
49 ND_PRINT("CALM FAST");
50 if (src != NULL)
51 ND_PRINT(" src:%s", (src->addr_string)(ndo, src->addr));
52 ND_PRINT("; ");
53
54 if (length < 2) {
55 ND_PRINT(" (length %u < 2)", length);
56 goto invalid;
57 }
58
59 ND_PRINT("SrcNwref:%u; ", GET_U_1(bp));
60 length -= 1;
61 bp += 1;
62
63 ND_PRINT("DstNwref:%u; ", GET_U_1(bp));
64 length -= 1;
65 bp += 1;
66
67 if (ndo->ndo_vflag)
68 ND_DEFAULTPRINT(bp, length);
69 return;
70
71 invalid:
72 nd_print_invalid(ndo);
73 ND_TCHECK_LEN(bp, length);
74 }
75