4 * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 #include <sys/cdefs.h>
27 static const char rcsid
[] _U_
=
28 "@(#)Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32.2.15 2006/02/01 14:39:56 hannes Exp (LBL)";
30 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
38 #include <tcpdump-stdinc.h>
44 #include "addrtoname.h"
45 #include "interface.h"
46 #include "ethertype.h"
51 static void frf15_print(const u_char
*, u_int
);
54 * the frame relay header has a variable length
56 * the EA bit determines if there is another byte
59 * minimum header length is 2 bytes
60 * maximum header length is 4 bytes
63 * +----+----+----+----+----+----+----+----+
64 * | DLCI (6 bits) | CR | EA |
65 * +----+----+----+----+----+----+----+----+
66 * | DLCI (4 bits) |FECN|BECN| DE | EA |
67 * +----+----+----+----+----+----+----+----+
68 * | DLCI (7 bits) | EA |
69 * +----+----+----+----+----+----+----+----+
70 * | DLCI (6 bits) |SDLC| EA |
71 * +----+----+----+----+----+----+----+----+
74 #define FR_EA_BIT 0x01
76 #define FR_CR_BIT 0x02000000
77 #define FR_DE_BIT 0x00020000
78 #define FR_BECN_BIT 0x00040000
79 #define FR_FECN_BIT 0x00080000
80 #define FR_SDLC_BIT 0x00000002
83 struct tok fr_header_flag_values
[] = {
86 { FR_BECN_BIT
, "BECN" },
87 { FR_FECN_BIT
, "FECN" },
88 { FR_SDLC_BIT
, "sdlcore" },
93 #define MFR_B_BIT 0x80
94 #define MFR_E_BIT 0x40
95 #define MFR_C_BIT 0x20
96 #define MFR_BEC_MASK (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT)
97 #define MFR_CTRL_FRAME (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT)
98 #define MFR_FRAG_FRAME (MFR_B_BIT | MFR_E_BIT )
100 struct tok frf_flag_values
[] = {
101 { MFR_B_BIT
, "Begin" },
102 { MFR_E_BIT
, "End" },
103 { MFR_C_BIT
, "Control" },
107 /* Finds out Q.922 address length, DLCI and flags. Returns 0 on success
108 * save the flags dep. on address length
110 static int parse_q922_addr(const u_char
*p
, u_int
*dlci
, u_int
*sdlcore
,
111 u_int
*addr_len
, u_int8_t
*flags
)
113 if ((p
[0] & FR_EA_BIT
))
117 *dlci
= ((p
[0] & 0xFC) << 2) | ((p
[1] & 0xF0) >> 4);
119 flags
[0] = p
[0] & 0x02; /* populate the first flag fields */
120 flags
[1] = p
[1] & 0x0c;
121 flags
[2] = 0; /* clear the rest of the flags */
124 if (p
[1] & FR_EA_BIT
)
125 return 0; /* 2-byte Q.922 address */
128 (*addr_len
)++; /* 3- or 4-byte Q.922 address */
129 if ((p
[0] & FR_EA_BIT
) == 0) {
130 *dlci
= (*dlci
<< 7) | (p
[0] >> 1);
131 (*addr_len
)++; /* 4-byte Q.922 address */
135 if ((p
[0] & FR_EA_BIT
) == 0)
136 return -1; /* more than 4 bytes of Q.922 address? */
138 flags
[3] = p
[0] & 0x02;
141 *sdlcore
= p
[0] >> 2;
143 *dlci
= (*dlci
<< 6) | (p
[0] >> 2);
148 /* Frame Relay packet structure, with flags and CRC removed
150 +---------------------------+
154 +---------------------------+
155 | Control (UI = 0x03) |
156 +---------------------------+
157 | Optional Pad (0x00) |
158 +---------------------------+
160 +---------------------------+
167 +---------------------------+
169 * Q.922 addresses, as presently defined, are two octets and
170 contain a 10-bit DLCI. In some networks Q.922 addresses
171 may optionally be increased to three or four octets.
175 fr_hdrlen(const u_char
*p
, u_int addr_len
)
177 if (!p
[addr_len
+ 1] /* pad exist */)
178 return addr_len
+ 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */;
180 return addr_len
+ 1 /* UI */ + 1 /* NLPID */;
184 fr_hdr_print(int length
, u_int addr_len
, u_int dlci
, u_int8_t
*flags
, u_int16_t nlpid
)
187 (void)printf("Q.922, DLCI %u, length %u: ",
191 if (nlpid
<= 0xff) /* if its smaller than 256 then its a NLPID */
192 (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
195 bittok2str(fr_header_flag_values
, "none", EXTRACT_32BITS(flags
)),
196 tok2str(nlpid_values
,"unknown", nlpid
),
199 else /* must be an ethertype */
200 (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
203 bittok2str(fr_header_flag_values
, "none", EXTRACT_32BITS(flags
)),
204 tok2str(ethertype_values
, "unknown", nlpid
),
211 fr_if_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
213 register u_int length
= h
->len
;
214 register u_int caplen
= h
->caplen
;
216 TCHECK2(*p
, 4); /* minimum frame header length */
218 if ((length
= fr_print(p
, length
)) == 0)
228 fr_print(register const u_char
*p
, u_int length
)
230 u_int16_t extracted_ethertype
;
238 if (parse_q922_addr(p
, &dlci
, &sdlcore
, &addr_len
, flags
)) {
239 printf("Q.922, invalid address");
243 TCHECK2(*p
,addr_len
+1+1);
244 hdr_len
= fr_hdrlen(p
, addr_len
);
247 if (p
[addr_len
] != 0x03 && dlci
!= 0) {
249 /* lets figure out if we have cisco style encapsulation: */
250 extracted_ethertype
= EXTRACT_16BITS(p
+addr_len
);
253 fr_hdr_print(length
, addr_len
, dlci
, flags
, extracted_ethertype
);
255 if (ether_encap_print(extracted_ethertype
,
256 p
+addr_len
+ETHERTYPE_LEN
,
257 length
-addr_len
-ETHERTYPE_LEN
,
258 length
-addr_len
-ETHERTYPE_LEN
,
259 &extracted_ethertype
) == 0)
260 /* ether_type not known, probably it wasn't one */
261 printf("UI %02x! ", p
[addr_len
]);
266 if (!p
[addr_len
+ 1]) { /* pad byte should be used with 3-byte Q.922 */
269 } else if (addr_len
== 3)
272 nlpid
= p
[hdr_len
- 1];
275 fr_hdr_print(length
, addr_len
, dlci
, flags
, nlpid
);
281 ip_print(gndo
, p
, length
);
286 ip6_print(p
, length
);
292 isoclns_print(p
-1, length
+1, length
+1); /* OSI printers need the NLPID field */
296 if (snap_print(p
, length
, length
, &extracted_ethertype
, 0) == 0) {
297 /* ether_type not known, print raw packet */
299 fr_hdr_print(length
+ hdr_len
, hdr_len
,
301 if (!suppress_default_print
)
302 default_print(p
- hdr_len
, length
+ hdr_len
);
307 q933_print(p
, length
);
311 frf15_print(p
, length
);
315 ppp_print(p
, length
);
320 fr_hdr_print(length
+ hdr_len
, addr_len
,
323 default_print(p
, length
);
335 mfr_if_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
337 register u_int length
= h
->len
;
338 register u_int caplen
= h
->caplen
;
340 TCHECK2(*p
, 2); /* minimum frame header length */
342 if ((length
= mfr_print(p
, length
)) == 0)
352 #define MFR_CTRL_MSG_ADD_LINK 1
353 #define MFR_CTRL_MSG_ADD_LINK_ACK 2
354 #define MFR_CTRL_MSG_ADD_LINK_REJ 3
355 #define MFR_CTRL_MSG_HELLO 4
356 #define MFR_CTRL_MSG_HELLO_ACK 5
357 #define MFR_CTRL_MSG_REMOVE_LINK 6
358 #define MFR_CTRL_MSG_REMOVE_LINK_ACK 7
360 struct tok mfr_ctrl_msg_values
[] = {
361 { MFR_CTRL_MSG_ADD_LINK
, "Add Link" },
362 { MFR_CTRL_MSG_ADD_LINK_ACK
, "Add Link ACK" },
363 { MFR_CTRL_MSG_ADD_LINK_REJ
, "Add Link Reject" },
364 { MFR_CTRL_MSG_HELLO
, "Hello" },
365 { MFR_CTRL_MSG_HELLO_ACK
, "Hello ACK" },
366 { MFR_CTRL_MSG_REMOVE_LINK
, "Remove Link" },
367 { MFR_CTRL_MSG_REMOVE_LINK_ACK
, "Remove Link ACK" },
371 #define MFR_CTRL_IE_BUNDLE_ID 1
372 #define MFR_CTRL_IE_LINK_ID 2
373 #define MFR_CTRL_IE_MAGIC_NUM 3
374 #define MFR_CTRL_IE_TIMESTAMP 5
375 #define MFR_CTRL_IE_VENDOR_EXT 6
376 #define MFR_CTRL_IE_CAUSE 7
378 struct tok mfr_ctrl_ie_values
[] = {
379 { MFR_CTRL_IE_BUNDLE_ID
, "Bundle ID"},
380 { MFR_CTRL_IE_LINK_ID
, "Link ID"},
381 { MFR_CTRL_IE_MAGIC_NUM
, "Magic Number"},
382 { MFR_CTRL_IE_TIMESTAMP
, "Timestamp"},
383 { MFR_CTRL_IE_VENDOR_EXT
, "Vendor Extension"},
384 { MFR_CTRL_IE_CAUSE
, "Cause"},
388 #define MFR_ID_STRING_MAXLEN 50
390 struct ie_tlv_header_t
{
396 mfr_print(register const u_char
*p
, u_int length
)
398 u_int tlen
,idx
,hdr_len
= 0;
399 u_int16_t sequence_num
;
400 u_int8_t ie_type
,ie_len
;
401 const u_int8_t
*tptr
;
405 * FRF.16 Link Integrity Control Frame
408 * +----+----+----+----+----+----+----+----+
409 * | B | E | C=1| 0 0 0 0 | EA |
410 * +----+----+----+----+----+----+----+----+
411 * | 0 0 0 0 0 0 0 0 |
412 * +----+----+----+----+----+----+----+----+
414 * +----+----+----+----+----+----+----+----+
417 TCHECK2(*p
, 4); /* minimum frame header length */
419 if ((p
[0] & MFR_BEC_MASK
) == MFR_CTRL_FRAME
&& p
[1] == 0) {
420 printf("FRF.16 Control, Flags [%s], %s, length %u",
421 bittok2str(frf_flag_values
,"none",(p
[0] & MFR_BEC_MASK
)),
422 tok2str(mfr_ctrl_msg_values
,"Unknown Message (0x%02x)",p
[2]),
431 while (tlen
>sizeof(struct ie_tlv_header_t
)) {
432 TCHECK2(*tptr
, sizeof(struct ie_tlv_header_t
));
436 printf("\n\tIE %s (%u), length %u: ",
437 tok2str(mfr_ctrl_ie_values
,"Unknown",ie_type
),
441 /* infinite loop check */
442 if (ie_type
== 0 || ie_len
<= sizeof(struct ie_tlv_header_t
))
445 TCHECK2(*tptr
,ie_len
);
446 tptr
+=sizeof(struct ie_tlv_header_t
);
447 /* tlv len includes header */
448 ie_len
-=sizeof(struct ie_tlv_header_t
);
449 tlen
-=sizeof(struct ie_tlv_header_t
);
453 case MFR_CTRL_IE_MAGIC_NUM
:
454 printf("0x%08x",EXTRACT_32BITS(tptr
));
457 case MFR_CTRL_IE_BUNDLE_ID
: /* same message format */
458 case MFR_CTRL_IE_LINK_ID
:
459 for (idx
= 0; idx
< ie_len
&& idx
< MFR_ID_STRING_MAXLEN
; idx
++) {
460 if (*(tptr
+idx
) != 0) /* don't print null termination */
461 safeputchar(*(tptr
+idx
));
467 case MFR_CTRL_IE_TIMESTAMP
:
468 if (ie_len
== sizeof(struct timeval
)) {
469 ts_print((const struct timeval
*)tptr
);
472 /* fall through and hexdump if no unix timestamp */
475 * FIXME those are the defined IEs that lack a decoder
476 * you are welcome to contribute code ;-)
479 case MFR_CTRL_IE_VENDOR_EXT
:
480 case MFR_CTRL_IE_CAUSE
:
484 print_unknown_data(tptr
,"\n\t ",ie_len
);
488 /* do we want to see a hexdump of the IE ? */
490 print_unknown_data(tptr
,"\n\t ",ie_len
);
498 * FRF.16 Fragmentation Frame
501 * +----+----+----+----+----+----+----+----+
502 * | B | E | C=0|seq. (high 4 bits) | EA |
503 * +----+----+----+----+----+----+----+----+
504 * | sequence (low 8 bits) |
505 * +----+----+----+----+----+----+----+----+
506 * | DLCI (6 bits) | CR | EA |
507 * +----+----+----+----+----+----+----+----+
508 * | DLCI (4 bits) |FECN|BECN| DE | EA |
509 * +----+----+----+----+----+----+----+----+
512 sequence_num
= (p
[0]&0x1e)<<7 | p
[1];
513 /* whole packet or first fragment ? */
514 if ((p
[0] & MFR_BEC_MASK
) == MFR_FRAG_FRAME
||
515 (p
[0] & MFR_BEC_MASK
) == MFR_B_BIT
) {
516 printf("FRF.16 Frag, seq %u, Flags [%s], ",
518 bittok2str(frf_flag_values
,"none",(p
[0] & MFR_BEC_MASK
)));
520 fr_print(p
+hdr_len
,length
-hdr_len
);
524 /* must be a middle or the last fragment */
525 printf("FRF.16 Frag, seq %u, Flags [%s]",
527 bittok2str(frf_flag_values
,"none",(p
[0] & MFR_BEC_MASK
)));
528 print_unknown_data(p
,"\n\t",length
);
537 /* an NLPID of 0xb1 indicates a 2-byte
541 * +----+----+----+----+----+----+----+----+
543 * +----+----+----+----+----+----+----+----+
544 * | NLPID (8 bits) | NLPID=0xb1
545 * +----+----+----+----+----+----+----+----+
546 * | B | E | C |seq. (high 4 bits) | R |
547 * +----+----+----+----+----+----+----+----+
548 * | sequence (low 8 bits) |
549 * +----+----+----+----+----+----+----+----+
552 #define FR_FRF15_FRAGTYPE 0x01
555 frf15_print (const u_char
*p
, u_int length
) {
557 u_int16_t sequence_num
, flags
;
559 flags
= p
[0]&MFR_BEC_MASK
;
560 sequence_num
= (p
[0]&0x1e)<<7 | p
[1];
562 printf("FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
564 bittok2str(frf_flag_values
,"none",flags
),
565 p
[0]&FR_FRF15_FRAGTYPE
? "Interface" : "End-to-End",
569 * depending on all permutations of the B, E and C bit
570 * dig as deep as we can - e.g. on the first (B) fragment
571 * there is enough payload to print the IP header
572 * on non (B) fragments it depends if the fragmentation
573 * model is end-to-end or interface based wether we want to print
574 * another Q.922 header
580 * Q.933 decoding portion for framerelay specific.
583 /* Q.933 packet format
584 Format of Other Protocols
586 +-------------------------------+
588 +---------------+---------------+
589 |Control 0x03 | NLPID 0x08 |
590 +---------------+---------------+
592 | octet 1 | octet 2 |
593 +-------------------------------+
595 | octet 2 | octet 2 |
596 +-------------------------------+
598 +-------------------------------+
600 +-------------------------------+
603 /* L2 (Octet 1)- Call Reference Usually is 0x0 */
606 * L2 (Octet 2)- Message Types definition 1 byte long.
609 #define MSG_TYPE_ESC_TO_NATIONAL 0x00
610 #define MSG_TYPE_ALERT 0x01
611 #define MSG_TYPE_CALL_PROCEEDING 0x02
612 #define MSG_TYPE_CONNECT 0x07
613 #define MSG_TYPE_CONNECT_ACK 0x0F
614 #define MSG_TYPE_PROGRESS 0x03
615 #define MSG_TYPE_SETUP 0x05
617 #define MSG_TYPE_DISCONNECT 0x45
618 #define MSG_TYPE_RELEASE 0x4D
619 #define MSG_TYPE_RELEASE_COMPLETE 0x5A
620 #define MSG_TYPE_RESTART 0x46
621 #define MSG_TYPE_RESTART_ACK 0x4E
623 #define MSG_TYPE_STATUS 0x7D
624 #define MSG_TYPE_STATUS_ENQ 0x75
626 struct tok fr_q933_msg_values
[] = {
627 { MSG_TYPE_ESC_TO_NATIONAL
, "ESC to National" },
628 { MSG_TYPE_ALERT
, "Alert" },
629 { MSG_TYPE_CALL_PROCEEDING
, "Call proceeding" },
630 { MSG_TYPE_CONNECT
, "Connect" },
631 { MSG_TYPE_CONNECT_ACK
, "Connect ACK" },
632 { MSG_TYPE_PROGRESS
, "Progress" },
633 { MSG_TYPE_SETUP
, "Setup" },
634 { MSG_TYPE_DISCONNECT
, "Disconnect" },
635 { MSG_TYPE_RELEASE
, "Release" },
636 { MSG_TYPE_RELEASE_COMPLETE
, "Release Complete" },
637 { MSG_TYPE_RESTART
, "Restart" },
638 { MSG_TYPE_RESTART_ACK
, "Restart ACK" },
639 { MSG_TYPE_STATUS
, "Status Reply" },
640 { MSG_TYPE_STATUS_ENQ
, "Status Enquiry" },
644 #define MSG_ANSI_LOCKING_SHIFT 0x95
646 #define FR_LMI_ANSI_REPORT_TYPE_IE 0x01
647 #define FR_LMI_ANSI_LINK_VERIFY_IE_91 0x19 /* details? */
648 #define FR_LMI_ANSI_LINK_VERIFY_IE 0x03
649 #define FR_LMI_ANSI_PVC_STATUS_IE 0x07
651 #define FR_LMI_CCITT_REPORT_TYPE_IE 0x51
652 #define FR_LMI_CCITT_LINK_VERIFY_IE 0x53
653 #define FR_LMI_CCITT_PVC_STATUS_IE 0x57
655 struct tok fr_q933_ie_values_codeset5
[] = {
656 { FR_LMI_ANSI_REPORT_TYPE_IE
, "ANSI Report Type" },
657 { FR_LMI_ANSI_LINK_VERIFY_IE_91
, "ANSI Link Verify" },
658 { FR_LMI_ANSI_LINK_VERIFY_IE
, "ANSI Link Verify" },
659 { FR_LMI_ANSI_PVC_STATUS_IE
, "ANSI PVC Status" },
660 { FR_LMI_CCITT_REPORT_TYPE_IE
, "CCITT Report Type" },
661 { FR_LMI_CCITT_LINK_VERIFY_IE
, "CCITT Link Verify" },
662 { FR_LMI_CCITT_PVC_STATUS_IE
, "CCITT PVC Status" },
666 #define FR_LMI_REPORT_TYPE_IE_FULL_STATUS 0
667 #define FR_LMI_REPORT_TYPE_IE_LINK_VERIFY 1
668 #define FR_LMI_REPORT_TYPE_IE_ASYNC_PVC 2
670 struct tok fr_lmi_report_type_ie_values
[] = {
671 { FR_LMI_REPORT_TYPE_IE_FULL_STATUS
, "Full Status" },
672 { FR_LMI_REPORT_TYPE_IE_LINK_VERIFY
, "Link verify" },
673 { FR_LMI_REPORT_TYPE_IE_ASYNC_PVC
, "Async PVC Status" },
677 /* array of 16 codepages - currently we only support codepage 1,5 */
678 static struct tok
*fr_q933_ie_codesets
[] = {
680 fr_q933_ie_values_codeset5
,
684 fr_q933_ie_values_codeset5
,
697 static int fr_q933_print_ie_codeset5(const struct ie_tlv_header_t
*ie_p
,
700 typedef int (*codeset_pr_func_t
)(const struct ie_tlv_header_t
*ie_p
,
703 /* array of 16 codepages - currently we only support codepage 1,5 */
704 static codeset_pr_func_t fr_q933_print_ie_codeset
[] = {
706 fr_q933_print_ie_codeset5
,
710 fr_q933_print_ie_codeset5
,
724 q933_print(const u_char
*p
, u_int length
)
726 const u_char
*ptemp
= p
;
727 struct ie_tlv_header_t
*ie_p
;
731 u_int ie_is_known
= 0;
733 if (length
< 9) { /* shortest: Q.933a LINK VERIFY */
738 codeset
= p
[2]&0x0f; /* extract the codeset */
740 if (p
[2] == MSG_ANSI_LOCKING_SHIFT
)
743 printf("%s", eflag
? "" : "Q.933, ");
745 /* printing out header part */
746 printf("%s, codeset %u", is_ansi
? "ANSI" : "CCITT", codeset
);
749 printf(", Call Ref: 0x%02x", p
[0]);
752 printf(", %s (0x%02x), length %u",
753 tok2str(fr_q933_msg_values
,"unknown message",p
[1]),
758 tok2str(fr_q933_msg_values
,"unknown message 0x%02x",p
[1]));
760 olen
= length
; /* preserve the original length for non verbose mode */
762 if (length
< (u_int
)(2 - is_ansi
)) {
766 length
-= 2 - is_ansi
;
767 ptemp
+= 2 + is_ansi
;
769 /* Loop through the rest of IE */
770 while (length
> sizeof(struct ie_tlv_header_t
)) {
771 ie_p
= (struct ie_tlv_header_t
*)ptemp
;
772 if (length
< sizeof(struct ie_tlv_header_t
) ||
773 length
< sizeof(struct ie_tlv_header_t
) + ie_p
->ie_len
) {
774 if (vflag
) /* not bark if there is just a trailer */
775 printf("\n[|q.933]");
777 printf(", length %u",olen
);
781 /* lets do the full IE parsing only in verbose mode
782 * however some IEs (DLCI Status, Link Verify)
783 * are also intereststing in non-verbose mode */
785 printf("\n\t%s IE (0x%02x), length %u: ",
786 tok2str(fr_q933_ie_codesets
[codeset
],"unknown",ie_p
->ie_type
),
791 if (ie_p
->ie_type
== 0 || ie_p
->ie_len
== 0)
794 if (fr_q933_print_ie_codeset
[codeset
] != NULL
)
795 ie_is_known
= fr_q933_print_ie_codeset
[codeset
](ie_p
, ptemp
);
797 if (vflag
>= 1 && !ie_is_known
)
798 print_unknown_data(ptemp
+2,"\n\t",ie_p
->ie_len
);
800 /* do we want to see a hexdump of the IE ? */
801 if (vflag
> 1 && ie_is_known
)
802 print_unknown_data(ptemp
+2,"\n\t ",ie_p
->ie_len
);
804 length
= length
- ie_p
->ie_len
- 2;
805 ptemp
= ptemp
+ ie_p
->ie_len
+ 2;
808 printf(", length %u",olen
);
812 fr_q933_print_ie_codeset5(const struct ie_tlv_header_t
*ie_p
, const u_char
*p
)
816 switch (ie_p
->ie_type
) {
818 case FR_LMI_ANSI_REPORT_TYPE_IE
: /* fall through */
819 case FR_LMI_CCITT_REPORT_TYPE_IE
:
822 tok2str(fr_lmi_report_type_ie_values
,"unknown",p
[2]),
826 case FR_LMI_ANSI_LINK_VERIFY_IE
: /* fall through */
827 case FR_LMI_CCITT_LINK_VERIFY_IE
:
828 case FR_LMI_ANSI_LINK_VERIFY_IE_91
:
831 printf("TX Seq: %3d, RX Seq: %3d", p
[2], p
[3]);
834 case FR_LMI_ANSI_PVC_STATUS_IE
: /* fall through */
835 case FR_LMI_CCITT_PVC_STATUS_IE
:
838 /* now parse the DLCI information element. */
839 if ((ie_p
->ie_len
< 3) ||
841 ((ie_p
->ie_len
== 3) && !(p
[3] & 0x80)) ||
842 ((ie_p
->ie_len
== 4) && ((p
[3] & 0x80) || !(p
[4] & 0x80))) ||
843 ((ie_p
->ie_len
== 5) && ((p
[3] & 0x80) || (p
[4] & 0x80) ||
845 (ie_p
->ie_len
> 5) ||
846 !(p
[ie_p
->ie_len
+ 1] & 0x80))
847 printf("Invalid DLCI IE");
849 dlci
= ((p
[2] & 0x3F) << 4) | ((p
[3] & 0x78) >> 3);
850 if (ie_p
->ie_len
== 4)
851 dlci
= (dlci
<< 6) | ((p
[4] & 0x7E) >> 1);
852 else if (ie_p
->ie_len
== 5)
853 dlci
= (dlci
<< 13) | (p
[4] & 0x7F) | ((p
[5] & 0x7E) >> 1);
855 printf("DLCI %u: status %s%s", dlci
,
856 p
[ie_p
->ie_len
+ 1] & 0x8 ? "New, " : "",
857 p
[ie_p
->ie_len
+ 1] & 0x2 ? "Active" : "Inactive");