Coverage Report

Created: 2026-08-14 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-lisp.c
Line
Count
Source
1
/* packet-lisp.c
2
 * Routines for Locator/ID Separation Protocol (LISP) Control Message dissection
3
 * Copyright 2011, 2014 Lorand Jakab <ljakab@ac.upc.edu>
4
 *
5
 * Geo Coordinates LCAF dissection based on previous work by Radu Terciu
6
 *
7
 * Wireshark - Network traffic analyzer
8
 * By Gerald Combs <gerald@wireshark.org>
9
 * Copyright 1998 Gerald Combs
10
 *
11
 * SPDX-License-Identifier: GPL-2.0-or-later
12
 */
13
14
#include "config.h"
15
#include "packet-lisp.h"
16
17
#include <epan/to_str.h>
18
#include <epan/oui.h>
19
#include <epan/expert.h>
20
#include <epan/tfs.h>
21
#include <epan/iana-info.h>
22
#include <wsutil/array.h>
23
#include <wsutil/utf8_entities.h>
24
25
void proto_register_lisp(void);
26
void proto_reg_handoff_lisp(void);
27
28
/*
29
 * See RFC 6830 "Locator/ID Separation Protocol (LISP)",
30
 * draft-ietf-lisp-lcaf-05 "LISP Canonical Address Format (LCAF)",
31
 * draft-ietf-lisp-vendor-lcaf-07 "Vendor Specific LISP Canonical Address Format (LCAF)"
32
 * draft-ietf-lisp-sec-04 "LISP-Security (LISP-SEC)",
33
 * draft-ermagan-lisp-nat-traversal-03 "NAT traversal for LISP",
34
 * draft-farinacci-lisp-name-encoding-09 "LISP Distinguished Name Encoding"
35
 * for packet format and protocol information.
36
 */
37
38
/* LISP Control Message types */
39
9
#define LISP_MAP_REQUEST    1
40
97
#define LISP_MAP_REPLY      2
41
14
#define LISP_MAP_REGISTER   3
42
20
#define LISP_MAP_NOTIFY     4
43
31
#define LISP_MAP_REFERRAL   6
44
6
#define LISP_INFO           7
45
198
#define LISP_ECM            8
46
47
#define LISP_ACT_NONE       0
48
#define LISP_ACT_FWD_NATIVE 1
49
#define LISP_ACT_MREQ       2
50
#define LISP_ACT_DROP       3
51
#define LISP_ACT_DROP_PD    4
52
#define LISP_ACT_DROP_AF    5
53
#define LISP_ACT_FWD_UA     6
54
55
#define DDT_NODE_REF        0
56
#define DDT_MS_REF          1
57
#define DDT_MS_ACK          2
58
#define DDT_MS_NREG         3
59
#define DDT_DLGT_HOLE       4
60
#define DDT_NAUTH           5
61
62
1
#define LCAF_NULL           0
63
0
#define LCAF_AFI_LIST       1
64
82
#define LCAF_IID            2
65
78
#define LCAF_ASN            3
66
#define LCAF_APP_DATA       4
67
0
#define LCAF_GEO            5
68
#define LCAF_OKEY           6
69
35
#define LCAF_NATT           7
70
1
#define LCAF_NONCE_LOC      8
71
80
#define LCAF_MCAST_INFO     9
72
27
#define LCAF_ELP            10
73
#define LCAF_SEC_KEY        11
74
0
#define LCAF_SRC_DST_KEY    12
75
6
#define LCAF_RLE            13
76
#define LCAF_JSON           14
77
0
#define LCAF_KV_ADDR_PAIR   15
78
0
#define LCAF_VENDOR         255
79
80
246
#define LCAF_HEADER_LEN     6
81
20
#define LISP_ECM_HEADER_LEN 4
82
83
3.24k
#define LISP_MAP_ACT        0xE000
84
334
#define LISP_MAP_AUTH       0x1000
85
107
#define REFERRAL_INCOMPLETE 0x0800
86
271
#define LOCAL_BIT_MASK      0x0004
87
271
#define PROBE_BIT_MASK      0x0002
88
271
#define REACH_BIT_MASK      0x0001
89
90
16
#define MAP_REQ_FLAG_A      0x080000
91
25
#define MAP_REQ_FLAG_M      0x040000
92
25
#define MAP_REQ_FLAG_P      0x020000
93
25
#define MAP_REQ_FLAG_S      0x010000
94
25
#define MAP_REQ_FLAG_p      0x008000
95
25
#define MAP_REQ_FLAG_s      0x004000
96
16
#define MAP_REQ_RESERVED    0x003FE0
97
98
113
#define MAP_REP_FLAG_P      0x080000
99
16
#define MAP_REP_FLAG_E      0x040000
100
16
#define MAP_REP_FLAG_S      0x020000
101
16
#define MAP_REP_RESERVED    0x01FFFF
102
103
16
#define MAP_REG_FLAG_P      0x080000
104
16
#define MAP_REG_FLAG_S      0x040000
105
30
#define MAP_REG_FLAG_I      0x020000
106
30
#define MAP_REG_FLAG_R      0x010000
107
16
#define MAP_REG_RESERVED    0x00FFFE
108
16
#define MAP_REG_FLAG_M      0x000001
109
110
36
#define MAP_NOT_FLAG_I      0x080000
111
36
#define MAP_NOT_FLAG_R      0x040000
112
16
#define MAP_NOT_RESERVED    0x03FFFF
113
114
16
#define MAP_REF_RESERVED    0x0FFFFF
115
116
22
#define INFO_FLAG_R         0x080000
117
16
#define INFO_RESERVED       0x07FFFFFF
118
119
16
#define ECM_FLAG_S          0x08000000
120
26
#define ECM_FLAG_D          0x04000000
121
122
16
#define MCINFO_FLAG_R       0x04
123
16
#define MCINFO_FLAG_L       0x02
124
16
#define MCINFO_FLAG_J       0x01
125
126
16
#define ELP_FLAG_L          0x0004
127
16
#define ELP_FLAG_P          0x0002
128
16
#define ELP_FLAG_S          0x0001
129
130
/* Initialize the protocol and registered fields */
131
static int proto_lisp;
132
static int hf_lisp_type;
133
static int hf_lisp_irc;
134
static int hf_lisp_records;
135
static int hf_lisp_nonce;
136
static int hf_lisp_keyid;
137
static int hf_lisp_authlen;
138
static int hf_lisp_auth;
139
static int hf_lisp_msrtr_keyid;
140
static int hf_lisp_msrtr_authlen;
141
static int hf_lisp_msrtr_auth;
142
static int hf_lisp_xtrid;
143
static int hf_lisp_siteid;
144
145
/* Map-Request fields */
146
static int hf_lisp_mreq_flags;
147
static int hf_lisp_mreq_flags_auth;
148
static int hf_lisp_mreq_flags_mrp;
149
static int hf_lisp_mreq_flags_probe;
150
static int hf_lisp_mreq_flags_smr;
151
static int hf_lisp_mreq_flags_pitr;
152
static int hf_lisp_mreq_flags_smri;
153
static int hf_lisp_mreq_res;
154
static int hf_lisp_mreq_srceid_afi;
155
static int hf_lisp_mreq_srceid_string;
156
static int hf_lisp_mreq_srceid_ipv4;
157
static int hf_lisp_mreq_srceid_ipv6;
158
static int hf_lisp_mreq_srceid_mac;
159
static int hf_lisp_mreq_itr_rloc;
160
static int hf_lisp_mreq_itr_rloc_afi;
161
static int hf_lisp_mreq_itr_rloc_ipv4;
162
static int hf_lisp_mreq_itr_rloc_ipv6;
163
static int hf_lisp_mreq_record;
164
static int hf_lisp_mreq_record_res;
165
static int hf_lisp_mreq_record_prefix_length;
166
static int hf_lisp_mreq_record_prefix_afi;
167
static int hf_lisp_mreq_record_prefix_ipv4;
168
static int hf_lisp_mreq_record_prefix_ipv6;
169
static int hf_lisp_mreq_record_prefix_mac;
170
static int hf_lisp_mreq_record_prefix_dn;
171
172
/* Map-Reply fields */
173
static int hf_lisp_mrep_record;
174
static int hf_lisp_mrep_flags_probe;
175
static int hf_lisp_mrep_flags_enlr;
176
static int hf_lisp_mrep_flags_sec;
177
static int hf_lisp_mrep_res;
178
179
/* Map-Register fields */
180
static int hf_lisp_mreg_flags_pmr;
181
static int hf_lisp_mreg_flags_sec;
182
static int hf_lisp_mreg_flags_xtrid;
183
static int hf_lisp_mreg_flags_rtr;
184
static int hf_lisp_mreg_flags_wmn;
185
static int hf_lisp_mreg_res;
186
187
/* Map-Notify fields */
188
static int hf_lisp_mnot_flags_xtrid;
189
static int hf_lisp_mnot_flags_rtr;
190
static int hf_lisp_mnot_res;
191
192
/* Map-Referral fields */
193
static int hf_lisp_mref_res;
194
static int hf_lisp_referral_sigcnt;
195
static int hf_lisp_referral_incomplete;
196
197
/* Info fields */
198
static int hf_lisp_info_r;
199
static int hf_lisp_info_res1;
200
static int hf_lisp_info_ttl;
201
static int hf_lisp_info_res2;
202
static int hf_lisp_info_prefix_masklen;
203
static int hf_lisp_info_prefix_afi;
204
static int hf_lisp_info_prefix_ipv4;
205
static int hf_lisp_info_prefix_ipv6;
206
static int hf_lisp_info_afi;
207
208
/* Mapping record fields */
209
static int hf_lisp_mapping;
210
static int hf_lisp_mapping_ttl;
211
static int hf_lisp_mapping_loccnt;
212
static int hf_lisp_mapping_eid_masklen;
213
static int hf_lisp_mapping_act;
214
static int hf_lisp_mapping_auth;
215
static int hf_lisp_mapping_res1;
216
static int hf_lisp_mapping_res2;
217
static int hf_lisp_mapping_ver;
218
static int hf_lisp_mapping_eid_afi;
219
static int hf_lisp_mapping_eid_ipv4;
220
static int hf_lisp_mapping_eid_ipv6;
221
static int hf_lisp_mapping_eid_mac;
222
static int hf_lisp_mapping_eid_dn;
223
224
/* Locator fields */
225
static int hf_lisp_loc;
226
static int hf_lisp_loc_priority;
227
static int hf_lisp_loc_weight;
228
static int hf_lisp_loc_mpriority;
229
static int hf_lisp_loc_mweight;
230
static int hf_lisp_loc_flags;
231
static int hf_lisp_loc_flags_local;
232
static int hf_lisp_loc_flags_probe;
233
static int hf_lisp_loc_flags_reach;
234
static int hf_lisp_loc_flags_res;
235
static int hf_lisp_loc_afi;
236
static int hf_lisp_loc_locator;
237
238
/* LCAF fields */
239
static int hf_lisp_lcaf;
240
static int hf_lisp_lcaf_header;
241
static int hf_lisp_lcaf_res1;
242
static int hf_lisp_lcaf_flags;
243
static int hf_lisp_lcaf_type;
244
static int hf_lisp_lcaf_res2;
245
static int hf_lisp_lcaf_length;
246
247
/* LCAF AFI List fields */
248
static int hf_lisp_lcaf_afi_list_item;
249
static int hf_lisp_lcaf_afi_list_afi;
250
static int hf_lisp_lcaf_afi_list_ipv4;
251
static int hf_lisp_lcaf_afi_list_ipv6;
252
static int hf_lisp_lcaf_afi_list_mac;
253
static int hf_lisp_lcaf_afi_list_dn;
254
255
/* LCAF IID fields */
256
static int hf_lisp_lcaf_iid;
257
static int hf_lisp_lcaf_iid_afi;
258
static int hf_lisp_lcaf_iid_ipv4;
259
static int hf_lisp_lcaf_iid_ipv6;
260
static int hf_lisp_lcaf_iid_mac;
261
static int hf_lisp_lcaf_iid_dn;
262
263
/* LCAF ASN fields */
264
static int hf_lisp_lcaf_asn;
265
static int hf_lisp_lcaf_asn_afi;
266
static int hf_lisp_lcaf_asn_ipv4;
267
static int hf_lisp_lcaf_asn_ipv6;
268
static int hf_lisp_lcaf_asn_mac;
269
static int hf_lisp_lcaf_asn_dn;
270
271
/* LCAF Geo Coordinates fields */
272
static int hf_lisp_lcaf_geo_lat;
273
static int hf_lisp_lcaf_geo_lat_hemisphere;
274
static int hf_lisp_lcaf_geo_lat_deg;
275
static int hf_lisp_lcaf_geo_lat_min;
276
static int hf_lisp_lcaf_geo_lat_sec;
277
static int hf_lisp_lcaf_geo_lon;
278
static int hf_lisp_lcaf_geo_lon_hemisphere;
279
static int hf_lisp_lcaf_geo_lon_deg;
280
static int hf_lisp_lcaf_geo_lon_min;
281
static int hf_lisp_lcaf_geo_lon_sec;
282
static int hf_lisp_lcaf_geo_alt;
283
static int hf_lisp_lcaf_geo_afi;
284
static int hf_lisp_lcaf_geo_ipv4;
285
static int hf_lisp_lcaf_geo_ipv6;
286
static int hf_lisp_lcaf_geo_mac;
287
static int hf_lisp_lcaf_geo_dn;
288
289
/* LCAF NATT fields */
290
static int hf_lisp_lcaf_natt_msport;
291
static int hf_lisp_lcaf_natt_etrport;
292
static int hf_lisp_lcaf_natt_rloc;
293
static int hf_lisp_lcaf_natt_rloc_afi;
294
static int hf_lisp_lcaf_natt_rloc_ipv4;
295
static int hf_lisp_lcaf_natt_rloc_ipv6;
296
297
/* LCAF Nonce Locator fields */
298
static int hf_lisp_lcaf_nonce_loc_res;
299
static int hf_lisp_lcaf_nonce_loc;
300
static int hf_lisp_lcaf_nonce_loc_afi;
301
static int hf_lisp_lcaf_nonce_loc_ipv4;
302
static int hf_lisp_lcaf_nonce_loc_ipv6;
303
static int hf_lisp_lcaf_nonce_loc_mac;
304
static int hf_lisp_lcaf_nonce_loc_dn;
305
306
/* LCAF Multicast Group Membership Information fields */
307
static int hf_lisp_lcaf_mcinfo_flags;
308
static int hf_lisp_lcaf_mcinfo_flags_res;
309
static int hf_lisp_lcaf_mcinfo_flags_rp;
310
static int hf_lisp_lcaf_mcinfo_flags_leave;
311
static int hf_lisp_lcaf_mcinfo_flags_join;
312
static int hf_lisp_lcaf_mcinfo_iid;
313
static int hf_lisp_lcaf_mcinfo_res;
314
static int hf_lisp_lcaf_mcinfo_src_masklen;
315
static int hf_lisp_lcaf_mcinfo_grp_masklen;
316
static int hf_lisp_lcaf_mcinfo_src;
317
static int hf_lisp_lcaf_mcinfo_src_afi;
318
static int hf_lisp_lcaf_mcinfo_src_ipv4;
319
static int hf_lisp_lcaf_mcinfo_src_ipv6;
320
static int hf_lisp_lcaf_mcinfo_grp;
321
static int hf_lisp_lcaf_mcinfo_grp_afi;
322
static int hf_lisp_lcaf_mcinfo_grp_ipv4;
323
static int hf_lisp_lcaf_mcinfo_grp_ipv6;
324
325
/* LCAF ELP fields */
326
static int hf_lisp_lcaf_elp_hop;
327
static int hf_lisp_lcaf_elp_hop_flags;
328
static int hf_lisp_lcaf_elp_hop_flags_res;
329
static int hf_lisp_lcaf_elp_hop_flags_lookup;
330
static int hf_lisp_lcaf_elp_hop_flags_probe;
331
static int hf_lisp_lcaf_elp_hop_flags_strict;
332
static int hf_lisp_lcaf_elp_hop_afi;
333
static int hf_lisp_lcaf_elp_hop_ipv4;
334
static int hf_lisp_lcaf_elp_hop_ipv6;
335
336
/* LCAF Source/Destination 2-Tuple Lookups fields */
337
static int hf_lisp_lcaf_srcdst_res;
338
static int hf_lisp_lcaf_srcdst_src_masklen;
339
static int hf_lisp_lcaf_srcdst_dst_masklen;
340
static int hf_lisp_lcaf_srcdst_src;
341
static int hf_lisp_lcaf_srcdst_src_afi;
342
static int hf_lisp_lcaf_srcdst_src_ipv4;
343
static int hf_lisp_lcaf_srcdst_src_ipv6;
344
static int hf_lisp_lcaf_srcdst_src_mac;
345
static int hf_lisp_lcaf_srcdst_dst;
346
static int hf_lisp_lcaf_srcdst_dst_afi;
347
static int hf_lisp_lcaf_srcdst_dst_ipv4;
348
static int hf_lisp_lcaf_srcdst_dst_ipv6;
349
static int hf_lisp_lcaf_srcdst_dst_mac;
350
351
/* LCAF RLE fields */
352
static int hf_lisp_lcaf_rle_entry;
353
static int hf_lisp_lcaf_rle_entry_res;
354
static int hf_lisp_lcaf_rle_entry_level;
355
static int hf_lisp_lcaf_rle_entry_afi;
356
static int hf_lisp_lcaf_rle_entry_ipv4;
357
static int hf_lisp_lcaf_rle_entry_ipv6;
358
359
/* LCAF Key/Value Pair fields */
360
static int hf_lisp_lcaf_kv_key;
361
static int hf_lisp_lcaf_kv_key_afi;
362
static int hf_lisp_lcaf_kv_key_ipv4;
363
static int hf_lisp_lcaf_kv_key_ipv6;
364
static int hf_lisp_lcaf_kv_key_mac;
365
static int hf_lisp_lcaf_kv_key_dn;
366
static int hf_lisp_lcaf_kv_value;
367
static int hf_lisp_lcaf_kv_value_afi;
368
static int hf_lisp_lcaf_kv_value_ipv4;
369
static int hf_lisp_lcaf_kv_value_ipv6;
370
static int hf_lisp_lcaf_kv_value_mac;
371
static int hf_lisp_lcaf_kv_value_dn;
372
373
/* Vendor Specific LCAF fields */
374
static int hf_lisp_lcaf_vendor_res;
375
static int hf_lisp_lcaf_vendor_oui;
376
static int hf_lisp_lcaf_vendor_data;
377
378
/* Encapsulated Control Message fields */
379
static int hf_lisp_ecm_flags_sec;
380
static int hf_lisp_ecm_flags_ddt;
381
static int hf_lisp_ecm_res;
382
383
/* Initialize the subtree pointers */
384
static int ett_lisp;
385
static int ett_lisp_mr;
386
static int ett_lisp_mreq_flags;
387
static int ett_lisp_mapping;
388
static int ett_lisp_itr;
389
static int ett_lisp_record;
390
static int ett_lisp_lcaf;
391
static int ett_lisp_lcaf_header;
392
static int ett_lisp_lcaf_geo_lat;
393
static int ett_lisp_lcaf_geo_lon;
394
static int ett_lisp_lcaf_natt_rloc;
395
static int ett_lisp_lcaf_mcinfo_flags;
396
static int ett_lisp_lcaf_mcinfo_src;
397
static int ett_lisp_lcaf_mcinfo_grp;
398
static int ett_lisp_lcaf_elp_hop;
399
static int ett_lisp_lcaf_elp_hop_flags;
400
static int ett_lisp_lcaf_srcdst_src;
401
static int ett_lisp_lcaf_srcdst_dst;
402
static int ett_lisp_lcaf_rle_entry;
403
static int ett_lisp_lcaf_kv_key;
404
static int ett_lisp_lcaf_kv_value;
405
static int ett_lisp_lcaf_vendor;
406
static int ett_lisp_loc;
407
static int ett_lisp_loc_flags;
408
static int ett_lisp_info_prefix;
409
static int ett_lisp_afi_list;
410
411
static expert_field ei_lisp_undecoded;
412
static expert_field ei_lisp_expected_field;
413
static expert_field ei_lisp_invalid_field;
414
static expert_field ei_lisp_unexpected_field;
415
416
static dissector_handle_t lisp_handle;
417
418
static dissector_handle_t ipv4_handle;
419
static dissector_handle_t ipv6_handle;
420
421
static bool encapsulated;
422
static bool ddt_originated;
423
424
static const value_string lisp_typevals[] = {
425
    { LISP_MAP_REQUEST,     "Map-Request" },
426
    { LISP_MAP_REPLY,       "Map-Reply" },
427
    { LISP_MAP_REGISTER,    "Map-Register" },
428
    { LISP_MAP_NOTIFY,      "Map-Notify" },
429
    { LISP_MAP_REFERRAL,    "Map-Referral" },
430
    { LISP_INFO,            "Info" },
431
    { LISP_ECM,             "Encapsulated Control Message" },
432
    { 0,                    NULL}
433
};
434
435
static const value_string mapping_actions[] = {
436
    { LISP_ACT_NONE,        "No-Action" },
437
    { LISP_ACT_FWD_NATIVE,  "Natively-Forward" },
438
    { LISP_ACT_MREQ,        "Send-Map-Request" },
439
    { LISP_ACT_DROP,        "Drop/No-Reason" },
440
    { LISP_ACT_DROP_PD,     "Drop/Policy-Denied" },
441
    { LISP_ACT_DROP_AF,     "Drop/Authentication-Failure" },
442
    { LISP_ACT_FWD_UA,      "Forward-For-Unknown-Address" },
443
    { 0,                    NULL}
444
};
445
446
static const value_string referral_actions[] = {
447
    { DDT_NODE_REF,         "Node Referral" },
448
    { DDT_MS_REF,           "Map-Server Referral" },
449
    { DDT_MS_ACK,           "Map-Server ACK" },
450
    { DDT_MS_NREG,          "Map-Server Not Registered" },
451
    { DDT_DLGT_HOLE,        "Delegation Hole" },
452
    { DDT_NAUTH,            "Not Authoritative" },
453
    { 0,                    NULL}
454
};
455
456
static const value_string lcaf_typevals[] = {
457
    { LCAF_NULL,            "Null Body" },
458
    { LCAF_AFI_LIST,        "AFI List" },
459
    { LCAF_IID,             "Instance ID" },
460
    { LCAF_ASN,             "AS Number" },
461
    { LCAF_APP_DATA,        "Application Data" },
462
    { LCAF_GEO,             "Geo Coordinates" },
463
    { LCAF_OKEY,            "Opaque Key" },
464
    { LCAF_NATT,            "NAT Traversal" },
465
    { LCAF_NONCE_LOC,       "Nonce Locator" },
466
    { LCAF_MCAST_INFO,      "Multicast Info" },
467
    { LCAF_ELP,             "Explicit Locator Path" },
468
    { LCAF_SEC_KEY,         "Security Key" },
469
    { LCAF_SRC_DST_KEY,     "Source/Dest Key" },
470
    { LCAF_RLE,             "Replication List Entry" },
471
    { LCAF_JSON,            "JSON Data Model" },
472
    { LCAF_KV_ADDR_PAIR,    "Key/Value Address Pair" },
473
    { LCAF_VENDOR,          "Vendor Specific LCAF" },
474
    { 0,                    NULL}
475
};
476
477
static const value_string lat_typevals[] = {
478
    { 0,                    "S" },
479
    { 1,                    "N" },
480
    { 0,                    NULL}
481
};
482
483
static const value_string lon_typevals[] = {
484
    { 0,                    "W" },
485
    { 1,                    "E" },
486
    { 0,                    NULL}
487
};
488
489
/* Add your company OUI here if you're developing a vendor LCAF dissector */
490
static const value_string oui_vals[] = {
491
    { OUI_CISCO,            "Cisco" },
492
    { 0,                    NULL}
493
};
494
495
static int
496
get_lcaf_data(tvbuff_t *tvb, int offset, uint8_t *lcaf_type, uint16_t *len)
497
80
{
498
    /* Jump over Rsvd1 and Flags (16 bits) */
499
80
    offset += 2;
500
501
    /* Type (8 bits) */
502
80
    if (lcaf_type)
503
80
        *lcaf_type = tvb_get_uint8(tvb, offset);
504
80
    offset += 1;
505
506
    /* Jump over Rsvd2 bits (8 bits) */
507
80
    offset += 1;
508
509
    /* Length (16 bits) */
510
80
    if (len)
511
        /* Adding the size of the LCAF header as well */
512
80
        *len = tvb_get_ntohs(tvb, offset) + LCAF_HEADER_LEN;
513
80
    offset += 2;
514
515
80
    return offset;
516
80
}
517
518
const char *
519
// NOLINTNEXTLINE(misc-no-recursion)
520
get_addr_str(tvbuff_t *tvb, packet_info *pinfo, int offset, uint16_t afi, uint16_t *addr_len)
521
11.2k
{
522
11.2k
    const char        *notset_str = "not set";
523
11.2k
    const char        *addr_str;
524
11.2k
    uint8_t            lcaf_type;
525
11.2k
    uint32_t           iid, asn;
526
11.2k
    uint16_t           cur_len;
527
528
11.2k
    switch (afi) {
529
1.93k
        case AFNUM_RESERVED_0:
530
1.93k
            *addr_len  = 0;
531
1.93k
            return notset_str;
532
62
        case AFNUM_IP:
533
62
            *addr_len  = INET_ADDRLEN;
534
62
            addr_str   = tvb_ip_to_str(pinfo->pool, tvb, offset);
535
62
            return addr_str;
536
27
        case AFNUM_IP6:
537
27
            *addr_len  = INET6_ADDRLEN;
538
27
            addr_str   = tvb_ip6_to_str(pinfo->pool, tvb, offset);
539
27
            return addr_str;
540
80
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
541
80
            get_lcaf_data(tvb, offset, &lcaf_type, addr_len);
542
80
            addr_str = val_to_str(pinfo->pool, lcaf_type, lcaf_typevals, "Unknown LCAF Type (%d)");
543
80
            if (lcaf_type == LCAF_IID) {
544
2
                iid = tvb_get_ntohl(tvb, offset + LCAF_HEADER_LEN);
545
2
                afi = tvb_get_ntohs(tvb, offset + LCAF_HEADER_LEN + 4);
546
2
                increment_dissection_depth(pinfo);
547
2
                addr_str = get_addr_str(tvb, pinfo, offset + LCAF_HEADER_LEN + 6, afi, &cur_len);
548
2
                decrement_dissection_depth(pinfo);
549
2
                return wmem_strdup_printf(pinfo->pool, "[%d] %s", iid, addr_str);
550
2
            }
551
78
            if (lcaf_type == LCAF_ASN) {
552
0
                asn = tvb_get_ntohl(tvb, offset + LCAF_HEADER_LEN);
553
0
                afi = tvb_get_ntohs(tvb, offset + LCAF_HEADER_LEN + 4);
554
0
                increment_dissection_depth(pinfo);
555
0
                addr_str = get_addr_str(tvb, pinfo, offset + LCAF_HEADER_LEN + 6, afi, &cur_len);
556
0
                decrement_dissection_depth(pinfo);
557
0
                return wmem_strdup_printf(pinfo->pool, "%s (ASN %d)", addr_str, asn);
558
0
            }
559
78
            return addr_str;
560
9
        case AFNUM_802:
561
10
        case AFNUM_48_BIT_MAC:
562
10
            *addr_len = EUI48_ADDRLEN;
563
10
            addr_str  = tvb_ether_to_str(pinfo->pool, tvb, offset);
564
10
            return addr_str;
565
2
        case AFNUM_DISTINGUISHED_NAME:
566
2
            *addr_len = tvb_strsize(tvb, offset);
567
2
            addr_str  = (char*)tvb_get_stringz_enc(pinfo->pool, tvb, offset, NULL, ENC_ASCII);
568
2
            return addr_str;
569
9.14k
        default:
570
9.14k
            return NULL;
571
11.2k
    }
572
11.2k
}
573
574
static int
575
// NOLINTNEXTLINE(misc-no-recursion)
576
dissect_lcaf_natt_rloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
577
        int offset, const char *str, int idx)
