Coverage Report

Created: 2026-07-12 07:10

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
8
#define LISP_MAP_REQUEST    1
40
71
#define LISP_MAP_REPLY      2
41
13
#define LISP_MAP_REGISTER   3
42
17
#define LISP_MAP_NOTIFY     4
43
21
#define LISP_MAP_REFERRAL   6
44
5
#define LISP_INFO           7
45
154
#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
63
#define LCAF_IID            2
65
59
#define LCAF_ASN            3
66
#define LCAF_APP_DATA       4
67
0
#define LCAF_GEO            5
68
#define LCAF_OKEY           6
69
30
#define LCAF_NATT           7
70
1
#define LCAF_NONCE_LOC      8
71
61
#define LCAF_MCAST_INFO     9
72
13
#define LCAF_ELP            10
73
#define LCAF_SEC_KEY        11
74
0
#define LCAF_SRC_DST_KEY    12
75
4
#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
189
#define LCAF_HEADER_LEN     6
81
18
#define LISP_ECM_HEADER_LEN 4
82
83
2.39k
#define LISP_MAP_ACT        0xE000
84
285
#define LISP_MAP_AUTH       0x1000
85
81
#define REFERRAL_INCOMPLETE 0x0800
86
350
#define LOCAL_BIT_MASK      0x0004
87
350
#define PROBE_BIT_MASK      0x0002
88
350
#define REACH_BIT_MASK      0x0001
89
90
15
#define MAP_REQ_FLAG_A      0x080000
91
23
#define MAP_REQ_FLAG_M      0x040000
92
23
#define MAP_REQ_FLAG_P      0x020000
93
23
#define MAP_REQ_FLAG_S      0x010000
94
23
#define MAP_REQ_FLAG_p      0x008000
95
23
#define MAP_REQ_FLAG_s      0x004000
96
15
#define MAP_REQ_RESERVED    0x003FE0
97
98
86
#define MAP_REP_FLAG_P      0x080000
99
15
#define MAP_REP_FLAG_E      0x040000
100
15
#define MAP_REP_FLAG_S      0x020000
101
15
#define MAP_REP_RESERVED    0x01FFFF
102
103
15
#define MAP_REG_FLAG_P      0x080000
104
15
#define MAP_REG_FLAG_S      0x040000
105
28
#define MAP_REG_FLAG_I      0x020000
106
28
#define MAP_REG_FLAG_R      0x010000
107
15
#define MAP_REG_RESERVED    0x00FFFE
108
15
#define MAP_REG_FLAG_M      0x000001
109
110
32
#define MAP_NOT_FLAG_I      0x080000
111
32
#define MAP_NOT_FLAG_R      0x040000
112
15
#define MAP_NOT_RESERVED    0x03FFFF
113
114
15
#define MAP_REF_RESERVED    0x0FFFFF
115
116
20
#define INFO_FLAG_R         0x080000
117
15
#define INFO_RESERVED       0x07FFFFFF
118
119
15
#define ECM_FLAG_S          0x08000000
120
24
#define ECM_FLAG_D          0x04000000
121
122
15
#define MCINFO_FLAG_R       0x04
123
15
#define MCINFO_FLAG_L       0x02
124
15
#define MCINFO_FLAG_J       0x01
125
126
15
#define ELP_FLAG_L          0x0004
127
15
#define ELP_FLAG_P          0x0002
128
15
#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
61
{
498
    /* Jump over Rsvd1 and Flags (16 bits) */
499
61
    offset += 2;
500
501
    /* Type (8 bits) */
502
61
    if (lcaf_type)
503
61
        *lcaf_type = tvb_get_uint8(tvb, offset);
504
61
    offset += 1;
505
506
    /* Jump over Rsvd2 bits (8 bits) */
507
61
    offset += 1;
508
509
    /* Length (16 bits) */
510
61
    if (len)
511
        /* Adding the size of the LCAF header as well */
512
61
        *len = tvb_get_ntohs(tvb, offset) + LCAF_HEADER_LEN;
513
61
    offset += 2;
514
515
61
    return offset;
516
61
}
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
10.3k
{
522
10.3k
    const char        *notset_str = "not set";
523
10.3k
    const char        *addr_str;
524
10.3k
    uint8_t            lcaf_type;
525
10.3k
    uint32_t           iid, asn;
526
10.3k
    uint16_t           cur_len;
527
528
10.3k
    switch (afi) {
529
2.05k
        case AFNUM_RESERVED_0:
530
2.05k
            *addr_len  = 0;
531
2.05k
            return notset_str;
532
65
        case AFNUM_IP:
533
65
            *addr_len  = INET_ADDRLEN;
534
65
            addr_str   = tvb_ip_to_str(pinfo->pool, tvb, offset);
535
65
            return addr_str;
536
21
        case AFNUM_IP6:
537
21
            *addr_len  = INET6_ADDRLEN;
538
21
            addr_str   = tvb_ip6_to_str(pinfo->pool, tvb, offset);
539
21
            return addr_str;
540
61
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
541
61
            get_lcaf_data(tvb, offset, &lcaf_type, addr_len);
542
61
            addr_str = val_to_str(pinfo->pool, lcaf_type, lcaf_typevals, "Unknown LCAF Type (%d)");
543
61
            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
59
            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
59
            return addr_str;
560
5
        case AFNUM_802:
561
5
        case AFNUM_48_BIT_MAC:
562
5
            *addr_len = EUI48_ADDRLEN;
563
5
            addr_str  = tvb_ether_to_str(pinfo->pool, tvb, offset);
564
5
            return addr_str;
565
3
        case AFNUM_DISTINGUISHED_NAME:
566
3
            *addr_len = tvb_strsize(tvb, offset);
567
3
            addr_str  = (char*)tvb_get_stringz_enc(pinfo->pool, tvb, offset, NULL, ENC_ASCII);
568
3
            return addr_str;
569
8.14k
        default:
570
8.14k
            return NULL;
571
10.3k
    }
572
10.3k
}
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.94k
{
579
6.94k
    uint16_t     addr_len = 0;
580
6.94k
    uint16_t     rloc_afi;
581
6.94k
    const char *rloc_str;
582
6.94k
    proto_item  *ti;
583
6.94k
    proto_tree  *rloc_tree;
584
585
6.94k
    ti = proto_tree_add_item(tree, hf_lisp_lcaf_natt_rloc, tvb, offset, 2, ENC_NA);
586
6.94k
    rloc_tree = proto_item_add_subtree(ti, ett_lisp_lcaf_natt_rloc);
587
588
    /* AFI (2 bytes) */
589
6.94k
    proto_tree_add_item_ret_uint16(rloc_tree, hf_lisp_lcaf_natt_rloc_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &rloc_afi);
590
6.94k
    offset += 2;
591
592
    /* Reencap hop */
593
6.94k
    rloc_str = get_addr_str(tvb, pinfo, offset, rloc_afi, &addr_len);
594
595
6.94k
    switch (rloc_afi) {
596
1.53k
        case AFNUM_RESERVED_0:
597
1.53k
            break;
598
57
        case AFNUM_IP:
599
57
            proto_tree_add_item(rloc_tree, hf_lisp_lcaf_natt_rloc_ipv4,
600
57
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
601
57
            break;
602
7
        case AFNUM_IP6:
603
7
            proto_tree_add_item(rloc_tree, hf_lisp_lcaf_natt_rloc_ipv6,
604
7
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
605
7
            break;
606
12
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
607
12
            dissect_lcaf(tvb, pinfo, rloc_tree, offset, NULL);
608
12
            break;
609
5.30k
        default:
610
5.30k
            expert_add_info_format(pinfo, rloc_tree, &ei_lisp_unexpected_field,
611
5.30k
                    "Unexpected NAT-T RLOC AFI (%d), cannot decode", rloc_afi);
612
6.94k
    }
613
614
6.91k
    if (idx) {
615
6.82k
        proto_item_append_text(ti, str, idx, rloc_str);
616
6.82k
    } else {
617
90
        proto_item_append_text(ti, str, rloc_str);
618
90
    }
619
6.91k
    proto_item_set_len(ti, 2 + addr_len);
620
621
6.91k
    return addr_len + 2;
622
6.94k
}
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
326
{
629
326
    uint16_t     addr_len = 0;
630
326
    uint16_t     hop_afi;
631
326
    uint16_t     hop_flags;
632
326
    const char *hop_str;
633
326
    proto_item  *ti, *ti_flags;
634
326
    proto_tree  *hop_tree, *flags_tree;
635
636
326
    ti = proto_tree_add_item(tree, hf_lisp_lcaf_elp_hop, tvb, offset, 2, ENC_NA);
637
326
    hop_tree = proto_item_add_subtree(ti, ett_lisp_lcaf_elp_hop);
638
639
    /* Flags (2 bytes) */
640
326
    ti_flags = proto_tree_add_item(hop_tree, hf_lisp_lcaf_elp_hop_flags, tvb, offset, 2, ENC_BIG_ENDIAN);
641
326
    flags_tree = proto_item_add_subtree(ti_flags, ett_lisp_lcaf_elp_hop_flags);
642
326
    proto_tree_add_item(flags_tree, hf_lisp_lcaf_elp_hop_flags_res, tvb, offset, 2, ENC_BIG_ENDIAN);
643
326
    proto_tree_add_item(flags_tree, hf_lisp_lcaf_elp_hop_flags_lookup, tvb, offset, 2, ENC_BIG_ENDIAN);
644
326
    proto_tree_add_item(flags_tree, hf_lisp_lcaf_elp_hop_flags_probe, tvb, offset, 2, ENC_BIG_ENDIAN);
645
326
    proto_tree_add_item(flags_tree, hf_lisp_lcaf_elp_hop_flags_strict, tvb, offset, 2, ENC_BIG_ENDIAN);
646
647
326
    hop_flags = tvb_get_ntohs(tvb, offset);
648
326
    offset += 2;
649
650
    /* AFI (2 bytes) */
651
326
    proto_tree_add_item_ret_uint16(hop_tree, hf_lisp_lcaf_elp_hop_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &hop_afi);
652
326
    offset += 2;
653
654
    /* Reencap hop */
655
326
    hop_str = get_addr_str(tvb, pinfo, offset, hop_afi, &addr_len);
656
657
326
    switch (hop_afi) {
658
1
        case AFNUM_IP:
659
1
            proto_tree_add_item(hop_tree, hf_lisp_lcaf_elp_hop_ipv4,
660
1
                    tvb, offset, INET_ADDRLEN, ENC_BIG_ENDIAN);
661
1
            break;
662
0
        case AFNUM_IP6:
663
0
            proto_tree_add_item(hop_tree, hf_lisp_lcaf_elp_hop_ipv6,
664
0
                    tvb, offset, INET6_ADDRLEN, ENC_NA);
665
0
            break;
666
0
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
667
0
            dissect_lcaf(tvb, pinfo, hop_tree, offset, NULL);
668
0
            break;
669
316
        default:
670
316
            expert_add_info_format(pinfo, hop_tree, &ei_lisp_unexpected_field,
671
316
                    "Unexpected Reencap Hop AFI (%d), cannot decode", hop_afi);
672
326
    }
673
674
317
    if (idx) {
675
317
        proto_item_append_text(ti, " %d.", idx);
676
317
    } else {
677
0
        proto_item_append_text(ti, ":");
678
0
    }
679
680
317
    proto_item_append_text(ti, " %s", hop_str);
681
317
    proto_item_set_len(ti, 4 + addr_len);
682
683
317
    if (hop_flags & 0x04)
684
228
        proto_item_append_text(ti, ", Lookup");
685
317
    if (hop_flags & 0x02)
686
245
        proto_item_append_text(ti, ", RLOC-Probe");
687
317
    if (hop_flags & 0x01)
688
171
        proto_item_append_text(ti, ", Strict");
689
690
317
    proto_item_append_text(tip, ", %s", hop_str);
691
692
317
    return addr_len + 4;
693
326
}
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
47
{
701
47
    uint8_t      level;
702
47
    uint16_t     addr_len = 0;
703
47
    uint16_t     entry_afi;
704
47
    const char *entry_str;
705
47
    proto_item  *ti;
706
47
    proto_tree  *entry_tree;
707
708
47
    ti = proto_tree_add_item(tree, hf_lisp_lcaf_rle_entry, tvb, offset, 2, ENC_NA);
709
47
    entry_tree = proto_item_add_subtree(ti, ett_lisp_lcaf_rle_entry);
710
711
    /* Reserved (3 bytes) */
712
47
    proto_tree_add_item(entry_tree, hf_lisp_lcaf_rle_entry_res, tvb, offset, 3, ENC_BIG_ENDIAN);
713
47
    offset += 3;
714
715
    /* Level Value (1 byte) */
716
47
    proto_tree_add_item_ret_uint8(entry_tree, hf_lisp_lcaf_rle_entry_level, tvb, offset, 1, ENC_BIG_ENDIAN, &level);
717
47
    offset += 1;
718
719
    /* AFI (2 bytes) */
720
47
    proto_tree_add_item_ret_uint16(entry_tree, hf_lisp_lcaf_rle_entry_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &entry_afi);
721
47
    offset += 2;
722
723
    /* RTR/ETR entry */
724
47
    entry_str = get_addr_str(tvb, pinfo, offset, entry_afi, &addr_len);
725
726
47
    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
43
        default:
739
43
            expert_add_info_format(pinfo, entry_tree, &ei_lisp_unexpected_field,
740
43
                    "Unexpected RTR/ETR AFI (%d), cannot decode", entry_afi);
741
47
    }
742
743
44
    if (idx) {
744
44
        proto_item_append_text(ti, " %d.", idx);
745
44
    } else {
746
0
        proto_item_append_text(ti, ":");
747
0
    }
748
749
44
    proto_item_append_text(ti, " %s, level %d", entry_str, level);
750
44
    proto_item_set_len(ti, 6 + addr_len);
751
752
44
    proto_item_append_text(tip, ", %s (%d)", entry_str, level);
753
754
44
    return addr_len + 6;
755
47
}
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
30
{
1181
30
    int          i;
1182
30
    int          len;
1183
30
    int          remaining   = length;
1184
30
    const char *global_etr  = " of Global ETR: %s";
1185
30
    const char *ms          = " of MS: %s";
1186
30
    const char *private_etr = " of Private ETR: %s";
1187
30
    const char *rtr         = " of RTR %d: %s";
1188
1189
30
    remaining -= 4;
1190
1191
30
    proto_tree_add_item(tree, hf_lisp_lcaf_natt_msport, tvb, offset, 2, ENC_BIG_ENDIAN);
1192
30
    offset += 2;
1193
30
    remaining -= 2;
1194
30
    proto_tree_add_item(tree, hf_lisp_lcaf_natt_etrport, tvb, offset, 2, ENC_BIG_ENDIAN);
1195
30
    offset += 2;
1196
30
    remaining -= 2;
1197
1198
30
    len = dissect_lcaf_natt_rloc(tvb, pinfo, tree, offset, global_etr, 0);
1199
30
    offset += len;
1200
30
    remaining -= len;
1201
1202
30
    len = dissect_lcaf_natt_rloc(tvb, pinfo, tree, offset, ms, 0);
1203
30
    offset += len;
1204
30
    remaining -= len;
1205
1206
30
    len = dissect_lcaf_natt_rloc(tvb, pinfo, tree, offset, private_etr, 0);
1207
30
    offset += len;
1208
30
    remaining -= len;
1209
1210
30
    i = 1;
1211
6.88k
    while (remaining > 0) {
1212
6.85k
        len = dissect_lcaf_natt_rloc(tvb, pinfo, tree, offset, rtr, i);
1213
6.85k
        offset += len;
1214
6.85k
        remaining -= len;
1215
6.85k
        i++;
1216
6.85k
    }
1217
1218
30
    return offset;
1219
30
}
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
13
{
1446
13
    int len;
1447
13
    int remaining = length;
1448
13
    int i = 1;
1449
1450
339
    while (remaining > 0) {
1451
326
        len = dissect_lcaf_elp_hop(tvb, pinfo, tree, offset, i, tir);
1452
326
        offset += len;
1453
326
        remaining -= len;
1454
326
        i++;
1455
326
    }
1456
1457
13
    return offset;
1458
13
}
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
4
{
1610
4
    int len;
1611
4
    int remaining = length;
1612
4
    int i = 1;
1613
1614
51
    while (remaining > 0) {
1615
47
        len = dissect_lcaf_rle_entry(tvb, pinfo, tree, offset, i, tir);
1616
47
        offset += len;
1617
47
        remaining -= len;
1618
47
        i++;
1619
47
    }
1620
1621
4
    return offset;
1622
4
}
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
61
{
1823
61
    uint8_t      lcaf_type;
1824
61
    uint16_t     len;
1825
61
    proto_item  *tir, *ti_header, *ti_flags, *ti;
1826
61
    proto_tree  *lcaf_tree, *lcaf_header_tree, *flags_tree;
1827
61
    tvbuff_t    *payload_tvb;
1828
1829
61
    len = tvb_get_ntohs(tvb, offset + 4);
1830
1831
61
    tir = proto_tree_add_item(tree, hf_lisp_lcaf, tvb, offset, LCAF_HEADER_LEN + len, ENC_NA);
1832
61
    lcaf_tree = proto_item_add_subtree(tir, ett_lisp_lcaf);
1833
1834
61
    ti_header = proto_tree_add_item(lcaf_tree, hf_lisp_lcaf_header, tvb, offset, LCAF_HEADER_LEN, ENC_NA);
1835
61
    lcaf_header_tree = proto_item_add_subtree(ti_header, ett_lisp_lcaf_header);
1836
1837
    /* Reserved bits (8 bits) */
1838
61
    proto_tree_add_item(lcaf_header_tree, hf_lisp_lcaf_res1, tvb, offset, 1, ENC_BIG_ENDIAN);
1839
61
    offset += 1;
1840
1841
    /* Flags (8 bits) */
1842
61
    proto_tree_add_item(lcaf_header_tree, hf_lisp_lcaf_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
1843
61
    offset += 1;
1844
1845
    /* Type (8 bits) */
1846
61
    proto_tree_add_item_ret_uint8(lcaf_header_tree, hf_lisp_lcaf_type, tvb, offset, 1, ENC_BIG_ENDIAN, &lcaf_type);
1847
61
    proto_item_append_text(tir, ": %s", val_to_str(pinfo->pool, lcaf_type, lcaf_typevals, "Unknown (%d)"));
1848
61
    offset += 1;
1849
1850
61
    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
61
    } else {
1862
        /* Reserved (8 bits) */
1863
61
        proto_tree_add_item(lcaf_header_tree, hf_lisp_lcaf_res2, tvb, offset, 1, ENC_BIG_ENDIAN);
1864
61
    }
1865
61
    offset += 1;
1866
1867
    /* Length (16 bits) */
1868
61
    proto_tree_add_item(lcaf_header_tree, hf_lisp_lcaf_length, tvb, offset, 2, ENC_BIG_ENDIAN);
1869
61
    offset += 2;
1870
1871
61
    payload_tvb = tvb_new_subset_length(tvb, 0, offset + len);
1872
61
    ti = (tip) ? tip : tir;
1873
1874
61
    increment_dissection_depth(pinfo);
1875
61
    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
30
        case LCAF_NATT:
1891
30
            offset = dissect_lcaf_natt(payload_tvb, pinfo, lcaf_tree, offset, len);
1892
30
            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
13
        case LCAF_ELP:
1900
13
            offset = dissect_lcaf_elp(payload_tvb, pinfo, lcaf_tree, offset, len, ti);
1901
13
            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
4
        case LCAF_RLE:
1906
4
            offset = dissect_lcaf_rle(payload_tvb, pinfo, lcaf_tree, offset, len, ti);
1907
4
            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
10
        default:
1915
10
            proto_tree_add_expert(tree, pinfo, &ei_lisp_undecoded, tvb, offset, len);
1916
10
            return offset + len;
1917
61
    }
1918
9
    decrement_dissection_depth(pinfo);
1919
9
    return offset;
1920
61
}
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
706
{
1941
706
    int          offset   = 0;
1942
706
    uint16_t     addr_len = 0;
1943
706
    uint8_t      prio;
1944
706
    uint8_t      weight;
1945
706
    uint8_t      m_prio;
1946
706
    uint8_t      m_weight;
1947
706
    uint16_t     flags;
1948
706
    uint16_t     loc_afi;
1949
706
    const char *locator;
1950
706
    proto_item  *tir, *ti_flags;
1951
706
    proto_tree  *lisp_lcaf_tree, *lisp_loc_tree, *lisp_flags_tree;
1952
1953
706
    tir = proto_tree_add_item(lisp_mapping_tree, hf_lisp_loc, tvb, offset, 8, ENC_NA);
1954
1955
706
    lisp_loc_tree = proto_item_add_subtree(tir, ett_lisp_loc);
1956
1957
706
    proto_tree_add_item(lisp_loc_tree, hf_lisp_loc_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
1958
706
    prio = tvb_get_uint8(tvb, offset);
1959
706
    offset += 1;
1960
1961
706
    proto_tree_add_item_ret_uint8(lisp_loc_tree, hf_lisp_loc_weight, tvb, offset, 1, ENC_BIG_ENDIAN, &weight);
1962
706
    offset += 1;
1963
1964
706
    proto_tree_add_item(lisp_loc_tree, hf_lisp_loc_mpriority, tvb, offset, 1, ENC_BIG_ENDIAN);
1965
706
    m_prio = tvb_get_uint8(tvb, offset);
1966
706
    offset += 1;
1967
1968
706
    proto_tree_add_item(lisp_loc_tree, hf_lisp_loc_mweight, tvb, offset, 1, ENC_BIG_ENDIAN);
1969
706
    m_weight = tvb_get_uint8(tvb, offset);
1970
706
    offset += 1;
1971
1972
706
    ti_flags = proto_tree_add_item(lisp_loc_tree, hf_lisp_loc_flags, tvb, offset, 2, ENC_BIG_ENDIAN);
1973
706
    lisp_flags_tree = proto_item_add_subtree(ti_flags, ett_lisp_loc_flags);
1974
706
    proto_tree_add_item(lisp_flags_tree, hf_lisp_loc_flags_res, tvb, offset, 2, ENC_BIG_ENDIAN);
1975
706
    proto_tree_add_item(lisp_flags_tree, hf_lisp_loc_flags_local, tvb, offset, 2, ENC_BIG_ENDIAN);
1976
706
    proto_tree_add_item(lisp_flags_tree, hf_lisp_loc_flags_probe, tvb, offset, 2, ENC_BIG_ENDIAN);
1977
706
    proto_tree_add_item(lisp_flags_tree, hf_lisp_loc_flags_reach, tvb, offset, 2, ENC_BIG_ENDIAN);
1978
706
    flags = tvb_get_ntohs(tvb, offset);
1979
706
    offset += 2;
1980
1981
706
    proto_tree_add_item_ret_uint16(lisp_loc_tree, hf_lisp_loc_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &loc_afi);
1982
706
    offset += 2;
1983
1984
706
    locator = get_addr_str(tvb, pinfo, offset, loc_afi, &addr_len);
1985
1986
706
    if (locator == NULL) {
1987
371
        expert_add_info_format(pinfo, lisp_mapping_tree, &ei_lisp_unexpected_field,
1988
371
                "Unexpected locator AFI (%d), cannot decode", loc_afi);
1989
371
        return offset;
1990
371
    }
1991
1992
335
    if (loc_afi == AFNUM_LISP_CANONICAL_ADDRESS_FORMAT) {
1993
        /* Create a sub-tree for the mapping */
1994
0
        lisp_lcaf_tree = proto_item_add_subtree(tir, ett_lisp_lcaf);
1995
0
        offset = dissect_lcaf(tvb, pinfo, lisp_lcaf_tree, offset, NULL);
1996
335
    } else {
1997
335
        proto_tree_add_string(lisp_loc_tree, hf_lisp_loc_locator, tvb, offset, addr_len, locator);
1998
335
        offset += addr_len;
1999
335
    }
2000
2001
335
    proto_item_append_text(tir, " %d, %sRLOC: %s%s, %s, Priority/Weight: %d/%d, Multicast Priority/Weight: %d/%d",
2002
335
            rec,
2003
335
            (flags&LOCAL_BIT_MASK) ? "Local " : "",
2004
335
            locator,
2005
335
            (flags&PROBE_BIT_MASK) ? " (probed)" : "",
2006
335
            (flags&REACH_BIT_MASK) ? "Reachable" : "Unreachable",
2007
335
            prio, weight, m_prio, m_weight);
2008
335
    proto_item_set_len(tir, 8 + addr_len);
2009
2010
335
    return offset;
2011
706
}
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
2.39k
{
2035
2.39k
    int          i;
2036
2.39k
    int          str_len;
2037
2.39k
    uint16_t     addr_len      = 0;
2038
2.39k
    uint8_t      prefix_mask, loc_cnt;
2039
2.39k
    uint16_t     flags;
2040
2.39k
    uint16_t     act;
2041
2.39k
    uint16_t     prefix_afi, eid_afi;
2042
2.39k
    const char *prefix;
2043
2.39k
    proto_item  *tir;
2044
2.39k
    proto_tree  *lisp_mapping_tree, *lcaf_prefix_tree;
2045
2046
2.39k
    prefix_mask   = tvb_get_uint8(tvb, offset + 5);
2047
2.39k
    flags         = tvb_get_ntohs(tvb, offset + 6);
2048
2.39k
    prefix_afi    = tvb_get_ntohs(tvb, offset + 10);
2049
2050
2.39k
    act = flags & LISP_MAP_ACT;
2051
2.39k
    act >>= 13;
2052
2053
2.39k
    prefix = get_addr_str(tvb, pinfo, offset + 12, prefix_afi, &addr_len);
2054
2055
2.39k
    if (prefix == NULL) {
2056
2.12k
        expert_add_info_format(pinfo, lisp_tree, &ei_lisp_unexpected_field,
2057
2.12k
                "Unexpected EID prefix AFI (%d), cannot decode", prefix_afi);
2058
2.12k
        return offset;
2059
2.12k
    }
2060
270
    tir = proto_tree_add_item(lisp_tree, hf_lisp_mapping, tvb, offset, 12 + addr_len, ENC_NA);
2061
270
    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
270
    if (rec_cnt == 1)
2067
1
        col_append_fstr(pinfo->cinfo, COL_INFO, " for %s/%d",
2068
1
                prefix, prefix_mask);
2069
2070
    /* Create a sub-tree for the mapping */
2071
270
    lisp_mapping_tree = proto_item_add_subtree(tir, ett_lisp_mapping);
2072
270
    proto_item_append_text(tir, " %d, EID Prefix: %s/%d", rec, prefix, prefix_mask);
2073
2074
    /* TTL (32 bits) */
2075
270
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_ttl, tvb, offset, 4, ENC_BIG_ENDIAN);
2076
270
    if (tvb_get_ntohl(tvb, offset) == 0xFFFFFFFF) {
2077
1
        proto_item_append_text(tir, ", TTL: Unlimited");
2078
269
    } else {
2079
269
        proto_item_append_text(tir, ", TTL: %d", tvb_get_ntohl(tvb, offset));
2080
269
    }
2081
270
    offset += 4;
2082
2083
    /* Locator count (8 bits) */
2084
270
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_loccnt, tvb, offset, 1, ENC_BIG_ENDIAN);
2085
270
    loc_cnt = tvb_get_uint8(tvb, offset);
