Home | History | Annotate | Line # | Download | only in dist
print-ospf.c revision 1.10
      1   1.1  christos /*
      2   1.1  christos  * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
      3   1.1  christos  *	The Regents of the University of California.  All rights reserved.
      4   1.1  christos  *
      5   1.1  christos  * Redistribution and use in source and binary forms, with or without
      6   1.1  christos  * modification, are permitted provided that: (1) source code distributions
      7   1.1  christos  * retain the above copyright notice and this paragraph in its entirety, (2)
      8   1.1  christos  * distributions including binary code include the above copyright notice and
      9   1.1  christos  * this paragraph in its entirety in the documentation or other materials
     10   1.1  christos  * provided with the distribution, and (3) all advertising materials mentioning
     11   1.1  christos  * features or use of this software display the following acknowledgement:
     12   1.1  christos  * ``This product includes software developed by the University of California,
     13   1.1  christos  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
     14   1.1  christos  * the University nor the names of its contributors may be used to endorse
     15   1.1  christos  * or promote products derived from this software without specific prior
     16   1.1  christos  * written permission.
     17   1.1  christos  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
     18   1.1  christos  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
     19   1.1  christos  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
     20   1.1  christos  *
     21   1.1  christos  * OSPF support contributed by Jeffrey Honig (jch (at) mitchell.cit.cornell.edu)
     22   1.1  christos  */
     23   1.1  christos 
     24   1.2  christos #include <sys/cdefs.h>
     25   1.1  christos #ifndef lint
     26  1.10  christos __RCSID("$NetBSD: print-ospf.c,v 1.10 2023/08/17 20:19:40 christos Exp $");
     27   1.1  christos #endif
     28   1.1  christos 
     29   1.8       spz /* \summary: Open Shortest Path First (OSPF) printer */
     30   1.8       spz 
     31   1.1  christos #ifdef HAVE_CONFIG_H
     32  1.10  christos #include <config.h>
     33   1.1  christos #endif
     34   1.1  christos 
     35  1.10  christos #include "netdissect-stdinc.h"
     36   1.1  christos 
     37   1.7  christos #include "netdissect.h"
     38   1.1  christos #include "addrtoname.h"
     39   1.1  christos #include "extract.h"
     40   1.1  christos #include "gmpls.h"
     41   1.1  christos 
     42   1.1  christos #include "ospf.h"
     43   1.1  christos 
     44   1.1  christos 
     45   1.4  christos static const struct tok ospf_option_values[] = {
     46  1.10  christos 	{ OSPF_OPTION_MT,	"MultiTopology" }, /* draft-ietf-ospf-mt-09 */
     47   1.1  christos 	{ OSPF_OPTION_E,	"External" },
     48   1.1  christos 	{ OSPF_OPTION_MC,	"Multicast" },
     49   1.1  christos 	{ OSPF_OPTION_NP,	"NSSA" },
     50  1.10  christos 	{ OSPF_OPTION_L,	"LLS" },
     51   1.1  christos 	{ OSPF_OPTION_DC,	"Demand Circuit" },
     52   1.1  christos 	{ OSPF_OPTION_O,	"Opaque" },
     53   1.1  christos 	{ OSPF_OPTION_DN,	"Up/Down" },
     54   1.1  christos 	{ 0,			NULL }
     55   1.1  christos };
     56   1.1  christos 
     57   1.4  christos static const struct tok ospf_authtype_values[] = {
     58   1.1  christos 	{ OSPF_AUTH_NONE,	"none" },
     59   1.1  christos 	{ OSPF_AUTH_SIMPLE,	"simple" },
     60   1.1  christos 	{ OSPF_AUTH_MD5,	"MD5" },
     61   1.1  christos 	{ 0,			NULL }
     62   1.1  christos };
     63   1.1  christos 
     64   1.4  christos static const struct tok ospf_rla_flag_values[] = {
     65   1.1  christos 	{ RLA_FLAG_B,		"ABR" },
     66   1.1  christos 	{ RLA_FLAG_E,		"ASBR" },
     67  1.10  christos 	{ RLA_FLAG_V,		"Virtual" },
     68  1.10  christos 	{ RLA_FLAG_W,		"Wildcard" },
     69  1.10  christos 	{ RLA_FLAG_NT,		"Nt" },
     70  1.10  christos 	{ RLA_FLAG_H,		"Host" },
     71   1.1  christos 	{ 0,			NULL }
     72   1.1  christos };
     73   1.1  christos 
     74   1.4  christos static const struct tok type2str[] = {
     75   1.1  christos 	{ OSPF_TYPE_HELLO,	"Hello" },
     76   1.1  christos 	{ OSPF_TYPE_DD,		"Database Description" },
     77   1.1  christos 	{ OSPF_TYPE_LS_REQ,	"LS-Request" },
     78   1.1  christos 	{ OSPF_TYPE_LS_UPDATE,	"LS-Update" },
     79   1.1  christos 	{ OSPF_TYPE_LS_ACK,	"LS-Ack" },
     80   1.1  christos 	{ 0,			NULL }
     81   1.1  christos };
     82   1.1  christos 
     83   1.4  christos static const struct tok lsa_values[] = {
     84   1.1  christos 	{ LS_TYPE_ROUTER,       "Router" },
     85   1.1  christos 	{ LS_TYPE_NETWORK,      "Network" },
     86   1.1  christos 	{ LS_TYPE_SUM_IP,       "Summary" },
     87   1.1  christos 	{ LS_TYPE_SUM_ABR,      "ASBR Summary" },
     88   1.1  christos 	{ LS_TYPE_ASE,          "External" },
     89   1.1  christos 	{ LS_TYPE_GROUP,        "Multicast Group" },
     90   1.1  christos 	{ LS_TYPE_NSSA,         "NSSA" },
     91   1.1  christos 	{ LS_TYPE_OPAQUE_LL,    "Link Local Opaque" },
     92   1.1  christos 	{ LS_TYPE_OPAQUE_AL,    "Area Local Opaque" },
     93   1.1  christos 	{ LS_TYPE_OPAQUE_DW,    "Domain Wide Opaque" },
     94   1.1  christos 	{ 0,			NULL }
     95   1.1  christos };
     96   1.1  christos 
     97   1.4  christos static const struct tok ospf_dd_flag_values[] = {
     98   1.1  christos 	{ OSPF_DB_INIT,	        "Init" },
     99   1.1  christos 	{ OSPF_DB_MORE,	        "More" },
    100   1.1  christos 	{ OSPF_DB_MASTER,	"Master" },
    101   1.1  christos     { OSPF_DB_RESYNC,	"OOBResync" },
    102   1.1  christos 	{ 0,			NULL }
    103   1.1  christos };
    104   1.1  christos 
    105   1.4  christos static const struct tok lsa_opaque_values[] = {
    106   1.1  christos 	{ LS_OPAQUE_TYPE_TE,    "Traffic Engineering" },
    107   1.1  christos 	{ LS_OPAQUE_TYPE_GRACE, "Graceful restart" },
    108   1.1  christos 	{ LS_OPAQUE_TYPE_RI,    "Router Information" },
    109   1.1  christos 	{ 0,			NULL }
    110   1.1  christos };
    111   1.1  christos 
    112   1.4  christos static const struct tok lsa_opaque_te_tlv_values[] = {
    113   1.1  christos 	{ LS_OPAQUE_TE_TLV_ROUTER, "Router Address" },
    114   1.1  christos 	{ LS_OPAQUE_TE_TLV_LINK,   "Link" },
    115   1.1  christos 	{ 0,			NULL }
    116   1.1  christos };
    117   1.1  christos 
    118   1.4  christos static const struct tok lsa_opaque_te_link_tlv_subtlv_values[] = {
    119   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE,            "Link Type" },
    120   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID,              "Link ID" },
    121   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP,             "Local Interface IP address" },
    122   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP,            "Remote Interface IP address" },
    123   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC,            "Traffic Engineering Metric" },
    124   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW,               "Maximum Bandwidth" },
    125   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW,           "Maximum Reservable Bandwidth" },
    126   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW,             "Unreserved Bandwidth" },
    127   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP,          "Administrative Group" },
    128   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
    129   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE, "Link Protection Type" },
    130   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR,    "Interface Switching Capability" },
    131   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP,    "Shared Risk Link Group" },
    132   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS,       "Bandwidth Constraints" },
    133   1.1  christos 	{ 0,			NULL }
    134   1.1  christos };
    135   1.1  christos 
    136   1.4  christos static const struct tok lsa_opaque_grace_tlv_values[] = {
    137   1.1  christos 	{ LS_OPAQUE_GRACE_TLV_PERIOD,             "Grace Period" },
    138   1.1  christos 	{ LS_OPAQUE_GRACE_TLV_REASON,             "Graceful restart Reason" },
    139   1.1  christos 	{ LS_OPAQUE_GRACE_TLV_INT_ADDRESS,        "IPv4 interface address" },
    140   1.1  christos 	{ 0,		        NULL }
    141   1.1  christos };
    142   1.1  christos 
    143   1.4  christos static const struct tok lsa_opaque_grace_tlv_reason_values[] = {
    144   1.1  christos 	{ LS_OPAQUE_GRACE_TLV_REASON_UNKNOWN,     "Unknown" },
    145   1.1  christos 	{ LS_OPAQUE_GRACE_TLV_REASON_SW_RESTART,  "Software Restart" },
    146   1.1  christos 	{ LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE,  "Software Reload/Upgrade" },
    147   1.1  christos 	{ LS_OPAQUE_GRACE_TLV_REASON_CP_SWITCH,   "Control Processor Switch" },
    148   1.1  christos 	{ 0,		        NULL }
    149   1.1  christos };
    150   1.1  christos 
    151   1.4  christos static const struct tok lsa_opaque_te_tlv_link_type_sub_tlv_values[] = {
    152   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP, "Point-to-point" },
    153   1.1  christos 	{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA,  "Multi-Access" },
    154   1.1  christos 	{ 0,			NULL }
    155   1.1  christos };
    156   1.1  christos 
    157   1.4  christos static const struct tok lsa_opaque_ri_tlv_values[] = {
    158   1.1  christos 	{ LS_OPAQUE_RI_TLV_CAP, "Router Capabilities" },
    159   1.1  christos 	{ 0,		        NULL }
    160   1.1  christos };
    161   1.1  christos 
    162   1.4  christos static const struct tok lsa_opaque_ri_tlv_cap_values[] = {
    163   1.1  christos 	{ 1, "Reserved" },
    164   1.1  christos 	{ 2, "Reserved" },
    165   1.1  christos 	{ 4, "Reserved" },
    166   1.1  christos 	{ 8, "Reserved" },
    167   1.1  christos 	{ 16, "graceful restart capable" },
    168   1.1  christos 	{ 32, "graceful restart helper" },
    169   1.1  christos 	{ 64, "Stub router support" },
    170   1.1  christos 	{ 128, "Traffic engineering" },
    171   1.1  christos 	{ 256, "p2p over LAN" },
    172   1.1  christos 	{ 512, "path computation server" },
    173   1.1  christos 	{ 0,		        NULL }
    174   1.1  christos };
    175   1.1  christos 
    176   1.4  christos static const struct tok ospf_lls_tlv_values[] = {
    177   1.1  christos 	{ OSPF_LLS_EO,	"Extended Options" },
    178   1.1  christos 	{ OSPF_LLS_MD5,	"MD5 Authentication" },
    179   1.1  christos 	{ 0,	NULL }
    180   1.1  christos };
    181   1.1  christos 
    182   1.4  christos static const struct tok ospf_lls_eo_options[] = {
    183   1.1  christos 	{ OSPF_LLS_EO_LR,	"LSDB resync" },
    184   1.1  christos 	{ OSPF_LLS_EO_RS,	"Restart" },
    185   1.1  christos 	{ 0,	NULL }
    186   1.1  christos };
    187   1.1  christos 
    188   1.1  christos int
    189  1.10  christos ospf_grace_lsa_print(netdissect_options *ndo,
    190  1.10  christos                      const u_char *tptr, u_int ls_length)
    191   1.6  christos {
    192   1.1  christos     u_int tlv_type, tlv_length;
    193   1.1  christos 
    194   1.1  christos 
    195   1.1  christos     while (ls_length > 0) {
    196  1.10  christos         ND_TCHECK_4(tptr);
    197   1.1  christos         if (ls_length < 4) {
    198  1.10  christos             ND_PRINT("\n\t    Remaining LS length %u < 4", ls_length);
    199   1.1  christos             return -1;
    200   1.1  christos         }
    201  1.10  christos         tlv_type = GET_BE_U_2(tptr);
    202  1.10  christos         tlv_length = GET_BE_U_2(tptr + 2);
    203   1.1  christos         tptr+=4;
    204   1.1  christos         ls_length-=4;
    205   1.5  christos 
    206  1.10  christos         ND_PRINT("\n\t    %s TLV (%u), length %u, value: ",
    207   1.1  christos                tok2str(lsa_opaque_grace_tlv_values,"unknown",tlv_type),
    208   1.1  christos                tlv_type,
    209  1.10  christos                tlv_length);
    210   1.1  christos 
    211   1.1  christos         if (tlv_length > ls_length) {
    212  1.10  christos             ND_PRINT("\n\t    Bogus length %u > %u", tlv_length,
    213  1.10  christos                    ls_length);
    214   1.1  christos             return -1;
    215   1.1  christos         }
    216   1.1  christos 
    217   1.1  christos         /* Infinite loop protection. */
    218   1.1  christos         if (tlv_type == 0 || tlv_length ==0) {
    219   1.1  christos             return -1;
    220   1.1  christos         }
    221   1.1  christos 
    222  1.10  christos         ND_TCHECK_LEN(tptr, tlv_length);
    223   1.1  christos         switch(tlv_type) {
    224   1.1  christos 
    225   1.1  christos         case LS_OPAQUE_GRACE_TLV_PERIOD:
    226   1.1  christos             if (tlv_length != 4) {
    227  1.10  christos                 ND_PRINT("\n\t    Bogus length %u != 4", tlv_length);
    228   1.1  christos                 return -1;
    229   1.1  christos             }
    230  1.10  christos             ND_PRINT("%us", GET_BE_U_4(tptr));
    231   1.1  christos             break;
    232   1.1  christos 
    233   1.1  christos         case LS_OPAQUE_GRACE_TLV_REASON:
    234   1.1  christos             if (tlv_length != 1) {
    235  1.10  christos                 ND_PRINT("\n\t    Bogus length %u != 1", tlv_length);
    236   1.1  christos                 return -1;
    237   1.1  christos             }
    238  1.10  christos             ND_PRINT("%s (%u)",
    239  1.10  christos                    tok2str(lsa_opaque_grace_tlv_reason_values, "Unknown", GET_U_1(tptr)),
    240  1.10  christos                    GET_U_1(tptr));
    241   1.1  christos             break;
    242   1.1  christos 
    243   1.1  christos         case LS_OPAQUE_GRACE_TLV_INT_ADDRESS:
    244   1.1  christos             if (tlv_length != 4) {
    245  1.10  christos                 ND_PRINT("\n\t    Bogus length %u != 4", tlv_length);
    246   1.1  christos                 return -1;
    247   1.1  christos             }
    248  1.10  christos             ND_PRINT("%s", GET_IPADDR_STRING(tptr));
    249   1.1  christos             break;
    250   1.1  christos 
    251   1.1  christos         default:
    252   1.5  christos             if (ndo->ndo_vflag <= 1) {
    253   1.5  christos                 if (!print_unknown_data(ndo, tptr, "\n\t      ", tlv_length))
    254   1.1  christos                     return -1;
    255   1.1  christos             }
    256   1.1  christos             break;
    257   1.1  christos 
    258   1.1  christos         }
    259   1.1  christos         /* in OSPF everything has to be 32-bit aligned, including TLVs */
    260   1.1  christos         if (tlv_length%4 != 0)
    261   1.1  christos             tlv_length+=4-(tlv_length%4);
    262   1.1  christos         ls_length-=tlv_length;
    263   1.1  christos         tptr+=tlv_length;
    264   1.1  christos     }
    265   1.1  christos 
    266   1.1  christos     return 0;
    267   1.1  christos trunc:
    268   1.1  christos     return -1;
    269   1.1  christos }
    270   1.1  christos 
    271   1.1  christos int
    272  1.10  christos ospf_te_lsa_print(netdissect_options *ndo,
    273  1.10  christos                   const u_char *tptr, u_int ls_length)
    274   1.6  christos {
    275   1.1  christos     u_int tlv_type, tlv_length, subtlv_type, subtlv_length;
    276   1.1  christos     u_int priority_level, te_class, count_srlg;
    277   1.1  christos     union { /* int to float conversion buffer for several subTLVs */
    278   1.5  christos         float f;
    279   1.5  christos         uint32_t i;
    280   1.1  christos     } bw;
    281   1.1  christos 
    282   1.1  christos     while (ls_length != 0) {
    283  1.10  christos         ND_TCHECK_4(tptr);
    284   1.1  christos         if (ls_length < 4) {
    285  1.10  christos             ND_PRINT("\n\t    Remaining LS length %u < 4", ls_length);
    286   1.1  christos             return -1;
    287   1.1  christos         }
    288  1.10  christos         tlv_type = GET_BE_U_2(tptr);
    289  1.10  christos         tlv_length = GET_BE_U_2(tptr + 2);
    290   1.1  christos         tptr+=4;
    291   1.1  christos         ls_length-=4;
    292   1.5  christos 
    293  1.10  christos         ND_PRINT("\n\t    %s TLV (%u), length: %u",
    294   1.1  christos                tok2str(lsa_opaque_te_tlv_values,"unknown",tlv_type),
    295   1.1  christos                tlv_type,
    296  1.10  christos                tlv_length);
    297   1.1  christos 
    298   1.1  christos         if (tlv_length > ls_length) {
    299  1.10  christos             ND_PRINT("\n\t    Bogus length %u > %u", tlv_length,
    300  1.10  christos                    ls_length);
    301   1.1  christos             return -1;
    302   1.1  christos         }
    303   1.1  christos 
    304   1.1  christos         /* Infinite loop protection. */
    305   1.1  christos         if (tlv_type == 0 || tlv_length ==0) {
    306   1.1  christos             return -1;
    307   1.1  christos         }
    308   1.1  christos 
    309   1.1  christos         switch(tlv_type) {
    310   1.1  christos         case LS_OPAQUE_TE_TLV_LINK:
    311  1.10  christos             while (tlv_length != 0) {
    312   1.1  christos                 if (tlv_length < 4) {
    313  1.10  christos                     ND_PRINT("\n\t    Remaining TLV length %u < 4",
    314  1.10  christos                            tlv_length);
    315   1.1  christos                     return -1;
    316   1.1  christos                 }
    317  1.10  christos                 subtlv_type = GET_BE_U_2(tptr);
    318  1.10  christos                 subtlv_length = GET_BE_U_2(tptr + 2);
    319   1.1  christos                 tptr+=4;
    320   1.1  christos                 tlv_length-=4;
    321   1.5  christos 
    322   1.7  christos 		/* Infinite loop protection */
    323   1.7  christos 		if (subtlv_type == 0 || subtlv_length == 0)
    324   1.7  christos 		    goto invalid;
    325   1.7  christos 
    326  1.10  christos                 ND_PRINT("\n\t      %s subTLV (%u), length: %u",
    327   1.1  christos                        tok2str(lsa_opaque_te_link_tlv_subtlv_values,"unknown",subtlv_type),
    328   1.1  christos                        subtlv_type,
    329  1.10  christos                        subtlv_length);
    330   1.5  christos 
    331  1.10  christos                 if (tlv_length < subtlv_length) {
    332  1.10  christos                     ND_PRINT("\n\t    Remaining TLV length %u < %u",
    333  1.10  christos                            tlv_length + 4, subtlv_length + 4);
    334  1.10  christos                     return -1;
    335  1.10  christos                 }
    336  1.10  christos                 ND_TCHECK_LEN(tptr, subtlv_length);
    337   1.1  christos                 switch(subtlv_type) {
    338   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP:
    339   1.7  christos 		    if (subtlv_length != 4) {
    340  1.10  christos 			ND_PRINT(" != 4");
    341   1.7  christos 			goto invalid;
    342   1.7  christos 		    }
    343  1.10  christos                     ND_PRINT(", 0x%08x", GET_BE_U_4(tptr));
    344   1.1  christos                     break;
    345   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID:
    346   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID:
    347   1.7  christos 		    if (subtlv_length != 4 && subtlv_length != 8) {
    348  1.10  christos 			ND_PRINT(" != 4 && != 8");
    349   1.7  christos 			goto invalid;
    350   1.7  christos 		    }
    351  1.10  christos                     ND_PRINT(", %s (0x%08x)",
    352  1.10  christos                            GET_IPADDR_STRING(tptr),
    353  1.10  christos                            GET_BE_U_4(tptr));
    354   1.1  christos                     if (subtlv_length == 8) /* rfc4203 */
    355  1.10  christos                         ND_PRINT(", %s (0x%08x)",
    356  1.10  christos                                GET_IPADDR_STRING(tptr+4),
    357  1.10  christos                                GET_BE_U_4(tptr + 4));
    358   1.1  christos                     break;
    359   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP:
    360   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP:
    361   1.7  christos 		    if (subtlv_length != 4) {
    362  1.10  christos 			ND_PRINT(" != 4");
    363   1.7  christos 			goto invalid;
    364   1.7  christos 		    }
    365  1.10  christos                     ND_PRINT(", %s", GET_IPADDR_STRING(tptr));
    366   1.1  christos                     break;
    367   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW:
    368   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW:
    369   1.7  christos 		    if (subtlv_length != 4) {
    370  1.10  christos 			ND_PRINT(" != 4");
    371   1.7  christos 			goto invalid;
    372   1.7  christos 		    }
    373  1.10  christos                     bw.i = GET_BE_U_4(tptr);
    374  1.10  christos                     ND_PRINT(", %.3f Mbps", bw.f * 8 / 1000000);
    375   1.1  christos                     break;
    376   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW:
    377   1.7  christos 		    if (subtlv_length != 32) {
    378  1.10  christos 			ND_PRINT(" != 32");
    379   1.7  christos 			goto invalid;
    380   1.7  christos 		    }
    381   1.1  christos                     for (te_class = 0; te_class < 8; te_class++) {
    382  1.10  christos                         bw.i = GET_BE_U_4(tptr + te_class * 4);
    383  1.10  christos                         ND_PRINT("\n\t\tTE-Class %u: %.3f Mbps",
    384   1.1  christos                                te_class,
    385  1.10  christos                                bw.f * 8 / 1000000);
    386   1.1  christos                     }
    387   1.1  christos                     break;
    388   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS:
    389   1.7  christos 		    if (subtlv_length < 4) {
    390  1.10  christos 			ND_PRINT(" < 4");
    391   1.7  christos 			goto invalid;
    392   1.7  christos 		    }
    393   1.7  christos 		    /* BC Model Id (1 octet) + Reserved (3 octets) */
    394  1.10  christos                     ND_PRINT("\n\t\tBandwidth Constraints Model ID: %s (%u)",
    395  1.10  christos                            tok2str(diffserv_te_bc_values, "unknown", GET_U_1(tptr)),
    396  1.10  christos                            GET_U_1(tptr));
    397   1.7  christos 		    if (subtlv_length % 4 != 0) {
    398  1.10  christos 			ND_PRINT("\n\t\tlength %u != N x 4", subtlv_length);
    399   1.7  christos 			goto invalid;
    400   1.7  christos 		    }
    401   1.7  christos 		    if (subtlv_length > 36) {
    402  1.10  christos 			ND_PRINT("\n\t\tlength %u > 36", subtlv_length);
    403   1.7  christos 			goto invalid;
    404   1.7  christos 		    }
    405   1.1  christos                     /* decode BCs until the subTLV ends */
    406   1.1  christos                     for (te_class = 0; te_class < (subtlv_length-4)/4; te_class++) {
    407  1.10  christos                         bw.i = GET_BE_U_4(tptr + 4 + te_class * 4);
    408  1.10  christos                         ND_PRINT("\n\t\t  Bandwidth constraint CT%u: %.3f Mbps",
    409   1.1  christos                                te_class,
    410  1.10  christos                                bw.f * 8 / 1000000);
    411   1.1  christos                     }
    412   1.1  christos                     break;
    413   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC:
    414   1.7  christos 		    if (subtlv_length != 4) {
    415  1.10  christos 			ND_PRINT(" != 4");
    416   1.7  christos 			goto invalid;
    417   1.7  christos 		    }
    418  1.10  christos                     ND_PRINT(", Metric %u", GET_BE_U_4(tptr));
    419   1.1  christos                     break;
    420   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE:
    421   1.7  christos 		    /* Protection Cap (1 octet) + Reserved ((3 octets) */
    422   1.7  christos 		    if (subtlv_length != 4) {
    423  1.10  christos 			ND_PRINT(" != 4");
    424   1.7  christos 			goto invalid;
    425   1.7  christos 		    }
    426  1.10  christos                     ND_PRINT(", %s",
    427  1.10  christos                              bittok2str(gmpls_link_prot_values, "none", GET_U_1(tptr)));
    428   1.1  christos                     break;
    429   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR:
    430   1.7  christos 		    if (subtlv_length < 36) {
    431  1.10  christos 			ND_PRINT(" < 36");
    432   1.7  christos 			goto invalid;
    433   1.7  christos 		    }
    434   1.7  christos 		    /* Switching Cap (1 octet) + Encoding (1) +  Reserved (2) */
    435  1.10  christos                     ND_PRINT("\n\t\tInterface Switching Capability: %s",
    436  1.10  christos                            tok2str(gmpls_switch_cap_values, "Unknown", GET_U_1((tptr))));
    437  1.10  christos                     ND_PRINT("\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:",
    438  1.10  christos                            tok2str(gmpls_encoding_values, "Unknown", GET_U_1((tptr + 1))));
    439   1.1  christos                     for (priority_level = 0; priority_level < 8; priority_level++) {
    440  1.10  christos                         bw.i = GET_BE_U_4(tptr + 4 + (priority_level * 4));
    441  1.10  christos                         ND_PRINT("\n\t\t  priority level %u: %.3f Mbps",
    442   1.1  christos                                priority_level,
    443  1.10  christos                                bw.f * 8 / 1000000);
    444   1.1  christos                     }
    445   1.1  christos                     break;
    446   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE:
    447   1.7  christos 		    if (subtlv_length != 1) {
    448  1.10  christos 			ND_PRINT(" != 1");
    449   1.7  christos 			goto invalid;
    450   1.7  christos 		    }
    451  1.10  christos                     ND_PRINT(", %s (%u)",
    452  1.10  christos                            tok2str(lsa_opaque_te_tlv_link_type_sub_tlv_values,"unknown",GET_U_1(tptr)),
    453  1.10  christos                            GET_U_1(tptr));
    454   1.1  christos                     break;
    455   1.1  christos 
    456   1.1  christos                 case LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP:
    457   1.7  christos 		    if (subtlv_length % 4 != 0) {
    458  1.10  christos 			ND_PRINT(" != N x 4");
    459   1.7  christos 			goto invalid;
    460   1.7  christos 		    }
    461   1.1  christos                     count_srlg = subtlv_length / 4;
    462   1.1  christos                     if (count_srlg != 0)
    463  1.10  christos                         ND_PRINT("\n\t\t  Shared risk group: ");
    464   1.1  christos                     while (count_srlg > 0) {
    465  1.10  christos                         bw.i = GET_BE_U_4(tptr);
    466  1.10  christos                         ND_PRINT("%u", bw.i);
    467   1.1  christos                         tptr+=4;
    468   1.1  christos                         count_srlg--;
    469   1.1  christos                         if (count_srlg > 0)
    470  1.10  christos                             ND_PRINT(", ");
    471   1.1  christos                     }
    472   1.1  christos                     break;
    473   1.1  christos 
    474   1.1  christos                 default:
    475   1.5  christos                     if (ndo->ndo_vflag <= 1) {
    476   1.5  christos                         if (!print_unknown_data(ndo, tptr, "\n\t\t", subtlv_length))
    477   1.1  christos                             return -1;
    478   1.1  christos                     }
    479   1.1  christos                     break;
    480   1.1  christos                 }
    481   1.1  christos                 /* in OSPF everything has to be 32-bit aligned, including subTLVs */
    482   1.1  christos                 if (subtlv_length%4 != 0)
    483   1.1  christos                     subtlv_length+=4-(subtlv_length%4);
    484   1.5  christos 
    485  1.10  christos                 if (tlv_length < subtlv_length) {
    486  1.10  christos                     ND_PRINT("\n\t    Remaining TLV length %u < %u",
    487  1.10  christos                            tlv_length + 4, subtlv_length + 4);
    488  1.10  christos                     return -1;
    489  1.10  christos                 }
    490   1.1  christos                 tlv_length-=subtlv_length;
    491   1.1  christos                 tptr+=subtlv_length;
    492   1.5  christos 
    493   1.1  christos             }
    494   1.1  christos             break;
    495   1.5  christos 
    496   1.1  christos         case LS_OPAQUE_TE_TLV_ROUTER:
    497   1.1  christos             if (tlv_length < 4) {
    498  1.10  christos                 ND_PRINT("\n\t    TLV length %u < 4", tlv_length);
    499   1.1  christos                 return -1;
    500   1.1  christos             }
    501  1.10  christos             ND_PRINT(", %s", GET_IPADDR_STRING(tptr));
    502   1.1  christos             break;
    503   1.5  christos 
    504   1.1  christos         default:
    505   1.5  christos             if (ndo->ndo_vflag <= 1) {
    506   1.5  christos                 if (!print_unknown_data(ndo, tptr, "\n\t      ", tlv_length))
    507   1.1  christos                     return -1;
    508   1.1  christos             }
    509   1.1  christos             break;
    510   1.1  christos         }
    511   1.1  christos         /* in OSPF everything has to be 32-bit aligned, including TLVs */
    512   1.1  christos         if (tlv_length%4 != 0)
    513   1.1  christos             tlv_length+=4-(tlv_length%4);
    514  1.10  christos         if (tlv_length > ls_length) {
    515  1.10  christos             ND_PRINT("\n\t    Bogus padded length %u > %u", tlv_length,
    516  1.10  christos                    ls_length);
    517  1.10  christos             return -1;
    518  1.10  christos         }
    519   1.1  christos         ls_length-=tlv_length;
    520   1.1  christos         tptr+=tlv_length;
    521   1.1  christos     }
    522   1.1  christos     return 0;
    523   1.1  christos trunc:
    524   1.1  christos     return -1;
    525   1.7  christos invalid:
    526  1.10  christos     nd_print_invalid(ndo);
    527   1.7  christos     return -1;
    528   1.1  christos }
    529   1.1  christos 
    530   1.1  christos static int
    531   1.5  christos ospf_print_lshdr(netdissect_options *ndo,
    532  1.10  christos                  const struct lsa_hdr *lshp)
    533   1.1  christos {
    534  1.10  christos         u_int ls_type;
    535   1.1  christos         u_int ls_length;
    536   1.1  christos 
    537  1.10  christos         ls_length = GET_BE_U_2(lshp->ls_length);
    538   1.1  christos         if (ls_length < sizeof(struct lsa_hdr)) {
    539  1.10  christos                 ND_PRINT("\n\t    Bogus length %u < header (%zu)", ls_length,
    540  1.10  christos                     sizeof(struct lsa_hdr));
    541   1.1  christos                 return(-1);
    542   1.1  christos         }
    543  1.10  christos         ND_PRINT("\n\t  Advertising Router %s, seq 0x%08x, age %us, length %zu",
    544  1.10  christos                   GET_IPADDR_STRING(lshp->ls_router),
    545  1.10  christos                   GET_BE_U_4(lshp->ls_seq),
    546  1.10  christos                   GET_BE_U_2(lshp->ls_age),
    547  1.10  christos                   ls_length - sizeof(struct lsa_hdr));
    548  1.10  christos         ls_type = GET_U_1(lshp->ls_type);
    549  1.10  christos         switch (ls_type) {
    550   1.5  christos         /* the LSA header for opaque LSAs was slightly changed */
    551   1.1  christos         case LS_TYPE_OPAQUE_LL:
    552   1.1  christos         case LS_TYPE_OPAQUE_AL:
    553   1.1  christos         case LS_TYPE_OPAQUE_DW:
    554  1.10  christos             ND_PRINT("\n\t    %s LSA (%u), Opaque-Type %s LSA (%u), Opaque-ID %u",
    555  1.10  christos                    tok2str(lsa_values,"unknown",ls_type),
    556  1.10  christos                    ls_type,
    557   1.1  christos 
    558   1.1  christos 		   tok2str(lsa_opaque_values,
    559   1.1  christos 			   "unknown",
    560  1.10  christos 			   GET_U_1(lshp->un_lsa_id.opaque_field.opaque_type)),
    561  1.10  christos 		   GET_U_1(lshp->un_lsa_id.opaque_field.opaque_type),
    562  1.10  christos 		   GET_BE_U_3(lshp->un_lsa_id.opaque_field.opaque_id)
    563   1.5  christos 
    564  1.10  christos                    );
    565   1.1  christos             break;
    566   1.1  christos 
    567   1.5  christos         /* all other LSA types use regular style LSA headers */
    568   1.5  christos         default:
    569  1.10  christos             ND_PRINT("\n\t    %s LSA (%u), LSA-ID: %s",
    570  1.10  christos                    tok2str(lsa_values,"unknown",ls_type),
    571  1.10  christos                    ls_type,
    572  1.10  christos                    GET_IPADDR_STRING(lshp->un_lsa_id.lsa_id));
    573   1.1  christos             break;
    574   1.1  christos         }
    575  1.10  christos         ND_PRINT("\n\t    Options: [%s]",
    576  1.10  christos 		 bittok2str(ospf_option_values, "none", GET_U_1(lshp->ls_options)));
    577   1.1  christos 
    578   1.1  christos         return (ls_length);
    579   1.1  christos }
    580   1.1  christos 
    581   1.1  christos /* draft-ietf-ospf-mt-09 */
    582   1.4  christos static const struct tok ospf_topology_values[] = {
    583   1.7  christos     { 0, "default" },
    584   1.7  christos     { 1, "multicast" },
    585   1.7  christos     { 2, "management" },
    586   1.1  christos     { 0, NULL }
    587   1.1  christos };
    588   1.1  christos 
    589   1.1  christos /*
    590   1.1  christos  * Print all the per-topology metrics.
    591   1.1  christos  */
    592  1.10  christos static void
    593   1.5  christos ospf_print_tos_metrics(netdissect_options *ndo,
    594   1.5  christos                        const union un_tos *tos)
    595   1.1  christos {
    596  1.10  christos     u_int metric_count;
    597  1.10  christos     u_int toscount;
    598  1.10  christos     u_int tos_type;
    599   1.1  christos 
    600  1.10  christos     toscount = GET_U_1(tos->link.link_tos_count)+1;
    601   1.1  christos     metric_count = 0;
    602   1.1  christos 
    603   1.1  christos     /*
    604   1.1  christos      * All but the first metric contain a valid topology id.
    605   1.1  christos      */
    606  1.10  christos     while (toscount != 0) {
    607  1.10  christos         tos_type = GET_U_1(tos->metrics.tos_type);
    608  1.10  christos         ND_PRINT("\n\t\ttopology %s (%u), metric %u",
    609   1.7  christos                tok2str(ospf_topology_values, "Unknown",
    610  1.10  christos                        metric_count ? tos_type : 0),
    611  1.10  christos                metric_count ? tos_type : 0,
    612  1.10  christos                GET_BE_U_2(tos->metrics.tos_metric));
    613   1.1  christos         metric_count++;
    614   1.1  christos         tos++;
    615   1.1  christos         toscount--;
    616   1.1  christos     }
    617   1.1  christos }
    618   1.1  christos 
    619   1.1  christos /*
    620   1.1  christos  * Print a single link state advertisement.  If truncated or if LSA length
    621   1.1  christos  * field is less than the length of the LSA header, return NULl, else
    622   1.1  christos  * return pointer to data past end of LSA.
    623   1.1  christos  */
    624   1.5  christos static const uint8_t *
    625   1.5  christos ospf_print_lsa(netdissect_options *ndo,
    626  1.10  christos                const struct lsa *lsap)
    627   1.1  christos {
    628  1.10  christos 	const uint8_t *ls_end;
    629  1.10  christos 	const struct rlalink *rlp;
    630  1.10  christos 	const nd_ipv4 *ap;
    631  1.10  christos 	const struct aslametric *almp;
    632  1.10  christos 	const struct mcla *mcp;
    633  1.10  christos 	const uint8_t *lp;
    634  1.10  christos 	u_int tlv_type, tlv_length, rla_count, topology;
    635  1.10  christos 	int ospf_print_lshdr_ret;
    636  1.10  christos 	u_int ls_length;
    637   1.5  christos 	const uint8_t *tptr;
    638   1.1  christos 
    639   1.7  christos 	tptr = (const uint8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */
    640  1.10  christos 	ospf_print_lshdr_ret = ospf_print_lshdr(ndo, &lsap->ls_hdr);
    641  1.10  christos 	if (ospf_print_lshdr_ret < 0)
    642  1.10  christos 		return(NULL);
    643  1.10  christos 	ls_length = (u_int)ospf_print_lshdr_ret;
    644   1.7  christos 	ls_end = (const uint8_t *)lsap + ls_length;
    645  1.10  christos 	/*
    646  1.10  christos 	 * ospf_print_lshdr() returns -1 if the length is too short,
    647  1.10  christos 	 * so we know ls_length is >= sizeof(struct lsa_hdr).
    648  1.10  christos 	 */
    649   1.1  christos 	ls_length -= sizeof(struct lsa_hdr);
    650   1.1  christos 
    651  1.10  christos 	switch (GET_U_1(lsap->ls_hdr.ls_type)) {
    652   1.1  christos 
    653   1.1  christos 	case LS_TYPE_ROUTER:
    654  1.10  christos 		ND_PRINT("\n\t    Router LSA Options: [%s]",
    655  1.10  christos 		          bittok2str(ospf_rla_flag_values, "none", GET_U_1(lsap->lsa_un.un_rla.rla_flags)));
    656  1.10  christos 
    657  1.10  christos 		rla_count = GET_BE_U_2(lsap->lsa_un.un_rla.rla_count);
    658  1.10  christos 		ND_TCHECK_SIZE(lsap->lsa_un.un_rla.rla_link);
    659   1.1  christos 		rlp = lsap->lsa_un.un_rla.rla_link;
    660  1.10  christos 		for (u_int i = rla_count; i != 0; i--) {
    661  1.10  christos 			ND_TCHECK_SIZE(rlp);
    662  1.10  christos 			switch (GET_U_1(rlp->un_tos.link.link_type)) {
    663   1.1  christos 
    664   1.1  christos 			case RLA_TYPE_VIRTUAL:
    665  1.10  christos 				ND_PRINT("\n\t      Virtual Link: Neighbor Router-ID: %s, Interface Address: %s",
    666  1.10  christos 				    GET_IPADDR_STRING(rlp->link_id),
    667  1.10  christos 				    GET_IPADDR_STRING(rlp->link_data));
    668   1.5  christos 				break;
    669   1.1  christos 
    670   1.1  christos 			case RLA_TYPE_ROUTER:
    671  1.10  christos 				ND_PRINT("\n\t      Neighbor Router-ID: %s, Interface Address: %s",
    672  1.10  christos 				    GET_IPADDR_STRING(rlp->link_id),
    673  1.10  christos 				    GET_IPADDR_STRING(rlp->link_data));
    674   1.1  christos 				break;
    675   1.1  christos 
    676   1.1  christos 			case RLA_TYPE_TRANSIT:
    677  1.10  christos 				ND_PRINT("\n\t      Neighbor Network-ID: %s, Interface Address: %s",
    678  1.10  christos 				    GET_IPADDR_STRING(rlp->link_id),
    679  1.10  christos 				    GET_IPADDR_STRING(rlp->link_data));
    680   1.1  christos 				break;
    681   1.1  christos 
    682   1.1  christos 			case RLA_TYPE_STUB:
    683  1.10  christos 				ND_PRINT("\n\t      Stub Network: %s, Mask: %s",
    684  1.10  christos 				    GET_IPADDR_STRING(rlp->link_id),
    685  1.10  christos 				    GET_IPADDR_STRING(rlp->link_data));
    686   1.1  christos 				break;
    687   1.1  christos 
    688   1.1  christos 			default:
    689  1.10  christos 				ND_PRINT("\n\t      Unknown Router Link Type (%u)",
    690  1.10  christos 				    GET_U_1(rlp->un_tos.link.link_type));
    691   1.1  christos 				return (ls_end);
    692   1.1  christos 			}
    693   1.1  christos 
    694  1.10  christos 			ospf_print_tos_metrics(ndo, &rlp->un_tos);
    695   1.1  christos 
    696   1.7  christos 			rlp = (const struct rlalink *)((const u_char *)(rlp + 1) +
    697  1.10  christos 			    (GET_U_1(rlp->un_tos.link.link_tos_count) * sizeof(union un_tos)));
    698   1.1  christos 		}
    699   1.1  christos 		break;
    700   1.1  christos 
    701   1.1  christos 	case LS_TYPE_NETWORK:
    702  1.10  christos 		ND_PRINT("\n\t    Mask %s\n\t    Connected Routers:",
    703  1.10  christos 		    GET_IPADDR_STRING(lsap->lsa_un.un_nla.nla_mask));
    704   1.1  christos 		ap = lsap->lsa_un.un_nla.nla_router;
    705   1.7  christos 		while ((const u_char *)ap < ls_end) {
    706  1.10  christos 			ND_PRINT("\n\t      %s", GET_IPADDR_STRING(ap));
    707   1.1  christos 			++ap;
    708   1.1  christos 		}
    709   1.1  christos 		break;
    710   1.1  christos 
    711   1.1  christos 	case LS_TYPE_SUM_IP:
    712  1.10  christos 		ND_TCHECK_4(lsap->lsa_un.un_nla.nla_mask);
    713  1.10  christos 		ND_PRINT("\n\t    Mask %s",
    714  1.10  christos 		    GET_IPADDR_STRING(lsap->lsa_un.un_sla.sla_mask));
    715  1.10  christos 		ND_TCHECK_SIZE(lsap->lsa_un.un_sla.sla_tosmetric);
    716  1.10  christos 		lp = (const uint8_t *)lsap->lsa_un.un_sla.sla_tosmetric;
    717  1.10  christos 		while (lp < ls_end) {
    718  1.10  christos 			uint32_t ul;
    719   1.1  christos 
    720  1.10  christos 			ul = GET_BE_U_4(lp);
    721   1.1  christos                         topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
    722  1.10  christos 			ND_PRINT("\n\t\ttopology %s (%u) metric %u",
    723   1.7  christos                                tok2str(ospf_topology_values, "Unknown", topology),
    724   1.1  christos                                topology,
    725  1.10  christos                                ul & SLA_MASK_METRIC);
    726  1.10  christos 			lp += 4;
    727   1.1  christos 		}
    728   1.1  christos 		break;
    729   1.1  christos 
    730   1.1  christos 	case LS_TYPE_SUM_ABR:
    731  1.10  christos 		ND_TCHECK_SIZE(lsap->lsa_un.un_sla.sla_tosmetric);
    732  1.10  christos 		lp = (const uint8_t *)lsap->lsa_un.un_sla.sla_tosmetric;
    733  1.10  christos 		while (lp < ls_end) {
    734  1.10  christos 			uint32_t ul;
    735   1.1  christos 
    736  1.10  christos 			ul = GET_BE_U_4(lp);
    737   1.1  christos                         topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
    738  1.10  christos 			ND_PRINT("\n\t\ttopology %s (%u) metric %u",
    739   1.7  christos                                tok2str(ospf_topology_values, "Unknown", topology),
    740   1.1  christos                                topology,
    741  1.10  christos                                ul & SLA_MASK_METRIC);
    742  1.10  christos 			lp += 4;
    743   1.1  christos 		}
    744   1.1  christos 		break;
    745   1.1  christos 
    746   1.1  christos 	case LS_TYPE_ASE:
    747   1.1  christos         case LS_TYPE_NSSA: /* fall through - those LSAs share the same format */
    748  1.10  christos 		ND_TCHECK_4(lsap->lsa_un.un_nla.nla_mask);
    749  1.10  christos 		ND_PRINT("\n\t    Mask %s",
    750  1.10  christos 		    GET_IPADDR_STRING(lsap->lsa_un.un_asla.asla_mask));
    751   1.1  christos 
    752  1.10  christos 		ND_TCHECK_SIZE(lsap->lsa_un.un_sla.sla_tosmetric);
    753   1.1  christos 		almp = lsap->lsa_un.un_asla.asla_metric;
    754   1.7  christos 		while ((const u_char *)almp < ls_end) {
    755  1.10  christos 			uint32_t ul;
    756   1.1  christos 
    757  1.10  christos 			ul = GET_BE_U_4(almp->asla_tosmetric);
    758   1.1  christos                         topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS);
    759  1.10  christos 			ND_PRINT("\n\t\ttopology %s (%u), type %u, metric",
    760   1.7  christos                                tok2str(ospf_topology_values, "Unknown", topology),
    761   1.1  christos                                topology,
    762  1.10  christos                                (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1);
    763   1.5  christos 			if ((ul & ASLA_MASK_METRIC) == 0xffffff)
    764  1.10  christos 				ND_PRINT(" infinite");
    765   1.5  christos 			else
    766  1.10  christos 				ND_PRINT(" %u", (ul & ASLA_MASK_METRIC));
    767   1.1  christos 
    768  1.10  christos 			if (GET_IPV4_TO_NETWORK_ORDER(almp->asla_forward) != 0) {
    769  1.10  christos 				ND_PRINT(", forward %s", GET_IPADDR_STRING(almp->asla_forward));
    770   1.1  christos 			}
    771  1.10  christos 			if (GET_IPV4_TO_NETWORK_ORDER(almp->asla_tag) != 0) {
    772  1.10  christos 				ND_PRINT(", tag %s", GET_IPADDR_STRING(almp->asla_tag));
    773   1.1  christos 			}
    774   1.1  christos 			++almp;
    775   1.1  christos 		}
    776   1.1  christos 		break;
    777   1.1  christos 
    778   1.1  christos 	case LS_TYPE_GROUP:
    779   1.1  christos 		/* Multicast extensions as of 23 July 1991 */
    780   1.1  christos 		mcp = lsap->lsa_un.un_mcla;
    781   1.7  christos 		while ((const u_char *)mcp < ls_end) {
    782  1.10  christos 			switch (GET_BE_U_4(mcp->mcla_vtype)) {
    783   1.1  christos 
    784   1.1  christos 			case MCLA_VERTEX_ROUTER:
    785  1.10  christos 				ND_PRINT("\n\t    Router Router-ID %s",
    786  1.10  christos 				    GET_IPADDR_STRING(mcp->mcla_vid));
    787   1.1  christos 				break;
    788   1.1  christos 
    789   1.1  christos 			case MCLA_VERTEX_NETWORK:
    790  1.10  christos 				ND_PRINT("\n\t    Network Designated Router %s",
    791  1.10  christos 				    GET_IPADDR_STRING(mcp->mcla_vid));
    792   1.1  christos 				break;
    793   1.1  christos 
    794   1.1  christos 			default:
    795  1.10  christos 				ND_PRINT("\n\t    unknown VertexType (%u)",
    796  1.10  christos 				    GET_BE_U_4(mcp->mcla_vtype));
    797   1.1  christos 				break;
    798   1.1  christos 			}
    799   1.1  christos 		++mcp;
    800   1.1  christos 		}
    801   1.1  christos 		break;
    802   1.1  christos 
    803   1.1  christos 	case LS_TYPE_OPAQUE_LL: /* fall through */
    804   1.5  christos 	case LS_TYPE_OPAQUE_AL:
    805   1.1  christos 	case LS_TYPE_OPAQUE_DW:
    806   1.1  christos 
    807  1.10  christos 	    switch (GET_U_1(lsap->ls_hdr.un_lsa_id.opaque_field.opaque_type)) {
    808   1.1  christos             case LS_OPAQUE_TYPE_RI:
    809  1.10  christos 		tptr = (const uint8_t *)(lsap->lsa_un.un_ri_tlv);
    810   1.1  christos 
    811  1.10  christos 		u_int ls_length_remaining = ls_length;
    812  1.10  christos 		while (ls_length_remaining != 0) {
    813  1.10  christos                     ND_TCHECK_4(tptr);
    814  1.10  christos 		    if (ls_length_remaining < 4) {
    815  1.10  christos                         ND_PRINT("\n\t    Remaining LS length %u < 4", ls_length_remaining);
    816   1.1  christos                         return(ls_end);
    817   1.1  christos                     }
    818  1.10  christos                     tlv_type = GET_BE_U_2(tptr);
    819  1.10  christos                     tlv_length = GET_BE_U_2(tptr + 2);
    820   1.1  christos                     tptr+=4;
    821  1.10  christos                     ls_length_remaining-=4;
    822   1.5  christos 
    823  1.10  christos                     ND_PRINT("\n\t    %s TLV (%u), length: %u, value: ",
    824   1.1  christos                            tok2str(lsa_opaque_ri_tlv_values,"unknown",tlv_type),
    825   1.1  christos                            tlv_type,
    826  1.10  christos                            tlv_length);
    827   1.1  christos 
    828  1.10  christos                     if (tlv_length > ls_length_remaining) {
    829  1.10  christos                         ND_PRINT("\n\t    Bogus length %u > remaining LS length %u", tlv_length,
    830  1.10  christos                             ls_length_remaining);
    831   1.1  christos                         return(ls_end);
    832   1.1  christos                     }
    833  1.10  christos                     ND_TCHECK_LEN(tptr, tlv_length);
    834   1.1  christos                     switch(tlv_type) {
    835   1.1  christos 
    836   1.1  christos                     case LS_OPAQUE_RI_TLV_CAP:
    837   1.1  christos                         if (tlv_length != 4) {
    838  1.10  christos                             ND_PRINT("\n\t    Bogus length %u != 4", tlv_length);
    839   1.1  christos                             return(ls_end);
    840   1.1  christos                         }
    841  1.10  christos                         ND_PRINT("Capabilities: %s",
    842  1.10  christos                                bittok2str(lsa_opaque_ri_tlv_cap_values, "Unknown", GET_BE_U_4(tptr)));
    843   1.1  christos                         break;
    844   1.1  christos                     default:
    845   1.5  christos                         if (ndo->ndo_vflag <= 1) {
    846   1.5  christos                             if (!print_unknown_data(ndo, tptr, "\n\t      ", tlv_length))
    847   1.1  christos                                 return(ls_end);
    848   1.1  christos                         }
    849   1.1  christos                         break;
    850   1.1  christos 
    851   1.1  christos                     }
    852   1.1  christos                     tptr+=tlv_length;
    853  1.10  christos                     ls_length_remaining-=tlv_length;
    854   1.1  christos                 }
    855   1.1  christos                 break;
    856   1.1  christos 
    857   1.1  christos             case LS_OPAQUE_TYPE_GRACE:
    858  1.10  christos                 if (ospf_grace_lsa_print(ndo, (const u_char *)(lsap->lsa_un.un_grace_tlv),
    859   1.1  christos                                          ls_length) == -1) {
    860   1.1  christos                     return(ls_end);
    861   1.1  christos                 }
    862   1.1  christos                 break;
    863   1.1  christos 
    864   1.1  christos 	    case LS_OPAQUE_TYPE_TE:
    865  1.10  christos                 if (ospf_te_lsa_print(ndo, (const u_char *)(lsap->lsa_un.un_te_lsa_tlv),
    866   1.1  christos                                       ls_length) == -1) {
    867   1.1  christos                     return(ls_end);
    868   1.1  christos                 }
    869   1.1  christos                 break;
    870   1.1  christos 
    871   1.1  christos             default:
    872   1.5  christos                 if (ndo->ndo_vflag <= 1) {
    873   1.7  christos                     if (!print_unknown_data(ndo, (const uint8_t *)lsap->lsa_un.un_unknown,
    874   1.1  christos                                            "\n\t    ", ls_length))
    875   1.1  christos                         return(ls_end);
    876   1.5  christos                 }
    877   1.1  christos                 break;
    878   1.1  christos             }
    879   1.1  christos         }
    880   1.1  christos 
    881   1.1  christos         /* do we want to see an additionally hexdump ? */
    882   1.5  christos         if (ndo->ndo_vflag> 1)
    883   1.7  christos             if (!print_unknown_data(ndo, (const uint8_t *)lsap->lsa_un.un_unknown,
    884   1.1  christos                                    "\n\t    ", ls_length)) {
    885   1.1  christos                 return(ls_end);
    886   1.1  christos             }
    887   1.5  christos 
    888   1.1  christos 	return (ls_end);
    889   1.1  christos trunc:
    890   1.1  christos 	return (NULL);
    891   1.1  christos }
    892   1.1  christos 
    893  1.10  christos static void
    894   1.5  christos ospf_decode_lls(netdissect_options *ndo,
    895  1.10  christos                 const struct ospfhdr *op, u_int length)
    896   1.1  christos {
    897  1.10  christos     const u_char *dptr;
    898  1.10  christos     const u_char *dataend;
    899  1.10  christos     u_int length2;
    900  1.10  christos     uint16_t lls_type, lls_len;
    901  1.10  christos     uint32_t lls_flags;
    902   1.1  christos 
    903  1.10  christos     switch (GET_U_1(op->ospf_type)) {
    904   1.1  christos 
    905   1.1  christos     case OSPF_TYPE_HELLO:
    906  1.10  christos         if (!(GET_U_1(op->ospf_hello.hello_options) & OSPF_OPTION_L))
    907  1.10  christos             return;
    908   1.1  christos         break;
    909   1.1  christos 
    910   1.1  christos     case OSPF_TYPE_DD:
    911  1.10  christos         if (!(GET_U_1(op->ospf_db.db_options) & OSPF_OPTION_L))
    912  1.10  christos             return;
    913   1.1  christos         break;
    914   1.1  christos 
    915   1.1  christos     default:
    916  1.10  christos         return;
    917   1.1  christos     }
    918   1.1  christos 
    919   1.1  christos     /* dig deeper if LLS data is available; see RFC4813 */
    920  1.10  christos     length2 = GET_BE_U_2(op->ospf_len);
    921   1.7  christos     dptr = (const u_char *)op + length2;
    922   1.7  christos     dataend = (const u_char *)op + length;
    923   1.1  christos 
    924  1.10  christos     if (GET_BE_U_2(op->ospf_authtype) == OSPF_AUTH_MD5) {
    925  1.10  christos         dptr = dptr + GET_U_1(op->ospf_authdata + 3);
    926  1.10  christos         length2 += GET_U_1(op->ospf_authdata + 3);
    927   1.1  christos     }
    928   1.1  christos     if (length2 >= length) {
    929  1.10  christos         ND_PRINT("\n\t[LLS truncated]");
    930  1.10  christos         return;
    931   1.1  christos     }
    932  1.10  christos     ND_PRINT("\n\t  LLS: checksum: 0x%04x", (u_int) GET_BE_U_2(dptr));
    933   1.1  christos 
    934   1.1  christos     dptr += 2;
    935  1.10  christos     length2 = GET_BE_U_2(dptr);
    936  1.10  christos     ND_PRINT(", length: %u", length2);
    937   1.1  christos 
    938   1.1  christos     dptr += 2;
    939   1.1  christos     while (dptr < dataend) {
    940  1.10  christos         lls_type = GET_BE_U_2(dptr);
    941  1.10  christos         ND_PRINT("\n\t    %s (%u)",
    942   1.1  christos                tok2str(ospf_lls_tlv_values,"Unknown TLV",lls_type),
    943  1.10  christos                lls_type);
    944   1.1  christos         dptr += 2;
    945  1.10  christos         lls_len = GET_BE_U_2(dptr);
    946  1.10  christos         ND_PRINT(", length: %u", lls_len);
    947   1.1  christos         dptr += 2;
    948   1.1  christos         switch (lls_type) {
    949   1.1  christos 
    950   1.1  christos         case OSPF_LLS_EO:
    951   1.1  christos             if (lls_len != 4) {
    952  1.10  christos                 ND_PRINT(" [should be 4]");
    953   1.1  christos                 lls_len = 4;
    954   1.1  christos             }
    955  1.10  christos             lls_flags = GET_BE_U_4(dptr);
    956  1.10  christos             ND_PRINT("\n\t      Options: 0x%08x [%s]", lls_flags,
    957  1.10  christos                    bittok2str(ospf_lls_eo_options, "?", lls_flags));
    958   1.1  christos 
    959   1.1  christos             break;
    960   1.1  christos 
    961   1.1  christos         case OSPF_LLS_MD5:
    962   1.1  christos             if (lls_len != 20) {
    963  1.10  christos                 ND_PRINT(" [should be 20]");
    964   1.1  christos                 lls_len = 20;
    965   1.1  christos             }
    966  1.10  christos             ND_PRINT("\n\t      Sequence number: 0x%08x", GET_BE_U_4(dptr));
    967   1.1  christos             break;
    968   1.1  christos         }
    969   1.1  christos 
    970   1.1  christos         dptr += lls_len;
    971   1.1  christos     }
    972   1.1  christos }
    973   1.1  christos 
    974   1.1  christos static int
    975   1.5  christos ospf_decode_v2(netdissect_options *ndo,
    976  1.10  christos                const struct ospfhdr *op, const u_char *dataend)
    977   1.1  christos {
    978  1.10  christos 	const nd_ipv4 *ap;
    979  1.10  christos 	const struct lsr *lsrp;
    980  1.10  christos 	const struct lsa_hdr *lshp;
    981  1.10  christos 	const struct lsa *lsap;
    982  1.10  christos 	uint32_t lsa_count,lsa_count_max;
    983  1.10  christos 
    984  1.10  christos 	switch (GET_U_1(op->ospf_type)) {
    985   1.1  christos 
    986   1.1  christos 	case OSPF_TYPE_HELLO:
    987  1.10  christos 		ND_PRINT("\n\tOptions [%s]",
    988  1.10  christos 		          bittok2str(ospf_option_values,"none",GET_U_1(op->ospf_hello.hello_options)));
    989  1.10  christos 
    990  1.10  christos 		ND_PRINT("\n\t  Hello Timer %us, Dead Timer %us, Mask %s, Priority %u",
    991  1.10  christos 		          GET_BE_U_2(op->ospf_hello.hello_helloint),
    992  1.10  christos 		          GET_BE_U_4(op->ospf_hello.hello_deadint),
    993  1.10  christos 		          GET_IPADDR_STRING(op->ospf_hello.hello_mask),
    994  1.10  christos 		          GET_U_1(op->ospf_hello.hello_priority));
    995  1.10  christos 
    996  1.10  christos 		if (GET_IPV4_TO_NETWORK_ORDER(op->ospf_hello.hello_dr) != 0)
    997  1.10  christos 			ND_PRINT("\n\t  Designated Router %s",
    998  1.10  christos 			    GET_IPADDR_STRING(op->ospf_hello.hello_dr));
    999  1.10  christos 
   1000  1.10  christos 		if (GET_IPV4_TO_NETWORK_ORDER(op->ospf_hello.hello_bdr) != 0)
   1001  1.10  christos 			ND_PRINT(", Backup Designated Router %s",
   1002  1.10  christos 			          GET_IPADDR_STRING(op->ospf_hello.hello_bdr));
   1003   1.1  christos 
   1004   1.5  christos 		ap = op->ospf_hello.hello_neighbor;
   1005   1.7  christos 		if ((const u_char *)ap < dataend)
   1006  1.10  christos 			ND_PRINT("\n\t  Neighbor List:");
   1007   1.7  christos 		while ((const u_char *)ap < dataend) {
   1008  1.10  christos 			ND_PRINT("\n\t    %s", GET_IPADDR_STRING(ap));
   1009   1.5  christos 			++ap;
   1010   1.5  christos 		}
   1011   1.1  christos 		break;	/* HELLO */
   1012   1.1  christos 
   1013   1.1  christos 	case OSPF_TYPE_DD:
   1014  1.10  christos 		ND_PRINT("\n\tOptions [%s]",
   1015  1.10  christos 		          bittok2str(ospf_option_values, "none", GET_U_1(op->ospf_db.db_options)));
   1016  1.10  christos 		ND_PRINT(", DD Flags [%s]",
   1017  1.10  christos 		          bittok2str(ospf_dd_flag_values, "none", GET_U_1(op->ospf_db.db_flags)));
   1018  1.10  christos 		if (GET_BE_U_2(op->ospf_db.db_ifmtu)) {
   1019  1.10  christos 			ND_PRINT(", MTU: %u",
   1020  1.10  christos 				 GET_BE_U_2(op->ospf_db.db_ifmtu));
   1021   1.5  christos 		}
   1022  1.10  christos 		ND_PRINT(", Sequence: 0x%08x", GET_BE_U_4(op->ospf_db.db_seq));
   1023   1.1  christos 
   1024   1.5  christos 		/* Print all the LS adv's */
   1025   1.5  christos 		lshp = op->ospf_db.db_lshdr;
   1026   1.7  christos 		while (((const u_char *)lshp < dataend) && ospf_print_lshdr(ndo, lshp) != -1) {
   1027   1.5  christos 			++lshp;
   1028   1.5  christos 		}
   1029   1.1  christos 		break;
   1030   1.1  christos 
   1031   1.1  christos 	case OSPF_TYPE_LS_REQ:
   1032   1.1  christos                 lsrp = op->ospf_lsr;
   1033   1.7  christos                 while ((const u_char *)lsrp < dataend) {
   1034  1.10  christos                     ND_TCHECK_SIZE(lsrp);
   1035   1.1  christos 
   1036  1.10  christos                     ND_PRINT("\n\t  Advertising Router: %s, %s LSA (%u)",
   1037  1.10  christos                            GET_IPADDR_STRING(lsrp->ls_router),
   1038  1.10  christos                            tok2str(lsa_values,"unknown",GET_BE_U_4(lsrp->ls_type)),
   1039  1.10  christos                            GET_BE_U_4(lsrp->ls_type));
   1040   1.1  christos 
   1041  1.10  christos                     switch (GET_BE_U_4(lsrp->ls_type)) {
   1042   1.1  christos                         /* the LSA header for opaque LSAs was slightly changed */
   1043   1.1  christos                     case LS_TYPE_OPAQUE_LL:
   1044   1.1  christos                     case LS_TYPE_OPAQUE_AL:
   1045   1.1  christos                     case LS_TYPE_OPAQUE_DW:
   1046  1.10  christos                         ND_PRINT(", Opaque-Type: %s LSA (%u), Opaque-ID: %u",
   1047  1.10  christos                                tok2str(lsa_opaque_values, "unknown",GET_U_1(lsrp->un_ls_stateid.opaque_field.opaque_type)),
   1048  1.10  christos                                GET_U_1(lsrp->un_ls_stateid.opaque_field.opaque_type),
   1049  1.10  christos                                GET_BE_U_3(lsrp->un_ls_stateid.opaque_field.opaque_id));
   1050   1.1  christos                         break;
   1051   1.1  christos                     default:
   1052  1.10  christos                         ND_PRINT(", LSA-ID: %s",
   1053  1.10  christos                                GET_IPADDR_STRING(lsrp->un_ls_stateid.ls_stateid));
   1054   1.1  christos                         break;
   1055   1.1  christos                     }
   1056   1.5  christos 
   1057   1.1  christos                     ++lsrp;
   1058   1.1  christos                 }
   1059   1.1  christos 		break;
   1060   1.1  christos 
   1061   1.1  christos 	case OSPF_TYPE_LS_UPDATE:
   1062   1.1  christos                 lsap = op->ospf_lsu.lsu_lsa;
   1063  1.10  christos                 lsa_count_max = GET_BE_U_4(op->ospf_lsu.lsu_count);
   1064  1.10  christos                 ND_PRINT(", %u LSA%s", lsa_count_max, PLURAL_SUFFIX(lsa_count_max));
   1065   1.1  christos                 for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) {
   1066  1.10  christos                     ND_PRINT("\n\t  LSA #%u", lsa_count);
   1067   1.5  christos                         lsap = (const struct lsa *)ospf_print_lsa(ndo, lsap);
   1068   1.1  christos                         if (lsap == NULL)
   1069   1.1  christos                                 goto trunc;
   1070   1.1  christos                 }
   1071   1.1  christos 		break;
   1072   1.1  christos 
   1073   1.1  christos 	case OSPF_TYPE_LS_ACK:
   1074   1.1  christos                 lshp = op->ospf_lsa.lsa_lshdr;
   1075   1.5  christos                 while (ospf_print_lshdr(ndo, lshp) != -1) {
   1076   1.1  christos                     ++lshp;
   1077   1.1  christos                 }
   1078   1.1  christos                 break;
   1079   1.1  christos 
   1080   1.1  christos 	default:
   1081   1.1  christos 		break;
   1082   1.1  christos 	}
   1083   1.1  christos 	return (0);
   1084   1.1  christos trunc:
   1085   1.1  christos 	return (1);
   1086   1.1  christos }
   1087   1.1  christos 
   1088   1.1  christos void
   1089   1.5  christos ospf_print(netdissect_options *ndo,
   1090  1.10  christos            const u_char *bp, u_int length,
   1091   1.5  christos            const u_char *bp2 _U_)
   1092   1.1  christos {
   1093  1.10  christos 	const struct ospfhdr *op;
   1094  1.10  christos 	const u_char *dataend;
   1095  1.10  christos 	const char *cp;
   1096   1.1  christos 
   1097  1.10  christos 	ndo->ndo_protocol = "ospf2";
   1098   1.7  christos 	op = (const struct ospfhdr *)bp;
   1099   1.1  christos 
   1100   1.5  christos 	/* XXX Before we do anything else, strip off the MD5 trailer */
   1101  1.10  christos 	if (GET_BE_U_2(op->ospf_authtype) == OSPF_AUTH_MD5) {
   1102   1.5  christos 		length -= OSPF_AUTH_MD5_LEN;
   1103   1.5  christos 		ndo->ndo_snapend -= OSPF_AUTH_MD5_LEN;
   1104   1.5  christos 	}
   1105   1.1  christos 
   1106   1.1  christos 	/* If the type is valid translate it, or just print the type */
   1107   1.1  christos 	/* value.  If it's not valid, say so and return */
   1108  1.10  christos 	cp = tok2str(type2str, "unknown LS-type %u", GET_U_1(op->ospf_type));
   1109  1.10  christos 	ND_PRINT("OSPFv%u, %s, length %u", GET_U_1(op->ospf_version), cp,
   1110  1.10  christos 		 length);
   1111   1.1  christos 	if (*cp == 'u')
   1112   1.1  christos 		return;
   1113   1.1  christos 
   1114   1.5  christos 	if (!ndo->ndo_vflag) { /* non verbose - so lets bail out here */
   1115   1.5  christos 		return;
   1116   1.5  christos 	}
   1117   1.1  christos 
   1118  1.10  christos 	if (length != GET_BE_U_2(op->ospf_len)) {
   1119  1.10  christos 		ND_PRINT(" [len %u]", GET_BE_U_2(op->ospf_len));
   1120   1.1  christos 	}
   1121   1.1  christos 
   1122  1.10  christos 	if (length > GET_BE_U_2(op->ospf_len)) {
   1123  1.10  christos 		dataend = bp + GET_BE_U_2(op->ospf_len);
   1124   1.1  christos 	} else {
   1125   1.1  christos 		dataend = bp + length;
   1126   1.1  christos 	}
   1127   1.1  christos 
   1128  1.10  christos 	ND_PRINT("\n\tRouter-ID %s", GET_IPADDR_STRING(op->ospf_routerid));
   1129   1.1  christos 
   1130  1.10  christos 	if (GET_IPV4_TO_NETWORK_ORDER(op->ospf_areaid) != 0)
   1131  1.10  christos 		ND_PRINT(", Area %s", GET_IPADDR_STRING(op->ospf_areaid));
   1132   1.1  christos 	else
   1133  1.10  christos 		ND_PRINT(", Backbone Area");
   1134   1.1  christos 
   1135   1.5  christos 	if (ndo->ndo_vflag) {
   1136   1.1  christos 		/* Print authentication data (should we really do this?) */
   1137  1.10  christos 		ND_TCHECK_LEN(op->ospf_authdata, sizeof(op->ospf_authdata));
   1138   1.1  christos 
   1139  1.10  christos 		ND_PRINT(", Authentication Type: %s (%u)",
   1140  1.10  christos 		          tok2str(ospf_authtype_values, "unknown", GET_BE_U_2(op->ospf_authtype)),
   1141  1.10  christos 		          GET_BE_U_2(op->ospf_authtype));
   1142   1.1  christos 
   1143  1.10  christos 		switch (GET_BE_U_2(op->ospf_authtype)) {
   1144   1.1  christos 
   1145   1.1  christos 		case OSPF_AUTH_NONE:
   1146   1.1  christos 			break;
   1147   1.1  christos 
   1148   1.1  christos 		case OSPF_AUTH_SIMPLE:
   1149  1.10  christos 			ND_PRINT("\n\tSimple text password: ");
   1150  1.10  christos 			nd_printjnp(ndo, op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN);
   1151   1.1  christos 			break;
   1152   1.1  christos 
   1153   1.1  christos 		case OSPF_AUTH_MD5:
   1154  1.10  christos 			ND_PRINT("\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x",
   1155  1.10  christos 			          GET_U_1(op->ospf_authdata + 2),
   1156  1.10  christos 			          GET_U_1(op->ospf_authdata + 3),
   1157  1.10  christos 			          GET_BE_U_4((op->ospf_authdata) + 4));
   1158   1.1  christos 			break;
   1159   1.1  christos 
   1160   1.1  christos 		default:
   1161   1.1  christos 			return;
   1162   1.1  christos 		}
   1163   1.1  christos 	}
   1164   1.1  christos 	/* Do rest according to version.	 */
   1165  1.10  christos 	switch (GET_U_1(op->ospf_version)) {
   1166   1.1  christos 
   1167   1.1  christos 	case 2:
   1168   1.1  christos 		/* ospf version 2 */
   1169   1.5  christos 		if (ospf_decode_v2(ndo, op, dataend))
   1170   1.1  christos 			goto trunc;
   1171  1.10  christos 		if (length > GET_BE_U_2(op->ospf_len))
   1172  1.10  christos 			ospf_decode_lls(ndo, op, length);
   1173   1.1  christos 		break;
   1174   1.1  christos 
   1175   1.1  christos 	default:
   1176  1.10  christos 		ND_PRINT(" ospf [version %u]", GET_U_1(op->ospf_version));
   1177   1.1  christos 		break;
   1178   1.1  christos 	}			/* end switch on version */
   1179   1.1  christos 
   1180   1.1  christos 	return;
   1181   1.1  christos trunc:
   1182  1.10  christos 	nd_trunc_longjmp(ndo);
   1183   1.1  christos }
   1184