Home | History | Annotate | Download | only in tcpdump
      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 (at) juniper.net)
     14  * Support for LMP service discovery extensions (defined by UNI 1.0) added
     15  * by Manu Pathak (mapathak (at) 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.4 2006/06/23 02:07:27 hannes 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     { 0x01, "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 /*
    311  * the ctypes are not globally unique so for
    312  * translating it to strings we build a table based
    313  * on objects offsetted by the ctype
    314  */
    315 
    316 static const struct tok lmp_ctype_values[] = {
    317     { 256*LMP_OBJ_CC_ID+LMP_CTYPE_LOC, "Local" },
    318     { 256*LMP_OBJ_CC_ID+LMP_CTYPE_RMT, "Remote" },
    319     { 256*LMP_OBJ_NODE_ID+LMP_CTYPE_LOC, "Local" },
    320     { 256*LMP_OBJ_NODE_ID+LMP_CTYPE_RMT, "Remote" },
    321     { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV4_LOC, "IPv4 Local" },
    322     { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV4_RMT, "IPv4 Remote" },
    323     { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV6_LOC, "IPv6 Local" },
    324     { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV6_RMT, "IPv6 Remote" },
    325     { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_UNMD_LOC, "Unnumbered Local" },
    326     { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_UNMD_RMT, "Unnumbered Remote" },
    327     { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV4_LOC, "IPv4 Local" },
    328     { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV4_RMT, "IPv4 Remote" },
    329     { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV6_LOC, "IPv6 Local" },
    330     { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV6_RMT, "IPv6 Remote" },
    331     { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_UNMD_LOC, "Unnumbered Local" },
    332     { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_UNMD_RMT, "Unnumbered Remote" },
    333     { 256*LMP_OBJ_MESSAGE_ID+LMP_CTYPE_1, "1" },
    334     { 256*LMP_OBJ_MESSAGE_ID+LMP_CTYPE_2, "2" },
    335     { 256*LMP_OBJ_CONFIG+LMP_CTYPE_1, "1" },
    336     { 256*LMP_OBJ_HELLO+LMP_CTYPE_1, "1" },
    337     { 256*LMP_OBJ_VERIFY_BEGIN+LMP_CTYPE_1, "1" },
    338     { 256*LMP_OBJ_VERIFY_BEGIN_ACK+LMP_CTYPE_1, "1" },
    339     { 256*LMP_OBJ_VERIFY_ID+LMP_CTYPE_1, "1" },
    340     { 256*LMP_OBJ_TE_LINK+LMP_CTYPE_IPV4, "IPv4" },
    341     { 256*LMP_OBJ_TE_LINK+LMP_CTYPE_IPV6, "IPv6" },
    342     { 256*LMP_OBJ_TE_LINK+LMP_CTYPE_UNMD, "Unnumbered" },
    343     { 256*LMP_OBJ_DATA_LINK+LMP_CTYPE_IPV4, "IPv4" },
    344     { 256*LMP_OBJ_DATA_LINK+LMP_CTYPE_IPV6, "IPv6" },
    345     { 256*LMP_OBJ_DATA_LINK+LMP_CTYPE_UNMD, "Unnumbered" },
    346     { 256*LMP_OBJ_CHANNEL_STATUS+LMP_CTYPE_IPV4, "IPv4" },
    347     { 256*LMP_OBJ_CHANNEL_STATUS+LMP_CTYPE_IPV6, "IPv6" },
    348     { 256*LMP_OBJ_CHANNEL_STATUS+LMP_CTYPE_UNMD, "Unnumbered" },
    349     { 256*LMP_OBJ_CHANNEL_STATUS_REQ+LMP_CTYPE_IPV4, "IPv4" },
    350     { 256*LMP_OBJ_CHANNEL_STATUS_REQ+LMP_CTYPE_IPV6, "IPv6" },
    351     { 256*LMP_OBJ_CHANNEL_STATUS_REQ+LMP_CTYPE_UNMD, "Unnumbered" },
    352     { 256*LMP_OBJ_ERROR_CODE+LMP_CTYPE_1, "1" },
    353     { 256*LMP_OBJ_ERROR_CODE+LMP_CTYPE_2, "2" },
    354     { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_SP, "1" },
    355     { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_CPSA, "2" },
    356     { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM, "3" },
    357     { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY, "4" },
    358     { 0, NULL}
    359 };
    360 
    361 void
    362 lmp_print(register const u_char *pptr, register u_int len) {
    363 
    364     const struct lmp_common_header *lmp_com_header;
    365     const struct lmp_object_header *lmp_obj_header;
    366     const u_char *tptr,*obj_tptr;
    367     int tlen,lmp_obj_len,lmp_obj_ctype,obj_tlen;
    368     int hexdump;
    369     int offset,subobj_type,subobj_len,total_subobj_len;
    370     int link_type;
    371 
    372     union { /* int to float conversion buffer */
    373         float f;
    374         u_int32_t i;
    375     } bw;
    376 
    377     tptr=pptr;
    378     lmp_com_header = (const struct lmp_common_header *)pptr;
    379     TCHECK(*lmp_com_header);
    380 
    381     /*
    382      * Sanity checking of the header.
    383      */
    384     if (LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]) != LMP_VERSION) {
    385 	printf("LMP version %u packet not supported",
    386                LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]));
    387 	return;
    388     }
    389 
    390     /* in non-verbose mode just lets print the basic Message Type*/
    391     if (vflag < 1) {
    392         printf("LMPv%u %s Message, length: %u",
    393                LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]),
    394                tok2str(lmp_msg_type_values, "unknown (%u)",lmp_com_header->msg_type),
    395                len);
    396         return;
    397     }
    398 
    399     /* ok they seem to want to know everything - lets fully decode it */
    400 
    401     tlen=EXTRACT_16BITS(lmp_com_header->length);
    402 
    403     printf("\n\tLMPv%u, msg-type: %s, Flags: [%s], length: %u",
    404            LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]),
    405            tok2str(lmp_msg_type_values, "unknown, type: %u",lmp_com_header->msg_type),
    406            bittok2str(lmp_header_flag_values,"none",lmp_com_header->flags),
    407            tlen);
    408 
    409     tptr+=sizeof(const struct lmp_common_header);
    410     tlen-=sizeof(const struct lmp_common_header);
    411 
    412     while(tlen>0) {
    413         /* did we capture enough for fully decoding the object header ? */
    414         if (!TTEST2(*tptr, sizeof(struct lmp_object_header)))
    415             goto trunc;
    416 
    417         lmp_obj_header = (const struct lmp_object_header *)tptr;
    418         lmp_obj_len=EXTRACT_16BITS(lmp_obj_header->length);
    419         lmp_obj_ctype=(lmp_obj_header->ctype)&0x7f;
    420 
    421         if(lmp_obj_len % 4 || lmp_obj_len < 4)
    422             return;
    423 
    424         printf("\n\t  %s Object (%u), Class-Type: %s (%u) Flags: [%snegotiable], length: %u",
    425                tok2str(lmp_obj_values,
    426                        "Unknown",
    427                        lmp_obj_header->class_num),
    428                lmp_obj_header->class_num,
    429                tok2str(lmp_ctype_values,
    430                        "Unknown",
    431                        ((lmp_obj_header->class_num)<<8)+lmp_obj_ctype),
    432                lmp_obj_ctype,
    433                (lmp_obj_header->ctype)&0x80 ? "" : "non-",
    434                lmp_obj_len);
    435 
    436         obj_tptr=tptr+sizeof(struct lmp_object_header);
    437         obj_tlen=lmp_obj_len-sizeof(struct lmp_object_header);
    438 
    439         /* did we capture enough for fully decoding the object ? */
    440         if (!TTEST2(*tptr, lmp_obj_len))
    441             goto trunc;
    442         hexdump=FALSE;
    443 
    444         switch(lmp_obj_header->class_num) {
    445 
    446         case LMP_OBJ_CC_ID:
    447             switch(lmp_obj_ctype) {
    448             case LMP_CTYPE_LOC:
    449             case LMP_CTYPE_RMT:
    450                 printf("\n\t    Control Channel ID: %u (0x%08x)",
    451                        EXTRACT_32BITS(obj_tptr),
    452                        EXTRACT_32BITS(obj_tptr));
    453                 break;
    454 
    455             default:
    456                 hexdump=TRUE;
    457             }
    458             break;
    459 
    460         case LMP_OBJ_LINK_ID:
    461         case LMP_OBJ_INTERFACE_ID:
    462             switch(lmp_obj_ctype) {
    463             case LMP_CTYPE_IPV4_LOC:
    464             case LMP_CTYPE_IPV4_RMT:
    465                 printf("\n\t    IPv4 Link ID: %s (0x%08x)",
    466                        ipaddr_string(obj_tptr),
    467                        EXTRACT_32BITS(obj_tptr));
    468                 break;
    469 #ifdef INET6
    470             case LMP_CTYPE_IPV6_LOC:
    471             case LMP_CTYPE_IPV6_RMT:
    472                 printf("\n\t    IPv6 Link ID: %s (0x%08x)",
    473                        ip6addr_string(obj_tptr),
    474                        EXTRACT_32BITS(obj_tptr));
    475                 break;
    476 #endif
    477             case LMP_CTYPE_UNMD_LOC:
    478             case LMP_CTYPE_UNMD_RMT:
    479                 printf("\n\t    Link ID: %u (0x%08x)",
    480                        EXTRACT_32BITS(obj_tptr),
    481                        EXTRACT_32BITS(obj_tptr));
    482                 break;
    483             default:
    484                 hexdump=TRUE;
    485             }
    486             break;
    487 
    488         case LMP_OBJ_MESSAGE_ID:
    489             switch(lmp_obj_ctype) {
    490             case LMP_CTYPE_1:
    491                 printf("\n\t    Message ID: %u (0x%08x)",
    492                        EXTRACT_32BITS(obj_tptr),
    493                        EXTRACT_32BITS(obj_tptr));
    494                 break;
    495             case LMP_CTYPE_2:
    496                 printf("\n\t    Message ID Ack: %u (0x%08x)",
    497                        EXTRACT_32BITS(obj_tptr),
    498                        EXTRACT_32BITS(obj_tptr));
    499                 break;
    500             default:
    501                 hexdump=TRUE;
    502             }
    503             break;
    504 
    505         case LMP_OBJ_NODE_ID:
    506             switch(lmp_obj_ctype) {
    507             case LMP_CTYPE_LOC:
    508             case LMP_CTYPE_RMT:
    509                 printf("\n\t    Node ID: %s (0x%08x)",
    510                        ipaddr_string(obj_tptr),
    511                        EXTRACT_32BITS(obj_tptr));
    512                 break;
    513 
    514             default:
    515                 hexdump=TRUE;
    516             }
    517             break;
    518 
    519         case LMP_OBJ_CONFIG:
    520             switch(lmp_obj_ctype) {
    521             case LMP_CTYPE_HELLO_CONFIG:
    522                 printf("\n\t    Hello Interval: %u\n\t    Hello Dead Interval: %u",
    523                        EXTRACT_16BITS(obj_tptr),
    524                        EXTRACT_16BITS(obj_tptr+2));
    525                 break;
    526 
    527             default:
    528                 hexdump=TRUE;
    529             }
    530             break;
    531 
    532         case LMP_OBJ_HELLO:
    533             switch(lmp_obj_ctype) {
    534 	    case LMP_CTYPE_HELLO:
    535                 printf("\n\t    TxSeqNum: %u\n\t    RcvSeqNum: %u",
    536                        EXTRACT_32BITS(obj_tptr),
    537                        EXTRACT_32BITS(obj_tptr+4));
    538                 break;
    539 
    540             default:
    541                 hexdump=TRUE;
    542             }
    543             break;
    544 
    545         case LMP_OBJ_TE_LINK:
    546 		printf("\n\t    Flags: [%s]",
    547 		bittok2str(lmp_obj_te_link_flag_values,
    548 			"none",
    549 			EXTRACT_16BITS(obj_tptr)>>8));
    550 
    551 	    switch(lmp_obj_ctype) {
    552 	    case LMP_CTYPE_IPV4:
    553 		printf("\n\t    Local Link-ID: %s (0x%08x) \
    554 			\n\t    Remote Link-ID: %s (0x%08x)",
    555                        ipaddr_string(obj_tptr+4),
    556                        EXTRACT_32BITS(obj_tptr+4),
    557                        ipaddr_string(obj_tptr+8),
    558                        EXTRACT_32BITS(obj_tptr+8));
    559 		break;
    560 
    561 #ifdef INET6
    562 	    case LMP_CTYPE_IPV6:
    563 #endif
    564 	    case LMP_CTYPE_UNMD:
    565             default:
    566                 hexdump=TRUE;
    567             }
    568             break;
    569 
    570         case LMP_OBJ_DATA_LINK:
    571 		printf("\n\t    Flags: [%s]",
    572 		bittok2str(lmp_obj_data_link_flag_values,
    573 			"none",
    574 			EXTRACT_16BITS(obj_tptr)>>8));
    575 
    576 	    switch(lmp_obj_ctype) {
    577 	    case LMP_CTYPE_IPV4:
    578 	    case LMP_CTYPE_UNMD:
    579                 printf("\n\t    Local Interface ID: %s (0x%08x) \
    580 			\n\t    Remote Interface ID: %s (0x%08x)",
    581                        ipaddr_string(obj_tptr+4),
    582                        EXTRACT_32BITS(obj_tptr+4),
    583                        ipaddr_string(obj_tptr+8),
    584                        EXTRACT_32BITS(obj_tptr+8));
    585 
    586 		total_subobj_len = lmp_obj_len - 16;
    587 		offset = 12;
    588 		while (total_subobj_len > 0 && hexdump == FALSE ) {
    589 			subobj_type = EXTRACT_16BITS(obj_tptr+offset)>>8;
    590 			subobj_len  = EXTRACT_16BITS(obj_tptr+offset)&0x00FF;
    591 			printf("\n\t    Subobject, Type: %s (%u), Length: %u",
    592 				tok2str(lmp_data_link_subobj,
    593 					"Unknown",
    594 					subobj_type),
    595 					subobj_type,
    596 					subobj_len);
    597 			switch(subobj_type) {
    598 			case INT_SWITCHING_TYPE_SUBOBJ:
    599 				printf("\n\t      Switching Type: %s (%u)",
    600 					tok2str(gmpls_switch_cap_values,
    601 						"Unknown",
    602 						EXTRACT_16BITS(obj_tptr+offset+2)>>8),
    603 					EXTRACT_16BITS(obj_tptr+offset+2)>>8);
    604 				printf("\n\t      Encoding Type: %s (%u)",
    605 					tok2str(gmpls_encoding_values,
    606 						"Unknown",
    607 						EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF),
    608 					EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF);
    609 				bw.i = EXTRACT_32BITS(obj_tptr+offset+4);
    610 				printf("\n\t      Min Reservable Bandwidth: %.3f Mbps",
    611                                        bw.f*8/1000000);
    612 				bw.i = EXTRACT_32BITS(obj_tptr+offset+8);
    613 				printf("\n\t      Max Reservable Bandwidth: %.3f Mbps",
    614                                        bw.f*8/1000000);
    615 				break;
    616 			case WAVELENGTH_SUBOBJ:
    617 				printf("\n\t      Wavelength: %u",
    618 					EXTRACT_32BITS(obj_tptr+offset+4));
    619 				break;
    620 			default:
    621 				/* Any Unknown Subobject ==> Exit loop */
    622 				hexdump=TRUE;
    623 				break;
    624 			}
    625 			total_subobj_len-=subobj_len;
    626 			offset+=subobj_len;
    627 		}
    628 
    629 		break;
    630 #ifdef INET6
    631 	    case LMP_CTYPE_IPV6:
    632 #endif
    633             default:
    634                 hexdump=TRUE;
    635             }
    636             break;
    637 
    638         case LMP_OBJ_VERIFY_BEGIN:
    639 	    switch(lmp_obj_ctype) {
    640             case LMP_CTYPE_1:
    641 		printf("\n\t    Flags: %s",
    642 		bittok2str(lmp_obj_begin_verify_flag_values,
    643 			"none",
    644 			EXTRACT_16BITS(obj_tptr)));
    645 		printf("\n\t    Verify Interval: %u",
    646 			EXTRACT_16BITS(obj_tptr+2));
    647 		printf("\n\t    Data links: %u",
    648 			EXTRACT_32BITS(obj_tptr+4));
    649                 printf("\n\t    Encoding type: %s",
    650 			tok2str(gmpls_encoding_values, "Unknown", *(obj_tptr+8)));
    651                 printf("\n\t    Verify Tranport Mechanism: %u (0x%x) %s",
    652 			EXTRACT_16BITS(obj_tptr+10),
    653 			EXTRACT_16BITS(obj_tptr+10),
    654 			EXTRACT_16BITS(obj_tptr+10)&8000 ? "(Payload test messages capable)" : "");
    655                 bw.i = EXTRACT_32BITS(obj_tptr+12);
    656 		printf("\n\t    Transmission Rate: %.3f Mbps",bw.f*8/1000000);
    657 		printf("\n\t    Wavelength: %u",
    658 			EXTRACT_32BITS(obj_tptr+16));
    659 		break;
    660 
    661             default:
    662                 hexdump=TRUE;
    663             }
    664             break;
    665 
    666         case LMP_OBJ_VERIFY_BEGIN_ACK:
    667 	    switch(lmp_obj_ctype) {
    668             case LMP_CTYPE_1:
    669                 printf("\n\t    Verify Dead Interval: %u 	\
    670 			\n\t    Verify Transport Response: %u",
    671                        EXTRACT_16BITS(obj_tptr),
    672                        EXTRACT_16BITS(obj_tptr+2));
    673                 break;
    674 
    675             default:
    676                 hexdump=TRUE;
    677             }
    678             break;
    679 
    680 	case LMP_OBJ_VERIFY_ID:
    681 	    switch(lmp_obj_ctype) {
    682             case LMP_CTYPE_1:
    683                 printf("\n\t    Verify ID: %u",
    684                        EXTRACT_32BITS(obj_tptr));
    685                 break;
    686 
    687             default:
    688                 hexdump=TRUE;
    689             }
    690             break;
    691 
    692 	case LMP_OBJ_CHANNEL_STATUS:
    693             switch(lmp_obj_ctype) {
    694 	    case LMP_CTYPE_IPV4:
    695 	    case LMP_CTYPE_UNMD:
    696 		offset = 0;
    697 		/* Decode pairs: <Interface_ID (4 bytes), Channel_status (4 bytes)> */
    698 		while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) {
    699 			printf("\n\t    Interface ID: %s (0x%08x)",
    700 			ipaddr_string(obj_tptr+offset),
    701 			EXTRACT_32BITS(obj_tptr+offset));
    702 
    703 			printf("\n\t\t    Active: %s (%u)", 		(EXTRACT_32BITS(obj_tptr+offset+4)>>31) ?
    704 						"Allocated" : "Non-allocated",
    705 				(EXTRACT_32BITS(obj_tptr+offset+4)>>31));
    706 
    707 			printf("\n\t\t    Direction: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ?
    708 						"Transmit" : "Receive",
    709 				(EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1);
    710 
    711 			printf("\n\t\t    Channel Status: %s (%u)",
    712 					tok2str(lmp_obj_channel_status_values,
    713 			 		"Unknown",
    714 					EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF),
    715 			EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF);
    716 			offset+=8;
    717 		}
    718                 break;
    719 #ifdef INET6
    720 	    case LMP_CTYPE_IPV6:
    721 #endif
    722             default:
    723                 hexdump=TRUE;
    724             }
    725             break;
    726 
    727 	case LMP_OBJ_CHANNEL_STATUS_REQ:
    728             switch(lmp_obj_ctype) {
    729 	    case LMP_CTYPE_IPV4:
    730 	    case LMP_CTYPE_UNMD:
    731 		offset = 0;
    732 		while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) {
    733 			printf("\n\t    Interface ID: %s (0x%08x)",
    734 			ipaddr_string(obj_tptr+offset),
    735 			EXTRACT_32BITS(obj_tptr+offset));
    736 			offset+=4;
    737 		}
    738                 break;
    739 #ifdef INET6
    740 	    case LMP_CTYPE_IPV6:
    741 #endif
    742 	    default:
    743                 hexdump=TRUE;
    744             }
    745             break;
    746 
    747         case LMP_OBJ_ERROR_CODE:
    748 	    switch(lmp_obj_ctype) {
    749             case LMP_CTYPE_BEGIN_VERIFY_ERROR:
    750 		printf("\n\t    Error Code: %s",
    751 		bittok2str(lmp_obj_begin_verify_error_values,
    752 			"none",
    753 			EXTRACT_32BITS(obj_tptr)));
    754                 break;
    755 
    756             case LMP_CTYPE_LINK_SUMMARY_ERROR:
    757 		printf("\n\t    Error Code: %s",
    758 		bittok2str(lmp_obj_link_summary_error_values,
    759 			"none",
    760 			EXTRACT_32BITS(obj_tptr)));
    761                 break;
    762             default:
    763                 hexdump=TRUE;
    764             }
    765             break;
    766 
    767 	case LMP_OBJ_SERVICE_CONFIG:
    768 	    switch (lmp_obj_ctype) {
    769 	    case LMP_CTYPE_SERVICE_CONFIG_SP:
    770 
    771 		printf("\n\t Flags: %s",
    772 		       bittok2str(lmp_obj_service_config_sp_flag_values,
    773 				  "none",
    774 				  EXTRACT_16BITS(obj_tptr)>>8));
    775 
    776 		printf("\n\t  UNI Version: %u",
    777 		       EXTRACT_16BITS(obj_tptr) & 0x00FF);
    778 
    779 		break;
    780 
    781             case LMP_CTYPE_SERVICE_CONFIG_CPSA:
    782 
    783 		link_type = EXTRACT_16BITS(obj_tptr)>>8;
    784 
    785 		printf("\n\t Link Type: %s (%u)",
    786 		       tok2str(lmp_sd_service_config_cpsa_link_type_values,
    787 			       "Unknown", link_type),
    788 		       link_type);
    789 
    790 		if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH) {
    791 		    printf("\n\t Signal Type: %s (%u)",
    792 			   tok2str(lmp_sd_service_config_cpsa_signal_type_sdh_values,
    793 				   "Unknown",
    794 				   EXTRACT_16BITS(obj_tptr) & 0x00FF),
    795 			   EXTRACT_16BITS(obj_tptr) & 0x00FF);
    796 		}
    797 
    798 		if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET) {
    799 		    printf("\n\t Signal Type: %s (%u)",
    800 			   tok2str(lmp_sd_service_config_cpsa_signal_type_sonet_values,
    801 				   "Unknown",
    802 				   EXTRACT_16BITS(obj_tptr) & 0x00FF),
    803 			   EXTRACT_16BITS(obj_tptr) & 0x00FF);
    804 		}
    805 
    806 		printf("\n\t Transparency: %s",
    807 		       bittok2str(lmp_obj_service_config_cpsa_tp_flag_values,
    808 				  "none",
    809 				  EXTRACT_16BITS(obj_tptr+2)>>8));
    810 
    811 		printf("\n\t Contiguous Concatenation Types: %s",
    812 		       bittok2str(lmp_obj_service_config_cpsa_cct_flag_values,
    813 				  "none",
    814 				  EXTRACT_16BITS(obj_tptr+2)>>8 & 0x00FF));
    815 
    816 		printf("\n\t Minimum NCC: %u",
    817 		       EXTRACT_16BITS(obj_tptr+4));
    818 
    819 		printf("\n\t Maximum NCC: %u",
    820 		       EXTRACT_16BITS(obj_tptr+6));
    821 
    822 		printf("\n\t Minimum NVC:%u",
    823 		       EXTRACT_16BITS(obj_tptr+8));
    824 
    825 		printf("\n\t Maximum NVC:%u",
    826 		       EXTRACT_16BITS(obj_tptr+10));
    827 
    828 		printf("\n\t    Local Interface ID: %s (0x%08x)",
    829 		       ipaddr_string(obj_tptr+12),
    830 		       EXTRACT_32BITS(obj_tptr+12));
    831 
    832 		break;
    833 
    834 	    case LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM:
    835 
    836 		printf("\n\t Transparency Flags: %s",
    837 		       bittok2str(
    838 			   lmp_obj_service_config_nsa_transparency_flag_values,
    839 			   "none",
    840 			   EXTRACT_32BITS(obj_tptr)));
    841 
    842 		printf("\n\t TCM Monitoring Flags: %s",
    843 		       bittok2str(
    844 			   lmp_obj_service_config_nsa_tcm_flag_values,
    845 			   "none",
    846 			   EXTRACT_16BITS(obj_tptr+6) & 0x00FF));
    847 
    848 		break;
    849 
    850 	    case LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY:
    851 
    852 		printf("\n\t Diversity: Flags: %s",
    853 		       bittok2str(
    854 			   lmp_obj_service_config_nsa_network_diversity_flag_values,
    855 			   "none",
    856 			   EXTRACT_16BITS(obj_tptr+2) & 0x00FF));
    857 		break;
    858 
    859 	    default:
    860 		hexdump = TRUE;
    861 	    };
    862 
    863 	break;
    864 
    865         default:
    866             if (vflag <= 1)
    867                 print_unknown_data(obj_tptr,"\n\t    ",obj_tlen);
    868             break;
    869         }
    870         /* do we want to see an additionally hexdump ? */
    871         if (vflag > 1 || hexdump==TRUE)
    872             print_unknown_data(tptr+sizeof(sizeof(struct lmp_object_header)),"\n\t    ",
    873                                lmp_obj_len-sizeof(struct lmp_object_header));
    874 
    875         tptr+=lmp_obj_len;
    876         tlen-=lmp_obj_len;
    877     }
    878     return;
    879 trunc:
    880     printf("\n\t\t packet exceeded snapshot");
    881 }
    882