2086
270
    offset += 1;
2087
2088
    /* EID mask length (8 bits) */
2089
270
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_eid_masklen, tvb, offset, 1, ENC_BIG_ENDIAN);
2090
270
    offset += 1;
2091
2092
    /* Action (3 bits) */
2093
270
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_act, tvb, offset, 2, ENC_BIG_ENDIAN);
2094
270
    proto_item_append_text(tir, ", %s%s%s",
2095
270
            (referral) ? "" : "Action: ",
2096
270
            val_to_str(pinfo->pool, act, (referral) ? referral_actions : mapping_actions, "Invalid action code (%d)"),
2097
270
            (referral&&(flags&REFERRAL_INCOMPLETE)) ? " (Incomplete)" : "");
2098
2099
    /* Authoritative bit */
2100
270
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_auth, tvb, offset, 2, ENC_BIG_ENDIAN);
2101
270
    if (flags&LISP_MAP_AUTH) {
2102
41
        proto_item_append_text(tir, ", Authoritative");
2103
229
    } else {
2104
229
        proto_item_append_text(tir, ", Not Authoritative");
2105
229
    }
2106
2107
    /* Incomplete bit in Map-Referrals */
2108
270
    if (referral)
2109
66
        proto_tree_add_item(lisp_mapping_tree, hf_lisp_referral_incomplete, tvb, offset, 2, ENC_BIG_ENDIAN);
