blob: 0012e06eea15b09290ab368dc149555fd2a334a7 [file] [log] [blame]
Elliott Hughese2e3bd12017-05-15 10:59:29 -07001/*
2 * Copyright (c) 2015 Ritesh Ranjan (r.ranjan789@gmail.com)
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/* \summary: - Locator/Identifier Separation Protocol (LISP) printer */
30
31/*
32 * specification: RFC 6830
33 *
34 *
35 * The Map-Register message format is:
36 *
37 * 0 1 2 3
38 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
39 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 * |Type=3 |P|S|I|R| Reserved |M| Record Count |
41 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 * | Nonce . . . |
43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 * | . . . Nonce |
45 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 * | Key ID | Authentication Data Length |
47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 * ~ Authentication Data ~
49 * +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 * | | Record TTL |
51 * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 * R | Locator Count | EID mask-len | ACT |A| Reserved |
53 * e +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 * c | Rsvd | Map-Version Number | EID-Prefix-AFI |
55 * o +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 * r | EID-Prefix |
57 * d +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58 * | /| Priority | Weight | M Priority | M Weight |
59 * | L +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
60 * | o | Unused Flags |L|p|R| Loc-AFI |
61 * | c +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62 * | \| Locator |
63 * +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64 *
65 *
66 * The Map-Notify message format is:
67 *
68 * 0 1 2 3
69 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
70 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
71 * |Type=4 |I|R| Reserved | Record Count |
72 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73 * | Nonce . . . |
74 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
75 * | . . . Nonce |
76 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77 * | Key ID | Authentication Data Length |
78 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
79 * ~ Authentication Data ~
80 * +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81 * | | Record TTL |
82 * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
83 * R | Locator Count | EID mask-len | ACT |A| Reserved |
84 * e +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
85 * c | Rsvd | Map-Version Number | EID-Prefix-AFI |
86 * o +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
87 * r | EID-Prefix |
88 * d +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
89 * | /| Priority | Weight | M Priority | M Weight |
90 * | L +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
91 * | o | Unused Flags |L|p|R| Loc-AFI |
92 * | c +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
93 * | \| Locator |
94 * +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95 */
96
97#ifdef HAVE_CONFIG_H
Elliott Hughes820eced2021-08-20 18:00:50 -070098#include <config.h>
Elliott Hughese2e3bd12017-05-15 10:59:29 -070099#endif
100
Elliott Hughes820eced2021-08-20 18:00:50 -0700101#include "netdissect-stdinc.h"
102#include "netdissect.h"
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700103
104#include "ip.h"
105#include "ip6.h"
106
107#include "extract.h"
108#include "addrtoname.h"
109
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700110
111#define IPv4_AFI 1
112#define IPv6_AFI 2
113#define TYPE_INDEX 4
114#define LISP_MAP_NOTIFY_IBIT_MASK 8
115#define LISP_MAP_REGISTER_IBIT_MASK 2
116
117enum {
118 LISP_MAP_REQUEST = 1,
119 LISP_MAP_REPLY,
120 LISP_MAP_REGISTER,
121 LISP_MAP_NOTIFY,
122 LISP_ENCAPSULATED_CONTROL_MESSAGE = 8
123};
124
125enum {
126 LISP_AUTH_NONE,
127 LISP_AUTH_SHA1,
128 LISP_AUTH_SHA256
129};
130
131static const struct tok lisp_type [] = {
132 { 0, "LISP-Reserved" },
133 { 1, "LISP-Map-Request" },
134 { 2, "LISP-Map-Reply" },
135 { 3, "LISP-Map-Register" },
136 { 4, "LISP-Map-Notify" },
137 { 8, "LISP-Encapsulated-Contol-Message" },
138 { 0, NULL }
139};
140
141/*
142 * P-Bit : Request for Proxy Map-Reply from the MS/MR
143 * S-Bit : Security Enhancement. ETR is LISP-SEC enabled. draft-ietf-lisp-sec
144 * I-Bit : 128 bit xTR-ID and 64 bit Site-ID present.
145 * xTR-ID and Site-ID help in differentiation of xTRs in multi xTR
146 * and multi Site deployment scenarios.
147 * R-Bit : Built for a Reencapsulating-Tunnel-Router. Used in Traffic
148 * Engineering and Service Chaining
149 */
150static const struct tok map_register_hdr_flag[] = {
151 { 0x08000000, "P-Proxy-Map-Reply" },
152 { 0x04000000, "S-LISP-SEC-Capable" },
153 { 0x02000000, "I-xTR-ID-Present" },
154 { 0x01000000, "R-Build-For-RTR" },
155 { 0x00000100, "M-Want-Map-Notify" },
156 { 0, NULL }
157};
158
159static const struct tok map_notify_hdr_flag[] = {
160 { 0x08000000, "I-xTR-ID-Present" },
161 { 0x04000000, "R-Build-For-RTR" },
162 { 0, NULL }
163};
164
165static const struct tok auth_type[] = {
166 { LISP_AUTH_NONE, "None" },
167 { LISP_AUTH_SHA1, "SHA1" },
168 { LISP_AUTH_SHA256, "SHA256" },
169 { 0, NULL}
170};
171
172static const struct tok lisp_eid_action[] = {
173 { 0, "No-Action" },
174 { 1, "Natively-Forward" },
175 { 2, "Send-Map-Request" },
176 { 3, "Drop" },
177 { 0, NULL}
178};
179
180static const struct tok lisp_loc_flag[] = {
181 { 0x0004, "Local-Locator" },
182 { 0x0002, "RLoc-Probed" },
183 { 0x0001, "Reachable" },
184 { 0, NULL }
185};
186
187typedef struct map_register_hdr {
188 nd_uint8_t type_and_flag;
189 nd_uint8_t reserved;
190 nd_uint8_t reserved_and_flag2;
191 nd_uint8_t record_count;
192 nd_uint64_t nonce;
193 nd_uint16_t key_id;
194 nd_uint16_t auth_data_len;
195} lisp_map_register_hdr;
196
197#define MAP_REGISTER_HDR_LEN sizeof(lisp_map_register_hdr)
198
199typedef struct map_register_eid {
200 nd_uint32_t ttl;
201 nd_uint8_t locator_count;
202 nd_uint8_t eid_prefix_mask_length;
203 nd_uint8_t act_auth_inc_res;
204 nd_uint8_t reserved;
Elliott Hughes820eced2021-08-20 18:00:50 -0700205 nd_uint16_t reserved_and_version;
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700206 nd_uint16_t eid_prefix_afi;
207} lisp_map_register_eid;
208
209#define MAP_REGISTER_EID_LEN sizeof(lisp_map_register_eid)
210
211typedef struct map_register_loc {
212 nd_uint8_t priority;
213 nd_uint8_t weight;
214 nd_uint8_t m_priority;
215 nd_uint8_t m_weight;
216 nd_uint16_t unused_and_flag;
217 nd_uint16_t locator_afi;
218} lisp_map_register_loc;
219
220#define MAP_REGISTER_LOC_LEN sizeof(lisp_map_register_loc)
221
Elliott Hughes820eced2021-08-20 18:00:50 -0700222static uint8_t extract_lisp_type(uint8_t);
223static uint8_t is_xtr_data_present(uint8_t, uint8_t);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700224static void lisp_hdr_flag(netdissect_options *, const lisp_map_register_hdr *);
225static void action_flag(netdissect_options *, uint8_t);
226static void loc_hdr_flag(netdissect_options *, uint16_t);
227
Elliott Hughes820eced2021-08-20 18:00:50 -0700228void
229lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700230{
Elliott Hughes820eced2021-08-20 18:00:50 -0700231 uint8_t type_and_flag;
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700232 uint8_t type;
233 uint8_t mask_len;
234 uint8_t loc_count;
235 uint8_t xtr_present;
236 uint8_t record_count;
237 uint16_t key_id;
238 uint16_t eid_afi;
239 uint16_t loc_afi;
240 uint16_t map_version;
241 uint16_t packet_offset;
242 uint16_t auth_data_len;
243 uint32_t ttl;
244 const u_char *packet_iterator;
245 const u_char *loc_ip_pointer;
246 const lisp_map_register_hdr *lisp_hdr;
247 const lisp_map_register_eid *lisp_eid;
248 const lisp_map_register_loc *lisp_loc;
249
Elliott Hughes820eced2021-08-20 18:00:50 -0700250 ndo->ndo_protocol = "lisp";
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700251 /* Check if enough bytes for header are available */
Elliott Hughes820eced2021-08-20 18:00:50 -0700252 ND_TCHECK_LEN(bp, MAP_REGISTER_HDR_LEN);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700253 lisp_hdr = (const lisp_map_register_hdr *) bp;
254 lisp_hdr_flag(ndo, lisp_hdr);
255 /* Supporting only MAP NOTIFY and MAP REGISTER LISP packets */
Elliott Hughes820eced2021-08-20 18:00:50 -0700256 type_and_flag = GET_U_1(lisp_hdr->type_and_flag);
257 type = extract_lisp_type(type_and_flag);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700258 if ((type != LISP_MAP_REGISTER) && (type != LISP_MAP_NOTIFY))
259 return;
260
261 /* Find if the packet contains xTR and Site-ID data */
Elliott Hughes820eced2021-08-20 18:00:50 -0700262 xtr_present = is_xtr_data_present(type, type_and_flag);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700263
264 /* Extract the number of EID records present */
Elliott Hughes820eced2021-08-20 18:00:50 -0700265 auth_data_len = GET_BE_U_2(lisp_hdr->auth_data_len);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700266 packet_iterator = (const u_char *)(lisp_hdr);
267 packet_offset = MAP_REGISTER_HDR_LEN;
Elliott Hughes820eced2021-08-20 18:00:50 -0700268 record_count = GET_U_1(lisp_hdr->record_count);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700269
270 if (ndo->ndo_vflag) {
Elliott Hughes820eced2021-08-20 18:00:50 -0700271 key_id = GET_BE_U_2(lisp_hdr->key_id);
272 ND_PRINT("\n %u record(s), ", record_count);
273 ND_PRINT("Authentication %s,",
274 tok2str(auth_type, "unknown-type", key_id));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700275 hex_print(ndo, "\n Authentication-Data: ", packet_iterator +
276 packet_offset, auth_data_len);
277 } else {
Elliott Hughes820eced2021-08-20 18:00:50 -0700278 ND_PRINT(" %u record(s),", record_count);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700279 }
280 packet_offset += auth_data_len;
281
282 if (record_count == 0)
283 goto invalid;
284
285 /* Print all the EID records */
286 while ((length > packet_offset) && (record_count--)) {
287
Elliott Hughes820eced2021-08-20 18:00:50 -0700288 ND_TCHECK_LEN(packet_iterator + packet_offset,
289 MAP_REGISTER_EID_LEN);
290 ND_PRINT("\n");
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700291 lisp_eid = (const lisp_map_register_eid *)
292 ((const u_char *)lisp_hdr + packet_offset);
293 packet_offset += MAP_REGISTER_EID_LEN;
Elliott Hughes820eced2021-08-20 18:00:50 -0700294 mask_len = GET_U_1(lisp_eid->eid_prefix_mask_length);
295 eid_afi = GET_BE_U_2(lisp_eid->eid_prefix_afi);
296 loc_count = GET_U_1(lisp_eid->locator_count);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700297
298 if (ndo->ndo_vflag) {
Elliott Hughes820eced2021-08-20 18:00:50 -0700299 ttl = GET_BE_U_4(lisp_eid->ttl);
300 ND_PRINT(" Record TTL %u,", ttl);
301 action_flag(ndo, GET_U_1(lisp_eid->act_auth_inc_res));
302 map_version = GET_BE_U_2(lisp_eid->reserved_and_version) & 0x0FFF;
303 ND_PRINT(" Map Version: %u,", map_version);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700304 }
305
306 switch (eid_afi) {
307 case IPv4_AFI:
Elliott Hughes820eced2021-08-20 18:00:50 -0700308 ND_PRINT(" EID %s/%u,",
309 GET_IPADDR_STRING(packet_iterator + packet_offset),
310 mask_len);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700311 packet_offset += 4;
312 break;
313 case IPv6_AFI:
Elliott Hughes820eced2021-08-20 18:00:50 -0700314 ND_PRINT(" EID %s/%u,",
315 GET_IP6ADDR_STRING(packet_iterator + packet_offset),
316 mask_len);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700317 packet_offset += 16;
318 break;
319 default:
320 /*
321 * No support for LCAF right now.
322 */
323 return;
324 break;
325 }
326
Elliott Hughes820eced2021-08-20 18:00:50 -0700327 ND_PRINT(" %u locator(s)", loc_count);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700328
329 while (loc_count--) {
Elliott Hughes820eced2021-08-20 18:00:50 -0700330 ND_TCHECK_LEN(packet_iterator + packet_offset,
331 MAP_REGISTER_LOC_LEN);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700332 lisp_loc = (const lisp_map_register_loc *) (packet_iterator + packet_offset);
333 loc_ip_pointer = (const u_char *) (lisp_loc + 1);
334 packet_offset += MAP_REGISTER_LOC_LEN;
Elliott Hughes820eced2021-08-20 18:00:50 -0700335 loc_afi = GET_BE_U_2(lisp_loc->locator_afi);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700336
337 if (ndo->ndo_vflag)
Elliott Hughes820eced2021-08-20 18:00:50 -0700338 ND_PRINT("\n ");
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700339
340 switch (loc_afi) {
341 case IPv4_AFI:
Elliott Hughes820eced2021-08-20 18:00:50 -0700342 ND_TCHECK_4(packet_iterator + packet_offset);
343 ND_PRINT(" LOC %s", GET_IPADDR_STRING(loc_ip_pointer));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700344 packet_offset += 4;
345 break;
346 case IPv6_AFI:
Elliott Hughes820eced2021-08-20 18:00:50 -0700347 ND_TCHECK_16(packet_iterator + packet_offset);
348 ND_PRINT(" LOC %s", GET_IP6ADDR_STRING(loc_ip_pointer));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700349 packet_offset += 16;
350 break;
351 default:
352 break;
353 }
354 if (ndo->ndo_vflag) {
Elliott Hughes820eced2021-08-20 18:00:50 -0700355 ND_PRINT("\n Priority/Weight %u/%u,"
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700356 " Multicast Priority/Weight %u/%u,",
Elliott Hughes820eced2021-08-20 18:00:50 -0700357 GET_U_1(lisp_loc->priority),
358 GET_U_1(lisp_loc->weight),
359 GET_U_1(lisp_loc->m_priority),
360 GET_U_1(lisp_loc->m_weight));
361 loc_hdr_flag(ndo,
362 GET_BE_U_2(lisp_loc->unused_and_flag));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700363 }
364 }
365 }
366
367 /*
368 * Print xTR and Site ID. Handle the fact that the packet could be invalid.
369 * If the xTR_ID_Present bit is not set, and we still have data to display,
370 * show it as hex data.
371 */
372 if (xtr_present) {
Elliott Hughes820eced2021-08-20 18:00:50 -0700373 if (!ND_TTEST_LEN(packet_iterator + packet_offset, 24))
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700374 goto invalid;
Elliott Hughes820eced2021-08-20 18:00:50 -0700375 hex_print(ndo, "\n xTR-ID: ", packet_iterator + packet_offset, 16);
376 ND_PRINT("\n SITE-ID: %" PRIu64,
377 GET_BE_U_8(packet_iterator + packet_offset + 16));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700378 } else {
379 /* Check if packet isn't over yet */
380 if (packet_iterator + packet_offset < ndo->ndo_snapend) {
Elliott Hughes820eced2021-08-20 18:00:50 -0700381 hex_print(ndo, "\n Data: ", packet_iterator + packet_offset,
382 ND_BYTES_AVAILABLE_AFTER(packet_iterator + packet_offset));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700383 }
384 }
385 return;
386trunc:
Elliott Hughes820eced2021-08-20 18:00:50 -0700387 nd_print_trunc(ndo);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700388 return;
389invalid:
Elliott Hughes820eced2021-08-20 18:00:50 -0700390 nd_print_invalid(ndo);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700391}
392
Elliott Hughes820eced2021-08-20 18:00:50 -0700393static uint8_t
394extract_lisp_type(uint8_t lisp_hdr_flags)
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700395{
396 return (lisp_hdr_flags) >> TYPE_INDEX;
397}
398
Elliott Hughes820eced2021-08-20 18:00:50 -0700399static uint8_t
400is_xtr_data_present(uint8_t type, uint8_t lisp_hdr_flags)
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700401{
402 uint8_t xtr_present = 0;
403
404 if (type == LISP_MAP_REGISTER)
405 xtr_present = (lisp_hdr_flags) & LISP_MAP_REGISTER_IBIT_MASK;
406 else if (type == LISP_MAP_NOTIFY)
407 xtr_present = (lisp_hdr_flags) & LISP_MAP_NOTIFY_IBIT_MASK;
408
409 return xtr_present;
410}
411
412static void lisp_hdr_flag(netdissect_options *ndo, const lisp_map_register_hdr *lisp_hdr)
413{
Elliott Hughes820eced2021-08-20 18:00:50 -0700414 uint8_t type = extract_lisp_type(GET_U_1(lisp_hdr->type_and_flag));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700415
416 if (!ndo->ndo_vflag) {
Elliott Hughes820eced2021-08-20 18:00:50 -0700417 ND_PRINT("%s,", tok2str(lisp_type, "unknown-type-%u", type));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700418 return;
419 } else {
Elliott Hughes820eced2021-08-20 18:00:50 -0700420 ND_PRINT("%s,", tok2str(lisp_type, "unknown-type-%u", type));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700421 }
422
423 if (type == LISP_MAP_REGISTER) {
Elliott Hughes820eced2021-08-20 18:00:50 -0700424 ND_PRINT(" flags [%s],", bittok2str(map_register_hdr_flag,
425 "none", GET_BE_U_4(lisp_hdr)));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700426 } else if (type == LISP_MAP_NOTIFY) {
Elliott Hughes820eced2021-08-20 18:00:50 -0700427 ND_PRINT(" flags [%s],", bittok2str(map_notify_hdr_flag,
428 "none", GET_BE_U_4(lisp_hdr)));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700429 }
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700430}
431
432static void action_flag(netdissect_options *ndo, uint8_t act_auth_inc_res)
433{
434 uint8_t action;
435 uint8_t authoritative;
436
437 authoritative = ((act_auth_inc_res >> 4) & 1);
438
439 if (authoritative)
Elliott Hughes820eced2021-08-20 18:00:50 -0700440 ND_PRINT(" Authoritative,");
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700441 else
Elliott Hughes820eced2021-08-20 18:00:50 -0700442 ND_PRINT(" Non-Authoritative,");
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700443
444 action = act_auth_inc_res >> 5;
Elliott Hughes820eced2021-08-20 18:00:50 -0700445 ND_PRINT(" %s,", tok2str(lisp_eid_action, "unknown", action));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700446}
447
448static void loc_hdr_flag(netdissect_options *ndo, uint16_t flag)
449{
Elliott Hughes820eced2021-08-20 18:00:50 -0700450 ND_PRINT(" flags [%s],", bittok2str(lisp_loc_flag, "none", flag));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700451}
452