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