]>
The Tcpdump Group git mirrors - tcpdump/blob - print-geonet.c
3 * lykkja@hotmail.com All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by Paolo Abeni.''
13 * The name of author may not be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 #include <tcpdump-stdinc.h>
30 #include "interface.h"
32 #include "addrtoname.h"
36 ETSI TS 102 636-5-1 V1.1.1 (2011-02)
37 Intelligent Transport Systems (ITS); Vehicular Communications; GeoNetworking;
38 Part 5: Transport Protocols; Sub-part 1: Basic Transport Protocol
40 ETSI TS 102 636-4-1 V1.1.1 (2011-06)
41 Intelligent Transport Systems (ITS); Vehicular communications; GeoNetworking;
42 Part 4: Geographical addressing and forwarding for point-to-point and point-to-multipoint communications;
43 Sub-part 1: Media-Independent Functionality
47 hex48_to_string(const u_char
*bp
)
50 static char sz
[6*3+2];
51 memset(sz
, 0, sizeof(sz
));
53 if (i
) strcat(sz
,":");
54 sprintf(sz
+strlen(sz
), "%02x", bp
[i
]);
60 print_btp_body(const u_char
*bp
, u_int length
)
62 // Assuming ItsDpuHeader
65 const char *msg_type_str
= "Unknown";
68 case 0: msg_type_str
= "CAM"; break;
69 case 1: msg_type_str
= "DENM"; break;
70 case 101: msg_type_str
= "TPEGM"; break;
71 case 102: msg_type_str
= "TSPDM"; break;
72 case 103: msg_type_str
= "VPM"; break;
73 case 104: msg_type_str
= "SRM"; break;
74 case 105: msg_type_str
= "SLAM"; break;
75 case 106: msg_type_str
= "ecoCAM"; break;
76 case 107: msg_type_str
= "ITM"; break;
77 case 150: msg_type_str
= "SA"; break;
79 printf("; ItsPduHeader v:%d t:%d-%s", version
, msg_type
, msg_type_str
);
83 print_btp(const u_char
*bp
, u_int length
)
85 u_int16_t dest
= EXTRACT_16BITS(bp
+0);
86 u_int16_t src
= EXTRACT_16BITS(bp
+2);
87 printf("; BTP Dst:%u Src:%u", dest
, src
);
91 print_long_pos_vector(const char *type
, const u_char
*bp
, u_int length
)
99 printf("%02x", bp
[i
]);
103 lat
= EXTRACT_32BITS(bp
+12);
104 printf("lat:%d ", lat
);
105 lon
= EXTRACT_32BITS(bp
+16);
106 printf("lon:%d", lon
);
111 * This is the top level routine of the printer. 'p' points
112 * to the geonet header of the packet.
115 geonet_print(netdissect_options
*ndo
, const u_char
*eth
, const u_char
*bp
, u_int length
)
117 printf("GeoNet src:%s; ", hex48_to_string(eth
+6));
120 // Process Common Header
121 int version
= bp
[0] >> 4;
122 int next_hdr
= bp
[0] & 0x0f;
123 int hdr_type
= bp
[1] >> 4;
124 int hdr_subtype
= bp
[1] & 0x0f;
125 u_int16_t payload_length
= EXTRACT_16BITS(bp
+4);
126 int hop_limit
= bp
[7];
127 const char *next_hdr_txt
= "Unknown";
128 const char *hdr_type_txt
= "Unknown";
132 case 0: next_hdr_txt
= "Any"; break;
133 case 1: next_hdr_txt
= "BTP-A"; break;
134 case 2: next_hdr_txt
= "BTP-B"; break;
135 case 3: next_hdr_txt
= "IPv6"; break;
139 case 0: hdr_type_txt
= "Any"; break;
140 case 1: hdr_type_txt
= "Beacon"; break;
141 case 2: hdr_type_txt
= "GeoUnicast"; break;
142 case 3: switch (hdr_subtype
) {
143 case 0: hdr_type_txt
= "GeoAnycastCircle"; break;
144 case 1: hdr_type_txt
= "GeoAnycastRect"; break;
145 case 2: hdr_type_txt
= "GeoAnycastElipse"; break;
148 case 4: switch (hdr_subtype
) {
149 case 0: hdr_type_txt
= "GeoBroadcastCircle"; break;
150 case 1: hdr_type_txt
= "GeoBroadcastRect"; break;
151 case 2: hdr_type_txt
= "GeoBroadcastElipse"; break;
154 case 5: switch (hdr_subtype
) {
155 case 0: hdr_type_txt
= "TopoScopeBcast-SH"; break;
156 case 1: hdr_type_txt
= "TopoScopeBcast-MH"; break;
159 case 6: switch (hdr_subtype
) {
160 case 0: hdr_type_txt
= "LocService-Request"; break;
161 case 1: hdr_type_txt
= "LocService-Reply"; break;
166 printf("v:%d ", version
);
167 printf("NH:%d-%s ", next_hdr
, next_hdr_txt
);
168 printf("HT:%d-%d-%s ", hdr_type
, hdr_subtype
, hdr_type_txt
);
169 printf("HopLim:%d ", hop_limit
);
170 printf("Payload:%d ", payload_length
);
171 print_long_pos_vector("Sender", bp
+ 8, 36-8);
173 // Skip Common Header
177 // Process Extended Headers
185 case 2: /* GeoUnicast */
187 case 3: switch (hdr_subtype
) {
188 case 0: /* GeoAnycastCircle */
190 case 1: /* GeoAnycastRect */
192 case 2: /* GeoAnycastElipse */
196 case 4: switch (hdr_subtype
) {
197 case 0: /* GeoBroadcastCircle */
199 case 1: /* GeoBroadcastRect */
201 case 2: /* GeoBroadcastElipse */
205 case 5: switch (hdr_subtype
) {
206 case 0: /* TopoScopeBcast-SH */
209 case 1: /* TopoScopeBcast-MH */
214 case 6: switch (hdr_subtype
) {
215 case 0: /* LocService-Request */
217 case 1: /* LocService-Reply */
223 // Skip Extended headers
231 case 2: /* BTP A/B */
232 print_btp(bp
, length
);
235 print_btp_body(bp
, length
);
242 printf("Malformed (small) ");
245 // Print user data part
247 default_print(bp
, length
);
253 * c-style: whitesmith