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 /* \summary: Communication access for land mobiles (CALM) printer */ 19 20 #include <config.h> 21 22 #include "netdissect-stdinc.h" 23 24 #define ND_LONGJMP_FROM_TCHECK 25 #include "netdissect.h" 26 #include "extract.h" 27 #include "addrtoname.h" 28 29 /* 30 ISO 29281:2009 31 Intelligent Transport Systems . Communications access for land mobiles (CALM) 32 CALM non-IP networking 33 */ 34 35 /* 36 * This is the top level routine of the printer. 'bp' points 37 * to the calm header of the packet. 38 */ 39 void 40 calm_fast_print(netdissect_options *ndo, const u_char *bp, u_int length, const struct lladdr_info *src) 41 { 42 ndo->ndo_protocol = "calm_fast"; 43 44 ND_PRINT("CALM FAST"); 45 if (src != NULL) 46 ND_PRINT(" src:%s", (src->addr_string)(ndo, src->addr)); 47 ND_PRINT("; "); 48 49 if (length < 2) { 50 ND_PRINT(" (length %u < 2)", length); 51 goto invalid; 52 } 53 54 ND_PRINT("SrcNwref:%u; ", GET_U_1(bp)); 55 length -= 1; 56 bp += 1; 57 58 ND_PRINT("DstNwref:%u; ", GET_U_1(bp)); 59 length -= 1; 60 bp += 1; 61 62 if (ndo->ndo_vflag) 63 ND_DEFAULTPRINT(bp, length); 64 return; 65 66 invalid: 67 nd_print_invalid(ndo); 68 ND_TCHECK_LEN(bp, length); 69 } 70