2 * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 static const char rcsid
[] _U_
=
24 "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32.2.13 2005-11-04 07:17:40 hannes Exp $ (LBL)";
31 #include <tcpdump-stdinc.h>
37 #include "addrtoname.h"
38 #include "interface.h"
39 #include "ethertype.h"
44 static void frf15_print(const u_char
*, u_int
);
47 * the frame relay header has a variable length
49 * the EA bit determines if there is another byte
52 * minimum header length is 2 bytes
53 * maximum header length is 4 bytes
56 * +----+----+----+----+----+----+----+----+
57 * | DLCI (6 bits) | CR | EA |
58 * +----+----+----+----+----+----+----+----+
59 * | DLCI (4 bits) |FECN|BECN| DE | EA |
60 * +----+----+----+----+----+----+----+----+
61 * | DLCI (7 bits) | EA |
62 * +----+----+----+----+----+----+----+----+
63 * | DLCI (6 bits) |SDLC| EA |
64 * +----+----+----+----+----+----+----+----+
67 #define FR_EA_BIT 0x01
69 #define FR_CR_BIT 0x02000000
70 #define FR_DE_BIT 0x00020000
71 #define FR_BECN_BIT 0x00040000
72 #define FR_FECN_BIT 0x00080000
73 #define FR_SDLC_BIT 0x00000002
76 struct tok fr_header_flag_values
[] = {
79 { FR_BECN_BIT
, "BECN" },
80 { FR_FECN_BIT
, "FECN" },
81 { FR_SDLC_BIT
, "sdlcore" },
86 #define MFR_B_BIT 0x80
87 #define MFR_E_BIT 0x40
88 #define MFR_C_BIT 0x20
89 #define MFR_BEC_MASK (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT)
90 #define MFR_CTRL_FRAME (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT)
91 #define MFR_FRAG_FRAME (MFR_B_BIT | MFR_E_BIT )
93 struct tok frf_flag_values
[] = {
94 { MFR_B_BIT
, "Begin" },
96 { MFR_C_BIT
, "Control" },
100 /* Finds out Q.922 address length, DLCI and flags. Returns 0 on success
101 * save the flags dep. on address length
103 static int parse_q922_addr(const u_char
*p
, u_int
*dlci
, u_int
*sdlcore
,
104 u_int
*addr_len
, u_int8_t
*flags
)
106 if ((p
[0] & FR_EA_BIT
))
110 *dlci
= ((p
[0] & 0xFC) << 2) | ((p
[1] & 0xF0) >> 4);
112 flags
[0] = p
[0] & 0x02; /* populate the first flag fields */
113 flags
[1] = p
[1] & 0x0c;
115 if (p
[1] & FR_EA_BIT
)
116 return 0; /* 2-byte Q.922 address */
119 (*addr_len
)++; /* 3- or 4-byte Q.922 address */
120 if ((p
[0] & FR_EA_BIT
) == 0) {
121 *dlci
= (*dlci
<< 7) | (p
[0] >> 1);
122 (*addr_len
)++; /* 4-byte Q.922 address */
126 if ((p
[0] & FR_EA_BIT
) == 0)
127 return -1; /* more than 4 bytes of Q.922 address? */
129 flags
[3] = p
[0] & 0x02;
132 *sdlcore
= p
[0] >> 2;
134 *dlci
= (*dlci
<< 6) | (p
[0] >> 2);
139 /* Frame Relay packet structure, with flags and CRC removed
141 +---------------------------+
145 +---------------------------+
146 | Control (UI = 0x03) |
147 +---------------------------+
148 | Optional Pad (0x00) |
149 +---------------------------+
151 +---------------------------+
158 +---------------------------+
160 * Q.922 addresses, as presently defined, are two octets and
161 contain a 10-bit DLCI. In some networks Q.922 addresses
162 may optionally be increased to three or four octets.
166 fr_hdrlen(const u_char
*p
, u_int addr_len
)
168 if (!p
[addr_len
+ 1] /* pad exist */)
169 return addr_len
+ 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */;
171 return addr_len
+ 1 /* UI */ + 1 /* NLPID */;
175 fr_hdr_print(int length
, u_int addr_len
, u_int dlci
, u_int8_t
*flags
, u_int16_t nlpid
)
178 (void)printf("Q.922, DLCI %u, length %u: ",
182 if (nlpid
<= 0xff) /* if its smaller than 256 then its a NLPID */
183 (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
186 bittok2str(fr_header_flag_values
, "none", EXTRACT_32BITS(flags
)),
187 tok2str(nlpid_values
,"unknown", nlpid
),
190 else /* must be an ethertype */
191 (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
194 bittok2str(fr_header_flag_values
, "none", EXTRACT_32BITS(flags
)),
195 tok2str(ethertype_values
, "unknown", nlpid
),
202 fr_if_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
204 register u_int length
= h
->len
;
205 register u_int caplen
= h
->caplen
;
207 TCHECK2(*p
, 4); /* minimum frame header length */
209 if ((length
= fr_print(p
, length
)) == 0)
219 fr_print(register const u_char
*p
, u_int length
)
221 u_int16_t extracted_ethertype
;
229 if (parse_q922_addr(p
, &dlci
, &sdlcore
, &addr_len
, flags
)) {
230 printf("Q.922, invalid address");
234 TCHECK2(*p
,addr_len
+1+1);
235 hdr_len
= fr_hdrlen(p
, addr_len
);
238 if (p
[addr_len
] != 0x03 && dlci
!= 0) {
240 /* lets figure out if we have cisco style encapsulation: */
241 extracted_ethertype
= EXTRACT_16BITS(p
+addr_len
);
244 fr_hdr_print(length
, addr_len
, dlci
, flags
, extracted_ethertype
);
246 if (ether_encap_print(extracted_ethertype
,
247 p
+addr_len
+ETHERTYPE_LEN
,
248 length
-addr_len
-ETHERTYPE_LEN
,
249 length
-addr_len
-ETHERTYPE_LEN
,
250 &extracted_ethertype
) == 0)
251 /* ether_type not known, probably it wasn't one */
252 printf("UI %02x! ", p
[addr_len
]);
257 if (!p
[addr_len
+ 1]) { /* pad byte should be used with 3-byte Q.922 */
260 } else if (addr_len
== 3)
263 nlpid
= p
[hdr_len
- 1];
266 fr_hdr_print(length
, addr_len
, dlci
, flags
, nlpid
);
272 ip_print(gndo
, p
, length
);
277 ip6_print(p
, length
);
283 isoclns_print(p
-1, length
+1, length
+1); /* OSI printers need the NLPID field */
287 if (snap_print(p
, length
, length
, &extracted_ethertype
, 0) == 0) {
288 /* ether_type not known, print raw packet */
290 fr_hdr_print(length
+ hdr_len
, hdr_len
,
292 if (!suppress_default_print
)
293 default_print(p
- hdr_len
, length
+ hdr_len
);
298 q933_print(p
, length
);
302 frf15_print(p
, length
);
306 ppp_print(p
, length
);
311 fr_hdr_print(length
+ hdr_len
, addr_len
,
314 default_print(p
, length
);
325 #define MFR_CTRL_MSG_ADD_LINK 1
326 #define MFR_CTRL_MSG_ADD_LINK_ACK 2
327 #define MFR_CTRL_MSG_ADD_LINK_REJ 3
328 #define MFR_CTRL_MSG_HELLO 4
329 #define MFR_CTRL_MSG_HELLO_ACK 5
330 #define MFR_CTRL_MSG_REMOVE_LINK 6
331 #define MFR_CTRL_MSG_REMOVE_LINK_ACK 7
333 struct tok mfr_ctrl_msg_values
[] = {
334 { MFR_CTRL_MSG_ADD_LINK
, "Add Link" },
335 { MFR_CTRL_MSG_ADD_LINK_ACK
, "Add Link ACK" },
336 { MFR_CTRL_MSG_ADD_LINK_REJ
, "Add Link Reject" },
337 { MFR_CTRL_MSG_HELLO
, "Hello" },
338 { MFR_CTRL_MSG_HELLO_ACK
, "Hello ACK" },
339 { MFR_CTRL_MSG_REMOVE_LINK
, "Remove Link" },
340 { MFR_CTRL_MSG_REMOVE_LINK_ACK
, "Remove Link ACK" },
344 #define MFR_CTRL_IE_BUNDLE_ID 1
345 #define MFR_CTRL_IE_LINK_ID 2
346 #define MFR_CTRL_IE_MAGIC_NUM 3
347 #define MFR_CTRL_IE_TIMESTAMP 5
348 #define MFR_CTRL_IE_VENDOR_EXT 6
349 #define MFR_CTRL_IE_CAUSE 7
351 struct tok mfr_ctrl_ie_values
[] = {
352 { MFR_CTRL_IE_BUNDLE_ID
, "Bundle ID"},
353 { MFR_CTRL_IE_LINK_ID
, "Link ID"},
354 { MFR_CTRL_IE_MAGIC_NUM
, "Magic Number"},
355 { MFR_CTRL_IE_TIMESTAMP
, "Timestamp"},
356 { MFR_CTRL_IE_VENDOR_EXT
, "Vendor Extension"},
357 { MFR_CTRL_IE_CAUSE
, "Cause"},
361 #define MFR_ID_STRING_MAXLEN 50
363 struct ie_tlv_header_t
{
369 mfr_print(register const u_char
*p
, u_int length
)
371 u_int tlen
,idx
,hdr_len
= 0;
372 u_int16_t sequence_num
;
373 u_int8_t ie_type
,ie_len
;
374 const u_int8_t
*tptr
;
378 * FRF.16 Link Integrity Control Frame
381 * +----+----+----+----+----+----+----+----+
382 * | B | E | C=1| 0 0 0 0 | EA |
383 * +----+----+----+----+----+----+----+----+
384 * | 0 0 0 0 0 0 0 0 |
385 * +----+----+----+----+----+----+----+----+
387 * +----+----+----+----+----+----+----+----+
390 TCHECK2(*p
, 4); /* minimum frame header length */
392 if ((p
[0] & MFR_BEC_MASK
) == MFR_CTRL_FRAME
&& p
[1] == 0) {
393 printf("FRF.16 Control, Flags [%s], %s, length %u",
394 bittok2str(frf_flag_values
,"none",(p
[0] & MFR_BEC_MASK
)),
395 tok2str(mfr_ctrl_msg_values
,"Unknown Message (0x%02x)",p
[2]),
404 while (tlen
>sizeof(struct ie_tlv_header_t
)) {
405 TCHECK2(*tptr
, sizeof(struct ie_tlv_header_t
));
409 printf("\n\tIE %s (%u), length %u: ",
410 tok2str(mfr_ctrl_ie_values
,"Unknown",ie_type
),
414 /* infinite loop check */
415 if (ie_type
== 0 || ie_len
<= sizeof(struct ie_tlv_header_t
))
418 TCHECK2(*tptr
,ie_len
);
419 tptr
+=sizeof(struct ie_tlv_header_t
);
420 /* tlv len includes header */
421 ie_len
-=sizeof(struct ie_tlv_header_t
);
422 tlen
-=sizeof(struct ie_tlv_header_t
);
426 case MFR_CTRL_IE_MAGIC_NUM
:
427 printf("0x%08x",EXTRACT_32BITS(tptr
));
430 case MFR_CTRL_IE_BUNDLE_ID
: /* same message format */
431 case MFR_CTRL_IE_LINK_ID
:
432 for (idx
= 0; idx
< ie_len
&& idx
< MFR_ID_STRING_MAXLEN
; idx
++) {
433 if (*(tptr
+idx
) != 0) /* don't print null termination */
434 safeputchar(*(tptr
+idx
));
440 case MFR_CTRL_IE_TIMESTAMP
:
441 if (ie_len
== sizeof(struct timeval
)) {
442 ts_print((const struct timeval
*)tptr
);
445 /* fall through and hexdump if no unix timestamp */
448 * FIXME those are the defined IEs that lack a decoder
449 * you are welcome to contribute code ;-)
452 case MFR_CTRL_IE_VENDOR_EXT
:
453 case MFR_CTRL_IE_CAUSE
:
457 print_unknown_data(tptr
,"\n\t ",ie_len
);
461 /* do we want to see a hexdump of the IE ? */
463 print_unknown_data(tptr
,"\n\t ",ie_len
);
471 * FRF.16 Fragmentation Frame
474 * +----+----+----+----+----+----+----+----+
475 * | B | E | C=0|seq. (high 4 bits) | EA |
476 * +----+----+----+----+----+----+----+----+
477 * | sequence (low 8 bits) |
478 * +----+----+----+----+----+----+----+----+
479 * | DLCI (6 bits) | CR | EA |
480 * +----+----+----+----+----+----+----+----+
481 * | DLCI (4 bits) |FECN|BECN| DE | EA |
482 * +----+----+----+----+----+----+----+----+
485 sequence_num
= (p
[0]&0x1e)<<7 | p
[1];
486 /* whole packet or first fragment ? */
487 if ((p
[0] & MFR_BEC_MASK
) == MFR_FRAG_FRAME
||
488 (p
[0] & MFR_BEC_MASK
) == MFR_B_BIT
) {
489 printf("FRF.16 Frag, seq %u, Flags [%s], ",
491 bittok2str(frf_flag_values
,"none",(p
[0] & MFR_BEC_MASK
)));
493 fr_print(p
+hdr_len
,length
-hdr_len
);
497 /* must be a middle or the last fragment */
498 printf("FRF.16 Frag, seq %u, Flags [%s]",
500 bittok2str(frf_flag_values
,"none",(p
[0] & MFR_BEC_MASK
)));
501 print_unknown_data(p
,"\n\t",length
);
510 /* an NLPID of 0xb1 indicates a 2-byte
514 * +----+----+----+----+----+----+----+----+
516 * +----+----+----+----+----+----+----+----+
517 * | NLPID (8 bits) | NLPID=0xb1
518 * +----+----+----+----+----+----+----+----+
519 * | B | E | C |seq. (high 4 bits) | R |
520 * +----+----+----+----+----+----+----+----+
521 * | sequence (low 8 bits) |
522 * +----+----+----+----+----+----+----+----+
525 #define FR_FRF15_FRAGTYPE 0x01
528 frf15_print (const u_char
*p
, u_int length
) {
530 u_int16_t sequence_num
, flags
;
532 flags
= p
[0]&MFR_BEC_MASK
;
533 sequence_num
= (p
[0]&0x1e)<<7 | p
[1];
535 printf("FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
537 bittok2str(frf_flag_values
,"none",flags
),
538 p
[0]&FR_FRF15_FRAGTYPE
? "Interface" : "End-to-End",
542 * depending on all permutations of the B, E and C bit
543 * dig as deep as we can - e.g. on the first (B) fragment
544 * there is enough payload to print the IP header
545 * on non (B) fragments it depends if the fragmentation
546 * model is end-to-end or interface based wether we want to print
547 * another Q.922 header
553 * Q.933 decoding portion for framerelay specific.
556 /* Q.933 packet format
557 Format of Other Protocols
559 +-------------------------------+
561 +---------------+---------------+
562 |Control 0x03 | NLPID 0x08 |
563 +---------------+---------------+
565 | octet 1 | octet 2 |
566 +-------------------------------+
568 | octet 2 | octet 2 |
569 +-------------------------------+
571 +-------------------------------+
573 +-------------------------------+
576 /* L2 (Octet 1)- Call Reference Usually is 0x0 */
579 * L2 (Octet 2)- Message Types definition 1 byte long.
582 #define MSG_TYPE_ESC_TO_NATIONAL 0x00
583 #define MSG_TYPE_ALERT 0x01
584 #define MSG_TYPE_CALL_PROCEEDING 0x02
585 #define MSG_TYPE_CONNECT 0x07
586 #define MSG_TYPE_CONNECT_ACK 0x0F
587 #define MSG_TYPE_PROGRESS 0x03
588 #define MSG_TYPE_SETUP 0x05
590 #define MSG_TYPE_DISCONNECT 0x45
591 #define MSG_TYPE_RELEASE 0x4D
592 #define MSG_TYPE_RELEASE_COMPLETE 0x5A
593 #define MSG_TYPE_RESTART 0x46
594 #define MSG_TYPE_RESTART_ACK 0x4E
596 #define MSG_TYPE_STATUS 0x7D
597 #define MSG_TYPE_STATUS_ENQ 0x75
599 struct tok fr_q933_msg_values
[] = {
600 { MSG_TYPE_ESC_TO_NATIONAL
, "ESC to National" },
601 { MSG_TYPE_ALERT
, "Alert" },
602 { MSG_TYPE_CALL_PROCEEDING
, "Call proceeding" },
603 { MSG_TYPE_CONNECT
, "Connect" },
604 { MSG_TYPE_CONNECT_ACK
, "Connect ACK" },
605 { MSG_TYPE_PROGRESS
, "Progress" },
606 { MSG_TYPE_SETUP
, "Setup" },
607 { MSG_TYPE_DISCONNECT
, "Disconnect" },
608 { MSG_TYPE_RELEASE
, "Release" },
609 { MSG_TYPE_RELEASE_COMPLETE
, "Release Complete" },
610 { MSG_TYPE_RESTART
, "Restart" },
611 { MSG_TYPE_RESTART_ACK
, "Restart ACK" },
612 { MSG_TYPE_STATUS
, "Status Reply" },
613 { MSG_TYPE_STATUS_ENQ
, "Status Enquiry" },
617 #define MSG_ANSI_LOCKING_SHIFT 0x95
619 #define FR_LMI_ANSI_REPORT_TYPE_IE 0x01
620 #define FR_LMI_ANSI_LINK_VERIFY_IE_91 0x19 /* details? */
621 #define FR_LMI_ANSI_LINK_VERIFY_IE 0x03
622 #define FR_LMI_ANSI_PVC_STATUS_IE 0x07
624 #define FR_LMI_CCITT_REPORT_TYPE_IE 0x51
625 #define FR_LMI_CCITT_LINK_VERIFY_IE 0x53
626 #define FR_LMI_CCITT_PVC_STATUS_IE 0x57
628 struct tok fr_q933_ie_values_codeset5
[] = {
629 { FR_LMI_ANSI_REPORT_TYPE_IE
, "ANSI Report Type" },
630 { FR_LMI_ANSI_LINK_VERIFY_IE_91
, "ANSI Link Verify" },
631 { FR_LMI_ANSI_LINK_VERIFY_IE
, "ANSI Link Verify" },
632 { FR_LMI_ANSI_PVC_STATUS_IE
, "ANSI PVC Status" },
633 { FR_LMI_CCITT_REPORT_TYPE_IE
, "CCITT Report Type" },
634 { FR_LMI_CCITT_LINK_VERIFY_IE
, "CCITT Link Verify" },
635 { FR_LMI_CCITT_PVC_STATUS_IE
, "CCITT PVC Status" },
639 #define FR_LMI_REPORT_TYPE_IE_FULL_STATUS 0
640 #define FR_LMI_REPORT_TYPE_IE_LINK_VERIFY 1
641 #define FR_LMI_REPORT_TYPE_IE_ASYNC_PVC 2
643 struct tok fr_lmi_report_type_ie_values
[] = {
644 { FR_LMI_REPORT_TYPE_IE_FULL_STATUS
, "Full Status" },
645 { FR_LMI_REPORT_TYPE_IE_LINK_VERIFY
, "Link verify" },
646 { FR_LMI_REPORT_TYPE_IE_ASYNC_PVC
, "Async PVC Status" },
650 /* array of 16 codepages - currently we only support codepage 1,5 */
651 static struct tok
*fr_q933_ie_codesets
[] = {
653 fr_q933_ie_values_codeset5
,
657 fr_q933_ie_values_codeset5
,
670 static int fr_q933_print_ie_codeset5(const struct ie_tlv_header_t
*ie_p
,
673 typedef int (*codeset_pr_func_t
)(const struct ie_tlv_header_t
*ie_p
,
676 /* array of 16 codepages - currently we only support codepage 1,5 */
677 static codeset_pr_func_t fr_q933_print_ie_codeset
[] = {
679 fr_q933_print_ie_codeset5
,
683 fr_q933_print_ie_codeset5
,
697 q933_print(const u_char
*p
, u_int length
)
699 const u_char
*ptemp
= p
;
700 struct ie_tlv_header_t
*ie_p
;
704 u_int ie_is_known
= 0;
706 if (length
< 9) { /* shortest: Q.933a LINK VERIFY */
711 codeset
= p
[2]&0x0f; /* extract the codeset */
713 if (p
[2] == MSG_ANSI_LOCKING_SHIFT
)
716 printf("%s", eflag
? "" : "Q.933, ");
718 /* printing out header part */
719 printf("%s, codeset %u", is_ansi
? "ANSI" : "CCITT", codeset
);
722 printf(", Call Ref: 0x%02x", p
[0]);
725 printf(", %s (0x%02x), length %u",
726 tok2str(fr_q933_msg_values
,"unknown message",p
[1]),
731 tok2str(fr_q933_msg_values
,"unknown message 0x%02x",p
[1]));
733 olen
= length
; /* preserve the original length for non verbose mode */
735 if (length
< (u_int
)(2 - is_ansi
)) {
739 length
-= 2 - is_ansi
;
740 ptemp
+= 2 + is_ansi
;
742 /* Loop through the rest of IE */
743 while (length
> sizeof(struct ie_tlv_header_t
)) {
744 ie_p
= (struct ie_tlv_header_t
*)ptemp
;
745 if (length
< sizeof(struct ie_tlv_header_t
) ||
746 length
< sizeof(struct ie_tlv_header_t
) + ie_p
->ie_len
) {
747 if (vflag
) /* not bark if there is just a trailer */
748 printf("\n[|q.933]");
750 printf(", length %u",olen
);
754 /* lets do the full IE parsing only in verbose mode
755 * however some IEs (DLCI Status, Link Verify)
756 * are also intereststing in non-verbose mode */
758 printf("\n\t%s IE (0x%02x), length %u: ",
759 tok2str(fr_q933_ie_codesets
[codeset
],"unknown",ie_p
->ie_type
),
764 if (ie_p
->ie_type
== 0 || ie_p
->ie_len
== 0)
767 if (fr_q933_print_ie_codeset
[codeset
] != NULL
)
768 ie_is_known
= fr_q933_print_ie_codeset
[codeset
](ie_p
, ptemp
);
770 if (vflag
>= 1 && !ie_is_known
)
771 print_unknown_data(ptemp
+2,"\n\t",ie_p
->ie_len
);
773 /* do we want to see a hexdump of the IE ? */
774 if (vflag
> 1 && ie_is_known
)
775 print_unknown_data(ptemp
+2,"\n\t ",ie_p
->ie_len
);
777 length
= length
- ie_p
->ie_len
- 2;
778 ptemp
= ptemp
+ ie_p
->ie_len
+ 2;
781 printf(", length %u",olen
);
785 fr_q933_print_ie_codeset5(const struct ie_tlv_header_t
*ie_p
, const u_char
*p
)
789 switch (ie_p
->ie_type
) {
791 case FR_LMI_ANSI_REPORT_TYPE_IE
: /* fall through */
792 case FR_LMI_CCITT_REPORT_TYPE_IE
:
795 tok2str(fr_lmi_report_type_ie_values
,"unknown",p
[2]),
799 case FR_LMI_ANSI_LINK_VERIFY_IE
: /* fall through */
800 case FR_LMI_CCITT_LINK_VERIFY_IE
:
801 case FR_LMI_ANSI_LINK_VERIFY_IE_91
:
804 printf("TX Seq: %3d, RX Seq: %3d", p
[2], p
[3]);
807 case FR_LMI_ANSI_PVC_STATUS_IE
: /* fall through */
808 case FR_LMI_CCITT_PVC_STATUS_IE
:
811 /* now parse the DLCI information element. */
812 if ((ie_p
->ie_len
< 3) ||
814 ((ie_p
->ie_len
== 3) && !(p
[3] & 0x80)) ||
815 ((ie_p
->ie_len
== 4) && ((p
[3] & 0x80) || !(p
[4] & 0x80))) ||
816 ((ie_p
->ie_len
== 5) && ((p
[3] & 0x80) || (p
[4] & 0x80) ||
818 (ie_p
->ie_len
> 5) ||
819 !(p
[ie_p
->ie_len
+ 1] & 0x80))
820 printf("Invalid DLCI IE");
822 dlci
= ((p
[2] & 0x3F) << 4) | ((p
[3] & 0x78) >> 3);
823 if (ie_p
->ie_len
== 4)
824 dlci
= (dlci
<< 6) | ((p
[4] & 0x7E) >> 1);
825 else if (ie_p
->ie_len
== 5)
826 dlci
= (dlci
<< 13) | (p
[4] & 0x7F) | ((p
[5] & 0x7E) >> 1);
828 printf("DLCI %u: status %s%s", dlci
,
829 p
[ie_p
->ie_len
+ 1] & 0x8 ? "New, " : "",
830 p
[ie_p
->ie_len
+ 1] & 0x2 ? "Active" : "Inactive");