1 /* 2 * Redistribution and use in source and binary forms, with or without 3 * modification, are permitted provided that: (1) source code 4 * distributions retain the above copyright notice and this paragraph 5 * in its entirety, and (2) distributions including binary code include 6 * the above copyright notice and this paragraph in its entirety in 7 * the documentation or other materials provided with the distribution. 8 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND 9 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT 10 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 11 * FOR A PARTICULAR PURPOSE. 12 * 13 * Original code by Hannes Gredler (hannes@juniper.net) 14 * Support for LMP service discovery extensions (defined by UNI 1.0) added 15 * by Manu Pathak (mapathak@cisco.com), May 2005 16 */ 17 18 #ifndef lint 19 static const char rcsid[] _U_ = 20 "@(#) $Header: /tcpdump/master/tcpdump/print-lmp.c,v 1.5.2.1 2005/05/19 06:44:03 guy Exp $"; 21 #endif 22 23 #ifdef HAVE_CONFIG_H 24 #include "config.h" 25 #endif 26 27 #include <tcpdump-stdinc.h> 28 29 #include <stdio.h> 30 #include <stdlib.h> 31 #include <string.h> 32 33 #include "interface.h" 34 #include "extract.h" 35 #include "addrtoname.h" 36 #include "gmpls.h" 37 38 /* 39 * LMP common header 40 * 41 * 0 1 2 3 42 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 * | Vers | (Reserved) | Flags | Msg Type | 45 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 46 * | LMP Length | (Reserved) | 47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 48 */ 49 50 struct lmp_common_header { 51 u_int8_t version_res[2]; 52 u_int8_t flags; 53 u_int8_t msg_type; 54 u_int8_t length[2]; 55 u_int8_t reserved[2]; 56 }; 57 58 #define LMP_VERSION 1 59 #define LMP_EXTRACT_VERSION(x) (((x)&0xf0)>>4) 60 61 static const struct tok lmp_header_flag_values[] = { 62 { 0x00, "Control Channel Down"}, 63 { 0x02, "LMP restart"}, 64 { 0, NULL} 65 }; 66 67 static const struct tok lmp_obj_te_link_flag_values[] = { 68 { 0x01, "Fault Management Supported"}, 69 { 0x02, "Link Verification Supported"}, 70 { 0, NULL} 71 }; 72 73 static const struct tok lmp_obj_data_link_flag_values[] = { 74 { 0x01, "Data Link Port"}, 75 { 0x02, "Allocated for user traffic"}, 76 { 0x04, "Failed link"}, 77 { 0, NULL} 78 }; 79 80 static const struct tok lmp_obj_channel_status_values[] = { 81 { 1, "Signal Okay"}, 82 { 2, "Signal Degraded"}, 83 { 3, "Signal Fail"}, 84 { 0, NULL} 85 }; 86 87 static const struct tok lmp_obj_begin_verify_flag_values[] = { 88 { 0x0001, "Verify all links"}, 89 { 0x0002, "Data link type"}, 90 { 0, NULL} 91 }; 92 93 static const struct tok lmp_obj_begin_verify_error_values[] = { 94 { 0x01, "\n\t\tLink Verification Procedure Not supported"}, 95 { 0x02, "\n\t\tUnwilling to verify"}, 96 { 0x04, "\n\t\tUnsupported verification transport mechanism"}, 97 { 0x08, "\n\t\tLink_Id configuration error"}, 98 { 0x10, "\n\t\tUnknown object c-type"}, 99 { 0, NULL} 100 }; 101 102 static const struct tok lmp_obj_link_summary_error_values[] = { 103 { 0x01, "\n\t\tUnacceptable non-negotiable LINK_SUMMARY parameters"}, 104 { 0x02, "\n\t\tRenegotiate LINK_SUMMARY parameters"}, 105 { 0x04, "\n\t\tInvalid TE-LINK Object"}, 106 { 0x08, "\n\t\tInvalid DATA-LINK Object"}, 107 { 0x10, "\n\t\tUnknown TE-LINK Object c-type"}, 108 { 0x20, "\n\t\tUnknown DATA-LINK Object c-type"}, 109 { 0, NULL} 110 }; 111 112 /* Service Config Supported Protocols Flags */ 113 static const struct tok lmp_obj_service_config_sp_flag_values[] = { 114 { 0x01, "RSVP Supported"}, 115 { 0x02, "LDP Supported"}, 116 { 0, NULL} 117 }; 118 119 /* Service Config Client Port Service Attribute Transparency Flags */ 120 static const struct tok lmp_obj_service_config_cpsa_tp_flag_values[] = { 121 { 0x01, "Path/VC Overhead Transparency Supported"}, 122 { 0x02, "Line/MS Overhead Transparency Supported"}, 123 { 0x04, "Section/RS Overhead Transparency Supported"}, 124 { 0, NULL} 125 }; 126 127 /* Service Config Client Port Service Attribute Contiguous Concatenation Types Flags */ 128 static const struct tok lmp_obj_service_config_cpsa_cct_flag_values[] = { 129 { 0x01, "Contiguous Concatenation Types Supported"}, 130 { 0, NULL} 131 }; 132 133 /* Service Config Network Service Attributes Transparency Flags */ 134 static const struct tok lmp_obj_service_config_nsa_transparency_flag_values[] = { 135 { 0x01, "Standard SOH/RSOH Transparency Supported"}, 136 { 0x02, "Standard LOH/MSOH Transparency Supported"}, 137 { 0, NULL} 138 }; 139 140 /* Service Config Network Service Attributes TCM Monitoring Flags */ 141 static const struct tok lmp_obj_service_config_nsa_tcm_flag_values[] = { 142 { 0x01, "Transparent Tandem Connection Monitoring Supported"}, 143 { 0, NULL} 144 }; 145 146 /* Network Service Attributes Network Diversity Flags */ 147 static const struct tok lmp_obj_service_config_nsa_network_diversity_flag_values[] = { 148 { 0x01, "Node Diversity Supported"}, 149 { 0x02, "Link Diversity Supported"}, 150 { 0x04, "SRLG Diversity Supported"}, 151 { 0, NULL} 152 }; 153 154 #define LMP_MSGTYPE_CONFIG 1 155 #define LMP_MSGTYPE_CONFIG_ACK 2 156 #define LMP_MSGTYPE_CONFIG_NACK 3 157 #define LMP_MSGTYPE_HELLO 4 158 #define LMP_MSGTYPE_VERIFY_BEGIN 5 159 #define LMP_MSGTYPE_VERIFY_BEGIN_ACK 6 160 #define LMP_MSGTYPE_VERIFY_BEGIN_NACK 7 161 #define LMP_MSGTYPE_VERIFY_END 8 162 #define LMP_MSGTYPE_VERIFY_END_ACK 9 163 #define LMP_MSGTYPE_TEST 10 164 #define LMP_MSGTYPE_TEST_STATUS_SUCCESS 11 165 #define LMP_MSGTYPE_TEST_STATUS_FAILURE 12 166 #define LMP_MSGTYPE_TEST_STATUS_ACK 13 167 #define LMP_MSGTYPE_LINK_SUMMARY 14 168 #define LMP_MSGTYPE_LINK_SUMMARY_ACK 15 169 #define LMP_MSGTYPE_LINK_SUMMARY_NACK 16 170 #define LMP_MSGTYPE_CHANNEL_STATUS 17 171 #define LMP_MSGTYPE_CHANNEL_STATUS_ACK 18 172 #define LMP_MSGTYPE_CHANNEL_STATUS_REQ 19 173 #define LMP_MSGTYPE_CHANNEL_STATUS_RESP 20 174 /* LMP Service Discovery message types defined by UNI 1.0 */ 175 #define LMP_MSGTYPE_SERVICE_CONFIG 50 176 #define LMP_MSGTYPE_SERVICE_CONFIG_ACK 51 177 #define LMP_MSGTYPE_SERVICE_CONFIG_NACK 52 178 179 static const struct tok lmp_msg_type_values[] = { 180 { LMP_MSGTYPE_CONFIG, "Config"}, 181 { LMP_MSGTYPE_CONFIG_ACK, "Config ACK"}, 182 { LMP_MSGTYPE_CONFIG_NACK, "Config NACK"}, 183 { LMP_MSGTYPE_HELLO, "Hello"}, 184 { LMP_MSGTYPE_VERIFY_BEGIN, "Begin Verify"}, 185 { LMP_MSGTYPE_VERIFY_BEGIN_ACK, "Begin Verify ACK"}, 186 { LMP_MSGTYPE_VERIFY_BEGIN_NACK, "Begin Verify NACK"}, 187 { LMP_MSGTYPE_VERIFY_END, "End Verify"}, 188 { LMP_MSGTYPE_VERIFY_END_ACK, "End Verify ACK"}, 189 { LMP_MSGTYPE_TEST, "Test"}, 190 { LMP_MSGTYPE_TEST_STATUS_SUCCESS, "Test Status Success"}, 191 { LMP_MSGTYPE_TEST_STATUS_FAILURE, "Test Status Failure"}, 192 { LMP_MSGTYPE_TEST_STATUS_ACK, "Test Status ACK"}, 193 { LMP_MSGTYPE_LINK_SUMMARY, "Link Summary"}, 194 { LMP_MSGTYPE_LINK_SUMMARY_ACK, "Link Summary ACK"}, 195 { LMP_MSGTYPE_LINK_SUMMARY_NACK, "Link Summary NACK"}, 196 { LMP_MSGTYPE_CHANNEL_STATUS, "Channel Status"}, 197 { LMP_MSGTYPE_CHANNEL_STATUS_ACK, "Channel Status ACK"}, 198 { LMP_MSGTYPE_CHANNEL_STATUS_REQ, "Channel Status Request"}, 199 { LMP_MSGTYPE_CHANNEL_STATUS_RESP, "Channel Status Response"}, 200 { LMP_MSGTYPE_SERVICE_CONFIG, "Service Config"}, 201 { LMP_MSGTYPE_SERVICE_CONFIG_ACK, "Service Config ACK"}, 202 { LMP_MSGTYPE_SERVICE_CONFIG_NACK, "Service Config NACK"}, 203 { 0, NULL} 204 }; 205 206 /* 207 * LMP object header 208 * 209 * 0 1 2 3 210 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 211 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 212 * |N| C-Type | Class | Length | 213 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 214 * | | 215 * // (object contents) // 216 * | | 217 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 218 */ 219 220 struct lmp_object_header { 221 u_int8_t ctype; 222 u_int8_t class_num; 223 u_int8_t length[2]; 224 }; 225 226 #define LMP_OBJ_CC_ID 1 227 #define LMP_OBJ_NODE_ID 2 228 #define LMP_OBJ_LINK_ID 3 229 #define LMP_OBJ_INTERFACE_ID 4 230 #define LMP_OBJ_MESSAGE_ID 5 231 #define LMP_OBJ_CONFIG 6 232 #define LMP_OBJ_HELLO 7 233 #define LMP_OBJ_VERIFY_BEGIN 8 234 #define LMP_OBJ_VERIFY_BEGIN_ACK 9 235 #define LMP_OBJ_VERIFY_ID 10 236 #define LMP_OBJ_TE_LINK 11 237 #define LMP_OBJ_DATA_LINK 12 238 #define LMP_OBJ_CHANNEL_STATUS 13 239 #define LMP_OBJ_CHANNEL_STATUS_REQ 14 240 #define LMP_OBJ_ERROR_CODE 20 241 242 #define LMP_OBJ_SERVICE_CONFIG 51 /* defined in UNI 1.0 */ 243 244 static const struct tok lmp_obj_values[] = { 245 { LMP_OBJ_CC_ID, "Control Channel ID" }, 246 { LMP_OBJ_NODE_ID, "Node ID" }, 247 { LMP_OBJ_LINK_ID, "Link ID" }, 248 { LMP_OBJ_INTERFACE_ID, "Interface ID" }, 249 { LMP_OBJ_MESSAGE_ID, "Message ID" }, 250 { LMP_OBJ_CONFIG, "Configuration" }, 251 { LMP_OBJ_HELLO, "Hello" }, 252 { LMP_OBJ_VERIFY_BEGIN, "Verify Begin" }, 253 { LMP_OBJ_VERIFY_BEGIN_ACK, "Verify Begin ACK" }, 254 { LMP_OBJ_VERIFY_ID, "Verify ID" }, 255 { LMP_OBJ_TE_LINK, "TE Link" }, 256 { LMP_OBJ_DATA_LINK, "Data Link" }, 257 { LMP_OBJ_CHANNEL_STATUS, "Channel Status" }, 258 { LMP_OBJ_CHANNEL_STATUS_REQ, "Channel Status Request" }, 259 { LMP_OBJ_ERROR_CODE, "Error Code" }, 260 { LMP_OBJ_SERVICE_CONFIG, "Service Config" }, 261 262 { 0, NULL} 263 }; 264 265 #define INT_SWITCHING_TYPE_SUBOBJ 1 266 #define WAVELENGTH_SUBOBJ 2 267 268 static const struct tok lmp_data_link_subobj[] = { 269 { INT_SWITCHING_TYPE_SUBOBJ, "Interface Switching Type" }, 270 { WAVELENGTH_SUBOBJ , "Wavelength" }, 271 { 0, NULL} 272 }; 273 274 #define LMP_CTYPE_IPV4 1 275 #define LMP_CTYPE_IPV6 2 276 277 #define LMP_CTYPE_LOC 1 278 #define LMP_CTYPE_RMT 2 279 #define LMP_CTYPE_UNMD 3 280 281 #define LMP_CTYPE_IPV4_LOC 1 282 #define LMP_CTYPE_IPV4_RMT 2 283 #define LMP_CTYPE_IPV6_LOC 3 284 #define LMP_CTYPE_IPV6_RMT 4 285 #define LMP_CTYPE_UNMD_LOC 5 286 #define LMP_CTYPE_UNMD_RMT 6 287 288 #define LMP_CTYPE_1 1 289 #define LMP_CTYPE_2 2 290 291 #define LMP_CTYPE_HELLO_CONFIG 1 292 #define LMP_CTYPE_HELLO 1 293 294 #define LMP_CTYPE_BEGIN_VERIFY_ERROR 1 295 #define LMP_CTYPE_LINK_SUMMARY_ERROR 2 296 297 /* C-Types for Service Config Object */ 298 #define LMP_CTYPE_SERVICE_CONFIG_SP 1 299 #define LMP_CTYPE_SERVICE_CONFIG_CPSA 2 300 #define LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM 3 301 #define LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY 4 302 303 /* 304 * Different link types allowed in the Client Port Service Attributes 305 * subobject defined for LMP Service Discovery in the UNI 1.0 spec 306 */ 307 #define LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH 5 /* UNI 1.0 Sec 9.4.2 */ 308 #define LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET 6 /* UNI 1.0 Sec 9.4.2 */ 309 310 #define FALSE 0 311 #define TRUE 1 312 313 /* 314 * the ctypes are not globally unique so for 315 * translating it to strings we build a table based 316 * on objects offsetted by the ctype 317 */ 318 319 static const struct tok lmp_ctype_values[] = { 320 { 256*LMP_OBJ_CC_ID+LMP_CTYPE_LOC, "Local" }, 321 { 256*LMP_OBJ_CC_ID+LMP_CTYPE_RMT, "Remote" }, 322 { 256*LMP_OBJ_NODE_ID+LMP_CTYPE_LOC, "Local" }, 323 { 256*LMP_OBJ_NODE_ID+LMP_CTYPE_RMT, "Remote" }, 324 { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV4_LOC, "IPv4 Local" }, 325 { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV4_RMT, "IPv4 Remote" }, 326 { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV6_LOC, "IPv6 Local" }, 327 { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV6_RMT, "IPv6 Remote" }, 328 { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_UNMD_LOC, "Unnumbered Local" }, 329 { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_UNMD_RMT, "Unnumbered Remote" }, 330 { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV4_LOC, "IPv4 Local" }, 331 { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV4_RMT, "IPv4 Remote" }, 332 { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV6_LOC, "IPv6 Local" }, 333 { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV6_RMT, "IPv6 Remote" }, 334 { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_UNMD_LOC, "Unnumbered Local" }, 335 { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_UNMD_RMT, "Unnumbered Remote" }, 336 { 256*LMP_OBJ_MESSAGE_ID+LMP_CTYPE_1, "1" }, 337 { 256*LMP_OBJ_MESSAGE_ID+LMP_CTYPE_2, "2" }, 338 { 256*LMP_OBJ_CONFIG+LMP_CTYPE_1, "1" }, 339 { 256*LMP_OBJ_HELLO+LMP_CTYPE_1, "1" }, 340 { 256*LMP_OBJ_VERIFY_BEGIN+LMP_CTYPE_1, "1" }, 341 { 256*LMP_OBJ_VERIFY_BEGIN_ACK+LMP_CTYPE_1, "1" }, 342 { 256*LMP_OBJ_VERIFY_ID+LMP_CTYPE_1, "1" }, 343 { 256*LMP_OBJ_TE_LINK+LMP_CTYPE_IPV4, "IPv4" }, 344 { 256*LMP_OBJ_TE_LINK+LMP_CTYPE_IPV6, "IPv6" }, 345 { 256*LMP_OBJ_TE_LINK+LMP_CTYPE_UNMD, "Unnumbered" }, 346 { 256*LMP_OBJ_DATA_LINK+LMP_CTYPE_IPV4, "IPv4" }, 347 { 256*LMP_OBJ_DATA_LINK+LMP_CTYPE_IPV6, "IPv6" }, 348 { 256*LMP_OBJ_DATA_LINK+LMP_CTYPE_UNMD, "Unnumbered" }, 349 { 256*LMP_OBJ_CHANNEL_STATUS+LMP_CTYPE_IPV4, "IPv4" }, 350 { 256*LMP_OBJ_CHANNEL_STATUS+LMP_CTYPE_IPV6, "IPv6" }, 351 { 256*LMP_OBJ_CHANNEL_STATUS+LMP_CTYPE_UNMD, "Unnumbered" }, 352 { 256*LMP_OBJ_CHANNEL_STATUS_REQ+LMP_CTYPE_IPV4, "IPv4" }, 353 { 256*LMP_OBJ_CHANNEL_STATUS_REQ+LMP_CTYPE_IPV6, "IPv6" }, 354 { 256*LMP_OBJ_CHANNEL_STATUS_REQ+LMP_CTYPE_UNMD, "Unnumbered" }, 355 { 256*LMP_OBJ_ERROR_CODE+LMP_CTYPE_1, "1" }, 356 { 256*LMP_OBJ_ERROR_CODE+LMP_CTYPE_2, "2" }, 357 { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_SP, "1" }, 358 { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_CPSA, "2" }, 359 { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM, "3" }, 360 { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY, "4" }, 361 { 0, NULL} 362 }; 363 364 void 365 lmp_print(register const u_char *pptr, register u_int len) { 366 367 const struct lmp_common_header *lmp_com_header; 368 const struct lmp_object_header *lmp_obj_header; 369 const u_char *tptr,*obj_tptr; 370 int tlen,lmp_obj_len,lmp_obj_ctype,obj_tlen; 371 int hexdump; 372 int offset,subobj_type,subobj_len,total_subobj_len; 373 int link_type; 374 375 union { /* int to float conversion buffer */ 376 float f; 377 u_int32_t i; 378 } bw; 379 380 tptr=pptr; 381 lmp_com_header = (const struct lmp_common_header *)pptr; 382 TCHECK(*lmp_com_header); 383 384 /* 385 * Sanity checking of the header. 386 */ 387 if (LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]) != LMP_VERSION) { 388 printf("LMP version %u packet not supported", 389 LMP_EXTRACT_VERSION(lmp_com_header->version_res[0])); 390 return; 391 } 392 393 /* in non-verbose mode just lets print the basic Message Type*/ 394 if (vflag < 1) { 395 printf("LMPv%u %s Message, length: %u", 396 LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]), 397 tok2str(lmp_msg_type_values, "unknown (%u)",lmp_com_header->msg_type), 398 len); 399 return; 400 } 401 402 /* ok they seem to want to know everything - lets fully decode it */ 403 404 tlen=EXTRACT_16BITS(lmp_com_header->length); 405 406 printf("\n\tLMPv%u, msg-type: %s, Flags: [%s], length: %u", 407 LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]), 408 tok2str(lmp_msg_type_values, "unknown, type: %u",lmp_com_header->msg_type), 409 bittok2str(lmp_header_flag_values,"none",lmp_com_header->flags), 410 tlen); 411 412 tptr+=sizeof(const struct lmp_common_header); 413 tlen-=sizeof(const struct lmp_common_header); 414 415 while(tlen>0) { 416 /* did we capture enough for fully decoding the object header ? */ 417 if (!TTEST2(*tptr, sizeof(struct lmp_object_header))) 418 goto trunc; 419 420 lmp_obj_header = (const struct lmp_object_header *)tptr; 421 lmp_obj_len=EXTRACT_16BITS(lmp_obj_header->length); 422 lmp_obj_ctype=(lmp_obj_header->ctype)&0x7f; 423 424 if(lmp_obj_len % 4 || lmp_obj_len < 4) 425 return; 426 427 printf("\n\t %s Object (%u), Class-Type: %s (%u) Flags: [%snegotiable], length: %u", 428 tok2str(lmp_obj_values, 429 "Unknown", 430 lmp_obj_header->class_num), 431 lmp_obj_header->class_num, 432 tok2str(lmp_ctype_values, 433 "Unknown", 434 ((lmp_obj_header->class_num)<<8)+lmp_obj_ctype), 435 lmp_obj_ctype, 436 (lmp_obj_header->ctype)&0x80 ? "" : "non-", 437 lmp_obj_len); 438 439 obj_tptr=tptr+sizeof(struct lmp_object_header); 440 obj_tlen=lmp_obj_len-sizeof(struct lmp_object_header); 441 442 /* did we capture enough for fully decoding the object ? */ 443 if (!TTEST2(*tptr, lmp_obj_len)) 444 goto trunc; 445 hexdump=FALSE; 446 447 switch(lmp_obj_header->class_num) { 448 449 case LMP_OBJ_CC_ID: 450 switch(lmp_obj_ctype) { 451 case LMP_CTYPE_LOC: 452 case LMP_CTYPE_RMT: 453 printf("\n\t Control Channel ID: %u (0x%08x)", 454 EXTRACT_32BITS(obj_tptr), 455 EXTRACT_32BITS(obj_tptr)); 456 break; 457 458 default: 459 hexdump=TRUE; 460 } 461 break; 462 463 case LMP_OBJ_LINK_ID: 464 case LMP_OBJ_INTERFACE_ID: 465 switch(lmp_obj_ctype) { 466 case LMP_CTYPE_IPV4_LOC: 467 case LMP_CTYPE_IPV4_RMT: 468 printf("\n\t IPv4 Link ID: %s (0x%08x)", 469 ipaddr_string(obj_tptr), 470 EXTRACT_32BITS(obj_tptr)); 471 break; 472 #ifdef INET6 473 case LMP_CTYPE_IPV6_LOC: 474 case LMP_CTYPE_IPV6_RMT: 475 printf("\n\t IPv6 Link ID: %s (0x%08x)", 476 ip6addr_string(obj_tptr), 477 EXTRACT_32BITS(obj_tptr)); 478 break; 479 #endif 480 case LMP_CTYPE_UNMD_LOC: 481 case LMP_CTYPE_UNMD_RMT: 482 printf("\n\t Link ID: %u (0x%08x)", 483 EXTRACT_32BITS(obj_tptr), 484 EXTRACT_32BITS(obj_tptr)); 485 break; 486 default: 487 hexdump=TRUE; 488 } 489 break; 490 491 case LMP_OBJ_MESSAGE_ID: 492 switch(lmp_obj_ctype) { 493 case LMP_CTYPE_1: 494 printf("\n\t Message ID: %u (0x%08x)", 495 EXTRACT_32BITS(obj_tptr), 496 EXTRACT_32BITS(obj_tptr)); 497 break; 498 case LMP_CTYPE_2: 499 printf("\n\t Message ID Ack: %u (0x%08x)", 500 EXTRACT_32BITS(obj_tptr), 501 EXTRACT_32BITS(obj_tptr)); 502 break; 503 default: 504 hexdump=TRUE; 505 } 506 break; 507 508 case LMP_OBJ_NODE_ID: 509 switch(lmp_obj_ctype) { 510 case LMP_CTYPE_LOC: 511 case LMP_CTYPE_RMT: 512 printf("\n\t Node ID: %s (0x%08x)", 513 ipaddr_string(obj_tptr), 514 EXTRACT_32BITS(obj_tptr)); 515 break; 516 517 default: 518 hexdump=TRUE; 519 } 520 break; 521 522 case LMP_OBJ_CONFIG: 523 switch(lmp_obj_ctype) { 524 case LMP_CTYPE_HELLO_CONFIG: 525 printf("\n\t Hello Interval: %u\n\t Hello Dead Interval: %u", 526 EXTRACT_16BITS(obj_tptr), 527 EXTRACT_16BITS(obj_tptr+2)); 528 break; 529 530 default: 531 hexdump=TRUE; 532 } 533 break; 534 535 case LMP_OBJ_HELLO: 536 switch(lmp_obj_ctype) { 537 case LMP_CTYPE_HELLO: 538 printf("\n\t TxSeqNum: %u\n\t RcvSeqNum: %u", 539 EXTRACT_32BITS(obj_tptr), 540 EXTRACT_32BITS(obj_tptr+4)); 541 break; 542 543 default: 544 hexdump=TRUE; 545 } 546 break; 547 548 case LMP_OBJ_TE_LINK: 549 printf("\n\t Flags: [%s]", 550 bittok2str(lmp_obj_te_link_flag_values, 551 "none", 552 EXTRACT_16BITS(obj_tptr)>>8)); 553 554 switch(lmp_obj_ctype) { 555 case LMP_CTYPE_IPV4: 556 printf("\n\t Local Link-ID: %s (0x%08x) \ 557 \n\t Remote Link-ID: %s (0x%08x)", 558 ipaddr_string(obj_tptr+4), 559 EXTRACT_32BITS(obj_tptr+4), 560 ipaddr_string(obj_tptr+8), 561 EXTRACT_32BITS(obj_tptr+8)); 562 break; 563 564 #ifdef INET6 565 case LMP_CTYPE_IPV6: 566 #endif 567 case LMP_CTYPE_UNMD: 568 default: 569 hexdump=TRUE; 570 } 571 break; 572 573 case LMP_OBJ_DATA_LINK: 574 printf("\n\t Flags: [%s]", 575 bittok2str(lmp_obj_data_link_flag_values, 576 "none", 577 EXTRACT_16BITS(obj_tptr)>>8)); 578 579 switch(lmp_obj_ctype) { 580 case LMP_CTYPE_IPV4: 581 case LMP_CTYPE_UNMD: 582 printf("\n\t Local Interface ID: %s (0x%08x) \ 583 \n\t Remote Interface ID: %s (0x%08x)", 584 ipaddr_string(obj_tptr+4), 585 EXTRACT_32BITS(obj_tptr+4), 586 ipaddr_string(obj_tptr+8), 587 EXTRACT_32BITS(obj_tptr+8)); 588 589 total_subobj_len = lmp_obj_len - 16; 590 offset = 12; 591 while (total_subobj_len > 0 && hexdump == FALSE ) { 592 subobj_type = EXTRACT_16BITS(obj_tptr+offset)>>8; 593 subobj_len = EXTRACT_16BITS(obj_tptr+offset)&0x00FF; 594 printf("\n\t Subobject, Type: %s (%u), Length: %u", 595 tok2str(lmp_data_link_subobj, 596 "Unknown", 597 subobj_type), 598 subobj_type, 599 subobj_len); 600 switch(subobj_type) { 601 case INT_SWITCHING_TYPE_SUBOBJ: 602 printf("\n\t\t Switching Type: %s (%u)", 603 tok2str(gmpls_switch_cap_values, 604 "Unknown", 605 EXTRACT_16BITS(obj_tptr+offset+2)>>8), 606 EXTRACT_16BITS(obj_tptr+offset+2)>>8); 607 printf("\n\t\t Encoding Type: %s (%u)", 608 tok2str(gmpls_encoding_values, 609 "Unknown", 610 EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF), 611 EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF); 612 bw.i = EXTRACT_32BITS(obj_tptr+offset+4); 613 printf("\n\t\t Min Reservable Bandwidth: %.3f Mbps", 614 bw.f); 615 bw.i = EXTRACT_32BITS(obj_tptr+offset+8); 616 printf("\n\t\t Max Reservable Bandwidth: %.3f Mbps", 617 bw.f); 618 break; 619 case WAVELENGTH_SUBOBJ: 620 printf("\n\t\t Wavelength: %u", 621 EXTRACT_32BITS(obj_tptr+offset+4)); 622 break; 623 default: 624 /* Any Unknown Subobject ==> Exit loop */ 625 hexdump=TRUE; 626 break; 627 } 628 total_subobj_len-=subobj_len; 629 offset+=subobj_len; 630 } 631 632 break; 633 #ifdef INET6 634 case LMP_CTYPE_IPV6: 635 #endif 636 default: 637 hexdump=TRUE; 638 } 639 break; 640 641 case LMP_OBJ_VERIFY_BEGIN: 642 switch(lmp_obj_ctype) { 643 case LMP_CTYPE_1: 644 printf("\n\t Flags: %s", 645 bittok2str(lmp_obj_begin_verify_flag_values, 646 "none", 647 EXTRACT_16BITS(obj_tptr))); 648 printf("\n\t Verify Interval: %u", 649 EXTRACT_16BITS(obj_tptr+2)); 650 printf("\n\t Data links: %u", 651 EXTRACT_32BITS(obj_tptr+4)); 652 printf("\n\t Encoding type: %s", 653 tok2str(gmpls_encoding_values, "Unknown", *(obj_tptr+8))); 654 printf("\n\t Verify Tranport Mechanism: %u (0x%x) %s", 655 EXTRACT_16BITS(obj_tptr+10), 656 EXTRACT_16BITS(obj_tptr+10), 657 EXTRACT_16BITS(obj_tptr+10)&8000 ? "(Payload test messages capable)" : ""); 658 bw.i = EXTRACT_32BITS(obj_tptr+12); 659 printf("\n\t Transmission Rate: %.3f Mbps",bw.f); 660 printf("\n\t Wavelength: %u", 661 EXTRACT_32BITS(obj_tptr+16)); 662 break; 663 664 default: 665 hexdump=TRUE; 666 } 667 break; 668 669 case LMP_OBJ_VERIFY_BEGIN_ACK: 670 switch(lmp_obj_ctype) { 671 case LMP_CTYPE_1: 672 printf("\n\t Verify Dead Interval: %u \ 673 \n\t Verify Transport Response: %u", 674 EXTRACT_16BITS(obj_tptr), 675 EXTRACT_16BITS(obj_tptr+2)); 676 break; 677 678 default: 679 hexdump=TRUE; 680 } 681 break; 682 683 case LMP_OBJ_VERIFY_ID: 684 switch(lmp_obj_ctype) { 685 case LMP_CTYPE_1: 686 printf("\n\t Verify ID: %u", 687 EXTRACT_32BITS(obj_tptr)); 688 break; 689 690 default: 691 hexdump=TRUE; 692 } 693 break; 694 695 case LMP_OBJ_CHANNEL_STATUS: 696 switch(lmp_obj_ctype) { 697 case LMP_CTYPE_IPV4: 698 case LMP_CTYPE_UNMD: 699 offset = 0; 700 /* Decode pairs: <Interface_ID (4 bytes), Channel_status (4 bytes)> */ 701 while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) { 702 printf("\n\t Interface ID: %s (0x%08x)", 703 ipaddr_string(obj_tptr+offset), 704 EXTRACT_32BITS(obj_tptr+offset)); 705 706 printf("\n\t\t Active: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>31) ? 707 "Allocated" : "Non-allocated", 708 (EXTRACT_32BITS(obj_tptr+offset+4)>>31)); 709 710 printf("\n\t\t Direction: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ? 711 "Transmit" : "Receive", 712 (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1); 713 714 printf("\n\t\t Channel Status: %s (%u)", 715 tok2str(lmp_obj_channel_status_values, 716 "Unknown", 717 EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF), 718 EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF); 719 offset+=8; 720 } 721 break; 722 #ifdef INET6 723 case LMP_CTYPE_IPV6: 724 #endif 725 default: 726 hexdump=TRUE; 727 } 728 break; 729 730 case LMP_OBJ_CHANNEL_STATUS_REQ: 731 switch(lmp_obj_ctype) { 732 case LMP_CTYPE_IPV4: 733 case LMP_CTYPE_UNMD: 734 offset = 0; 735 while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) { 736 printf("\n\t Interface ID: %s (0x%08x)", 737 ipaddr_string(obj_tptr+offset), 738 EXTRACT_32BITS(obj_tptr+offset)); 739 offset+=4; 740 } 741 break; 742 #ifdef INET6 743 case LMP_CTYPE_IPV6: 744 #endif 745 default: 746 hexdump=TRUE; 747 } 748 break; 749 750 case LMP_OBJ_ERROR_CODE: 751 switch(lmp_obj_ctype) { 752 case LMP_CTYPE_BEGIN_VERIFY_ERROR: 753 printf("\n\t Error Code: %s", 754 bittok2str(lmp_obj_begin_verify_error_values, 755 "none", 756 EXTRACT_32BITS(obj_tptr))); 757 break; 758 759 case LMP_CTYPE_LINK_SUMMARY_ERROR: 760 printf("\n\t Error Code: %s", 761 bittok2str(lmp_obj_link_summary_error_values, 762 "none", 763 EXTRACT_32BITS(obj_tptr))); 764 break; 765 default: 766 hexdump=TRUE; 767 } 768 break; 769 770 case LMP_OBJ_SERVICE_CONFIG: 771 switch (lmp_obj_ctype) { 772 case LMP_CTYPE_SERVICE_CONFIG_SP: 773 774 printf("\n\t Flags: %s", 775 bittok2str(lmp_obj_service_config_sp_flag_values, 776 "none", 777 EXTRACT_16BITS(obj_tptr)>>8)); 778 779 printf("\n\t UNI Version: %u", 780 EXTRACT_16BITS(obj_tptr) & 0x00FF); 781 782 break; 783 784 case LMP_CTYPE_SERVICE_CONFIG_CPSA: 785 786 link_type = EXTRACT_16BITS(obj_tptr)>>8; 787 788 printf("\n\t Link Type: %s (%u)", 789 tok2str(lmp_sd_service_config_cpsa_link_type_values, 790 "Unknown", link_type), 791 link_type); 792 793 if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH) { 794 printf("\n\t Signal Type: %s (%u)", 795 tok2str(lmp_sd_service_config_cpsa_signal_type_sdh_values, 796 "Unknown", 797 EXTRACT_16BITS(obj_tptr) & 0x00FF), 798 EXTRACT_16BITS(obj_tptr) & 0x00FF); 799 } 800 801 if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET) { 802 printf("\n\t Signal Type: %s (%u)", 803 tok2str(lmp_sd_service_config_cpsa_signal_type_sonet_values, 804 "Unknown", 805 EXTRACT_16BITS(obj_tptr) & 0x00FF), 806 EXTRACT_16BITS(obj_tptr) & 0x00FF); 807 } 808 809 printf("\n\t Transparency: %s", 810 bittok2str(lmp_obj_service_config_cpsa_tp_flag_values, 811 "none", 812 EXTRACT_16BITS(obj_tptr+2)>>8)); 813 814 printf("\n\t Contiguous Concatenation Types: %s", 815 bittok2str(lmp_obj_service_config_cpsa_cct_flag_values, 816 "none", 817 EXTRACT_16BITS(obj_tptr+2)>>8 & 0x00FF)); 818 819 printf("\n\t Minimum NCC: %u", 820 EXTRACT_16BITS(obj_tptr+4)); 821 822 printf("\n\t Maximum NCC: %u", 823 EXTRACT_16BITS(obj_tptr+6)); 824 825 printf("\n\t Minimum NVC:%u", 826 EXTRACT_16BITS(obj_tptr+8)); 827 828 printf("\n\t Maximum NVC:%u", 829 EXTRACT_16BITS(obj_tptr+10)); 830 831 printf("\n\t Local Interface ID: %s (0x%08x)", 832 ipaddr_string(obj_tptr+12), 833 EXTRACT_32BITS(obj_tptr+12)); 834 835 break; 836 837 case LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM: 838 839 printf("\n\t Transparency Flags: %s", 840 bittok2str( 841 lmp_obj_service_config_nsa_transparency_flag_values, 842 "none", 843 EXTRACT_32BITS(obj_tptr))); 844 845 printf("\n\t TCM Monitoring Flags: %s", 846 bittok2str( 847 lmp_obj_service_config_nsa_tcm_flag_values, 848 "none", 849 EXTRACT_16BITS(obj_tptr+6) & 0x00FF)); 850 851 break; 852 853 case LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY: 854 855 printf("\n\t Diversity: Flags: %s", 856 bittok2str( 857 lmp_obj_service_config_nsa_network_diversity_flag_values, 858 "none", 859 EXTRACT_16BITS(obj_tptr+2) & 0x00FF)); 860 break; 861 862 default: 863 hexdump = TRUE; 864 }; 865 866 break; 867 868 default: 869 if (vflag <= 1) 870 print_unknown_data(obj_tptr,"\n\t ",obj_tlen); 871 break; 872 } 873 /* do we want to see an additionally hexdump ? */ 874 if (vflag > 1 || hexdump==TRUE) 875 print_unknown_data(tptr+sizeof(sizeof(struct lmp_object_header)),"\n\t ", 876 lmp_obj_len-sizeof(struct lmp_object_header)); 877 878 tptr+=lmp_obj_len; 879 tlen-=lmp_obj_len; 880 } 881 return; 882 trunc: 883 printf("\n\t\t packet exceeded snapshot"); 884 } 885