2110
2111
    /* Reserved (11 bits) */
2112
270
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_res1, tvb, offset, 2, ENC_BIG_ENDIAN);
2113
270
    offset += 2;
2114
2115
270
    if (referral) {
2116
        /* SigCnt (4 bits) */
2117
66
        proto_tree_add_item(lisp_mapping_tree, hf_lisp_referral_sigcnt, tvb, offset, 2, ENC_BIG_ENDIAN);
2118
204
    } else {
2119
        /* Reserved (4 bits) */
2120
204
        proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_res2, tvb, offset, 2, ENC_BIG_ENDIAN);
2121
204
    }
2122
2123
    /* Map-Version Number (12 bits) */
2124
270
    proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_ver, tvb, offset, 2, ENC_BIG_ENDIAN);
2125
270
    offset += 2;
2126
2127
    /* EID prefix AFI (16 bits) */
2128
270
    proto_tree_add_item_ret_uint16(lisp_mapping_tree, hf_lisp_mapping_eid_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &eid_afi);
2129
270
    offset += 2;
2130
2131
    /* EID */
2132
270
    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
5
        case AFNUM_IP6:
2138
5
            proto_tree_add_item(lisp_mapping_tree, hf_lisp_mapping_eid_ipv6, tvb, offset, INET6_ADDRLEN, ENC_NA);
2139
5
            offset += INET6_ADDRLEN;
2140
5
            break;
2141
49
        case AFNUM_LISP_CANONICAL_ADDRESS_FORMAT:
2142
49
            lcaf_prefix_tree = proto_tree_add_subtree_format(lisp_mapping_tree, tvb, offset, addr_len, ett_lisp_lcaf, NULL, "EID Prefix: %s", prefix);
2143
49
            dissect_lcaf(tvb, pinfo, lcaf_prefix_tree, offset, NULL);
2144
49
            offset += addr_len;
2145
49
            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
270
    }
2157
2158
    /* Locators */
2159
918
    for(i=0; i < loc_cnt; i++) {
2160
707
        tvbuff_t *loc_tvb;
2161
707
        int len = 0;
2162
2163
707
        loc_tvb = tvb_new_subset_remaining(tvb, offset);
2164
707
        len = dissect_lisp_locator(loc_tvb, pinfo, lisp_mapping_tree, i+1);
2165
707
        offset += len;
2166
707
    }
2167
2168
211
    return offset;
