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