2 * Routines for OSPF packet disassembly
3 * (c) Copyright Hannes R. Boehm <hannes@boehm.org>
7 * At this time, this module is able to analyze OSPF
8 * packets as specified in RFC2328. MOSPF (RFC1584) and other
9 * OSPF Extensions which introduce new Packet types
10 * (e.g the External Atributes LSA) are not supported.
11 * Furthermore RFC2740 (OSPFv3 - OSPF for IPv6) is now supported
12 * - (c) 2001 Palle Lyckegaard <palle[AT]lyckegaard.dk>
14 * Added support to E-NNI routing (OIF2003.259.02)
15 * - (c) 2004 Roberto Morro <roberto.morro[AT]tilab.com>
17 * TOS - support is not fully implemented
19 * Ethereal - Network traffic analyzer
20 * By Gerald Combs <gerald@ethereal.com>
21 * Copyright 1998 Gerald Combs
23 * This program is free software; you can redistribute it and/or
24 * modify it under the terms of the GNU General Public License
25 * as published by the Free Software Foundation; either version 2
26 * of the License, or (at your option) any later version.
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the Free Software
35 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
46 #include <epan/packet.h>
47 #include <epan/ipproto.h>
48 #include <epan/in_cksum.h>
49 #include "packet-rsvp.h"
51 #define OSPF_VERSION_2 2
52 #define OSPF_VERSION_3 3
53 #define OSPF_VERSION_2_HEADER_LENGTH 24
54 #define OSPF_VERSION_3_HEADER_LENGTH 16
58 #define OSPF_DB_DESC 2
63 static const value_string pt_vals[] = {
64 {OSPF_HELLO, "Hello Packet" },
65 {OSPF_DB_DESC, "DB Descr." },
66 {OSPF_LS_REQ, "LS Request" },
67 {OSPF_LS_UPD, "LS Update" },
68 {OSPF_LS_ACK, "LS Acknowledge" },
72 #define OSPF_AUTH_NONE 0
73 #define OSPF_AUTH_SIMPLE 1
74 #define OSPF_AUTH_CRYPT 2
76 static const value_string auth_vals[] = {
77 {OSPF_AUTH_NONE, "Null" },
78 {OSPF_AUTH_SIMPLE, "Simple password" },
79 {OSPF_AUTH_CRYPT, "Cryptographic" },
83 #define OSPF_V2_OPTIONS_DN 0x01
84 #define OSPF_V2_OPTIONS_E 0x02
85 #define OSPF_V2_OPTIONS_MC 0x04
86 #define OSPF_V2_OPTIONS_NP 0x08
87 #define OSPF_V2_OPTIONS_EA 0x10
88 #define OSPF_V2_OPTIONS_DC 0x20
89 #define OSPF_V2_OPTIONS_O 0x40
90 #define OSPF_V3_OPTIONS_V6 0x01
91 #define OSPF_V3_OPTIONS_E 0x02
92 #define OSPF_V3_OPTIONS_MC 0x04
93 #define OSPF_V3_OPTIONS_N 0x08
94 #define OSPF_V3_OPTIONS_R 0x10
95 #define OSPF_V3_OPTIONS_DC 0x20
98 #define OSPF_DBD_FLAG_MS 1
99 #define OSPF_DBD_FLAG_M 2
100 #define OSPF_DBD_FLAG_I 4
102 #define OSPF_LS_REQ_LENGTH 12
104 #define OSPF_LSTYPE_ROUTER 1
105 #define OSPF_LSTYPE_NETWORK 2
106 #define OSPF_LSTYPE_SUMMERY 3
107 #define OSPF_LSTYPE_ASBR 4
108 #define OSPF_LSTYPE_ASEXT 5
109 #define OSPF_LSTYPE_GRPMEMBER 6
110 #define OSPF_LSTYPE_ASEXT7 7
111 #define OSPF_LSTYPE_EXTATTR 8
112 #define OSPF_V3_LSTYPE_ROUTER 0x2001
113 #define OSPF_V3_LSTYPE_NETWORK 0x2002
114 #define OSPF_V3_LSTYPE_INTER_AREA_PREFIX 0x2003
115 #define OSPF_V3_LSTYPE_INTER_AREA_ROUTER 0x2004
116 #define OSPF_V3_LSTYPE_AS_EXTERNAL 0x4005
117 #define OSPF_V3_LSTYPE_GROUP_MEMBERSHIP 0x2006
118 #define OSPF_V3_LSTYPE_TYPE_7 0x2007
119 #define OSPF_V3_LSTYPE_LINK 0x0008
120 #define OSPF_V3_LSTYPE_INTRA_AREA_PREFIX 0x2009
122 /* Opaque LSA types */
123 #define OSPF_LSTYPE_OP_LINKLOCAL 9
124 #define OSPF_LSTYPE_OP_AREALOCAL 10
125 #define OSPF_LSTYPE_OP_ASWIDE 11
127 #define OSPF_LINK_PTP 1
128 #define OSPF_LINK_TRANSIT 2
129 #define OSPF_LINK_STUB 3
130 #define OSPF_LINK_VIRTUAL 4
132 #define OSPF_V3_LINK_PTP 1
133 #define OSPF_V3_LINK_TRANSIT 2
134 #define OSPF_V3_LINK_RESERVED 3
135 #define OSPF_V3_LINK_VIRTUAL 4
137 #define OSPF_LSA_HEADER_LENGTH 20
139 /* Known opaque LSAs */
140 #define OSPF_LSA_MPLS_TE 1
143 static const value_string ls_type_vals[] = {
144 {OSPF_LSTYPE_ROUTER, "Router-LSA" },
145 {OSPF_LSTYPE_NETWORK, "Network-LSA" },
146 {OSPF_LSTYPE_SUMMERY, "Summary-LSA (IP network)" },
147 {OSPF_LSTYPE_ASBR, "Summary-LSA (ASBR)" },
148 {OSPF_LSTYPE_ASEXT, "AS-External-LSA (ASBR)" },
149 {OSPF_LSTYPE_GRPMEMBER, "Group Membership LSA" },
150 {OSPF_LSTYPE_ASEXT7, "NSSA AS-External-LSA" },
151 {OSPF_LSTYPE_EXTATTR, "External Attributes LSA" },
152 {OSPF_LSTYPE_OP_LINKLOCAL, "Opaque LSA, Link-local scope" },
153 {OSPF_LSTYPE_OP_AREALOCAL, "Opaque LSA, Area-local scope" },
158 static const value_string ls_opaque_type_vals[] = {
159 {OSPF_LSA_MPLS_TE, "Traffic Engineering LSA" },
160 {2, "Sycamore Optical Topology Descriptions" },
165 static const value_string v3_ls_type_vals[] = {
166 {OSPF_V3_LSTYPE_ROUTER, "Router-LSA" },
167 {OSPF_V3_LSTYPE_NETWORK, "Network-LSA" },
168 {OSPF_V3_LSTYPE_INTER_AREA_PREFIX, "Inter-Area-Prefix-LSA" },
169 {OSPF_V3_LSTYPE_INTER_AREA_ROUTER, "Inter-Area-Router-LSA" },
170 {OSPF_V3_LSTYPE_AS_EXTERNAL, "AS-External-LSA" },
171 {OSPF_V3_LSTYPE_GROUP_MEMBERSHIP, "Group-Membership-LSA" },
172 {OSPF_V3_LSTYPE_TYPE_7, "Type-LSA" },
173 {OSPF_V3_LSTYPE_LINK, "Link-LSA" },
174 {OSPF_V3_LSTYPE_INTRA_AREA_PREFIX, "Intra-Area-Prefix-LSA" },
179 static const value_string mpls_link_stlv_ltype_str[] = {
180 {1, "Point-to-point"},
185 #define OSPF_V3_ROUTER_LSA_FLAG_B 0x01
186 #define OSPF_V3_ROUTER_LSA_FLAG_E 0x02
187 #define OSPF_V3_ROUTER_LSA_FLAG_V 0x04
188 #define OSPF_V3_ROUTER_LSA_FLAG_W 0x08
190 #define OSPF_V3_PREFIX_OPTION_NU 0x01
191 #define OSPF_V3_PREFIX_OPTION_LA 0x02
192 #define OSPF_V3_PREFIX_OPTION_MC 0x04
193 #define OSPF_V3_PREFIX_OPTION_P 0x08
195 #define OSPF_V3_AS_EXTERNAL_FLAG_T 0x01
196 #define OSPF_V3_AS_EXTERNAL_FLAG_F 0x02
197 #define OSPF_V3_AS_EXTERNAL_FLAG_E 0x04
200 static int proto_ospf = -1;
202 static gint ett_ospf = -1;
203 static gint ett_ospf_hdr = -1;
204 static gint ett_ospf_hello = -1;
205 static gint ett_ospf_desc = -1;
206 static gint ett_ospf_lsr = -1;
207 static gint ett_ospf_lsa = -1;
208 static gint ett_ospf_lsa_router_link = -1;
209 static gint ett_ospf_lsa_upd = -1;
211 /* Trees for opaque LSAs */
212 static gint ett_ospf_lsa_mpls = -1;
213 static gint ett_ospf_lsa_mpls_router = -1;
214 static gint ett_ospf_lsa_mpls_link = -1;
215 static gint ett_ospf_lsa_mpls_link_stlv = -1;
216 static gint ett_ospf_lsa_mpls_link_stlv_admingrp = -1;
217 static gint ett_ospf_lsa_oif_tna = -1;
218 static gint ett_ospf_lsa_oif_tna_stlv = -1;
220 /*-----------------------------------------------------------------------
222 *-----------------------------------------------------------------------*/
224 /* The OSPF filtering keys */
237 OSPFF_LS_OPAQUE_TYPE,
239 OSPFF_LS_MPLS_TE_INSTANCE,
255 OSPFF_LS_MPLS_ROUTERID,
257 OSPFF_LS_MPLS_LINKTYPE,
258 OSPFF_LS_MPLS_LINKID,
259 OSPFF_LS_MPLS_LOCAL_ADDR,
260 OSPFF_LS_MPLS_REMOTE_ADDR,
261 OSPFF_LS_MPLS_LOCAL_IFID,
262 OSPFF_LS_MPLS_REMOTE_IFID,
263 OSPFF_LS_MPLS_LINKCOLOR,
268 static int ospf_filter[OSPFF_MAX];
270 static hf_register_info ospff_info[] = {
272 /* Message type number */
273 {&ospf_filter[OSPFF_MSG_TYPE],
274 { "Message Type", "ospf.msg", FT_UINT8, BASE_DEC, VALS(pt_vals), 0x0,
278 {&ospf_filter[OSPFF_MSG_HELLO],
279 { "Hello", "ospf.msg.hello", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
281 {&ospf_filter[OSPFF_MSG_DB_DESC],
282 { "Database Description", "ospf.msg.dbdesc", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
284 {&ospf_filter[OSPFF_MSG_LS_REQ],
285 { "Link State Adv Request", "ospf.msg.lsreq", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
287 {&ospf_filter[OSPFF_MSG_LS_UPD],
288 { "Link State Adv Update", "ospf.msg.lsupdate", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
290 {&ospf_filter[OSPFF_MSG_LS_ACK],
291 { "Link State Adv Acknowledgement", "ospf.msg.lsack", FT_BOOLEAN,
292 BASE_NONE, NULL, 0x0, "", HFILL }},
297 {&ospf_filter[OSPFF_LS_TYPE],
298 { "Link-State Advertisement Type", "ospf.lsa", FT_UINT8, BASE_DEC,
299 VALS(ls_type_vals), 0x0, "", HFILL }},
300 {&ospf_filter[OSPFF_LS_OPAQUE_TYPE],
301 { "Link State ID Opaque Type", "ospf.lsid_opaque_type", FT_UINT8, BASE_DEC,
302 VALS(ls_opaque_type_vals), 0x0, "", HFILL }},
304 {&ospf_filter[OSPFF_LS_MPLS_TE_INSTANCE],
305 { "Link State ID TE-LSA Instance", "ospf.lsid_te_lsa.instance", FT_UINT16, BASE_DEC,
306 NULL, 0x0, "", HFILL }},
308 {&ospf_filter[OSPFF_LS_ROUTER],
309 { "Router LSA", "ospf.lsa.router", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
311 {&ospf_filter[OSPFF_LS_NETWORK],
312 { "Network LSA", "ospf.lsa.network", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
314 {&ospf_filter[OSPFF_LS_SUMMARY],
315 { "Summary LSA (IP Network)", "ospf.lsa.summary", FT_BOOLEAN, BASE_NONE,
316 NULL, 0x0, "", HFILL }},
317 {&ospf_filter[OSPFF_LS_ASBR],
318 { "Summary LSA (ASBR)", "ospf.lsa.asbr", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
320 {&ospf_filter[OSPFF_LS_ASEXT],
321 { "AS-External LSA (ASBR)", "ospf.lsa.asext", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
323 {&ospf_filter[OSPFF_LS_GRPMEMBER],
324 { "Group Membership LSA", "ospf.lsa.member", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
326 {&ospf_filter[OSPFF_LS_ASEXT7],
327 { "NSSA AS-External LSA", "ospf.lsa.nssa", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
329 {&ospf_filter[OSPFF_LS_EXTATTR],
330 { "External Attributes LSA", "ospf.lsa.attr", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
332 {&ospf_filter[OSPFF_LS_OPAQUE],
333 { "Opaque LSA", "ospf.lsa.opaque", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
336 /* Other interesting OSPF values */
338 {&ospf_filter[OSPFF_SRC_ROUTER],
339 { "Source OSPF Router", "ospf.srcrouter", FT_IPv4, BASE_NONE, NULL, 0x0,
342 {&ospf_filter[OSPFF_ADV_ROUTER],
343 { "Advertising Router", "ospf.advrouter", FT_IPv4, BASE_NONE, NULL, 0x0,
346 {&ospf_filter[OSPFF_LS_MPLS],
347 { "MPLS Traffic Engineering LSA", "ospf.lsa.mpls", FT_BOOLEAN,
348 BASE_NONE, NULL, 0x0, "", HFILL }},
350 {&ospf_filter[OSPFF_LS_MPLS_ROUTERID],
351 { "MPLS/TE Router ID", "ospf.mpls.routerid", FT_IPv4, BASE_NONE, NULL, 0x0,
354 {&ospf_filter[OSPFF_LS_MPLS_LINKTYPE],
355 { "MPLS/TE Link Type", "ospf.mpls.linktype", FT_UINT8, BASE_DEC, VALS(mpls_link_stlv_ltype_str), 0x0,
356 "MPLS/TE Link Type", HFILL }},
357 {&ospf_filter[OSPFF_LS_MPLS_LINKID],
358 { "MPLS/TE Link ID", "ospf.mpls.linkid", FT_IPv4, BASE_NONE, NULL, 0x0,
360 {&ospf_filter[OSPFF_LS_MPLS_LOCAL_ADDR],
361 { "MPLS/TE Local Interface Address", "ospf.mpls.local_addr", FT_IPv4,
362 BASE_NONE, NULL, 0x0, "", HFILL }},
363 {&ospf_filter[OSPFF_LS_MPLS_REMOTE_ADDR],
364 { "MPLS/TE Remote Interface Address", "ospf.mpls.remote_addr", FT_IPv4,
365 BASE_NONE, NULL, 0x0, "", HFILL }},
366 {&ospf_filter[OSPFF_LS_MPLS_LOCAL_IFID],
367 { "MPLS/TE Local Interface Index", "ospf.mpls.local_id", FT_UINT32,
368 BASE_DEC, NULL, 0x0, "", HFILL }},
369 {&ospf_filter[OSPFF_LS_MPLS_REMOTE_IFID],
370 { "MPLS/TE Remote Interface Index", "ospf.mpls.remote_id", FT_UINT32,
371 BASE_DEC, NULL, 0x0, "", HFILL }},
372 {&ospf_filter[OSPFF_LS_MPLS_LINKCOLOR],
373 { "MPLS/TE Link Resource Class/Color", "ospf.mpls.linkcolor", FT_UINT32,
374 BASE_HEX, NULL, 0x0, "MPLS/TE Link Resource Class/Color", HFILL }},
380 static guint8 ospf_msg_type_to_filter (guint8 msg_type)
382 if (msg_type >= OSPF_HELLO &&
383 msg_type <= OSPF_LS_ACK)
384 return msg_type + OSPFF_MSG_MIN;
388 static guint8 ospf_ls_type_to_filter (guint8 ls_type)
390 if (ls_type >= OSPF_LSTYPE_ROUTER &&
391 ls_type <= OSPF_LSTYPE_EXTATTR)
392 return OSPFF_LS_MIN + ls_type;
393 else if (ls_type >= OSPF_LSTYPE_OP_LINKLOCAL &&
394 ls_type <= OSPF_LSTYPE_OP_ASWIDE)
395 return OSPFF_LS_OPAQUE;
400 static dissector_handle_t data_handle;
402 static void dissect_ospf_hello(tvbuff_t*, int, proto_tree*, guint8);
403 static void dissect_ospf_db_desc(tvbuff_t*, int, proto_tree*, guint8);
404 static void dissect_ospf_ls_req(tvbuff_t*, int, proto_tree*, guint8);
405 static void dissect_ospf_ls_upd(tvbuff_t*, int, proto_tree*, guint8);
406 static void dissect_ospf_ls_ack(tvbuff_t*, int, proto_tree*, guint8);
408 /* dissect_ospf_v[23]lsa returns the offset of the next LSA
409 * if disassemble_body is set to FALSE (e.g. in LSA ACK
410 * packets), the offset is set to the offset of the next
413 static int dissect_ospf_v2_lsa(tvbuff_t*, int, proto_tree*, gboolean disassemble_body);
414 static int dissect_ospf_v3_lsa(tvbuff_t*, int, proto_tree*, gboolean disassemble_body);
416 static void dissect_ospf_options(tvbuff_t *, int, proto_tree *, guint8);
418 static void dissect_ospf_v3_prefix_options(tvbuff_t *, int, proto_tree *);
420 static void dissect_ospf_v3_address_prefix(tvbuff_t *, int, int, proto_tree *);
423 dissect_ospf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
425 proto_tree *ospf_tree = NULL;
427 proto_tree *ospf_header_tree;
434 guint16 cksum, computed_cksum;
435 guint length, reported_length;
439 unsigned int ospf_header_length;
445 if (check_col(pinfo->cinfo, COL_PROTOCOL))
446 col_set_str(pinfo->cinfo, COL_PROTOCOL, "OSPF");
447 if (check_col(pinfo->cinfo, COL_INFO))
448 col_clear(pinfo->cinfo, COL_INFO);
450 version = tvb_get_guint8(tvb, 0);
453 ospf_header_length = OSPF_VERSION_2_HEADER_LENGTH;
456 ospf_header_length = OSPF_VERSION_3_HEADER_LENGTH;
459 ospf_header_length = 0;
463 packet_type = tvb_get_guint8(tvb, 1);
464 if (check_col(pinfo->cinfo, COL_INFO)) {
465 col_add_str(pinfo->cinfo, COL_INFO,
466 val_to_str(packet_type, pt_vals, "Unknown (%u)"));
470 ospflen = tvb_get_ntohs(tvb, 2);
472 ti = proto_tree_add_item(tree, proto_ospf, tvb, 0, ospflen, FALSE);
473 ospf_tree = proto_item_add_subtree(ti, ett_ospf);
475 ti = proto_tree_add_text(ospf_tree, tvb, 0, ospf_header_length,
477 ospf_header_tree = proto_item_add_subtree(ti, ett_ospf_hdr);
479 proto_tree_add_text(ospf_header_tree, tvb, 0, 1, "OSPF Version: %u",
481 proto_tree_add_item(ospf_header_tree, ospf_filter[OSPFF_MSG_TYPE],
483 proto_tree_add_item_hidden(ospf_header_tree,
484 ospf_filter[ospf_msg_type_to_filter(packet_type)],
486 proto_tree_add_text(ospf_header_tree, tvb, 2, 2, "Packet Length: %u",
488 proto_tree_add_item(ospf_header_tree, ospf_filter[OSPFF_SRC_ROUTER],
490 areaid=tvb_get_ntohl(tvb,8);
491 proto_tree_add_text(ospf_header_tree, tvb, 8, 4, "Area ID: %s%s",
492 ip_to_str(tvb_get_ptr(tvb, 8, 4)), areaid == 0 ? " (Backbone)" : "");
493 cksum = tvb_get_ntohs(tvb, 12);
494 length = tvb_length(tvb);
495 /* XXX - include only the length from the OSPF header? */
496 reported_length = tvb_reported_length(tvb);
498 /* No checksum supplied in the packet. */
499 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
500 "Packet Checksum: 0x%04x (none)", cksum);
501 } else if (!pinfo->fragmented && length >= reported_length
502 && length >= ospf_header_length
503 && (version == OSPF_VERSION_2 || version == OSPF_VERSION_3)) {
504 /* The packet isn't part of a fragmented datagram and isn't
505 truncated, and we know how to checksum this version of
506 OSPF, so we can checksum it. */
511 /* Header, not including the authentication data (the OSPFv2
512 checksum excludes the 64-bit authentication field). */
513 cksum_vec[0].ptr = tvb_get_ptr(tvb, 0, 16);
514 cksum_vec[0].len = 16;
515 if (length > ospf_header_length) {
516 /* Rest of the packet, again not including the
517 authentication data. */
518 reported_length -= ospf_header_length;
519 cksum_vec[1].ptr = tvb_get_ptr(tvb, ospf_header_length, reported_length);
520 cksum_vec[1].len = reported_length;
523 /* There's nothing but a header. */
529 /* IPv6-style checksum, covering the entire OSPF packet
530 and a prepended IPv6 pseudo-header. */
532 /* Set up the fields of the pseudo-header. */
533 cksum_vec[0].ptr = pinfo->src.data;
534 cksum_vec[0].len = pinfo->src.len;
535 cksum_vec[1].ptr = pinfo->dst.data;
536 cksum_vec[1].len = pinfo->dst.len;
537 cksum_vec[2].ptr = (const guint8 *)&phdr;
538 phdr[0] = g_htonl(ospflen);
539 phdr[1] = g_htonl(IP_PROTO_OSPF);
540 cksum_vec[2].len = 8;
542 cksum_vec[3].ptr = tvb_get_ptr(tvb, 0, reported_length);
543 cksum_vec[3].len = reported_length;
548 g_assert_not_reached();
551 computed_cksum = in_cksum(cksum_vec, cksum_vec_len);
552 if (computed_cksum == 0) {
553 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
554 "Packet Checksum: 0x%04x (correct)", cksum);
556 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
557 "Packet Checksum: 0x%04x (incorrect, should be 0x%04x)",
558 cksum, in_cksum_shouldbe(cksum, computed_cksum));
561 proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
562 "Packet Checksum: 0x%04x", cksum);
566 /* Authentication is only valid for OSPFv2 */
567 if ( version == OSPF_VERSION_2 ) {
568 auth_type = tvb_get_ntohs(tvb, 14);
569 proto_tree_add_text(ospf_header_tree, tvb, 14, 2, "Auth Type: %s",
570 val_to_str(auth_type, auth_vals, "Unknown (%u)"));
574 proto_tree_add_text(ospf_header_tree, tvb, 16, 8, "Auth Data (none)");
577 case OSPF_AUTH_SIMPLE:
578 tvb_get_nstringz0(tvb, 16, 8+1, auth_data);
579 proto_tree_add_text(ospf_header_tree, tvb, 16, 8, "Auth Data: %s", auth_data);
582 case OSPF_AUTH_CRYPT:
583 proto_tree_add_text(ospf_header_tree, tvb, 18, 1, "Auth Key ID: %u",
584 tvb_get_guint8(tvb, 18));
585 crypto_len = tvb_get_guint8(tvb, 19);
586 proto_tree_add_text(ospf_header_tree, tvb, 19, 1, "Auth Data Length: %u",
588 proto_tree_add_text(ospf_header_tree, tvb, 20, 4, "Auth Crypto Sequence Number: 0x%x",
589 tvb_get_ntohl(tvb, 20));
591 /* Show the message digest that was appended to the end of the
592 OSPF message - but only if it's present (we don't want
593 to get an exception before we've tried dissecting OSPF
595 if (tvb_bytes_exist(tvb, ospflen, crypto_len)) {
596 proto_tree_add_text(ospf_header_tree, tvb, ospflen, crypto_len,
598 tvb_bytes_to_str(tvb, ospflen, crypto_len));
603 proto_tree_add_text(ospf_header_tree, tvb, 16, 8, "Auth Data (unknown)");
609 /* Instance ID and "reserved" is OSPFv3-only */
610 if ( version == OSPF_VERSION_3 ) {
611 instance_ID = tvb_get_guint8(tvb, 14);
612 proto_tree_add_text(ospf_header_tree, tvb, 14, 1, "Instance ID: %u",
614 reserved = tvb_get_guint8(tvb, 15);
615 proto_tree_add_text(ospf_header_tree, tvb, 15, 1, (reserved == 0 ? "Reserved: %u" : "Reserved: %u (incorrect, should be 0)"),
620 /* Adjust the length of the tvbuff to match the size of the OSPF
621 * packet (since the dissect routines use it to work out where the
622 * end of the OSPF packet is).
624 tvb_set_reported_length(tvb, ospflen);
626 switch (packet_type){
629 dissect_ospf_hello(tvb, ospf_header_length, ospf_tree, version);
633 dissect_ospf_db_desc(tvb, ospf_header_length, ospf_tree, version);
637 dissect_ospf_ls_req(tvb, ospf_header_length, ospf_tree, version);
641 dissect_ospf_ls_upd(tvb, ospf_header_length, ospf_tree, version);
645 dissect_ospf_ls_ack(tvb, ospf_header_length, ospf_tree, version);
649 call_dissector(data_handle,
650 tvb_new_subset(tvb, ospf_header_length, -1, -1), pinfo, tree);
657 dissect_ospf_hello(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version)
659 proto_tree *ospf_hello_tree;
662 ti = proto_tree_add_text(tree, tvb, offset, -1, "OSPF Hello Packet");
663 ospf_hello_tree = proto_item_add_subtree(ti, ett_ospf_hello);
667 proto_tree_add_text(ospf_hello_tree, tvb, offset, 4, "Network Mask: %s",
668 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
669 proto_tree_add_text(ospf_hello_tree, tvb, offset + 4, 2,
670 "Hello Interval: %u seconds",
671 tvb_get_ntohs(tvb, offset + 4));
673 dissect_ospf_options(tvb, offset + 6, ospf_hello_tree, version);
674 proto_tree_add_text(ospf_hello_tree, tvb, offset + 7, 1, "Router Priority: %u",
675 tvb_get_guint8(tvb, offset + 7));
676 proto_tree_add_text(ospf_hello_tree, tvb, offset + 8, 4, "Router Dead Interval: %u seconds",
677 tvb_get_ntohl(tvb, offset + 8));
678 proto_tree_add_text(ospf_hello_tree, tvb, offset + 12, 4, "Designated Router: %s",
679 ip_to_str(tvb_get_ptr(tvb, offset + 12, 4)));
680 proto_tree_add_text(ospf_hello_tree, tvb, offset + 16, 4, "Backup Designated Router: %s",
681 ip_to_str(tvb_get_ptr(tvb, offset + 16, 4)));
684 while (tvb_reported_length_remaining(tvb, offset) != 0) {
685 proto_tree_add_text(ospf_hello_tree, tvb, offset, 4,
686 "Active Neighbor: %s",
687 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
692 proto_tree_add_text(ospf_hello_tree, tvb, offset + 0, 4, "Interface ID: %u",
693 tvb_get_ntohl(tvb, offset + 0));
694 proto_tree_add_text(ospf_hello_tree, tvb, offset + 4, 1, "Router Priority: %u",
695 tvb_get_guint8(tvb, offset + 4));
696 dissect_ospf_options(tvb, offset + 5, ospf_hello_tree, version);
697 proto_tree_add_text(ospf_hello_tree, tvb, offset + 8, 2,
698 "Hello Interval: %u seconds",
699 tvb_get_ntohs(tvb, offset + 8));
700 proto_tree_add_text(ospf_hello_tree, tvb, offset + 10, 2, "Router Dead Interval: %u seconds",
701 tvb_get_ntohs(tvb, offset + 10));
702 proto_tree_add_text(ospf_hello_tree, tvb, offset + 12, 4, "Designated Router: %s",
703 ip_to_str(tvb_get_ptr(tvb, offset + 12, 4)));
704 proto_tree_add_text(ospf_hello_tree, tvb, offset + 16, 4, "Backup Designated Router: %s",
705 ip_to_str(tvb_get_ptr(tvb, offset + 16, 4)));
707 while (tvb_reported_length_remaining(tvb, offset) != 0) {
708 proto_tree_add_text(ospf_hello_tree, tvb, offset, 4,
709 "Active Neighbor: %s",
710 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
722 dissect_ospf_db_desc(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version)
724 proto_tree *ospf_db_desc_tree=NULL;
728 char flags_string[20] = "";
731 ti = proto_tree_add_text(tree, tvb, offset, -1, "OSPF DB Description");
732 ospf_db_desc_tree = proto_item_add_subtree(ti, ett_ospf_desc);
738 proto_tree_add_text(ospf_db_desc_tree, tvb, offset, 2, "Interface MTU: %u",
739 tvb_get_ntohs(tvb, offset));
741 dissect_ospf_options(tvb, offset + 2, ospf_db_desc_tree, version);
743 flags = tvb_get_guint8(tvb, offset + 3);
744 if (flags & OSPF_DBD_FLAG_MS)
745 strcat(flags_string, "MS");
746 if (flags & OSPF_DBD_FLAG_M) {
747 if (flags_string[0] != '\0')
748 strcat(flags_string, "/");
749 strcat(flags_string, "M");
751 if (flags & OSPF_DBD_FLAG_I) {
752 if (flags_string[0] != '\0')
753 strcat(flags_string, "/");
754 strcat(flags_string, "I");
756 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 3, 1, "Flags: 0x%x (%s)",
757 flags, flags_string);
758 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 4, 4, "DD Sequence: %u",
759 tvb_get_ntohl(tvb, offset + 4));
766 reserved = tvb_get_guint8(tvb, offset);
767 proto_tree_add_text(ospf_db_desc_tree, tvb, offset, 1, (reserved == 0 ? "Reserved: %u" : "Reserved: %u (incorrect, should be 0)"),
770 dissect_ospf_options(tvb, offset + 1, ospf_db_desc_tree, version);
772 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 4, 2, "Interface MTU: %u",
773 tvb_get_ntohs(tvb, offset+4));
775 reserved = tvb_get_guint8(tvb, offset + 6);
776 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 6, 1, (reserved == 0 ? "Reserved: %u" : "Reserved: %u (incorrect, should be 0)"),
779 flags = tvb_get_guint8(tvb, offset + 7);
780 if (flags & OSPF_DBD_FLAG_MS)
781 strcat(flags_string, "MS");
782 if (flags & OSPF_DBD_FLAG_M) {
783 if (flags_string[0] != '\0')
784 strcat(flags_string, "/");
785 strcat(flags_string, "M");
787 if (flags & OSPF_DBD_FLAG_I) {
788 if (flags_string[0] != '\0')
789 strcat(flags_string, "/");
790 strcat(flags_string, "I");
792 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 7, 1, "Flags: 0x%x (%s)",
793 flags, flags_string);
795 proto_tree_add_text(ospf_db_desc_tree, tvb, offset + 8, 4, "DD Sequence: %u",
796 tvb_get_ntohl(tvb, offset + 8));
806 /* LS Headers will be processed here */
807 /* skip to the end of DB-Desc header */
808 while (tvb_reported_length_remaining(tvb, offset) != 0) {
809 if ( version == OSPF_VERSION_2)
810 offset = dissect_ospf_v2_lsa(tvb, offset, tree, FALSE);
812 if ( version == OSPF_VERSION_3)
813 offset = dissect_ospf_v3_lsa(tvb, offset, tree, FALSE);
819 dissect_ospf_ls_req(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version)
821 proto_tree *ospf_lsr_tree;
826 /* zero or more LS requests may be within a LS Request */
827 /* we place every request for a LSA in a single subtree */
828 while (tvb_reported_length_remaining(tvb, offset) != 0) {
829 ti = proto_tree_add_text(tree, tvb, offset, OSPF_LS_REQ_LENGTH,
830 "Link State Request");
831 ospf_lsr_tree = proto_item_add_subtree(ti, ett_ospf_lsr);
836 ls_type = tvb_get_ntohl(tvb, offset);
837 proto_tree_add_item(ospf_lsr_tree, ospf_filter[OSPFF_LS_TYPE],
838 tvb, offset, 4, FALSE);
841 reserved = tvb_get_ntohs(tvb, offset);
842 proto_tree_add_text(ospf_lsr_tree, tvb, offset, 2,
843 (reserved == 0 ? "Reserved: %u" : "Reserved: %u (incorrect, should be 0)"), reserved);
844 ls_type = tvb_get_ntohs(tvb, offset+2);
845 proto_tree_add_text(ospf_lsr_tree, tvb, offset+2, 2, "LS Type: %s (0x%04x)",
846 val_to_str(ls_type, v3_ls_type_vals, "Unknown"),
855 proto_tree_add_text(ospf_lsr_tree, tvb, offset + 4, 4, "Link State ID: %s",
856 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
857 proto_tree_add_item(ospf_lsr_tree, ospf_filter[OSPFF_ADV_ROUTER],
858 tvb, offset + 8, 4, FALSE);
865 dissect_ospf_ls_upd(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version)
867 proto_tree *ospf_lsa_upd_tree=NULL;
872 ti = proto_tree_add_text(tree, tvb, offset, -1, "LS Update Packet");
873 ospf_lsa_upd_tree = proto_item_add_subtree(ti, ett_ospf_lsa_upd);
875 lsa_nr = tvb_get_ntohl(tvb, offset);
876 proto_tree_add_text(ospf_lsa_upd_tree, tvb, offset, 4, "Number of LSAs: %u",
878 /* skip to the beginning of the first LSA */
879 offset += 4; /* the LS Upd Packet contains only a 32 bit #LSAs field */
882 while (lsa_counter < lsa_nr) {
883 if ( version == OSPF_VERSION_2)
884 offset = dissect_ospf_v2_lsa(tvb, offset, ospf_lsa_upd_tree, TRUE);
886 if ( version == OSPF_VERSION_3)
887 offset = dissect_ospf_v3_lsa(tvb, offset, ospf_lsa_upd_tree, TRUE);
893 dissect_ospf_ls_ack(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version)
895 /* the body of a LS Ack packet simply contains zero or more LSA Headers */
896 while (tvb_reported_length_remaining(tvb, offset) != 0) {
897 if ( version == OSPF_VERSION_2)
898 offset = dissect_ospf_v2_lsa(tvb, offset, tree, FALSE);
900 if ( version == OSPF_VERSION_3)
901 offset = dissect_ospf_v3_lsa(tvb, offset, tree, FALSE);
906 * Returns if an LSA is opaque, i.e. requires special treatment
909 is_opaque(int lsa_type)
911 return (lsa_type >= OSPF_LSTYPE_OP_LINKLOCAL &&
912 lsa_type <= OSPF_LSTYPE_OP_ASWIDE);
915 /* MPLS/TE TLV types */
916 #define MPLS_TLV_ROUTER 1
917 #define MPLS_TLV_LINK 2
918 #define OIF_TLV_TNA 32768
920 /* MPLS/TE Link STLV types */
928 MPLS_LINK_MAX_RES_BW,
931 MPLS_LINK_LOCAL_REMOTE_ID = 11,
932 MPLS_LINK_PROTECTION = 14,
933 MPLS_LINK_IF_SWITCHING_DESC,
934 MPLS_LINK_SHARED_RISK_GROUP
939 OIF_LOCAL_NODE_ID = 32773,
941 OIF_SONET_SDH_SWITCHING_CAPABILITY,
942 OIF_TNA_IPv4_ADDRESS,
944 OIF_TNA_IPv6_ADDRESS,
948 static const value_string mpls_link_stlv_str[] = {
949 {MPLS_LINK_TYPE, "Link Type"},
950 {MPLS_LINK_ID, "Link ID"},
951 {MPLS_LINK_LOCAL_IF, "Local Interface IP Address"},
952 {MPLS_LINK_REMOTE_IF, "Remote Interface IP Address"},
953 {MPLS_LINK_TE_METRIC, "Traffic Engineering Metric"},
954 {MPLS_LINK_MAX_BW, "Maximum Bandwidth"},
955 {MPLS_LINK_MAX_RES_BW, "Maximum Reservable Bandwidth"},
956 {MPLS_LINK_UNRES_BW, "Unreserved Bandwidth"},
957 {MPLS_LINK_COLOR, "Resource Class/Color"},
958 {MPLS_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier"},
959 {MPLS_LINK_PROTECTION, "Link Protection Type"},
960 {MPLS_LINK_IF_SWITCHING_DESC, "Interface Switching Capability Descriptor"},
961 {MPLS_LINK_SHARED_RISK_GROUP, "Shared Risk Link Group"},
962 {OIF_LOCAL_NODE_ID, "Local Node ID"},
963 {OIF_REMOTE_NODE_ID, "Remote Node ID"},
964 {OIF_SONET_SDH_SWITCHING_CAPABILITY, "Sonet/SDH Interface Switching Capability"},
968 static const value_string oif_stlv_str[] = {
969 {OIF_TNA_IPv4_ADDRESS, "TNA address"},
970 {OIF_NODE_ID, "Node ID"},
971 {OIF_TNA_IPv6_ADDRESS, "TNA address"},
972 {OIF_TNA_NSAP_ADDRESS, "TNA address"},
977 * Dissect MPLS/TE opaque LSA
980 dissect_ospf_lsa_mpls(tvbuff_t *tvb, int offset, proto_tree *tree,
984 proto_tree *mpls_tree;
985 proto_tree *tlv_tree;
986 proto_tree *stlv_tree;
987 proto_tree *stlv_admingrp_tree = NULL;
993 int stlv_type, stlv_len, stlv_offset;
995 guint32 stlv_admingrp, mask;
999 ti = proto_tree_add_text(tree, tvb, offset, length,
1000 "MPLS Traffic Engineering LSA");
1001 proto_tree_add_item_hidden(tree, ospf_filter[OSPFF_LS_MPLS],
1002 tvb, offset, 2, FALSE);
1003 mpls_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls);
1005 while (length != 0) {
1006 tlv_type = tvb_get_ntohs(tvb, offset);
1007 tlv_length = tvb_get_ntohs(tvb, offset + 2);
1008 tlv_end_offset = offset + tlv_length + 4;
1012 case MPLS_TLV_ROUTER:
1013 ti = proto_tree_add_text(mpls_tree, tvb, offset, tlv_length+4,
1014 "Router Address: %s",
1015 ip_to_str(tvb_get_ptr(tvb, offset+4, 4)));
1016 tlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_router);
1017 proto_tree_add_text(tlv_tree, tvb, offset, 2, "TLV Type: 1 - Router Address");
1018 proto_tree_add_text(tlv_tree, tvb, offset+2, 2, "TLV Length: %u",
1020 proto_tree_add_item(tlv_tree, ospf_filter[OSPFF_LS_MPLS_ROUTERID],
1021 tvb, offset+4, 4, FALSE);
1025 ti = proto_tree_add_text(mpls_tree, tvb, offset, tlv_length+4,
1026 "Link Information");
1027 tlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link);
1028 proto_tree_add_text(tlv_tree, tvb, offset, 2, "TLV Type: 2 - Link Information");
1029 proto_tree_add_text(tlv_tree, tvb, offset+2, 2, "TLV Length: %u",
1031 stlv_offset = offset + 4;
1033 /* Walk down the sub-TLVs for link information */
1034 while (stlv_offset < tlv_end_offset) {
1035 stlv_type = tvb_get_ntohs(tvb, stlv_offset);
1036 stlv_len = tvb_get_ntohs(tvb, stlv_offset + 2);
1037 stlv_name = val_to_str(stlv_type, mpls_link_stlv_str, "Unknown sub-TLV");
1038 switch (stlv_type) {
1040 case MPLS_LINK_TYPE:
1041 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1042 "%s: %u - %s", stlv_name,
1043 tvb_get_guint8(tvb, stlv_offset + 4),
1044 val_to_str(tvb_get_guint8(tvb, stlv_offset + 4),
1045 mpls_link_stlv_ltype_str, "Unknown Link Type"));
1046 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1047 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1048 "TLV Type: %u: %s", stlv_type, stlv_name);
1049 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1051 proto_tree_add_item(stlv_tree, ospf_filter[OSPFF_LS_MPLS_LINKTYPE],
1052 tvb, stlv_offset+4, 1,FALSE);
1056 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1057 "%s: %s", stlv_name,
1058 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
1059 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1060 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1061 "TLV Type: %u: %s", stlv_type, stlv_name);
1062 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1064 proto_tree_add_item(stlv_tree, ospf_filter[OSPFF_LS_MPLS_LINKID],
1065 tvb, stlv_offset+4, 4, FALSE);
1068 case MPLS_LINK_LOCAL_IF:
1069 case MPLS_LINK_REMOTE_IF:
1070 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1072 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1073 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1074 "TLV Type: %u: %s", stlv_type, stlv_name);
1075 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1077 /* The Local/Remote Interface IP Address sub-TLV is TLV type 3/4, and is 4N
1078 octets in length, where N is the number of neighbor addresses. */
1079 for (i=0; i < stlv_len; i+=4)
1080 proto_tree_add_item(stlv_tree,
1081 stlv_type==MPLS_LINK_LOCAL_IF ?
1082 ospf_filter[OSPFF_LS_MPLS_LOCAL_ADDR] :
1083 ospf_filter[OSPFF_LS_MPLS_REMOTE_ADDR],
1084 tvb, stlv_offset+4+i, 4, FALSE);
1087 case MPLS_LINK_TE_METRIC:
1088 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1089 "%s: %u", stlv_name,
1090 tvb_get_ntohl(tvb, stlv_offset + 4));
1091 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1092 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1093 "TLV Type: %u: %s", stlv_type, stlv_name);
1094 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1096 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 4, "%s: %u", stlv_name,
1097 tvb_get_ntohl(tvb, stlv_offset + 4));
1100 case MPLS_LINK_COLOR:
1101 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1102 "%s: 0x%08x", stlv_name,
1103 tvb_get_ntohl(tvb, stlv_offset + 4));
1104 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1105 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1106 "TLV Type: %u: %s", stlv_type, stlv_name);
1107 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1109 stlv_admingrp = tvb_get_ntohl(tvb, stlv_offset + 4);
1111 ti = proto_tree_add_item(stlv_tree, ospf_filter[OSPFF_LS_MPLS_LINKCOLOR],
1112 tvb, stlv_offset+4, 4, FALSE);
1113 stlv_admingrp_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv_admingrp);
1114 if (stlv_admingrp_tree == NULL)
1116 for (i = 0 ; i < 32 ; i++) {
1117 if ((stlv_admingrp & mask) != 0) {
1118 proto_tree_add_text(stlv_admingrp_tree, tvb, stlv_offset+4,
1125 case MPLS_LINK_MAX_BW:
1126 case MPLS_LINK_MAX_RES_BW:
1127 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1128 "%s: %.10g bytes/s (%.0f bits/s)", stlv_name,
1129 tvb_get_ntohieee_float(tvb, stlv_offset + 4),
1130 tvb_get_ntohieee_float(tvb, stlv_offset + 4) * 8.0);
1131 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1132 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1133 "TLV Type: %u: %s", stlv_type, stlv_name);
1134 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1136 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 4, "%s: %.10g bytes/s (%.0f bits/s)", stlv_name,
1137 tvb_get_ntohieee_float(tvb, stlv_offset + 4),
1138 tvb_get_ntohieee_float(tvb, stlv_offset + 4) * 8.0);
1141 case MPLS_LINK_UNRES_BW:
1142 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1144 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1145 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1146 "TLV Type: %u: %s", stlv_type, stlv_name);
1147 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1149 for (i = 0; i < 8; i++) {
1150 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4+(i*4), 4,
1151 "Pri %d: %.10g bytes/s (%.0f bits/s)", i,
1152 tvb_get_ntohieee_float(tvb, stlv_offset + 4 + i*4),
1153 tvb_get_ntohieee_float(tvb, stlv_offset + 4 + i*4) * 8.0);
1157 case MPLS_LINK_LOCAL_REMOTE_ID:
1158 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1159 "%s: %d (0x%x) - %d (0x%x)", stlv_name,
1160 tvb_get_ntohl(tvb, stlv_offset + 4),
1161 tvb_get_ntohl(tvb, stlv_offset + 4),
1162 tvb_get_ntohl(tvb, stlv_offset + 8),
1163 tvb_get_ntohl(tvb, stlv_offset + 8));
1164 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1166 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1167 "TLV Type: %u: %s", stlv_type, stlv_name);
1168 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1170 proto_tree_add_item(stlv_tree,
1171 ospf_filter[OSPFF_LS_MPLS_LOCAL_IFID],
1172 tvb, stlv_offset+4, 4, FALSE);
1173 proto_tree_add_item(stlv_tree,
1174 ospf_filter[OSPFF_LS_MPLS_REMOTE_IFID],
1175 tvb, stlv_offset+8, 4, FALSE);
1178 case MPLS_LINK_IF_SWITCHING_DESC:
1179 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1181 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1182 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1183 "TLV Type: %u: %s", stlv_type, stlv_name);
1184 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1186 switch_cap = tvb_get_guint8 (tvb, stlv_offset+4);
1187 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Switching Type: %s",
1188 val_to_str(tvb_get_guint8(tvb,stlv_offset+4),
1189 gmpls_switching_type_str, "Unknown (%d)"));
1190 proto_tree_add_text(stlv_tree, tvb, stlv_offset+5, 1, "Encoding: %s",
1191 val_to_str(tvb_get_guint8(tvb,stlv_offset+5),
1192 gmpls_lsp_enc_str, "Unknown (%d)"));
1193 for (i = 0; i < 8; i++) {
1194 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8+(i*4), 4,
1195 "Pri %d: %.10g bytes/s (%.0f bits/s)", i,
1196 tvb_get_ntohieee_float(tvb, stlv_offset + 8 + i*4),
1197 tvb_get_ntohieee_float(tvb, stlv_offset + 8 + i*4) * 8.0);
1199 if (switch_cap >=1 && switch_cap <=4) { /* PSC-1 .. PSC-4 */
1200 proto_tree_add_text(stlv_tree, tvb, stlv_offset+40, 4,
1201 "Minimum LSP bandwidth: %.10g bytes/s (%.0f bits/s)",
1202 tvb_get_ntohieee_float(tvb, stlv_offset + 40),
1203 tvb_get_ntohieee_float(tvb, stlv_offset + 40) * 8.0);
1204 proto_tree_add_text(stlv_tree, tvb, stlv_offset+44, 2,
1205 "Interface MTU: %d", tvb_get_ntohs(tvb, stlv_offset+44));
1208 if (switch_cap == 100) { /* TDM */
1209 proto_tree_add_text(stlv_tree, tvb, stlv_offset+40, 4,
1210 "Minimum LSP bandwidth: %.10g bytes/s (%.0f bits/s)",
1211 tvb_get_ntohieee_float(tvb, stlv_offset + 40),
1212 tvb_get_ntohieee_float(tvb, stlv_offset + 40) * 8.0);
1213 proto_tree_add_text(stlv_tree, tvb, stlv_offset+44, 2,
1215 tvb_get_guint8(tvb, stlv_offset+44) ?
1216 "Arbitrary" : "Standard");
1219 case MPLS_LINK_PROTECTION:
1220 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1222 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1223 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1224 "TLV Type: %u: %s", stlv_type, stlv_name);
1225 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1227 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Protection Capability: %s (0x%x)",
1228 val_to_str(tvb_get_guint8(tvb,stlv_offset+4), gmpls_protection_cap_str, "Unknown (%d)"),tvb_get_guint8(tvb,stlv_offset+4));
1231 case MPLS_LINK_SHARED_RISK_GROUP:
1232 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1234 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1235 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1236 "TLV Type: %u: %s", stlv_type, stlv_name);
1237 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1239 for (i=0; i < stlv_len; i+=4)
1240 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4+i, 4, "Shared Risk Link Group: %u",
1241 tvb_get_ntohl(tvb,stlv_offset+4+i));
1244 case OIF_LOCAL_NODE_ID:
1245 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1246 "%s: %s", stlv_name,
1247 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
1248 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1249 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1250 "TLV Type: %u: %s", stlv_type, stlv_name);
1251 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1253 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 4, "Local Node ID: %s",
1254 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
1257 case OIF_REMOTE_NODE_ID:
1258 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1259 "%s: %s", stlv_name,
1260 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
1261 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1262 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1263 "TLV Type: %u: %s", stlv_type, stlv_name);
1264 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1266 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 4, "Remote Node ID: %s",
1267 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
1270 case OIF_SONET_SDH_SWITCHING_CAPABILITY:
1271 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4, "%s", stlv_name);
1272 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1273 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1274 "TLV Type: %u: %s", stlv_type, stlv_name);
1275 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1277 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Switching Cap: %s",
1278 val_to_str(tvb_get_guint8 (tvb, stlv_offset+4),
1279 gmpls_switching_type_str, "Unknown (%d)"));
1280 proto_tree_add_text(stlv_tree, tvb, stlv_offset+5, 1, "Encoding: %s",
1281 val_to_str(tvb_get_guint8(tvb,stlv_offset+5),
1282 gmpls_lsp_enc_str, "Unknown (%d)"));
1283 for (i = 0; i < (stlv_len - 4) / 4; i++) {
1284 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8+(i*4), 4,
1285 "%s: %d free timeslots",
1286 val_to_str(tvb_get_guint8(tvb, stlv_offset+8+(i*4)),
1287 gmpls_sonet_signal_type_str,
1288 "Unknown Signal Type (%d)"),
1289 tvb_get_ntoh24(tvb, stlv_offset + 9 + i*4));
1294 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1295 "Unknown Link sub-TLV: %u", stlv_type);
1296 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
1297 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1298 "TLV Type: %u: %s", stlv_type, stlv_name);
1299 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1301 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, stlv_len,
1305 stlv_offset += ((stlv_len+4+3)/4)*4;
1310 ti = proto_tree_add_text(mpls_tree, tvb, offset, tlv_length+4,
1312 tlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna);
1313 proto_tree_add_text(tlv_tree, tvb, offset, 2, "TLV Type: 32768 - TNA Information");
1314 proto_tree_add_text(tlv_tree, tvb, offset+2, 2, "TLV Length: %u",
1316 stlv_offset = offset + 4;
1318 /* Walk down the sub-TLVs for TNA information */
1319 while (stlv_offset < tlv_end_offset) {
1320 stlv_type = tvb_get_ntohs(tvb, stlv_offset);
1321 stlv_len = tvb_get_ntohs(tvb, stlv_offset + 2);
1322 stlv_name = val_to_str(stlv_type, oif_stlv_str, "Unknown sub-TLV");
1323 switch (stlv_type) {
1326 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1327 "%s: %s", stlv_name,
1328 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
1329 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna_stlv);
1330 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1331 "TLV Type: %u: %s", stlv_type, stlv_name);
1332 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u",
1334 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 4, "%s: %s", stlv_name,
1335 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 4, 4)));
1338 case OIF_TNA_IPv4_ADDRESS:
1339 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1341 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 8, 4)));
1342 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna_stlv);
1343 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1344 "TLV Type: %u: %s (IPv4)", stlv_type, stlv_name);
1345 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u", stlv_len);
1346 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Addr Length: %u",
1347 tvb_get_guint8 (tvb, stlv_offset+4));
1348 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8, stlv_len - 4, "TNA Addr: %s",
1349 ip_to_str(tvb_get_ptr(tvb, stlv_offset + 8, 4)));
1352 case OIF_TNA_IPv6_ADDRESS:
1353 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1354 "%s (IPv6): %s", stlv_name,
1355 ip6_to_str((const struct e_in6_addr *)
1356 tvb_get_ptr(tvb, stlv_offset + 8, 16)));
1357 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna_stlv);
1358 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1359 "TLV Type: %u: %s (IPv6)", stlv_type, stlv_name);
1360 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u", stlv_len);
1361 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Addr Length: %u",
1362 tvb_get_guint8 (tvb, stlv_offset+4));
1363 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8, stlv_len - 4, "TNA Addr: %s",
1364 ip6_to_str((const struct e_in6_addr *)
1365 tvb_get_ptr(tvb, stlv_offset + 8, 16)));
1368 case OIF_TNA_NSAP_ADDRESS:
1369 ti = proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1370 "%s (NSAP): %s", stlv_name,
1371 tvb_bytes_to_str (tvb, stlv_offset + 8, stlv_len - 4));
1372 stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_oif_tna_stlv);
1373 proto_tree_add_text(stlv_tree, tvb, stlv_offset, 2,
1374 "TLV Type: %u: %s (NSAP)", stlv_type, stlv_name);
1375 proto_tree_add_text(stlv_tree, tvb, stlv_offset+2, 2, "TLV Length: %u", stlv_len);
1376 proto_tree_add_text(stlv_tree, tvb, stlv_offset+4, 1, "Addr Length: %u",
1377 tvb_get_guint8 (tvb, stlv_offset+4));
1378 proto_tree_add_text(stlv_tree, tvb, stlv_offset+8, stlv_len - 4, "TNA Addr: %s",
1379 tvb_bytes_to_str(tvb, stlv_offset+8, stlv_len - 4));
1383 proto_tree_add_text(tlv_tree, tvb, stlv_offset, stlv_len+4,
1384 "Unknown Link sub-TLV: %u", stlv_type);
1387 stlv_offset += ((stlv_len+4+3)/4)*4;
1391 ti = proto_tree_add_text(mpls_tree, tvb, offset, tlv_length+4,
1392 "Unknown LSA: %u", tlv_type);
1393 tlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link);
1394 proto_tree_add_text(tlv_tree, tvb, offset, 2, "TLV Type: %u - Unknown",
1396 proto_tree_add_text(tlv_tree, tvb, offset+2, 2, "TLV Length: %u",
1398 proto_tree_add_text(tlv_tree, tvb, offset+4, tlv_length, "TLV Data");
1402 offset += tlv_length + 4;
1403 length -= tlv_length + 4;
1408 * Dissect opaque LSAs
1411 dissect_ospf_lsa_opaque(tvbuff_t *tvb, int offset, proto_tree *tree,
1412 guint8 ls_id_type, guint32 length)
1414 switch (ls_id_type) {
1416 case OSPF_LSA_MPLS_TE:
1417 dissect_ospf_lsa_mpls(tvb, offset, tree, length);
1421 proto_tree_add_text(tree, tvb, offset, length,
1422 "Unknown LSA Type %u", ls_id_type);
1424 } /* switch on opaque LSA id */
1428 dissect_ospf_v2_lsa(tvbuff_t *tvb, int offset, proto_tree *tree,
1429 gboolean disassemble_body)
1431 proto_tree *ospf_lsa_tree;
1442 guint16 link_counter;
1444 char *link_type_str;
1445 char *link_type_short_str;
1448 /* AS-external LSA */
1454 ls_type = tvb_get_guint8(tvb, offset + 3);
1455 ls_length = tvb_get_ntohs(tvb, offset + 18);
1456 end_offset = offset + ls_length;
1458 if (disassemble_body) {
1459 ti = proto_tree_add_text(tree, tvb, offset, ls_length,
1461 val_to_str(ls_type, ls_type_vals, "Unknown (%d)"));
1463 ti = proto_tree_add_text(tree, tvb, offset, OSPF_LSA_HEADER_LENGTH,
1466 ospf_lsa_tree = proto_item_add_subtree(ti, ett_ospf_lsa);
1468 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2, "LS Age: %u seconds",
1469 tvb_get_ntohs(tvb, offset));
1470 dissect_ospf_options(tvb, offset + 2, ospf_lsa_tree, OSPF_VERSION_2);
1471 proto_tree_add_item(ospf_lsa_tree, ospf_filter[OSPFF_LS_TYPE], tvb,
1472 offset + 3, 1, FALSE);
1473 proto_tree_add_item_hidden(ospf_lsa_tree,
1474 ospf_filter[ospf_ls_type_to_filter(ls_type)], tvb,
1475 offset + 3, 1, FALSE);
1477 if (is_opaque(ls_type)) {
1478 ls_id_type = tvb_get_guint8(tvb, offset + 4);
1479 proto_tree_add_uint(ospf_lsa_tree, ospf_filter[OSPFF_LS_OPAQUE_TYPE],
1480 tvb, offset + 4, 1, ls_id_type);
1482 switch (ls_id_type) {
1484 case OSPF_LSA_MPLS_TE:
1485 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 5, 1, "Link State ID TE-LSA Reserved: %u",
1486 tvb_get_guint8(tvb, offset + 5));
1487 proto_tree_add_item(ospf_lsa_tree, ospf_filter[OSPFF_LS_MPLS_TE_INSTANCE],
1488 tvb, offset + 6, 2, FALSE);
1492 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 5, 3, "Link State ID Opaque ID: %u",
1493 tvb_get_ntoh24(tvb, offset + 5));
1498 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 4, "Link State ID: %s",
1499 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
1502 proto_tree_add_item(ospf_lsa_tree, ospf_filter[OSPFF_ADV_ROUTER],
1503 tvb, offset + 8, 4, FALSE);
1504 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 12, 4, "LS Sequence Number: 0x%08x",
1505 tvb_get_ntohl(tvb, offset + 12));
1506 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 16, 2, "LS Checksum: %04x",
1507 tvb_get_ntohs(tvb, offset + 16));
1509 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 18, 2, "Length: %u",
1512 /* skip past the LSA header to the body */
1513 offset += OSPF_LSA_HEADER_LENGTH;
1514 if (ls_length <= OSPF_LSA_HEADER_LENGTH)
1515 return offset; /* no data, or bogus length */
1516 ls_length -= OSPF_LSA_HEADER_LENGTH;
1518 if (!disassemble_body)
1523 case OSPF_LSTYPE_ROUTER:
1524 /* again: flags should be secified in detail */
1525 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "Flags: 0x%02x",
1526 tvb_get_guint8(tvb, offset));
1527 nr_links = tvb_get_ntohs(tvb, offset + 2);
1528 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 2, 2, "Number of Links: %u",
1531 /* nr_links links follow
1532 * maybe we should put each of the links into its own subtree ???
1534 for (link_counter = 1; link_counter <= nr_links; link_counter++) {
1535 proto_tree *ospf_lsa_router_link_tree;
1536 proto_item *ti_local;
1539 /* check the Link Type and ID */
1540 link_type = tvb_get_guint8(tvb, offset + 8);
1541 switch (link_type) {
1544 link_type_str="Point-to-point connection to another router";
1545 link_type_short_str="PTP";
1546 link_id="Neighboring router's Router ID";
1549 case OSPF_LINK_TRANSIT:
1550 link_type_str="Connection to a transit network";
1551 link_type_short_str="Transit";
1552 link_id="IP address of Designated Router";
1555 case OSPF_LINK_STUB:
1556 link_type_str="Connection to a stub network";
1557 link_type_short_str="Stub";
1558 link_id="IP network/subnet number";
1561 case OSPF_LINK_VIRTUAL:
1562 link_type_str="Virtual link";
1563 link_type_short_str="Virtual";
1564 link_id="Neighboring router's Router ID";
1568 link_type_str="Unknown link type";
1569 link_type_short_str="Unknown";
1570 link_id="Unknown link ID";
1574 nr_tos = tvb_get_guint8(tvb, offset + 9);
1577 ti_local = proto_tree_add_text(ospf_lsa_tree, tvb, offset, 12 + 4 * nr_tos,
1578 "Type: %-8s ID: %-15s Data: %-15s Metric: %d",
1579 link_type_short_str,
1580 ip_to_str(tvb_get_ptr(tvb, offset, 4)),
1581 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)),
1582 tvb_get_ntohs(tvb, offset + 10));
1584 ospf_lsa_router_link_tree = proto_item_add_subtree(ti_local, ett_ospf_lsa_router_link);
1586 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset, 4, "%s: %s", link_id,
1587 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1589 /* link_data should be specified in detail (e.g. network mask) (depends on link type)*/
1590 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset + 4, 4, "Link Data: %s",
1591 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
1593 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset + 8, 1, "Link Type: %u - %s",
1594 link_type, link_type_str);
1595 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset + 9, 1, "Number of TOS metrics: %u",
1597 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset + 10, 2, "TOS 0 metric: %u",
1598 tvb_get_ntohs(tvb, offset + 10));
1602 /* nr_tos metrics may follow each link
1603 * ATTENTION: TOS metrics are not tested (I don't have TOS
1605 * please send me a mail if it is/isn't working
1607 for (tos_counter = 1; tos_counter <= nr_tos; tos_counter++) {
1608 proto_tree_add_text(ospf_lsa_router_link_tree, tvb, offset, 4, "TOS: %u, Metric: %u",
1609 tvb_get_guint8(tvb, offset),
1610 tvb_get_ntohs(tvb, offset + 2));
1616 case OSPF_LSTYPE_NETWORK:
1617 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Netmask: %s",
1618 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1621 while (offset < end_offset) {
1622 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Attached Router: %s",
1623 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1628 case OSPF_LSTYPE_SUMMERY:
1629 /* Type 3 and 4 LSAs have the same format */
1630 case OSPF_LSTYPE_ASBR:
1631 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Netmask: %s",
1632 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1635 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Metric: %u",
1636 tvb_get_ntoh24(tvb, offset + 1));
1639 /* TOS-specific information, if any */
1640 while (offset < end_offset) {
1641 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "TOS: %u, Metric: %u",
1642 tvb_get_guint8(tvb, offset),
1643 tvb_get_ntoh24(tvb, offset + 1));
1648 case OSPF_LSTYPE_ASEXT:
1649 case OSPF_LSTYPE_ASEXT7:
1650 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Netmask: %s",
1651 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1654 options = tvb_get_guint8(tvb, offset);
1655 if (options & 0x80) { /* check wether or not E bit is set */
1656 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
1657 "External Type: Type 2 (metric is larger than any other link state path)");
1659 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
1660 "External Type: Type 1 (metric is specified in the same units as interface cost)");
1662 /* the metric field of a AS-external LAS is specified in 3 bytes */
1663 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 1, 3, "Metric: %u",
1664 tvb_get_ntoh24(tvb, offset + 1));
1667 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Forwarding Address: %s",
1668 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1671 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "External Route Tag: %u",
1672 tvb_get_ntohl(tvb, offset));
1675 /* TOS-specific information, if any */
1676 while (offset < end_offset) {
1677 options = tvb_get_guint8(tvb, offset);
1678 if (options & 0x80) { /* check wether or not E bit is set */
1679 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
1680 "External Type: Type 2 (metric is larger than any other link state path)");
1682 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
1683 "External Type: Type 1 (metric is specified in the same units as interface cost)");
1685 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "TOS: %u, Metric: %u",
1687 tvb_get_ntoh24(tvb, offset + 1));
1690 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Forwarding Address: %s",
1691 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1694 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "External Route Tag: %u",
1695 tvb_get_ntohl(tvb, offset));
1700 case OSPF_LSTYPE_OP_LINKLOCAL:
1701 case OSPF_LSTYPE_OP_AREALOCAL:
1702 case OSPF_LSTYPE_OP_ASWIDE:
1704 * RFC 2370 opaque LSAs.
1706 dissect_ospf_lsa_opaque(tvb, offset, ospf_lsa_tree, ls_id_type,
1708 offset += ls_length;
1712 /* unknown LSA type */
1713 proto_tree_add_text(ospf_lsa_tree, tvb, offset, ls_length,
1714 "Unknown LSA Type");
1715 offset += ls_length;
1718 /* return the offset of the next LSA */
1723 dissect_ospf_v3_lsa(tvbuff_t *tvb, int offset, proto_tree *tree,
1724 gboolean disassemble_body)
1726 proto_tree *ospf_lsa_tree;
1736 char *link_type_str;
1739 guint8 router_lsa_flags;
1740 char router_lsa_flags_string[5];
1742 guint8 router_priority;
1743 guint32 number_prefixes;
1744 guint8 prefix_length;
1747 guint16 referenced_ls_type;
1750 guint8 flags_string[4];
1751 guint32 external_route_tag;
1754 ls_type = tvb_get_ntohs(tvb, offset + 2);
1755 ls_length = tvb_get_ntohs(tvb, offset + 18);
1756 end_offset = offset + ls_length;
1758 if (disassemble_body) {
1759 ti = proto_tree_add_text(tree, tvb, offset, ls_length,
1760 "%s (Type: 0x%04x)", val_to_str(ls_type, v3_ls_type_vals,"Unknown"), ls_type);
1762 ti = proto_tree_add_text(tree, tvb, offset, OSPF_LSA_HEADER_LENGTH,
1765 ospf_lsa_tree = proto_item_add_subtree(ti, ett_ospf_lsa);
1767 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2, "LS Age: %u seconds",
1768 tvb_get_ntohs(tvb, offset));
1770 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 2, 2, "LSA Type: 0x%04x (%s)",
1771 ls_type, val_to_str(ls_type, v3_ls_type_vals,"Unkown"));
1773 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 4, "Link State ID: %s",
1774 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
1776 proto_tree_add_item(ospf_lsa_tree, ospf_filter[OSPFF_ADV_ROUTER],
1777 tvb, offset + 8, 4, FALSE);
1778 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 12, 4, "LS Sequence Number: 0x%08x",
1779 tvb_get_ntohl(tvb, offset + 12));
1780 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 16, 2, "LS Checksum: %04x",
1781 tvb_get_ntohs(tvb, offset + 16));
1783 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 18, 2, "Length: %u",
1786 /* skip past the LSA header to the body */
1787 offset += OSPF_LSA_HEADER_LENGTH;
1788 ls_length -= OSPF_LSA_HEADER_LENGTH;
1790 if (!disassemble_body)
1796 case OSPF_V3_LSTYPE_ROUTER:
1798 /* flags field in an router-lsa */
1799 router_lsa_flags=tvb_get_guint8(tvb,offset);
1800 if (router_lsa_flags & OSPF_V3_ROUTER_LSA_FLAG_B)
1801 router_lsa_flags_string[3] = 'B';
1803 router_lsa_flags_string[3] = '.';
1804 if (router_lsa_flags & OSPF_V3_ROUTER_LSA_FLAG_E)
1805 router_lsa_flags_string[2] = 'E';
1807 router_lsa_flags_string[2] = '.';
1808 if (router_lsa_flags & OSPF_V3_ROUTER_LSA_FLAG_V)
1809 router_lsa_flags_string[1] = 'V';
1811 router_lsa_flags_string[1] = '.';
1812 if (router_lsa_flags & OSPF_V3_ROUTER_LSA_FLAG_W)
1813 router_lsa_flags_string[0] = 'W';
1815 router_lsa_flags_string[0] = '.';
1817 router_lsa_flags_string[4]=0;
1819 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "Flags: 0x%02x (%s)",
1820 router_lsa_flags, router_lsa_flags_string);
1822 /* options field in an router-lsa */
1823 dissect_ospf_options(tvb, offset + 1, ospf_lsa_tree, OSPF_VERSION_3);
1825 /* skip the router-lsa flags and options */
1830 proto_tree_add_text(ospf_lsa_tree, tvb, offset, ls_length,
1831 "Router Interfaces:");
1833 /* scan all router-lsa router interfaces */
1834 /* maybe we should put each of the links into its own subtree ??? */
1835 while (ls_length > 0 ) {
1837 /* check the type */
1838 link_type = tvb_get_guint8(tvb, offset);
1839 switch (link_type) {
1841 case OSPF_V3_LINK_PTP:
1842 link_type_str="Point-to-point connection to another router";
1845 case OSPF_V3_LINK_TRANSIT:
1846 link_type_str="Connection to a transit network";
1849 case OSPF_V3_LINK_RESERVED:
1850 link_type_str="Connection to a stub network";
1853 case OSPF_V3_LINK_VIRTUAL:
1854 link_type_str="Virtual link";
1858 link_type_str="Unknown link type";
1862 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "Type: %u (%s)", link_type,link_type_str);
1864 /* reserved field */
1865 reserved = tvb_get_guint8(tvb, offset+1);
1866 proto_tree_add_text(ospf_lsa_tree, tvb, offset+1, 1,
1867 (reserved == 0 ? "Reserved: %u" : "Reserved: %u (incorrect, should be 0)"),reserved);
1870 metric=tvb_get_ntohs(tvb, offset+2);
1871 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 2, 2,"Metric: %u",metric);
1874 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 4, "Interface ID: %u",
1875 tvb_get_ntohl(tvb, offset + 4));
1877 /* Neighbor Interface ID */
1878 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 8, 4, "Neighbor Interface ID: %u",
1879 tvb_get_ntohl(tvb, offset + 8));
1881 /* Neighbor Router ID */
1882 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 12, 4, "Neighbor Router ID: %s",
1883 ip_to_str(tvb_get_ptr(tvb, offset + 12, 4)));
1885 /* skip to the (possible) next entry */
1892 case OSPF_V3_LSTYPE_NETWORK:
1894 /* reserved field */
1895 reserved = tvb_get_guint8(tvb, offset);
1896 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
1897 (reserved == 0 ? "Reserved: %u" : "Reserved: %u (incorrect, should be 0)"),reserved);
1899 /* options field in an network-lsa */
1900 dissect_ospf_options(tvb, offset + 1, ospf_lsa_tree, OSPF_VERSION_3);
1905 while (ls_length > 0 ) {
1906 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Attached Router: %s",
1907 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
1914 case OSPF_V3_LSTYPE_INTER_AREA_PREFIX:
1916 /* reserved field */
1917 reserved = tvb_get_guint8(tvb, offset);
1918 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
1919 (reserved == 0 ? "Reserved: %u" : "Reserved: %u (incorrect, should be 0)"),reserved);
1922 metric=tvb_get_ntoh24(tvb, offset+1);
1923 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 1, 3,"Metric: %u",metric);
1926 prefix_length=tvb_get_guint8(tvb, offset+4);
1927 proto_tree_add_text(ospf_lsa_tree, tvb, offset+4, 1, "PrefixLength: %u",prefix_length);
1929 /* prefix options */
1930 dissect_ospf_v3_prefix_options(tvb, offset+5, ospf_lsa_tree);
1932 /* 16 bits reserved */
1933 reserved16=tvb_get_ntohs(tvb, offset+6);
1934 proto_tree_add_text(ospf_lsa_tree, tvb, offset+6, 2,
1935 (reserved16 == 0 ? "Reserved: %u" : "Reserved: %u (incorrect, should be 0)"),reserved16);
1939 /* address_prefix */
1940 dissect_ospf_v3_address_prefix(tvb, offset, prefix_length, ospf_lsa_tree);
1942 offset+=(prefix_length+31)/32*4;
1947 case OSPF_V3_LSTYPE_INTER_AREA_ROUTER:
1949 /* reserved field */
1950 reserved = tvb_get_guint8(tvb, offset);
1951 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1,
1952 (reserved == 0 ? "Reserved: %u" : "Reserved: %u (incorrect, should be 0)"),reserved);
1954 /* options field in an inter-area-router-lsa */
1955 dissect_ospf_options(tvb, offset + 1, ospf_lsa_tree, OSPF_VERSION_3);
1957 /* reserved field */
1958 reserved = tvb_get_guint8(tvb, offset+4);
1959 proto_tree_add_text(ospf_lsa_tree, tvb, offset+4, 1,
1960 (reserved == 0 ? "Reserved: %u" : "Reserved: %u (incorrect, should be 0)"),reserved);
1963 metric=tvb_get_ntoh24(tvb, offset+5);
1964 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 5, 3,"Metric: %u",metric);
1966 /* Destination Router ID */
1967 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 8, 4, "Destination Router ID: %s",
1968 ip_to_str(tvb_get_ptr(tvb, offset + 8, 4)));
1974 case OSPF_V3_LSTYPE_AS_EXTERNAL:
1977 flags=tvb_get_guint8(tvb, offset);
1978 if (flags & OSPF_V3_AS_EXTERNAL_FLAG_E)
1979 flags_string[0] = 'E';
1981 flags_string[0] = '.';
1982 if (flags & OSPF_V3_AS_EXTERNAL_FLAG_F)
1983 flags_string[1] = 'F';
1985 flags_string[1] = '.';
1986 if (flags & OSPF_V3_AS_EXTERNAL_FLAG_T)
1987 flags_string[2] = 'T';
1989 flags_string[2] = '.';
1993 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "Flags: 0x%02x (%s)",
1994 flags, flags_string);
1996 /* 24 bits metric */
1997 metric=tvb_get_ntoh24(tvb, offset+1);
1998 proto_tree_add_text(ospf_lsa_tree, tvb, offset+1, 3,
1999 "Metric: %u", metric);
2002 prefix_length=tvb_get_guint8(tvb, offset+4);
2003 proto_tree_add_text(ospf_lsa_tree, tvb, offset+4, 1, "PrefixLength: %u",prefix_length);
2005 /* prefix options */
2006 dissect_ospf_v3_prefix_options(tvb, offset+5, ospf_lsa_tree);
2008 /* referenced LS type */
2009 referenced_ls_type=tvb_get_ntohs(tvb, offset+6);
2010 proto_tree_add_text(ospf_lsa_tree, tvb, offset+6, 2,"Referenced LS type 0x%04x (%s)",
2011 referenced_ls_type, val_to_str(referenced_ls_type, v3_ls_type_vals, "Unknown"));
2015 /* address_prefix */
2016 dissect_ospf_v3_address_prefix(tvb, offset, prefix_length, ospf_lsa_tree);
2018 offset+=(prefix_length+31)/32*4;
2020 /* Forwarding Address (optional - only if F-flag is on) */
2021 if ( (offset < end_offset) && (flags & OSPF_V3_AS_EXTERNAL_FLAG_F) ) {
2022 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 16,"Forwarding Address: %s",
2023 ip6_to_str((const struct e_in6_addr *)tvb_get_ptr(tvb, offset, 16)));
2028 /* External Route Tag (optional - only if T-flag is on) */
2029 if ( (offset < end_offset) && (flags & OSPF_V3_AS_EXTERNAL_FLAG_T) ) {
2030 external_route_tag=tvb_get_ntohl(tvb, offset);
2031 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4,"External Route Tag: %u",
2032 external_route_tag);
2037 /* Referenced Link State ID (optional - only if Referenced LS type is non-zero */
2038 if ( (offset < end_offset) && (referenced_ls_type != 0) ) {
2039 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 4, "Referenced Link State ID: %s",
2040 ip_to_str(tvb_get_ptr(tvb, offset, 4)));
2046 case OSPF_V3_LSTYPE_LINK:
2048 /* router priority */
2049 router_priority=tvb_get_guint8(tvb, offset);
2050 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "Router Priority: %u", router_priority);
2052 /* options field in an link-lsa */
2053 dissect_ospf_options(tvb, offset + 1, ospf_lsa_tree, OSPF_VERSION_3);
2055 /* Link-local Interface Address */
2056 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 16, "Link-local Interface Address: %s",
2057 ip6_to_str((const struct e_in6_addr *)tvb_get_ptr(tvb, offset + 4, 16)));
2059 /* Number prefixes */
2060 number_prefixes=tvb_get_ntohl(tvb, offset + 20);
2061 proto_tree_add_text(ospf_lsa_tree, tvb, offset+20, 4, "# prefixes: %d",number_prefixes);
2065 while (number_prefixes > 0) {
2068 prefix_length=tvb_get_guint8(tvb, offset);
2069 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "PrefixLength: %u",prefix_length);
2071 /* prefix options */
2072 dissect_ospf_v3_prefix_options(tvb, offset+1, ospf_lsa_tree);
2074 /* 16 bits reserved */
2075 reserved16=tvb_get_ntohs(tvb, offset+2);
2076 proto_tree_add_text(ospf_lsa_tree, tvb, offset+2, 2,
2077 (reserved16 == 0 ? "Reserved: %u" : "Reserved: %u (incorrect, should be 0)"),reserved16);
2081 /* address_prefix */
2082 dissect_ospf_v3_address_prefix(tvb, offset, prefix_length, ospf_lsa_tree);
2084 offset+=(prefix_length+31)/32*4;
2091 case OSPF_V3_LSTYPE_INTRA_AREA_PREFIX:
2094 number_prefixes=tvb_get_ntohs(tvb, offset);
2095 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 2,"# prefixes: %u",number_prefixes);
2097 /* referenced LS type */
2098 referenced_ls_type=tvb_get_ntohs(tvb, offset+2);
2099 proto_tree_add_text(ospf_lsa_tree, tvb, offset+2, 2,"Referenced LS type 0x%04x (%s)",
2100 referenced_ls_type, val_to_str(referenced_ls_type, v3_ls_type_vals, "Unknown"));
2102 /* Referenced Link State ID */
2103 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 4, 4, "Referenced Link State ID: %s",
2104 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)));
2106 /* Referenced Advertising Router */
2107 proto_tree_add_text(ospf_lsa_tree, tvb, offset + 8, 4, "Referenced Advertising Router: %s",
2108 ip_to_str(tvb_get_ptr(tvb, offset + 8, 4)));
2112 while (number_prefixes > 0) {
2115 prefix_length=tvb_get_guint8(tvb, offset);
2116 proto_tree_add_text(ospf_lsa_tree, tvb, offset, 1, "PrefixLength: %u",prefix_length);
2118 /* prefix options */
2119 dissect_ospf_v3_prefix_options(tvb, offset+1, ospf_lsa_tree);
2121 /* 16 bits metric */
2122 metric=tvb_get_ntohs(tvb, offset+2);
2123 proto_tree_add_text(ospf_lsa_tree, tvb, offset+2, 2,
2124 "Metric: %u", metric);
2128 /* address_prefix */
2129 dissect_ospf_v3_address_prefix(tvb, offset, prefix_length, ospf_lsa_tree);
2131 offset+=(prefix_length+31)/32*4;
2138 /* unknown LSA type */
2139 proto_tree_add_text(ospf_lsa_tree, tvb, offset, ls_length,
2140 "Unknown LSA Type 0x%04x",ls_type);
2141 offset += ls_length;
2144 /* return the offset of the next LSA */
2150 dissect_ospf_options(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 version)
2152 guint8 options_ospfv2;
2153 guint32 options_ospfv3;
2154 char options_string[20] = "";
2156 /* ATTENTION !!! no check for length of options string - with OSPFv3 maximum length is 14 characters */
2158 switch ( version ) {
2160 case OSPF_VERSION_2:
2162 options_ospfv2 = tvb_get_guint8(tvb, offset);
2164 if (options_ospfv2 & OSPF_V2_OPTIONS_E)
2165 strcat(options_string, "E");
2167 if (options_ospfv2 & OSPF_V2_OPTIONS_MC) {
2168 if (options_string[0] != '\0')
2169 strcat(options_string, "/");
2170 strcat(options_string, "MC");
2173 if (options_ospfv2 & OSPF_V2_OPTIONS_NP) {
2174 if (options_string[0] != '\0')
2175 strcat(options_string, "/");
2176 strcat(options_string, "NP");
2179 if (options_ospfv2 & OSPF_V2_OPTIONS_EA) {
2180 if (options_string[0] != '\0')
2181 strcat(options_string, "/");
2182 strcat(options_string, "EA");
2185 if (options_ospfv2 & OSPF_V2_OPTIONS_DC) {
2186 if (options_string[0] != '\0')
2187 strcat(options_string, "/");
2188 strcat(options_string, "DC");
2191 if (options_ospfv2 & OSPF_V2_OPTIONS_O) {
2192 if (options_string[0] != '\0')
2193 strcat(options_string, "/");
2194 strcat(options_string, "O");
2197 if (options_ospfv2 & OSPF_V2_OPTIONS_DN) {
2198 if (options_string[0] != '\0')
2199 strcat(options_string, "/");
2200 strcat(options_string, "DN");
2203 proto_tree_add_text(tree, tvb, offset, 1, "Options: 0x%x (%s)",
2204 options_ospfv2, options_string);
2208 case OSPF_VERSION_3:
2210 options_ospfv3 = tvb_get_ntoh24(tvb, offset);
2212 if (options_ospfv3 & OSPF_V3_OPTIONS_V6)
2213 strcat(options_string, "V6");
2215 if (options_ospfv3 & OSPF_V3_OPTIONS_E) {
2216 if (options_string[0] != '\0')
2217 strcat(options_string, "/");
2218 strcat(options_string, "E");
2221 if (options_ospfv3 & OSPF_V3_OPTIONS_MC) {
2222 if (options_string[0] != '\0')
2223 strcat(options_string, "/");
2224 strcat(options_string, "MC");
2227 if (options_ospfv3 & OSPF_V3_OPTIONS_N) {
2228 if (options_string[0] != '\0')
2229 strcat(options_string, "/");
2230 strcat(options_string, "N");
2233 if (options_ospfv3 & OSPF_V3_OPTIONS_R) {
2234 if (options_string[0] != '\0')
2235 strcat(options_string, "/");
2236 strcat(options_string, "R");
2239 if (options_ospfv3 & OSPF_V3_OPTIONS_DC) {
2240 if (options_string[0] != '\0')
2241 strcat(options_string, "/");
2242 strcat(options_string, "DC");
2245 proto_tree_add_text(tree, tvb, offset, 3, "Options: 0x%x (%s)",
2246 options_ospfv3, options_string);
2256 static void dissect_ospf_v3_prefix_options(tvbuff_t *tvb, int offset, proto_tree *tree)
2259 guint8 prefix_options;
2260 char prefix_options_string[11];
2265 prefix_options=tvb_get_guint8(tvb, offset);
2267 strcpy(prefix_options_string,"");
2269 if (prefix_options & OSPF_V3_PREFIX_OPTION_P) {
2270 strcat(prefix_options_string, "P");
2274 if (prefix_options & OSPF_V3_PREFIX_OPTION_MC) {
2275 if ( (position > 0) && (prefix_options_string[position-1] != '/') ) {
2276 strcat(prefix_options_string, "/");
2279 strcat(prefix_options_string, "MC");
2283 if (prefix_options & OSPF_V3_PREFIX_OPTION_LA) {
2284 if ( (position > 0) && (prefix_options_string[position-1] != '/') ) {
2285 strcat(prefix_options_string, "/");
2288 strcat(prefix_options_string, "LA");
2292 if (prefix_options & OSPF_V3_PREFIX_OPTION_NU) {
2293 if ( (position > 0) && (prefix_options_string[position-1] != '/') ) {
2294 strcat(prefix_options_string, "/");
2297 strcat(prefix_options_string, "NU");
2300 prefix_options_string[10]=0;
2302 proto_tree_add_text(tree, tvb, offset, 1, "PrefixOptions: 0x%02x (%s)",prefix_options, prefix_options_string);
2307 static void dissect_ospf_v3_address_prefix(tvbuff_t *tvb, int offset, int prefix_length, proto_tree *tree)
2315 guint8 bytes_to_process;
2318 start_offset=offset;
2321 bytes_to_process=((prefix_length+31)/32)*4;
2323 while (bytes_to_process > 0 ) {
2325 value=tvb_get_guint8(tvb, offset);
2327 if ( (position > 0) && ( (position%2) == 0 ) )
2328 buffer[bufpos++]=':';
2330 sprintf(bytebuf,"%02x",value);
2331 buffer[bufpos++]=bytebuf[0];
2332 buffer[bufpos++]=bytebuf[1];
2340 proto_tree_add_text(tree, tvb, start_offset, ((prefix_length+31)/32)*4, "Address Prefix: %s",buffer);
2346 proto_register_ospf(void)
2348 static gint *ett[] = {
2355 &ett_ospf_lsa_router_link,
2358 &ett_ospf_lsa_mpls_router,
2359 &ett_ospf_lsa_mpls_link,
2360 &ett_ospf_lsa_mpls_link_stlv,
2361 &ett_ospf_lsa_mpls_link_stlv_admingrp,
2362 &ett_ospf_lsa_oif_tna,
2363 &ett_ospf_lsa_oif_tna_stlv
2366 proto_ospf = proto_register_protocol("Open Shortest Path First",
2368 proto_register_field_array(proto_ospf, ospff_info, array_length(ospff_info));
2369 proto_register_subtree_array(ett, array_length(ett));
2373 proto_reg_handoff_ospf(void)
2375 dissector_handle_t ospf_handle;
2377 ospf_handle = create_dissector_handle(dissect_ospf, proto_ospf);
2378 dissector_add("ip.proto", IP_PROTO_OSPF, ospf_handle);
2379 data_handle = find_dissector("data");