2169
270
}
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
8
{
2204
8
    int                i;
2205
8
    uint16_t           addr_len    = 0;
2206
8
    int                offset      = 0;
2207
8
    uint16_t           flags;
2208
8
    bool               mrep;
2209
8
    bool               smr;
2210
8
    bool               probe;
2211
8
    bool               pitr;
2212
8
    bool               smr_invoked;
2213
8
    uint8_t            itr_rec_cnt = 0;
2214
8
    uint8_t            rec_cnt     = 0;
2215
8
    uint16_t           src_eid_afi;
2216
8
    const char        *src_eid;
2217
8
    proto_item        *ti_flags;
2218
8
    proto_tree        *flags_tree, *lcaf_src_eid_tree, *lcaf_prefix_tree;
2219
8
    tvbuff_t          *next_tvb;
2220
2221
    /* Flags (6 bits)*/
2222
8
    flags       = tvb_get_ntohs(tvb, offset);
2223
8
    mrep        = flags & (MAP_REQ_FLAG_M >> 8);
2224
8
    smr         = flags & (MAP_REQ_FLAG_S >> 8);
2225
8
    probe       = flags & (MAP_REQ_FLAG_P >> 8);
2226
8
    pitr        = flags & (MAP_REQ_FLAG_p >> 8);
2227
8
    smr_invoked = flags & (MAP_REQ_FLAG_s >> 8);
2228
2229
8
    ti_flags = proto_tree_add_item(lisp_tree, hf_lisp_mreq_flags, tvb, offset, 3, ENC_BIG_ENDIAN);
2230
8
    flags_tree = proto_item_add_subtree(ti_flags, ett_lisp_mreq_flags);
2231
8
    proto_tree_add_item(flags_tree, hf_lisp_mreq_flags_auth, tvb, offset, 3, ENC_BIG_ENDIAN);
2232
8
    proto_tree_add_item(flags_tree, hf_lisp_mreq_flags_mrp, tvb, offset, 3, ENC_BIG_ENDIAN);
2233
8
    proto_tree_add_item(flags_tree, hf_lisp_mreq_flags_probe, tvb, offset, 3, ENC_BIG_ENDIAN);
2234
8
    proto_tree_add_item(flags_tree, hf_lisp_mreq_flags_smr, tvb, offset, 3, ENC_BIG_ENDIAN);
2235
8
    proto_tree_add_item(flags_tree, hf_lisp_mreq_flags_pitr, tvb, offset, 3, ENC_BIG_ENDIAN);
2236
8
    proto_tree_add_item(flags_tree, hf_lisp_mreq_flags_smri, tvb, offset, 3, ENC_BIG_ENDIAN);
2237
2238
8
    if (pitr)
2239
1
        col_append_str(pinfo->cinfo, COL_INFO, " by P-ITR");
2240
2241
8
    if (smr)
2242
4
        col_append_str(pinfo->cinfo, COL_INFO, " (SMR)");
2243
2244
8
    if (probe)
2245
3
        col_append_str(pinfo->cinfo, COL_INFO, " (RLOC-probe)");
2246
2247
8
    if (smr_invoked)
2248
2
        col_append_str(pinfo->cinfo, COL_INFO, " (SMR-invoked)");
2249
2250
    /* Reserved bits (9 bits) */
2251
8
    proto_tree_add_item(lisp_tree, hf_lisp_mreq_res, tvb, offset, 3, ENC_BIG_ENDIAN);
2252
2253
    /* ITR record count (5 bits) */
2254
8
    itr_rec_cnt = tvb_get_uint8(tvb, offset + 2) & 0x1F;
2255
8
    proto_tree_add_item(lisp_tree, hf_lisp_irc, tvb, offset, 3, ENC_BIG_ENDIAN);
2256
8
    offset += 3;
2257
2258
    /* Record count (8 bits) */
2259
8
    rec_cnt = tvb_get_uint8(tvb, offset);
2260
8
    proto_tree_add_item(lisp_tree, hf_lisp_records, tvb, offset, 1, ENC_BIG_ENDIAN);
2261
8
    offset += 1;
2262
2263
    /* Nonce (64 bits) */
2264
8
    proto_tree_add_item(lisp_tree, hf_lisp_nonce, tvb, offset, 8, ENC_BIG_ENDIAN);
2265
8
    offset += 8;
2266
2267
    /* Source EID AFI (16 bits) */
2268
8
    src_eid_afi = tvb_get_ntohs(tvb, offset);
2269
8
    proto_tree_add_item(lisp_tree, hf_lisp_mreq_srceid_afi, tvb, offset, 2, ENC_BIG_ENDIAN);
2270
8
    offset += 2;
2271
2272
    /* Source EID */
2273
8
    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
8
    }
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
71
{
2455
71
    int       i;
2456
71
    int       offset  = 0;
2457
71
    bool      probe;
2458
71
    uint8_t   flags;
2459
71
    uint8_t   rec_cnt = 0;
2460
71
    tvbuff_t *next_tvb;
2461
2462
    /* Flags (2 bits) */
2463
71
    flags = tvb_get_uint8(tvb, offset);
2464
71
    probe = flags & (MAP_REP_FLAG_P >> 16);
2465
71
    proto_tree_add_item(lisp_tree, hf_lisp_mrep_flags_probe, tvb, offset, 3, ENC_BIG_ENDIAN);
2466
71
    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
71
    proto_tree_add_item(lisp_tree, hf_lisp_mrep_flags_sec, tvb, offset, 3, ENC_BIG_ENDIAN);
2470
2471
71
    if (probe)
2472
13
        col_append_str(pinfo->cinfo, COL_INFO, " (RLOC-probe reply)");
2473
2474
    /* Reserved bits (18 bits) */
2475
71
    proto_tree_add_item(lisp_tree, hf_lisp_mrep_res, tvb, offset, 3, ENC_BIG_ENDIAN);
2476
71
    offset += 3;
2477
2478
    /* Record count (8 bits) */
2479
71
    rec_cnt = tvb_get_uint8(tvb, offset);
2480
71
    proto_tree_add_item(lisp_tree, hf_lisp_records, tvb, offset, 1, ENC_BIG_ENDIAN);
2481
71
    offset += 1;
2482
2483
    /* Nonce (64 bits) */
2484
71
    proto_tree_add_item(lisp_tree, hf_lisp_nonce, tvb, offset, 8, ENC_BIG_ENDIAN);
2485
71
    offset += 8;
2486
2487
    /* Reply records */
2488
502
    for(i=0; i < rec_cnt; i++) {
2489
431
        offset = dissect_lisp_mapping(tvb, pinfo, lisp_tree, rec_cnt, i+1, false, offset, NULL);
2490
431
    }
2491
2492
71
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2493
71
    call_data_dissector(next_tvb, pinfo, lisp_tree);
2494
71
}
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
13
{
2534
13
    int       i;
2535
13
    uint8_t   rec_cnt = 0;
2536
13
    tvbuff_t *next_tvb;
2537
13
    uint16_t  authlen = 0;
2538
13
    uint16_t  flags;
2539
13
    bool      xtrid;
2540
13
    bool      rtr;
2541
2542
    /* Flags (1 bit) */
2543
13
    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
13
    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
13
    flags = tvb_get_ntohs(tvb, offset);
2550
13
    xtrid = flags & (MAP_REG_FLAG_I >> 8);
2551
13
    rtr   = flags & (MAP_REG_FLAG_R >> 8);
2552
2553
13
    proto_tree_add_item(lisp_tree, hf_lisp_mreg_flags_xtrid, tvb, offset, 3, ENC_BIG_ENDIAN);
2554
13
    proto_tree_add_item(lisp_tree, hf_lisp_mreg_flags_rtr, tvb, offset, 3, ENC_BIG_ENDIAN);
2555
2556
13
    if (rtr)
2557
5
        col_append_str(pinfo->cinfo, COL_INFO, " (RTR)");
2558
2559
    /* Reserved bits (15 bits) */
2560
13
    proto_tree_add_item(lisp_tree, hf_lisp_mreg_res, tvb, offset, 3, ENC_BIG_ENDIAN);
2561
2562
    /* Flags (1 bit) */
2563
13
    proto_tree_add_item(lisp_tree, hf_lisp_mreg_flags_wmn, tvb, offset, 3, ENC_BIG_ENDIAN);
2564
13
    offset += 3;
2565
2566
    /* Record count (8 bits) */
2567
13
    rec_cnt = tvb_get_uint8(tvb, offset);
2568
13
    proto_tree_add_item(lisp_tree, hf_lisp_records, tvb, offset, 1, ENC_BIG_ENDIAN);
2569
13
    offset += 1;
2570
2571
    /* Nonce (64 bits) */
2572
13
    proto_tree_add_item(lisp_tree, hf_lisp_nonce, tvb, offset, 8, ENC_BIG_ENDIAN);
2573
13
    offset += 8;
2574
2575
    /* Key ID (16 bits) */
2576
13
    proto_tree_add_item(lisp_tree, hf_lisp_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
2577
13
    offset += 2;
2578
2579
    /* Authentication Data Length (16 bits) */
2580
13
    proto_tree_add_item_ret_uint16(lisp_tree, hf_lisp_authlen, tvb, offset, 2, ENC_BIG_ENDIAN, &authlen);
2581
13
    offset += 2;
2582
2583
    /* Authentication Data */
2584
    /* XXX: need to check is there is still enough data in buffer */
2585
13
    proto_tree_add_item(lisp_tree, hf_lisp_auth, tvb, offset, authlen, ENC_NA);
2586
13
    offset += authlen;
2587
2588
329
    for(i=0; i < rec_cnt; i++) {
2589
316
        offset = dissect_lisp_mapping(tvb, pinfo, lisp_tree, rec_cnt, i+1, false, offset, tim);
2590
316
    }
2591
2592
    /* If I bit is set, we have an xTR-ID and a site-ID field */
2593
13
    if (xtrid) {
2594
3
        proto_tree_add_item(lisp_tree, hf_lisp_xtrid, tvb, offset, LISP_XTRID_LEN, ENC_NA);
2595
3
        proto_tree_add_item(lisp_tree, hf_lisp_siteid, tvb, offset + LISP_XTRID_LEN, LISP_SITEID_LEN, ENC_NA);
2596
3
        offset += LISP_XTRID_LEN + LISP_SITEID_LEN;
2597
3
    }
2598
2599
13
    if (keep_going) {
2600
3
        next_tvb = tvb_new_subset_remaining(tvb, offset);
2601
3
        call_data_dissector(next_tvb, pinfo, lisp_tree);
2602
10
    } else {
2603
10
        return offset;
2604
10
    }
2605
2606
3
    return 0;
2607
13
}
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
17
{
2646
17
    int       i;
2647
17
    int       offset  = 0;
2648
17
    uint8_t   rec_cnt = 0;
2649
17
    tvbuff_t *next_tvb;
2650
17
    uint16_t  authlen = 0;
2651
17
    uint16_t  flags;
2652
17
    bool      xtrid;
2653
17
    bool      rtr;
2654
2655
    /* Flags defined in NAT Traversal draft (2 bits) */
2656
17
    flags = tvb_get_ntohs(tvb, offset);
2657
17
    xtrid = flags & (MAP_NOT_FLAG_I >> 8);
2658
17
    rtr   = flags & (MAP_NOT_FLAG_R >> 8);
2659
2660
17
    proto_tree_add_item(lisp_tree, hf_lisp_mnot_flags_xtrid, tvb, offset, 3, ENC_BIG_ENDIAN);
2661
17
    proto_tree_add_item(lisp_tree, hf_lisp_mnot_flags_rtr, tvb, offset, 3, ENC_BIG_ENDIAN);
2662
2663
17
    if (rtr)
2664
1
        col_append_str(pinfo->cinfo, COL_INFO, " (RTR)");
2665
2666
    /* Reserved bits (18 bits) */
2667
17
    proto_tree_add_item(lisp_tree, hf_lisp_mnot_res, tvb, offset, 3, ENC_BIG_ENDIAN);
2668
17
    offset += 3;
2669
2670
    /* Record count (8 bits) */
2671
17
    rec_cnt = tvb_get_uint8(tvb, offset);
2672
17
    proto_tree_add_item(lisp_tree, hf_lisp_records, tvb, offset, 1, ENC_BIG_ENDIAN);
2673
17
    offset += 1;
2674
2675
    /* Nonce (64 bits) */
2676
17
    proto_tree_add_item(lisp_tree, hf_lisp_nonce, tvb, offset, 8, ENC_BIG_ENDIAN);
2677
17
    offset += 8;
2678
2679
    /* Key ID (16 bits) */
2680
17
    proto_tree_add_item(lisp_tree, hf_lisp_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
2681
17
    offset += 2;
2682
2683
    /* Authentication Data Length (16 bits) */
2684
17
    proto_tree_add_item_ret_uint16(lisp_tree, hf_lisp_authlen, tvb, offset, 2, ENC_BIG_ENDIAN, &authlen);
2685
17
    offset += 2;
2686
2687
    /* Authentication Data */
2688
    /* XXX: need to check is there is still enough data in buffer */
2689
17
    proto_tree_add_item(lisp_tree, hf_lisp_auth, tvb, offset, authlen, ENC_NA);
2690
17
    offset += authlen;
2691
2692
967
    for(i=0; i < rec_cnt; i++) {
2693
950
        offset = dissect_lisp_mapping(tvb, pinfo, lisp_tree, rec_cnt, i+1, false, offset, NULL);
2694
950
    }
2695
2696
    /* If I bit is set, we have an xTR-ID and a site-ID field */
2697
17
    if (xtrid) {
2698
2
        proto_tree_add_item(lisp_tree, hf_lisp_xtrid, tvb, offset, LISP_XTRID_LEN, ENC_NA);
2699
2
        proto_tree_add_item(lisp_tree, hf_lisp_siteid, tvb, offset + LISP_XTRID_LEN, LISP_SITEID_LEN, ENC_NA);
2700
2
        offset += LISP_XTRID_LEN + LISP_SITEID_LEN;
2701
2
    }
2702
2703
    /* If R bit is set, we have MS-RTR authentication data */
2704
17
    if (rtr) {
2705
        /* MS-RTR Key ID (16 bits) */
2706
0
        proto_tree_add_item(lisp_tree, hf_lisp_msrtr_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
2707
0
        offset += 2;
2708
2709
        /* MS-RTR Authentication Data Length (16 bits) */
2710
0
        proto_tree_add_item_ret_uint16(lisp_tree, hf_lisp_msrtr_authlen, tvb, offset, 2, ENC_BIG_ENDIAN, &authlen);
2711
0
        offset += 2;
2712
2713
        /* MS-RTR Authentication Data */
2714
        /* XXX: need to check is there is still enough data in buffer */
2715
0
        proto_tree_add_item(lisp_tree, hf_lisp_msrtr_auth, tvb, offset, authlen, ENC_NA);
2716
0
        offset += authlen;
2717
0
    }
2718
2719
17
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2720
17
    call_data_dissector(next_tvb, pinfo, lisp_tree);
2721
17
}
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
21
{
2755
21
    int       i;
2756
21
    int       offset  = 0;
2757
21
    uint8_t   rec_cnt = 0;
2758
21
    tvbuff_t *next_tvb;
2759
2760
    /* Reserved bits (20 bits) */
2761
21
    proto_tree_add_item(lisp_tree, hf_lisp_mref_res, tvb, offset, 3, ENC_BIG_ENDIAN);
2762
21
    offset += 3;
2763
2764
    /* Record count (8 bits) */
2765
21
    rec_cnt = tvb_get_uint8(tvb, offset);
2766
21
    proto_tree_add_item(lisp_tree, hf_lisp_records, tvb, offset, 1, ENC_BIG_ENDIAN);
2767
21
    offset += 1;
2768
2769
    /* Nonce (64 bits) */
2770
21
    proto_tree_add_item(lisp_tree, hf_lisp_nonce, tvb, offset, 8, ENC_BIG_ENDIAN);
2771
21
    offset += 8;
2772
2773
    /* Referral records */
2774
723
    for(i=0; i < rec_cnt; i++) {
2775
702
        offset = dissect_lisp_mapping(tvb, pinfo, lisp_tree, rec_cnt, i+1, true, offset, NULL);
2776
702
    }
2777
2778
21
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2779
21
    call_data_dissector(next_tvb, pinfo, lisp_tree);
2780
21
}
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
5
{
2813
5
    int          offset   = 0;
2814
5
    tvbuff_t    *next_tvb;
2815
5
    uint8_t      flags;
2816
5
    bool         reply;
2817
5
    uint16_t     authlen  = 0;
2818
5
    uint8_t      prefix_mask;
2819
5
    uint16_t     prefix_afi, afi;
2820
5
    const char *prefix;
2821
5
    uint16_t     addr_len = 0;
2822
5
    proto_item  *tir, *ti_prefix;
2823
5
    proto_tree  *prefix_tree;
2824
2825
    /* Flags (1 bit) */
2826
5
    flags = tvb_get_uint8(tvb, offset);
2827
5
    reply = flags & (INFO_FLAG_R >> 16);
2828
2829
5
    if (reply)
2830
1
        col_append_str(pinfo->cinfo, COL_INFO, "-Reply");
2831
4
    else
2832
4
        col_append_str(pinfo->cinfo, COL_INFO, "-Request");
2833
2834
5
    proto_tree_add_item(lisp_tree, hf_lisp_info_r, tvb, offset, 3, ENC_BIG_ENDIAN);
2835
2836
    /* Reserved bits (27 bits) */
2837
5
    proto_tree_add_item(lisp_tree, hf_lisp_info_res1, tvb, offset, 4, ENC_BIG_ENDIAN);
2838
5
    offset += 4;
2839
2840
    /* Nonce (64 bits) */
2841
5
    proto_tree_add_item(lisp_tree, hf_lisp_nonce, tvb, offset, 8, ENC_BIG_ENDIAN);
2842
5
    offset += 8;
2843
2844
    /* Key ID (16 bits) */
2845
5
    proto_tree_add_item(lisp_tree, hf_lisp_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
2846
5
    offset += 2;
2847
2848
    /* Authentication Data Length (16 bits) */
2849
5
    proto_tree_add_item_ret_uint16(lisp_tree, hf_lisp_authlen, tvb, offset, 2, ENC_BIG_ENDIAN, &authlen);
2850
5
    offset += 2;
2851
2852
    /* Authentication Data */
2853
    /* XXX: need to check is there is still enough data in buffer */
2854
5
    proto_tree_add_item(lisp_tree, hf_lisp_auth, tvb, offset, authlen, ENC_NA);
2855
5
    offset += authlen;
2856
2857
    /* TTL */
2858
5
    proto_tree_add_item(lisp_tree, hf_lisp_info_ttl, tvb, offset, 4, ENC_BIG_ENDIAN);
2859
5
    offset += 4;
2860
2861
    /* Reserved bits (8 bits) */
2862
5
    proto_tree_add_item(lisp_tree, hf_lisp_info_res2, tvb, offset, 1, ENC_BIG_ENDIAN);
2863
5
    offset += 1;
2864
2865
5
    prefix_tree = proto_tree_add_subtree(lisp_tree, tvb, offset, 3, ett_lisp_info_prefix, &ti_prefix, "EID Prefix: ");
2866
2867
5
    proto_tree_add_item(prefix_tree, hf_lisp_info_prefix_masklen, tvb, offset, 1, ENC_BIG_ENDIAN);
2868
5
    prefix_mask = tvb_get_uint8(tvb, offset); offset += 1;
2869
2870
5
    proto_tree_add_item_ret_uint16(prefix_tree, hf_lisp_info_prefix_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &prefix_afi);
2871
5
    offset += 2;
2872
2873
5
    prefix = get_addr_str(tvb, pinfo, offset, prefix_afi, &addr_len);
2874
2875
5
    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
4
    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
4
    }
2891
2892
2
    proto_item_append_text(ti_prefix, "%s/%d", prefix, prefix_mask);
2893
2
    proto_item_set_len(ti_prefix, 3 + addr_len);
2894
2
    offset += addr_len;
2895
2896
    /* Update the INFO column */
2897
2
    col_append_fstr(pinfo->cinfo, COL_INFO, " for %s/%d", prefix, prefix_mask);
2898
2899
2
    tir = proto_tree_add_item_ret_uint16(lisp_tree, hf_lisp_info_afi, tvb, offset, 2, ENC_BIG_ENDIAN, &afi);
2900
2
    offset += 2;
2901
2902
2
    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
0
        if (afi != AFNUM_LISP_CANONICAL_ADDRESS_FORMAT) {
2909
0
            expert_add_info_format(pinfo, tir, &ei_lisp_expected_field,
2910
0
                    "Expecting LCAF AFI (%d), found %d, incorrect packet!",
2911
0
                    AFNUM_LISP_CANONICAL_ADDRESS_FORMAT, afi);
2912
0
        } else {
2913
0
            offset = dissect_lcaf(tvb, pinfo, lisp_tree, offset, NULL);
2914
0
        }
2915
0
    }
2916
2917
2
    next_tvb = tvb_new_subset_remaining(tvb, offset);
2918
2
    call_data_dissector(next_tvb, pinfo, lisp_tree);
2919
2
}
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
9
{
2937
9
    tvbuff_t *next_tvb;
2938
9
    uint8_t   flags;
2939
9
    uint8_t   ip_ver;
2940
2941
    /* Flags (2 bits) */
2942
9
    flags = tvb_get_uint8(tvb, 0);
2943
9
    ddt_originated = flags & (ECM_FLAG_D >> 24);
2944
2945
9
    proto_tree_add_item(lisp_tree, hf_lisp_ecm_flags_sec, tvb, 0, 4, ENC_BIG_ENDIAN);
2946
9
    proto_tree_add_item(lisp_tree, hf_lisp_ecm_flags_ddt, tvb, 0, 4, ENC_BIG_ENDIAN);
2947
9
    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
9
    next_tvb = tvb_new_subset_remaining(tvb, LISP_ECM_HEADER_LEN);
2951
9
    ip_ver = tvb_get_bits8(next_tvb, 0, 4);
2952
2953
9
    switch (ip_ver) {
2954
1
        case 4:
2955
1
            call_dissector(ipv4_handle, next_tvb, pinfo, tree);
2956
1
            break;
2957
7
        case 6:
2958
7
            call_dissector(ipv6_handle, next_tvb, pinfo, tree);
2959
7
            break;
2960
1
        default:
2961
1
            call_data_dissector(next_tvb, pinfo, tree);
2962
1
            break;
2963
9
    }
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
145
{
2975
145
    uint8_t type;
2976
2977
145
    proto_tree *lisp_tree = NULL;
2978
2979
    /* Clear Info column before fetching data in case an exception is thrown */
2980
145
    col_clear(pinfo->cinfo, COL_INFO);
2981
2982
145
    type = tvb_get_bits8(tvb, 0, 4);
2983
2984
    /* Make entries in Protocol column and Info column on summary display */
2985
145
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "LISP");
2986
2987
145
    if (encapsulated) {
2988
121
        col_add_fstr(pinfo->cinfo, COL_INFO, "Encapsulated %s", val_to_str(pinfo->pool, type, lisp_typevals,
2989
121
                    "Unknown LISP Control Packet (%d)"));
2990
121
    } else {
2991
24
        col_add_str(pinfo->cinfo, COL_INFO, val_to_str(pinfo->pool, type, lisp_typevals,
2992
24
                    "Unknown LISP Control Packet (%d)"));
2993
24
    }
2994
2995
145
    if (ddt_originated) {
2996
5
        col_append_str(pinfo->cinfo, COL_INFO, " (DDT-originated)");
2997
5
        ddt_originated = false;
2998
5
    }
2999
3000
145
    if (tree) {
3001
145
        proto_item *ti;
3002
3003
        /* create display subtree for the protocol */
3004
145
        ti = proto_tree_add_item(tree, proto_lisp, tvb, 0,
3005
145
                (type == LISP_ECM) ? LISP_ECM_HEADER_LEN : -1, ENC_NA);
3006
3007
145
        lisp_tree = proto_item_add_subtree(ti, ett_lisp);
3008
3009
145
        proto_tree_add_item(lisp_tree,
3010
145
            hf_lisp_type, tvb, 0, 3, ENC_BIG_ENDIAN);
3011
145
    }
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
145
    switch (type) {
3017
8
    case LISP_MAP_REQUEST:
3018
8
        dissect_lisp_map_request(tvb, pinfo, lisp_tree);
3019
8
        break;
3020
71
    case LISP_MAP_REPLY:
3021
71
        dissect_lisp_map_reply(tvb, pinfo, lisp_tree);
3022
71
        break;
3023
13
    case LISP_MAP_REGISTER:
3024
13
        dissect_lisp_map_register(tvb, pinfo, lisp_tree, 0, NULL, true);
3025
13
        break;
3026
17
    case LISP_MAP_NOTIFY:
3027
17
        dissect_lisp_map_notify(tvb, pinfo, lisp_tree);
3028
17
        break;
3029
21
    case LISP_MAP_REFERRAL:
3030
21
        dissect_lisp_map_referral(tvb, pinfo, lisp_tree);
3031
21
        break;
3032
5
    case LISP_INFO:
3033
5
        dissect_lisp_info(tvb, pinfo, lisp_tree);
3034
5
        break;
3035
9
    case LISP_ECM:
3036
9
        encapsulated = true;
3037
9
        dissect_lisp_ecm(tvb, pinfo, tree, lisp_tree);
3038
9
        break;
3039
1
    default:
3040
1
        call_data_dissector(tvb, pinfo, tree);
3041
1
        break;
3042
145
    }
3043
3044
    /* Return the amount of data this dissector was able to dissect */
3045
39
    return tvb_reported_length(tvb);
3046
145
}
3047
3048
3049
/*
3050
 *  Register the LISP protocol with Wireshark
3051
 */
3052
3053
void
3054
proto_register_lisp(void)
3055
15
{
3056
    /* Setup list of header fields */
3057
15
    static hf_register_info hf[] = {
3058
15
        { &hf_lisp_type,
3059
15
            { "Type", "lisp.type",
3060
15
            FT_UINT24, BASE_DEC, VALS(lisp_typevals), 0xF00000, "LISP Control Message Type", HFILL }},
3061
15
        { &hf_lisp_irc,
3062
15
            { "ITR-RLOC Count", "lisp.irc",
3063
15
            FT_UINT24, BASE_DEC, NULL, 0x00001F, NULL, HFILL }},
3064
15
        { &hf_lisp_records,
3065
15
            { "Record Count", "lisp.records",
3066
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3067
15
        { &hf_lisp_nonce,
3068
15
            { "Nonce", "lisp.nonce",
3069
15
            FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3070
15
        { &hf_lisp_mreq_flags,
3071
15
            { "Flags", "lisp.mreq.flags",
3072
15
            FT_UINT24, BASE_HEX, NULL, 0x0FC000, NULL, HFILL }},
3073
15
        { &hf_lisp_mreq_flags_auth,
3074
15
            { "A bit (Authoritative)", "lisp.mreq.flags.auth",
3075
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REQ_FLAG_A, NULL, HFILL }},
3076
15
        { &hf_lisp_mreq_flags_mrp,
3077
15
            { "M bit (Map-Reply present)", "lisp.mreq.flags.mrp",
3078
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REQ_FLAG_M, NULL, HFILL }},
3079
15
        { &hf_lisp_mreq_flags_probe,
3080
15
            { "P bit (Probe)", "lisp.mreq.flags.probe",
3081
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REQ_FLAG_P, NULL, HFILL }},
3082
15
        { &hf_lisp_mreq_flags_smr,
3083
15
            { "S bit (Solicit-Map-Request)", "lisp.mreq.flags.smr",
3084
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REQ_FLAG_S, NULL, HFILL }},
3085
15
        { &hf_lisp_mreq_flags_pitr,
3086
15
            { "p bit (Proxy ITR)", "lisp.mreq.flags.pitr",
3087
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REQ_FLAG_p, NULL, HFILL }},
3088
15
        { &hf_lisp_mreq_flags_smri,
3089
15
            { "s bit (SMR-invoked)", "lisp.mreq.flags.smri",
3090
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REQ_FLAG_s, NULL, HFILL }},
3091
15
        { &hf_lisp_mreq_res,
3092
15
            { "Reserved bits", "lisp.mreq.res",
3093
15
            FT_UINT24, BASE_HEX, NULL, MAP_REQ_RESERVED, "Must be zero", HFILL }},
3094
15
        { &hf_lisp_mreq_srceid_afi,
3095
15
            { "Source EID AFI", "lisp.mreq.srceid.afi",
3096
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, "Source EID Address Family Indicator", HFILL }},
3097
15
        { &hf_lisp_mreq_srceid_string,
3098
15
            { "Source EID", "lisp.mreq.srceid.string",
3099
15
            FT_STRING, BASE_NONE, NULL, 0x0, "Source EID Address", HFILL }},
3100
15
        { &hf_lisp_mreq_srceid_ipv4,
3101
15
            { "Source EID", "lisp.mreq.srceid.ipv4",
3102
15
            FT_IPv4, BASE_NONE, NULL, 0x0, "Source EID Address", HFILL }},
3103
15
        { &hf_lisp_mreq_srceid_ipv6,
3104
15
            { "Source EID", "lisp.mreq.srceid_ipv6",
3105
15
            FT_IPv6, BASE_NONE, NULL, 0x0, "Source EID Address", HFILL }},
3106
15
        { &hf_lisp_mreq_srceid_mac,
3107
15
            { "Source EID", "lisp.mreq.srceid.mac",
3108
15
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3109
15
        { &hf_lisp_mreq_itr_rloc,
3110
15
            { "ITR-RLOC", "lisp.mreq.itr_rloc",
3111
15
            FT_NONE, BASE_NONE, NULL, 0x0, "Originating ITR RLOC Address", HFILL }},
3112
15
        { &hf_lisp_mreq_itr_rloc_afi,
3113
15
            { "ITR-RLOC AFI", "lisp.mreq.itr_rloc.afi",
3114
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, "Originating ITR RLOC Address Family Indicator", HFILL }},
3115
15
        { &hf_lisp_mreq_itr_rloc_ipv4,
3116
15
            { "ITR-RLOC Address", "lisp.mreq.itr_rloc_ipv4",
3117
15
            FT_IPv4, BASE_NONE, NULL, 0x0, "Originating ITR RLOC Address", HFILL }},
3118
15
        { &hf_lisp_mreq_itr_rloc_ipv6,
3119
15
            { "ITR-RLOC Address", "lisp.mreq.itr_rloc_ipv6",
3120
15
            FT_IPv6, BASE_NONE, NULL, 0x0, "Originating ITR RLOC Address", HFILL }},
3121
15
        { &hf_lisp_mreq_record_res,
3122
15
            { "Reserved", "lisp.mreq.record.res",
3123
15
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3124
15
        { &hf_lisp_mreq_record_prefix_length,
3125
15
            { "Prefix Length", "lisp.mreq.record.prefix.length",
3126
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3127
15
        { &hf_lisp_mreq_record_prefix_afi,
3128
15
            { "Prefix AFI", "lisp.mreq.record.prefix.afi",
3129
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3130
15
        { &hf_lisp_mreq_record_prefix_ipv4,
3131
15
            { "Prefix", "lisp.mreq.record.prefix.ipv4",
3132
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3133
15
        { &hf_lisp_mreq_record_prefix_ipv6,
3134
15
            { "Prefix", "lisp.mreq.record.prefix.ipv6",
3135
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3136
15
        { &hf_lisp_mreq_record_prefix_mac,
3137
15
            { "Prefix", "lisp.mreq.record.prefix.mac",
3138
15
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3139
15
        { &hf_lisp_mreq_record_prefix_dn,
3140
15
            { "Prefix", "lisp.mreq.record.prefix.dn",
3141
15
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3142
15
        { &hf_lisp_mreq_record,
3143
15
            { "Map-Request Record", "lisp.mreq.record",
3144
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3145
15
        { &hf_lisp_mrep_record,
3146
15
            { "Map-Reply Record", "lisp.mrep.record",
3147
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3148
15
        { &hf_lisp_mrep_flags_probe,
3149
15
            { "P bit (Probe)", "lisp.mrep.flags.probe",
3150
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REP_FLAG_P, NULL, HFILL }},
3151
15
        { &hf_lisp_mrep_flags_enlr,
3152
15
            { "E bit (Echo-Nonce locator reachability algorithm enabled)", "lisp.mrep.flags.enlr",
3153
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REP_FLAG_E, NULL, HFILL }},
3154
15
        { &hf_lisp_mrep_flags_sec,
3155
15
            { "S bit (LISP-SEC capable)", "lisp.mrep.flags.sec",
3156
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REP_FLAG_S, NULL, HFILL }},
3157
15
        { &hf_lisp_mrep_res,
3158
15
            { "Reserved bits", "lisp.mrep.res",
3159
15
            FT_UINT24, BASE_HEX, NULL, MAP_REP_RESERVED, "Must be zero", HFILL }},
3160
15
        { &hf_lisp_mreg_flags_pmr,
3161
15
            { "P bit (Proxy-Map-Reply)", "lisp.mreg.flags.pmr",
3162
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REG_FLAG_P, NULL, HFILL }},
3163
15
        { &hf_lisp_mreg_flags_sec,
3164
15
            { "S bit (LISP-SEC capable)", "lisp.mreg.flags.sec",
3165
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REG_FLAG_S, NULL, HFILL }},
3166
15
        { &hf_lisp_mreg_flags_xtrid,
3167
15
            { "I bit (xTR-ID present)", "lisp.mreg.flags.xtrid",
3168
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REG_FLAG_I, NULL, HFILL }},
3169
15
        { &hf_lisp_mreg_flags_rtr,
3170
15
            { "R bit (Built for an RTR)", "lisp.mreg.flags.rtr",
3171
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REG_FLAG_R, NULL, HFILL }},
3172
15
        { &hf_lisp_mreg_flags_wmn,
3173
15
            { "M bit (Want-Map-Notify)", "lisp.mreg.flags.wmn",
3174
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_REG_FLAG_M, NULL, HFILL }},
3175
15
        { &hf_lisp_mreg_res,
3176
15
            { "Reserved bits", "lisp.mreg.res",
3177
15
            FT_UINT24, BASE_HEX, NULL, MAP_REG_RESERVED, "Must be zero", HFILL }},
3178
15
        { &hf_lisp_mref_res,
3179
15
            { "Reserved bits", "lisp.mref.res",
3180
15
            FT_UINT24, BASE_HEX, NULL, MAP_REF_RESERVED, "Must be zero", HFILL }},
3181
15
        { &hf_lisp_keyid,
3182
15
            { "Key ID", "lisp.keyid",
3183
15
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3184
15
        { &hf_lisp_authlen,
3185
15
            { "Authentication Data Length", "lisp.authlen",
3186
15
            FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3187
15
        { &hf_lisp_auth,
3188
15
            { "Authentication Data", "lisp.auth",
3189
15
            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3190
15
        { &hf_lisp_msrtr_keyid,
3191
15
            { "MS-RTR Key ID", "lisp.msrtr.keyid",
3192
15
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3193
15
        { &hf_lisp_msrtr_authlen,
3194
15
            { "MS-RTR Authentication Data Length", "lisp.msrtr.authlen",
3195
15
            FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3196
15
        { &hf_lisp_msrtr_auth,
3197
15
            { "MS-RTR Authentication Data", "lisp.msrtr.auth",
3198
15
            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3199
15
        { &hf_lisp_xtrid,
3200
15
            { "xTR-ID", "lisp.xtrid",
3201
15
            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3202
15
        { &hf_lisp_siteid,
3203
15
            { "Site-ID", "lisp.siteid",
3204
15
            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3205
15
        { &hf_lisp_mnot_flags_xtrid,
3206
15
            { "I bit (xTR-ID present)", "lisp.mnot.flags.xtrid",
3207
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_NOT_FLAG_I, NULL, HFILL }},
3208
15
        { &hf_lisp_mnot_flags_rtr,
3209
15
            { "R bit (Built for an RTR)", "lisp.mnot.flags.rtr",
3210
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), MAP_NOT_FLAG_R, NULL, HFILL }},
3211
15
        { &hf_lisp_mnot_res,
3212
15
            { "Reserved bits", "lisp.mnot.res",
3213
15
            FT_UINT24, BASE_HEX, NULL, MAP_NOT_RESERVED, "Must be zero", HFILL }},
3214
15
        { &hf_lisp_info_r,
3215
15
            { "R bit (Info-Reply)", "lisp.info.r",
3216
15
            FT_BOOLEAN, 24, TFS(&tfs_set_notset), INFO_FLAG_R, NULL, HFILL }},
3217
15
        { &hf_lisp_info_res1,
3218
15
            { "Reserved bits", "lisp.info.res1",
3219
15
            FT_UINT32, BASE_HEX, NULL, INFO_RESERVED, "Must be zero", HFILL }},
3220
15
        { &hf_lisp_info_ttl,
3221
15
            { "TTL", "lisp.info.ttl",
3222
15
            FT_UINT32, BASE_DEC, NULL, 0x0, "RTR information time-to-live", HFILL }},
3223
15
        { &hf_lisp_info_res2,
3224
15
            { "Reserved bits", "lisp.info.res2",
3225
15
            FT_UINT8, BASE_HEX, NULL, 0xFF, "Must be zero", HFILL }},
3226
15
        { &hf_lisp_info_prefix_masklen,
3227
15
            { "EID Prefix Mask Length", "lisp.info.prefix.masklen",
3228
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3229
15
        { &hf_lisp_info_prefix_afi,
3230
15
            { "Prefix AFI", "lisp.info.prefix.afi",
3231
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3232
15
        { &hf_lisp_info_prefix_ipv4,
3233
15
            { "Prefix", "lisp.info.prefix.ipv4",
3234
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3235
15
        { &hf_lisp_info_prefix_ipv6,
3236
15
            { "Prefix", "lisp.info.prefix.ipv6",
3237
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3238
15
        { &hf_lisp_info_afi,
3239
15
            { "AFI", "lisp.info.afi",
3240
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, "Address Family Indicator", HFILL }},
3241
15
        { &hf_lisp_loc,
3242
15
            { "Locator Record", "lisp.loc",
3243
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3244
15
        { &hf_lisp_loc_priority,
3245
15
            { "Priority", "lisp.loc.priority",
3246
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3247
15
        { &hf_lisp_loc_weight,
3248
15
            { "Weight", "lisp.loc.weight",
3249
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3250
15
        { &hf_lisp_loc_mpriority,
3251
15
            { "Multicast Priority", "lisp.loc.multicast_priority",
3252
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3253
15
        { &hf_lisp_loc_mweight,
3254
15
            { "Multicast Weight", "lisp.loc.multicast_weight",
3255
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3256
15
        { &hf_lisp_loc_flags,
3257
15
            { "Flags", "lisp.loc.flags",
3258
15
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3259
15
        { &hf_lisp_loc_flags_local,
3260
15
            { "Local", "lisp.loc.flags.local",
3261
15
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), LOCAL_BIT_MASK, NULL, HFILL }},
3262
15
        { &hf_lisp_loc_flags_probe,
3263
15
            { "Probe", "lisp.loc.flags.probe",
3264
15
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), PROBE_BIT_MASK, NULL, HFILL }},
3265
15
        { &hf_lisp_loc_flags_reach,
3266
15
            { "Reachable", "lisp.loc.flags.reach",
3267
15
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), REACH_BIT_MASK, NULL, HFILL }},
3268
15
        { &hf_lisp_loc_flags_res,
3269
15
            { "Reserved", "lisp.loc.flags.res",
3270
15
            FT_UINT16, BASE_HEX, NULL, 0xFFF8, "Must be zero", HFILL }},
3271
15
        { &hf_lisp_loc_afi,
3272
15
            { "AFI", "lisp.loc.afi",
3273
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3274
15
        { &hf_lisp_loc_locator,
3275
15
            { "Locator", "lisp.loc.locator",
3276
15
            FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3277
15
        { &hf_lisp_mapping,
3278
15
            { "Mapping Record", "lisp.mapping",
3279
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3280
15
        { &hf_lisp_mapping_ttl,
3281
15
            { "Record TTL", "lisp.mapping.ttl",
3282
15
            FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3283
15
        { &hf_lisp_mapping_loccnt,
3284
15
            { "Locator Count", "lisp.mapping.loccnt",
3285
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3286
15
        { &hf_lisp_mapping_eid_masklen,
3287
15
            { "EID Mask Length", "lisp.mapping.eid.masklen",
3288
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3289
15
        { &hf_lisp_mapping_act,
3290
15
            { "Action", "lisp.mapping.act",
3291
15
            FT_UINT16, BASE_DEC, VALS(mapping_actions), 0xE000, NULL, HFILL }},
3292
15
        { &hf_lisp_mapping_auth,
3293
15
            { "Authoritative bit", "lisp.mapping.auth",
3294
15
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), LISP_MAP_AUTH, NULL, HFILL }},
3295
15
        { &hf_lisp_referral_incomplete,
3296
15
            { "Incomplete", "lisp.referral.incomplete",
3297
15
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), REFERRAL_INCOMPLETE, NULL, HFILL }},
3298
15
        { &hf_lisp_mapping_res1,
3299
15
            { "Reserved", "lisp.mapping.res1",
3300
15
            FT_UINT16, BASE_HEX, NULL, 0x07FF, NULL, HFILL }},
3301
15
        { &hf_lisp_mapping_res2,
3302
15
            { "Reserved", "lisp.mapping.res2",
3303
15
            FT_UINT16, BASE_HEX, NULL, 0xF000, NULL, HFILL }},
3304
15
        { &hf_lisp_mapping_ver,
3305
15
            { "Mapping Version", "lisp.mapping.ver",
3306
15
            FT_UINT16, BASE_DEC, NULL, 0x0FFF, NULL, HFILL }},
3307
15
        { &hf_lisp_referral_sigcnt,
3308
15
            { "Signature Count", "lisp.referral.sigcnt",
3309
15
            FT_UINT16, BASE_DEC, NULL, 0xF000, NULL, HFILL }},
3310
15
        { &hf_lisp_mapping_eid_afi,
3311
15
            { "EID Prefix AFI", "lisp.mapping.eid.afi",
3312
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3313
15
        { &hf_lisp_mapping_eid_ipv4,
3314
15
            { "EID Prefix", "lisp.mapping.eid.ipv4",
3315
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3316
15
        { &hf_lisp_mapping_eid_ipv6,
3317
15
            { "EID Prefix", "lisp.mapping.eid.ipv6",
3318
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3319
15
        { &hf_lisp_mapping_eid_mac,
3320
15
            { "EID Prefix", "lisp.mapping.eid.mac",
3321
15
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3322
15
        { &hf_lisp_mapping_eid_dn,
3323
15
            { "EID Prefix", "lisp.mapping.eid.dn",
3324
15
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3325
15
        { &hf_lisp_ecm_flags_sec,
3326
15
            { "S bit (LISP-SEC capable)", "lisp.ecm.flags.sec",
3327
15
            FT_BOOLEAN, 32, TFS(&tfs_set_notset), ECM_FLAG_S, NULL, HFILL }},
3328
15
        { &hf_lisp_ecm_flags_ddt,
3329
15
            { "D bit (DDT-originated)", "lisp.ecm.flags.ddt",
3330
15
            FT_BOOLEAN, 32, TFS(&tfs_set_notset), ECM_FLAG_D, NULL, HFILL }},
3331
15
        { &hf_lisp_ecm_res,
3332
15
            { "Reserved bits", "lisp.ecm.res",
3333
15
            FT_UINT32, BASE_HEX, NULL, 0x03FFFFFF, NULL, HFILL }},
3334
15
        { &hf_lisp_lcaf,
3335
15
            { "LCAF", "lisp.lcaf",
3336
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3337
15
        { &hf_lisp_lcaf_header,
3338
15
            { "LCAF Header", "lisp.lcaf.header",
3339
15
            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3340
15
        { &hf_lisp_lcaf_res1,
3341
15
            { "Reserved bits", "lisp.lcaf.res1",
3342
15
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3343
15
        { &hf_lisp_lcaf_flags,
3344
15
            { "Flags", "lisp.lcaf.flags",
3345
15
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3346
15
        { &hf_lisp_lcaf_type,
3347
15
            { "Type", "lisp.lcaf.type",
3348
15
            FT_UINT8, BASE_DEC, VALS(lcaf_typevals), 0x0, "LISP LCAF Type", HFILL }},
3349
15
        { &hf_lisp_lcaf_res2,
3350
15
            { "Reserved bits", "lisp.lcaf.res2",
3351
15
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3352
15
        { &hf_lisp_lcaf_length,
3353
15
            { "Length", "lisp.lcaf.length",
3354
15
            FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3355
15
        { &hf_lisp_lcaf_afi_list_item,
3356
15
            { "List Item", "lisp.lcaf.afi_list.item",
3357
15
            FT_NONE, BASE_NONE, NULL, 0x0, "AFI List Item", HFILL }},
3358
15
        { &hf_lisp_lcaf_afi_list_afi,
3359
15
            { "List Item AFI", "lisp.lcaf.afi_list.afi",
3360
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3361
15
        { &hf_lisp_lcaf_afi_list_ipv4,
3362
15
            { "List Item Address", "lisp.lcaf.afi_list.ipv4",
3363
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3364
15
        { &hf_lisp_lcaf_afi_list_ipv6,
3365
15
            { "List Item Address", "lisp.lcaf.afi_list.ipv6",
3366
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3367
15
        { &hf_lisp_lcaf_afi_list_mac,
3368
15
            { "List Item Address", "lisp.lcaf.afi_list.mac",
3369
15
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3370
15
        { &hf_lisp_lcaf_afi_list_dn,
3371
15
            { "List Item Address", "lisp.lcaf.afi_list.dn",
3372
15
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3373
15
        { &hf_lisp_lcaf_iid,
3374
15
            { "Instance ID", "lisp.lcaf.iid",
3375
15
            FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3376
15
        { &hf_lisp_lcaf_iid_afi,
3377
15
            { "Address AFI", "lisp.lcaf.iid.afi",
3378
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3379
15
        { &hf_lisp_lcaf_iid_ipv4,
3380
15
            { "Address", "lisp.lcaf.iid.ipv4",
3381
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3382
15
        { &hf_lisp_lcaf_iid_ipv6,
3383
15
            { "Address", "lisp.lcaf.iid.ipv6",
3384
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3385
15
        { &hf_lisp_lcaf_iid_mac,
3386
15
            { "Address", "lisp.lcaf.iid.mac",
3387
15
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3388
15
        { &hf_lisp_lcaf_iid_dn,
3389
15
            { "Address", "lisp.lcaf.iid.dn",
3390
15
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3391
15
        { &hf_lisp_lcaf_asn,
3392
15
            { "AS Number", "lisp.lcaf.asn",
3393
15
            FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3394
15
        { &hf_lisp_lcaf_asn_afi,
3395
15
            { "Address AFI", "lisp.lcaf.asn.afi",
3396
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3397
15
        { &hf_lisp_lcaf_asn_ipv4,
3398
15
            { "Address", "lisp.lcaf.asn.ipv4",
3399
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3400
15
        { &hf_lisp_lcaf_asn_ipv6,
3401
15
            { "Address", "lisp.lcaf.asn.ipv6",
3402
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3403
15
        { &hf_lisp_lcaf_asn_mac,
3404
15
            { "Address", "lisp.lcaf.asn.mac",
3405
15
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3406
15
        { &hf_lisp_lcaf_asn_dn,
3407
15
            { "Address", "lisp.lcaf.asn.dn",
3408
15
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3409
15
        { &hf_lisp_lcaf_geo_lat,
3410
15
            { "Latitude", "lisp.lcaf.geo.lat",
3411
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3412
15
        { &hf_lisp_lcaf_geo_lat_hemisphere,
3413
15
            { "Hemisphere", "lisp.lcaf.geo.lat.hemisphere",
3414
15
            FT_UINT16, BASE_DEC, VALS(lat_typevals), 0x8000, NULL, HFILL }},
3415
15
        { &hf_lisp_lcaf_geo_lat_deg,
3416
15
            { "Degrees", "lisp.lcaf.geo.lat.deg",
3417
15
            FT_UINT16, BASE_DEC, NULL, 0x7FFF, NULL, HFILL }},
3418
15
        { &hf_lisp_lcaf_geo_lat_min,
3419
15
            { "Minutes", "lisp.lcaf.geo.lat.min",
3420
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3421
15
        { &hf_lisp_lcaf_geo_lat_sec,
3422
15
            { "Seconds", "lisp.lcaf.geo.lat.sec",
3423
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3424
15
        { &hf_lisp_lcaf_geo_lon,
3425
15
            { "Longitude", "lisp.lcaf.geo.lon",
3426
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3427
15
        { &hf_lisp_lcaf_geo_lon_hemisphere,
3428
15
            { "Hemisphere", "lisp.lcaf.geo.lon.hemisphere",
3429
15
            FT_UINT16, BASE_DEC, VALS(lon_typevals), 0x8000, NULL, HFILL }},
3430
15
        { &hf_lisp_lcaf_geo_lon_deg,
3431
15
            { "Degrees", "lisp.lcaf.geo.lon.deg",
3432
15
            FT_UINT16, BASE_DEC, NULL, 0x7FFF, NULL, HFILL }},
3433
15
        { &hf_lisp_lcaf_geo_lon_min,
3434
15
            { "Minutes", "lisp.lcaf.geo.lon.min",
3435
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3436
15
        { &hf_lisp_lcaf_geo_lon_sec,
3437
15
            { "Seconds", "lisp.lcaf.geo.lon.sec",
3438
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3439
15
        { &hf_lisp_lcaf_geo_alt,
3440
15
            { "Altitude", "lisp.lcaf.geo.alt",
3441
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3442
15
        { &hf_lisp_lcaf_geo_afi,
3443
15
            { "Address AFI", "lisp.lcaf.geo.afi",
3444
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3445
15
        { &hf_lisp_lcaf_geo_ipv4,
3446
15
            { "Address", "lisp.lcaf.geo.ipv4",
3447
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3448
15
        { &hf_lisp_lcaf_geo_ipv6,
3449
15
            { "Address", "lisp.lcaf.geo.ipv6",
3450
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3451
15
        { &hf_lisp_lcaf_geo_mac,
3452
15
            { "Address", "lisp.lcaf.geo.mac",
3453
15
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3454
15
        { &hf_lisp_lcaf_geo_dn,
3455
15
            { "Address", "lisp.lcaf.geo.dn",
3456
15
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3457
15
        { &hf_lisp_lcaf_nonce_loc_res,
3458
15
            { "Reserved bits", "lisp.lcaf.nonce_loc.res",
3459
15
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3460
15
        { &hf_lisp_lcaf_nonce_loc,
3461
15
            { "Nonce", "lisp.lcaf.nonce_loc",
3462
15
            FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3463
15
        { &hf_lisp_lcaf_nonce_loc_afi,
3464
15
            { "Address AFI", "lisp.lcaf.nonce_loc.afi",
3465
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3466
15
        { &hf_lisp_lcaf_nonce_loc_ipv4,
3467
15
            { "Address", "lisp.lcaf.nonce_loc.ipv4",
3468
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3469
15
        { &hf_lisp_lcaf_nonce_loc_ipv6,
3470
15
            { "Address", "lisp.lcaf.nonce_loc.ipv6",
3471
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3472
15
        { &hf_lisp_lcaf_nonce_loc_mac,
3473
15
            { "Address", "lisp.lcaf.nonce_loc.mac",
3474
15
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3475
15
        { &hf_lisp_lcaf_nonce_loc_dn,
3476
15
            { "Address", "lisp.lcaf.nonce_loc.dn",
3477
15
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3478
15
        { &hf_lisp_lcaf_mcinfo_flags,
3479
15
            { "Multicast Info Flags", "lisp.lcaf.mcinfo.flags",
3480
15
            FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3481
15
        { &hf_lisp_lcaf_mcinfo_flags_res,
3482
15
            { "Reserved", "lisp.lcaf.mcinfo.flags.res",
3483
15
            FT_UINT8, BASE_HEX, NULL, 0xF8, "Must be zero", HFILL }},
3484
15
        { &hf_lisp_lcaf_mcinfo_flags_rp,
3485
15
            { "RP-bit", "lisp.lcaf.mcinfo.flags.rp",
3486
15
            FT_BOOLEAN, 8, TFS(&tfs_set_notset), MCINFO_FLAG_R, NULL, HFILL }},
3487
15
        { &hf_lisp_lcaf_mcinfo_flags_leave,
3488
15
            { "Leave (L-bit)", "lisp.lcaf.mcinfo.flags.leave",
3489
15
            FT_BOOLEAN, 8, TFS(&tfs_set_notset), MCINFO_FLAG_L, NULL, HFILL }},
3490
15
        { &hf_lisp_lcaf_mcinfo_flags_join,
3491
15
            { "Join (J-bit)", "lisp.lcaf_mcinfo.flags.join",
3492
15
            FT_BOOLEAN, 8, TFS(&tfs_set_notset), MCINFO_FLAG_J, NULL, HFILL }},
3493
15
        { &hf_lisp_lcaf_mcinfo_iid,
3494
15
            { "Instance ID", "lisp.lcaf.mcinfo_iid",
3495
15
            FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3496
15
        { &hf_lisp_lcaf_mcinfo_res,
3497
15
            { "Reserved bits", "lisp.lcaf.mcinfo.res",
3498
15
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3499
15
        { &hf_lisp_lcaf_mcinfo_src_masklen,
3500
15
            { "Source Mask Length", "lisp.lcaf.mcinfo.src.masklen",
3501
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3502
15
        { &hf_lisp_lcaf_mcinfo_grp_masklen,
3503
15
            { "Group Mask Length", "lisp.lcaf.mcinfo.grp.masklen",
3504
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3505
15
        { &hf_lisp_lcaf_mcinfo_src,
3506
15
            { "Source/Subnet Address", "lisp.lcaf.mcinfo.src",
3507
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3508
15
        { &hf_lisp_lcaf_mcinfo_src_afi,
3509
15
            { "Source/Subnet AFI", "lisp.lcaf.mcinfo.src.afi",
3510
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3511
15
        { &hf_lisp_lcaf_mcinfo_src_ipv4,
3512
15
            { "Source/Subnet Address", "lisp.lcaf.mcinfo.src.ipv4",
3513
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3514
15
        { &hf_lisp_lcaf_mcinfo_src_ipv6,
3515
15
            { "Source/Subnet Address", "lisp.lcaf.mcinfo.src.ipv6",
3516
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3517
15
        { &hf_lisp_lcaf_mcinfo_grp,
3518
15
            { "Group Address", "lisp.lcaf.mcinfo.grp",
3519
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3520
15
        { &hf_lisp_lcaf_mcinfo_grp_afi,
3521
15
            { "Group AFI", "lisp.lcaf.mcinfo.grp.afi",
3522
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3523
15
        { &hf_lisp_lcaf_mcinfo_grp_ipv4,
3524
15
            { "Group Address", "lisp.lcaf.mcinfo.grp.ipv4",
3525
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3526
15
        { &hf_lisp_lcaf_mcinfo_grp_ipv6,
3527
15
            { "Group Address", "lisp.lcaf.mcinfo.grp.ipv6",
3528
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3529
15
        { &hf_lisp_lcaf_elp_hop,
3530
15
            { "Reencap Hop", "lisp.lcaf.elp_hop",
3531
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3532
15
        { &hf_lisp_lcaf_elp_hop_flags,
3533
15
            { "Flags", "lisp.lcaf.elp_hop.flags",
3534
15
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3535
15
        { &hf_lisp_lcaf_elp_hop_flags_res,
3536
15
            { "Reserved", "lisp.lcaf.elp_hop.flags.res",
3537
15
            FT_UINT16, BASE_HEX, NULL, 0xFFF8, "Must be zero", HFILL }},
3538
15
        { &hf_lisp_lcaf_elp_hop_flags_lookup,
3539
15
            { "Lookup", "lisp.lcaf.elp_hop.flags.local",
3540
15
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), ELP_FLAG_L, NULL, HFILL }},
3541
15
        { &hf_lisp_lcaf_elp_hop_flags_probe,
3542
15
            { "Probe", "lisp.lcaf.elp_hop.flags.probe",
3543
15
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), ELP_FLAG_P, NULL, HFILL }},
3544
15
        { &hf_lisp_lcaf_elp_hop_flags_strict,
3545
15
            { "Strict", "lisp.lcaf_elp_hop.flags.strict",
3546
15
            FT_BOOLEAN, 16, TFS(&tfs_set_notset), ELP_FLAG_S, NULL, HFILL }},
3547
15
        { &hf_lisp_lcaf_elp_hop_afi,
3548
15
            { "Reencap Hop AFI", "lisp.lcaf.elp_hop.afi",
3549
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3550
15
        { &hf_lisp_lcaf_elp_hop_ipv4,
3551
15
            { "Reencap Hop", "lisp.lcaf.elp_hop.ipv4",
3552
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3553
15
        { &hf_lisp_lcaf_elp_hop_ipv6,
3554
15
            { "Reencap Hop", "lisp.lcaf.elp_hop.ipv6",
3555
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3556
15
        { &hf_lisp_lcaf_srcdst_res,
3557
15
            { "Reserved bits", "lisp.lcaf.srcdst.res",
3558
15
            FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3559
15
        { &hf_lisp_lcaf_srcdst_src_masklen,
3560
15
            { "Source Prefix Mask Length", "lisp.lcaf.srcdst.src.masklen",
3561
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3562
15
        { &hf_lisp_lcaf_srcdst_dst_masklen,
3563
15
            { "Destination Prefix Mask Length", "lisp.lcaf.srcdst.dst.masklen",
3564
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3565
15
        { &hf_lisp_lcaf_srcdst_src,
3566
15
            { "Source Prefix", "lisp.lcaf.srcdst.src",
3567
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3568
15
        { &hf_lisp_lcaf_srcdst_src_afi,
3569
15
            { "Source Prefix AFI", "lisp.lcaf.srcdst.src.afi",
3570
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3571
15
        { &hf_lisp_lcaf_srcdst_src_ipv4,
3572
15
            { "Source Prefix", "lisp.lcaf.srcdst.src.ipv4",
3573
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3574
15
        { &hf_lisp_lcaf_srcdst_src_ipv6,
3575
15
            { "Source Prefix", "lisp.lcaf.srcdst.src.ipv6",
3576
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3577
15
        { &hf_lisp_lcaf_srcdst_src_mac,
3578
15
            { "Destination Prefix", "lisp.lcaf.srcdst.src.mac",
3579
15
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3580
15
        { &hf_lisp_lcaf_srcdst_dst,
3581
15
            { "Destination Prefix", "lisp.lcaf.srcdst.dst",
3582
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3583
15
        { &hf_lisp_lcaf_srcdst_dst_afi,
3584
15
            { "Destination Prefix AFI", "lisp.lcaf.srcdst.dst.afi",
3585
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3586
15
        { &hf_lisp_lcaf_srcdst_dst_ipv4,
3587
15
            { "Destination Prefix", "lisp.lcaf.srcdst.dst.ipv4",
3588
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3589
15
        { &hf_lisp_lcaf_srcdst_dst_ipv6,
3590
15
            { "Destination Prefix", "lisp.lcaf.srcdst.dst.ipv6",
3591
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3592
15
        { &hf_lisp_lcaf_srcdst_dst_mac,
3593
15
            { "Destination Prefix", "lisp.lcaf.srcdst.dst.mac",
3594
15
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3595
15
        { &hf_lisp_lcaf_rle_entry,
3596
15
            { "RTR/ETR", "lisp.lcaf.rle_entry",
3597
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3598
15
        { &hf_lisp_lcaf_rle_entry_res,
3599
15
            { "Reserved bits", "lisp.lcaf.rle_entry.res",
3600
15
            FT_UINT24, BASE_HEX, NULL, 0x0, "Must be zero", HFILL }},
3601
15
        { &hf_lisp_lcaf_rle_entry_level,
3602
15
            { "Level Value", "lisp.lcaf.rle_entry.level",
3603
15
            FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3604
15
        { &hf_lisp_lcaf_rle_entry_afi,
3605
15
            { "RTR/ETR AFI", "lisp.lcaf.rle_entry.afi",
3606
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3607
15
        { &hf_lisp_lcaf_rle_entry_ipv4,
3608
15
            { "RTR/ETR", "lisp.lcaf.rle_entry.ipv4",
3609
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3610
15
        { &hf_lisp_lcaf_rle_entry_ipv6,
3611
15
            { "RTR/ETR", "lisp.lcaf.rle_entry.ipv6",
3612
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3613
15
        { &hf_lisp_lcaf_kv_key,
3614
15
            { "Key", "lisp.lcaf.kv_key",
3615
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3616
15
        { &hf_lisp_lcaf_kv_key_afi,
3617
15
            { "Key AFI", "lisp.lcaf.kv_key.afi",
3618
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3619
15
        { &hf_lisp_lcaf_kv_key_ipv4,
3620
15
            { "Key", "lisp.lcaf.kv_key.ipv4",
3621
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3622
15
        { &hf_lisp_lcaf_kv_key_ipv6,
3623
15
            { "Key", "lisp.lcaf.kv_key.ipv6",
3624
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3625
15
        { &hf_lisp_lcaf_kv_key_mac,
3626
15
            { "Key", "lisp.lcaf.kv_key.mac",
3627
15
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3628
15
        { &hf_lisp_lcaf_kv_key_dn,
3629
15
            { "Key", "lisp.lcaf.kv_key.dn",
3630
15
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3631
15
        { &hf_lisp_lcaf_kv_value,
3632
15
            { "Value", "lisp.lcaf.kv_value",
3633
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3634
15
        { &hf_lisp_lcaf_kv_value_afi,
3635
15
            { "Value AFI", "lisp.lcaf.kv_value.afi",
3636
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3637
15
        { &hf_lisp_lcaf_kv_value_ipv4,
3638
15
            { "Value", "lisp.lcaf.kv_value.ipv4",
3639
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3640
15
        { &hf_lisp_lcaf_kv_value_ipv6,
3641
15
            { "Value", "lisp.lcaf.kv_value.ipv6",
3642
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3643
15
        { &hf_lisp_lcaf_kv_value_mac,
3644
15
            { "Value", "lisp.lcaf.kv_value.mac",
3645
15
            FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3646
15
        { &hf_lisp_lcaf_kv_value_dn,
3647
15
            { "Value", "lisp.lcaf.kv_value.dn",
3648
15
            FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3649
15
        { &hf_lisp_lcaf_natt_rloc,
3650
15
            { "RLOC", "lisp.lcaf.natt.rloc",
3651
15
            FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3652
15
        { &hf_lisp_lcaf_natt_rloc_afi,
3653
15
            { "RLOC AFI", "lisp.lcaf.natt.rloc.afi",
3654
15
            FT_UINT16, BASE_DEC, VALS(afn_vals), 0x0, NULL, HFILL }},
3655
15
        { &hf_lisp_lcaf_natt_rloc_ipv4,
3656
15
            { "RLOC", "lisp.lcaf.natt.rloc.ipv4",
3657
15
            FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3658
15
        { &hf_lisp_lcaf_natt_rloc_ipv6,
3659
15
            { "RLOC", "lisp.lcaf.natt.rloc.ipv6",
3660
15
            FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3661
15
        { &hf_lisp_lcaf_natt_msport,
3662
15
            { "MS UDP Port Number", "lisp.lcaf.natt.msport",
3663
15
            FT_UINT16, BASE_PT_UDP, NULL, 0x0, NULL, HFILL }},
3664
15
        { &hf_lisp_lcaf_natt_etrport,
3665
15
            { "ETR UDP Port Number", "lisp.lcaf.natt.etrport",
3666
15
            FT_UINT16, BASE_PT_UDP, NULL, 0x0, NULL, HFILL }},
3667
15
        { &hf_lisp_lcaf_vendor_res,
3668
15
            { "Reserved", "lisp.lcaf.vendor.res",
3669
15
            FT_UINT8, BASE_HEX, NULL, 0x0, "Must be zero", HFILL }},
3670
15
        { &hf_lisp_lcaf_vendor_oui,
3671
15
            { "OUI", "lisp.lcaf.vendor.oui",
3672
15
            FT_UINT24, BASE_HEX, VALS(oui_vals), 0x0, "Organizationally Unique Identifier", HFILL }},
3673
15
        { &hf_lisp_lcaf_vendor_data,
3674
15
            { "Vendor Specific Data", "lisp.lcaf.vendor.data",
3675
15
            FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3676
15
    };
3677
3678
    /* Setup protocol subtree array */
3679
15
    static int *ett[] = {
3680
15
        &ett_lisp,
3681
15
        &ett_lisp_mr,
3682
15
        &ett_lisp_mreq_flags,
3683
15
        &ett_lisp_mapping,
3684
15
        &ett_lisp_itr,
3685
15
        &ett_lisp_record,
3686
15
        &ett_lisp_lcaf,
3687
15
        &ett_lisp_lcaf_header,
3688
15
        &ett_lisp_lcaf_geo_lat,
3689
15
        &ett_lisp_lcaf_geo_lon,
3690
15
        &ett_lisp_lcaf_natt_rloc,
3691
15
        &ett_lisp_lcaf_mcinfo_flags,
3692
15
        &ett_lisp_lcaf_mcinfo_src,
3693
15
        &ett_lisp_lcaf_mcinfo_grp,
3694
15
        &ett_lisp_lcaf_elp_hop,
3695
15
        &ett_lisp_lcaf_elp_hop_flags,
3696
15
        &ett_lisp_lcaf_srcdst_src,
3697
15
        &ett_lisp_lcaf_srcdst_dst,
3698
15
        &ett_lisp_lcaf_rle_entry,
3699
15
        &ett_lisp_lcaf_kv_key,
3700
15
        &ett_lisp_lcaf_kv_value,
3701
15
        &ett_lisp_lcaf_vendor,
3702
15
        &ett_lisp_loc,
3703
15
        &ett_lisp_loc_flags,
3704
15
        &ett_lisp_info_prefix,
3705
15
        &ett_lisp_afi_list
3706
15
    };
3707
3708
15
    static ei_register_info ei[] = {
3709
15
        { &ei_lisp_undecoded, { "lisp.undecoded", PI_UNDECODED, PI_WARN, "Not dissected yet (report to wireshark.org)", EXPFILL }},
3710
15
        { &ei_lisp_unexpected_field, { "lisp.unexpected_field", PI_PROTOCOL, PI_ERROR, "Unexpected field", EXPFILL }},
3711
15
        { &ei_lisp_invalid_field, { "lisp.invalid_field", PI_PROTOCOL, PI_WARN, "Invalid field", EXPFILL }},
3712
15
        { &ei_lisp_expected_field, { "lisp.expected_field", PI_PROTOCOL, PI_ERROR, "Expecting field", EXPFILL }},
3713
15
    };
3714
3715
15
    expert_module_t* expert_lisp;
3716
3717
    /* Register the protocol name and description */
3718
15
    proto_lisp = proto_register_protocol("Locator/ID Separation Protocol",
3719
15
        "LISP Control", "lisp");
3720
3721
    /* Required function calls to register the header fields and subtrees used */
3722
15
    proto_register_field_array(proto_lisp, hf, array_length(hf));
3723
15
    proto_register_subtree_array(ett, array_length(ett));
3724
15
    expert_lisp = expert_register_protocol(proto_lisp);
3725
15
    expert_register_field_array(expert_lisp, ei, array_length(ei));
3726
3727
    /* Register dissector so that other dissectors can call it */
3728
15
    lisp_handle = register_dissector("lisp", dissect_lisp, proto_lisp);
3729
15
}
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
15
{
3740
15
    dissector_add_uint_with_preference("udp.port", LISP_CONTROL_PORT, lisp_handle);
3741
15
    ipv4_handle = find_dissector_add_dependency("ip", proto_lisp);
3742
15
    ipv6_handle = find_dissector_add_dependency("ipv6", proto_lisp);
3743
15
}
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
 */