2 * Routines for OSPF packet disassembly
3 * (c) Copyright Hannes R. Boehm <hannes@boehm.org>
5 * $Id: packet-ospf.c,v 1.17 1999/11/17 19:07:10 guy Exp $
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.
12 * TOS - support is not fully implemented
14 * Ethereal - Network traffic analyzer
15 * By Gerald Combs <gerald@zing.org>
16 * Copyright 1998 Gerald Combs
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #ifdef HAVE_SYS_TYPES_H
39 # include <sys/types.h>
42 #ifdef HAVE_NETINET_IN_H
43 # include <netinet/in.h>
51 #include "packet-ospf.h"
53 static int proto_ospf = -1;
55 static gint ett_ospf = -1;
56 static gint ett_ospf_hdr = -1;
57 static gint ett_ospf_hello = -1;
58 static gint ett_ospf_desc = -1;
59 static gint ett_ospf_lsr = -1;
60 static gint ett_ospf_lsa = -1;
61 static gint ett_ospf_lsa_upd = -1;
64 dissect_ospf(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
66 e_ospf_crypto *crypto;
67 int i, saved_len, ospflen;
69 proto_tree *ospf_tree = NULL;
71 proto_tree *ospf_header_tree;
72 char auth_data[(2 * 16) + 1]="";
74 static value_string pt_vals[] = { {OSPF_HELLO, "Hello Packet" },
75 {OSPF_DB_DESC, "DB Descr." },
76 {OSPF_LS_REQ, "LS Request" },
77 {OSPF_LS_UPD, "LS Update" },
78 {OSPF_LS_ACK, "LS Acknowledge" },
81 memcpy(&ospfh, &pd[offset], sizeof(e_ospfhdr));
83 packet_type = match_strval(ospfh.packet_type, pt_vals);
84 if (check_col(fd, COL_PROTOCOL))
85 col_add_str(fd, COL_PROTOCOL, "OSPF");
86 if (check_col(fd, COL_INFO)) {
87 if (packet_type != NULL)
88 col_add_str(fd, COL_INFO, packet_type);
90 col_add_fstr(fd, COL_INFO, "Unknown (%d)", ospfh.packet_type);
94 ti = proto_tree_add_item(tree, proto_ospf, offset, ntohs(ospfh.length), NULL);
95 ospf_tree = proto_item_add_subtree(ti, ett_ospf);
97 ti = proto_tree_add_text(ospf_tree, offset, OSPF_HEADER_LENGTH, "OSPF Header");
98 ospf_header_tree = proto_item_add_subtree(ti, ett_ospf_hdr);
100 proto_tree_add_text(ospf_header_tree, offset, 1, "OSPF Version: %d", ospfh.version);
101 proto_tree_add_text(ospf_header_tree, offset + 1 , 1, "OSPF Packet Type: %d (%s)",
103 (packet_type != NULL ?
106 proto_tree_add_text(ospf_header_tree, offset + 2 , 2, "Packet Length: %d",
107 ntohs(ospfh.length));
108 proto_tree_add_text(ospf_header_tree, offset + 4 , 4, "Source OSPF Router ID: %s",
110 ip_to_str((guint8 *) &(ospfh.routerid)));
112 proto_tree_add_text(ospf_header_tree, offset + 8 , 4, "Area ID: Backbone");
114 proto_tree_add_text(ospf_header_tree, offset + 8 , 4, "Area ID: %s", ip_to_str((guint8 *) &(ospfh.area)));
116 proto_tree_add_text(ospf_header_tree, offset + 12 , 2, "Packet Checksum: 0x%x",
117 ntohs(ospfh.checksum));
118 switch( ntohs(ospfh.auth_type) ) {
120 proto_tree_add_text(ospf_header_tree, offset + 14 , 2, "Auth Type: none");
121 proto_tree_add_text(ospf_header_tree, offset + 16 , 8, "Auth Data (none)");
123 case OSPF_AUTH_SIMPLE:
124 proto_tree_add_text(ospf_header_tree, offset + 14 , 2, "Auth Type: simple");
125 strncpy(auth_data, (char *) &ospfh.auth_data, 8);
126 proto_tree_add_text(ospf_header_tree, offset + 16 , 8, "Auth Data: %s", auth_data);
128 case OSPF_AUTH_CRYPT:
129 crypto = (e_ospf_crypto *)ospfh.auth_data;
130 proto_tree_add_text(ospf_header_tree, offset + 14 , 2, "Auth Type: crypt");
131 proto_tree_add_text(ospf_header_tree, offset + 18 , 1, "Auth Key ID: %d",
133 proto_tree_add_text(ospf_header_tree, offset + 19 , 1, "Auth Data Length: %d",
135 proto_tree_add_text(ospf_header_tree, offset + 20 , 4, "Auth Crypto Sequence Number: 0x%x",
136 ntohl(crypto->sequence_num));
138 ospflen = ntohs(ospfh.length);
139 for (i = 0; i < crypto->length && i < (sizeof(auth_data)/2); i++)
140 sprintf(&auth_data[i*2],"%02x",pd[offset + ospflen + i]);
141 proto_tree_add_text(ospf_header_tree, offset + ospflen , 16, "Auth Data: %s", auth_data);
144 proto_tree_add_text(ospf_header_tree, offset + 14 , 2, "Auth Type (unknown)");
145 proto_tree_add_text(ospf_header_tree, offset + 16 , 8, "Auth Data (unknown)");
150 /* Temporarily adjust the captured length to match the size of the OSPF
151 * packet (since the dissect routines use it to work out where the end of
152 * the ospf packet is).
154 saved_len = pi.captured_len;
155 if (BYTES_ARE_IN_FRAME(offset, ntohs(ospfh.length))) {
156 pi.captured_len = offset + ntohs(ospfh.length);
159 /* Skip over header */
160 offset += OSPF_HEADER_LENGTH;
162 switch(ospfh.packet_type){
164 dissect_ospf_hello(pd, offset, fd, ospf_tree);
167 dissect_ospf_db_desc(pd, offset, fd, ospf_tree);
170 dissect_ospf_ls_req(pd, offset, fd, ospf_tree);
173 dissect_ospf_ls_upd(pd, offset, fd, ospf_tree);
176 dissect_ospf_ls_ack(pd, offset, fd, ospf_tree);
179 pi.captured_len = saved_len;
180 dissect_data(pd, offset, fd, tree);
182 pi.captured_len = saved_len;
186 dissect_ospf_hello(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
187 e_ospf_hello ospfhello;
188 guint32 *ospfneighbor;
192 proto_tree *ospf_hello_tree;
195 memcpy(&ospfhello, &pd[offset], sizeof(e_ospf_hello));
198 ti = proto_tree_add_text(tree, offset, END_OF_FRAME, "OSPF Hello Packet");
199 ospf_hello_tree = proto_item_add_subtree(ti, ett_ospf_hello);
202 proto_tree_add_text(ospf_hello_tree, offset , 4, "Network Mask: %s", ip_to_str((guint8 *) &ospfhello.network_mask));
203 proto_tree_add_text(ospf_hello_tree, offset + 4, 2, "Hello Interval: %d seconds", ntohs(ospfhello.hellointervall));
205 /* ATTENTION !!! no check for length of options string */
207 if(( ospfhello.options & OSPF_OPTIONS_E ) == OSPF_OPTIONS_E){
208 strcpy( (char *)(options + options_offset), "E");
211 if(( ospfhello.options & OSPF_OPTIONS_MC ) == OSPF_OPTIONS_MC){
212 strcpy((char *) (options + options_offset), "/MC");
215 if(( ospfhello.options & OSPF_OPTIONS_NP ) == OSPF_OPTIONS_NP){
216 strcpy((char *) (options + options_offset), "/NP");
219 if(( ospfhello.options & OSPF_OPTIONS_EA ) == OSPF_OPTIONS_EA){
220 strcpy((char *) (options + options_offset) , "/EA");
223 if(( ospfhello.options & OSPF_OPTIONS_DC ) == OSPF_OPTIONS_DC){
224 strcpy((char *) (options + options_offset) , "/DC");
228 proto_tree_add_text(ospf_hello_tree, offset + 6, 1, "Options: %d (%s)", ospfhello.options, options);
229 proto_tree_add_text(ospf_hello_tree, offset + 7, 1, "Router Priority: %d", ospfhello.priority);
230 proto_tree_add_text(ospf_hello_tree, offset + 8, 4, "Router Dead Interval: %ld seconds", (long)ntohl(ospfhello.dead_interval));
231 proto_tree_add_text(ospf_hello_tree, offset + 12, 4, "Designated Router: %s", ip_to_str((guint8 *) &ospfhello.drouter));
232 proto_tree_add_text(ospf_hello_tree, offset + 16, 4, "Backup Designated Router: %s", ip_to_str((guint8 *) &ospfhello.bdrouter));
236 while(((int)(pi.captured_len - offset)) >= 4){
237 ospfneighbor=(guint32 *) &pd[offset];
238 proto_tree_add_text(ospf_hello_tree, offset, 4, "Active Neighbor: %s", ip_to_str((guint8 *) ospfneighbor));
245 dissect_ospf_db_desc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
252 proto_tree *ospf_db_desc_tree=NULL;
255 memcpy(&ospf_dbd, &pd[offset], sizeof(e_ospf_dbd));
258 ti = proto_tree_add_text(tree, offset, END_OF_FRAME, "OSPF DB Description");
259 ospf_db_desc_tree = proto_item_add_subtree(ti, ett_ospf_desc);
261 proto_tree_add_text(ospf_db_desc_tree, offset, 2, "Interface MTU: %d", ntohs(ospf_dbd.interface_mtu) );
265 if(( ospf_dbd.options & OSPF_OPTIONS_E ) == OSPF_OPTIONS_E){
266 strcpy( (char *)(options + options_offset), "_E_");
269 if(( ospf_dbd.options & OSPF_OPTIONS_MC ) == OSPF_OPTIONS_MC){
270 strcpy((char *) (options + options_offset), "_MC_");
273 if(( ospf_dbd.options & OSPF_OPTIONS_NP ) == OSPF_OPTIONS_NP){
274 strcpy((char *) (options + options_offset), "_NP_");
277 if(( ospf_dbd.options & OSPF_OPTIONS_EA ) == OSPF_OPTIONS_EA){
278 strcpy((char *) (options + options_offset) , "_EA_");
281 if(( ospf_dbd.options & OSPF_OPTIONS_DC ) == OSPF_OPTIONS_DC){
282 strcpy((char *) (options + options_offset) , "_DC_");
286 proto_tree_add_text(ospf_db_desc_tree, offset + 2 , 1, "Options: %d (%s)", ospf_dbd.options, options );
290 if(( ospf_dbd.flags & OSPF_DBD_FLAG_MS ) == OSPF_DBD_FLAG_MS){
291 strcpy( (char *)(flags + flags_offset), "_I_");
294 if(( ospf_dbd.flags & OSPF_DBD_FLAG_M ) == OSPF_DBD_FLAG_M){
295 strcpy((char *) (flags + flags_offset), "_M_");
298 if(( ospf_dbd.flags & OSPF_DBD_FLAG_I ) == OSPF_DBD_FLAG_I){
299 strcpy((char *) (flags + flags_offset), "_I_");
303 proto_tree_add_text(ospf_db_desc_tree, offset + 3 , 1, "Flags: %d (%s)", ospf_dbd.flags, flags );
304 proto_tree_add_text(ospf_db_desc_tree, offset + 4 , 4, "DD Sequence: %ld", (long)ntohl(ospf_dbd.dd_sequence) );
306 /* LS Headers will be processed here */
307 /* skip to the end of DB-Desc header */
309 while( ((int) (pi.captured_len - offset)) >= OSPF_LSA_HEADER_LENGTH ) {
310 dissect_ospf_lsa(pd, offset, fd, tree, FALSE);
311 offset+=OSPF_LSA_HEADER_LENGTH;
316 dissect_ospf_ls_req(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
317 e_ospf_ls_req ospf_lsr;
319 proto_tree *ospf_lsr_tree;
323 /* zero or more LS requests may be within a LS Request */
324 /* we place every request for a LSA in a single subtree */
326 while( ((int) (pi.captured_len - offset)) >= OSPF_LS_REQ_LENGTH ){
327 memcpy(&ospf_lsr, &pd[offset], sizeof(e_ospf_ls_req));
328 ti = proto_tree_add_text(tree, offset, OSPF_LS_REQ_LENGTH, "Link State Request");
329 ospf_lsr_tree = proto_item_add_subtree(ti, ett_ospf_lsr);
331 switch( ntohl( ospf_lsr.ls_type ) ){
332 case OSPF_LSTYPE_ROUTER:
333 proto_tree_add_text(ospf_lsr_tree, offset, 4, "LS Type: Router-LSA (%ld)",
334 (long)ntohl( ospf_lsr.ls_type ) );
336 case OSPF_LSTYPE_NETWORK:
337 proto_tree_add_text(ospf_lsr_tree, offset, 4, "LS Type: Network-LSA (%ld)",
338 (long)ntohl( ospf_lsr.ls_type ) );
340 case OSPF_LSTYPE_SUMMERY:
341 proto_tree_add_text(ospf_lsr_tree, offset, 4, "LS Type: Summary-LSA (IP network) (%ld)",
342 (long)ntohl( ospf_lsr.ls_type ) );
344 case OSPF_LSTYPE_ASBR:
345 proto_tree_add_text(ospf_lsr_tree, offset, 4, "LS Type: Summary-LSA (ASBR) (%ld)",
346 (long)ntohl( ospf_lsr.ls_type ) );
348 case OSPF_LSTYPE_ASEXT:
349 proto_tree_add_text(ospf_lsr_tree, offset, 4, "LS Type: AS-External-LSA (ASBR) (%ld)",
350 (long)ntohl( ospf_lsr.ls_type ) );
353 proto_tree_add_text(ospf_lsr_tree, offset, 4, "LS Type: %ld (unknown)",
354 (long)ntohl( ospf_lsr.ls_type ) );
357 proto_tree_add_text(ospf_lsr_tree, offset + 4, 4, "Link State ID : %s",
358 ip_to_str((guint8 *) &(ospf_lsr.ls_id)));
359 proto_tree_add_text(ospf_lsr_tree, offset + 8, 4, "Advertising Router : %s",
360 ip_to_str((guint8 *) &(ospf_lsr.adv_router)));
367 dissect_ospf_ls_upd(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
368 e_ospf_lsa_upd_hdr upd_hdr;
371 proto_tree *ospf_lsa_upd_tree=NULL;
374 memcpy(&upd_hdr, &pd[offset], sizeof(e_ospf_lsa_upd_hdr));
377 ti = proto_tree_add_text(tree, offset, END_OF_FRAME, "LS Update Packet");
378 ospf_lsa_upd_tree = proto_item_add_subtree(ti, ett_ospf_lsa_upd);
380 proto_tree_add_text(ospf_lsa_upd_tree, offset, 4, "Nr oF LSAs: %ld", (long)ntohl(upd_hdr.lsa_nr) );
382 /* skip to the beginning of the first LSA */
383 offset+=4; /* the LS Upd PAcket contains only a 32 bit #LSAs field */
386 while(lsa_counter < ntohl(upd_hdr.lsa_nr)){
387 offset+=dissect_ospf_lsa(pd, offset, fd, ospf_lsa_upd_tree, TRUE);
393 dissect_ospf_ls_ack(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
395 /* the body of a LS Ack packet simply contains zero or more LSA Headers */
396 while( ((int)(pi.captured_len - offset)) >= OSPF_LSA_HEADER_LENGTH ) {
397 dissect_ospf_lsa(pd, offset, fd, tree, FALSE);
398 offset+=OSPF_LSA_HEADER_LENGTH;
404 dissect_ospf_lsa(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int disassemble_body) {
405 e_ospf_lsa_hdr lsa_hdr;
409 /* data strutures for the router LSA */
410 e_ospf_router_lsa router_lsa;
411 e_ospf_router_data router_data;
412 e_ospf_router_metric tos_data;
413 guint16 link_counter;
418 /* data structures for the network lsa */
419 e_ospf_network_lsa network_lsa;
420 guint32 *attached_router;
422 /* data structures for the summary and ASBR LSAs */
423 e_ospf_summary_lsa summary_lsa;
425 /* data structures for the AS-External LSA */
426 e_ospf_asexternal_lsa asext_lsa;
427 guint32 asext_metric;
429 proto_tree *ospf_lsa_tree;
432 memcpy(&lsa_hdr, &pd[offset], sizeof(e_ospf_lsa_hdr));
436 switch(lsa_hdr.ls_type) {
437 case OSPF_LSTYPE_ROUTER:
438 lsa_type="Router LSA";
440 case OSPF_LSTYPE_NETWORK:
441 lsa_type="Network LSA";
443 case OSPF_LSTYPE_SUMMERY:
444 lsa_type="Summary LSA";
446 case OSPF_LSTYPE_ASBR:
449 case OSPF_LSTYPE_ASEXT:
450 lsa_type="AS-external-LSA";
457 if(disassemble_body){
458 ti = proto_tree_add_text(tree, offset, ntohs(lsa_hdr.length),
459 "%s (Type: %d)", lsa_type, lsa_hdr.ls_type);
461 ti = proto_tree_add_text(tree, offset, OSPF_LSA_HEADER_LENGTH, "LSA Header");
463 ospf_lsa_tree = proto_item_add_subtree(ti, ett_ospf_lsa);
466 proto_tree_add_text(ospf_lsa_tree, offset, 2, "LS Age: %d seconds", ntohs(lsa_hdr.ls_age));
467 proto_tree_add_text(ospf_lsa_tree, offset + 2, 1, "Options: %d ", lsa_hdr.options);
468 proto_tree_add_text(ospf_lsa_tree, offset + 3, 1, "LSA Type: %d (%s)", lsa_hdr.ls_type, lsa_type);
470 proto_tree_add_text(ospf_lsa_tree, offset + 4, 4, "Linke State ID: %s ",
471 ip_to_str((guint8 *) &(lsa_hdr.ls_id)));
473 proto_tree_add_text(ospf_lsa_tree, offset + 8, 4, "Advertising Router: %s ",
474 ip_to_str((guint8 *) &(lsa_hdr.adv_router)));
475 proto_tree_add_text(ospf_lsa_tree, offset + 12, 4, "LS Sequence Number: 0x%04lx ",
476 (unsigned long)ntohl(lsa_hdr.ls_seq));
477 proto_tree_add_text(ospf_lsa_tree, offset + 16, 2, "LS Checksum: %d ", ntohs(lsa_hdr.ls_checksum));
479 proto_tree_add_text(ospf_lsa_tree, offset + 18, 2, "Length: %d ", ntohs(lsa_hdr.length));
481 if(!disassemble_body){
482 return OSPF_LSA_HEADER_LENGTH;
485 lsa_end = offset + ntohs(lsa_hdr.length);
486 /* the LSA body starts after 20 bytes of LSA Header */
489 switch(lsa_hdr.ls_type){
490 case(OSPF_LSTYPE_ROUTER):
491 memcpy(&router_lsa, &pd[offset], sizeof(e_ospf_router_lsa));
493 /* again: flags should be secified in detail */
494 proto_tree_add_text(ospf_lsa_tree, offset, 1, "Flags: 0x%02x ", router_lsa.flags);
495 proto_tree_add_text(ospf_lsa_tree, offset + 2, 2, "Nr. of Links: %d ",
496 ntohs(router_lsa.nr_links));
498 /* router_lsa.nr_links links follow
499 * maybe we should put each of the links into its own subtree ???
501 for(link_counter = 1 ; link_counter <= ntohs(router_lsa.nr_links); link_counter++){
503 memcpy(&router_data, &pd[offset], sizeof(e_ospf_router_data));
504 /* check the Link Type and ID */
505 switch(router_data.link_type) {
507 link_type="Point-to-point connection to another router";
508 link_id="Neighboring router's Router ID";
510 case OSPF_LINK_TRANSIT:
511 link_type="Connection to a transit network";
512 link_id="IP address of Designated Router";
515 link_type="Connection to a stub network";
516 link_id="IP network/subnet number";
518 case OSPF_LINK_VIRTUAL:
519 link_type="Virtual link";
520 link_id="Neighboring router's Router ID";
523 link_type="unknown link type";
524 link_id="unknown link id";
527 proto_tree_add_text(ospf_lsa_tree, offset, 4, "%s: %s", link_id,
528 ip_to_str((guint8 *) &(router_data.link_id)));
530 /* link_data should be specified in detail (e.g. network mask) (depends on link type)*/
531 proto_tree_add_text(ospf_lsa_tree, offset + 4, 4, "Link Data: %s",
532 ip_to_str((guint8 *) &(router_data.link_data)));
534 proto_tree_add_text(ospf_lsa_tree, offset + 8, 1, "Link Type: %d - %s",
535 router_data.link_type, link_type);
536 proto_tree_add_text(ospf_lsa_tree, offset + 9, 1, "Nr. of TOS metrics: %d", router_data.nr_tos);
537 proto_tree_add_text(ospf_lsa_tree, offset + 10, 2, "TOS 0 metric: %d", ntohs( router_data.tos0_metric ));
541 /* router_data.nr_tos metrics may follow each link
542 * ATTENTION: TOS metrics are not tested (I don't have TOS based routing)
543 * please send me a mail if it is/isn't working
546 for(tos_counter = 1 ; link_counter <= ntohs(router_data.nr_tos); tos_counter++){
547 memcpy(&tos_data, &pd[offset], sizeof(e_ospf_router_metric));
548 proto_tree_add_text(ospf_lsa_tree, offset, 1, "TOS: %d, Metric: %d",
549 tos_data.tos, ntohs(tos_data.metric));
554 case(OSPF_LSTYPE_NETWORK):
555 memcpy(&network_lsa, &pd[offset], sizeof(e_ospf_network_lsa));
556 proto_tree_add_text(ospf_lsa_tree, offset, 4, "Netmask: %s",
557 ip_to_str((guint8 *) &(network_lsa.network_mask)));
560 while( (lsa_end - offset) >= 4){
561 attached_router = (guint32 *) &pd[offset];
562 proto_tree_add_text(ospf_lsa_tree, offset, 4, "Attached Router: %s",
563 ip_to_str((guint8 *) attached_router));
567 case(OSPF_LSTYPE_SUMMERY):
568 /* Type 3 and 4 LSAs have the same format */
569 case(OSPF_LSTYPE_ASBR):
570 memcpy(&summary_lsa, &pd[offset], sizeof(e_ospf_summary_lsa));
571 proto_tree_add_text(ospf_lsa_tree, offset, 4, "Netmask: %s",
572 ip_to_str((guint8 *) &(summary_lsa.network_mask)));
573 /* returns only the TOS 0 metric (even if there are more TOS metrics) */
575 case(OSPF_LSTYPE_ASEXT):
576 memcpy(&summary_lsa, &pd[offset], sizeof(e_ospf_summary_lsa));
577 proto_tree_add_text(ospf_lsa_tree, offset, 4, "Netmask: %s",
578 ip_to_str((guint8 *) &(summary_lsa.network_mask)));
580 /* asext_lsa = (e_ospf_asexternal_lsa *) &pd[offset + 4]; */
581 memcpy(&asext_lsa, &pd[offset + 4], sizeof(asext_lsa));
582 if( (asext_lsa.options & 128) == 128 ) { /* check wether or not E bit is set */
583 proto_tree_add_text(ospf_lsa_tree, offset, 1,
584 "External Type: Type 2 (metric is larger than any other link state path)");
586 proto_tree_add_text(ospf_lsa_tree, offset + 4, 1,
587 "External Type: Type 1 (metric is specified in the same units as interface cost)");
589 /* the metric field of a AS-external LAS is specified in 3 bytes -> not well aligned */
590 /* this routine returns only the TOS 0 metric (even if there are more TOS metrics) */
591 memcpy(&asext_metric, &pd[offset+4], 4);
593 /* erase the leading 8 bits (the dont belong to the metric */
594 asext_metric = ntohl(asext_metric) & 0x00ffffff ;
596 proto_tree_add_text(ospf_lsa_tree, offset + 5, 3,"Metric: %d", asext_metric);
597 proto_tree_add_text(ospf_lsa_tree, offset + 8, 4,"Forwarding Address: %s",
598 ip_to_str((guint8 *) &(asext_lsa.gateway)));
599 proto_tree_add_text(ospf_lsa_tree, offset + 12, 4,"External Route Tag: %ld", (long)ntohl(asext_lsa.external_tag));
603 /* unknown LSA type */
604 proto_tree_add_text(ospf_lsa_tree, offset, END_OF_FRAME, "Unknown LSA Type");
607 /* return the length of this LSA */
608 return ntohs(lsa_hdr.length);
612 proto_register_ospf(void)
614 /* static hf_register_info hf[] = {
616 { "Name", "ospf.abbreviation", TYPE, VALS_POINTER }},
618 static gint *ett[] = {
628 proto_ospf = proto_register_protocol("Open Shortest Path First", "ospf");
629 /* proto_register_field_array(proto_ospf, hf, array_length(hf));*/
630 proto_register_subtree_array(ett, array_length(ett));