2 * Routines for OSPF packet disassembly
3 * (c) Copyright Hannes R. Boehm <hannes@boehm.org>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 * At this time, this module is able to analyze OSPF
27 * packets as specified in RFC2328. MOSPF (RFC1584) and other
28 * OSPF Extensions which introduce new Packet types
29 * (e.g the External Atributes LSA) are not supported.
30 * Furthermore RFC2740 (OSPFv3 - OSPF for IPv6) is now supported
31 * - (c) 2001 Palle Lyckegaard <palle[AT]lyckegaard.dk>
33 * Added support to E-NNI routing (OIF2003.259.02)
34 * - (c) 2004 Roberto Morro <roberto.morro[AT]tilab.com>
36 * Added support for OSPF restart signaling:
37 * draft-nguyen-ospf-lls-05.txt
38 * draft-nguyen-ospf-oob-resync-05.txt
39 * draft-nguyen-ospf-restart-05.txt
40 * - (c) 2005 Michael Rozhavsky <mrozhavsky@fortinet.com>
42 * Added support of MPLS Diffserv-aware TE (RFC 4124); new BC sub-TLV
43 * - (c) 2006 (FF) <francesco.fondelli[AT]gmail.com>
45 * Added support for decoding the TLVs in a grace-LSA
46 * - (c) 2007 Todd J Martin <todd.martin@acm.org>
48 * Added support for draft-ietf-ospf-manet-or-02
49 * Added support for draft-ietf-ospf-af-alt-06
50 * - (c) 2008 Cisco Systems
52 * Added support for Multi-Topology (MT) Routing (RFC4915)
53 * - (c) 2009 Stig Bjorlykke <stig@bjorlykke.org>, Thales Norway AS
63 #include <epan/packet.h>
64 #include <epan/ipproto.h>
65 #include <epan/in_cksum.h>
66 #include <epan/emem.h>
67 #include <epan/addr_resolv.h>
68 #include "packet-rsvp.h"
70 #define OSPF_VERSION_2 2
71 #define OSPF_VERSION_3 3
74 #define OSPF_VERSION_2_HEADER_LENGTH 24
75 #define OSPF_VERSION_3_HEADER_LENGTH 16
79 #define OSPF_DB_DESC 2
84 static const value_string pt_vals[] = {
85 {OSPF_HELLO, "Hello Packet" },
86 {OSPF_DB_DESC, "DB Description" },
87 {OSPF_LS_REQ, "LS Request" },
88 {OSPF_LS_UPD, "LS Update" },
89 {OSPF_LS_ACK, "LS Acknowledge" },
93 #define OSPF_AUTH_NONE 0
94 #define OSPF_AUTH_SIMPLE 1
95 #define OSPF_AUTH_CRYPT 2
97 static const value_string auth_vals[] = {
98 {OSPF_AUTH_NONE, "Null" },
99 {OSPF_AUTH_SIMPLE, "Simple password" },
100 {OSPF_AUTH_CRYPT, "Cryptographic" },
104 #define OSPF_V2_OPTIONS_MT 0x01
105 #define OSPF_V2_OPTIONS_E 0x02
106 #define OSPF_V2_OPTIONS_MC 0x04
107 #define OSPF_V2_OPTIONS_NP 0x08
108 #define OSPF_V2_OPTIONS_L 0x10
109 #define OSPF_V2_OPTIONS_DC 0x20
110 #define OSPF_V2_OPTIONS_O 0x40
111 #define OSPF_V2_OPTIONS_DN 0x80
112 #define OSPF_V3_OPTIONS_V6 0x01
113 #define OSPF_V3_OPTIONS_E 0x02
114 #define OSPF_V3_OPTIONS_MC 0x04
115 #define OSPF_V3_OPTIONS_N 0x08
116 #define OSPF_V3_OPTIONS_R 0x10
117 #define OSPF_V3_OPTIONS_DC 0x20
118 #define OSPF_V3_OPTIONS_AF 0x0100
119 #define OSPF_V3_OPTIONS_L 0x0200
120 #define OSPF_V3_OPTIONS_I 0x0400
121 #define OSPF_V3_OPTIONS_F 0x0800
123 #define OSPF_LLS_EXT_OPTIONS_LR 0x00000001
124 #define OSPF_LLS_EXT_OPTIONS_RS 0x00000002
126 #define OSPF_V3_LLS_EXT_OPTIONS_LR 0x00000001
127 #define OSPF_V3_LLS_EXT_OPTIONS_RS 0x00000002
129 #define OSPF_V3_LLS_STATE_OPTIONS_R 0x80
130 #define OSPF_V3_LLS_STATE_OPTIONS_A 0x40
131 #define OSPF_V3_LLS_STATE_OPTIONS_N 0x20
132 #define OSPF_V3_LLS_RELAY_OPTIONS_A 0x80
133 #define OSPF_V3_LLS_RELAY_OPTIONS_N 0x40
135 #define OSPF_DBD_FLAG_MS 1
136 #define OSPF_DBD_FLAG_M 2
137 #define OSPF_DBD_FLAG_I 4
138 #define OSPF_DBD_FLAG_R 8
140 #define OSPF_LS_REQ_LENGTH 12
142 #define OSPF_LSTYPE_ROUTER 1
143 #define OSPF_LSTYPE_NETWORK 2
144 #define OSPF_LSTYPE_SUMMERY 3
145 #define OSPF_LSTYPE_ASBR 4
146 #define OSPF_LSTYPE_ASEXT 5
147 #define OSPF_LSTYPE_GRPMEMBER 6
148 #define OSPF_LSTYPE_ASEXT7 7
149 #define OSPF_LSTYPE_EXTATTR 8
150 #define OSPF_V3_LSTYPE_ROUTER 0x2001
151 #define OSPF_V3_LSTYPE_NETWORK 0x2002
152 #define OSPF_V3_LSTYPE_INTER_AREA_PREFIX 0x2003
153 #define OSPF_V3_LSTYPE_INTER_AREA_ROUTER 0x2004
154 #define OSPF_V3_LSTYPE_AS_EXTERNAL 0x4005
155 #define OSPF_V3_LSTYPE_GROUP_MEMBERSHIP 0x2006
156 #define OSPF_V3_LSTYPE_TYPE_7 0x2007
157 #define OSPF_V3_LSTYPE_LINK 0x0008
158 #define OSPF_V3_LSTYPE_INTRA_AREA_PREFIX 0x2009
160 /* Opaque LSA types */
161 #define OSPF_LSTYPE_OP_LINKLOCAL 9
162 #define OSPF_LSTYPE_OP_AREALOCAL 10
163 #define OSPF_LSTYPE_OP_ASWIDE 11
165 #define OSPF_LINK_PTP 1
166 #define OSPF_LINK_TRANSIT 2
167 #define OSPF_LINK_STUB 3
168 #define OSPF_LINK_VIRTUAL 4
170 #define OSPF_V3_LINK_PTP 1
171 #define OSPF_V3_LINK_TRANSIT 2
172 #define OSPF_V3_LINK_RESERVED 3
173 #define OSPF_V3_LINK_VIRTUAL 4
175 #define OSPF_LSA_HEADER_LENGTH 20
177 #define OSPF_DNA_LSA 0x8000
178 /* Known opaque LSAs */
179 #define OSPF_LSA_MPLS_TE 1
180 #define OSPF_LSA_GRACE 3
181 #define OSPF_RESTART_REASON_UNKNOWN 0
182 #define OSPF_RESTART_REASON_SWRESTART 1
183 #define OSPF_RESTART_REASON_SWRELOAD 2
184 #define OSPF_RESTART_REASON_SWITCH 3
186 static const value_string restart_reason_vals[] = {
187 {OSPF_RESTART_REASON_UNKNOWN, "Unknown" },
188 {OSPF_RESTART_REASON_SWRESTART, "Software Restart" },
189 {OSPF_RESTART_REASON_SWRELOAD, "Software Reload/Upgrade" },
190 {OSPF_RESTART_REASON_SWITCH, "Processor Switchover" },
194 /* grace-LSA TLV Types */
195 #define GRACE_TLV_PERIOD 1
196 #define GRACE_TLV_REASON 2
197 #define GRACE_TLV_IP 3
199 static const value_string grace_tlv_type_vals[] = {
200 {GRACE_TLV_PERIOD, "grace-LSA Grace Period"},
201 {GRACE_TLV_REASON, "grace-LSA Restart Reason"},
202 {GRACE_TLV_IP, "grace-LSA Restart IP"},
206 static const value_string ls_type_vals[] = {
207 {OSPF_LSTYPE_ROUTER, "Router-LSA" },
208 {OSPF_LSTYPE_NETWORK, "Network-LSA" },
209 {OSPF_LSTYPE_SUMMERY, "Summary-LSA (IP network)" },
210 {OSPF_LSTYPE_ASBR, "Summary-LSA (ASBR)" },
211 {OSPF_LSTYPE_ASEXT, "AS-External-LSA (ASBR)" },
212 {OSPF_LSTYPE_GRPMEMBER, "Group Membership LSA" },
213 {OSPF_LSTYPE_ASEXT7, "NSSA AS-External-LSA" },
214 {OSPF_LSTYPE_EXTATTR, "External Attributes LSA" },
215 {OSPF_LSTYPE_OP_LINKLOCAL, "Opaque LSA, Link-local scope" },
216 {OSPF_LSTYPE_OP_AREALOCAL, "Opaque LSA, Area-local scope" },
221 static const value_string ls_opaque_type_vals[] = {
222 {OSPF_LSA_MPLS_TE, "Traffic Engineering LSA" },
223 {2, "Sycamore Optical Topology Descriptions" },
224 {OSPF_LSA_GRACE, "grace-LSA" },
228 static const value_string v3_ls_type_vals[] = {
229 {OSPF_V3_LSTYPE_ROUTER, "Router-LSA" },
230 {OSPF_V3_LSTYPE_NETWORK, "Network-LSA" },
231 {OSPF_V3_LSTYPE_INTER_AREA_PREFIX, "Inter-Area-Prefix-LSA" },
232 {OSPF_V3_LSTYPE_INTER_AREA_ROUTER, "Inter-Area-Router-LSA" },
233 {OSPF_V3_LSTYPE_AS_EXTERNAL, "AS-External-LSA" },
234 {OSPF_V3_LSTYPE_GROUP_MEMBERSHIP, "Group-Membership-LSA" },
235 {OSPF_V3_LSTYPE_TYPE_7, "Type-LSA" },
236 {OSPF_V3_LSTYPE_LINK, "Link-LSA" },
237 {OSPF_V3_LSTYPE_INTRA_AREA_PREFIX, "Intra-Area-Prefix-LSA" },
242 static const value_string lls_tlv_type_vals[] = {
243 {1, "Extended options TLV" },
244 {2, "Crypto Authentication TLV" },
248 /* OSPFv3 LLS TLV Types */
249 #define LLS_V3_EXT_OPT 1
250 #define LLS_V3_STATE_CHECK 3
251 #define LLS_V3_NBR_DROP 4
252 #define LLS_V3_RELAYS 7
253 #define LLS_V3_WILLING 8
254 #define LLS_V3_RQST_FROM 5
255 #define LLS_V3_FULL_STATE 6
257 static const value_string lls_v3_tlv_type_vals[] = {
258 {LLS_V3_EXT_OPT, "Extended Options TLV" },
259 {LLS_V3_STATE_CHECK, "State Check Sequence TLV" },
260 {LLS_V3_NBR_DROP, "Neighbor Drop TLV" },
261 {LLS_V3_RELAYS, "Active Overlapping Relays TLV" },
262 {LLS_V3_WILLING, "Willingness TLV" },
263 {LLS_V3_RQST_FROM, "Request From LTV" },
264 {LLS_V3_FULL_STATE, "Full State For TLV" },
268 static const value_string mpls_link_stlv_ltype_str[] = {
269 {1, "Point-to-point"},
274 /* FF: from www.iana.org/assignments/bandwidth-constraints-model-ids */
275 static const range_string mpls_link_stlv_bcmodel_rvals[] = {
276 { 0, 0, "(Russian Dolls Model - RDM)" },
277 { 1, 1, "(Maximum Allocation Model - MAM)" },
278 { 2, 2, "(Maximum Allocation with Reservation Model - MAR)" },
279 { 3, 239, "(Unassigned, Specification Required)" },
280 { 240, 255, "(Reserved, Private Use)" },
284 #define OSPF_V2_ROUTER_LSA_FLAG_B 0x01
285 #define OSPF_V2_ROUTER_LSA_FLAG_E 0x02
286 #define OSPF_V2_ROUTER_LSA_FLAG_V 0x04
287 #define OSPF_V2_ROUTER_LSA_FLAG_W 0x08
288 #define OSPF_V2_ROUTER_LSA_FLAG_N 0x10
289 #define OSPF_V3_ROUTER_LSA_FLAG_B 0x01
290 #define OSPF_V3_ROUTER_LSA_FLAG_E 0x02
291 #define OSPF_V3_ROUTER_LSA_FLAG_V 0x04
292 #define OSPF_V3_ROUTER_LSA_FLAG_W 0x08
294 #define OSPF_V3_PREFIX_OPTION_NU 0x01
295 #define OSPF_V3_PREFIX_OPTION_LA 0x02
296 #define OSPF_V3_PREFIX_OPTION_MC 0x04
297 #define OSPF_V3_PREFIX_OPTION_P 0x08
299 #define OSPF_V3_AS_EXTERNAL_FLAG_T 0x01
300 #define OSPF_V3_AS_EXTERNAL_FLAG_F 0x02
301 #define OSPF_V3_AS_EXTERNAL_FLAG_E 0x04
304 static int proto_ospf = -1;
306 static gint ett_ospf = -1;
307 static gint ett_ospf_hdr = -1;
308 static gint ett_ospf_hello = -1;
309 static gint ett_ospf_desc = -1;
310 static gint ett_ospf_lsr = -1;
311 static gint ett_ospf_lsa = -1;
312 static gint ett_ospf_lsa_router_link = -1;
313 static gint ett_ospf_lsa_upd = -1;
314 static gint ett_ospf_v2_options = -1;
315 static gint ett_ospf_v3_options = -1;
316 static gint ett_ospf_dbd = -1;
317 static gint ett_ospf_lls_data_block = -1;
318 static gint ett_ospf_lls_tlv = -1;
319 static gint ett_ospf_lls_ext_options = -1;
320 static gint ett_ospf_v3_lls_ext_options_tlv = -1;
321 static gint ett_ospf_v3_lls_ext_options = -1;
322 static gint ett_ospf_v3_lls_state_tlv = -1;
323 static gint ett_ospf_v3_lls_state_scs = -1;
324 static gint ett_ospf_v3_lls_state_options = -1;
325 static gint ett_ospf_v3_lls_drop_tlv = -1;
326 static gint ett_ospf_v3_lls_relay_tlv = -1;
327 static gint ett_ospf_v3_lls_relay_added = -1;
328 static gint ett_ospf_v3_lls_relay_options = -1;
329 static gint ett_ospf_v3_lls_willingness_tlv = -1;
330 static gint ett_ospf_v3_lls_willingness = -1;
331 static gint ett_ospf_v3_lls_rf_tlv = -1;
332 static gint ett_ospf_v3_lls_fsf_tlv = -1;
333 static gint ett_ospf_v2_router_lsa_flags = -1;
334 static gint ett_ospf_v3_router_lsa_flags = -1;
335 static gint ett_ospf_v3_as_external_flags = -1;
336 static gint ett_ospf_v3_prefix_options = -1;
338 /* Trees for opaque LSAs */
339 static gint ett_ospf_lsa_mpls = -1;
340 static gint ett_ospf_lsa_mpls_router = -1;
341 static gint ett_ospf_lsa_mpls_link = -1;
342 static gint ett_ospf_lsa_mpls_link_stlv = -1;
343 static gint ett_ospf_lsa_mpls_link_stlv_admingrp = -1;
344 static gint ett_ospf_lsa_oif_tna = -1;
345 static gint ett_ospf_lsa_oif_tna_stlv = -1;
346 static gint ett_ospf_lsa_grace_tlv = -1;
350 static const true_false_string tfs_v2_options_dc = {
351 "Demand Circuits are supported",
352 "Demand Circuits are NOT supported"
354 static const true_false_string tfs_v2_options_l = {
355 "The packet contains LLS data block",
356 "The packet does NOT contain LLS data block"
358 static const true_false_string tfs_v2_options_np = {
360 "NSSA is NOT supported"
362 static const true_false_string tfs_v2_options_mc = {
364 "NOT Multicast Capable"
366 static const true_false_string tfs_v2_options_e = {
367 "External Routing Capability",
368 "NO External Routing Capability"
370 static const true_false_string tfs_v2_options_mt = {
371 "Multi-Topology Routing",
372 "NO Multi-Topology Routing"
374 static const true_false_string tfs_v2_options_o = {
378 static const true_false_string tfs_v2_options_dn = {
382 static const true_false_string tfs_v3_options_v6 = {
386 static const true_false_string tfs_v3_options_e = {
390 static const true_false_string tfs_v3_options_mc = {
394 static const true_false_string tfs_v3_options_n = {
398 static const true_false_string tfs_v3_options_r = {
402 static const true_false_string tfs_v3_options_dc = {
406 static const true_false_string tfs_v3_options_af = {
410 static const true_false_string tfs_v3_options_l = {
414 static const true_false_string tfs_v3_options_i = {
418 static const true_false_string tfs_v3_options_f = {
422 static const true_false_string tfs_dbd_i = {
424 "Init bit is NOT set"
426 static const true_false_string tfs_dbd_m = {
428 "More bit is NOT set"
430 static const true_false_string tfs_dbd_ms = {
431 "Master/Slave bit is SET",
432 "Master/Slave bit is NOT set"
434 static const true_false_string tfs_dbd_r = {
435 "OOBResync bit is SET",
436 "OOBResync bit is NOT set"
438 static const true_false_string tfs_lls_ext_options_lr = {
439 "LSDB Resynchronization (LR-bit) is SET",
440 "LSDB Resynchronization (LR-bit) is NOT set"
442 static const true_false_string tfs_lls_ext_options_rs = {
443 "Restart Signal (RS-bit) is SET",
444 "Restart Signal (RS-bit) is NOT set"
446 static const true_false_string tfs_v3_lls_ext_options_lr = {
447 "LSDB Resynchronization (LR-bit) is SET",
448 "LSDB Resynchronization (LR-bit) is NOT set"
450 static const true_false_string tfs_v3_lls_ext_options_rs = {
451 "Restart Signal (RS-bit) is SET",
452 "Restart Signal (RS-bit) is NOT set"
454 static const true_false_string tfs_v3_lls_state_options_r = {
455 "Request (R-bit) is SET",
456 "Request (R-bit) is NOT set",
458 static const true_false_string tfs_v3_lls_state_options_a = {
459 "Answer (A-bit) is SET",
460 "Answer (A-bit) is NOT set",
462 static const true_false_string tfs_v3_lls_state_options_n = {
463 "Incomplete (N-bit) is SET",
464 "Incomplete (N-bit) is NOT set",
466 static const true_false_string tfs_v3_lls_relay_options_a = {
467 "Always (A-bit) is SET",
468 "Always (A-bit) is NOT set",
470 static const true_false_string tfs_v3_lls_relay_options_n = {
471 "Never (N-bit) is SET",
472 "Never (N-bit) is NOT set",
474 static const true_false_string tfs_v2_router_lsa_flags_b = {
475 "Area border router",
476 "NO Area border router"
478 static const true_false_string tfs_v2_router_lsa_flags_e = {
479 "AS boundary router",
480 "NO AS boundary router"
482 static const true_false_string tfs_v2_router_lsa_flags_v = {
483 "Virtual link endpoint",
484 "NO Virtual link endpoint"
486 static const true_false_string tfs_v2_router_lsa_flags_w = {
487 "Wild-card multicast receiver",
488 "NO Wild-card multicast receiver"
490 static const true_false_string tfs_v2_router_lsa_flags_n = {
494 static const true_false_string tfs_v3_router_lsa_flags_b = {
495 "Area border router",
496 "NO Area border router"
498 static const true_false_string tfs_v3_router_lsa_flags_e = {
499 "AS boundary router",
500 "NO AS boundary router"
502 static const true_false_string tfs_v3_router_lsa_flags_v = {
503 "Virtual link endpoint",
504 "NO Virtual link endpoint"
506 static const true_false_string tfs_v3_router_lsa_flags_w = {
507 "Wild-card multicast receiver",
508 "NO Wild-card multicast receiver"
510 static const true_false_string tfs_v3_as_external_flags_t = {
511 "External Route Tag is included",
512 "External Route Tag is NOT included"
514 static const true_false_string tfs_v3_as_external_flags_f = {
515 "Forwarding Address is included",
516 "Forwarding Address is NOT included"
518 static const true_false_string tfs_v3_as_external_flags_e = {
519 "Type 2 external metric",
520 "Type 1 external metric"
522 static const true_false_string tfs_v3_prefix_options_nu = {
523 "NoUnicast capability bit is SET",
524 "NoUnicast capability bit is NOT set"
526 static const true_false_string tfs_v3_prefix_options_la = {
527 "LocalAddress capability bit is SET",
528 "LocalAddress capability bit is NOT set"
530 static const true_false_string tfs_v3_prefix_options_mc = {
531 "Multicast capability bit is SET",
532 "Multicast capability bit is NOT set"
534 static const true_false_string tfs_v3_prefix_options_p = {
535 "Propagate bit is SET",
536 "Propagate bit is NOT set"
539 /*-----------------------------------------------------------------------
541 *-----------------------------------------------------------------------*/
543 /* The OSPF filtering keys */
556 OSPFF_LS_OPAQUE_TYPE,
558 OSPFF_LS_MPLS_TE_INSTANCE,
574 OSPFF_LS_MPLS_ROUTERID,
576 OSPFF_LS_MPLS_LINKTYPE,
577 OSPFF_LS_MPLS_LINKID,
578 OSPFF_LS_MPLS_LOCAL_ADDR,
579 OSPFF_LS_MPLS_REMOTE_ADDR,
580 OSPFF_LS_MPLS_LOCAL_IFID,
581 OSPFF_LS_MPLS_REMOTE_IFID,
582 OSPFF_LS_MPLS_LINKCOLOR,
583 OSPFF_LS_MPLS_BC_MODEL_ID,
584 OSPFF_LS_OIF_LOCAL_NODE_ID,
585 OSPFF_LS_OIF_REMOTE_NODE_ID,
612 OSPFF_LLS_EXT_OPTIONS_TLV,
613 OSPFF_LLS_EXT_OPTIONS,
614 OSPFF_LLS_EXT_OPTIONS_LR,
615 OSPFF_LLS_EXT_OPTIONS_RS,
616 OSPFF_V3_LLS_EXT_OPTIONS_TLV,
617 OSPFF_V3_LLS_EXT_OPTIONS,
618 OSPFF_V3_LLS_EXT_OPTIONS_LR,
619 OSPFF_V3_LLS_EXT_OPTIONS_RS,
620 OSPFF_V3_LLS_STATE_TLV,
621 OSPFF_V3_LLS_STATE_SCS,
622 OSPFF_V3_LLS_STATE_OPTIONS,
623 OSPFF_V3_LLS_STATE_OPTIONS_R,
624 OSPFF_V3_LLS_STATE_OPTIONS_A,
625 OSPFF_V3_LLS_STATE_OPTIONS_N,
626 OSPFF_V3_LLS_DROP_TLV,
627 OSPFF_V3_LLS_RELAY_TLV,
628 OSPFF_V3_LLS_RELAY_ADDED,
629 OSPFF_V3_LLS_RELAY_OPTIONS,
630 OSPFF_V3_LLS_RELAY_OPTIONS_A,
631 OSPFF_V3_LLS_RELAY_OPTIONS_N,
632 OSPFF_V3_LLS_WILLINGNESS_TLV,
633 OSPFF_V3_LLS_WILLINGNESS,
635 OSPFF_V3_LLS_FSF_TLV,
636 OSPFF_V2_ROUTER_LSA_FLAG,
637 OSPFF_V2_ROUTER_LSA_FLAG_B,
638 OSPFF_V2_ROUTER_LSA_FLAG_E,
639 OSPFF_V2_ROUTER_LSA_FLAG_V,
640 OSPFF_V2_ROUTER_LSA_FLAG_W,
641 OSPFF_V2_ROUTER_LSA_FLAG_N,
642 OSPFF_V3_ROUTER_LSA_FLAG,
643 OSPFF_V3_ROUTER_LSA_FLAG_B,
644 OSPFF_V3_ROUTER_LSA_FLAG_E,
645 OSPFF_V3_ROUTER_LSA_FLAG_V,
646 OSPFF_V3_ROUTER_LSA_FLAG_W,
647 OSPFF_V3_AS_EXTERNAL_FLAG,
648 OSPFF_V3_AS_EXTERNAL_FLAG_T,
649 OSPFF_V3_AS_EXTERNAL_FLAG_F,
650 OSPFF_V3_AS_EXTERNAL_FLAG_E,
651 OSPFF_V3_PREFIX_OPTION,
652 OSPFF_V3_PREFIX_OPTION_NU,
653 OSPFF_V3_PREFIX_OPTION_LA,
654 OSPFF_V3_PREFIX_OPTION_MC,
655 OSPFF_V3_PREFIX_OPTION_P,
658 OSPFF_V2_GRACE_PERIOD,
659 OSPFF_V2_GRACE_REASON,
665 static int hf_ospf_filter[OSPFF_MAX];
667 static gint ospf_msg_type_to_filter (guint8 msg_type)
669 if (msg_type >= OSPF_HELLO &&
670 msg_type <= OSPF_LS_ACK)
671 return msg_type + OSPFF_MSG_MIN;
675 static gint ospf_ls_type_to_filter (guint8 ls_type)
677 if (ls_type >= OSPF_LSTYPE_ROUTER &&
678 ls_type <= OSPF_LSTYPE_EXTATTR)
679 return OSPFF_LS_MIN + ls_type;
680 else if (ls_type >= OSPF_LSTYPE_OP_LINKLOCAL &&
681 ls_type <= OSPF_LSTYPE_OP_ASWIDE)
682 return OSPFF_LS_OPAQUE;
687 typedef struct _bitfield_info {
694 static int bf_dbd[] = {
700 static int bf_lls_ext_options[] = {
701 OSPFF_LLS_EXT_OPTIONS_RS,
702 OSPFF_LLS_EXT_OPTIONS_LR
704 static int bf_v3_lls_ext_options[] = {
705 OSPFF_V3_LLS_EXT_OPTIONS_LR,
706 OSPFF_V3_LLS_EXT_OPTIONS_RS
709 static int bf_v3_lls_state_options[] = {
710 OSPFF_V3_LLS_STATE_OPTIONS_R,
711 OSPFF_V3_LLS_STATE_OPTIONS_A,
712 OSPFF_V3_LLS_STATE_OPTIONS_N
714 static int bf_v3_lls_relay_options[] = {
715 OSPFF_V3_LLS_RELAY_OPTIONS_A,
716 OSPFF_V3_LLS_RELAY_OPTIONS_N
718 static int bf_v2_router_lsa_flags[] = {
719 OSPFF_V2_ROUTER_LSA_FLAG_V,
720 OSPFF_V2_ROUTER_LSA_FLAG_E,
721 OSPFF_V2_ROUTER_LSA_FLAG_B
723 static int bf_v2_router_lsa_mt_flags[] = {
724 OSPFF_V2_ROUTER_LSA_FLAG_N,
725 OSPFF_V2_ROUTER_LSA_FLAG_W,
726 OSPFF_V2_ROUTER_LSA_FLAG_V,
727 OSPFF_V2_ROUTER_LSA_FLAG_E,
728 OSPFF_V2_ROUTER_LSA_FLAG_B
730 static int bf_v3_router_lsa_flags[] = {
731 OSPFF_V3_ROUTER_LSA_FLAG_W,
732 OSPFF_V3_ROUTER_LSA_FLAG_V,
733 OSPFF_V3_ROUTER_LSA_FLAG_E,
734 OSPFF_V3_ROUTER_LSA_FLAG_B
736 static int bf_v3_as_external_flags[] = {
737 OSPFF_V3_AS_EXTERNAL_FLAG_E,
738 OSPFF_V3_AS_EXTERNAL_FLAG_F,
739 OSPFF_V3_AS_EXTERNAL_FLAG_T
741 static int bf_v2_options[] = {
751 static int bf_v3_options[] = {
763 static int bf_v3_prefix_options[] = {
764 OSPFF_V3_PREFIX_OPTION_P,
765 OSPFF_V3_PREFIX_OPTION_MC,
766 OSPFF_V3_PREFIX_OPTION_LA,
767 OSPFF_V3_PREFIX_OPTION_NU
770 static bitfield_info bfinfo_dbd = {
771 OSPFF_DBD, &ett_ospf_dbd,
772 bf_dbd, array_length(bf_dbd)
774 static bitfield_info bfinfo_lls_ext_options = {
775 OSPFF_LLS_EXT_OPTIONS, &ett_ospf_lls_ext_options,
776 bf_lls_ext_options, array_length(bf_lls_ext_options)
778 static bitfield_info bfinfo_v3_lls_ext_options = {
779 OSPFF_V3_LLS_EXT_OPTIONS, &ett_ospf_v3_lls_ext_options,
780 bf_v3_lls_ext_options, array_length(bf_v3_lls_ext_options)
782 static bitfield_info bfinfo_v3_lls_state_options = {
783 OSPFF_V3_LLS_STATE_OPTIONS, &ett_ospf_v3_lls_state_options,
784 bf_v3_lls_state_options, array_length(bf_v3_lls_state_options)
786 static bitfield_info bfinfo_v3_lls_relay_options = {
787 OSPFF_V3_LLS_RELAY_OPTIONS, &ett_ospf_v3_lls_relay_options,
788 bf_v3_lls_relay_options, array_length(bf_v3_lls_relay_options)
790 static bitfield_info bfinfo_v2_router_lsa_flags = {
791 OSPFF_V2_ROUTER_LSA_FLAG, &ett_ospf_v2_router_lsa_flags,
792 bf_v2_router_lsa_flags, array_length(bf_v2_router_lsa_flags)
794 static bitfield_info bfinfo_v2_router_lsa_mt_flags = {
795 OSPFF_V2_ROUTER_LSA_FLAG, &ett_ospf_v2_router_lsa_flags,
796 bf_v2_router_lsa_mt_flags, array_length(bf_v2_router_lsa_mt_flags)
798 static bitfield_info bfinfo_v3_router_lsa_flags = {
799 OSPFF_V3_ROUTER_LSA_FLAG, &ett_ospf_v3_router_lsa_flags,
800 bf_v3_router_lsa_flags, array_length(bf_v3_router_lsa_flags)
802 static bitfield_info bfinfo_v3_as_external_flags = {
803 OSPFF_V3_AS_EXTERNAL_FLAG, &ett_ospf_v3_as_external_flags,
804 bf_v3_as_external_flags, array_length(bf_v3_as_external_flags)
806 static bitfield_info bfinfo_v2_options = {
807 OSPFF_V2_OPTIONS, &ett_ospf_v2_options,
808 bf_v2_options, array_length(bf_v2_options)
810 static bitfield_info bfinfo_v3_options = {
811 OSPFF_V3_OPTIONS, &ett_ospf_v3_options,
812 bf_v3_options, array_length(bf_v3_options)
814 static bitfield_info bfinfo_v3_prefix_options = {
815 OSPFF_V3_PREFIX_OPTION, &ett_ospf_v3_prefix_options,
816 bf_v3_prefix_options, array_length(bf_v3_prefix_options)
819 #define MAX_OPTIONS_LEN 128
821 dissect_ospf_bitfield (proto_tree *parent_tree, tvbuff_t *tvb, int offset,
822 bitfield_info *bfinfo)
824 proto_item *item = NULL;
825 proto_tree *tree = NULL;
830 header_field_info *hfinfo;
832 gint returned_length;
834 hfindex = hf_ospf_filter[bfinfo->hfindex];
835 hfinfo = proto_registrar_get_nth(hfindex);
836 switch (hfinfo->type) {
838 flags = tvb_get_guint8(tvb, offset);
842 flags = tvb_get_ntohs(tvb, offset);
846 flags = tvb_get_ntoh24(tvb, offset);
850 flags = tvb_get_ntohl(tvb, offset);
858 item = proto_tree_add_uint(parent_tree, hfindex, tvb, offset, length, flags);
859 tree = proto_item_add_subtree(item, *bfinfo->ett);
861 str = ep_alloc(MAX_OPTIONS_LEN);
863 for (i = 0, pos = 0; i < bfinfo->num; i++) {
864 idx = hf_ospf_filter[bfinfo->idx[i]];
865 hfinfo = proto_registrar_get_nth(idx);
866 if (flags & hfinfo->bitmask) {
867 returned_length = g_snprintf(&str[pos], MAX_OPTIONS_LEN-pos, "%s%s",
870 pos += MIN(returned_length, MAX_OPTIONS_LEN-pos);
872 proto_tree_add_boolean(tree, idx, tvb, offset, length, flags);
875 proto_item_append_text(item, " (%s)", str);
880 static dissector_handle_t data_handle;
882 static void dissect_ospf_hello(tvbuff_t*, int, proto_tree*, guint8, guint16);
883 static void dissect_ospf_db_desc(tvbuff_t*, int, proto_tree*, guint8, guint16, guint8);
884 static void dissect_ospf_ls_req(tvbuff_t*, int, proto_tree*, guint8, guint16);
885 static void dissect_ospf_ls_upd(tvbuff_t*, int, proto_tree*, guint8, guint16, guint8);
886 static void dissect_ospf_ls_ack(tvbuff_t*, int, proto_tree*, guint8, guint16, guint8);
887 static void dissect_ospf_lls_data_block(tvbuff_t*, int, proto_tree*, guint8);
889 /* dissect_ospf_v[23]lsa returns the offset of the next LSA
890 * if disassemble_body is set to FALSE (e.g. in LSA ACK
891 * packets), the offset is set to the offset of the next
894 static int dissect_ospf_v2_lsa(tvbuff_t*, int, proto_tree*, gboolean disassemble_body);
895 static int dissect_ospf_v3_lsa(tvbuff_t*, int, proto_tree*, gboolean disassemble_body,
898 static void dissect_ospf_v3_address_prefix(tvbuff_t *, int, int, proto_tree *, guint8);
901 ospf_has_lls_block(tvbuff_t *tvb, int offset, guint8 packet_type, guint8 version)
906 /* LLS block can be found only in HELLO and DBDESC packets */
907 switch (packet_type) {
911 flags = tvb_get_guint8 (tvb, offset + 6);
912 return flags & OSPF_V2_OPTIONS_L;
914 v3flags = tvb_get_ntohl(tvb, offset + 5);
915 v3flags = v3flags >> 8;
916 return v3flags & OSPF_V3_OPTIONS_L;
921 flags = tvb_get_guint8 (tvb, offset + 2);
922 return flags & OSPF_V2_OPTIONS_L;
924 v3flags = tvb_get_ntohl(tvb, offset + 1);
925 v3flags = v3flags >> 8;
926 return v3flags & OSPF_V3_OPTIONS_L;
934 dissect_ospf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
936 proto_tree *ospf_tree = NULL;
937 proto_item *ti, *hidden_item;
938 proto_tree *ospf_header_tree;
945 guint16 cksum, computed_cksum;
946 guint length, reported_length;
950 unsigned int ospf_header_length;
954 guint8 address_family = OSPF_AF_6;
956 col_set_str(pinfo->cinfo, COL_PROTOCOL, "OSPF");
957 col_clear(pinfo->cinfo, COL_INFO);
959 version = tvb_get_guint8(tvb, 0);
962 ospf_header_length = OSPF_VERSION_2_HEADER_LENGTH;
965 ospf_header_length = OSPF_VERSION_3_HEADER_LENGTH;
968 ospf_header_length = 14;
972 packet_type = tvb_get_guint8(tvb, 1);
973 col_add_str(pinfo->cinfo, COL_INFO,
974 val_to_str(packet_type, pt_vals, "Unknown (%u)"));
977 ospflen = tvb_get_ntohs(tvb, 2);
979 ti = proto_tree_add_item(tree, proto_ospf, tvb, 0, -1, FALSE);
980 ospf_tree = proto_item_add_subtree(ti, ett_ospf);
982 ti = proto_tree_add_text(ospf_tree, tvb, 0, ospf_header_length,
984 ospf_header_tree = proto_item_add_subtree(ti, ett_ospf_hdr);
986 proto_tree_add_text(ospf_header_tree, tvb, 0, 1, "OSPF Version: %u",
988 proto_tree_add_item(ospf_header_tree, hf_ospf_filter[OSPFF_MSG_TYPE],
990 if (ospf_msg_type_to_filter(packet_type) != -1) {
991 hidden_item = proto_tree_add_item(ospf_header_tree,
992 hf_ospf_filter[ospf_msg_type_to_filter(packet_type)],
994 PROTO_ITEM_SET_HIDDEN(hidden_item);
996 proto_tree_add_text(ospf_header_tree, tvb, 2, 2, "Packet Length: %u",
998 proto_tree_add_item(ospf_header_tree, hf_ospf_filter[OSPFF_SRC_ROUTER],
1000 areaid=tvb_get_ntohl(tvb,8);
1001 proto_tree_add_text(ospf_header_tree, tvb, 8, 4, "Area ID: %s%s",
1002 ip_to_str(tvb_get_ptr(tvb, 8, 4)), areaid == 0 ? " (Backbone)" : "");
1005 * Quit at this point if it's an unknown OSPF version.
1009 case OSPF_VERSION_2:
1010 case OSPF_VERSION_3:
1014 cksum = tvb_get_ntohs(tvb, 12);
1016 /* No checksum supplied in the packet. */
1017 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
1018 "Packet Checksum: 0x%04x (none)", cksum);
1020 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
1021 "Packet Checksum: 0x%04x", cksum);
1023 proto_tree_add_text(ospf_tree, tvb, 14, -1,
1024 "Unknown OSPF version %u", version);
1028 cksum = tvb_get_ntohs(tvb, 12);
1029 length = tvb_length(tvb);
1030 /* XXX - include only the length from the OSPF header? */
1031 reported_length = tvb_reported_length(tvb);
1033 /* No checksum supplied in the packet. */
1034 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
1035 "Packet Checksum: 0x%04x (none)", cksum);
1036 } else if (!pinfo->fragmented && length >= reported_length
1037 && length >= ospf_header_length) {
1038 /* The packet isn't part of a fragmented datagram and isn't
1039 truncated, so we can checksum it. */
1043 case OSPF_VERSION_2:
1044 /* Header, not including the authentication data (the OSPFv2
1045 checksum excludes the 64-bit authentication field). */
1046 cksum_vec[0].ptr = tvb_get_ptr(tvb, 0, 16);
1047 cksum_vec[0].len = 16;
1048 if (length > ospf_header_length) {
1049 /* Rest of the packet, again not including the
1050 authentication data. */
1051 reported_length -= ospf_header_length;
1052 cksum_vec[1].ptr = tvb_get_ptr(tvb, ospf_header_length, reported_length);
1053 cksum_vec[1].len = reported_length;
1056 /* There's nothing but a header. */
1061 case OSPF_VERSION_3:
1062 /* IPv6-style checksum, covering the entire OSPF packet
1063 and a prepended IPv6 pseudo-header. */
1065 /* Set up the fields of the pseudo-header. */
1066 cksum_vec[0].ptr = pinfo->src.data;
1067 cksum_vec[0].len = pinfo->src.len;
1068 cksum_vec[1].ptr = pinfo->dst.data;
1069 cksum_vec[1].len = pinfo->dst.len;
1070 cksum_vec[2].ptr = (const guint8 *)&phdr;
1071 phdr[0] = g_htonl(ospflen);
1072 phdr[1] = g_htonl(IP_PROTO_OSPF);
1073 cksum_vec[2].len = 8;
1075 cksum_vec[3].ptr = tvb_get_ptr(tvb, 0, reported_length);
1076 cksum_vec[3].len = reported_length;
1081 DISSECTOR_ASSERT_NOT_REACHED();
1085 computed_cksum = in_cksum(cksum_vec, cksum_vec_len);
1086 if (computed_cksum == 0) {
1087 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
1088 "Packet Checksum: 0x%04x [correct]", cksum);
1090 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
1091 "Packet Checksum: 0x%04x [incorrect, should be 0x%04x]",
1092 cksum, in_cksum_shouldbe(cksum, computed_cksum));
1095 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
1096 "Packet Checksum: 0x%04x", cksum);
1102 case OSPF_VERSION_2:
1103 /* Authentication is only valid for OSPFv2 */
1104 auth_type = tvb_get_ntohs(tvb, 14);
1105 proto_tree_add_text(ospf_header_tree, tvb, 14, 2, "Auth Type: %s",
1106 val_to_str(auth_type, auth_vals, "Unknown (%u)"));
1107 switch (auth_type) {
1109 case OSPF_AUTH_NONE:
1110 proto_tree_add_text(ospf_header_tree, tvb, 16, 8, "Auth Data (none)");
1113 case OSPF_AUTH_SIMPLE:
1114 tvb_get_nstringz0(tvb, 16, 8+1, auth_data);
1115 proto_tree_add_text(ospf_header_tree, tvb, 16, 8, "Auth Data: %s", auth_data);
1118 case OSPF_AUTH_CRYPT:
1119 proto_tree_add_text(ospf_header_tree, tvb, 18, 1, "Auth Key ID: %u",
1120 tvb_get_guint8(tvb, 18));
1121 crypto_len = tvb_get_guint8(tvb, 19);
1122 proto_tree_add_text(ospf_header_tree, tvb, 19, 1, "Auth Data Length: %u",
1124 proto_tree_add_text(ospf_header_tree, tvb, 20, 4, "Auth Crypto Sequence Number: 0x%x",
1125 tvb_get_ntohl(tvb, 20));
1127 /* Show the message digest that was appended to the end of the
1128 OSPF message - but only if it's present (we don't want
1129 to get an exception before we've tried dissecting OSPF
1131 if (tvb_bytes_exist(tvb, ospflen, crypto_len)) {
1132 proto_tree_add_text(ospf_header_tree, tvb, ospflen, crypto_len,
1134 tvb_bytes_to_str(tvb, ospflen, crypto_len));
1135 proto_tree_set_appendix(ospf_header_tree, tvb, ospflen, crypto_len);
1140 proto_tree_add_text(ospf_header_tree, tvb, 16, 8, "Auth Data (unknown)");
1145 case OSPF_VERSION_3:
1146 /* Instance ID and "reserved" is OSPFv3-only */
1147 instance_ID = tvb_get_guint8(tvb, 14);
1148 ti = proto_tree_add_text(ospf_header_tree, tvb, 14, 1, "Instance ID: %u",
1151 if (instance_ID < 32) {
1152 proto_item_append_text(ti, " (IPv6 unicast AF)");
1153 address_family = OSPF_AF_6;
1154 } else if (instance_ID < 64) {
1155 proto_item_append_text(ti, " (IPv6 multicast AF)");
1156 address_family = OSPF_AF_6;
1157 } else if (instance_ID < 96) {
1158 proto_item_append_text(ti, " (IPv4 unicast AF)");
1159 address_family = OSPF_AF_4;
1160 } else if (instance_ID < 128) {
1161 proto_item_append_text(ti, " (IPv4 multicast AF)");
1162 address_family = OSPF_AF_4;
1164 proto_item_append_text(ti, " (Reserved)");
1165 address_family = OSPF_AF_6;
1168 reserved = tvb_get_guint8(tvb, 15);
1169 proto_tree_add_text(ospf_header_tree, tvb, 15, 1, (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),
1174 switch (packet_type){
1177 dissect_ospf_hello(tvb, ospf_header_length, ospf_tree, version,
1178 (guint16)(ospflen - ospf_header_length));
1182 dissect_ospf_db_desc(tvb, (int)ospf_header_length, ospf_tree, version,
1183 (guint16)(ospflen - ospf_header_length),
1188 dissect_ospf_ls_req(tvb, (int)ospf_header_length, ospf_tree, version,
1189 (guint16)(ospflen - ospf_header_length));
1193 dissect_ospf_ls_upd(tvb, (int)ospf_header_length, ospf_tree, version,
1194 (guint16)(ospflen - ospf_header_length),
1199 dissect_ospf_ls_ack(tvb, (int)ospf_header_length, ospf_tree, version,
1200 (guint16)(ospflen - ospf_header_length),
1205 call_dissector(data_handle,
1206 tvb_new_subset_remaining(tvb, ospf_header_length), pinfo, tree);
1210 /* take care of the LLS data block */
1211 if (ospf_has_lls_block(tvb, ospf_header_length, packet_type, version)) {
1212 dissect_ospf_lls_data_block(tvb, ospflen + crypto_len, ospf_tree,
1219 dissect_ospfv2_lls_tlv(tvbuff_t *tvb, int offset, proto_tree *tree)
1222 proto_tree *ospf_lls_tlv_tree;
1226 type = tvb_get_ntohs(tvb, offset);
1227 length = tvb_get_ntohs(tvb, offset + 2);
1229 ti = proto_tree_add_text(tree, tvb, offset, length + 4, "%s",
1230 val_to_str(type, lls_tlv_type_vals, "Unknown TLV"));
1231 ospf_lls_tlv_tree = proto_item_add_subtree(ti, ett_ospf_lls_tlv);
1233 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset, 2,
1235 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset + 2, 2,
1236 "Length: %d", length);
1240 dissect_ospf_bitfield(ospf_lls_tlv_tree, tvb, offset + 4, &bfinfo_lls_ext_options);
1243 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset + 4, 4,
1244 "Sequence number 0x%08x",
1245 tvb_get_ntohl(tvb, offset + 4));
1246 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset + 8, length - 4,
1248 tvb_bytes_to_str(tvb, offset + 8, length - 4));
1252 return offset + length + 4;
1256 dissect_ospfv3_lls_tlv(tvbuff_t *tvb, int offset, proto_tree *tree)
1259 proto_tree *ospf_lls_tlv_tree;
1262 guint8 relays_added;
1265 type = tvb_get_ntohs(tvb, offset);
1266 length = tvb_get_ntohs(tvb, offset + 2);
1269 case LLS_V3_EXT_OPT:
1270 ti = proto_tree_add_item(tree, hf_ospf_filter[OSPFF_V3_LLS_EXT_OPTIONS_TLV], tvb,
1271 offset, length + 4, FALSE);
1273 case LLS_V3_STATE_CHECK:
1274 ti = proto_tree_add_item(tree, hf_ospf_filter[OSPFF_V3_LLS_STATE_TLV], tvb,
1275 offset, length + 4, FALSE);
1277 case LLS_V3_NBR_DROP:
1278 ti = proto_tree_add_item(tree, hf_ospf_filter[OSPFF_V3_LLS_DROP_TLV], tvb,
1279 offset, length + 4, FALSE);
1282 ti = proto_tree_add_item(tree, hf_ospf_filter[OSPFF_V3_LLS_RELAY_TLV], tvb,
1283 offset, length + 4, FALSE);
1285 case LLS_V3_WILLING:
1286 ti = proto_tree_add_item(tree, hf_ospf_filter[OSPFF_V3_LLS_WILLINGNESS_TLV], tvb,
1287 offset, length + 4, FALSE);
1289 case LLS_V3_RQST_FROM:
1290 ti = proto_tree_add_item(tree, hf_ospf_filter[OSPFF_V3_LLS_RF_TLV], tvb,
1291 offset, length + 4, FALSE);
1293 case LLS_V3_FULL_STATE:
1294 ti = proto_tree_add_item(tree, hf_ospf_filter[OSPFF_V3_LLS_FSF_TLV], tvb,
1295 offset, length + 4, FALSE);
1298 ti = proto_tree_add_text(tree, tvb, offset, length + 4, "%s",
1299 val_to_str(type, lls_v3_tlv_type_vals, "Unknown TLV"));
1302 ospf_lls_tlv_tree = proto_item_add_subtree(ti, ett_ospf_lls_tlv);
1303 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset, 2,
1305 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset + 2, 2,
1306 "Length: %d", length);
1308 orig_offset = offset;
1311 case LLS_V3_EXT_OPT:
1312 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset + 4, 4,
1313 "Extended Options: 0x%08x",
1314 tvb_get_ntohl(tvb, offset + 4));
1316 dissect_ospf_bitfield(ospf_lls_tlv_tree, tvb, offset + 4, &bfinfo_v3_lls_ext_options);
1318 case LLS_V3_STATE_CHECK:
1319 proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_filter[OSPFF_V3_LLS_STATE_SCS],
1320 tvb, offset+4, 2, FALSE);
1322 dissect_ospf_bitfield(ospf_lls_tlv_tree, tvb, offset + 6,
1323 &bfinfo_v3_lls_state_options);
1325 case LLS_V3_NBR_DROP:
1327 while (orig_offset + length >= offset) {
1328 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset, 4,
1329 "Dropped Neighbor: %s",
1330 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1333 offset = orig_offset;
1336 relays_added = tvb_get_guint8(tvb, offset+4);
1337 proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_filter[OSPFF_V3_LLS_RELAY_ADDED],
1338 tvb, offset+4, 1, FALSE);
1339 dissect_ospf_bitfield(ospf_lls_tlv_tree, tvb, offset + 5,
1340 &bfinfo_v3_lls_relay_options);
1342 while (orig_offset + length >= offset) {
1343 ti = proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset, 4,
1345 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1346 if (relays_added > 0) {
1347 proto_item_append_text(ti, " Added");
1349 proto_item_append_text(ti, " Deleted");
1356 case LLS_V3_WILLING:
1357 proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_filter[OSPFF_V3_LLS_WILLINGNESS],
1358 tvb, offset+4, 1, FALSE);
1361 case LLS_V3_RQST_FROM:
1363 while (orig_offset + length >= offset) {
1364 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset, 4,
1366 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1369 offset = orig_offset;
1371 case LLS_V3_FULL_STATE:
1373 while (orig_offset + length >= offset) {
1374 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset, 4,
1375 "Full State For: %s",
1376 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1379 offset = orig_offset;
1383 return offset + length + 4;
1388 dissect_ospf_lls_data_block(tvbuff_t *tvb, int offset, proto_tree *tree,
1391 proto_tree *ospf_lls_data_block_tree;
1393 guint16 ospf_lls_len;
1394 int orig_offset = offset;
1396 ospf_lls_len = tvb_get_ntohs(tvb, offset + 2);
1397 ti = proto_tree_add_text(tree, tvb, offset, -1, "OSPF LLS Data Block");
1398 ospf_lls_data_block_tree = proto_item_add_subtree(ti,
1399 ett_ospf_lls_data_block);
1401 /* TODO: verify checksum */
1402 proto_tree_add_text(ospf_lls_data_block_tree, tvb, offset, 2,
1403 "Checksum: 0x%04x", tvb_get_ntohs(tvb, offset));
1404 proto_tree_add_text(ospf_lls_data_block_tree, tvb, offset + 2, 2,
1405 "LLS Data Length: %d bytes", ospf_lls_len * 4);
1408 while (orig_offset + ospf_lls_len * 4 > offset) {
1410 case OSPF_VERSION_2:
1411 offset = dissect_ospfv2_lls_tlv (tvb, offset, ospf_lls_data_block_tree);
1413 case OSPF_VERSION_3:
1414 offset = dissect_ospfv3_lls_tlv (tvb, offset, ospf_lls_data_block_tree);
1421 dissect_ospf_hello(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version,
1424 proto_tree *ospf_hello_tree;
1426 int orig_offset = offset;
1428 ti = proto_tree_add_text(tree, tvb, offset, length, "OSPF Hello Packet");
1429 ospf_hello_tree = proto_item_add_subtree(ti, ett_ospf_hello);
1432 case OSPF_VERSION_2:
1433 proto_tree_add_text(ospf_hello_tree, tvb, offset, 4, "Network Mask: %s",
1434 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1435 proto_tree_add_text(ospf_hello_tree, tvb, offset + 4, 2,
1436 "Hello Interval: %u seconds",
1437 tvb_get_ntohs(tvb, offset + 4));
1439 dissect_ospf_bitfield(ospf_hello_tree, tvb, offset + 6, &bfinfo_v2_options);
1440 proto_tree_add_text(ospf_hello_tree, tvb, offset + 7, 1, "Router Priority: %u",
1441 tvb_get_guint8(tvb, offset + 7));
1442 proto_tree_add_text(ospf_hello_tree, tvb, offset + 8, 4, "Router Dead Interval: %u seconds",
1443 tvb_get_ntohl(tvb, offset + 8));
1444 proto_tree_add_text(ospf_hello_tree, tvb, offset + 12, 4, "Designated Router: %s",
1445 ip_to_str(tvb_get_ptr(tvb, offset + 12, 4)));
1446 proto_tree_add_text(ospf_hello_tree, tvb, offset + 16, 4, "Backup Designated Router: %s",
1447 ip_to_str(tvb_get_ptr(tvb, offset + 16, 4)));
1450 while (orig_offset + length > offset) {
1451 proto_tree_add_text(ospf_hello_tree, tvb, offset, 4,
1452 "Active Neighbor: %s",
1453 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1457 case OSPF_VERSION_3:
1458 proto_tree_add_text(ospf_hello_tree, tvb, offset + 0, 4, "Interface ID: %u",
1459 tvb_get_ntohl(tvb, offset + 0));
1460 proto_tree_add_text(ospf_hello_tree, tvb, offset + 4, 1, "Router Priority: %u",
1461 tvb_get_guint8(tvb, offset + 4));
1462 dissect_ospf_bitfield(ospf_hello_tree, tvb, offset + 5, &bfinfo_v3_options);
1463 proto_tree_add_text(ospf_hello_tree, tvb, offset + 8, 2,
1464 "Hello Interval: %u seconds",
1465 tvb_get_ntohs(tvb, offset + 8));
1466 proto_tree_add_text(ospf_hello_tree, tvb, offset + 10, 2, "Router Dead Interval: %u seconds",
1467 tvb_get_ntohs(tvb, offset + 10));
1468 proto_tree_add_text(ospf_hello_tree, tvb, offset + 12, 4, "Designated Router: %s",
1469 ip_to_str(tvb_get_ptr(tvb, offset + 12, 4)));
1470 proto_tree_add_text(ospf_hello_tree, tvb, offset + 16, 4, "Backup Designated Router: %s",
1471 ip_to_str(tvb_get_ptr(tvb, offset + 16, 4)));
1473 while (orig_offset + length > offset) {
1474 proto_tree_add_text(ospf_hello_tree, tvb, offset, 4,
1475 "Active Neighbor: %s",
1476 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1485 dissect_ospf_db_desc(tvbuff_t *tvb, int offset, proto_tree *tree,
1486 guint8 version, guint16 length, guint8 address_family)
1488 proto_tree *ospf_db_desc_tree=NULL;
1491 int orig_offset = offset;
1494 ti = proto_tree_add_text(tree, tvb, offset, length, "OSPF DB Description");
1495 ospf_db_desc_tree = proto_item_add_subtree(ti, ett_ospf_desc);
1499 case OSPF_VERSION_2:
1500 proto_tree_add_text(ospf_db_desc_tree, tvb, offset, 2, "Interface MTU: %u",
1501 tvb_get_ntohs(tvb, offset));
1503 dissect_ospf_bitfield(ospf_db_desc_tree, tvb, offset + 2, &bfinfo_v2_options);
1504 dissect_ospf_bitfield(ospf_db_desc_tree, tvb, offset + 3, &bfinfo_dbd);
1506 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 4, 4, "DD Sequence: %u",
1507 tvb_get_ntohl(tvb, offset + 4));
1512 case OSPF_VERSION_3:
1514 reserved = tvb_get_guint8(tvb, offset);
1515 proto_tree_add_text(ospf_db_desc_tree, tvb, offset, 1, (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),
1518 dissect_ospf_bitfield(ospf_db_desc_tree, tvb, offset + 1, &bfinfo_v3_options);
1520 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 4, 2, "Interface MTU: %u",
1521 tvb_get_ntohs(tvb, offset+4));
1523 reserved = tvb_get_guint8(tvb, offset + 6);
1524 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 6, 1, (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),
1527 dissect_ospf_bitfield(ospf_db_desc_tree, tvb, offset + 7, &bfinfo_dbd);
1529 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 8, 4, "DD Sequence: %u",
1530 tvb_get_ntohl(tvb, offset + 8));
1537 /* LS Headers will be processed here */
1538 /* skip to the end of DB-Desc header */
1539 while (orig_offset + length > offset) {
1540 if ( version == OSPF_VERSION_2)
1541 offset = dissect_ospf_v2_lsa(tvb, offset, tree, FALSE);
1543 if ( version == OSPF_VERSION_3)
1544 offset = dissect_ospf_v3_lsa(tvb, offset, tree, FALSE, address_family);
1550 dissect_ospf_ls_req(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version,
1553 proto_tree *ospf_lsr_tree;
1557 int orig_offset = offset;
1559 /* zero or more LS requests may be within a LS Request */
1560 /* we place every request for a LSA in a single subtree */
1561 while (orig_offset + length > offset) {
1562 ti = proto_tree_add_text(tree, tvb, offset, OSPF_LS_REQ_LENGTH,
1563 "Link State Request");
1564 ospf_lsr_tree = proto_item_add_subtree(ti, ett_ospf_lsr);
1566 switch ( version ) {
1568 case OSPF_VERSION_2:
1569 proto_tree_add_item(ospf_lsr_tree, hf_ospf_filter[OSPFF_LS_TYPE],
1570 tvb, offset, 4, FALSE);
1572 case OSPF_VERSION_3:
1573 reserved = tvb_get_ntohs(tvb, offset);
1574 proto_tree_add_text(ospf_lsr_tree, tvb, offset, 2,
1575 (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"), reserved);
1576 ls_type = tvb_get_ntohs(tvb, offset+2);
1577 proto_tree_add_text(ospf_lsr_tree, tvb, offset+2, 2, "LS Type: %s (0x%04x)",
1578 val_to_str(ls_type, v3_ls_type_vals, "Unknown"),
1584 proto_tree_add_text(ospf_lsr_tree, tvb, offset + 4, 4, "Link State ID: %s",
1585 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
1586 proto_tree_add_item(ospf_lsr_tree, hf_ospf_filter[OSPFF_ADV_ROUTER],
1587 tvb, offset + 8, 4, FALSE);
1594 dissect_ospf_ls_upd(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version,
1595 guint16 length, guint8 address_family)
1597 proto_tree *ospf_lsa_upd_tree=NULL;
1600 guint32 lsa_counter;
1602 ti = proto_tree_add_text(tree, tvb, offset, length, "LS Update Packet");
1603 ospf_lsa_upd_tree = proto_item_add_subtree(ti, ett_ospf_lsa_upd);
1605 lsa_nr = tvb_get_ntohl(tvb, offset);
1606 proto_tree_add_text(ospf_lsa_upd_tree, tvb, offset, 4, "Number of LSAs: %u",
1608 /* skip to the beginning of the first LSA */
1609 offset += 4; /* the LS Upd Packet contains only a 32 bit #LSAs field */
1612 while (lsa_counter < lsa_nr) {
1613 if ( version == OSPF_VERSION_2)
1614 offset = dissect_ospf_v2_lsa(tvb, offset, ospf_lsa_upd_tree, TRUE);
1615 else if ( version == OSPF_VERSION_3)
1616 offset = dissect_ospf_v3_lsa(tvb, offset, ospf_lsa_upd_tree, TRUE,
1619 /* We could potentially waste CPU cycles looping */
1620 lsa_counter = lsa_nr;
1627 dissect_ospf_ls_ack(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version,
1628 guint16 length, guint8 address_family)
1630 int orig_offset = offset;
1631 /* the body of a LS Ack packet simply contains zero or more LSA Headers */
1632 while (orig_offset + length > offset) {
1633 if ( version == OSPF_VERSION_2)
1634 offset = dissect_ospf_v2_lsa(tvb, offset, tree, FALSE);
1636 if ( version == OSPF_VERSION_3)
1637 offset = dissect_ospf_v3_lsa(tvb, offset, tree, FALSE,
1643 * Returns if an LSA is opaque, i.e. requires special treatment
1646 is_opaque(int lsa_type)
1648 return (lsa_type >= OSPF_LSTYPE_OP_LINKLOCAL &&
1649 lsa_type <= OSPF_LSTYPE_OP_ASWIDE);
1652 /* MPLS/TE TLV types */
1653 #define MPLS_TLV_ROUTER 1
1654 #define MPLS_TLV_LINK 2
1655 #define OIF_TLV_TNA 32768
1657 /* MPLS/TE Link STLV types */
1659 MPLS_LINK_TYPE = 1, /* RFC 3630, OSPF-TE */
1662 MPLS_LINK_REMOTE_IF,
1663 MPLS_LINK_TE_METRIC,
1665 MPLS_LINK_MAX_RES_BW,
1668 MPLS_LINK_LOCAL_REMOTE_ID = 11, /* RFC 4203, GMPLS */
1669 MPLS_LINK_PROTECTION = 14,
1670 MPLS_LINK_IF_SWITCHING_DESC,
1671 MPLS_LINK_SHARED_RISK_GROUP,
1672 MPLS_LINK_BANDWIDTH_CONSTRAINT = 17 /* RFC 4124, OSPF-DSTE */
1678 OIF_LOCAL_NODE_ID = 32773,
1680 OIF_SONET_SDH_SWITCHING_CAPABILITY,
1681 OIF_TNA_IPv4_ADDRESS,
1683 OIF_TNA_IPv6_ADDRESS,
1684 OIF_TNA_NSAP_ADDRESS
1687 static const value_string mpls_link_stlv_str[] = {
1688 {MPLS_LINK_TYPE, "Link Type"},
1689 {MPLS_LINK_ID, "Link ID"},
1690 {MPLS_LINK_LOCAL_IF, "Local Interface IP Address"},
1691 {MPLS_LINK_REMOTE_IF, "Remote Interface IP Address"},
1692 {MPLS_LINK_TE_METRIC, "Traffic Engineering Metric"},
1693 {MPLS_LINK_MAX_BW, "Maximum Bandwidth"},
1694 {MPLS_LINK_MAX_RES_BW, "Maximum Reservable Bandwidth"},
1695 {MPLS_LINK_UNRES_BW, "Unreserved Bandwidth"},
1696 {MPLS_LINK_COLOR, "Resource Class/Color"},
1697 {MPLS_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier"},
1698 {MPLS_LINK_PROTECTION, "Link Protection Type"},
1699 {MPLS_LINK_IF_SWITCHING_DESC, "Interface Switching Capability Descriptor"},
1700 {MPLS_LINK_SHARED_RISK_GROUP, "Shared Risk Link Group"},
1701 {MPLS_LINK_BANDWIDTH_CONSTRAINT, "Bandwidth Constraints"},
1702 {OIF_LOCAL_NODE_ID, "Local Node ID"},
1703 {OIF_REMOTE_NODE_ID, "Remote Node ID"},
1704 {OIF_SONET_SDH_SWITCHING_CAPABILITY, "Sonet/SDH Interface Switching Capability"},
1708 static const value_string oif_stlv_str[] = {
1709 {OIF_TNA_IPv4_ADDRESS, "TNA address"},
1710 {OIF_NODE_ID, "Node ID"},
1711 {OIF_TNA_IPv6_ADDRESS, "TNA address"},
1712 {OIF_TNA_NSAP_ADDRESS, "TNA address"},
1717 * Dissect MPLS/TE opaque LSA
1720 dissect_ospf_lsa_mpls(tvbuff_t *tvb, int offset, proto_tree *tree,
1723 proto_item *ti, *hidden_item;
1724 proto_tree *mpls_tree;
1725 proto_tree *tlv_tree;
1726 proto_tree *stlv_tree;
1727 proto_tree *stlv_admingrp_tree = NULL;
1733 int stlv_type, stlv_len, stlv_offset;
1734 const char *stlv_name;
1735 guint32 stlv_admingrp, mask;
1739 const guint8 allzero[] = { 0x00, 0x00, 0x00 };
1742 ti = proto_tree_add_text(tree, tvb, offset, length,
1743 "MPLS Traffic Engineering LSA");
1744 hidden_item = proto_tree_add_item(tree, hf_ospf_filter[OSPFF_LS_MPLS],
1745 tvb, offset, 2, FALSE);
1746 PROTO_ITEM_SET_HIDDEN(hidden_item);
1747 mpls_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls);
1749 while (length != 0) {
1750 tlv_type = tvb_get_ntohs(tvb, offset);
1751 tlv_length = tvb_get_ntohs(tvb, offset + 2);
1752 tlv_end_offset = offset + tlv_length + 4;
1756 case MPLS_TLV_ROUTER:
1757 ti = proto_tree_add_text(mpls_tree, tvb, offset, tlv_length+4,
1758 "Router Address: %s",
1759 ip_to_str(tvb_get_ptr(tvb, offset+4, 4)));
1760 tlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_router);
1761 proto_tree_add_text(tlv_tree, tvb, offset, 2, "TLV Type: 1 - Router Address");
1762 proto_tree_add_text(tlv_tree, tvb, offset+2, 2, "TLV Length: %u",
1764 proto_tree_add_item(tlv_tree, hf_ospf_filter[OSPFF_LS_MPLS_ROUTERID],
1765 tvb, offset+4, 4, FALSE);
1769 ti = proto_tree_add_text(mpls_tree, tvb, offset, tlv_length+4,
1770 "Link Information");
1771 tlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link);
1772 proto_tree_add_text(tlv_tree, tvb, offset, 2, "TLV Type: 2 - Link Information");
1773 proto_tree_add_text(tlv_tree, tvb, offset+2, 2, "TLV Length: %u",
1775 stlv_offset = offset + 4;
1777 /* Walk down the sub-TLVs for link information */
1778 while (stlv_offset < tlv_end_offset) {
1779 stlv_type = tvb_get_ntohs(tvb, stlv_offset);
1780 stlv_len = tvb_get_ntohs(tvb, stlv_offset + 2);
1781 stlv_name = val_to_str(stlv_type, mpls_link_stlv_str, "Unknown sub-TLV");
1782 switch (stlv_type) {
1784 case MPLS_LINK_TYPE:
1785 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1786 "%s: %u - %s", stlv_name,
1787 tvb_get_guint8(tvb, stlv_offset + 4),
1788 val_to_str(tvb_get_guint8(tvb, stlv_offset + 4),
1789 mpls_link_stlv_ltype_str, "Unknown Link Type"));
1790 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1791 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1792 "TLV Type: %u: %s", stlv_type, stlv_name);
1793 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1795 proto_tree_add_item(stlv_tree, hf_ospf_filter[OSPFF_LS_MPLS_LINKTYPE],
1796 tvb, stlv_offset+4, 1,FALSE);
1800 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1801 "%s: %s", stlv_name,
1802 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
1803 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1804 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1805 "TLV Type: %u: %s", stlv_type, stlv_name);
1806 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1808 proto_tree_add_item(stlv_tree, hf_ospf_filter[OSPFF_LS_MPLS_LINKID],
1809 tvb, stlv_offset+4, 4, FALSE);
1812 case MPLS_LINK_LOCAL_IF:
1813 case MPLS_LINK_REMOTE_IF:
1814 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1816 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1817 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1818 "TLV Type: %u: %s", stlv_type, stlv_name);
1819 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1821 /* The Local/Remote Interface IP Address sub-TLV is TLV type 3/4, and is 4N
1822 octets in length, where N is the number of neighbor addresses. */
1823 for (i=0; i < stlv_len; i+=4)
1824 proto_tree_add_item(stlv_tree,
1825 stlv_type==MPLS_LINK_LOCAL_IF ?
1826 hf_ospf_filter[OSPFF_LS_MPLS_LOCAL_ADDR] :
1827 hf_ospf_filter[OSPFF_LS_MPLS_REMOTE_ADDR],
1828 tvb, stlv_offset+4+i, 4, FALSE);
1831 case MPLS_LINK_TE_METRIC:
1832 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1833 "%s: %u", stlv_name,
1834 tvb_get_ntohl(tvb, stlv_offset + 4));
1835 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1836 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1837 "TLV Type: %u: %s", stlv_type, stlv_name);
1838 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1840 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 4, "%s: %u", stlv_name,
1841 tvb_get_ntohl(tvb, stlv_offset + 4));
1844 case MPLS_LINK_COLOR:
1845 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1846 "%s: 0x%08x", stlv_name,
1847 tvb_get_ntohl(tvb, stlv_offset + 4));
1848 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1849 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1850 "TLV Type: %u: %s", stlv_type, stlv_name);
1851 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1853 stlv_admingrp = tvb_get_ntohl(tvb, stlv_offset + 4);
1855 ti = proto_tree_add_item(stlv_tree, hf_ospf_filter[OSPFF_LS_MPLS_LINKCOLOR],
1856 tvb, stlv_offset+4, 4, FALSE);
1857 stlv_admingrp_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv_admingrp);
1858 if (stlv_admingrp_tree == NULL)
1860 for (i = 0 ; i < 32 ; i++) {
1861 if ((stlv_admingrp & mask) != 0) {
1862 proto_tree_add_text(stlv_admingrp_tree, tvb, stlv_offset+4,
1869 case MPLS_LINK_MAX_BW:
1870 case MPLS_LINK_MAX_RES_BW:
1871 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1872 "%s: %.10g bytes/s (%.0f bits/s)", stlv_name,
1873 tvb_get_ntohieee_float(tvb, stlv_offset + 4),
1874 tvb_get_ntohieee_float(tvb, stlv_offset + 4) * 8.0);
1875 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1876 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1877 "TLV Type: %u: %s", stlv_type, stlv_name);
1878 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1880 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 4, "%s: %.10g bytes/s (%.0f bits/s)", stlv_name,
1881 tvb_get_ntohieee_float(tvb, stlv_offset + 4),
1882 tvb_get_ntohieee_float(tvb, stlv_offset + 4) * 8.0);
1885 case MPLS_LINK_UNRES_BW:
1886 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1888 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1889 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1890 "TLV Type: %u: %s", stlv_type, stlv_name);
1891 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1893 for (i = 0; i < 8; i++) {
1894 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4+(i*4), 4,
1895 "Pri (or TE-Class) %d: %.10g bytes/s (%.0f bits/s)", i,
1896 tvb_get_ntohieee_float(tvb, stlv_offset + 4 + i*4),
1897 tvb_get_ntohieee_float(tvb, stlv_offset + 4 + i*4) * 8.0);
1901 case MPLS_LINK_BANDWIDTH_CONSTRAINT:
1903 The "Bandwidth Constraints" sub-TLV format is illustrated below:
1906 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
1907 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1908 | BC Model Id | Reserved |
1909 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1911 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1913 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1915 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1918 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1921 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1923 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1924 "TLV Type: %u: %s", stlv_type, stlv_name);
1926 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1929 proto_tree_add_item(stlv_tree, hf_ospf_filter[OSPFF_LS_MPLS_BC_MODEL_ID],
1930 tvb, stlv_offset+4, 1, FALSE);
1932 /* 3 octets reserved +5, +6 and +7 (all 0x00) */
1933 if(tvb_memeql(tvb, stlv_offset+5, allzero, 3) == -1) {
1934 proto_tree_add_text(stlv_tree, tvb, stlv_offset+5, 3,
1935 "Warning: these bytes are reserved and must be 0x00");
1938 if(((stlv_len % 4)!=0)) {
1939 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, stlv_len,
1940 "Malformed Packet: Length must be N x 4 octets");
1944 /* stlv_len shound range from 4 to 36 bytes */
1945 num_bcs = (stlv_len - 4)/4;
1948 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, stlv_len,
1949 "Malformed Packet: too many BC (%u)", num_bcs);
1954 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, stlv_len,
1955 "Malformed Packet: Bandwidth Constraints sub-TLV with no BC?");
1959 for(i = 0; i < (int) num_bcs; i++) {
1960 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8+(i*4), 4,
1961 "BC %d: %.10g bytes/s (%.0f bits/s)", i,
1962 tvb_get_ntohieee_float(tvb, stlv_offset + 8 + i*4),
1963 tvb_get_ntohieee_float(tvb, stlv_offset + 8 + i*4) * 8.0);
1967 case MPLS_LINK_LOCAL_REMOTE_ID:
1968 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1969 "%s: %d (0x%x) - %d (0x%x)", stlv_name,
1970 tvb_get_ntohl(tvb, stlv_offset + 4),
1971 tvb_get_ntohl(tvb, stlv_offset + 4),
1972 tvb_get_ntohl(tvb, stlv_offset + 8),
1973 tvb_get_ntohl(tvb, stlv_offset + 8));
1974 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1976 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1977 "TLV Type: %u: %s", stlv_type, stlv_name);
1978 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1980 proto_tree_add_item(stlv_tree,
1981 hf_ospf_filter[OSPFF_LS_MPLS_LOCAL_IFID],
1982 tvb, stlv_offset+4, 4, FALSE);
1983 proto_tree_add_item(stlv_tree,
1984 hf_ospf_filter[OSPFF_LS_MPLS_REMOTE_IFID],
1985 tvb, stlv_offset+8, 4, FALSE);
1988 case MPLS_LINK_IF_SWITCHING_DESC:
1989 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1991 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1992 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1993 "TLV Type: %u: %s", stlv_type, stlv_name);
1994 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1996 switch_cap = tvb_get_guint8 (tvb, stlv_offset+4);
1997 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Switching Type: %s",
1998 rval_to_str(tvb_get_guint8(tvb,stlv_offset+4),
1999 gmpls_switching_type_rvals, "Unknown (%d)"));
2000 proto_tree_add_text(stlv_tree, tvb, stlv_offset+5, 1, "Encoding: %s",
2001 rval_to_str(tvb_get_guint8(tvb,stlv_offset+5),
2002 gmpls_lsp_enc_rvals, "Unknown (%d)"));
2003 for (i = 0; i < 8; i++) {
2004 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8+(i*4), 4,
2005 "Pri %d: %.10g bytes/s (%.0f bits/s)", i,
2006 tvb_get_ntohieee_float(tvb, stlv_offset + 8 + i*4),
2007 tvb_get_ntohieee_float(tvb, stlv_offset + 8 + i*4) * 8.0);
2009 if (switch_cap >=1 && switch_cap <=4) { /* PSC-1 .. PSC-4 */
2010 proto_tree_add_text(stlv_tree, tvb, stlv_offset+40, 4,
2011 "Minimum LSP bandwidth: %.10g bytes/s (%.0f bits/s)",
2012 tvb_get_ntohieee_float(tvb, stlv_offset + 40),
2013 tvb_get_ntohieee_float(tvb, stlv_offset + 40) * 8.0);
2014 proto_tree_add_text(stlv_tree, tvb, stlv_offset+44, 2,
2015 "Interface MTU: %d", tvb_get_ntohs(tvb, stlv_offset+44));
2018 if (switch_cap == 100) { /* TDM */
2019 proto_tree_add_text(stlv_tree, tvb, stlv_offset+40, 4,
2020 "Minimum LSP bandwidth: %.10g bytes/s (%.0f bits/s)",
2021 tvb_get_ntohieee_float(tvb, stlv_offset + 40),
2022 tvb_get_ntohieee_float(tvb, stlv_offset + 40) * 8.0);
2023 proto_tree_add_text(stlv_tree, tvb, stlv_offset+44, 2,
2025 tvb_get_guint8(tvb, stlv_offset+44) ?
2026 "Arbitrary" : "Standard");
2029 case MPLS_LINK_PROTECTION:
2030 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2032 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
2033 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2034 "TLV Type: %u: %s", stlv_type, stlv_name);
2035 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2037 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Protection Capability: %s (0x%x)",
2038 val_to_str(tvb_get_guint8(tvb,stlv_offset+4), gmpls_protection_cap_str, "Unknown (%d)"),tvb_get_guint8(tvb,stlv_offset+4));
2041 case MPLS_LINK_SHARED_RISK_GROUP:
2042 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2044 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
2045 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2046 "TLV Type: %u: %s", stlv_type, stlv_name);
2047 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2049 for (i=0; i < stlv_len; i+=4)
2050 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4+i, 4, "Shared Risk Link Group: %u",
2051 tvb_get_ntohl(tvb,stlv_offset+4+i));
2054 case OIF_LOCAL_NODE_ID:
2055 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2056 "%s: %s", stlv_name,
2057 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
2058 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
2059 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2060 "TLV Type: %u: %s", stlv_type, stlv_name);
2061 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2063 proto_tree_add_item(stlv_tree,
2064 hf_ospf_filter[OSPFF_LS_OIF_LOCAL_NODE_ID],
2065 tvb, stlv_offset + 4, 4, FALSE);
2068 case OIF_REMOTE_NODE_ID:
2069 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2070 "%s: %s", stlv_name,
2071 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
2072 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
2073 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2074 "TLV Type: %u: %s", stlv_type, stlv_name);
2075 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2077 proto_tree_add_item(stlv_tree,
2078 hf_ospf_filter[OSPFF_LS_OIF_REMOTE_NODE_ID],
2079 tvb, stlv_offset + 4, 4, FALSE);
2082 case OIF_SONET_SDH_SWITCHING_CAPABILITY:
2083 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4, "%s", stlv_name);
2084 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
2085 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2086 "TLV Type: %u: %s", stlv_type, stlv_name);
2087 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2089 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Switching Cap: %s",
2090 rval_to_str(tvb_get_guint8 (tvb, stlv_offset+4),
2091 gmpls_switching_type_rvals, "Unknown (%d)"));
2092 proto_tree_add_text(stlv_tree, tvb, stlv_offset+5, 1, "Encoding: %s",
2093 rval_to_str(tvb_get_guint8(tvb,stlv_offset+5),
2094 gmpls_lsp_enc_rvals, "Unknown (%d)"));
2095 for (i = 0; i < (stlv_len - 4) / 4; i++) {
2096 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8+(i*4), 4,
2097 "%s: %d free timeslots",
2098 val_to_str(tvb_get_guint8(tvb, stlv_offset+8+(i*4)),
2099 gmpls_sonet_signal_type_str,
2100 "Unknown Signal Type (%d)"),
2101 tvb_get_ntoh24(tvb, stlv_offset + 9 + i*4));
2106 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2107 "Unknown Link sub-TLV: %u", stlv_type);
2108 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
2109 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2110 "TLV Type: %u: %s", stlv_type, stlv_name);
2111 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2113 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, stlv_len,
2117 stlv_offset += ((stlv_len+4+3)/4)*4;
2122 ti = proto_tree_add_text(mpls_tree, tvb, offset, tlv_length+4,
2124 tlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna);
2125 proto_tree_add_text(tlv_tree, tvb, offset, 2, "TLV Type: 32768 - TNA Information");
2126 proto_tree_add_text(tlv_tree, tvb, offset+2, 2, "TLV Length: %u",
2128 stlv_offset = offset + 4;
2130 /* Walk down the sub-TLVs for TNA information */
2131 while (stlv_offset < tlv_end_offset) {
2132 stlv_type = tvb_get_ntohs(tvb, stlv_offset);
2133 stlv_len = tvb_get_ntohs(tvb, stlv_offset + 2);
2134 stlv_name = val_to_str(stlv_type, oif_stlv_str, "Unknown sub-TLV");
2135 switch (stlv_type) {
2138 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2139 "%s: %s", stlv_name,
2140 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
2141 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna_stlv);
2142 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2143 "TLV Type: %u: %s", stlv_type, stlv_name);
2144 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2146 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 4, "%s: %s", stlv_name,
2147 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
2150 case OIF_TNA_IPv4_ADDRESS:
2151 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2152 "%s (IPv4): %s", stlv_name,
2153 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 8, 4)));
2154 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna_stlv);
2155 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2156 "TLV Type: %u: %s (IPv4)", stlv_type, stlv_name);
2157 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u", stlv_len);
2158 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Addr Length: %u",
2159 tvb_get_guint8 (tvb, stlv_offset+4));
2160 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8, stlv_len - 4, "TNA Addr: %s",
2161 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 8, 4)));
2164 case OIF_TNA_IPv6_ADDRESS:
2165 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2166 "%s (IPv6): %s", stlv_name,
2167 ip6_to_str((const struct e_in6_addr *)
2168 tvb_get_ptr(tvb, stlv_offset + 8, 16)));
2169 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna_stlv);
2170 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2171 "TLV Type: %u: %s (IPv6)", stlv_type, stlv_name);
2172 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u", stlv_len);
2173 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Addr Length: %u",
2174 tvb_get_guint8 (tvb, stlv_offset+4));
2175 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8, stlv_len - 4, "TNA Addr: %s",
2176 ip6_to_str((const struct e_in6_addr *)
2177 tvb_get_ptr(tvb, stlv_offset + 8, 16)));
2180 case OIF_TNA_NSAP_ADDRESS:
2181 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2182 "%s (NSAP): %s", stlv_name,
2183 tvb_bytes_to_str (tvb, stlv_offset + 8, stlv_len - 4));
2184 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna_stlv);
2185 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2186 "TLV Type: %u: %s (NSAP)", stlv_type, stlv_name);
2187 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u", stlv_len);
2188 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Addr Length: %u",
2189 tvb_get_guint8 (tvb, stlv_offset+4));
2190 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8, stlv_len - 4, "TNA Addr: %s",
2191 tvb_bytes_to_str(tvb, stlv_offset+8, stlv_len - 4));
2195 proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2196 "Unknown Link sub-TLV: %u", stlv_type);
2199 stlv_offset += ((stlv_len+4+3)/4)*4;
2203 ti = proto_tree_add_text(mpls_tree, tvb, offset, tlv_length+4,
2204 "Unknown LSA: %u", tlv_type);
2205 tlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link);
2206 proto_tree_add_text(tlv_tree, tvb, offset, 2, "TLV Type: %u - Unknown",
2208 proto_tree_add_text(tlv_tree, tvb, offset+2, 2, "TLV Length: %u",
2210 proto_tree_add_text(tlv_tree, tvb, offset+4, tlv_length, "TLV Data");
2214 offset += tlv_length + 4;
2215 length -= tlv_length + 4;
2220 * Dissect the TLVs within a Grace-LSA as defined by RFC 3623
2222 static void dissect_ospf_lsa_grace_tlv (tvbuff_t *tvb, int offset,
2223 proto_tree *tree, guint32 length)
2227 int tlv_length_with_pad; /* The total length of the TLV including the type
2228 and length fields and any padding */
2229 guint32 grace_period;
2230 guint8 restart_reason;
2232 proto_tree *tlv_tree;
2233 proto_item *tree_item;
2234 proto_item *grace_tree_item;
2236 if (!tree) { return; }
2240 tlv_type = tvb_get_ntohs(tvb, offset);
2241 tlv_length = tvb_get_ntohs(tvb, offset + 2);
2242 /* The total length of the TLV including the type, length, value and
2243 * pad bytes (TLVs are padded to 4 octet alignment).
2245 tlv_length_with_pad = tlv_length + 4 + ((4 - (tlv_length % 4)) % 4);
2247 tree_item = proto_tree_add_item(tree, hf_ospf_filter[OSPFF_V2_GRACE_TLV], tvb, offset,
2248 tlv_length_with_pad, FALSE);
2249 tlv_tree = proto_item_add_subtree(tree_item, ett_ospf_lsa_grace_tlv);
2250 proto_tree_add_text(tlv_tree, tvb, offset, 2, "Type: %s (%u)",
2251 val_to_str(tlv_type, grace_tlv_type_vals, "Unknown grace-LSA TLV"), tlv_type);
2252 proto_tree_add_text(tlv_tree, tvb, offset + 2, 2, "Length: %u", tlv_length);
2255 case GRACE_TLV_PERIOD:
2256 grace_period = tvb_get_ntohl(tvb, offset + 4);
2257 grace_tree_item = proto_tree_add_item(tlv_tree, hf_ospf_filter[OSPFF_V2_GRACE_PERIOD], tvb,
2258 offset + 4, tlv_length, FALSE);
2259 proto_item_append_text(grace_tree_item, " seconds");
2260 proto_item_set_text(tree_item, "Grace Period: %u seconds", grace_period);
2262 case GRACE_TLV_REASON:
2263 restart_reason = tvb_get_guint8(tvb, offset + 4);
2264 proto_tree_add_item(tlv_tree, hf_ospf_filter[OSPFF_V2_GRACE_REASON], tvb, offset + 4,
2266 proto_item_set_text(tree_item, "Restart Reason: %s (%u)",
2267 val_to_str(restart_reason, restart_reason_vals, "Unknown Restart Reason"),
2271 restart_ip = tvb_get_ipv4(tvb, offset + 4);
2272 proto_tree_add_item(tlv_tree, hf_ospf_filter[OSPFF_V2_GRACE_IP], tvb, offset + 4,
2274 proto_item_set_text(tree_item, "Restart IP: %s (%s)",
2275 get_hostname(restart_ip), ip_to_str((guint8 *)&restart_ip));
2278 proto_item_set_text(tree_item, "Unknown grace-LSA TLV");
2281 if (4 + tlv_length < tlv_length_with_pad) {
2282 proto_tree_add_text(tlv_tree, tvb, offset + 4 + tlv_length,
2283 tlv_length_with_pad - (4 + tlv_length), "Pad Bytes (%u)",
2284 tlv_length_with_pad - (4 + tlv_length) );
2286 offset += tlv_length_with_pad;
2287 length -= tlv_length_with_pad;
2292 * Dissect opaque LSAs
2295 dissect_ospf_lsa_opaque(tvbuff_t *tvb, int offset, proto_tree *tree,
2296 guint8 ls_id_type, guint32 length)
2298 switch (ls_id_type) {
2300 case OSPF_LSA_MPLS_TE:
2301 dissect_ospf_lsa_mpls(tvb, offset, tree, length);
2303 case OSPF_LSA_GRACE:
2304 dissect_ospf_lsa_grace_tlv(tvb, offset, tree, length);
2308 proto_tree_add_text(tree, tvb, offset, length,
2309 "Unknown LSA Type %u", ls_id_type);
2311 } /* switch on opaque LSA id */
2315 dissect_ospf_v2_lsa(tvbuff_t *tvb, int offset, proto_tree *tree,
2316 gboolean disassemble_body)
2318 proto_tree *ospf_lsa_tree;
2319 proto_item *ti, *hidden_item;
2329 guint16 link_counter;
2330 guint8 metric_counter;
2331 const char *link_type_str;
2332 const char *link_type_short_str;
2333 const char *link_id;
2334 const char *metric_type_str;
2336 /* AS-external LSA */
2342 ls_type = tvb_get_guint8(tvb, offset + 3);
2343 ls_length = tvb_get_ntohs(tvb, offset + 18);
2344 end_offset = offset + ls_length;
2346 if (disassemble_body) {
2347 ti = proto_tree_add_text(tree, tvb, offset, ls_length,
2349 val_to_str(ls_type, ls_type_vals, "Unknown (%d)"));
2351 ti = proto_tree_add_text(tree, tvb, offset, OSPF_LSA_HEADER_LENGTH,
2354 ospf_lsa_tree = proto_item_add_subtree(ti, ett_ospf_lsa);
2356 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2, "LS Age: %u seconds",
2357 tvb_get_ntohs(tvb, offset) & ~OSPF_DNA_LSA);
2358 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2, "Do Not Age: %s",
2359 (tvb_get_ntohs(tvb, offset) & OSPF_DNA_LSA) ? "True" : "False");
2360 options = tvb_get_guint8 (tvb, offset + 2);
2361 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset + 2, &bfinfo_v2_options);
2362 proto_tree_add_item(ospf_lsa_tree, hf_ospf_filter[OSPFF_LS_TYPE], tvb,
2363 offset + 3, 1, FALSE);
2364 if (ospf_ls_type_to_filter(ls_type) != -1) {
2365 hidden_item = proto_tree_add_item(ospf_lsa_tree,
2366 hf_ospf_filter[ospf_ls_type_to_filter(ls_type)], tvb,
2367 offset + 3, 1, FALSE);
2368 PROTO_ITEM_SET_HIDDEN(hidden_item);
2371 if (options & OSPF_V2_OPTIONS_MT) {
2372 metric_type_str = "MT-ID";
2374 metric_type_str = "TOS";
2377 if (is_opaque(ls_type)) {
2378 ls_id_type = tvb_get_guint8(tvb, offset + 4);
2379 proto_tree_add_uint(ospf_lsa_tree, hf_ospf_filter[OSPFF_LS_OPAQUE_TYPE],
2380 tvb, offset + 4, 1, ls_id_type);
2382 switch (ls_id_type) {
2384 case OSPF_LSA_MPLS_TE:
2385 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 5, 1, "Link State ID TE-LSA Reserved: %u",
2386 tvb_get_guint8(tvb, offset + 5));
2387 proto_tree_add_item(ospf_lsa_tree, hf_ospf_filter[OSPFF_LS_MPLS_TE_INSTANCE],
2388 tvb, offset + 6, 2, FALSE);
2392 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 5, 3, "Link State ID Opaque ID: %u",
2393 tvb_get_ntoh24(tvb, offset + 5));
2398 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 4, "Link State ID: %s",
2399 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
2402 proto_tree_add_item(ospf_lsa_tree, hf_ospf_filter[OSPFF_ADV_ROUTER],
2403 tvb, offset + 8, 4, FALSE);
2404 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 12, 4, "LS Sequence Number: 0x%08x",
2405 tvb_get_ntohl(tvb, offset + 12));
2406 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 16, 2, "LS Checksum: 0x%04x",
2407 tvb_get_ntohs(tvb, offset + 16));
2409 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 18, 2, "Length: %u",
2412 /* skip past the LSA header to the body */
2413 offset += OSPF_LSA_HEADER_LENGTH;
2414 if (ls_length <= OSPF_LSA_HEADER_LENGTH)
2415 return offset; /* no data, or bogus length */
2416 ls_length -= OSPF_LSA_HEADER_LENGTH;
2418 if (!disassemble_body)
2423 case OSPF_LSTYPE_ROUTER:
2424 /* flags field in an router-lsa */
2425 if (options & OSPF_V2_OPTIONS_MT) {
2426 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset, &bfinfo_v2_router_lsa_mt_flags);
2428 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset, &bfinfo_v2_router_lsa_flags);
2431 nr_links = tvb_get_ntohs(tvb, offset + 2);
2432 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 2, 2, "Number of Links: %u",
2435 /* nr_links links follow
2436 * maybe we should put each of the links into its own subtree ???
2438 for (link_counter = 1; link_counter <= nr_links; link_counter++) {
2439 proto_tree *ospf_lsa_router_link_tree;
2440 proto_item *ti_local;
2443 /* check the Link Type and ID */
2444 link_type = tvb_get_guint8(tvb, offset + 8);
2445 switch (link_type) {
2448 link_type_str="Point-to-point connection to another router";
2449 link_type_short_str="PTP";
2450 link_id="Neighboring router's Router ID";
2453 case OSPF_LINK_TRANSIT:
2454 link_type_str="Connection to a transit network";
2455 link_type_short_str="Transit";
2456 link_id="IP address of Designated Router";
2459 case OSPF_LINK_STUB:
2460 link_type_str="Connection to a stub network";
2461 link_type_short_str="Stub";
2462 link_id="IP network/subnet number";
2465 case OSPF_LINK_VIRTUAL:
2466 link_type_str="Virtual link";
2467 link_type_short_str="Virtual";
2468 link_id="Neighboring router's Router ID";
2472 link_type_str="Unknown link type";
2473 link_type_short_str="Unknown";
2474 link_id="Unknown link ID";
2478 nr_metric = tvb_get_guint8(tvb, offset + 9);
2481 ti_local = proto_tree_add_text(ospf_lsa_tree, tvb, offset, 12 + 4 * nr_metric,
2482 "Type: %-8s ID: %-15s Data: %-15s Metric: %d",
2483 link_type_short_str,
2484 ip_to_str(tvb_get_ptr(tvb, offset, 4)),
2485 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)),
2486 tvb_get_ntohs(tvb, offset + 10));
2488 ospf_lsa_router_link_tree = proto_item_add_subtree(ti_local, ett_ospf_lsa_router_link);
2490 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset, 4, "%s: %s", link_id,
2491 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2493 /* link_data should be specified in detail (e.g. network mask) (depends on link type)*/
2494 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset + 4, 4, "Link Data: %s",
2495 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
2497 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset + 8, 1, "Link Type: %u - %s",
2498 link_type, link_type_str);
2499 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset + 9, 1, "Number of %s metrics: %u",
2500 metric_type_str, nr_metric);
2501 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset + 10, 2, "%s 0 metric: %u",
2502 metric_type_str, tvb_get_ntohs(tvb, offset + 10));
2506 /* nr_metric metrics may follow each link
2507 * According to RFC4915 the TOS metrics was never deployed and was subsequently deprecated,
2508 * but decoding still present because MT-ID use the same structure.
2510 for (metric_counter = 1; metric_counter <= nr_metric; metric_counter++) {
2511 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset, 4, "%s: %u, Metric: %u",
2513 tvb_get_guint8(tvb, offset),
2514 tvb_get_ntohs(tvb, offset + 2));
2520 case OSPF_LSTYPE_NETWORK:
2521 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Netmask: %s",
2522 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2525 while (offset < end_offset) {
2526 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Attached Router: %s",
2527 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2532 case OSPF_LSTYPE_SUMMERY:
2533 /* Type 3 and 4 LSAs have the same format */
2534 case OSPF_LSTYPE_ASBR:
2535 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Netmask: %s",
2536 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2539 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Metric: %u",
2540 tvb_get_ntoh24(tvb, offset + 1));
2543 /* Metric specific information, if any */
2544 while (offset < end_offset) {
2545 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "%s: %u, Metric: %u",
2547 tvb_get_guint8(tvb, offset),
2548 tvb_get_ntoh24(tvb, offset + 1));
2553 case OSPF_LSTYPE_ASEXT:
2554 case OSPF_LSTYPE_ASEXT7:
2555 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Netmask: %s",
2556 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2559 options = tvb_get_guint8(tvb, offset);
2560 if (options & 0x80) { /* check whether or not E bit is set */
2561 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2562 "External Type: Type 2 (metric is larger than any other link state path)");
2564 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2565 "External Type: Type 1 (metric is specified in the same units as interface cost)");
2567 /* the metric field of a AS-external LAS is specified in 3 bytes */
2568 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 1, 3, "Metric: %u",
2569 tvb_get_ntoh24(tvb, offset + 1));
2572 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Forwarding Address: %s",
2573 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2576 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "External Route Tag: %u",
2577 tvb_get_ntohl(tvb, offset));
2580 /* Metric specific information, if any */
2581 while (offset < end_offset) {
2582 options = tvb_get_guint8(tvb, offset);
2583 if (options & 0x80) { /* check whether or not E bit is set */
2584 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2585 "External Type: Type 2 (metric is larger than any other link state path)");
2587 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2588 "External Type: Type 1 (metric is specified in the same units as interface cost)");
2590 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "%s: %u, Metric: %u",
2591 metric_type_str, options & 0x7F,
2592 tvb_get_ntoh24(tvb, offset + 1));
2595 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Forwarding Address: %s",
2596 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2599 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "External Route Tag: %u",
2600 tvb_get_ntohl(tvb, offset));
2605 case OSPF_LSTYPE_OP_LINKLOCAL:
2606 case OSPF_LSTYPE_OP_AREALOCAL:
2607 case OSPF_LSTYPE_OP_ASWIDE:
2609 * RFC 2370 opaque LSAs.
2611 dissect_ospf_lsa_opaque(tvb, offset, ospf_lsa_tree, ls_id_type,
2613 offset += ls_length;
2617 /* unknown LSA type */
2618 proto_tree_add_text(ospf_lsa_tree, tvb, offset, ls_length,
2619 "Unknown LSA Type");
2620 offset += ls_length;
2623 /* return the offset of the next LSA */
2628 dissect_ospf_v3_lsa(tvbuff_t *tvb, int offset, proto_tree *tree,
2629 gboolean disassemble_body, guint8 address_family)
2631 proto_tree *ospf_lsa_tree;
2641 const char *link_type_str;
2644 guint8 router_priority;
2645 guint32 number_prefixes;
2646 guint8 prefix_length;
2649 guint16 referenced_ls_type;
2652 guint32 external_route_tag;
2655 ls_type = tvb_get_ntohs(tvb, offset + 2);
2656 ls_length = tvb_get_ntohs(tvb, offset + 18);
2657 end_offset = offset + ls_length;
2659 if (disassemble_body) {
2660 ti = proto_tree_add_text(tree, tvb, offset, ls_length,
2661 "%s (Type: 0x%04x)", val_to_str(ls_type, v3_ls_type_vals,"Unknown"), ls_type);
2663 ti = proto_tree_add_text(tree, tvb, offset, OSPF_LSA_HEADER_LENGTH,
2666 ospf_lsa_tree = proto_item_add_subtree(ti, ett_ospf_lsa);
2668 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2, "LS Age: %u seconds",
2669 tvb_get_ntohs(tvb, offset) & ~OSPF_DNA_LSA);
2670 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2, "Do Not Age: %s",
2671 (tvb_get_ntohs(tvb, offset) & OSPF_DNA_LSA) ? "True" : "False");
2673 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 2, 2, "LSA Type: 0x%04x (%s)",
2674 ls_type, val_to_str(ls_type, v3_ls_type_vals,"Unkown"));
2676 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 4, "Link State ID: %s",
2677 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
2679 proto_tree_add_item(ospf_lsa_tree, hf_ospf_filter[OSPFF_ADV_ROUTER],
2680 tvb, offset + 8, 4, FALSE);
2681 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 12, 4, "LS Sequence Number: 0x%08x",
2682 tvb_get_ntohl(tvb, offset + 12));
2683 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 16, 2, "LS Checksum: 0x%04x",
2684 tvb_get_ntohs(tvb, offset + 16));
2686 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 18, 2, "Length: %u",
2689 /* skip past the LSA header to the body */
2690 offset += OSPF_LSA_HEADER_LENGTH;
2691 ls_length -= OSPF_LSA_HEADER_LENGTH;
2693 if (!disassemble_body)
2699 case OSPF_V3_LSTYPE_ROUTER:
2700 /* flags field in an router-lsa */
2701 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset, &bfinfo_v3_router_lsa_flags);
2703 /* options field in an router-lsa */
2704 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset + 1, &bfinfo_v3_options);
2706 /* skip the router-lsa flags and options */
2711 proto_tree_add_text(ospf_lsa_tree, tvb, offset, ls_length,
2712 "Router Interfaces:");
2714 /* scan all router-lsa router interfaces */
2715 /* maybe we should put each of the links into its own subtree ??? */
2716 while (ls_length > 0 ) {
2718 /* check the type */
2719 link_type = tvb_get_guint8(tvb, offset);
2720 switch (link_type) {
2722 case OSPF_V3_LINK_PTP:
2723 link_type_str="Point-to-point connection to another router";
2726 case OSPF_V3_LINK_TRANSIT:
2727 link_type_str="Connection to a transit network";
2730 case OSPF_V3_LINK_RESERVED:
2731 link_type_str="Connection to a stub network";
2734 case OSPF_V3_LINK_VIRTUAL:
2735 link_type_str="Virtual link";
2739 link_type_str="Unknown link type";
2743 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "Type: %u (%s)", link_type,link_type_str);
2745 /* reserved field */
2746 reserved = tvb_get_guint8(tvb, offset+1);
2747 proto_tree_add_text(ospf_lsa_tree, tvb, offset+1, 1,
2748 (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved);
2751 metric=tvb_get_ntohs(tvb, offset+2);
2752 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 2, 2,"Metric: %u",metric);
2755 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 4, "Interface ID: %u",
2756 tvb_get_ntohl(tvb, offset + 4));
2758 /* Neighbor Interface ID */
2759 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 8, 4, "Neighbor Interface ID: %u",
2760 tvb_get_ntohl(tvb, offset + 8));
2762 /* Neighbor Router ID */
2763 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 12, 4, "Neighbor Router ID: %s",
2764 ip_to_str(tvb_get_ptr(tvb, offset + 12, 4)));
2766 /* skip to the (possible) next entry */
2773 case OSPF_V3_LSTYPE_NETWORK:
2775 /* reserved field */
2776 reserved = tvb_get_guint8(tvb, offset);
2777 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2778 (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved);
2780 /* options field in an network-lsa */
2781 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset + 1, &bfinfo_v3_options);
2786 while (ls_length > 0 ) {
2787 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Attached Router: %s",
2788 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2795 case OSPF_V3_LSTYPE_INTER_AREA_PREFIX:
2797 /* reserved field */
2798 reserved = tvb_get_guint8(tvb, offset);
2799 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2800 (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved);
2803 metric=tvb_get_ntoh24(tvb, offset+1);
2804 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 1, 3,"Metric: %u",metric);
2807 prefix_length=tvb_get_guint8(tvb, offset+4);
2808 proto_tree_add_text(ospf_lsa_tree, tvb, offset+4, 1, "PrefixLength: %u",prefix_length);
2810 /* prefix options */
2811 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset+5, &bfinfo_v3_prefix_options);
2813 /* 16 bits reserved */
2814 reserved16=tvb_get_ntohs(tvb, offset+6);
2815 proto_tree_add_text(ospf_lsa_tree, tvb, offset+6, 2,
2816 (reserved16 == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved16);
2820 /* address_prefix */
2821 dissect_ospf_v3_address_prefix(tvb, offset, prefix_length, ospf_lsa_tree, address_family);
2823 offset+=(prefix_length+31)/32*4;
2828 case OSPF_V3_LSTYPE_INTER_AREA_ROUTER:
2830 /* reserved field */
2831 reserved = tvb_get_guint8(tvb, offset);
2832 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2833 (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved);
2835 /* options field in an inter-area-router-lsa */
2836 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset + 1, &bfinfo_v3_options);
2838 /* reserved field */
2839 reserved = tvb_get_guint8(tvb, offset+4);
2840 proto_tree_add_text(ospf_lsa_tree, tvb, offset+4, 1,
2841 (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved);
2844 metric=tvb_get_ntoh24(tvb, offset+5);
2845 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 5, 3,"Metric: %u",metric);
2847 /* Destination Router ID */
2848 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 8, 4, "Destination Router ID: %s",
2849 ip_to_str(tvb_get_ptr(tvb, offset + 8, 4)));
2855 case OSPF_V3_LSTYPE_TYPE_7:
2856 case OSPF_V3_LSTYPE_AS_EXTERNAL:
2859 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset, &bfinfo_v3_as_external_flags);
2860 flags=tvb_get_guint8(tvb, offset);
2862 /* 24 bits metric */
2863 metric=tvb_get_ntoh24(tvb, offset+1);
2864 proto_tree_add_text(ospf_lsa_tree, tvb, offset+1, 3,
2865 "Metric: %u", metric);
2868 prefix_length=tvb_get_guint8(tvb, offset+4);
2869 proto_tree_add_text(ospf_lsa_tree, tvb, offset+4, 1, "PrefixLength: %u",prefix_length);
2871 /* prefix options */
2872 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset+5, &bfinfo_v3_prefix_options);
2874 /* referenced LS type */
2875 referenced_ls_type=tvb_get_ntohs(tvb, offset+6);
2876 proto_tree_add_text(ospf_lsa_tree, tvb, offset+6, 2,"Referenced LS type 0x%04x (%s)",
2877 referenced_ls_type, val_to_str(referenced_ls_type, v3_ls_type_vals, "Unknown"));
2881 /* address_prefix */
2882 dissect_ospf_v3_address_prefix(tvb, offset, prefix_length, ospf_lsa_tree, address_family);
2884 offset+=(prefix_length+31)/32*4;
2886 /* Forwarding Address (optional - only if F-flag is on) */
2887 if ( (offset < end_offset) && (flags & OSPF_V3_AS_EXTERNAL_FLAG_F) ) {
2888 if (address_family == OSPF_AF_6) {
2889 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 16,"Forwarding Address: %s",
2890 ip6_to_str((const struct e_in6_addr *)tvb_get_ptr(tvb, offset, 16)));
2892 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 16,"Forwarding Address: %s",
2893 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2899 /* External Route Tag (optional - only if T-flag is on) */
2900 if ( (offset < end_offset) && (flags & OSPF_V3_AS_EXTERNAL_FLAG_T) ) {
2901 external_route_tag=tvb_get_ntohl(tvb, offset);
2902 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4,"External Route Tag: %u",
2903 external_route_tag);
2908 /* Referenced Link State ID (optional - only if Referenced LS type is non-zero */
2909 if ( (offset < end_offset) && (referenced_ls_type != 0) ) {
2910 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Referenced Link State ID: %s",
2911 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2917 case OSPF_V3_LSTYPE_LINK:
2919 /* router priority */
2920 router_priority=tvb_get_guint8(tvb, offset);
2921 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "Router Priority: %u", router_priority);
2923 /* options field in an link-lsa */
2924 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset + 1, &bfinfo_v3_options);
2926 /* Link-local Interface Address */
2927 if (address_family == OSPF_AF_6) {
2928 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 16, "Link-local Interface Address: %s",
2929 ip6_to_str((const struct e_in6_addr *)tvb_get_ptr(tvb, offset + 4, 16)));
2931 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 16, "Link-local Interface Address: %s",
2932 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
2934 /* Number prefixes */
2935 number_prefixes=tvb_get_ntohl(tvb, offset + 20);
2936 proto_tree_add_text(ospf_lsa_tree, tvb, offset+20, 4, "# prefixes: %d",number_prefixes);
2940 while (number_prefixes > 0) {
2943 prefix_length=tvb_get_guint8(tvb, offset);
2944 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "PrefixLength: %u",prefix_length);
2946 /* prefix options */
2947 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset+1, &bfinfo_v3_prefix_options);
2949 /* 16 bits reserved */
2950 reserved16=tvb_get_ntohs(tvb, offset+2);
2951 proto_tree_add_text(ospf_lsa_tree, tvb, offset+2, 2,
2952 (reserved16 == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved16);
2956 /* address_prefix */
2957 dissect_ospf_v3_address_prefix(tvb, offset, prefix_length, ospf_lsa_tree, address_family);
2959 offset+=(prefix_length+31)/32*4;
2966 case OSPF_V3_LSTYPE_INTRA_AREA_PREFIX:
2969 number_prefixes=tvb_get_ntohs(tvb, offset);
2970 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2,"# prefixes: %u",number_prefixes);
2972 /* referenced LS type */
2973 referenced_ls_type=tvb_get_ntohs(tvb, offset+2);
2974 proto_tree_add_text(ospf_lsa_tree, tvb, offset+2, 2,"Referenced LS type 0x%04x (%s)",
2975 referenced_ls_type, val_to_str(referenced_ls_type, v3_ls_type_vals, "Unknown"));
2977 /* Referenced Link State ID */
2978 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 4, "Referenced Link State ID: %s",
2979 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
2981 /* Referenced Advertising Router */
2982 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 8, 4, "Referenced Advertising Router: %s",
2983 ip_to_str(tvb_get_ptr(tvb, offset + 8, 4)));
2987 while (number_prefixes > 0) {
2990 prefix_length=tvb_get_guint8(tvb, offset);
2991 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "PrefixLength: %u",prefix_length);
2993 /* prefix options */
2994 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset+1, &bfinfo_v3_prefix_options);
2996 /* 16 bits metric */
2997 metric=tvb_get_ntohs(tvb, offset+2);
2998 proto_tree_add_text(ospf_lsa_tree, tvb, offset+2, 2,
2999 "Metric: %u", metric);
3003 /* address_prefix */
3004 dissect_ospf_v3_address_prefix(tvb, offset, prefix_length, ospf_lsa_tree, address_family);
3006 offset+=(prefix_length+31)/32*4;
3013 /* unknown LSA type */
3014 proto_tree_add_text(ospf_lsa_tree, tvb, offset, ls_length,
3015 "Unknown LSA Type 0x%04x",ls_type);
3016 offset += ls_length;
3019 /* return the offset of the next LSA */
3023 static void dissect_ospf_v3_address_prefix(tvbuff_t *tvb, int offset, int prefix_length, proto_tree *tree,
3024 guint8 address_family)
3027 int bytes_to_process;
3028 struct e_in6_addr prefix;
3030 bytes_to_process=((prefix_length+31)/32)*4;
3032 if (prefix_length > 128) {
3033 proto_tree_add_text(tree, tvb, offset, bytes_to_process,
3034 "Address Prefix: length is invalid (%d, should be <= 128)",
3039 memset(prefix.bytes, 0, sizeof prefix.bytes);
3040 if (bytes_to_process != 0) {
3041 tvb_memcpy(tvb, prefix.bytes, offset, bytes_to_process);
3042 if (prefix_length % 8) {
3043 prefix.bytes[bytes_to_process - 1] &=
3044 ((0xff00 >> (prefix_length % 8)) & 0xff);
3047 if (address_family == OSPF_AF_6) {
3048 proto_tree_add_text(tree, tvb, offset, bytes_to_process,
3049 "Address Prefix: %s", ip6_to_str(&prefix));
3051 proto_tree_add_text(tree, tvb, offset, bytes_to_process,
3052 "Address Prefix: %s", ip_to_str(tvb_get_ptr(tvb, offset, 4)));
3059 proto_register_ospf(void)
3061 static hf_register_info ospff_info[] = {
3063 /* Message type number */
3064 {&hf_ospf_filter[OSPFF_MSG_TYPE],
3065 { "Message Type", "ospf.msg", FT_UINT8, BASE_DEC, VALS(pt_vals), 0x0,
3069 {&hf_ospf_filter[OSPFF_MSG_HELLO],
3070 { "Hello", "ospf.msg.hello", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3072 {&hf_ospf_filter[OSPFF_MSG_DB_DESC],
3073 { "Database Description", "ospf.msg.dbdesc", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3075 {&hf_ospf_filter[OSPFF_MSG_LS_REQ],
3076 { "Link State Adv Request", "ospf.msg.lsreq", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3078 {&hf_ospf_filter[OSPFF_MSG_LS_UPD],
3079 { "Link State Adv Update", "ospf.msg.lsupdate", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3081 {&hf_ospf_filter[OSPFF_MSG_LS_ACK],
3082 { "Link State Adv Acknowledgement", "ospf.msg.lsack", FT_BOOLEAN,
3083 BASE_NONE, NULL, 0x0, NULL, HFILL }},
3088 {&hf_ospf_filter[OSPFF_LS_TYPE],
3089 { "Link-State Advertisement Type", "ospf.lsa", FT_UINT8, BASE_DEC,
3090 VALS(ls_type_vals), 0x0, NULL, HFILL }},
3091 {&hf_ospf_filter[OSPFF_LS_OPAQUE_TYPE],
3092 { "Link State ID Opaque Type", "ospf.lsid_opaque_type", FT_UINT8, BASE_DEC,
3093 VALS(ls_opaque_type_vals), 0x0, NULL, HFILL }},
3095 {&hf_ospf_filter[OSPFF_LS_MPLS_TE_INSTANCE],
3096 { "Link State ID TE-LSA Instance", "ospf.lsid_te_lsa.instance", FT_UINT16, BASE_DEC,
3097 NULL, 0x0, NULL, HFILL }},
3099 {&hf_ospf_filter[OSPFF_LS_ROUTER],
3100 { "Router LSA", "ospf.lsa.router", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3102 {&hf_ospf_filter[OSPFF_LS_NETWORK],
3103 { "Network LSA", "ospf.lsa.network", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3105 {&hf_ospf_filter[OSPFF_LS_SUMMARY],
3106 { "Summary LSA (IP Network)", "ospf.lsa.summary", FT_BOOLEAN, BASE_NONE,
3107 NULL, 0x0, NULL, HFILL }},
3108 {&hf_ospf_filter[OSPFF_LS_ASBR],
3109 { "Summary LSA (ASBR)", "ospf.lsa.asbr", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3111 {&hf_ospf_filter[OSPFF_LS_ASEXT],
3112 { "AS-External LSA (ASBR)", "ospf.lsa.asext", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3114 {&hf_ospf_filter[OSPFF_LS_GRPMEMBER],
3115 { "Group Membership LSA", "ospf.lsa.member", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3117 {&hf_ospf_filter[OSPFF_LS_ASEXT7],
3118 { "NSSA AS-External LSA", "ospf.lsa.nssa", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3120 {&hf_ospf_filter[OSPFF_LS_EXTATTR],
3121 { "External Attributes LSA", "ospf.lsa.attr", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3123 {&hf_ospf_filter[OSPFF_LS_OPAQUE],
3124 { "Opaque LSA", "ospf.lsa.opaque", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3127 /* Other interesting OSPF values */
3129 {&hf_ospf_filter[OSPFF_SRC_ROUTER],
3130 { "Source OSPF Router", "ospf.srcrouter", FT_IPv4, BASE_NONE, NULL, 0x0,
3133 {&hf_ospf_filter[OSPFF_ADV_ROUTER],
3134 { "Advertising Router", "ospf.advrouter", FT_IPv4, BASE_NONE, NULL, 0x0,
3137 {&hf_ospf_filter[OSPFF_LS_MPLS],
3138 { "MPLS Traffic Engineering LSA", "ospf.lsa.mpls", FT_BOOLEAN,
3139 BASE_NONE, NULL, 0x0, NULL, HFILL }},
3141 {&hf_ospf_filter[OSPFF_LS_MPLS_ROUTERID],
3142 { "MPLS/TE Router ID", "ospf.mpls.routerid", FT_IPv4, BASE_NONE, NULL, 0x0,
3145 {&hf_ospf_filter[OSPFF_LS_MPLS_LINKTYPE],
3146 { "MPLS/TE Link Type", "ospf.mpls.linktype", FT_UINT8, BASE_DEC,
3147 VALS(mpls_link_stlv_ltype_str), 0x0, NULL, HFILL }},
3148 {&hf_ospf_filter[OSPFF_LS_MPLS_LINKID],
3149 { "MPLS/TE Link ID", "ospf.mpls.linkid", FT_IPv4, BASE_NONE, NULL, 0x0,
3151 {&hf_ospf_filter[OSPFF_LS_MPLS_LOCAL_ADDR],
3152 { "MPLS/TE Local Interface Address", "ospf.mpls.local_addr", FT_IPv4,
3153 BASE_NONE, NULL, 0x0, NULL, HFILL }},
3154 {&hf_ospf_filter[OSPFF_LS_MPLS_REMOTE_ADDR],
3155 { "MPLS/TE Remote Interface Address", "ospf.mpls.remote_addr", FT_IPv4,
3156 BASE_NONE, NULL, 0x0, NULL, HFILL }},
3157 {&hf_ospf_filter[OSPFF_LS_MPLS_LOCAL_IFID],
3158 { "MPLS/TE Local Interface Index", "ospf.mpls.local_id", FT_UINT32,
3159 BASE_DEC, NULL, 0x0, NULL, HFILL }},
3160 {&hf_ospf_filter[OSPFF_LS_MPLS_REMOTE_IFID],
3161 { "MPLS/TE Remote Interface Index", "ospf.mpls.remote_id", FT_UINT32,
3162 BASE_DEC, NULL, 0x0, NULL, HFILL }},
3163 {&hf_ospf_filter[OSPFF_LS_MPLS_LINKCOLOR],
3164 { "MPLS/TE Link Resource Class/Color", "ospf.mpls.linkcolor", FT_UINT32,
3165 BASE_HEX, NULL, 0x0, NULL, HFILL }},
3166 {&hf_ospf_filter[OSPFF_LS_MPLS_BC_MODEL_ID],
3167 { "MPLS/DSTE Bandwidth Constraints Model Id", "ospf.mpls.bc", FT_UINT8,
3168 BASE_RANGE_STRING | BASE_DEC, RVALS(&mpls_link_stlv_bcmodel_rvals), 0x0,
3171 {&hf_ospf_filter[OSPFF_LS_OIF_LOCAL_NODE_ID],
3172 { "Local Node ID", "ospf.oif.local_node_id", FT_IPv4,
3173 BASE_NONE, NULL, 0x0, NULL, HFILL }},
3174 {&hf_ospf_filter[OSPFF_LS_OIF_REMOTE_NODE_ID],
3175 { "Remote Node ID", "ospf.oif.remote_node_id", FT_IPv4,
3176 BASE_NONE, NULL, 0x0, NULL, HFILL }},
3178 {&hf_ospf_filter[OSPFF_V2_OPTIONS],
3179 { "Options", "ospf.v2.options", FT_UINT8, BASE_HEX,
3180 NULL, 0x0, NULL, HFILL }},
3181 {&hf_ospf_filter[OSPFF_V2_OPTIONS_MT],
3182 { "MT", "ospf.v2.options.mt", FT_BOOLEAN, 8,
3183 TFS(&tfs_v2_options_mt), OSPF_V2_OPTIONS_MT, "", HFILL }},
3184 {&hf_ospf_filter[OSPFF_V2_OPTIONS_E],
3185 { "E", "ospf.v2.options.e", FT_BOOLEAN, 8,
3186 TFS(&tfs_v2_options_e), OSPF_V2_OPTIONS_E, NULL, HFILL }},
3187 {&hf_ospf_filter[OSPFF_V2_OPTIONS_MC],
3188 { "MC", "ospf.v2.options.mc", FT_BOOLEAN, 8,
3189 TFS(&tfs_v2_options_mc), OSPF_V2_OPTIONS_MC, NULL, HFILL }},
3190 {&hf_ospf_filter[OSPFF_V2_OPTIONS_NP],
3191 { "NP", "ospf.v2.options.np", FT_BOOLEAN, 8,
3192 TFS(&tfs_v2_options_np), OSPF_V2_OPTIONS_NP, NULL, HFILL }},
3193 {&hf_ospf_filter[OSPFF_V2_OPTIONS_L],
3194 { "L", "ospf.v2.options.l", FT_BOOLEAN, 8,
3195 TFS(&tfs_v2_options_l), OSPF_V2_OPTIONS_L, NULL, HFILL }},
3196 {&hf_ospf_filter[OSPFF_V2_OPTIONS_DC],
3197 { "DC", "ospf.v2.options.dc", FT_BOOLEAN, 8,
3198 TFS(&tfs_v2_options_dc), OSPF_V2_OPTIONS_DC, NULL, HFILL }},
3199 {&hf_ospf_filter[OSPFF_V2_OPTIONS_O],
3200 { "O", "ospf.v2.options.o", FT_BOOLEAN, 8,
3201 TFS(&tfs_v2_options_o), OSPF_V2_OPTIONS_O, NULL, HFILL }},
3202 {&hf_ospf_filter[OSPFF_V2_OPTIONS_DN],
3203 { "DN", "ospf.v2.options.dn", FT_BOOLEAN, 8,
3204 TFS(&tfs_v2_options_dn), OSPF_V2_OPTIONS_DN, NULL, HFILL }},
3205 {&hf_ospf_filter[OSPFF_V3_OPTIONS],
3206 { "Options", "ospf.v3.options", FT_UINT24, BASE_HEX,
3207 NULL, 0x0, NULL, HFILL }},
3208 {&hf_ospf_filter[OSPFF_V3_OPTIONS_V6],
3209 { "V6", "ospf.v3.options.v6", FT_BOOLEAN, 24,
3210 TFS(&tfs_v3_options_v6), OSPF_V3_OPTIONS_V6, NULL, HFILL }},
3211 {&hf_ospf_filter[OSPFF_V3_OPTIONS_E],
3212 { "E", "ospf.v3.options.e", FT_BOOLEAN, 24,
3213 TFS(&tfs_v3_options_e), OSPF_V3_OPTIONS_E, NULL, HFILL }},
3214 {&hf_ospf_filter[OSPFF_V3_OPTIONS_MC],
3215 { "MC", "ospf.v3.options.mc", FT_BOOLEAN, 24,
3216 TFS(&tfs_v3_options_mc), OSPF_V3_OPTIONS_MC, NULL, HFILL }},
3217 {&hf_ospf_filter[OSPFF_V3_OPTIONS_N],
3218 { "N", "ospf.v3.options.n", FT_BOOLEAN, 24,
3219 TFS(&tfs_v3_options_n), OSPF_V3_OPTIONS_N, NULL, HFILL }},
3220 {&hf_ospf_filter[OSPFF_V3_OPTIONS_R],
3221 { "R", "ospf.v3.options.r", FT_BOOLEAN, 24,
3222 TFS(&tfs_v3_options_r), OSPF_V3_OPTIONS_R, NULL, HFILL }},
3223 {&hf_ospf_filter[OSPFF_V3_OPTIONS_DC],
3224 { "DC", "ospf.v3.options.dc", FT_BOOLEAN, 24,
3225 TFS(&tfs_v3_options_dc), OSPF_V3_OPTIONS_DC, NULL, HFILL }},
3226 {&hf_ospf_filter[OSPFF_V3_OPTIONS_AF],
3227 { "AF", "ospf.v3.options.af", FT_BOOLEAN, 24,
3228 TFS(&tfs_v3_options_af), OSPF_V3_OPTIONS_AF, NULL, HFILL }},
3229 {&hf_ospf_filter[OSPFF_V3_OPTIONS_L],
3230 { "L", "ospf.v3.options.l", FT_BOOLEAN, 24,
3231 TFS(&tfs_v3_options_l), OSPF_V3_OPTIONS_L, NULL, HFILL }},
3232 {&hf_ospf_filter[OSPFF_V3_OPTIONS_I],
3233 { "I", "ospf.v3.options.i", FT_BOOLEAN, 24,
3234 TFS(&tfs_v3_options_i), OSPF_V3_OPTIONS_I, NULL, HFILL }},
3235 {&hf_ospf_filter[OSPFF_V3_OPTIONS_F],
3236 { "F", "ospf.v3.options.f", FT_BOOLEAN, 24,
3237 TFS(&tfs_v3_options_f), OSPF_V3_OPTIONS_F, NULL, HFILL }},
3238 {&hf_ospf_filter[OSPFF_DBD],
3239 { "DB Description", "ospf.dbd", FT_UINT8, BASE_HEX,
3240 NULL, 0x0, NULL, HFILL }},
3241 {&hf_ospf_filter[OSPFF_DBD_R],
3242 { "R", "ospf.dbd.r", FT_BOOLEAN, 8,
3243 TFS(&tfs_dbd_r), OSPF_DBD_FLAG_R, NULL, HFILL }},
3244 {&hf_ospf_filter[OSPFF_DBD_I],
3245 { "I", "ospf.dbd.i", FT_BOOLEAN, 8,
3246 TFS(&tfs_dbd_i), OSPF_DBD_FLAG_I, NULL, HFILL }},
3247 {&hf_ospf_filter[OSPFF_DBD_M],
3248 { "M", "ospf.dbd.m", FT_BOOLEAN, 8,
3249 TFS(&tfs_dbd_m), OSPF_DBD_FLAG_M, NULL, HFILL }},
3250 {&hf_ospf_filter[OSPFF_DBD_MS],
3251 { "MS", "ospf.dbd.ms", FT_BOOLEAN, 8,
3252 TFS(&tfs_dbd_ms), OSPF_DBD_FLAG_MS, NULL, HFILL }},
3253 {&hf_ospf_filter[OSPFF_LLS_EXT_OPTIONS],
3254 { "Options", "ospf.lls.ext.options", FT_UINT32, BASE_HEX,
3255 NULL, 0x0, NULL, HFILL }},
3256 {&hf_ospf_filter[OSPFF_LLS_EXT_OPTIONS_LR],
3257 { "LR", "ospf.lls.ext.options.lr", FT_BOOLEAN, 32,
3258 TFS(&tfs_lls_ext_options_lr), OSPF_LLS_EXT_OPTIONS_LR, NULL, HFILL }},
3259 {&hf_ospf_filter[OSPFF_LLS_EXT_OPTIONS_RS],
3260 { "RS", "ospf.lls.ext.options.rs", FT_BOOLEAN, 32,
3261 TFS(&tfs_lls_ext_options_rs), OSPF_LLS_EXT_OPTIONS_RS, NULL, HFILL }},
3262 {&hf_ospf_filter[OSPFF_V2_ROUTER_LSA_FLAG],
3263 { "Flags", "ospf.v2.router.lsa.flags", FT_UINT8, BASE_HEX,
3264 NULL, 0x0, NULL, HFILL }},
3265 {&hf_ospf_filter[OSPFF_V2_ROUTER_LSA_FLAG_B],
3266 { "B", "ospf.v2.router.lsa.flags.b", FT_BOOLEAN, 8,
3267 TFS(&tfs_v2_router_lsa_flags_b), OSPF_V2_ROUTER_LSA_FLAG_B, NULL, HFILL }},
3268 {&hf_ospf_filter[OSPFF_V2_ROUTER_LSA_FLAG_E],
3269 { "E", "ospf.v2.router.lsa.flags.e", FT_BOOLEAN, 8,
3270 TFS(&tfs_v2_router_lsa_flags_e), OSPF_V2_ROUTER_LSA_FLAG_E, NULL, HFILL }},
3271 {&hf_ospf_filter[OSPFF_V2_ROUTER_LSA_FLAG_V],
3272 { "V", "ospf.v2.router.lsa.flags.v", FT_BOOLEAN, 8,
3273 TFS(&tfs_v2_router_lsa_flags_v), OSPF_V2_ROUTER_LSA_FLAG_V, NULL, HFILL }},
3274 {&hf_ospf_filter[OSPFF_V2_ROUTER_LSA_FLAG_W],
3275 { "W", "ospf.v2.router.lsa.flags.w", FT_BOOLEAN, 8,
3276 TFS(&tfs_v2_router_lsa_flags_w), OSPF_V2_ROUTER_LSA_FLAG_W, "", HFILL }},
3277 {&hf_ospf_filter[OSPFF_V2_ROUTER_LSA_FLAG_N],
3278 { "N", "ospf.v2.router.lsa.flags.n", FT_BOOLEAN, 8,
3279 TFS(&tfs_v2_router_lsa_flags_n), OSPF_V2_ROUTER_LSA_FLAG_N, "", HFILL }},
3280 {&hf_ospf_filter[OSPFF_V3_ROUTER_LSA_FLAG],
3281 { "Flags", "ospf.v3.router.lsa.flags", FT_UINT8, BASE_HEX,
3282 NULL, 0x0, NULL, HFILL }},
3283 {&hf_ospf_filter[OSPFF_V3_ROUTER_LSA_FLAG_B],
3284 { "B", "ospf.v3.router.lsa.flags.b", FT_BOOLEAN, 8,
3285 TFS(&tfs_v3_router_lsa_flags_b), OSPF_V3_ROUTER_LSA_FLAG_B, NULL, HFILL }},
3286 {&hf_ospf_filter[OSPFF_V3_ROUTER_LSA_FLAG_E],
3287 { "E", "ospf.v3.router.lsa.flags.e", FT_BOOLEAN, 8,
3288 TFS(&tfs_v3_router_lsa_flags_e), OSPF_V3_ROUTER_LSA_FLAG_E, NULL, HFILL }},
3289 {&hf_ospf_filter[OSPFF_V3_ROUTER_LSA_FLAG_V],
3290 { "V", "ospf.v3.router.lsa.flags.v", FT_BOOLEAN, 8,
3291 TFS(&tfs_v3_router_lsa_flags_v), OSPF_V3_ROUTER_LSA_FLAG_V, NULL, HFILL }},
3292 {&hf_ospf_filter[OSPFF_V3_ROUTER_LSA_FLAG_W],
3293 { "W", "ospf.v3.router.lsa.flags.w", FT_BOOLEAN, 8,
3294 TFS(&tfs_v3_router_lsa_flags_w), OSPF_V3_ROUTER_LSA_FLAG_W, NULL, HFILL }},
3295 {&hf_ospf_filter[OSPFF_V3_AS_EXTERNAL_FLAG],
3296 { "Flags", "ospf.v3.as.external.flags", FT_UINT8, BASE_HEX,
3297 NULL, 0x0, NULL, HFILL }},
3298 {&hf_ospf_filter[OSPFF_V3_AS_EXTERNAL_FLAG_T],
3299 { "T", "ospf.v3.as.external.flags.t", FT_BOOLEAN, 8,
3300 TFS(&tfs_v3_as_external_flags_t), OSPF_V3_AS_EXTERNAL_FLAG_T, NULL, HFILL }},
3301 {&hf_ospf_filter[OSPFF_V3_AS_EXTERNAL_FLAG_F],
3302 { "F", "ospf.v3.as.external.flags.f", FT_BOOLEAN, 8,
3303 TFS(&tfs_v3_as_external_flags_f), OSPF_V3_AS_EXTERNAL_FLAG_F, NULL, HFILL }},
3304 {&hf_ospf_filter[OSPFF_V3_AS_EXTERNAL_FLAG_E],
3305 { "E", "ospf.v3.as.external.flags.e", FT_BOOLEAN, 8,
3306 TFS(&tfs_v3_as_external_flags_e), OSPF_V3_AS_EXTERNAL_FLAG_E, NULL, HFILL }},
3307 {&hf_ospf_filter[OSPFF_V3_PREFIX_OPTION],
3308 { "PrefixOptions", "ospf.v3.prefix.options", FT_UINT8, BASE_HEX,
3309 NULL, 0x0, NULL, HFILL }},
3310 {&hf_ospf_filter[OSPFF_V3_PREFIX_OPTION_NU],
3311 { "NU", "ospf.v3.prefix.options.nu", FT_BOOLEAN, 8,
3312 TFS(&tfs_v3_prefix_options_nu), OSPF_V3_PREFIX_OPTION_NU, NULL, HFILL }},
3313 {&hf_ospf_filter[OSPFF_V3_PREFIX_OPTION_LA],
3314 { "LA", "ospf.v3.prefix.options.la", FT_BOOLEAN, 8,
3315 TFS(&tfs_v3_prefix_options_la), OSPF_V3_PREFIX_OPTION_LA, NULL, HFILL }},
3316 {&hf_ospf_filter[OSPFF_V3_PREFIX_OPTION_MC],
3317 { "MC", "ospf.v3.prefix.options.mc", FT_BOOLEAN, 8,
3318 TFS(&tfs_v3_prefix_options_mc), OSPF_V3_PREFIX_OPTION_MC, NULL, HFILL }},
3319 {&hf_ospf_filter[OSPFF_V3_PREFIX_OPTION_P],
3320 { "P", "ospf.v3.prefix.options.p", FT_BOOLEAN, 8,
3321 TFS(&tfs_v3_prefix_options_p), OSPF_V3_PREFIX_OPTION_P, NULL, HFILL }},
3323 /* OSPF Restart TLVs */
3324 {&hf_ospf_filter[OSPFF_V2_GRACE_TLV],
3325 { "Grace TLV", "ospf.v2.grace", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}},
3326 {&hf_ospf_filter[OSPFF_V2_GRACE_PERIOD],
3327 { "Grace Period", "ospf.v2.grace.period", FT_UINT32, BASE_DEC,
3329 "The number of seconds neighbors should advertise the router as fully adjacent",
3331 {&hf_ospf_filter[OSPFF_V2_GRACE_REASON],
3332 { "Restart Reason", "ospf.v2.grace.reason", FT_UINT8, BASE_DEC,
3333 VALS(restart_reason_vals), 0x0, "The reason the router is restarting", HFILL }},
3334 {&hf_ospf_filter[OSPFF_V2_GRACE_IP],
3335 { "Restart IP", "ospf.v2.grace.ip", FT_IPv4, BASE_NONE,
3336 NULL, 0x0, "The IP address of the interface originating this LSA", HFILL }},
3338 /* OSPFv3 LLS TLVs */
3339 {&hf_ospf_filter[OSPFF_V3_LLS_EXT_OPTIONS_TLV],
3340 { "Extended Options TLV", "ospf.v3.lls.ext.options.tlv", FT_NONE, BASE_NONE,
3341 NULL, 0x0, NULL, HFILL }},
3342 {&hf_ospf_filter[OSPFF_V3_LLS_EXT_OPTIONS],
3343 { "Options", "ospf.v3.lls.ext.options", FT_UINT32, BASE_HEX,
3344 NULL, 0x0, NULL, HFILL }},
3345 {&hf_ospf_filter[OSPFF_V3_LLS_EXT_OPTIONS_LR],
3346 { "LR", "ospf.v3.lls.ext.options.lr", FT_BOOLEAN, 32,
3347 TFS(&tfs_v3_lls_ext_options_lr), OSPF_V3_LLS_EXT_OPTIONS_LR, NULL, HFILL }},
3348 {&hf_ospf_filter[OSPFF_V3_LLS_EXT_OPTIONS_RS],
3349 { "RS", "ospf.v3.lls.ext.options.rs", FT_BOOLEAN, 32,
3350 TFS(&tfs_v3_lls_ext_options_rs), OSPF_V3_LLS_EXT_OPTIONS_RS, NULL, HFILL }},
3351 {&hf_ospf_filter[OSPFF_V3_LLS_STATE_TLV],
3352 { "State Check Sequence TLV", "ospf.v3.lls.state.tlv", FT_NONE, BASE_NONE,
3353 NULL, 0x0, NULL, HFILL }},
3354 {&hf_ospf_filter[OSPFF_V3_LLS_STATE_SCS],
3355 { "SCS Number", "ospf.v3.lls.state.scs", FT_UINT16, BASE_DEC,
3356 NULL, 0x0, NULL, HFILL }},
3357 {&hf_ospf_filter[OSPFF_V3_LLS_STATE_OPTIONS],
3358 { "Options", "ospf.v3.lls.state.options", FT_UINT8, BASE_HEX,
3359 NULL, 0x0, NULL, HFILL }},
3360 {&hf_ospf_filter[OSPFF_V3_LLS_STATE_OPTIONS_R],
3361 { "R", "ospf.v3.lls.state.options.r", FT_BOOLEAN, 8,
3362 TFS(&tfs_v3_lls_state_options_r), OSPF_V3_LLS_STATE_OPTIONS_R, NULL, HFILL }},
3363 {&hf_ospf_filter[OSPFF_V3_LLS_STATE_OPTIONS_A],
3364 { "A", "ospf.v3.lls.state.options.a", FT_BOOLEAN, 8,
3365 TFS(&tfs_v3_lls_state_options_a), OSPF_V3_LLS_STATE_OPTIONS_A , NULL, HFILL }},
3366 {&hf_ospf_filter[OSPFF_V3_LLS_STATE_OPTIONS_N],
3367 { "N", "ospf.v3.lls.state.options.n", FT_BOOLEAN, 8,
3368 TFS(&tfs_v3_lls_state_options_n), OSPF_V3_LLS_STATE_OPTIONS_N ,NULL, HFILL }},
3369 {&hf_ospf_filter[OSPFF_V3_LLS_DROP_TLV],
3370 { "Neighbor Drop TLV", "ospf.v3.lls.drop.tlv", FT_NONE, BASE_NONE,
3371 NULL, 0x0, NULL, HFILL }},
3372 {&hf_ospf_filter[OSPFF_V3_LLS_RELAY_TLV],
3373 { "Active Overlapping Relays TLV", "ospf.v3.lls.relay.tlv", FT_NONE, BASE_NONE,
3374 NULL, 0x0, NULL, HFILL }},
3375 {&hf_ospf_filter[OSPFF_V3_LLS_RELAY_ADDED],
3376 { "Relays Added", "ospf.v3.lls.relay.added", FT_UINT8, BASE_DEC,
3377 NULL, 0x0, NULL, HFILL }},
3378 {&hf_ospf_filter[OSPFF_V3_LLS_RELAY_OPTIONS],
3379 { "Options", "ospf.v3.lls.relay.options", FT_UINT8, BASE_HEX,
3380 NULL, 0x0, NULL, HFILL }},
3381 {&hf_ospf_filter[OSPFF_V3_LLS_RELAY_OPTIONS_A],
3382 { "A", "ospf.v3.lls.relay.options.a", FT_BOOLEAN, 8,
3383 TFS(&tfs_v3_lls_relay_options_a), OSPF_V3_LLS_RELAY_OPTIONS_A , NULL, HFILL }},
3384 {&hf_ospf_filter[OSPFF_V3_LLS_RELAY_OPTIONS_N],
3385 { "N", "ospf.v3.lls.relay.options.n", FT_BOOLEAN, 8,
3386 TFS(&tfs_v3_lls_relay_options_n), OSPF_V3_LLS_RELAY_OPTIONS_N ,NULL, HFILL }},
3387 {&hf_ospf_filter[OSPFF_V3_LLS_WILLINGNESS_TLV],
3388 { "Willingness TLV", "ospf.v3.lls.willingness.tlv", FT_NONE, BASE_NONE,
3389 NULL, 0x0, NULL, HFILL }},
3390 {&hf_ospf_filter[OSPFF_V3_LLS_WILLINGNESS],
3391 { "Willingness", "ospf.v3.lls.willingness", FT_UINT8, BASE_DEC,
3392 NULL, 0x0, NULL, HFILL }},
3393 {&hf_ospf_filter[OSPFF_V3_LLS_RF_TLV],
3394 { "Request From TLV", "ospf.v3.lls.rf.tlv", FT_NONE, BASE_NONE,
3395 NULL, 0x0, NULL, HFILL }},
3396 {&hf_ospf_filter[OSPFF_V3_LLS_FSF_TLV],
3397 { "Full State For TLV", "ospf.v3.lls.fsf.tlv", FT_NONE, BASE_NONE,
3398 NULL, 0x0, NULL, HFILL }}
3401 static gint *ett[] = {
3408 &ett_ospf_lsa_router_link,
3411 &ett_ospf_lsa_mpls_router,
3412 &ett_ospf_lsa_mpls_link,
3413 &ett_ospf_lsa_mpls_link_stlv,
3414 &ett_ospf_lsa_mpls_link_stlv_admingrp,
3415 &ett_ospf_lsa_oif_tna,
3416 &ett_ospf_lsa_oif_tna_stlv,
3417 &ett_ospf_lsa_grace_tlv,
3418 &ett_ospf_v2_options,
3419 &ett_ospf_v3_options,
3421 &ett_ospf_lls_data_block,
3423 &ett_ospf_lls_ext_options,
3424 &ett_ospf_v3_lls_ext_options_tlv,
3425 &ett_ospf_v3_lls_ext_options,
3426 &ett_ospf_v3_lls_state_tlv,
3427 &ett_ospf_v3_lls_state_scs,
3428 &ett_ospf_v3_lls_state_options,
3429 &ett_ospf_v3_lls_drop_tlv,
3430 &ett_ospf_v3_lls_relay_tlv,
3431 &ett_ospf_v3_lls_relay_added,
3432 &ett_ospf_v3_lls_relay_options,
3433 &ett_ospf_v3_lls_willingness_tlv,
3434 &ett_ospf_v3_lls_willingness,
3435 &ett_ospf_v3_lls_rf_tlv,
3436 &ett_ospf_v3_lls_fsf_tlv,
3437 &ett_ospf_v2_router_lsa_flags,
3438 &ett_ospf_v3_router_lsa_flags,
3439 &ett_ospf_v3_as_external_flags,
3440 &ett_ospf_v3_prefix_options
3443 proto_ospf = proto_register_protocol("Open Shortest Path First",
3445 proto_register_field_array(proto_ospf, ospff_info, array_length(ospff_info));
3446 proto_register_subtree_array(ett, array_length(ett));
3450 proto_reg_handoff_ospf(void)
3452 dissector_handle_t ospf_handle;
3454 ospf_handle = create_dissector_handle(dissect_ospf, proto_ospf);
3455 dissector_add("ip.proto", IP_PROTO_OSPF, ospf_handle);
3456 data_handle = find_dissector("data");