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