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