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