Home | History | Annotate | Line # | Download | only in dist
print-rsvp.c revision 1.13
      1   1.1  christos /*
      2   1.1  christos  * Copyright (c) 1998-2007 The TCPDUMP project
      3   1.1  christos  *
      4   1.1  christos  * Redistribution and use in source and binary forms, with or without
      5   1.1  christos  * modification, are permitted provided that: (1) source code
      6   1.1  christos  * distributions retain the above copyright notice and this paragraph
      7   1.1  christos  * in its entirety, and (2) distributions including binary code include
      8   1.1  christos  * the above copyright notice and this paragraph in its entirety in
      9   1.1  christos  * the documentation or other materials provided with the distribution.
     10   1.1  christos  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
     11   1.1  christos  * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
     12   1.1  christos  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     13   1.1  christos  * FOR A PARTICULAR PURPOSE.
     14   1.1  christos  *
     15  1.10  christos  * Original code by Hannes Gredler (hannes (at) gredler.at)
     16   1.1  christos  */
     17   1.1  christos 
     18   1.2  christos #include <sys/cdefs.h>
     19   1.1  christos #ifndef lint
     20  1.13  christos __RCSID("$NetBSD: print-rsvp.c,v 1.13 2024/09/02 16:15:32 christos Exp $");
     21   1.1  christos #endif
     22   1.1  christos 
     23   1.9       spz /* \summary: Resource ReSerVation Protocol (RSVP) printer */
     24   1.9       spz 
     25  1.12  christos /* specification: RFC 2205 */
     26  1.12  christos 
     27  1.12  christos #include <config.h>
     28   1.1  christos 
     29  1.12  christos #include "netdissect-stdinc.h"
     30   1.1  christos 
     31   1.8  christos #include "netdissect.h"
     32   1.1  christos #include "extract.h"
     33   1.1  christos #include "addrtoname.h"
     34   1.1  christos #include "ethertype.h"
     35   1.1  christos #include "gmpls.h"
     36   1.1  christos #include "af.h"
     37   1.1  christos #include "signature.h"
     38   1.1  christos 
     39   1.8  christos 
     40   1.1  christos /*
     41   1.1  christos  * RFC 2205 common header
     42   1.1  christos  *
     43   1.1  christos  *               0             1              2             3
     44   1.1  christos  *        +-------------+-------------+-------------+-------------+
     45   1.1  christos  *        | Vers | Flags|  Msg Type   |       RSVP Checksum       |
     46   1.1  christos  *        +-------------+-------------+-------------+-------------+
     47   1.1  christos  *        |  Send_TTL   | (Reserved)  |        RSVP Length        |
     48   1.1  christos  *        +-------------+-------------+-------------+-------------+
     49   1.1  christos  *
     50   1.1  christos  */
     51   1.1  christos 
     52   1.1  christos struct rsvp_common_header {
     53  1.12  christos     nd_uint8_t  version_flags;
     54  1.12  christos     nd_uint8_t  msg_type;
     55  1.12  christos     nd_uint16_t checksum;
     56  1.12  christos     nd_uint8_t  ttl;
     57  1.12  christos     nd_byte     reserved[1];
     58  1.12  christos     nd_uint16_t length;
     59   1.1  christos };
     60   1.1  christos 
     61   1.6  christos /*
     62   1.1  christos  * RFC2205 object header
     63   1.1  christos  *
     64   1.6  christos  *
     65   1.1  christos  *               0             1              2             3
     66   1.1  christos  *        +-------------+-------------+-------------+-------------+
     67   1.1  christos  *        |       Length (bytes)      |  Class-Num  |   C-Type    |
     68   1.1  christos  *        +-------------+-------------+-------------+-------------+
     69   1.1  christos  *        |                                                       |
     70   1.1  christos  *        //                  (Object contents)                   //
     71   1.1  christos  *        |                                                       |
     72   1.1  christos  *        +-------------+-------------+-------------+-------------+
     73   1.1  christos  */
     74   1.1  christos 
     75   1.1  christos struct rsvp_object_header {
     76  1.12  christos     nd_uint16_t length;
     77  1.12  christos     nd_uint8_t  class_num;
     78  1.12  christos     nd_uint8_t  ctype;
     79   1.1  christos };
     80   1.1  christos 
     81   1.1  christos #define RSVP_VERSION            1
     82   1.6  christos #define	RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
     83   1.1  christos #define	RSVP_EXTRACT_FLAGS(x)   ((x)&0x0f)
     84   1.1  christos 
     85   1.1  christos #define	RSVP_MSGTYPE_PATH       1
     86   1.1  christos #define	RSVP_MSGTYPE_RESV       2
     87   1.1  christos #define	RSVP_MSGTYPE_PATHERR    3
     88   1.1  christos #define	RSVP_MSGTYPE_RESVERR    4
     89   1.1  christos #define	RSVP_MSGTYPE_PATHTEAR   5
     90   1.1  christos #define	RSVP_MSGTYPE_RESVTEAR   6
     91   1.1  christos #define	RSVP_MSGTYPE_RESVCONF   7
     92   1.8  christos #define RSVP_MSGTYPE_BUNDLE     12
     93   1.1  christos #define RSVP_MSGTYPE_ACK        13
     94   1.1  christos #define RSVP_MSGTYPE_HELLO_OLD  14      /* ancient Hellos */
     95   1.1  christos #define RSVP_MSGTYPE_SREFRESH   15
     96   1.1  christos #define	RSVP_MSGTYPE_HELLO      20
     97   1.1  christos 
     98   1.1  christos static const struct tok rsvp_msg_type_values[] = {
     99   1.1  christos     { RSVP_MSGTYPE_PATH,	"Path" },
    100   1.1  christos     { RSVP_MSGTYPE_RESV,	"Resv" },
    101   1.1  christos     { RSVP_MSGTYPE_PATHERR,	"PathErr" },
    102   1.1  christos     { RSVP_MSGTYPE_RESVERR,	"ResvErr" },
    103   1.1  christos     { RSVP_MSGTYPE_PATHTEAR,	"PathTear" },
    104   1.1  christos     { RSVP_MSGTYPE_RESVTEAR,	"ResvTear" },
    105   1.1  christos     { RSVP_MSGTYPE_RESVCONF,	"ResvConf" },
    106   1.8  christos     { RSVP_MSGTYPE_BUNDLE,	"Bundle" },
    107   1.1  christos     { RSVP_MSGTYPE_ACK,	        "Acknowledgement" },
    108   1.1  christos     { RSVP_MSGTYPE_HELLO_OLD,	"Hello (Old)" },
    109   1.1  christos     { RSVP_MSGTYPE_SREFRESH,	"Refresh" },
    110   1.1  christos     { RSVP_MSGTYPE_HELLO,	"Hello" },
    111   1.1  christos     { 0, NULL}
    112   1.1  christos };
    113   1.1  christos 
    114   1.1  christos static const struct tok rsvp_header_flag_values[] = {
    115   1.1  christos     { 0x01,	              "Refresh reduction capable" }, /* rfc2961 */
    116   1.1  christos     { 0, NULL}
    117   1.1  christos };
    118   1.1  christos 
    119  1.12  christos static const struct tok rsvp_obj_capability_flag_values[] = {
    120  1.12  christos     { 0x0004,                "RecoveryPath Transmit Enabled" },
    121  1.12  christos     { 0x0002,                "RecoveryPath Desired" },
    122  1.12  christos     { 0x0001,                "RecoveryPath Srefresh Capable" },
    123  1.12  christos     { 0, NULL}
    124  1.12  christos };
    125  1.12  christos 
    126   1.1  christos #define	RSVP_OBJ_SESSION            1   /* rfc2205 */
    127   1.1  christos #define	RSVP_OBJ_RSVP_HOP           3   /* rfc2205, rfc3473 */
    128   1.1  christos #define	RSVP_OBJ_INTEGRITY          4   /* rfc2747 */
    129   1.1  christos #define	RSVP_OBJ_TIME_VALUES        5   /* rfc2205 */
    130   1.6  christos #define	RSVP_OBJ_ERROR_SPEC         6
    131   1.1  christos #define	RSVP_OBJ_SCOPE              7
    132   1.1  christos #define	RSVP_OBJ_STYLE              8   /* rfc2205 */
    133   1.1  christos #define	RSVP_OBJ_FLOWSPEC           9   /* rfc2215 */
    134   1.1  christos #define	RSVP_OBJ_FILTERSPEC         10  /* rfc2215 */
    135   1.1  christos #define	RSVP_OBJ_SENDER_TEMPLATE    11
    136   1.1  christos #define	RSVP_OBJ_SENDER_TSPEC       12  /* rfc2215 */
    137   1.1  christos #define	RSVP_OBJ_ADSPEC             13  /* rfc2215 */
    138   1.1  christos #define	RSVP_OBJ_POLICY_DATA        14
    139   1.1  christos #define	RSVP_OBJ_CONFIRM            15  /* rfc2205 */
    140   1.1  christos #define	RSVP_OBJ_LABEL              16  /* rfc3209 */
    141   1.1  christos #define	RSVP_OBJ_LABEL_REQ          19  /* rfc3209 */
    142   1.1  christos #define	RSVP_OBJ_ERO                20  /* rfc3209 */
    143   1.1  christos #define	RSVP_OBJ_RRO                21  /* rfc3209 */
    144   1.1  christos #define	RSVP_OBJ_HELLO              22  /* rfc3209 */
    145   1.1  christos #define	RSVP_OBJ_MESSAGE_ID         23  /* rfc2961 */
    146   1.1  christos #define	RSVP_OBJ_MESSAGE_ID_ACK     24  /* rfc2961 */
    147   1.1  christos #define	RSVP_OBJ_MESSAGE_ID_LIST    25  /* rfc2961 */
    148   1.1  christos #define	RSVP_OBJ_RECOVERY_LABEL     34  /* rfc3473 */
    149   1.1  christos #define	RSVP_OBJ_UPSTREAM_LABEL     35  /* rfc3473 */
    150   1.1  christos #define	RSVP_OBJ_LABEL_SET          36  /* rfc3473 */
    151   1.1  christos #define	RSVP_OBJ_PROTECTION         37  /* rfc3473 */
    152   1.1  christos #define RSVP_OBJ_S2L                50  /* rfc4875 */
    153  1.12  christos #define	RSVP_OBJ_DETOUR             63  /* rfc4090 */
    154   1.1  christos #define	RSVP_OBJ_CLASSTYPE          66  /* rfc4124 */
    155   1.1  christos #define RSVP_OBJ_CLASSTYPE_OLD      125 /* draft-ietf-tewg-diff-te-proto-07 */
    156   1.1  christos #define	RSVP_OBJ_SUGGESTED_LABEL    129 /* rfc3473 */
    157   1.1  christos #define	RSVP_OBJ_ACCEPT_LABEL_SET   130 /* rfc3473 */
    158   1.1  christos #define	RSVP_OBJ_RESTART_CAPABILITY 131 /* rfc3473 */
    159  1.12  christos #define RSVP_OBJ_CAPABILITY         134 /* rfc5063 */
    160   1.1  christos #define	RSVP_OBJ_NOTIFY_REQ         195 /* rfc3473 */
    161   1.1  christos #define	RSVP_OBJ_ADMIN_STATUS       196 /* rfc3473 */
    162   1.1  christos #define	RSVP_OBJ_PROPERTIES         204 /* juniper proprietary */
    163  1.12  christos #define	RSVP_OBJ_FASTREROUTE        205 /* rfc4090 */
    164   1.1  christos #define	RSVP_OBJ_SESSION_ATTRIBUTE  207 /* rfc3209 */
    165   1.1  christos #define RSVP_OBJ_GENERALIZED_UNI    229 /* OIF RSVP extensions UNI 1.0 Signaling, Rel. 2 */
    166   1.1  christos #define RSVP_OBJ_CALL_ID            230 /* rfc3474 */
    167   1.1  christos #define RSVP_OBJ_CALL_OPS           236 /* rfc3474 */
    168   1.1  christos 
    169   1.1  christos static const struct tok rsvp_obj_values[] = {
    170   1.1  christos     { RSVP_OBJ_SESSION,            "Session" },
    171   1.1  christos     { RSVP_OBJ_RSVP_HOP,           "RSVP Hop" },
    172   1.1  christos     { RSVP_OBJ_INTEGRITY,          "Integrity" },
    173   1.1  christos     { RSVP_OBJ_TIME_VALUES,        "Time Values" },
    174   1.1  christos     { RSVP_OBJ_ERROR_SPEC,         "Error Spec" },
    175   1.1  christos     { RSVP_OBJ_SCOPE,              "Scope" },
    176   1.1  christos     { RSVP_OBJ_STYLE,              "Style" },
    177   1.1  christos     { RSVP_OBJ_FLOWSPEC,           "Flowspec" },
    178   1.1  christos     { RSVP_OBJ_FILTERSPEC,         "FilterSpec" },
    179   1.1  christos     { RSVP_OBJ_SENDER_TEMPLATE,    "Sender Template" },
    180   1.1  christos     { RSVP_OBJ_SENDER_TSPEC,       "Sender TSpec" },
    181   1.1  christos     { RSVP_OBJ_ADSPEC,             "Adspec" },
    182   1.1  christos     { RSVP_OBJ_POLICY_DATA,        "Policy Data" },
    183   1.1  christos     { RSVP_OBJ_CONFIRM,            "Confirm" },
    184   1.1  christos     { RSVP_OBJ_LABEL,              "Label" },
    185   1.1  christos     { RSVP_OBJ_LABEL_REQ,          "Label Request" },
    186   1.1  christos     { RSVP_OBJ_ERO,                "ERO" },
    187   1.1  christos     { RSVP_OBJ_RRO,                "RRO" },
    188   1.1  christos     { RSVP_OBJ_HELLO,              "Hello" },
    189   1.1  christos     { RSVP_OBJ_MESSAGE_ID,         "Message ID" },
    190   1.1  christos     { RSVP_OBJ_MESSAGE_ID_ACK,     "Message ID Ack" },
    191   1.1  christos     { RSVP_OBJ_MESSAGE_ID_LIST,    "Message ID List" },
    192   1.1  christos     { RSVP_OBJ_RECOVERY_LABEL,     "Recovery Label" },
    193   1.1  christos     { RSVP_OBJ_UPSTREAM_LABEL,     "Upstream Label" },
    194   1.1  christos     { RSVP_OBJ_LABEL_SET,          "Label Set" },
    195   1.1  christos     { RSVP_OBJ_ACCEPT_LABEL_SET,   "Acceptable Label Set" },
    196   1.1  christos     { RSVP_OBJ_DETOUR,             "Detour" },
    197   1.1  christos     { RSVP_OBJ_CLASSTYPE,          "Class Type" },
    198   1.1  christos     { RSVP_OBJ_CLASSTYPE_OLD,      "Class Type (old)" },
    199   1.1  christos     { RSVP_OBJ_SUGGESTED_LABEL,    "Suggested Label" },
    200   1.1  christos     { RSVP_OBJ_PROPERTIES,         "Properties" },
    201   1.1  christos     { RSVP_OBJ_FASTREROUTE,        "Fast Re-Route" },
    202   1.1  christos     { RSVP_OBJ_SESSION_ATTRIBUTE,  "Session Attribute" },
    203   1.1  christos     { RSVP_OBJ_GENERALIZED_UNI,    "Generalized UNI" },
    204   1.1  christos     { RSVP_OBJ_CALL_ID,            "Call-ID" },
    205   1.1  christos     { RSVP_OBJ_CALL_OPS,           "Call Capability" },
    206   1.1  christos     { RSVP_OBJ_RESTART_CAPABILITY, "Restart Capability" },
    207  1.12  christos     { RSVP_OBJ_CAPABILITY,         "Capability" },
    208   1.1  christos     { RSVP_OBJ_NOTIFY_REQ,         "Notify Request" },
    209   1.1  christos     { RSVP_OBJ_PROTECTION,         "Protection" },
    210   1.1  christos     { RSVP_OBJ_ADMIN_STATUS,       "Administrative Status" },
    211   1.1  christos     { RSVP_OBJ_S2L,                "Sub-LSP to LSP" },
    212   1.1  christos     { 0, NULL}
    213   1.1  christos };
    214   1.1  christos 
    215   1.1  christos #define	RSVP_CTYPE_IPV4        1
    216   1.1  christos #define	RSVP_CTYPE_IPV6        2
    217   1.1  christos #define	RSVP_CTYPE_TUNNEL_IPV4 7
    218   1.1  christos #define	RSVP_CTYPE_TUNNEL_IPV6 8
    219   1.1  christos #define	RSVP_CTYPE_UNI_IPV4    11 /* OIF RSVP extensions UNI 1.0 Signaling Rel. 2 */
    220   1.1  christos #define RSVP_CTYPE_1           1
    221   1.1  christos #define RSVP_CTYPE_2           2
    222   1.1  christos #define RSVP_CTYPE_3           3
    223   1.1  christos #define RSVP_CTYPE_4           4
    224   1.1  christos #define RSVP_CTYPE_12         12
    225   1.1  christos #define RSVP_CTYPE_13         13
    226   1.1  christos #define RSVP_CTYPE_14         14
    227   1.1  christos 
    228   1.1  christos /*
    229   1.1  christos  * the ctypes are not globally unique so for
    230   1.1  christos  * translating it to strings we build a table based
    231   1.1  christos  * on objects offsetted by the ctype
    232   1.1  christos  */
    233   1.1  christos 
    234   1.1  christos static const struct tok rsvp_ctype_values[] = {
    235   1.1  christos     { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_IPV4,	             "IPv4" },
    236   1.1  christos     { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_IPV6,	             "IPv6" },
    237   1.1  christos     { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_3,	             "IPv4 plus opt. TLVs" },
    238   1.1  christos     { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_4,	             "IPv6 plus opt. TLVs" },
    239   1.1  christos     { 256*RSVP_OBJ_NOTIFY_REQ+RSVP_CTYPE_IPV4,	             "IPv4" },
    240   1.1  christos     { 256*RSVP_OBJ_NOTIFY_REQ+RSVP_CTYPE_IPV6,	             "IPv6" },
    241   1.1  christos     { 256*RSVP_OBJ_CONFIRM+RSVP_CTYPE_IPV4,	             "IPv4" },
    242   1.1  christos     { 256*RSVP_OBJ_CONFIRM+RSVP_CTYPE_IPV6,	             "IPv6" },
    243   1.1  christos     { 256*RSVP_OBJ_TIME_VALUES+RSVP_CTYPE_1,	             "1" },
    244   1.1  christos     { 256*RSVP_OBJ_FLOWSPEC+RSVP_CTYPE_1,	             "obsolete" },
    245   1.1  christos     { 256*RSVP_OBJ_FLOWSPEC+RSVP_CTYPE_2,	             "IntServ" },
    246   1.1  christos     { 256*RSVP_OBJ_SENDER_TSPEC+RSVP_CTYPE_2,	             "IntServ" },
    247   1.1  christos     { 256*RSVP_OBJ_ADSPEC+RSVP_CTYPE_2,	                     "IntServ" },
    248   1.1  christos     { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_IPV4,	             "IPv4" },
    249   1.1  christos     { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_IPV6,	             "IPv6" },
    250   1.1  christos     { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_3,	             "IPv6 Flow-label" },
    251   1.1  christos     { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_TUNNEL_IPV4,	     "Tunnel IPv4" },
    252   1.1  christos     { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_12,                 "IPv4 P2MP LSP Tunnel" },
    253   1.1  christos     { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_13,                 "IPv6 P2MP LSP Tunnel" },
    254   1.1  christos     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV4,	             "IPv4" },
    255   1.1  christos     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV6,	             "IPv6" },
    256   1.1  christos     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_TUNNEL_IPV4,           "Tunnel IPv4" },
    257   1.1  christos     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_UNI_IPV4,              "UNI IPv4" },
    258   1.1  christos     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_13,                    "IPv4 P2MP LSP Tunnel" },
    259   1.1  christos     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_14,                    "IPv6 P2MP LSP Tunnel" },
    260   1.1  christos     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV4,          "IPv4" },
    261   1.1  christos     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV6,          "IPv6" },
    262   1.1  christos     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_TUNNEL_IPV4,   "Tunnel IPv4" },
    263   1.1  christos     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_12,            "IPv4 P2MP LSP Tunnel" },
    264   1.1  christos     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_13,            "IPv6 P2MP LSP Tunnel" },
    265   1.1  christos     { 256*RSVP_OBJ_MESSAGE_ID+RSVP_CTYPE_1,                  "1" },
    266   1.1  christos     { 256*RSVP_OBJ_MESSAGE_ID_ACK+RSVP_CTYPE_1,              "Message id ack" },
    267   1.1  christos     { 256*RSVP_OBJ_MESSAGE_ID_ACK+RSVP_CTYPE_2,              "Message id nack" },
    268   1.1  christos     { 256*RSVP_OBJ_MESSAGE_ID_LIST+RSVP_CTYPE_1,             "1" },
    269   1.1  christos     { 256*RSVP_OBJ_STYLE+RSVP_CTYPE_1,                       "1" },
    270   1.1  christos     { 256*RSVP_OBJ_HELLO+RSVP_CTYPE_1,                       "Hello Request" },
    271   1.1  christos     { 256*RSVP_OBJ_HELLO+RSVP_CTYPE_2,                       "Hello Ack" },
    272   1.1  christos     { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_1,	             "without label range" },
    273   1.1  christos     { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_2,	             "with ATM label range" },
    274   1.1  christos     { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_3,                   "with FR label range" },
    275   1.1  christos     { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_4,                   "Generalized Label" },
    276   1.1  christos     { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_1,                       "Label" },
    277   1.1  christos     { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_2,                       "Generalized Label" },
    278   1.1  christos     { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_3,                       "Waveband Switching" },
    279   1.1  christos     { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_1,             "Label" },
    280   1.1  christos     { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_2,             "Generalized Label" },
    281   1.1  christos     { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_3,             "Waveband Switching" },
    282   1.1  christos     { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_1,              "Label" },
    283   1.1  christos     { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_2,              "Generalized Label" },
    284   1.1  christos     { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_3,              "Waveband Switching" },
    285   1.1  christos     { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_1,              "Label" },
    286   1.1  christos     { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_2,              "Generalized Label" },
    287   1.1  christos     { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_3,              "Waveband Switching" },
    288   1.1  christos     { 256*RSVP_OBJ_ERO+RSVP_CTYPE_IPV4,                      "IPv4" },
    289   1.1  christos     { 256*RSVP_OBJ_RRO+RSVP_CTYPE_IPV4,                      "IPv4" },
    290   1.1  christos     { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_IPV4,               "IPv4" },
    291   1.1  christos     { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_IPV6,               "IPv6" },
    292   1.1  christos     { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_3,                  "IPv4 plus opt. TLVs" },
    293   1.1  christos     { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_4,                  "IPv6 plus opt. TLVs" },
    294   1.1  christos     { 256*RSVP_OBJ_RESTART_CAPABILITY+RSVP_CTYPE_1,          "IPv4" },
    295  1.12  christos     { 256*RSVP_OBJ_CAPABILITY+RSVP_CTYPE_1,                  "1" },
    296   1.1  christos     { 256*RSVP_OBJ_SESSION_ATTRIBUTE+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" },
    297   1.1  christos     { 256*RSVP_OBJ_FASTREROUTE+RSVP_CTYPE_TUNNEL_IPV4,       "Tunnel IPv4" }, /* old style*/
    298   1.1  christos     { 256*RSVP_OBJ_FASTREROUTE+RSVP_CTYPE_1,                 "1" }, /* new style */
    299   1.1  christos     { 256*RSVP_OBJ_DETOUR+RSVP_CTYPE_TUNNEL_IPV4,            "Tunnel IPv4" },
    300   1.1  christos     { 256*RSVP_OBJ_PROPERTIES+RSVP_CTYPE_1,                  "1" },
    301   1.1  christos     { 256*RSVP_OBJ_ADMIN_STATUS+RSVP_CTYPE_1,                "1" },
    302   1.1  christos     { 256*RSVP_OBJ_CLASSTYPE+RSVP_CTYPE_1,                   "1" },
    303   1.1  christos     { 256*RSVP_OBJ_CLASSTYPE_OLD+RSVP_CTYPE_1,               "1" },
    304   1.1  christos     { 256*RSVP_OBJ_LABEL_SET+RSVP_CTYPE_1,                   "1" },
    305   1.1  christos     { 256*RSVP_OBJ_GENERALIZED_UNI+RSVP_CTYPE_1,             "1" },
    306   1.1  christos     { 256*RSVP_OBJ_S2L+RSVP_CTYPE_IPV4,                      "IPv4 sub-LSP" },
    307   1.1  christos     { 256*RSVP_OBJ_S2L+RSVP_CTYPE_IPV6,                      "IPv6 sub-LSP" },
    308   1.1  christos     { 0, NULL}
    309   1.1  christos };
    310   1.1  christos 
    311  1.12  christos /*
    312  1.12  christos  * XXX - this assumes a 16-byte digest, which is true for HMAC-MD5, but
    313  1.12  christos  * isn't necessarily the case for other hash algorithms.
    314  1.12  christos  *
    315  1.12  christos  * Unless I've missed something, there's nothing in RFC 2747 to indicate
    316  1.12  christos  * the hash algorithm being used, so it's presumably something set up
    317  1.12  christos  * out-of-band, or negotiated by other RSVP objects.
    318  1.12  christos  */
    319   1.1  christos struct rsvp_obj_integrity_t {
    320   1.6  christos     uint8_t flags;
    321   1.6  christos     uint8_t res;
    322   1.6  christos     uint8_t key_id[6];
    323   1.6  christos     uint8_t sequence[8];
    324   1.6  christos     uint8_t digest[16];
    325   1.1  christos };
    326   1.1  christos 
    327   1.1  christos static const struct tok rsvp_obj_integrity_flag_values[] = {
    328   1.1  christos     { 0x80, "Handshake" },
    329   1.1  christos     { 0, NULL}
    330   1.1  christos };
    331   1.1  christos 
    332   1.1  christos struct rsvp_obj_frr_t {
    333   1.6  christos     uint8_t setup_prio;
    334   1.6  christos     uint8_t hold_prio;
    335   1.6  christos     uint8_t hop_limit;
    336   1.6  christos     uint8_t flags;
    337   1.6  christos     uint8_t bandwidth[4];
    338   1.6  christos     uint8_t include_any[4];
    339   1.6  christos     uint8_t exclude_any[4];
    340   1.6  christos     uint8_t include_all[4];
    341   1.1  christos };
    342   1.1  christos 
    343   1.1  christos 
    344   1.1  christos #define RSVP_OBJ_XRO_MASK_SUBOBJ(x)   ((x)&0x7f)
    345   1.1  christos #define RSVP_OBJ_XRO_MASK_LOOSE(x)    ((x)&0x80)
    346   1.1  christos 
    347  1.12  christos #define RSVP_OBJ_CAPABILITY_FLAGS_MASK  0x7U
    348  1.12  christos 
    349   1.1  christos #define	RSVP_OBJ_XRO_RES       0
    350   1.1  christos #define	RSVP_OBJ_XRO_IPV4      1
    351   1.1  christos #define	RSVP_OBJ_XRO_IPV6      2
    352   1.1  christos #define	RSVP_OBJ_XRO_LABEL     3
    353   1.1  christos #define	RSVP_OBJ_XRO_ASN       32
    354   1.1  christos #define	RSVP_OBJ_XRO_MPLS      64
    355   1.1  christos 
    356   1.1  christos static const struct tok rsvp_obj_xro_values[] = {
    357   1.1  christos     { RSVP_OBJ_XRO_RES,	      "Reserved" },
    358   1.1  christos     { RSVP_OBJ_XRO_IPV4,      "IPv4 prefix" },
    359   1.1  christos     { RSVP_OBJ_XRO_IPV6,      "IPv6 prefix" },
    360   1.1  christos     { RSVP_OBJ_XRO_LABEL,     "Label" },
    361   1.1  christos     { RSVP_OBJ_XRO_ASN,       "Autonomous system number" },
    362   1.1  christos     { RSVP_OBJ_XRO_MPLS,      "MPLS label switched path termination" },
    363   1.1  christos     { 0, NULL}
    364   1.1  christos };
    365   1.1  christos 
    366  1.12  christos /* RFC4090 */
    367   1.1  christos static const struct tok rsvp_obj_rro_flag_values[] = {
    368   1.1  christos     { 0x01,	              "Local protection available" },
    369   1.1  christos     { 0x02,                   "Local protection in use" },
    370   1.1  christos     { 0x04,                   "Bandwidth protection" },
    371   1.1  christos     { 0x08,                   "Node protection" },
    372   1.1  christos     { 0, NULL}
    373   1.1  christos };
    374   1.1  christos 
    375   1.1  christos /* RFC3209 */
    376   1.1  christos static const struct tok rsvp_obj_rro_label_flag_values[] = {
    377   1.1  christos     { 0x01,                   "Global" },
    378   1.1  christos     { 0, NULL}
    379   1.1  christos };
    380   1.1  christos 
    381   1.1  christos static const struct tok rsvp_resstyle_values[] = {
    382   1.1  christos     { 17,	              "Wildcard Filter" },
    383   1.1  christos     { 10,                     "Fixed Filter" },
    384   1.1  christos     { 18,                     "Shared Explicit" },
    385   1.1  christos     { 0, NULL}
    386   1.1  christos };
    387   1.1  christos 
    388   1.1  christos #define RSVP_OBJ_INTSERV_GUARANTEED_SERV 2
    389   1.1  christos #define RSVP_OBJ_INTSERV_CONTROLLED_LOAD 5
    390   1.1  christos 
    391   1.1  christos static const struct tok rsvp_intserv_service_type_values[] = {
    392   1.1  christos     { 1,                                "Default/Global Information" },
    393   1.1  christos     { RSVP_OBJ_INTSERV_GUARANTEED_SERV, "Guaranteed Service" },
    394   1.1  christos     { RSVP_OBJ_INTSERV_CONTROLLED_LOAD,	"Controlled Load" },
    395   1.1  christos     { 0, NULL}
    396   1.1  christos };
    397   1.1  christos 
    398   1.1  christos static const struct tok rsvp_intserv_parameter_id_values[] = {
    399   1.1  christos     { 4,                     "IS hop cnt" },
    400   1.1  christos     { 6,                     "Path b/w estimate" },
    401   1.1  christos     { 8,                     "Minimum path latency" },
    402   1.1  christos     { 10,                    "Composed MTU" },
    403   1.1  christos     { 127,                   "Token Bucket TSpec" },
    404   1.1  christos     { 130,                   "Guaranteed Service RSpec" },
    405   1.1  christos     { 133,                   "End-to-end composed value for C" },
    406   1.1  christos     { 134,                   "End-to-end composed value for D" },
    407   1.1  christos     { 135,                   "Since-last-reshaping point composed C" },
    408   1.1  christos     { 136,                   "Since-last-reshaping point composed D" },
    409   1.1  christos     { 0, NULL}
    410   1.1  christos };
    411   1.1  christos 
    412   1.5  christos static const struct tok rsvp_session_attribute_flag_values[] = {
    413   1.1  christos     { 0x01,	              "Local Protection" },
    414   1.1  christos     { 0x02,                   "Label Recording" },
    415   1.1  christos     { 0x04,                   "SE Style" },
    416   1.1  christos     { 0x08,                   "Bandwidth protection" }, /* RFC4090 */
    417   1.1  christos     { 0x10,                   "Node protection" },      /* RFC4090 */
    418   1.1  christos     { 0, NULL}
    419   1.1  christos };
    420   1.1  christos 
    421   1.5  christos static const struct tok rsvp_obj_prop_tlv_values[] = {
    422   1.1  christos     { 0x01,                   "Cos" },
    423   1.1  christos     { 0x02,                   "Metric 1" },
    424   1.1  christos     { 0x04,                   "Metric 2" },
    425   1.1  christos     { 0x08,                   "CCC Status" },
    426   1.1  christos     { 0x10,                   "Path Type" },
    427   1.1  christos     { 0, NULL}
    428   1.1  christos };
    429   1.1  christos 
    430   1.1  christos #define RSVP_OBJ_ERROR_SPEC_CODE_ROUTING 24
    431   1.1  christos #define RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY  25
    432   1.1  christos #define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE 28
    433   1.1  christos #define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD 125
    434   1.1  christos 
    435   1.5  christos static const struct tok rsvp_obj_error_code_values[] = {
    436   1.1  christos     { RSVP_OBJ_ERROR_SPEC_CODE_ROUTING, "Routing Problem" },
    437   1.1  christos     { RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY,  "Notify Error" },
    438   1.1  christos     { RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE, "Diffserv TE Error" },
    439   1.1  christos     { RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD, "Diffserv TE Error (Old)" },
    440   1.1  christos     { 0, NULL}
    441   1.1  christos };
    442   1.1  christos 
    443   1.5  christos static const struct tok rsvp_obj_error_code_routing_values[] = {
    444   1.1  christos     { 1,                      "Bad EXPLICIT_ROUTE object" },
    445   1.1  christos     { 2,                      "Bad strict node" },
    446   1.1  christos     { 3,                      "Bad loose node" },
    447   1.1  christos     { 4,                      "Bad initial subobject" },
    448   1.1  christos     { 5,                      "No route available toward destination" },
    449   1.1  christos     { 6,                      "Unacceptable label value" },
    450   1.1  christos     { 7,                      "RRO indicated routing loops" },
    451   1.1  christos     { 8,                      "non-RSVP-capable router in the path" },
    452   1.1  christos     { 9,                      "MPLS label allocation failure" },
    453   1.1  christos     { 10,                     "Unsupported L3PID" },
    454   1.1  christos     { 0, NULL}
    455   1.1  christos };
    456   1.1  christos 
    457   1.5  christos static const struct tok rsvp_obj_error_code_diffserv_te_values[] = {
    458   1.1  christos     { 1,                      "Unexpected CT object" },
    459   1.1  christos     { 2,                      "Unsupported CT" },
    460   1.1  christos     { 3,                      "Invalid CT value" },
    461   1.1  christos     { 4,                      "CT/setup priority do not form a configured TE-Class" },
    462   1.1  christos     { 5,                      "CT/holding priority do not form a configured TE-Class" },
    463   1.1  christos     { 6,                      "CT/setup priority and CT/holding priority do not form a configured TE-Class" },
    464   1.6  christos     { 7,                      "Inconsistency between signaled PSC and signaled CT" },
    465   1.1  christos     { 8,                      "Inconsistency between signaled PHBs and signaled CT" },
    466   1.1  christos    { 0, NULL}
    467   1.1  christos };
    468   1.1  christos 
    469   1.1  christos /* rfc3473 / rfc 3471 */
    470   1.1  christos static const struct tok rsvp_obj_admin_status_flag_values[] = {
    471   1.1  christos     { 0x80000000, "Reflect" },
    472   1.1  christos     { 0x00000004, "Testing" },
    473   1.1  christos     { 0x00000002, "Admin-down" },
    474   1.1  christos     { 0x00000001, "Delete-in-progress" },
    475   1.1  christos     { 0, NULL}
    476   1.1  christos };
    477   1.1  christos 
    478   1.1  christos /* label set actions - rfc3471 */
    479   1.1  christos #define LABEL_SET_INCLUSIVE_LIST  0
    480   1.1  christos #define LABEL_SET_EXCLUSIVE_LIST  1
    481   1.1  christos #define LABEL_SET_INCLUSIVE_RANGE 2
    482   1.1  christos #define LABEL_SET_EXCLUSIVE_RANGE 3
    483   1.1  christos 
    484   1.1  christos static const struct tok rsvp_obj_label_set_action_values[] = {
    485   1.1  christos     { LABEL_SET_INCLUSIVE_LIST, "Inclusive list" },
    486   1.1  christos     { LABEL_SET_EXCLUSIVE_LIST, "Exclusive list" },
    487   1.1  christos     { LABEL_SET_INCLUSIVE_RANGE, "Inclusive range" },
    488   1.1  christos     { LABEL_SET_EXCLUSIVE_RANGE, "Exclusive range" },
    489   1.1  christos     { 0, NULL}
    490   1.1  christos };
    491   1.1  christos 
    492   1.1  christos /* OIF RSVP extensions UNI 1.0 Signaling, release 2 */
    493   1.1  christos #define RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS	    1
    494   1.1  christos #define RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS 2
    495   1.1  christos #define RSVP_GEN_UNI_SUBOBJ_DIVERSITY		    3
    496   1.1  christos #define RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL            4
    497   1.1  christos #define RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL           5
    498   1.1  christos 
    499   1.1  christos static const struct tok rsvp_obj_generalized_uni_values[] = {
    500   1.1  christos     { RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS, "Source TNA address" },
    501   1.1  christos     { RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS, "Destination TNA address" },
    502   1.1  christos     { RSVP_GEN_UNI_SUBOBJ_DIVERSITY, "Diversity" },
    503   1.1  christos     { RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL, "Egress label" },
    504   1.1  christos     { RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL, "Service level" },
    505   1.1  christos     { 0, NULL}
    506   1.1  christos };
    507   1.1  christos 
    508   1.6  christos /*
    509   1.1  christos  * this is a dissector for all the intserv defined
    510   1.1  christos  * specs as defined per rfc2215
    511   1.1  christos  * it is called from various rsvp objects;
    512   1.1  christos  * returns the amount of bytes being processed
    513   1.1  christos  */
    514  1.12  christos static u_int
    515   1.6  christos rsvp_intserv_print(netdissect_options *ndo,
    516  1.12  christos                    const u_char *tptr, u_int obj_tlen)
    517   1.7  christos {
    518  1.12  christos     u_int parameter_id,parameter_length;
    519   1.1  christos     union {
    520   1.1  christos 	float f;
    521   1.6  christos 	uint32_t i;
    522   1.1  christos     } bw;
    523   1.1  christos 
    524   1.1  christos     if (obj_tlen < 4)
    525   1.1  christos         return 0;
    526  1.12  christos     parameter_id = GET_U_1(tptr);
    527  1.12  christos     parameter_length = GET_BE_U_2(tptr + 2)<<2; /* convert wordcount to bytecount */
    528   1.1  christos 
    529  1.12  christos     ND_PRINT("\n\t      Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
    530   1.1  christos            tok2str(rsvp_intserv_parameter_id_values,"unknown",parameter_id),
    531   1.1  christos            parameter_id,
    532   1.1  christos            parameter_length,
    533  1.12  christos            GET_U_1(tptr + 1));
    534   1.1  christos 
    535   1.1  christos     if (obj_tlen < parameter_length+4)
    536   1.1  christos         return 0;
    537   1.1  christos     switch(parameter_id) { /* parameter_id */
    538   1.1  christos 
    539   1.1  christos     case 4:
    540   1.1  christos        /*
    541   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    542   1.1  christos         * |    4 (e)      |    (f)        |           1 (g)               |
    543   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    544   1.1  christos         * |        IS hop cnt (32-bit unsigned integer)                   |
    545   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    546   1.1  christos         */
    547   1.9       spz         if (parameter_length == 4) {
    548  1.12  christos             ND_PRINT("\n\t\tIS hop count: %u", GET_BE_U_4(tptr + 4));
    549   1.9       spz         }
    550   1.1  christos         break;
    551   1.1  christos 
    552   1.1  christos     case 6:
    553   1.1  christos        /*
    554   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    555   1.1  christos         * |    6 (h)      |    (i)        |           1 (j)               |
    556   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    557   1.1  christos         * |  Path b/w estimate  (32-bit IEEE floating point number)       |
    558   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    559   1.1  christos         */
    560   1.1  christos         if (parameter_length == 4) {
    561  1.12  christos             bw.i = GET_BE_U_4(tptr + 4);
    562  1.12  christos             ND_PRINT("\n\t\tPath b/w estimate: %.10g Mbps", bw.f / 125000);
    563   1.1  christos         }
    564   1.1  christos         break;
    565   1.1  christos 
    566   1.1  christos     case 8:
    567   1.1  christos        /*
    568   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    569   1.1  christos         * |     8 (k)     |    (l)        |           1 (m)               |
    570   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    571   1.1  christos         * |        Minimum path latency (32-bit integer)                  |
    572   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    573   1.1  christos         */
    574   1.1  christos         if (parameter_length == 4) {
    575  1.12  christos             ND_PRINT("\n\t\tMinimum path latency: ");
    576  1.12  christos             if (GET_BE_U_4(tptr + 4) == 0xffffffff)
    577  1.12  christos                 ND_PRINT("don't care");
    578   1.1  christos             else
    579  1.12  christos                 ND_PRINT("%u", GET_BE_U_4(tptr + 4));
    580   1.1  christos         }
    581   1.1  christos         break;
    582   1.1  christos 
    583   1.1  christos     case 10:
    584   1.1  christos 
    585   1.1  christos        /*
    586   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    587   1.1  christos         * |     10 (n)    |      (o)      |           1 (p)               |
    588   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    589   1.1  christos         * |      Composed MTU (32-bit unsigned integer)                   |
    590   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    591   1.1  christos         */
    592   1.9       spz         if (parameter_length == 4) {
    593  1.12  christos             ND_PRINT("\n\t\tComposed MTU: %u bytes", GET_BE_U_4(tptr + 4));
    594   1.9       spz         }
    595   1.1  christos         break;
    596   1.1  christos     case 127:
    597   1.6  christos        /*
    598   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    599   1.1  christos         * |   127 (e)     |    0 (f)      |             5 (g)             |
    600   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    601   1.1  christos         * |  Token Bucket Rate [r] (32-bit IEEE floating point number)    |
    602   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    603   1.1  christos         * |  Token Bucket Size [b] (32-bit IEEE floating point number)    |
    604   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    605   1.1  christos         * |  Peak Data Rate [p] (32-bit IEEE floating point number)       |
    606   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    607   1.1  christos         * |  Minimum Policed Unit [m] (32-bit integer)                    |
    608   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    609   1.1  christos         * |  Maximum Packet Size [M]  (32-bit integer)                    |
    610   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    611   1.1  christos         */
    612   1.1  christos 
    613   1.1  christos         if (parameter_length == 20) {
    614  1.12  christos 	    ND_TCHECK_LEN(tptr + 4, 20);
    615  1.12  christos             bw.i = GET_BE_U_4(tptr + 4);
    616  1.12  christos             ND_PRINT("\n\t\tToken Bucket Rate: %.10g Mbps", bw.f / 125000);
    617  1.12  christos             bw.i = GET_BE_U_4(tptr + 8);
    618  1.12  christos             ND_PRINT("\n\t\tToken Bucket Size: %.10g bytes", bw.f);
    619  1.12  christos             bw.i = GET_BE_U_4(tptr + 12);
    620  1.12  christos             ND_PRINT("\n\t\tPeak Data Rate: %.10g Mbps", bw.f / 125000);
    621  1.12  christos             ND_PRINT("\n\t\tMinimum Policed Unit: %u bytes",
    622  1.12  christos                      GET_BE_U_4(tptr + 16));
    623  1.12  christos             ND_PRINT("\n\t\tMaximum Packet Size: %u bytes",
    624  1.12  christos                      GET_BE_U_4(tptr + 20));
    625   1.1  christos         }
    626   1.1  christos         break;
    627   1.1  christos 
    628   1.1  christos     case 130:
    629   1.6  christos        /*
    630   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    631   1.1  christos         * |     130 (h)   |    0 (i)      |            2 (j)              |
    632   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    633   1.1  christos         * |  Rate [R]  (32-bit IEEE floating point number)                |
    634   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    635   1.1  christos         * |  Slack Term [S]  (32-bit integer)                             |
    636   1.1  christos         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    637   1.1  christos         */
    638   1.1  christos 
    639   1.1  christos         if (parameter_length == 8) {
    640  1.12  christos 	    ND_TCHECK_8(tptr + 4);
    641  1.12  christos             bw.i = GET_BE_U_4(tptr + 4);
    642  1.12  christos             ND_PRINT("\n\t\tRate: %.10g Mbps", bw.f / 125000);
    643  1.12  christos             ND_PRINT("\n\t\tSlack Term: %u", GET_BE_U_4(tptr + 8));
    644   1.1  christos         }
    645   1.1  christos         break;
    646   1.1  christos 
    647   1.1  christos     case 133:
    648   1.1  christos     case 134:
    649   1.1  christos     case 135:
    650   1.1  christos     case 136:
    651   1.9       spz         if (parameter_length == 4) {
    652  1.12  christos             ND_PRINT("\n\t\tValue: %u", GET_BE_U_4(tptr + 4));
    653   1.9       spz         }
    654   1.1  christos         break;
    655   1.1  christos 
    656   1.1  christos     default:
    657   1.6  christos         if (ndo->ndo_vflag <= 1)
    658   1.6  christos             print_unknown_data(ndo, tptr + 4, "\n\t\t", parameter_length);
    659   1.1  christos     }
    660   1.1  christos     return (parameter_length+4); /* header length 4 bytes */
    661   1.8  christos 
    662   1.8  christos trunc:
    663  1.12  christos     nd_print_trunc(ndo);
    664   1.8  christos     return 0;
    665   1.8  christos }
    666   1.8  christos 
    667   1.8  christos /*
    668   1.8  christos  * Clear checksum prior to signature verification.
    669   1.8  christos  */
    670   1.8  christos static void
    671   1.8  christos rsvp_clear_checksum(void *header)
    672   1.8  christos {
    673   1.8  christos     struct rsvp_common_header *rsvp_com_header = (struct rsvp_common_header *) header;
    674   1.8  christos 
    675   1.8  christos     rsvp_com_header->checksum[0] = 0;
    676   1.8  christos     rsvp_com_header->checksum[1] = 0;
    677   1.1  christos }
    678   1.1  christos 
    679   1.1  christos static int
    680   1.6  christos rsvp_obj_print(netdissect_options *ndo,
    681   1.8  christos                const u_char *pptr, u_int plen, const u_char *tptr,
    682  1.12  christos                const char *indent, u_int tlen,
    683   1.8  christos                const struct rsvp_common_header *rsvp_com_header)
    684   1.7  christos {
    685   1.1  christos     const struct rsvp_object_header *rsvp_obj_header;
    686   1.1  christos     const u_char *obj_tptr;
    687   1.1  christos     union {
    688   1.1  christos         const struct rsvp_obj_integrity_t *rsvp_obj_integrity;
    689   1.1  christos         const struct rsvp_obj_frr_t *rsvp_obj_frr;
    690   1.1  christos     } obj_ptr;
    691   1.1  christos 
    692  1.12  christos     u_short rsvp_obj_len,rsvp_obj_ctype,rsvp_obj_class_num;
    693  1.12  christos     u_int obj_tlen,intserv_serv_tlen;
    694  1.12  christos     int hexdump;
    695  1.12  christos     u_int processed,padbytes,error_code,error_value,i,sigcheck;
    696   1.1  christos     union {
    697   1.1  christos 	float f;
    698   1.6  christos 	uint32_t i;
    699   1.1  christos     } bw;
    700  1.12  christos     u_int namelen;
    701   1.1  christos 
    702   1.1  christos     u_int action, subchannel;
    703   1.1  christos 
    704   1.1  christos     while(tlen>=sizeof(struct rsvp_object_header)) {
    705   1.1  christos         /* did we capture enough for fully decoding the object header ? */
    706  1.12  christos         ND_TCHECK_LEN(tptr, sizeof(struct rsvp_object_header));
    707   1.1  christos 
    708   1.1  christos         rsvp_obj_header = (const struct rsvp_object_header *)tptr;
    709  1.12  christos         rsvp_obj_len=GET_BE_U_2(rsvp_obj_header->length);
    710  1.12  christos         rsvp_obj_ctype=GET_U_1(rsvp_obj_header->ctype);
    711   1.1  christos 
    712   1.1  christos         if(rsvp_obj_len % 4) {
    713  1.12  christos             ND_PRINT("%sERROR: object header size %u not a multiple of 4", indent, rsvp_obj_len);
    714   1.1  christos             return -1;
    715   1.1  christos         }
    716   1.1  christos         if(rsvp_obj_len < sizeof(struct rsvp_object_header)) {
    717  1.12  christos             ND_PRINT("%sERROR: object header too short %u < %zu", indent, rsvp_obj_len,
    718  1.12  christos                    sizeof(struct rsvp_object_header));
    719   1.1  christos             return -1;
    720   1.1  christos         }
    721   1.1  christos 
    722  1.12  christos         rsvp_obj_class_num = GET_U_1(rsvp_obj_header->class_num);
    723  1.12  christos         ND_PRINT("%s%s Object (%u) Flags: [%s",
    724  1.12  christos                indent,
    725   1.1  christos                tok2str(rsvp_obj_values,
    726   1.1  christos                        "Unknown",
    727  1.12  christos                        rsvp_obj_class_num),
    728  1.12  christos                rsvp_obj_class_num,
    729  1.12  christos                (rsvp_obj_class_num & 0x80) ?
    730  1.12  christos                    ((rsvp_obj_class_num & 0x40) ? "ignore and forward" :
    731  1.12  christos                                          "ignore silently") :
    732  1.12  christos                    "reject");
    733   1.1  christos 
    734  1.12  christos         ND_PRINT(" if unknown], Class-Type: %s (%u), length: %u",
    735   1.1  christos                tok2str(rsvp_ctype_values,
    736   1.1  christos                        "Unknown",
    737  1.12  christos                        (rsvp_obj_class_num<<8)+rsvp_obj_ctype),
    738   1.1  christos                rsvp_obj_ctype,
    739  1.12  christos                rsvp_obj_len);
    740   1.6  christos 
    741   1.1  christos         if(tlen < rsvp_obj_len) {
    742  1.12  christos             ND_PRINT("%sERROR: object goes past end of objects TLV", indent);
    743   1.1  christos             return -1;
    744   1.1  christos         }
    745   1.1  christos 
    746   1.1  christos         obj_tptr=tptr+sizeof(struct rsvp_object_header);
    747   1.1  christos         obj_tlen=rsvp_obj_len-sizeof(struct rsvp_object_header);
    748   1.1  christos 
    749   1.1  christos         /* did we capture enough for fully decoding the object ? */
    750  1.12  christos         ND_TCHECK_LEN(tptr, rsvp_obj_len);
    751   1.1  christos         hexdump=FALSE;
    752   1.1  christos 
    753  1.12  christos         switch(rsvp_obj_class_num) {
    754   1.1  christos         case RSVP_OBJ_SESSION:
    755   1.1  christos             switch(rsvp_obj_ctype) {
    756   1.1  christos             case RSVP_CTYPE_IPV4:
    757   1.1  christos                 if (obj_tlen < 8)
    758  1.12  christos                     goto obj_tooshort;
    759  1.12  christos                 ND_PRINT("%s  IPv4 DestAddress: %s, Protocol ID: 0x%02x",
    760  1.12  christos                        indent,
    761  1.12  christos                        GET_IPADDR_STRING(obj_tptr),
    762  1.12  christos                        GET_U_1(obj_tptr + sizeof(nd_ipv4)));
    763  1.12  christos                 ND_PRINT("%s  Flags: [0x%02x], DestPort %u",
    764  1.12  christos                        indent,
    765  1.12  christos                        GET_U_1((obj_tptr + 5)),
    766  1.12  christos                        GET_BE_U_2(obj_tptr + 6));
    767   1.1  christos                 obj_tlen-=8;
    768   1.6  christos                 obj_tptr+=8;
    769   1.1  christos                 break;
    770   1.1  christos             case RSVP_CTYPE_IPV6:
    771   1.1  christos                 if (obj_tlen < 20)
    772  1.12  christos                     goto obj_tooshort;
    773  1.12  christos                 ND_PRINT("%s  IPv6 DestAddress: %s, Protocol ID: 0x%02x",
    774  1.12  christos                        indent,
    775  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr),
    776  1.12  christos                        GET_U_1(obj_tptr + sizeof(nd_ipv6)));
    777  1.12  christos                 ND_PRINT("%s  Flags: [0x%02x], DestPort %u",
    778  1.12  christos                        indent,
    779  1.12  christos                        GET_U_1((obj_tptr + sizeof(nd_ipv6) + 1)),
    780  1.12  christos                        GET_BE_U_2(obj_tptr + sizeof(nd_ipv6) + 2));
    781   1.1  christos                 obj_tlen-=20;
    782   1.6  christos                 obj_tptr+=20;
    783   1.1  christos                 break;
    784   1.1  christos 
    785   1.1  christos             case RSVP_CTYPE_TUNNEL_IPV6:
    786   1.1  christos                 if (obj_tlen < 36)
    787  1.12  christos                     goto obj_tooshort;
    788  1.12  christos                 ND_PRINT("%s  IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
    789  1.12  christos                        indent,
    790  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr),
    791  1.12  christos                        GET_BE_U_2(obj_tptr + 18),
    792  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr + 20));
    793   1.1  christos                 obj_tlen-=36;
    794   1.6  christos                 obj_tptr+=36;
    795   1.1  christos                 break;
    796   1.1  christos 
    797   1.1  christos             case RSVP_CTYPE_14: /* IPv6 p2mp LSP Tunnel */
    798   1.1  christos                 if (obj_tlen < 26)
    799  1.12  christos                     goto obj_tooshort;
    800  1.12  christos                 ND_PRINT("%s  IPv6 P2MP LSP ID: 0x%08x, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
    801  1.12  christos                        indent,
    802  1.12  christos                        GET_BE_U_4(obj_tptr),
    803  1.12  christos                        GET_BE_U_2(obj_tptr + 6),
    804  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr + 8));
    805   1.1  christos                 obj_tlen-=26;
    806   1.6  christos                 obj_tptr+=26;
    807   1.1  christos                 break;
    808   1.1  christos             case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */
    809   1.1  christos                 if (obj_tlen < 12)
    810  1.12  christos                     goto obj_tooshort;
    811  1.12  christos                 ND_PRINT("%s  IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
    812  1.12  christos                        indent,
    813  1.12  christos                        GET_IPADDR_STRING(obj_tptr),
    814  1.12  christos                        GET_BE_U_2(obj_tptr + 6),
    815  1.12  christos                        GET_IPADDR_STRING(obj_tptr + 8));
    816   1.1  christos                 obj_tlen-=12;
    817   1.6  christos                 obj_tptr+=12;
    818   1.1  christos                 break;
    819   1.1  christos             case RSVP_CTYPE_TUNNEL_IPV4:
    820   1.1  christos             case RSVP_CTYPE_UNI_IPV4:
    821   1.1  christos                 if (obj_tlen < 12)
    822  1.12  christos                     goto obj_tooshort;
    823  1.12  christos                 ND_PRINT("%s  IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
    824  1.12  christos                        indent,
    825  1.12  christos                        GET_IPADDR_STRING(obj_tptr),
    826  1.12  christos                        GET_BE_U_2(obj_tptr + 6),
    827  1.12  christos                        GET_IPADDR_STRING(obj_tptr + 8));
    828   1.1  christos                 obj_tlen-=12;
    829   1.6  christos                 obj_tptr+=12;
    830   1.1  christos                 break;
    831   1.1  christos             default:
    832   1.1  christos                 hexdump=TRUE;
    833   1.1  christos             }
    834   1.1  christos             break;
    835   1.1  christos 
    836   1.1  christos         case RSVP_OBJ_CONFIRM:
    837   1.1  christos             switch(rsvp_obj_ctype) {
    838   1.1  christos             case RSVP_CTYPE_IPV4:
    839  1.12  christos                 if (obj_tlen < sizeof(nd_ipv4))
    840  1.12  christos                     goto obj_tooshort;
    841  1.12  christos                 ND_PRINT("%s  IPv4 Receiver Address: %s",
    842  1.12  christos                        indent,
    843  1.12  christos                        GET_IPADDR_STRING(obj_tptr));
    844  1.12  christos                 obj_tlen-=sizeof(nd_ipv4);
    845  1.12  christos                 obj_tptr+=sizeof(nd_ipv4);
    846   1.1  christos                 break;
    847   1.1  christos             case RSVP_CTYPE_IPV6:
    848  1.12  christos                 if (obj_tlen < sizeof(nd_ipv6))
    849  1.12  christos                     goto obj_tooshort;
    850  1.12  christos                 ND_PRINT("%s  IPv6 Receiver Address: %s",
    851  1.12  christos                        indent,
    852  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr));
    853  1.12  christos                 obj_tlen-=sizeof(nd_ipv6);
    854  1.12  christos                 obj_tptr+=sizeof(nd_ipv6);
    855   1.1  christos                 break;
    856   1.1  christos             default:
    857   1.1  christos                 hexdump=TRUE;
    858   1.1  christos             }
    859   1.1  christos             break;
    860   1.1  christos 
    861   1.1  christos         case RSVP_OBJ_NOTIFY_REQ:
    862   1.1  christos             switch(rsvp_obj_ctype) {
    863   1.1  christos             case RSVP_CTYPE_IPV4:
    864  1.12  christos                 if (obj_tlen < sizeof(nd_ipv4))
    865  1.12  christos                     goto obj_tooshort;
    866  1.12  christos                 ND_PRINT("%s  IPv4 Notify Node Address: %s",
    867  1.12  christos                        indent,
    868  1.12  christos                        GET_IPADDR_STRING(obj_tptr));
    869  1.12  christos                 obj_tlen-=sizeof(nd_ipv4);
    870  1.12  christos                 obj_tptr+=sizeof(nd_ipv4);
    871   1.1  christos                 break;
    872   1.1  christos             case RSVP_CTYPE_IPV6:
    873  1.12  christos                 if (obj_tlen < sizeof(nd_ipv6))
    874  1.12  christos                     goto obj_tooshort;
    875  1.12  christos                 ND_PRINT("%s  IPv6 Notify Node Address: %s",
    876  1.12  christos                        indent,
    877  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr));
    878  1.12  christos                 obj_tlen-=sizeof(nd_ipv6);
    879  1.12  christos                 obj_tptr+=sizeof(nd_ipv6);
    880   1.1  christos                 break;
    881   1.1  christos             default:
    882   1.1  christos                 hexdump=TRUE;
    883   1.1  christos             }
    884   1.1  christos             break;
    885   1.1  christos 
    886   1.1  christos         case RSVP_OBJ_SUGGESTED_LABEL: /* fall through */
    887   1.1  christos         case RSVP_OBJ_UPSTREAM_LABEL:  /* fall through */
    888   1.1  christos         case RSVP_OBJ_RECOVERY_LABEL:  /* fall through */
    889   1.1  christos         case RSVP_OBJ_LABEL:
    890   1.1  christos             switch(rsvp_obj_ctype) {
    891   1.1  christos             case RSVP_CTYPE_1:
    892   1.1  christos                 while(obj_tlen >= 4 ) {
    893  1.12  christos                     ND_PRINT("%s  Label: %u", indent, GET_BE_U_4(obj_tptr));
    894   1.1  christos                     obj_tlen-=4;
    895   1.1  christos                     obj_tptr+=4;
    896   1.1  christos                 }
    897   1.1  christos                 break;
    898   1.1  christos             case RSVP_CTYPE_2:
    899   1.1  christos                 if (obj_tlen < 4)
    900  1.12  christos                     goto obj_tooshort;
    901  1.12  christos                 ND_PRINT("%s  Generalized Label: %u",
    902  1.12  christos                        indent,
    903  1.12  christos                        GET_BE_U_4(obj_tptr));
    904   1.1  christos                 obj_tlen-=4;
    905   1.1  christos                 obj_tptr+=4;
    906   1.1  christos                 break;
    907   1.1  christos             case RSVP_CTYPE_3:
    908   1.1  christos                 if (obj_tlen < 12)
    909  1.12  christos                     goto obj_tooshort;
    910  1.12  christos                 ND_PRINT("%s  Waveband ID: %u%s  Start Label: %u, Stop Label: %u",
    911  1.12  christos                        indent,
    912  1.12  christos                        GET_BE_U_4(obj_tptr),
    913  1.12  christos                        indent,
    914  1.12  christos                        GET_BE_U_4(obj_tptr + 4),
    915  1.12  christos                        GET_BE_U_4(obj_tptr + 8));
    916   1.1  christos                 obj_tlen-=12;
    917   1.1  christos                 obj_tptr+=12;
    918   1.1  christos                 break;
    919   1.1  christos             default:
    920   1.1  christos                 hexdump=TRUE;
    921   1.1  christos             }
    922   1.1  christos             break;
    923   1.1  christos 
    924   1.1  christos         case RSVP_OBJ_STYLE:
    925   1.1  christos             switch(rsvp_obj_ctype) {
    926   1.1  christos             case RSVP_CTYPE_1:
    927   1.1  christos                 if (obj_tlen < 4)
    928  1.12  christos                     goto obj_tooshort;
    929  1.12  christos                 ND_PRINT("%s  Reservation Style: %s, Flags: [0x%02x]",
    930  1.12  christos                        indent,
    931   1.1  christos                        tok2str(rsvp_resstyle_values,
    932   1.1  christos                                "Unknown",
    933  1.12  christos                                GET_BE_U_3(obj_tptr + 1)),
    934  1.12  christos                        GET_U_1(obj_tptr));
    935   1.1  christos                 obj_tlen-=4;
    936   1.1  christos                 obj_tptr+=4;
    937   1.1  christos                 break;
    938   1.1  christos             default:
    939   1.1  christos                 hexdump=TRUE;
    940   1.1  christos             }
    941   1.1  christos             break;
    942   1.1  christos 
    943   1.1  christos         case RSVP_OBJ_SENDER_TEMPLATE:
    944   1.1  christos             switch(rsvp_obj_ctype) {
    945   1.1  christos             case RSVP_CTYPE_IPV4:
    946   1.1  christos                 if (obj_tlen < 8)
    947  1.12  christos                     goto obj_tooshort;
    948  1.12  christos                 ND_PRINT("%s  Source Address: %s, Source Port: %u",
    949  1.12  christos                        indent,
    950  1.12  christos                        GET_IPADDR_STRING(obj_tptr),
    951  1.12  christos                        GET_BE_U_2(obj_tptr + 6));
    952   1.1  christos                 obj_tlen-=8;
    953   1.1  christos                 obj_tptr+=8;
    954   1.1  christos                 break;
    955   1.1  christos             case RSVP_CTYPE_IPV6:
    956   1.1  christos                 if (obj_tlen < 20)
    957  1.12  christos                     goto obj_tooshort;
    958  1.12  christos                 ND_PRINT("%s  Source Address: %s, Source Port: %u",
    959  1.12  christos                        indent,
    960  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr),
    961  1.12  christos                        GET_BE_U_2(obj_tptr + 18));
    962   1.1  christos                 obj_tlen-=20;
    963   1.1  christos                 obj_tptr+=20;
    964   1.1  christos                 break;
    965   1.1  christos             case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */
    966   1.1  christos                 if (obj_tlen < 40)
    967  1.12  christos                     goto obj_tooshort;
    968  1.12  christos                 ND_PRINT("%s  IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
    969   1.1  christos                        "%s  Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
    970  1.12  christos                        indent,
    971  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr),
    972  1.12  christos                        GET_BE_U_2(obj_tptr + 18),
    973  1.12  christos                        indent,
    974  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr+20),
    975  1.12  christos                        GET_BE_U_2(obj_tptr + 38));
    976   1.1  christos                 obj_tlen-=40;
    977   1.1  christos                 obj_tptr+=40;
    978   1.1  christos                 break;
    979   1.1  christos             case RSVP_CTYPE_TUNNEL_IPV4:
    980   1.1  christos                 if (obj_tlen < 8)
    981  1.12  christos                     goto obj_tooshort;
    982  1.12  christos                 ND_PRINT("%s  IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x",
    983  1.12  christos                        indent,
    984  1.12  christos                        GET_IPADDR_STRING(obj_tptr),
    985  1.12  christos                        GET_BE_U_2(obj_tptr + 6));
    986   1.1  christos                 obj_tlen-=8;
    987   1.1  christos                 obj_tptr+=8;
    988   1.1  christos                 break;
    989   1.1  christos             case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */
    990   1.1  christos                 if (obj_tlen < 16)
    991  1.12  christos                     goto obj_tooshort;
    992  1.12  christos                 ND_PRINT("%s  IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
    993   1.1  christos                        "%s  Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
    994  1.12  christos                        indent,
    995  1.12  christos                        GET_IPADDR_STRING(obj_tptr),
    996  1.12  christos                        GET_BE_U_2(obj_tptr + 6),
    997  1.12  christos                        indent,
    998  1.12  christos                        GET_IPADDR_STRING(obj_tptr+8),
    999  1.12  christos                        GET_BE_U_2(obj_tptr + 12));
   1000   1.1  christos                 obj_tlen-=16;
   1001   1.1  christos                 obj_tptr+=16;
   1002   1.1  christos                 break;
   1003   1.1  christos             default:
   1004   1.1  christos                 hexdump=TRUE;
   1005   1.1  christos             }
   1006   1.1  christos             break;
   1007   1.1  christos 
   1008   1.1  christos         case RSVP_OBJ_LABEL_REQ:
   1009   1.1  christos             switch(rsvp_obj_ctype) {
   1010   1.1  christos             case RSVP_CTYPE_1:
   1011   1.1  christos                 while(obj_tlen >= 4 ) {
   1012  1.12  christos                     ND_PRINT("%s  L3 Protocol ID: %s",
   1013  1.12  christos                            indent,
   1014   1.1  christos                            tok2str(ethertype_values,
   1015   1.1  christos                                    "Unknown Protocol (0x%04x)",
   1016  1.12  christos                                    GET_BE_U_2(obj_tptr + 2)));
   1017   1.1  christos                     obj_tlen-=4;
   1018   1.1  christos                     obj_tptr+=4;
   1019   1.1  christos                 }
   1020   1.1  christos                 break;
   1021   1.1  christos             case RSVP_CTYPE_2:
   1022   1.1  christos                 if (obj_tlen < 12)
   1023  1.12  christos                     goto obj_tooshort;
   1024  1.12  christos                 ND_PRINT("%s  L3 Protocol ID: %s",
   1025  1.12  christos                        indent,
   1026   1.1  christos                        tok2str(ethertype_values,
   1027   1.1  christos                                "Unknown Protocol (0x%04x)",
   1028  1.12  christos                                GET_BE_U_2(obj_tptr + 2)));
   1029  1.12  christos                 ND_PRINT(",%s merge capability",
   1030  1.12  christos                          ((GET_U_1(obj_tptr + 4)) & 0x80) ? "no" : "" );
   1031  1.12  christos                 ND_PRINT("%s  Minimum VPI/VCI: %u/%u",
   1032  1.12  christos                        indent,
   1033  1.12  christos                        (GET_BE_U_2(obj_tptr + 4))&0xfff,
   1034  1.12  christos                        (GET_BE_U_2(obj_tptr + 6)) & 0xfff);
   1035  1.12  christos                 ND_PRINT("%s  Maximum VPI/VCI: %u/%u",
   1036  1.12  christos                        indent,
   1037  1.12  christos                        (GET_BE_U_2(obj_tptr + 8))&0xfff,
   1038  1.12  christos                        (GET_BE_U_2(obj_tptr + 10)) & 0xfff);
   1039   1.1  christos                 obj_tlen-=12;
   1040   1.1  christos                 obj_tptr+=12;
   1041   1.1  christos                 break;
   1042   1.1  christos             case RSVP_CTYPE_3:
   1043   1.1  christos                 if (obj_tlen < 12)
   1044  1.12  christos                     goto obj_tooshort;
   1045  1.12  christos                 ND_PRINT("%s  L3 Protocol ID: %s",
   1046  1.12  christos                        indent,
   1047   1.1  christos                        tok2str(ethertype_values,
   1048   1.1  christos                                "Unknown Protocol (0x%04x)",
   1049  1.12  christos                                GET_BE_U_2(obj_tptr + 2)));
   1050  1.12  christos                 ND_PRINT("%s  Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI",
   1051  1.12  christos                        indent,
   1052  1.12  christos                        (GET_BE_U_4(obj_tptr + 4))&0x7fffff,
   1053  1.12  christos                        (GET_BE_U_4(obj_tptr + 8))&0x7fffff,
   1054  1.12  christos                        (((GET_BE_U_2(obj_tptr + 4)>>7)&3) == 0 ) ? "10" : "",
   1055  1.12  christos                        (((GET_BE_U_2(obj_tptr + 4) >> 7) & 3) == 2 ) ? "23" : "");
   1056   1.1  christos                 obj_tlen-=12;
   1057   1.1  christos                 obj_tptr+=12;
   1058   1.1  christos                 break;
   1059   1.1  christos             case RSVP_CTYPE_4:
   1060   1.1  christos                 if (obj_tlen < 4)
   1061  1.12  christos                     goto obj_tooshort;
   1062  1.12  christos                 ND_PRINT("%s  LSP Encoding Type: %s (%u)",
   1063  1.12  christos                        indent,
   1064   1.1  christos                        tok2str(gmpls_encoding_values,
   1065   1.1  christos                                "Unknown",
   1066  1.12  christos                                GET_U_1(obj_tptr)),
   1067  1.12  christos                        GET_U_1(obj_tptr));
   1068  1.12  christos                 ND_PRINT("%s  Switching Type: %s (%u), Payload ID: %s (0x%04x)",
   1069  1.12  christos                        indent,
   1070   1.1  christos                        tok2str(gmpls_switch_cap_values,
   1071   1.1  christos                                "Unknown",
   1072  1.12  christos                                GET_U_1((obj_tptr + 1))),
   1073  1.12  christos                        GET_U_1(obj_tptr + 1),
   1074   1.1  christos                        tok2str(gmpls_payload_values,
   1075   1.1  christos                                "Unknown",
   1076  1.12  christos                                GET_BE_U_2(obj_tptr + 2)),
   1077  1.12  christos                        GET_BE_U_2(obj_tptr + 2));
   1078   1.1  christos                 obj_tlen-=4;
   1079   1.1  christos                 obj_tptr+=4;
   1080   1.1  christos                 break;
   1081   1.1  christos             default:
   1082   1.1  christos                 hexdump=TRUE;
   1083   1.1  christos             }
   1084   1.1  christos             break;
   1085   1.1  christos 
   1086   1.1  christos         case RSVP_OBJ_RRO:
   1087   1.1  christos         case RSVP_OBJ_ERO:
   1088   1.1  christos             switch(rsvp_obj_ctype) {
   1089   1.1  christos             case RSVP_CTYPE_IPV4:
   1090   1.1  christos                 while(obj_tlen >= 4 ) {
   1091   1.8  christos 		    u_char length;
   1092   1.8  christos 
   1093  1.12  christos 		    ND_TCHECK_4(obj_tptr);
   1094  1.12  christos 		    length = GET_U_1(obj_tptr + 1);
   1095  1.12  christos                     ND_PRINT("%s  Subobject Type: %s, length %u",
   1096  1.12  christos                            indent,
   1097   1.1  christos                            tok2str(rsvp_obj_xro_values,
   1098   1.1  christos                                    "Unknown %u",
   1099  1.12  christos                                    RSVP_OBJ_XRO_MASK_SUBOBJ(GET_U_1(obj_tptr))),
   1100  1.12  christos                            length);
   1101  1.12  christos                     if (obj_tlen < length) {
   1102  1.12  christos                         ND_PRINT("%s  ERROR: ERO subobject length > object length", indent);
   1103  1.12  christos                         break;
   1104  1.12  christos                     }
   1105   1.1  christos 
   1106   1.8  christos                     if (length == 0) { /* prevent infinite loops */
   1107  1.12  christos                         ND_PRINT("%s  ERROR: zero length ERO subtype", indent);
   1108   1.1  christos                         break;
   1109   1.1  christos                     }
   1110   1.1  christos 
   1111  1.12  christos                     switch(RSVP_OBJ_XRO_MASK_SUBOBJ(GET_U_1(obj_tptr))) {
   1112   1.8  christos 		    u_char prefix_length;
   1113   1.8  christos 
   1114   1.1  christos                     case RSVP_OBJ_XRO_IPV4:
   1115   1.8  christos 			if (length != 8) {
   1116  1.12  christos 				ND_PRINT(" ERROR: length != 8");
   1117   1.8  christos 				goto invalid;
   1118   1.8  christos 			}
   1119  1.12  christos 			ND_TCHECK_8(obj_tptr);
   1120  1.12  christos 			prefix_length = GET_U_1(obj_tptr + 6);
   1121   1.8  christos 			if (prefix_length != 32) {
   1122  1.12  christos 				ND_PRINT(" ERROR: Prefix length %u != 32",
   1123  1.12  christos 					  prefix_length);
   1124   1.8  christos 				goto invalid;
   1125   1.8  christos 			}
   1126  1.12  christos                         ND_PRINT(", %s, %s/%u, Flags: [%s]",
   1127  1.12  christos                                RSVP_OBJ_XRO_MASK_LOOSE(GET_U_1(obj_tptr)) ? "Loose" : "Strict",
   1128  1.12  christos                                GET_IPADDR_STRING(obj_tptr+2),
   1129  1.12  christos                                GET_U_1((obj_tptr + 6)),
   1130   1.1  christos                                bittok2str(rsvp_obj_rro_flag_values,
   1131   1.1  christos                                    "none",
   1132  1.12  christos                                    GET_U_1((obj_tptr + 7)))); /* rfc3209 says that this field is rsvd. */
   1133   1.1  christos                     break;
   1134   1.1  christos                     case RSVP_OBJ_XRO_LABEL:
   1135   1.8  christos 			if (length != 8) {
   1136  1.12  christos 				ND_PRINT(" ERROR: length != 8");
   1137   1.8  christos 				goto invalid;
   1138   1.8  christos 			}
   1139  1.12  christos 			ND_TCHECK_8(obj_tptr);
   1140  1.12  christos                         ND_PRINT(", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
   1141   1.1  christos                                bittok2str(rsvp_obj_rro_label_flag_values,
   1142   1.1  christos                                    "none",
   1143  1.12  christos                                    GET_U_1((obj_tptr + 2))),
   1144  1.12  christos                                GET_U_1(obj_tptr + 2),
   1145   1.1  christos                                tok2str(rsvp_ctype_values,
   1146   1.1  christos                                        "Unknown",
   1147  1.12  christos                                        GET_U_1((obj_tptr + 3)) + (256 * RSVP_OBJ_RRO)),
   1148  1.12  christos                                GET_U_1((obj_tptr + 3)),
   1149  1.12  christos                                GET_BE_U_4(obj_tptr + 4));
   1150   1.1  christos                     }
   1151  1.12  christos                     obj_tlen-=length;
   1152  1.12  christos                     obj_tptr+=length;
   1153   1.1  christos                 }
   1154   1.1  christos                 break;
   1155   1.1  christos             default:
   1156   1.1  christos                 hexdump=TRUE;
   1157   1.1  christos             }
   1158   1.1  christos             break;
   1159   1.1  christos 
   1160   1.1  christos         case RSVP_OBJ_HELLO:
   1161   1.1  christos             switch(rsvp_obj_ctype) {
   1162   1.1  christos             case RSVP_CTYPE_1:
   1163   1.1  christos             case RSVP_CTYPE_2:
   1164   1.1  christos                 if (obj_tlen < 8)
   1165  1.12  christos                     goto obj_tooshort;
   1166  1.12  christos                 ND_PRINT("%s  Source Instance: 0x%08x, Destination Instance: 0x%08x",
   1167  1.12  christos                        indent,
   1168  1.12  christos                        GET_BE_U_4(obj_tptr),
   1169  1.12  christos                        GET_BE_U_4(obj_tptr + 4));
   1170   1.1  christos                 obj_tlen-=8;
   1171   1.1  christos                 obj_tptr+=8;
   1172   1.1  christos                 break;
   1173   1.1  christos             default:
   1174   1.1  christos                 hexdump=TRUE;
   1175   1.1  christos             }
   1176   1.1  christos             break;
   1177   1.1  christos 
   1178   1.1  christos         case RSVP_OBJ_RESTART_CAPABILITY:
   1179   1.1  christos             switch(rsvp_obj_ctype) {
   1180   1.1  christos             case RSVP_CTYPE_1:
   1181   1.1  christos                 if (obj_tlen < 8)
   1182  1.12  christos                     goto obj_tooshort;
   1183  1.12  christos                 ND_PRINT("%s  Restart  Time: %ums, Recovery Time: %ums",
   1184  1.12  christos                        indent,
   1185  1.12  christos                        GET_BE_U_4(obj_tptr),
   1186  1.12  christos                        GET_BE_U_4(obj_tptr + 4));
   1187   1.1  christos                 obj_tlen-=8;
   1188   1.1  christos                 obj_tptr+=8;
   1189   1.1  christos                 break;
   1190   1.1  christos             default:
   1191   1.1  christos                 hexdump=TRUE;
   1192   1.1  christos             }
   1193   1.1  christos             break;
   1194   1.1  christos 
   1195  1.12  christos         case RSVP_OBJ_CAPABILITY:
   1196  1.12  christos             switch(rsvp_obj_ctype) {
   1197  1.12  christos             case RSVP_CTYPE_1:
   1198  1.12  christos                 if (obj_tlen < 4)
   1199  1.12  christos                     goto obj_tooshort;
   1200  1.12  christos                 uint32_t unused_and_flags = GET_BE_U_4(obj_tptr);
   1201  1.12  christos                 if (unused_and_flags & ~RSVP_OBJ_CAPABILITY_FLAGS_MASK)
   1202  1.12  christos                     ND_PRINT("%s  [reserved=0x%08x must be zero]", indent,
   1203  1.12  christos                         unused_and_flags & ~RSVP_OBJ_CAPABILITY_FLAGS_MASK);
   1204  1.12  christos                 ND_PRINT("%s  Flags: [%s]",
   1205  1.12  christos                        indent,
   1206  1.12  christos                        bittok2str(rsvp_obj_capability_flag_values,
   1207  1.12  christos                                   "none",
   1208  1.12  christos                                   (unused_and_flags & RSVP_OBJ_CAPABILITY_FLAGS_MASK)));
   1209  1.12  christos                 obj_tlen-=4;
   1210  1.12  christos                 obj_tptr+=4;
   1211  1.12  christos                 break;
   1212  1.12  christos             default:
   1213  1.12  christos                 hexdump=TRUE;
   1214  1.12  christos             }
   1215  1.12  christos             break;
   1216  1.12  christos 
   1217   1.1  christos         case RSVP_OBJ_SESSION_ATTRIBUTE:
   1218   1.1  christos             switch(rsvp_obj_ctype) {
   1219   1.1  christos             case RSVP_CTYPE_TUNNEL_IPV4:
   1220   1.1  christos                 if (obj_tlen < 4)
   1221  1.12  christos                     goto obj_tooshort;
   1222  1.12  christos                 namelen = GET_U_1(obj_tptr + 3);
   1223   1.1  christos                 if (obj_tlen < 4+namelen)
   1224  1.12  christos                     goto obj_tooshort;
   1225  1.12  christos                 ND_PRINT("%s  Session Name: ", indent);
   1226   1.1  christos                 for (i = 0; i < namelen; i++)
   1227  1.12  christos                     fn_print_char(ndo, GET_U_1(obj_tptr + 4 + i));
   1228  1.12  christos                 ND_PRINT("%s  Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)",
   1229  1.12  christos                        indent,
   1230  1.12  christos                        GET_U_1(obj_tptr),
   1231  1.12  christos                        GET_U_1(obj_tptr + 1),
   1232   1.1  christos                        bittok2str(rsvp_session_attribute_flag_values,
   1233   1.1  christos                                   "none",
   1234  1.12  christos                                   GET_U_1((obj_tptr + 2))),
   1235  1.12  christos                        GET_U_1(obj_tptr + 2));
   1236  1.12  christos                 obj_tlen-=4+namelen;
   1237  1.12  christos                 obj_tptr+=4+namelen;
   1238   1.1  christos                 break;
   1239   1.1  christos             default:
   1240   1.1  christos                 hexdump=TRUE;
   1241   1.1  christos             }
   1242   1.1  christos             break;
   1243   1.1  christos 
   1244   1.1  christos 	case RSVP_OBJ_GENERALIZED_UNI:
   1245   1.1  christos             switch(rsvp_obj_ctype) {
   1246  1.12  christos 		u_int subobj_type,af,subobj_len,total_subobj_len;
   1247   1.1  christos 
   1248   1.6  christos             case RSVP_CTYPE_1:
   1249   1.1  christos 
   1250   1.1  christos                 if (obj_tlen < 4)
   1251  1.12  christos                     goto obj_tooshort;
   1252   1.1  christos 
   1253   1.1  christos 		/* read variable length subobjects */
   1254   1.1  christos 		total_subobj_len = obj_tlen;
   1255   1.1  christos                 while(total_subobj_len > 0) {
   1256  1.10  christos                     /* If RFC 3476 Section 3.1 defined that a sub-object of the
   1257  1.10  christos                      * GENERALIZED_UNI RSVP object must have the Length field as
   1258  1.10  christos                      * a multiple of 4, instead of the check below it would be
   1259  1.10  christos                      * better to test total_subobj_len only once before the loop.
   1260  1.10  christos                      * So long as it does not define it and this while loop does
   1261  1.10  christos                      * not implement such a requirement, let's accept that within
   1262  1.10  christos                      * each iteration subobj_len may happen to be a multiple of 1
   1263  1.10  christos                      * and test it and total_subobj_len respectively.
   1264  1.10  christos                      */
   1265  1.10  christos                     if (total_subobj_len < 4)
   1266  1.10  christos                         goto invalid;
   1267  1.12  christos                     subobj_len  = GET_BE_U_2(obj_tptr);
   1268  1.12  christos                     subobj_type = (GET_BE_U_2(obj_tptr + 2))>>8;
   1269  1.12  christos                     af = (GET_BE_U_2(obj_tptr + 2))&0x00FF;
   1270   1.1  christos 
   1271  1.12  christos                     ND_PRINT("%s  Subobject Type: %s (%u), AF: %s (%u), length: %u",
   1272  1.12  christos                            indent,
   1273   1.1  christos                            tok2str(rsvp_obj_generalized_uni_values, "Unknown", subobj_type),
   1274   1.1  christos                            subobj_type,
   1275   1.1  christos                            tok2str(af_values, "Unknown", af), af,
   1276  1.12  christos                            subobj_len);
   1277   1.1  christos 
   1278  1.10  christos                     /* In addition to what is explained above, the same spec does not
   1279  1.10  christos                      * explicitly say that the same Length field includes the 4-octet
   1280  1.10  christos                      * sub-object header, but as long as this while loop implements it
   1281  1.10  christos                      * as it does include, let's keep the check below consistent with
   1282  1.10  christos                      * the rest of the code.
   1283  1.12  christos                      *
   1284  1.12  christos                      * XXX - RFC 3476 Section 3.1 says "The contents of these
   1285  1.12  christos                      * sub-objects are described in [8]", where [8] is
   1286  1.12  christos                      * UNI 1.0 Signaling Specification, The Optical
   1287  1.12  christos                      * Internetworking Forum.  The URL they give for that
   1288  1.12  christos                      * document is
   1289  1.12  christos                      *
   1290  1.12  christos                      *    http://www.oiforum.com/public/UNI_1.0_ia.html
   1291  1.12  christos                      *
   1292  1.12  christos                      * but that doesn't work; the new URL appears to be
   1293  1.12  christos                      *
   1294  1.12  christos                      *    https://web.archive.org/web/20160401194747/http://www.oiforum.com/public/documents/OIF-UNI-01.0.pdf
   1295  1.12  christos                      *
   1296  1.12  christos                      * and *that* document, in section 12.5.2.3
   1297  1.12  christos                      * "GENERALIZED_UNI Object (Class-Num=11bbbbbb (TBA))",
   1298  1.12  christos                      * says nothing about the length field in general, but
   1299  1.12  christos                      * some of the examples it gives in subsections have
   1300  1.12  christos                      * length field values that clearly includes the length
   1301  1.12  christos                      * of the sub-object header as well as the length of the
   1302  1.12  christos                      * value.
   1303  1.10  christos                      */
   1304  1.12  christos                     if(subobj_len < 4 || subobj_len > total_subobj_len ||
   1305  1.12  christos                        obj_tlen < subobj_len)
   1306   1.8  christos                         goto invalid;
   1307   1.8  christos 
   1308   1.1  christos                     switch(subobj_type) {
   1309   1.1  christos                     case RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS:
   1310   1.1  christos                     case RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS:
   1311   1.1  christos 
   1312   1.1  christos                         switch(af) {
   1313   1.1  christos                         case AFNUM_INET:
   1314   1.1  christos                             if (subobj_len < 8)
   1315  1.12  christos                                 goto subobj_tooshort;
   1316  1.12  christos                             ND_PRINT("%s    UNI IPv4 TNA address: %s",
   1317  1.12  christos                                    indent, GET_IPADDR_STRING(obj_tptr + 4));
   1318   1.1  christos                             break;
   1319   1.1  christos                         case AFNUM_INET6:
   1320   1.1  christos                             if (subobj_len < 20)
   1321  1.12  christos                                 goto subobj_tooshort;
   1322  1.12  christos                             ND_PRINT("%s    UNI IPv6 TNA address: %s",
   1323  1.12  christos                                    indent, GET_IP6ADDR_STRING(obj_tptr + 4));
   1324   1.1  christos                             break;
   1325   1.1  christos                         case AFNUM_NSAP:
   1326   1.1  christos                             if (subobj_len) {
   1327   1.1  christos                                 /* unless we have a TLV parser lets just hexdump */
   1328   1.1  christos                                 hexdump=TRUE;
   1329   1.1  christos                             }
   1330   1.1  christos                             break;
   1331   1.1  christos                         }
   1332   1.1  christos                         break;
   1333   1.1  christos 
   1334   1.1  christos                     case RSVP_GEN_UNI_SUBOBJ_DIVERSITY:
   1335  1.12  christos                         if (subobj_len > 4) {
   1336   1.1  christos                             /* unless we have a TLV parser lets just hexdump */
   1337   1.1  christos                             hexdump=TRUE;
   1338   1.1  christos                         }
   1339   1.1  christos                         break;
   1340   1.1  christos 
   1341   1.1  christos                     case RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL:
   1342   1.1  christos                         if (subobj_len < 16) {
   1343  1.12  christos                             goto subobj_tooshort;
   1344   1.1  christos                         }
   1345   1.1  christos 
   1346  1.12  christos                         ND_PRINT("%s    U-bit: %x, Label type: %u, Logical port id: %u, Label: %u",
   1347  1.12  christos                                indent,
   1348  1.12  christos                                ((GET_BE_U_4(obj_tptr + 4))>>31),
   1349  1.12  christos                                ((GET_BE_U_4(obj_tptr + 4))&0xFF),
   1350  1.12  christos                                GET_BE_U_4(obj_tptr + 8),
   1351  1.12  christos                                GET_BE_U_4(obj_tptr + 12));
   1352   1.1  christos                         break;
   1353   1.1  christos 
   1354   1.1  christos                     case RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL:
   1355   1.1  christos                         if (subobj_len < 8) {
   1356  1.12  christos                             goto subobj_tooshort;
   1357   1.1  christos                         }
   1358   1.1  christos 
   1359  1.12  christos                         ND_PRINT("%s    Service level: %u",
   1360  1.12  christos                                indent, (GET_BE_U_4(obj_tptr + 4)) >> 24);
   1361   1.1  christos                         break;
   1362   1.1  christos 
   1363   1.1  christos                     default:
   1364   1.1  christos                         hexdump=TRUE;
   1365   1.1  christos                         break;
   1366   1.1  christos                     }
   1367   1.1  christos                     total_subobj_len-=subobj_len;
   1368   1.1  christos                     obj_tptr+=subobj_len;
   1369   1.1  christos                     obj_tlen+=subobj_len;
   1370   1.1  christos 		}
   1371   1.1  christos                 break;
   1372   1.1  christos 
   1373   1.1  christos             default:
   1374   1.1  christos                 hexdump=TRUE;
   1375   1.1  christos             }
   1376   1.1  christos             break;
   1377   1.1  christos 
   1378   1.1  christos         case RSVP_OBJ_RSVP_HOP:
   1379   1.1  christos             switch(rsvp_obj_ctype) {
   1380   1.1  christos             case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */
   1381   1.1  christos             case RSVP_CTYPE_IPV4:
   1382   1.1  christos                 if (obj_tlen < 8)
   1383  1.12  christos                     goto obj_tooshort;
   1384  1.12  christos                 ND_PRINT("%s  Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
   1385  1.12  christos                        indent,
   1386  1.12  christos                        GET_IPADDR_STRING(obj_tptr),
   1387  1.12  christos                        GET_BE_U_4(obj_tptr + 4));
   1388   1.1  christos                 obj_tlen-=8;
   1389   1.1  christos                 obj_tptr+=8;
   1390   1.1  christos                 if (obj_tlen)
   1391   1.1  christos                     hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
   1392   1.1  christos                 break;
   1393   1.1  christos             case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */
   1394   1.1  christos             case RSVP_CTYPE_IPV6:
   1395   1.1  christos                 if (obj_tlen < 20)
   1396  1.12  christos                     goto obj_tooshort;
   1397  1.12  christos                 ND_PRINT("%s  Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
   1398  1.12  christos                        indent,
   1399  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr),
   1400  1.12  christos                        GET_BE_U_4(obj_tptr + 16));
   1401   1.1  christos                 obj_tlen-=20;
   1402   1.1  christos                 obj_tptr+=20;
   1403   1.1  christos                 hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
   1404   1.1  christos                 break;
   1405   1.1  christos             default:
   1406   1.1  christos                 hexdump=TRUE;
   1407   1.1  christos             }
   1408   1.1  christos             break;
   1409   1.1  christos 
   1410   1.1  christos         case RSVP_OBJ_TIME_VALUES:
   1411   1.1  christos             switch(rsvp_obj_ctype) {
   1412   1.1  christos             case RSVP_CTYPE_1:
   1413   1.1  christos                 if (obj_tlen < 4)
   1414  1.12  christos                     goto obj_tooshort;
   1415  1.12  christos                 ND_PRINT("%s  Refresh Period: %ums",
   1416  1.12  christos                        indent,
   1417  1.12  christos                        GET_BE_U_4(obj_tptr));
   1418   1.1  christos                 obj_tlen-=4;
   1419   1.1  christos                 obj_tptr+=4;
   1420   1.1  christos                 break;
   1421   1.1  christos             default:
   1422   1.1  christos                 hexdump=TRUE;
   1423   1.1  christos             }
   1424   1.1  christos             break;
   1425   1.1  christos 
   1426   1.1  christos         /* those three objects do share the same semantics */
   1427   1.1  christos         case RSVP_OBJ_SENDER_TSPEC:
   1428   1.1  christos         case RSVP_OBJ_ADSPEC:
   1429   1.1  christos         case RSVP_OBJ_FLOWSPEC:
   1430   1.1  christos             switch(rsvp_obj_ctype) {
   1431   1.1  christos             case RSVP_CTYPE_2:
   1432   1.1  christos                 if (obj_tlen < 4)
   1433  1.12  christos                     goto obj_tooshort;
   1434  1.12  christos                 ND_PRINT("%s  Msg-Version: %u, length: %u",
   1435  1.12  christos                        indent,
   1436  1.12  christos                        (GET_U_1(obj_tptr) & 0xf0) >> 4,
   1437  1.12  christos                        GET_BE_U_2(obj_tptr + 2) << 2);
   1438   1.1  christos                 obj_tptr+=4; /* get to the start of the service header */
   1439   1.1  christos                 obj_tlen-=4;
   1440   1.1  christos 
   1441   1.1  christos                 while (obj_tlen >= 4) {
   1442  1.12  christos                     intserv_serv_tlen=GET_BE_U_2(obj_tptr + 2)<<2;
   1443  1.12  christos                     ND_PRINT("%s  Service Type: %s (%u), break bit %sset, Service length: %u",
   1444  1.12  christos                            indent,
   1445  1.12  christos                            tok2str(rsvp_intserv_service_type_values,"unknown",GET_U_1((obj_tptr))),
   1446  1.12  christos                            GET_U_1(obj_tptr),
   1447  1.12  christos                            (GET_U_1(obj_tptr + 1)&0x80) ? "" : "not ",
   1448  1.12  christos                            intserv_serv_tlen);
   1449   1.6  christos 
   1450   1.1  christos                     obj_tptr+=4; /* get to the start of the parameter list */
   1451   1.1  christos                     obj_tlen-=4;
   1452   1.1  christos 
   1453   1.1  christos                     while (intserv_serv_tlen>=4) {
   1454   1.6  christos                         processed = rsvp_intserv_print(ndo, obj_tptr, obj_tlen);
   1455   1.1  christos                         if (processed == 0)
   1456   1.1  christos                             break;
   1457   1.1  christos                         obj_tlen-=processed;
   1458   1.1  christos                         intserv_serv_tlen-=processed;
   1459   1.1  christos                         obj_tptr+=processed;
   1460   1.1  christos                     }
   1461   1.1  christos                 }
   1462   1.1  christos                 break;
   1463   1.1  christos             default:
   1464   1.1  christos                 hexdump=TRUE;
   1465   1.1  christos             }
   1466   1.1  christos             break;
   1467   1.1  christos 
   1468   1.1  christos         case RSVP_OBJ_FILTERSPEC:
   1469   1.1  christos             switch(rsvp_obj_ctype) {
   1470   1.1  christos             case RSVP_CTYPE_IPV4:
   1471   1.1  christos                 if (obj_tlen < 8)
   1472  1.12  christos                     goto obj_tooshort;
   1473  1.12  christos                 ND_PRINT("%s  Source Address: %s, Source Port: %u",
   1474  1.12  christos                        indent,
   1475  1.12  christos                        GET_IPADDR_STRING(obj_tptr),
   1476  1.12  christos                        GET_BE_U_2(obj_tptr + 6));
   1477   1.1  christos                 obj_tlen-=8;
   1478   1.1  christos                 obj_tptr+=8;
   1479   1.1  christos                 break;
   1480   1.1  christos             case RSVP_CTYPE_IPV6:
   1481   1.1  christos                 if (obj_tlen < 20)
   1482  1.12  christos                     goto obj_tooshort;
   1483  1.12  christos                 ND_PRINT("%s  Source Address: %s, Source Port: %u",
   1484  1.12  christos                        indent,
   1485  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr),
   1486  1.12  christos                        GET_BE_U_2(obj_tptr + 18));
   1487   1.1  christos                 obj_tlen-=20;
   1488   1.1  christos                 obj_tptr+=20;
   1489   1.1  christos                 break;
   1490   1.1  christos             case RSVP_CTYPE_3:
   1491   1.1  christos                 if (obj_tlen < 20)
   1492  1.12  christos                     goto obj_tooshort;
   1493  1.12  christos                 ND_PRINT("%s  Source Address: %s, Flow Label: %u",
   1494  1.12  christos                        indent,
   1495  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr),
   1496  1.12  christos                        GET_BE_U_3(obj_tptr + 17));
   1497   1.1  christos                 obj_tlen-=20;
   1498   1.1  christos                 obj_tptr+=20;
   1499   1.1  christos                 break;
   1500   1.1  christos             case RSVP_CTYPE_TUNNEL_IPV6:
   1501   1.1  christos                 if (obj_tlen < 20)
   1502  1.12  christos                     goto obj_tooshort;
   1503  1.12  christos                 ND_PRINT("%s  Source Address: %s, LSP-ID: 0x%04x",
   1504  1.12  christos                        indent,
   1505  1.12  christos                        GET_IPADDR_STRING(obj_tptr),
   1506  1.12  christos                        GET_BE_U_2(obj_tptr + 18));
   1507   1.1  christos                 obj_tlen-=20;
   1508   1.1  christos                 obj_tptr+=20;
   1509   1.1  christos                 break;
   1510   1.1  christos             case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */
   1511   1.1  christos                 if (obj_tlen < 40)
   1512  1.12  christos                     goto obj_tooshort;
   1513  1.12  christos                 ND_PRINT("%s  IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
   1514   1.1  christos                        "%s  Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
   1515  1.12  christos                        indent,
   1516  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr),
   1517  1.12  christos                        GET_BE_U_2(obj_tptr + 18),
   1518  1.12  christos                        indent,
   1519  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr+20),
   1520  1.12  christos                        GET_BE_U_2(obj_tptr + 38));
   1521   1.1  christos                 obj_tlen-=40;
   1522   1.1  christos                 obj_tptr+=40;
   1523   1.1  christos                 break;
   1524   1.1  christos             case RSVP_CTYPE_TUNNEL_IPV4:
   1525   1.1  christos                 if (obj_tlen < 8)
   1526  1.12  christos                     goto obj_tooshort;
   1527  1.12  christos                 ND_PRINT("%s  Source Address: %s, LSP-ID: 0x%04x",
   1528  1.12  christos                        indent,
   1529  1.12  christos                        GET_IPADDR_STRING(obj_tptr),
   1530  1.12  christos                        GET_BE_U_2(obj_tptr + 6));
   1531   1.1  christos                 obj_tlen-=8;
   1532   1.1  christos                 obj_tptr+=8;
   1533   1.1  christos                 break;
   1534   1.1  christos             case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */
   1535   1.1  christos                 if (obj_tlen < 16)
   1536  1.12  christos                     goto obj_tooshort;
   1537  1.12  christos                 ND_PRINT("%s  IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
   1538   1.1  christos                        "%s  Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
   1539  1.12  christos                        indent,
   1540  1.12  christos                        GET_IPADDR_STRING(obj_tptr),
   1541  1.12  christos                        GET_BE_U_2(obj_tptr + 6),
   1542  1.12  christos                        indent,
   1543  1.12  christos                        GET_IPADDR_STRING(obj_tptr+8),
   1544  1.12  christos                        GET_BE_U_2(obj_tptr + 12));
   1545   1.1  christos                 obj_tlen-=16;
   1546   1.1  christos                 obj_tptr+=16;
   1547   1.1  christos                 break;
   1548   1.1  christos             default:
   1549   1.1  christos                 hexdump=TRUE;
   1550   1.1  christos             }
   1551   1.1  christos             break;
   1552   1.1  christos 
   1553   1.1  christos         case RSVP_OBJ_FASTREROUTE:
   1554   1.1  christos             /* the differences between c-type 1 and 7 are minor */
   1555   1.1  christos             obj_ptr.rsvp_obj_frr = (const struct rsvp_obj_frr_t *)obj_tptr;
   1556   1.1  christos 
   1557   1.1  christos             switch(rsvp_obj_ctype) {
   1558   1.1  christos             case RSVP_CTYPE_1: /* new style */
   1559   1.1  christos                 if (obj_tlen < sizeof(struct rsvp_obj_frr_t))
   1560  1.12  christos                     goto obj_tooshort;
   1561  1.12  christos                 bw.i = GET_BE_U_4(obj_ptr.rsvp_obj_frr->bandwidth);
   1562  1.12  christos                 ND_PRINT("%s  Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
   1563  1.12  christos                        indent,
   1564  1.12  christos                        obj_ptr.rsvp_obj_frr->setup_prio,
   1565  1.12  christos                        obj_ptr.rsvp_obj_frr->hold_prio,
   1566  1.12  christos                        obj_ptr.rsvp_obj_frr->hop_limit,
   1567  1.12  christos                        bw.f * 8 / 1000000);
   1568  1.12  christos                 ND_PRINT("%s  Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x",
   1569  1.12  christos                        indent,
   1570  1.12  christos                        GET_BE_U_4(obj_ptr.rsvp_obj_frr->include_any),
   1571  1.12  christos                        GET_BE_U_4(obj_ptr.rsvp_obj_frr->exclude_any),
   1572  1.12  christos                        GET_BE_U_4(obj_ptr.rsvp_obj_frr->include_all));
   1573   1.1  christos                 obj_tlen-=sizeof(struct rsvp_obj_frr_t);
   1574   1.1  christos                 obj_tptr+=sizeof(struct rsvp_obj_frr_t);
   1575   1.1  christos                 break;
   1576   1.1  christos 
   1577   1.1  christos             case RSVP_CTYPE_TUNNEL_IPV4: /* old style */
   1578   1.1  christos                 if (obj_tlen < 16)
   1579  1.12  christos                     goto obj_tooshort;
   1580  1.12  christos                 bw.i = GET_BE_U_4(obj_ptr.rsvp_obj_frr->bandwidth);
   1581  1.12  christos                 ND_PRINT("%s  Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
   1582  1.12  christos                        indent,
   1583  1.12  christos                        obj_ptr.rsvp_obj_frr->setup_prio,
   1584  1.12  christos                        obj_ptr.rsvp_obj_frr->hold_prio,
   1585  1.12  christos                        obj_ptr.rsvp_obj_frr->hop_limit,
   1586  1.12  christos                        bw.f * 8 / 1000000);
   1587  1.12  christos                 ND_PRINT("%s  Include Colors: 0x%08x, Exclude Colors: 0x%08x",
   1588  1.12  christos                        indent,
   1589  1.12  christos                        GET_BE_U_4(obj_ptr.rsvp_obj_frr->include_any),
   1590  1.12  christos                        GET_BE_U_4(obj_ptr.rsvp_obj_frr->exclude_any));
   1591   1.1  christos                 obj_tlen-=16;
   1592   1.1  christos                 obj_tptr+=16;
   1593   1.1  christos                 break;
   1594   1.1  christos 
   1595   1.1  christos             default:
   1596   1.1  christos                 hexdump=TRUE;
   1597   1.1  christos             }
   1598   1.1  christos             break;
   1599   1.1  christos 
   1600   1.1  christos         case RSVP_OBJ_DETOUR:
   1601   1.1  christos             switch(rsvp_obj_ctype) {
   1602   1.1  christos             case RSVP_CTYPE_TUNNEL_IPV4:
   1603   1.1  christos                 while(obj_tlen >= 8) {
   1604  1.12  christos                     ND_PRINT("%s  PLR-ID: %s, Avoid-Node-ID: %s",
   1605  1.12  christos                            indent,
   1606  1.12  christos                            GET_IPADDR_STRING(obj_tptr),
   1607  1.12  christos                            GET_IPADDR_STRING(obj_tptr + 4));
   1608   1.1  christos                     obj_tlen-=8;
   1609   1.1  christos                     obj_tptr+=8;
   1610   1.1  christos                 }
   1611   1.1  christos                 break;
   1612   1.1  christos             default:
   1613   1.1  christos                 hexdump=TRUE;
   1614   1.1  christos             }
   1615   1.1  christos             break;
   1616   1.1  christos 
   1617   1.1  christos         case RSVP_OBJ_CLASSTYPE:
   1618   1.1  christos         case RSVP_OBJ_CLASSTYPE_OLD: /* fall through */
   1619   1.1  christos             switch(rsvp_obj_ctype) {
   1620   1.1  christos             case RSVP_CTYPE_1:
   1621  1.12  christos                 if (obj_tlen < 4)
   1622  1.12  christos                     goto obj_tooshort;
   1623  1.12  christos                 ND_PRINT("%s  CT: %u",
   1624  1.12  christos                        indent,
   1625  1.12  christos                        GET_BE_U_4(obj_tptr) & 0x7);
   1626   1.1  christos                 obj_tlen-=4;
   1627   1.1  christos                 obj_tptr+=4;
   1628   1.1  christos                 break;
   1629   1.1  christos             default:
   1630   1.1  christos                 hexdump=TRUE;
   1631   1.1  christos             }
   1632   1.1  christos             break;
   1633   1.1  christos 
   1634   1.1  christos         case RSVP_OBJ_ERROR_SPEC:
   1635   1.1  christos             switch(rsvp_obj_ctype) {
   1636   1.1  christos             case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */
   1637   1.1  christos             case RSVP_CTYPE_IPV4:
   1638   1.1  christos                 if (obj_tlen < 8)
   1639  1.12  christos                     goto obj_tooshort;
   1640  1.12  christos                 error_code=GET_U_1(obj_tptr + 5);
   1641  1.12  christos                 error_value=GET_BE_U_2(obj_tptr + 6);
   1642  1.12  christos                 ND_PRINT("%s  Error Node Address: %s, Flags: [0x%02x]%s  Error Code: %s (%u)",
   1643  1.12  christos                        indent,
   1644  1.12  christos                        GET_IPADDR_STRING(obj_tptr),
   1645  1.12  christos                        GET_U_1(obj_tptr + 4),
   1646  1.12  christos                        indent,
   1647   1.1  christos                        tok2str(rsvp_obj_error_code_values,"unknown",error_code),
   1648  1.12  christos                        error_code);
   1649   1.1  christos                 switch (error_code) {
   1650   1.1  christos                 case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
   1651  1.12  christos                     ND_PRINT(", Error Value: %s (%u)",
   1652   1.1  christos                            tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
   1653  1.12  christos                            error_value);
   1654   1.1  christos                     break;
   1655   1.1  christos                 case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE: /* fall through */
   1656   1.1  christos                 case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD:
   1657  1.12  christos                     ND_PRINT(", Error Value: %s (%u)",
   1658   1.1  christos                            tok2str(rsvp_obj_error_code_diffserv_te_values,"unknown",error_value),
   1659  1.12  christos                            error_value);
   1660   1.1  christos                     break;
   1661   1.1  christos                 default:
   1662  1.12  christos                     ND_PRINT(", Unknown Error Value (%u)", error_value);
   1663   1.1  christos                     break;
   1664   1.1  christos                 }
   1665   1.1  christos                 obj_tlen-=8;
   1666   1.1  christos                 obj_tptr+=8;
   1667   1.1  christos                 break;
   1668   1.1  christos             case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */
   1669   1.1  christos             case RSVP_CTYPE_IPV6:
   1670   1.1  christos                 if (obj_tlen < 20)
   1671  1.12  christos                     goto obj_tooshort;
   1672  1.12  christos                 error_code=GET_U_1(obj_tptr + 17);
   1673  1.12  christos                 error_value=GET_BE_U_2(obj_tptr + 18);
   1674  1.12  christos                 ND_PRINT("%s  Error Node Address: %s, Flags: [0x%02x]%s  Error Code: %s (%u)",
   1675  1.12  christos                        indent,
   1676  1.12  christos                        GET_IP6ADDR_STRING(obj_tptr),
   1677  1.12  christos                        GET_U_1(obj_tptr + 16),
   1678  1.12  christos                        indent,
   1679   1.1  christos                        tok2str(rsvp_obj_error_code_values,"unknown",error_code),
   1680  1.12  christos                        error_code);
   1681   1.1  christos 
   1682   1.1  christos                 switch (error_code) {
   1683   1.1  christos                 case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
   1684  1.12  christos                     ND_PRINT(", Error Value: %s (%u)",
   1685   1.1  christos                            tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
   1686  1.12  christos 			   error_value);
   1687   1.1  christos                     break;
   1688   1.1  christos                 default:
   1689   1.1  christos                     break;
   1690   1.1  christos                 }
   1691   1.1  christos                 obj_tlen-=20;
   1692   1.1  christos                 obj_tptr+=20;
   1693   1.1  christos                 break;
   1694   1.1  christos             default:
   1695   1.1  christos                 hexdump=TRUE;
   1696   1.1  christos             }
   1697   1.1  christos             break;
   1698   1.1  christos 
   1699   1.1  christos         case RSVP_OBJ_PROPERTIES:
   1700   1.1  christos             switch(rsvp_obj_ctype) {
   1701   1.1  christos             case RSVP_CTYPE_1:
   1702   1.1  christos                 if (obj_tlen < 4)
   1703  1.12  christos                     goto obj_tooshort;
   1704  1.12  christos                 padbytes = GET_BE_U_2(obj_tptr + 2);
   1705  1.12  christos                 ND_PRINT("%s  TLV count: %u, padding bytes: %u",
   1706  1.12  christos                        indent,
   1707  1.12  christos                        GET_BE_U_2(obj_tptr),
   1708  1.12  christos                        padbytes);
   1709   1.1  christos                 obj_tlen-=4;
   1710   1.1  christos                 obj_tptr+=4;
   1711   1.1  christos                 /* loop through as long there is anything longer than the TLV header (2) */
   1712   1.1  christos                 while(obj_tlen >= 2 + padbytes) {
   1713  1.12  christos                     ND_PRINT("%s    %s TLV (0x%02x), length: %u", /* length includes header */
   1714  1.12  christos                            indent,
   1715  1.12  christos                            tok2str(rsvp_obj_prop_tlv_values,"unknown",GET_U_1(obj_tptr)),
   1716  1.12  christos                            GET_U_1(obj_tptr),
   1717  1.12  christos                            GET_U_1(obj_tptr + 1));
   1718  1.12  christos                     if (obj_tlen < GET_U_1(obj_tptr + 1))
   1719  1.12  christos                         goto obj_tooshort;
   1720  1.12  christos                     if (GET_U_1(obj_tptr + 1) < 2) {
   1721  1.12  christos                         ND_PRINT("%sERROR: property TLV is too short", indent);
   1722   1.1  christos                         return -1;
   1723  1.12  christos                     }
   1724  1.12  christos                     print_unknown_data(ndo, obj_tptr + 2, "\n\t\t",
   1725  1.12  christos                                        GET_U_1(obj_tptr + 1) - 2);
   1726  1.12  christos                     obj_tlen-=GET_U_1(obj_tptr + 1);
   1727  1.12  christos                     obj_tptr+=GET_U_1(obj_tptr + 1);
   1728   1.1  christos                 }
   1729   1.1  christos                 break;
   1730   1.1  christos             default:
   1731   1.1  christos                 hexdump=TRUE;
   1732   1.1  christos             }
   1733   1.1  christos             break;
   1734   1.1  christos 
   1735   1.1  christos         case RSVP_OBJ_MESSAGE_ID:     /* fall through */
   1736   1.1  christos         case RSVP_OBJ_MESSAGE_ID_ACK: /* fall through */
   1737   1.1  christos         case RSVP_OBJ_MESSAGE_ID_LIST:
   1738   1.1  christos             switch(rsvp_obj_ctype) {
   1739   1.1  christos             case RSVP_CTYPE_1:
   1740   1.1  christos             case RSVP_CTYPE_2:
   1741  1.12  christos                 if (obj_tlen < 4)
   1742  1.12  christos                     goto obj_tooshort;
   1743  1.12  christos                 ND_PRINT("%s  Flags [0x%02x], epoch: %u",
   1744  1.12  christos                        indent,
   1745  1.12  christos                        GET_U_1(obj_tptr),
   1746  1.12  christos                        GET_BE_U_3(obj_tptr + 1));
   1747   1.1  christos                 obj_tlen-=4;
   1748   1.1  christos                 obj_tptr+=4;
   1749   1.1  christos                 /* loop through as long there are no messages left */
   1750   1.1  christos                 while(obj_tlen >= 4) {
   1751  1.12  christos                     ND_PRINT("%s    Message-ID 0x%08x (%u)",
   1752  1.12  christos                            indent,
   1753  1.12  christos                            GET_BE_U_4(obj_tptr),
   1754  1.12  christos                            GET_BE_U_4(obj_tptr));
   1755   1.1  christos                     obj_tlen-=4;
   1756   1.1  christos                     obj_tptr+=4;
   1757   1.1  christos                 }
   1758   1.1  christos                 break;
   1759   1.1  christos             default:
   1760   1.1  christos                 hexdump=TRUE;
   1761   1.1  christos             }
   1762   1.1  christos             break;
   1763   1.1  christos 
   1764   1.1  christos         case RSVP_OBJ_INTEGRITY:
   1765   1.1  christos             switch(rsvp_obj_ctype) {
   1766   1.1  christos             case RSVP_CTYPE_1:
   1767   1.1  christos                 if (obj_tlen < sizeof(struct rsvp_obj_integrity_t))
   1768  1.12  christos                     goto obj_tooshort;
   1769   1.1  christos                 obj_ptr.rsvp_obj_integrity = (const struct rsvp_obj_integrity_t *)obj_tptr;
   1770  1.12  christos                 ND_PRINT("%s  Key-ID 0x%04x%08x, Sequence 0x%08x%08x, Flags [%s]",
   1771  1.12  christos                        indent,
   1772  1.12  christos                        GET_BE_U_2(obj_ptr.rsvp_obj_integrity->key_id),
   1773  1.12  christos                        GET_BE_U_4(obj_ptr.rsvp_obj_integrity->key_id + 2),
   1774  1.12  christos                        GET_BE_U_4(obj_ptr.rsvp_obj_integrity->sequence),
   1775  1.12  christos                        GET_BE_U_4(obj_ptr.rsvp_obj_integrity->sequence + 4),
   1776   1.1  christos                        bittok2str(rsvp_obj_integrity_flag_values,
   1777   1.1  christos                                   "none",
   1778  1.12  christos                                   obj_ptr.rsvp_obj_integrity->flags));
   1779  1.12  christos                 ND_PRINT("%s  MD5-sum 0x%08x%08x%08x%08x ",
   1780  1.12  christos                        indent,
   1781  1.12  christos                        GET_BE_U_4(obj_ptr.rsvp_obj_integrity->digest),
   1782  1.12  christos                        GET_BE_U_4(obj_ptr.rsvp_obj_integrity->digest + 4),
   1783  1.12  christos                        GET_BE_U_4(obj_ptr.rsvp_obj_integrity->digest + 8),
   1784  1.12  christos                        GET_BE_U_4(obj_ptr.rsvp_obj_integrity->digest + 12));
   1785   1.1  christos 
   1786   1.8  christos                 sigcheck = signature_verify(ndo, pptr, plen,
   1787   1.8  christos                                             obj_ptr.rsvp_obj_integrity->digest,
   1788   1.8  christos                                             rsvp_clear_checksum,
   1789   1.8  christos                                             rsvp_com_header);
   1790  1.12  christos                 ND_PRINT(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck));
   1791   1.1  christos 
   1792   1.1  christos                 obj_tlen+=sizeof(struct rsvp_obj_integrity_t);
   1793   1.1  christos                 obj_tptr+=sizeof(struct rsvp_obj_integrity_t);
   1794   1.1  christos                 break;
   1795   1.1  christos             default:
   1796   1.1  christos                 hexdump=TRUE;
   1797   1.1  christos             }
   1798   1.6  christos             break;
   1799   1.1  christos 
   1800   1.1  christos         case RSVP_OBJ_ADMIN_STATUS:
   1801   1.1  christos             switch(rsvp_obj_ctype) {
   1802   1.6  christos             case RSVP_CTYPE_1:
   1803   1.1  christos                 if (obj_tlen < 4)
   1804  1.12  christos                     goto obj_tooshort;
   1805  1.12  christos                 ND_PRINT("%s  Flags [%s]", indent,
   1806   1.1  christos                        bittok2str(rsvp_obj_admin_status_flag_values, "none",
   1807  1.12  christos                                   GET_BE_U_4(obj_tptr)));
   1808   1.1  christos                 obj_tlen-=4;
   1809   1.1  christos                 obj_tptr+=4;
   1810   1.1  christos                 break;
   1811   1.1  christos             default:
   1812   1.1  christos                 hexdump=TRUE;
   1813   1.1  christos             }
   1814   1.1  christos             break;
   1815   1.1  christos 
   1816   1.1  christos         case RSVP_OBJ_LABEL_SET:
   1817   1.1  christos             switch(rsvp_obj_ctype) {
   1818   1.6  christos             case RSVP_CTYPE_1:
   1819   1.1  christos                 if (obj_tlen < 4)
   1820  1.12  christos                     goto obj_tooshort;
   1821  1.12  christos                 action = (GET_BE_U_2(obj_tptr)>>8);
   1822   1.1  christos 
   1823  1.12  christos                 ND_PRINT("%s  Action: %s (%u), Label type: %u", indent,
   1824   1.1  christos                        tok2str(rsvp_obj_label_set_action_values, "Unknown", action),
   1825  1.12  christos                        action, (GET_BE_U_4(obj_tptr) & 0x7F));
   1826   1.1  christos 
   1827   1.1  christos                 switch (action) {
   1828   1.1  christos                 case LABEL_SET_INCLUSIVE_RANGE:
   1829   1.1  christos                 case LABEL_SET_EXCLUSIVE_RANGE: /* fall through */
   1830   1.1  christos 
   1831   1.1  christos 		    /* only a couple of subchannels are expected */
   1832   1.1  christos 		    if (obj_tlen < 12)
   1833  1.12  christos 			goto obj_tooshort;
   1834  1.12  christos 		    ND_PRINT("%s  Start range: %u, End range: %u", indent,
   1835  1.12  christos                            GET_BE_U_4(obj_tptr + 4),
   1836  1.12  christos                            GET_BE_U_4(obj_tptr + 8));
   1837   1.1  christos 		    obj_tlen-=12;
   1838   1.1  christos 		    obj_tptr+=12;
   1839   1.1  christos                     break;
   1840   1.1  christos 
   1841   1.1  christos                 default:
   1842   1.1  christos                     obj_tlen-=4;
   1843   1.1  christos                     obj_tptr+=4;
   1844   1.1  christos                     subchannel = 1;
   1845   1.1  christos                     while(obj_tlen >= 4 ) {
   1846  1.12  christos                         ND_PRINT("%s  Subchannel #%u: %u", indent, subchannel,
   1847  1.12  christos                                GET_BE_U_4(obj_tptr));
   1848   1.1  christos                         obj_tptr+=4;
   1849   1.1  christos                         obj_tlen-=4;
   1850   1.1  christos                         subchannel++;
   1851   1.1  christos                     }
   1852   1.1  christos                     break;
   1853   1.1  christos                 }
   1854   1.1  christos                 break;
   1855   1.1  christos             default:
   1856   1.1  christos                 hexdump=TRUE;
   1857   1.1  christos             }
   1858  1.12  christos             break;
   1859   1.1  christos 
   1860   1.1  christos         case RSVP_OBJ_S2L:
   1861   1.1  christos             switch (rsvp_obj_ctype) {
   1862   1.6  christos             case RSVP_CTYPE_IPV4:
   1863   1.1  christos                 if (obj_tlen < 4)
   1864  1.12  christos                     goto obj_tooshort;
   1865  1.12  christos                 ND_PRINT("%s  Sub-LSP destination address: %s",
   1866  1.12  christos                        indent, GET_IPADDR_STRING(obj_tptr));
   1867   1.1  christos 
   1868   1.1  christos                 obj_tlen-=4;
   1869   1.1  christos                 obj_tptr+=4;
   1870   1.1  christos                 break;
   1871   1.6  christos             case RSVP_CTYPE_IPV6:
   1872   1.1  christos                 if (obj_tlen < 16)
   1873  1.12  christos                     goto obj_tooshort;
   1874  1.12  christos                 ND_PRINT("%s  Sub-LSP destination address: %s",
   1875  1.12  christos                        indent, GET_IP6ADDR_STRING(obj_tptr));
   1876   1.1  christos 
   1877   1.1  christos                 obj_tlen-=16;
   1878   1.1  christos                 obj_tptr+=16;
   1879   1.1  christos                 break;
   1880   1.1  christos             default:
   1881   1.1  christos                 hexdump=TRUE;
   1882   1.1  christos             }
   1883  1.12  christos             break;
   1884   1.1  christos 
   1885   1.1  christos         /*
   1886   1.1  christos          *  FIXME those are the defined objects that lack a decoder
   1887   1.1  christos          *  you are welcome to contribute code ;-)
   1888   1.1  christos          */
   1889   1.1  christos 
   1890   1.1  christos         case RSVP_OBJ_SCOPE:
   1891   1.1  christos         case RSVP_OBJ_POLICY_DATA:
   1892   1.1  christos         case RSVP_OBJ_ACCEPT_LABEL_SET:
   1893   1.1  christos         case RSVP_OBJ_PROTECTION:
   1894   1.1  christos         default:
   1895   1.6  christos             if (ndo->ndo_vflag <= 1)
   1896   1.6  christos                 print_unknown_data(ndo, obj_tptr, "\n\t    ", obj_tlen); /* FIXME indentation */
   1897   1.1  christos             break;
   1898   1.1  christos         }
   1899   1.1  christos         /* do we also want to see a hex dump ? */
   1900   1.6  christos         if (ndo->ndo_vflag > 1 || hexdump == TRUE)
   1901   1.6  christos             print_unknown_data(ndo, tptr + sizeof(struct rsvp_object_header), "\n\t    ", /* FIXME indentation */
   1902   1.6  christos                                rsvp_obj_len - sizeof(struct rsvp_object_header));
   1903   1.1  christos 
   1904   1.1  christos         tptr+=rsvp_obj_len;
   1905   1.1  christos         tlen-=rsvp_obj_len;
   1906   1.1  christos     }
   1907   1.1  christos     return 0;
   1908  1.12  christos subobj_tooshort:
   1909  1.12  christos     ND_PRINT("%sERROR: sub-object is too short", indent);
   1910  1.12  christos     return -1;
   1911  1.12  christos obj_tooshort:
   1912  1.12  christos     ND_PRINT("%sERROR: object is too short", indent);
   1913  1.12  christos     return -1;
   1914   1.8  christos invalid:
   1915  1.12  christos     nd_print_invalid(ndo);
   1916   1.8  christos     return -1;
   1917   1.1  christos trunc:
   1918  1.12  christos     nd_print_trunc(ndo);
   1919   1.1  christos     return -1;
   1920   1.1  christos }
   1921   1.1  christos 
   1922   1.1  christos void
   1923   1.6  christos rsvp_print(netdissect_options *ndo,
   1924  1.12  christos            const u_char *pptr, u_int len)
   1925   1.7  christos {
   1926   1.8  christos     const struct rsvp_common_header *rsvp_com_header;
   1927  1.12  christos     uint8_t version_flags, msg_type;
   1928   1.8  christos     const u_char *tptr;
   1929   1.8  christos     u_short plen, tlen;
   1930   1.1  christos 
   1931  1.12  christos     ndo->ndo_protocol = "rsvp";
   1932   1.1  christos     tptr=pptr;
   1933   1.1  christos 
   1934   1.8  christos     rsvp_com_header = (const struct rsvp_common_header *)pptr;
   1935  1.12  christos     ND_TCHECK_SIZE(rsvp_com_header);
   1936  1.12  christos     version_flags = GET_U_1(rsvp_com_header->version_flags);
   1937   1.1  christos 
   1938   1.1  christos     /*
   1939   1.1  christos      * Sanity checking of the header.
   1940   1.1  christos      */
   1941  1.12  christos     if (RSVP_EXTRACT_VERSION(version_flags) != RSVP_VERSION) {
   1942  1.12  christos 	ND_PRINT("ERROR: RSVP version %u packet not supported",
   1943  1.12  christos                RSVP_EXTRACT_VERSION(version_flags));
   1944   1.1  christos 	return;
   1945   1.1  christos     }
   1946   1.1  christos 
   1947  1.12  christos     msg_type = GET_U_1(rsvp_com_header->msg_type);
   1948  1.12  christos 
   1949   1.1  christos     /* in non-verbose mode just lets print the basic Message Type*/
   1950   1.6  christos     if (ndo->ndo_vflag < 1) {
   1951  1.12  christos         ND_PRINT("RSVPv%u %s Message, length: %u",
   1952  1.12  christos                RSVP_EXTRACT_VERSION(version_flags),
   1953  1.12  christos                tok2str(rsvp_msg_type_values, "unknown (%u)",msg_type),
   1954  1.12  christos                len);
   1955   1.1  christos         return;
   1956   1.1  christos     }
   1957   1.1  christos 
   1958   1.1  christos     /* ok they seem to want to know everything - lets fully decode it */
   1959   1.1  christos 
   1960  1.12  christos     plen = tlen = GET_BE_U_2(rsvp_com_header->length);
   1961   1.1  christos 
   1962  1.12  christos     ND_PRINT("\n\tRSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
   1963  1.12  christos            RSVP_EXTRACT_VERSION(version_flags),
   1964  1.12  christos            tok2str(rsvp_msg_type_values, "unknown, type: %u",msg_type),
   1965  1.12  christos            msg_type,
   1966  1.12  christos            bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(version_flags)),
   1967   1.1  christos            tlen,
   1968  1.12  christos            GET_U_1(rsvp_com_header->ttl),
   1969  1.12  christos            GET_BE_U_2(rsvp_com_header->checksum));
   1970   1.1  christos 
   1971  1.12  christos     if (tlen < sizeof(struct rsvp_common_header)) {
   1972  1.12  christos         ND_PRINT("ERROR: common header too short %u < %zu", tlen,
   1973  1.12  christos                sizeof(struct rsvp_common_header));
   1974   1.1  christos         return;
   1975   1.1  christos     }
   1976   1.1  christos 
   1977  1.12  christos     tptr+=sizeof(struct rsvp_common_header);
   1978  1.12  christos     tlen-=sizeof(struct rsvp_common_header);
   1979   1.1  christos 
   1980  1.12  christos     switch(msg_type) {
   1981   1.1  christos 
   1982   1.8  christos     case RSVP_MSGTYPE_BUNDLE:
   1983   1.8  christos         /*
   1984   1.8  christos          * Process each submessage in the bundle message.
   1985   1.8  christos          * Bundle messages may not contain bundle submessages, so we don't
   1986   1.8  christos          * need to handle bundle submessages specially.
   1987   1.8  christos          */
   1988   1.1  christos         while(tlen > 0) {
   1989   1.8  christos             const u_char *subpptr=tptr, *subtptr;
   1990   1.8  christos             u_short subplen, subtlen;
   1991   1.8  christos 
   1992   1.8  christos             subtptr=subpptr;
   1993   1.8  christos 
   1994   1.8  christos             rsvp_com_header = (const struct rsvp_common_header *)subpptr;
   1995  1.12  christos             ND_TCHECK_SIZE(rsvp_com_header);
   1996  1.12  christos             version_flags = GET_U_1(rsvp_com_header->version_flags);
   1997   1.1  christos 
   1998   1.1  christos             /*
   1999   1.1  christos              * Sanity checking of the header.
   2000   1.1  christos              */
   2001  1.12  christos             if (RSVP_EXTRACT_VERSION(version_flags) != RSVP_VERSION) {
   2002  1.12  christos                 ND_PRINT("ERROR: RSVP version %u packet not supported",
   2003  1.12  christos                        RSVP_EXTRACT_VERSION(version_flags));
   2004   1.1  christos                 return;
   2005   1.1  christos             }
   2006   1.8  christos 
   2007  1.12  christos             subplen = subtlen = GET_BE_U_2(rsvp_com_header->length);
   2008   1.6  christos 
   2009  1.12  christos             msg_type = GET_U_1(rsvp_com_header->msg_type);
   2010  1.12  christos             ND_PRINT("\n\t  RSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
   2011  1.12  christos                    RSVP_EXTRACT_VERSION(version_flags),
   2012  1.12  christos                    tok2str(rsvp_msg_type_values, "unknown, type: %u",msg_type),
   2013  1.12  christos                    msg_type,
   2014  1.12  christos                    bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(version_flags)),
   2015   1.1  christos                    subtlen,
   2016  1.12  christos                    GET_U_1(rsvp_com_header->ttl),
   2017  1.12  christos                    GET_BE_U_2(rsvp_com_header->checksum));
   2018   1.1  christos 
   2019  1.12  christos             if (subtlen < sizeof(struct rsvp_common_header)) {
   2020  1.12  christos                 ND_PRINT("ERROR: common header too short %u < %zu", subtlen,
   2021  1.12  christos                        sizeof(struct rsvp_common_header));
   2022   1.1  christos                 return;
   2023   1.1  christos             }
   2024   1.1  christos 
   2025   1.1  christos             if (tlen < subtlen) {
   2026  1.12  christos                 ND_PRINT("ERROR: common header too large %u > %u", subtlen,
   2027  1.12  christos                        tlen);
   2028   1.1  christos                 return;
   2029   1.1  christos             }
   2030   1.1  christos 
   2031  1.12  christos             subtptr+=sizeof(struct rsvp_common_header);
   2032  1.12  christos             subtlen-=sizeof(struct rsvp_common_header);
   2033   1.1  christos 
   2034   1.8  christos             /*
   2035   1.8  christos              * Print all objects in the submessage.
   2036   1.8  christos              */
   2037   1.8  christos             if (rsvp_obj_print(ndo, subpptr, subplen, subtptr, "\n\t    ", subtlen, rsvp_com_header) == -1)
   2038   1.1  christos                 return;
   2039   1.1  christos 
   2040  1.12  christos             tptr+=subtlen+sizeof(struct rsvp_common_header);
   2041  1.12  christos             tlen-=subtlen+sizeof(struct rsvp_common_header);
   2042   1.1  christos         }
   2043   1.1  christos 
   2044   1.1  christos         break;
   2045   1.1  christos 
   2046   1.1  christos     case RSVP_MSGTYPE_PATH:
   2047   1.1  christos     case RSVP_MSGTYPE_RESV:
   2048   1.1  christos     case RSVP_MSGTYPE_PATHERR:
   2049   1.1  christos     case RSVP_MSGTYPE_RESVERR:
   2050   1.1  christos     case RSVP_MSGTYPE_PATHTEAR:
   2051   1.1  christos     case RSVP_MSGTYPE_RESVTEAR:
   2052   1.1  christos     case RSVP_MSGTYPE_RESVCONF:
   2053   1.1  christos     case RSVP_MSGTYPE_HELLO_OLD:
   2054   1.1  christos     case RSVP_MSGTYPE_HELLO:
   2055   1.1  christos     case RSVP_MSGTYPE_ACK:
   2056   1.1  christos     case RSVP_MSGTYPE_SREFRESH:
   2057   1.8  christos         /*
   2058   1.8  christos          * Print all objects in the message.
   2059   1.8  christos          */
   2060   1.8  christos         if (rsvp_obj_print(ndo, pptr, plen, tptr, "\n\t  ", tlen, rsvp_com_header) == -1)
   2061   1.1  christos             return;
   2062   1.1  christos         break;
   2063   1.1  christos 
   2064   1.6  christos     default:
   2065   1.6  christos         print_unknown_data(ndo, tptr, "\n\t    ", tlen);
   2066   1.1  christos         break;
   2067   1.1  christos     }
   2068   1.1  christos 
   2069   1.1  christos     return;
   2070   1.1  christos trunc:
   2071  1.12  christos     nd_print_trunc(ndo);
   2072   1.1  christos }
   2073