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