Coverage Report

Created: 2026-06-30 07:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-ospf.c
Line
Count
Source
1
/* packet-ospf.c
2
 * Routines for OSPF packet disassembly
3
 * (c) Copyright Hannes R. Boehm <hannes@boehm.org>
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 */
11
/*
12
 * At this time, this module is able to analyze OSPF
13
 * packets as specified in RFC2328. MOSPF (RFC1584) and other
14
 * OSPF Extensions which introduce new Packet types
15
 * (e.g the External Attributes LSA) are not supported.
16
 * Furthermore RFC2740 (OSPFv3 - OSPF for IPv6) is now supported
17
 *   - (c) 2001 Palle Lyckegaard <palle[AT]lyckegaard.dk>
18
 *
19
 * Added support to E-NNI routing (OIF2003.259.02)
20
 *   - (c) 2004 Roberto Morro <roberto.morro[AT]tilab.com>
21
 *
22
 * Added support for OSPF restart signaling:
23
 *       draft-nguyen-ospf-lls-05.txt
24
 *       draft-nguyen-ospf-oob-resync-05.txt
25
 *       draft-nguyen-ospf-restart-05.txt
26
 *   - (c) 2005 Michael Rozhavsky <mrozhavsky@fortinet.com>
27
 *
28
 * Added support of MPLS Diffserv-aware TE (RFC 4124); new BC sub-TLV
29
 *   - (c) 2006 (FF) <francesco.fondelli[AT]gmail.com>
30
 *
31
 * Added support for decoding the TLVs in a grace-LSA
32
 *   - (c) 2007 Todd J Martin <todd.martin@acm.org>
33
 *
34
 * Added support for draft-ietf-ospf-manet-or-02
35
 * Added support for draft-ietf-ospf-af-alt-06
36
 *   - (c) 2008 Cisco Systems
37
 *
38
 * Added support for Multi-Topology (MT) Routing (RFC4915)
39
 *   - (c) 2009 Stig Bjorlykke <stig@bjorlykke.org>, Thales Norway AS
40
 *
41
 * Added support for OSPFv2 & OSPFv3 Router Information (RI) Opaque LSA (RFC4970); RI Capabilities TLV
42
 * Added support for OSPFv2 & OSPFv3 Dynamic Hostname TLV in RI Opaque LSA (RFC5642)
43
 *   - (c) 2011 Salil Kanitkar <sskanitk@ncsu.edu>, North Carolina State University
44
 *
45
 * Added support for Type Classification of Experimental and Reserved sub-TLVs (RFC3630)
46
 *   - (c) 2013 Kaushal Shah <kshah3@ncsu.edu>, North Carolina State University
47
 *
48
 * Added support for Authentication Trailer for OSPFv3 (RFC6506)
49
 *   - (c) 2014 Alexis La Goutte (See AUTHORS)
50
 *
51
 * Added support for optical spectrum occupation for fixed grid WDM links (RFC 7688)
52
 * Added support for optical spectrum occupation for flexi grid WDM links (RFC 8363)
53
 *   - (c) 2018 Julien Meuric <julien.meuric@orange.com>
54
 *   - (c) 2018 Khalifa Ndiaye <khalifa.ndiaye@orange.com>
55
 *
56
 * Added support for OSPFv3 Link State Advertisement Extensibility (RFC 8362)
57
 *   - (c) 2024 Jacob Lodge
58
 */
59
60
#include "config.h"
61
62
#include <epan/packet.h>
63
#include <epan/tfs.h>
64
#include <epan/capture_dissectors.h>
65
#include <epan/in_cksum.h>
66
#include <epan/expert.h>
67
#include <epan/addr_resolv.h>
68
#include <epan/unit_strings.h>
69
#include <epan/iana-info.h>
70
71
#include <wsutil/ws_roundup.h>
72
#include <wsutil/ws_padding_to.h>
73
74
#include "packet-rsvp.h"
75
76
void proto_register_ospf(void);
77
void proto_reg_handoff_ospf(void);
78
79
static dissector_handle_t ospf_handle;
80
static capture_dissector_handle_t ospf_cap_handle;
81
82
32.8k
#define OSPF_VERSION_2 2
83
8.80k
#define OSPF_VERSION_3 3
84
167
#define OSPF_AF_4 4
85
9.80k
#define OSPF_AF_6 6
86
2.93k
#define OSPF_VERSION_2_HEADER_LENGTH    24
87
1.90k
#define OSPF_VERSION_3_HEADER_LENGTH    16
88
89
90
28.9k
#define OSPF_HELLO      1
91
910
#define OSPF_DB_DESC    2
92
84
#define OSPF_LS_REQ     3
93
3.92k
#define OSPF_LS_UPD     4
94
9.82k
#define OSPF_LS_ACK     5
95
9.54k
#define OSPF_LS_BASE    OSPF_HELLO
96
97
static const value_string pt_vals[] = {
98
    {OSPF_HELLO,   "Hello Packet"   },
99
    {OSPF_DB_DESC, "DB Description" },
100
    {OSPF_LS_REQ,  "LS Request"     },
101
    {OSPF_LS_UPD,  "LS Update"      },
102
    {OSPF_LS_ACK,  "LS Acknowledge" },
103
    {0,             NULL            }
104
};
105
106
static const value_string ospf_at_authentication_type_vals[] = {
107
    {0, "Reserved" },
108
    {1, "HMAC Cryptographic Authentication" },
109
    {0, NULL }
110
};
111
112
768
#define OSPF_AUTH_NONE          0
113
93
#define OSPF_AUTH_SIMPLE        1
114
205
#define OSPF_AUTH_CRYPT         2
115
116
static const value_string auth_vals[] = {
117
    {OSPF_AUTH_NONE,   "Null"            },
118
    {OSPF_AUTH_SIMPLE, "Simple password" },
119
    {OSPF_AUTH_CRYPT,  "Cryptographic"   },
120
    {0,                NULL              }
121
};
122
123
6.26k
#define OSPF_V2_OPTIONS_MT              0x01
124
14
#define OSPF_V2_OPTIONS_E               0x02
125
14
#define OSPF_V2_OPTIONS_MC              0x04
126
28
#define OSPF_V2_OPTIONS_NP              0x08
127
89
#define OSPF_V2_OPTIONS_L               0x10
128
14
#define OSPF_V2_OPTIONS_DC              0x20
129
14
#define OSPF_V2_OPTIONS_O               0x40
130
14
#define OSPF_V2_OPTIONS_DN              0x80
131
14
#define OSPF_V3_OPTIONS_V6              0x000001
132
14
#define OSPF_V3_OPTIONS_E               0x000002
133
14
#define OSPF_V3_OPTIONS_MC              0x000004
134
14
#define OSPF_V3_OPTIONS_N               0x000008
135
14
#define OSPF_V3_OPTIONS_R               0x000010
136
14
#define OSPF_V3_OPTIONS_DC              0x000020
137
14
#define OSPF_V3_OPTIONS_AF              0x000100
138
346
#define OSPF_V3_OPTIONS_L               0x000200
139
101
#define OSPF_V3_OPTIONS_AT              0x000400
140
141
/* Bitmask definitions for the informational capabilities bits. */
142
14
#define OSPF_RI_OPTIONS_GRC             0x80
143
14
#define OSPF_RI_OPTIONS_GRH             0x40
144
14
#define OSPF_RI_OPTIONS_SRS             0x20
145
14
#define OSPF_RI_OPTIONS_TES             0x10
146
14
#define OSPF_RI_OPTIONS_P2PLAN          0x08
147
14
#define OSPF_RI_OPTIONS_ETE             0x04
148
14
#define OSPF_RI_OPTIONS_HOST            0x01
149
150
14
#define OSPF_LLS_EXT_OPTIONS_LR         0x00000001
151
14
#define OSPF_LLS_EXT_OPTIONS_RS         0x00000002
152
153
14
#define OSPF_V3_LLS_EXT_OPTIONS_LR      0x00000001
154
14
#define OSPF_V3_LLS_EXT_OPTIONS_RS      0x00000002
155
156
14
#define OSPF_V3_LLS_STATE_OPTIONS_R     0x80
157
14
#define OSPF_V3_LLS_STATE_OPTIONS_A     0x40
158
14
#define OSPF_V3_LLS_STATE_OPTIONS_N     0x20
159
14
#define OSPF_V3_LLS_RELAY_OPTIONS_A     0x80
160
14
#define OSPF_V3_LLS_RELAY_OPTIONS_N     0x40
161
162
14
#define OSPF_DBD_FLAG_MS        1
163
14
#define OSPF_DBD_FLAG_M         2
164
14
#define OSPF_DBD_FLAG_I         4
165
14
#define OSPF_DBD_FLAG_R         8
166
167
324
#define OSPF_LS_REQ_LENGTH      12
168
169
23.6k
#define OSPF_LSTYPE_ROUTER      1
170
110
#define OSPF_LSTYPE_NETWORK     2
171
138
#define OSPF_LSTYPE_SUMMARY     3
172
247
#define OSPF_LSTYPE_ASBR        4
173
52
#define OSPF_LSTYPE_ASEXT       5
174
#define OSPF_LSTYPE_GRPMEMBER   6
175
144
#define OSPF_LSTYPE_ASEXT7      7
176
10.7k
#define OSPF_LSTYPE_EXTATTR     8
177
1.66k
#define OSPF_LSTYPE_BASE        OSPF_LSTYPE_ROUTER
178
146
#define OSPF_V3_LSTYPE_ROUTER                1
179
254
#define OSPF_V3_LSTYPE_NETWORK               2
180
271
#define OSPF_V3_LSTYPE_INTER_AREA_PREFIX     3
181
151
#define OSPF_V3_LSTYPE_INTER_AREA_ROUTER     4
182
429
#define OSPF_V3_LSTYPE_AS_EXTERNAL           5
183
#define OSPF_V3_LSTYPE_GROUP_MEMBERSHIP      6
184
141
#define OSPF_V3_LSTYPE_NSSA                  7
185
207
#define OSPF_V3_LSTYPE_LINK                  8
186
98
#define OSPF_V3_LSTYPE_INTRA_AREA_PREFIX     9
187
#define OSPF_V3_LSTYPE_INTRA_AREA_TE        10
188
181
#define OSPF_V3_LSTYPE_GRACE                11
189
580
#define OSPF_V3_LSTYPE_OPAQUE_RI            12
190
#define OSPF_V3_LSTYPE_INTER_AS_TE_V3       13
191
#define OSPF_V3_LSTYPE_OSPF_V3_L1VPN        14
192
#define OSPF_V3_LSTYPE_OSPF_V3_AC           15
193
#define OSPF_V3_LSTYPE_OSPF_V3_DF           16
194
195
/* OSPFv3 E-LSA*/
196
82
#define OSPF_V3_LSTYPE_E_ROUTER            33
197
147
#define OSPF_V3_LSTYPE_E_NETWORK           34
198
#define OSPF_V3_LSTYPE_E_INTER_AREA_PREFIX 35
199
#define OSPF_V3_LSTYPE_E_INTER_AREA_ROUTER 36
200
289
#define OSPF_V3_LSTYPE_E_AS_EXTERNAL       37
201
// Not to be used per RFC 8362             38
202
#define OSPF_V3_LSTYPE_E_TYPE_7            39
203
68
#define OSPF_V3_LSTYPE_E_LINK              40
204
35
#define OSPF_V3_LSTYPE_E_INTRA_AREA_PREFIX 41
205
206
#define OSPF_V3_LSTYPE_SRV6_LOCATOR        42
207
208
/* Opaque LSA types */
209
8.67k
#define OSPF_LSTYPE_OP_BASE      8
210
31.5k
#define OSPF_LSTYPE_OP_LINKLOCAL 9
211
2.56k
#define OSPF_LSTYPE_OP_AREALOCAL 10
212
23.4k
#define OSPF_LSTYPE_OP_ASWIDE    11
213
214
14.7k
#define OSPF_V3_LSA_FUNCTION_CODE_ROUTER            1
215
#define OSPF_V3_LSA_FUNCTION_CODE_NETWORK           2
216
#define OSPF_V3_LSA_FUNCTION_CODE_INTER_AREA_PREFIX 3
217
#define OSPF_V3_LSA_FUNCTION_CODE_INTER_AREA_ROUTER 4
218
#define OSPF_V3_LSA_FUNCTION_CODE_AS_EXTERNAL       5
219
#define OSPF_V3_LSA_FUNCTION_CODE_GROUP_MEMBERSHIP  6
220
#define OSPF_V3_LSA_FUNCTION_CODE_NSSA              7
221
#define OSPF_V3_LSA_FUNCTION_CODE_LINK              8
222
5.61k
#define OSPF_V3_LSA_FUNCTION_CODE_INTRA_AREA_PREFIX 9
223
3.27k
#define OSPF_V3_LSA_FUNCTION_CODE_BASE              OSPF_V3_LSA_FUNCTION_CODE_ROUTER
224
2.47k
#define OSPF_V3_LSA_FUNCTION_CODE_OPAQUE_RI         12
225
1.19k
#define OSPF_V3_LSA_FUNCTION_CODE_OPAQUE_RI_BASE    9
226
227
#define OSPF_LINK_PTP           1
228
#define OSPF_LINK_TRANSIT       2
229
#define OSPF_LINK_STUB          3
230
#define OSPF_LINK_VIRTUAL       4
231
232
#define OSPF_V3_LINK_PTP        1
233
#define OSPF_V3_LINK_TRANSIT    2
234
#define OSPF_V3_LINK_RESERVED   3
235
#define OSPF_V3_LINK_VIRTUAL    4
236
237
27.5k
#define OSPF_LSA_HEADER_LENGTH  20
238
239
42
#define OSPF_DNA_LSA            0x8000
240
/* Opaque Link-State Advertisements (LSA) Option Types
241
 * https://www.iana.org/assignments/ospf-opaque-types/ospf-opaque-types.xhtml */
242
2.56k
#define OSPF_LSA_MPLS_TE        1
243
#define OSPF_LSA_SYCAMORE       2
244
276
#define OSPF_LSA_GRACE          3
245
200
#define OSPF_LSA_OPAQUE_RI      4
246
#define OSPF_LSA_L1VPN          5
247
#define OSPF_LSA_IAS_TE_V2      6
248
483
#define OSPF_LSA_EXT_PREFIX     7
249
1.40k
#define OSPF_LSA_EXT_LINK       8
250
#define OSPF_LSA_TTZ            9
251
#define OSPF_LSA_DYN_FLOODING   10
252
532
#define OSPF_LSA_EXT_IA_ASBR    11
253
#define OSPF_RESTART_REASON_UNKNOWN   0
254
#define OSPF_RESTART_REASON_SWRESTART 1
255
#define OSPF_RESTART_REASON_SWRELOAD  2
256
#define OSPF_RESTART_REASON_SWITCH    3
257
258
static const value_string restart_reason_vals[] = {
259
    {OSPF_RESTART_REASON_UNKNOWN,     "Unknown"                  },
260
    {OSPF_RESTART_REASON_SWRESTART,   "Software Restart"         },
261
    {OSPF_RESTART_REASON_SWRELOAD,    "Software Reload/Upgrade"  },
262
    {OSPF_RESTART_REASON_SWITCH,      "Processor Switchover"     },
263
    {0, NULL}
264
};
265
266
/* grace-LSA TLV Types */
267
3.16k
#define GRACE_TLV_PERIOD 1
268
2.60k
#define GRACE_TLV_REASON 2
269
4.77k
#define GRACE_TLV_IP 3
270
271
static const value_string grace_tlv_type_vals[] = {
272
    {GRACE_TLV_PERIOD,     "Grace-LSA Grace Period"   },
273
    {GRACE_TLV_REASON,     "Grace-LSA Restart Reason" },
274
    {GRACE_TLV_IP,         "Grace-LSA Restart IP"     },
275
    {0,                    NULL                       }
276
};
277
278
/* http://www.iana.org/assignments/ospf-parameters/ospf-parameters.xhtml#ri-tlv */
279
280
/* Opaque-LSA - Router Informational Capabilities: TLV Types*/
281
245
#define OPAQUE_TLV_RI               1
282
#define OPAQUE_TLV_RF               2
283
#define OPAQUE_TLV_TMG_IP4          3
284
#define OPAQUE_TLV_TMG_IP6          4
285
#define OPAQUE_TLV_TNCD             5
286
#define OPAQUE_TLV_PCED             6
287
197
#define OPAQUE_TLV_DH               7
288
274
#define OPAQUE_TLV_SA               8
289
542
#define OPAQUE_TLV_SLR              9
290
#define OPAQUE_TLV_NAT              10
291
#define OPAQUE_TLV_SBD              11
292
285
#define OPAQUE_TLV_NODE_MSD         12
293
#define OPAQUE_TLV_TUNN_ENCAPS      13
294
918
#define OPAQUE_TLV_SRLB             14
295
259
#define OPAQUE_TLV_SRMS_PREF        15
296
395
#define OPAQUE_TLV_FLEX_ALGO_DEF    16
297
#define OPAQUE_TLV_OSPF_AREA_LEADER 17
298
#define OPAQUE_TLV_OSPF_DYN_FLOOD   18
299
#define OPAQUE_TLV_SRV6_CAPS        20
300
#define OPAQUE_TLV_IP_ALGO          21
301
302
/* The Opaque RI LSA TLV types definitions. */
303
static const value_string ri_tlv_type_vals[] = {
304
    {OPAQUE_TLV_RI,                 "Router Informational Capabilities"  },
305
    {OPAQUE_TLV_RF,                 "Router Functional Capabilities"     },
306
    {OPAQUE_TLV_TMG_IP4,            "TE-MESH-GROUP TLV (IPv4)"           },
307
    {OPAQUE_TLV_TMG_IP6,            "TE-MESH-GROUP TLV (IPv6)"           },
308
    {OPAQUE_TLV_TNCD,               "TE Node Capability Descriptor"      },
309
    {OPAQUE_TLV_PCED,               "PCED"                               },
310
    {OPAQUE_TLV_DH,                 "OSPF Dynamic Hostname"              },
311
    {OPAQUE_TLV_SA,                 "SR-Algorithm "                      },
312
    {OPAQUE_TLV_SLR,                "SID/Label Range"                    },
313
    {OPAQUE_TLV_NAT,                "Node Admin Tag "                    },
314
    {OPAQUE_TLV_SBD,                "S-BFD Discriminator"                },
315
    {OPAQUE_TLV_NODE_MSD,           "Node MSD"                           },
316
    {OPAQUE_TLV_TUNN_ENCAPS,        "Tunnel Encapsulations"              },
317
    {OPAQUE_TLV_SRLB,               "SR Local Block"                     },
318
    {OPAQUE_TLV_SRMS_PREF,          "SRMS Preference"                    },
319
    {OPAQUE_TLV_FLEX_ALGO_DEF,      "Flexible Algorithm Definition"      },
320
    {OPAQUE_TLV_OSPF_AREA_LEADER,   "OSPF Area Leader"                   },
321
    {OPAQUE_TLV_OSPF_DYN_FLOOD,     "OSPF Dynamic Flooding"              },
322
    {OPAQUE_TLV_SRV6_CAPS,          "SRv6 Capabilities"                  },
323
    {OPAQUE_TLV_IP_ALGO,            "IP Algorithm"                       },
324
    {0, NULL}
325
};
326
327
static const value_string ri_lsa_sa_tlv_type_vals[] = {
328
    {0,                             "Shortest Path First"                },
329
    {1,                             "Strict Shortest Path First"         },
330
    {0, NULL}
331
};
332
333
/* https://www.iana.org/assignments/ospfv3-parameters/ospfv3-parameters.xhtml#extended-lsa-tlvs */
334
335
/* OSPFv3 Extended-LSA TLVS (RFC 8362)*/
336
#define OSPF6_TLV_RESERVED  0
337
212
#define OSPF6_TLV_ROUTER_LINK  1
338
197
#define OSPF6_TLV_ATTACHED_ROUTERS  2
339
#define OSPF6_TLV_INTER_AREA_PREFIX  3
340
#define OSPF6_TLV_INTER_AREA_ROUTER  4
341
523
#define OSPF6_TLV_EXTERNAL_PREFIX  5
342
210
#define OSPF6_TLV_INTRA_AREA_PREFIX  6
343
194
#define OSPF6_TLV_IPV6_LL_ADDR  7
344
#define OSPF6_TLV_IPV4_LL_ADDR  8
345
346
static const value_string ospf6_extended_lsa_tlv_type_vals[] = {
347
    {OSPF6_TLV_ROUTER_LINK, "Router-Link TLV"},
348
    {OSPF6_TLV_ATTACHED_ROUTERS, "Attached-Routers TLV"},
349
    {OSPF6_TLV_INTER_AREA_PREFIX, "Inter-Area-Prefix TLV"},
350
    {OSPF6_TLV_INTER_AREA_ROUTER, "Inter-Area-Router TLV"},
351
    {OSPF6_TLV_EXTERNAL_PREFIX, "External-Prefix TLV"},
352
    {OSPF6_TLV_INTRA_AREA_PREFIX, "Intra-Area-Prefix TLV"},
353
    {OSPF6_TLV_IPV6_LL_ADDR, "IPv6 Link-Local Address TLV"},
354
    {OSPF6_TLV_IPV4_LL_ADDR, "IPv4 Link-Local Address TLV"},
355
    { 0, NULL }
356
357
};
358
359
/* OSPFv3 Extended-LSA Sub-TLVs  */
360
#define OSPF6_STLV_RESERVED 0
361
#define OSPF6_STLV_IPV6_FWD_ADDR 1
362
#define OSPF6_STLV_IPV4_FWD_ADDR 2
363
364
/* IGP MSD Type (rfc8491) */
365
#define IGP_MSD_TYPE_RESERVED           0
366
#define IGP_MSD_TYPE_MPLS               1
367
#define IGP_MSD_TYPE_SEGMENT_LEFT       41
368
#define IGP_MSD_TYPE_END_POP            42
369
#define IGP_MSD_TYPE_T_INSERT           43
370
#define IGP_MSD_TYPE_T_ENCAP            44
371
#define IGP_MSD_TYPE_END_D              45
372
373
static const value_string ospf_igp_msd_types[] = {
374
    { IGP_MSD_TYPE_RESERVED,            "Reserved" },
375
    { IGP_MSD_TYPE_MPLS,                "Base MPLS Imposition" },
376
    { IGP_MSD_TYPE_SEGMENT_LEFT,        "Maximum Segments Left" },
377
    { IGP_MSD_TYPE_END_POP,             "Maximum End Pop" },
378
    { IGP_MSD_TYPE_T_INSERT,            "Maximum T.Insert" },
379
    { IGP_MSD_TYPE_T_ENCAP,             "Maximum T.Encaps" },
380
    { IGP_MSD_TYPE_END_D,               "Maximum End D" },
381
    { 0, NULL }
382
};
383
384
static const value_string ri_lsa_fad_metric_type_vals[] = {
385
    {0,                             "IGP Metric"                         },
386
    {1,                             "Min Unidirectional Link Delay"      },
387
    {2,                             "Traffic Engineering Metric"         },
388
    {0, NULL}
389
};
390
391
/* Flex Algo Definition Sub-TLV (rfc9350) */
392
370
#define FAD_EXCLUDE_AG              1
393
648
#define FAD_INCLUDE_ANY_AG          2
394
858
#define FAD_INCLUDE_ALL_AG          3
395
315
#define FAD_DEF_FLAGS               4
396
444
#define FAD_EXCLUDE_SRLG            5
397
398
static const value_string ri_lsa_fad_stlv_type_vals[] = {
399
    { FAD_EXCLUDE_AG,       "Flexible Algorithm Exclude Admin Group"},
400
    { FAD_INCLUDE_ANY_AG,   "Flexible Algorithm Include-Any Admin Group"},
401
    { FAD_INCLUDE_ALL_AG,   "Flexible Algorithm Include-All Admin Group"},
402
    { FAD_DEF_FLAGS,        "Flexible Algorithm Definition Flags"},
403
    { FAD_EXCLUDE_SRLG,     "Flexible Algorithm Exclude SRLG"},
404
    { 0, NULL }
405
};
406
407
/* Flex Algo Definition Flags (rfc9350) */
408
14
#define FAD_DEF_FLAGS_M             0x80000000
409
410
/* Flex Algo Prefix Metric Flags (rfc9350) */
411
14
#define FAPM_FLAGS_E                0x80
412
413
static const value_string ls_type_vals[] = {
414
    {OSPF_LSTYPE_ROUTER,                  "Router-LSA"                   },
415
    {OSPF_LSTYPE_NETWORK,                 "Network-LSA"                  },
416
    {OSPF_LSTYPE_SUMMARY,                 "Summary-LSA (IP network)"     },
417
    {OSPF_LSTYPE_ASBR,                    "Summary-LSA (ASBR)"           },
418
    {OSPF_LSTYPE_ASEXT,                   "AS-External-LSA (ASBR)"       },
419
    {OSPF_LSTYPE_GRPMEMBER,               "Group Membership LSA"         },
420
    {OSPF_LSTYPE_ASEXT7,                  "NSSA AS-External-LSA"         },
421
    {OSPF_LSTYPE_EXTATTR,                 "External Attributes LSA"      },
422
    {OSPF_LSTYPE_OP_LINKLOCAL,            "Opaque LSA, Link-local scope" },
423
    {OSPF_LSTYPE_OP_AREALOCAL,            "Opaque LSA, Area-local scope" },
424
    {OSPF_LSTYPE_OP_ASWIDE,               "Opaque LSA, AS-local scope" },
425
    {0,                                   NULL                           }
426
427
};
428
429
static const value_string ls_opaque_type_vals[] = {
430
    {OSPF_LSA_MPLS_TE,      "Traffic Engineering LSA"                   },
431
    {OSPF_LSA_SYCAMORE,     "Sycamore Optical Topology Descriptions"    },
432
    {OSPF_LSA_GRACE,        "Grace-LSA"                                 },
433
    {OSPF_LSA_OPAQUE_RI,    "Router Information (RI)"                   },
434
    {OSPF_LSA_L1VPN,        "L1VPN LSA"                                 },
435
    {OSPF_LSA_IAS_TE_V2,    "Inter-AS-TE-v2 LSA"                        },
436
    {OSPF_LSA_EXT_PREFIX,   "OSPFv2 Extended Prefix Opaque LSA"         },
437
    {OSPF_LSA_EXT_LINK,     "OSPFv2 Extended Link Opaque LSA"           },
438
    {OSPF_LSA_TTZ,          "TTZ LSA"                                   },
439
    {OSPF_LSA_DYN_FLOODING, "OSPFv2 Dynamic Flooding Opaque LSA"        },
440
    {OSPF_LSA_EXT_IA_ASBR,  "OSPFv2 Extended Inter-Area ASBR LSA"       },
441
    {0,                     NULL                                        }
442
};
443
444
static const value_string v3_ls_type_vals[] = {
445
    {OSPF_V3_LSTYPE_ROUTER,               "Router-LSA"                   },
446
    {OSPF_V3_LSTYPE_NETWORK,              "Network-LSA"                  },
447
    {OSPF_V3_LSTYPE_INTER_AREA_PREFIX,    "Inter-Area-Prefix-LSA"        },
448
    {OSPF_V3_LSTYPE_INTER_AREA_ROUTER,    "Inter-Area-Router-LSA"        },
449
    {OSPF_V3_LSTYPE_AS_EXTERNAL,          "AS-External-LSA"              },
450
    {OSPF_V3_LSTYPE_GROUP_MEMBERSHIP,     "Group-Membership-LSA"         },
451
    {OSPF_V3_LSTYPE_NSSA,                 "NSSA-LSA"                     },
452
    {OSPF_V3_LSTYPE_LINK,                 "Link-LSA"                     },
453
    {OSPF_V3_LSTYPE_INTRA_AREA_PREFIX,    "Intra-Area-Prefix-LSA"        },
454
    {OSPF_V3_LSTYPE_INTRA_AREA_TE,        "Intra-Area-TE-LSA"            },
455
    {OSPF_V3_LSTYPE_GRACE,                "GRACE-LSA"                    },
456
    {OSPF_V3_LSTYPE_OPAQUE_RI,            "Router Information Opaque-LSA"},
457
    {OSPF_V3_LSTYPE_INTER_AS_TE_V3,       "Inter-AS-TE-V3 LSA"           },
458
    {OSPF_V3_LSTYPE_OSPF_V3_L1VPN,        "OSPFv3 L1VPN LSA"             },
459
    {OSPF_V3_LSTYPE_OSPF_V3_AC,           "OSPFv3 Autoconfiguration LSA" },
460
    {OSPF_V3_LSTYPE_OSPF_V3_DF,           "OSPFv3 Dynamic Flooding LSA"  },
461
    {OSPF_V3_LSTYPE_E_ROUTER,             "E-Router-LSA"                 },
462
    {OSPF_V3_LSTYPE_E_NETWORK,            "E-Network-LSA"                },
463
    {OSPF_V3_LSTYPE_E_INTER_AREA_PREFIX,  "E-Inter-Area-Prefix-LSA"      },
464
    {OSPF_V3_LSTYPE_E_INTER_AREA_ROUTER,  "E-Inter-Area-Router-LSA"      },
465
    {OSPF_V3_LSTYPE_E_AS_EXTERNAL,        "E-AS-External-LSA"            },
466
    {OSPF_V3_LSTYPE_E_TYPE_7,             "E-Type-7-LSA"                 },
467
    {OSPF_V3_LSTYPE_E_LINK,               "E-Link-LSA"                   },
468
    {OSPF_V3_LSTYPE_E_INTRA_AREA_PREFIX,  "E-Intra-Area-Prefix-LSA"      },
469
    {OSPF_V3_LSTYPE_SRV6_LOCATOR,         "SRv6 Locator LSA"             },
470
    {0,                                   NULL                           }
471
};
472
473
static const value_string v3_ls_type_s12_vals[] = {
474
    {0, "Link-Local Scoping - Flooded only on originating link"          },
475
    {1, "Area Scoping - Flooded only in originating area"                },
476
    {2, "AS Scoping - Flooded throughout AS"                             },
477
    {3, "Reserved"                                                       },
478
    {0, NULL                                                             }
479
};
480
481
static const true_false_string tfs_v3_ls_type_u = {
482
    "Treat the LSA as if it had link-local flooding scope",
483
    "Store and flood the LSA as if the type is understood"
484
};
485
486
static const true_false_string tfs_lsa_external_type = { "Type 2 (metric is larger than any other link state path)",
487
                                                         "Type 1 (metric is specified in the same units as interface cost)" };
488
489
static const value_string ospf_v3_lsa_type_vals[] = {
490
    {OSPF_V3_LINK_PTP, "Point-to-point connection to another router"},
491
    {OSPF_V3_LINK_TRANSIT, "Connection to a transit network"},
492
    {OSPF_LINK_STUB, "Connection to a stub network"},
493
    {OSPF_V3_LINK_VIRTUAL, "Virtual link"},
494
    {0, NULL},
495
};
496
497
static const value_string ospf_v3_lsa_type_short_vals[] = {
498
    {OSPF_V3_LINK_PTP, "PTP"},
499
    {OSPF_V3_LINK_TRANSIT, "Transit"},
500
    {OSPF_LINK_STUB, "Stub"},
501
    {OSPF_V3_LINK_VIRTUAL, "Virtual"},
502
    {0, NULL},
503
};
504
505
static const value_string ospf_v3_lsa_link_id_vals[] = {
506
    {OSPF_V3_LINK_PTP, "Neighboring router's Router ID"},
507
    {OSPF_V3_LINK_TRANSIT, "IP address of Designated Router"},
508
    {OSPF_LINK_STUB, "IP network/subnet number"},
509
    {OSPF_V3_LINK_VIRTUAL, "Neighboring router's Router ID"},
510
    {0, NULL},
511
};
512
513
/* OSPFv3 LLS TLV Types */
514
194
#define LLS_V2_EXT_OPT         1
515
632
#define LLS_V2_CRYPTO_OPT      2
516
194
#define LLS_V2_LI_ID_OPT       18
517
518
static const value_string lls_tlv_type_vals[] = {
519
    {LLS_V2_EXT_OPT,                      "Extended options TLV"         },
520
    {LLS_V2_CRYPTO_OPT,                   "Crypto Authentication TLV"    },
521
    {LLS_V2_LI_ID_OPT,                    "Local Interface ID"           },
522
    {0,                                   NULL                           }
523
};
524
525
/* OSPFv3 LLS TLV Types */
526
500
#define LLS_V3_EXT_OPT       1
527
606
#define LLS_V3_STATE_CHECK   3
528
540
#define LLS_V3_NBR_DROP      4
529
352
#define LLS_V3_RELAYS        7
530
406
#define LLS_V3_WILLING       8
531
518
#define LLS_V3_RQST_FROM     5
532
608
#define LLS_V3_FULL_STATE    6
533
534
static const value_string lls_v3_tlv_type_vals[] = {
535
    {LLS_V3_EXT_OPT,                      "Extended Options TLV"          },
536
    {LLS_V3_STATE_CHECK,                  "State Check Sequence TLV"      },
537
    {LLS_V3_NBR_DROP,                     "Neighbor Drop TLV"             },
538
    {LLS_V3_RELAYS,                       "Active Overlapping Relays TLV" },
539
    {LLS_V3_WILLING,                      "Willingness TLV"               },
540
    {LLS_V3_RQST_FROM,                    "Request From LTV"              },
541
    {LLS_V3_FULL_STATE,                   "Full State For TLV"            },
542
    {0,                                   NULL                            }
543
};
544
545
static const value_string mpls_link_stlv_ltype_str[] = {
546
    {1, "Point-to-point"},
547
    {2, "Multi-access"},
548
    {0, NULL}
549
};
550
551
/* FF: from www.iana.org/assignments/bandwidth-constraints-model-ids */
552
static const range_string mpls_link_stlv_bcmodel_rvals[] = {
553
    { 0,     0, "(Russian Dolls Model - RDM)"                       },
554
    { 1,     1, "(Maximum Allocation Model - MAM)"                  },
555
    { 2,     2, "(Maximum Allocation with Reservation Model - MAR)" },
556
    { 3,   239, "(Unassigned, Specification Required)"              },
557
    { 240, 255, "(Reserved, Private Use)"                           },
558
    { 0,     0, NULL                                                }
559
};
560
561
static const true_false_string tfs_arbitrary_standard = { "Arbitrary", "Standard" };
562
563
14
#define OSPF_V2_ROUTER_LSA_FLAG_B 0x01
564
14
#define OSPF_V2_ROUTER_LSA_FLAG_E 0x02
565
14
#define OSPF_V2_ROUTER_LSA_FLAG_V 0x04
566
14
#define OSPF_V2_ROUTER_LSA_FLAG_W 0x08
567
14
#define OSPF_V2_ROUTER_LSA_FLAG_N 0x10
568
14
#define OSPF_V2_ROUTER_LSA_FLAG_S 0x20
569
14
#define OSPF_V2_ROUTER_LSA_FLAG_H 0x80
570
14
#define OSPF_V3_ROUTER_LSA_FLAG_B 0x01
571
14
#define OSPF_V3_ROUTER_LSA_FLAG_E 0x02
572
14
#define OSPF_V3_ROUTER_LSA_FLAG_V 0x04
573
14
#define OSPF_V3_ROUTER_LSA_FLAG_W 0x08
574
575
14
#define OSPF_V3_PREFIX_OPTION_NU 0x01
576
14
#define OSPF_V3_PREFIX_OPTION_LA 0x02
577
14
#define OSPF_V3_PREFIX_OPTION_MC 0x04
578
14
#define OSPF_V3_PREFIX_OPTION_P  0x08
579
580
173
#define OSPF_V3_AS_EXTERNAL_FLAG_T 0x01
581
238
#define OSPF_V3_AS_EXTERNAL_FLAG_F 0x02
582
14
#define OSPF_V3_AS_EXTERNAL_FLAG_E 0x04
583
584
/* OSPFv2 Extended Prefix LSA TLV types definitions. (RFC7684) */
585
/* OSPF Extended Prefix TLV Registry */
586
3.87k
#define EXT_PREFIX_TLV_PREFIX             1
587
1.37k
#define EXT_PREFIX_TLV_PREFIX_RANGE       2
588
589
#define EXT_PREFIX_TLV_ROUTE_UNSPEC       0
590
#define EXT_PREFIX_TLV_ROUTE_INTRA        1
591
#define EXT_PREFIX_TLV_ROUTE_INTER        3
592
#define EXT_PREFIX_TLV_ROUTE_ASEXT        5
593
#define EXT_PREFIX_TLV_ROUTE_NSSAEXT      7
594
595
#define EXT_PREFIX_TLV_AF_IPV4_UNI        0
596
597
28
#define EXT_PREFIX_TLV_FLAG_A             0x80
598
28
#define EXT_PREFIX_TLV_FLAG_N             0x40
599
14
#define EXT_PREFIX_TLV_FLAG_UNKNOWN       ~(EXT_PREFIX_TLV_FLAG_A | EXT_PREFIX_TLV_FLAG_N)
600
601
28
#define EXT_PREFIX_RANGE_TLV_FLAG_IA      0x80
602
14
#define EXT_PREFIX_RANGE_TLV_FLAG_UNKNOWN ~(EXT_PREFIX_RANGE_TLV_FLAG_IA)
603
604
static const value_string ext_pfx_tlv_type_vals[] = {
605
    {EXT_PREFIX_TLV_PREFIX,               "OSPFv2 Extended Prefix"       },
606
    {EXT_PREFIX_TLV_PREFIX_RANGE,         "OSPFv2 Extended Prefix Range" },
607
    {0, NULL}
608
};
609
static const value_string ext_pfx_tlv_route_vals[] = {
610
    {EXT_PREFIX_TLV_ROUTE_UNSPEC,         "Unspecified"                  },
611
    {EXT_PREFIX_TLV_ROUTE_INTRA,          "Intra-Area"                   },
612
    {EXT_PREFIX_TLV_ROUTE_INTER,          "Inter-Area"                   },
613
    {EXT_PREFIX_TLV_ROUTE_ASEXT,          "AS-External"                  },
614
    {EXT_PREFIX_TLV_ROUTE_NSSAEXT,        "NSSA-External"                },
615
    {0, NULL}
616
};
617
static const value_string ext_pfx_tlv_af_vals[] = {
618
    {EXT_PREFIX_TLV_AF_IPV4_UNI,          "IPv4 Unicast"                 },
619
    {0, NULL}
620
};
621
622
/* OSPF Extended Prefix Sub-TLV Registry */
623
352
#define SR_STLV_SID_LABEL                 1
624
1.13k
#define SR_STLV_PREFIX_SID                2
625
618
#define SR_STLV_FLEX_ALGO_PREFIX_METRIC   3
626
627
28
#define SR_STLV_PFXSID_FLAG_NP            0x40
628
28
#define SR_STLV_PFXSID_FLAG_M             0x20
629
28
#define SR_STLV_PFXSID_FLAG_E             0x10
630
28
#define SR_STLV_PFXSID_FLAG_V             0x08
631
28
#define SR_STLV_PFXSID_FLAG_L             0x04
632
14
#define SR_STLV_PFXSID_FLAG_UNKNOWN       ~(SR_STLV_PFXSID_FLAG_NP | SR_STLV_PFXSID_FLAG_M | SR_STLV_PFXSID_FLAG_E | SR_STLV_PFXSID_FLAG_V | SR_STLV_PFXSID_FLAG_L)
633
634
static const value_string ext_pfx_stlv_type_vals[] = {
635
    {SR_STLV_SID_LABEL,                   "SID/Label"                    },
636
    {SR_STLV_PREFIX_SID,                  "Prefix SID"                   },
637
    {SR_STLV_FLEX_ALGO_PREFIX_METRIC,     "Flexible Algorithm Prefix Metric" },
638
    {0, NULL}
639
};
640
641
/* OSPFv2 Extended Link LSA TLV types definitions. (RFC7684) */
642
/* OSPF Extended Link TLV Registry */
643
1.58k
#define EXT_LINK_TLV_LINK                 1
644
645
static const value_string ext_link_tlv_type_vals[] = {
646
    {EXT_LINK_TLV_LINK,                   "OSPFv2 Extended Link"         },
647
    {0, NULL}
648
};
649
650
/* OSPF Extended Link Sub-TLV Registry */
651
834
#define SR_STLV_ADJSID                    2
652
1.20k
#define SR_STLV_LAN_ADJSID                3
653
495
#define SR_STLV_LINK_MSD                  6
654
#define SR_STLV_GRACEFUL_LINK_SHUTDOWN    7
655
531
#define SR_STLV_REMOTE_IPV4_ADDRESS       8
656
313
#define SR_STLV_LOCAL_REMOTE_INTERFACE_ID 9
657
17.2k
#define SR_STLV_APP_SPEC_LINK_ATTR        10
658
729
#define SR_STLV_SRLG                      11
659
2.13k
#define SR_STLV_UNIDIR_LINK_DELAY         12
660
409k
#define SR_STLV_UNIDIR_LINK_DELAY_MIN_MAX 13
661
19.0k
#define SR_STLV_UNIDIR_DELAY_VARIATION    14
662
478
#define SR_STLV_ADMIN_GROUP               19
663
1.76k
#define SR_STLV_EXT_ADMIN_GROUP           20
664
601
#define SR_STLV_TE_METRIC                 22
665
666
28
#define SR_STLV_ADJSID_FLAG_B             0x80
667
28
#define SR_STLV_ADJSID_FLAG_V             0x40
668
28
#define SR_STLV_ADJSID_FLAG_L             0x20
669
28
#define SR_STLV_ADJSID_FLAG_G             0x10
670
28
#define SR_STLV_ADJSID_FLAG_P             0x08
671
14
#define SR_STLV_ADJSID_FLAG_UNKNOWN       ~(SR_STLV_ADJSID_FLAG_B | SR_STLV_ADJSID_FLAG_V | SR_STLV_ADJSID_FLAG_L | SR_STLV_ADJSID_FLAG_G | SR_STLV_ADJSID_FLAG_P)
672
673
static const value_string ext_link_stlv_type_vals[] = {
674
    {SR_STLV_SID_LABEL,                   "SID/Label"                    },
675
    {SR_STLV_ADJSID,                      "Adj-SID"                      },
676
    {SR_STLV_LAN_ADJSID,                  "LAN Adj-SID"                  },
677
    {SR_STLV_LINK_MSD,                    "Link MSD"                     },
678
    {SR_STLV_GRACEFUL_LINK_SHUTDOWN,      "Graceful Link Shutdown"       },
679
    {SR_STLV_REMOTE_IPV4_ADDRESS,         "Remote IPv4 Address"          },
680
    {SR_STLV_LOCAL_REMOTE_INTERFACE_ID,   "Local/Remote Interface ID"    },
681
    {SR_STLV_APP_SPEC_LINK_ATTR,          "Application-Specific Link Attributes"},
682
    {SR_STLV_SRLG,                        "Shared Risk Link Group"       },
683
    {SR_STLV_UNIDIR_LINK_DELAY,           "Unidirectional Link Delay"    },
684
    {SR_STLV_UNIDIR_LINK_DELAY_MIN_MAX,   "Min/Max Unidirectional Link Delay"},
685
    {SR_STLV_UNIDIR_DELAY_VARIATION,      "Unidirectional Delay Variation"},
686
    {SR_STLV_ADMIN_GROUP,                 "Administrative Group"         },
687
    {SR_STLV_EXT_ADMIN_GROUP,             "Extended Administrative Group"},
688
    {SR_STLV_TE_METRIC,                   "TE Metric"                    },
689
    {0, NULL}
690
};
691
692
/* OSPFv2 Extended Inter-Area ASBR LSA TLV types definitions. (RFC9350) */
693
/* OSPFv2 Extended Inter-Area ASBR TLV Registry */
694
438
#define EXT_IA_ASBR_TLV_EIA_ASBR          1
695
696
static const value_string ext_ia_asbr_tlv_type_vals[] = {
697
    {EXT_IA_ASBR_TLV_EIA_ASBR,            "OSPFv2 Extended Inter-Area ASBR"       },
698
    {0, NULL}
699
};
700
701
/* OSPFv2 Extended Inter-Area ASBR Sub-TLVs Registry */
702
363
#define SR_STLV_FLEX_ALGO_ASBR_METRIC     1
703
704
static const value_string ext_ia_asbr_stlv_type_vals[] = {
705
    {SR_STLV_FLEX_ALGO_ASBR_METRIC,       "Flexible Algorithm ASBR Metric"        },
706
    {0, NULL}
707
};
708
709
static int proto_ospf;
710
711
static int ett_ospf;
712
static int ett_ospf_at;
713
static int ett_ospf_hdr;
714
static int ett_ospf_hello;
715
static int ett_ospf_desc;
716
static int ett_ospf_lsr;
717
static int ett_ospf_lsa;
718
static int ett_ospf_elsa;
719
static int ett_ospf_elsa_pfx_tlv;
720
static int ett_ospf_lsa_router_link;
721
static int ett_ospf_lsa_upd;
722
static int ett_ospf_v2_options;
723
static int ett_ospf_ri_options;
724
static int ett_ospf_v3_options;
725
static int ett_ospf_dbd;
726
static int ett_ospf_lls_data_block;
727
static int ett_ospf_lls_tlv;
728
static int ett_ospf_lls_ext_options;
729
static int ett_ospf_v3_lls_ext_options_tlv;
730
static int ett_ospf_v3_lls_ext_options;
731
static int ett_ospf_v3_lls_state_tlv;
732
static int ett_ospf_v3_lls_state_scs;
733
static int ett_ospf_v3_lls_state_options;
734
static int ett_ospf_v3_lls_drop_tlv;
735
static int ett_ospf_v3_lls_relay_tlv;
736
static int ett_ospf_v3_lls_relay_added;
737
static int ett_ospf_v3_lls_relay_options;
738
static int ett_ospf_v3_lls_willingness_tlv;
739
static int ett_ospf_v3_lls_willingness;
740
static int ett_ospf_v3_lls_rf_tlv;
741
static int ett_ospf_v3_lls_fsf_tlv;
742
static int ett_ospf_v2_router_lsa_flags;
743
static int ett_ospf_v3_router_lsa_flags;
744
static int ett_ospf_v3_as_external_flags;
745
static int ett_ospf_v3_prefix_options;
746
static int ett_ospf_v3_router_interface;
747
static int ett_ospf_v3_router_interface_entry;
748
static int ett_ospf_mpls_pri;
749
static int ett_ospf_mpls_bitmap;
750
751
/* Trees for opaque LSAs */
752
static int ett_ospf_lsa_mpls;
753
static int ett_ospf_lsa_mpls_bandwidth_sstlv;
754
static int ett_ospf_lsa_mpls_base_label;
755
static int ett_ospf_lsa_mpls_router;
756
static int ett_ospf_lsa_mpls_link;
757
static int ett_ospf_lsa_mpls_link_stlv;
758
static int ett_ospf_lsa_mpls_link_stlv_admingrp;
759
static int ett_ospf_lsa_oif_tna;
760
static int ett_ospf_lsa_oif_tna_stlv;
761
static int ett_ospf_lsa_grace_tlv;
762
static int ett_ospf_lsa_opaque_ri;
763
static int ett_ospf_lsa_ri_tlv;
764
static int ett_ospf_lsa_dh_tlv;
765
static int ett_ospf_lsa_sa_tlv;
766
static int ett_ospf_lsa_slr_tlv;
767
static int ett_ospf_lsa_slr_stlv;
768
static int ett_ospf_lsa_srms_tlv;
769
static int ett_ospf_lsa_node_msd_tlv;
770
static int ett_ospf_lsa_fad_tlv;
771
static int ett_ospf_lsa_fad_stlv;
772
static int ett_ospf_lsa_fad_def_flags;
773
static int ett_ospf_lsa_fapm_flags;
774
static int ett_ospf_lsa_elink;
775
static int ett_ospf_lsa_epfx;
776
static int ett_ospf_lsa_elink_tlv;
777
static int ett_ospf_lsa_elink_stlv;
778
static int ett_ospf_lsa_epfx_tlv;
779
static int ett_ospf_lsa_epfx_flags;
780
static int ett_ospf_lsa_epfx_stlv;
781
static int ett_ospf_lsa_epfx_range_flags;
782
static int ett_ospf_lsa_pfxsid_flags;
783
static int ett_ospf_lsa_adjsid_flags;
784
static int ett_ospf_lsa_app_sabm_bits;
785
static int ett_ospf_lsa_app_link_attrs_stlv;
786
static int ett_ospf_lsa_unidir_link_flags;
787
static int ett_ospf_lsa_eia_asbr;
788
static int ett_ospf_lsa_eia_asbr_tlv;
789
static int ett_ospf_lsa_eia_asbr_stlv;
790
static int ett_ospf_lsa_unknown_tlv;
791
792
static int ett_ospf_lsa_type;
793
794
795
/* The Options field in the first TLV of the Opaque RI LSA with type field set to "4" for OSPFv2
796
   and type field set to "12" in OSPFv3, is interpreted as advertizing optional router capabilties.
797
   (RFC4970) */
798
static const true_false_string tfs_v3_as_external_flags_e = {
799
    "Type 2",
800
    "Type 1"
801
};
802
803
/*-----------------------------------------------------------------------
804
 * OSPF Filtering
805
 *-----------------------------------------------------------------------*/
806
807
/* OSPF MSG Type */
808
static int hf_ospf_msg_hello;
809
static int hf_ospf_msg_db_desc;
810
static int hf_ospf_msg_ls_req;
811
static int hf_ospf_msg_ls_upd;
812
static int hf_ospf_msg_ls_ack;
813
814
static int *hf_ospf_msg_type_array[] = {
815
        &hf_ospf_msg_hello,
816
        &hf_ospf_msg_db_desc,
817
        &hf_ospf_msg_ls_req,
818
        &hf_ospf_msg_ls_upd,
819
        &hf_ospf_msg_ls_ack,
820
};
821
822
static int hf_ospf_ls_type;
823
static int hf_ospf_ls_age;
824
static int hf_ospf_ls_donotage;
825
static int hf_ospf_ls_id;
826
static int hf_ospf_ls_seqnum;
827
static int hf_ospf_ls_chksum;
828
static int hf_ospf_ls_length;
829
static int hf_ospf_ls_opaque_type;
830
static int hf_ospf_ls_mpls_te_instance;
831
832
/* OSPF V2 LSA Type  */
833
static int hf_ospf_ls_router;
834
static int hf_ospf_ls_router_linktype;
835
static int hf_ospf_ls_router_linkid;
836
static int hf_ospf_ls_router_linkdata;
837
static int hf_ospf_ls_router_nummetrics;
838
static int hf_ospf_ls_router_metric0;
839
static int hf_ospf_ls_network;
840
static int hf_ospf_ls_network_netmask;
841
static int hf_ospf_ls_network_attachrtr;
842
static int hf_ospf_ls_summary;
843
static int hf_ospf_ls_asbr;
844
static int hf_ospf_ls_asbr_netmask;
845
static int hf_ospf_ls_asext;
846
static int hf_ospf_ls_asext_netmask;
847
static int hf_ospf_ls_asext_fwdaddr;
848
static int hf_ospf_ls_asext_extrtrtag;
849
static int hf_ospf_ls_grpmember;
850
static int hf_ospf_ls_asext7;
851
static int hf_ospf_ls_extattr;
852
static int hf_ospf_ls_opaque;
853
854
static int *hf_ospf_ls_type_array[] = {
855
        &hf_ospf_ls_router,
856
        &hf_ospf_ls_network,
857
        &hf_ospf_ls_summary,
858
        &hf_ospf_ls_asbr,
859
        &hf_ospf_ls_asext,
860
        &hf_ospf_ls_grpmember,
861
        &hf_ospf_ls_asext7,
862
        &hf_ospf_ls_extattr,
863
        &hf_ospf_ls_opaque
864
};
865
866
static int hf_ospf_v3_ls_type;
867
static int hf_ospf_v3_ls_type_u;
868
static int hf_ospf_v3_ls_type_s12;
869
static int hf_ospf_v3_ls_type_fc;
870
871
/* OSPF V3 LSA Type */
872
static int hf_ospf_v3_ls_router;
873
static int hf_ospf_v3_ls_network;
874
static int hf_ospf_v3_ls_inter_area_prefix;
875
static int hf_ospf_v3_ls_inter_area_router;
876
static int hf_ospf_v3_ls_as_external;
877
static int hf_ospf_v3_ls_group_membership;
878
static int hf_ospf_v3_ls_nssa;
879
static int hf_ospf_v3_ls_link;
880
static int hf_ospf_v3_ls_intra_area_prefix;
881
static int hf_ospf_v3_ls_opaque_ri;
882
883
static int hf_ospf_v3_elsa_intra_area_prefix;
884
885
static int *hf_ospf_v3_ls_type_array[] = {
886
        &hf_ospf_v3_ls_router,
887
        &hf_ospf_v3_ls_network,
888
        &hf_ospf_v3_ls_inter_area_prefix,
889
        &hf_ospf_v3_ls_inter_area_router,
890
        &hf_ospf_v3_ls_as_external,
891
        &hf_ospf_v3_ls_group_membership,
892
        &hf_ospf_v3_ls_nssa,
893
        &hf_ospf_v3_ls_link,
894
        &hf_ospf_v3_ls_intra_area_prefix,
895
        &hf_ospf_v3_ls_opaque_ri,
896
        &hf_ospf_v3_elsa_intra_area_prefix
897
};
898
899
static int hf_ospf_adv_router;
900
static int hf_ospf_ls_mpls;
901
static int hf_ospf_ls_mpls_routerid;
902
static int hf_ospf_ls_mpls_linktype;
903
static int hf_ospf_ls_mpls_linkid;
904
static int hf_ospf_ls_mpls_local_addr;
905
static int hf_ospf_ls_mpls_remote_addr;
906
static int hf_ospf_ls_mpls_local_ifid;
907
static int hf_ospf_ls_mpls_remote_ifid;
908
static int hf_ospf_ls_mpls_te_metric;
909
static int hf_ospf_ls_mpls_linkcolor;
910
static int hf_ospf_ls_mpls_group;
911
static int hf_ospf_ls_mpls_link_max_bw;
912
static int hf_ospf_ls_mpls_bc_model_id;
913
static int hf_ospf_ls_oif_local_node_id;
914
static int hf_ospf_ls_oif_remote_node_id;
915
static int hf_ospf_v2_options;
916
static int hf_ospf_v2_options_mt;
917
static int hf_ospf_v2_options_e;
918
static int hf_ospf_v2_options_mc;
919
static int hf_ospf_v2_options_n;
920
static int hf_ospf_v2_options_p;
921
static int hf_ospf_v2_options_l;
922
static int hf_ospf_v2_options_dc;
923
static int hf_ospf_v2_options_o;
924
static int hf_ospf_v2_options_dn;
925
926
static int hf_ospf_tlv_type_opaque;
927
928
static int hf_ospf_ri_options;
929
/* OSPF Router Informational Capabilities Options */
930
static int hf_ospf_ri_options_grc;
931
static int hf_ospf_ri_options_grh;
932
static int hf_ospf_ri_options_srs;
933
static int hf_ospf_ri_options_tes;
934
static int hf_ospf_ri_options_p2plan;
935
static int hf_ospf_ri_options_ete;
936
static int hf_ospf_ri_options_host;
937
938
/* OSPF Extended Link Opaque LSA */
939
static int hf_ospf_ls_elink_tlv;
940
static int hf_ospf_ls_elink_stlv;
941
static int hf_ospf_ls_elink_mt_id;
942
static int hf_ospf_ls_elink_weight;
943
static int hf_ospf_ls_elink_nbr;
944
static int hf_ospf_ls_pfxsid_flags;
945
static int hf_ospf_ls_pfxsid_flag_np;
946
static int hf_ospf_ls_pfxsid_flag_m;
947
static int hf_ospf_ls_pfxsid_flag_e;
948
static int hf_ospf_ls_pfxsid_flag_v;
949
static int hf_ospf_ls_pfxsid_flag_l;
950
static int hf_ospf_ls_pfxsid_flag_unknown;
951
static int hf_ospf_ls_adjsid_flags;
952
static int hf_ospf_ls_adjsid_flag_b;
953
static int hf_ospf_ls_adjsid_flag_v;
954
static int hf_ospf_ls_adjsid_flag_l;
955
static int hf_ospf_ls_adjsid_flag_g;
956
static int hf_ospf_ls_adjsid_flag_p;
957
static int hf_ospf_ls_adjsid_flag_unknown;
958
static int hf_ospf_ls_app_sabm_length;
959
static int hf_ospf_ls_app_udabm_length;
960
static int hf_ospf_ls_app_sabm_bits;
961
static int hf_ospf_ls_app_sabm_bits_r;
962
static int hf_ospf_ls_app_sabm_bits_s;
963
static int hf_ospf_ls_app_sabm_bits_f;
964
static int hf_ospf_ls_app_sabm_bits_x;
965
static int hf_ospf_ls_app_udabm_bits;
966
static int hf_ospf_ls_app_link_attrs_stlv;
967
static int hf_ospf_ls_srlg;
968
static int hf_ospf_ls_admin_group;
969
static int hf_ospf_ls_ext_admin_group;
970
static int hf_ospf_ls_unidir_link_flags;
971
static int hf_ospf_ls_unidir_link_flags_a;
972
static int hf_ospf_ls_unidir_link_flags_reserved;
973
static int hf_ospf_ls_unidir_link_delay;
974
static int hf_ospf_ls_unidir_link_reserved;
975
static int hf_ospf_ls_unidir_link_delay_min;
976
static int hf_ospf_ls_unidir_link_delay_max;
977
static int hf_ospf_ls_unidir_delay_variation;
978
979
/* OSPF Extended Prefix Opaque LSA */
980
static int hf_ospf_ls_epfx_tlv;
981
static int hf_ospf_ls_epfx_stlv;
982
static int hf_ospf_ls_epfx_route_type;
983
static int hf_ospf_ls_epfx_af;
984
static int hf_ospf_ls_epfx_flags;
985
static int hf_ospf_ls_epfx_flag_a;
986
static int hf_ospf_ls_epfx_flag_n;
987
static int hf_ospf_ls_epfx_flag_unknown;
988
static int hf_ospf_ls_epfx_range_flags;
989
static int hf_ospf_ls_epfx_range_flag_ia;
990
static int hf_ospf_ls_epfx_range_flag_unknown;
991
992
/* OSPF Extended Inter-Area ASBR LSA */
993
static int hf_ospf_ls_eia_asbr_tlv;
994
static int hf_ospf_ls_eia_asbr_stlv;
995
static int hf_ospf_ls_eia_asbr_asbr_routerid;
996
static int hf_ospf_ls_faam_reserved;
997
static int hf_ospf_ls_faam_metric;
998
999
/* OSPF Dynamic Hostname support (RFC5642) */
1000
static int hf_ospf_v3_options;
1001
static int hf_ospf_v3_options_v6;
1002
static int hf_ospf_v3_options_e;
1003
static int hf_ospf_v3_options_mc;
1004
static int hf_ospf_v3_options_n;
1005
static int hf_ospf_v3_options_r;
1006
static int hf_ospf_v3_options_dc;
1007
static int hf_ospf_v3_options_af;
1008
static int hf_ospf_v3_options_l;
1009
static int hf_ospf_v3_options_at;
1010
static int hf_ospf_dbd;
1011
static int hf_ospf_dbd_r;
1012
static int hf_ospf_dbd_i;
1013
static int hf_ospf_dbd_m;
1014
static int hf_ospf_dbd_ms;
1015
static int hf_ospf_lls_ext_options;
1016
static int hf_ospf_lls_ext_options_lr;
1017
static int hf_ospf_lls_ext_options_rs;
1018
static int hf_ospf_v2_router_lsa_flag;
1019
static int hf_ospf_v2_router_lsa_flag_b;
1020
static int hf_ospf_v2_router_lsa_flag_e;
1021
static int hf_ospf_v2_router_lsa_flag_v;
1022
static int hf_ospf_v2_router_lsa_flag_w;
1023
static int hf_ospf_v2_router_lsa_flag_n;
1024
static int hf_ospf_v2_router_lsa_flag_s;
1025
static int hf_ospf_v2_router_lsa_flag_h;
1026
static int hf_ospf_v3_router_lsa_flag;
1027
static int hf_ospf_v3_router_lsa_flag_b;
1028
static int hf_ospf_v3_router_lsa_flag_e;
1029
static int hf_ospf_v3_router_lsa_flag_v;
1030
static int hf_ospf_v3_router_lsa_flag_w;
1031
static int hf_ospf_v3_as_external_flag;
1032
static int hf_ospf_v3_as_external_flag_t;
1033
static int hf_ospf_v3_as_external_flag_f;
1034
static int hf_ospf_v3_as_external_flag_e;
1035
static int hf_ospf_v3_prefix_option;
1036
static int hf_ospf_v3_prefix_option_nu;
1037
static int hf_ospf_v3_prefix_option_la;
1038
static int hf_ospf_v3_prefix_option_mc;
1039
static int hf_ospf_v3_prefix_option_p;
1040
static int hf_ospf_dyn_hostname;
1041
static int hf_ospf_lsa_sa;
1042
static int hf_ospf_ls_slr_stlv;
1043
static int hf_ospf_ls_range_size;
1044
static int hf_ospf_ls_sid_label;
1045
static int hf_ospf_ls_preference;
1046
static int hf_ospf_ls_igp_msd_type;
1047
static int hf_ospf_ls_igp_msd_value;
1048
static int hf_ospf_ls_remote_ipv4_addr;
1049
static int hf_ospf_ls_local_interface_id;
1050
static int hf_ospf_ls_remote_interface_id;
1051
static int hf_ospf_ls_flex_algorithm;
1052
static int hf_ospf_ls_fad_metric_type;
1053
static int hf_ospf_ls_fad_calc_type;
1054
static int hf_ospf_ls_fad_priority;
1055
static int hf_ospf_ls_fad_stlv;
1056
static int hf_ospf_ls_fad_def_flags;
1057
static int hf_ospf_ls_fad_def_flags_m;
1058
static int hf_ospf_ls_fapm_flags;
1059
static int hf_ospf_ls_fapm_flags_e;
1060
static int hf_ospf_ls_fapm_metric;
1061
static int hf_ospf_unknown_tlv;
1062
static int hf_ospf_grace_tlv;
1063
static int hf_ospf_grace_period;
1064
static int hf_ospf_grace_reason;
1065
static int hf_ospf_grace_ip;
1066
static int hf_ospf_v3_lls_ext_options_tlv;
1067
static int hf_ospf_v3_lls_ext_options;
1068
static int hf_ospf_v3_lls_ext_options_lr;
1069
static int hf_ospf_v3_lls_ext_options_rs;
1070
static int hf_ospf_v3_lls_state_tlv;
1071
static int hf_ospf_v3_lls_state_scs;
1072
static int hf_ospf_v3_lls_state_options;
1073
static int hf_ospf_v3_lls_state_options_r;
1074
static int hf_ospf_v3_lls_state_options_a;
1075
static int hf_ospf_v3_lls_state_options_n;
1076
static int hf_ospf_v3_lls_drop_tlv;
1077
static int hf_ospf_v3_lls_relay_tlv;
1078
static int hf_ospf_v3_lls_relay_added;
1079
static int hf_ospf_v3_lls_relay_options;
1080
static int hf_ospf_v3_lls_relay_options_a;
1081
static int hf_ospf_v3_lls_relay_options_n;
1082
static int hf_ospf_v3_lls_willingness_tlv;
1083
static int hf_ospf_v3_lls_willingness;
1084
static int hf_ospf_v3_lls_rf_tlv;
1085
static int hf_ospf_v3_lls_fsf_tlv;
1086
1087
static int hf_ospf_header;
1088
static int hf_ospf_header_version;
1089
static int hf_ospf_header_msg_type;
1090
static int hf_ospf_header_packet_length;
1091
static int hf_ospf_header_src_router;
1092
static int hf_ospf_header_area_id;
1093
static int hf_ospf_header_checksum;
1094
static int hf_ospf_tlv_type;
1095
static int hf_ospf_tlv_length;
1096
1097
1098
/* OSPF v3 Extended LSA TLV's RFC 8362*/
1099
static int hf_ospf_v3_e_lsa_tlv_type;
1100
static int hf_ospf_v3_e_lsa_tlv_length;
1101
1102
/* Header OSPF v2 auth + multi-instance */
1103
static int hf_ospf_header_instance_id;
1104
static int hf_ospf_header_auth_type;
1105
static int hf_ospf_header_auth_data_none;
1106
static int hf_ospf_header_auth_data_simple;
1107
static int hf_ospf_header_auth_crypt_key_id;
1108
static int hf_ospf_header_auth_crypt_data_length;
1109
static int hf_ospf_header_auth_crypt_seq_nbr;
1110
static int hf_ospf_header_auth_crypt_data;
1111
static int hf_ospf_header_auth_data_unknown;
1112
1113
/* Header OSPF v3 */
1114
static int hf_ospf_v3_header_instance_id;
1115
static int hf_ospf_header_reserved;
1116
1117
/* Hello */
1118
static int hf_ospf_hello;
1119
static int hf_ospf_hello_network_mask;
1120
static int hf_ospf_hello_interface_id;
1121
static int hf_ospf_hello_hello_interval;
1122
static int hf_ospf_hello_router_priority;
1123
static int hf_ospf_hello_router_dead_interval;
1124
static int hf_ospf_hello_designated_router;
1125
static int hf_ospf_hello_backup_designated_router;
1126
static int hf_ospf_hello_active_neighbor;
1127
1128
/* Authentication Trailer RFC6506 */
1129
static int hf_ospf_at;
1130
static int hf_ospf_at_auth_type;
1131
static int hf_ospf_at_auth_data_len;
1132
static int hf_ospf_at_reserved;
1133
static int hf_ospf_at_sa_id;
1134
static int hf_ospf_at_crypto_seq_nbr;
1135
static int hf_ospf_at_auth_data;
1136
1137
/* Generated from convert_proto_tree_add_text.pl */
1138
static int hf_ospf_referenced_advertising_router;
1139
static int hf_ospf_v3_lsa_referenced_link_state_id;
1140
static int hf_ospf_mpls_protection_capability;
1141
static int hf_ospf_oif_encoding;
1142
static int hf_ospf_ls_id_te_lsa_reserved;
1143
static int hf_ospf_db_interface_mtu;
1144
static int hf_ospf_v3_lls_full_state_for;
1145
static int hf_ospf_v3_lsa_interface_id;
1146
static int hf_ospf_v3_lsa_router_priority;
1147
static int hf_ospf_v3_lsa_forwarding_address_ipv6;
1148
static int hf_ospf_v3_lls_dropped_neighbor;
1149
static int hf_ospf_v3_lsa_external_route_tag;
1150
static int hf_ospf_tna_addr;
1151
static int hf_ospf_v3_lsa_neighbor_router_id;
1152
static int hf_ospf_mpls_switching_type;
1153
static int hf_ospf_oif_tna_addr_length;
1154
static int hf_ospf_oif_tna_addr_ipv4;
1155
static int hf_ospf_link_state_id;
1156
static int hf_ospf_ls_id_opaque_id;
1157
static int hf_ospf_v2_lls_sequence_number;
1158
static int hf_ospf_v3_lsa_do_not_age;
1159
static int hf_ospf_lls_data_length;
1160
static int hf_ospf_mpls_shared_risk_link_group;
1161
static int hf_ospf_db_dd_sequence;
1162
static int hf_ospf_v3_lsa_destination_router_id;
1163
static int hf_ospf_tna_addr_ipv6;
1164
static int hf_ospf_v3_lsa_link_local_interface_address;
1165
static int hf_ospf_mpls_interface_mtu;
1166
static int hf_ospf_v3_lsa_neighbor_interface_id;
1167
static int hf_ospf_lsa_number_of_links;
1168
static int hf_ospf_v2_lls_auth_data;
1169
static int hf_ospf_v2_lls_li_id;
1170
static int hf_ospf_oif_switching_cap;
1171
static int hf_ospf_ls_number_of_lsas;
1172
static int hf_ospf_v3_lls_neighbor;
1173
static int hf_ospf_v3_lls_request_from;
1174
static int hf_ospf_lls_checksum;
1175
static int hf_ospf_v3_lsa_attached_router;
1176
static int hf_ospf_v3_lsa_referenced_ls_type;
1177
static int hf_ospf_mpls_encoding;
1178
static int hf_ospf_mpls_num_labels;
1179
static int hf_ospf_lsa_external_type;
1180
static int hf_ospf_lsa_tos;
1181
static int hf_ospf_lsa_external_tos;
1182
static int hf_ospf_v3_lsa_type;
1183
static int hf_ospf_metric;
1184
static int hf_ospf_prefix_length;
1185
static int hf_ospf_ls_mpls_pri;
1186
static int hf_ospf_ls_mpls_bc;
1187
static int hf_ospf_mpls_action;
1188
static int hf_ospf_mpls_bandwidth_type;
1189
static int hf_ospf_mpls_bitmap;
1190
static int hf_ospf_mpls_grid;
1191
static int hf_ospf_mpls_cs2;
1192
static int hf_ospf_mpls_n;
1193
static int hf_ospf_mpls_cs;
1194
static int hf_ospf_mpls_length;
1195
static int hf_ospf_mpls_minimum_lsp_bandwidth;
1196
static int hf_ospf_mpls_pri;
1197
static int hf_ospf_mpls_sonet_sdh;
1198
static int hf_ospf_mpls_starting;
1199
static int hf_ospf_mpls_no_effective_bits;
1200
static int hf_ospf_mpls_type;
1201
static int hf_ospf_oif_signal_type;
1202
static int hf_ospf_tlv_value;
1203
static int hf_ospf_oif_node_id;
1204
static int hf_ospf_pad_bytes;
1205
static int hf_ospf_ls_metric;
1206
static int hf_ospf_v3_lsa_forwarding_address_ipv4;
1207
static int hf_ospf_link_local_interface_address_ipv4;
1208
static int hf_ospf_v3_lsa_num_prefixes;
1209
static int hf_ospf_v3_address_prefix_ipv6;
1210
static int hf_ospf_v3_address_prefix_ipv4;
1211
1212
static expert_field ei_ospf_header_reserved;
1213
static expert_field ei_ospf_lsa_bad_length;
1214
static expert_field ei_ospf_lsa_constraint_missing;
1215
static expert_field ei_ospf_lsa_bc_error;
1216
static expert_field ei_ospf_lsa_unknown_type;
1217
static expert_field ei_ospf_unknown_link_subtype;
1218
static expert_field ei_ospf_stlv_length_invalid;
1219
1220
static int ospf_msg_type_to_filter (uint8_t msg_type)
1221
9.66k
{
1222
9.66k
    if (msg_type >= OSPF_HELLO &&
1223
9.64k
        msg_type <= OSPF_LS_ACK)
1224
9.54k
        return msg_type - OSPF_LS_BASE;
1225
115
    return -1;
1226
9.66k
}
1227
1228
static int ospf_ls_type_to_filter (uint8_t ls_type)
1229
10.9k
{
1230
10.9k
    if (ls_type >= OSPF_LSTYPE_ROUTER &&
1231
10.7k
        ls_type <= OSPF_LSTYPE_EXTATTR)
1232
1.66k
        return ls_type - OSPF_LSTYPE_BASE;
1233
9.26k
    else if (ls_type >= OSPF_LSTYPE_OP_LINKLOCAL &&
1234
9.04k
             ls_type <= OSPF_LSTYPE_OP_ASWIDE)
1235
8.67k
        return OSPF_LSTYPE_OP_BASE;
1236
590
    else
1237
590
        return -1;
1238
10.9k
}
1239
1240
static int ospf_v3_ls_type_to_filter (uint16_t ls_type)
1241
5.74k
{
1242
5.74k
    uint16_t function_code;
1243
1244
5.74k
    function_code = ls_type & 0x1fff;
1245
5.74k
    if (function_code >= OSPF_V3_LSA_FUNCTION_CODE_ROUTER &&
1246
5.61k
        function_code <= OSPF_V3_LSA_FUNCTION_CODE_INTRA_AREA_PREFIX)
1247
3.27k
        return function_code - OSPF_V3_LSA_FUNCTION_CODE_BASE;
1248
2.47k
    else if (function_code == OSPF_V3_LSA_FUNCTION_CODE_OPAQUE_RI)
1249
1.19k
        return OSPF_V3_LSA_FUNCTION_CODE_OPAQUE_RI_BASE;
1250
1.27k
    else
1251
1.27k
        return -1;
1252
5.74k
}
1253
1254
static int * const bf_dbd[] = {
1255
    &hf_ospf_dbd_r,
1256
    &hf_ospf_dbd_i,
1257
    &hf_ospf_dbd_m,
1258
    &hf_ospf_dbd_ms,
1259
    NULL
1260
};
1261
static int * const bf_lls_ext_options[] = {
1262
    &hf_ospf_lls_ext_options_rs,
1263
    &hf_ospf_lls_ext_options_lr,
1264
    NULL
1265
};
1266
static int * const bf_v3_lls_ext_options[] = {
1267
    &hf_ospf_v3_lls_ext_options_lr,
1268
    &hf_ospf_v3_lls_ext_options_rs,
1269
    NULL
1270
};
1271
1272
static int * const bf_v3_lls_state_options[] = {
1273
    &hf_ospf_v3_lls_state_options_r,
1274
    &hf_ospf_v3_lls_state_options_a,
1275
    &hf_ospf_v3_lls_state_options_n,
1276
    NULL
1277
};
1278
static int * const bf_v3_lls_relay_options[] = {
1279
    &hf_ospf_v3_lls_relay_options_a,
1280
    &hf_ospf_v3_lls_relay_options_n,
1281
    NULL
1282
};
1283
static int * const bf_v2_router_lsa_flags[] = {
1284
    &hf_ospf_v2_router_lsa_flag_h,
1285
    &hf_ospf_v2_router_lsa_flag_s,
1286
    &hf_ospf_v2_router_lsa_flag_n,
1287
    &hf_ospf_v2_router_lsa_flag_w,
1288
    &hf_ospf_v2_router_lsa_flag_v,
1289
    &hf_ospf_v2_router_lsa_flag_e,
1290
    &hf_ospf_v2_router_lsa_flag_b,
1291
    NULL
1292
};
1293
static int * const bf_v3_router_lsa_flags[] = {
1294
    &hf_ospf_v3_router_lsa_flag_w,
1295
    &hf_ospf_v3_router_lsa_flag_v,
1296
    &hf_ospf_v3_router_lsa_flag_e,
1297
    &hf_ospf_v3_router_lsa_flag_b,
1298
    NULL
1299
};
1300
static int * const bf_v3_as_external_flags[] = {
1301
    &hf_ospf_v3_as_external_flag_e,
1302
    &hf_ospf_v3_as_external_flag_f,
1303
    &hf_ospf_v3_as_external_flag_t,
1304
    NULL
1305
};
1306
static int * const bf_v2_options[] = {
1307
    &hf_ospf_v2_options_dn,
1308
    &hf_ospf_v2_options_o,
1309
    &hf_ospf_v2_options_dc,
1310
    &hf_ospf_v2_options_l,
1311
    &hf_ospf_v2_options_n,
1312
    &hf_ospf_v2_options_mc,
1313
    &hf_ospf_v2_options_e,
1314
    &hf_ospf_v2_options_mt,
1315
    NULL
1316
};
1317
static int * const bf_v2_options_lsa7[] = {
1318
    &hf_ospf_v2_options_dn,
1319
    &hf_ospf_v2_options_o,
1320
    &hf_ospf_v2_options_dc,
1321
    &hf_ospf_v2_options_l,
1322
    &hf_ospf_v2_options_p,
1323
    &hf_ospf_v2_options_mc,
1324
    &hf_ospf_v2_options_e,
1325
    &hf_ospf_v2_options_mt,
1326
    NULL
1327
};
1328
/* Structures for handling the bitfield of the Options field of Optional Router Capabilities LSA (RFC4970). */
1329
static int * const bf_ri_options[] = {
1330
    &hf_ospf_ri_options_grc,
1331
    &hf_ospf_ri_options_grh,
1332
    &hf_ospf_ri_options_srs,
1333
    &hf_ospf_ri_options_tes,
1334
    &hf_ospf_ri_options_p2plan,
1335
    &hf_ospf_ri_options_ete,
1336
    &hf_ospf_ri_options_host,
1337
    NULL
1338
};
1339
static int * const bf_v3_options[] = {
1340
    &hf_ospf_v3_options_at,
1341
    &hf_ospf_v3_options_l,
1342
    &hf_ospf_v3_options_af,
1343
    &hf_ospf_v3_options_dc,
1344
    &hf_ospf_v3_options_r,
1345
    &hf_ospf_v3_options_n,
1346
    &hf_ospf_v3_options_mc,
1347
    &hf_ospf_v3_options_e,
1348
    &hf_ospf_v3_options_v6,
1349
    NULL
1350
};
1351
static int * const bf_v3_prefix_options[] = {
1352
    &hf_ospf_v3_prefix_option_p,
1353
    &hf_ospf_v3_prefix_option_mc,
1354
    &hf_ospf_v3_prefix_option_la,
1355
    &hf_ospf_v3_prefix_option_nu,
1356
    NULL
1357
};
1358
static int * const bf_ospf_epfx_flags[] = {
1359
    &hf_ospf_ls_epfx_flag_a,
1360
    &hf_ospf_ls_epfx_flag_n,
1361
    &hf_ospf_ls_epfx_flag_unknown,
1362
    NULL
1363
};
1364
static int * const bf_ospf_epfx_range_flags[] = {
1365
    &hf_ospf_ls_epfx_range_flag_ia,
1366
    &hf_ospf_ls_epfx_range_flag_unknown,
1367
    NULL
1368
};
1369
static int * const bf_ospf_pfxsid_flags[] = {
1370
    &hf_ospf_ls_pfxsid_flag_np,
1371
    &hf_ospf_ls_pfxsid_flag_m,
1372
    &hf_ospf_ls_pfxsid_flag_e,
1373
    &hf_ospf_ls_pfxsid_flag_v,
1374
    &hf_ospf_ls_pfxsid_flag_l,
1375
    &hf_ospf_ls_pfxsid_flag_unknown,
1376
    NULL
1377
};
1378
static int * const bf_ospf_adjsid_flags[] = {
1379
    &hf_ospf_ls_adjsid_flag_b,
1380
    &hf_ospf_ls_adjsid_flag_v,
1381
    &hf_ospf_ls_adjsid_flag_l,
1382
    &hf_ospf_ls_adjsid_flag_g,
1383
    &hf_ospf_ls_adjsid_flag_p,
1384
    &hf_ospf_ls_adjsid_flag_unknown,
1385
    NULL
1386
};
1387
static int * const bf_ospf_app_sabm_bits[] = {
1388
    &hf_ospf_ls_app_sabm_bits_r,
1389
    &hf_ospf_ls_app_sabm_bits_s,
1390
    &hf_ospf_ls_app_sabm_bits_f,
1391
    &hf_ospf_ls_app_sabm_bits_x,
1392
    NULL,
1393
};
1394
static int * const unidir_link_flags[] = {
1395
    &hf_ospf_ls_unidir_link_flags_a,
1396
    &hf_ospf_ls_unidir_link_flags_reserved,
1397
    NULL,
1398
};
1399
static int * const bf_ospf_fad_def_flags[] = {
1400
    &hf_ospf_ls_fad_def_flags_m,
1401
    NULL,
1402
};
1403
static int * const bf_ospf_fapm_flags[] = {
1404
    &hf_ospf_ls_fapm_flags_e,
1405
    NULL,
1406
};
1407
1408
static void dissect_ospf_hello(tvbuff_t*, int, proto_tree*, uint8_t, uint16_t);
1409
static void dissect_ospf_db_desc(tvbuff_t*, packet_info*, int, proto_tree*, uint8_t, uint16_t, uint8_t);
1410
static void dissect_ospf_ls_req(tvbuff_t*, packet_info*, int, proto_tree*, uint8_t, uint16_t);
1411
static void dissect_ospf_ls_upd(tvbuff_t*, packet_info*, int, proto_tree*, uint8_t, uint16_t, uint8_t);
1412
static void dissect_ospf_ls_ack(tvbuff_t*, packet_info*, int, proto_tree*, uint8_t, uint16_t, uint8_t);
1413
static int dissect_ospf_authentication_trailer(tvbuff_t*, int, proto_tree*);
1414
static void dissect_ospf_lls_data_block(tvbuff_t*, packet_info*, int, proto_tree*, uint8_t);
1415
1416
/* dissect_ospf_v[23]lsa returns the offset of the next LSA
1417
 * if disassemble_body is set to false (e.g. in LSA ACK
1418
 * packets), the offset is set to the offset of the next
1419
 * LSA header
1420
 */
1421
static int dissect_ospf_v2_lsa(tvbuff_t*, packet_info*, int, proto_tree*, bool disassemble_body);
1422
static int dissect_ospf_v3_lsa(tvbuff_t*, packet_info*, int, proto_tree*, bool disassemble_body,
1423
                               uint8_t);
1424
1425
static void dissect_ospf_v3_address_prefix(tvbuff_t *, packet_info *, int, int, proto_tree *, uint8_t);
1426
1427
static int
1428
ospf_has_lls_block(tvbuff_t *tvb, int offset, uint8_t packet_type, uint8_t version)
1429
492
{
1430
492
    uint8_t flags;
1431
492
    uint32_t v3flags;
1432
1433
    /* LLS block can be found only in HELLO and DBDESC packets */
1434
492
    switch (packet_type) {
1435
19
    case OSPF_HELLO:
1436
19
        switch (version) {
1437
7
        case OSPF_VERSION_2:
1438
7
            flags = tvb_get_uint8 (tvb, offset + 6);
1439
7
            return flags & OSPF_V2_OPTIONS_L;
1440
12
        case OSPF_VERSION_3:
1441
12
            v3flags = tvb_get_ntohl(tvb, offset + 5);
1442
12
            v3flags = v3flags >> 8;
1443
12
            return v3flags & OSPF_V3_OPTIONS_L;
1444
19
        }
1445
0
        break;
1446
388
    case OSPF_DB_DESC:
1447
388
        switch (version) {
1448
68
        case OSPF_VERSION_2:
1449
68
            flags = tvb_get_uint8 (tvb, offset + 2);
1450
68
            return flags & OSPF_V2_OPTIONS_L;
1451
320
        case OSPF_VERSION_3:
1452
320
            v3flags = tvb_get_ntohl(tvb, offset + 1);
1453
320
            v3flags = v3flags >> 8;
1454
320
            return v3flags & OSPF_V3_OPTIONS_L;
1455
388
        }
1456
0
        break;
1457
492
    }
1458
1459
85
    return 0;
1460
492
}
1461
1462
static int
1463
ospf_has_at_block(tvbuff_t *tvb, int offset, uint8_t packet_type, uint8_t version)
1464
182
{
1465
182
    uint32_t v3flags;
1466
1467
    /* AT (Authentication Trailer) block can be found in OSPFv3 HELLO and DD packets */
1468
182
    switch (packet_type) {
1469
12
    case OSPF_HELLO:
1470
12
        switch (version) {
1471
10
        case OSPF_VERSION_3:
1472
10
            v3flags = tvb_get_ntohl(tvb, offset + 5);
1473
10
            v3flags = v3flags >> 8;
1474
10
            return v3flags & OSPF_V3_OPTIONS_AT;
1475
12
        }
1476
2
        break;
1477
85
    case OSPF_DB_DESC:
1478
85
        switch (version) {
1479
77
        case OSPF_VERSION_3:
1480
77
            v3flags = tvb_get_ntohl(tvb, offset + 1);
1481
77
            v3flags = v3flags >> 8;
1482
77
            return v3flags & OSPF_V3_OPTIONS_AT;
1483
85
        }
1484
8
        break;
1485
182
    }
1486
1487
95
    return 0;
1488
182
}
1489
1490
static bool
1491
capture_ospf(const unsigned char *pd _U_, int offset _U_, int len _U_, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_)
1492
0
{
1493
0
    capture_dissector_increment_count(cpinfo, proto_ospf);
1494
0
    return true;
1495
0
}
1496
1497
static int
1498
dissect_ospf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
1499
4.91k
{
1500
4.91k
    proto_tree *ospf_tree = NULL;
1501
4.91k
    proto_item *ti, *ti_sum, *hidden_item;
1502
4.91k
    proto_tree *ospf_header_tree;
1503
4.91k
    uint8_t version;
1504
4.91k
    uint8_t packet_type;
1505
4.91k
    uint16_t ospflen;
1506
4.91k
    vec_t cksum_vec[4];
1507
4.91k
    int cksum_vec_len;
1508
4.91k
    uint32_t phdr[2];
1509
4.91k
    uint16_t cksum, computed_cksum;
1510
4.91k
    unsigned length, reported_length;
1511
4.91k
    uint8_t auth_type;
1512
4.91k
    int crypto_len = 0;
1513
4.91k
    unsigned int ospf_header_length;
1514
4.91k
    uint8_t instance_id;
1515
4.91k
    uint32_t areaid;
1516
4.91k
    uint8_t address_family = OSPF_AF_6;
1517
1518
4.91k
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "OSPF");
1519
4.91k
    col_clear(pinfo->cinfo, COL_INFO);
1520
1521
4.91k
    version = tvb_get_uint8(tvb, 0);
1522
4.91k
    switch (version) {
1523
2.93k
    case OSPF_VERSION_2:
1524
2.93k
        ospf_header_length = OSPF_VERSION_2_HEADER_LENGTH;
1525
2.93k
        break;
1526
1.90k
    case OSPF_VERSION_3:
1527
1.90k
        ospf_header_length = OSPF_VERSION_3_HEADER_LENGTH;
1528
1.90k
        break;
1529
79
    default:
1530
79
        ospf_header_length = 14;
1531
79
        break;
1532
4.91k
    }
1533
1534
4.91k
    packet_type = tvb_get_uint8(tvb, 1);
1535
4.91k
    col_add_str(pinfo->cinfo, COL_INFO,
1536
4.91k
                val_to_str(pinfo->pool, packet_type, pt_vals, "Unknown (%u)"));
1537
1538
4.91k
    ospflen = tvb_get_ntohs(tvb, 2);
1539
1540
4.91k
    ti = proto_tree_add_item(tree, proto_ospf, tvb, 0, -1, ENC_NA);
1541
4.91k
    ospf_tree = proto_item_add_subtree(ti, ett_ospf);
1542
1543
1544
4.91k
    ti = proto_tree_add_item(ospf_tree, hf_ospf_header, tvb, 0, ospf_header_length, ENC_NA);
1545
4.91k
    ospf_header_tree = proto_item_add_subtree(ti, ett_ospf_hdr);
1546
1547
4.91k
    proto_tree_add_item(ospf_header_tree, hf_ospf_header_version, tvb, 0, 1, ENC_BIG_ENDIAN);
1548
4.91k
    proto_tree_add_item(ospf_header_tree, hf_ospf_header_msg_type, tvb, 1, 1, ENC_BIG_ENDIAN);
1549
1550
4.91k
    if (ospf_msg_type_to_filter(packet_type) != -1) {
1551
4.77k
        hidden_item = proto_tree_add_item(ospf_header_tree,
1552
4.77k
                                          *hf_ospf_msg_type_array[ospf_msg_type_to_filter(packet_type)],
1553
4.77k
                                          tvb, 1, 1, ENC_BIG_ENDIAN);
1554
4.77k
        proto_item_set_hidden(hidden_item);
1555
4.77k
    }
1556
4.91k
    proto_tree_add_item(ospf_header_tree, hf_ospf_header_packet_length, tvb, 2, 2, ENC_BIG_ENDIAN);
1557
4.91k
    proto_tree_add_item(ospf_header_tree, hf_ospf_header_src_router, tvb, 4, 4, ENC_BIG_ENDIAN);
1558
1559
1560
4.91k
    ti = proto_tree_add_item_ret_ipv4(ospf_header_tree, hf_ospf_header_area_id, tvb, 8, 4, ENC_BIG_ENDIAN, &areaid);
1561
4.91k
    if(areaid == 0){
1562
262
        proto_item_append_text(ti, " (Backbone)");
1563
262
    }
1564
1565
4.91k
    ti_sum = proto_tree_add_item_ret_uint16(ospf_header_tree, hf_ospf_header_checksum, tvb, 12, 2, ENC_BIG_ENDIAN, &cksum);
1566
4.91k
    if(cksum == 0){
1567
774
        proto_item_append_text(ti_sum, " (None)");
1568
774
    }
1569
1570
    /* Quit at this point if it's an unknown OSPF version. */
1571
4.91k
    if(version != OSPF_VERSION_2 && version != OSPF_VERSION_3) {
1572
20
        return 12;
1573
20
    }
1574
1575
4.89k
    length = tvb_captured_length(tvb);
1576
    /* XXX - include only the length from the OSPF header? */
1577
4.89k
    reported_length = tvb_reported_length(tvb);
1578
4.89k
    if (cksum !=0 && !pinfo->fragmented && length >= reported_length
1579
4.02k
               && length >= ospf_header_length) {
1580
        /* The packet isn't part of a fragmented datagram and isn't
1581
           truncated, so we can checksum it. */
1582
1583
3.98k
        switch (version) {
1584
1585
2.47k
        case OSPF_VERSION_2:
1586
            /* Header, not including the authentication data (the OSPFv2
1587
               checksum excludes the 64-bit authentication field). */
1588
2.47k
            SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, 16);
1589
2.47k
            if (length > ospf_header_length) {
1590
                /* Rest of the packet, again not including the
1591
                   authentication data. */
1592
2.45k
                reported_length -= ospf_header_length;
1593
2.45k
                SET_CKSUM_VEC_TVB(cksum_vec[1], tvb, ospf_header_length, reported_length);
1594
2.45k
                cksum_vec_len = 2;
1595
2.45k
            } else {
1596
                /* There's nothing but a header. */
1597
21
                cksum_vec_len = 1;
1598
21
            }
1599
2.47k
            break;
1600
1601
1.51k
        case OSPF_VERSION_3:
1602
            /* IPv6-style checksum, covering the entire OSPF packet
1603
               and a prepended IPv6 pseudo-header. */
1604
1605
            /* Set up the fields of the pseudo-header. */
1606
1.51k
            SET_CKSUM_VEC_PTR(cksum_vec[0], (const uint8_t *)pinfo->src.data, pinfo->src.len);
1607
1.51k
            SET_CKSUM_VEC_PTR(cksum_vec[1], (const uint8_t *)pinfo->dst.data, pinfo->dst.len);
1608
1.51k
            phdr[0] = g_htonl(ospflen);
1609
1.51k
            phdr[1] = g_htonl(IP_PROTO_OSPFIGP);
1610
1.51k
            SET_CKSUM_VEC_PTR(cksum_vec[2], (const uint8_t *)&phdr, 8);
1611
1.51k
            SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, reported_length);
1612
1.51k
            cksum_vec_len = 4;
1613
1.51k
            break;
1614
1615
0
        default:
1616
0
            DISSECTOR_ASSERT_NOT_REACHED();
1617
0
            break;
1618
3.98k
        }
1619
3.98k
        computed_cksum = in_cksum(cksum_vec, cksum_vec_len);
1620
        /*
1621
         * in_cksum() should never return 0xFFFF here, because, to quote
1622
         * RFC 1624 section 3 "Discussion":
1623
         *
1624
         *     In one's complement, there are two representations of
1625
         *     zero: the all zero and the all one bit values, often
1626
         *     referred to as +0 and -0.  One's complement addition
1627
         *     of non-zero inputs can produce -0 as a result, but
1628
         *     never +0.  Since there is guaranteed to be at least
1629
         *     one non-zero field in the IP header, and the checksum
1630
         *     field in the protocol header is the complement of the
1631
         *     sum, the checksum field can never contain ~(+0), which
1632
         *     is -0 (0xFFFF).  It can, however, contain ~(-0), which
1633
         *     is +0 (0x0000).
1634
         *
1635
         * RFC 1624 is discussing the checksum of the *IPv4* header,
1636
         * where the "version" field is 4, ensuring that, in a valid
1637
         * IPv4 header, there is at least one non-zero field, but it
1638
         * also applies to an OSPF packet, because, for OSPFv2, the
1639
         * header includes a version field with the value 2 and, for
1640
         * OSPFv3, the pseudo-header includes the non-zero IP protocol
1641
         * number for OSPF, so at least one field in the checksummed
1642
         * data is non-zero.
1643
         *
1644
         * in_cksum() returns the negation of the one's-complement
1645
         * sum of all the data handed to it, and that data won't be
1646
         * all zero, so the sum won't be 0 (+0), and thus the negation
1647
         * won't be -0, i.e. won't be 0xFFFF.
1648
         */
1649
3.98k
        if (computed_cksum == 0) {
1650
4
            proto_item_append_text(ti_sum, " [correct]");
1651
3.97k
        } else {
1652
3.97k
            proto_item_append_text(ti_sum, " [incorrect, should be 0x%04x]", in_cksum_shouldbe(cksum, computed_cksum));
1653
3.97k
        }
1654
3.98k
    }
1655
1656
4.89k
    switch (version) {
1657
1658
2.90k
    case OSPF_VERSION_2:
1659
        /* Authentication and multi-instance is only valid for OSPFv2 */
1660
2.90k
        proto_tree_add_item(ospf_header_tree, hf_ospf_header_instance_id, tvb, 14, 1, ENC_BIG_ENDIAN);
1661
2.90k
        proto_tree_add_item_ret_uint8(ospf_header_tree, hf_ospf_header_auth_type, tvb, 15, 1, ENC_BIG_ENDIAN, &auth_type);
1662
2.90k
        switch (auth_type) {
1663
768
        case OSPF_AUTH_NONE:
1664
768
            proto_tree_add_item(ospf_header_tree, hf_ospf_header_auth_data_none, tvb, 16, 8, ENC_NA);
1665
768
            break;
1666
1667
93
        case OSPF_AUTH_SIMPLE:
1668
93
            proto_tree_add_item(ospf_header_tree, hf_ospf_header_auth_data_simple, tvb, 16, 8, ENC_ASCII);
1669
93
            break;
1670
1671
205
        case OSPF_AUTH_CRYPT:
1672
205
            proto_tree_add_item(ospf_header_tree, hf_ospf_header_auth_crypt_key_id, tvb, 18, 1, ENC_BIG_ENDIAN);
1673
1674
205
            proto_tree_add_item(ospf_header_tree, hf_ospf_header_auth_crypt_data_length, tvb, 19, 1, ENC_BIG_ENDIAN);
1675
205
            crypto_len = tvb_get_uint8(tvb, 19);
1676
1677
205
            proto_tree_add_item(ospf_header_tree, hf_ospf_header_auth_crypt_seq_nbr, tvb, 20, 4, ENC_BIG_ENDIAN);
1678
               /* Show the message digest that was appended to the end of the
1679
               OSPF message - but only if it's present (we don't want
1680
               to get an exception before we've tried dissecting OSPF
1681
               message). */
1682
205
            if (tvb_bytes_exist(tvb, ospflen, crypto_len)) {
1683
117
                proto_tree_add_item(ospf_header_tree, hf_ospf_header_auth_crypt_data, tvb, ospflen, crypto_len, ENC_NA);
1684
117
                proto_tree_set_appendix(ospf_header_tree, tvb, ospflen, crypto_len);
1685
117
            }
1686
205
            break;
1687
1688
1.82k
        default:
1689
1.82k
            proto_tree_add_item(ospf_header_tree, hf_ospf_header_auth_data_unknown, tvb, 16, 8, ENC_NA);
1690
1.82k
            break;
1691
2.90k
        }
1692
2.88k
        break;
1693
1694
2.88k
    case OSPF_VERSION_3:
1695
        /* Instance ID and "reserved" is OSPFv3-only */
1696
1.89k
        proto_tree_add_item_ret_uint8(ospf_header_tree, hf_ospf_v3_header_instance_id, tvb, 14, 1, ENC_BIG_ENDIAN, &instance_id);
1697
        /* By default set address_family to OSPF_AF_6 */
1698
1.89k
        address_family = OSPF_AF_6;
1699
1.89k
        if(instance_id > 65 && instance_id < 128) {
1700
167
            address_family = OSPF_AF_4;
1701
167
        }
1702
1703
1.89k
        ti = proto_tree_add_item(ospf_header_tree, hf_ospf_header_reserved, tvb, 15, 1, ENC_NA);
1704
1.89k
        if(tvb_get_uint8(tvb, 15)){
1705
1.26k
            expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
1706
1.26k
        }
1707
1.89k
        break;
1708
1709
0
    default:
1710
0
        DISSECTOR_ASSERT_NOT_REACHED();
1711
0
        break;
1712
4.89k
    }
1713
1714
4.75k
    switch (packet_type){
1715
1716
71
    case OSPF_HELLO:
1717
71
        dissect_ospf_hello(tvb, ospf_header_length, ospf_tree, version,
1718
71
                           (uint16_t)(ospflen - ospf_header_length));
1719
71
        break;
1720
1721
437
    case OSPF_DB_DESC:
1722
437
        dissect_ospf_db_desc(tvb, pinfo, (int)ospf_header_length, ospf_tree, version,
1723
437
                             (uint16_t)(ospflen - ospf_header_length),
1724
437
                                 address_family);
1725
437
        break;
1726
1727
84
    case OSPF_LS_REQ:
1728
84
        dissect_ospf_ls_req(tvb, pinfo, (int)ospf_header_length, ospf_tree, version,
1729
84
                            (uint16_t)(ospflen - ospf_header_length));
1730
84
        break;
1731
1732
3.92k
    case OSPF_LS_UPD:
1733
3.92k
        dissect_ospf_ls_upd(tvb, pinfo, (int)ospf_header_length, ospf_tree, version,
1734
3.92k
                            (uint16_t)(ospflen - ospf_header_length),
1735
3.92k
                            address_family);
1736
3.92k
        break;
1737
1738
184
    case OSPF_LS_ACK:
1739
184
        dissect_ospf_ls_ack(tvb, pinfo, (int)ospf_header_length, ospf_tree, version,
1740
184
                            (uint16_t)(ospflen - ospf_header_length),
1741
184
                            address_family);
1742
184
        break;
1743
1744
52
    default:
1745
52
        call_data_dissector(tvb_new_subset_remaining(tvb, ospf_header_length), pinfo, tree);
1746
52
        break;
1747
4.75k
    }
1748
1749
    /* take care of the LLS data block */
1750
492
    if (ospf_has_lls_block(tvb, ospf_header_length, packet_type, version)) {
1751
373
        dissect_ospf_lls_data_block(tvb, pinfo, ospflen + crypto_len, ospf_tree,
1752
373
                                    version);
1753
373
    }
1754
1755
    /* take care of the AT (Authentication Trailer) data block */
1756
492
    if (ospf_has_at_block(tvb, ospf_header_length, packet_type, version)) {
1757
72
        dissect_ospf_authentication_trailer(tvb, ospflen + crypto_len, ospf_tree);
1758
72
    }
1759
1760
492
    return tvb_captured_length(tvb);
1761
4.75k
}
1762
1763
static int
1764
dissect_ospfv2_lls_tlv(tvbuff_t *tvb, int offset, proto_tree *tree)
1765
1.24k
{
1766
1.24k
    proto_tree *ospf_lls_tlv_tree;
1767
1.24k
    uint16_t type;
1768
1.24k
    uint16_t length;
1769
1770
1.24k
    type = tvb_get_ntohs(tvb, offset);
1771
1.24k
    length = tvb_get_ntohs(tvb, offset + 2);
1772
1773
1.24k
    ospf_lls_tlv_tree = proto_tree_add_subtree(tree, tvb, offset, length + 4, ett_ospf_lls_tlv,
1774
1.24k
                             NULL, val_to_str_const(type, lls_tlv_type_vals, "Unknown LLS TLV"));
1775
1776
1.24k
    proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_tlv_type, tvb, offset, 2, ENC_BIG_ENDIAN);
1777
1.24k
    proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
1778
1779
1.24k
    switch(type) {
1780
194
    case LLS_V2_EXT_OPT:
1781
194
        proto_tree_add_bitmask(ospf_lls_tlv_tree, tvb, offset + 4, hf_ospf_lls_ext_options, ett_ospf_lls_ext_options, bf_lls_ext_options, ENC_BIG_ENDIAN);
1782
194
        break;
1783
632
    case LLS_V2_CRYPTO_OPT:
1784
632
        proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_v2_lls_sequence_number, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
1785
632
        proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_v2_lls_auth_data, tvb, offset + 8, length - 4, ENC_NA);
1786
632
        break;
1787
194
    case LLS_V2_LI_ID_OPT:
1788
194
        proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_v2_lls_li_id, tvb, offset + 4, 4, ENC_NA);
1789
1.24k
    }
1790
1791
1.19k
    return offset + length + 4;
1792
1.24k
}
1793
1794
static int
1795
dissect_ospfv3_lls_tlv(tvbuff_t *tvb, int offset, proto_tree *tree)
1796
2.39k
{
1797
2.39k
    proto_item *ti = NULL;
1798
2.39k
    proto_tree *ospf_lls_tlv_tree = NULL;
1799
2.39k
    uint16_t type;
1800
2.39k
    uint16_t length;
1801
2.39k
    uint8_t relays_added;
1802
2.39k
    int orig_offset;
1803
1804
2.39k
    type = tvb_get_ntohs(tvb, offset);
1805
2.39k
    length = tvb_get_ntohs(tvb, offset + 2);
1806
1807
2.39k
    switch(type) {
1808
250
    case LLS_V3_EXT_OPT:
1809
250
        ti = proto_tree_add_item(tree, hf_ospf_v3_lls_ext_options_tlv, tvb,
1810
250
                                 offset, length + 4, ENC_NA);
1811
250
       break;
1812
303
    case LLS_V3_STATE_CHECK:
1813
303
        ti = proto_tree_add_item(tree, hf_ospf_v3_lls_state_tlv, tvb,
1814
303
                                 offset, length + 4, ENC_NA);
1815
303
        break;
1816
270
    case LLS_V3_NBR_DROP:
1817
270
        ti = proto_tree_add_item(tree, hf_ospf_v3_lls_drop_tlv, tvb,
1818
270
                                 offset, length + 4, ENC_NA);
1819
270
        break;
1820
176
    case LLS_V3_RELAYS:
1821
176
        ti = proto_tree_add_item(tree, hf_ospf_v3_lls_relay_tlv, tvb,
1822
176
                                 offset, length + 4, ENC_NA);
1823
176
        break;
1824
203
    case LLS_V3_WILLING:
1825
203
        ti = proto_tree_add_item(tree, hf_ospf_v3_lls_willingness_tlv, tvb,
1826
203
                                 offset, length + 4, ENC_NA);
1827
203
        break;
1828
259
    case LLS_V3_RQST_FROM:
1829
259
         ti = proto_tree_add_item(tree, hf_ospf_v3_lls_rf_tlv, tvb,
1830
259
                                  offset, length + 4, ENC_NA);
1831
259
         break;
1832
304
    case LLS_V3_FULL_STATE:
1833
304
        ti = proto_tree_add_item(tree, hf_ospf_v3_lls_fsf_tlv, tvb,
1834
304
                                 offset, length + 4, ENC_NA);
1835
304
        break;
1836
507
    default:
1837
507
        ospf_lls_tlv_tree = proto_tree_add_subtree_format(tree, tvb, offset, length + 4, ett_ospf_lls_tlv, NULL,
1838
507
                                 "%s", val_to_str_const(type, lls_v3_tlv_type_vals, "Unknown LLS TLV"));
1839
2.39k
    }
1840
1841
2.27k
    if (ti != NULL)
1842
1.76k
        ospf_lls_tlv_tree = proto_item_add_subtree(ti, ett_ospf_lls_tlv);
1843
2.27k
    proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_tlv_type, tvb, offset, 2, ENC_BIG_ENDIAN);
1844
2.27k
    proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
1845
1846
2.27k
    orig_offset = offset;
1847
1848
2.27k
    switch (type) {
1849
250
    case LLS_V3_EXT_OPT:
1850
250
        proto_tree_add_bitmask(ospf_lls_tlv_tree, tvb, offset + 4, hf_ospf_v3_lls_ext_options, ett_ospf_v3_lls_ext_options, bf_v3_lls_ext_options, ENC_BIG_ENDIAN);
1851
250
        break;
1852
303
    case LLS_V3_STATE_CHECK:
1853
303
        proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_v3_lls_state_scs,
1854
303
                            tvb, offset+4, 2, ENC_BIG_ENDIAN);
1855
303
        proto_tree_add_bitmask(ospf_lls_tlv_tree, tvb, offset + 6, hf_ospf_v3_lls_state_options, ett_ospf_v3_lls_state_options, bf_v3_lls_state_options, ENC_BIG_ENDIAN);
1856
303
        break;
1857
270
    case LLS_V3_NBR_DROP:
1858
270
        offset += 4;
1859
562
        while (orig_offset + length >= offset) {
1860
292
            proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_v3_lls_dropped_neighbor, tvb, offset, 4, ENC_BIG_ENDIAN);
1861
292
            offset += 4;
1862
292
        }
1863
270
        offset = orig_offset;
1864
270
        break;
1865
176
    case LLS_V3_RELAYS:
1866
176
        relays_added = tvb_get_uint8(tvb, offset+4);
1867
176
        proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_v3_lls_relay_added,
1868
176
                            tvb, offset+4, 1, ENC_BIG_ENDIAN);
1869
176
        proto_tree_add_bitmask(ospf_lls_tlv_tree, tvb, offset + 5, hf_ospf_v3_lls_relay_options, ett_ospf_v3_lls_relay_options, bf_v3_lls_relay_options, ENC_BIG_ENDIAN);
1870
176
        offset += 8;
1871
482
        while (orig_offset + length >= offset) {
1872
306
            ti = proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_v3_lls_neighbor, tvb, offset, 4, ENC_BIG_ENDIAN);
1873
306
            if (relays_added > 0) {
1874
204
                proto_item_append_text(ti, " Added");
1875
204
            } else {
1876
102
                proto_item_append_text(ti, " Deleted");
1877
102
            }
1878
1879
306
            relays_added--;
1880
306
            offset += 4;
1881
306
        }
1882
176
        break;
1883
203
    case LLS_V3_WILLING:
1884
203
        proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_v3_lls_willingness,
1885
203
                            tvb, offset+4, 1, ENC_BIG_ENDIAN);
1886
1887
203
        break;
1888
259
    case LLS_V3_RQST_FROM:
1889
259
        offset += 4;
1890
497
        while (orig_offset + length >= offset) {
1891
238
            proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_v3_lls_request_from, tvb, offset, 4, ENC_BIG_ENDIAN);
1892
238
            offset += 4;
1893
238
        }
1894
259
        offset = orig_offset;
1895
259
        break;
1896
304
    case LLS_V3_FULL_STATE:
1897
304
           offset += 4;
1898
612
        while (orig_offset + length >= offset) {
1899
308
            proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_v3_lls_full_state_for, tvb, offset, 4, ENC_BIG_ENDIAN);
1900
308
            offset += 4;
1901
308
        }
1902
304
        offset = orig_offset;
1903
304
        break;
1904
2.27k
    }
1905
1906
2.15k
    return offset + length + 4;
1907
2.27k
}
1908
1909
1910
static void
1911
dissect_ospf_lls_data_block(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
1912
                            uint8_t version)
1913
373
{
1914
373
    proto_tree *ospf_lls_data_block_tree;
1915
373
    int ospf_lls_len;
1916
373
    int orig_offset = offset;
1917
373
    unsigned length_remaining;
1918
1919
373
    length_remaining = tvb_reported_length_remaining(tvb, offset);
1920
373
    if (length_remaining < 4) {
1921
25
        proto_tree_add_expert_format(tree, pinfo, &ei_ospf_lsa_bad_length,
1922
25
            tvb, offset, length_remaining, "LLS option bit set but data block missing");
1923
25
        return;
1924
25
    }
1925
1926
348
    ospf_lls_len = tvb_get_ntohs(tvb, offset + 2) * 4;
1927
348
    ospf_lls_data_block_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_ospf_lls_data_block, NULL, "OSPF LLS Data Block");
1928
1929
    /* TODO: verify checksum */
1930
348
    proto_tree_add_checksum(ospf_lls_data_block_tree, tvb, offset, hf_ospf_lls_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
1931
348
    proto_tree_add_uint(ospf_lls_data_block_tree, hf_ospf_lls_data_length, tvb, offset + 2, 2, ospf_lls_len);
1932
1933
348
    offset += 4;
1934
348
    DISSECTOR_ASSERT((version == OSPF_VERSION_2) || (version == OSPF_VERSION_3));
1935
3.98k
    while (orig_offset + ospf_lls_len > offset) {
1936
3.64k
        if (version == OSPF_VERSION_2)
1937
1.24k
            offset = dissect_ospfv2_lls_tlv (tvb, offset, ospf_lls_data_block_tree);
1938
2.39k
        else
1939
2.39k
            offset = dissect_ospfv3_lls_tlv (tvb, offset, ospf_lls_data_block_tree);
1940
3.64k
    }
1941
348
}
1942
1943
static int
1944
dissect_ospf_authentication_trailer(tvbuff_t *tvb, int offset, proto_tree *tree)
1945
72
{
1946
72
    proto_tree *ospf_at_tree;
1947
72
    proto_item *ti;
1948
72
    uint32_t auth_data_len;
1949
1950
72
    ti = proto_tree_add_item(tree, hf_ospf_at, tvb, offset, -1, ENC_NA);
1951
72
    ospf_at_tree = proto_item_add_subtree(ti, ett_ospf_at);
1952
1953
72
    proto_tree_add_item(ospf_at_tree, hf_ospf_at_auth_type, tvb, offset, 2, ENC_BIG_ENDIAN);
1954
72
    offset += 2;
1955
1956
72
    proto_tree_add_item_ret_uint(ospf_at_tree, hf_ospf_at_auth_data_len, tvb, offset, 2, ENC_BIG_ENDIAN, &auth_data_len);
1957
72
    offset += 2;
1958
72
    if (auth_data_len < (2 + 2 + 2 + 8)) {
1959
        /* XXX - report an error here */
1960
8
        proto_item_set_len(ti, 4);
1961
8
        return offset;
1962
8
    }
1963
64
    proto_item_set_len(ti, auth_data_len);
1964
1965
64
    proto_tree_add_item(ospf_at_tree, hf_ospf_at_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
1966
64
    offset += 2;
1967
1968
64
    proto_tree_add_item(ospf_at_tree, hf_ospf_at_sa_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1969
64
    offset += 2;
1970
1971
64
    proto_tree_add_item(ospf_at_tree, hf_ospf_at_crypto_seq_nbr, tvb, offset, 8, ENC_BIG_ENDIAN);
1972
64
    offset += 8;
1973
1974
    /* Add Check of Data ? */
1975
64
    proto_tree_add_item(ospf_at_tree, hf_ospf_at_auth_data, tvb, offset, auth_data_len - ( 2 + 2 + 2 + 2 + 8), ENC_NA);
1976
64
    offset = auth_data_len;
1977
1978
64
    return offset;
1979
72
}
1980
1981
static void
1982
dissect_ospf_hello(tvbuff_t *tvb, int offset, proto_tree *tree, uint8_t version,
1983
                   uint16_t length)
1984
71
{
1985
71
    proto_tree *ospf_hello_tree;
1986
71
    proto_item *ti;
1987
71
    int orig_offset = offset;
1988
1989
71
    ti = proto_tree_add_item(tree, hf_ospf_hello, tvb, offset, length, ENC_NA);
1990
71
    ospf_hello_tree = proto_item_add_subtree(ti, ett_ospf_hello);
1991
1992
71
    switch (version) {
1993
17
    case OSPF_VERSION_2:
1994
17
        proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_network_mask, tvb, offset, 4, ENC_BIG_ENDIAN);
1995
17
        proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_hello_interval, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
1996
17
        proto_tree_add_bitmask(ospf_hello_tree, tvb, offset + 6, hf_ospf_v2_options, ett_ospf_v2_options, bf_v2_options, ENC_BIG_ENDIAN);
1997
17
        proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_router_priority, tvb, offset + 7, 1, ENC_BIG_ENDIAN);
1998
17
        proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_router_dead_interval, tvb, offset + 8, 4, ENC_BIG_ENDIAN);
1999
17
        proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_designated_router, tvb, offset + 12, 4, ENC_BIG_ENDIAN);
2000
17
        proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_backup_designated_router, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
2001
17
        offset += 20;
2002
2003
509
        while (orig_offset + length > offset) {
2004
492
            proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_active_neighbor, tvb, offset, 4, ENC_BIG_ENDIAN);
2005
492
            offset += 4;
2006
492
        }
2007
17
        break;
2008
38
    case OSPF_VERSION_3:
2009
38
        proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_interface_id, tvb, offset, 4, ENC_BIG_ENDIAN);
2010
38
        proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_router_priority, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
2011
38
        proto_tree_add_bitmask(ospf_hello_tree, tvb, offset + 5, hf_ospf_v3_options, ett_ospf_v3_options, bf_v3_options, ENC_BIG_ENDIAN);
2012
38
        proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_hello_interval, tvb, offset + 8, 2, ENC_BIG_ENDIAN);
2013
38
        proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_router_dead_interval, tvb, offset + 10, 2, ENC_BIG_ENDIAN);
2014
38
        proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_designated_router, tvb, offset + 12, 4, ENC_BIG_ENDIAN);
2015
38
        proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_backup_designated_router, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
2016
38
        offset += 20;
2017
2018
452
        while (orig_offset + length > offset) {
2019
414
            proto_tree_add_item(ospf_hello_tree, hf_ospf_hello_active_neighbor, tvb, offset, 4, ENC_BIG_ENDIAN);
2020
414
            offset += 4;
2021
414
        }
2022
38
        break;
2023
71
    }
2024
71
}
2025
2026
static void
2027
dissect_ospf_db_desc(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
2028
                     uint8_t version, uint16_t length, uint8_t address_family)
2029
437
{
2030
437
    proto_tree *ospf_db_desc_tree;
2031
437
    proto_item *ti;
2032
437
    uint8_t reserved;
2033
437
    int orig_offset = offset;
2034
2035
437
    if (tree) {
2036
437
        ospf_db_desc_tree = proto_tree_add_subtree(tree, tvb, offset, length, ett_ospf_desc, NULL, "OSPF DB Description");
2037
2038
437
        switch (version ) {
2039
2040
78
        case OSPF_VERSION_2:
2041
78
            proto_tree_add_item(ospf_db_desc_tree, hf_ospf_db_interface_mtu, tvb, offset, 2, ENC_BIG_ENDIAN);
2042
2043
78
            proto_tree_add_bitmask(ospf_db_desc_tree, tvb, offset + 2, hf_ospf_v2_options, ett_ospf_v2_options, bf_v2_options, ENC_BIG_ENDIAN);
2044
78
            proto_tree_add_bitmask(ospf_db_desc_tree, tvb, offset + 3, hf_ospf_dbd, ett_ospf_dbd, bf_dbd, ENC_BIG_ENDIAN);
2045
2046
78
            proto_tree_add_item(ospf_db_desc_tree, hf_ospf_db_dd_sequence, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
2047
78
            break;
2048
2049
359
        case OSPF_VERSION_3:
2050
2051
359
            reserved = tvb_get_uint8(tvb, offset);
2052
359
            ti = proto_tree_add_item(ospf_db_desc_tree, hf_ospf_header_reserved, tvb, offset, 1, ENC_NA);
2053
359
            if (reserved != 0)
2054
251
                expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
2055
2056
359
            proto_tree_add_bitmask(ospf_db_desc_tree, tvb, offset + 1, hf_ospf_v3_options, ett_ospf_v3_options, bf_v3_options, ENC_BIG_ENDIAN);
2057
2058
359
            proto_tree_add_item(ospf_db_desc_tree, hf_ospf_db_interface_mtu, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
2059
2060
359
            reserved = tvb_get_uint8(tvb, offset + 6);
2061
359
            ti = proto_tree_add_item(ospf_db_desc_tree, hf_ospf_header_reserved, tvb, offset + 6, 1, ENC_NA);
2062
359
            if (reserved != 0)
2063
165
                expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
2064
2065
359
            proto_tree_add_bitmask(ospf_db_desc_tree, tvb, offset + 7, hf_ospf_dbd, ett_ospf_dbd, bf_dbd, ENC_BIG_ENDIAN);
2066
2067
359
            proto_tree_add_item(ospf_db_desc_tree, hf_ospf_db_dd_sequence, tvb, offset + 8, 4, ENC_BIG_ENDIAN);
2068
359
            break;
2069
437
        }
2070
437
    }
2071
408
    switch (version ) {
2072
76
    case OSPF_VERSION_2:
2073
76
        offset += 8;
2074
76
        break;
2075
332
    case OSPF_VERSION_3:
2076
332
        offset += 12;
2077
332
        break;
2078
408
    }
2079
2080
    /* LS Headers will be processed here */
2081
    /* skip to the end of DB-Desc header */
2082
408
    DISSECTOR_ASSERT((version == OSPF_VERSION_2) || (version == OSPF_VERSION_3));
2083
655
    while (orig_offset + length > offset) {
2084
247
        if ( version == OSPF_VERSION_2)
2085
86
            offset = dissect_ospf_v2_lsa(tvb, pinfo, offset, tree, false);
2086
161
        else
2087
161
            offset = dissect_ospf_v3_lsa(tvb, pinfo, offset, tree, false, address_family);
2088
247
    }
2089
2090
408
}
2091
2092
static void
2093
dissect_ospf_ls_req(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, uint8_t version,
2094
                    uint16_t length)
2095
84
{
2096
84
    proto_item *ti;
2097
84
    proto_tree *ospf_lsr_tree;
2098
84
    proto_tree *lsa_type_tree;
2099
84
    uint16_t reserved;
2100
84
    int orig_offset = offset;
2101
2102
    /* zero or more LS requests may be within a LS Request */
2103
    /* we place every request for a LSA in a single subtree */
2104
331
    while (orig_offset + length > offset) {
2105
324
        ospf_lsr_tree = proto_tree_add_subtree(tree, tvb, offset, OSPF_LS_REQ_LENGTH,
2106
324
                                 ett_ospf_lsr, NULL, "Link State Request");
2107
2108
324
        switch ( version ) {
2109
2110
67
        case OSPF_VERSION_2:
2111
67
            proto_tree_add_item(ospf_lsr_tree, hf_ospf_ls_type,
2112
67
                                tvb, offset, 4, ENC_BIG_ENDIAN);
2113
67
            break;
2114
257
        case OSPF_VERSION_3:
2115
257
            reserved = tvb_get_ntohs(tvb, offset);
2116
257
            ti = proto_tree_add_item(ospf_lsr_tree, hf_ospf_header_reserved, tvb, offset, 2, ENC_NA);
2117
257
            if (reserved != 0)
2118
143
                expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
2119
2120
257
            ti = proto_tree_add_item(ospf_lsr_tree, hf_ospf_v3_ls_type,
2121
257
                                tvb, offset + 2, 2, ENC_BIG_ENDIAN);
2122
257
            lsa_type_tree = proto_item_add_subtree(ti, ett_ospf_lsa_type);
2123
257
            proto_tree_add_item(lsa_type_tree, hf_ospf_v3_ls_type_u, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
2124
257
            proto_tree_add_item(lsa_type_tree, hf_ospf_v3_ls_type_s12, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
2125
257
            proto_tree_add_item(lsa_type_tree, hf_ospf_v3_ls_type_fc, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
2126
257
            break;
2127
324
        }
2128
2129
2130
247
        proto_tree_add_item(ospf_lsr_tree, hf_ospf_link_state_id, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
2131
247
        proto_tree_add_item(ospf_lsr_tree, hf_ospf_adv_router,
2132
247
                            tvb, offset + 8, 4, ENC_BIG_ENDIAN);
2133
2134
247
        offset += 12;
2135
247
    }
2136
84
}
2137
2138
static void
2139
dissect_ospf_ls_upd(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, uint8_t version,
2140
                    uint16_t length, uint8_t address_family)
2141
3.92k
{
2142
3.92k
    proto_tree *ospf_lsa_upd_tree;
2143
3.92k
    uint32_t lsa_nr;
2144
3.92k
    uint32_t lsa_counter;
2145
2146
3.92k
    ospf_lsa_upd_tree = proto_tree_add_subtree(tree, tvb, offset, length, ett_ospf_lsa_upd, NULL, "LS Update Packet");
2147
2148
3.92k
    lsa_nr = tvb_get_ntohl(tvb, offset);
2149
3.92k
    proto_tree_add_item(ospf_lsa_upd_tree, hf_ospf_ls_number_of_lsas, tvb, offset, 4, ENC_BIG_ENDIAN);
2150
    /* skip to the beginning of the first LSA */
2151
3.92k
    offset += 4; /* the LS Upd Packet contains only a 32 bit #LSAs field */
2152
2153
3.92k
    DISSECTOR_ASSERT((version == OSPF_VERSION_2) || (version == OSPF_VERSION_3));
2154
3.92k
    lsa_counter = 0;
2155
12.6k
    while (lsa_counter < lsa_nr) {
2156
8.73k
        if (version == OSPF_VERSION_2)
2157
5.48k
            offset = dissect_ospf_v2_lsa(tvb, pinfo, offset, ospf_lsa_upd_tree, true);
2158
3.25k
        else
2159
3.25k
            offset = dissect_ospf_v3_lsa(tvb, pinfo, offset, ospf_lsa_upd_tree, true,
2160
3.25k
                                         address_family);
2161
8.73k
        lsa_counter += 1;
2162
8.73k
    }
2163
3.92k
}
2164
2165
static void
2166
dissect_ospf_ls_ack(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, uint8_t version,
2167
                    uint16_t length, uint8_t address_family)
2168
184
{
2169
184
    int orig_offset = offset;
2170
184
    DISSECTOR_ASSERT((version == OSPF_VERSION_2) || (version == OSPF_VERSION_3));
2171
    /* the body of a LS Ack packet simply contains zero or more LSA Headers */
2172
1.26k
    while (orig_offset + length > offset) {
2173
1.07k
        if (version == OSPF_VERSION_2)
2174
684
            offset = dissect_ospf_v2_lsa(tvb, pinfo, offset, tree, false);
2175
395
        else
2176
395
            offset = dissect_ospf_v3_lsa(tvb, pinfo, offset, tree, false, address_family);
2177
1.07k
    }
2178
184
}
2179
2180
/*
2181
 * Returns if an LSA is opaque, i.e. requires special treatment
2182
 */
2183
static int
2184
is_opaque(int lsa_type)
2185
5.75k
{
2186
5.75k
    return (lsa_type >= OSPF_LSTYPE_OP_LINKLOCAL &&
2187
4.71k
        lsa_type <= OSPF_LSTYPE_OP_ASWIDE);
2188
5.75k
}
2189
2190
/* MPLS/TE TLV types */
2191
273
#define MPLS_TLV_ROUTER    1
2192
3.02k
#define MPLS_TLV_LINK      2
2193
1.29k
#define OIF_TLV_TNA    32768
2194
2195
/* MPLS/TE Link STLV types */
2196
enum {
2197
    MPLS_LINK_TYPE       = 1,           /* RFC 3630, OSPF-TE   */
2198
    MPLS_LINK_ID,
2199
    MPLS_LINK_LOCAL_IF,
2200
    MPLS_LINK_REMOTE_IF,
2201
    MPLS_LINK_TE_METRIC,
2202
    MPLS_LINK_MAX_BW,
2203
    MPLS_LINK_MAX_RES_BW,
2204
    MPLS_LINK_UNRES_BW,
2205
    MPLS_LINK_COLOR,
2206
    MPLS_LINK_LOCAL_REMOTE_ID = 11,     /* RFC 4203, GMPLS     */
2207
    MPLS_LINK_PROTECTION = 14,
2208
    MPLS_LINK_IF_SWITCHING_DESC,
2209
    MPLS_LINK_SHARED_RISK_GROUP,
2210
    MPLS_LINK_BANDWIDTH_CONSTRAINT = 17,/* RFC 4124, OSPF-DSTE */
2211
    MPLS_LINK_EXT_ADMIN_GROUP = 26,     /* RFC 7308            */
2212
    MPLS_LINK_UNIDIR_LINK_DELAY,        /* RFC 7471            */
2213
    MPLS_LINK_UNIDIR_LINK_DELAY_MIN_MAX,
2214
    MPLS_LINK_UNIDIR_DELAY_VARIATION,
2215
};
2216
2217
enum {
2218
    MPLS_BANDWIDTH_AVAILABLE       = 1,           /* RFC 3630, OSPF-TE   */
2219
    MPLS_BANDWIDTH_SHARED          = 2
2220
};
2221
2222
/* OIF TLV types */
2223
enum {
2224
    OIF_LOCAL_NODE_ID = 32773,
2225
    OIF_REMOTE_NODE_ID,
2226
    OIF_SONET_SDH_SWITCHING_CAPABILITY,
2227
    OIF_TNA_IPv4_ADDRESS,
2228
    OIF_NODE_ID,
2229
    OIF_TNA_IPv6_ADDRESS,
2230
    OIF_TNA_NSAP_ADDRESS
2231
};
2232
2233
static const value_string mpls_link_stlv_str[] = {
2234
    {MPLS_LINK_TYPE, "Link Type"},
2235
    {MPLS_LINK_ID, "Link ID"},
2236
    {MPLS_LINK_LOCAL_IF, "Local Interface IP Address"},
2237
    {MPLS_LINK_REMOTE_IF, "Remote Interface IP Address"},
2238
    {MPLS_LINK_TE_METRIC, "Traffic Engineering Metric"},
2239
    {MPLS_LINK_MAX_BW, "Maximum Bandwidth"},
2240
    {MPLS_LINK_MAX_RES_BW, "Maximum Reservable Bandwidth"},
2241
    {MPLS_LINK_UNRES_BW, "Unreserved Bandwidth"},
2242
    {MPLS_LINK_COLOR, "Resource Class/Color"},
2243
    {MPLS_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier"},
2244
    {MPLS_LINK_PROTECTION, "Link Protection Type"},
2245
    {MPLS_LINK_IF_SWITCHING_DESC, "Interface Switching Capability Descriptor"},
2246
    {MPLS_LINK_SHARED_RISK_GROUP, "Shared Risk Link Group"},
2247
    {MPLS_LINK_BANDWIDTH_CONSTRAINT, "Bandwidth Constraints"},
2248
    {MPLS_LINK_EXT_ADMIN_GROUP, "Extended Administrative Group"},
2249
    {MPLS_LINK_UNIDIR_LINK_DELAY, "Unidirectional Link Delay"},
2250
    {MPLS_LINK_UNIDIR_LINK_DELAY_MIN_MAX, "Min/Max Unidirectional Link Delay"},
2251
    {MPLS_LINK_UNIDIR_DELAY_VARIATION, "Unidirectional Delay Variation"},
2252
    {OIF_LOCAL_NODE_ID, "Local Node ID"},
2253
    {OIF_REMOTE_NODE_ID, "Remote Node ID"},
2254
    {OIF_SONET_SDH_SWITCHING_CAPABILITY, "Sonet/SDH Interface Switching Capability"},
2255
    {0, NULL},
2256
};
2257
2258
static const value_string mpls_bandwidth_sstlv_str[] = {
2259
    {MPLS_BANDWIDTH_AVAILABLE, "Available Label"},
2260
    {MPLS_BANDWIDTH_SHARED, "Shared Backup Label"},
2261
    {0, NULL},
2262
};
2263
2264
static const range_string mpls_te_tlv_rvals[] = {
2265
    { 3,     32767, "(Assigned via Standards Action)"},
2266
    { 32768, 32777, "(For Experimental Use)"},
2267
    { 32778, 65535, "(Not to be Assigned)"},
2268
    { 0,         0, NULL}
2269
};
2270
2271
static const range_string mpls_te_sub_tlv_rvals[] = {
2272
    { 10,     32767, "(Assigned via Standards Action)"},
2273
    { 32768, 32777, "(For Experimental Use)"},
2274
    { 32778, 65535, "(Not to be Assigned)"},
2275
    { 0,         0, NULL}
2276
};
2277
2278
static const value_string oif_stlv_str[] = {
2279
    {OIF_TNA_IPv4_ADDRESS, "TNA address"},
2280
    {OIF_NODE_ID, "Node ID"},
2281
    {OIF_TNA_IPv6_ADDRESS, "TNA address"},
2282
    {OIF_TNA_NSAP_ADDRESS, "TNA address"},
2283
    {0, NULL},
2284
};
2285
2286
/* Ref. https://www.iana.org/assignments/ospfv2-parameters/ospfv2-parameters.xhtml#instance-ids */
2287
static const range_string ospf_instance_id_rvals[] = {
2288
    {   0,   0, "Base IPv4 Unicast Instance" },
2289
    {   1,   1, "Base IPv4 Multicast Instance" },
2290
    {   2,   2, "Base IPv4 In-band Management Instance" },
2291
    {   3, 127, "Private Use" },
2292
    { 128, 255, "Unassigned" },
2293
    {   0,   0, NULL },
2294
};
2295
2296
/* Ref. https://www.iana.org/assignments/ospfv3-parameters/ospfv3-parameters.xhtml#ospfv3-parameters-9 */
2297
static const range_string ospfv3_instance_id_rvals[] = {
2298
    {   0,   0, "Base IPv6 Unicast AF" },
2299
    {   1,  31, "Base IPv6 Unicast AF (local policy)" },
2300
    {  32,  32, "Base IPv6 Multicast" },
2301
    {  33,  63, "IPv6 Multicast AFs (local policy)" },
2302
    {  64,  64, "Base IPv4 Unicast AF" },
2303
    {  65,  95, "IPv4 Unicast AFs (local policy)" },
2304
    {  96,  96, "Base IPv4 Multicast" },
2305
    {  97, 127, "IPv4 Multicast AFs (local policy)" },
2306
    { 128, 191, "Unassigned" },
2307
    { 192, 255, "Private Use" },
2308
    {   0,   0, NULL },
2309
};
2310
2311
/*
2312
 * Name : dissect_ospf_subtlv_ext_admin_group()
2313
 *
2314
 * Description :
2315
 *
2316
 *   Dissect Extended Administrative Groups Sub-TLV
2317
 *
2318
 * Input :
2319
 *   tvbuff_t * : tvbuffer for packet data
2320
 *   proto_tree * : protocol display tree to fill out.
2321
 *   int : offset into packet data where we are (beginning of the sub_clv value).
2322
 *   int : subtlv type
2323
 *   int : subtlv length
2324
 *
2325
 * Output:
2326
 *   void
2327
 */
2328
static void
2329
dissect_ospf_subtlv_ext_admin_group(tvbuff_t *tvb, proto_tree *tree,
2330
                                    int offset, int subtype _U_, int sublen)
2331
2.94k
{
2332
2.94k
    int i;
2333
2.94k
    uint32_t admin_group;
2334
2335
    /* Number of Extended Admin Groups */
2336
4.35k
    for (i = 0; i < (sublen / 4); i++) {
2337
1.41k
        admin_group = tvb_get_uint32(tvb, offset + (i * 4), ENC_BIG_ENDIAN);
2338
1.41k
        proto_tree_add_uint_format(tree, hf_ospf_ls_ext_admin_group,
2339
1.41k
                                   tvb, offset + (i * 4), 4, admin_group,
2340
1.41k
                                   "Extended Admin Group[%d]: 0x%08x",
2341
1.41k
                                   i, admin_group);
2342
1.41k
    }
2343
2.94k
}
2344
2345
/*
2346
 * Dissect MPLS/TE opaque LSA
2347
 */
2348
static void
2349
dissect_ospf_lsa_mpls(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
2350
                      uint32_t length)
2351
1.25k
{
2352
1.25k
    proto_item *ti, *hidden_item;
2353
1.25k
    proto_tree *mpls_tree, *cs_tree, *label_tree, *grid_tree;
2354
1.25k
    proto_tree *tlv_tree;
2355
1.25k
    proto_tree *stlv_tree;
2356
1.25k
    proto_tree *sstlv_tree;
2357
1.25k
    proto_tree *stlv_admingrp_tree = NULL;
2358
2359
1.25k
    int tlv_type;
2360
1.25k
    int tlv_length;
2361
1.25k
    int tlv_end_offset;
2362
2363
1.25k
    int stlv_type, stlv_len, stlv_offset;
2364
1.25k
    int sstlv_type, sstlv_len, sstlv_offset;
2365
1.25k
    int bitmap_length, no_eff_bits, nb_octets;
2366
1.25k
    int bitmap_offset, bitmap_end_offset;
2367
1.25k
    uint8_t grid;
2368
1.25k
    const char *stlv_name;
2369
1.25k
    const char *sstlv_name;
2370
1.25k
    uint32_t stlv_admingrp, mask, reserved;
2371
1.25k
    int i;
2372
1.25k
    uint8_t switch_cap;
2373
1.25k
    uint8_t action;
2374
1.25k
    float tmp_float;
2375
2376
1.25k
    static const value_string lambda_grid_vals[] = {
2377
1.25k
        {   1, "DWDM"},
2378
1.25k
        {   2, "CWDM"},
2379
1.25k
        {   3, "Flexi"},
2380
1.25k
        {   0, NULL }
2381
1.25k
    };
2382
2383
1.25k
    static const value_string grid1_cs_vals[] = {
2384
1.25k
        {   1, "100GHz"},
2385
1.25k
        {   2, "50GHz"},
2386
1.25k
        {   3, "25GHz"},
2387
1.25k
        {   4, "12.5GHz"},
2388
1.25k
        {   0, NULL }
2389
1.25k
    };
2390
1.25k
    static const value_string grid2_cs_vals[] = {
2391
1.25k
        {   1, "20nm"},
2392
1.25k
        {   0, NULL }
2393
1.25k
    };
2394
1.25k
    static const value_string grid3_cs_vals[] = {
2395
1.25k
        {   5, "6.25GHz"},
2396
1.25k
        {   0, NULL }
2397
1.25k
    };
2398
2399
1.25k
    static const uint8_t allzero[] = { 0x00, 0x00, 0x00 };
2400
1.25k
    unsigned num_bcs = 0;
2401
2402
1.25k
    mpls_tree = proto_tree_add_subtree(tree, tvb, offset, length,
2403
1.25k
                             ett_ospf_lsa_mpls, NULL, "MPLS Traffic Engineering LSA");
2404
1.25k
    hidden_item = proto_tree_add_item(tree, hf_ospf_ls_mpls,
2405
1.25k
                                      tvb, offset, 2, ENC_BIG_ENDIAN);
2406
1.25k
    proto_item_set_hidden(hidden_item);
2407
2408
6.20k
    while (length != 0) {
2409
6.07k
        tlv_type = tvb_get_ntohs(tvb, offset);
2410
6.07k
        tlv_length = tvb_get_ntohs(tvb, offset + 2);
2411
6.07k
        tlv_end_offset = offset + tlv_length + 4;
2412
2413
6.07k
        switch (tlv_type) {
2414
2415
273
        case MPLS_TLV_ROUTER:
2416
273
            tlv_tree = proto_tree_add_subtree_format(mpls_tree, tvb, offset, tlv_length+4,
2417
273
                                     ett_ospf_lsa_mpls_router, NULL, "Router Address: %s",
2418
273
                                     tvb_ip_to_str(pinfo->pool, tvb, offset+4));
2419
273
            proto_tree_add_uint_format_value(tlv_tree, hf_ospf_tlv_type, tvb, offset, 2, tlv_type, "1 - Router Address");
2420
273
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
2421
273
            proto_tree_add_item(tlv_tree, hf_ospf_ls_mpls_routerid,
2422
273
                                tvb, offset+4, 4, ENC_BIG_ENDIAN);
2423
273
            break;
2424
2425
3.02k
        case MPLS_TLV_LINK:
2426
3.02k
            tlv_tree = proto_tree_add_subtree(mpls_tree, tvb, offset, tlv_length+4,
2427
3.02k
                                     ett_ospf_lsa_mpls_link, NULL, "Link Information");
2428
3.02k
            proto_tree_add_uint_format_value(tlv_tree, hf_ospf_tlv_type, tvb, offset, 2, tlv_type, "2 - Link Information");
2429
3.02k
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
2430
3.02k
            stlv_offset = offset + 4;
2431
2432
            /* Walk down the sub-TLVs for link information */
2433
11.9k
            while (stlv_offset < tlv_end_offset) {
2434
9.63k
                stlv_type = tvb_get_ntohs(tvb, stlv_offset);
2435
9.63k
                stlv_len = tvb_get_ntohs(tvb, stlv_offset + 2);
2436
9.63k
                stlv_name = val_to_str_const(stlv_type, mpls_link_stlv_str, "Unknown sub-TLV");
2437
9.63k
                switch (stlv_type) {
2438
2439
205
                case MPLS_LINK_TYPE:
2440
205
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2441
205
                                             ett_ospf_lsa_mpls_link_stlv, NULL, "%s: %u - %s", stlv_name,
2442
205
                                             tvb_get_uint8(tvb, stlv_offset + 4),
2443
205
                                             val_to_str_const(tvb_get_uint8(tvb, stlv_offset + 4),
2444
205
                                                              mpls_link_stlv_ltype_str, "Unknown Link Type"));
2445
205
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2446
205
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2447
205
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2448
205
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_mpls_linktype,
2449
205
                                        tvb, stlv_offset+4, 1,ENC_BIG_ENDIAN);
2450
205
                    break;
2451
2452
212
                case MPLS_LINK_ID:
2453
212
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2454
212
                                             ett_ospf_lsa_mpls_link_stlv, NULL, "%s: %s", stlv_name,
2455
212
                                             tvb_ip_to_str(pinfo->pool, tvb, stlv_offset + 4));
2456
212
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2457
212
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2458
212
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2459
212
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_mpls_linkid,
2460
212
                                        tvb, stlv_offset+4, 4, ENC_BIG_ENDIAN);
2461
212
                    break;
2462
2463
214
                case MPLS_LINK_LOCAL_IF:
2464
567
                case MPLS_LINK_REMOTE_IF:
2465
567
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2466
567
                                             ett_ospf_lsa_mpls_link_stlv, NULL, "%s: %s", stlv_name,
2467
567
                                             tvb_ip_to_str(pinfo->pool, tvb, stlv_offset + 4));
2468
567
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2469
567
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2470
567
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2471
                    /*   The Local/Remote Interface IP Address sub-TLV is TLV type 3/4, and is 4N
2472
                         octets in length, where N is the number of neighbor addresses. */
2473
1.42k
                    for (i=0; i < stlv_len; i+=4)
2474
857
                        proto_tree_add_item(stlv_tree,
2475
857
                                            stlv_type==MPLS_LINK_LOCAL_IF ?
2476
326
                                            hf_ospf_ls_mpls_local_addr :
2477
857
                                            hf_ospf_ls_mpls_remote_addr,
2478
857
                                            tvb, stlv_offset+4+i, 4, ENC_BIG_ENDIAN);
2479
567
                    break;
2480
2481
163
                case MPLS_LINK_TE_METRIC:
2482
163
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2483
163
                                             ett_ospf_lsa_mpls_link_stlv, NULL, "%s: %u", stlv_name,
2484
163
                                             tvb_get_ntohl(tvb, stlv_offset + 4));
2485
163
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2486
163
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2487
163
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2488
163
                    proto_tree_add_uint_format(stlv_tree, hf_ospf_ls_mpls_te_metric, tvb, stlv_offset+4, 4,
2489
163
                                        tvb_get_ntohl(tvb, stlv_offset + 4), "%s: %u", stlv_name,
2490
163
                                        tvb_get_ntohl(tvb, stlv_offset + 4));
2491
163
                    break;
2492
2493
843
                case MPLS_LINK_COLOR:
2494
843
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2495
843
                                             ett_ospf_lsa_mpls_link_stlv, NULL, "%s: 0x%08x", stlv_name,
2496
843
                                             tvb_get_ntohl(tvb, stlv_offset + 4));
2497
843
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2498
843
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2499
843
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2500
843
                    stlv_admingrp = tvb_get_ntohl(tvb, stlv_offset + 4);
2501
843
                    mask = 1;
2502
843
                    ti = proto_tree_add_item(stlv_tree, hf_ospf_ls_mpls_linkcolor,
2503
843
                                             tvb, stlv_offset+4, 4, ENC_BIG_ENDIAN);
2504
843
                    stlv_admingrp_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv_admingrp);
2505
843
                    if (stlv_admingrp_tree == NULL)
2506
0
                        return;
2507
27.6k
                    for (i = 0 ; i < 32 ; i++) {
2508
26.8k
                        if ((stlv_admingrp & mask) != 0) {
2509
2.07k
                            proto_tree_add_uint_format(stlv_admingrp_tree, hf_ospf_ls_mpls_group, tvb, stlv_offset+4,
2510
2.07k
                                                4, 1 << i, "Group %d", i);
2511
2.07k
                        }
2512
26.8k
                        mask <<= 1;
2513
26.8k
                    }
2514
843
                    break;
2515
2516
198
                case MPLS_LINK_MAX_BW:
2517
394
                case MPLS_LINK_MAX_RES_BW:
2518
394
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2519
394
                                             ett_ospf_lsa_mpls_link_stlv, NULL, "%s: %.10g bytes/s (%.0f bits/s)", stlv_name,
2520
394
                                             tvb_get_ntohieee_float(tvb, stlv_offset + 4),
2521
394
                                             tvb_get_ntohieee_float(tvb, stlv_offset + 4) * 8.0);
2522
394
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2523
394
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2524
394
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2525
394
                    proto_tree_add_float_format(stlv_tree, hf_ospf_ls_mpls_link_max_bw, tvb, stlv_offset+4, 4,
2526
394
                                        tvb_get_ntohieee_float(tvb, stlv_offset + 4), "%s: %.10g bytes/s (%.0f bits/s)", stlv_name,
2527
394
                                        tvb_get_ntohieee_float(tvb, stlv_offset + 4),
2528
394
                                        tvb_get_ntohieee_float(tvb, stlv_offset + 4) * 8.0);
2529
394
                    break;
2530
2531
248
                case MPLS_LINK_UNRES_BW:
2532
248
                    stlv_tree = proto_tree_add_subtree(tlv_tree, tvb, stlv_offset, stlv_len+4,
2533
248
                                             ett_ospf_lsa_mpls_link_stlv, NULL, stlv_name);
2534
248
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2535
248
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2536
248
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2537
2.15k
                    for (i = 0; i < 8; i++) {
2538
1.90k
                        tmp_float = tvb_get_ntohieee_float(tvb, stlv_offset + 4 + i*4);
2539
1.90k
                        proto_tree_add_float_format(stlv_tree, hf_ospf_ls_mpls_pri, tvb, stlv_offset+4+(i*4), 4,
2540
1.90k
                                            tmp_float, "Pri (or TE-Class) %d: %.10g bytes/s (%.0f bits/s)", i,
2541
1.90k
                                            tmp_float, tmp_float * 8.0);
2542
1.90k
                    }
2543
248
                    break;
2544
2545
2.05k
                case MPLS_LINK_BANDWIDTH_CONSTRAINT:
2546
                    /*
2547
                      The "Bandwidth Constraints" sub-TLV format is illustrated below:
2548
2549
                      0                   1                   2                   3
2550
                      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
2551
                      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2552
                      | BC Model Id   |           Reserved                            |
2553
                      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2554
                      |                       BC0 value                               |
2555
                      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2556
                      //                       . . .                                 //
2557
                      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2558
                      |                       BCh value                               |
2559
                      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2560
                    */
2561
2562
2.05k
                    stlv_tree = proto_tree_add_subtree(tlv_tree, tvb, stlv_offset, stlv_len+4,
2563
2.05k
                                             ett_ospf_lsa_mpls_link_stlv, NULL, stlv_name);
2564
2565
2.05k
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2566
2.05k
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2567
2568
2.05k
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2569
2570
2.05k
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_mpls_bc_model_id,
2571
2.05k
                                        tvb, stlv_offset+4, 1, ENC_BIG_ENDIAN);
2572
2573
                    /* 3 octets reserved +5, +6 and +7 (all 0x00) */
2574
2.05k
                    if(tvb_memeql(tvb, stlv_offset+5, allzero, 3) == -1) {
2575
1.93k
                        proto_tree_add_expert_format(stlv_tree, pinfo, &ei_ospf_header_reserved,
2576
1.93k
                                            tvb, stlv_offset+5, 3,
2577
1.93k
                                            "These bytes are reserved and must be 0x00");
2578
1.93k
                    }
2579
2580
2.05k
                    if(((stlv_len % 4)!=0)) {
2581
694
                        proto_tree_add_expert_format(stlv_tree, pinfo, &ei_ospf_lsa_bad_length, tvb, stlv_offset+4, stlv_len,
2582
694
                                            "Malformed Packet: Length must be N x 4 octets");
2583
694
                        break;
2584
694
                    }
2585
2586
                    /* stlv_len should range from 4 to 36 bytes */
2587
1.35k
                    num_bcs = (stlv_len - 4)/4;
2588
2589
1.35k
                    if(num_bcs>8) {
2590
831
                        proto_tree_add_expert_format(stlv_tree, pinfo, &ei_ospf_lsa_bc_error, tvb, stlv_offset+4, stlv_len,
2591
831
                                            "Malformed Packet: too many BC (%u)", num_bcs);
2592
831
                        break;
2593
831
                    }
2594
2595
527
                    if(num_bcs==0) {
2596
174
                        proto_tree_add_expert_format(stlv_tree, pinfo, &ei_ospf_lsa_bc_error, tvb, stlv_offset+4, stlv_len,
2597
174
                                            "Malformed Packet: Bandwidth Constraints sub-TLV with no BC?");
2598
174
                        break;
2599
174
                    }
2600
2601
1.71k
                    for(i = 0; i < (int) num_bcs; i++) {
2602
1.36k
                        tmp_float = tvb_get_ntohieee_float(tvb, stlv_offset + 8 + i*4);
2603
1.36k
                        proto_tree_add_float_format(stlv_tree, hf_ospf_ls_mpls_bc, tvb, stlv_offset+8+(i*4), 4,
2604
1.36k
                                            tmp_float, "BC %d: %.10g bytes/s (%.0f bits/s)", i,
2605
1.36k
                                            tmp_float, tmp_float * 8.0);
2606
1.36k
                    }
2607
353
                    break;
2608
2609
196
                case MPLS_LINK_LOCAL_REMOTE_ID:
2610
196
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2611
196
                                             ett_ospf_lsa_mpls_link_stlv, NULL, "%s: %d (0x%x) - %d (0x%x)", stlv_name,
2612
196
                                             tvb_get_ntohl(tvb, stlv_offset + 4),
2613
196
                                             tvb_get_ntohl(tvb, stlv_offset + 4),
2614
196
                                             tvb_get_ntohl(tvb, stlv_offset + 8),
2615
196
                                             tvb_get_ntohl(tvb, stlv_offset + 8));
2616
2617
196
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2618
196
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2619
196
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2620
196
                    proto_tree_add_item(stlv_tree,
2621
196
                                        hf_ospf_ls_mpls_local_ifid,
2622
196
                                        tvb, stlv_offset+4, 4, ENC_BIG_ENDIAN);
2623
196
                    proto_tree_add_item(stlv_tree,
2624
196
                                        hf_ospf_ls_mpls_remote_ifid,
2625
196
                                        tvb, stlv_offset+8, 4, ENC_BIG_ENDIAN);
2626
196
                    break;
2627
2628
1.43k
                case MPLS_LINK_IF_SWITCHING_DESC:
2629
1.43k
                    stlv_tree = proto_tree_add_subtree(tlv_tree, tvb, stlv_offset, stlv_len+4,
2630
1.43k
                                             ett_ospf_lsa_mpls_link_stlv, NULL, stlv_name);
2631
1.43k
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2632
1.43k
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2633
1.43k
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2634
1.43k
                    switch_cap = tvb_get_uint8 (tvb, stlv_offset + 4);
2635
1.43k
                    proto_tree_add_item(stlv_tree, hf_ospf_mpls_switching_type, tvb, stlv_offset + 4, 1, ENC_BIG_ENDIAN);
2636
1.43k
                    proto_tree_add_item(stlv_tree, hf_ospf_mpls_encoding, tvb, stlv_offset+5, 1, ENC_BIG_ENDIAN);
2637
12.9k
                    for (i = 0; i < 8; i++) {
2638
11.4k
                        tmp_float = tvb_get_ntohieee_float(tvb, stlv_offset + 8 + i*4);
2639
11.4k
                        proto_tree_add_float_format(stlv_tree, hf_ospf_ls_mpls_pri, tvb, stlv_offset+8+(i*4), 4,
2640
11.4k
                                            tmp_float, "Pri %d: %.10g bytes/s (%.0f bits/s)", i,
2641
11.4k
                                            tmp_float, tmp_float * 8.0);
2642
11.4k
                    }
2643
1.43k
                    if (switch_cap >=1 && switch_cap <=4) {           /* PSC-1 .. PSC-4 */
2644
243
                        tmp_float = tvb_get_ntohieee_float(tvb, stlv_offset + 40);
2645
243
                        proto_tree_add_float_format_value(stlv_tree, hf_ospf_mpls_minimum_lsp_bandwidth, tvb, stlv_offset+40, 4,
2646
243
                                            tmp_float, "%.10g bytes/s (%.0f bits/s)",
2647
243
                                            tmp_float, tmp_float * 8.0);
2648
243
                        proto_tree_add_item(stlv_tree, hf_ospf_mpls_interface_mtu, tvb, stlv_offset+44, 2, ENC_BIG_ENDIAN);
2649
243
                    }
2650
2651
1.43k
                    if (switch_cap == 100) {                         /* TDM */
2652
70
                        tmp_float = tvb_get_ntohieee_float(tvb, stlv_offset + 40);
2653
70
                        proto_tree_add_float_format_value(stlv_tree, hf_ospf_mpls_minimum_lsp_bandwidth, tvb, stlv_offset+40, 4,
2654
70
                                            tmp_float, "%.10g bytes/s (%.0f bits/s)",
2655
70
                                            tmp_float, tmp_float * 8.0);
2656
70
                        proto_tree_add_item(stlv_tree, hf_ospf_mpls_sonet_sdh, tvb, stlv_offset+44, 1, ENC_NA);
2657
70
                    }
2658
1.43k
                    if (switch_cap == 150) {
2659
210
                        if(tvb_get_ntohs(tvb, stlv_offset+2) > 36){
2660
169
                            sstlv_offset = stlv_offset + 40;
2661
169
                            sstlv_type = tvb_get_ntohs(tvb, sstlv_offset);
2662
169
                            sstlv_len = tvb_get_ntohs(tvb, sstlv_offset + 2);
2663
169
                            sstlv_name = val_to_str_const(sstlv_type, mpls_bandwidth_sstlv_str, "Unknown sub-TLV");
2664
2665
169
                            sstlv_tree = proto_tree_add_subtree(stlv_tree, tvb, sstlv_offset, sstlv_len,ett_ospf_lsa_mpls_bandwidth_sstlv, NULL, sstlv_name);
2666
169
                            proto_tree_add_item(sstlv_tree, hf_ospf_mpls_bandwidth_type, tvb, sstlv_offset, 2, ENC_BIG_ENDIAN);
2667
169
                            proto_tree_add_item(sstlv_tree, hf_ospf_mpls_length, tvb, sstlv_offset + 2, 2, ENC_BIG_ENDIAN);
2668
169
                            proto_tree_add_item(sstlv_tree, hf_ospf_mpls_pri, tvb, sstlv_offset + 4, 1, ENC_NA);
2669
169
                            proto_tree_add_item_ret_uint8(sstlv_tree, hf_ospf_mpls_action, tvb, sstlv_offset + 8, 1, ENC_NA, &action);
2670
169
                            proto_tree_add_item(sstlv_tree, hf_ospf_mpls_num_labels, tvb, sstlv_offset + 8, 2, ENC_BIG_ENDIAN);
2671
169
                            proto_tree_add_item(sstlv_tree, hf_ospf_mpls_length, tvb, sstlv_offset + 10, 2, ENC_BIG_ENDIAN);
2672
169
                            bitmap_length = tvb_get_ntohs(tvb, sstlv_offset + 10);
2673
169
                            if(action == 4){
2674
87
                                bitmap_offset = sstlv_offset + 16;
2675
87
                                bitmap_end_offset = sstlv_offset + 8 + bitmap_length;
2676
87
                                label_tree = proto_tree_add_subtree(sstlv_tree, tvb, sstlv_offset + 12, 4,ett_ospf_lsa_mpls_bandwidth_sstlv, NULL, "Base label");
2677
87
                                proto_tree_add_item(label_tree, hf_ospf_mpls_grid, tvb, sstlv_offset + 12, 1, ENC_NA);
2678
87
                                proto_tree_add_item(label_tree, hf_ospf_mpls_cs2, tvb, sstlv_offset + 12, 1, ENC_NA);
2679
87
                                proto_tree_add_item(label_tree, hf_ospf_mpls_n, tvb, sstlv_offset + 14, 2, ENC_BIG_ENDIAN);
2680
390
                                while(bitmap_offset < bitmap_end_offset){
2681
303
                                    proto_tree_add_item(sstlv_tree, hf_ospf_mpls_bitmap, tvb, bitmap_offset, 4, ENC_BIG_ENDIAN);
2682
303
                                    bitmap_offset += 4;
2683
303
                                }
2684
87
                            }
2685
169
                        }
2686
210
                    }
2687
2688
                    /*   WSON_LSC, see RFC 7579 */
2689
1.43k
                    if (switch_cap == 151) {
2690
383
                        sstlv_offset = stlv_offset + 40;
2691
383
                        sstlv_type = tvb_get_ntohs(tvb, sstlv_offset);
2692
383
                        sstlv_len = tvb_get_ntohs(tvb, sstlv_offset + 2);
2693
383
                        sstlv_name = val_to_str_const(sstlv_type, mpls_bandwidth_sstlv_str, "Unknown sub-TLV");
2694
383
                        sstlv_tree = proto_tree_add_subtree(stlv_tree, tvb, sstlv_offset, sstlv_len,ett_ospf_lsa_mpls_bandwidth_sstlv, NULL, sstlv_name);
2695
383
                        proto_tree_add_item(sstlv_tree, hf_ospf_mpls_bandwidth_type, tvb, sstlv_offset, 2, ENC_BIG_ENDIAN);
2696
383
                        proto_tree_add_item(sstlv_tree, hf_ospf_mpls_length, tvb, sstlv_offset + 2, 2, ENC_BIG_ENDIAN);
2697
383
                        proto_tree_add_item(sstlv_tree, hf_ospf_mpls_pri, tvb, sstlv_offset + 4, 1, ENC_NA);
2698
383
                        proto_tree_add_item_ret_uint8(sstlv_tree, hf_ospf_mpls_action, tvb, sstlv_offset + 8, 1, ENC_NA, &action);
2699
383
                        proto_tree_add_item(sstlv_tree, hf_ospf_mpls_num_labels, tvb, sstlv_offset+8, 2, ENC_BIG_ENDIAN);
2700
383
                        proto_tree_add_item(sstlv_tree, hf_ospf_mpls_length, tvb, sstlv_offset + 10, 2, ENC_BIG_ENDIAN);
2701
383
                        bitmap_length = tvb_get_ntohs(tvb, sstlv_offset + 10);
2702
383
                        if(action == 4){
2703
288
                            bitmap_offset = sstlv_offset + 16;
2704
288
                            bitmap_end_offset = sstlv_offset + 8 + bitmap_length;
2705
288
                            grid =((tvb_get_uint8(tvb, sstlv_offset + 12) & 0xE0) >> 5);
2706
288
                            label_tree = proto_tree_add_subtree(sstlv_tree, tvb, sstlv_offset + 12, 4,ett_ospf_lsa_mpls_bandwidth_sstlv, NULL, "Base label");
2707
288
                            grid_tree = proto_tree_add_item(label_tree, hf_ospf_mpls_grid, tvb, sstlv_offset + 12, 1, ENC_NA);
2708
288
                            proto_item_set_text(grid_tree, "Grid: %s (%u)",val_to_str_const(grid, lambda_grid_vals, "Unknown"),
2709
288
                                                (grid ));
2710
288
                            switch(grid){
2711
119
                            case 1:
2712
119
                                cs_tree = proto_tree_add_item(label_tree, hf_ospf_mpls_cs2, tvb, stlv_offset + 12, 1, ENC_NA);
2713
119
                                proto_item_set_text(cs_tree, "Channel Spacing: %s (%d)",val_to_str_const((tvb_get_uint8(tvb, stlv_offset + 12) & 0x1E) >> 1, grid1_cs_vals, "Unknown"),
2714
119
                                         (tvb_get_uint8(tvb, stlv_offset + 12) & 0x1E) >> 1 );
2715
119
                                break;
2716
75
                            case 2:
2717
75
                                cs_tree = proto_tree_add_item(label_tree, hf_ospf_mpls_cs2, tvb, stlv_offset + 12, 1, ENC_NA);
2718
75
                                proto_item_set_text(cs_tree, "Channel Spacing: %s (%d)",val_to_str_const((tvb_get_uint8(tvb, stlv_offset + 12) & 0x1E) >> 1, grid2_cs_vals, "Unknown"),
2719
75
                                         (tvb_get_uint8(tvb, stlv_offset + 12) & 0x1E) >> 1 );
2720
75
                                break;
2721
93
                            default:
2722
93
                                proto_tree_add_item(label_tree, hf_ospf_mpls_cs2, tvb, sstlv_offset + 12, 1, ENC_NA);
2723
93
                                break;
2724
288
                            }
2725
287
                            proto_tree_add_item(label_tree, hf_ospf_mpls_n, tvb, sstlv_offset + 14, 2, ENC_BIG_ENDIAN);
2726
775
                            while(bitmap_offset < bitmap_end_offset){
2727
488
                                proto_tree_add_item(sstlv_tree, hf_ospf_mpls_bitmap, tvb, bitmap_offset, 4, ENC_BIG_ENDIAN);
2728
488
                                bitmap_offset += 4;
2729
488
                            }
2730
287
                        }
2731
383
                    }
2732
                    /*   flexi-grid_lsc, see RFC 8363 */
2733
1.43k
                    if (switch_cap == 152){
2734
233
                        bitmap_offset = stlv_offset + 40 + 16;
2735
233
                        no_eff_bits = tvb_get_ntohs(tvb, stlv_offset + 54) & 0x0FFF;
2736
233
                        if(no_eff_bits % 32 == 0){
2737
72
                            nb_octets = (( no_eff_bits / 32 ) * 4);
2738
72
                        }
2739
161
                        else{
2740
161
                            nb_octets = ((( no_eff_bits / 32 ) + 1 ) * 4);
2741
161
                        }
2742
233
                        bitmap_end_offset = bitmap_offset + nb_octets;
2743
233
                        proto_tree_add_item(stlv_tree, hf_ospf_mpls_type, tvb, stlv_offset + 40, 2, ENC_BIG_ENDIAN);
2744
233
                        proto_tree_add_item(stlv_tree, hf_ospf_mpls_length, tvb, stlv_offset + 42, 2, ENC_BIG_ENDIAN);
2745
233
                        proto_tree_add_item(stlv_tree, hf_ospf_mpls_pri, tvb, stlv_offset + 44, 1, ENC_NA);
2746
233
                        cs_tree = proto_tree_add_item(stlv_tree, hf_ospf_mpls_cs, tvb, stlv_offset + 52, 1, ENC_NA);
2747
233
                        proto_item_set_text(cs_tree, "Channel Spacing: %s (%d)",val_to_str_const((tvb_get_uint8(tvb, stlv_offset + 52) & 0xF0) >> 4, grid3_cs_vals, "Unknown"),
2748
233
                                         (tvb_get_uint8(tvb, stlv_offset + 52) & 0xF0) >> 4 );
2749
233
                        proto_tree_add_item(stlv_tree, hf_ospf_mpls_starting, tvb, stlv_offset + 52, 4, ENC_BIG_ENDIAN);
2750
233
                        proto_tree_add_item(stlv_tree, hf_ospf_mpls_no_effective_bits, tvb, stlv_offset + 54, 2, ENC_BIG_ENDIAN);
2751
675
                        while(bitmap_offset < bitmap_end_offset){
2752
442
                            proto_tree_add_item(stlv_tree, hf_ospf_mpls_bitmap, tvb, bitmap_offset, 4, ENC_BIG_ENDIAN);
2753
442
                            bitmap_offset += 4;
2754
442
                        }
2755
233
                    }
2756
1.43k
                    break;
2757
223
                case MPLS_LINK_PROTECTION:
2758
223
                    stlv_tree = proto_tree_add_subtree(tlv_tree, tvb, stlv_offset, stlv_len+4,
2759
223
                                             ett_ospf_lsa_mpls_link_stlv, NULL, stlv_name);
2760
223
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2761
223
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2762
223
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2763
223
                    proto_tree_add_item(stlv_tree, hf_ospf_mpls_protection_capability, tvb, stlv_offset+4, 1, ENC_BIG_ENDIAN);
2764
223
                    break;
2765
2766
258
                case MPLS_LINK_SHARED_RISK_GROUP:
2767
258
                    stlv_tree = proto_tree_add_subtree(tlv_tree, tvb, stlv_offset, stlv_len+4,
2768
258
                                             ett_ospf_lsa_mpls_link_stlv, NULL, stlv_name);
2769
258
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2770
258
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2771
258
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2772
551
                    for (i=0; i < stlv_len; i+=4)
2773
293
                        proto_tree_add_item(stlv_tree, hf_ospf_mpls_shared_risk_link_group, tvb, stlv_offset+4+i, 4, ENC_BIG_ENDIAN);
2774
258
                    break;
2775
2776
320
                case MPLS_LINK_EXT_ADMIN_GROUP:
2777
320
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2778
320
                                                              ett_ospf_lsa_mpls_link_stlv, NULL,
2779
320
                                                              "%s", stlv_name);
2780
320
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2781
320
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2782
320
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2783
320
                    dissect_ospf_subtlv_ext_admin_group(tvb, stlv_tree, stlv_offset+4, stlv_type, stlv_len);
2784
320
                    break;
2785
2786
207
                case MPLS_LINK_UNIDIR_LINK_DELAY:
2787
207
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2788
207
                                             ett_ospf_lsa_mpls_link_stlv, NULL,
2789
207
                                             "%s: %u usec", stlv_name,
2790
207
                                             tvb_get_uint24(tvb, stlv_offset + 5, ENC_BIG_ENDIAN));
2791
207
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2792
207
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2793
207
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2794
207
                    ti = proto_tree_add_bitmask(stlv_tree, tvb, stlv_offset+4,
2795
207
                                                hf_ospf_ls_unidir_link_flags,
2796
207
                                                ett_ospf_lsa_unidir_link_flags,
2797
207
                                                unidir_link_flags, ENC_NA);
2798
207
                    reserved = tvb_get_uint8(tvb, stlv_offset) & 0x7f;
2799
207
                    if (reserved != 0) {
2800
0
                        expert_add_info_format(pinfo, ti, &ei_ospf_header_reserved,
2801
0
                                               "Reserved field should be 0");
2802
0
                    }
2803
207
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_unidir_link_delay, tvb, stlv_offset+5, 3, ENC_BIG_ENDIAN);
2804
207
                    break;
2805
2806
247
                case MPLS_LINK_UNIDIR_LINK_DELAY_MIN_MAX:
2807
247
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2808
247
                                             ett_ospf_lsa_mpls_link_stlv, NULL,
2809
247
                                             "%s: Min/Max %u/%u usec", stlv_name,
2810
247
                                             tvb_get_uint24(tvb, stlv_offset + 5, ENC_BIG_ENDIAN),
2811
247
                                             tvb_get_uint24(tvb, stlv_offset + 9, ENC_BIG_ENDIAN));
2812
247
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2813
247
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2814
247
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2815
247
                    ti = proto_tree_add_bitmask(stlv_tree, tvb, stlv_offset+4,
2816
247
                                                hf_ospf_ls_unidir_link_flags,
2817
247
                                                ett_ospf_lsa_unidir_link_flags,
2818
247
                                                unidir_link_flags, ENC_NA);
2819
247
                    reserved = tvb_get_uint8(tvb, stlv_offset) & 0x7f;
2820
247
                    if (reserved != 0) {
2821
0
                        expert_add_info_format(pinfo, ti, &ei_ospf_header_reserved,
2822
0
                                               "Reserved field should be 0");
2823
0
                    }
2824
247
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_unidir_link_delay_min, tvb, stlv_offset+5, 3, ENC_BIG_ENDIAN);
2825
247
                    ti = proto_tree_add_item_ret_uint(stlv_tree, hf_ospf_ls_unidir_link_reserved, tvb, stlv_offset+8, 1, ENC_NA, &reserved);
2826
247
                    if (reserved != 0) {
2827
68
                        expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
2828
68
                    }
2829
247
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_unidir_link_delay_max, tvb, stlv_offset+9, 3, ENC_BIG_ENDIAN);
2830
247
                    break;
2831
2832
266
                case MPLS_LINK_UNIDIR_DELAY_VARIATION:
2833
266
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2834
266
                                             ett_ospf_lsa_mpls_link_stlv, NULL,
2835
266
                                             "%s: %u usec", stlv_name,
2836
266
                                             tvb_get_uint24(tvb, stlv_offset + 5, ENC_BIG_ENDIAN));
2837
266
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2838
266
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2839
266
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2840
266
                    ti = proto_tree_add_item_ret_uint(stlv_tree, hf_ospf_ls_unidir_link_reserved, tvb, stlv_offset+4, 1, ENC_NA, &reserved);
2841
266
                    if (reserved != 0) {
2842
66
                        expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
2843
66
                    }
2844
266
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_unidir_delay_variation, tvb, stlv_offset+5, 3, ENC_BIG_ENDIAN);
2845
266
                    break;
2846
2847
196
                case OIF_LOCAL_NODE_ID:
2848
196
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2849
196
                                             ett_ospf_lsa_mpls_link_stlv, NULL, "%s: %s", stlv_name,
2850
196
                                             tvb_ip_to_str(pinfo->pool, tvb, stlv_offset + 4));
2851
196
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2852
196
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2853
196
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2854
196
                    proto_tree_add_item(stlv_tree,
2855
196
                                        hf_ospf_ls_oif_local_node_id,
2856
196
                                        tvb, stlv_offset + 4, 4, ENC_BIG_ENDIAN);
2857
196
                    break;
2858
2859
276
                case OIF_REMOTE_NODE_ID:
2860
276
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2861
276
                                             ett_ospf_lsa_mpls_link_stlv, NULL, "%s: %s", stlv_name,
2862
276
                                             tvb_ip_to_str(pinfo->pool, tvb, stlv_offset + 4));
2863
276
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2864
276
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2865
276
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2866
276
                    proto_tree_add_item(stlv_tree,
2867
276
                                        hf_ospf_ls_oif_remote_node_id,
2868
276
                                        tvb, stlv_offset + 4, 4, ENC_BIG_ENDIAN);
2869
276
                    break;
2870
2871
353
                case OIF_SONET_SDH_SWITCHING_CAPABILITY:
2872
353
                    stlv_tree = proto_tree_add_subtree(tlv_tree, tvb, stlv_offset, stlv_len+4,
2873
353
                                             ett_ospf_lsa_mpls_link_stlv, NULL, stlv_name);
2874
353
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2875
353
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2876
353
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2877
353
                    proto_tree_add_item(stlv_tree, hf_ospf_oif_switching_cap, tvb, stlv_offset+4, 1, ENC_BIG_ENDIAN);
2878
353
                    proto_tree_add_item(stlv_tree, hf_ospf_oif_encoding, tvb, stlv_offset+5, 1, ENC_BIG_ENDIAN);
2879
1.57k
                    for (i = 0; i < (stlv_len - 4) / 4; i++) {
2880
1.22k
                        proto_tree_add_uint_format(stlv_tree, hf_ospf_oif_signal_type, tvb, stlv_offset+8+(i*4), 4,
2881
1.22k
                                            tvb_get_uint8(tvb, stlv_offset+8+(i*4)), "%s: %d free timeslots",
2882
1.22k
                                            val_to_str_ext(pinfo->pool, tvb_get_uint8(tvb, stlv_offset+8+(i*4)),
2883
1.22k
                                                           &gmpls_sonet_signal_type_str_ext,
2884
1.22k
                                                           "Unknown Signal Type (%d)"),
2885
1.22k
                                            tvb_get_ntoh24(tvb, stlv_offset + 9 + i*4));
2886
1.22k
                    }
2887
2888
353
                    break;
2889
843
                default:
2890
843
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2891
843
                                             ett_ospf_lsa_mpls_link_stlv, NULL, "Unknown Link sub-TLV: %u %s", stlv_type,
2892
843
                                             rval_to_str_const(stlv_type, mpls_te_sub_tlv_rvals, "Unknown"));
2893
843
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2894
843
                                        stlv_type, "%u: %s %s", stlv_type, stlv_name,
2895
843
                                        rval_to_str_const(stlv_type, mpls_te_sub_tlv_rvals, "Unknown"));
2896
843
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2897
843
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_value, tvb, stlv_offset+4, stlv_len, ENC_NA);
2898
843
                    break;
2899
9.63k
                }
2900
8.95k
                stlv_offset += ((stlv_len+4+3)/4)*4;
2901
8.95k
            }
2902
2.34k
            break;
2903
2904
2.34k
        case OIF_TLV_TNA:
2905
1.29k
            tlv_tree = proto_tree_add_subtree(mpls_tree, tvb, offset, tlv_length+4,
2906
1.29k
                                     ett_ospf_lsa_oif_tna, NULL, "TNA Information");
2907
1.29k
            proto_tree_add_uint_format_value(tlv_tree, hf_ospf_tlv_type, tvb, offset, 2, 32768, "32768 - TNA Information");
2908
1.29k
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
2909
1.29k
            stlv_offset = offset + 4;
2910
2911
            /* Walk down the sub-TLVs for TNA information */
2912
2.18k
            while (stlv_offset < tlv_end_offset) {
2913
1.28k
                stlv_type = tvb_get_ntohs(tvb, stlv_offset);
2914
1.28k
                stlv_len = tvb_get_ntohs(tvb, stlv_offset + 2);
2915
2916
1.28k
                if (stlv_len < 4) {
2917
204
                  proto_tree_add_expert_format(tlv_tree, pinfo, &ei_ospf_stlv_length_invalid, tvb, stlv_offset + 2, 2,
2918
204
                                        "Invalid sub-TLV length: %u", stlv_len);
2919
204
                  break;
2920
204
                }
2921
2922
1.07k
                stlv_name = val_to_str_const(stlv_type, oif_stlv_str, "Unknown sub-TLV");
2923
1.07k
                switch (stlv_type) {
2924
2925
307
                case OIF_NODE_ID:
2926
307
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2927
307
                                             ett_ospf_lsa_oif_tna_stlv, NULL, "%s: %s", stlv_name,
2928
307
                                             tvb_ip_to_str(pinfo->pool, tvb, stlv_offset + 4));
2929
307
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2930
307
                                        stlv_type, "%u: %s", stlv_type, stlv_name);
2931
307
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2932
307
                    proto_tree_add_ipv4_format(stlv_tree, hf_ospf_oif_node_id, tvb, stlv_offset+4, 4,
2933
307
                                        tvb_get_ntohl(tvb, stlv_offset + 4), "%s: %s", stlv_name,
2934
307
                                        tvb_ip_to_str(pinfo->pool, tvb, stlv_offset + 4));
2935
307
                    break;
2936
2937
65
                case OIF_TNA_IPv4_ADDRESS:
2938
65
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2939
65
                                             ett_ospf_lsa_oif_tna_stlv, NULL, "%s (IPv4): %s", stlv_name,
2940
65
                                             tvb_ip_to_str(pinfo->pool, tvb, stlv_offset + 8));
2941
65
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2942
65
                                        stlv_type, "%u: %s (IPv4)", stlv_type, stlv_name);
2943
65
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2944
65
                    proto_tree_add_item(stlv_tree, hf_ospf_oif_tna_addr_length, tvb, stlv_offset+4, 1, ENC_BIG_ENDIAN);
2945
65
                    proto_tree_add_item(stlv_tree, hf_ospf_oif_tna_addr_ipv4, tvb, stlv_offset+8, stlv_len - 4, ENC_BIG_ENDIAN);
2946
65
                    break;
2947
2948
106
                case OIF_TNA_IPv6_ADDRESS:
2949
106
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2950
106
                                             ett_ospf_lsa_oif_tna_stlv, NULL, "%s (IPv6): %s", stlv_name,
2951
106
                                             tvb_ip6_to_str(pinfo->pool, tvb, stlv_offset + 8));
2952
106
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2953
106
                                        stlv_type, "%u: %s (IPv6)", stlv_type, stlv_name);
2954
106
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2955
106
                    proto_tree_add_item(stlv_tree, hf_ospf_oif_tna_addr_length, tvb, stlv_offset+4, 1, ENC_BIG_ENDIAN);
2956
106
                    proto_tree_add_item(stlv_tree, hf_ospf_tna_addr_ipv6, tvb, stlv_offset+8, stlv_len - 4, ENC_NA);
2957
106
                    break;
2958
2959
413
                case OIF_TNA_NSAP_ADDRESS:
2960
413
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_len+4,
2961
413
                                             ett_ospf_lsa_oif_tna_stlv, NULL, "%s (NSAP): %s", stlv_name,
2962
413
                                             tvb_bytes_to_str(pinfo->pool, tvb, stlv_offset + 8, stlv_len - 4));
2963
413
                    proto_tree_add_uint_format_value(stlv_tree, hf_ospf_tlv_type, tvb, stlv_offset, 2,
2964
413
                                        stlv_type, "%u: %s (NSAP)", stlv_type, stlv_name);
2965
413
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset+2, 2, ENC_BIG_ENDIAN);
2966
413
                    proto_tree_add_item(stlv_tree, hf_ospf_oif_tna_addr_length, tvb, stlv_offset+4, 1, ENC_BIG_ENDIAN);
2967
413
                    proto_tree_add_item(stlv_tree, hf_ospf_tna_addr, tvb, stlv_offset+8, stlv_len - 4, ENC_NA);
2968
413
                    break;
2969
2970
139
                default:
2971
139
                    proto_tree_add_expert_format(tlv_tree, pinfo, &ei_ospf_unknown_link_subtype, tvb, stlv_offset, stlv_len+4,
2972
139
                                        "Unknown Link sub-TLV: %u", stlv_type);
2973
139
                    break;
2974
1.07k
                }
2975
896
                stlv_offset += ((stlv_len+4+3)/4)*4;
2976
896
            }
2977
1.10k
            break;
2978
1.39k
        default:
2979
1.39k
            tlv_tree = proto_tree_add_subtree_format(mpls_tree, tvb, offset, tlv_length+4,
2980
1.39k
                                     ett_ospf_lsa_mpls_link, NULL, "Unknown LSA: %u %s", tlv_type,
2981
1.39k
                                     rval_to_str_const(tlv_type, mpls_te_tlv_rvals, "Unknown"));
2982
1.39k
            proto_tree_add_uint_format_value(tlv_tree, hf_ospf_tlv_type, tvb, offset, 2, tlv_type, "%u - Unknown %s",
2983
1.39k
                                tlv_type, rval_to_str_const(tlv_type, mpls_te_tlv_rvals, "Unknown"));
2984
1.39k
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
2985
1.39k
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_value, tvb, offset+4, tlv_length, ENC_NA);
2986
1.39k
            break;
2987
6.07k
        }
2988
2989
4.95k
        offset += tlv_length + 4;
2990
4.95k
        length -= tlv_length + 4;
2991
4.95k
    }
2992
1.25k
}
2993
2994
/*
2995
 * Dissect the TLVs within a grace-LSA as defined by RFC 3623 and 5187.
2996
 */
2997
static void dissect_ospf_lsa_grace_tlv (tvbuff_t *tvb, packet_info *pinfo, int offset,
2998
                                        proto_tree *tree, uint32_t length, uint8_t ospf_version)
2999
457
{
3000
457
    uint16_t tlv_type;
3001
457
    uint16_t tlv_length;
3002
457
    unsigned tlv_total_length; /* The total length of the TLV including the type
3003
                                  and length fields and any padding */
3004
457
    uint32_t grace_period;
3005
457
    uint8_t restart_reason;
3006
457
    proto_tree *tlv_tree;
3007
457
    proto_item *tree_item;
3008
3009
3.40k
    while (length > 0)
3010
3.16k
    {
3011
3.16k
        tlv_type = tvb_get_ntohs(tvb, offset);
3012
3.16k
        tlv_length = tvb_get_ntohs(tvb, offset + 2);
3013
        /* The total length of the TLV including the type, length, value and
3014
         * pad bytes (TLVs are padded to 4 octet alignment).
3015
         */
3016
3.16k
        tlv_total_length = tlv_length + 4 + WS_PADDING_TO_4(tlv_length);
3017
3018
3.16k
        tree_item = proto_tree_add_item(tree, hf_ospf_grace_tlv, tvb, offset,
3019
3.16k
                                        tlv_total_length, ENC_NA);
3020
3.16k
        tlv_tree = proto_item_add_subtree(tree_item, ett_ospf_lsa_grace_tlv);
3021
3.16k
        proto_tree_add_uint_format_value(tlv_tree, hf_ospf_tlv_type, tvb, offset, 2, tlv_type, "%s (%u)",
3022
3.16k
                            val_to_str_const(tlv_type, grace_tlv_type_vals, "Unknown grace-LSA TLV"), tlv_type);
3023
3.16k
        proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
3024
3025
3.16k
        if(tlv_type == GRACE_TLV_PERIOD)
3026
556
        {
3027
556
            proto_tree_add_item_ret_uint(tlv_tree, hf_ospf_grace_period, tvb, offset + 4, tlv_length, ENC_BIG_ENDIAN, &grace_period);
3028
556
            proto_item_set_text(tree_item, "Grace Period: %u seconds", grace_period);
3029
556
        }
3030
2.60k
        else if(tlv_type == GRACE_TLV_REASON)
3031
220
        {
3032
220
            restart_reason = tvb_get_uint8(tvb, offset + 4);
3033
220
            proto_tree_add_item(tlv_tree, hf_ospf_grace_reason, tvb, offset + 4, tlv_length, ENC_BIG_ENDIAN);
3034
220
            proto_item_set_text(tree_item, "Restart Reason: %s (%u)",
3035
220
                                val_to_str_const(restart_reason, restart_reason_vals, "Unknown Restart Reason"),
3036
220
                                restart_reason);
3037
220
        }
3038
2.38k
        else if(tlv_type == GRACE_TLV_IP && ospf_version == OSPF_VERSION_2)
3039
216
        {
3040
            /* Type 3 is only applicable to OSPFv2. */
3041
216
            proto_tree_add_item(tlv_tree, hf_ospf_grace_ip, tvb, offset + 4, tlv_length, ENC_BIG_ENDIAN);
3042
216
            proto_item_set_text(tree_item, "Restart IP: %s", tvb_address_with_resolution_to_str(pinfo->pool, tvb, AT_IPv4, offset + 4));
3043
216
            break;
3044
216
        }
3045
2.17k
        else
3046
2.17k
        {
3047
2.17k
            proto_item_set_text(tree_item, "Unknown grace-LSA TLV");
3048
2.17k
        }
3049
3050
2.94k
        if (4U + tlv_length < tlv_total_length) {
3051
978
            proto_tree_add_item(tlv_tree, hf_ospf_pad_bytes, tvb, offset + 4U + tlv_length, tlv_total_length - (4U + tlv_length), ENC_NA);
3052
978
        }
3053
2.94k
        offset += tlv_total_length;
3054
2.94k
        length -= tlv_total_length;
3055
2.94k
    }
3056
457
}
3057
3058
/*
3059
 * Dissect the TLVs within a Extended-LSA as defined by RFC 8362
3060
*/
3061
static void dissect_ospf6_e_lsa_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
3062
                           uint32_t length, uint8_t address_family)
3063
579
{
3064
579
    int tlv_type;
3065
579
    unsigned tlv_length;
3066
579
    uint8_t prefix_length;
3067
3068
579
    int offset_end = offset + length;
3069
3070
579
    proto_tree *tlv_tree;
3071
3072
2.28k
    while(offset < offset_end) {
3073
1.81k
        tlv_type = tvb_get_ntohs(tvb, offset);
3074
1.81k
        tlv_length = tvb_get_ntohs(tvb, offset + 2);
3075
3076
1.81k
        tlv_tree = proto_tree_add_subtree_format(tree, tvb, offset, tlv_length+4,
3077
1.81k
                                ett_ospf_elsa_pfx_tlv, NULL, "%s", val_to_str_const(tlv_type, ospf6_extended_lsa_tlv_type_vals, "Unknown E-LSA TLV"));
3078
3079
1.81k
        proto_tree_add_item(tlv_tree, hf_ospf_v3_e_lsa_tlv_type, tvb, offset, 2, ENC_BIG_ENDIAN);
3080
3081
1.81k
        proto_tree_add_item(tlv_tree, hf_ospf_v3_e_lsa_tlv_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
3082
3083
1.81k
        switch(tlv_type)
3084
1.81k
        {
3085
210
            case OSPF6_TLV_INTRA_AREA_PREFIX:
3086
            /* metric */
3087
210
            proto_tree_add_item(tlv_tree, hf_ospf_metric, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
3088
3089
            /* prefix length */
3090
210
            prefix_length=tvb_get_uint8(tvb, offset + 8);
3091
210
            proto_tree_add_item(tlv_tree, hf_ospf_prefix_length, tvb, offset + 8, 1, ENC_BIG_ENDIAN);
3092
3093
            /* prefix options */
3094
210
            proto_tree_add_bitmask(tlv_tree, tvb, offset + 9, hf_ospf_v3_prefix_option, ett_ospf_v3_prefix_options, bf_v3_prefix_options, ENC_BIG_ENDIAN);
3095
3096
            /* address_prefix */
3097
210
            dissect_ospf_v3_address_prefix(tvb, pinfo, offset + 12, prefix_length, tlv_tree, address_family);
3098
3099
210
            offset +=  4 + WS_ROUNDUP_4(tlv_length);
3100
3101
210
            break;
3102
212
            case OSPF6_TLV_ROUTER_LINK:
3103
                /* Type */
3104
212
                proto_tree_add_item(tlv_tree, hf_ospf_v3_lsa_type, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
3105
                /* Reserved */
3106
212
                proto_tree_add_item(tlv_tree, hf_ospf_header_reserved, tvb, offset+5, 1, ENC_NA);
3107
                /* Metric */
3108
212
                proto_tree_add_item(tlv_tree, hf_ospf_metric, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
3109
                /* Interface ID */
3110
212
                proto_tree_add_item(tlv_tree, hf_ospf_v3_lsa_interface_id, tvb, offset + 8, 4, ENC_BIG_ENDIAN);
3111
                /* Neighbor Interface ID */
3112
212
                proto_tree_add_item(tlv_tree, hf_ospf_v3_lsa_neighbor_interface_id, tvb, offset + 12, 4, ENC_BIG_ENDIAN);
3113
                /* Neighbor Router ID */
3114
212
                proto_tree_add_item(tlv_tree, hf_ospf_v3_lsa_neighbor_router_id, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
3115
3116
212
                offset +=  4 + WS_ROUNDUP_4(tlv_length);
3117
3118
212
                break;
3119
194
            case OSPF6_TLV_IPV6_LL_ADDR:
3120
                /* Ipv6 addr */
3121
194
                proto_tree_add_item(tlv_tree, hf_ospf_v3_lsa_link_local_interface_address, tvb, offset + 4, 16, ENC_NA);
3122
194
                offset +=  4 + WS_ROUNDUP_4(tlv_length);
3123
194
            break;
3124
197
            case OSPF6_TLV_ATTACHED_ROUTERS:
3125
197
                proto_tree_add_item(tlv_tree, hf_ospf_v3_lsa_attached_router, tvb, offset+4, 4, ENC_BIG_ENDIAN);
3126
197
                offset +=  4 + WS_ROUNDUP_4(tlv_length);
3127
197
            break;
3128
523
            case OSPF6_TLV_EXTERNAL_PREFIX:
3129
                /* FIXME: first 8 bits unclear in RFC 8362. */
3130
523
                proto_tree_add_bitmask(tlv_tree, tvb, offset+4, hf_ospf_v3_as_external_flag, ett_ospf_v3_as_external_flags, bf_v3_as_external_flags, ENC_BIG_ENDIAN);
3131
3132
                /* metric */
3133
523
                proto_tree_add_item(tlv_tree, hf_ospf_metric, tvb, offset+5, 3, ENC_BIG_ENDIAN);
3134
                /* prefix length */
3135
523
                prefix_length=tvb_get_uint8(tvb, offset+8);
3136
523
                proto_tree_add_item(tlv_tree, hf_ospf_prefix_length, tvb, offset+8, 1, ENC_BIG_ENDIAN);
3137
3138
                /* prefix options */
3139
523
                proto_tree_add_bitmask(tlv_tree, tvb, offset + 9, hf_ospf_v3_prefix_option, ett_ospf_v3_prefix_options, bf_v3_prefix_options, ENC_BIG_ENDIAN);
3140
3141
                /* address_prefix */
3142
523
                dissect_ospf_v3_address_prefix(tvb, pinfo, offset + 12, prefix_length, tlv_tree, address_family);
3143
523
                offset +=  4 + WS_ROUNDUP_4(tlv_length);
3144
3145
523
            break;
3146
443
            default:
3147
443
                offset +=  4 + WS_ROUNDUP_4(tlv_length);
3148
443
            break;
3149
3150
1.81k
        }
3151
1.81k
    }
3152
579
}
3153
3154
3155
/*
3156
 * This function dissects the Optional Router capabilities LSA.
3157
 * In case of OSPFv2, the Router Capabilities would be advertized via the first TLV
3158
 * of an RI LSA and in the case of OSPFv3, the router capabilities would be advertized
3159
 * using a special purpose type field value. (RFC 4970)
3160
 * Also, the Dynamic Hostname or FQDN is advertized via a special purpose TLV type.
3161
 * The below function adds the support to handle this as well. (RFC5642).
3162
 */
3163
static void
3164
dissect_ospf_lsa_opaque_ri(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
3165
                           uint32_t length)
3166
680
{
3167
680
    proto_tree *ri_tree;
3168
680
    proto_tree *tlv_tree;
3169
680
    proto_tree *stlv_tree;
3170
680
    proto_item *ti_tree = NULL;
3171
680
    proto_item *ti;
3172
680
    int offset_end = offset + length;
3173
3174
680
    int tlv_type;
3175
680
    unsigned tlv_length;
3176
680
    int tlv_offset, tlv_end_offset;
3177
680
    uint16_t stlv_type;
3178
680
    uint16_t stlv_length;
3179
680
    int stlv_offset;
3180
680
    const char *tlv_name;
3181
680
    const char *stlv_name;
3182
680
    uint32_t range_size;
3183
680
    uint32_t reserved;
3184
680
    int i;
3185
3186
680
    ri_tree = proto_tree_add_subtree(tree, tvb, offset, length,
3187
680
                             ett_ospf_lsa_opaque_ri, NULL, "Opaque Router Information LSA");
3188
3189
3.50k
    while (offset < offset_end) {
3190
3.31k
        tlv_type = tvb_get_ntohs(tvb, offset);
3191
3.31k
        tlv_length = tvb_get_ntohs(tvb, offset + 2);
3192
3.31k
        tlv_end_offset = offset + tlv_length + 4;
3193
3.31k
        tlv_name = val_to_str_const(tlv_type, ri_tlv_type_vals, "Unknown");
3194
3195
3.31k
        switch(tlv_type) {
3196
3197
245
        case OPAQUE_TLV_RI:
3198
245
            tlv_tree = proto_tree_add_subtree_format(ri_tree, tvb, offset, tlv_length+4,
3199
245
                                    ett_ospf_lsa_ri_tlv, NULL, "%s", val_to_str_const(tlv_type, ri_tlv_type_vals, "Unknown Opaque RI LSA TLV"));
3200
3201
245
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_type_opaque, tvb, offset, 2, ENC_BIG_ENDIAN);
3202
3203
245
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
3204
3205
245
            proto_tree_add_bitmask(tlv_tree, tvb, offset + 4, hf_ospf_ri_options, ett_ospf_ri_options, bf_ri_options, ENC_BIG_ENDIAN);
3206
245
            break;
3207
3208
197
        case OPAQUE_TLV_DH:
3209
197
            tlv_tree = proto_tree_add_subtree_format(ri_tree, tvb, offset, tlv_length+4,
3210
197
                                    ett_ospf_lsa_dh_tlv, NULL, "%s", val_to_str_const(tlv_type, ri_tlv_type_vals, "Unknown Opaque RI LSA TLV"));
3211
3212
197
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_type_opaque, tvb, offset, 2, ENC_BIG_ENDIAN);
3213
3214
197
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
3215
3216
197
            proto_tree_add_item(tlv_tree, hf_ospf_dyn_hostname, tvb, offset+4, tlv_length, ENC_ASCII);
3217
197
            break;
3218
3219
274
        case OPAQUE_TLV_SA:{
3220
274
            unsigned sa_number;
3221
274
            tlv_tree = proto_tree_add_subtree_format(ri_tree, tvb, offset, tlv_length+4,
3222
274
                                    ett_ospf_lsa_sa_tlv, NULL, "%s", val_to_str_const(tlv_type, ri_tlv_type_vals, "Unknown Opaque RI LSA TLV"));
3223
3224
274
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_type_opaque, tvb, offset, 2, ENC_BIG_ENDIAN);
3225
3226
274
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
3227
3228
714
            for(sa_number = 0; sa_number < tlv_length; sa_number++){
3229
440
                proto_tree_add_item(tlv_tree, hf_ospf_lsa_sa, tvb, offset+sa_number+4, 1, ENC_NA);
3230
440
            }
3231
274
            break;
3232
0
            }
3233
3234
542
        case OPAQUE_TLV_SLR:
3235
918
        case OPAQUE_TLV_SRLB:
3236
918
            tlv_tree = proto_tree_add_subtree_format(ri_tree, tvb, offset, tlv_length + 4,
3237
918
                                                     ett_ospf_lsa_slr_tlv, &ti_tree, "%s", tlv_name);
3238
918
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_type_opaque, tvb, offset, 2, ENC_BIG_ENDIAN);
3239
918
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
3240
918
            proto_tree_add_item_ret_uint(tlv_tree, hf_ospf_ls_range_size, tvb, offset + 4, 3, ENC_BIG_ENDIAN, &range_size);
3241
918
            proto_item_append_text(ti_tree, "  (Range Size: %u)", range_size);
3242
918
            reserved = tvb_get_uint8(tvb, offset + 7);
3243
918
            ti = proto_tree_add_item(tlv_tree, hf_ospf_header_reserved, tvb, offset + 7, 1, ENC_NA);
3244
918
            if (reserved != 0) {
3245
268
                expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
3246
268
            }
3247
918
            stlv_offset = offset + 8;
3248
3249
            /* Walk down the sub-TLVs in SID/Label Range TLV */
3250
1.52k
            while (stlv_offset < tlv_end_offset) {
3251
686
                uint32_t sid_label;
3252
686
                stlv_type = tvb_get_ntohs(tvb, stlv_offset);
3253
686
                stlv_length = tvb_get_ntohs(tvb, stlv_offset + 2);
3254
686
                stlv_name = val_to_str_const(stlv_type, ext_pfx_stlv_type_vals, "Unknown");
3255
3256
686
                switch (stlv_type) {
3257
3258
352
                case SR_STLV_SID_LABEL:
3259
352
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_length + 4,
3260
352
                                                              ett_ospf_lsa_slr_stlv, &ti_tree,
3261
352
                                                              "%s Sub-TLV", stlv_name);
3262
352
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_slr_stlv, tvb, stlv_offset, 2, ENC_BIG_ENDIAN);
3263
352
                    ti = proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset + 2, 2, ENC_BIG_ENDIAN);
3264
352
                    if (stlv_length == 3) {
3265
66
                        sid_label = tvb_get_ntoh24(tvb, stlv_offset + 4);
3266
286
                    } else if (stlv_length == 4) {
3267
68
                        sid_label = tvb_get_ntohl(tvb, stlv_offset + 4);
3268
218
                    } else {
3269
                        /* Invalid sub-TLV length. */
3270
218
                        proto_item_append_text(ti, " [Invalid length - %u]", stlv_length);
3271
218
                        proto_tree_add_item(stlv_tree, hf_ospf_tlv_value, tvb, stlv_offset + 4, stlv_length, ENC_NA);
3272
218
                        break;
3273
218
                    }
3274
134
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_sid_label, tvb, stlv_offset + 4, stlv_length, ENC_BIG_ENDIAN);
3275
134
                    proto_item_append_text(ti_tree, "  (SID/Label: %u)", sid_label);
3276
134
                    break;
3277
3278
302
                default:
3279
302
                    stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_length + 4,
3280
302
                                                              ett_ospf_lsa_slr_stlv, NULL,
3281
302
                                                              "%s Sub-TLV: %u", stlv_name, stlv_type);
3282
302
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset + 2, 2, ENC_BIG_ENDIAN);
3283
302
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_value, tvb, stlv_offset + 4, stlv_length, ENC_NA);
3284
302
                    break;
3285
686
                }
3286
602
                stlv_offset += 4 + WS_ROUNDUP_4(stlv_length);
3287
602
            }
3288
834
            break;
3289
3290
834
        case OPAQUE_TLV_SRMS_PREF:
3291
259
            tlv_tree = proto_tree_add_subtree_format(ri_tree, tvb, offset, tlv_length + 4,
3292
259
                                    ett_ospf_lsa_srms_tlv, NULL, "%s", val_to_str_const(tlv_type, ri_tlv_type_vals, "Unknown Opaque RI LSA TLV"));
3293
259
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_type_opaque, tvb, offset, 2, ENC_BIG_ENDIAN);
3294
259
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
3295
259
            proto_tree_add_item(tlv_tree, hf_ospf_ls_preference, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
3296
259
            reserved = tvb_get_ntoh24(tvb, offset + 5);
3297
259
            ti = proto_tree_add_item(tlv_tree, hf_ospf_header_reserved, tvb, offset + 5, 3, ENC_NA);
3298
259
            if (reserved != 0) {
3299
191
                expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
3300
191
            }
3301
259
            break;
3302
3303
285
        case OPAQUE_TLV_NODE_MSD:
3304
            /* Node MSD (rfc8476) */
3305
285
            tlv_offset = offset + 4;
3306
285
            tlv_tree = proto_tree_add_subtree_format(ri_tree, tvb, offset, tlv_length + 4,
3307
285
                                                     ett_ospf_lsa_node_msd_tlv, &ti_tree, "%s", tlv_name);
3308
285
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_type_opaque, tvb, offset, 2, ENC_BIG_ENDIAN);
3309
285
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
3310
637
            while (tlv_offset + 2 <= tlv_end_offset) {
3311
352
                proto_tree_add_item(tlv_tree, hf_ospf_ls_igp_msd_type, tvb, tlv_offset, 1, ENC_NA);
3312
352
                proto_tree_add_item(tlv_tree, hf_ospf_ls_igp_msd_value, tvb, tlv_offset+1, 1, ENC_NA);
3313
352
                tlv_offset += 2;
3314
352
            }
3315
285
            break;
3316
3317
395
        case OPAQUE_TLV_FLEX_ALGO_DEF:
3318
            /* Flex Algo Definition (FAD) (rfc9350) */
3319
395
            tlv_tree = proto_tree_add_subtree_format(ri_tree, tvb, offset, tlv_length + 4,
3320
395
                                                     ett_ospf_lsa_fad_tlv, &ti_tree, "%s", tlv_name);
3321
395
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_type_opaque, tvb, offset, 2, ENC_BIG_ENDIAN);
3322
395
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
3323
395
            proto_item_append_text(ti_tree, "  (%u)", tvb_get_uint8(tvb, offset + 4));
3324
395
            proto_tree_add_item(tlv_tree, hf_ospf_ls_flex_algorithm, tvb, offset + 4, 1, ENC_NA);
3325
395
            proto_tree_add_item(tlv_tree, hf_ospf_ls_fad_metric_type, tvb, offset + 5, 1, ENC_NA);
3326
395
            proto_tree_add_item(tlv_tree, hf_ospf_ls_fad_calc_type, tvb, offset + 6, 1, ENC_NA);
3327
395
            proto_tree_add_item(tlv_tree, hf_ospf_ls_fad_priority, tvb, offset + 7, 1, ENC_NA);
3328
3329
            /* Walk down sub-TLVs in FAD TLV */
3330
395
            stlv_offset = offset + 8;
3331
2.34k
            while (stlv_offset < tlv_end_offset) {
3332
2.06k
                stlv_type = tvb_get_ntohs(tvb, stlv_offset);
3333
2.06k
                stlv_length = tvb_get_ntohs(tvb, stlv_offset + 2);
3334
2.06k
                stlv_name = val_to_str_const(stlv_type, ri_lsa_fad_stlv_type_vals, "Unknown");
3335
3336
2.06k
                stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_length + 4,
3337
2.06k
                                                          ett_ospf_lsa_fad_stlv,
3338
2.06k
                                                          NULL, "%s", stlv_name);
3339
2.06k
                proto_tree_add_item(stlv_tree, hf_ospf_ls_fad_stlv, tvb, stlv_offset, 2, ENC_BIG_ENDIAN);
3340
2.06k
                proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset + 2, 2, ENC_BIG_ENDIAN);
3341
2.06k
                switch (stlv_type) {
3342
370
                case FAD_EXCLUDE_AG:
3343
648
                case FAD_INCLUDE_ANY_AG:
3344
858
                case FAD_INCLUDE_ALL_AG:
3345
858
                    dissect_ospf_subtlv_ext_admin_group(tvb, stlv_tree, stlv_offset + 4, stlv_type, stlv_length);
3346
858
                    break;
3347
315
                case FAD_DEF_FLAGS:
3348
315
                    proto_tree_add_bitmask(stlv_tree, tvb, stlv_offset + 4, hf_ospf_ls_fad_def_flags, ett_ospf_lsa_fad_def_flags, bf_ospf_fad_def_flags, ENC_BIG_ENDIAN);
3349
315
                    break;
3350
444
                case FAD_EXCLUDE_SRLG:
3351
939
                    for (i = 0; i < stlv_length; i += 4) {
3352
495
                        proto_tree_add_item(stlv_tree, hf_ospf_ls_srlg, tvb, stlv_offset + 4 + i, 4, ENC_BIG_ENDIAN);
3353
495
                    }
3354
444
                    break;
3355
387
                default:
3356
387
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_value, tvb, stlv_offset + 4, stlv_length, ENC_NA);
3357
387
                    break;
3358
2.06k
                }
3359
3360
1.94k
                stlv_offset += 4 + WS_ROUNDUP_4(stlv_length);
3361
1.94k
            }
3362
281
            break;
3363
3364
635
        default:
3365
635
            if (tlv_length > (unsigned)(offset_end - offset)) {
3366
                /* Invalid length, probably not TLV. */
3367
65
                return;
3368
65
            }
3369
570
            tlv_tree = proto_tree_add_subtree_format(ri_tree, tvb, offset, tlv_length+4,
3370
570
                                    ett_ospf_lsa_unknown_tlv, NULL, "%s  (t=%u, l=%u)",
3371
570
                                    val_to_str_const(tlv_type, ri_tlv_type_vals, "Unknown Opaque RI LSA TLV"),
3372
570
                                    tlv_type, tlv_length);
3373
3374
570
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_type_opaque, tvb, offset, 2, ENC_BIG_ENDIAN);
3375
3376
570
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
3377
3378
570
            proto_tree_add_item(tlv_tree, hf_ospf_unknown_tlv, tvb, offset+4, tlv_length, ENC_NA);
3379
570
            break;
3380
3381
3.31k
        }
3382
3383
        /*
3384
         * RFC 7770, section 2.3: 4-octet aligned, but type, length and padding
3385
         * is not included in the length.
3386
         * */
3387
2.82k
        offset += 4 + WS_ROUNDUP_4(tlv_length);
3388
2.82k
    }
3389
680
}
3390
3391
/*
3392
 * Dissect Extended Prefix Opaque LSA
3393
 *
3394
 * This function dissects the Optional Extended Prefix Opaque LSA.
3395
 * The below function adds the support to handle this as well. (RFC7684).
3396
 */
3397
static void
3398
dissect_ospf_lsa_ext_prefix(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
3399
                            uint32_t length)
3400
483
{
3401
483
    proto_tree *ep_tree;
3402
483
    proto_tree *tlv_tree;
3403
483
    proto_tree *stlv_tree;
3404
483
    proto_item *ti_tree = NULL;
3405
483
    proto_item *ti;
3406
483
    int offset_end = offset + length;
3407
3408
483
    int tlv_type;
3409
483
    unsigned tlv_length;
3410
483
    int tlv_end_offset;
3411
483
    uint16_t stlv_type;
3412
483
    uint16_t stlv_length;
3413
483
    int stlv_offset;
3414
483
    const char *tlv_name;
3415
483
    const char *stlv_name;
3416
483
    uint8_t route_type;
3417
483
    uint32_t prefix_length;
3418
483
    uint32_t sid_label;
3419
483
    uint32_t range_size;
3420
483
    uint32_t reserved;
3421
483
    uint32_t metric = 0;
3422
3423
483
    ep_tree = proto_tree_add_subtree(tree, tvb, offset, length,
3424
483
                                     ett_ospf_lsa_epfx, NULL, "OSPFv2 Extended Prefix Opaque LSA");
3425
3426
1.90k
    while (offset < offset_end) {
3427
1.77k
        tlv_type = tvb_get_ntohs(tvb, offset);
3428
1.77k
        tlv_length = tvb_get_ntohs(tvb, offset + 2);
3429
1.77k
        tlv_end_offset = offset + tlv_length + 4;
3430
1.77k
        tlv_name = val_to_str_const(tlv_type, ext_pfx_tlv_type_vals, "Unknown");
3431
3432
1.77k
        switch(tlv_type) {
3433
3434
731
        case EXT_PREFIX_TLV_PREFIX:
3435
731
            tlv_tree = proto_tree_add_subtree_format(ep_tree, tvb, offset, tlv_length + 4,
3436
731
                                                     ett_ospf_lsa_epfx_tlv, &ti_tree, "%s TLV", tlv_name);
3437
731
            proto_tree_add_item(tlv_tree, hf_ospf_ls_epfx_tlv, tvb, offset, 2, ENC_BIG_ENDIAN);
3438
731
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
3439
731
            proto_tree_add_item_ret_uint8(tlv_tree, hf_ospf_ls_epfx_route_type, tvb, offset + 4, 1, ENC_BIG_ENDIAN, &route_type);
3440
731
            proto_tree_add_item_ret_uint(tlv_tree, hf_ospf_prefix_length, tvb, offset + 5, 1, ENC_BIG_ENDIAN, &prefix_length);
3441
731
            proto_tree_add_item(tlv_tree, hf_ospf_ls_epfx_af, tvb, offset + 6, 1, ENC_BIG_ENDIAN);
3442
731
            proto_tree_add_bitmask(tlv_tree, tvb, offset + 7, hf_ospf_ls_epfx_flags, ett_ospf_lsa_epfx_flags, bf_ospf_epfx_flags, ENC_BIG_ENDIAN);
3443
731
            if (prefix_length != 0) {
3444
492
                proto_tree_add_item(tlv_tree, hf_ospf_v3_address_prefix_ipv4, tvb, offset + 8, 4, ENC_BIG_ENDIAN);
3445
492
            }
3446
731
            proto_item_append_text(ti_tree, "  (Type: %-13s Prefix: %s/%u)",
3447
731
                                   val_to_str_const(route_type, ext_pfx_tlv_route_vals, "Unknown"),
3448
731
                                   prefix_length == 0 ? "0.0.0.0" : tvb_ip_to_str(pinfo->pool, tvb, offset + 8),
3449
731
                                   prefix_length);
3450
731
            stlv_offset = offset + 8 + (prefix_length != 0 ? 4 : 0);
3451
731
            break;
3452
3453
514
        case EXT_PREFIX_TLV_PREFIX_RANGE:
3454
514
            tlv_tree = proto_tree_add_subtree_format(ep_tree, tvb, offset, tlv_length + 4,
3455
514
                                                     ett_ospf_lsa_epfx_tlv, &ti_tree, "%s TLV", tlv_name);
3456
514
            proto_tree_add_item(tlv_tree, hf_ospf_ls_epfx_tlv, tvb, offset, 2, ENC_BIG_ENDIAN);
3457
514
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
3458
514
            proto_tree_add_item_ret_uint(tlv_tree, hf_ospf_prefix_length, tvb, offset + 4, 1, ENC_BIG_ENDIAN, &prefix_length);
3459
514
            proto_tree_add_item(tlv_tree, hf_ospf_ls_epfx_af, tvb, offset + 5, 1, ENC_BIG_ENDIAN);
3460
514
            proto_tree_add_item_ret_uint(tlv_tree, hf_ospf_ls_range_size, tvb, offset + 6, 2, ENC_BIG_ENDIAN, &range_size);
3461
514
            proto_tree_add_bitmask(tlv_tree, tvb, offset + 8, hf_ospf_ls_epfx_range_flags, ett_ospf_lsa_epfx_range_flags, bf_ospf_epfx_range_flags, ENC_BIG_ENDIAN);
3462
514
            reserved = tvb_get_ntoh24(tvb, offset + 9);
3463
514
            ti = proto_tree_add_item(tlv_tree, hf_ospf_header_reserved, tvb, offset + 9, 3, ENC_NA);
3464
514
            if (reserved != 0) {
3465
434
                expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
3466
434
            }
3467
514
            if (prefix_length != 0) {
3468
98
                proto_tree_add_item(tlv_tree, hf_ospf_v3_address_prefix_ipv4, tvb, offset + 12, 4, ENC_BIG_ENDIAN);
3469
98
            }
3470
514
            proto_item_append_text(ti_tree, "  (Range Size: %u, Prefix: %s/%u)",
3471
514
                                   range_size,
3472
514
                                   prefix_length == 0 ? "0.0.0.0" : tvb_ip_to_str(pinfo->pool, tvb, offset + 12),
3473
514
                                   prefix_length);
3474
514
            stlv_offset = offset + 12 + (prefix_length != 0 ? 4 : 0);
3475
514
            break;
3476
3477
480
        default:
3478
480
            if (tlv_length > (unsigned)(offset_end - offset)) {
3479
                /* Invalid length, probably not TLV. */
3480
81
                return;
3481
81
            }
3482
399
            tlv_tree = proto_tree_add_subtree_format(ep_tree, tvb, offset, tlv_length + 4,
3483
399
                                                     ett_ospf_lsa_epfx_tlv, NULL,
3484
399
                                                     "%s TLV: %u - Unknown", tlv_name, tlv_type);
3485
399
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_type_opaque, tvb, offset, 2, ENC_BIG_ENDIAN);
3486
399
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
3487
399
            proto_tree_add_item(tlv_tree, hf_ospf_unknown_tlv, tvb, offset + 4, tlv_length, ENC_NA);
3488
399
            stlv_offset = offset + 4;
3489
399
            break;
3490
1.77k
        }
3491
3492
1.57k
        if (tlv_type == EXT_PREFIX_TLV_PREFIX || tlv_type == EXT_PREFIX_TLV_PREFIX_RANGE) {
3493
            /* Walk down the sub-TLVs in Extended Link TLV */
3494
3.48k
            while (stlv_offset < tlv_end_offset) {
3495
2.43k
                stlv_type = tvb_get_ntohs(tvb, stlv_offset);
3496
2.43k
                stlv_length = tvb_get_ntohs(tvb, stlv_offset + 2);
3497
2.43k
                stlv_name = val_to_str_const(stlv_type, ext_pfx_stlv_type_vals, "Unknown");
3498
3499
2.43k
                stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_length + 4,
3500
2.43k
                                                          ett_ospf_lsa_epfx_stlv, &ti_tree,
3501
2.43k
                                                          "%s Sub-TLV", stlv_name);
3502
2.43k
                proto_tree_add_item(stlv_tree, hf_ospf_ls_epfx_stlv, tvb, stlv_offset, 2, ENC_BIG_ENDIAN);
3503
2.43k
                ti = proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset + 2, 2, ENC_BIG_ENDIAN);
3504
3505
2.43k
                switch (stlv_type) {
3506
3507
1.13k
                case SR_STLV_PREFIX_SID:
3508
1.13k
                    if (stlv_length == 7) {
3509
354
                        sid_label = tvb_get_ntoh24(tvb, stlv_offset + 8);
3510
781
                    } else if (stlv_length == 8) {
3511
500
                        sid_label = tvb_get_ntohl(tvb, stlv_offset + 8);
3512
500
                    } else {
3513
                        /* Invalid sub-TLV length. */
3514
281
                        proto_item_append_text(ti, " [Invalid length - %u]", stlv_length);
3515
281
                        proto_tree_add_item(stlv_tree, hf_ospf_tlv_value, tvb, stlv_offset + 4, stlv_length, ENC_NA);
3516
281
                        break;
3517
281
                    }
3518
854
                    proto_tree_add_bitmask(stlv_tree, tvb, stlv_offset + 4, hf_ospf_ls_pfxsid_flags, ett_ospf_lsa_pfxsid_flags, bf_ospf_pfxsid_flags, ENC_BIG_ENDIAN);
3519
854
                    reserved = tvb_get_uint8(tvb, stlv_offset + 5);
3520
854
                    ti = proto_tree_add_item(stlv_tree, hf_ospf_header_reserved, tvb, stlv_offset + 5, 1, ENC_NA);
3521
854
                    if (reserved != 0) {
3522
390
                        expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
3523
390
                    }
3524
854
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_elink_mt_id, tvb, stlv_offset + 6, 1, ENC_BIG_ENDIAN);
3525
854
                    proto_tree_add_item(stlv_tree, hf_ospf_lsa_sa, tvb, stlv_offset + 7, 1, ENC_BIG_ENDIAN);
3526
854
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_sid_label, tvb, stlv_offset + 8, (stlv_length - 4), ENC_BIG_ENDIAN);
3527
854
                    proto_item_append_text(ti_tree, "  (SID/Label: %u)",sid_label);
3528
854
                    break;
3529
3530
618
                case SR_STLV_FLEX_ALGO_PREFIX_METRIC:
3531
618
                    if (stlv_length != 8) {
3532
292
                        proto_item_append_text(ti, " [Invalid length - %u]", stlv_length);
3533
292
                        proto_tree_add_item(stlv_tree, hf_ospf_tlv_value, tvb, stlv_offset + 4, stlv_length, ENC_NA);
3534
292
                        break;
3535
292
                    }
3536
326
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_flex_algorithm, tvb, stlv_offset + 4, 1, ENC_NA);
3537
326
                    proto_tree_add_bitmask(stlv_tree, tvb, stlv_offset + 5, hf_ospf_ls_fapm_flags, ett_ospf_lsa_fapm_flags, bf_ospf_fapm_flags, ENC_NA);
3538
326
                    reserved = tvb_get_ntoh24(tvb, stlv_offset + 6);
3539
326
                    ti = proto_tree_add_item(stlv_tree, hf_ospf_header_reserved, tvb, stlv_offset + 6, 3, ENC_NA);
3540
326
                    if (reserved != 0) {
3541
253
                        expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
3542
253
                    }
3543
326
                    proto_tree_add_item_ret_uint(stlv_tree, hf_ospf_ls_fapm_metric, tvb, stlv_offset + 8, 4, ENC_BIG_ENDIAN, &metric);
3544
326
                    proto_item_append_text(ti_tree, "  (Metric: %u)", metric);
3545
326
                    break;
3546
3547
599
                default:
3548
599
                    proto_item_append_text(ti, "  (t=%u, l=%u)", stlv_type, stlv_length);
3549
599
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_value, tvb, stlv_offset + 4, stlv_length, ENC_NA);
3550
599
                    break;
3551
2.43k
                }
3552
2.27k
                stlv_offset += 4 + WS_ROUNDUP_4(stlv_length);
3553
2.27k
            }
3554
1.20k
        }
3555
3556
        /*
3557
         * RFC 7770, section 2.3: 4-octet aligned, but type, length and padding
3558
         * is not included in the length.
3559
         * */
3560
1.41k
        offset += 4 + WS_ROUNDUP_4(tlv_length);
3561
1.41k
    }
3562
483
}
3563
3564
/*
3565
 * Dissect Application-Specific Link Attributes Sub-Sub-TLVs
3566
 */
3567
static void
3568
dissect_ospf_lsa_app_link_attributes(tvbuff_t *tvb, packet_info *pinfo _U_, int offset, proto_tree *tree,
3569
                                     uint32_t length)
3570
16.9k
{
3571
16.9k
    proto_tree *stlv_tree = NULL;
3572
16.9k
    proto_item *ti_tree = NULL, *ti = NULL;
3573
16.9k
    int offset_end = offset + length;
3574
16.9k
    int stlv_offset = offset;
3575
16.9k
    uint16_t stlv_type, stlv_length;
3576
16.9k
    const char *stlv_name;
3577
16.9k
    uint32_t delay, delay_min, delay_max, reserved;
3578
16.9k
    uint32_t admin_group, te_metric;
3579
16.9k
    int i;
3580
3581
849k
    while (stlv_offset < offset_end) {
3582
832k
        stlv_type = tvb_get_ntohs(tvb, stlv_offset);
3583
832k
        stlv_length = tvb_get_ntohs(tvb, stlv_offset + 2);
3584
832k
        stlv_name = val_to_str_const(stlv_type, ext_link_stlv_type_vals, "Unknown");
3585
3586
832k
        stlv_tree = proto_tree_add_subtree_format(tree, tvb, stlv_offset, stlv_length + 4,
3587
832k
                                                  ett_ospf_lsa_app_link_attrs_stlv, &ti_tree,
3588
832k
                                                  "%s Sub-TLV", stlv_name);
3589
832k
        proto_tree_add_item(stlv_tree, hf_ospf_ls_app_link_attrs_stlv, tvb, stlv_offset, 2, ENC_BIG_ENDIAN);
3590
832k
        proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset + 2, 2, ENC_BIG_ENDIAN);
3591
832k
        stlv_offset += 4;
3592
3593
832k
        switch (stlv_type) {
3594
729
        case SR_STLV_SRLG:
3595
            /* 11: Shared Risk Link Group */
3596
1.32k
            for (i = 0; i < stlv_length; i += 4) {
3597
593
                proto_tree_add_item(stlv_tree, hf_ospf_ls_srlg, tvb, stlv_offset + i, 4, ENC_BIG_ENDIAN);
3598
593
            }
3599
729
            break;
3600
2.13k
        case SR_STLV_UNIDIR_LINK_DELAY:
3601
            /* 12: Unidirectional Link Delay (rfc7471) */
3602
2.13k
            ti = proto_tree_add_bitmask(stlv_tree, tvb, stlv_offset,
3603
2.13k
                                        hf_ospf_ls_unidir_link_flags,
3604
2.13k
                                        ett_ospf_lsa_unidir_link_flags,
3605
2.13k
                                        unidir_link_flags, ENC_NA);
3606
2.13k
            reserved = tvb_get_uint8(tvb, stlv_offset) & 0x7f;
3607
2.13k
            if (reserved != 0) {
3608
1.69k
                expert_add_info_format(pinfo, ti, &ei_ospf_header_reserved,
3609
1.69k
                                       "Reserved field should be 0");
3610
1.69k
            }
3611
2.13k
            delay = tvb_get_uint24(tvb, stlv_offset + 1, ENC_BIG_ENDIAN);
3612
2.13k
            proto_tree_add_item(stlv_tree, hf_ospf_ls_unidir_link_delay, tvb, stlv_offset + 1, 3, ENC_BIG_ENDIAN);
3613
2.13k
            if (ti_tree) {
3614
2.12k
                proto_item_append_text(ti_tree, "  (Delay: %u usec)", delay);
3615
2.12k
            }
3616
2.13k
            break;
3617
3618
409k
        case SR_STLV_UNIDIR_LINK_DELAY_MIN_MAX:
3619
            /* 13: Min/Max Unidirectional Link Delay (rfc7471) */
3620
409k
            ti = proto_tree_add_bitmask(stlv_tree, tvb, stlv_offset,
3621
409k
                                        hf_ospf_ls_unidir_link_flags,
3622
409k
                                        ett_ospf_lsa_unidir_link_flags,
3623
409k
                                        unidir_link_flags, ENC_NA);
3624
409k
            reserved = tvb_get_uint8(tvb, stlv_offset) & 0x7f;
3625
409k
            if (reserved != 0) {
3626
145k
                expert_add_info_format(pinfo, ti, &ei_ospf_header_reserved,
3627
145k
                                       "Reserved field should be 0");
3628
145k
            }
3629
409k
            delay_min = tvb_get_uint24(tvb, stlv_offset + 1, ENC_BIG_ENDIAN);
3630
409k
            proto_tree_add_item(stlv_tree, hf_ospf_ls_unidir_link_delay_min, tvb, stlv_offset+1, 3, ENC_BIG_ENDIAN);
3631
409k
            ti = proto_tree_add_item_ret_uint(stlv_tree, hf_ospf_ls_unidir_link_reserved, tvb, stlv_offset+4, 1, ENC_NA, &reserved);
3632
409k
            if (reserved != 0) {
3633
173k
                expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
3634
173k
            }
3635
409k
            proto_tree_add_item_ret_uint(stlv_tree, hf_ospf_ls_unidir_link_delay_max, tvb, stlv_offset+5, 3, ENC_BIG_ENDIAN, &delay_max);
3636
409k
            if (ti_tree) {
3637
409k
                proto_item_append_text(ti_tree, "  (Min/Max Delay: %u/%u usec)", delay_min, delay_max);
3638
409k
            }
3639
409k
            break;
3640
3641
19.0k
        case SR_STLV_UNIDIR_DELAY_VARIATION:
3642
            /* 14: Unidirectional Delay Variation (rfc7471) */
3643
19.0k
            ti = proto_tree_add_item_ret_uint(stlv_tree, hf_ospf_ls_unidir_link_reserved, tvb, stlv_offset, 1, ENC_NA, &reserved);
3644
19.0k
            if (reserved != 0) {
3645
18.3k
                expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
3646
18.3k
            }
3647
19.0k
            proto_tree_add_item_ret_uint(stlv_tree, hf_ospf_ls_unidir_delay_variation, tvb, stlv_offset + 1, 3, ENC_BIG_ENDIAN, &delay);
3648
19.0k
            if (ti_tree) {
3649
19.0k
                proto_item_append_text(ti_tree, "  (Variation: %u usec)", delay);
3650
19.0k
            }
3651
19.0k
            break;
3652
3653
478
        case SR_STLV_ADMIN_GROUP:
3654
            /* 19: Administrative Group (rfc3630) */
3655
478
            proto_tree_add_item_ret_uint(stlv_tree, hf_ospf_ls_admin_group, tvb, stlv_offset, 4, ENC_BIG_ENDIAN, &admin_group);
3656
478
            if (ti_tree) {
3657
478
                proto_item_append_text(ti_tree, "  (Admin Group: 0x%08x)", admin_group);
3658
478
            }
3659
478
            break;
3660
3661
1.76k
        case SR_STLV_EXT_ADMIN_GROUP:
3662
            /* 20: Extended Administrative Group (rfc7308) */
3663
1.76k
            dissect_ospf_subtlv_ext_admin_group(tvb, stlv_tree, stlv_offset, stlv_type, stlv_length);
3664
1.76k
            break;
3665
3666
601
        case SR_STLV_TE_METRIC:
3667
            /* 22: TE Metric (rfc3630) */
3668
601
            proto_tree_add_item_ret_uint(stlv_tree, hf_ospf_ls_mpls_te_metric, tvb, stlv_offset, 4, ENC_BIG_ENDIAN, &te_metric);
3669
601
            if (ti_tree) {
3670
601
                proto_item_append_text(ti_tree, "  (TE Metric: %u)", te_metric);
3671
601
            }
3672
601
            break;
3673
3674
398k
        default:
3675
398k
            proto_tree_add_item(stlv_tree, hf_ospf_tlv_value, tvb, stlv_offset, stlv_length, ENC_NA);
3676
398k
            break;
3677
832k
        }
3678
3679
832k
        stlv_offset += WS_ROUNDUP_4(stlv_length);
3680
832k
    }
3681
16.9k
}
3682
3683
/*
3684
 * Dissect Extended Link Opaque LSA
3685
 *
3686
 * This function dissects the Optional Extended Link Opaque LSA.
3687
 * The below function adds the support to handle this as well. (RFC7684).
3688
 */
3689
static void
3690
dissect_ospf_lsa_ext_link(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
3691
                          uint32_t length)
3692
1.40k
{
3693
1.40k
    proto_tree *el_tree;
3694
1.40k
    proto_tree *tlv_tree;
3695
1.40k
    proto_tree *stlv_tree;
3696
1.40k
    proto_item *ti_tree = NULL;
3697
1.40k
    proto_item *ti;
3698
1.40k
    int offset_end = offset + length;
3699
3700
1.40k
    int tlv_type;
3701
1.40k
    unsigned tlv_length;
3702
1.40k
    int tlv_end_offset;
3703
1.40k
    uint16_t stlv_type;
3704
1.40k
    uint16_t stlv_length;
3705
1.40k
    int stlv_offset;
3706
1.40k
    const char *tlv_name;
3707
1.40k
    const char *stlv_name;
3708
1.40k
    uint8_t link_type;
3709
1.40k
    uint32_t sid_label;
3710
1.40k
    uint32_t reserved;
3711
1.40k
    int local_offset;
3712
1.40k
    uint16_t local_length;
3713
1.40k
    uint32_t local_id = 0, remote_id = 0;
3714
1.40k
    uint8_t sabm_length = 0, udabm_length = 0;
3715
3716
1.40k
    el_tree = proto_tree_add_subtree(tree, tvb, offset, length,
3717
1.40k
                                     ett_ospf_lsa_elink, NULL, "OSPFv2 Extended Link Opaque LSA");
3718
3719
2.96k
    while (offset < offset_end) {
3720
2.15k
        tlv_type = tvb_get_ntohs(tvb, offset);
3721
2.15k
        tlv_length = tvb_get_ntohs(tvb, offset + 2);
3722
2.15k
        tlv_end_offset = offset + tlv_length + 4;
3723
2.15k
        tlv_name = val_to_str_const(tlv_type, ext_link_tlv_type_vals, "Unknown");
3724
3725
2.15k
        switch(tlv_type) {
3726
3727
1.58k
        case EXT_LINK_TLV_LINK:
3728
1.58k
            tlv_tree = proto_tree_add_subtree_format(el_tree, tvb, offset, tlv_length + 4,
3729
1.58k
                                                     ett_ospf_lsa_elink_tlv, &ti_tree, "%s TLV", tlv_name);
3730
1.58k
            proto_tree_add_item(tlv_tree, hf_ospf_ls_elink_tlv, tvb, offset, 2, ENC_BIG_ENDIAN);
3731
1.58k
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
3732
3733
1.58k
            link_type = tvb_get_uint8(tvb, offset + 4);
3734
1.58k
            ti = proto_tree_add_item(tlv_tree, hf_ospf_ls_router_linktype, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
3735
1.58k
            proto_item_append_text(ti, " - %s",
3736
1.58k
                                   val_to_str_const(link_type, ospf_v3_lsa_type_vals, "Unknown link type"));
3737
1.58k
            proto_item_append_text(ti_tree, "  (Type: %-8s ID: %-15s Data: %s)",
3738
1.58k
                                   val_to_str_const(link_type, ospf_v3_lsa_type_short_vals, "Unknown"),
3739
1.58k
                                   tvb_ip_to_str(pinfo->pool, tvb, offset + 8),
3740
1.58k
                                   tvb_ip_to_str(pinfo->pool, tvb, offset + 12));
3741
1.58k
            reserved = tvb_get_ntoh24(tvb, offset + 5);
3742
1.58k
            ti = proto_tree_add_item(tlv_tree, hf_ospf_header_reserved, tvb, offset + 5, 3, ENC_NA);
3743
1.58k
            if (reserved != 0) {
3744
1.44k
                expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
3745
1.44k
            }
3746
1.58k
            proto_tree_add_item(tlv_tree, hf_ospf_ls_router_linkid, tvb, offset + 8, 4, ENC_BIG_ENDIAN);
3747
1.58k
            proto_tree_add_item(tlv_tree, hf_ospf_ls_router_linkdata, tvb, offset + 12, 4, ENC_BIG_ENDIAN);
3748
1.58k
            stlv_offset = offset + 16;
3749
3750
            /* Walk down the sub-TLVs in Extended Link TLV */
3751
26.7k
            while (stlv_offset + 4 <= tlv_end_offset) {
3752
25.5k
                stlv_type = tvb_get_ntohs(tvb, stlv_offset);
3753
25.5k
                stlv_length = tvb_get_ntohs(tvb, stlv_offset + 2);
3754
25.5k
                stlv_name = val_to_str_const(stlv_type, ext_link_stlv_type_vals, "Unknown");
3755
3756
25.5k
                stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_length + 4,
3757
25.5k
                                                          ett_ospf_lsa_elink_stlv, &ti_tree,
3758
25.5k
                                                          "%s Sub-TLV", stlv_name);
3759
25.5k
                proto_tree_add_item(stlv_tree, hf_ospf_ls_elink_stlv, tvb, stlv_offset, 2, ENC_BIG_ENDIAN);
3760
25.5k
                ti = proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset + 2, 2, ENC_BIG_ENDIAN);
3761
25.5k
                switch (stlv_type) {
3762
834
                case SR_STLV_ADJSID:
3763
834
                    if (stlv_length == 7) {
3764
270
                        sid_label = tvb_get_ntoh24(tvb, stlv_offset + 8);
3765
564
                    } else if (stlv_length == 8) {
3766
294
                        sid_label = tvb_get_ntohl(tvb, stlv_offset + 8);
3767
294
                    } else {
3768
                        /* Invalid sub-TLV length. */
3769
270
                        proto_item_append_text(ti, " [Invalid length - %u]", stlv_length);
3770
270
                        proto_tree_add_item(stlv_tree, hf_ospf_tlv_value, tvb, stlv_offset + 4, stlv_length, ENC_NA);
3771
270
                        break;
3772
270
                    }
3773
564
                    proto_tree_add_bitmask(stlv_tree, tvb, stlv_offset + 4, hf_ospf_ls_adjsid_flags, ett_ospf_lsa_adjsid_flags, bf_ospf_adjsid_flags, ENC_BIG_ENDIAN);
3774
564
                    reserved = tvb_get_uint8(tvb, offset + 5);
3775
564
                    ti = proto_tree_add_item(stlv_tree, hf_ospf_header_reserved, tvb, stlv_offset + 5, 1, ENC_NA);
3776
564
                    if (reserved != 0) {
3777
358
                        proto_item_append_text(ti, " [incorrect, should be 0]");
3778
358
                    }
3779
564
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_elink_mt_id, tvb, stlv_offset + 6, 1, ENC_BIG_ENDIAN);
3780
564
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_elink_weight, tvb, stlv_offset + 7, 1, ENC_BIG_ENDIAN);
3781
564
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_sid_label, tvb, stlv_offset + 8, (stlv_length - 4), ENC_BIG_ENDIAN);
3782
564
                    proto_item_append_text(ti_tree, "  (SID/Label: %u)", sid_label);
3783
564
                    break;
3784
3785
1.20k
                case SR_STLV_LAN_ADJSID:
3786
1.20k
                    if (stlv_length == 11) {
3787
527
                        sid_label = tvb_get_ntoh24(tvb, stlv_offset + 12);
3788
682
                    } else if (stlv_length == 12) {
3789
429
                        sid_label = tvb_get_ntohl(tvb, stlv_offset + 12);
3790
429
                    } else {
3791
                        /* Invalid sub-TLV length. */
3792
253
                        proto_item_append_text(ti, " [Invalid length - %u]", stlv_length);
3793
253
                        proto_tree_add_item(stlv_tree, hf_ospf_tlv_value, tvb, stlv_offset + 4, stlv_length, ENC_NA);
3794
253
                        break;
3795
253
                    }
3796
956
                    proto_tree_add_bitmask(stlv_tree, tvb, stlv_offset + 4, hf_ospf_ls_adjsid_flags, ett_ospf_lsa_adjsid_flags, bf_ospf_adjsid_flags, ENC_BIG_ENDIAN);
3797
956
                    reserved = tvb_get_uint8(tvb, offset + 5);
3798
956
                    ti = proto_tree_add_item(stlv_tree, hf_ospf_header_reserved, tvb, stlv_offset + 5, 1, ENC_NA);
3799
956
                    if (reserved != 0) {
3800
719
                        expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
3801
719
                    }
3802
956
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_elink_mt_id, tvb, stlv_offset + 6, 1, ENC_BIG_ENDIAN);
3803
956
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_elink_weight, tvb, stlv_offset + 7, 1, ENC_BIG_ENDIAN);
3804
956
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_elink_nbr, tvb, stlv_offset + 8, 4, ENC_BIG_ENDIAN);
3805
956
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_sid_label, tvb, stlv_offset + 12, (stlv_length - 8), ENC_BIG_ENDIAN);
3806
956
                    proto_item_append_text(ti_tree, "  (SID/Label: %u, Neighbor: %s)",
3807
956
                                           sid_label, tvb_ip_to_str(pinfo->pool, tvb, stlv_offset + 8));
3808
956
                    break;
3809
3810
495
                case SR_STLV_LINK_MSD:
3811
                    /* Link MSD Sub-TLV (rfc8476) */
3812
495
                    local_length = stlv_length;
3813
495
                    local_offset = stlv_offset + 4;
3814
1.34k
                    while (local_length >= 2) {
3815
850
                        proto_tree_add_item(stlv_tree, hf_ospf_ls_igp_msd_type, tvb, local_offset, 1, ENC_NA);
3816
850
                        proto_tree_add_item(stlv_tree, hf_ospf_ls_igp_msd_value, tvb, local_offset+1, 1, ENC_NA);
3817
850
                        local_offset += 2;
3818
850
                        local_length -= 2;
3819
850
                    }
3820
495
                    break;
3821
3822
531
                case SR_STLV_REMOTE_IPV4_ADDRESS:
3823
                    /* Remote IPv4 Address Sub-TLV (rfc8379) */
3824
531
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_remote_ipv4_addr, tvb, stlv_offset + 4, 4, ENC_BIG_ENDIAN);
3825
531
                    proto_item_append_text(ti_tree, "  (%s)", tvb_ip_to_str(pinfo->pool, tvb, stlv_offset + 4));
3826
531
                    break;
3827
3828
313
                case SR_STLV_LOCAL_REMOTE_INTERFACE_ID:
3829
                    /* Local/Remote Interface ID Sub-TLV (rfc8379) */
3830
313
                    proto_tree_add_item_ret_uint(stlv_tree, hf_ospf_ls_local_interface_id, tvb, stlv_offset + 4, 4, ENC_BIG_ENDIAN, &local_id);
3831
313
                    proto_tree_add_item_ret_uint(stlv_tree, hf_ospf_ls_remote_interface_id, tvb, stlv_offset + 8, 4, ENC_BIG_ENDIAN, &remote_id);
3832
313
                    proto_item_append_text(ti_tree, "  (Local: %u, Remote: %u)", local_id, remote_id);
3833
313
                    break;
3834
3835
17.2k
                case SR_STLV_APP_SPEC_LINK_ATTR:
3836
                    /* Application-Specific Link Attributes Sub-TLV (rfc9492) */
3837
17.2k
                    local_length = stlv_length;
3838
17.2k
                    local_offset = stlv_offset + 4;
3839
17.2k
                    proto_tree_add_item_ret_uint8(stlv_tree, hf_ospf_ls_app_sabm_length, tvb, local_offset, 1, ENC_NA, &sabm_length);
3840
17.2k
                    proto_tree_add_item_ret_uint8(stlv_tree, hf_ospf_ls_app_udabm_length, tvb, local_offset + 1, 1, ENC_NA, &udabm_length);
3841
17.2k
                    reserved = tvb_get_uint16(tvb, local_offset + 2, ENC_BIG_ENDIAN);
3842
17.2k
                    ti = proto_tree_add_item(stlv_tree, hf_ospf_header_reserved, tvb, local_offset + 2, 2, ENC_NA);
3843
17.2k
                    if (reserved != 0) {
3844
2.33k
                        expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
3845
2.33k
                    }
3846
17.2k
                    local_offset += 4;
3847
17.2k
                    local_length -= 4;
3848
17.2k
                    if (sabm_length > 0 ) {
3849
449
                        proto_tree_add_bitmask(stlv_tree, tvb, local_offset,
3850
449
                                               hf_ospf_ls_app_sabm_bits,
3851
449
                                               ett_ospf_lsa_app_sabm_bits,
3852
449
                                               bf_ospf_app_sabm_bits, ENC_NA);
3853
449
                        local_offset += sabm_length;
3854
449
                        local_length -= sabm_length;
3855
449
                    }
3856
17.2k
                    if (udabm_length > 0) {
3857
16.6k
                        proto_tree_add_item(stlv_tree, hf_ospf_ls_app_udabm_bits,
3858
16.6k
                                            tvb, local_offset, udabm_length, ENC_NA);
3859
16.6k
                        local_offset += udabm_length;
3860
16.6k
                        local_length -= udabm_length;
3861
16.6k
                    }
3862
                    /* Link Attribute Sub-TLVs */
3863
17.2k
                    if (local_length > 4) {
3864
16.9k
                        dissect_ospf_lsa_app_link_attributes(tvb, pinfo, local_offset, stlv_tree, local_length);
3865
16.9k
                    }
3866
17.2k
                    break;
3867
3868
4.85k
                default:
3869
4.85k
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_value, tvb, stlv_offset + 4, stlv_length, ENC_NA);
3870
4.85k
                    proto_item_append_text(ti_tree, "  (t=%u, l=%u)", stlv_type, stlv_length);
3871
4.85k
                    break;
3872
25.5k
                }
3873
25.2k
                stlv_offset += 4 + WS_ROUNDUP_4(stlv_length);
3874
25.2k
            }
3875
1.20k
            break;
3876
3877
1.20k
        default:
3878
517
            if (tlv_length > (unsigned)(offset_end - offset)) {
3879
                /* Invalid length, probably not TLV. */
3880
121
                return;
3881
121
            }
3882
396
            tlv_tree = proto_tree_add_subtree_format(el_tree, tvb, offset, tlv_length + 4,
3883
396
                                                     ett_ospf_lsa_elink_tlv, NULL,
3884
396
                                                     "%s TLV: %u - Unknown", tlv_name, tlv_type);
3885
396
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_type_opaque, tvb, offset, 2, ENC_BIG_ENDIAN);
3886
396
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
3887
396
            proto_tree_add_item(tlv_tree, hf_ospf_unknown_tlv, tvb, offset + 4, tlv_length, ENC_NA);
3888
396
            break;
3889
3890
2.15k
        }
3891
3892
        /*
3893
         * RFC 7770, section 2.3: 4-octet aligned, but type, length and padding
3894
         * is not included in the length.
3895
         * */
3896
1.55k
        offset += 4 + WS_ROUNDUP_4(tlv_length);
3897
1.55k
    }
3898
1.40k
}
3899
3900
/*
3901
 * Dissect Extended Inter-Area ASBR LSA
3902
 *
3903
 * This function dissects the Optional Extended Inter-Area ASBR LSA.
3904
 * The below function adds the support to handle this as well. (RFC9350).
3905
 */
3906
static void
3907
dissect_ospf_lsa_ext_ia_asbr(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, uint32_t length)
3908
532
{
3909
532
    proto_tree *eia_tree;
3910
532
    proto_tree *tlv_tree;
3911
532
    proto_tree *stlv_tree;
3912
532
    proto_item *ti_tree = NULL;
3913
532
    proto_item *ti = NULL;
3914
532
    int offset_end = offset + length;
3915
3916
532
    uint16_t tlv_type;
3917
532
    uint16_t tlv_length;
3918
532
    int tlv_offset_end;
3919
532
    uint16_t stlv_type;
3920
532
    uint16_t stlv_length;
3921
532
    int stlv_offset, stlv_offset_end;
3922
532
    const char *tlv_name;
3923
532
    const char *stlv_name;
3924
532
    uint32_t reserved, metric;
3925
3926
532
    eia_tree = proto_tree_add_subtree(tree, tvb, offset, length, ett_ospf_lsa_eia_asbr, NULL,
3927
532
                                      "OSPFv2 Extended Inter-Area ASBR LSA");
3928
3929
952
    while (offset + 4 <= offset_end) {
3930
848
        tlv_type = tvb_get_ntohs(tvb, offset);
3931
848
        tlv_length = tvb_get_ntohs(tvb, offset + 2);
3932
848
        tlv_offset_end = offset + tlv_length + 4;
3933
848
        tlv_name = val_to_str_const(tlv_type, ext_ia_asbr_tlv_type_vals, "Unknown");
3934
3935
848
        switch(tlv_type) {
3936
438
        case EXT_IA_ASBR_TLV_EIA_ASBR:
3937
438
            tlv_tree = proto_tree_add_subtree_format(eia_tree, tvb, offset, tlv_length + 4,
3938
438
                                                     ett_ospf_lsa_eia_asbr_tlv, &ti_tree,
3939
438
                                                     "%s TLV", tlv_name);
3940
438
            proto_tree_add_item(tlv_tree, hf_ospf_ls_eia_asbr_tlv, tvb, offset, 2, ENC_BIG_ENDIAN);
3941
438
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
3942
438
            if (tlv_length < 4 || tlv_offset_end > offset_end) {
3943
161
                proto_tree_add_expert_format(tlv_tree, pinfo,
3944
161
                                             &ei_ospf_stlv_length_invalid, tvb, offset + 2, 2,
3945
161
                                             "Invalid TLV length: %u", tlv_length);
3946
161
                return;
3947
161
            }
3948
277
            proto_tree_add_item(tlv_tree, hf_ospf_ls_eia_asbr_asbr_routerid, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
3949
277
            proto_item_append_text(ti_tree, "  (ASBR: %s)",
3950
277
                                   tvb_ip_to_str(pinfo->pool, tvb, offset + 4));
3951
277
            stlv_offset = offset + 8;
3952
3953
            /* Walk down the sub-TLVs in Extended Inter-Area ASBR TLV */
3954
881
            while (stlv_offset + 4 <= tlv_offset_end) {
3955
727
                stlv_type = tvb_get_ntohs(tvb, stlv_offset);
3956
727
                stlv_length = tvb_get_ntohs(tvb, stlv_offset + 2);
3957
727
                stlv_offset_end = stlv_offset + stlv_length + 4;
3958
727
                stlv_name = val_to_str_const(stlv_type, ext_ia_asbr_stlv_type_vals, "Unknown");
3959
3960
727
                stlv_tree = proto_tree_add_subtree_format(tlv_tree, tvb, stlv_offset, stlv_length + 4,
3961
727
                                                          ett_ospf_lsa_eia_asbr_stlv, &ti_tree,
3962
727
                                                          "%s Sub-TLV", stlv_name);
3963
727
                proto_tree_add_item(stlv_tree, hf_ospf_ls_eia_asbr_stlv, tvb, stlv_offset, 2, ENC_BIG_ENDIAN);
3964
727
                proto_tree_add_item(stlv_tree, hf_ospf_tlv_length, tvb, stlv_offset + 2, 2, ENC_BIG_ENDIAN);
3965
727
                if (stlv_offset_end > offset_end) {
3966
42
                    proto_tree_add_expert_format(stlv_tree, pinfo,
3967
42
                                                 &ei_ospf_stlv_length_invalid, tvb, stlv_offset + 2, 2,
3968
42
                                                 "Invalid sub-TLV length: %u", stlv_length);
3969
42
                    return;
3970
42
                }
3971
685
                switch (stlv_type) {
3972
363
                case SR_STLV_FLEX_ALGO_ASBR_METRIC:
3973
                    /* Flexible Algorithm ASBR Metric (FAAM) */
3974
363
                    if (stlv_length != 8) {
3975
211
                        proto_tree_add_expert_format(stlv_tree, pinfo,
3976
211
                                                     &ei_ospf_stlv_length_invalid, tvb, stlv_offset + 2, 2,
3977
211
                                                     "Invalid sub-TLV length: %u (should be 8)", stlv_length);
3978
211
                        break;
3979
211
                    }
3980
152
                    proto_tree_add_item(stlv_tree, hf_ospf_ls_flex_algorithm, tvb, stlv_offset + 4, 1, ENC_NA);
3981
152
                    reserved = tvb_get_uint24(tvb, stlv_offset + 5, ENC_BIG_ENDIAN);
3982
152
                    ti = proto_tree_add_item(stlv_tree, hf_ospf_header_reserved, tvb, stlv_offset + 5, 3, ENC_NA);
3983
152
                    if (reserved != 0) {
3984
86
                        expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
3985
86
                    }
3986
152
                    proto_tree_add_item_ret_uint(stlv_tree, hf_ospf_ls_faam_metric, tvb, stlv_offset + 8, 4, ENC_BIG_ENDIAN, &metric);
3987
152
                    proto_item_append_text(ti_tree, "  (Metric: %u)", metric);
3988
152
                    break;
3989
3990
286
                default:
3991
286
                    proto_tree_add_item(stlv_tree, hf_ospf_tlv_value, tvb, stlv_offset + 4, stlv_length, ENC_NA);
3992
286
                    proto_item_append_text(ti_tree, "  (t=%u, l=%u)", stlv_type, stlv_length);
3993
286
                    break;
3994
685
                }
3995
604
                stlv_offset += 4 + WS_ROUNDUP_4(stlv_length);
3996
604
            }
3997
154
            break;
3998
3999
357
        default:
4000
357
            if (tlv_length > (unsigned)(offset_end - offset)) {
4001
                /* Invalid length, probably not TLV. */
4002
72
                return;
4003
72
            }
4004
285
            tlv_tree = proto_tree_add_subtree_format(eia_tree, tvb, offset, tlv_length + 4,
4005
285
                                                     ett_ospf_lsa_eia_asbr_tlv, NULL,
4006
285
                                                     "%s TLV: %u - Unknown", tlv_name, tlv_type);
4007
285
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_type_opaque, tvb, offset, 2, ENC_BIG_ENDIAN);
4008
285
            proto_tree_add_item(tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
4009
285
            proto_tree_add_item(tlv_tree, hf_ospf_unknown_tlv, tvb, offset + 4, tlv_length, ENC_NA);
4010
285
            break;
4011
4012
848
        }
4013
4014
        /*
4015
         * RFC 7770, section 2.3: 4-octet aligned, but type, length and padding
4016
         * is not included in the length.
4017
         * */
4018
420
        offset += 4 + WS_ROUNDUP_4(tlv_length);
4019
420
    }
4020
532
}
4021
4022
/*
4023
 * Dissect opaque LSAs
4024
 */
4025
static void
4026
dissect_ospf_lsa_opaque(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
4027
                        uint8_t ls_id_type, uint32_t length)
4028
4.17k
{
4029
4.17k
    switch (ls_id_type) {
4030
4031
1.25k
    case OSPF_LSA_MPLS_TE:
4032
1.25k
        dissect_ospf_lsa_mpls(tvb, pinfo, offset, tree, length);
4033
1.25k
        break;
4034
100
    case OSPF_LSA_OPAQUE_RI:
4035
100
        dissect_ospf_lsa_opaque_ri(tvb, pinfo, offset, tree, length);
4036
100
        break;
4037
276
    case OSPF_LSA_GRACE:
4038
276
        dissect_ospf_lsa_grace_tlv(tvb, pinfo, offset, tree, length, OSPF_VERSION_2);
4039
276
        break;
4040
483
    case OSPF_LSA_EXT_PREFIX:
4041
483
        dissect_ospf_lsa_ext_prefix(tvb, pinfo, offset, tree, length);
4042
483
        break;
4043
1.40k
    case OSPF_LSA_EXT_LINK:
4044
1.40k
        dissect_ospf_lsa_ext_link(tvb, pinfo, offset, tree, length);
4045
1.40k
        break;
4046
532
    case OSPF_LSA_EXT_IA_ASBR:
4047
532
        dissect_ospf_lsa_ext_ia_asbr(tvb, pinfo, offset, tree, length);
4048
532
        break;
4049
4050
125
    default:
4051
125
        proto_tree_add_expert_format(tree, pinfo, &ei_ospf_lsa_unknown_type, tvb, offset, length,
4052
125
                            "Unknown LSA Type %u", ls_id_type);
4053
125
        break;
4054
4.17k
    } /* switch on opaque LSA id */
4055
4.17k
}
4056
4057
static int
4058
dissect_ospf_v2_lsa(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
4059
                    bool disassemble_body)
4060
6.25k
{
4061
6.25k
    proto_tree *ospf_lsa_tree;
4062
6.25k
    proto_item *ti, *lsa_ti, *hidden_item;
4063
4064
6.25k
    uint8_t              ls_type;
4065
6.25k
    uint16_t             ls_length;
4066
6.25k
    int                  end_offset;
4067
6.25k
    uint32_t             nr_links;
4068
6.25k
    uint16_t             nr_metric;
4069
4070
    /* router LSA */
4071
6.25k
    uint8_t              link_type;
4072
6.25k
    uint16_t             metric_counter;
4073
6.25k
    const char          *metric_type_str;
4074
4075
    /* AS-external LSA */
4076
6.25k
    uint8_t              options;
4077
4078
    /* opaque LSA */
4079
6.25k
    uint8_t              ls_id_type;
4080
4081
6.25k
    uint8_t              ls_length_constraints[] = { 0, 24, 28, 28, 28, 36, 20, 36, 20, 20, 20, 20 };
4082
4083
6.25k
    ls_type = tvb_get_uint8(tvb, offset + 3);
4084
6.25k
    ls_length = tvb_get_ntohs(tvb, offset + 18);
4085
6.25k
    end_offset = offset + ls_length;
4086
4087
6.25k
    ospf_lsa_tree = proto_tree_add_subtree_format(tree, tvb, offset,
4088
6.25k
                        disassemble_body?ls_length:OSPF_LSA_HEADER_LENGTH,
4089
6.25k
                        ett_ospf_lsa, &lsa_ti, "LSA-type %d (%s), len %d",
4090
6.25k
                        ls_type, val_to_str_const(ls_type, ls_type_vals, "Unknown"),
4091
6.25k
                        ls_length);
4092
6.25k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_age, tvb,
4093
6.25k
                        offset, 2, ENC_BIG_ENDIAN);
4094
6.25k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_donotage, tvb,
4095
6.25k
                        offset, 2, ENC_BIG_ENDIAN);
4096
6.25k
    options = tvb_get_uint8 (tvb, offset + 2);
4097
6.25k
    if (ls_type != 7)
4098
5.58k
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset + 2, hf_ospf_v2_options, ett_ospf_v2_options, bf_v2_options, ENC_BIG_ENDIAN);
4099
666
    else
4100
666
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset + 2, hf_ospf_v2_options, ett_ospf_v2_options, bf_v2_options_lsa7, ENC_BIG_ENDIAN);
4101
6.25k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_type, tvb,
4102
6.25k
                        offset + 3, 1, ENC_BIG_ENDIAN);
4103
6.25k
    if (ospf_ls_type_to_filter(ls_type) != -1) {
4104
5.16k
        hidden_item = proto_tree_add_item(ospf_lsa_tree,
4105
5.16k
                                          *hf_ospf_ls_type_array[ospf_ls_type_to_filter(ls_type)], tvb,
4106
5.16k
                                          offset + 3, 1, ENC_BIG_ENDIAN);
4107
5.16k
        proto_item_set_hidden(hidden_item);
4108
5.16k
    }
4109
4110
6.25k
    if (options & OSPF_V2_OPTIONS_MT) {
4111
2.81k
        metric_type_str = "MT-ID";
4112
3.43k
    } else {
4113
3.43k
        metric_type_str = "TOS";
4114
3.43k
    }
4115
4116
6.25k
    if (is_opaque(ls_type)) {
4117
4.33k
        ls_id_type = tvb_get_uint8(tvb, offset + 4);
4118
4.33k
        proto_tree_add_uint(ospf_lsa_tree, hf_ospf_ls_opaque_type,
4119
4.33k
                            tvb, offset + 4, 1, ls_id_type);
4120
4121
4.33k
        switch (ls_id_type) {
4122
4123
1.31k
        case OSPF_LSA_MPLS_TE:
4124
1.31k
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_id_te_lsa_reserved, tvb, offset + 5, 1, ENC_BIG_ENDIAN);
4125
1.31k
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_mpls_te_instance,
4126
1.31k
                                tvb, offset + 6, 2, ENC_BIG_ENDIAN);
4127
1.31k
            break;
4128
4129
100
        case OSPF_LSA_OPAQUE_RI:
4130
3.01k
        default:
4131
3.01k
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_id_opaque_id, tvb, offset + 5, 3, ENC_BIG_ENDIAN);
4132
3.01k
            break;
4133
4.33k
        }
4134
4.33k
    } else {
4135
1.91k
        ls_id_type = 0;
4136
1.91k
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_id, tvb,
4137
1.91k
                            offset + 4, 4, ENC_BIG_ENDIAN);
4138
1.91k
    }
4139
4140
6.25k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_adv_router,
4141
6.25k
                        tvb, offset + 8, 4, ENC_BIG_ENDIAN);
4142
6.25k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_seqnum, tvb,
4143
6.25k
                        offset + 12, 4, ENC_BIG_ENDIAN);
4144
6.25k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_chksum, tvb,
4145
6.25k
                        offset + 16, 2, ENC_BIG_ENDIAN);
4146
6.25k
    ti = proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_length, tvb,
4147
6.25k
                        offset + 18, 2, ENC_BIG_ENDIAN);
4148
4149
6.25k
    if(ls_type && ls_type <= OSPF_LSTYPE_OP_ASWIDE) {
4150
5.16k
        if(ls_length < ls_length_constraints[ls_type]) {
4151
43
            expert_add_info_format(pinfo, ti, &ei_ospf_lsa_bad_length, "Invalid LSA length (%u) for type %s, expected >= (%u)",
4152
43
                                ls_length, val_to_str_const(ls_type, ls_type_vals, "Unknown"), ls_length_constraints[ls_type]);
4153
43
            return -1;
4154
43
        }
4155
5.16k
    } else if(ls_length < 20) { /* As type is unknown, we check for a minimum length of 20 */
4156
135
        expert_add_info_format(pinfo, ti, &ei_ospf_lsa_bad_length, "Invalid LSA length (%u) for unknown LSA type (%u), expected minimum of (20)", ls_length, ls_type);
4157
135
        return -1;
4158
135
    }
4159
4160
    /* skip past the LSA header to the body */
4161
6.07k
    offset += OSPF_LSA_HEADER_LENGTH;
4162
6.07k
    if (ls_length <= OSPF_LSA_HEADER_LENGTH)
4163
89
        return offset;  /* no data, or bogus length */
4164
5.98k
    ls_length -= OSPF_LSA_HEADER_LENGTH;
4165
4166
5.98k
    if (!disassemble_body)
4167
585
        return offset;
4168
4169
5.39k
    switch (ls_type){
4170
4171
149
    case OSPF_LSTYPE_ROUTER:
4172
        /* flags field in an router-lsa */
4173
149
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset, hf_ospf_v2_router_lsa_flag, ett_ospf_v2_router_lsa_flags, bf_v2_router_lsa_flags, ENC_BIG_ENDIAN);
4174
        /* TODO: flags are only 1 byte, so there is an apparently unused byte here */
4175
149
        proto_tree_add_item_ret_uint(ospf_lsa_tree, hf_ospf_lsa_number_of_links, tvb, offset + 2, 2, ENC_BIG_ENDIAN, &nr_links);
4176
4177
149
        offset += 4;
4178
4179
        /* nr_links links follow
4180
         * maybe we should put each of the links into its own subtree ???
4181
         */
4182
404
        for (unsigned link_counter = 0; link_counter < nr_links; link_counter++) {
4183
255
            proto_tree *ospf_lsa_router_link_tree;
4184
255
            proto_item *ti_item;
4185
4186
4187
            /* check the Link Type and ID */
4188
255
            link_type = tvb_get_uint8(tvb, offset + 8);
4189
255
            nr_metric = tvb_get_uint8(tvb, offset + 9);
4190
4191
255
            ospf_lsa_router_link_tree = proto_tree_add_subtree_format(ospf_lsa_tree, tvb, offset, 12 + 4 * nr_metric,
4192
255
                                           ett_ospf_lsa_router_link, NULL, "Type: %-8s ID: %-15s Data: %-15s Metric: %d",
4193
255
                                           val_to_str_const(link_type, ospf_v3_lsa_type_short_vals, "Unknown"),
4194
255
                                           tvb_ip_to_str(pinfo->pool, tvb, offset),
4195
255
                                           tvb_ip_to_str(pinfo->pool, tvb, offset + 4),
4196
255
                                           tvb_get_ntohs(tvb, offset + 10));
4197
4198
255
            ti_item = proto_tree_add_item(ospf_lsa_router_link_tree, hf_ospf_ls_router_linkid,
4199
255
                        tvb, offset, 4, ENC_BIG_ENDIAN);
4200
255
            proto_item_append_text(ti_item, " - %s", val_to_str_const(link_type, ospf_v3_lsa_link_id_vals, "Unknown link ID"));
4201
4202
            /* link_data should be specified in detail (e.g. network mask) (depends on link type)*/
4203
255
            proto_tree_add_item(ospf_lsa_router_link_tree, hf_ospf_ls_router_linkdata,
4204
255
                        tvb, offset +4, 4, ENC_BIG_ENDIAN);
4205
4206
255
            ti_item = proto_tree_add_item(ospf_lsa_router_link_tree, hf_ospf_ls_router_linktype,
4207
255
                        tvb, offset + 8, 1, ENC_BIG_ENDIAN);
4208
255
            proto_item_append_text(ti_item, " - %s", val_to_str_const(link_type, ospf_v3_lsa_type_vals, "Unknown link type"));
4209
4210
255
            ti_item = proto_tree_add_item(ospf_lsa_router_link_tree, hf_ospf_ls_router_nummetrics,
4211
255
                                tvb, offset + 9, 1, ENC_BIG_ENDIAN);
4212
255
            proto_item_append_text(ti_item, " - %s", metric_type_str);
4213
255
            proto_tree_add_item(ospf_lsa_router_link_tree, hf_ospf_ls_router_metric0,
4214
255
                                tvb, offset + 10, 2, ENC_BIG_ENDIAN);
4215
4216
255
            offset += 12;
4217
4218
            /* nr_metric metrics may follow each link
4219
             * According to RFC4915 the TOS metrics was never deployed and was subsequently deprecated,
4220
             * but decoding still present because MT-ID use the same structure.
4221
             */
4222
545
            for (metric_counter = 0; metric_counter < nr_metric; metric_counter++) {
4223
290
                proto_tree_add_uint_format(ospf_lsa_router_link_tree, hf_ospf_ls_metric, tvb, offset, 4,
4224
290
                                    tvb_get_ntohs(tvb, offset + 2), "%s: %u, Metric: %u",
4225
290
                                    metric_type_str,
4226
290
                                    tvb_get_uint8(tvb, offset),
4227
290
                                    tvb_get_ntohs(tvb, offset + 2));
4228
290
                offset += 4;
4229
290
            }
4230
255
        }
4231
149
        break;
4232
4233
110
    case OSPF_LSTYPE_NETWORK:
4234
110
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_network_netmask,
4235
110
                            tvb, offset, 4, ENC_BIG_ENDIAN);
4236
110
        offset += 4;
4237
4238
110
        if (offset == end_offset)
4239
0
                proto_tree_add_expert_format(ospf_lsa_tree, pinfo, &ei_ospf_lsa_constraint_missing, tvb, offset - 4, 4, "1 or more router-IDs required");
4240
4241
656
        while (offset < end_offset) {
4242
546
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_network_attachrtr,
4243
546
                                tvb, offset, 4, ENC_BIG_ENDIAN);
4244
546
            offset += 4;
4245
546
        }
4246
110
        break;
4247
4248
138
    case OSPF_LSTYPE_SUMMARY:
4249
        /* Type 3 and 4 LSAs have the same format */
4250
247
    case OSPF_LSTYPE_ASBR:
4251
247
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_asbr_netmask,
4252
247
                            tvb, offset, 4, ENC_BIG_ENDIAN);
4253
247
        offset += 4;
4254
4255
247
        if ((offset+4) > end_offset)
4256
0
                expert_add_info_format(pinfo, lsa_ti, &ei_ospf_lsa_constraint_missing, "1 or more TOS metrics required");
4257
4258
731
        while (offset < end_offset) {
4259
484
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_lsa_tos, tvb, offset, 1, ENC_NA);
4260
484
            offset += 1;
4261
484
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_metric, tvb, offset, 3,
4262
484
                                ENC_BIG_ENDIAN);
4263
484
            offset += 3;
4264
484
        }
4265
247
        break;
4266
4267
52
    case OSPF_LSTYPE_ASEXT:
4268
144
    case OSPF_LSTYPE_ASEXT7:
4269
144
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_asext_netmask,
4270
144
                            tvb, offset, 4, ENC_BIG_ENDIAN);
4271
144
        offset += 4;
4272
4273
144
        if ((offset+12) > end_offset)
4274
0
                expert_add_info_format(pinfo, lsa_ti, &ei_ospf_lsa_constraint_missing, "1 or more TOS forwarding blocks required");
4275
4276
342
        while (offset < end_offset) {
4277
198
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_lsa_external_type, tvb, offset, 1, ENC_NA);
4278
198
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_lsa_external_tos, tvb, offset, 1, ENC_NA);
4279
198
            offset += 1;
4280
4281
198
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_metric, tvb, offset, 3, ENC_BIG_ENDIAN);
4282
198
            offset += 3;
4283
4284
198
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_asext_fwdaddr,
4285
198
                                tvb, offset, 4, ENC_BIG_ENDIAN);
4286
198
            offset += 4;
4287
4288
198
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_asext_extrtrtag,
4289
198
                                tvb, offset, 4, ENC_BIG_ENDIAN);
4290
198
            offset += 4;
4291
198
        }
4292
144
        break;
4293
4294
1.51k
    case OSPF_LSTYPE_OP_LINKLOCAL:
4295
2.56k
    case OSPF_LSTYPE_OP_AREALOCAL:
4296
4.17k
    case OSPF_LSTYPE_OP_ASWIDE:
4297
        /*
4298
         * RFC 2370 opaque LSAs.
4299
         */
4300
4.17k
        dissect_ospf_lsa_opaque(tvb, pinfo, offset, ospf_lsa_tree, ls_id_type,
4301
4.17k
                                ls_length);
4302
4.17k
        offset += ls_length;
4303
4.17k
        break;
4304
4305
85
    default:
4306
        /* unknown LSA type */
4307
85
        expert_add_info(pinfo, ti, &ei_ospf_lsa_unknown_type);
4308
85
        offset += ls_length;
4309
85
        break;
4310
5.39k
    }
4311
    /* return the offset of the next LSA */
4312
2.65k
    return offset;
4313
5.39k
}
4314
4315
/* dissect common elements of the Network E-LSA and LSA */
4316
static void dissect_ospf_v3_network_lsa_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ospf_lsa_tree, int *offset, uint16_t *ls_length)
4317
401
{
4318
    /* reserved field */
4319
401
    uint8_t reserved = tvb_get_uint8(tvb, *offset);
4320
401
    proto_item *ti = proto_tree_add_item(ospf_lsa_tree, hf_ospf_header_reserved, tvb, *offset, 1, ENC_NA);
4321
401
    if (reserved != 0)
4322
252
        expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
4323
4324
    /* options field in an network-lsa */
4325
401
    proto_tree_add_bitmask(ospf_lsa_tree, tvb, *offset + 1, hf_ospf_v3_options, ett_ospf_v3_options, bf_v3_options, ENC_BIG_ENDIAN);
4326
4327
401
    *offset += 4;
4328
401
    *ls_length-=4;
4329
401
}
4330
4331
static int
4332
dissect_ospf_v3_lsa(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
4333
                    bool disassemble_body, uint8_t address_family)
4334
3.81k
{
4335
3.81k
    proto_tree *ospf_lsa_tree, *router_tree = NULL, *router_entry_tree, *lsa_type_tree;
4336
3.81k
    proto_item *ti, *hidden_item, *type_item;
4337
4338
3.81k
    uint16_t             ls_type;
4339
3.81k
    uint16_t             ls_length;
4340
3.81k
    int                  end_offset;
4341
3.81k
    uint8_t              reserved;
4342
4343
    /* router LSA */
4344
3.81k
    uint32_t             number_prefixes;
4345
3.81k
    uint8_t              prefix_length;
4346
3.81k
    uint16_t             reserved16;
4347
4348
3.81k
    uint16_t             referenced_ls_type;
4349
3.81k
    uint16_t             entry_count = 0;
4350
4351
3.81k
    uint8_t              flags;
4352
4353
4354
3.81k
    ls_type = tvb_get_ntohs(tvb, offset + 2) & 0x1FFF;
4355
3.81k
    ls_length = tvb_get_ntohs(tvb, offset + 18);
4356
3.81k
    end_offset = offset + ls_length;
4357
4358
3.81k
    ospf_lsa_tree = proto_tree_add_subtree_format(tree, tvb, offset,
4359
3.81k
                        disassemble_body?ls_length:OSPF_LSA_HEADER_LENGTH,
4360
3.81k
                        ett_ospf_lsa, &type_item, "LSA-type %d (%s), len %d",
4361
3.81k
                        ls_type, val_to_str_const(ls_type, v3_ls_type_vals, "Unknown"),
4362
3.81k
                        ls_length);
4363
3.81k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_age, tvb, offset, 2, ENC_BIG_ENDIAN);
4364
3.81k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_do_not_age, tvb, offset, 2, ENC_BIG_ENDIAN);
4365
4366
3.81k
    ti = proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_ls_type, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
4367
3.81k
    lsa_type_tree = proto_item_add_subtree(ti, ett_ospf_lsa_type);
4368
3.81k
    proto_tree_add_item(lsa_type_tree, hf_ospf_v3_ls_type_u, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
4369
3.81k
    proto_tree_add_item(lsa_type_tree, hf_ospf_v3_ls_type_s12, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
4370
3.81k
    proto_tree_add_item(lsa_type_tree, hf_ospf_v3_ls_type_fc, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
4371
4372
3.81k
    if (ospf_v3_ls_type_to_filter(ls_type) != -1) {
4373
2.23k
        hidden_item = proto_tree_add_item(ospf_lsa_tree,
4374
2.23k
                                          *hf_ospf_v3_ls_type_array[ospf_v3_ls_type_to_filter(ls_type)], tvb,
4375
2.23k
                                          offset + 2, 2, ENC_BIG_ENDIAN);
4376
2.23k
        proto_item_set_hidden(hidden_item);
4377
2.23k
    }
4378
4379
3.81k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_link_state_id, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
4380
4381
3.81k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_adv_router,
4382
3.81k
                        tvb, offset + 8, 4, ENC_BIG_ENDIAN);
4383
3.81k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_seqnum, tvb,
4384
3.81k
                        offset + 12, 4, ENC_BIG_ENDIAN);
4385
3.81k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_chksum, tvb,
4386
3.81k
                        offset + 16, 2, ENC_BIG_ENDIAN);
4387
3.81k
    proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_length, tvb,
4388
3.81k
                        offset + 18, 2, ENC_BIG_ENDIAN);
4389
4390
    /* skip past the LSA header to the body */
4391
3.81k
    offset += OSPF_LSA_HEADER_LENGTH;
4392
3.81k
    ls_length -= OSPF_LSA_HEADER_LENGTH;
4393
4394
3.81k
    if (!disassemble_body)
4395
465
        return offset;
4396
4397
3.34k
    switch (ls_type)
4398
3.34k
    {
4399
146
    case OSPF_V3_LSTYPE_ROUTER:
4400
        /* flags field in an router-lsa */
4401
146
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset, hf_ospf_v3_router_lsa_flag, ett_ospf_v3_router_lsa_flags, bf_v3_router_lsa_flags, ENC_BIG_ENDIAN);
4402
4403
        /* options field in an router-lsa */
4404
146
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset + 1, hf_ospf_v3_options, ett_ospf_v3_options, bf_v3_options, ENC_BIG_ENDIAN);
4405
4406
        /* skip the router-lsa flags and options */
4407
146
        offset+=4;
4408
146
        ls_length-=4;
4409
4410
146
        if (ls_length > 0)
4411
79
            router_tree = proto_tree_add_subtree(ospf_lsa_tree, tvb, offset, ls_length,
4412
79
                                ett_ospf_v3_router_interface, NULL, "Router Interfaces");
4413
4414
        /* scan all router-lsa router interfaces */
4415
416
        while (ls_length > 0 ) {
4416
270
            entry_count++;
4417
270
            router_entry_tree = proto_tree_add_subtree_format(router_tree, tvb, offset, 16,
4418
270
                ett_ospf_v3_router_interface_entry, NULL, "Entry #%d", entry_count);
4419
4420
270
            proto_tree_add_item(router_entry_tree, hf_ospf_v3_lsa_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4421
4422
            /* reserved field */
4423
270
            reserved = tvb_get_uint8(tvb, offset+1);
4424
270
            ti = proto_tree_add_item(router_entry_tree, hf_ospf_header_reserved, tvb, offset+1, 1, ENC_NA);
4425
270
            if (reserved != 0)
4426
152
                expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
4427
4428
            /* metric */
4429
270
            proto_tree_add_item(router_entry_tree, hf_ospf_metric, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
4430
4431
            /* Interface ID */
4432
270
            proto_tree_add_item(router_entry_tree, hf_ospf_v3_lsa_interface_id, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
4433
4434
            /* Neighbor Interface ID */
4435
270
            proto_tree_add_item(router_entry_tree, hf_ospf_v3_lsa_neighbor_interface_id, tvb, offset + 8, 4, ENC_BIG_ENDIAN);
4436
4437
            /* Neighbor Router ID */
4438
270
            proto_tree_add_item(router_entry_tree, hf_ospf_v3_lsa_neighbor_router_id, tvb, offset + 12, 4, ENC_BIG_ENDIAN);
4439
4440
            /* skip to the (possible) next entry */
4441
270
            offset+=16;
4442
270
            ls_length-=16;
4443
4444
270
        }
4445
146
        break;
4446
4447
254
    case OSPF_V3_LSTYPE_NETWORK:
4448
254
        dissect_ospf_v3_network_lsa_common(tvb, pinfo, ospf_lsa_tree, &offset, &ls_length);
4449
4450
537
        while (ls_length > 0 ) {
4451
283
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_attached_router, tvb, offset, 4, ENC_BIG_ENDIAN);
4452
283
            ls_length-=4;
4453
283
            offset += 4;
4454
283
        }
4455
254
        break;
4456
4457
271
    case OSPF_V3_LSTYPE_INTER_AREA_PREFIX:
4458
        /* reserved field */
4459
271
        reserved = tvb_get_uint8(tvb, offset);
4460
271
        ti = proto_tree_add_item(ospf_lsa_tree, hf_ospf_header_reserved, tvb, offset, 1, ENC_NA);
4461
271
        if (reserved != 0)
4462
120
            expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
4463
4464
        /* metric */
4465
271
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_metric, tvb, offset + 1, 3, ENC_BIG_ENDIAN);
4466
4467
        /* prefix length */
4468
271
        prefix_length=tvb_get_uint8(tvb, offset+4);
4469
271
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_prefix_length, tvb, offset+4, 1, ENC_BIG_ENDIAN);
4470
4471
        /* prefix options */
4472
271
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset + 5, hf_ospf_v3_prefix_option, ett_ospf_v3_prefix_options, bf_v3_prefix_options, ENC_BIG_ENDIAN);
4473
4474
        /* 16 bits reserved */
4475
271
        reserved16=tvb_get_ntohs(tvb, offset+6);
4476
271
        ti = proto_tree_add_item(ospf_lsa_tree, hf_ospf_header_reserved, tvb, offset+6, 2, ENC_NA);
4477
271
        if (reserved16 != 0)
4478
154
            expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
4479
4480
271
        offset+=8;
4481
4482
        /* address_prefix */
4483
271
        dissect_ospf_v3_address_prefix(tvb, pinfo, offset, prefix_length, ospf_lsa_tree, address_family);
4484
4485
271
        offset+=(prefix_length+31)/32*4;
4486
271
        break;
4487
4488
151
    case OSPF_V3_LSTYPE_INTER_AREA_ROUTER:
4489
        /* reserved field */
4490
151
        reserved = tvb_get_uint8(tvb, offset);
4491
151
        ti = proto_tree_add_item(ospf_lsa_tree, hf_ospf_header_reserved, tvb, offset, 1, ENC_NA);
4492
151
        if (reserved != 0)
4493
56
            expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
4494
4495
        /* options field in an inter-area-router-lsa */
4496
151
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset + 1, hf_ospf_v3_options, ett_ospf_v3_options, bf_v3_options, ENC_BIG_ENDIAN);
4497
4498
        /* reserved field */
4499
151
        reserved = tvb_get_uint8(tvb, offset+4);
4500
151
        ti = proto_tree_add_item(ospf_lsa_tree, hf_ospf_header_reserved, tvb, offset+4, 1, ENC_NA);
4501
151
        if (reserved != 0)
4502
61
            expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
4503
4504
        /* metric */
4505
151
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_metric, tvb, offset + 5, 3, ENC_BIG_ENDIAN);
4506
4507
        /* Destination Router ID */
4508
151
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_destination_router_id, tvb, offset + 8, 4, ENC_BIG_ENDIAN);
4509
4510
151
        offset+=12;
4511
151
        break;
4512
4513
141
    case OSPF_V3_LSTYPE_NSSA:
4514
429
    case OSPF_V3_LSTYPE_AS_EXTERNAL:
4515
        /* flags */
4516
429
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset, hf_ospf_v3_as_external_flag, ett_ospf_v3_as_external_flags, bf_v3_as_external_flags, ENC_BIG_ENDIAN);
4517
429
        flags=tvb_get_uint8(tvb, offset);
4518
4519
        /* 24 bits metric */
4520
429
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_metric, tvb, offset+1, 3, ENC_BIG_ENDIAN);
4521
4522
        /* prefix length */
4523
429
        prefix_length=tvb_get_uint8(tvb, offset+4);
4524
429
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_prefix_length, tvb, offset+4, 1, ENC_BIG_ENDIAN);
4525
4526
        /* prefix options */
4527
429
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset + 5, hf_ospf_v3_prefix_option, ett_ospf_v3_prefix_options, bf_v3_prefix_options, ENC_BIG_ENDIAN);
4528
4529
        /* referenced LS type */
4530
429
        referenced_ls_type=tvb_get_ntohs(tvb, offset+6);
4531
429
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_referenced_ls_type, tvb, offset+6, 2, ENC_BIG_ENDIAN);
4532
4533
429
        offset+=8;
4534
4535
        /* address_prefix */
4536
429
        dissect_ospf_v3_address_prefix(tvb, pinfo, offset, prefix_length, ospf_lsa_tree, address_family);
4537
4538
429
        offset+=(prefix_length+31)/32*4;
4539
4540
        /* Forwarding Address (optional - only if F-flag is on) */
4541
429
        if ( (offset < end_offset) && (flags & OSPF_V3_AS_EXTERNAL_FLAG_F) ) {
4542
74
            if (address_family == OSPF_AF_6) {
4543
40
                proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_forwarding_address_ipv6, tvb, offset, 16, ENC_NA);
4544
40
            } else {
4545
34
                proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_forwarding_address_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
4546
34
            }
4547
4548
74
            offset+=16;
4549
74
        }
4550
4551
        /* External Route Tag (optional - only if T-flag is on) */
4552
429
        if ( (offset < end_offset) && (flags & OSPF_V3_AS_EXTERNAL_FLAG_T) ) {
4553
46
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_external_route_tag, tvb, offset, 4, ENC_BIG_ENDIAN);
4554
46
            offset+=4;
4555
46
        }
4556
4557
        /* Referenced Link State ID (optional - only if Referenced LS type is non-zero */
4558
429
        if ( (offset < end_offset) && (referenced_ls_type != 0) ) {
4559
58
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_referenced_link_state_id, tvb, offset, 4, ENC_BIG_ENDIAN);
4560
58
            offset+=4;
4561
58
        }
4562
429
        break;
4563
4564
207
    case OSPF_V3_LSTYPE_LINK:
4565
        /* router priority */
4566
207
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_router_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
4567
4568
        /* options field in an link-lsa */
4569
207
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset + 1, hf_ospf_v3_options, ett_ospf_v3_options, bf_v3_options, ENC_BIG_ENDIAN);
4570
4571
        /* Link-local Interface Address */
4572
207
        if (address_family == OSPF_AF_6) {
4573
162
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_link_local_interface_address, tvb, offset + 4, 16, ENC_NA);
4574
162
        } else {
4575
45
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_link_local_interface_address_ipv4, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
4576
45
        }
4577
        /* Number prefixes */
4578
207
        proto_tree_add_item_ret_uint(ospf_lsa_tree, hf_ospf_v3_lsa_num_prefixes, tvb, offset+20, 4, ENC_BIG_ENDIAN, &number_prefixes);
4579
4580
207
        offset+=24;
4581
4582
1.31k
        while (number_prefixes > 0) {
4583
4584
            /* prefix length */
4585
1.11k
            prefix_length=tvb_get_uint8(tvb, offset);
4586
1.11k
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_prefix_length, tvb, offset, 1, ENC_BIG_ENDIAN);
4587
4588
            /* prefix options */
4589
1.11k
            proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset + 1, hf_ospf_v3_prefix_option, ett_ospf_v3_prefix_options, bf_v3_prefix_options, ENC_BIG_ENDIAN);
4590
4591
            /* 16 bits reserved */
4592
1.11k
            reserved16=tvb_get_ntohs(tvb, offset+2);
4593
1.11k
            ti = proto_tree_add_item(ospf_lsa_tree, hf_ospf_header_reserved, tvb, offset+2, 2, ENC_NA);
4594
1.11k
            if (reserved16 != 0)
4595
566
                expert_add_info(pinfo, ti, &ei_ospf_header_reserved);
4596
4597
1.11k
            offset+=4;
4598
4599
            /* address_prefix */
4600
1.11k
            dissect_ospf_v3_address_prefix(tvb, pinfo, offset, prefix_length, ospf_lsa_tree, address_family);
4601
4602
1.11k
            offset+=(prefix_length+31)/32*4;
4603
4604
1.11k
            number_prefixes--;
4605
4606
1.11k
        }
4607
207
        break;
4608
4609
98
    case OSPF_V3_LSTYPE_INTRA_AREA_PREFIX:
4610
        /* # prefixes */
4611
98
        proto_tree_add_item_ret_uint(ospf_lsa_tree, hf_ospf_v3_lsa_num_prefixes, tvb, offset, 2, ENC_BIG_ENDIAN, &number_prefixes);
4612
4613
        /* referenced LS type */
4614
98
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_referenced_ls_type, tvb, offset+2, 2, ENC_BIG_ENDIAN);
4615
4616
        /* Referenced Link State ID */
4617
98
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_referenced_link_state_id, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
4618
4619
        /* Referenced Advertising Router */
4620
98
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_referenced_advertising_router, tvb, offset + 8, 4, ENC_BIG_ENDIAN);
4621
4622
98
        offset+=12;
4623
4624
519
        while (number_prefixes > 0) {
4625
4626
            /* prefix length */
4627
421
            prefix_length=tvb_get_uint8(tvb, offset);
4628
421
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_prefix_length, tvb, offset, 1, ENC_BIG_ENDIAN);
4629
4630
            /* prefix options */
4631
421
            proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset + 1, hf_ospf_v3_prefix_option, ett_ospf_v3_prefix_options, bf_v3_prefix_options, ENC_BIG_ENDIAN);
4632
4633
            /* 16 bits metric */
4634
421
            proto_tree_add_item(ospf_lsa_tree, hf_ospf_metric, tvb, offset+2, 2, ENC_BIG_ENDIAN);
4635
4636
421
            offset+=4;
4637
4638
            /* address_prefix */
4639
421
            dissect_ospf_v3_address_prefix(tvb, pinfo, offset, prefix_length, ospf_lsa_tree, address_family);
4640
4641
421
            offset+=(prefix_length+31)/32*4;
4642
4643
421
            number_prefixes--;
4644
421
        }
4645
98
        break;
4646
4647
580
    case OSPF_V3_LSTYPE_OPAQUE_RI:
4648
580
        dissect_ospf_lsa_opaque_ri(tvb, pinfo, offset, ospf_lsa_tree, ls_length);
4649
580
        offset += ls_length;
4650
580
        break;
4651
4652
35
    case OSPF_V3_LSTYPE_E_INTRA_AREA_PREFIX:
4653
        /* prefixes, 0 as per RFC  */
4654
35
        proto_tree_add_item_ret_uint(ospf_lsa_tree, hf_ospf_v3_lsa_num_prefixes, tvb, offset, 2, ENC_BIG_ENDIAN, &number_prefixes);
4655
4656
        /* referenced LS type */
4657
35
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_referenced_ls_type, tvb, offset+2, 2, ENC_BIG_ENDIAN);
4658
4659
        /* Referenced Link State ID */
4660
35
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_referenced_link_state_id, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
4661
4662
        /* Referenced Advertising Router */
4663
35
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_referenced_advertising_router, tvb, offset + 8, 4, ENC_BIG_ENDIAN);
4664
4665
35
        offset+=12;
4666
35
        ls_length-=12;
4667
4668
35
        dissect_ospf6_e_lsa_tlv(tvb, pinfo, offset, ospf_lsa_tree, ls_length, address_family);
4669
35
        offset += ls_length;
4670
35
        break;
4671
4672
82
    case OSPF_V3_LSTYPE_E_ROUTER:
4673
        /* flags field in an router-lsa */
4674
82
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset, hf_ospf_v3_router_lsa_flag, ett_ospf_v3_router_lsa_flags, bf_v3_router_lsa_flags, ENC_BIG_ENDIAN);
4675
4676
        /* options field in an router-lsa */
4677
82
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset + 1, hf_ospf_v3_options, ett_ospf_v3_options, bf_v3_options, ENC_BIG_ENDIAN);
4678
4679
        /* skip the router-lsa flags and options */
4680
82
        offset+=4;
4681
82
        ls_length-=4;
4682
82
        dissect_ospf6_e_lsa_tlv(tvb, pinfo, offset, ospf_lsa_tree, ls_length, address_family);
4683
82
        offset += ls_length;
4684
82
        break;
4685
4686
147
    case OSPF_V3_LSTYPE_E_NETWORK:
4687
        /* reserved field & options */
4688
147
        dissect_ospf_v3_network_lsa_common(tvb, pinfo, ospf_lsa_tree, &offset, &ls_length);
4689
4690
        /* Attached-Routers TLV */
4691
147
        dissect_ospf6_e_lsa_tlv(tvb, pinfo, offset, ospf_lsa_tree, ls_length, address_family);
4692
147
        offset += ls_length;
4693
147
        break;
4694
4695
289
    case OSPF_V3_LSTYPE_E_AS_EXTERNAL:
4696
        /* External-Prefix TLV */
4697
289
        dissect_ospf6_e_lsa_tlv(tvb, pinfo, offset, ospf_lsa_tree, ls_length, address_family);
4698
289
        offset += ls_length;
4699
289
        break;
4700
4701
68
    case OSPF_V3_LSTYPE_E_LINK:
4702
        /* router priority */
4703
68
        proto_tree_add_item(ospf_lsa_tree, hf_ospf_v3_lsa_router_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
4704
4705
        /* options field in an link-lsa */
4706
68
        proto_tree_add_bitmask(ospf_lsa_tree, tvb, offset + 1, hf_ospf_v3_options, ett_ospf_v3_options, bf_v3_options, ENC_BIG_ENDIAN);
4707
4708
68
        offset+=4;
4709
68
        ls_length-=4;
4710
4711
68
        dissect_ospf6_e_lsa_tlv(tvb, pinfo, offset, ospf_lsa_tree, ls_length, address_family);
4712
68
        offset += ls_length;
4713
68
        break;
4714
4715
181
    case OSPF_V3_LSTYPE_GRACE:
4716
        /* Grace-TLV */
4717
181
        dissect_ospf_lsa_grace_tlv(tvb, pinfo, offset, ospf_lsa_tree, ls_length, OSPF_VERSION_3);
4718
181
        offset += ls_length;
4719
181
        break;
4720
4721
103
    default:
4722
        /* unknown LSA type */
4723
103
        expert_add_info_format(pinfo, type_item, &ei_ospf_lsa_unknown_type,
4724
103
                            "Unknown LSA Type %u",ls_type);
4725
103
        offset += ls_length;
4726
103
        break;
4727
3.34k
    }
4728
    /* return the offset of the next LSA */
4729
2.01k
    return offset;
4730
3.34k
}
4731
4732
static void dissect_ospf_v3_address_prefix(tvbuff_t *tvb, packet_info *pinfo, int offset, int prefix_length, proto_tree *tree,
4733
                                           uint8_t address_family)
4734
2.81k
{
4735
4736
2.81k
    int bytes_to_process;
4737
2.81k
    ws_in6_addr prefix;
4738
4739
2.81k
    bytes_to_process=((prefix_length+31)/32)*4;
4740
4741
2.81k
    if (prefix_length > 128) {
4742
103
        proto_tree_add_expert_format(tree, pinfo, &ei_ospf_lsa_bad_length, tvb, offset, bytes_to_process,
4743
103
            "Address Prefix: length is invalid (%d, should be <= 128)",
4744
103
            prefix_length);
4745
103
        return;
4746
103
    }
4747
4748
2.71k
    memset(prefix.bytes, 0, sizeof prefix.bytes);
4749
2.71k
    if (bytes_to_process != 0) {
4750
363
        tvb_memcpy(tvb, prefix.bytes, offset, bytes_to_process);
4751
363
        if (prefix_length % 8) {
4752
209
            prefix.bytes[bytes_to_process - 1] &=
4753
209
                ((0xff00 >> (prefix_length % 8)) & 0xff);
4754
209
        }
4755
363
    }
4756
2.71k
    if (address_family == OSPF_AF_6) {
4757
2.30k
        proto_tree_add_ipv6(tree, hf_ospf_v3_address_prefix_ipv6, tvb, offset, bytes_to_process,
4758
2.30k
                            &prefix);
4759
2.30k
    } else {
4760
410
        proto_tree_add_item(tree, hf_ospf_v3_address_prefix_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
4761
410
    }
4762
4763
2.71k
}
4764
4765
4766
void
4767
proto_register_ospf(void)
4768
14
{
4769
14
    static hf_register_info ospff_info[] = {
4770
4771
14
        {&hf_ospf_header,
4772
14
         { "OSPF Header", "ospf.header", FT_NONE, BASE_NONE, NULL, 0x0,
4773
14
           NULL, HFILL }},
4774
14
        {&hf_ospf_header_version,
4775
14
         { "Version", "ospf.version", FT_UINT8, BASE_DEC, NULL, 0x0,
4776
14
           NULL, HFILL }},
4777
        /* Message type number */
4778
14
        {&hf_ospf_header_msg_type,
4779
14
         { "Message Type", "ospf.msg", FT_UINT8, BASE_DEC, VALS(pt_vals), 0x0,
4780
14
           NULL, HFILL }},
4781
14
        {&hf_ospf_header_packet_length,
4782
14
         { "Packet Length", "ospf.packet_length", FT_UINT16, BASE_DEC, NULL, 0x0,
4783
14
           NULL, HFILL }},
4784
14
        {&hf_ospf_header_src_router,
4785
14
         { "Source OSPF Router", "ospf.srcrouter", FT_IPv4, BASE_NONE, NULL, 0x0,
4786
14
           NULL, HFILL }},
4787
14
        {&hf_ospf_header_area_id,
4788
14
         { "Area ID", "ospf.area_id", FT_IPv4, BASE_NONE, NULL, 0x0,
4789
14
           NULL, HFILL }},
4790
14
        {&hf_ospf_header_checksum,
4791
14
         { "Checksum", "ospf.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
4792
14
           NULL, HFILL }},
4793
14
        {&hf_ospf_tlv_type,
4794
14
         { "TLV Type", "ospf.tlv_type", FT_UINT16, BASE_DEC, NULL, 0x0,
4795
14
           NULL, HFILL }},
4796
14
        {&hf_ospf_tlv_length,
4797
14
         { "TLV Length", "ospf.tlv_length", FT_UINT16, BASE_DEC, NULL, 0x0,
4798
14
           NULL, HFILL }},
4799
14
        {&hf_ospf_header_instance_id,
4800
14
         { "Instance ID", "ospf.instance_id", FT_UINT8, BASE_RANGE_STRING | BASE_DEC, RVALS(ospf_instance_id_rvals), 0x0,
4801
14
           NULL, HFILL }},
4802
        /* OSPF Header v2 (Auth) */
4803
14
        {&hf_ospf_header_auth_type,
4804
14
         { "Auth Type", "ospf.auth.type", FT_UINT8, BASE_DEC, VALS(auth_vals), 0x0,
4805
14
           NULL, HFILL }},
4806
14
        {&hf_ospf_header_auth_data_none,
4807
14
         { "Auth Data (none)", "ospf.auth.none", FT_BYTES, BASE_NONE, NULL, 0x0,
4808
14
           NULL, HFILL }},
4809
14
        {&hf_ospf_header_auth_data_simple,
4810
14
         { "Auth Data (Simple)", "ospf.auth.simple", FT_STRING, BASE_NONE, NULL, 0x0,
4811
14
           NULL, HFILL }},
4812
14
        {&hf_ospf_header_auth_crypt_key_id,
4813
14
         { "Auth Crypt Key id", "ospf.auth.crypt.key_id", FT_UINT8, BASE_DEC, NULL, 0x0,
4814
14
           NULL, HFILL }},
4815
14
        {&hf_ospf_header_auth_crypt_data_length,
4816
14
         { "Auth Crypt Data Length", "ospf.auth.crypt.data_length", FT_UINT8, BASE_DEC, NULL, 0x0,
4817
14
           NULL, HFILL }},
4818
14
        {&hf_ospf_header_auth_crypt_seq_nbr,
4819
14
         { "Auth Crypt Sequence Number", "ospf.auth.crypt.seq_nbr", FT_UINT32, BASE_HEX, NULL, 0x0,
4820
14
           NULL, HFILL }},
4821
14
        {&hf_ospf_header_auth_crypt_data,
4822
14
         { "Auth Crypt Data", "ospf.auth.crypt.data", FT_BYTES, BASE_NONE, NULL, 0x0,
4823
14
           NULL, HFILL }},
4824
14
        {&hf_ospf_header_auth_data_unknown,
4825
14
         { "Auth Unknown", "ospf.auth.unknown", FT_BYTES, BASE_NONE, NULL, 0x0,
4826
14
           NULL, HFILL }},
4827
4828
        /* OSPF Header v3 */
4829
14
        {&hf_ospf_v3_header_instance_id,
4830
14
         { "Instance ID", "ospf.v3.instance_id", FT_UINT8, BASE_RANGE_STRING | BASE_DEC, RVALS(ospfv3_instance_id_rvals), 0x0,
4831
14
           NULL, HFILL }},
4832
4833
14
        {&hf_ospf_header_reserved,
4834
14
         { "Reserved", "ospf.reserved", FT_BYTES, BASE_NONE, NULL, 0x0,
4835
14
           "Must be zero", HFILL }},
4836
4837
        /* Message types */
4838
14
        {&hf_ospf_msg_hello,
4839
14
         { "Hello", "ospf.msg.hello", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4840
14
           NULL, HFILL }},
4841
14
        {&hf_ospf_msg_db_desc,
4842
14
         { "Database Description", "ospf.msg.dbdesc", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4843
14
           NULL, HFILL }},
4844
14
        {&hf_ospf_msg_ls_req,
4845
14
         { "Link State Adv Request", "ospf.msg.lsreq", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4846
14
           NULL, HFILL }},
4847
14
        {&hf_ospf_msg_ls_upd,
4848
14
         { "Link State Adv Update", "ospf.msg.lsupdate", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4849
14
           NULL, HFILL }},
4850
14
        {&hf_ospf_msg_ls_ack,
4851
14
         { "Link State Adv Acknowledgement", "ospf.msg.lsack", FT_BOOLEAN,
4852
14
           BASE_NONE, NULL, 0x0, NULL, HFILL }},
4853
4854
        /* Hello Packet */
4855
14
        {&hf_ospf_hello,
4856
14
         { "OSPF Hello Packet", "ospf.hello", FT_NONE,
4857
14
           BASE_NONE, NULL, 0x0, NULL, HFILL }},
4858
14
        {&hf_ospf_hello_network_mask,
4859
14
         { "Network Mask", "ospf.hello.network_mask", FT_IPv4,
4860
14
           BASE_NETMASK, NULL, 0x0, NULL, HFILL }},
4861
14
        {&hf_ospf_hello_interface_id,
4862
14
         { "Interface ID", "ospf.hello.interface_id", FT_UINT32,
4863
14
           BASE_DEC, NULL, 0x0, NULL, HFILL }},
4864
14
        {&hf_ospf_hello_hello_interval,
4865
14
         { "Hello Interval [sec]", "ospf.hello.hello_interval", FT_UINT32,
4866
14
           BASE_DEC, NULL, 0x0, NULL, HFILL }},
4867
14
        {&hf_ospf_hello_router_priority,
4868
14
         { "Router Priority", "ospf.hello.router_priority", FT_UINT8,
4869
14
           BASE_DEC, NULL, 0x0, NULL, HFILL }},
4870
14
        {&hf_ospf_hello_router_dead_interval,
4871
14
         { "Router Dead Interval [sec]", "ospf.hello.router_dead_interval", FT_UINT32,
4872
14
           BASE_DEC, NULL, 0x0, NULL, HFILL }},
4873
14
        {&hf_ospf_hello_designated_router,
4874
14
         { "Designated Router", "ospf.hello.designated_router", FT_IPv4,
4875
14
           BASE_NONE, NULL, 0x0, NULL, HFILL }},
4876
14
        {&hf_ospf_hello_backup_designated_router,
4877
14
         { "Backup Designated Router", "ospf.hello.backup_designated_router", FT_IPv4,
4878
14
           BASE_NONE, NULL, 0x0, NULL, HFILL }},
4879
14
        {&hf_ospf_hello_active_neighbor,
4880
14
         { "Active Neighbor", "ospf.hello.active_neighbor", FT_IPv4,
4881
14
           BASE_NONE, NULL, 0x0, NULL, HFILL }},
4882
4883
4884
        /* Authentication trailer */
4885
14
        {&hf_ospf_at,
4886
14
         { "OSPF Authentication Trailer", "ospf.at", FT_NONE,
4887
14
           BASE_NONE, NULL, 0x0, NULL, HFILL }},
4888
14
        {&hf_ospf_at_auth_type,
4889
14
         { "Authentication Type", "ospf.at.auth_type", FT_UINT16,
4890
14
           BASE_DEC, VALS(ospf_at_authentication_type_vals), 0x0, "Identifying the type of authentication", HFILL }},
4891
14
        {&hf_ospf_at_auth_data_len,
4892
14
         { "Authentication Data Length", "ospf.at.auth_data_len", FT_UINT16,
4893
14
           BASE_DEC, NULL, 0x0, "The length in octets of the Authentication Trailer (AT) including both the 16-octet fixed header and the variable length message digest", HFILL }},
4894
14
        {&hf_ospf_at_reserved,
4895
14
         { "Reserved", "ospf.at.reserved", FT_UINT16,
4896
14
           BASE_HEX, NULL, 0x0, "It SHOULD be set to 0", HFILL }},
4897
14
        {&hf_ospf_at_sa_id,
4898
14
         { "Security Association Identifier (SA ID)", "ospf.at.sa_id", FT_UINT16,
4899
14
           BASE_HEX, NULL, 0x0, "That maps to the authentication algorithm and the secret key used to create the message digest", HFILL }},
4900
14
        {&hf_ospf_at_crypto_seq_nbr,
4901
14
         { "Cryptographic Sequence Number", "ospf.at.crypto_seq_nbr", FT_UINT64,
4902
14
           BASE_DEC, NULL, 0x0, "Increasing sequence number that is used to guard against replay attacks", HFILL }},
4903
14
        {&hf_ospf_at_auth_data,
4904
14
         { "Authentication Data", "ospf.at.auth_data", FT_BYTES,
4905
14
           BASE_NONE, NULL, 0x0, "Variable data that is carrying the digest for the protocol packet and optional LLS data block", HFILL }},
4906
4907
        /* LS Types */
4908
14
        {&hf_ospf_ls_type,
4909
14
         { "LS Type", "ospf.lsa", FT_UINT32, BASE_DEC,
4910
14
           VALS(ls_type_vals), 0x0, NULL, HFILL }},
4911
14
        {&hf_ospf_ls_age,
4912
14
         {"LS Age (seconds)", "ospf.lsa.age", FT_UINT16,
4913
14
            BASE_DEC, NULL, ~OSPF_DNA_LSA, NULL, HFILL }},
4914
14
        {&hf_ospf_ls_donotage,
4915
14
         {"Do Not Age Flag", "ospf.lsa.donotage", FT_UINT16,
4916
14
            BASE_DEC, NULL, OSPF_DNA_LSA, NULL, HFILL }},
4917
14
        {&hf_ospf_ls_id,
4918
14
         {"Link State ID", "ospf.lsa.id", FT_IPv4,
4919
14
            BASE_NONE, NULL, 0x0, NULL, HFILL }},
4920
14
        {&hf_ospf_ls_seqnum,
4921
14
         {"Sequence Number", "ospf.lsa.seqnum", FT_UINT32,
4922
14
            BASE_HEX, NULL, 0x0, NULL, HFILL }},
4923
14
        {&hf_ospf_ls_chksum,
4924
14
         {"Checksum", "ospf.lsa.chksum", FT_UINT16,
4925
14
            BASE_HEX, NULL, 0x0, NULL, HFILL }},
4926
14
        {&hf_ospf_ls_length,
4927
14
         {"Length", "ospf.lsa.length", FT_UINT16,
4928
14
            BASE_DEC, NULL, 0x0, NULL, HFILL }},
4929
4930
14
        {&hf_ospf_ls_opaque_type,
4931
14
         { "Link State ID Opaque Type", "ospf.lsid_opaque_type", FT_UINT8, BASE_DEC,
4932
14
           VALS(ls_opaque_type_vals), 0x0, NULL, HFILL }},
4933
4934
14
        {&hf_ospf_ls_mpls_te_instance,
4935
14
         { "Link State ID TE-LSA Instance", "ospf.lsid_te_lsa.instance", FT_UINT16, BASE_DEC,
4936
14
           NULL, 0x0, NULL, HFILL }},
4937
4938
14
        {&hf_ospf_ls_router,
4939
14
         { "Router LSA", "ospf.lsa.router", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4940
14
           NULL, HFILL }},
4941
14
        {&hf_ospf_ls_router_linktype,
4942
14
         { "Link Type", "ospf.lsa.router.linktype", FT_UINT8, BASE_DEC, NULL, 0x0,
4943
14
           NULL, HFILL }},
4944
14
        {&hf_ospf_ls_router_linkid,
4945
14
         { "Link ID", "ospf.lsa.router.linkid", FT_IPv4, BASE_NONE, NULL, 0x0,
4946
14
           NULL, HFILL }},
4947
14
        {&hf_ospf_ls_router_linkdata,
4948
14
         { "Link Data", "ospf.lsa.router.linkdata", FT_IPv4, BASE_NONE, NULL, 0x0,
4949
14
           NULL, HFILL }},
4950
14
        {&hf_ospf_ls_router_nummetrics,
4951
14
         { "Number of Metrics", "ospf.lsa.router.nummetrics", FT_UINT8, BASE_DEC, NULL, 0x0,
4952
14
           NULL, HFILL }},
4953
14
        {&hf_ospf_ls_router_metric0,
4954
14
         { "0 Metric", "ospf.lsa.router.metric0", FT_UINT16, BASE_DEC, NULL, 0x0,
4955
14
           NULL, HFILL }},
4956
4957
14
        {&hf_ospf_ls_network,
4958
14
         { "Network LSA", "ospf.lsa.network", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4959
14
           NULL, HFILL }},
4960
14
        {&hf_ospf_ls_network_netmask,
4961
14
         { "Netmask", "ospf.lsa.network.netmask", FT_IPv4, BASE_NETMASK, NULL, 0x0,
4962
14
           NULL, HFILL }},
4963
14
        {&hf_ospf_ls_network_attachrtr,
4964
14
         { "Attached Router", "ospf.lsa.network.attchrtr", FT_IPv4, BASE_NONE, NULL, 0x0,
4965
14
           NULL, HFILL }},
4966
4967
14
        {&hf_ospf_ls_summary,
4968
14
         { "Summary LSA (IP Network)", "ospf.lsa.summary", FT_BOOLEAN, BASE_NONE,
4969
14
           NULL, 0x0, NULL, HFILL }},
4970
14
        {&hf_ospf_ls_asbr,
4971
14
         { "Summary LSA (ASBR)", "ospf.lsa.asbr", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4972
14
           NULL, HFILL }},
4973
14
        {&hf_ospf_ls_asbr_netmask,
4974
14
         { "Netmask", "ospf.lsa.asbr.netmask", FT_IPv4, BASE_NETMASK, NULL, 0x0,
4975
14
           NULL, HFILL }},
4976
4977
14
        {&hf_ospf_ls_asext,
4978
14
         { "AS-External LSA (ASBR)", "ospf.lsa.asext", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4979
14
           NULL, HFILL }},
4980
14
        {&hf_ospf_ls_asext_netmask,
4981
14
         { "Netmask", "ospf.lsa.asext.netmask", FT_IPv4, BASE_NETMASK, NULL, 0x0,
4982
14
           NULL, HFILL }},
4983
14
        {&hf_ospf_ls_asext_fwdaddr,
4984
14
         { "Forwarding Address", "ospf.lsa.asext.fwdaddr", FT_IPv4, BASE_NONE, NULL, 0x0,
4985
14
           NULL, HFILL }},
4986
14
        {&hf_ospf_ls_asext_extrtrtag,
4987
14
         { "External Route Tag", "ospf.lsa.asext.extrttag", FT_UINT32, BASE_DEC, NULL, 0x0,
4988
14
           NULL, HFILL }},
4989
4990
14
        {&hf_ospf_ls_grpmember,
4991
14
         { "Group Membership LSA", "ospf.lsa.member", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4992
14
           NULL, HFILL }},
4993
14
        {&hf_ospf_ls_asext7,
4994
14
         { "NSSA AS-External LSA", "ospf.lsa.nssa", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4995
14
           NULL, HFILL }},
4996
14
        {&hf_ospf_ls_extattr,
4997
14
         { "External Attributes LSA", "ospf.lsa.attr", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4998
14
           NULL, HFILL }},
4999
14
        {&hf_ospf_ls_opaque,
5000
14
         { "Opaque LSA", "ospf.lsa.opaque", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
5001
14
           NULL, HFILL }},
5002
5003
        /* OSPFv3 E-LSA TLV */
5004
14
        {&hf_ospf_v3_e_lsa_tlv_type,
5005
14
         { "TLV Type", "ospf.v3.elsa.tlv_type", FT_UINT16, BASE_DEC, NULL, 0x0,
5006
14
           NULL, HFILL }},
5007
14
        {&hf_ospf_v3_e_lsa_tlv_length,
5008
14
         { "TLV Length", "ospf.v3.elsa.tlv_length", FT_UINT16, BASE_DEC, NULL, 0x0,
5009
14
           NULL, HFILL }},
5010
5011
        /* OSPFv3 LS Types */
5012
14
        {&hf_ospf_v3_ls_type,
5013
14
         { "LS Type", "ospf.v3.lsa", FT_UINT16, BASE_HEX, NULL, 0x0,
5014
14
           NULL, HFILL }},
5015
14
        {&hf_ospf_v3_ls_type_u,
5016
14
         { "LSA Handling", "ospf.v3.lsa.u", FT_BOOLEAN, 16, TFS(&tfs_v3_ls_type_u), 0x8000,
5017
14
           NULL, HFILL }},
5018
14
        {&hf_ospf_v3_ls_type_s12,
5019
14
         { "Flooding Scope", "ospf.v3.lsa.s12", FT_UINT16, BASE_HEX, VALS(v3_ls_type_s12_vals), 0x6000,
5020
14
           NULL, HFILL }},
5021
14
        {&hf_ospf_v3_ls_type_fc,
5022
14
         { "Function Code", "ospf.v3.lsa.fc", FT_UINT16, BASE_DEC, VALS(v3_ls_type_vals), 0x1FFF,
5023
14
           NULL, HFILL }},
5024
5025
14
        {&hf_ospf_v3_ls_router,
5026
14
         { "Router-LSA", "ospf.v3.lsa.router", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
5027
14
           NULL, HFILL }},
5028
14
        {&hf_ospf_v3_ls_network,
5029
14
         { "Network-LSA", "ospf.v3.lsa.network", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
5030
14
           NULL, HFILL }},
5031
14
        {&hf_ospf_v3_ls_inter_area_prefix,
5032
14
         { "Inter-Area-Prefix-LSA", "ospf.v3.lsa.interprefix", FT_BOOLEAN, BASE_NONE,
5033
14
           NULL, 0x0, NULL, HFILL }},
5034
14
        {&hf_ospf_v3_ls_inter_area_router,
5035
14
         { "Inter-Area-Router-LSA", "ospf.v3.lsa.interrouter", FT_BOOLEAN, BASE_NONE,
5036
14
           NULL, 0x0, NULL, HFILL }},
5037
14
        {&hf_ospf_v3_ls_as_external,
5038
14
         { "AS-External-LSA", "ospf.v3.lsa.asext", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
5039
14
           NULL, HFILL }},
5040
14
        {&hf_ospf_v3_ls_group_membership,
5041
14
         { "Group-Membership-LSA", "ospf.v3.lsa.member", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
5042
14
           NULL, HFILL }},
5043
14
        {&hf_ospf_v3_ls_nssa,
5044
14
         { "NSSA-LSA", "ospf.v3.lsa.nssa", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
5045
14
           NULL, HFILL }},
5046
14
        {&hf_ospf_v3_ls_link,
5047
14
         { "Link-LSA", "ospf.v3.lsa.link", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
5048
14
           NULL, HFILL }},
5049
14
        {&hf_ospf_v3_ls_intra_area_prefix,
5050
14
         { "Intra-Area-Prefix-LSA", "ospf.v3.lsa.intraprefix", FT_BOOLEAN, BASE_NONE,
5051
14
           NULL, 0x0, NULL, HFILL }},
5052
14
        {&hf_ospf_v3_elsa_intra_area_prefix,
5053
14
         { "E-Intra-Area-Prefix-LSA", "ospf.v3.elsa.intraprefix", FT_BOOLEAN, BASE_NONE,
5054
14
           NULL, 0x0, NULL, HFILL }},
5055
14
        {&hf_ospf_v3_ls_opaque_ri,
5056
14
         { "Router Information Opaque-LSA", "ospf.v3.lsa.opaque", FT_BOOLEAN, BASE_NONE,
5057
14
           NULL, 0x0, NULL, HFILL }},
5058
5059
        /* Other interesting OSPF values */
5060
5061
14
        {&hf_ospf_adv_router,
5062
14
         { "Advertising Router", "ospf.advrouter", FT_IPv4, BASE_NONE, NULL, 0x0,
5063
14
           NULL, HFILL }},
5064
5065
14
        {&hf_ospf_ls_mpls,
5066
14
         { "MPLS Traffic Engineering LSA", "ospf.lsa.mpls", FT_BOOLEAN,
5067
14
           BASE_NONE, NULL, 0x0, NULL, HFILL }},
5068
5069
14
        {&hf_ospf_ls_mpls_routerid,
5070
14
         { "MPLS/TE Router ID", "ospf.mpls.routerid", FT_IPv4, BASE_NONE, NULL, 0x0,
5071
14
           NULL, HFILL }},
5072
5073
14
        {&hf_ospf_ls_mpls_linktype,
5074
14
         { "MPLS/TE Link Type", "ospf.mpls.linktype", FT_UINT8, BASE_DEC,
5075
14
           VALS(mpls_link_stlv_ltype_str), 0x0, NULL, HFILL }},
5076
14
        {&hf_ospf_ls_mpls_linkid,
5077
14
         { "MPLS/TE Link ID", "ospf.mpls.linkid", FT_IPv4, BASE_NONE, NULL, 0x0,
5078
14
           NULL, HFILL }},
5079
14
        {&hf_ospf_ls_mpls_local_addr,
5080
14
         { "MPLS/TE Local Interface Address", "ospf.mpls.local_addr", FT_IPv4,
5081
14
           BASE_NONE, NULL, 0x0, NULL, HFILL }},
5082
14
        {&hf_ospf_ls_mpls_remote_addr,
5083
14
         { "MPLS/TE Remote Interface Address", "ospf.mpls.remote_addr", FT_IPv4,
5084
14
           BASE_NONE, NULL, 0x0, NULL, HFILL }},
5085
14
        {&hf_ospf_ls_mpls_te_metric,
5086
14
         { "MPLS/TE Metric", "ospf.mpls.te_metric", FT_UINT32,
5087
14
           BASE_DEC, NULL, 0x0, NULL, HFILL }},
5088
5089
14
        {&hf_ospf_ls_mpls_local_ifid,
5090
14
         { "MPLS/TE Local Interface Index", "ospf.mpls.local_id", FT_UINT32,
5091
14
           BASE_DEC, NULL, 0x0, NULL, HFILL }},
5092
14
        {&hf_ospf_ls_mpls_remote_ifid,
5093
14
         { "MPLS/TE Remote Interface Index", "ospf.mpls.remote_id", FT_UINT32,
5094
14
           BASE_DEC, NULL, 0x0, NULL, HFILL }},
5095
14
        {&hf_ospf_ls_mpls_linkcolor,
5096
14
         { "MPLS/TE Link Resource Class/Color", "ospf.mpls.linkcolor", FT_UINT32,
5097
14
           BASE_HEX, NULL, 0x0, NULL, HFILL }},
5098
14
        {&hf_ospf_ls_mpls_group,
5099
14
         { "MPLS/TE Group", "ospf.mpls.group", FT_UINT32,
5100
14
           BASE_HEX, NULL, 0x0, NULL, HFILL }},
5101
14
        {&hf_ospf_ls_mpls_link_max_bw,
5102
14
         { "Link Max BW", "ospf.mpls.link_max_bw", FT_FLOAT,
5103
14
           BASE_NONE, NULL, 0x0, NULL, HFILL }},
5104
14
        {&hf_ospf_ls_mpls_bc_model_id,
5105
14
         { "MPLS/DSTE Bandwidth Constraints Model Id", "ospf.mpls.bc.model_id", FT_UINT8,
5106
14
           BASE_RANGE_STRING | BASE_DEC, RVALS(mpls_link_stlv_bcmodel_rvals), 0x0,
5107
14
           NULL, HFILL }},
5108
5109
14
        {&hf_ospf_ls_oif_local_node_id,
5110
14
         { "Local Node ID", "ospf.oif.local_node_id", FT_IPv4,
5111
14
           BASE_NONE, NULL, 0x0, NULL, HFILL }},
5112
14
        {&hf_ospf_ls_oif_remote_node_id,
5113
14
         { "Remote Node ID", "ospf.oif.remote_node_id", FT_IPv4,
5114
14
           BASE_NONE, NULL, 0x0, NULL, HFILL }},
5115
5116
14
        {&hf_ospf_v2_options,
5117
14
         { "Options", "ospf.v2.options", FT_UINT8, BASE_HEX,
5118
14
           NULL, 0x0, NULL, HFILL }},
5119
14
        {&hf_ospf_v2_options_mt,
5120
14
         { "(MT) Multi-Topology Routing", "ospf.v2.options.mt", FT_BOOLEAN, 8,
5121
14
           TFS(&tfs_yes_no), OSPF_V2_OPTIONS_MT, NULL, HFILL }},
5122
14
        {&hf_ospf_v2_options_e,
5123
14
         { "(E) External Routing", "ospf.v2.options.e", FT_BOOLEAN, 8,
5124
14
           TFS(&tfs_capable_not_capable), OSPF_V2_OPTIONS_E, NULL, HFILL }},
5125
14
        {&hf_ospf_v2_options_mc,
5126
14
         { "(MC) Multicast", "ospf.v2.options.mc", FT_BOOLEAN, 8,
5127
14
           TFS(&tfs_capable_not_capable), OSPF_V2_OPTIONS_MC, NULL, HFILL }},
5128
14
        {&hf_ospf_v2_options_n,
5129
14
         { "(N) NSSA", "ospf.v2.options.n", FT_BOOLEAN, 8,
5130
14
           TFS(&tfs_supported_not_supported), OSPF_V2_OPTIONS_NP, NULL, HFILL }},
5131
14
        {&hf_ospf_v2_options_p,
5132
14
         { "(P) Propagate", "ospf.v2.options.p", FT_BOOLEAN, 8,
5133
14
           TFS(&tfs_set_notset), OSPF_V2_OPTIONS_NP, NULL, HFILL }},
5134
14
        {&hf_ospf_v2_options_l,
5135
14
         { "(L) LLS Data block", "ospf.v2.options.l", FT_BOOLEAN, 8,
5136
14
           TFS(&tfs_present_not_present), OSPF_V2_OPTIONS_L, NULL, HFILL }},
5137
14
        {&hf_ospf_v2_options_dc,
5138
14
         { "(DC) Demand Circuits", "ospf.v2.options.dc", FT_BOOLEAN, 8,
5139
14
           TFS(&tfs_supported_not_supported), OSPF_V2_OPTIONS_DC, NULL, HFILL }},
5140
14
        {&hf_ospf_v2_options_o,
5141
14
         { "(O) Opaque", "ospf.v2.options.o", FT_BOOLEAN, 8,
5142
14
           TFS(&tfs_set_notset), OSPF_V2_OPTIONS_O, NULL, HFILL }},
5143
14
        {&hf_ospf_v2_options_dn,
5144
14
         { "DN", "ospf.v2.options.dn", FT_BOOLEAN, 8,
5145
14
           TFS(&tfs_set_notset), OSPF_V2_OPTIONS_DN, NULL, HFILL }},
5146
5147
14
        {&hf_ospf_ri_options,
5148
14
         { "RI Options", "ospf.ri.options", FT_UINT8, BASE_HEX,
5149
14
           NULL, 0x0, NULL, HFILL }},
5150
14
        {&hf_ospf_ri_options_grc,
5151
14
         { "(GRC) Graceful Restart", "ospf.ri.options.grc", FT_BOOLEAN, 8,
5152
14
           TFS(&tfs_capable_not_capable), OSPF_RI_OPTIONS_GRC, NULL, HFILL }},
5153
14
        {&hf_ospf_ri_options_grh,
5154
14
         { "(GRH) Graceful Restart Helper", "ospf.ri.options.grh", FT_BOOLEAN, 8,
5155
14
           TFS(&tfs_enabled_disabled), OSPF_RI_OPTIONS_GRH, NULL, HFILL }},
5156
14
        {&hf_ospf_ri_options_srs,
5157
14
         { "Stub Router Support", "ospf.ri.options.srs", FT_BOOLEAN, 8,
5158
14
           TFS(&tfs_yes_no), OSPF_RI_OPTIONS_SRS, NULL, HFILL }},
5159
14
        {&hf_ospf_ri_options_tes,
5160
14
         { "(TES) Traffic Engineering", "ospf.ri.options.tes", FT_BOOLEAN, 8,
5161
14
           TFS(&tfs_supported_not_supported), OSPF_RI_OPTIONS_TES, NULL, HFILL }},
5162
14
        {&hf_ospf_ri_options_p2plan,
5163
14
         { "(P2PLAN) Point-to-point over LAN", "ospf.ri.options.p2plan", FT_BOOLEAN, 8,
5164
14
           TFS(&tfs_capable_not_capable), OSPF_RI_OPTIONS_P2PLAN, NULL, HFILL }},
5165
14
        {&hf_ospf_ri_options_ete,
5166
14
         { "(ETE) Experimental TE", "ospf.ri.options.ete", FT_BOOLEAN, 8,
5167
14
           TFS(&tfs_capable_not_capable), OSPF_RI_OPTIONS_ETE, NULL, HFILL }},
5168
14
        {&hf_ospf_ri_options_host,
5169
14
         { "Host Router", "ospf.ri.options.host", FT_BOOLEAN, 8,
5170
14
           TFS(&tfs_capable_not_capable), OSPF_RI_OPTIONS_HOST, NULL, HFILL }},
5171
5172
14
        {&hf_ospf_tlv_type_opaque,
5173
14
         { "TLV Type", "ospf.tlv_type.opaque", FT_UINT16, BASE_DEC, VALS(ri_tlv_type_vals), 0x0,
5174
14
           NULL, HFILL }},
5175
5176
14
        {&hf_ospf_v3_options,
5177
14
         { "Options", "ospf.v3.options", FT_UINT24, BASE_HEX,
5178
14
           NULL, 0x0, NULL, HFILL }},
5179
14
        {&hf_ospf_v3_options_v6,
5180
14
         { "V6", "ospf.v3.options.v6", FT_BOOLEAN, 24,
5181
14
           TFS(&tfs_set_notset), OSPF_V3_OPTIONS_V6, NULL, HFILL }},
5182
14
        {&hf_ospf_v3_options_e,
5183
14
         { "E", "ospf.v3.options.e", FT_BOOLEAN, 24,
5184
14
           TFS(&tfs_set_notset), OSPF_V3_OPTIONS_E, NULL, HFILL }},
5185
14
        {&hf_ospf_v3_options_mc,
5186
14
         { "MC", "ospf.v3.options.mc", FT_BOOLEAN, 24,
5187
14
           TFS(&tfs_set_notset), OSPF_V3_OPTIONS_MC, NULL, HFILL }},
5188
14
        {&hf_ospf_v3_options_n,
5189
14
         { "N", "ospf.v3.options.n", FT_BOOLEAN, 24,
5190
14
           TFS(&tfs_set_notset), OSPF_V3_OPTIONS_N, NULL, HFILL }},
5191
14
        {&hf_ospf_v3_options_r,
5192
14
         { "R", "ospf.v3.options.r", FT_BOOLEAN, 24,
5193
14
           TFS(&tfs_set_notset), OSPF_V3_OPTIONS_R, NULL, HFILL }},
5194
14
        {&hf_ospf_v3_options_dc,
5195
14
         { "DC", "ospf.v3.options.dc", FT_BOOLEAN, 24,
5196
14
           TFS(&tfs_set_notset), OSPF_V3_OPTIONS_DC, NULL, HFILL }},
5197
14
        {&hf_ospf_v3_options_af,
5198
14
         { "AF", "ospf.v3.options.af", FT_BOOLEAN, 24,
5199
14
           TFS(&tfs_set_notset), OSPF_V3_OPTIONS_AF, NULL, HFILL }},
5200
14
        {&hf_ospf_v3_options_l,
5201
14
         { "L", "ospf.v3.options.l", FT_BOOLEAN, 24,
5202
14
           TFS(&tfs_set_notset), OSPF_V3_OPTIONS_L, NULL, HFILL }},
5203
14
        {&hf_ospf_v3_options_at,
5204
14
         { "AT", "ospf.v3.options.at", FT_BOOLEAN, 24,
5205
14
           TFS(&tfs_set_notset), OSPF_V3_OPTIONS_AT, NULL, HFILL }},
5206
14
        {&hf_ospf_dbd,
5207
14
         { "DB Description", "ospf.dbd", FT_UINT8, BASE_HEX,
5208
14
           NULL, 0x0, NULL, HFILL }},
5209
14
        {&hf_ospf_dbd_r,
5210
14
         { "(R) OOBResync", "ospf.dbd.r", FT_BOOLEAN, 8,
5211
14
           TFS(&tfs_set_notset), OSPF_DBD_FLAG_R, NULL, HFILL }},
5212
14
        {&hf_ospf_dbd_i,
5213
14
         { "(I) Init", "ospf.dbd.i", FT_BOOLEAN, 8,
5214
14
           TFS(&tfs_set_notset), OSPF_DBD_FLAG_I, NULL, HFILL }},
5215
14
        {&hf_ospf_dbd_m,
5216
14
         { "(M) More", "ospf.dbd.m", FT_BOOLEAN, 8,
5217
14
           TFS(&tfs_set_notset), OSPF_DBD_FLAG_M, NULL, HFILL }},
5218
14
        {&hf_ospf_dbd_ms,
5219
14
         { "(MS) Master", "ospf.dbd.ms", FT_BOOLEAN, 8,
5220
14
           TFS(&tfs_yes_no), OSPF_DBD_FLAG_MS, NULL, HFILL }},
5221
14
        {&hf_ospf_lls_ext_options,
5222
14
         { "Options", "ospf.lls.ext.options", FT_UINT32, BASE_HEX,
5223
14
           NULL, 0x0, NULL, HFILL }},
5224
14
        {&hf_ospf_lls_ext_options_lr,
5225
14
         { "(LR) LSDB Resynchronization", "ospf.lls.ext.options.lr", FT_BOOLEAN, 32,
5226
14
           TFS(&tfs_set_notset), OSPF_LLS_EXT_OPTIONS_LR, NULL, HFILL }},
5227
14
        {&hf_ospf_lls_ext_options_rs,
5228
14
         { "(RS) Restart Signal", "ospf.lls.ext.options.rs", FT_BOOLEAN, 32,
5229
14
           TFS(&tfs_set_notset), OSPF_LLS_EXT_OPTIONS_RS, NULL, HFILL }},
5230
14
        {&hf_ospf_v2_router_lsa_flag,
5231
14
         { "Flags", "ospf.v2.router.lsa.flags", FT_UINT8, BASE_HEX,
5232
14
           NULL, 0x0, NULL, HFILL }},
5233
14
        {&hf_ospf_v2_router_lsa_flag_b,
5234
14
         { "(B) Area border router", "ospf.v2.router.lsa.flags.b", FT_BOOLEAN, 8,
5235
14
           TFS(&tfs_yes_no), OSPF_V2_ROUTER_LSA_FLAG_B, NULL, HFILL }},
5236
14
        {&hf_ospf_v2_router_lsa_flag_e,
5237
14
         { "(E) AS boundary router", "ospf.v2.router.lsa.flags.e", FT_BOOLEAN, 8,
5238
14
           TFS(&tfs_yes_no), OSPF_V2_ROUTER_LSA_FLAG_E, NULL, HFILL }},
5239
14
        {&hf_ospf_v2_router_lsa_flag_v,
5240
14
         { "(V) Virtual link endpoint", "ospf.v2.router.lsa.flags.v", FT_BOOLEAN, 8,
5241
14
           TFS(&tfs_yes_no), OSPF_V2_ROUTER_LSA_FLAG_V, NULL, HFILL }},
5242
14
        {&hf_ospf_v2_router_lsa_flag_w,
5243
14
         { "(W) Wild-card multicast receiver", "ospf.v2.router.lsa.flags.w", FT_BOOLEAN, 8,
5244
14
           TFS(&tfs_yes_no), OSPF_V2_ROUTER_LSA_FLAG_W, NULL, HFILL }},
5245
14
        {&hf_ospf_v2_router_lsa_flag_n,
5246
14
         { "(N) NSSA translation", "ospf.v2.router.lsa.flags.n", FT_BOOLEAN, 8,
5247
14
           TFS(&tfs_yes_no), OSPF_V2_ROUTER_LSA_FLAG_N, NULL, HFILL }},
5248
14
        {&hf_ospf_v2_router_lsa_flag_s,
5249
14
         { "(S) Shortcut-capable ABR", "ospf.v2.router.lsa.flags.s", FT_BOOLEAN, 8,
5250
14
           TFS(&tfs_yes_no), OSPF_V2_ROUTER_LSA_FLAG_S, NULL, HFILL }},
5251
14
        {&hf_ospf_v2_router_lsa_flag_h,
5252
14
         { "(H) Host", "ospf.v2.router.lsa.flags.h", FT_BOOLEAN, 8,
5253
14
           TFS(&tfs_yes_no), OSPF_V2_ROUTER_LSA_FLAG_H, NULL, HFILL }},
5254
14
        {&hf_ospf_v3_router_lsa_flag,
5255
14
         { "Flags", "ospf.v3.router.lsa.flags", FT_UINT8, BASE_HEX,
5256
14
           NULL, 0x0, NULL, HFILL }},
5257
14
        {&hf_ospf_v3_router_lsa_flag_b,
5258
14
         { "(B) Area border router", "ospf.v3.router.lsa.flags.b", FT_BOOLEAN, 8,
5259
14
           TFS(&tfs_yes_no), OSPF_V3_ROUTER_LSA_FLAG_B, NULL, HFILL }},
5260
14
        {&hf_ospf_v3_router_lsa_flag_e,
5261
14
         { "(E) AS boundary router", "ospf.v3.router.lsa.flags.e", FT_BOOLEAN, 8,
5262
14
           TFS(&tfs_yes_no), OSPF_V3_ROUTER_LSA_FLAG_E, NULL, HFILL }},
5263
14
        {&hf_ospf_v3_router_lsa_flag_v,
5264
14
         { "(V) Virtual link endpoint", "ospf.v3.router.lsa.flags.v", FT_BOOLEAN, 8,
5265
14
           TFS(&tfs_yes_no), OSPF_V3_ROUTER_LSA_FLAG_V, NULL, HFILL }},
5266
14
        {&hf_ospf_v3_router_lsa_flag_w,
5267
14
         { "(W) Wild-card multicast receiver", "ospf.v3.router.lsa.flags.w", FT_BOOLEAN, 8,
5268
14
           TFS(&tfs_yes_no), OSPF_V3_ROUTER_LSA_FLAG_W, NULL, HFILL }},
5269
14
        {&hf_ospf_v3_as_external_flag,
5270
14
         { "Flags", "ospf.v3.as.external.flags", FT_UINT8, BASE_HEX,
5271
14
           NULL, 0x0, NULL, HFILL }},
5272
14
        {&hf_ospf_v3_as_external_flag_t,
5273
14
         { "(T) External Route Tag", "ospf.v3.as.external.flags.t", FT_BOOLEAN, 8,
5274
14
           TFS(&tfs_present_not_present), OSPF_V3_AS_EXTERNAL_FLAG_T, NULL, HFILL }},
5275
14
        {&hf_ospf_v3_as_external_flag_f,
5276
14
         { "(F) Forwarding Address", "ospf.v3.as.external.flags.f", FT_BOOLEAN, 8,
5277
14
           TFS(&tfs_present_absent), OSPF_V3_AS_EXTERNAL_FLAG_F, NULL, HFILL }},
5278
14
        {&hf_ospf_v3_as_external_flag_e,
5279
14
         { "(E) External Metric", "ospf.v3.as.external.flags.e", FT_BOOLEAN, 8,
5280
14
           TFS(&tfs_v3_as_external_flags_e), OSPF_V3_AS_EXTERNAL_FLAG_E, NULL, HFILL }},
5281
14
        {&hf_ospf_v3_prefix_option,
5282
14
         { "PrefixOptions", "ospf.v3.prefix.options", FT_UINT8, BASE_HEX,
5283
14
           NULL, 0x0, NULL, HFILL }},
5284
14
        {&hf_ospf_v3_prefix_option_nu,
5285
14
         { "(NU) NoUnicast", "ospf.v3.prefix.options.nu", FT_BOOLEAN, 8,
5286
14
           TFS(&tfs_set_notset), OSPF_V3_PREFIX_OPTION_NU, NULL, HFILL }},
5287
14
        {&hf_ospf_v3_prefix_option_la,
5288
14
         { "(LA) Local Address", "ospf.v3.prefix.options.la", FT_BOOLEAN, 8,
5289
14
           TFS(&tfs_set_notset), OSPF_V3_PREFIX_OPTION_LA, NULL, HFILL }},
5290
14
        {&hf_ospf_v3_prefix_option_mc,
5291
14
         { "(MC) Multicast", "ospf.v3.prefix.options.mc", FT_BOOLEAN, 8,
5292
14
           TFS(&tfs_set_notset), OSPF_V3_PREFIX_OPTION_MC, NULL, HFILL }},
5293
14
        {&hf_ospf_v3_prefix_option_p,
5294
14
         { "(P) Propagate", "ospf.v3.prefix.options.p", FT_BOOLEAN, 8,
5295
14
           TFS(&tfs_set_notset), OSPF_V3_PREFIX_OPTION_P, NULL, HFILL }},
5296
5297
        /* Dynamic Hostname contained in the Opaque RI LSA - dynamic hostname TLV*/
5298
14
        {&hf_ospf_dyn_hostname,
5299
14
         { "Dynamic Hostname", "ospf.dynhostname", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5300
5301
14
        {&hf_ospf_lsa_sa,
5302
14
         { "SR-Algorithm", "ospf.lsa_sa", FT_UINT8, BASE_DEC, VALS(ri_lsa_sa_tlv_type_vals), 0x0, NULL, HFILL }},
5303
5304
14
        {&hf_ospf_ls_slr_stlv,
5305
14
         { "TLV Type", "ospf.tlv.sidlabel_range.type", FT_UINT16, BASE_DEC, VALS(ext_pfx_stlv_type_vals), 0x0, NULL, HFILL }},
5306
14
        {&hf_ospf_ls_range_size,
5307
14
         { "Range Size", "ospf.tlv.range_size", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5308
14
        {&hf_ospf_ls_sid_label,
5309
14
         { "SID/Label", "ospf.tlv.sid_label", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5310
14
        {&hf_ospf_ls_preference,
5311
14
         { "Preference", "ospf.tlv.preference", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5312
14
        {&hf_ospf_ls_igp_msd_type,
5313
14
         { "MSD Type", "ospf.tlv.igp_msd_type", FT_UINT8, BASE_DEC, VALS(ospf_igp_msd_types), 0x0, NULL, HFILL }},
5314
14
        {&hf_ospf_ls_igp_msd_value,
5315
14
         { "MSD Value", "ospf.tlv.igp_msd_value", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5316
14
        {&hf_ospf_ls_remote_ipv4_addr,
5317
14
         { "Remote IPv4 Address", "ospf.tlv.remote_ipv4_address", FT_IPv4, BASE_NONE,
5318
14
           NULL, 0x0, NULL, HFILL }},
5319
14
        {&hf_ospf_ls_local_interface_id,
5320
14
         { "Local Interface ID", "ospf.tlv.local_interface_id", FT_UINT32, BASE_DEC,
5321
14
           NULL, 0x0, NULL, HFILL }},
5322
14
        {&hf_ospf_ls_remote_interface_id,
5323
14
         { "Remote Interface ID", "ospf.tlv.remote_interface_id", FT_UINT32, BASE_DEC,
5324
14
           NULL, 0x0, NULL, HFILL }},
5325
5326
        /* Flex Algo Definition TLV (rfc9350) */
5327
14
        {&hf_ospf_ls_flex_algorithm,
5328
14
         { "Flex-Algorithm", "ospf.tlv.flex_algorithm", FT_UINT8, BASE_DEC,
5329
14
           NULL, 0x0, NULL, HFILL }},
5330
14
        {&hf_ospf_ls_fad_metric_type,
5331
14
         { "Metric-Type", "ospf.tlv.fad.metric_type", FT_UINT8, BASE_DEC,
5332
14
           VALS(ri_lsa_fad_metric_type_vals), 0x0, NULL, HFILL }},
5333
14
        {&hf_ospf_ls_fad_calc_type,
5334
14
         { "Calc-Type", "ospf.tlv.fad.calc_type", FT_UINT8, BASE_DEC,
5335
14
           VALS(ri_lsa_sa_tlv_type_vals), 0x0, NULL, HFILL }},
5336
14
        {&hf_ospf_ls_fad_priority,
5337
14
         { "Priority", "ospf.tlv.fad.priority", FT_UINT8, BASE_DEC,
5338
14
           NULL, 0x0, NULL, HFILL }},
5339
14
        {&hf_ospf_ls_fad_stlv,
5340
14
         { "TLV Type", "ospf.tlv.fad.subtlv_type", FT_UINT16, BASE_DEC, VALS(ri_lsa_fad_stlv_type_vals), 0x0,
5341
14
           NULL, HFILL }},
5342
14
        {&hf_ospf_ls_fad_def_flags,
5343
14
         { "Flags", "ospf.tlv.fad.definition_flags", FT_UINT32, BASE_HEX,
5344
14
           NULL, 0x0, NULL, HFILL }},
5345
14
        {&hf_ospf_ls_fad_def_flags_m,
5346
14
         { "M-flag (M)", "ospf.tlv.fad.definition_flags.m", FT_BOOLEAN, 32,
5347
14
           TFS(&tfs_set_notset), FAD_DEF_FLAGS_M, NULL, HFILL }},
5348
14
        {&hf_ospf_ls_fapm_flags,
5349
14
         { "Flags", "ospf.tlv.fapm.flags", FT_UINT8, BASE_HEX,
5350
14
           NULL, 0x0, NULL, HFILL }},
5351
14
        {&hf_ospf_ls_fapm_flags_e,
5352
14
         { "E bit", "ospf.tlv.fapm.flags.e", FT_BOOLEAN, 8,
5353
14
           TFS(&tfs_set_notset), FAPM_FLAGS_E, NULL, HFILL }},
5354
14
        {&hf_ospf_ls_fapm_metric,
5355
14
         { "Metric", "ospf.tlv.fapm.metric", FT_UINT32, BASE_DEC,
5356
14
           NULL, 0, NULL, HFILL }},
5357
5358
        /* the Unknown TLV of the Opaque RI LSA */
5359
14
        {&hf_ospf_unknown_tlv,
5360
14
         { "Unknown TLV", "ospf.tlv.unknown", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5361
5362
        /* OSPF Extended Prefix TLV */
5363
14
        {&hf_ospf_ls_epfx_tlv,
5364
14
         { "TLV Type", "ospf.tlv.extpfx.tlv_type", FT_UINT16, BASE_DEC, VALS(ext_pfx_tlv_type_vals), 0x0, NULL, HFILL }},
5365
14
        {&hf_ospf_ls_epfx_stlv,
5366
14
         { "TLV Type", "ospf.tlv.extpfx.subtlv_type", FT_UINT16, BASE_DEC, VALS(ext_pfx_stlv_type_vals), 0x0, NULL, HFILL }},
5367
14
        {&hf_ospf_ls_epfx_route_type,
5368
14
         { "Route Type", "ospf.tlv.extpfx.routetype", FT_UINT8, BASE_DEC, VALS(ext_pfx_tlv_route_vals), 0x0, NULL, HFILL }},
5369
14
        {&hf_ospf_ls_epfx_af,
5370
14
         { "Address Family", "ospf.tlv.extpfx.af", FT_UINT8, BASE_DEC, VALS(ext_pfx_tlv_af_vals), 0x0, NULL, HFILL }},
5371
5372
14
        {&hf_ospf_ls_epfx_flags,
5373
14
         { "Flags", "ospf.tlv.extpfx.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
5374
14
        {&hf_ospf_ls_epfx_flag_a,
5375
14
         { "(A) Attach Flag", "ospf.tlv.extpfx.flags.a", FT_BOOLEAN, 8,
5376
14
           TFS(&tfs_set_notset), EXT_PREFIX_TLV_FLAG_A, NULL, HFILL }},
5377
14
        {&hf_ospf_ls_epfx_flag_n,
5378
14
         { "(N) Node Flag", "ospf.tlv.extpfx.flags.n", FT_BOOLEAN, 8,
5379
14
           TFS(&tfs_set_notset), EXT_PREFIX_TLV_FLAG_N, NULL, HFILL }},
5380
14
        {&hf_ospf_ls_epfx_flag_unknown,
5381
14
         { "(*) Unknown Flag", "ospf.tlv.extpfx.flags.unknown", FT_UINT8, BASE_HEX,
5382
14
           NULL, EXT_PREFIX_TLV_FLAG_UNKNOWN, NULL, HFILL }},
5383
5384
14
        {&hf_ospf_ls_epfx_range_flags,
5385
14
         { "Flags", "ospf.tlv.extpfx_range.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
5386
14
        {&hf_ospf_ls_epfx_range_flag_ia,
5387
14
         { "(IA) Inter-Area Flag", "ospf.tlv.extpfx_range.flags.ia", FT_BOOLEAN, 8,
5388
14
           TFS(&tfs_set_notset), EXT_PREFIX_RANGE_TLV_FLAG_IA, NULL, HFILL }},
5389
14
        {&hf_ospf_ls_epfx_range_flag_unknown,
5390
14
         { "(*) Unknown Flag", "ospf.tlv.extpfx_range.flags.unknown", FT_UINT8, BASE_HEX,
5391
14
           NULL, EXT_PREFIX_RANGE_TLV_FLAG_UNKNOWN, NULL, HFILL }},
5392
5393
14
        {&hf_ospf_ls_pfxsid_flags,
5394
14
         { "Flags", "ospf.tlv.pfxsid.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
5395
14
        {&hf_ospf_ls_pfxsid_flag_np,
5396
14
         { "(NP) No-PHP Flag", "ospf.tlv.pfxsid.flags.np", FT_BOOLEAN, 8,
5397
14
           TFS(&tfs_set_notset), SR_STLV_PFXSID_FLAG_NP, NULL, HFILL }},
5398
14
        {&hf_ospf_ls_pfxsid_flag_m,
5399
14
         { "(M) Mapping Server Flag", "ospf.tlv.pfxsid.flags.m", FT_BOOLEAN, 8,
5400
14
           TFS(&tfs_set_notset), SR_STLV_PFXSID_FLAG_M, NULL, HFILL }},
5401
14
        {&hf_ospf_ls_pfxsid_flag_e,
5402
14
         { "(E) Explicit-Null Flag", "ospf.tlv.pfxsid.flags.e", FT_BOOLEAN, 8,
5403
14
           TFS(&tfs_set_notset), SR_STLV_PFXSID_FLAG_E, NULL, HFILL }},
5404
14
        {&hf_ospf_ls_pfxsid_flag_v,
5405
14
         { "(V) Value/Index Flag", "ospf.tlv.pfxsid.flags.v", FT_BOOLEAN, 8,
5406
14
           TFS(&tfs_set_notset), SR_STLV_PFXSID_FLAG_V, NULL, HFILL }},
5407
14
        {&hf_ospf_ls_pfxsid_flag_l,
5408
14
         { "(L) Local/Global Flag", "ospf.tlv.pfxsid.flags.l", FT_BOOLEAN, 8,
5409
14
           TFS(&tfs_set_notset), SR_STLV_PFXSID_FLAG_L, NULL, HFILL }},
5410
14
        {&hf_ospf_ls_pfxsid_flag_unknown,
5411
14
         { "(*) Unknown Flag", "ospf.tlv.pfxsid.flags.unknown", FT_UINT8, BASE_HEX,
5412
14
           NULL, SR_STLV_PFXSID_FLAG_UNKNOWN, NULL, HFILL }},
5413
5414
        /* OSPF Extended Link TLV */
5415
14
        {&hf_ospf_ls_elink_tlv,
5416
14
         { "TLV Type", "ospf.tlv.extlink.tlv_type", FT_UINT16, BASE_DEC, VALS(ext_link_tlv_type_vals), 0x0, NULL, HFILL }},
5417
14
        {&hf_ospf_ls_elink_stlv,
5418
14
         { "TLV Type", "ospf.tlv.extlink.subtlv_type", FT_UINT16, BASE_DEC, VALS(ext_link_stlv_type_vals), 0x0, NULL, HFILL }},
5419
14
        {&hf_ospf_ls_elink_mt_id,
5420
14
         { "Multi-Topology ID", "ospf.tlv.extlink.mt_id", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5421
14
        {&hf_ospf_ls_elink_weight,
5422
14
         { "Weight", "ospf.tlv.extlink.weight", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5423
14
        {&hf_ospf_ls_elink_nbr,
5424
14
         { "Neighbor ID", "ospf.tlv.extlink.nbr", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5425
5426
14
        {&hf_ospf_ls_adjsid_flags,
5427
14
         { "Flags", "ospf.tlv.adjsid.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
5428
14
        {&hf_ospf_ls_adjsid_flag_b,
5429
14
         { "(B) Backup Flag", "ospf.tlv.adjsid.flags.b", FT_BOOLEAN, 8,
5430
14
           TFS(&tfs_set_notset), SR_STLV_ADJSID_FLAG_B, NULL, HFILL }},
5431
14
        {&hf_ospf_ls_adjsid_flag_v,
5432
14
         { "(V) Value/Index Flag", "ospf.tlv.adjsid.flags.v", FT_BOOLEAN, 8,
5433
14
           TFS(&tfs_set_notset), SR_STLV_ADJSID_FLAG_V, NULL, HFILL }},
5434
14
        {&hf_ospf_ls_adjsid_flag_l,
5435
14
         { "(L) Local/Global Flag", "ospf.tlv.adjsid.flags.l", FT_BOOLEAN, 8,
5436
14
           TFS(&tfs_set_notset), SR_STLV_ADJSID_FLAG_L, NULL, HFILL }},
5437
14
        {&hf_ospf_ls_adjsid_flag_g,
5438
14
         { "(G) Group Flag", "ospf.tlv.adjsid.flags.g", FT_BOOLEAN, 8,
5439
14
           TFS(&tfs_set_notset), SR_STLV_ADJSID_FLAG_G, NULL, HFILL }},
5440
14
        {&hf_ospf_ls_adjsid_flag_p,
5441
14
         { "(P) Persistent Flag", "ospf.tlv.adjsid.flags.p", FT_BOOLEAN, 8,
5442
14
           TFS(&tfs_set_notset), SR_STLV_ADJSID_FLAG_P, NULL, HFILL }},
5443
14
        {&hf_ospf_ls_adjsid_flag_unknown,
5444
14
         { "(*) Unknown Flag", "ospf.tlv.adjsid.flags.unknown", FT_UINT8, BASE_HEX,
5445
14
           NULL, SR_STLV_ADJSID_FLAG_UNKNOWN, NULL, HFILL }},
5446
        /* Application-Specific Link Attributes Sub-TLV (rfc9492) */
5447
14
        {&hf_ospf_ls_app_sabm_length,
5448
14
         { "SABM Length", "ospf.tlv.application.sabm.length",
5449
14
           FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5450
14
        {&hf_ospf_ls_app_udabm_length,
5451
14
         { "UDABM Length", "ospf.tlv.application.udabm.length",
5452
14
           FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5453
14
        {&hf_ospf_ls_app_sabm_bits,
5454
14
         { "Standard Application Identifier Bit Mask", "ospf.tlv.application.sabm.bits",
5455
14
           FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
5456
14
        {&hf_ospf_ls_app_sabm_bits_r,
5457
14
         { "(R) RSVP-TE", "ospf.tlv.application.sabm.bits.r",
5458
14
           FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x80, NULL, HFILL }},
5459
14
        {&hf_ospf_ls_app_sabm_bits_s,
5460
14
         { "(S) Segment Routing Policy", "ospf.tlv.application.sabm.bits.s",
5461
14
           FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x40, NULL, HFILL }},
5462
14
        {&hf_ospf_ls_app_sabm_bits_f,
5463
14
         { "(F) Loop-Free Alternate (LFA)", "ospf.tlv.application.sabm.bits.f",
5464
14
           FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x20, NULL, HFILL }},
5465
14
        {&hf_ospf_ls_app_sabm_bits_x,
5466
14
         { "(X) Flexible Algorithm", "ospf.tlv.application.sabm.bits.x",
5467
14
           FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x10, NULL, HFILL }},
5468
14
        {&hf_ospf_ls_app_udabm_bits,
5469
14
         { "User-Defined Application Identifier Bit Mask", "ospf.tlv.application.udabm.bits",
5470
14
           FT_BYTES, SEP_SPACE, NULL, 0x0, NULL, HFILL }},
5471
14
        {&hf_ospf_ls_app_link_attrs_stlv,
5472
14
         { "TLV Type", "ospf.tlv.application.subtlv_type",
5473
14
           FT_UINT16, BASE_DEC, VALS(ext_link_stlv_type_vals), 0x0, NULL, HFILL }},
5474
14
        {&hf_ospf_ls_srlg,
5475
14
         { "Shared Risk Link Group", "ospf.tlv.srlg",
5476
14
           FT_UINT32, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }},
5477
        /* OSPF Traffic Engineering (TE) Metric Extensions (rfc7471) */
5478
14
        {&hf_ospf_ls_unidir_link_flags,
5479
14
         { "Flags", "ospf.tlv.unidirectional_link_flags",
5480
14
           FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
5481
14
        },
5482
14
        {&hf_ospf_ls_unidir_link_flags_a,
5483
14
         { "(A) Anomalous", "ospf.tlv.unidirectional_link_flags.a",
5484
14
           FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x80, NULL, HFILL }
5485
14
        },
5486
14
        {&hf_ospf_ls_unidir_link_flags_reserved,
5487
14
         { "Reserved", "ospf.tlv.unidirectional_link_flags.reserved",
5488
14
           FT_UINT8, BASE_HEX, NULL, 0x7f, NULL, HFILL }
5489
14
        },
5490
14
        {&hf_ospf_ls_unidir_link_reserved,
5491
14
         { "Reserved", "ospf.tlv.unidirectional_link_reserved",
5492
14
           FT_UINT8, BASE_HEX, NULL, 0,NULL, HFILL }
5493
14
        },
5494
14
        {&hf_ospf_ls_unidir_link_delay,
5495
14
         { "Delay", "ospf.tlv.unidirectional_link_delay",
5496
14
           FT_UINT24, BASE_DEC, NULL, 0,NULL, HFILL }
5497
14
        },
5498
14
        {&hf_ospf_ls_unidir_link_delay_min,
5499
14
         { "Min Delay", "ospf.tlv.unidirectional_link_delay_min",
5500
14
           FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }
5501
14
        },
5502
14
        {&hf_ospf_ls_unidir_link_delay_max,
5503
14
         { "Max Delay", "ospf.tlv.unidirectional_link_delay_max",
5504
14
           FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }
5505
14
        },
5506
14
        {&hf_ospf_ls_unidir_delay_variation,
5507
14
         { "Delay Variation", "ospf.tlv.unidirectional_delay_variation",
5508
14
           FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }
5509
14
        },
5510
        /* Administrative Group (rfc3630) */
5511
14
        {&hf_ospf_ls_admin_group,
5512
14
         { "Admin Group", "ospf.tlv.admin_group", FT_UINT32, BASE_HEX,
5513
14
           NULL, 0x0, NULL, HFILL }},
5514
        /* Extended Administrative Group (rfc7308) */
5515
14
        {&hf_ospf_ls_ext_admin_group,
5516
14
         { "Extended Admin Group", "ospf.tlv.extended_admin_group", FT_UINT32, BASE_HEX,
5517
14
           NULL, 0x0, NULL, HFILL }},
5518
5519
        /* OSPF Extended Inter-Area ASBR TLV */
5520
14
        {&hf_ospf_ls_eia_asbr_tlv,
5521
14
         { "TLV Type", "ospf.tlv.extasbr.tlv_type", FT_UINT16, BASE_DEC,
5522
14
           VALS(ext_ia_asbr_tlv_type_vals), 0x0, NULL, HFILL }},
5523
14
        {&hf_ospf_ls_eia_asbr_stlv,
5524
14
         { "TLV Type", "ospf.tlv.extasbr.subtlv_type", FT_UINT16, BASE_DEC,
5525
14
           VALS(ext_ia_asbr_stlv_type_vals), 0x0, NULL, HFILL }},
5526
14
        {&hf_ospf_ls_eia_asbr_asbr_routerid,
5527
14
         { "ASBR Router ID", "ospf.tlv.extasbr.asbr_routerid", FT_IPv4, BASE_NONE,
5528
14
           NULL, 0x0, NULL, HFILL }},
5529
14
        {&hf_ospf_ls_faam_reserved,
5530
14
         { "Reserved", "ospf.tlv.faam.reserved", FT_UINT24, BASE_HEX,
5531
14
           NULL, 0x0, NULL, HFILL }},
5532
14
        {&hf_ospf_ls_faam_metric,
5533
14
         { "Metric", "ospf.tlv.faam.metric", FT_UINT32, BASE_DEC,
5534
14
           NULL, 0, NULL, HFILL }},
5535
5536
        /* OSPF Restart TLVs  */
5537
14
        {&hf_ospf_grace_tlv,
5538
14
         { "Grace TLV", "ospf.grace", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}},
5539
14
        {&hf_ospf_grace_period,
5540
14
         { "Grace Period", "ospf.grace.period", FT_UINT32, BASE_DEC|BASE_UNIT_STRING,
5541
14
           UNS(&units_seconds), 0x0,
5542
14
           "The number of seconds neighbors should advertise the router as fully adjacent",
5543
14
           HFILL }},
5544
14
        {&hf_ospf_grace_reason,
5545
14
         { "Restart Reason", "ospf.grace.reason", FT_UINT8, BASE_DEC,
5546
14
           VALS(restart_reason_vals), 0x0, "The reason the router is restarting", HFILL }},
5547
14
        {&hf_ospf_grace_ip,
5548
14
         { "Restart IP", "ospf.grace.ip", FT_IPv4, BASE_NONE,
5549
14
           NULL, 0x0, "The IP address of the interface originating this LSA", HFILL }},
5550
5551
        /* OSPFv3 LLS TLVs */
5552
14
        {&hf_ospf_v3_lls_ext_options_tlv,
5553
14
         { "Extended Options TLV", "ospf.v3.lls.ext.options.tlv", FT_NONE, BASE_NONE,
5554
14
           NULL, 0x0, NULL, HFILL }},
5555
14
        {&hf_ospf_v3_lls_ext_options,
5556
14
         { "Options", "ospf.v3.lls.ext.options", FT_UINT32,  BASE_HEX,
5557
14
           NULL, 0x0, NULL, HFILL }},
5558
14
        {&hf_ospf_v3_lls_ext_options_lr,
5559
14
         { "(LR) LSDB Resynchronization", "ospf.v3.lls.ext.options.lr", FT_BOOLEAN, 32,
5560
14
           TFS(&tfs_set_notset), OSPF_V3_LLS_EXT_OPTIONS_LR, NULL, HFILL }},
5561
14
        {&hf_ospf_v3_lls_ext_options_rs,
5562
14
         { "(RS) Restart Signal", "ospf.v3.lls.ext.options.rs", FT_BOOLEAN, 32,
5563
14
           TFS(&tfs_set_notset), OSPF_V3_LLS_EXT_OPTIONS_RS, NULL, HFILL }},
5564
14
        {&hf_ospf_v3_lls_state_tlv,
5565
14
         { "State Check Sequence TLV", "ospf.v3.lls.state.tlv", FT_NONE, BASE_NONE,
5566
14
           NULL, 0x0, NULL, HFILL }},
5567
14
        {&hf_ospf_v3_lls_state_scs,
5568
14
         { "SCS Number", "ospf.v3.lls.state.scs", FT_UINT16,  BASE_DEC,
5569
14
           NULL, 0x0, NULL, HFILL }},
5570
14
        {&hf_ospf_v3_lls_state_options,
5571
14
         { "Options", "ospf.v3.lls.state.options", FT_UINT8,  BASE_HEX,
5572
14
           NULL, 0x0, NULL, HFILL }},
5573
14
        {&hf_ospf_v3_lls_state_options_r,
5574
14
         { "(R) Request", "ospf.v3.lls.state.options.r", FT_BOOLEAN, 8,
5575
14
           TFS(&tfs_set_notset), OSPF_V3_LLS_STATE_OPTIONS_R, NULL, HFILL }},
5576
14
        {&hf_ospf_v3_lls_state_options_a,
5577
14
         { "(A) Answer", "ospf.v3.lls.state.options.a", FT_BOOLEAN, 8,
5578
14
           TFS(&tfs_set_notset), OSPF_V3_LLS_STATE_OPTIONS_A , NULL, HFILL }},
5579
14
        {&hf_ospf_v3_lls_state_options_n,
5580
14
         { "(N) Incomplete", "ospf.v3.lls.state.options.n", FT_BOOLEAN, 8,
5581
14
           TFS(&tfs_set_notset), OSPF_V3_LLS_STATE_OPTIONS_N ,NULL, HFILL }},
5582
14
        {&hf_ospf_v3_lls_drop_tlv,
5583
14
         { "Neighbor Drop TLV", "ospf.v3.lls.drop.tlv", FT_NONE, BASE_NONE,
5584
14
           NULL, 0x0, NULL, HFILL }},
5585
14
        {&hf_ospf_v3_lls_relay_tlv,
5586
14
         { "Active Overlapping Relays TLV", "ospf.v3.lls.relay.tlv", FT_NONE, BASE_NONE,
5587
14
           NULL, 0x0, NULL, HFILL }},
5588
14
        {&hf_ospf_v3_lls_relay_added,
5589
14
         { "Relays Added", "ospf.v3.lls.relay.added", FT_UINT8,  BASE_DEC,
5590
14
           NULL, 0x0, NULL, HFILL }},
5591
14
        {&hf_ospf_v3_lls_relay_options,
5592
14
         { "Options", "ospf.v3.lls.relay.options", FT_UINT8,  BASE_HEX,
5593
14
           NULL, 0x0, NULL, HFILL }},
5594
14
        {&hf_ospf_v3_lls_relay_options_a,
5595
14
         { "(A) Always", "ospf.v3.lls.relay.options.a", FT_BOOLEAN, 8,
5596
14
           TFS(&tfs_set_notset), OSPF_V3_LLS_RELAY_OPTIONS_A, NULL, HFILL }},
5597
14
        {&hf_ospf_v3_lls_relay_options_n,
5598
14
         { "(N) Never", "ospf.v3.lls.relay.options.n", FT_BOOLEAN, 8,
5599
14
           TFS(&tfs_set_notset), OSPF_V3_LLS_RELAY_OPTIONS_N, NULL, HFILL }},
5600
14
        {&hf_ospf_v3_lls_willingness_tlv,
5601
14
         { "Willingness TLV", "ospf.v3.lls.willingness.tlv", FT_NONE, BASE_NONE,
5602
14
           NULL, 0x0, NULL, HFILL }},
5603
14
        {&hf_ospf_v3_lls_willingness,
5604
14
         { "Willingness", "ospf.v3.lls.willingness", FT_UINT8,  BASE_DEC,
5605
14
           NULL, 0x0, NULL, HFILL }},
5606
14
        {&hf_ospf_v3_lls_rf_tlv,
5607
14
         { "Request From TLV", "ospf.v3.lls.rf.tlv", FT_NONE, BASE_NONE,
5608
14
           NULL, 0x0, NULL, HFILL }},
5609
14
        {&hf_ospf_v3_lls_fsf_tlv,
5610
14
         { "Full State For TLV", "ospf.v3.lls.fsf.tlv", FT_NONE, BASE_NONE,
5611
14
           NULL, 0x0, NULL, HFILL }},
5612
14
        {&hf_ospf_v2_lls_li_id,
5613
14
         { "Local Interface ID", "ospf.v3.lls.ll_id", FT_BYTES, BASE_NONE,
5614
14
           NULL, 0x0, NULL, HFILL }},
5615
      /* Generated from convert_proto_tree_add_text.pl */
5616
14
      { &hf_ospf_v2_lls_sequence_number, { "Sequence number", "ospf.v2.lls.sequence_number", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
5617
14
      { &hf_ospf_v2_lls_auth_data, { "Auth Data", "ospf.v2.lls.auth_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5618
14
      { &hf_ospf_v3_lls_dropped_neighbor, { "Dropped Neighbor", "ospf.v3.lls.dropped_neighbor", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5619
14
      { &hf_ospf_v3_lls_neighbor, { "Neighbor", "ospf.v3.lls.neighbor", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5620
14
      { &hf_ospf_v3_lls_request_from, { "Request From", "ospf.v3.lls.request_from", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5621
14
      { &hf_ospf_v3_lls_full_state_for, { "Full State For", "ospf.v3.lls.full_state_for", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5622
14
      { &hf_ospf_lls_checksum, { "Checksum", "ospf.lls.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
5623
14
      { &hf_ospf_lls_data_length, { "LLS Data Length", "ospf.lls.data_length", FT_UINT16, BASE_DEC|BASE_UNIT_STRING, UNS(&units_byte_bytes), 0x0, NULL, HFILL }},
5624
14
      { &hf_ospf_db_interface_mtu, { "Interface MTU", "ospf.db.interface_mtu", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5625
14
      { &hf_ospf_db_dd_sequence, { "DD Sequence", "ospf.db.dd_sequence", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5626
14
      { &hf_ospf_link_state_id, { "Link State ID", "ospf.link_state_id", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5627
14
      { &hf_ospf_ls_number_of_lsas, { "Number of LSAs", "ospf.ls.number_of_lsas", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5628
14
      { &hf_ospf_mpls_action, { "Action", "ospf.mpls.action", FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL }},
5629
14
      { &hf_ospf_mpls_bandwidth_type, { "Bandwidth Type", "ospf.mpls.bandwidth.type", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5630
14
      { &hf_ospf_mpls_cs, { "Channel Spacing", "ospf.mpls.cs", FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL }},
5631
14
      { &hf_ospf_mpls_switching_type, { "Switching Type", "ospf.mpls.switching_type", FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gmpls_switching_type_rvals), 0x0, NULL, HFILL }},
5632
14
      { &hf_ospf_mpls_encoding, { "Encoding", "ospf.mpls.encoding", FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gmpls_lsp_enc_rvals), 0x0, NULL, HFILL }},
5633
14
      { &hf_ospf_mpls_num_labels, { "Num Labels", "ospf.mpls.num.labels", FT_UINT16, BASE_DEC, NULL, 0x0FFF, NULL, HFILL }},
5634
14
      { &hf_ospf_mpls_interface_mtu, { "Interface MTU", "ospf.mpls.interface_mtu", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5635
14
      { &hf_ospf_mpls_length, { "Length", "ospf.mpls.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5636
14
      { &hf_ospf_mpls_pri, { "Priority", "ospf.mpls.priority", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5637
14
      { &hf_ospf_mpls_protection_capability, { "Protection Capability", "ospf.mpls.protection_capability", FT_UINT8, BASE_HEX, VALS(gmpls_protection_cap_str), 0x0, NULL, HFILL }},
5638
14
      { &hf_ospf_mpls_shared_risk_link_group, { "Shared Risk Link Group", "ospf.mpls.shared_risk_link_group", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5639
14
      { &hf_ospf_mpls_starting, { "Starting n", "ospf.mpls.starting", FT_UINT32, BASE_DEC, NULL, 0x0FFFF000, NULL, HFILL }},
5640
14
      { &hf_ospf_mpls_no_effective_bits, { "No. of effective. Bits", "ospf.mpls.effective", FT_UINT16, BASE_DEC, NULL, 0x0FFF, NULL, HFILL }},
5641
14
      { &hf_ospf_mpls_bitmap, { "Bitmap", "ospf.mpls.bitmap", FT_UINT32, BASE_HEX, NULL, 0xFFFFFFFF, NULL, HFILL }},
5642
14
      { &hf_ospf_mpls_grid, { "Grid", "ospf.mpls.grid", FT_UINT8, BASE_DEC, NULL, 0xE0, NULL, HFILL }},
5643
14
      { &hf_ospf_mpls_cs2, { "Channel Spacing", "ospf.mpls.cs", FT_UINT8, BASE_DEC, NULL, 0x1E, NULL, HFILL }},
5644
14
      { &hf_ospf_mpls_n, { "Starting n", "ospf.mpls.n", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5645
14
      { &hf_ospf_mpls_type, { "Type", "ospf.mpls.type", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5646
14
      { &hf_ospf_oif_switching_cap, { "Switching Cap", "ospf.oif.switching_cap", FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gmpls_switching_type_rvals), 0x0, NULL, HFILL }},
5647
14
      { &hf_ospf_oif_encoding, { "Encoding", "ospf.oif.encoding", FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(gmpls_lsp_enc_rvals), 0x0, NULL, HFILL }},
5648
14
      { &hf_ospf_oif_tna_addr_length, { "Addr Length", "ospf.oif.tna_addr_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5649
14
      { &hf_ospf_oif_tna_addr_ipv4, { "TNA Addr", "ospf.oif.tna_addr.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5650
14
      { &hf_ospf_tna_addr_ipv6, { "TNA Addr", "ospf.oif.tna_addr.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5651
14
      { &hf_ospf_tna_addr, { "TNA Addr", "ospf.oif.tna_addr", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5652
14
      { &hf_ospf_ls_id_te_lsa_reserved, { "Link State ID TE-LSA Reserved", "ospf.lsid_te_lsa.reserved", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5653
14
      { &hf_ospf_ls_id_opaque_id, { "Link State ID Opaque ID", "ospf.lsid.opaque_id", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5654
14
      { &hf_ospf_lsa_number_of_links, { "Number of Links", "ospf.lsa.number_of_links", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5655
14
      { &hf_ospf_v3_lsa_do_not_age, { "Do Not Age", "ospf.v3.lsa.do_not_age", FT_BOOLEAN, 16, NULL, OSPF_DNA_LSA, NULL, HFILL }},
5656
14
      { &hf_ospf_v3_lsa_interface_id, { "Interface ID", "ospf.v3.lsa.interface_id", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5657
14
      { &hf_ospf_v3_lsa_neighbor_interface_id, { "Neighbor Interface ID", "ospf.v3.lsa.neighbor_interface_id", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5658
14
      { &hf_ospf_v3_lsa_neighbor_router_id, { "Neighbor Router ID", "ospf.v3.lsa.neighbor_router_id", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5659
14
      { &hf_ospf_v3_lsa_attached_router, { "Attached Router", "ospf.v3.lsa.attached_router", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5660
14
      { &hf_ospf_v3_lsa_destination_router_id, { "Destination Router ID", "ospf.v3.lsa.destination_router_id", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5661
14
      { &hf_ospf_v3_lsa_referenced_ls_type, { "Referenced LS type", "ospf.v3.lsa.referenced_ls_type", FT_UINT16, BASE_HEX, VALS(v3_ls_type_vals), 0x0, NULL, HFILL }},
5662
14
      { &hf_ospf_v3_lsa_forwarding_address_ipv6, { "Forwarding Address", "ospf.v3.lsa.forwarding_address.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5663
14
      { &hf_ospf_v3_lsa_external_route_tag, { "External Route Tag", "ospf.v3.lsa.external_route_tag", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5664
14
      { &hf_ospf_v3_lsa_referenced_link_state_id, { "Referenced Link State ID", "ospf.v3.lsa.referenced_link_state_id", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5665
14
      { &hf_ospf_v3_lsa_router_priority, { "Router Priority", "ospf.v3.lsa.router_priority", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5666
14
      { &hf_ospf_v3_lsa_link_local_interface_address, { "Link-local Interface Address", "ospf.v3.lsa.link_local_interface_address.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5667
14
      { &hf_ospf_referenced_advertising_router, { "Referenced Advertising Router", "ospf.v3.lsa.referenced_advertising_router", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5668
14
      { &hf_ospf_lsa_external_type, { "External Type", "ospf.lsa.asext.type", FT_BOOLEAN, 8, TFS(&tfs_lsa_external_type), 0x80, NULL, HFILL }},
5669
14
      { &hf_ospf_lsa_tos, { "TOS", "ospf.lsa.tos", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5670
14
      { &hf_ospf_lsa_external_tos, { "TOS", "ospf.lsa.tos", FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
5671
14
      { &hf_ospf_v3_lsa_type, { "Type", "ospf.v3.lsa.type", FT_UINT8, BASE_DEC, VALS(ospf_v3_lsa_type_vals), 0, NULL, HFILL }},
5672
14
      { &hf_ospf_metric, { "Metric", "ospf.metric", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
5673
14
      { &hf_ospf_prefix_length, { "PrefixLength", "ospf.prefix_length", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
5674
14
      { &hf_ospf_ls_mpls_pri, { "Pri (or TE-Class)", "ospf.mpls.pri", FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5675
14
      { &hf_ospf_ls_mpls_bc, { "BC", "ospf.mpls.bc", FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5676
14
      { &hf_ospf_mpls_minimum_lsp_bandwidth, { "Minimum LSP bandwidth", "ospf.mpls.minimum_lsp_bandwidth", FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5677
14
      { &hf_ospf_mpls_sonet_sdh, { "SONET/SDH", "ospf.mpls.sonet.sdh", FT_BOOLEAN, BASE_NONE, TFS(&tfs_arbitrary_standard), 0x0, NULL, HFILL }},
5678
14
      { &hf_ospf_oif_signal_type, { "Signal Type", "ospf.oif.signal_type", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gmpls_sonet_signal_type_str_ext, 0x0, NULL, HFILL }},
5679
14
      { &hf_ospf_tlv_value, { "TLV Value", "ospf.tlv_value", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5680
14
      { &hf_ospf_oif_node_id, { "Node ID", "ospf.oif.node_id", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5681
14
      { &hf_ospf_pad_bytes, { "Pad Bytes", "ospf.pad_bytes", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5682
14
      { &hf_ospf_ls_metric, { "Metric", "ospf.ls.metric", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5683
14
      { &hf_ospf_v3_lsa_forwarding_address_ipv4, { "Forwarding Address", "ospf.v3.lsa.forwarding_address.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5684
14
      { &hf_ospf_link_local_interface_address_ipv4, { "Link-local Interface Address", "ospf.v3.lsa.link_local_interface_address.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5685
14
      { &hf_ospf_v3_lsa_num_prefixes, { "# prefixes", "ospf.v3.lsa.num_prefixes", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
5686
14
      { &hf_ospf_v3_address_prefix_ipv6, { "Address Prefix", "ospf.v3.address_prefix.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5687
14
      { &hf_ospf_v3_address_prefix_ipv4, { "Address Prefix", "ospf.v3.address_prefix.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
5688
14
    };
5689
5690
14
    static int *ett[] = {
5691
14
        &ett_ospf,
5692
14
        &ett_ospf_at,
5693
14
        &ett_ospf_hdr,
5694
14
        &ett_ospf_hello,
5695
14
        &ett_ospf_desc,
5696
14
        &ett_ospf_lsr,
5697
14
        &ett_ospf_lsa,
5698
14
        &ett_ospf_lsa_router_link,
5699
14
        &ett_ospf_lsa_upd,
5700
14
        &ett_ospf_lsa_mpls,
5701
14
        &ett_ospf_lsa_mpls_bandwidth_sstlv,
5702
14
        &ett_ospf_lsa_mpls_base_label,
5703
14
        &ett_ospf_lsa_mpls_router,
5704
14
        &ett_ospf_lsa_mpls_link,
5705
14
        &ett_ospf_lsa_mpls_link_stlv,
5706
14
        &ett_ospf_lsa_mpls_link_stlv_admingrp,
5707
14
        &ett_ospf_lsa_opaque_ri,
5708
14
        &ett_ospf_elsa,
5709
14
        &ett_ospf_elsa_pfx_tlv,
5710
14
        &ett_ospf_lsa_ri_tlv,
5711
14
        &ett_ospf_lsa_dh_tlv,
5712
14
        &ett_ospf_lsa_sa_tlv,
5713
14
        &ett_ospf_lsa_slr_tlv,
5714
14
        &ett_ospf_lsa_slr_stlv,
5715
14
        &ett_ospf_lsa_srms_tlv,
5716
14
        &ett_ospf_lsa_node_msd_tlv,
5717
14
        &ett_ospf_lsa_fad_tlv,
5718
14
        &ett_ospf_lsa_fad_stlv,
5719
14
        &ett_ospf_lsa_fad_def_flags,
5720
14
        &ett_ospf_lsa_fapm_flags,
5721
14
        &ett_ospf_lsa_unknown_tlv,
5722
14
        &ett_ospf_lsa_epfx,
5723
14
        &ett_ospf_lsa_elink,
5724
14
        &ett_ospf_lsa_elink_tlv,
5725
14
        &ett_ospf_lsa_elink_stlv,
5726
14
        &ett_ospf_lsa_epfx_tlv,
5727
14
        &ett_ospf_lsa_epfx_flags,
5728
14
        &ett_ospf_lsa_epfx_range_flags,
5729
14
        &ett_ospf_lsa_epfx_stlv,
5730
14
        &ett_ospf_lsa_pfxsid_flags,
5731
14
        &ett_ospf_lsa_adjsid_flags,
5732
14
        &ett_ospf_lsa_app_sabm_bits,
5733
14
        &ett_ospf_lsa_app_link_attrs_stlv,
5734
14
        &ett_ospf_lsa_unidir_link_flags,
5735
14
        &ett_ospf_lsa_eia_asbr,
5736
14
        &ett_ospf_lsa_eia_asbr_tlv,
5737
14
        &ett_ospf_lsa_oif_tna,
5738
14
        &ett_ospf_lsa_oif_tna_stlv,
5739
14
        &ett_ospf_lsa_grace_tlv,
5740
14
        &ett_ospf_lsa_type,
5741
14
        &ett_ospf_v2_options,
5742
14
        &ett_ospf_ri_options,
5743
14
        &ett_ospf_v3_options,
5744
14
        &ett_ospf_dbd,
5745
14
        &ett_ospf_lls_data_block,
5746
14
        &ett_ospf_lls_tlv,
5747
14
        &ett_ospf_lls_ext_options,
5748
14
        &ett_ospf_v3_router_interface,
5749
14
        &ett_ospf_v3_router_interface_entry,
5750
14
        &ett_ospf_v3_lls_ext_options_tlv,
5751
14
        &ett_ospf_v3_lls_ext_options,
5752
14
        &ett_ospf_v3_lls_state_tlv,
5753
14
        &ett_ospf_v3_lls_state_scs,
5754
14
        &ett_ospf_v3_lls_state_options,
5755
14
        &ett_ospf_v3_lls_drop_tlv,
5756
14
        &ett_ospf_v3_lls_relay_tlv,
5757
14
        &ett_ospf_v3_lls_relay_added,
5758
14
        &ett_ospf_v3_lls_relay_options,
5759
14
        &ett_ospf_v3_lls_willingness_tlv,
5760
14
        &ett_ospf_v3_lls_willingness,
5761
14
        &ett_ospf_v3_lls_rf_tlv,
5762
14
        &ett_ospf_v3_lls_fsf_tlv,
5763
14
        &ett_ospf_v2_router_lsa_flags,
5764
14
        &ett_ospf_v3_router_lsa_flags,
5765
14
        &ett_ospf_v3_as_external_flags,
5766
14
        &ett_ospf_v3_prefix_options,
5767
14
        &ett_ospf_mpls_pri,
5768
14
        &ett_ospf_mpls_bitmap,
5769
14
        &ett_ospf_lsa_eia_asbr_stlv
5770
14
    };
5771
5772
14
    static ei_register_info ei[] = {
5773
14
        { &ei_ospf_header_reserved, { "ospf.reserved.not_zero", PI_PROTOCOL, PI_WARN, "incorrect, should be 0", EXPFILL }},
5774
14
        { &ei_ospf_lsa_bad_length, { "ospf.lsa.invalid_length", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }},
5775
14
        { &ei_ospf_lsa_constraint_missing, { "ospf.lsa.tos_missing", PI_MALFORMED, PI_WARN, "Blocks missing", EXPFILL }},
5776
14
        { &ei_ospf_lsa_bc_error, { "ospf.lsa.bc_error", PI_PROTOCOL, PI_WARN, "BC error", EXPFILL }},
5777
14
        { &ei_ospf_lsa_unknown_type, { "ospf.lsa.unknown_type", PI_PROTOCOL, PI_WARN, "Unknown LSA Type", EXPFILL }},
5778
14
        { &ei_ospf_unknown_link_subtype, { "ospf.unknown_link_subtype", PI_PROTOCOL, PI_WARN, "Unknown Link sub-TLV", EXPFILL }},
5779
14
        { &ei_ospf_stlv_length_invalid, { "ospf.stlv.invalid_length", PI_PROTOCOL, PI_WARN, "Invalid sub-TLV length", EXPFILL }},
5780
14
    };
5781
5782
14
    expert_module_t* expert_ospf;
5783
5784
14
    proto_ospf = proto_register_protocol("Open Shortest Path First",
5785
14
                                         "OSPF", "ospf");
5786
14
    ospf_handle = register_dissector("ospf", dissect_ospf, proto_ospf);
5787
14
    ospf_cap_handle = register_capture_dissector("ospf", capture_ospf, proto_ospf);
5788
14
    proto_register_field_array(proto_ospf, ospff_info, array_length(ospff_info));
5789
14
    proto_register_subtree_array(ett, array_length(ett));
5790
14
    expert_ospf = expert_register_protocol(proto_ospf);
5791
14
    expert_register_field_array(expert_ospf, ei, array_length(ei));
5792
14
}
5793
5794
void
5795
proto_reg_handoff_ospf(void)
5796
14
{
5797
14
    dissector_add_uint("ip.proto", IP_PROTO_OSPFIGP, ospf_handle);
5798
14
    capture_dissector_add_uint("ip.proto", IP_PROTO_OSPFIGP, ospf_cap_handle);
5799
14
}
5800
5801
/*
5802
 * Editor modelines
5803
 *
5804
 * Local Variables:
5805
 * c-basic-offset: 4
5806
 * tab-width: 8
5807
 * indent-tabs-mode: nil
5808
 * End:
5809
 *
5810
 * ex: set shiftwidth=4 tabstop=8 expandtab:
5811
 * :indentSize=4:tabSize=8:noTabs=true:
5812
 */