578
6.84k
{
579
6.84k
    uint16_t     addr_len = 0;
580
6.84k
    uint16_t     rloc_afi;
581
6.84k
    const char *rloc_str;
582
6.84k
    proto_item  *ti;
583
6.84k
    proto_tree  *rloc_tree;
584
585
6.84k
    ti = proto_tree_add_item(tree, hf_lisp_lcaf_natt_rloc, tvb, offset, 2, ENC_NA);
586
6.84k
    rloc_tree = proto_item_add_subtree(ti, ett_lisp_lcaf_natt_rloc);
587
588
    /* AFI (2 bytes) */
589
6.84k
    proto_tree_add_item_ret_uint16(rloc_tree, hf_lisp_lcaf_natt_rloc_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &rloc_afi);
590
6.84k
    offset += 2;
591
592
    /* Reencap hop */
593
6.84k
    rloc_str = get_addr_str(tvb, pinfo, offset, rloc_afi, &addr_len);
594
595
6.84k
    switch (rloc_afi) {
596
1.43k
        case AFNUM_RESERVED_0:
597
1.43k
            break;
598
51
        case AFNUM_IP:
599
51
            proto_tree_add_item(rloc_tree, hf_lisp_lcaf_natt_rloc_ipv4,
600
51
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
601
51
            break;
602
11
        case AFNUM_IP6:
603
11
            proto_tree_add_item(rloc_tree, hf_lisp_lcaf_natt_rloc_ipv6,
604
11
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
605
11
            break;
606
11
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
607
11
            dissect_lcaf(tvb, pinfo, rloc_tree, offset, NULL);
608
11
            break;
609
5.31k
        default:
610
5.31k
            expert_add_info_format(pinfo, rloc_tree, &ei_lisp_unexpected_field,
611
5.31k
                    "Unexpected NAT-T RLOC AFI (%d), cannot decode", rloc_afi);
612
6.84k
    }
613
614
6.81k
    if (idx) {
615
6.70k
        proto_item_append_text(ti, str, idx, rloc_str);
616
6.70k
    } else {
617
105
        proto_item_append_text(ti, str, rloc_str);
618
105
    }
619
6.81k
    proto_item_set_len(ti, 2 + addr_len);
620
621
6.81k
    return addr_len + 2;
622
6.84k
}
623
624
static int
625
// NOLINTNEXTLINE(misc-no-recursion)
626
dissect_lcaf_elp_hop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
627
        int offset, int idx, proto_item *tip)
628
564
{
629
564
    uint16_t     addr_len = 0;
630
564
    uint16_t     hop_afi;
631
564
    uint16_t     hop_flags;
632
564
    const char *hop_str;
633
564
    proto_item  *ti, *ti_flags;
634
564
    proto_tree  *hop_tree, *flags_tree;
635
636
564
    ti = proto_tree_add_item(tree, hf_lisp_lcaf_elp_hop, tvb, offset, 2, ENC_NA);
637
564
    hop_tree = proto_item_add_subtree(ti, ett_lisp_lcaf_elp_hop);
638
639
    /* Flags (2 bytes) */
640
564
    ti_flags = proto_tree_add_item(hop_tree, hf_lisp_lcaf_elp_hop_flags, tvb, offset, 2, ENC_BIG_ENDIAN);
641
564
    flags_tree = proto_item_add_subtree(ti_flags, ett_lisp_lcaf_elp_hop_flags);
642
564
    proto_tree_add_item(flags_tree, hf_lisp_lcaf_elp_hop_flags_res, tvb, offset, 2, ENC_BIG_ENDIAN);
643
564
    proto_tree_add_item(flags_tree, hf_lisp_lcaf_elp_hop_flags_lookup, tvb, offset, 2, ENC_BIG_ENDIAN);
644
564
    proto_tree_add_item(flags_tree, hf_lisp_lcaf_elp_hop_flags_probe, tvb, offset, 2, ENC_BIG_ENDIAN);
645
564
    proto_tree_add_item(flags_tree, hf_lisp_lcaf_elp_hop_flags_strict, tvb, offset, 2, ENC_BIG_ENDIAN);
646
647
564
    hop_flags = tvb_get_ntohs(tvb, offset);
648
564
    offset += 2;
649
650
    /* AFI (2 bytes) */
651
564
    proto_tree_add_item_ret_uint16(hop_tree, hf_lisp_lcaf_elp_hop_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &hop_afi);
652
564
    offset += 2;
653
654
    /* Reencap hop */
655
564
    hop_str = get_addr_str(tvb, pinfo, offset, hop_afi, &addr_len);
656
657
564
    switch (hop_afi) {
658
4
        case AFNUM_IP:
659
4
            proto_tree_add_item(hop_tree, hf_lisp_lcaf_elp_hop_ipv4,
660
4
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
661
4
            break;
662
1
        case AFNUM_IP6:
663
1
            proto_tree_add_item(hop_tree, hf_lisp_lcaf_elp_hop_ipv6,
664
1
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
665
1
            break;
666
1
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
667
1
            dissect_lcaf(tvb, pinfo, hop_tree, offset, NULL);
668
1
            break;
669
536
        default:
670
536
            expert_add_info_format(pinfo, hop_tree, &ei_lisp_unexpected_field,
671
536
                    "Unexpected Reencap Hop AFI (%d), cannot decode", hop_afi);
672
564
    }
673
674
541
    if (idx) {
675
541
        proto_item_append_text(ti, " %d.", idx);
676
541
    } else {
677
0
        proto_item_append_text(ti, ":");
678
0
    }
679
680
541
    proto_item_append_text(ti, " %s", hop_str);
681
541
    proto_item_set_len(ti, 4 + addr_len);
682
683
541
    if (hop_flags & 0x04)
684
318
        proto_item_append_text(ti, ", Lookup");
685
541
    if (hop_flags & 0x02)
686
373
        proto_item_append_text(ti, ", RLOC-Probe");
687
541
    if (hop_flags & 0x01)
688
269
        proto_item_append_text(ti, ", Strict");
689
690
541
    proto_item_append_text(tip, ", %s", hop_str);
691
692
541
    return addr_len + 4;
693
564
}
694
695
696
static int
697
// NOLINTNEXTLINE(misc-no-recursion)
698
dissect_lcaf_rle_entry(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
699
        int offset, int idx, proto_item *tip)
700
54
{
701
54
    uint8_t      level;
702
54
    uint16_t     addr_len = 0;
703
54
    uint16_t     entry_afi;
704
54
    const char *entry_str;
705
54
    proto_item  *ti;
706
54
    proto_tree  *entry_tree;
707
708
54
    ti = proto_tree_add_item(tree, hf_lisp_lcaf_rle_entry, tvb, offset, 2, ENC_NA);
709
54
    entry_tree = proto_item_add_subtree(ti, ett_lisp_lcaf_rle_entry);
710
711
    /* Reserved (3 bytes) */
712
54
    proto_tree_add_item(entry_tree, hf_lisp_lcaf_rle_entry_res, tvb, offset, 3, ENC_BIG_ENDIAN);
713
54
    offset += 3;
714
715
    /* Level Value (1 byte) */
716
54
    proto_tree_add_item_ret_uint8(entry_tree, hf_lisp_lcaf_rle_entry_level, tvb, offset, 1, ENC_BIG_ENDIAN, &level);
717
54
    offset += 1;
718
719
    /* AFI (2 bytes) */
720
54
    proto_tree_add_item_ret_uint16(entry_tree, hf_lisp_lcaf_rle_entry_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &entry_afi);
721
54
    offset += 2;
722
723
    /* RTR/ETR entry */
724
54
    entry_str = get_addr_str(tvb, pinfo, offset, entry_afi, &addr_len);
725
726
54
    switch (entry_afi) {
727
1
        case AFNUM_IP:
728
1
            proto_tree_add_item(entry_tree, hf_lisp_lcaf_rle_entry_ipv4,
729
1
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
730
1
            break;
731
0
        case AFNUM_IP6:
732
0
            proto_tree_add_item(entry_tree, hf_lisp_lcaf_rle_entry_ipv6,
733
0
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
734
0
            break;
735
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
736
0
            dissect_lcaf(tvb, pinfo, entry_tree, offset, NULL);
737
0
            break;
738
48
        default:
739
48
            expert_add_info_format(pinfo, entry_tree, &ei_lisp_unexpected_field,
740
48
                    "Unexpected RTR/ETR AFI (%d), cannot decode", entry_afi);
741
54
    }
742
743
49
    if (idx) {
744
49
        proto_item_append_text(ti, " %d.", idx);
745
49
    } else {
746
0
        proto_item_append_text(ti, ":");
747
0
    }
748
749
49
    proto_item_append_text(ti, " %s, level %d", entry_str, level);
750
49
    proto_item_set_len(ti, 6 + addr_len);
751
752
49
    proto_item_append_text(tip, ", %s (%d)", entry_str, level);
753
754
49
    return addr_len + 6;
755
54
}
756
757
758
/*
759
 * Dissector code for AFI List
760
 *
761
 */
762
763
static int
764
// NOLINTNEXTLINE(misc-no-recursion)
765
dissect_lcaf_afi_list(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
766
        int offset, uint16_t length)
767
0
{
768
0
    int old_offset;
769
0
    int remaining = length;
770
0
    int i = 1;
771
0
    int str_len;
772
773
0
    uint16_t           addr_len = 0;
774
0
    uint16_t           afi;
775
0
    const char        *lcaf_str;
776
0
    char              *disp_str;
777
0
    proto_item        *tir;
778
0
    proto_tree        *lisp_afi_list_tree;
779
780
0
    while (remaining > 0) {
781
0
        afi = tvb_get_ntohs(tvb, offset);
782
0
        tir = proto_tree_add_item(tree, hf_lisp_lcaf_afi_list_item, tvb, offset, LCAF_HEADER_LEN, ENC_NA);
783
0
        lisp_afi_list_tree = proto_item_add_subtree(tir, ett_lisp_afi_list);
784
0
        proto_tree_add_item(lisp_afi_list_tree, hf_lisp_lcaf_afi_list_afi, tvb, offset, 2, ENC_BIG_ENDIAN);
785
0
        offset    += 2;
786
0
        remaining -= 2;
787
788
0
        switch (afi) {
789
0
            case AFNUM_IP:
790
0
                proto_tree_add_item(lisp_afi_list_tree, hf_lisp_lcaf_afi_list_ipv4, tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
791
0
                proto_item_append_text(tir, " %d. IPv4 Address: %s", i, tvb_ip_to_str(pinfo->pool, tvb, offset));
792
0
                proto_item_set_len(tir, 2 + INET_ADDRLEN);
793
0
                offset    += INET_ADDRLEN;
794
0
                remaining -= INET_ADDRLEN;
795
0
                break;
796
0
            case AFNUM_IP6:
797
0
                proto_tree_add_item(lisp_afi_list_tree, hf_lisp_lcaf_afi_list_ipv6, tvb, offset, INET6_ADDRLEN, ENC_NA);
798
0
                proto_item_append_text(tir, " %d. IPv6 Address: %s", i, tvb_ip6_to_str(pinfo->pool, tvb, offset));
799
0
                proto_item_set_len(tir, 2 + INET6_ADDRLEN);
800
0
                offset    += INET6_ADDRLEN;
801
0
                remaining -= INET6_ADDRLEN;
802
0
                break;
803
0
            case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
804
0
                old_offset = offset;
805
0
                lcaf_str = get_addr_str(tvb, pinfo, offset, afi, &addr_len);
806
0
                proto_item_append_text(tir, " %d. %s", i, lcaf_str);
807
0
                proto_item_set_len(tir, 2 + addr_len);
808
0
                offset = dissect_lcaf(tvb, pinfo, lisp_afi_list_tree, offset, tir);
809
0
                remaining -= (offset - old_offset);
810
0
                break;
811
0
            case AFNUM_802:
812
0
            case AFNUM_48_BIT_MAC:
813
0
                proto_tree_add_item(lisp_afi_list_tree, hf_lisp_lcaf_afi_list_mac, tvb, offset, EUI48_ADDRLEN, ENC_NA);
814
0
                proto_item_append_text(tir, " %d. MAC Address: %s", i, tvb_ether_to_str(pinfo->pool, tvb, offset));
815
0
                proto_item_set_len(tir, 2 + EUI48_ADDRLEN);
816
0
                offset    += EUI48_ADDRLEN;
817
0
                remaining -= EUI48_ADDRLEN;
818
0
                break;
819
0
            case AFNUM_DISTINGUISHED_NAME:
820
0
                str_len = tvb_strsize(tvb, offset);
821
0
                proto_tree_add_item_ret_display_string(lisp_afi_list_tree, hf_lisp_lcaf_afi_list_dn, tvb, offset, str_len, ENC_ASCII,
822
0
                                                        pinfo->pool, &disp_str);
823
0
                proto_item_append_text(tir, " %d. Distinguished Name: %s", i, disp_str);
824
0
                offset    += str_len;
825
0
                remaining -= str_len;
826
0
                break;
827
0
            default:
828
0
                expert_add_info_format(pinfo, tree, &ei_lisp_unexpected_field,
829
0
                        "Unexpected AFI (%d), cannot decode", afi);
830
0
                return -1;
831
0
        }
832
0
        i++;
833
0
    }
834
835
0
    return offset;
836
0
}
837
838
839
/*
840
 * Dissector code for Instance ID
841
 *
842
 *   0                   1                   2                   3
843
 *   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
844
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
845
 *  |           AFI = 16387         |    Rsvd1      |    Flags      |
846
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
847
 *  |   Type = 2    |     Rsvd2     |             4 + n             |
848
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
849
 *  |                         Instance ID                           |
850
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
851
 *  |              AFI = x          |         Address  ...          |
852
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
853
 *
854
 */
855
856
static int
857
// NOLINTNEXTLINE(misc-no-recursion)
858
dissect_lcaf_iid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_item *tip)
859
2
{
860
2
    const char *ip_address;
861
2
    uint16_t afi, addr_len = 0;
862
2
    int str_len;
863
864
    /* Instance ID (4 bytes) */
865
2
    proto_tree_add_item(tree, hf_lisp_lcaf_iid, tvb, offset, 4, ENC_BIG_ENDIAN);
866
2
    proto_item_append_text(tip, ": %d", tvb_get_ntohl(tvb, offset));
867
2
    offset += 4;
868
869
    /* AFI (2 bytes) */
870
2
    proto_tree_add_item_ret_uint16(tree, hf_lisp_lcaf_iid_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &afi);
871
2
    offset += 2;
872
873
    /* Address */
874
2
    ip_address = get_addr_str(tvb, pinfo, offset, afi, &addr_len);
875
2
    if (ip_address && afi)
876
0
        proto_item_append_text(tip, ", Address: %s", ip_address);
877
878
2
    switch (afi) {
879
1
        case AFNUM_RESERVED_0:
880
1
            break;
881
0
        case AFNUM_IP:
882
0
            proto_tree_add_item(tree, hf_lisp_lcaf_iid_ipv4,
883
0
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
884
0
            offset += INET_ADDRLEN;
885
0
            break;
886
0
        case AFNUM_IP6:
887
0
            proto_tree_add_item(tree, hf_lisp_lcaf_iid_ipv6,
888
0
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
889
0
            offset += INET6_ADDRLEN;
890
0
            break;
891
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
892
0
            offset = dissect_lcaf(tvb, pinfo, tree, offset, NULL);
893
0
            break;
894
0
        case AFNUM_802:
895
0
        case AFNUM_48_BIT_MAC:
896
0
            proto_tree_add_item(tree, hf_lisp_lcaf_iid_mac,
897
0
                    tvb, offset, EUI48_ADDRLEN, ENC_NA);
898
0
            offset += EUI48_ADDRLEN;
899
0
            break;
900
0
        case AFNUM_DISTINGUISHED_NAME:
901
0
            str_len = tvb_strsize(tvb, offset);
902
0
            proto_tree_add_item(tree, hf_lisp_lcaf_iid_dn, tvb, offset, str_len, ENC_ASCII);
903
0
            offset += str_len;
904
0
            break;
905
1
        default:
906
1
            expert_add_info_format(pinfo, tree, &ei_lisp_unexpected_field,
907
1
                    "Unexpected Instance ID AFI (%d), cannot decode", afi);
908
2
    }
909
2
    return offset;
910
2
}
911
912
913
/*
914
 * Dissector code for AS Number
915
 *
916
 *    0                   1                   2                   3
917
 *    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
918
 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
919
 *   |           AFI = 16387         |     Rsvd1     |     Flags     |
920
 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
921
 *   |   Type = 3    |     Rsvd2     |             4 + n             |
922
 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
923
 *   |                           AS Number                           |
924
 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
925
 *   |              AFI = x          |         Address  ...          |
926
 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
927
 *
928
 */
929
930
static int
931
// NOLINTNEXTLINE(misc-no-recursion)
932
dissect_lcaf_asn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_item *tip)
933
0
{
934
0
    const char *addr;
935
0
    uint16_t afi, addr_len = 0;
936
0
    int str_len;
937
938
    /* AS Number (4 bytes) */
939
0
    proto_tree_add_item(tree, hf_lisp_lcaf_asn, tvb, offset, 4, ENC_BIG_ENDIAN);
940
0
    proto_item_append_text(tip, ": %d", tvb_get_ntohl(tvb, offset));
941
0
    offset += 4;
942
943
    /* AFI (2 bytes) */
944
0
    proto_tree_add_item_ret_uint16(tree, hf_lisp_lcaf_asn_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &afi);
945
0
    offset += 2;
946
947
    /* Address */
948
0
    addr = get_addr_str(tvb, pinfo, offset, afi, &addr_len);
949
0
    if (addr && afi)
950
0
        proto_item_append_text(tip, ", Address: %s", addr);
951
952
0
    switch (afi) {
953
0
        case AFNUM_RESERVED_0:
954
0
            break;
955
0
        case AFNUM_IP:
956
0
            proto_tree_add_item(tree, hf_lisp_lcaf_asn_ipv4,
957
0
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
958
0
            offset += INET_ADDRLEN;
959
0
            break;
960
0
        case AFNUM_IP6:
961
0
            proto_tree_add_item(tree, hf_lisp_lcaf_asn_ipv6,
962
0
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
963
0
            offset += INET6_ADDRLEN;
964
0
            break;
965
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
966
0
            offset = dissect_lcaf(tvb, pinfo, tree, offset, NULL);
967
0
            break;
968
0
        case AFNUM_802:
969
0
        case AFNUM_48_BIT_MAC:
970
0
            proto_tree_add_item(tree, hf_lisp_lcaf_asn_mac,
971
0
                    tvb, offset, EUI48_ADDRLEN, ENC_NA);
972
0
            offset += EUI48_ADDRLEN;
973
0
            break;
974
0
        case AFNUM_DISTINGUISHED_NAME:
975
0
            str_len = tvb_strsize(tvb, offset);
976
0
            proto_tree_add_item(tree, hf_lisp_lcaf_asn_dn, tvb, offset, str_len, ENC_ASCII);
977
0
            offset += str_len;
978
0
            break;
979
0
        default:
980
0
            expert_add_info_format(pinfo, tree, &ei_lisp_unexpected_field,
981
0
                    "Unexpected Instance ID AFI (%d), cannot decode", afi);
982
0
    }
983
0
    return offset;
984
0
}
985
986
987
/*
988
 * Dissector code for Geo Coordinates LCAF
989
 *
990
 *   0                   1                   2                   3
991
 *   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
992
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
993
 *  |           AFI = 16387         |     Rsvd1     |     Flags     |
994
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
995
 *  |   Type = 5    |     Rsvd2     |            12 + n             |
996
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
997
 *  |N|     Latitude Degrees        |    Minutes    |    Seconds    |
998
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
999
 *  |E|     Longitude Degrees       |    Minutes    |    Seconds    |
1000
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1001
 *  |                            Altitude                           |
1002
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1003
 *  |              AFI = x          |         Address  ...          |
1004
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1005
 *
1006
 */
1007
1008
static int
1009
// NOLINTNEXTLINE(misc-no-recursion)
1010
dissect_lcaf_geo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_item *tir)
1011
0
{
1012
0
    uint16_t addr_len = 0;
1013
0
    bool north, east;
1014
0
    uint16_t deg;
1015
0
    uint8_t min, sec;
1016
0
    uint32_t alt;
1017
0
    uint16_t afi;
1018
0
    int str_len;
1019
0
    const char *ip_address;
1020
0
    const uint16_t mask = 0x7FFF;   /* prepare mask for N or E bit */
1021
0
    proto_item *ti_lat, *ti_lon, *ti_alt;
1022
0
    proto_tree *lat_tree, *lon_tree;
1023
1024
    /* PROCESS LATITUDE */
1025
1026
0
    ti_lat = proto_tree_add_item(tree, hf_lisp_lcaf_geo_lat, tvb, offset, 4, ENC_NA);
1027
0
    lat_tree = proto_item_add_subtree(ti_lat, ett_lisp_lcaf_geo_lat);
1028
1029
    /* Hemisphere and degrees (2 bytes) */
1030
0
    proto_tree_add_item(lat_tree, hf_lisp_lcaf_geo_lat_hemisphere, tvb, offset, 2, ENC_BIG_ENDIAN);
1031
0
    proto_tree_add_item(lat_tree, hf_lisp_lcaf_geo_lat_deg, tvb, offset, 2, ENC_BIG_ENDIAN);
1032
0
    deg = tvb_get_ntohs(tvb, offset);
1033
0
    north = deg >> 15;
1034
0
    deg &= mask;
1035
0
    if (deg > 90)
1036
0
        expert_add_info_format(pinfo, tree, &ei_lisp_invalid_field,
1037
0
                "Invalid latitude degrees value (%d)", deg);
1038
0
    offset += 2;
1039
1040
    /* Minutes (1 byte) */
1041
0
    proto_tree_add_item_ret_uint8(lat_tree, hf_lisp_lcaf_geo_lat_min, tvb, offset, 1, ENC_BIG_ENDIAN, &min);
1042
0
    if (min > 60)
1043
0
        expert_add_info_format(pinfo, tree, &ei_lisp_invalid_field,
1044
0
                "Invalid latitude minutes value (%d)", min);
1045
0
    offset += 1;
1046
1047
    /* Seconds (1 byte) */
1048
0
    proto_tree_add_item_ret_uint8(lat_tree, hf_lisp_lcaf_geo_lat_sec, tvb, offset, 1, ENC_BIG_ENDIAN, &sec);
1049
0
    if (sec > 60)
1050
0
        expert_add_info_format(pinfo, tree, &ei_lisp_invalid_field,
1051
0
                "Invalid latitude seconds value (%d)", min);
1052
0
    offset += 1;
1053
1054
0
    proto_item_append_text(ti_lat, ": %s %d" UTF8_DEGREE_SIGN "%d' %d\"",
1055
0
            val_to_str_const(north, lat_typevals, ""), deg, min, sec);
1056
0
    proto_item_append_text(tir, ": (%s%d" UTF8_DEGREE_SIGN "%d'%d\"",
1057
0
            val_to_str_const(north, lat_typevals, ""), deg, min, sec);
1058
1059
    /* PROCESS LONGITUDE */
1060
1061
0
    ti_lon = proto_tree_add_item(tree, hf_lisp_lcaf_geo_lon, tvb, offset, 4, ENC_NA);
1062
0
    lon_tree = proto_item_add_subtree(ti_lon, ett_lisp_lcaf_geo_lon);
1063
1064
    /* Hemisphere and degrees (2 bytes) */
1065
0
    proto_tree_add_item(lon_tree, hf_lisp_lcaf_geo_lon_hemisphere, tvb, offset, 2, ENC_BIG_ENDIAN);
1066
0
    proto_tree_add_item(lon_tree, hf_lisp_lcaf_geo_lon_deg, tvb, offset, 2, ENC_BIG_ENDIAN);
1067
0
    deg = tvb_get_ntohs(tvb, offset);
1068
0
    east = deg >> 15;
1069
0
    deg &= mask;
1070
0
    if (deg > 180)
1071
0
        expert_add_info_format(pinfo, tree, &ei_lisp_invalid_field,
1072
0
                "Invalid longitude degrees value (%d)", deg);
1073
0
    offset += 2;
1074
1075
    /* Minutes (1 byte) */
1076
0
    proto_tree_add_item_ret_uint8(lon_tree, hf_lisp_lcaf_geo_lon_min, tvb, offset, 1, ENC_BIG_ENDIAN, &min);
1077
0
    if (min > 60)
1078
0
        expert_add_info_format(pinfo, tree, &ei_lisp_invalid_field,
1079
0
                "Invalid longitude minutes value (%d)", min);
1080
0
    offset += 1;
1081
1082
    /* Seconds (1 byte) */
1083
0
    proto_tree_add_item_ret_uint8(lon_tree, hf_lisp_lcaf_geo_lon_sec, tvb, offset, 1, ENC_BIG_ENDIAN, &sec);
1084
0
    if (sec > 60)
1085
0
        expert_add_info_format(pinfo, tree, &ei_lisp_invalid_field,
1086
0
                "Invalid longitude seconds value (%d)", min);
1087
0
    offset += 1;
1088
1089
0
    proto_item_append_text(ti_lon, ": %s %d" UTF8_DEGREE_SIGN " %d' %d\"",
1090
0
            val_to_str_const(east, lon_typevals, ""), deg, min, sec);
1091
0
    proto_item_append_text(tir, ", %s%d" UTF8_DEGREE_SIGN "%d'%d\")",
1092
0
            val_to_str_const(east, lon_typevals, ""), deg, min, sec);
1093
1094
    /* PROCESS ALTITUDE */
1095
0
    alt = tvb_get_ntohl(tvb, offset);
1096
0
    ti_alt = proto_tree_add_item(tree, hf_lisp_lcaf_geo_alt, tvb, offset, 4, ENC_NA);
1097
    /* if altitude equals 0x7fffffff then no altitude information encoded */
1098
0
    if (alt == 0x7fffffff) {
1099
0
        proto_item_append_text(ti_alt, ": no value encoded");
1100
0
    } else {
1101
0
        proto_item_append_text(ti_alt, ": %d m", alt);
1102
0
        proto_item_append_text(tir, ", Altitude: %d m", alt);
1103
0
    }
1104
0
    offset += 4;
1105
1106
    /* PROCESS ADDRESS */
1107
1108
    /* AFI (2 bytes) */
1109
0
    proto_tree_add_item_ret_uint16(tree, hf_lisp_lcaf_geo_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &afi);
1110
0
    offset += 2;
1111
1112
0
    ip_address = get_addr_str(tvb, pinfo, offset, afi, &addr_len);
1113
0
    if (ip_address && afi)
1114
0
        proto_item_append_text(tir, ", Address: %s", ip_address);
1115
1116
0
    switch (afi) {
1117
0
        case AFNUM_RESERVED_0:
1118
0
            break;
1119
0
        case AFNUM_IP:
1120
0
            proto_tree_add_item(tree, hf_lisp_lcaf_geo_ipv4,
1121
0
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
1122
0
            offset += INET_ADDRLEN;
1123
0
            break;
1124
0
        case AFNUM_IP6:
1125
0
            proto_tree_add_item(tree, hf_lisp_lcaf_geo_ipv6,
1126
0
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
1127
0
            offset += INET6_ADDRLEN;
1128
0
            break;
1129
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
1130
0
            offset = dissect_lcaf(tvb, pinfo, tree, offset, NULL);
1131
0
            break;
1132
0
        case AFNUM_802:
1133
0
        case AFNUM_48_BIT_MAC:
1134
0
            proto_tree_add_item(tree, hf_lisp_lcaf_geo_mac,
1135
0
                    tvb, offset, EUI48_ADDRLEN, ENC_NA);
1136
0
            offset += EUI48_ADDRLEN;
1137
0
            break;
1138
0
        case AFNUM_DISTINGUISHED_NAME:
1139
0
            str_len = tvb_strsize(tvb, offset);
1140
0
            proto_tree_add_item(tree, hf_lisp_lcaf_geo_dn, tvb, offset, str_len, ENC_ASCII);
1141
0
            offset += str_len;
1142
0
            break;
1143
0
        default:
1144
0
            expert_add_info_format(pinfo, tree, &ei_lisp_unexpected_field,
1145
0
                    "Unexpected Geo Coordinates AFI (%d), cannot decode", afi);
1146
0
    }
1147
0
    return offset;
1148
0
}
1149
1150
1151
/*
1152
 * Dissector code for NAT-Traversal
1153
 *
1154
 *   0                   1                   2                   3
1155
 *   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
1156
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1157
 *  |           AFI = 16387         |    Rsvd1      |     Flags     |
1158
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1159
 *  |    Type = 7     |     Rsvd2   |             4 + n             |
1160
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1161
 *  |        MS UDP Port Number     |      ETR UDP Port Number      |
1162
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1163
 *  |              AFI = x          | Global ETR RLOC Address  ...  |
1164
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1165
 *  |              AFI = x          |       MS RLOC Address  ...    |
1166
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1167
 *  |              AFI = x          | Private ETR RLOC Address ...  |
1168
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1169
 *  |              AFI = x          |      RTR RLOC Address 1 ...   |
1170
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1171
 *  |              AFI = x          |       RTR RLOC Address n ...  |
1172
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1173
 *
1174
 */
1175
1176
static int
1177
// NOLINTNEXTLINE(misc-no-recursion)
1178
dissect_lcaf_natt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1179
        int offset, uint16_t length)
1180
35
{
1181
35
    int          i;
1182
35
    int          len;
1183
35
    int          remaining   = length;
1184
35
    const char *global_etr  = " of Global ETR: %s";
1185
35
    const char *ms          = " of MS: %s";
1186
35
    const char *private_etr = " of Private ETR: %s";
1187
35
    const char *rtr         = " of RTR %d: %s";
1188
1189
35
    remaining -= 4;
1190
1191
35
    proto_tree_add_item(tree, hf_lisp_lcaf_natt_msport, tvb, offset, 2, ENC_BIG_ENDIAN);
1192
35
    offset += 2;
1193
35
    remaining -= 2;
1194
35
    proto_tree_add_item(tree, hf_lisp_lcaf_natt_etrport, tvb, offset, 2, ENC_BIG_ENDIAN);
1195
35
    offset += 2;
1196
35
    remaining -= 2;
1197
1198
35
    len = dissect_lcaf_natt_rloc(tvb, pinfo, tree, offset, global_etr, 0);
1199
35
    offset += len;
1200
35
    remaining -= len;
1201
1202
35
    len = dissect_lcaf_natt_rloc(tvb, pinfo, tree, offset, ms, 0);
1203
35
    offset += len;
1204
35
    remaining -= len;
1205
1206
35
    len = dissect_lcaf_natt_rloc(tvb, pinfo, tree, offset, private_etr, 0);
1207
35
    offset += len;
1208
35
    remaining -= len;
1209
1210
35
    i = 1;
1211
6.77k
    while (remaining > 0) {
1212
6.74k
        len = dissect_lcaf_natt_rloc(tvb, pinfo, tree, offset, rtr, i);
1213
6.74k
        offset += len;
1214
6.74k
        remaining -= len;
1215
6.74k
        i++;
1216
6.74k
    }
1217
1218
35
    return offset;
1219
35
}
1220
1221
1222
/*
1223
 * Dissector code for Nonce Locator
1224
 *
1225
 *   0                   1                   2                   3
1226
 *   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
1227
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1228
 *  |           AFI = 16387         |     Rsvd1     |     Flags     |
1229
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1230
 *  |   Type = 8    |     Rsvd2     |             4 + n             |
1231
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1232
 *  |   Reserved    |                  Nonce                        |
1233
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1234
 *  |              AFI = x          |         Address  ...          |
1235
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1236
 *
1237
 */
1238
1239
static int
1240
// NOLINTNEXTLINE(misc-no-recursion)
1241
dissect_lcaf_nonce_loc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_item *tip)
1242
1
{
1243
1
    const char *addr;
1244
1
    uint16_t afi, addr_len = 0;
1245
1
    int str_len;
1246
1247
    /* Reserved (1 byte) */
1248
1
    proto_tree_add_item(tree, hf_lisp_lcaf_nonce_loc_res, tvb, offset, 1, ENC_BIG_ENDIAN);
1249
1
    proto_item_append_text(tip, ": %d", tvb_get_ntohl(tvb, offset));
1250
1
    offset += 1;
1251
1252
    /* Nonce (3 bytes) */
1253
1
    proto_tree_add_item(tree, hf_lisp_lcaf_nonce_loc, tvb, offset, 3, ENC_BIG_ENDIAN);
1254
1
    proto_item_append_text(tip, ": %d", tvb_get_ntohl(tvb, offset));
1255
1
    offset += 3;
1256
1257
    /* AFI (2 bytes) */
1258
1
    proto_tree_add_item_ret_uint16(tree, hf_lisp_lcaf_nonce_loc_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &afi);
1259
1
    offset += 2;
1260
1261
    /* Address */
1262
1
    addr = get_addr_str(tvb, pinfo, offset, afi, &addr_len);
1263
1
    if (addr && afi)
1264
0
        proto_item_append_text(tip, ", Address: %s", addr);
1265
1266
1
    switch (afi) {
1267
0
        case AFNUM_RESERVED_0:
1268
0
            break;
1269
0
        case AFNUM_IP:
1270
0
            proto_tree_add_item(tree, hf_lisp_lcaf_nonce_loc_ipv4,
1271
0
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
1272
0
            offset += INET_ADDRLEN;
1273
0
            break;
1274
0
        case AFNUM_IP6:
1275
0
            proto_tree_add_item(tree, hf_lisp_lcaf_nonce_loc_ipv6,
1276
0
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
1277
0
            offset += INET6_ADDRLEN;
1278
0
            break;
1279
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
1280
0
            offset = dissect_lcaf(tvb, pinfo, tree, offset, NULL);
1281
0
            break;
1282
0
        case AFNUM_802:
1283
0
        case AFNUM_48_BIT_MAC:
1284
0
            proto_tree_add_item(tree, hf_lisp_lcaf_nonce_loc_mac,
1285
0
                    tvb, offset, EUI48_ADDRLEN, ENC_NA);
1286
0
            offset += EUI48_ADDRLEN;
1287
0
            break;
1288
0
        case AFNUM_DISTINGUISHED_NAME:
1289
0
            str_len = tvb_strsize(tvb, offset);
1290
0
            proto_tree_add_item(tree, hf_lisp_lcaf_nonce_loc_dn, tvb, offset, str_len, ENC_ASCII);
1291
0
            offset += str_len;
1292
0
            break;
1293
1
        default:
1294
1
            expert_add_info_format(pinfo, tree, &ei_lisp_unexpected_field,
1295
1
                    "Unexpected Instance ID AFI (%d), cannot decode", afi);
1296
1
    }
1297
1
    return offset;
1298
1
}
1299
1300
1301
/*
1302
 * Dissector code for Multicast Group Membership Information
1303
 *
1304
 *    0                   1                   2                   3
1305
 *    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
1306
 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1307
 *   |           AFI = 16387         |     Rsvd1     |     Flags     |
1308
 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1309
 *   |   Type = 9    |  Rsvd2  |R|L|J|             8 + n             |
1310
 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1311
 *   |                         Instance-ID                           |
1312
 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1313
 *   |            Reserved           | Source MaskLen| Group MaskLen |
1314
 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1315
 *   |              AFI = x          |   Source/Subnet Address  ...  |
1316
 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1317
 *   |              AFI = x          |       Group Address  ...      |
1318
 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1319
 *
1320
 */
1321
1322
static int
1323
// NOLINTNEXTLINE(misc-no-recursion)
1324
dissect_lcaf_mcast_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1325
        int offset, proto_item *tir)
1326
0
{
1327
0
    uint8_t      src_masklen, grp_masklen;
1328
0
    uint16_t     afi, addr_len = 0;
1329
0
    uint32_t     iid;
1330
0
    const char *src_str, *grp_str;
1331
0
    proto_item  *ti_src, *ti_grp;
1332
0
    proto_tree  *src_tree, *grp_tree;
1333
1334
    /* Instance ID (4 bytes) */
1335
0
    proto_tree_add_item_ret_uint(tree, hf_lisp_lcaf_mcinfo_iid, tvb, offset, 4, ENC_BIG_ENDIAN, &iid);
1336
0
    offset += 4;
1337
1338
    /* Reserved (2 bytes) */
1339
0
    proto_tree_add_item(tree, hf_lisp_lcaf_mcinfo_res, tvb, offset, 2, ENC_BIG_ENDIAN);
1340
0
    offset += 2;
1341
1342
    /* Source Mask Length (1 byte) */
1343
0
    proto_tree_add_item_ret_uint8(tree, hf_lisp_lcaf_mcinfo_src_masklen, tvb, offset, 1, ENC_BIG_ENDIAN, &src_masklen);
1344
0
    offset += 1;
1345
1346
    /* Group Mask Length (1 byte) */
1347
0
    proto_tree_add_item_ret_uint8(tree, hf_lisp_lcaf_mcinfo_grp_masklen, tvb, offset, 1, ENC_BIG_ENDIAN, &grp_masklen);
1348
0
    offset += 1;
1349
1350
0
    ti_src   = proto_tree_add_item(tree, hf_lisp_lcaf_mcinfo_src, tvb, offset, 2, ENC_NA);
1351
0
    src_tree = proto_item_add_subtree(ti_src, ett_lisp_lcaf_mcinfo_src);
1352
1353
    /* Source/Subnet AFI (2 bytes) */
1354
0
    proto_tree_add_item_ret_uint16(src_tree, hf_lisp_lcaf_mcinfo_src_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &afi);
1355
0
    offset += 2;
1356
1357
    /* Source/Subnet Address */
1358
0
    src_str = get_addr_str(tvb, pinfo, offset, afi, &addr_len);
1359
1360
0
    switch (afi) {
1361
0
        case AFNUM_IP:
1362
0
            proto_tree_add_item(src_tree, hf_lisp_lcaf_mcinfo_src_ipv4,
1363
0
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
1364
0
            offset += INET_ADDRLEN;
1365
0
            break;
1366
0
        case AFNUM_IP6:
1367
0
            proto_tree_add_item(src_tree, hf_lisp_lcaf_mcinfo_src_ipv6,
1368
0
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
1369
0
            offset += INET6_ADDRLEN;
1370
0
            break;
1371
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
1372
0
            offset = dissect_lcaf(tvb, pinfo, src_tree, offset, NULL);
1373
0
            break;
1374
0
        default:
1375
0
            expert_add_info_format(pinfo, src_tree, &ei_lisp_unexpected_field,
1376
0
                    "Unexpected Source Prefix AFI (%d), cannot decode", afi);
1377
0
    }
1378
1379
0
    proto_item_append_text(ti_src, ": %s", src_str);
1380
0
    proto_item_set_len(ti_src, 2 + addr_len);
1381
1382
0
    ti_grp = proto_tree_add_item(tree, hf_lisp_lcaf_mcinfo_grp, tvb, offset, 2, ENC_NA);
1383
0
    grp_tree = proto_item_add_subtree(ti_grp, ett_lisp_lcaf_mcinfo_grp);
1384
1385
    /* Group AFI (2 bytes) */
1386
0
    proto_tree_add_item_ret_uint16(grp_tree, hf_lisp_lcaf_mcinfo_grp_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &afi);
1387
0
    offset += 2;
1388
1389
    /* Group Address */
1390
0
    grp_str = get_addr_str(tvb, pinfo, offset, afi, &addr_len);
1391
1392
0
    switch (afi) {
1393
0
        case AFNUM_IP:
1394
0
            proto_tree_add_item(grp_tree, hf_lisp_lcaf_mcinfo_grp_ipv4,
1395
0
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
1396
0
            offset += INET_ADDRLEN;
1397
0
            break;
1398
0
        case AFNUM_IP6:
1399
0
            proto_tree_add_item(grp_tree, hf_lisp_lcaf_mcinfo_grp_ipv6,
1400
0
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
1401
0
            offset += INET6_ADDRLEN;
1402
0
            break;
1403
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
1404
0
            offset = dissect_lcaf(tvb, pinfo, grp_tree, offset, NULL);
1405
0
            break;
1406
0
        default:
1407
0
            expert_add_info_format(pinfo, grp_tree, &ei_lisp_unexpected_field,
1408
0
                    "Unexpected Destination Prefix AFI (%d), cannot decode", afi);
1409
0
    }
1410
1411
0
    proto_item_append_text(ti_grp, ": %s", grp_str);
1412
0
    proto_item_set_len(ti_grp, 2 + addr_len);
1413
1414
0
    proto_item_append_text(tir, " ([%d], %s/%d, %s/%d)", iid, src_str, src_masklen, grp_str, grp_masklen);
1415
0
    return offset;
1416
0
}
1417
1418
1419
/*
1420
 * Dissector code for Explicit Locator Path
1421
 *
1422
 *   0                   1                   2                   3
1423
 *   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
1424
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1425
 *  |           AFI = 16387         |     Rsvd1     |     Flags     |
1426
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1427
 *  |   Type = 10   |     Rsvd2     |               n               |
1428
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1429
 *  |           Rsvd3         |L|P|S|           AFI = x             |
1430
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1431
 *  |                         Reencap Hop 1  ...                    |
1432
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1433
 *  |           Rsvd3         |L|P|S|           AFI = x             |
1434
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1435
 *  |                         Reencap Hop k  ...                    |
1436
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1437
 *
1438
 *
1439
 */
1440
1441
static int
1442
// NOLINTNEXTLINE(misc-no-recursion)
1443
dissect_lcaf_elp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1444
        int offset, uint16_t length, proto_item *tir)
1445
27
{
1446
27
    int len;
1447
27
    int remaining = length;
1448
27
    int i = 1;
1449
1450
591
    while (remaining > 0) {
1451
564
        len = dissect_lcaf_elp_hop(tvb, pinfo, tree, offset, i, tir);
1452
564
        offset += len;
1453
564
        remaining -= len;
1454
564
        i++;
1455
564
    }
1456
1457
27
    return offset;
1458
27
}
1459
1460
1461
 /*
1462
  *  Dissector code for Source/Destination 2-Tuple Lookups
1463
  *
1464
  *   0                   1                   2                   3
1465
  *   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
1466
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1467
  *  |           AFI = 16387         |     Rsvd1     |     Flags     |
1468
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1469
  *  |   Type = 12   |     Rsvd2     |             4 + n             |
1470
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1471
  *  |            Reserved           |   Source-ML   |    Dest-ML    |
1472
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1473
  *  |              AFI = x          |         Source-Prefix ...     |
1474
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1475
  *  |              AFI = x          |     Destination-Prefix ...    |
1476
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1477
  *
1478
  */
1479
1480
static int
1481
// NOLINTNEXTLINE(misc-no-recursion)
1482
dissect_lcaf_src_dst_key(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1483
        int offset, proto_item *tir)
1484
0
{
1485
0
    uint8_t      src_masklen, dst_masklen;
1486
0
    uint16_t     afi, addr_len = 0;
1487
0
    const char *src_str, *dst_str;
1488
0
    proto_item  *ti_src, *ti_dst;
1489
0
    proto_tree  *src_tree, *dst_tree;
1490
1491
    /* Reserved (2 bytes) */
1492
0
    proto_tree_add_item(tree, hf_lisp_lcaf_srcdst_res, tvb, offset, 2, ENC_BIG_ENDIAN);
1493
0
    offset += 2;
1494
1495
    /* Source Prefix Mask Length (1 byte) */
1496
0
    proto_tree_add_item_ret_uint8(tree, hf_lisp_lcaf_srcdst_src_masklen, tvb, offset, 1, ENC_BIG_ENDIAN, &src_masklen);
1497
0
    offset += 1;
1498
1499
    /* Destination Prefix Mask Length (1 byte) */
1500
0
    proto_tree_add_item_ret_uint8(tree, hf_lisp_lcaf_srcdst_dst_masklen, tvb, offset, 1, ENC_BIG_ENDIAN, &dst_masklen);
1501
0
    offset += 1;
1502
1503
0
    ti_src   = proto_tree_add_item(tree, hf_lisp_lcaf_srcdst_src, tvb, offset, 2, ENC_NA);
1504
0
    src_tree = proto_item_add_subtree(ti_src, ett_lisp_lcaf_srcdst_src);
1505
1506
    /* Source Prefix AFI (2 bytes) */
1507
0
    proto_tree_add_item_ret_uint16(src_tree, hf_lisp_lcaf_srcdst_src_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &afi);
1508
0
    offset += 2;
1509
1510
    /* Source Prefix */
1511
0
    src_str = get_addr_str(tvb, pinfo, offset, afi, &addr_len);
1512
1513
0
    switch (afi) {
1514
0
        case AFNUM_IP:
1515
0
            proto_tree_add_item(src_tree, hf_lisp_lcaf_srcdst_src_ipv4,
1516
0
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
1517
0
            offset += INET_ADDRLEN;
1518
0
            break;
1519
0
        case AFNUM_IP6:
1520
0
            proto_tree_add_item(src_tree, hf_lisp_lcaf_srcdst_src_ipv6,
1521
0
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
1522
0
            offset += INET6_ADDRLEN;
1523
0
            break;
1524
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
1525
0
            offset = dissect_lcaf(tvb, pinfo, src_tree, offset, NULL);
1526
0
            break;
1527
0
        case AFNUM_802:
1528
0
        case AFNUM_48_BIT_MAC:
1529
0
            proto_tree_add_item(src_tree, hf_lisp_lcaf_srcdst_src_mac,
1530
0
                    tvb, offset, EUI48_ADDRLEN, ENC_NA);
1531
0
            offset += EUI48_ADDRLEN;
1532
0
            break;
1533
0
        default:
1534
0
            expert_add_info_format(pinfo, src_tree, &ei_lisp_unexpected_field,
1535
0
                    "Unexpected Source Prefix AFI (%d), cannot decode", afi);
1536
0
    }
1537
1538
0
    proto_item_append_text(ti_src, ": %s", src_str);
1539
0
    proto_item_set_len(ti_src, 2 + addr_len);
1540
1541
0
    ti_dst = proto_tree_add_item(tree, hf_lisp_lcaf_srcdst_dst, tvb, offset, 2, ENC_NA);
1542
0
    dst_tree = proto_item_add_subtree(ti_dst, ett_lisp_lcaf_srcdst_dst);
1543
1544
    /* Destination Prefix AFI (2 bytes) */
1545
0
    proto_tree_add_item_ret_uint16(dst_tree, hf_lisp_lcaf_srcdst_dst_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &afi);
1546
0
    offset += 2;
1547
1548
    /* Destination Prefix */
1549
0
    dst_str = get_addr_str(tvb, pinfo, offset, afi, &addr_len);
1550
1551
0
    switch (afi) {
1552
0
        case AFNUM_IP:
1553
0
            proto_tree_add_item(dst_tree, hf_lisp_lcaf_srcdst_dst_ipv4,
1554
0
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
1555
0
            offset += INET_ADDRLEN;
1556
0
            break;
1557
0
        case AFNUM_IP6:
1558
0
            proto_tree_add_item(dst_tree, hf_lisp_lcaf_srcdst_dst_ipv6,
1559
0
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
1560
0
            offset += INET6_ADDRLEN;
1561
0
            break;
1562
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
1563
0
            offset = dissect_lcaf(tvb, pinfo, dst_tree, offset, NULL);
1564
0
            break;
1565
0
        case AFNUM_802:
1566
0
        case AFNUM_48_BIT_MAC:
1567
0
            proto_tree_add_item(dst_tree, hf_lisp_lcaf_srcdst_dst_mac,
1568
0
                    tvb, offset, EUI48_ADDRLEN, ENC_NA);
1569
0
            offset += EUI48_ADDRLEN;
1570
0
            break;
1571
0
        default:
1572
0
            expert_add_info_format(pinfo, dst_tree, &ei_lisp_unexpected_field,
1573
0
                    "Unexpected Destination Prefix AFI (%d), cannot decode", afi);
1574
0
    }
1575
1576
0
    proto_item_append_text(ti_dst, ": %s", dst_str);
1577
0
    proto_item_set_len(ti_dst, 2 + addr_len);
1578
1579
0
    proto_item_append_text(tir, " (%s/%d, %s/%d)", src_str, src_masklen, dst_str, dst_masklen);
1580
0
    return offset;
1581
0
}
1582
1583
1584
/*
1585
 * Dissector code for Replication List Entries for Multicast Forwarding
1586
 *
1587
 *   0                   1                   2                   3
1588
 *   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
1589
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1590
 *  |           AFI = 16387         |     Rsvd1     |     Flags     |
1591
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1592
 *  |   Type = 13   |    Rsvd2      |             4 + n             |
1593
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1594
 *  |              Rsvd3            |     Rsvd4     |  Level Value  |
1595
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1596
 *  |              AFI = x          |           RTR/ETR #1 ...      |
1597
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1598
 *  |              Rsvd3            |     Rsvd4     |  Level Value  |
1599
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1600
 *  |              AFI = x          |           RTR/ETR  #n ...     |
1601
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1602
 *
1603
 */
1604
1605
static int
1606
// NOLINTNEXTLINE(misc-no-recursion)
1607
dissect_lcaf_rle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1608
        int offset, uint16_t length, proto_item *tir)
1609
6
{
1610
6
    int len;
1611
6
    int remaining = length;
1612
6
    int i = 1;
1613
1614
60
    while (remaining > 0) {
1615
54
        len = dissect_lcaf_rle_entry(tvb, pinfo, tree, offset, i, tir);
1616
54
        offset += len;
1617
54
        remaining -= len;
1618
54
        i++;
1619
54
    }
1620
1621
6
    return offset;
1622
6
}
1623
1624
1625
 /*
1626
  *  Dissector code for Key/Value Address Pairs
1627
  *
1628
  *   0                   1                   2                   3
1629
  *   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
1630
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1631
  *  |           AFI = 16387         |     Rsvd1     |     Flags     |
1632
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1633
  *  |   Type = 15   |     Rsvd2     |               n               |
1634
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1635
  *  |              AFI = x          |       Address as Key ...      |
1636
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1637
  *  |              AFI = x          |       Address as Value ...    |
1638
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1639
  *
1640
  */
1641
1642
static int
1643
// NOLINTNEXTLINE(misc-no-recursion)
1644
dissect_lcaf_kv_addr_pair(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1645
        int offset)
1646
0
{
1647
0
    uint16_t     afi, addr_len = 0;
1648
0
    const char *key_str, *value_str;
1649
0
    proto_item  *ti_key, *ti_value;
1650
0
    proto_tree  *key_tree, *value_tree;
1651
0
    int          str_len;
1652
1653
0
    ti_key   = proto_tree_add_item(tree, hf_lisp_lcaf_kv_key, tvb, offset, 2, ENC_NA);
1654
0
    key_tree = proto_item_add_subtree(ti_key, ett_lisp_lcaf_kv_key);
1655
1656
    /* Key AFI (2 bytes) */
1657
0
    proto_tree_add_item_ret_uint16(key_tree, hf_lisp_lcaf_kv_key_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &afi);
1658
0
    offset += 2;
1659
1660
    /* Key */
1661
0
    key_str = get_addr_str(tvb, pinfo, offset, afi, &addr_len);
1662
1663
0
    switch (afi) {
1664
0
        case AFNUM_IP:
1665
0
            proto_tree_add_item(key_tree, hf_lisp_lcaf_kv_key_ipv4,
1666
0
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
1667
0
            offset += INET_ADDRLEN;
1668
0
            break;
1669
0
        case AFNUM_IP6:
1670
0
            proto_tree_add_item(key_tree, hf_lisp_lcaf_kv_key_ipv6,
1671
0
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
1672
0
            offset += INET6_ADDRLEN;
1673
0
            break;
1674
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
1675
0
            offset = dissect_lcaf(tvb, pinfo, key_tree, offset, NULL);
1676
0
            break;
1677
0
        case AFNUM_802:
1678
0
        case AFNUM_48_BIT_MAC:
1679
0
            proto_tree_add_item(key_tree, hf_lisp_lcaf_kv_key_mac,
1680
0
                    tvb, offset, EUI48_ADDRLEN, ENC_NA);
1681
0
            offset += EUI48_ADDRLEN;
1682
0
            break;
1683
0
        case AFNUM_DISTINGUISHED_NAME:
1684
0
            str_len = tvb_strsize(tvb, offset);
1685
0
            proto_tree_add_item(key_tree, hf_lisp_lcaf_kv_key_dn, tvb, offset, str_len, ENC_ASCII);
1686
0
            offset += str_len;
1687
0
            break;
1688
0
        default:
1689
0
            expert_add_info_format(pinfo, key_tree, &ei_lisp_unexpected_field,
1690
0
                    "Unexpected Key AFI (%d), cannot decode", afi);
1691
0
    }
1692
1693
0
    proto_item_append_text(ti_key, ": %s", key_str);
1694
0
    proto_item_set_len(ti_key, 2 + addr_len);
1695
1696
0
    ti_value = proto_tree_add_item(tree, hf_lisp_lcaf_kv_value, tvb, offset, 2, ENC_NA);
1697
0
    value_tree = proto_item_add_subtree(ti_value, ett_lisp_lcaf_kv_value);
1698
1699
    /* Value AFI (2 bytes) */
1700
0
    proto_tree_add_item_ret_uint16(value_tree, hf_lisp_lcaf_kv_value_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &afi);
1701
0
    offset += 2;
1702
1703
    /* Value */
1704
0
    value_str = get_addr_str(tvb, pinfo, offset, afi, &addr_len);
1705
1706
0
    switch (afi) {
1707
0
        case AFNUM_IP:
1708
0
            proto_tree_add_item(value_tree, hf_lisp_lcaf_kv_value_ipv4,
1709
0
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
1710
0
            offset += INET_ADDRLEN;
1711
0
            break;
1712
0
        case AFNUM_IP6:
1713
0
            proto_tree_add_item(value_tree, hf_lisp_lcaf_kv_value_ipv6,
1714
0
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
1715
0
            offset += INET6_ADDRLEN;
1716
0
            break;
1717
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
1718
0
            offset = dissect_lcaf(tvb, pinfo, value_tree, offset, NULL);
1719
0
            break;
1720
0
        case AFNUM_802:
1721
0
        case AFNUM_48_BIT_MAC:
1722
0
            proto_tree_add_item(value_tree, hf_lisp_lcaf_kv_value_mac,
1723
0
                    tvb, offset, EUI48_ADDRLEN, ENC_NA);
1724
0
            offset += EUI48_ADDRLEN;
1725
0
            break;
1726
0
        case AFNUM_DISTINGUISHED_NAME:
1727
0
            str_len = tvb_strsize(tvb, offset);
1728
0
            proto_tree_add_item(value_tree, hf_lisp_lcaf_kv_value_dn, tvb, offset, str_len, ENC_ASCII);
1729
0
            offset += str_len;
1730
0
            break;
1731
0
        default:
1732
0
            expert_add_info_format(pinfo, value_tree, &ei_lisp_unexpected_field,
1733
0
                    "Unexpected Value AFI (%d), cannot decode", afi);
1734
0
    }
1735
1736
0
    proto_item_append_text(ti_value, ": %s", value_str);
1737
0
    proto_item_set_len(ti_value, 2 + addr_len);
1738
1739
0
    return offset;
1740
0
}
1741
1742
1743
/*
1744
  *  Dissector code for Vendor Specific LCAF
1745
  *
1746
  *   0                   1                   2                   3
1747
  *   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
1748
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1749
  *  |           AFI = 16387         |     Rsvd1     |     Flags     |
1750
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1751
  *  |   Type = 255  |     Rsvd2     |            Length             |
1752
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1753
  *  |      Rsvd3    |    Organizationally Unique Identifier (OUI)   |
1754
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1755
  *  |                        Internal format...                     |
1756
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1757
  *
1758
  */
1759
1760
static int
1761
dissect_lcaf_vendor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1762
        int offset, uint16_t length)
1763
0
{
1764
0
    int len;
1765
0
    proto_item  *ti_vendor;
1766
0
    proto_tree  *vendor_tree;
1767
1768
    /* Reserved (1 byte) */
1769
0
    proto_tree_add_item(tree, hf_lisp_lcaf_vendor_res, tvb, offset, 1, ENC_BIG_ENDIAN);
1770
0
    offset += 1;
1771
1772
    /* Organizationally Unique Identifier (3 bytes) */
1773
0
    proto_tree_add_item(tree, hf_lisp_lcaf_vendor_oui, tvb, offset, 3, ENC_BIG_ENDIAN);
1774
0
    offset += 3;
1775
1776
    /* Vendor Data */
1777
0
    len = length - 4;
1778
0
    ti_vendor = proto_tree_add_item(tree, hf_lisp_lcaf_vendor_data, tvb, offset, len, ENC_NA);
1779
0
    vendor_tree = proto_item_add_subtree(ti_vendor, ett_lisp_lcaf_vendor);
1780
0
    expert_add_info_format(pinfo, vendor_tree, &ei_lisp_undecoded,
1781
0
                    "Look up the vendor's OUI (IEEE 802-2001) and contact them for support on decoding this field");
1782
0
    offset += len;
1783
1784
0
    return offset;
1785
0
}
1786
1787
1788
/*
1789
 * Dissector code for LISP Canonical Address Format (LCAF)
1790
 *
1791
 *   0                   1                   2                   3
1792
 *   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
1793
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1794
 *  |           AFI = 16387         |    Rsvd1     |     Flags      |
1795
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1796
 *  |    Type       |     Rsvd2     |            Length             |
1797
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1798
 *
1799
 *  Type 0:   Null Body Type
1800
 *  Type 1:   AFI List Type
1801
 *  Type 2:   Instance ID Type
1802
 *  Type 3:   AS Number Type
1803
 *  Type 4:   Application Data Type
1804
 *  Type 5:   Geo Coordinates Type
1805
 *  Type 6:   Opaque Key Type
1806
 *  Type 7:   NAT-Traversal Type
1807
 *  Type 8:   Nonce Locator Type
1808
 *  Type 9:   Multicast Info Type
1809
 *  Type 10:  Explicit Locator Path Type
1810
 *  Type 11:  Security Key Type
1811
 *  Type 12:  Source/Dest Key Type
1812
 *  Type 13:  Replication List Entry Type
1813
 *  Type 14:  JSON Data Model Type
1814
 *  Type 15:  Key/Value Address Pair Type
1815
 *  Type 255: Vendor Specific LCAF
1816
 *
1817
 */
1818
1819
int
1820
// NOLINTNEXTLINE(misc-no-recursion)
1821
dissect_lcaf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_item *tip)
1822
80
{
1823
80
    uint8_t      lcaf_type;
1824
80
    uint16_t     len;
1825
80
    proto_item  *tir, *ti_header, *ti_flags, *ti;
1826
80
    proto_tree  *lcaf_tree, *lcaf_header_tree, *flags_tree;
1827
80
    tvbuff_t    *payload_tvb;
1828
1829
80
    len = tvb_get_ntohs(tvb, offset + 4);
1830
1831
80
    tir = proto_tree_add_item(tree, hf_lisp_lcaf, tvb, offset, LCAF_HEADER_LEN + len, ENC_NA);
1832
80
    lcaf_tree = proto_item_add_subtree(tir, ett_lisp_lcaf);
1833
1834
80
    ti_header = proto_tree_add_item(lcaf_tree, hf_lisp_lcaf_header, tvb, offset, LCAF_HEADER_LEN, ENC_NA);
1835
80
    lcaf_header_tree = proto_item_add_subtree(ti_header, ett_lisp_lcaf_header);
1836
1837
    /* Reserved bits (8 bits) */
1838
80
    proto_tree_add_item(lcaf_header_tree, hf_lisp_lcaf_res1, tvb, offset, 1, ENC_BIG_ENDIAN);
1839
80
    offset += 1;
1840
1841
    /* Flags (8 bits) */
1842
80
    proto_tree_add_item(lcaf_header_tree, hf_lisp_lcaf_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
1843
80
    offset += 1;
1844
1845
    /* Type (8 bits) */
1846
80
    proto_tree_add_item_ret_uint8(lcaf_header_tree, hf_lisp_lcaf_type, tvb, offset, 1, ENC_BIG_ENDIAN, &lcaf_type);
1847
80
    proto_item_append_text(tir, ": %s", val_to_str(pinfo->pool, lcaf_type, lcaf_typevals, "Unknown (%d)"));
1848
80
    offset += 1;
1849
1850
80
    if (lcaf_type == LCAF_MCAST_INFO) {
1851
0
        ti_flags = proto_tree_add_item(lcaf_header_tree, hf_lisp_lcaf_mcinfo_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
1852
0
        flags_tree = proto_item_add_subtree(ti_flags, ett_lisp_lcaf_mcinfo_flags);
1853
1854
        /* Reserved (5 bits) */
1855
0
        proto_tree_add_item(flags_tree, hf_lisp_lcaf_mcinfo_flags_res, tvb, offset, 1, ENC_BIG_ENDIAN);
1856
1857
        /* Flags (3 bits) */
1858
0
        proto_tree_add_item(flags_tree, hf_lisp_lcaf_mcinfo_flags_rp, tvb, offset, 1, ENC_NA);
1859
0
        proto_tree_add_item(flags_tree, hf_lisp_lcaf_mcinfo_flags_leave, tvb, offset, 1, ENC_NA);
1860
0
        proto_tree_add_item(flags_tree, hf_lisp_lcaf_mcinfo_flags_join, tvb, offset, 1, ENC_NA);
1861
80
    } else {
1862
        /* Reserved (8 bits) */
1863
80
        proto_tree_add_item(lcaf_header_tree, hf_lisp_lcaf_res2, tvb, offset, 1, ENC_BIG_ENDIAN);
1864
80
    }
1865
80
    offset += 1;
1866
1867
    /* Length (16 bits) */
1868
80
    proto_tree_add_item(lcaf_header_tree, hf_lisp_lcaf_length, tvb, offset, 2, ENC_BIG_ENDIAN);
1869
80
    offset += 2;
1870
1871
80
    payload_tvb = tvb_new_subset_length(tvb, 0, offset + len);
1872
80
    ti = (tip) ? tip : tir;
1873
1874
80
    increment_dissection_depth(pinfo);
1875
80
    switch (lcaf_type) {
1876
1
        case LCAF_NULL:
1877
1
            break;
1878
0
        case LCAF_AFI_LIST:
1879
0
            offset = dissect_lcaf_afi_list(payload_tvb, pinfo, lcaf_tree, offset, len);
1880
0
            break;
1881
2
        case LCAF_IID:
1882
2
            offset = dissect_lcaf_iid(payload_tvb, pinfo, lcaf_tree, offset, ti);
1883
2
            break;
1884
0
        case LCAF_ASN:
1885
0
            offset = dissect_lcaf_asn(payload_tvb, pinfo, lcaf_tree, offset, ti);
1886
0
            break;
1887
0
        case LCAF_GEO:
1888
0
            offset = dissect_lcaf_geo(payload_tvb, pinfo, lcaf_tree, offset, ti);
1889
0
            break;
1890
35
        case LCAF_NATT:
1891
35
            offset = dissect_lcaf_natt(payload_tvb, pinfo, lcaf_tree, offset, len);
1892
35
            break;
1893
1
        case LCAF_NONCE_LOC:
1894
1
            offset = dissect_lcaf_nonce_loc(payload_tvb, pinfo, lcaf_tree, offset, ti);
1895
1
            break;
1896
0
        case LCAF_MCAST_INFO:
1897
0
            offset = dissect_lcaf_mcast_info(payload_tvb, pinfo, lcaf_tree, offset, ti);
1898
0
            break;
1899
27
        case LCAF_ELP:
1900
27
            offset = dissect_lcaf_elp(payload_tvb, pinfo, lcaf_tree, offset, len, ti);
1901
27
            break;
1902
0
        case LCAF_SRC_DST_KEY:
1903
0
            offset = dissect_lcaf_src_dst_key(payload_tvb, pinfo, lcaf_tree, offset, ti);
1904
0
            break;
1905
6
        case LCAF_RLE:
1906
6
            offset = dissect_lcaf_rle(payload_tvb, pinfo, lcaf_tree, offset, len, ti);
1907
6
            break;
1908
0
        case LCAF_KV_ADDR_PAIR:
1909
0
            offset = dissect_lcaf_kv_addr_pair(payload_tvb, pinfo, lcaf_tree, offset);
1910
0
            break;
1911
0
        case LCAF_VENDOR:
1912
0
            offset = dissect_lcaf_vendor(payload_tvb, pinfo, lcaf_tree, offset, len);
1913
0
            break;
1914
8
        default:
1915
8
            proto_tree_add_expert(tree, pinfo, &ei_lisp_undecoded, tvb, offset, len);
1916
8
            return offset + len;
1917
80
    }
1918
9
    decrement_dissection_depth(pinfo);
1919
9
    return offset;
1920
80
}
1921
1922
1923
/*
1924
 * Dissector code for locator records within control packets
1925
 *
1926
 *   0                   1                   2                   3
1927
 *   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
1928
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1929
 *  |    Priority   |    Weight     |  M Priority   |   M Weight    |
1930
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1931
 *  |        Unused Flags     |L|p|R|           Loc-AFI             |
1932
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1933
 *  |                             Locator                           |
1934
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1935
 *
1936
 */
1937
1938
static int
1939
dissect_lisp_locator(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_mapping_tree, int rec)
1940
637
{
1941
637
    int          offset   = 0;
1942
637
    uint16_t     addr_len = 0;
1943
637
    uint8_t      prio;
1944
637
    uint8_t      weight;
1945
637
    uint8_t      m_prio;
1946
637
    uint8_t      m_weight;
1947
637
    uint16_t     flags;
1948
637
    uint16_t     loc_afi;
1949
637
    const char *locator;
1950
637
    proto_item  *tir, *ti_flags;
1951
637
    proto_tree  *lisp_lcaf_tree, *lisp_loc_tree, *lisp_flags_tree;
1952
1953
637
    tir = proto_tree_add_item(lisp_mapping_tree, hf_lisp_loc, tvb, offset, 8, ENC_NA);
1954
1955
637
    lisp_loc_tree = proto_item_add_subtree(tir, ett_lisp_loc);
1956
1957
637
    proto_tree_add_item(lisp_loc_tree, hf_lisp_loc_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
1958
637
    prio = tvb_get_uint8(tvb, offset);
1959
637
    offset += 1;
1960
1961
637
    proto_tree_add_item_ret_uint8(lisp_loc_tree, hf_lisp_loc_weight, tvb, offset, 1, ENC_BIG_ENDIAN, &weight);
1962
637
    offset += 1;
1963
1964
637
    proto_tree_add_item(lisp_loc_tree, hf_lisp_loc_mpriority, tvb, offset, 1, ENC_BIG_ENDIAN);
1965
637
    m_prio = tvb_get_uint8(tvb, offset);
1966
637
    offset += 1;
1967
1968
637
    proto_tree_add_item(lisp_loc_tree, hf_lisp_loc_mweight, tvb, offset, 1, ENC_BIG_ENDIAN);
1969
637
    m_weight = tvb_get_uint8(tvb, offset);
1970
637
    offset += 1;
1971
1972
637
    ti_flags = proto_tree_add_item(lisp_loc_tree, hf_lisp_loc_flags, tvb, offset, 2, ENC_BIG_ENDIAN);
1973
637
    lisp_flags_tree = proto_item_add_subtree(ti_flags, ett_lisp_loc_flags);
1974
637
    proto_tree_add_item(lisp_flags_tree, hf_lisp_loc_flags_res, tvb, offset, 2, ENC_BIG_ENDIAN);
1975
637
    proto_tree_add_item(lisp_flags_tree, hf_lisp_loc_flags_local, tvb, offset, 2, ENC_BIG_ENDIAN);
1976
637
    proto_tree_add_item(lisp_flags_tree, hf_lisp_loc_flags_probe, tvb, offset, 2, ENC_BIG_ENDIAN);
1977
637
    proto_tree_add_item(lisp_flags_tree, hf_lisp_loc_flags_reach, tvb, offset, 2, ENC_BIG_ENDIAN);
1978
637
    flags = tvb_get_ntohs(tvb, offset);
1979
637
    offset += 2;
1980
1981
637
    proto_tree_add_item_ret_uint16(lisp_loc_tree, hf_lisp_loc_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &loc_afi);
1982
637
    offset += 2;
1983
1984
637
    locator = get_addr_str(tvb, pinfo, offset, loc_afi, &addr_len);
1985
1986
637
    if (locator == NULL) {
1987
382
        expert_add_info_format(pinfo, lisp_mapping_tree, &ei_lisp_unexpected_field,
1988
382
                "Unexpected locator AFI (%d), cannot decode", loc_afi);
1989
382
        return offset;
1990
382
    }
1991
1992
255
    if (loc_afi == AFNUM_LISP_CANONICAL_ADDRESS_FORMAT) {
1993
        /* Create a sub-tree for the mapping */
1994
1
        lisp_lcaf_tree = proto_item_add_subtree(tir, ett_lisp_lcaf);
1995
1
        offset = dissect_lcaf(tvb, pinfo, lisp_lcaf_tree, offset, NULL);
1996
254
    } else {
1997
254
        proto_tree_add_string(lisp_loc_tree, hf_lisp_loc_locator, tvb, offset, addr_len, locator);
1998
254
        offset += addr_len;
1999
254
    }
2000
2001
255
    proto_item_append_text(tir, " %d, %sRLOC: %s%s, %s, Priority/Weight: %d/%d, Multicast Priority/Weight: %d/%d",
2002
255
            rec,
2003
255
            (flags&LOCAL_BIT_MASK) ? "Local " : "",
2004
255
            locator,
2005
255
            (flags&PROBE_BIT_MASK) ? " (probed)" : "",
2006
255
            (flags&REACH_BIT_MASK) ? "Reachable" : "Unreachable",
2007
255
            prio, weight, m_prio, m_weight);
2008
255
    proto_item_set_len(tir, 8 + addr_len);
2009
2010
255
    return offset;
2011
637
}
2012
2013
2014
/*
2015
 * Dissector code for mapping records within control packets
2016
 *
2017
 *   0                   1                   2                   3
2018
 *   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
2019
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2020
 *  |                          Record  TTL                          |
2021
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2022
 *  | Locator Count | EID mask-len  | ACT |A|      Reserved         |
2023
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2024
 *  | Rsvd  |  Map-Version Number   |            EID-AFI            |
2025
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2026
 *  |                          EID-prefix                           |
2027
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2028
 *
2029
 */
2030
2031
int
2032
dissect_lisp_mapping(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tree,
2033
        uint8_t rec_cnt, int rec, bool referral, int offset, proto_item *tim)
2034
3.24k
{
2035
3.24k
    int          i;
2036
3.24k
    int          str_len;
2037
3.24k
    uint16_t     addr_len      = 0;
2038
3.24k
    uint8_t      prefix_mask, loc_cnt;
2039
3.24k
    uint16_t     flags;
2040
3.24k
    uint16_t     act;
2041
3.24k
    uint16_t     prefix_afi, eid_afi;
2042
3.24k
    const char *prefix;
2043
3.24k
    proto_item  *tir;
2044
3.24k
    proto_tree  *lisp_mapping_tree, *lcaf_prefix_tree;
2045
2046
3.24k
    prefix_mask   = tvb_get_uint8(tvb, offset + 5);
2047
3.24k
    flags         = tvb_get_ntohs(tvb, offset + 6);
2048
3.24k
    prefix_afi    = tvb_get_ntohs(tvb, offset + 10);
2049
2050
3.24k
    act = flags & LISP_MAP_ACT;
2051
3.24k
    act >>= 13;
2052
2053
3.24k
    prefix = get_addr_str(tvb, pinfo, offset + 12, prefix_afi, &addr_len);
2054
2055
3.24k
    if (prefix == NULL) {
2056
2.93k
        expert_add_info_format(pinfo, lisp_tree, &ei_lisp_unexpected_field,
2057
2.93k
                "Unexpected EID prefix AFI (%d), cannot decode", prefix_afi);
2058
2.93k
        return offset;
2059
2.93k
    }
2060
318
    tir = proto_tree_add_item(lisp_tree, hf_lisp_mapping, tvb, offset, 12 + addr_len, ENC_NA);
2061
318
    if (tim) {
2062
0
        proto_item_append_text(tim, " for %s/%d", prefix, prefix_mask);
2063
0
    }
2064
2065
    /* Update the INFO column if there is only one record */
2066
318
    if (rec_cnt == 1)
2067
2
        col_append_fstr(pinfo->cinfo, COL_INFO, " for %s/%d",
2068
2
                prefix, prefix_mask);
2069
2070
    /* Create a sub-tree for the mapping */
2071
318
    lisp_mapping_tree = proto_item_add_subtree(tir, ett_lisp_mapping);
2072
318
    proto_item_append_text(tir, " %d, EID Prefix: %s/%d", rec, prefix, prefix_mask);
2073
2074
    /* TTL (32 bits) */
2075
318
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_ttl, tvb, offset, 4, ENC_BIG_ENDIAN);
2076
318
    if (tvb_get_ntohl(tvb, offset) == 0xFFFFFFFF) {
2077
1
        proto_item_append_text(tir, ", TTL: Unlimited");
2078
317
    } else {
2079
317
        proto_item_append_text(tir, ", TTL: %d", tvb_get_ntohl(tvb, offset));
2080
317
    }
2081
318
    offset += 4;
2082
2083
    /* Locator count (8 bits) */
2084
318
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_loccnt, tvb, offset, 1, ENC_BIG_ENDIAN);
2085
318
    loc_cnt = tvb_get_uint8(tvb, offset);
2086
318
    offset += 1;
2087
2088
    /* EID mask length (8 bits) */
2089
318
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_eid_masklen, tvb, offset, 1, ENC_BIG_ENDIAN);
2090
318
    offset += 1;
2091
2092
    /* Action (3 bits) */
2093
318
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_act, tvb, offset, 2, ENC_BIG_ENDIAN);
2094
318
    proto_item_append_text(tir, ", %s%s%s",
2095
318
            (referral) ? "" : "Action: ",
2096
318
            val_to_str(pinfo->pool, act, (referral) ? referral_actions : mapping_actions, "Invalid action code (%d)"),
2097
318
            (referral&&(flags&REFERRAL_INCOMPLETE)) ? " (Incomplete)" : "");
2098
2099
    /* Authoritative bit */
2100
318
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_auth, tvb, offset, 2, ENC_BIG_ENDIAN);
2101
318
    if (flags&LISP_MAP_AUTH) {
2102
61
        proto_item_append_text(tir, ", Authoritative");
2103
257
    } else {
2104
257
        proto_item_append_text(tir, ", Not Authoritative");
2105
257
    }
2106
2107
    /* Incomplete bit in Map-Referrals */
2108
318
    if (referral)
2109
91
        proto_tree_add_item(lisp_mapping_tree, hf_lisp_referral_incomplete, tvb, offset, 2, ENC_BIG_ENDIAN);
2110
2111
    /* Reserved (11 bits) */
2112
318
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_res1, tvb, offset, 2, ENC_BIG_ENDIAN);
2113
318
    offset += 2;
2114
2115
318
    if (referral) {
2116
        /* SigCnt (4 bits) */
2117
91
        proto_tree_add_item(lisp_mapping_tree, hf_lisp_referral_sigcnt, tvb, offset, 2, ENC_BIG_ENDIAN);
2118
227
    } else {
2119
        /* Reserved (4 bits) */
2120
227
        proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_res2, tvb, offset, 2, ENC_BIG_ENDIAN);
2121
227
    }
2122
2123
    /* Map-Version Number (12 bits) */
2124
318
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_ver, tvb, offset, 2, ENC_BIG_ENDIAN);
2125
318
    offset += 2;
2126
2127
    /* EID prefix AFI (16 bits) */
2128
318
    proto_tree_add_item_ret_uint16(lisp_mapping_tree, hf_lisp_mapping_eid_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &eid_afi);
2129
318
    offset += 2;
2130
2131
    /* EID */
2132
318
    switch (eid_afi) {
2133
3
        case AFNUM_IP:
2134
3
            proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_eid_ipv4, tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
2135
3
            offset += INET_ADDRLEN;
2136
3
            break;
2137
7
        case AFNUM_IP6:
2138
7
            proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_eid_ipv6, tvb, offset, INET6_ADDRLEN, ENC_NA);
2139
7
            offset += INET6_ADDRLEN;
2140
7
            break;
2141
67
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
2142
67
            lcaf_prefix_tree = proto_tree_add_subtree_format(lisp_mapping_tree, tvb, offset, addr_len, ett_lisp_lcaf, NULL, "EID Prefix: %s", prefix);
2143
67
            dissect_lcaf(tvb, pinfo, lcaf_prefix_tree, offset, NULL);
2144
67
            offset += addr_len;
2145
67
            break;
2146
3
        case AFNUM_802:
2147
3
        case AFNUM_48_BIT_MAC:
2148
3
            proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_eid_mac, tvb, offset, EUI48_ADDRLEN, ENC_NA);
2149
3
            offset += EUI48_ADDRLEN;
2150
3
            break;
2151
1
        case AFNUM_DISTINGUISHED_NAME:
2152
1
            str_len = tvb_strsize(tvb, offset);
2153
1
            proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_eid_dn, tvb, offset, str_len, ENC_ASCII);
2154
1
            offset += str_len;
2155
1
            break;
2156
318
    }
2157
2158
    /* Locators */
2159
876
    for(i=0; i < loc_cnt; i++) {
2160
638
        tvbuff_t *loc_tvb;
2161
638
        int len = 0;
2162
2163
638
        loc_tvb = tvb_new_subset_remaining(tvb, offset);
2164
638
        len = dissect_lisp_locator(loc_tvb, pinfo, lisp_mapping_tree, i+1);
2165
638
        offset += len;
2166
638
    }
2167
2168
238
    return offset;
2169
318
}
2170
2171
2172
/*
2173
 * Dissector code for Map-Request type control packets
2174
 *
2175
 *        0                   1                   2                   3
2176
 *        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
2177
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2178
 *       |Type=1 |A|M|P|S|p|s|    Reserved     |   IRC   | Record Count  |
2179
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2180
 *       |                         Nonce . . .                           |
2181
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2182
 *       |                         . . . Nonce                           |
2183
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2184
 *       |         Source-EID-AFI        |   Source EID Address  ...     |
2185
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2186
 *       |         ITR-RLOC-AFI 1        |    ITR-RLOC Address 1  ...    |
2187
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2188
 *       |                              ...                              |
2189
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2190
 *       |         ITR-RLOC-AFI n        |    ITR-RLOC Address n  ...    |
2191
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2192
 *     / |   Reserved    | EID mask-len  |        EID-prefix-AFI         |
2193
 *   Rec +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2194
 *     \ |                       EID-prefix  ...                         |
2195
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2196
 *       |                   Map-Reply Record  ...                       |
2197
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2198
 *
2199
 */
2200
2201
static void
2202
dissect_lisp_map_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tree)
2203
9
{
2204
9
    int                i;
2205
9
    uint16_t           addr_len    = 0;
2206
9
    int                offset      = 0;
2207
9
    uint16_t           flags;
2208
9
    bool               mrep;
2209
9
    bool               smr;
2210
9
    bool               probe;
2211
9
    bool               pitr;
2212
9
    bool               smr_invoked;
2213
9
    uint8_t            itr_rec_cnt = 0;
2214
9
    uint8_t            rec_cnt     = 0;
2215
9
    uint16_t           src_eid_afi;
2216
9
    const char        *src_eid;
2217
9
    proto_item        *ti_flags;
2218
9
    proto_tree        *flags_tree, *lcaf_src_eid_tree, *lcaf_prefix_tree;
2219
9
    tvbuff_t          *next_tvb;
2220
2221
    /* Flags (6 bits)*/
2222
9
    flags       = tvb_get_ntohs(tvb, offset);
2223
9
    mrep        = flags & (MAP_REQ_FLAG_M >> 8);
2224
9
    smr         = flags & (MAP_REQ_FLAG_S >> 8);
2225
9
    probe       = flags & (MAP_REQ_FLAG_P >> 8);
2226
9
    pitr        = flags & (MAP_REQ_FLAG_p >> 8);
2227
9
    smr_invoked = flags & (MAP_REQ_FLAG_s >> 8);
2228
2229
9
    ti_flags = proto_tree_add_item(lisp_tree, hf_lisp_mreq_flags, tvb, offset, 3, ENC_BIG_ENDIAN);
2230
9
    flags_tree = proto_item_add_subtree(ti_flags, ett_lisp_mreq_flags);
2231
9
    proto_tree_add_item(flags_tree, hf_lisp_mreq_flags_auth, tvb, offset, 3, ENC_BIG_ENDIAN);
2232
9
    proto_tree_add_item(flags_tree, hf_lisp_mreq_flags_mrp, tvb, offset, 3, ENC_BIG_ENDIAN);
2233
9
    proto_tree_add_item(flags_tree, hf_lisp_mreq_flags_probe, tvb, offset, 3, ENC_BIG_ENDIAN);
2234
9
    proto_tree_add_item(flags_tree, hf_lisp_mreq_flags_smr, tvb, offset, 3, ENC_BIG_ENDIAN);
2235
9
    proto_tree_add_item(flags_tree, hf_lisp_mreq_flags_pitr, tvb, offset, 3, ENC_BIG_ENDIAN);
2236
9
    proto_tree_add_item(flags_tree, hf_lisp_mreq_flags_smri, tvb, offset, 3, ENC_BIG_ENDIAN);
2237
2238
9
    if (pitr)
2239
1
        col_append_str(pinfo->cinfo, COL_INFO, " by P-ITR");
2240
2241
9
    if (smr)
2242
3
        col_append_str(pinfo->cinfo, COL_INFO, " (SMR)");
2243
2244
9
    if (probe)
2245
4
        col_append_str(pinfo->cinfo, COL_INFO, " (RLOC-probe)");
2246
2247
9
    if (smr_invoked)
2248
3
        col_append_str(pinfo->cinfo, COL_INFO, " (SMR-invoked)");
2249
2250
    /* Reserved bits (9 bits) */
2251
9
    proto_tree_add_item(lisp_tree, hf_lisp_mreq_res, tvb, offset, 3, ENC_BIG_ENDIAN);
2252
2253
    /* ITR record count (5 bits) */
2254
9
    itr_rec_cnt = tvb_get_uint8(tvb, offset + 2) & 0x1F;
2255
9
    proto_tree_add_item(lisp_tree, hf_lisp_irc, tvb, offset, 3, ENC_BIG_ENDIAN);
2256
9
    offset += 3;
2257
2258
    /* Record count (8 bits) */
2259
9
    rec_cnt = tvb_get_uint8(tvb, offset);
2260
9
    proto_tree_add_item(lisp_tree, hf_lisp_records, tvb, offset, 1, ENC_BIG_ENDIAN);
2261
9
    offset += 1;
2262
2263
    /* Nonce (64 bits) */
2264
9
    proto_tree_add_item(lisp_tree, hf_lisp_nonce, tvb, offset, 8, ENC_BIG_ENDIAN);
2265
9
    offset += 8;
2266
2267
    /* Source EID AFI (16 bits) */
2268
9
    src_eid_afi = tvb_get_ntohs(tvb, offset);
2269
9
    proto_tree_add_item(lisp_tree, hf_lisp_mreq_srceid_afi, tvb, offset, 2, ENC_BIG_ENDIAN);
2270
9
    offset += 2;
2271
2272
    /* Source EID */
2273
9
    switch (src_eid_afi) {
2274
4
        case AFNUM_RESERVED_0:
2275
4
            proto_tree_add_string(lisp_tree, hf_lisp_mreq_srceid_string, tvb, offset, 0, "not set");
2276
4
            break;
2277
1
        case AFNUM_IP:
2278
1
            proto_tree_add_item(lisp_tree,
2279
1
                    hf_lisp_mreq_srceid_ipv4, tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
2280
1
            offset += INET_ADDRLEN;
2281
1
            break;
2282
0
        case AFNUM_IP6:
2283
0
            proto_tree_add_item(lisp_tree,
2284
0
                    hf_lisp_mreq_srceid_ipv6, tvb, offset, INET6_ADDRLEN, ENC_NA);
2285
0
            offset += INET6_ADDRLEN;
2286
0
            break;
2287
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
2288
0
            src_eid = get_addr_str(tvb, pinfo, offset, src_eid_afi, &addr_len);
2289
0
            lcaf_src_eid_tree = proto_tree_add_subtree_format(lisp_tree, tvb, offset, addr_len, ett_lisp_lcaf, NULL, "Source EID: %s", src_eid);
2290
0
            dissect_lcaf(tvb, pinfo, lcaf_src_eid_tree, offset, NULL);
2291
0
            offset += addr_len;
2292
0
            break;
2293
0
        case AFNUM_802:
2294
0
        case AFNUM_48_BIT_MAC:
2295
0
            proto_tree_add_item(lisp_tree,
2296
0
                    hf_lisp_mreq_srceid_mac, tvb, offset, EUI48_ADDRLEN, ENC_NA);
2297
0
            offset += EUI48_ADDRLEN;
2298
0
            break;
2299
1
        default:
2300
1
            expert_add_info_format(pinfo, lisp_tree, &ei_lisp_unexpected_field,
2301
1
                    "Unexpected Source EID AFI (%d), cannot decode", src_eid_afi);
2302
1
            next_tvb = tvb_new_subset_remaining(tvb, offset);
2303
1
            call_data_dissector(next_tvb, pinfo, lisp_tree);
2304
1
            return;
2305
9
    }
2306
2307
    /* ITR records */
2308
7
    for(i=0; i < itr_rec_cnt+1; i++) {
2309
6
        uint16_t itr_afi;
2310
6
        proto_item *tir;
2311
6
        proto_tree *lisp_itr_tree;
2312
2313
6
        itr_afi = tvb_get_ntohs(tvb, offset);
2314
6
        tir = proto_tree_add_item(lisp_tree, hf_lisp_mreq_itr_rloc, tvb, offset, 2, ENC_NA);
2315
6
        lisp_itr_tree = proto_item_add_subtree(tir, ett_lisp_itr);
2316
6
        proto_tree_add_item(lisp_itr_tree, hf_lisp_mreq_itr_rloc_afi, tvb, offset, 2, ENC_BIG_ENDIAN);
2317
6
        offset += 2;
2318
2319
6
        switch (itr_afi) {
2320
1
            case AFNUM_IP:
2321
1
                proto_tree_add_item(lisp_itr_tree, hf_lisp_mreq_itr_rloc_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
2322
1
                proto_item_append_text(tir, " %d: %s", i + 1, tvb_ip_to_str(pinfo->pool, tvb, offset));
2323
1
                proto_item_set_len(tir, 2 + INET_ADDRLEN);
2324
1
                offset += INET_ADDRLEN;
2325
1
                break;
2326
1
            case AFNUM_IP6:
2327
1
                proto_tree_add_item(lisp_itr_tree, hf_lisp_mreq_itr_rloc_ipv6, tvb, offset, 16, ENC_NA);
2328
1
                proto_item_append_text(tir, " %d: %s", i + 1, tvb_ip6_to_str(pinfo->pool, tvb, offset));
2329
1
                proto_item_set_len(tir, 2 + INET6_ADDRLEN);
2330
1
                offset += INET6_ADDRLEN;
2331
1
                break;
2332
4
            default:
2333
4
                expert_add_info_format(pinfo, lisp_tree, &ei_lisp_unexpected_field,
2334
4
                        "Unexpected ITR-RLOC-AFI (%d), cannot decode", itr_afi);
2335
4
                next_tvb = tvb_new_subset_remaining(tvb, offset);
2336
4
                call_data_dissector(next_tvb, pinfo, lisp_tree);
2337
4
                return;
2338
6
        }
2339
6
    }
2340
2341
    /* Query records */
2342
3
    for(i=0; i < rec_cnt; i++) {
2343
3
        int str_len;
2344
3
        uint16_t prefix_mask;
2345
3
        uint16_t prefix_afi;
2346
3
        const char *prefix;
2347
3
        proto_item *tir;
2348
3
        proto_tree *lisp_record_tree;
2349
2350
3
        addr_len = 0;
2351
3
        prefix_mask = tvb_get_uint8(tvb, offset + 1);
2352
3
        prefix_afi = tvb_get_ntohs(tvb, offset + 2);
2353
3
        prefix = get_addr_str(tvb, pinfo, offset + 4, prefix_afi, &addr_len);
2354
2355
3
        if (prefix == NULL) {
2356
1
            expert_add_info_format(pinfo, lisp_tree, &ei_lisp_unexpected_field,
2357
1
                    "Unexpected EID prefix AFI (%d), cannot decode", prefix_afi);
2358
1
            next_tvb = tvb_new_subset_remaining(tvb, offset);
2359
1
            call_data_dissector(next_tvb, pinfo, lisp_tree);
2360
1
            return;
2361
1
        }
2362
2363
2
        tir = proto_tree_add_item(lisp_tree, hf_lisp_mreq_record, tvb, offset, 4+addr_len, ENC_NA);
2364
2365
        /* Update the INFO column if there is only one record */
2366
2
        if (rec_cnt == 1)
2367
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " for %s/%d", prefix, prefix_mask);
2368
2369
2
        lisp_record_tree = proto_item_add_subtree(tir, ett_lisp_record);
2370
2
        proto_tree_add_item(lisp_record_tree, hf_lisp_mreq_record_res, tvb, offset, 1, ENC_BIG_ENDIAN);
2371
2
        offset += 1;
2372
2373
2
        proto_tree_add_item(lisp_record_tree, hf_lisp_mreq_record_prefix_length, tvb, offset, 1, ENC_BIG_ENDIAN);
2374
2
        offset += 1;
2375
2376
2
        proto_tree_add_item(lisp_record_tree, hf_lisp_mreq_record_prefix_afi, tvb, offset, 2, ENC_BIG_ENDIAN);
2377
2
        offset += 2;
2378
2379
2
        switch (prefix_afi) {
2380
0
            case AFNUM_IP:
2381
0
                proto_tree_add_item(lisp_record_tree, hf_lisp_mreq_record_prefix_ipv4, tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
2382
0
                offset += INET_ADDRLEN;
2383
0
                break;
2384
0
            case AFNUM_IP6:
2385
0
                proto_tree_add_item(lisp_record_tree, hf_lisp_mreq_record_prefix_ipv6, tvb, offset, INET6_ADDRLEN, ENC_NA);
2386
0
                offset += INET6_ADDRLEN;
2387
0
                break;
2388
0
            case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
2389
0
                lcaf_prefix_tree = proto_tree_add_subtree_format(lisp_record_tree, tvb, offset, addr_len, ett_lisp_lcaf, NULL, "Prefix: %s", prefix);
2390
0
                dissect_lcaf(tvb, pinfo, lcaf_prefix_tree, offset, NULL);
2391
0
                offset += addr_len;
2392
0
                break;
2393
0
            case AFNUM_802:
2394
0
            case AFNUM_48_BIT_MAC:
2395
0
                proto_tree_add_item(lisp_record_tree, hf_lisp_mreq_record_prefix_mac, tvb, offset, EUI48_ADDRLEN, ENC_NA);
2396
0
                offset += EUI48_ADDRLEN;
2397
0
                break;
2398
0
            case AFNUM_DISTINGUISHED_NAME:
2399
0
                str_len = tvb_strsize(tvb, offset);
2400
0
                proto_tree_add_item(lisp_record_tree, hf_lisp_mreq_record_prefix_dn, tvb, offset, str_len, ENC_ASCII);
2401
0
                offset += str_len;
2402
0
                break;
2403
2
        }
2404
2
        proto_item_append_text(tir, " %d: %s/%d", i+1, prefix, prefix_mask);
2405
2
    }
2406
2407
    /* If M bit is set, we also have a Map-Reply */
2408
0
    if (mrep) {
2409
0
        proto_item *tim;
2410
0
        proto_tree *lisp_mr_tree;
2411
2412
0
        tim = proto_tree_add_item(lisp_tree, hf_lisp_mrep_record, tvb, offset, -1, ENC_NA);
2413
0
        lisp_mr_tree = proto_item_add_subtree(tim, ett_lisp_mr);
2414
2415
0
        offset = dissect_lisp_mapping(tvb, pinfo, lisp_mr_tree, 0, 1, false, offset, NULL);
2416
0
    }
2417
2418
0
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2419
0
    call_data_dissector(next_tvb, pinfo, lisp_tree);
2420
0
}
2421
2422
2423
/*
2424
 * Dissector code for Map-Reply type control packets
2425
 *
2426
 *        0                   1                   2                   3
2427
 *        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
2428
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2429
 *       |Type=2 |P|E|S|           Reserved              | Record Count  |
2430
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2431
 *       |                         Nonce . . .                           |
2432
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2433
 *       |                         . . . Nonce                           |
2434
 *   +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2435
 *   |   |                          Record  TTL                          |
2436
 *   |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2437
 *   R   | Locator Count | EID mask-len  | ACT |A|      Reserved         |
2438
 *   e   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2439
 *   c   | Rsvd  |  Map-Version Number   |            EID-AFI            |
2440
 *   o   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2441
 *   r   |                          EID-prefix                           |
2442
 *   d   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2443
 *   |  /|    Priority   |    Weight     |  M Priority   |   M Weight    |
2444
 *   | L +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2445
 *   | o |        Unused Flags     |L|p|R|           Loc-AFI             |
2446
 *   | c +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2447
 *   |  \|                             Locator                           |
2448
 *   +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2449
 *
2450
 */
2451
2452
static void
2453
dissect_lisp_map_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tree)
2454
97
{
2455
97
    int       i;
2456
97
    int       offset  = 0;
2457
97
    bool      probe;
2458
97
    uint8_t   flags;
2459
97
    uint8_t   rec_cnt = 0;
2460
97
    tvbuff_t *next_tvb;
2461
2462
    /* Flags (2 bits) */
2463
97
    flags = tvb_get_uint8(tvb, offset);
2464
97
    probe = flags & (MAP_REP_FLAG_P >> 16);
2465
97
    proto_tree_add_item(lisp_tree, hf_lisp_mrep_flags_probe, tvb, offset, 3, ENC_BIG_ENDIAN);
2466
97
    proto_tree_add_item(lisp_tree, hf_lisp_mrep_flags_enlr, tvb, offset, 3, ENC_BIG_ENDIAN);
2467
2468
    /* Flags defined in LISP-SEC draft (1 bit) */
2469
97
    proto_tree_add_item(lisp_tree, hf_lisp_mrep_flags_sec, tvb, offset, 3, ENC_BIG_ENDIAN);
2470
2471
97
    if (probe)
2472
13
        col_append_str(pinfo->cinfo, COL_INFO, " (RLOC-probe reply)");
2473
2474
    /* Reserved bits (18 bits) */
2475
97
    proto_tree_add_item(lisp_tree, hf_lisp_mrep_res, tvb, offset, 3, ENC_BIG_ENDIAN);
2476
97
    offset += 3;
2477
2478
    /* Record count (8 bits) */
2479
97
    rec_cnt = tvb_get_uint8(tvb, offset);
2480
97
    proto_tree_add_item(lisp_tree, hf_lisp_records, tvb, offset, 1, ENC_BIG_ENDIAN);
2481
97
    offset += 1;
2482
2483
    /* Nonce (64 bits) */
2484
97
    proto_tree_add_item(lisp_tree, hf_lisp_nonce, tvb, offset, 8, ENC_BIG_ENDIAN);
2485
97
    offset += 8;
2486
2487
    /* Reply records */
2488
967
    for(i=0; i < rec_cnt; i++) {
2489
870
        offset = dissect_lisp_mapping(tvb, pinfo, lisp_tree, rec_cnt, i+1, false, offset, NULL);
2490
870
    }
2491
2492
97
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2493
97
    call_data_dissector(next_tvb, pinfo, lisp_tree);
2494
97
}
2495
2496
2497
/*
2498
 *  Dissector code for Map-Register type control packets
2499
 *
2500
 *        0                   1                   2                   3
2501
 *        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
2502
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2503
 *       |Type=3 |P|S|I|R|         Reserved            |M| Record Count  |
2504
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2505
 *       |                         Nonce . . .                           |
2506
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2507
 *       |                         . . . Nonce                           |
2508
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2509
 *       |            Key ID             |  Authentication Data Length   |
2510
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2511
 *       ~                     Authentication Data                       ~
2512
 *   +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2513
 *   |   |                          Record  TTL                          |
2514
 *   |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2515
 *   R   | Locator Count | EID mask-len  | ACT |A|      Reserved         |
2516
 *   e   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2517
 *   c   | Rsvd  |  Map-Version Number   |            EID-AFI            |
2518
 *   o   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2519
 *   r   |                          EID-prefix                           |
2520
 *   d   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2521
 *   |  /|    Priority   |    Weight     |  M Priority   |   M Weight    |
2522
 *   | L +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2523
 *   | o |        Unused Flags     |L|p|R|           Loc-AFI             |
2524
 *   | c +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2525
 *   |  \|                             Locator                           |
2526
 *   +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2527
 *
2528
 */
2529
2530
int
2531
dissect_lisp_map_register(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tree,
2532
        int offset, proto_item *tim, bool keep_going)
2533
14
{
2534
14
    int       i;
2535
14
    uint8_t   rec_cnt = 0;
2536
14
    tvbuff_t *next_tvb;
2537
14
    uint16_t  authlen = 0;
2538
14
    uint16_t  flags;
2539
14
    bool      xtrid;
2540
14
    bool      rtr;
2541
2542
    /* Flags (1 bit) */
2543
14
    proto_tree_add_item(lisp_tree, hf_lisp_mreg_flags_pmr, tvb, offset, 3, ENC_BIG_ENDIAN);
2544
2545
    /* Flags defined in LISP-SEC draft (1 bit) */
2546
14
    proto_tree_add_item(lisp_tree, hf_lisp_mreg_flags_sec, tvb, offset, 3, ENC_BIG_ENDIAN);
2547
2548
    /* Flags defined in NAT Traversal draft (2 bits) */
2549
14
    flags = tvb_get_ntohs(tvb, offset);
2550
14
    xtrid = flags & (MAP_REG_FLAG_I >> 8);
2551
14
    rtr   = flags & (MAP_REG_FLAG_R >> 8);
2552
2553
14
    proto_tree_add_item(lisp_tree, hf_lisp_mreg_flags_xtrid, tvb, offset, 3, ENC_BIG_ENDIAN);
2554
14
    proto_tree_add_item(lisp_tree, hf_lisp_mreg_flags_rtr, tvb, offset, 3, ENC_BIG_ENDIAN);
2555
2556
14
    if (rtr)
2557
5
        col_append_str(pinfo->cinfo, COL_INFO, " (RTR)");
2558
2559
    /* Reserved bits (15 bits) */
2560
14
    proto_tree_add_item(lisp_tree, hf_lisp_mreg_res, tvb, offset, 3, ENC_BIG_ENDIAN);
2561
2562
    /* Flags (1 bit) */
2563
14
    proto_tree_add_item(lisp_tree, hf_lisp_mreg_flags_wmn, tvb, offset, 3, ENC_BIG_ENDIAN);
2564
14
    offset += 3;
2565
2566
    /* Record count (8 bits) */
2567
14
    rec_cnt = tvb_get_uint8(tvb, offset);
2568
14
    proto_tree_add_item(lisp_tree, hf_lisp_records, tvb, offset, 1, ENC_BIG_ENDIAN);
2569
14
    offset += 1;
2570
2571
    /* Nonce (64 bits) */
2572
14
    proto_tree_add_item(lisp_tree, hf_lisp_nonce, tvb, offset, 8, ENC_BIG_ENDIAN);
2573
14
    offset += 8;
2574
2575
    /* Key ID (16 bits) */
2576
14
    proto_tree_add_item(lisp_tree, hf_lisp_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
2577
14
    offset += 2;
2578
2579
    /* Authentication Data Length (16 bits) */
2580
14
    proto_tree_add_item_ret_uint16(lisp_tree, hf_lisp_authlen, tvb, offset, 2, ENC_BIG_ENDIAN, &authlen);
2581
14
    offset += 2;
2582
2583
    /* Authentication Data */
2584
    /* XXX: need to check is there is still enough data in buffer */
2585
14
    proto_tree_add_item(lisp_tree, hf_lisp_auth, tvb, offset, authlen, ENC_NA);
2586
14
    offset += authlen;
2587
2588
282
    for(i=0; i < rec_cnt; i++) {
2589
268
        offset = dissect_lisp_mapping(tvb, pinfo, lisp_tree, rec_cnt, i+1, false, offset, tim);
2590
268
    }
2591
2592
    /* If I bit is set, we have an xTR-ID and a site-ID field */
2593
14
    if (xtrid) {
2594
2
        proto_tree_add_item(lisp_tree, hf_lisp_xtrid, tvb, offset, LISP_XTRID_LEN, ENC_NA);
2595
2
        proto_tree_add_item(lisp_tree, hf_lisp_siteid, tvb, offset + LISP_XTRID_LEN, LISP_SITEID_LEN, ENC_NA);
2596
2
        offset += LISP_XTRID_LEN + LISP_SITEID_LEN;
2597
2
    }
2598
2599
14
    if (keep_going) {
2600
3
        next_tvb = tvb_new_subset_remaining(tvb, offset);
2601
3
        call_data_dissector(next_tvb, pinfo, lisp_tree);
2602
11
    } else {
2603
11
        return offset;
2604
11
    }
2605
2606
3
    return 0;
2607
14
}
2608
2609
2610
/*
2611
 *  Dissector code for Map-Notify type control packets
2612
 *
2613
 *        0                   1                   2                   3
2614
 *        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
2615
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2616
 *       |Type=4 |I|R|            Reserved               | Record Count  |
2617
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2618
 *       |                         Nonce . . .                           |
2619
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2620
 *       |                         . . . Nonce                           |
2621
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2622
 *       |            Key ID             |  Authentication Data Length   |
2623
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2624
 *       ~                     Authentication Data                       ~
2625
 *   +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2626
 *   |   |                          Record  TTL                          |
2627
 *   |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2628
 *   R   | Locator Count | EID mask-len  | ACT |A|      Reserved         |
2629
 *   e   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2630
 *   c   | Rsvd  |  Map-Version Number   |            EID-AFI            |
2631
 *   o   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2632
 *   r   |                          EID-prefix                           |
2633
 *   d   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2634
 *   |  /|    Priority   |    Weight     |  M Priority   |   M Weight    |
2635
 *   | L +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2636
 *   | o |        Unused Flags     |L|p|R|           Loc-AFI             |
2637
 *   | c +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2638
 *   |  \|                             Locator                           |
2639
 *   +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2640
 *
2641
 */
2642
2643
static void
2644
dissect_lisp_map_notify(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tree)
2645
20
{
2646
20
    int       i;
2647
20
    int       offset  = 0;
2648
20
    uint8_t   rec_cnt = 0;
2649
20
    tvbuff_t *next_tvb;
2650
20
    uint16_t  authlen = 0;
2651
20
    uint16_t  flags;
2652
20
    bool      xtrid;
2653
20
    bool      rtr;
2654
2655
    /* Flags defined in NAT Traversal draft (2 bits) */
2656
20
    flags = tvb_get_ntohs(tvb, offset);
2657
20
    xtrid = flags & (MAP_NOT_FLAG_I >> 8);
2658
20
    rtr   = flags & (MAP_NOT_FLAG_R >> 8);
2659
2660
20
    proto_tree_add_item(lisp_tree, hf_lisp_mnot_flags_xtrid, tvb, offset, 3, ENC_BIG_ENDIAN);
2661
20
    proto_tree_add_item(lisp_tree, hf_lisp_mnot_flags_rtr, tvb, offset, 3, ENC_BIG_ENDIAN);
2662
2663
20
    if (rtr)
2664
5
        col_append_str(pinfo->cinfo, COL_INFO, " (RTR)");
2665
2666
    /* Reserved bits (18 bits) */
2667
20
    proto_tree_add_item(lisp_tree, hf_lisp_mnot_res, tvb, offset, 3, ENC_BIG_ENDIAN);
2668
20
    offset += 3;
2669
2670
    /* Record count (8 bits) */
2671
20
    rec_cnt = tvb_get_uint8(tvb, offset);
2672
20
    proto_tree_add_item(lisp_tree, hf_lisp_records, tvb, offset, 1, ENC_BIG_ENDIAN);
2673
20
    offset += 1;
2674
2675
    /* Nonce (64 bits) */
2676
20
    proto_tree_add_item(lisp_tree, hf_lisp_nonce, tvb, offset, 8, ENC_BIG_ENDIAN);
2677
20
    offset += 8;
2678
2679
    /* Key ID (16 bits) */
2680
20
    proto_tree_add_item(lisp_tree, hf_lisp_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
2681
20
    offset += 2;
2682
2683
    /* Authentication Data Length (16 bits) */
2684
20
    proto_tree_add_item_ret_uint16(lisp_tree, hf_lisp_authlen, tvb, offset, 2, ENC_BIG_ENDIAN, &authlen);
2685
20
    offset += 2;
2686
2687
    /* Authentication Data */
2688
    /* XXX: need to check is there is still enough data in buffer */
2689
20
    proto_tree_add_item(lisp_tree, hf_lisp_auth, tvb, offset, authlen, ENC_NA);
2690
20
    offset += authlen;
2691
2692
1.23k
    for(i=0; i < rec_cnt; i++) {
2693
1.21k
        offset = dissect_lisp_mapping(tvb, pinfo, lisp_tree, rec_cnt, i+1, false, offset, NULL);
2694
1.21k
    }
2695
2696
    /* If I bit is set, we have an xTR-ID and a site-ID field */
2697
20
    if (xtrid) {
2698
3
        proto_tree_add_item(lisp_tree, hf_lisp_xtrid, tvb, offset, LISP_XTRID_LEN, ENC_NA);
2699
3
        proto_tree_add_item(lisp_tree, hf_lisp_siteid, tvb, offset + LISP_XTRID_LEN, LISP_SITEID_LEN, ENC_NA);
2700
3
        offset += LISP_XTRID_LEN + LISP_SITEID_LEN;
2701
3
    }
2702
2703
    /* If R bit is set, we have MS-RTR authentication data */
2704
20
    if (rtr) {
2705
        /* MS-RTR Key ID (16 bits) */
2706
2
        proto_tree_add_item(lisp_tree, hf_lisp_msrtr_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
2707
2
        offset += 2;
2708
2709
        /* MS-RTR Authentication Data Length (16 bits) */
2710
2
        proto_tree_add_item_ret_uint16(lisp_tree, hf_lisp_msrtr_authlen, tvb, offset, 2, ENC_BIG_ENDIAN, &authlen);
2711
2
        offset += 2;
2712
2713
        /* MS-RTR Authentication Data */
2714
        /* XXX: need to check is there is still enough data in buffer */
2715
2
        proto_tree_add_item(lisp_tree, hf_lisp_msrtr_auth, tvb, offset, authlen, ENC_NA);
2716
2
        offset += authlen;
2717
2
    }
2718
2719
20
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2720
20
    call_data_dissector(next_tvb, pinfo, lisp_tree);
2721
20
}
2722
2723
/*
2724
 *  Dissector code for Map-Referral type control packets
2725
 *
2726
 *        0                   1                   2                   3
2727
 *        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
2728
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2729
 *       |Type=6 |                Reserved               | Record Count  |
2730
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2731
 *       |                         Nonce . . .                           |
2732
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2733
 *       |                         . . . Nonce                           |
2734
 *   +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2735
 *   |   |                          Record  TTL                          |
2736
 *   |   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2737
 *   R   | Referral Count| EID mask-len  | ACT |A|I|     Reserved        |
2738
 *   e   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2739
 *   c   |SigCnt |   Map Version Number  |            EID-AFI            |
2740
 *   o   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2741
 *   r   |                          EID-prefix ...                       |
2742
 *   d   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2743
 *   |  /|    Priority   |    Weight     |  M Priority   |   M Weight    |
2744
 *   | L +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2745
 *   | o |        Unused Flags         |R|         Loc/LCAF-AFI          |
2746
 *   | c +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2747
 *   |  \|                             Locator ...                       |
2748
 *   +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2749
 *
2750
 */
2751
2752
static void
2753
dissect_lisp_map_referral(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tree)
2754
31
{
2755
31
    int       i;
2756
31
    int       offset  = 0;
2757
31
    uint8_t   rec_cnt = 0;
2758
31
    tvbuff_t *next_tvb;
2759
2760
    /* Reserved bits (20 bits) */
2761
31
    proto_tree_add_item(lisp_tree, hf_lisp_mref_res, tvb, offset, 3, ENC_BIG_ENDIAN);
2762
31
    offset += 3;
2763
2764
    /* Record count (8 bits) */
2765
31
    rec_cnt = tvb_get_uint8(tvb, offset);
2766
31
    proto_tree_add_item(lisp_tree, hf_lisp_records, tvb, offset, 1, ENC_BIG_ENDIAN);
2767
31
    offset += 1;
2768
2769
    /* Nonce (64 bits) */
2770
31
    proto_tree_add_item(lisp_tree, hf_lisp_nonce, tvb, offset, 8, ENC_BIG_ENDIAN);
2771
31
    offset += 8;
2772
2773
    /* Referral records */
2774
932
    for(i=0; i < rec_cnt; i++) {
2775
901
        offset = dissect_lisp_mapping(tvb, pinfo, lisp_tree, rec_cnt, i+1, true, offset, NULL);
2776
901
    }
2777
2778
31
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2779
31
    call_data_dissector(next_tvb, pinfo, lisp_tree);
2780
31
}
2781
2782
2783
/*
2784
 *  Dissector code for Info type control packets
2785
 *
2786
 *        0                   1                   2                   3
2787
 *        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
2788
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2789
 *       |Type=7 |R|            Reserved                                 |
2790
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2791
 *       |                         Nonce . . .                           |
2792
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2793
 *       |                      . . . Nonce                              |
2794
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2795
 *       |              Key ID           |  Authentication Data Length   |
2796
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2797
 *       ~                     Authentication Data                       ~
2798
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2799
 *       |                              TTL                              |
2800
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2801
 *       |   Reserved    | EID mask-len  |        EID-prefix-AFI         |
2802
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2803
 *       |                          EID-prefix                           |
2804
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2805
 *       |               AFI             |              ...
2806
 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2807
 *
2808
 */
2809
2810
static void
2811
dissect_lisp_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tree)
2812
6
{
2813
6
    int          offset   = 0;
2814
6
    tvbuff_t    *next_tvb;
2815
6
    uint8_t      flags;
2816
6
    bool         reply;
2817
6
    uint16_t     authlen  = 0;
2818
6
    uint8_t      prefix_mask;
2819
6
    uint16_t     prefix_afi, afi;
2820
6
    const char *prefix;
2821
6
    uint16_t     addr_len = 0;
2822
6
    proto_item  *tir, *ti_prefix;
2823
6
    proto_tree  *prefix_tree;
2824
2825
    /* Flags (1 bit) */
2826
6
    flags = tvb_get_uint8(tvb, offset);
2827
6
    reply = flags & (INFO_FLAG_R >> 16);
2828
2829
6
    if (reply)
2830
3
        col_append_str(pinfo->cinfo, COL_INFO, "-Reply");
2831
3
    else
2832
3
        col_append_str(pinfo->cinfo, COL_INFO, "-Request");
2833
2834
6
    proto_tree_add_item(lisp_tree, hf_lisp_info_r, tvb, offset, 3, ENC_BIG_ENDIAN);
2835
2836
    /* Reserved bits (27 bits) */
2837
6
    proto_tree_add_item(lisp_tree, hf_lisp_info_res1, tvb, offset, 4, ENC_BIG_ENDIAN);
2838
6
    offset += 4;
2839
2840
    /* Nonce (64 bits) */
2841
6
    proto_tree_add_item(lisp_tree, hf_lisp_nonce, tvb, offset, 8, ENC_BIG_ENDIAN);
2842
6
    offset += 8;
2843
2844
    /* Key ID (16 bits) */
2845
6
    proto_tree_add_item(lisp_tree, hf_lisp_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
2846
6
    offset += 2;
2847
2848
    /* Authentication Data Length (16 bits) */
2849
6
    proto_tree_add_item_ret_uint16(lisp_tree, hf_lisp_authlen, tvb, offset, 2, ENC_BIG_ENDIAN, &authlen);
2850
6
    offset += 2;
2851
2852
    /* Authentication Data */
2853
    /* XXX: need to check is there is still enough data in buffer */
2854
6
    proto_tree_add_item(lisp_tree, hf_lisp_auth, tvb, offset, authlen, ENC_NA);
2855
6
    offset += authlen;
2856
2857
    /* TTL */
2858
6
    proto_tree_add_item(lisp_tree, hf_lisp_info_ttl, tvb, offset, 4, ENC_BIG_ENDIAN);
2859
6
    offset += 4;
2860
2861
    /* Reserved bits (8 bits) */
2862
6
    proto_tree_add_item(lisp_tree, hf_lisp_info_res2, tvb, offset, 1, ENC_BIG_ENDIAN);
2863
6
    offset += 1;
2864
2865
6
    prefix_tree = proto_tree_add_subtree(lisp_tree, tvb, offset, 3, ett_lisp_info_prefix, &ti_prefix, "EID Prefix: ");
2866
2867
6
    proto_tree_add_item(prefix_tree, hf_lisp_info_prefix_masklen, tvb, offset, 1, ENC_BIG_ENDIAN);
2868
6
    prefix_mask = tvb_get_uint8(tvb, offset); offset += 1;
2869
2870
6
    proto_tree_add_item_ret_uint16(prefix_tree, hf_lisp_info_prefix_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &prefix_afi);
2871
6
    offset += 2;
2872
2873
6
    prefix = get_addr_str(tvb, pinfo, offset, prefix_afi, &addr_len);
2874
2875
6
    if (prefix == NULL) {
2876
1
        expert_add_info_format(pinfo, lisp_tree, &ei_lisp_unexpected_field,
2877
1
                "Unexpected EID prefix AFI (%d), cannot decode", prefix_afi);
2878
1
        next_tvb = tvb_new_subset_remaining(tvb, offset);
2879
1
        call_data_dissector(next_tvb, pinfo, lisp_tree);
2880
1
        return;
2881
1
    }
2882
2883
5
    switch (prefix_afi) {
2884
0
        case AFNUM_IP:
2885
0
            proto_tree_add_item(prefix_tree, hf_lisp_info_prefix_ipv4, tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
2886
0
            break;
2887
0
        case AFNUM_IP6:
2888
0
            proto_tree_add_item(prefix_tree, hf_lisp_info_prefix_ipv6, tvb, offset, INET6_ADDRLEN, ENC_NA);
2889
0
            break;
2890
5
    }
2891
2892
3
    proto_item_append_text(ti_prefix, "%s/%d", prefix, prefix_mask);
2893
3
    proto_item_set_len(ti_prefix, 3 + addr_len);
2894
3
    offset += addr_len;
2895
2896
    /* Update the INFO column */
2897
3
    col_append_fstr(pinfo->cinfo, COL_INFO, " for %s/%d", prefix, prefix_mask);
2898
2899
3
    tir = proto_tree_add_item_ret_uint16(lisp_tree, hf_lisp_info_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &afi);
2900
3
    offset += 2;
2901
2902
3
    if (!reply) {
2903
2
        if (afi != 0) {
2904
1
            expert_add_info_format(pinfo, tir, &ei_lisp_expected_field,
2905
1
                    "Expecting NULL AFI (0), found %d, incorrect packet!", afi);
2906
1
        }
2907
2
    } else {
2908
1
        if (afi != AFNUM_LISP_CANONICAL_ADDRESS_FORMAT) {
2909
1
            expert_add_info_format(pinfo, tir, &ei_lisp_expected_field,
2910
1
                    "Expecting LCAF AFI (%d), found %d, incorrect packet!",
2911
1
                    AFNUM_LISP_CANONICAL_ADDRESS_FORMAT, afi);
2912
1
        } else {
2913
0
            offset = dissect_lcaf(tvb, pinfo, lisp_tree, offset, NULL);
2914
0
        }
2915
1
    }
2916
2917
3
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2918
3
    call_data_dissector(next_tvb, pinfo, lisp_tree);
2919
3
}
2920
2921
2922
/*
2923
 * Dissector code for Encapsulated Control Message type packets
2924
 *
2925
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2926
 *  |Type=8 |S|D|                 Reserved                          |
2927
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2928
 *  |                       IPv4 or IPv6 Header                     |
2929
 *  |                  (uses RLOC or EID addresses)                 |
2930
 *  ~                                                               ~
2931
 *
2932
 */
2933
2934
static void
2935
dissect_lisp_ecm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *lisp_tree)
2936
10
{
2937
10
    tvbuff_t *next_tvb;
2938
10
    uint8_t   flags;
2939
10
    uint8_t   ip_ver;
2940
2941
    /* Flags (2 bits) */
2942
10
    flags = tvb_get_uint8(tvb, 0);
2943
10
    ddt_originated = flags & (ECM_FLAG_D >> 24);
2944
2945
10
    proto_tree_add_item(lisp_tree, hf_lisp_ecm_flags_sec, tvb, 0, 4, ENC_BIG_ENDIAN);
2946
10
    proto_tree_add_item(lisp_tree, hf_lisp_ecm_flags_ddt, tvb, 0, 4, ENC_BIG_ENDIAN);
2947
10
    proto_tree_add_item(lisp_tree, hf_lisp_ecm_res, tvb, 0, 4, ENC_BIG_ENDIAN);
2948
2949
    /* Determine if encapsulated packet is IPv4 or IPv6, and call dissector */
2950
10
    next_tvb = tvb_new_subset_remaining(tvb, LISP_ECM_HEADER_LEN);
2951
10
    ip_ver = tvb_get_bits8(next_tvb, 0, 4);
2952
2953
10
    switch (ip_ver) {
2954
1
        case 4:
2955
1
            call_dissector(ipv4_handle, next_tvb, pinfo, tree);
2956
1
            break;
2957
8
        case 6:
2958
8
            call_dissector(ipv6_handle, next_tvb, pinfo, tree);
2959
8
            break;
2960
1
        default:
2961
1
            call_data_dissector(next_tvb, pinfo, tree);
2962
1
            break;
2963
10
    }
2964
3
    encapsulated = false;
2965
3
}
2966
2967
2968
/*
2969
 * Main dissector code
2970
 */
2971
2972
static int
2973
dissect_lisp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
2974
188
{
2975
188
    uint8_t type;
2976
2977
188
    proto_tree *lisp_tree = NULL;
2978
2979
    /* Clear Info column before fetching data in case an exception is thrown */
2980
188
    col_clear(pinfo->cinfo, COL_INFO);
2981
2982
188
    type = tvb_get_bits8(tvb, 0, 4);
2983
2984
    /* Make entries in Protocol column and Info column on summary display */
2985
188
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "LISP");
2986
2987
188
    if (encapsulated) {
2988
119
        col_add_fstr(pinfo->cinfo, COL_INFO, "Encapsulated %s", val_to_str(pinfo->pool, type, lisp_typevals,
2989
119
                    "Unknown LISP Control Packet (%d)"));
2990
119
    } else {
2991
69
        col_add_str(pinfo->cinfo, COL_INFO, val_to_str(pinfo->pool, type, lisp_typevals,
2992
69
                    "Unknown LISP Control Packet (%d)"));
2993
69
    }
2994
2995
188
    if (ddt_originated) {
2996
5
        col_append_str(pinfo->cinfo, COL_INFO, " (DDT-originated)");
2997
5
        ddt_originated = false;
2998
5
    }
2999
3000
188
    if (tree) {
3001
188
        proto_item *ti;
3002
3003
        /* create display subtree for the protocol */
3004
188
        ti = proto_tree_add_item(tree, proto_lisp, tvb, 0,
3005
188
                (type == LISP_ECM) ? LISP_ECM_HEADER_LEN : -1, ENC_NA);
3006
3007
188
        lisp_tree = proto_item_add_subtree(ti, ett_lisp);
3008
3009
188
        proto_tree_add_item(lisp_tree,
3010
188
            hf_lisp_type, tvb, 0, 3, ENC_BIG_ENDIAN);
3011
188
    }
3012
3013
    /* Sub-dissectors are indirectly called by the following and thus
3014
       this code should be executed whether or not tree==NULL.
3015
    */
3016
188
    switch (type) {
3017
9
    case LISP_MAP_REQUEST:
3018
9
        dissect_lisp_map_request(tvb, pinfo, lisp_tree);
3019
9
        break;
3020
97
    case LISP_MAP_REPLY:
3021
97
        dissect_lisp_map_reply(tvb, pinfo, lisp_tree);
3022
97
        break;
3023
14
    case LISP_MAP_REGISTER:
3024
14
        dissect_lisp_map_register(tvb, pinfo, lisp_tree, 0, NULL, true);
3025
14
        break;
3026
20
    case LISP_MAP_NOTIFY:
3027
20
        dissect_lisp_map_notify(tvb, pinfo, lisp_tree);
3028
20
        break;
3029
31
    case LISP_MAP_REFERRAL:
3030
31
        dissect_lisp_map_referral(tvb, pinfo, lisp_tree);
3031
31
        break;
3032
6
    case LISP_INFO:
3033
6
        dissect_lisp_info(tvb, pinfo, lisp_tree);
3034
6
        break;
3035
10
    case LISP_ECM:
3036
10
        encapsulated = true;
3037
10
        dissect_lisp_ecm(tvb, pinfo, tree, lisp_tree);
3038
10
        break;
3039
1
    default:
3040
1
        call_data_dissector(tvb, pinfo, tree);
3041
1
        break;
3042
188
    }
3043
3044
    /* Return the amount of data this dissector was able to dissect */
3045
47
    return tvb_reported_length(tvb);
3046
188
}
3047
3048
3049
/*
3050
 *  Register the LISP protocol with Wireshark
3051
 */
3052
3053
void
3054
proto_register_lisp(void)
3055
16
{
3056
    /* Setup list of header fields */
3057
16
    static hf_register_info hf[] = {
3058
16
        { &hf_lisp_type,
3059
16
            { "Type", "lisp.type",
3060
16
            FT_UINT24, BASE_DEC, VALS(lisp_typevals), 0xF00000, "LISP Control Message Type", HFILL }},
3061
16
        { &hf_lisp_irc,
3062
16
            { "ITR-RLOC Count", "lisp.irc",
3063
16
            FT_UINT24, BASE_DEC, NULL, 0x00001F, NULL, HFILL }},
3064
16
        { &hf_lisp_records,
3065
16
            { "Record Count", "lisp.records",
3066
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3067
16
        { &hf_lisp_nonce,
3068
16
            { "Nonce", "lisp.nonce",
3069
16
            FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3070
16
        { &hf_lisp_mreq_flags,
3071
16
            { "Flags", "lisp.mreq.flags",
3072
16
            FT_UINT24, BASE_HEX, NULL, 0x0FC000, NULL, HFILL }},
3073
16
        { &hf_lisp_mreq_flags_auth,
3074
16
            { "A bit (Authoritative)", "lisp.mreq.flags.auth",
3075
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REQ_FLAG_A, NULL, HFILL }},
3076
16
        { &hf_lisp_mreq_flags_mrp,
3077
16
            { "M bit (Map-Reply present)", "lisp.mreq.flags.mrp",
3078
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REQ_FLAG_M, NULL, HFILL }},
3079
16
        { &hf_lisp_mreq_flags_probe,
3080
16
            { "P bit (Probe)", "lisp.mreq.flags.probe",
3081
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REQ_FLAG_P, NULL, HFILL }},
3082
16
        { &hf_lisp_mreq_flags_smr,
3083
16
            { "S bit (Solicit-Map-Request)", "lisp.mreq.flags.smr",
3084
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REQ_FLAG_S, NULL, HFILL }},
3085
16
        { &hf_lisp_mreq_flags_pitr,
3086
16
            { "p bit (Proxy ITR)", "lisp.mreq.flags.pitr",
3087
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REQ_FLAG_p, NULL, HFILL }},
3088
16
        { &hf_lisp_mreq_flags_smri,
3089
16
            { "s bit (SMR-invoked)", "lisp.mreq.flags.smri",
3090
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REQ_FLAG_s, NULL, HFILL }},
3091
16
        { &hf_lisp_mreq_res,
3092
16
            { "Reserved bits", "lisp.mreq.res",
3093
16
            FT_UINT24, BASE_HEX, NULL, MAP_REQ_RESERVED, "Must be zero", HFILL }},
3094
16
        { &hf_lisp_mreq_srceid_afi,
3095
16
            { "Source EID AFI", "lisp.mreq.srceid.afi",
3096
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, "Source EID Address Family Indicator", HFILL }},
3097
16
        { &hf_lisp_mreq_srceid_string,
3098
16
            { "Source EID", "lisp.mreq.srceid.string",
3099
16
            FT_STRING, BASE_NONE, NULL, 0x0, "Source EID Address", HFILL }},
3100
16
        { &hf_lisp_mreq_srceid_ipv4,
3101
16
            { "Source EID", "lisp.mreq.srceid.ipv4",
3102
16
            FT_IPv4, BASE_NONE, NULL, 0x0, "Source EID Address", HFILL }},
3103
16
        { &hf_lisp_mreq_srceid_ipv6,
3104
16
            { "Source EID", "lisp.mreq.srceid_ipv6",
3105
16
            FT_IPv6, BASE_NONE, NULL, 0x0, "Source EID Address", HFILL }},
3106
16
        { &hf_lisp_mreq_srceid_mac,
3107
16
            { "Source EID", "lisp.mreq.srceid.mac",
3108
16
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3109
16
        { &hf_lisp_mreq_itr_rloc,
3110
16
            { "ITR-RLOC", "lisp.mreq.itr_rloc",
3111
16
            FT_NONE, BASE_NONE, NULL, 0x0, "Originating ITR RLOC Address", HFILL }},
3112
16
        { &hf_lisp_mreq_itr_rloc_afi,
3113
16
            { "ITR-RLOC AFI", "lisp.mreq.itr_rloc.afi",
3114
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, "Originating ITR RLOC Address Family Indicator", HFILL }},
3115
16
        { &hf_lisp_mreq_itr_rloc_ipv4,
3116
16
            { "ITR-RLOC Address", "lisp.mreq.itr_rloc_ipv4",
3117
16
            FT_IPv4, BASE_NONE, NULL, 0x0, "Originating ITR RLOC Address", HFILL }},
3118
16
        { &hf_lisp_mreq_itr_rloc_ipv6,
3119
16
            { "ITR-RLOC Address", "lisp.mreq.itr_rloc_ipv6",
3120
16
            FT_IPv6, BASE_NONE, NULL, 0x0, "Originating ITR RLOC Address", HFILL }},
3121
16
        { &hf_lisp_mreq_record_res,
3122
16
            { "Reserved", "lisp.mreq.record.res",
3123
16
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3124
16
        { &hf_lisp_mreq_record_prefix_length,
3125
16
            { "Prefix Length", "lisp.mreq.record.prefix.length",
3126
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3127
16
        { &hf_lisp_mreq_record_prefix_afi,
3128
16
            { "Prefix AFI", "lisp.mreq.record.prefix.afi",
3129
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3130
16
        { &hf_lisp_mreq_record_prefix_ipv4,
3131
16
            { "Prefix", "lisp.mreq.record.prefix.ipv4",
3132
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3133
16
        { &hf_lisp_mreq_record_prefix_ipv6,
3134
16
            { "Prefix", "lisp.mreq.record.prefix.ipv6",
3135
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3136
16
        { &hf_lisp_mreq_record_prefix_mac,
3137
16
            { "Prefix", "lisp.mreq.record.prefix.mac",
3138
16
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3139
16
        { &hf_lisp_mreq_record_prefix_dn,
3140
16
            { "Prefix", "lisp.mreq.record.prefix.dn",
3141
16
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3142
16
        { &hf_lisp_mreq_record,
3143
16
            { "Map-Request Record", "lisp.mreq.record",
3144
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3145
16
        { &hf_lisp_mrep_record,
3146
16
            { "Map-Reply Record", "lisp.mrep.record",
3147
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3148
16
        { &hf_lisp_mrep_flags_probe,
3149
16
            { "P bit (Probe)", "lisp.mrep.flags.probe",
3150
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REP_FLAG_P, NULL, HFILL }},
3151
16
        { &hf_lisp_mrep_flags_enlr,
3152
16
            { "E bit (Echo-Nonce locator reachability algorithm enabled)", "lisp.mrep.flags.enlr",
3153
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REP_FLAG_E, NULL, HFILL }},
3154
16
        { &hf_lisp_mrep_flags_sec,
3155
16
            { "S bit (LISP-SEC capable)", "lisp.mrep.flags.sec",
3156
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REP_FLAG_S, NULL, HFILL }},
3157
16
        { &hf_lisp_mrep_res,
3158
16
            { "Reserved bits", "lisp.mrep.res",
3159
16
            FT_UINT24, BASE_HEX, NULL, MAP_REP_RESERVED, "Must be zero", HFILL }},
3160
16
        { &hf_lisp_mreg_flags_pmr,
3161
16
            { "P bit (Proxy-Map-Reply)", "lisp.mreg.flags.pmr",
3162
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REG_FLAG_P, NULL, HFILL }},
3163
16
        { &hf_lisp_mreg_flags_sec,
3164
16
            { "S bit (LISP-SEC capable)", "lisp.mreg.flags.sec",
3165
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REG_FLAG_S, NULL, HFILL }},
3166
16
        { &hf_lisp_mreg_flags_xtrid,
3167
16
            { "I bit (xTR-ID present)", "lisp.mreg.flags.xtrid",
3168
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REG_FLAG_I, NULL, HFILL }},
3169
16
        { &hf_lisp_mreg_flags_rtr,
3170
16
            { "R bit (Built for an RTR)", "lisp.mreg.flags.rtr",
3171
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REG_FLAG_R, NULL, HFILL }},
3172
16
        { &hf_lisp_mreg_flags_wmn,
3173
16
            { "M bit (Want-Map-Notify)", "lisp.mreg.flags.wmn",
3174
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REG_FLAG_M, NULL, HFILL }},
3175
16
        { &hf_lisp_mreg_res,
3176
16
            { "Reserved bits", "lisp.mreg.res",
3177
16
            FT_UINT24, BASE_HEX, NULL, MAP_REG_RESERVED, "Must be zero", HFILL }},
3178
16
        { &hf_lisp_mref_res,
3179
16
            { "Reserved bits", "lisp.mref.res",
3180
16
            FT_UINT24, BASE_HEX, NULL, MAP_REF_RESERVED, "Must be zero", HFILL }},
3181
16
        { &hf_lisp_keyid,
3182
16
            { "Key ID", "lisp.keyid",
3183
16
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3184
16
        { &hf_lisp_authlen,
3185
16
            { "Authentication Data Length", "lisp.authlen",
3186
16
            FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3187
16
        { &hf_lisp_auth,
3188
16
            { "Authentication Data", "lisp.auth",
3189
16
            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3190
16
        { &hf_lisp_msrtr_keyid,
3191
16
            { "MS-RTR Key ID", "lisp.msrtr.keyid",
3192
16
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3193
16
        { &hf_lisp_msrtr_authlen,
3194
16
            { "MS-RTR Authentication Data Length", "lisp.msrtr.authlen",
3195
16
            FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3196
16
        { &hf_lisp_msrtr_auth,
3197
16
            { "MS-RTR Authentication Data", "lisp.msrtr.auth",
3198
16
            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3199
16
        { &hf_lisp_xtrid,
3200
16
            { "xTR-ID", "lisp.xtrid",
3201
16
            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3202
16
        { &hf_lisp_siteid,
3203
16
            { "Site-ID", "lisp.siteid",
3204
16
            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3205
16
        { &hf_lisp_mnot_flags_xtrid,
3206
16
            { "I bit (xTR-ID present)", "lisp.mnot.flags.xtrid",
3207
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_NOT_FLAG_I, NULL, HFILL }},
3208
16
        { &hf_lisp_mnot_flags_rtr,
3209
16
            { "R bit (Built for an RTR)", "lisp.mnot.flags.rtr",
3210
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_NOT_FLAG_R, NULL, HFILL }},
3211
16
        { &hf_lisp_mnot_res,
3212
16
            { "Reserved bits", "lisp.mnot.res",
3213
16
            FT_UINT24, BASE_HEX, NULL, MAP_NOT_RESERVED, "Must be zero", HFILL }},
3214
16
        { &hf_lisp_info_r,
3215
16
            { "R bit (Info-Reply)", "lisp.info.r",
3216
16
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), INFO_FLAG_R, NULL, HFILL }},
3217
16
        { &hf_lisp_info_res1,
3218
16
            { "Reserved bits", "lisp.info.res1",
3219
16
            FT_UINT32, BASE_HEX, NULL, INFO_RESERVED, "Must be zero", HFILL }},
3220
16
        { &hf_lisp_info_ttl,
3221
16
            { "TTL", "lisp.info.ttl",
3222
16
            FT_UINT32, BASE_DEC, NULL, 0x0, "RTR information time-to-live", HFILL }},
3223
16
        { &hf_lisp_info_res2,
3224
16
            { "Reserved bits", "lisp.info.res2",
3225
16
            FT_UINT8, BASE_HEX, NULL, 0xFF, "Must be zero", HFILL }},
3226
16
        { &hf_lisp_info_prefix_masklen,
3227
16
            { "EID Prefix Mask Length", "lisp.info.prefix.masklen",
3228
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3229
16
        { &hf_lisp_info_prefix_afi,
3230
16
            { "Prefix AFI", "lisp.info.prefix.afi",
3231
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3232
16
        { &hf_lisp_info_prefix_ipv4,
3233
16
            { "Prefix", "lisp.info.prefix.ipv4",
3234
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3235
16
        { &hf_lisp_info_prefix_ipv6,
3236
16
            { "Prefix", "lisp.info.prefix.ipv6",
3237
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3238
16
        { &hf_lisp_info_afi,
3239
16
            { "AFI", "lisp.info.afi",
3240
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, "Address Family Indicator", HFILL }},
3241
16
        { &hf_lisp_loc,
3242
16
            { "Locator Record", "lisp.loc",
3243
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3244
16
        { &hf_lisp_loc_priority,
3245
16
            { "Priority", "lisp.loc.priority",
3246
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3247
16
        { &hf_lisp_loc_weight,
3248
16
            { "Weight", "lisp.loc.weight",
3249
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3250
16
        { &hf_lisp_loc_mpriority,
3251
16
            { "Multicast Priority", "lisp.loc.multicast_priority",
3252
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3253
16
        { &hf_lisp_loc_mweight,
3254
16
            { "Multicast Weight", "lisp.loc.multicast_weight",
3255
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3256
16
        { &hf_lisp_loc_flags,
3257
16
            { "Flags", "lisp.loc.flags",
3258
16
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3259
16
        { &hf_lisp_loc_flags_local,
3260
16
            { "Local", "lisp.loc.flags.local",
3261
16
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), LOCAL_BIT_MASK, NULL, HFILL }},
3262
16
        { &hf_lisp_loc_flags_probe,
3263
16
            { "Probe", "lisp.loc.flags.probe",
3264
16
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), PROBE_BIT_MASK, NULL, HFILL }},
3265
16
        { &hf_lisp_loc_flags_reach,
3266
16
            { "Reachable", "lisp.loc.flags.reach",
3267
16
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), REACH_BIT_MASK, NULL, HFILL }},
3268
16
        { &hf_lisp_loc_flags_res,
3269
16
            { "Reserved", "lisp.loc.flags.res",
3270
16
            FT_UINT16, BASE_HEX, NULL, 0xFFF8, "Must be zero", HFILL }},
3271
16
        { &hf_lisp_loc_afi,
3272
16
            { "AFI", "lisp.loc.afi",
3273
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3274
16
        { &hf_lisp_loc_locator,
3275
16
            { "Locator", "lisp.loc.locator",
3276
16
            FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3277
16
        { &hf_lisp_mapping,
3278
16
            { "Mapping Record", "lisp.mapping",
3279
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3280
16
        { &hf_lisp_mapping_ttl,
3281
16
            { "Record TTL", "lisp.mapping.ttl",
3282
16
            FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3283
16
        { &hf_lisp_mapping_loccnt,
3284
16
            { "Locator Count", "lisp.mapping.loccnt",
3285
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3286
16
        { &hf_lisp_mapping_eid_masklen,
3287
16
            { "EID Mask Length", "lisp.mapping.eid.masklen",
3288
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3289
16
        { &hf_lisp_mapping_act,
3290
16
            { "Action", "lisp.mapping.act",
3291
16
            FT_UINT16, BASE_DEC, VALS(mapping_actions), 0xE000, NULL, HFILL }},
3292
16
        { &hf_lisp_mapping_auth,
3293
16
            { "Authoritative bit", "lisp.mapping.auth",
3294
16
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), LISP_MAP_AUTH, NULL, HFILL }},
3295
16
        { &hf_lisp_referral_incomplete,
3296
16
            { "Incomplete", "lisp.referral.incomplete",
3297
16
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), REFERRAL_INCOMPLETE, NULL, HFILL }},
3298
16
        { &hf_lisp_mapping_res1,
3299
16
            { "Reserved", "lisp.mapping.res1",
3300
16
            FT_UINT16, BASE_HEX, NULL, 0x07FF, NULL, HFILL }},
3301
16
        { &hf_lisp_mapping_res2,
3302
16
            { "Reserved", "lisp.mapping.res2",
3303
16
            FT_UINT16, BASE_HEX, NULL, 0xF000, NULL, HFILL }},
3304
16
        { &hf_lisp_mapping_ver,
3305
16
            { "Mapping Version", "lisp.mapping.ver",
3306
16
            FT_UINT16, BASE_DEC, NULL, 0x0FFF, NULL, HFILL }},
3307
16
        { &hf_lisp_referral_sigcnt,
3308
16
            { "Signature Count", "lisp.referral.sigcnt",
3309
16
            FT_UINT16, BASE_DEC, NULL, 0xF000, NULL, HFILL }},
3310
16
        { &hf_lisp_mapping_eid_afi,
3311
16
            { "EID Prefix AFI", "lisp.mapping.eid.afi",
3312
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3313
16
        { &hf_lisp_mapping_eid_ipv4,
3314
16
            { "EID Prefix", "lisp.mapping.eid.ipv4",
3315
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3316
16
        { &hf_lisp_mapping_eid_ipv6,
3317
16
            { "EID Prefix", "lisp.mapping.eid.ipv6",
3318
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3319
16
        { &hf_lisp_mapping_eid_mac,
3320
16
            { "EID Prefix", "lisp.mapping.eid.mac",
3321
16
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3322
16
        { &hf_lisp_mapping_eid_dn,
3323
16
            { "EID Prefix", "lisp.mapping.eid.dn",
3324
16
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3325
16
        { &hf_lisp_ecm_flags_sec,
3326
16
            { "S bit (LISP-SEC capable)", "lisp.ecm.flags.sec",
3327
16
            FT_BOOLEAN, 32, TFS(&tfs_set_notset), ECM_FLAG_S, NULL, HFILL }},
3328
16
        { &hf_lisp_ecm_flags_ddt,
3329
16
            { "D bit (DDT-originated)", "lisp.ecm.flags.ddt",
3330
16
            FT_BOOLEAN, 32, TFS(&tfs_set_notset), ECM_FLAG_D, NULL, HFILL }},
3331
16
        { &hf_lisp_ecm_res,
3332
16
            { "Reserved bits", "lisp.ecm.res",
3333
16
            FT_UINT32, BASE_HEX, NULL, 0x03FFFFFF, NULL, HFILL }},
3334
16
        { &hf_lisp_lcaf,
3335
16
            { "LCAF", "lisp.lcaf",
3336
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3337
16
        { &hf_lisp_lcaf_header,
3338
16
            { "LCAF Header", "lisp.lcaf.header",
3339
16
            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3340
16
        { &hf_lisp_lcaf_res1,
3341
16
            { "Reserved bits", "lisp.lcaf.res1",
3342
16
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3343
16
        { &hf_lisp_lcaf_flags,
3344
16
            { "Flags", "lisp.lcaf.flags",
3345
16
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3346
16
        { &hf_lisp_lcaf_type,
3347
16
            { "Type", "lisp.lcaf.type",
3348
16
            FT_UINT8, BASE_DEC, VALS(lcaf_typevals), 0x0, "LISP LCAF Type", HFILL }},
3349
16
        { &hf_lisp_lcaf_res2,
3350
16
            { "Reserved bits", "lisp.lcaf.res2",
3351
16
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3352
16
        { &hf_lisp_lcaf_length,
3353
16
            { "Length", "lisp.lcaf.length",
3354
16
            FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3355
16
        { &hf_lisp_lcaf_afi_list_item,
3356
16
            { "List Item", "lisp.lcaf.afi_list.item",
3357
16
            FT_NONE, BASE_NONE, NULL, 0x0, "AFI List Item", HFILL }},
3358
16
        { &hf_lisp_lcaf_afi_list_afi,
3359
16
            { "List Item AFI", "lisp.lcaf.afi_list.afi",
3360
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3361
16
        { &hf_lisp_lcaf_afi_list_ipv4,
3362
16
            { "List Item Address", "lisp.lcaf.afi_list.ipv4",
3363
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3364
16
        { &hf_lisp_lcaf_afi_list_ipv6,
3365
16
            { "List Item Address", "lisp.lcaf.afi_list.ipv6",
3366
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3367
16
        { &hf_lisp_lcaf_afi_list_mac,
3368
16
            { "List Item Address", "lisp.lcaf.afi_list.mac",
3369
16
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3370
16
        { &hf_lisp_lcaf_afi_list_dn,
3371
16
            { "List Item Address", "lisp.lcaf.afi_list.dn",
3372
16
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3373
16
        { &hf_lisp_lcaf_iid,
3374
16
            { "Instance ID", "lisp.lcaf.iid",
3375
16
            FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3376
16
        { &hf_lisp_lcaf_iid_afi,
3377
16
            { "Address AFI", "lisp.lcaf.iid.afi",
3378
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3379
16
        { &hf_lisp_lcaf_iid_ipv4,
3380
16
            { "Address", "lisp.lcaf.iid.ipv4",
3381
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3382
16
        { &hf_lisp_lcaf_iid_ipv6,
3383
16
            { "Address", "lisp.lcaf.iid.ipv6",
3384
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3385
16
        { &hf_lisp_lcaf_iid_mac,
3386
16
            { "Address", "lisp.lcaf.iid.mac",
3387
16
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3388
16
        { &hf_lisp_lcaf_iid_dn,
3389
16
            { "Address", "lisp.lcaf.iid.dn",
3390
16
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3391
16
        { &hf_lisp_lcaf_asn,
3392
16
            { "AS Number", "lisp.lcaf.asn",
3393
16
            FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3394
16
        { &hf_lisp_lcaf_asn_afi,
3395
16
            { "Address AFI", "lisp.lcaf.asn.afi",
3396
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3397
16
        { &hf_lisp_lcaf_asn_ipv4,
3398
16
            { "Address", "lisp.lcaf.asn.ipv4",
3399
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3400
16
        { &hf_lisp_lcaf_asn_ipv6,
3401
16
            { "Address", "lisp.lcaf.asn.ipv6",
3402
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3403
16
        { &hf_lisp_lcaf_asn_mac,
3404
16
            { "Address", "lisp.lcaf.asn.mac",
3405
16
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3406
16
        { &hf_lisp_lcaf_asn_dn,
3407
16
            { "Address", "lisp.lcaf.asn.dn",
3408
16
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3409
16
        { &hf_lisp_lcaf_geo_lat,
3410
16
            { "Latitude", "lisp.lcaf.geo.lat",
3411
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3412
16
        { &hf_lisp_lcaf_geo_lat_hemisphere,
3413
16
            { "Hemisphere", "lisp.lcaf.geo.lat.hemisphere",
3414
16
            FT_UINT16, BASE_DEC, VALS(lat_typevals), 0x8000, NULL, HFILL }},
3415
16
        { &hf_lisp_lcaf_geo_lat_deg,
3416
16
            { "Degrees", "lisp.lcaf.geo.lat.deg",
3417
16
            FT_UINT16, BASE_DEC, NULL, 0x7FFF, NULL, HFILL }},
3418
16
        { &hf_lisp_lcaf_geo_lat_min,
3419
16
            { "Minutes", "lisp.lcaf.geo.lat.min",
3420
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3421
16
        { &hf_lisp_lcaf_geo_lat_sec,
3422
16
            { "Seconds", "lisp.lcaf.geo.lat.sec",
3423
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3424
16
        { &hf_lisp_lcaf_geo_lon,
3425
16
            { "Longitude", "lisp.lcaf.geo.lon",
3426
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3427
16
        { &hf_lisp_lcaf_geo_lon_hemisphere,
3428
16
            { "Hemisphere", "lisp.lcaf.geo.lon.hemisphere",
3429
16
            FT_UINT16, BASE_DEC, VALS(lon_typevals), 0x8000, NULL, HFILL }},
3430
16
        { &hf_lisp_lcaf_geo_lon_deg,
3431
16
            { "Degrees", "lisp.lcaf.geo.lon.deg",
3432
16
            FT_UINT16, BASE_DEC, NULL, 0x7FFF, NULL, HFILL }},
3433
16
        { &hf_lisp_lcaf_geo_lon_min,
3434
16
            { "Minutes", "lisp.lcaf.geo.lon.min",
3435
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3436
16
        { &hf_lisp_lcaf_geo_lon_sec,
3437
16
            { "Seconds", "lisp.lcaf.geo.lon.sec",
3438
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3439
16
        { &hf_lisp_lcaf_geo_alt,
3440
16
            { "Altitude", "lisp.lcaf.geo.alt",
3441
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3442
16
        { &hf_lisp_lcaf_geo_afi,
3443
16
            { "Address AFI", "lisp.lcaf.geo.afi",
3444
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3445
16
        { &hf_lisp_lcaf_geo_ipv4,
3446
16
            { "Address", "lisp.lcaf.geo.ipv4",
3447
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3448
16
        { &hf_lisp_lcaf_geo_ipv6,
3449
16
            { "Address", "lisp.lcaf.geo.ipv6",
3450
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3451
16
        { &hf_lisp_lcaf_geo_mac,
3452
16
            { "Address", "lisp.lcaf.geo.mac",
3453
16
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3454
16
        { &hf_lisp_lcaf_geo_dn,
3455
16
            { "Address", "lisp.lcaf.geo.dn",
3456
16
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3457
16
        { &hf_lisp_lcaf_nonce_loc_res,
3458
16
            { "Reserved bits", "lisp.lcaf.nonce_loc.res",
3459
16
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3460
16
        { &hf_lisp_lcaf_nonce_loc,
3461
16
            { "Nonce", "lisp.lcaf.nonce_loc",
3462
16
            FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3463
16
        { &hf_lisp_lcaf_nonce_loc_afi,
3464
16
            { "Address AFI", "lisp.lcaf.nonce_loc.afi",
3465
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3466
16
        { &hf_lisp_lcaf_nonce_loc_ipv4,
3467
16
            { "Address", "lisp.lcaf.nonce_loc.ipv4",
3468
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3469
16
        { &hf_lisp_lcaf_nonce_loc_ipv6,
3470
16
            { "Address", "lisp.lcaf.nonce_loc.ipv6",
3471
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3472
16
        { &hf_lisp_lcaf_nonce_loc_mac,
3473
16
            { "Address", "lisp.lcaf.nonce_loc.mac",
3474
16
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3475
16
        { &hf_lisp_lcaf_nonce_loc_dn,
3476
16
            { "Address", "lisp.lcaf.nonce_loc.dn",
3477
16
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3478
16
        { &hf_lisp_lcaf_mcinfo_flags,
3479
16
            { "Multicast Info Flags", "lisp.lcaf.mcinfo.flags",
3480
16
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3481
16
        { &hf_lisp_lcaf_mcinfo_flags_res,
3482
16
            { "Reserved", "lisp.lcaf.mcinfo.flags.res",
3483
16
            FT_UINT8, BASE_HEX, NULL, 0xF8, "Must be zero", HFILL }},
3484
16
        { &hf_lisp_lcaf_mcinfo_flags_rp,
3485
16
            { "RP-bit", "lisp.lcaf.mcinfo.flags.rp",
3486
16
            FT_BOOLEAN, 8, TFS(&tfs_set_notset), MCINFO_FLAG_R, NULL, HFILL }},
3487
16
        { &hf_lisp_lcaf_mcinfo_flags_leave,
3488
16
            { "Leave (L-bit)", "lisp.lcaf.mcinfo.flags.leave",
3489
16
            FT_BOOLEAN, 8, TFS(&tfs_set_notset), MCINFO_FLAG_L, NULL, HFILL }},
3490
16
        { &hf_lisp_lcaf_mcinfo_flags_join,
3491
16
            { "Join (J-bit)", "lisp.lcaf_mcinfo.flags.join",
3492
16
            FT_BOOLEAN, 8, TFS(&tfs_set_notset), MCINFO_FLAG_J, NULL, HFILL }},
3493
16
        { &hf_lisp_lcaf_mcinfo_iid,
3494
16
            { "Instance ID", "lisp.lcaf.mcinfo_iid",
3495
16
            FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3496
16
        { &hf_lisp_lcaf_mcinfo_res,
3497
16
            { "Reserved bits", "lisp.lcaf.mcinfo.res",
3498
16
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3499
16
        { &hf_lisp_lcaf_mcinfo_src_masklen,
3500
16
            { "Source Mask Length", "lisp.lcaf.mcinfo.src.masklen",
3501
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3502
16
        { &hf_lisp_lcaf_mcinfo_grp_masklen,
3503
16
            { "Group Mask Length", "lisp.lcaf.mcinfo.grp.masklen",
3504
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3505
16
        { &hf_lisp_lcaf_mcinfo_src,
3506
16
            { "Source/Subnet Address", "lisp.lcaf.mcinfo.src",
3507
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3508
16
        { &hf_lisp_lcaf_mcinfo_src_afi,
3509
16
            { "Source/Subnet AFI", "lisp.lcaf.mcinfo.src.afi",
3510
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3511
16
        { &hf_lisp_lcaf_mcinfo_src_ipv4,
3512
16
            { "Source/Subnet Address", "lisp.lcaf.mcinfo.src.ipv4",
3513
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3514
16
        { &hf_lisp_lcaf_mcinfo_src_ipv6,
3515
16
            { "Source/Subnet Address", "lisp.lcaf.mcinfo.src.ipv6",
3516
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3517
16
        { &hf_lisp_lcaf_mcinfo_grp,
3518
16
            { "Group Address", "lisp.lcaf.mcinfo.grp",
3519
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3520
16
        { &hf_lisp_lcaf_mcinfo_grp_afi,
3521
16
            { "Group AFI", "lisp.lcaf.mcinfo.grp.afi",
3522
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3523
16
        { &hf_lisp_lcaf_mcinfo_grp_ipv4,
3524
16
            { "Group Address", "lisp.lcaf.mcinfo.grp.ipv4",
3525
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3526
16
        { &hf_lisp_lcaf_mcinfo_grp_ipv6,
3527
16
            { "Group Address", "lisp.lcaf.mcinfo.grp.ipv6",
3528
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3529
16
        { &hf_lisp_lcaf_elp_hop,
3530
16
            { "Reencap Hop", "lisp.lcaf.elp_hop",
3531
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3532
16
        { &hf_lisp_lcaf_elp_hop_flags,
3533
16
            { "Flags", "lisp.lcaf.elp_hop.flags",
3534
16
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3535
16
        { &hf_lisp_lcaf_elp_hop_flags_res,
3536
16
            { "Reserved", "lisp.lcaf.elp_hop.flags.res",
3537
16
            FT_UINT16, BASE_HEX, NULL, 0xFFF8, "Must be zero", HFILL }},
3538
16
        { &hf_lisp_lcaf_elp_hop_flags_lookup,
3539
16
            { "Lookup", "lisp.lcaf.elp_hop.flags.local",
3540
16
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), ELP_FLAG_L, NULL, HFILL }},
3541
16
        { &hf_lisp_lcaf_elp_hop_flags_probe,
3542
16
            { "Probe", "lisp.lcaf.elp_hop.flags.probe",
3543
16
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), ELP_FLAG_P, NULL, HFILL }},
3544
16
        { &hf_lisp_lcaf_elp_hop_flags_strict,
3545
16
            { "Strict", "lisp.lcaf_elp_hop.flags.strict",
3546
16
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), ELP_FLAG_S, NULL, HFILL }},
3547
16
        { &hf_lisp_lcaf_elp_hop_afi,
3548
16
            { "Reencap Hop AFI", "lisp.lcaf.elp_hop.afi",
3549
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3550
16
        { &hf_lisp_lcaf_elp_hop_ipv4,
3551
16
            { "Reencap Hop", "lisp.lcaf.elp_hop.ipv4",
3552
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3553
16
        { &hf_lisp_lcaf_elp_hop_ipv6,
3554
16
            { "Reencap Hop", "lisp.lcaf.elp_hop.ipv6",
3555
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3556
16
        { &hf_lisp_lcaf_srcdst_res,
3557
16
            { "Reserved bits", "lisp.lcaf.srcdst.res",
3558
16
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3559
16
        { &hf_lisp_lcaf_srcdst_src_masklen,
3560
16
            { "Source Prefix Mask Length", "lisp.lcaf.srcdst.src.masklen",
3561
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3562
16
        { &hf_lisp_lcaf_srcdst_dst_masklen,
3563
16
            { "Destination Prefix Mask Length", "lisp.lcaf.srcdst.dst.masklen",
3564
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3565
16
        { &hf_lisp_lcaf_srcdst_src,
3566
16
            { "Source Prefix", "lisp.lcaf.srcdst.src",
3567
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3568
16
        { &hf_lisp_lcaf_srcdst_src_afi,
3569
16
            { "Source Prefix AFI", "lisp.lcaf.srcdst.src.afi",
3570
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3571
16
        { &hf_lisp_lcaf_srcdst_src_ipv4,
3572
16
            { "Source Prefix", "lisp.lcaf.srcdst.src.ipv4",
3573
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3574
16
        { &hf_lisp_lcaf_srcdst_src_ipv6,
3575
16
            { "Source Prefix", "lisp.lcaf.srcdst.src.ipv6",
3576
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3577
16
        { &hf_lisp_lcaf_srcdst_src_mac,
3578
16
            { "Destination Prefix", "lisp.lcaf.srcdst.src.mac",
3579
16
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3580
16
        { &hf_lisp_lcaf_srcdst_dst,
3581
16
            { "Destination Prefix", "lisp.lcaf.srcdst.dst",
3582
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3583
16
        { &hf_lisp_lcaf_srcdst_dst_afi,
3584
16
            { "Destination Prefix AFI", "lisp.lcaf.srcdst.dst.afi",
3585
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3586
16
        { &hf_lisp_lcaf_srcdst_dst_ipv4,
3587
16
            { "Destination Prefix", "lisp.lcaf.srcdst.dst.ipv4",
3588
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3589
16
        { &hf_lisp_lcaf_srcdst_dst_ipv6,
3590
16
            { "Destination Prefix", "lisp.lcaf.srcdst.dst.ipv6",
3591
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3592
16
        { &hf_lisp_lcaf_srcdst_dst_mac,
3593
16
            { "Destination Prefix", "lisp.lcaf.srcdst.dst.mac",
3594
16
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3595
16
        { &hf_lisp_lcaf_rle_entry,
3596
16
            { "RTR/ETR", "lisp.lcaf.rle_entry",
3597
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3598
16
        { &hf_lisp_lcaf_rle_entry_res,
3599
16
            { "Reserved bits", "lisp.lcaf.rle_entry.res",
3600
16
            FT_UINT24, BASE_HEX, NULL, 0x0, "Must be zero", HFILL }},
3601
16
        { &hf_lisp_lcaf_rle_entry_level,
3602
16
            { "Level Value", "lisp.lcaf.rle_entry.level",
3603
16
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3604
16
        { &hf_lisp_lcaf_rle_entry_afi,
3605
16
            { "RTR/ETR AFI", "lisp.lcaf.rle_entry.afi",
3606
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3607
16
        { &hf_lisp_lcaf_rle_entry_ipv4,
3608
16
            { "RTR/ETR", "lisp.lcaf.rle_entry.ipv4",
3609
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3610
16
        { &hf_lisp_lcaf_rle_entry_ipv6,
3611
16
            { "RTR/ETR", "lisp.lcaf.rle_entry.ipv6",
3612
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3613
16
        { &hf_lisp_lcaf_kv_key,
3614
16
            { "Key", "lisp.lcaf.kv_key",
3615
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3616
16
        { &hf_lisp_lcaf_kv_key_afi,
3617
16
            { "Key AFI", "lisp.lcaf.kv_key.afi",
3618
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3619
16
        { &hf_lisp_lcaf_kv_key_ipv4,
3620
16
            { "Key", "lisp.lcaf.kv_key.ipv4",
3621
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3622
16
        { &hf_lisp_lcaf_kv_key_ipv6,
3623
16
            { "Key", "lisp.lcaf.kv_key.ipv6",
3624
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3625
16
        { &hf_lisp_lcaf_kv_key_mac,
3626
16
            { "Key", "lisp.lcaf.kv_key.mac",
3627
16
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3628
16
        { &hf_lisp_lcaf_kv_key_dn,
3629
16
            { "Key", "lisp.lcaf.kv_key.dn",
3630
16
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3631
16
        { &hf_lisp_lcaf_kv_value,
3632
16
            { "Value", "lisp.lcaf.kv_value",
3633
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3634
16
        { &hf_lisp_lcaf_kv_value_afi,
3635
16
            { "Value AFI", "lisp.lcaf.kv_value.afi",
3636
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3637
16
        { &hf_lisp_lcaf_kv_value_ipv4,
3638
16
            { "Value", "lisp.lcaf.kv_value.ipv4",
3639
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3640
16
        { &hf_lisp_lcaf_kv_value_ipv6,
3641
16
            { "Value", "lisp.lcaf.kv_value.ipv6",
3642
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3643
16
        { &hf_lisp_lcaf_kv_value_mac,
3644
16
            { "Value", "lisp.lcaf.kv_value.mac",
3645
16
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3646
16
        { &hf_lisp_lcaf_kv_value_dn,
3647
16
            { "Value", "lisp.lcaf.kv_value.dn",
3648
16
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3649
16
        { &hf_lisp_lcaf_natt_rloc,
3650
16
            { "RLOC", "lisp.lcaf.natt.rloc",
3651
16
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3652
16
        { &hf_lisp_lcaf_natt_rloc_afi,
3653
16
            { "RLOC AFI", "lisp.lcaf.natt.rloc.afi",
3654
16
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3655
16
        { &hf_lisp_lcaf_natt_rloc_ipv4,
3656
16
            { "RLOC", "lisp.lcaf.natt.rloc.ipv4",
3657
16
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3658
16
        { &hf_lisp_lcaf_natt_rloc_ipv6,
3659
16
            { "RLOC", "lisp.lcaf.natt.rloc.ipv6",
3660
16
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3661
16
        { &hf_lisp_lcaf_natt_msport,
3662
16
            { "MS UDP Port Number", "lisp.lcaf.natt.msport",
3663
16
            FT_UINT16, BASE_PT_UDP, NULL, 0x0, NULL, HFILL }},
3664
16
        { &hf_lisp_lcaf_natt_etrport,
3665
16
            { "ETR UDP Port Number", "lisp.lcaf.natt.etrport",
3666
16
            FT_UINT16, BASE_PT_UDP, NULL, 0x0, NULL, HFILL }},
3667
16
        { &hf_lisp_lcaf_vendor_res,
3668
16
            { "Reserved", "lisp.lcaf.vendor.res",
3669
16
            FT_UINT8, BASE_HEX, NULL, 0x0, "Must be zero", HFILL }},
3670
16
        { &hf_lisp_lcaf_vendor_oui,
3671
16
            { "OUI", "lisp.lcaf.vendor.oui",
3672
16
            FT_UINT24, BASE_HEX, VALS(oui_vals), 0x0, "Organizationally Unique Identifier", HFILL }},
3673
16
        { &hf_lisp_lcaf_vendor_data,
3674
16
            { "Vendor Specific Data", "lisp.lcaf.vendor.data",
3675
16
            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3676
16
    };
3677
3678
    /* Setup protocol subtree array */
3679
16
    static int *ett[] = {
3680
16
        &ett_lisp,
3681
16
        &ett_lisp_mr,
3682
16
        &ett_lisp_mreq_flags,
3683
16
        &ett_lisp_mapping,
3684
16
        &ett_lisp_itr,
3685
16
        &ett_lisp_record,
3686
16
        &ett_lisp_lcaf,
3687
16
        &ett_lisp_lcaf_header,
3688
16
        &ett_lisp_lcaf_geo_lat,
3689
16
        &ett_lisp_lcaf_geo_lon,
3690
16
        &ett_lisp_lcaf_natt_rloc,
3691
16
        &ett_lisp_lcaf_mcinfo_flags,
3692
16
        &ett_lisp_lcaf_mcinfo_src,
3693
16
        &ett_lisp_lcaf_mcinfo_grp,
3694
16
        &ett_lisp_lcaf_elp_hop,
3695
16
        &ett_lisp_lcaf_elp_hop_flags,
3696
16
        &ett_lisp_lcaf_srcdst_src,
3697
16
        &ett_lisp_lcaf_srcdst_dst,
3698
16
        &ett_lisp_lcaf_rle_entry,
3699
16
        &ett_lisp_lcaf_kv_key,
3700
16
        &ett_lisp_lcaf_kv_value,
3701
16
        &ett_lisp_lcaf_vendor,
3702
16
        &ett_lisp_loc,
3703
16
        &ett_lisp_loc_flags,
3704
16
        &ett_lisp_info_prefix,
3705
16
        &ett_lisp_afi_list
3706
16
    };
3707
3708
16
    static ei_register_info ei[] = {
3709
16
        { &ei_lisp_undecoded, { "lisp.undecoded", PI_UNDECODED, PI_WARN, "Not dissected yet (report to wireshark.org)", EXPFILL }},
3710
16
        { &ei_lisp_unexpected_field, { "lisp.unexpected_field", PI_PROTOCOL, PI_ERROR, "Unexpected field", EXPFILL }},
3711
16
        { &ei_lisp_invalid_field, { "lisp.invalid_field", PI_PROTOCOL, PI_WARN, "Invalid field", EXPFILL }},
3712
16
        { &ei_lisp_expected_field, { "lisp.expected_field", PI_PROTOCOL, PI_ERROR, "Expecting field", EXPFILL }},
3713
16
    };
3714
3715
16
    expert_module_t* expert_lisp;
3716
3717
    /* Register the protocol name and description */
3718
16
    proto_lisp = proto_register_protocol("Locator/ID Separation Protocol",
3719
16
        "LISP Control", "lisp");
3720
3721
    /* Required function calls to register the header fields and subtrees used */
3722
16
    proto_register_field_array(proto_lisp, hf, array_length(hf));
3723
16
    proto_register_subtree_array(ett, array_length(ett));
3724
16
    expert_lisp = expert_register_protocol(proto_lisp);
3725
16
    expert_register_field_array(expert_lisp, ei, array_length(ei));
3726
3727
    /* Register dissector so that other dissectors can call it */
3728
16
    lisp_handle = register_dissector("lisp", dissect_lisp, proto_lisp);
3729
16
}
3730
3731
3732
/*
3733
 * Simple form of proto_reg_handoff_lisp which can be used if there are
3734
 * no prefs-dependent registration function calls.
3735
 */
3736
3737
void
3738
proto_reg_handoff_lisp(void)
3739
16
{
3740
16
    dissector_add_uint_with_preference("udp.port", LISP_CONTROL_PORT, lisp_handle);
3741
16
    ipv4_handle = find_dissector_add_dependency("ip", proto_lisp);
3742
16
    ipv6_handle = find_dissector_add_dependency("ipv6", proto_lisp);
3743
16
}
3744
3745
/*
3746
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
3747
 *
3748
 * Local variables:
3749
 * c-basic-offset: 4
3750
 * tab-width: 8
3751
 * indent-tabs-mode: nil
3752
 * End:
3753
 *
3754
 * vi: set shiftwidth=4 tabstop=8 expandtab:
3755
 * :indentSize=4:tabSize=8:noTabs=true:
3756
 */