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 * Added support for OSPF restart signaling:
27 * draft-nguyen-ospf-lls-05.txt
28 * draft-nguyen-ospf-oob-resync-05.txt
29 * draft-nguyen-ospf-restart-05.txt
30 * - (c) 2005 Michael Rozhavsky <mrozhavsky@fortinet.com>
32 * At this time, this module is able to analyze OSPF
33 * packets as specified in RFC2328. MOSPF (RFC1584) and other
34 * OSPF Extensions which introduce new Packet types
35 * (e.g the External Atributes LSA) are not supported.
36 * Furthermore RFC2740 (OSPFv3 - OSPF for IPv6) is now supported
37 * - (c) 2001 Palle Lyckegaard <palle[AT]lyckegaard.dk>
39 * Added support to E-NNI routing (OIF2003.259.02)
40 * - (c) 2004 Roberto Morro <roberto.morro[AT]tilab.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 * TOS - support is not fully implemented
62 #include <epan/packet.h>
63 #include <epan/ipproto.h>
64 #include <epan/in_cksum.h>
65 #include <epan/emem.h>
66 #include <epan/addr_resolv.h>
67 #include "packet-rsvp.h"
69 #define OSPF_VERSION_2 2
70 #define OSPF_VERSION_3 3
73 #define OSPF_VERSION_2_HEADER_LENGTH 24
74 #define OSPF_VERSION_3_HEADER_LENGTH 16
78 #define OSPF_DB_DESC 2
83 static const value_string pt_vals[] = {
84 {OSPF_HELLO, "Hello Packet" },
85 {OSPF_DB_DESC, "DB Descr." },
86 {OSPF_LS_REQ, "LS Request" },
87 {OSPF_LS_UPD, "LS Update" },
88 {OSPF_LS_ACK, "LS Acknowledge" },
92 #define OSPF_AUTH_NONE 0
93 #define OSPF_AUTH_SIMPLE 1
94 #define OSPF_AUTH_CRYPT 2
96 static const value_string auth_vals[] = {
97 {OSPF_AUTH_NONE, "Null" },
98 {OSPF_AUTH_SIMPLE, "Simple password" },
99 {OSPF_AUTH_CRYPT, "Cryptographic" },
103 #define OSPF_V2_OPTIONS_E 0x02
104 #define OSPF_V2_OPTIONS_MC 0x04
105 #define OSPF_V2_OPTIONS_NP 0x08
106 #define OSPF_V2_OPTIONS_L 0x10
107 #define OSPF_V2_OPTIONS_DC 0x20
108 #define OSPF_V2_OPTIONS_O 0x40
109 #define OSPF_V2_OPTIONS_DN 0x80
110 #define OSPF_V3_OPTIONS_V6 0x01
111 #define OSPF_V3_OPTIONS_E 0x02
112 #define OSPF_V3_OPTIONS_MC 0x04
113 #define OSPF_V3_OPTIONS_N 0x08
114 #define OSPF_V3_OPTIONS_R 0x10
115 #define OSPF_V3_OPTIONS_DC 0x20
116 #define OSPF_V3_OPTIONS_AF 0x0100
117 #define OSPF_V3_OPTIONS_L 0x0200
118 #define OSPF_V3_OPTIONS_I 0x0400
119 #define OSPF_V3_OPTIONS_F 0x0800
121 #define OSPF_LLS_EXT_OPTIONS_LR 0x00000001
122 #define OSPF_LLS_EXT_OPTIONS_RS 0x00000002
124 #define OSPF_V3_LLS_EXT_OPTIONS_LR 0x00000001
125 #define OSPF_V3_LLS_EXT_OPTIONS_RS 0x00000002
127 #define OSPF_V3_LLS_STATE_OPTIONS_R 0x80
128 #define OSPF_V3_LLS_STATE_OPTIONS_A 0x40
129 #define OSPF_V3_LLS_STATE_OPTIONS_N 0x20
130 #define OSPF_V3_LLS_RELAY_OPTIONS_A 0x80
131 #define OSPF_V3_LLS_RELAY_OPTIONS_N 0x40
133 #define OSPF_DBD_FLAG_MS 1
134 #define OSPF_DBD_FLAG_M 2
135 #define OSPF_DBD_FLAG_I 4
136 #define OSPF_DBD_FLAG_R 8
138 #define OSPF_LS_REQ_LENGTH 12
140 #define OSPF_LSTYPE_ROUTER 1
141 #define OSPF_LSTYPE_NETWORK 2
142 #define OSPF_LSTYPE_SUMMERY 3
143 #define OSPF_LSTYPE_ASBR 4
144 #define OSPF_LSTYPE_ASEXT 5
145 #define OSPF_LSTYPE_GRPMEMBER 6
146 #define OSPF_LSTYPE_ASEXT7 7
147 #define OSPF_LSTYPE_EXTATTR 8
148 #define OSPF_V3_LSTYPE_ROUTER 0x2001
149 #define OSPF_V3_LSTYPE_NETWORK 0x2002
150 #define OSPF_V3_LSTYPE_INTER_AREA_PREFIX 0x2003
151 #define OSPF_V3_LSTYPE_INTER_AREA_ROUTER 0x2004
152 #define OSPF_V3_LSTYPE_AS_EXTERNAL 0x4005
153 #define OSPF_V3_LSTYPE_GROUP_MEMBERSHIP 0x2006
154 #define OSPF_V3_LSTYPE_TYPE_7 0x2007
155 #define OSPF_V3_LSTYPE_LINK 0x0008
156 #define OSPF_V3_LSTYPE_INTRA_AREA_PREFIX 0x2009
158 /* Opaque LSA types */
159 #define OSPF_LSTYPE_OP_LINKLOCAL 9
160 #define OSPF_LSTYPE_OP_AREALOCAL 10
161 #define OSPF_LSTYPE_OP_ASWIDE 11
163 #define OSPF_LINK_PTP 1
164 #define OSPF_LINK_TRANSIT 2
165 #define OSPF_LINK_STUB 3
166 #define OSPF_LINK_VIRTUAL 4
168 #define OSPF_V3_LINK_PTP 1
169 #define OSPF_V3_LINK_TRANSIT 2
170 #define OSPF_V3_LINK_RESERVED 3
171 #define OSPF_V3_LINK_VIRTUAL 4
173 #define OSPF_LSA_HEADER_LENGTH 20
175 #define OSPF_DNA_LSA 0x8000
176 /* Known opaque LSAs */
177 #define OSPF_LSA_MPLS_TE 1
178 #define OSPF_LSA_GRACE 3
179 #define OSPF_RESTART_REASON_UNKNOWN 0
180 #define OSPF_RESTART_REASON_SWRESTART 1
181 #define OSPF_RESTART_REASON_SWRELOAD 2
182 #define OSPF_RESTART_REASON_SWITCH 3
184 static const value_string restart_reason_vals[] = {
185 {OSPF_RESTART_REASON_UNKNOWN, "Unknown" },
186 {OSPF_RESTART_REASON_SWRESTART, "Software Restart" },
187 {OSPF_RESTART_REASON_SWRELOAD, "Software Reload/Upgrade" },
188 {OSPF_RESTART_REASON_SWITCH, "Processor Switchover" },
192 /* grace-LSA TLV Types */
193 #define GRACE_TLV_PERIOD 1
194 #define GRACE_TLV_REASON 2
195 #define GRACE_TLV_IP 3
197 static const value_string grace_tlv_type_vals[] = {
198 {GRACE_TLV_PERIOD, "grace-LSA Grace Period"},
199 {GRACE_TLV_REASON, "grace-LSA Restart Reason"},
200 {GRACE_TLV_IP, "grace-LSA Restart IP"},
204 static const value_string ls_type_vals[] = {
205 {OSPF_LSTYPE_ROUTER, "Router-LSA" },
206 {OSPF_LSTYPE_NETWORK, "Network-LSA" },
207 {OSPF_LSTYPE_SUMMERY, "Summary-LSA (IP network)" },
208 {OSPF_LSTYPE_ASBR, "Summary-LSA (ASBR)" },
209 {OSPF_LSTYPE_ASEXT, "AS-External-LSA (ASBR)" },
210 {OSPF_LSTYPE_GRPMEMBER, "Group Membership LSA" },
211 {OSPF_LSTYPE_ASEXT7, "NSSA AS-External-LSA" },
212 {OSPF_LSTYPE_EXTATTR, "External Attributes LSA" },
213 {OSPF_LSTYPE_OP_LINKLOCAL, "Opaque LSA, Link-local scope" },
214 {OSPF_LSTYPE_OP_AREALOCAL, "Opaque LSA, Area-local scope" },
219 static const value_string ls_opaque_type_vals[] = {
220 {OSPF_LSA_MPLS_TE, "Traffic Engineering LSA" },
221 {2, "Sycamore Optical Topology Descriptions" },
222 {OSPF_LSA_GRACE, "grace-LSA" },
226 static const value_string v3_ls_type_vals[] = {
227 {OSPF_V3_LSTYPE_ROUTER, "Router-LSA" },
228 {OSPF_V3_LSTYPE_NETWORK, "Network-LSA" },
229 {OSPF_V3_LSTYPE_INTER_AREA_PREFIX, "Inter-Area-Prefix-LSA" },
230 {OSPF_V3_LSTYPE_INTER_AREA_ROUTER, "Inter-Area-Router-LSA" },
231 {OSPF_V3_LSTYPE_AS_EXTERNAL, "AS-External-LSA" },
232 {OSPF_V3_LSTYPE_GROUP_MEMBERSHIP, "Group-Membership-LSA" },
233 {OSPF_V3_LSTYPE_TYPE_7, "Type-LSA" },
234 {OSPF_V3_LSTYPE_LINK, "Link-LSA" },
235 {OSPF_V3_LSTYPE_INTRA_AREA_PREFIX, "Intra-Area-Prefix-LSA" },
240 static const value_string lls_tlv_type_vals[] = {
241 {1, "Extended options TLV" },
242 {2, "Crypto Authentication TLV" },
246 /* OSPFv3 LLS TLV Types */
247 #define LLS_V3_EXT_OPT 1
248 #define LLS_V3_STATE_CHECK 3
249 #define LLS_V3_NBR_DROP 4
250 #define LLS_V3_RELAYS 7
251 #define LLS_V3_WILLING 8
252 #define LLS_V3_RQST_FROM 5
253 #define LLS_V3_FULL_STATE 6
255 static const value_string lls_v3_tlv_type_vals[] = {
256 {LLS_V3_EXT_OPT, "Extended Options TLV" },
257 {LLS_V3_STATE_CHECK, "State Check Sequence TLV" },
258 {LLS_V3_NBR_DROP, "Neighbor Drop TLV" },
259 {LLS_V3_RELAYS, "Active Overlapping Relays TLV" },
260 {LLS_V3_WILLING, "Willingness TLV" },
261 {LLS_V3_RQST_FROM, "Request From LTV" },
262 {LLS_V3_FULL_STATE, "Full State For TLV" },
266 static const value_string mpls_link_stlv_ltype_str[] = {
267 {1, "Point-to-point"},
272 /* FF: from www.iana.org/assignments/bandwidth-constraints-model-ids */
273 static const range_string mpls_link_stlv_bcmodel_rvals[] = {
274 { 0, 0, "(Russian Dolls Model - RDM)" },
275 { 1, 1, "(Maximum Allocation Model - MAM)" },
276 { 2, 2, "(Maximum Allocation with Reservation Model - MAR)" },
277 { 3, 239, "(Unassigned, Specification Required)" },
278 { 240, 255, "(Reserved, Private Use)" },
282 #define OSPF_V2_ROUTER_LSA_FLAG_B 0x01
283 #define OSPF_V2_ROUTER_LSA_FLAG_E 0x02
284 #define OSPF_V2_ROUTER_LSA_FLAG_V 0x04
285 #define OSPF_V3_ROUTER_LSA_FLAG_B 0x01
286 #define OSPF_V3_ROUTER_LSA_FLAG_E 0x02
287 #define OSPF_V3_ROUTER_LSA_FLAG_V 0x04
288 #define OSPF_V3_ROUTER_LSA_FLAG_W 0x08
290 #define OSPF_V3_PREFIX_OPTION_NU 0x01
291 #define OSPF_V3_PREFIX_OPTION_LA 0x02
292 #define OSPF_V3_PREFIX_OPTION_MC 0x04
293 #define OSPF_V3_PREFIX_OPTION_P 0x08
295 #define OSPF_V3_AS_EXTERNAL_FLAG_T 0x01
296 #define OSPF_V3_AS_EXTERNAL_FLAG_F 0x02
297 #define OSPF_V3_AS_EXTERNAL_FLAG_E 0x04
300 static int proto_ospf = -1;
302 static gint ett_ospf = -1;
303 static gint ett_ospf_hdr = -1;
304 static gint ett_ospf_hello = -1;
305 static gint ett_ospf_desc = -1;
306 static gint ett_ospf_lsr = -1;
307 static gint ett_ospf_lsa = -1;
308 static gint ett_ospf_lsa_router_link = -1;
309 static gint ett_ospf_lsa_upd = -1;
310 static gint ett_ospf_v2_options = -1;
311 static gint ett_ospf_v3_options = -1;
312 static gint ett_ospf_dbd = -1;
313 static gint ett_ospf_lls_data_block = -1;
314 static gint ett_ospf_lls_tlv = -1;
315 static gint ett_ospf_lls_ext_options = -1;
316 static gint ett_ospf_v3_lls_ext_options_tlv = -1;
317 static gint ett_ospf_v3_lls_ext_options = -1;
318 static gint ett_ospf_v3_lls_state_tlv = -1;
319 static gint ett_ospf_v3_lls_state_scs = -1;
320 static gint ett_ospf_v3_lls_state_options = -1;
321 static gint ett_ospf_v3_lls_drop_tlv = -1;
322 static gint ett_ospf_v3_lls_relay_tlv = -1;
323 static gint ett_ospf_v3_lls_relay_added = -1;
324 static gint ett_ospf_v3_lls_relay_options = -1;
325 static gint ett_ospf_v3_lls_willingness_tlv = -1;
326 static gint ett_ospf_v3_lls_willingness = -1;
327 static gint ett_ospf_v3_lls_rf_tlv = -1;
328 static gint ett_ospf_v3_lls_fsf_tlv = -1;
329 static gint ett_ospf_v2_router_lsa_flags = -1;
330 static gint ett_ospf_v3_router_lsa_flags = -1;
331 static gint ett_ospf_v3_as_external_flags = -1;
332 static gint ett_ospf_v3_prefix_options = -1;
334 /* Trees for opaque LSAs */
335 static gint ett_ospf_lsa_mpls = -1;
336 static gint ett_ospf_lsa_mpls_router = -1;
337 static gint ett_ospf_lsa_mpls_link = -1;
338 static gint ett_ospf_lsa_mpls_link_stlv = -1;
339 static gint ett_ospf_lsa_mpls_link_stlv_admingrp = -1;
340 static gint ett_ospf_lsa_oif_tna = -1;
341 static gint ett_ospf_lsa_oif_tna_stlv = -1;
342 static gint ett_ospf_lsa_grace_tlv = -1;
346 static const true_false_string tfs_v2_options_dc = {
347 "Demand Circuits are supported",
348 "Demand circuits are NOT supported"
350 static const true_false_string tfs_v2_options_l = {
351 "The packet contains LLS data block",
352 "The packet does NOT contain LLS data block"
354 static const true_false_string tfs_v2_options_np = {
356 "Nssa is NOT supported"
358 static const true_false_string tfs_v2_options_mc = {
360 "NOT multicast capable"
362 static const true_false_string tfs_v2_options_e = {
363 "ExternalRoutingCapability",
364 "NO ExternalRoutingCapability"
366 static const true_false_string tfs_v2_options_o = {
370 static const true_false_string tfs_v2_options_dn = {
374 static const true_false_string tfs_v3_options_v6 = {
378 static const true_false_string tfs_v3_options_e = {
382 static const true_false_string tfs_v3_options_mc = {
386 static const true_false_string tfs_v3_options_n = {
390 static const true_false_string tfs_v3_options_r = {
394 static const true_false_string tfs_v3_options_dc = {
398 static const true_false_string tfs_v3_options_af = {
402 static const true_false_string tfs_v3_options_l = {
406 static const true_false_string tfs_v3_options_i = {
410 static const true_false_string tfs_v3_options_f = {
414 static const true_false_string tfs_dbd_i = {
416 "Init bit is NOT set"
418 static const true_false_string tfs_dbd_m = {
420 "More bit is NOT set"
422 static const true_false_string tfs_dbd_ms = {
423 "Master/Slave bit is SET",
424 "Master/Slave bit is NOT set"
426 static const true_false_string tfs_dbd_r = {
427 "OOBResync bit is SET",
428 "OOBResync bit is NOT set"
430 static const true_false_string tfs_lls_ext_options_lr = {
431 "LSDB Resynchronization (LR-bit) is SET",
432 "LSDB Resynchronization (LR-bit) is NOT set"
434 static const true_false_string tfs_lls_ext_options_rs = {
435 "Restart Signal (RS-bit) is SET",
436 "Restart Signal (RS-bit) is NOT set"
438 static const true_false_string tfs_v3_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_v3_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_state_options_r = {
447 "Request (R-bit) is SET",
448 "Request (R-bit) is NOT set",
450 static const true_false_string tfs_v3_lls_state_options_a = {
451 "Answer (A-bit) is SET",
452 "Answer (A-bit) is NOT set",
454 static const true_false_string tfs_v3_lls_state_options_n = {
455 "Incomplete (N-bit) is SET",
456 "Incomplete (N-bit) is NOT set",
458 static const true_false_string tfs_v3_lls_relay_options_a = {
459 "Answer (A-bit) is SET",
460 "Answer (A-bit) is NOT set",
462 static const true_false_string tfs_v3_lls_relay_options_n = {
463 "Incomplete (N-bit) is SET",
464 "Incomplete (N-bit) is NOT set",
466 static const true_false_string tfs_v2_router_lsa_flags_b = {
467 "Area border router",
468 "NO Area border router"
470 static const true_false_string tfs_v2_router_lsa_flags_e = {
471 "AS boundary router",
472 "NO AS boundary router"
474 static const true_false_string tfs_v2_router_lsa_flags_v = {
475 "Virtual link endpoint",
476 "NO Virtual link endpoint"
478 static const true_false_string tfs_v3_router_lsa_flags_b = {
479 "Area border router",
480 "NO Area border router"
482 static const true_false_string tfs_v3_router_lsa_flags_e = {
483 "AS boundary router",
484 "NO AS boundary router"
486 static const true_false_string tfs_v3_router_lsa_flags_v = {
487 "Virtual link endpoint",
488 "NO Virtual link endpoint"
490 static const true_false_string tfs_v3_router_lsa_flags_w = {
491 "Wild-card multicast receiver",
492 "NO Wild-card multicast receiver"
494 static const true_false_string tfs_v3_as_external_flags_t = {
495 "External Route Tag is included",
496 "External Route Tag is NOT included"
498 static const true_false_string tfs_v3_as_external_flags_f = {
499 "Forwarding Address is included",
500 "Forwarding Address is NOT included"
502 static const true_false_string tfs_v3_as_external_flags_e = {
503 "Type 2 external metric",
504 "Type 1 external metric"
506 static const true_false_string tfs_v3_prefix_options_nu = {
507 "NoUnicast capability bit is SET",
508 "NoUnicast capability bit is NOT set"
510 static const true_false_string tfs_v3_prefix_options_la = {
511 "LocalAddress capability bit is SET",
512 "LocalAddress capability bit is NOT set"
514 static const true_false_string tfs_v3_prefix_options_mc = {
515 "Multicast capability bit is SET",
516 "Multicast capability bit is NOT set"
518 static const true_false_string tfs_v3_prefix_options_p = {
519 "Propagate bit is SET",
520 "Propagate bit is NOT set"
523 /*-----------------------------------------------------------------------
525 *-----------------------------------------------------------------------*/
527 /* The OSPF filtering keys */
540 OSPFF_LS_OPAQUE_TYPE,
542 OSPFF_LS_MPLS_TE_INSTANCE,
558 OSPFF_LS_MPLS_ROUTERID,
560 OSPFF_LS_MPLS_LINKTYPE,
561 OSPFF_LS_MPLS_LINKID,
562 OSPFF_LS_MPLS_LOCAL_ADDR,
563 OSPFF_LS_MPLS_REMOTE_ADDR,
564 OSPFF_LS_MPLS_LOCAL_IFID,
565 OSPFF_LS_MPLS_REMOTE_IFID,
566 OSPFF_LS_MPLS_LINKCOLOR,
567 OSPFF_LS_MPLS_BC_MODEL_ID,
568 OSPFF_LS_OIF_LOCAL_NODE_ID,
569 OSPFF_LS_OIF_REMOTE_NODE_ID,
595 OSPFF_LLS_EXT_OPTIONS_TLV,
596 OSPFF_LLS_EXT_OPTIONS,
597 OSPFF_LLS_EXT_OPTIONS_LR,
598 OSPFF_LLS_EXT_OPTIONS_RS,
599 OSPFF_V3_LLS_EXT_OPTIONS_TLV,
600 OSPFF_V3_LLS_EXT_OPTIONS,
601 OSPFF_V3_LLS_EXT_OPTIONS_LR,
602 OSPFF_V3_LLS_EXT_OPTIONS_RS,
603 OSPFF_V3_LLS_STATE_TLV,
604 OSPFF_V3_LLS_STATE_SCS,
605 OSPFF_V3_LLS_STATE_OPTIONS,
606 OSPFF_V3_LLS_STATE_OPTIONS_R,
607 OSPFF_V3_LLS_STATE_OPTIONS_A,
608 OSPFF_V3_LLS_STATE_OPTIONS_N,
609 OSPFF_V3_LLS_DROP_TLV,
610 OSPFF_V3_LLS_RELAY_TLV,
611 OSPFF_V3_LLS_RELAY_ADDED,
612 OSPFF_V3_LLS_RELAY_OPTIONS,
613 OSPFF_V3_LLS_RELAY_OPTIONS_A,
614 OSPFF_V3_LLS_RELAY_OPTIONS_N,
615 OSPFF_V3_LLS_WILLINGNESS_TLV,
616 OSPFF_V3_LLS_WILLINGNESS,
618 OSPFF_V3_LLS_FSF_TLV,
619 OSPFF_V2_ROUTER_LSA_FLAG,
620 OSPFF_V2_ROUTER_LSA_FLAG_B,
621 OSPFF_V2_ROUTER_LSA_FLAG_E,
622 OSPFF_V2_ROUTER_LSA_FLAG_V,
623 OSPFF_V3_ROUTER_LSA_FLAG,
624 OSPFF_V3_ROUTER_LSA_FLAG_B,
625 OSPFF_V3_ROUTER_LSA_FLAG_E,
626 OSPFF_V3_ROUTER_LSA_FLAG_V,
627 OSPFF_V3_ROUTER_LSA_FLAG_W,
628 OSPFF_V3_AS_EXTERNAL_FLAG,
629 OSPFF_V3_AS_EXTERNAL_FLAG_T,
630 OSPFF_V3_AS_EXTERNAL_FLAG_F,
631 OSPFF_V3_AS_EXTERNAL_FLAG_E,
632 OSPFF_V3_PREFIX_OPTION,
633 OSPFF_V3_PREFIX_OPTION_NU,
634 OSPFF_V3_PREFIX_OPTION_LA,
635 OSPFF_V3_PREFIX_OPTION_MC,
636 OSPFF_V3_PREFIX_OPTION_P,
639 OSPFF_V2_GRACE_PERIOD,
640 OSPFF_V2_GRACE_REASON,
646 static int ospf_filter[OSPFF_MAX];
648 static gint ospf_msg_type_to_filter (guint8 msg_type)
650 if (msg_type >= OSPF_HELLO &&
651 msg_type <= OSPF_LS_ACK)
652 return msg_type + OSPFF_MSG_MIN;
656 static gint ospf_ls_type_to_filter (guint8 ls_type)
658 if (ls_type >= OSPF_LSTYPE_ROUTER &&
659 ls_type <= OSPF_LSTYPE_EXTATTR)
660 return OSPFF_LS_MIN + ls_type;
661 else if (ls_type >= OSPF_LSTYPE_OP_LINKLOCAL &&
662 ls_type <= OSPF_LSTYPE_OP_ASWIDE)
663 return OSPFF_LS_OPAQUE;
668 typedef struct _bitfield_info {
675 static int bf_dbd[] = {
681 static int bf_lls_ext_options[] = {
682 OSPFF_LLS_EXT_OPTIONS_RS,
683 OSPFF_LLS_EXT_OPTIONS_LR
685 static int bf_v3_lls_ext_options[] = {
686 OSPFF_V3_LLS_EXT_OPTIONS_LR,
687 OSPFF_V3_LLS_EXT_OPTIONS_RS
690 static int bf_v3_lls_state_options[] = {
691 OSPFF_V3_LLS_STATE_OPTIONS_R,
692 OSPFF_V3_LLS_STATE_OPTIONS_A,
693 OSPFF_V3_LLS_STATE_OPTIONS_N
695 static int bf_v3_lls_relay_options[] = {
696 OSPFF_V3_LLS_RELAY_OPTIONS_A,
697 OSPFF_V3_LLS_RELAY_OPTIONS_N
699 static int bf_v2_router_lsa_flags[] = {
700 OSPFF_V2_ROUTER_LSA_FLAG_V,
701 OSPFF_V2_ROUTER_LSA_FLAG_E,
702 OSPFF_V2_ROUTER_LSA_FLAG_B
704 static int bf_v3_router_lsa_flags[] = {
705 OSPFF_V3_ROUTER_LSA_FLAG_W,
706 OSPFF_V3_ROUTER_LSA_FLAG_V,
707 OSPFF_V3_ROUTER_LSA_FLAG_E,
708 OSPFF_V3_ROUTER_LSA_FLAG_B
710 static int bf_v3_as_external_flags[] = {
711 OSPFF_V3_AS_EXTERNAL_FLAG_E,
712 OSPFF_V3_AS_EXTERNAL_FLAG_F,
713 OSPFF_V3_AS_EXTERNAL_FLAG_T
715 static int bf_v2_options[] = {
724 static int bf_v3_options[] = {
736 static int bf_v3_prefix_options[] = {
737 OSPFF_V3_PREFIX_OPTION_P,
738 OSPFF_V3_PREFIX_OPTION_MC,
739 OSPFF_V3_PREFIX_OPTION_LA,
740 OSPFF_V3_PREFIX_OPTION_NU
743 static bitfield_info bfinfo_dbd = {
744 OSPFF_DBD, &ett_ospf_dbd,
745 bf_dbd, array_length(bf_dbd)
747 static bitfield_info bfinfo_lls_ext_options = {
748 OSPFF_LLS_EXT_OPTIONS, &ett_ospf_lls_ext_options,
749 bf_lls_ext_options, array_length(bf_lls_ext_options)
751 static bitfield_info bfinfo_v3_lls_ext_options = {
752 OSPFF_V3_LLS_EXT_OPTIONS, &ett_ospf_v3_lls_ext_options,
753 bf_v3_lls_ext_options, array_length(bf_v3_lls_ext_options)
755 static bitfield_info bfinfo_v3_lls_state_options = {
756 OSPFF_V3_LLS_STATE_OPTIONS, &ett_ospf_v3_lls_state_options,
757 bf_v3_lls_state_options, array_length(bf_v3_lls_state_options)
759 static bitfield_info bfinfo_v3_lls_relay_options = {
760 OSPFF_V3_LLS_RELAY_OPTIONS, &ett_ospf_v3_lls_relay_options,
761 bf_v3_lls_relay_options, array_length(bf_v3_lls_relay_options)
763 static bitfield_info bfinfo_v2_router_lsa_flags = {
764 OSPFF_V2_ROUTER_LSA_FLAG, &ett_ospf_v2_router_lsa_flags,
765 bf_v2_router_lsa_flags, array_length(bf_v2_router_lsa_flags)
767 static bitfield_info bfinfo_v3_router_lsa_flags = {
768 OSPFF_V3_ROUTER_LSA_FLAG, &ett_ospf_v3_router_lsa_flags,
769 bf_v3_router_lsa_flags, array_length(bf_v3_router_lsa_flags)
771 static bitfield_info bfinfo_v3_as_external_flags = {
772 OSPFF_V3_AS_EXTERNAL_FLAG, &ett_ospf_v3_as_external_flags,
773 bf_v3_as_external_flags, array_length(bf_v3_as_external_flags)
775 static bitfield_info bfinfo_v2_options = {
776 OSPFF_V2_OPTIONS, &ett_ospf_v2_options,
777 bf_v2_options, array_length(bf_v2_options)
779 static bitfield_info bfinfo_v3_options = {
780 OSPFF_V3_OPTIONS, &ett_ospf_v3_options,
781 bf_v3_options, array_length(bf_v3_options)
783 static bitfield_info bfinfo_v3_prefix_options = {
784 OSPFF_V3_PREFIX_OPTION, &ett_ospf_v3_prefix_options,
785 bf_v3_prefix_options, array_length(bf_v3_prefix_options)
788 #define MAX_OPTIONS_LEN 128
790 dissect_ospf_bitfield (proto_tree *parent_tree, tvbuff_t *tvb, int offset,
791 bitfield_info *bfinfo)
793 proto_item *item = NULL;
794 proto_tree *tree = NULL;
799 header_field_info *hfinfo;
801 gint returned_length;
803 hfindex = ospf_filter[bfinfo->hfindex];
804 hfinfo = proto_registrar_get_nth(hfindex);
805 switch (hfinfo->type) {
807 flags = tvb_get_guint8(tvb, offset);
811 flags = tvb_get_ntohs(tvb, offset);
815 flags = tvb_get_ntoh24(tvb, offset);
819 flags = tvb_get_ntohl(tvb, offset);
827 item = proto_tree_add_uint(parent_tree, hfindex, tvb, offset, length, flags);
828 tree = proto_item_add_subtree(item, *bfinfo->ett);
830 str = ep_alloc(MAX_OPTIONS_LEN);
832 for (i = 0, pos = 0; i < bfinfo->num; i++) {
833 index = ospf_filter[bfinfo->index[i]];
834 hfinfo = proto_registrar_get_nth(index);
835 if (flags & hfinfo->bitmask) {
836 returned_length = g_snprintf(&str[pos], MAX_OPTIONS_LEN-pos, "%s%s",
839 pos += MIN(returned_length, MAX_OPTIONS_LEN-pos);
841 proto_tree_add_boolean(tree, index, tvb, offset, length, flags);
843 proto_item_append_text(item, " (%s)", str);
847 static dissector_handle_t data_handle;
849 static void dissect_ospf_hello(tvbuff_t*, int, proto_tree*, guint8, guint16);
850 static void dissect_ospf_db_desc(tvbuff_t*, int, proto_tree*, guint8, guint16, guint8);
851 static void dissect_ospf_ls_req(tvbuff_t*, int, proto_tree*, guint8, guint16);
852 static void dissect_ospf_ls_upd(tvbuff_t*, int, proto_tree*, guint8, guint16, guint8);
853 static void dissect_ospf_ls_ack(tvbuff_t*, int, proto_tree*, guint8, guint16, guint8);
854 static void dissect_ospf_lls_data_block(tvbuff_t*, int, proto_tree*, guint8);
856 /* dissect_ospf_v[23]lsa returns the offset of the next LSA
857 * if disassemble_body is set to FALSE (e.g. in LSA ACK
858 * packets), the offset is set to the offset of the next
861 static int dissect_ospf_v2_lsa(tvbuff_t*, int, proto_tree*, gboolean disassemble_body);
862 static int dissect_ospf_v3_lsa(tvbuff_t*, int, proto_tree*, gboolean disassemble_body,
865 static void dissect_ospf_v3_address_prefix(tvbuff_t *, int, int, proto_tree *, guint8);
868 ospf_has_lls_block(tvbuff_t *tvb, int offset, guint8 packet_type, guint8 version)
873 /* LLS block can be found only in HELLO and DBDESC packets */
874 switch (packet_type) {
878 flags = tvb_get_guint8 (tvb, offset + 6);
879 return flags & OSPF_V2_OPTIONS_L;
881 v3flags = tvb_get_ntohl(tvb, offset + 5);
882 v3flags = v3flags >> 8;
883 return v3flags & OSPF_V3_OPTIONS_L;
888 flags = tvb_get_guint8 (tvb, offset + 2);
889 return flags & OSPF_V2_OPTIONS_L;
891 v3flags = tvb_get_ntohl(tvb, offset + 1);
892 v3flags = v3flags >> 8;
893 return v3flags & OSPF_V3_OPTIONS_L;
901 dissect_ospf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
903 proto_tree *ospf_tree = NULL;
904 proto_item *ti, *hidden_item;
905 proto_tree *ospf_header_tree;
912 guint16 cksum, computed_cksum;
913 guint length, reported_length;
917 unsigned int ospf_header_length;
921 guint8 address_family = OSPF_AF_6;
923 col_set_str(pinfo->cinfo, COL_PROTOCOL, "OSPF");
924 col_clear(pinfo->cinfo, COL_INFO);
926 version = tvb_get_guint8(tvb, 0);
929 ospf_header_length = OSPF_VERSION_2_HEADER_LENGTH;
932 ospf_header_length = OSPF_VERSION_3_HEADER_LENGTH;
935 ospf_header_length = 14;
939 packet_type = tvb_get_guint8(tvb, 1);
940 if (check_col(pinfo->cinfo, COL_INFO)) {
941 col_add_str(pinfo->cinfo, COL_INFO,
942 val_to_str(packet_type, pt_vals, "Unknown (%u)"));
946 ospflen = tvb_get_ntohs(tvb, 2);
948 ti = proto_tree_add_item(tree, proto_ospf, tvb, 0, -1, FALSE);
949 ospf_tree = proto_item_add_subtree(ti, ett_ospf);
951 ti = proto_tree_add_text(ospf_tree, tvb, 0, ospf_header_length,
953 ospf_header_tree = proto_item_add_subtree(ti, ett_ospf_hdr);
955 proto_tree_add_text(ospf_header_tree, tvb, 0, 1, "OSPF Version: %u",
957 proto_tree_add_item(ospf_header_tree, ospf_filter[OSPFF_MSG_TYPE],
959 if (ospf_msg_type_to_filter(packet_type) != -1) {
960 hidden_item = proto_tree_add_item(ospf_header_tree,
961 ospf_filter[ospf_msg_type_to_filter(packet_type)],
963 PROTO_ITEM_SET_HIDDEN(hidden_item);
965 proto_tree_add_text(ospf_header_tree, tvb, 2, 2, "Packet Length: %u",
967 proto_tree_add_item(ospf_header_tree, ospf_filter[OSPFF_SRC_ROUTER],
969 areaid=tvb_get_ntohl(tvb,8);
970 proto_tree_add_text(ospf_header_tree, tvb, 8, 4, "Area ID: %s%s",
971 ip_to_str(tvb_get_ptr(tvb, 8, 4)), areaid == 0 ? " (Backbone)" : "");
974 * Quit at this point if it's an unknown OSPF version.
983 cksum = tvb_get_ntohs(tvb, 12);
985 /* No checksum supplied in the packet. */
986 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
987 "Packet Checksum: 0x%04x (none)", cksum);
989 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
990 "Packet Checksum: 0x%04x", cksum);
992 proto_tree_add_text(ospf_tree, tvb, 14, -1,
993 "Unknown OSPF version %u", version);
997 cksum = tvb_get_ntohs(tvb, 12);
998 length = tvb_length(tvb);
999 /* XXX - include only the length from the OSPF header? */
1000 reported_length = tvb_reported_length(tvb);
1002 /* No checksum supplied in the packet. */
1003 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
1004 "Packet Checksum: 0x%04x (none)", cksum);
1005 } else if (!pinfo->fragmented && length >= reported_length
1006 && length >= ospf_header_length) {
1007 /* The packet isn't part of a fragmented datagram and isn't
1008 truncated, so we can checksum it. */
1012 case OSPF_VERSION_2:
1013 /* Header, not including the authentication data (the OSPFv2
1014 checksum excludes the 64-bit authentication field). */
1015 cksum_vec[0].ptr = tvb_get_ptr(tvb, 0, 16);
1016 cksum_vec[0].len = 16;
1017 if (length > ospf_header_length) {
1018 /* Rest of the packet, again not including the
1019 authentication data. */
1020 reported_length -= ospf_header_length;
1021 cksum_vec[1].ptr = tvb_get_ptr(tvb, ospf_header_length, reported_length);
1022 cksum_vec[1].len = reported_length;
1025 /* There's nothing but a header. */
1030 case OSPF_VERSION_3:
1031 /* IPv6-style checksum, covering the entire OSPF packet
1032 and a prepended IPv6 pseudo-header. */
1034 /* Set up the fields of the pseudo-header. */
1035 cksum_vec[0].ptr = pinfo->src.data;
1036 cksum_vec[0].len = pinfo->src.len;
1037 cksum_vec[1].ptr = pinfo->dst.data;
1038 cksum_vec[1].len = pinfo->dst.len;
1039 cksum_vec[2].ptr = (const guint8 *)&phdr;
1040 phdr[0] = g_htonl(ospflen);
1041 phdr[1] = g_htonl(IP_PROTO_OSPF);
1042 cksum_vec[2].len = 8;
1044 cksum_vec[3].ptr = tvb_get_ptr(tvb, 0, reported_length);
1045 cksum_vec[3].len = reported_length;
1050 DISSECTOR_ASSERT_NOT_REACHED();
1054 computed_cksum = in_cksum(cksum_vec, cksum_vec_len);
1055 if (computed_cksum == 0) {
1056 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
1057 "Packet Checksum: 0x%04x [correct]", cksum);
1059 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
1060 "Packet Checksum: 0x%04x [incorrect, should be 0x%04x]",
1061 cksum, in_cksum_shouldbe(cksum, computed_cksum));
1064 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
1065 "Packet Checksum: 0x%04x", cksum);
1071 case OSPF_VERSION_2:
1072 /* Authentication is only valid for OSPFv2 */
1073 auth_type = tvb_get_ntohs(tvb, 14);
1074 proto_tree_add_text(ospf_header_tree, tvb, 14, 2, "Auth Type: %s",
1075 val_to_str(auth_type, auth_vals, "Unknown (%u)"));
1076 switch (auth_type) {
1078 case OSPF_AUTH_NONE:
1079 proto_tree_add_text(ospf_header_tree, tvb, 16, 8, "Auth Data (none)");
1082 case OSPF_AUTH_SIMPLE:
1083 tvb_get_nstringz0(tvb, 16, 8+1, auth_data);
1084 proto_tree_add_text(ospf_header_tree, tvb, 16, 8, "Auth Data: %s", auth_data);
1087 case OSPF_AUTH_CRYPT:
1088 proto_tree_add_text(ospf_header_tree, tvb, 18, 1, "Auth Key ID: %u",
1089 tvb_get_guint8(tvb, 18));
1090 crypto_len = tvb_get_guint8(tvb, 19);
1091 proto_tree_add_text(ospf_header_tree, tvb, 19, 1, "Auth Data Length: %u",
1093 proto_tree_add_text(ospf_header_tree, tvb, 20, 4, "Auth Crypto Sequence Number: 0x%x",
1094 tvb_get_ntohl(tvb, 20));
1096 /* Show the message digest that was appended to the end of the
1097 OSPF message - but only if it's present (we don't want
1098 to get an exception before we've tried dissecting OSPF
1100 if (tvb_bytes_exist(tvb, ospflen, crypto_len)) {
1101 proto_tree_add_text(ospf_header_tree, tvb, ospflen, crypto_len,
1103 tvb_bytes_to_str(tvb, ospflen, crypto_len));
1104 proto_tree_set_appendix(ospf_header_tree, tvb, ospflen, crypto_len);
1109 proto_tree_add_text(ospf_header_tree, tvb, 16, 8, "Auth Data (unknown)");
1114 case OSPF_VERSION_3:
1115 /* Instance ID and "reserved" is OSPFv3-only */
1116 instance_ID = tvb_get_guint8(tvb, 14);
1117 ti = proto_tree_add_text(ospf_header_tree, tvb, 14, 1, "Instance ID: %u",
1120 if (instance_ID < 32) {
1121 proto_item_append_text(ti, " (IPv6 unicast AF)");
1122 address_family = OSPF_AF_6;
1123 } else if (instance_ID < 64) {
1124 proto_item_append_text(ti, " (IPv6 multicast AF)");
1125 address_family = OSPF_AF_6;
1126 } else if (instance_ID < 96) {
1127 proto_item_append_text(ti, " (IPv4 unicast AF)");
1128 address_family = OSPF_AF_4;
1129 } else if (instance_ID < 128) {
1130 proto_item_append_text(ti, " (IPv4 multicast AF)");
1131 address_family = OSPF_AF_4;
1133 proto_item_append_text(ti, " (Reserved)");
1134 address_family = OSPF_AF_6;
1137 reserved = tvb_get_guint8(tvb, 15);
1138 proto_tree_add_text(ospf_header_tree, tvb, 15, 1, (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),
1143 switch (packet_type){
1146 dissect_ospf_hello(tvb, ospf_header_length, ospf_tree, version,
1147 (guint16)(ospflen - ospf_header_length));
1151 dissect_ospf_db_desc(tvb, (int)ospf_header_length, ospf_tree, version,
1152 (guint16)(ospflen - ospf_header_length),
1157 dissect_ospf_ls_req(tvb, (int)ospf_header_length, ospf_tree, version,
1158 (guint16)(ospflen - ospf_header_length));
1162 dissect_ospf_ls_upd(tvb, (int)ospf_header_length, ospf_tree, version,
1163 (guint16)(ospflen - ospf_header_length),
1168 dissect_ospf_ls_ack(tvb, (int)ospf_header_length, ospf_tree, version,
1169 (guint16)(ospflen - ospf_header_length),
1174 call_dissector(data_handle,
1175 tvb_new_subset(tvb, ospf_header_length, -1, -1), pinfo, tree);
1179 /* take care of the LLS data block */
1180 if (ospf_has_lls_block(tvb, ospf_header_length, packet_type, version)) {
1181 dissect_ospf_lls_data_block(tvb, ospflen + crypto_len, ospf_tree,
1188 dissect_ospfv2_lls_tlv(tvbuff_t *tvb, int offset, proto_tree *tree)
1191 proto_tree *ospf_lls_tlv_tree;
1195 type = tvb_get_ntohs(tvb, offset);
1196 length = tvb_get_ntohs(tvb, offset + 2);
1198 ti = proto_tree_add_text(tree, tvb, offset, length + 4, "%s",
1199 val_to_str(type, lls_tlv_type_vals, "Unknown TLV"));
1200 ospf_lls_tlv_tree = proto_item_add_subtree(ti, ett_ospf_lls_tlv);
1202 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset, 2,
1204 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset + 2, 2,
1205 "Length: %d", length);
1209 dissect_ospf_bitfield(ospf_lls_tlv_tree, tvb, offset + 4, &bfinfo_lls_ext_options);
1212 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset + 4, 4,
1213 "Sequence number 0x%08x",
1214 tvb_get_ntohl(tvb, offset + 4));
1215 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset + 8, length - 4,
1217 tvb_bytes_to_str(tvb, offset + 8, length - 4));
1221 return offset + length + 4;
1225 dissect_ospfv3_lls_tlv(tvbuff_t *tvb, int offset, proto_tree *tree)
1228 proto_tree *ospf_lls_tlv_tree;
1231 guint8 relays_added;
1234 type = tvb_get_ntohs(tvb, offset);
1235 length = tvb_get_ntohs(tvb, offset + 2);
1238 case LLS_V3_EXT_OPT:
1239 ti = proto_tree_add_item(tree, ospf_filter[OSPFF_V3_LLS_EXT_OPTIONS_TLV], tvb,
1240 offset, length + 4, FALSE);
1242 case LLS_V3_STATE_CHECK:
1243 ti = proto_tree_add_item(tree, ospf_filter[OSPFF_V3_LLS_STATE_TLV], tvb,
1244 offset, length + 4, FALSE);
1246 case LLS_V3_NBR_DROP:
1247 ti = proto_tree_add_item(tree, ospf_filter[OSPFF_V3_LLS_DROP_TLV], tvb,
1248 offset, length + 4, FALSE);
1251 ti = proto_tree_add_item(tree, ospf_filter[OSPFF_V3_LLS_RELAY_TLV], tvb,
1252 offset, length + 4, FALSE);
1254 case LLS_V3_WILLING:
1255 ti = proto_tree_add_item(tree, ospf_filter[OSPFF_V3_LLS_WILLINGNESS_TLV], tvb,
1256 offset, length + 4, FALSE);
1258 case LLS_V3_RQST_FROM:
1259 ti = proto_tree_add_item(tree, ospf_filter[OSPFF_V3_LLS_RF_TLV], tvb,
1260 offset, length + 4, FALSE);
1262 case LLS_V3_FULL_STATE:
1263 ti = proto_tree_add_item(tree, ospf_filter[OSPFF_V3_LLS_FSF_TLV], tvb,
1264 offset, length + 4, FALSE);
1267 ti = proto_tree_add_text(tree, tvb, offset, length + 4, "%s",
1268 val_to_str(type, lls_v3_tlv_type_vals, "Unknown TLV"));
1271 ospf_lls_tlv_tree = proto_item_add_subtree(ti, ett_ospf_lls_tlv);
1272 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset, 2,
1274 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset + 2, 2,
1275 "Length: %d", length);
1277 orig_offset = offset;
1280 case LLS_V3_EXT_OPT:
1281 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset + 4, 4,
1282 "Extended Options: 0x%08x",
1283 tvb_get_ntohl(tvb, offset + 4));
1285 dissect_ospf_bitfield(ospf_lls_tlv_tree, tvb, offset + 4, &bfinfo_v3_lls_ext_options);
1287 case LLS_V3_STATE_CHECK:
1288 proto_tree_add_item(ospf_lls_tlv_tree, ospf_filter[OSPFF_V3_LLS_STATE_SCS],
1289 tvb, offset+4, 2, FALSE);
1291 dissect_ospf_bitfield(ospf_lls_tlv_tree, tvb, offset + 6,
1292 &bfinfo_v3_lls_state_options);
1294 case LLS_V3_NBR_DROP:
1296 while (orig_offset + length >= offset) {
1297 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset, 4,
1298 "Dropped Neighbor: %s",
1299 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1302 offset = orig_offset;
1305 relays_added = tvb_get_guint8(tvb, offset+4);
1306 proto_tree_add_item(ospf_lls_tlv_tree, ospf_filter[OSPFF_V3_LLS_RELAY_ADDED],
1307 tvb, offset+4, 1, FALSE);
1308 dissect_ospf_bitfield(ospf_lls_tlv_tree, tvb, offset + 5,
1309 &bfinfo_v3_lls_relay_options);
1311 while (orig_offset + length >= offset) {
1312 ti = proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset, 4,
1314 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1315 if (relays_added > 0) {
1316 proto_item_append_text(ti, " Added");
1318 proto_item_append_text(ti, " Deleted");
1325 case LLS_V3_WILLING:
1326 proto_tree_add_item(ospf_lls_tlv_tree, ospf_filter[OSPFF_V3_LLS_WILLINGNESS],
1327 tvb, offset+4, 1, FALSE);
1330 case LLS_V3_RQST_FROM:
1332 while (orig_offset + length >= offset) {
1333 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset, 4,
1335 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1338 offset = orig_offset;
1340 case LLS_V3_FULL_STATE:
1342 while (orig_offset + length >= offset) {
1343 proto_tree_add_text(ospf_lls_tlv_tree, tvb, offset, 4,
1344 "Full State For: %s",
1345 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1348 offset = orig_offset;
1352 return offset + length + 4;
1357 dissect_ospf_lls_data_block(tvbuff_t *tvb, int offset, proto_tree *tree,
1360 proto_tree *ospf_lls_data_block_tree;
1362 guint16 ospf_lls_len;
1363 int orig_offset = offset;
1365 ospf_lls_len = tvb_get_ntohs(tvb, offset + 2);
1366 ti = proto_tree_add_text(tree, tvb, offset, -1, "OSPF LLS Data Block");
1367 ospf_lls_data_block_tree = proto_item_add_subtree(ti,
1368 ett_ospf_lls_data_block);
1370 /* TODO: verify checksum */
1371 proto_tree_add_text(ospf_lls_data_block_tree, tvb, offset, 2,
1372 "Checksum: 0x%04x", tvb_get_ntohs(tvb, offset));
1373 proto_tree_add_text(ospf_lls_data_block_tree, tvb, offset + 2, 2,
1374 "LLS Data Length: %d bytes", ospf_lls_len * 4);
1377 while (orig_offset + ospf_lls_len * 4 > offset) {
1379 case OSPF_VERSION_2:
1380 offset = dissect_ospfv2_lls_tlv (tvb, offset, ospf_lls_data_block_tree);
1382 case OSPF_VERSION_3:
1383 offset = dissect_ospfv3_lls_tlv (tvb, offset, ospf_lls_data_block_tree);
1390 dissect_ospf_hello(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version,
1393 proto_tree *ospf_hello_tree;
1395 int orig_offset = offset;
1397 ti = proto_tree_add_text(tree, tvb, offset, length, "OSPF Hello Packet");
1398 ospf_hello_tree = proto_item_add_subtree(ti, ett_ospf_hello);
1401 case OSPF_VERSION_2:
1402 proto_tree_add_text(ospf_hello_tree, tvb, offset, 4, "Network Mask: %s",
1403 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1404 proto_tree_add_text(ospf_hello_tree, tvb, offset + 4, 2,
1405 "Hello Interval: %u seconds",
1406 tvb_get_ntohs(tvb, offset + 4));
1408 dissect_ospf_bitfield(ospf_hello_tree, tvb, offset + 6, &bfinfo_v2_options);
1409 proto_tree_add_text(ospf_hello_tree, tvb, offset + 7, 1, "Router Priority: %u",
1410 tvb_get_guint8(tvb, offset + 7));
1411 proto_tree_add_text(ospf_hello_tree, tvb, offset + 8, 4, "Router Dead Interval: %u seconds",
1412 tvb_get_ntohl(tvb, offset + 8));
1413 proto_tree_add_text(ospf_hello_tree, tvb, offset + 12, 4, "Designated Router: %s",
1414 ip_to_str(tvb_get_ptr(tvb, offset + 12, 4)));
1415 proto_tree_add_text(ospf_hello_tree, tvb, offset + 16, 4, "Backup Designated Router: %s",
1416 ip_to_str(tvb_get_ptr(tvb, offset + 16, 4)));
1419 while (orig_offset + length > offset) {
1420 proto_tree_add_text(ospf_hello_tree, tvb, offset, 4,
1421 "Active Neighbor: %s",
1422 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1426 case OSPF_VERSION_3:
1427 proto_tree_add_text(ospf_hello_tree, tvb, offset + 0, 4, "Interface ID: %u",
1428 tvb_get_ntohl(tvb, offset + 0));
1429 proto_tree_add_text(ospf_hello_tree, tvb, offset + 4, 1, "Router Priority: %u",
1430 tvb_get_guint8(tvb, offset + 4));
1431 dissect_ospf_bitfield(ospf_hello_tree, tvb, offset + 5, &bfinfo_v3_options);
1432 proto_tree_add_text(ospf_hello_tree, tvb, offset + 8, 2,
1433 "Hello Interval: %u seconds",
1434 tvb_get_ntohs(tvb, offset + 8));
1435 proto_tree_add_text(ospf_hello_tree, tvb, offset + 10, 2, "Router Dead Interval: %u seconds",
1436 tvb_get_ntohs(tvb, offset + 10));
1437 proto_tree_add_text(ospf_hello_tree, tvb, offset + 12, 4, "Designated Router: %s",
1438 ip_to_str(tvb_get_ptr(tvb, offset + 12, 4)));
1439 proto_tree_add_text(ospf_hello_tree, tvb, offset + 16, 4, "Backup Designated Router: %s",
1440 ip_to_str(tvb_get_ptr(tvb, offset + 16, 4)));
1442 while (orig_offset + length > offset) {
1443 proto_tree_add_text(ospf_hello_tree, tvb, offset, 4,
1444 "Active Neighbor: %s",
1445 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1454 dissect_ospf_db_desc(tvbuff_t *tvb, int offset, proto_tree *tree,
1455 guint8 version, guint16 length, guint8 address_family)
1457 proto_tree *ospf_db_desc_tree=NULL;
1460 int orig_offset = offset;
1463 ti = proto_tree_add_text(tree, tvb, offset, length, "OSPF DB Description");
1464 ospf_db_desc_tree = proto_item_add_subtree(ti, ett_ospf_desc);
1468 case OSPF_VERSION_2:
1469 proto_tree_add_text(ospf_db_desc_tree, tvb, offset, 2, "Interface MTU: %u",
1470 tvb_get_ntohs(tvb, offset));
1472 dissect_ospf_bitfield(ospf_db_desc_tree, tvb, offset + 2, &bfinfo_v2_options);
1473 dissect_ospf_bitfield(ospf_db_desc_tree, tvb, offset + 3, &bfinfo_dbd);
1475 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 4, 4, "DD Sequence: %u",
1476 tvb_get_ntohl(tvb, offset + 4));
1481 case OSPF_VERSION_3:
1483 reserved = tvb_get_guint8(tvb, offset);
1484 proto_tree_add_text(ospf_db_desc_tree, tvb, offset, 1, (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),
1487 dissect_ospf_bitfield(ospf_db_desc_tree, tvb, offset + 1, &bfinfo_v3_options);
1489 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 4, 2, "Interface MTU: %u",
1490 tvb_get_ntohs(tvb, offset+4));
1492 reserved = tvb_get_guint8(tvb, offset + 6);
1493 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 6, 1, (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),
1496 dissect_ospf_bitfield(ospf_db_desc_tree, tvb, offset + 7, &bfinfo_dbd);
1498 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 8, 4, "DD Sequence: %u",
1499 tvb_get_ntohl(tvb, offset + 8));
1506 /* LS Headers will be processed here */
1507 /* skip to the end of DB-Desc header */
1508 while (orig_offset + length > offset) {
1509 if ( version == OSPF_VERSION_2)
1510 offset = dissect_ospf_v2_lsa(tvb, offset, tree, FALSE);
1512 if ( version == OSPF_VERSION_3)
1513 offset = dissect_ospf_v3_lsa(tvb, offset, tree, FALSE, address_family);
1519 dissect_ospf_ls_req(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version,
1522 proto_tree *ospf_lsr_tree;
1526 int orig_offset = offset;
1528 /* zero or more LS requests may be within a LS Request */
1529 /* we place every request for a LSA in a single subtree */
1530 while (orig_offset + length > offset) {
1531 ti = proto_tree_add_text(tree, tvb, offset, OSPF_LS_REQ_LENGTH,
1532 "Link State Request");
1533 ospf_lsr_tree = proto_item_add_subtree(ti, ett_ospf_lsr);
1535 switch ( version ) {
1537 case OSPF_VERSION_2:
1538 proto_tree_add_item(ospf_lsr_tree, ospf_filter[OSPFF_LS_TYPE],
1539 tvb, offset, 4, FALSE);
1541 case OSPF_VERSION_3:
1542 reserved = tvb_get_ntohs(tvb, offset);
1543 proto_tree_add_text(ospf_lsr_tree, tvb, offset, 2,
1544 (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"), reserved);
1545 ls_type = tvb_get_ntohs(tvb, offset+2);
1546 proto_tree_add_text(ospf_lsr_tree, tvb, offset+2, 2, "LS Type: %s (0x%04x)",
1547 val_to_str(ls_type, v3_ls_type_vals, "Unknown"),
1553 proto_tree_add_text(ospf_lsr_tree, tvb, offset + 4, 4, "Link State ID: %s",
1554 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
1555 proto_tree_add_item(ospf_lsr_tree, ospf_filter[OSPFF_ADV_ROUTER],
1556 tvb, offset + 8, 4, FALSE);
1563 dissect_ospf_ls_upd(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version,
1564 guint16 length, guint8 address_family)
1566 proto_tree *ospf_lsa_upd_tree=NULL;
1569 guint32 lsa_counter;
1571 ti = proto_tree_add_text(tree, tvb, offset, length, "LS Update Packet");
1572 ospf_lsa_upd_tree = proto_item_add_subtree(ti, ett_ospf_lsa_upd);
1574 lsa_nr = tvb_get_ntohl(tvb, offset);
1575 proto_tree_add_text(ospf_lsa_upd_tree, tvb, offset, 4, "Number of LSAs: %u",
1577 /* skip to the beginning of the first LSA */
1578 offset += 4; /* the LS Upd Packet contains only a 32 bit #LSAs field */
1581 while (lsa_counter < lsa_nr) {
1582 if ( version == OSPF_VERSION_2)
1583 offset = dissect_ospf_v2_lsa(tvb, offset, ospf_lsa_upd_tree, TRUE);
1584 else if ( version == OSPF_VERSION_3)
1585 offset = dissect_ospf_v3_lsa(tvb, offset, ospf_lsa_upd_tree, TRUE,
1588 /* We could potentially waste CPU cycles looping */
1589 lsa_counter = lsa_nr;
1596 dissect_ospf_ls_ack(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version,
1597 guint16 length, guint8 address_family)
1599 int orig_offset = offset;
1600 /* the body of a LS Ack packet simply contains zero or more LSA Headers */
1601 while (orig_offset + length > offset) {
1602 if ( version == OSPF_VERSION_2)
1603 offset = dissect_ospf_v2_lsa(tvb, offset, tree, FALSE);
1605 if ( version == OSPF_VERSION_3)
1606 offset = dissect_ospf_v3_lsa(tvb, offset, tree, FALSE,
1612 * Returns if an LSA is opaque, i.e. requires special treatment
1615 is_opaque(int lsa_type)
1617 return (lsa_type >= OSPF_LSTYPE_OP_LINKLOCAL &&
1618 lsa_type <= OSPF_LSTYPE_OP_ASWIDE);
1621 /* MPLS/TE TLV types */
1622 #define MPLS_TLV_ROUTER 1
1623 #define MPLS_TLV_LINK 2
1624 #define OIF_TLV_TNA 32768
1626 /* MPLS/TE Link STLV types */
1628 MPLS_LINK_TYPE = 1, /* RFC 3630, OSPF-TE */
1631 MPLS_LINK_REMOTE_IF,
1632 MPLS_LINK_TE_METRIC,
1634 MPLS_LINK_MAX_RES_BW,
1637 MPLS_LINK_LOCAL_REMOTE_ID = 11, /* RFC 4203, GMPLS */
1638 MPLS_LINK_PROTECTION = 14,
1639 MPLS_LINK_IF_SWITCHING_DESC,
1640 MPLS_LINK_SHARED_RISK_GROUP,
1641 MPLS_LINK_BANDWIDTH_CONSTRAINT = 17 /* RFC 4124, OSPF-DSTE */
1647 OIF_LOCAL_NODE_ID = 32773,
1649 OIF_SONET_SDH_SWITCHING_CAPABILITY,
1650 OIF_TNA_IPv4_ADDRESS,
1652 OIF_TNA_IPv6_ADDRESS,
1653 OIF_TNA_NSAP_ADDRESS
1656 static const value_string mpls_link_stlv_str[] = {
1657 {MPLS_LINK_TYPE, "Link Type"},
1658 {MPLS_LINK_ID, "Link ID"},
1659 {MPLS_LINK_LOCAL_IF, "Local Interface IP Address"},
1660 {MPLS_LINK_REMOTE_IF, "Remote Interface IP Address"},
1661 {MPLS_LINK_TE_METRIC, "Traffic Engineering Metric"},
1662 {MPLS_LINK_MAX_BW, "Maximum Bandwidth"},
1663 {MPLS_LINK_MAX_RES_BW, "Maximum Reservable Bandwidth"},
1664 {MPLS_LINK_UNRES_BW, "Unreserved Bandwidth"},
1665 {MPLS_LINK_COLOR, "Resource Class/Color"},
1666 {MPLS_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier"},
1667 {MPLS_LINK_PROTECTION, "Link Protection Type"},
1668 {MPLS_LINK_IF_SWITCHING_DESC, "Interface Switching Capability Descriptor"},
1669 {MPLS_LINK_SHARED_RISK_GROUP, "Shared Risk Link Group"},
1670 {MPLS_LINK_BANDWIDTH_CONSTRAINT, "Bandwidth Constraints"},
1671 {OIF_LOCAL_NODE_ID, "Local Node ID"},
1672 {OIF_REMOTE_NODE_ID, "Remote Node ID"},
1673 {OIF_SONET_SDH_SWITCHING_CAPABILITY, "Sonet/SDH Interface Switching Capability"},
1677 static const value_string oif_stlv_str[] = {
1678 {OIF_TNA_IPv4_ADDRESS, "TNA address"},
1679 {OIF_NODE_ID, "Node ID"},
1680 {OIF_TNA_IPv6_ADDRESS, "TNA address"},
1681 {OIF_TNA_NSAP_ADDRESS, "TNA address"},
1686 * Dissect MPLS/TE opaque LSA
1689 dissect_ospf_lsa_mpls(tvbuff_t *tvb, int offset, proto_tree *tree,
1692 proto_item *ti, *hidden_item;
1693 proto_tree *mpls_tree;
1694 proto_tree *tlv_tree;
1695 proto_tree *stlv_tree;
1696 proto_tree *stlv_admingrp_tree = NULL;
1702 int stlv_type, stlv_len, stlv_offset;
1703 const char *stlv_name;
1704 guint32 stlv_admingrp, mask;
1708 const guint8 allzero[] = { 0x00, 0x00, 0x00 };
1711 ti = proto_tree_add_text(tree, tvb, offset, length,
1712 "MPLS Traffic Engineering LSA");
1713 hidden_item = proto_tree_add_item(tree, ospf_filter[OSPFF_LS_MPLS],
1714 tvb, offset, 2, FALSE);
1715 PROTO_ITEM_SET_HIDDEN(hidden_item);
1716 mpls_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls);
1718 while (length != 0) {
1719 tlv_type = tvb_get_ntohs(tvb, offset);
1720 tlv_length = tvb_get_ntohs(tvb, offset + 2);
1721 tlv_end_offset = offset + tlv_length + 4;
1725 case MPLS_TLV_ROUTER:
1726 ti = proto_tree_add_text(mpls_tree, tvb, offset, tlv_length+4,
1727 "Router Address: %s",
1728 ip_to_str(tvb_get_ptr(tvb, offset+4, 4)));
1729 tlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_router);
1730 proto_tree_add_text(tlv_tree, tvb, offset, 2, "TLV Type: 1 - Router Address");
1731 proto_tree_add_text(tlv_tree, tvb, offset+2, 2, "TLV Length: %u",
1733 proto_tree_add_item(tlv_tree, ospf_filter[OSPFF_LS_MPLS_ROUTERID],
1734 tvb, offset+4, 4, FALSE);
1738 ti = proto_tree_add_text(mpls_tree, tvb, offset, tlv_length+4,
1739 "Link Information");
1740 tlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link);
1741 proto_tree_add_text(tlv_tree, tvb, offset, 2, "TLV Type: 2 - Link Information");
1742 proto_tree_add_text(tlv_tree, tvb, offset+2, 2, "TLV Length: %u",
1744 stlv_offset = offset + 4;
1746 /* Walk down the sub-TLVs for link information */
1747 while (stlv_offset < tlv_end_offset) {
1748 stlv_type = tvb_get_ntohs(tvb, stlv_offset);
1749 stlv_len = tvb_get_ntohs(tvb, stlv_offset + 2);
1750 stlv_name = val_to_str(stlv_type, mpls_link_stlv_str, "Unknown sub-TLV");
1751 switch (stlv_type) {
1753 case MPLS_LINK_TYPE:
1754 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1755 "%s: %u - %s", stlv_name,
1756 tvb_get_guint8(tvb, stlv_offset + 4),
1757 val_to_str(tvb_get_guint8(tvb, stlv_offset + 4),
1758 mpls_link_stlv_ltype_str, "Unknown Link Type"));
1759 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1760 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1761 "TLV Type: %u: %s", stlv_type, stlv_name);
1762 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1764 proto_tree_add_item(stlv_tree, ospf_filter[OSPFF_LS_MPLS_LINKTYPE],
1765 tvb, stlv_offset+4, 1,FALSE);
1769 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1770 "%s: %s", stlv_name,
1771 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
1772 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1773 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1774 "TLV Type: %u: %s", stlv_type, stlv_name);
1775 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1777 proto_tree_add_item(stlv_tree, ospf_filter[OSPFF_LS_MPLS_LINKID],
1778 tvb, stlv_offset+4, 4, FALSE);
1781 case MPLS_LINK_LOCAL_IF:
1782 case MPLS_LINK_REMOTE_IF:
1783 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1785 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1786 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1787 "TLV Type: %u: %s", stlv_type, stlv_name);
1788 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1790 /* The Local/Remote Interface IP Address sub-TLV is TLV type 3/4, and is 4N
1791 octets in length, where N is the number of neighbor addresses. */
1792 for (i=0; i < stlv_len; i+=4)
1793 proto_tree_add_item(stlv_tree,
1794 stlv_type==MPLS_LINK_LOCAL_IF ?
1795 ospf_filter[OSPFF_LS_MPLS_LOCAL_ADDR] :
1796 ospf_filter[OSPFF_LS_MPLS_REMOTE_ADDR],
1797 tvb, stlv_offset+4+i, 4, FALSE);
1800 case MPLS_LINK_TE_METRIC:
1801 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1802 "%s: %u", stlv_name,
1803 tvb_get_ntohl(tvb, stlv_offset + 4));
1804 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1805 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1806 "TLV Type: %u: %s", stlv_type, stlv_name);
1807 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1809 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 4, "%s: %u", stlv_name,
1810 tvb_get_ntohl(tvb, stlv_offset + 4));
1813 case MPLS_LINK_COLOR:
1814 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1815 "%s: 0x%08x", stlv_name,
1816 tvb_get_ntohl(tvb, stlv_offset + 4));
1817 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1818 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1819 "TLV Type: %u: %s", stlv_type, stlv_name);
1820 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1822 stlv_admingrp = tvb_get_ntohl(tvb, stlv_offset + 4);
1824 ti = proto_tree_add_item(stlv_tree, ospf_filter[OSPFF_LS_MPLS_LINKCOLOR],
1825 tvb, stlv_offset+4, 4, FALSE);
1826 stlv_admingrp_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv_admingrp);
1827 if (stlv_admingrp_tree == NULL)
1829 for (i = 0 ; i < 32 ; i++) {
1830 if ((stlv_admingrp & mask) != 0) {
1831 proto_tree_add_text(stlv_admingrp_tree, tvb, stlv_offset+4,
1838 case MPLS_LINK_MAX_BW:
1839 case MPLS_LINK_MAX_RES_BW:
1840 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1841 "%s: %.10g bytes/s (%.0f bits/s)", stlv_name,
1842 tvb_get_ntohieee_float(tvb, stlv_offset + 4),
1843 tvb_get_ntohieee_float(tvb, stlv_offset + 4) * 8.0);
1844 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1845 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1846 "TLV Type: %u: %s", stlv_type, stlv_name);
1847 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1849 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 4, "%s: %.10g bytes/s (%.0f bits/s)", stlv_name,
1850 tvb_get_ntohieee_float(tvb, stlv_offset + 4),
1851 tvb_get_ntohieee_float(tvb, stlv_offset + 4) * 8.0);
1854 case MPLS_LINK_UNRES_BW:
1855 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1857 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1858 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1859 "TLV Type: %u: %s", stlv_type, stlv_name);
1860 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1862 for (i = 0; i < 8; i++) {
1863 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4+(i*4), 4,
1864 "Pri (or TE-Class) %d: %.10g bytes/s (%.0f bits/s)", i,
1865 tvb_get_ntohieee_float(tvb, stlv_offset + 4 + i*4),
1866 tvb_get_ntohieee_float(tvb, stlv_offset + 4 + i*4) * 8.0);
1870 case MPLS_LINK_BANDWIDTH_CONSTRAINT:
1872 The "Bandwidth Constraints" sub-TLV format is illustrated below:
1875 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
1876 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1877 | BC Model Id | Reserved |
1878 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1880 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1882 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1884 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1887 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1890 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1892 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1893 "TLV Type: %u: %s", stlv_type, stlv_name);
1895 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1898 proto_tree_add_item(stlv_tree, ospf_filter[OSPFF_LS_MPLS_BC_MODEL_ID],
1899 tvb, stlv_offset+4, 1, FALSE);
1901 /* 3 octets reserved +5, +6 and +7 (all 0x00) */
1902 if(tvb_memeql(tvb, stlv_offset+5, allzero, 3) == -1) {
1903 proto_tree_add_text(stlv_tree, tvb, stlv_offset+5, 3,
1904 "Warning: these bytes are reserved and must be 0x00");
1907 if(((stlv_len % 4)!=0)) {
1908 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, stlv_len,
1909 "Malformed Packet: Length must be N x 4 octets");
1913 /* stlv_len shound range from 4 to 36 bytes */
1914 num_bcs = (stlv_len - 4)/4;
1917 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, stlv_len,
1918 "Malformed Packet: too many BC (%u)", num_bcs);
1923 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, stlv_len,
1924 "Malformed Packet: Bandwidth Constraints sub-TLV with no BC?");
1928 for(i = 0; i < (int) num_bcs; i++) {
1929 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8+(i*4), 4,
1930 "BC %d: %.10g bytes/s (%.0f bits/s)", i,
1931 tvb_get_ntohieee_float(tvb, stlv_offset + 8 + i*4),
1932 tvb_get_ntohieee_float(tvb, stlv_offset + 8 + i*4) * 8.0);
1936 case MPLS_LINK_LOCAL_REMOTE_ID:
1937 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1938 "%s: %d (0x%x) - %d (0x%x)", stlv_name,
1939 tvb_get_ntohl(tvb, stlv_offset + 4),
1940 tvb_get_ntohl(tvb, stlv_offset + 4),
1941 tvb_get_ntohl(tvb, stlv_offset + 8),
1942 tvb_get_ntohl(tvb, stlv_offset + 8));
1943 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1945 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1946 "TLV Type: %u: %s", stlv_type, stlv_name);
1947 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1949 proto_tree_add_item(stlv_tree,
1950 ospf_filter[OSPFF_LS_MPLS_LOCAL_IFID],
1951 tvb, stlv_offset+4, 4, FALSE);
1952 proto_tree_add_item(stlv_tree,
1953 ospf_filter[OSPFF_LS_MPLS_REMOTE_IFID],
1954 tvb, stlv_offset+8, 4, FALSE);
1957 case MPLS_LINK_IF_SWITCHING_DESC:
1958 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1960 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1961 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1962 "TLV Type: %u: %s", stlv_type, stlv_name);
1963 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1965 switch_cap = tvb_get_guint8 (tvb, stlv_offset+4);
1966 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Switching Type: %s",
1967 val_to_str(tvb_get_guint8(tvb,stlv_offset+4),
1968 gmpls_switching_type_str, "Unknown (%d)"));
1969 proto_tree_add_text(stlv_tree, tvb, stlv_offset+5, 1, "Encoding: %s",
1970 val_to_str(tvb_get_guint8(tvb,stlv_offset+5),
1971 gmpls_lsp_enc_str, "Unknown (%d)"));
1972 for (i = 0; i < 8; i++) {
1973 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8+(i*4), 4,
1974 "Pri %d: %.10g bytes/s (%.0f bits/s)", i,
1975 tvb_get_ntohieee_float(tvb, stlv_offset + 8 + i*4),
1976 tvb_get_ntohieee_float(tvb, stlv_offset + 8 + i*4) * 8.0);
1978 if (switch_cap >=1 && switch_cap <=4) { /* PSC-1 .. PSC-4 */
1979 proto_tree_add_text(stlv_tree, tvb, stlv_offset+40, 4,
1980 "Minimum LSP bandwidth: %.10g bytes/s (%.0f bits/s)",
1981 tvb_get_ntohieee_float(tvb, stlv_offset + 40),
1982 tvb_get_ntohieee_float(tvb, stlv_offset + 40) * 8.0);
1983 proto_tree_add_text(stlv_tree, tvb, stlv_offset+44, 2,
1984 "Interface MTU: %d", tvb_get_ntohs(tvb, stlv_offset+44));
1987 if (switch_cap == 100) { /* TDM */
1988 proto_tree_add_text(stlv_tree, tvb, stlv_offset+40, 4,
1989 "Minimum LSP bandwidth: %.10g bytes/s (%.0f bits/s)",
1990 tvb_get_ntohieee_float(tvb, stlv_offset + 40),
1991 tvb_get_ntohieee_float(tvb, stlv_offset + 40) * 8.0);
1992 proto_tree_add_text(stlv_tree, tvb, stlv_offset+44, 2,
1994 tvb_get_guint8(tvb, stlv_offset+44) ?
1995 "Arbitrary" : "Standard");
1998 case MPLS_LINK_PROTECTION:
1999 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2001 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
2002 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2003 "TLV Type: %u: %s", stlv_type, stlv_name);
2004 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2006 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Protection Capability: %s (0x%x)",
2007 val_to_str(tvb_get_guint8(tvb,stlv_offset+4), gmpls_protection_cap_str, "Unknown (%d)"),tvb_get_guint8(tvb,stlv_offset+4));
2010 case MPLS_LINK_SHARED_RISK_GROUP:
2011 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2013 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
2014 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2015 "TLV Type: %u: %s", stlv_type, stlv_name);
2016 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2018 for (i=0; i < stlv_len; i+=4)
2019 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4+i, 4, "Shared Risk Link Group: %u",
2020 tvb_get_ntohl(tvb,stlv_offset+4+i));
2023 case OIF_LOCAL_NODE_ID:
2024 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2025 "%s: %s", stlv_name,
2026 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
2027 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
2028 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2029 "TLV Type: %u: %s", stlv_type, stlv_name);
2030 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2032 proto_tree_add_item(stlv_tree,
2033 ospf_filter[OSPFF_LS_OIF_LOCAL_NODE_ID],
2034 tvb, stlv_offset + 4, 4, FALSE);
2037 case OIF_REMOTE_NODE_ID:
2038 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2039 "%s: %s", stlv_name,
2040 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
2041 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
2042 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2043 "TLV Type: %u: %s", stlv_type, stlv_name);
2044 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2046 proto_tree_add_item(stlv_tree,
2047 ospf_filter[OSPFF_LS_OIF_REMOTE_NODE_ID],
2048 tvb, stlv_offset + 4, 4, FALSE);
2051 case OIF_SONET_SDH_SWITCHING_CAPABILITY:
2052 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4, "%s", stlv_name);
2053 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
2054 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2055 "TLV Type: %u: %s", stlv_type, stlv_name);
2056 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2058 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Switching Cap: %s",
2059 val_to_str(tvb_get_guint8 (tvb, stlv_offset+4),
2060 gmpls_switching_type_str, "Unknown (%d)"));
2061 proto_tree_add_text(stlv_tree, tvb, stlv_offset+5, 1, "Encoding: %s",
2062 val_to_str(tvb_get_guint8(tvb,stlv_offset+5),
2063 gmpls_lsp_enc_str, "Unknown (%d)"));
2064 for (i = 0; i < (stlv_len - 4) / 4; i++) {
2065 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8+(i*4), 4,
2066 "%s: %d free timeslots",
2067 val_to_str(tvb_get_guint8(tvb, stlv_offset+8+(i*4)),
2068 gmpls_sonet_signal_type_str,
2069 "Unknown Signal Type (%d)"),
2070 tvb_get_ntoh24(tvb, stlv_offset + 9 + i*4));
2075 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2076 "Unknown Link sub-TLV: %u", stlv_type);
2077 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
2078 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2079 "TLV Type: %u: %s", stlv_type, stlv_name);
2080 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2082 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, stlv_len,
2086 stlv_offset += ((stlv_len+4+3)/4)*4;
2091 ti = proto_tree_add_text(mpls_tree, tvb, offset, tlv_length+4,
2093 tlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna);
2094 proto_tree_add_text(tlv_tree, tvb, offset, 2, "TLV Type: 32768 - TNA Information");
2095 proto_tree_add_text(tlv_tree, tvb, offset+2, 2, "TLV Length: %u",
2097 stlv_offset = offset + 4;
2099 /* Walk down the sub-TLVs for TNA information */
2100 while (stlv_offset < tlv_end_offset) {
2101 stlv_type = tvb_get_ntohs(tvb, stlv_offset);
2102 stlv_len = tvb_get_ntohs(tvb, stlv_offset + 2);
2103 stlv_name = val_to_str(stlv_type, oif_stlv_str, "Unknown sub-TLV");
2104 switch (stlv_type) {
2107 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2108 "%s: %s", stlv_name,
2109 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
2110 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna_stlv);
2111 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2112 "TLV Type: %u: %s", stlv_type, stlv_name);
2113 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
2115 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 4, "%s: %s", stlv_name,
2116 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
2119 case OIF_TNA_IPv4_ADDRESS:
2120 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2121 "%s (IPv4): %s", stlv_name,
2122 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 8, 4)));
2123 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna_stlv);
2124 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2125 "TLV Type: %u: %s (IPv4)", stlv_type, stlv_name);
2126 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u", stlv_len);
2127 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Addr Length: %u",
2128 tvb_get_guint8 (tvb, stlv_offset+4));
2129 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8, stlv_len - 4, "TNA Addr: %s",
2130 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 8, 4)));
2133 case OIF_TNA_IPv6_ADDRESS:
2134 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2135 "%s (IPv6): %s", stlv_name,
2136 ip6_to_str((const struct e_in6_addr *)
2137 tvb_get_ptr(tvb, stlv_offset + 8, 16)));
2138 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna_stlv);
2139 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2140 "TLV Type: %u: %s (IPv6)", stlv_type, stlv_name);
2141 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u", stlv_len);
2142 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Addr Length: %u",
2143 tvb_get_guint8 (tvb, stlv_offset+4));
2144 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8, stlv_len - 4, "TNA Addr: %s",
2145 ip6_to_str((const struct e_in6_addr *)
2146 tvb_get_ptr(tvb, stlv_offset + 8, 16)));
2149 case OIF_TNA_NSAP_ADDRESS:
2150 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2151 "%s (NSAP): %s", stlv_name,
2152 tvb_bytes_to_str (tvb, stlv_offset + 8, stlv_len - 4));
2153 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna_stlv);
2154 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
2155 "TLV Type: %u: %s (NSAP)", stlv_type, stlv_name);
2156 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u", stlv_len);
2157 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Addr Length: %u",
2158 tvb_get_guint8 (tvb, stlv_offset+4));
2159 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8, stlv_len - 4, "TNA Addr: %s",
2160 tvb_bytes_to_str(tvb, stlv_offset+8, stlv_len - 4));
2164 proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
2165 "Unknown Link sub-TLV: %u", stlv_type);
2168 stlv_offset += ((stlv_len+4+3)/4)*4;
2172 ti = proto_tree_add_text(mpls_tree, tvb, offset, tlv_length+4,
2173 "Unknown LSA: %u", tlv_type);
2174 tlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link);
2175 proto_tree_add_text(tlv_tree, tvb, offset, 2, "TLV Type: %u - Unknown",
2177 proto_tree_add_text(tlv_tree, tvb, offset+2, 2, "TLV Length: %u",
2179 proto_tree_add_text(tlv_tree, tvb, offset+4, tlv_length, "TLV Data");
2183 offset += tlv_length + 4;
2184 length -= tlv_length + 4;
2189 * Dissect the TLVs within a Grace-LSA as defined by RFC 3623
2191 static void dissect_ospf_lsa_grace_tlv (tvbuff_t *tvb, int offset,
2192 proto_tree *tree, guint32 length)
2196 int tlv_length_with_pad; /* The total length of the TLV including the type
2197 and length fields and any padding */
2198 guint32 grace_period;
2199 guint8 restart_reason;
2201 proto_tree *tlv_tree;
2202 proto_item *tree_item;
2203 proto_item *grace_tree_item;
2205 if (!tree) { return; }
2209 tlv_type = tvb_get_ntohs(tvb, offset);
2210 tlv_length = tvb_get_ntohs(tvb, offset + 2);
2211 /* The total length of the TLV including the type, length, value and
2212 * pad bytes (TLVs are padded to 4 octet alignment).
2214 tlv_length_with_pad = tlv_length + 4 + ((4 - (tlv_length % 4)) % 4);
2216 tree_item = proto_tree_add_item(tree, ospf_filter[OSPFF_V2_GRACE_TLV], tvb, offset,
2217 tlv_length_with_pad, FALSE);
2218 tlv_tree = proto_item_add_subtree(tree_item, ett_ospf_lsa_grace_tlv);
2219 proto_tree_add_text(tlv_tree, tvb, offset, 2, "Type: %s (%u)",
2220 val_to_str(tlv_type, grace_tlv_type_vals, "Unknown grace-LSA TLV"), tlv_type);
2221 proto_tree_add_text(tlv_tree, tvb, offset + 2, 2, "Length: %u", tlv_length);
2224 case GRACE_TLV_PERIOD:
2225 grace_period = tvb_get_ntohl(tvb, offset + 4);
2226 grace_tree_item = proto_tree_add_item(tlv_tree, ospf_filter[OSPFF_V2_GRACE_PERIOD], tvb,
2227 offset + 4, tlv_length, FALSE);
2228 proto_item_append_text(grace_tree_item, " seconds");
2229 proto_item_set_text(tree_item, "Grace Period: %u seconds", grace_period);
2231 case GRACE_TLV_REASON:
2232 restart_reason = tvb_get_guint8(tvb, offset + 4);
2233 proto_tree_add_item(tlv_tree, ospf_filter[OSPFF_V2_GRACE_REASON], tvb, offset + 4,
2235 proto_item_set_text(tree_item, "Restart Reason: %s (%u)",
2236 val_to_str(restart_reason, restart_reason_vals, "Unknown Restart Reason"),
2240 restart_ip = tvb_get_ipv4(tvb, offset + 4);
2241 proto_tree_add_item(tlv_tree, ospf_filter[OSPFF_V2_GRACE_IP], tvb, offset + 4,
2243 proto_item_set_text(tree_item, "Restart IP: %s (%s)",
2244 get_hostname(restart_ip), ip_to_str((guint8 *)&restart_ip));
2247 proto_item_set_text(tree_item, "Unknown grace-LSA TLV");
2250 if (4 + tlv_length < tlv_length_with_pad) {
2251 proto_tree_add_text(tlv_tree, tvb, offset + 4 + tlv_length,
2252 tlv_length_with_pad - (4 + tlv_length), "Pad Bytes (%u)",
2253 tlv_length_with_pad - (4 + tlv_length) );
2255 offset += tlv_length_with_pad;
2256 length -= tlv_length_with_pad;
2261 * Dissect opaque LSAs
2264 dissect_ospf_lsa_opaque(tvbuff_t *tvb, int offset, proto_tree *tree,
2265 guint8 ls_id_type, guint32 length)
2267 switch (ls_id_type) {
2269 case OSPF_LSA_MPLS_TE:
2270 dissect_ospf_lsa_mpls(tvb, offset, tree, length);
2272 case OSPF_LSA_GRACE:
2273 dissect_ospf_lsa_grace_tlv(tvb, offset, tree, length);
2277 proto_tree_add_text(tree, tvb, offset, length,
2278 "Unknown LSA Type %u", ls_id_type);
2280 } /* switch on opaque LSA id */
2284 dissect_ospf_v2_lsa(tvbuff_t *tvb, int offset, proto_tree *tree,
2285 gboolean disassemble_body)
2287 proto_tree *ospf_lsa_tree;
2288 proto_item *ti, *hidden_item;
2298 guint16 link_counter;
2300 const char *link_type_str;
2301 const char *link_type_short_str;
2302 const char *link_id;
2304 /* AS-external LSA */
2310 ls_type = tvb_get_guint8(tvb, offset + 3);
2311 ls_length = tvb_get_ntohs(tvb, offset + 18);
2312 end_offset = offset + ls_length;
2314 if (disassemble_body) {
2315 ti = proto_tree_add_text(tree, tvb, offset, ls_length,
2317 val_to_str(ls_type, ls_type_vals, "Unknown (%d)"));
2319 ti = proto_tree_add_text(tree, tvb, offset, OSPF_LSA_HEADER_LENGTH,
2322 ospf_lsa_tree = proto_item_add_subtree(ti, ett_ospf_lsa);
2324 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2, "LS Age: %u seconds",
2325 tvb_get_ntohs(tvb, offset) & ~OSPF_DNA_LSA);
2326 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2, "Do Not Age: %s",
2327 (tvb_get_ntohs(tvb, offset) & OSPF_DNA_LSA) ? "True" : "False");
2328 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset + 2, &bfinfo_v2_options);
2329 proto_tree_add_item(ospf_lsa_tree, ospf_filter[OSPFF_LS_TYPE], tvb,
2330 offset + 3, 1, FALSE);
2331 if (ospf_ls_type_to_filter(ls_type) != -1) {
2332 hidden_item = proto_tree_add_item(ospf_lsa_tree,
2333 ospf_filter[ospf_ls_type_to_filter(ls_type)], tvb,
2334 offset + 3, 1, FALSE);
2335 PROTO_ITEM_SET_HIDDEN(hidden_item);
2338 if (is_opaque(ls_type)) {
2339 ls_id_type = tvb_get_guint8(tvb, offset + 4);
2340 proto_tree_add_uint(ospf_lsa_tree, ospf_filter[OSPFF_LS_OPAQUE_TYPE],
2341 tvb, offset + 4, 1, ls_id_type);
2343 switch (ls_id_type) {
2345 case OSPF_LSA_MPLS_TE:
2346 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 5, 1, "Link State ID TE-LSA Reserved: %u",
2347 tvb_get_guint8(tvb, offset + 5));
2348 proto_tree_add_item(ospf_lsa_tree, ospf_filter[OSPFF_LS_MPLS_TE_INSTANCE],
2349 tvb, offset + 6, 2, FALSE);
2353 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 5, 3, "Link State ID Opaque ID: %u",
2354 tvb_get_ntoh24(tvb, offset + 5));
2359 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 4, "Link State ID: %s",
2360 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
2363 proto_tree_add_item(ospf_lsa_tree, ospf_filter[OSPFF_ADV_ROUTER],
2364 tvb, offset + 8, 4, FALSE);
2365 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 12, 4, "LS Sequence Number: 0x%08x",
2366 tvb_get_ntohl(tvb, offset + 12));
2367 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 16, 2, "LS Checksum: 0x%04x",
2368 tvb_get_ntohs(tvb, offset + 16));
2370 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 18, 2, "Length: %u",
2373 /* skip past the LSA header to the body */
2374 offset += OSPF_LSA_HEADER_LENGTH;
2375 if (ls_length <= OSPF_LSA_HEADER_LENGTH)
2376 return offset; /* no data, or bogus length */
2377 ls_length -= OSPF_LSA_HEADER_LENGTH;
2379 if (!disassemble_body)
2384 case OSPF_LSTYPE_ROUTER:
2385 /* flags field in an router-lsa */
2386 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset, &bfinfo_v2_router_lsa_flags);
2388 nr_links = tvb_get_ntohs(tvb, offset + 2);
2389 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 2, 2, "Number of Links: %u",
2392 /* nr_links links follow
2393 * maybe we should put each of the links into its own subtree ???
2395 for (link_counter = 1; link_counter <= nr_links; link_counter++) {
2396 proto_tree *ospf_lsa_router_link_tree;
2397 proto_item *ti_local;
2400 /* check the Link Type and ID */
2401 link_type = tvb_get_guint8(tvb, offset + 8);
2402 switch (link_type) {
2405 link_type_str="Point-to-point connection to another router";
2406 link_type_short_str="PTP";
2407 link_id="Neighboring router's Router ID";
2410 case OSPF_LINK_TRANSIT:
2411 link_type_str="Connection to a transit network";
2412 link_type_short_str="Transit";
2413 link_id="IP address of Designated Router";
2416 case OSPF_LINK_STUB:
2417 link_type_str="Connection to a stub network";
2418 link_type_short_str="Stub";
2419 link_id="IP network/subnet number";
2422 case OSPF_LINK_VIRTUAL:
2423 link_type_str="Virtual link";
2424 link_type_short_str="Virtual";
2425 link_id="Neighboring router's Router ID";
2429 link_type_str="Unknown link type";
2430 link_type_short_str="Unknown";
2431 link_id="Unknown link ID";
2435 nr_tos = tvb_get_guint8(tvb, offset + 9);
2438 ti_local = proto_tree_add_text(ospf_lsa_tree, tvb, offset, 12 + 4 * nr_tos,
2439 "Type: %-8s ID: %-15s Data: %-15s Metric: %d",
2440 link_type_short_str,
2441 ip_to_str(tvb_get_ptr(tvb, offset, 4)),
2442 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)),
2443 tvb_get_ntohs(tvb, offset + 10));
2445 ospf_lsa_router_link_tree = proto_item_add_subtree(ti_local, ett_ospf_lsa_router_link);
2447 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset, 4, "%s: %s", link_id,
2448 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2450 /* link_data should be specified in detail (e.g. network mask) (depends on link type)*/
2451 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset + 4, 4, "Link Data: %s",
2452 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
2454 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset + 8, 1, "Link Type: %u - %s",
2455 link_type, link_type_str);
2456 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset + 9, 1, "Number of TOS metrics: %u",
2458 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset + 10, 2, "TOS 0 metric: %u",
2459 tvb_get_ntohs(tvb, offset + 10));
2463 /* nr_tos metrics may follow each link
2464 * ATTENTION: TOS metrics are not tested (I don't have TOS
2466 * please send me a mail if it is/isn't working
2468 for (tos_counter = 1; tos_counter <= nr_tos; tos_counter++) {
2469 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset, 4, "TOS: %u, Metric: %u",
2470 tvb_get_guint8(tvb, offset),
2471 tvb_get_ntohs(tvb, offset + 2));
2477 case OSPF_LSTYPE_NETWORK:
2478 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Netmask: %s",
2479 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2482 while (offset < end_offset) {
2483 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Attached Router: %s",
2484 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2489 case OSPF_LSTYPE_SUMMERY:
2490 /* Type 3 and 4 LSAs have the same format */
2491 case OSPF_LSTYPE_ASBR:
2492 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Netmask: %s",
2493 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2496 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Metric: %u",
2497 tvb_get_ntoh24(tvb, offset + 1));
2500 /* TOS-specific information, if any */
2501 while (offset < end_offset) {
2502 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "TOS: %u, Metric: %u",
2503 tvb_get_guint8(tvb, offset),
2504 tvb_get_ntoh24(tvb, offset + 1));
2509 case OSPF_LSTYPE_ASEXT:
2510 case OSPF_LSTYPE_ASEXT7:
2511 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Netmask: %s",
2512 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2515 options = tvb_get_guint8(tvb, offset);
2516 if (options & 0x80) { /* check whether or not E bit is set */
2517 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2518 "External Type: Type 2 (metric is larger than any other link state path)");
2520 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2521 "External Type: Type 1 (metric is specified in the same units as interface cost)");
2523 /* the metric field of a AS-external LAS is specified in 3 bytes */
2524 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 1, 3, "Metric: %u",
2525 tvb_get_ntoh24(tvb, offset + 1));
2528 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Forwarding Address: %s",
2529 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2532 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "External Route Tag: %u",
2533 tvb_get_ntohl(tvb, offset));
2536 /* TOS-specific information, if any */
2537 while (offset < end_offset) {
2538 options = tvb_get_guint8(tvb, offset);
2539 if (options & 0x80) { /* check whether or not E bit is set */
2540 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2541 "External Type: Type 2 (metric is larger than any other link state path)");
2543 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2544 "External Type: Type 1 (metric is specified in the same units as interface cost)");
2546 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "TOS: %u, Metric: %u",
2548 tvb_get_ntoh24(tvb, offset + 1));
2551 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Forwarding Address: %s",
2552 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2555 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "External Route Tag: %u",
2556 tvb_get_ntohl(tvb, offset));
2561 case OSPF_LSTYPE_OP_LINKLOCAL:
2562 case OSPF_LSTYPE_OP_AREALOCAL:
2563 case OSPF_LSTYPE_OP_ASWIDE:
2565 * RFC 2370 opaque LSAs.
2567 dissect_ospf_lsa_opaque(tvb, offset, ospf_lsa_tree, ls_id_type,
2569 offset += ls_length;
2573 /* unknown LSA type */
2574 proto_tree_add_text(ospf_lsa_tree, tvb, offset, ls_length,
2575 "Unknown LSA Type");
2576 offset += ls_length;
2579 /* return the offset of the next LSA */
2584 dissect_ospf_v3_lsa(tvbuff_t *tvb, int offset, proto_tree *tree,
2585 gboolean disassemble_body, guint8 address_family)
2587 proto_tree *ospf_lsa_tree;
2597 const char *link_type_str;
2600 guint8 router_priority;
2601 guint32 number_prefixes;
2602 guint8 prefix_length;
2605 guint16 referenced_ls_type;
2608 guint32 external_route_tag;
2611 ls_type = tvb_get_ntohs(tvb, offset + 2);
2612 ls_length = tvb_get_ntohs(tvb, offset + 18);
2613 end_offset = offset + ls_length;
2615 if (disassemble_body) {
2616 ti = proto_tree_add_text(tree, tvb, offset, ls_length,
2617 "%s (Type: 0x%04x)", val_to_str(ls_type, v3_ls_type_vals,"Unknown"), ls_type);
2619 ti = proto_tree_add_text(tree, tvb, offset, OSPF_LSA_HEADER_LENGTH,
2622 ospf_lsa_tree = proto_item_add_subtree(ti, ett_ospf_lsa);
2624 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2, "LS Age: %u seconds",
2625 tvb_get_ntohs(tvb, offset) & ~OSPF_DNA_LSA);
2626 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2, "Do Not Age: %s",
2627 (tvb_get_ntohs(tvb, offset) & OSPF_DNA_LSA) ? "True" : "False");
2629 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 2, 2, "LSA Type: 0x%04x (%s)",
2630 ls_type, val_to_str(ls_type, v3_ls_type_vals,"Unkown"));
2632 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 4, "Link State ID: %s",
2633 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
2635 proto_tree_add_item(ospf_lsa_tree, ospf_filter[OSPFF_ADV_ROUTER],
2636 tvb, offset + 8, 4, FALSE);
2637 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 12, 4, "LS Sequence Number: 0x%08x",
2638 tvb_get_ntohl(tvb, offset + 12));
2639 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 16, 2, "LS Checksum: 0x%04x",
2640 tvb_get_ntohs(tvb, offset + 16));
2642 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 18, 2, "Length: %u",
2645 /* skip past the LSA header to the body */
2646 offset += OSPF_LSA_HEADER_LENGTH;
2647 ls_length -= OSPF_LSA_HEADER_LENGTH;
2649 if (!disassemble_body)
2655 case OSPF_V3_LSTYPE_ROUTER:
2656 /* flags field in an router-lsa */
2657 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset, &bfinfo_v3_router_lsa_flags);
2659 /* options field in an router-lsa */
2660 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset + 1, &bfinfo_v3_options);
2662 /* skip the router-lsa flags and options */
2667 proto_tree_add_text(ospf_lsa_tree, tvb, offset, ls_length,
2668 "Router Interfaces:");
2670 /* scan all router-lsa router interfaces */
2671 /* maybe we should put each of the links into its own subtree ??? */
2672 while (ls_length > 0 ) {
2674 /* check the type */
2675 link_type = tvb_get_guint8(tvb, offset);
2676 switch (link_type) {
2678 case OSPF_V3_LINK_PTP:
2679 link_type_str="Point-to-point connection to another router";
2682 case OSPF_V3_LINK_TRANSIT:
2683 link_type_str="Connection to a transit network";
2686 case OSPF_V3_LINK_RESERVED:
2687 link_type_str="Connection to a stub network";
2690 case OSPF_V3_LINK_VIRTUAL:
2691 link_type_str="Virtual link";
2695 link_type_str="Unknown link type";
2699 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "Type: %u (%s)", link_type,link_type_str);
2701 /* reserved field */
2702 reserved = tvb_get_guint8(tvb, offset+1);
2703 proto_tree_add_text(ospf_lsa_tree, tvb, offset+1, 1,
2704 (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved);
2707 metric=tvb_get_ntohs(tvb, offset+2);
2708 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 2, 2,"Metric: %u",metric);
2711 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 4, "Interface ID: %u",
2712 tvb_get_ntohl(tvb, offset + 4));
2714 /* Neighbor Interface ID */
2715 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 8, 4, "Neighbor Interface ID: %u",
2716 tvb_get_ntohl(tvb, offset + 8));
2718 /* Neighbor Router ID */
2719 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 12, 4, "Neighbor Router ID: %s",
2720 ip_to_str(tvb_get_ptr(tvb, offset + 12, 4)));
2722 /* skip to the (possible) next entry */
2729 case OSPF_V3_LSTYPE_NETWORK:
2731 /* reserved field */
2732 reserved = tvb_get_guint8(tvb, offset);
2733 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2734 (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved);
2736 /* options field in an network-lsa */
2737 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset + 1, &bfinfo_v3_options);
2742 while (ls_length > 0 ) {
2743 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Attached Router: %s",
2744 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2751 case OSPF_V3_LSTYPE_INTER_AREA_PREFIX:
2753 /* reserved field */
2754 reserved = tvb_get_guint8(tvb, offset);
2755 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2756 (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved);
2759 metric=tvb_get_ntoh24(tvb, offset+1);
2760 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 1, 3,"Metric: %u",metric);
2763 prefix_length=tvb_get_guint8(tvb, offset+4);
2764 proto_tree_add_text(ospf_lsa_tree, tvb, offset+4, 1, "PrefixLength: %u",prefix_length);
2766 /* prefix options */
2767 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset+5, &bfinfo_v3_prefix_options);
2769 /* 16 bits reserved */
2770 reserved16=tvb_get_ntohs(tvb, offset+6);
2771 proto_tree_add_text(ospf_lsa_tree, tvb, offset+6, 2,
2772 (reserved16 == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved16);
2776 /* address_prefix */
2777 dissect_ospf_v3_address_prefix(tvb, offset, prefix_length, ospf_lsa_tree, address_family);
2779 offset+=(prefix_length+31)/32*4;
2784 case OSPF_V3_LSTYPE_INTER_AREA_ROUTER:
2786 /* reserved field */
2787 reserved = tvb_get_guint8(tvb, offset);
2788 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
2789 (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved);
2791 /* options field in an inter-area-router-lsa */
2792 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset + 1, &bfinfo_v3_options);
2794 /* reserved field */
2795 reserved = tvb_get_guint8(tvb, offset+4);
2796 proto_tree_add_text(ospf_lsa_tree, tvb, offset+4, 1,
2797 (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved);
2800 metric=tvb_get_ntoh24(tvb, offset+5);
2801 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 5, 3,"Metric: %u",metric);
2803 /* Destination Router ID */
2804 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 8, 4, "Destination Router ID: %s",
2805 ip_to_str(tvb_get_ptr(tvb, offset + 8, 4)));
2811 case OSPF_V3_LSTYPE_TYPE_7:
2812 case OSPF_V3_LSTYPE_AS_EXTERNAL:
2815 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset, &bfinfo_v3_as_external_flags);
2816 flags=tvb_get_guint8(tvb, offset);
2818 /* 24 bits metric */
2819 metric=tvb_get_ntoh24(tvb, offset+1);
2820 proto_tree_add_text(ospf_lsa_tree, tvb, offset+1, 3,
2821 "Metric: %u", metric);
2824 prefix_length=tvb_get_guint8(tvb, offset+4);
2825 proto_tree_add_text(ospf_lsa_tree, tvb, offset+4, 1, "PrefixLength: %u",prefix_length);
2827 /* prefix options */
2828 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset+5, &bfinfo_v3_prefix_options);
2830 /* referenced LS type */
2831 referenced_ls_type=tvb_get_ntohs(tvb, offset+6);
2832 proto_tree_add_text(ospf_lsa_tree, tvb, offset+6, 2,"Referenced LS type 0x%04x (%s)",
2833 referenced_ls_type, val_to_str(referenced_ls_type, v3_ls_type_vals, "Unknown"));
2837 /* address_prefix */
2838 dissect_ospf_v3_address_prefix(tvb, offset, prefix_length, ospf_lsa_tree, address_family);
2840 offset+=(prefix_length+31)/32*4;
2842 /* Forwarding Address (optional - only if F-flag is on) */
2843 if ( (offset < end_offset) && (flags & OSPF_V3_AS_EXTERNAL_FLAG_F) ) {
2844 if (address_family == OSPF_AF_6) {
2845 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 16,"Forwarding Address: %s",
2846 ip6_to_str((const struct e_in6_addr *)tvb_get_ptr(tvb, offset, 16)));
2848 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 16,"Forwarding Address: %s",
2849 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2855 /* External Route Tag (optional - only if T-flag is on) */
2856 if ( (offset < end_offset) && (flags & OSPF_V3_AS_EXTERNAL_FLAG_T) ) {
2857 external_route_tag=tvb_get_ntohl(tvb, offset);
2858 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4,"External Route Tag: %u",
2859 external_route_tag);
2864 /* Referenced Link State ID (optional - only if Referenced LS type is non-zero */
2865 if ( (offset < end_offset) && (referenced_ls_type != 0) ) {
2866 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Referenced Link State ID: %s",
2867 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2873 case OSPF_V3_LSTYPE_LINK:
2875 /* router priority */
2876 router_priority=tvb_get_guint8(tvb, offset);
2877 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "Router Priority: %u", router_priority);
2879 /* options field in an link-lsa */
2880 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset + 1, &bfinfo_v3_options);
2882 /* Link-local Interface Address */
2883 if (address_family == OSPF_AF_6) {
2884 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 16, "Link-local Interface Address: %s",
2885 ip6_to_str((const struct e_in6_addr *)tvb_get_ptr(tvb, offset + 4, 16)));
2887 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 16, "Link-local Interface Address: %s",
2888 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
2890 /* Number prefixes */
2891 number_prefixes=tvb_get_ntohl(tvb, offset + 20);
2892 proto_tree_add_text(ospf_lsa_tree, tvb, offset+20, 4, "# prefixes: %d",number_prefixes);
2896 while (number_prefixes > 0) {
2899 prefix_length=tvb_get_guint8(tvb, offset);
2900 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "PrefixLength: %u",prefix_length);
2902 /* prefix options */
2903 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset+1, &bfinfo_v3_prefix_options);
2905 /* 16 bits reserved */
2906 reserved16=tvb_get_ntohs(tvb, offset+2);
2907 proto_tree_add_text(ospf_lsa_tree, tvb, offset+2, 2,
2908 (reserved16 == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),reserved16);
2912 /* address_prefix */
2913 dissect_ospf_v3_address_prefix(tvb, offset, prefix_length, ospf_lsa_tree, address_family);
2915 offset+=(prefix_length+31)/32*4;
2922 case OSPF_V3_LSTYPE_INTRA_AREA_PREFIX:
2925 number_prefixes=tvb_get_ntohs(tvb, offset);
2926 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2,"# prefixes: %u",number_prefixes);
2928 /* referenced LS type */
2929 referenced_ls_type=tvb_get_ntohs(tvb, offset+2);
2930 proto_tree_add_text(ospf_lsa_tree, tvb, offset+2, 2,"Referenced LS type 0x%04x (%s)",
2931 referenced_ls_type, val_to_str(referenced_ls_type, v3_ls_type_vals, "Unknown"));
2933 /* Referenced Link State ID */
2934 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 4, "Referenced Link State ID: %s",
2935 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
2937 /* Referenced Advertising Router */
2938 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 8, 4, "Referenced Advertising Router: %s",
2939 ip_to_str(tvb_get_ptr(tvb, offset + 8, 4)));
2943 while (number_prefixes > 0) {
2946 prefix_length=tvb_get_guint8(tvb, offset);
2947 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "PrefixLength: %u",prefix_length);
2949 /* prefix options */
2950 dissect_ospf_bitfield(ospf_lsa_tree, tvb, offset+1, &bfinfo_v3_prefix_options);
2952 /* 16 bits metric */
2953 metric=tvb_get_ntohs(tvb, offset+2);
2954 proto_tree_add_text(ospf_lsa_tree, tvb, offset+2, 2,
2955 "Metric: %u", metric);
2959 /* address_prefix */
2960 dissect_ospf_v3_address_prefix(tvb, offset, prefix_length, ospf_lsa_tree, address_family);
2962 offset+=(prefix_length+31)/32*4;
2969 /* unknown LSA type */
2970 proto_tree_add_text(ospf_lsa_tree, tvb, offset, ls_length,
2971 "Unknown LSA Type 0x%04x",ls_type);
2972 offset += ls_length;
2975 /* return the offset of the next LSA */
2979 static void dissect_ospf_v3_address_prefix(tvbuff_t *tvb, int offset, int prefix_length, proto_tree *tree,
2980 guint8 address_family)
2983 int bytes_to_process;
2984 struct e_in6_addr prefix;
2986 bytes_to_process=((prefix_length+31)/32)*4;
2988 if (prefix_length > 128) {
2989 proto_tree_add_text(tree, tvb, offset, bytes_to_process,
2990 "Address Prefix: length is invalid (%d, should be <= 128)",
2995 memset(prefix.bytes, 0, sizeof prefix.bytes);
2996 if (bytes_to_process != 0) {
2997 tvb_memcpy(tvb, prefix.bytes, offset, bytes_to_process);
2998 if (prefix_length % 8) {
2999 prefix.bytes[bytes_to_process - 1] &=
3000 ((0xff00 >> (prefix_length % 8)) & 0xff);
3003 if (address_family == OSPF_AF_6) {
3004 proto_tree_add_text(tree, tvb, offset, bytes_to_process,
3005 "Address Prefix: %s", ip6_to_str(&prefix));
3007 proto_tree_add_text(tree, tvb, offset, bytes_to_process,
3008 "Address Prefix: %s", ip_to_str(tvb_get_ptr(tvb, offset, 4)));
3015 proto_register_ospf(void)
3017 static hf_register_info ospff_info[] = {
3019 /* Message type number */
3020 {&ospf_filter[OSPFF_MSG_TYPE],
3021 { "Message Type", "ospf.msg", FT_UINT8, BASE_DEC, VALS(pt_vals), 0x0,
3025 {&ospf_filter[OSPFF_MSG_HELLO],
3026 { "Hello", "ospf.msg.hello", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3028 {&ospf_filter[OSPFF_MSG_DB_DESC],
3029 { "Database Description", "ospf.msg.dbdesc", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3031 {&ospf_filter[OSPFF_MSG_LS_REQ],
3032 { "Link State Adv Request", "ospf.msg.lsreq", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3034 {&ospf_filter[OSPFF_MSG_LS_UPD],
3035 { "Link State Adv Update", "ospf.msg.lsupdate", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3037 {&ospf_filter[OSPFF_MSG_LS_ACK],
3038 { "Link State Adv Acknowledgement", "ospf.msg.lsack", FT_BOOLEAN,
3039 BASE_NONE, NULL, 0x0, NULL, HFILL }},
3044 {&ospf_filter[OSPFF_LS_TYPE],
3045 { "Link-State Advertisement Type", "ospf.lsa", FT_UINT8, BASE_DEC,
3046 VALS(ls_type_vals), 0x0, NULL, HFILL }},
3047 {&ospf_filter[OSPFF_LS_OPAQUE_TYPE],
3048 { "Link State ID Opaque Type", "ospf.lsid_opaque_type", FT_UINT8, BASE_DEC,
3049 VALS(ls_opaque_type_vals), 0x0, NULL, HFILL }},
3051 {&ospf_filter[OSPFF_LS_MPLS_TE_INSTANCE],
3052 { "Link State ID TE-LSA Instance", "ospf.lsid_te_lsa.instance", FT_UINT16, BASE_DEC,
3053 NULL, 0x0, NULL, HFILL }},
3055 {&ospf_filter[OSPFF_LS_ROUTER],
3056 { "Router LSA", "ospf.lsa.router", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3058 {&ospf_filter[OSPFF_LS_NETWORK],
3059 { "Network LSA", "ospf.lsa.network", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3061 {&ospf_filter[OSPFF_LS_SUMMARY],
3062 { "Summary LSA (IP Network)", "ospf.lsa.summary", FT_BOOLEAN, BASE_NONE,
3063 NULL, 0x0, NULL, HFILL }},
3064 {&ospf_filter[OSPFF_LS_ASBR],
3065 { "Summary LSA (ASBR)", "ospf.lsa.asbr", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3067 {&ospf_filter[OSPFF_LS_ASEXT],
3068 { "AS-External LSA (ASBR)", "ospf.lsa.asext", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3070 {&ospf_filter[OSPFF_LS_GRPMEMBER],
3071 { "Group Membership LSA", "ospf.lsa.member", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3073 {&ospf_filter[OSPFF_LS_ASEXT7],
3074 { "NSSA AS-External LSA", "ospf.lsa.nssa", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3076 {&ospf_filter[OSPFF_LS_EXTATTR],
3077 { "External Attributes LSA", "ospf.lsa.attr", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3079 {&ospf_filter[OSPFF_LS_OPAQUE],
3080 { "Opaque LSA", "ospf.lsa.opaque", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3083 /* Other interesting OSPF values */
3085 {&ospf_filter[OSPFF_SRC_ROUTER],
3086 { "Source OSPF Router", "ospf.srcrouter", FT_IPv4, BASE_NONE, NULL, 0x0,
3089 {&ospf_filter[OSPFF_ADV_ROUTER],
3090 { "Advertising Router", "ospf.advrouter", FT_IPv4, BASE_NONE, NULL, 0x0,
3093 {&ospf_filter[OSPFF_LS_MPLS],
3094 { "MPLS Traffic Engineering LSA", "ospf.lsa.mpls", FT_BOOLEAN,
3095 BASE_NONE, NULL, 0x0, NULL, HFILL }},
3097 {&ospf_filter[OSPFF_LS_MPLS_ROUTERID],
3098 { "MPLS/TE Router ID", "ospf.mpls.routerid", FT_IPv4, BASE_NONE, NULL, 0x0,
3101 {&ospf_filter[OSPFF_LS_MPLS_LINKTYPE],
3102 { "MPLS/TE Link Type", "ospf.mpls.linktype", FT_UINT8, BASE_DEC,
3103 VALS(mpls_link_stlv_ltype_str), 0x0, NULL, HFILL }},
3104 {&ospf_filter[OSPFF_LS_MPLS_LINKID],
3105 { "MPLS/TE Link ID", "ospf.mpls.linkid", FT_IPv4, BASE_NONE, NULL, 0x0,
3107 {&ospf_filter[OSPFF_LS_MPLS_LOCAL_ADDR],
3108 { "MPLS/TE Local Interface Address", "ospf.mpls.local_addr", FT_IPv4,
3109 BASE_NONE, NULL, 0x0, NULL, HFILL }},
3110 {&ospf_filter[OSPFF_LS_MPLS_REMOTE_ADDR],
3111 { "MPLS/TE Remote Interface Address", "ospf.mpls.remote_addr", FT_IPv4,
3112 BASE_NONE, NULL, 0x0, NULL, HFILL }},
3113 {&ospf_filter[OSPFF_LS_MPLS_LOCAL_IFID],
3114 { "MPLS/TE Local Interface Index", "ospf.mpls.local_id", FT_UINT32,
3115 BASE_DEC, NULL, 0x0, NULL, HFILL }},
3116 {&ospf_filter[OSPFF_LS_MPLS_REMOTE_IFID],
3117 { "MPLS/TE Remote Interface Index", "ospf.mpls.remote_id", FT_UINT32,
3118 BASE_DEC, NULL, 0x0, NULL, HFILL }},
3119 {&ospf_filter[OSPFF_LS_MPLS_LINKCOLOR],
3120 { "MPLS/TE Link Resource Class/Color", "ospf.mpls.linkcolor", FT_UINT32,
3121 BASE_HEX, NULL, 0x0, NULL, HFILL }},
3122 {&ospf_filter[OSPFF_LS_MPLS_BC_MODEL_ID],
3123 { "MPLS/DSTE Bandwidth Constraints Model Id", "ospf.mpls.bc", FT_UINT8,
3124 BASE_RANGE_STRING | BASE_DEC, RVALS(&mpls_link_stlv_bcmodel_rvals), 0x0,
3127 {&ospf_filter[OSPFF_LS_OIF_LOCAL_NODE_ID],
3128 { "Local Node ID", "ospf.oif.local_node_id", FT_IPv4,
3129 BASE_NONE, NULL, 0x0, NULL, HFILL }},
3130 {&ospf_filter[OSPFF_LS_OIF_REMOTE_NODE_ID],
3131 { "Remote Node ID", "ospf.oif.remote_node_id", FT_IPv4,
3132 BASE_NONE, NULL, 0x0, NULL, HFILL }},
3134 {&ospf_filter[OSPFF_V2_OPTIONS],
3135 { "Options", "ospf.v2.options", FT_UINT8, BASE_HEX,
3136 NULL, 0x0, NULL, HFILL }},
3137 {&ospf_filter[OSPFF_V2_OPTIONS_E],
3138 { "E", "ospf.v2.options.e", FT_BOOLEAN, 8,
3139 TFS(&tfs_v2_options_e), OSPF_V2_OPTIONS_E, NULL, HFILL }},
3140 {&ospf_filter[OSPFF_V2_OPTIONS_MC],
3141 { "MC", "ospf.v2.options.mc", FT_BOOLEAN, 8,
3142 TFS(&tfs_v2_options_mc), OSPF_V2_OPTIONS_MC, NULL, HFILL }},
3143 {&ospf_filter[OSPFF_V2_OPTIONS_NP],
3144 { "NP", "ospf.v2.options.np", FT_BOOLEAN, 8,
3145 TFS(&tfs_v2_options_np), OSPF_V2_OPTIONS_NP, NULL, HFILL }},
3146 {&ospf_filter[OSPFF_V2_OPTIONS_L],
3147 { "L", "ospf.v2.options.l", FT_BOOLEAN, 8,
3148 TFS(&tfs_v2_options_l), OSPF_V2_OPTIONS_L, NULL, HFILL }},
3149 {&ospf_filter[OSPFF_V2_OPTIONS_DC],
3150 { "DC", "ospf.v2.options.dc", FT_BOOLEAN, 8,
3151 TFS(&tfs_v2_options_dc), OSPF_V2_OPTIONS_DC, NULL, HFILL }},
3152 {&ospf_filter[OSPFF_V2_OPTIONS_O],
3153 { "O", "ospf.v2.options.o", FT_BOOLEAN, 8,
3154 TFS(&tfs_v2_options_o), OSPF_V2_OPTIONS_O, NULL, HFILL }},
3155 {&ospf_filter[OSPFF_V2_OPTIONS_DN],
3156 { "DN", "ospf.v2.options.dn", FT_BOOLEAN, 8,
3157 TFS(&tfs_v2_options_dn), OSPF_V2_OPTIONS_DN, NULL, HFILL }},
3158 {&ospf_filter[OSPFF_V3_OPTIONS],
3159 { "Options", "ospf.v3.options", FT_UINT24, BASE_HEX,
3160 NULL, 0x0, NULL, HFILL }},
3161 {&ospf_filter[OSPFF_V3_OPTIONS_V6],
3162 { "V6", "ospf.v3.options.v6", FT_BOOLEAN, 24,
3163 TFS(&tfs_v3_options_v6), OSPF_V3_OPTIONS_V6, NULL, HFILL }},
3164 {&ospf_filter[OSPFF_V3_OPTIONS_E],
3165 { "E", "ospf.v3.options.e", FT_BOOLEAN, 24,
3166 TFS(&tfs_v3_options_e), OSPF_V3_OPTIONS_E, NULL, HFILL }},
3167 {&ospf_filter[OSPFF_V3_OPTIONS_MC],
3168 { "MC", "ospf.v3.options.mc", FT_BOOLEAN, 24,
3169 TFS(&tfs_v3_options_mc), OSPF_V3_OPTIONS_MC, NULL, HFILL }},
3170 {&ospf_filter[OSPFF_V3_OPTIONS_N],
3171 { "N", "ospf.v3.options.n", FT_BOOLEAN, 24,
3172 TFS(&tfs_v3_options_n), OSPF_V3_OPTIONS_N, NULL, HFILL }},
3173 {&ospf_filter[OSPFF_V3_OPTIONS_R],
3174 { "R", "ospf.v3.options.r", FT_BOOLEAN, 24,
3175 TFS(&tfs_v3_options_r), OSPF_V3_OPTIONS_R, NULL, HFILL }},
3176 {&ospf_filter[OSPFF_V3_OPTIONS_DC],
3177 { "DC", "ospf.v3.options.dc", FT_BOOLEAN, 24,
3178 TFS(&tfs_v3_options_dc), OSPF_V3_OPTIONS_DC, NULL, HFILL }},
3179 {&ospf_filter[OSPFF_V3_OPTIONS_AF],
3180 { "AF", "ospf.v3.options.af", FT_BOOLEAN, 24,
3181 TFS(&tfs_v3_options_af), OSPF_V3_OPTIONS_AF, NULL, HFILL }},
3182 {&ospf_filter[OSPFF_V3_OPTIONS_L],
3183 { "L", "ospf.v3.options.l", FT_BOOLEAN, 24,
3184 TFS(&tfs_v3_options_l), OSPF_V3_OPTIONS_L, NULL, HFILL }},
3185 {&ospf_filter[OSPFF_V3_OPTIONS_I],
3186 { "I", "ospf.v3.options.i", FT_BOOLEAN, 24,
3187 TFS(&tfs_v3_options_i), OSPF_V3_OPTIONS_I, NULL, HFILL }},
3188 {&ospf_filter[OSPFF_V3_OPTIONS_F],
3189 { "F", "ospf.v3.options.f", FT_BOOLEAN, 24,
3190 TFS(&tfs_v3_options_f), OSPF_V3_OPTIONS_F, NULL, HFILL }},
3191 {&ospf_filter[OSPFF_DBD],
3192 { "DB Description", "ospf.dbd", FT_UINT8, BASE_HEX,
3193 NULL, 0x0, NULL, HFILL }},
3194 {&ospf_filter[OSPFF_DBD_R],
3195 { "R", "ospf.dbd.r", FT_BOOLEAN, 8,
3196 TFS(&tfs_dbd_r), OSPF_DBD_FLAG_R, NULL, HFILL }},
3197 {&ospf_filter[OSPFF_DBD_I],
3198 { "I", "ospf.dbd.i", FT_BOOLEAN, 8,
3199 TFS(&tfs_dbd_i), OSPF_DBD_FLAG_I, NULL, HFILL }},
3200 {&ospf_filter[OSPFF_DBD_M],
3201 { "M", "ospf.dbd.m", FT_BOOLEAN, 8,
3202 TFS(&tfs_dbd_m), OSPF_DBD_FLAG_M, NULL, HFILL }},
3203 {&ospf_filter[OSPFF_DBD_MS],
3204 { "MS", "ospf.dbd.ms", FT_BOOLEAN, 8,
3205 TFS(&tfs_dbd_ms), OSPF_DBD_FLAG_MS, NULL, HFILL }},
3206 {&ospf_filter[OSPFF_LLS_EXT_OPTIONS],
3207 { "Options", "ospf.lls.ext.options", FT_UINT32, BASE_HEX,
3208 NULL, 0x0, NULL, HFILL }},
3209 {&ospf_filter[OSPFF_LLS_EXT_OPTIONS_LR],
3210 { "LR", "ospf.lls.ext.options.lr", FT_BOOLEAN, 32,
3211 TFS(&tfs_lls_ext_options_lr), OSPF_LLS_EXT_OPTIONS_LR, NULL, HFILL }},
3212 {&ospf_filter[OSPFF_LLS_EXT_OPTIONS_RS],
3213 { "RS", "ospf.lls.ext.options.rs", FT_BOOLEAN, 32,
3214 TFS(&tfs_lls_ext_options_rs), OSPF_LLS_EXT_OPTIONS_RS, NULL, HFILL }},
3215 {&ospf_filter[OSPFF_V2_ROUTER_LSA_FLAG],
3216 { "Flags", "ospf.v2.router.lsa.flags", FT_UINT8, BASE_HEX,
3217 NULL, 0x0, NULL, HFILL }},
3218 {&ospf_filter[OSPFF_V2_ROUTER_LSA_FLAG_B],
3219 { "B", "ospf.v2.router.lsa.flags.b", FT_BOOLEAN, 8,
3220 TFS(&tfs_v2_router_lsa_flags_b), OSPF_V2_ROUTER_LSA_FLAG_B, NULL, HFILL }},
3221 {&ospf_filter[OSPFF_V2_ROUTER_LSA_FLAG_E],
3222 { "E", "ospf.v2.router.lsa.flags.e", FT_BOOLEAN, 8,
3223 TFS(&tfs_v2_router_lsa_flags_e), OSPF_V2_ROUTER_LSA_FLAG_E, NULL, HFILL }},
3224 {&ospf_filter[OSPFF_V2_ROUTER_LSA_FLAG_V],
3225 { "V", "ospf.v2.router.lsa.flags.v", FT_BOOLEAN, 8,
3226 TFS(&tfs_v2_router_lsa_flags_v), OSPF_V2_ROUTER_LSA_FLAG_V, NULL, HFILL }},
3227 {&ospf_filter[OSPFF_V3_ROUTER_LSA_FLAG],
3228 { "Flags", "ospf.v3.router.lsa.flags", FT_UINT8, BASE_HEX,
3229 NULL, 0x0, NULL, HFILL }},
3230 {&ospf_filter[OSPFF_V3_ROUTER_LSA_FLAG_B],
3231 { "B", "ospf.v3.router.lsa.flags.b", FT_BOOLEAN, 8,
3232 TFS(&tfs_v3_router_lsa_flags_b), OSPF_V3_ROUTER_LSA_FLAG_B, NULL, HFILL }},
3233 {&ospf_filter[OSPFF_V3_ROUTER_LSA_FLAG_E],
3234 { "E", "ospf.v3.router.lsa.flags.e", FT_BOOLEAN, 8,
3235 TFS(&tfs_v3_router_lsa_flags_e), OSPF_V3_ROUTER_LSA_FLAG_E, NULL, HFILL }},
3236 {&ospf_filter[OSPFF_V3_ROUTER_LSA_FLAG_V],
3237 { "V", "ospf.v3.router.lsa.flags.v", FT_BOOLEAN, 8,
3238 TFS(&tfs_v3_router_lsa_flags_v), OSPF_V3_ROUTER_LSA_FLAG_V, NULL, HFILL }},
3239 {&ospf_filter[OSPFF_V3_ROUTER_LSA_FLAG_W],
3240 { "W", "ospf.v3.router.lsa.flags.w", FT_BOOLEAN, 8,
3241 TFS(&tfs_v3_router_lsa_flags_w), OSPF_V3_ROUTER_LSA_FLAG_W, NULL, HFILL }},
3242 {&ospf_filter[OSPFF_V3_AS_EXTERNAL_FLAG],
3243 { "Flags", "ospf.v3.as.external.flags", FT_UINT8, BASE_HEX,
3244 NULL, 0x0, NULL, HFILL }},
3245 {&ospf_filter[OSPFF_V3_AS_EXTERNAL_FLAG_T],
3246 { "T", "ospf.v3.as.external.flags.t", FT_BOOLEAN, 8,
3247 TFS(&tfs_v3_as_external_flags_t), OSPF_V3_AS_EXTERNAL_FLAG_T, NULL, HFILL }},
3248 {&ospf_filter[OSPFF_V3_AS_EXTERNAL_FLAG_F],
3249 { "F", "ospf.v3.as.external.flags.f", FT_BOOLEAN, 8,
3250 TFS(&tfs_v3_as_external_flags_f), OSPF_V3_AS_EXTERNAL_FLAG_F, NULL, HFILL }},
3251 {&ospf_filter[OSPFF_V3_AS_EXTERNAL_FLAG_E],
3252 { "E", "ospf.v3.as.external.flags.e", FT_BOOLEAN, 8,
3253 TFS(&tfs_v3_as_external_flags_e), OSPF_V3_AS_EXTERNAL_FLAG_E, NULL, HFILL }},
3254 {&ospf_filter[OSPFF_V3_PREFIX_OPTION],
3255 { "PrefixOptions", "ospf.v3.prefix.options", FT_UINT8, BASE_HEX,
3256 NULL, 0x0, NULL, HFILL }},
3257 {&ospf_filter[OSPFF_V3_PREFIX_OPTION_NU],
3258 { "NU", "ospf.v3.prefix.options.nu", FT_BOOLEAN, 8,
3259 TFS(&tfs_v3_prefix_options_nu), OSPF_V3_PREFIX_OPTION_NU, NULL, HFILL }},
3260 {&ospf_filter[OSPFF_V3_PREFIX_OPTION_LA],
3261 { "LA", "ospf.v3.prefix.options.la", FT_BOOLEAN, 8,
3262 TFS(&tfs_v3_prefix_options_la), OSPF_V3_PREFIX_OPTION_LA, NULL, HFILL }},
3263 {&ospf_filter[OSPFF_V3_PREFIX_OPTION_MC],
3264 { "MC", "ospf.v3.prefix.options.mc", FT_BOOLEAN, 8,
3265 TFS(&tfs_v3_prefix_options_mc), OSPF_V3_PREFIX_OPTION_MC, NULL, HFILL }},
3266 {&ospf_filter[OSPFF_V3_PREFIX_OPTION_P],
3267 { "P", "ospf.v3.prefix.options.p", FT_BOOLEAN, 8,
3268 TFS(&tfs_v3_prefix_options_p), OSPF_V3_PREFIX_OPTION_P, NULL, HFILL }},
3270 /* OSPF Restart TLVs */
3271 {&ospf_filter[OSPFF_V2_GRACE_TLV],
3272 { "Grace TLV", "ospf.v2.grace", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}},
3273 {&ospf_filter[OSPFF_V2_GRACE_PERIOD],
3274 { "Grace Period", "ospf.v2.grace.period", FT_UINT32, BASE_DEC,
3276 "The number of seconds neighbors should advertise the router as fully adjacent",
3278 {&ospf_filter[OSPFF_V2_GRACE_REASON],
3279 { "Restart Reason", "ospf.v2.grace.reason", FT_UINT8, BASE_DEC,
3280 VALS(restart_reason_vals), 0x0, "The reason the router is restarting", HFILL }},
3281 {&ospf_filter[OSPFF_V2_GRACE_IP],
3282 { "Restart IP", "ospf.v2.grace.ip", FT_IPv4, BASE_NONE,
3283 NULL, 0x0, "The IP address of the interface originating this LSA", HFILL }},
3285 /* OSPFv3 LLS TLVs */
3286 {&ospf_filter[OSPFF_V3_LLS_EXT_OPTIONS_TLV],
3287 { "Extended Options TLV", "ospf.v3.lls.ext.options.tlv", FT_NONE, BASE_NONE,
3288 NULL, 0x0, NULL, HFILL }},
3289 {&ospf_filter[OSPFF_V3_LLS_EXT_OPTIONS],
3290 { "Options", "ospf.v3.lls.ext.options", FT_UINT32, BASE_HEX,
3291 NULL, 0x0, NULL, HFILL }},
3292 {&ospf_filter[OSPFF_V3_LLS_EXT_OPTIONS_LR],
3293 { "LR", "ospf.v3.lls.ext.options.lr", FT_BOOLEAN, 32,
3294 TFS(&tfs_v3_lls_ext_options_lr), OSPF_V3_LLS_EXT_OPTIONS_LR, NULL, HFILL }},
3295 {&ospf_filter[OSPFF_V3_LLS_EXT_OPTIONS_RS],
3296 { "RS", "ospf.v3.lls.ext.options.rs", FT_BOOLEAN, 32,
3297 TFS(&tfs_v3_lls_ext_options_rs), OSPF_V3_LLS_EXT_OPTIONS_RS, NULL, HFILL }},
3298 {&ospf_filter[OSPFF_V3_LLS_STATE_TLV],
3299 { "State Check Sequence TLV", "ospf.v3.lls.state.tlv", FT_NONE, BASE_NONE,
3300 NULL, 0x0, NULL, HFILL }},
3301 {&ospf_filter[OSPFF_V3_LLS_STATE_SCS],
3302 { "SCS Number", "ospf.v3.lls.state.scs", FT_UINT16, BASE_DEC,
3303 NULL, 0x0, NULL, HFILL }},
3304 {&ospf_filter[OSPFF_V3_LLS_STATE_OPTIONS],
3305 { "Options", "ospf.v3.lls.state.options", FT_UINT8, BASE_HEX,
3306 NULL, 0x0, NULL, HFILL }},
3307 {&ospf_filter[OSPFF_V3_LLS_STATE_OPTIONS_R],
3308 { "R", "ospf.v3.lls.state.options.r", FT_BOOLEAN, 8,
3309 TFS(&tfs_v3_lls_state_options_r), OSPF_V3_LLS_STATE_OPTIONS_R, NULL, HFILL }},
3310 {&ospf_filter[OSPFF_V3_LLS_STATE_OPTIONS_A],
3311 { "A", "ospf.v3.lls.state.options.a", FT_BOOLEAN, 8,
3312 TFS(&tfs_v3_lls_state_options_a), OSPF_V3_LLS_STATE_OPTIONS_A , NULL, HFILL }},
3313 {&ospf_filter[OSPFF_V3_LLS_STATE_OPTIONS_N],
3314 { "N", "ospf.v3.lls.state.options.n", FT_BOOLEAN, 8,
3315 TFS(&tfs_v3_lls_state_options_n), OSPF_V3_LLS_STATE_OPTIONS_N ,NULL, HFILL }},
3316 {&ospf_filter[OSPFF_V3_LLS_DROP_TLV],
3317 { "Neighbor Drop TLV", "ospf.v3.lls.drop.tlv", FT_NONE, BASE_NONE,
3318 NULL, 0x0, NULL, HFILL }},
3319 {&ospf_filter[OSPFF_V3_LLS_RELAY_TLV],
3320 { "Active Overlapping Relays TLV", "ospf.v3.lls.relay.tlv", FT_NONE, BASE_NONE,
3321 NULL, 0x0, NULL, HFILL }},
3322 {&ospf_filter[OSPFF_V3_LLS_RELAY_ADDED],
3323 { "Relays Added", "ospf.v3.lls.relay.added", FT_UINT8, BASE_DEC,
3324 NULL, 0x0, NULL, HFILL }},
3325 {&ospf_filter[OSPFF_V3_LLS_RELAY_OPTIONS],
3326 { "Options", "ospf.v3.lls.relay.options", FT_UINT8, BASE_HEX,
3327 NULL, 0x0, NULL, HFILL }},
3328 {&ospf_filter[OSPFF_V3_LLS_RELAY_OPTIONS_A],
3329 { "A", "ospf.v3.lls.relay.options.a", FT_BOOLEAN, 8,
3330 TFS(&tfs_v3_lls_relay_options_a), OSPF_V3_LLS_RELAY_OPTIONS_A , NULL, HFILL }},
3331 {&ospf_filter[OSPFF_V3_LLS_RELAY_OPTIONS_N],
3332 { "N", "ospf.v3.lls.relay.options.n", FT_BOOLEAN, 8,
3333 TFS(&tfs_v3_lls_relay_options_n), OSPF_V3_LLS_RELAY_OPTIONS_N ,NULL, HFILL }},
3334 {&ospf_filter[OSPFF_V3_LLS_WILLINGNESS_TLV],
3335 { "Willingness TLV", "ospf.v3.lls.willingness.tlv", FT_NONE, BASE_NONE,
3336 NULL, 0x0, NULL, HFILL }},
3337 {&ospf_filter[OSPFF_V3_LLS_WILLINGNESS],
3338 { "Willingness", "ospf.v3.lls.willingness", FT_UINT8, BASE_DEC,
3339 NULL, 0x0, NULL, HFILL }},
3340 {&ospf_filter[OSPFF_V3_LLS_RF_TLV],
3341 { "Request From TLV", "ospf.v3.lls.rf.tlv", FT_NONE, BASE_NONE,
3342 NULL, 0x0, NULL, HFILL }},
3343 {&ospf_filter[OSPFF_V3_LLS_FSF_TLV],
3344 { "Full State For TLV", "ospf.v3.lls.fsf.tlv", FT_NONE, BASE_NONE,
3345 NULL, 0x0, NULL, HFILL }}
3348 static gint *ett[] = {
3355 &ett_ospf_lsa_router_link,
3358 &ett_ospf_lsa_mpls_router,
3359 &ett_ospf_lsa_mpls_link,
3360 &ett_ospf_lsa_mpls_link_stlv,
3361 &ett_ospf_lsa_mpls_link_stlv_admingrp,
3362 &ett_ospf_lsa_oif_tna,
3363 &ett_ospf_lsa_oif_tna_stlv,
3364 &ett_ospf_lsa_grace_tlv,
3365 &ett_ospf_v2_options,
3366 &ett_ospf_v3_options,
3368 &ett_ospf_lls_data_block,
3370 &ett_ospf_lls_ext_options,
3371 &ett_ospf_v3_lls_ext_options_tlv,
3372 &ett_ospf_v3_lls_ext_options,
3373 &ett_ospf_v3_lls_state_tlv,
3374 &ett_ospf_v3_lls_state_scs,
3375 &ett_ospf_v3_lls_state_options,
3376 &ett_ospf_v3_lls_drop_tlv,
3377 &ett_ospf_v3_lls_relay_tlv,
3378 &ett_ospf_v3_lls_relay_added,
3379 &ett_ospf_v3_lls_relay_options,
3380 &ett_ospf_v3_lls_willingness_tlv,
3381 &ett_ospf_v3_lls_willingness,
3382 &ett_ospf_v3_lls_rf_tlv,
3383 &ett_ospf_v3_lls_fsf_tlv,
3384 &ett_ospf_v2_router_lsa_flags,
3385 &ett_ospf_v3_router_lsa_flags,
3386 &ett_ospf_v3_as_external_flags,
3387 &ett_ospf_v3_prefix_options
3390 proto_ospf = proto_register_protocol("Open Shortest Path First",
3392 proto_register_field_array(proto_ospf, ospff_info, array_length(ospff_info));
3393 proto_register_subtree_array(ett, array_length(ett));
3397 proto_reg_handoff_ospf(void)
3399 dissector_handle_t ospf_handle;
3401 ospf_handle = create_dissector_handle(dissect_ospf, proto_ospf);
3402 dissector_add("ip.proto", IP_PROTO_OSPF, ospf_handle);
3403 data_handle = find_dissector("data");