4 * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
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.
23 * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
26 #include <sys/cdefs.h>
29 static const char rcsid
[] _U_
=
30 "@(#) Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.17.2.3 2006/06/23 02:07:27 hannes Exp";
32 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
40 #include <tcpdump-stdinc.h>
45 #include "interface.h"
48 static char tstr
[] = " [|l2tp]";
50 #define L2TP_MSGTYPE_SCCRQ 1 /* Start-Control-Connection-Request */
51 #define L2TP_MSGTYPE_SCCRP 2 /* Start-Control-Connection-Reply */
52 #define L2TP_MSGTYPE_SCCCN 3 /* Start-Control-Connection-Connected */
53 #define L2TP_MSGTYPE_STOPCCN 4 /* Stop-Control-Connection-Notification */
54 #define L2TP_MSGTYPE_HELLO 6 /* Hello */
55 #define L2TP_MSGTYPE_OCRQ 7 /* Outgoing-Call-Request */
56 #define L2TP_MSGTYPE_OCRP 8 /* Outgoing-Call-Reply */
57 #define L2TP_MSGTYPE_OCCN 9 /* Outgoing-Call-Connected */
58 #define L2TP_MSGTYPE_ICRQ 10 /* Incoming-Call-Request */
59 #define L2TP_MSGTYPE_ICRP 11 /* Incoming-Call-Reply */
60 #define L2TP_MSGTYPE_ICCN 12 /* Incoming-Call-Connected */
61 #define L2TP_MSGTYPE_CDN 14 /* Call-Disconnect-Notify */
62 #define L2TP_MSGTYPE_WEN 15 /* WAN-Error-Notify */
63 #define L2TP_MSGTYPE_SLI 16 /* Set-Link-Info */
65 static struct tok l2tp_msgtype2str
[] = {
66 { L2TP_MSGTYPE_SCCRQ
, "SCCRQ" },
67 { L2TP_MSGTYPE_SCCRP
, "SCCRP" },
68 { L2TP_MSGTYPE_SCCCN
, "SCCCN" },
69 { L2TP_MSGTYPE_STOPCCN
, "StopCCN" },
70 { L2TP_MSGTYPE_HELLO
, "HELLO" },
71 { L2TP_MSGTYPE_OCRQ
, "OCRQ" },
72 { L2TP_MSGTYPE_OCRP
, "OCRP" },
73 { L2TP_MSGTYPE_OCCN
, "OCCN" },
74 { L2TP_MSGTYPE_ICRQ
, "ICRQ" },
75 { L2TP_MSGTYPE_ICRP
, "ICRP" },
76 { L2TP_MSGTYPE_ICCN
, "ICCN" },
77 { L2TP_MSGTYPE_CDN
, "CDN" },
78 { L2TP_MSGTYPE_WEN
, "WEN" },
79 { L2TP_MSGTYPE_SLI
, "SLI" },
83 #define L2TP_AVP_MSGTYPE 0 /* Message Type */
84 #define L2TP_AVP_RESULT_CODE 1 /* Result Code */
85 #define L2TP_AVP_PROTO_VER 2 /* Protocol Version */
86 #define L2TP_AVP_FRAMING_CAP 3 /* Framing Capabilities */
87 #define L2TP_AVP_BEARER_CAP 4 /* Bearer Capabilities */
88 #define L2TP_AVP_TIE_BREAKER 5 /* Tie Breaker */
89 #define L2TP_AVP_FIRM_VER 6 /* Firmware Revision */
90 #define L2TP_AVP_HOST_NAME 7 /* Host Name */
91 #define L2TP_AVP_VENDOR_NAME 8 /* Vendor Name */
92 #define L2TP_AVP_ASSND_TUN_ID 9 /* Assigned Tunnel ID */
93 #define L2TP_AVP_RECV_WIN_SIZE 10 /* Receive Window Size */
94 #define L2TP_AVP_CHALLENGE 11 /* Challenge */
95 #define L2TP_AVP_Q931_CC 12 /* Q.931 Cause Code */
96 #define L2TP_AVP_CHALLENGE_RESP 13 /* Challenge Response */
97 #define L2TP_AVP_ASSND_SESS_ID 14 /* Assigned Session ID */
98 #define L2TP_AVP_CALL_SER_NUM 15 /* Call Serial Number */
99 #define L2TP_AVP_MINIMUM_BPS 16 /* Minimum BPS */
100 #define L2TP_AVP_MAXIMUM_BPS 17 /* Maximum BPS */
101 #define L2TP_AVP_BEARER_TYPE 18 /* Bearer Type */
102 #define L2TP_AVP_FRAMING_TYPE 19 /* Framing Type */
103 #define L2TP_AVP_PACKET_PROC_DELAY 20 /* Packet Processing Delay (OBSOLETE) */
104 #define L2TP_AVP_CALLED_NUMBER 21 /* Called Number */
105 #define L2TP_AVP_CALLING_NUMBER 22 /* Calling Number */
106 #define L2TP_AVP_SUB_ADDRESS 23 /* Sub-Address */
107 #define L2TP_AVP_TX_CONN_SPEED 24 /* (Tx) Connect Speed */
108 #define L2TP_AVP_PHY_CHANNEL_ID 25 /* Physical Channel ID */
109 #define L2TP_AVP_INI_RECV_LCP 26 /* Initial Received LCP CONFREQ */
110 #define L2TP_AVP_LAST_SENT_LCP 27 /* Last Sent LCP CONFREQ */
111 #define L2TP_AVP_LAST_RECV_LCP 28 /* Last Received LCP CONFREQ */
112 #define L2TP_AVP_PROXY_AUTH_TYPE 29 /* Proxy Authen Type */
113 #define L2TP_AVP_PROXY_AUTH_NAME 30 /* Proxy Authen Name */
114 #define L2TP_AVP_PROXY_AUTH_CHAL 31 /* Proxy Authen Challenge */
115 #define L2TP_AVP_PROXY_AUTH_ID 32 /* Proxy Authen ID */
116 #define L2TP_AVP_PROXY_AUTH_RESP 33 /* Proxy Authen Response */
117 #define L2TP_AVP_CALL_ERRORS 34 /* Call Errors */
118 #define L2TP_AVP_ACCM 35 /* ACCM */
119 #define L2TP_AVP_RANDOM_VECTOR 36 /* Random Vector */
120 #define L2TP_AVP_PRIVATE_GRP_ID 37 /* Private Group ID */
121 #define L2TP_AVP_RX_CONN_SPEED 38 /* (Rx) Connect Speed */
122 #define L2TP_AVP_SEQ_REQUIRED 39 /* Sequencing Required */
123 #define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code */
125 static struct tok l2tp_avp2str
[] = {
126 { L2TP_AVP_MSGTYPE
, "MSGTYPE" },
127 { L2TP_AVP_RESULT_CODE
, "RESULT_CODE" },
128 { L2TP_AVP_PROTO_VER
, "PROTO_VER" },
129 { L2TP_AVP_FRAMING_CAP
, "FRAMING_CAP" },
130 { L2TP_AVP_BEARER_CAP
, "BEARER_CAP" },
131 { L2TP_AVP_TIE_BREAKER
, "TIE_BREAKER" },
132 { L2TP_AVP_FIRM_VER
, "FIRM_VER" },
133 { L2TP_AVP_HOST_NAME
, "HOST_NAME" },
134 { L2TP_AVP_VENDOR_NAME
, "VENDOR_NAME" },
135 { L2TP_AVP_ASSND_TUN_ID
, "ASSND_TUN_ID" },
136 { L2TP_AVP_RECV_WIN_SIZE
, "RECV_WIN_SIZE" },
137 { L2TP_AVP_CHALLENGE
, "CHALLENGE" },
138 { L2TP_AVP_Q931_CC
, "Q931_CC", },
139 { L2TP_AVP_CHALLENGE_RESP
, "CHALLENGE_RESP" },
140 { L2TP_AVP_ASSND_SESS_ID
, "ASSND_SESS_ID" },
141 { L2TP_AVP_CALL_SER_NUM
, "CALL_SER_NUM" },
142 { L2TP_AVP_MINIMUM_BPS
, "MINIMUM_BPS" },
143 { L2TP_AVP_MAXIMUM_BPS
, "MAXIMUM_BPS" },
144 { L2TP_AVP_BEARER_TYPE
, "BEARER_TYPE" },
145 { L2TP_AVP_FRAMING_TYPE
, "FRAMING_TYPE" },
146 { L2TP_AVP_PACKET_PROC_DELAY
, "PACKET_PROC_DELAY" },
147 { L2TP_AVP_CALLED_NUMBER
, "CALLED_NUMBER" },
148 { L2TP_AVP_CALLING_NUMBER
, "CALLING_NUMBER" },
149 { L2TP_AVP_SUB_ADDRESS
, "SUB_ADDRESS" },
150 { L2TP_AVP_TX_CONN_SPEED
, "TX_CONN_SPEED" },
151 { L2TP_AVP_PHY_CHANNEL_ID
, "PHY_CHANNEL_ID" },
152 { L2TP_AVP_INI_RECV_LCP
, "INI_RECV_LCP" },
153 { L2TP_AVP_LAST_SENT_LCP
, "LAST_SENT_LCP" },
154 { L2TP_AVP_LAST_RECV_LCP
, "LAST_RECV_LCP" },
155 { L2TP_AVP_PROXY_AUTH_TYPE
, "PROXY_AUTH_TYPE" },
156 { L2TP_AVP_PROXY_AUTH_NAME
, "PROXY_AUTH_NAME" },
157 { L2TP_AVP_PROXY_AUTH_CHAL
, "PROXY_AUTH_CHAL" },
158 { L2TP_AVP_PROXY_AUTH_ID
, "PROXY_AUTH_ID" },
159 { L2TP_AVP_PROXY_AUTH_RESP
, "PROXY_AUTH_RESP" },
160 { L2TP_AVP_CALL_ERRORS
, "CALL_ERRORS" },
161 { L2TP_AVP_ACCM
, "ACCM" },
162 { L2TP_AVP_RANDOM_VECTOR
, "RANDOM_VECTOR" },
163 { L2TP_AVP_PRIVATE_GRP_ID
, "PRIVATE_GRP_ID" },
164 { L2TP_AVP_RX_CONN_SPEED
, "RX_CONN_SPEED" },
165 { L2TP_AVP_SEQ_REQUIRED
, "SEQ_REQUIRED" },
166 { L2TP_AVP_PPP_DISCON_CC
, "PPP_DISCON_CC" },
170 static struct tok l2tp_authentype2str
[] = {
171 { L2TP_AUTHEN_TYPE_RESERVED
, "Reserved" },
172 { L2TP_AUTHEN_TYPE_TEXTUAL
, "Textual" },
173 { L2TP_AUTHEN_TYPE_CHAP
, "CHAP" },
174 { L2TP_AUTHEN_TYPE_PAP
, "PAP" },
175 { L2TP_AUTHEN_TYPE_NO_AUTH
, "No Auth" },
176 { L2TP_AUTHEN_TYPE_MSCHAPv1
, "MS-CHAPv1" },
180 #define L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL 0
181 #define L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER 1
182 #define L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL 2
184 static struct tok l2tp_cc_direction2str
[] = {
185 { L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL
, "global error" },
186 { L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER
, "at peer" },
187 { L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL
,"at local" },
192 static char *l2tp_result_code_StopCCN
[] = {
194 "General request to clear control connection",
195 "General error--Error Code indicates the problem",
196 "Control channel already exists",
197 "Requester is not authorized to establish a control channel",
198 "The protocol version of the requester is not supported",
199 "Requester is being shut down",
200 "Finite State Machine error"
201 #define L2TP_MAX_RESULT_CODE_STOPCC_INDEX 8
206 static char *l2tp_result_code_CDN
[] = {
208 "Call disconnected due to loss of carrier",
209 "Call disconnected for the reason indicated in error code",
210 "Call disconnected for administrative reasons",
211 "Call failed due to lack of appropriate facilities being " \
212 "available (temporary condition)",
213 "Call failed due to lack of appropriate facilities being " \
214 "available (permanent condition)",
215 "Invalid destination",
216 "Call failed due to no carrier detected",
217 "Call failed due to detection of a busy signal",
218 "Call failed due to lack of a dial tone",
219 "Call was not established within time allotted by LAC",
220 "Call was connected but no appropriate framing was detected"
221 #define L2TP_MAX_RESULT_CODE_CDN_INDEX 12
226 static char *l2tp_error_code_general
[] = {
228 "No control connection exists yet for this LAC-LNS pair",
230 "One of the field values was out of range or " \
231 "reserved field was non-zero"
232 "Insufficient resources to handle this operation now",
233 "The Session ID is invalid in this context",
234 "A generic vendor-specific error occurred in the LAC",
236 #define L2TP_MAX_ERROR_CODE_GENERAL_INDEX 8
240 /******************************/
241 /* generic print out routines */
242 /******************************/
244 print_string(const u_char
*dat
, u_int length
)
247 for (i
=0; i
<length
; i
++) {
248 printf("%c", *dat
++);
253 print_octets(const u_char
*dat
, u_int length
)
256 for (i
=0; i
<length
; i
++) {
257 printf("%02x", *dat
++);
262 print_16bits_val(const u_int16_t
*dat
)
264 printf("%u", EXTRACT_16BITS(dat
));
268 print_32bits_val(const u_int32_t
*dat
)
270 printf("%lu", (u_long
)EXTRACT_32BITS(dat
));
273 /***********************************/
274 /* AVP-specific print out routines */
275 /***********************************/
277 l2tp_msgtype_print(const u_char
*dat
)
279 u_int16_t
*ptr
= (u_int16_t
*)dat
;
281 printf("%s", tok2str(l2tp_msgtype2str
, "MSGTYPE-#%u",
282 EXTRACT_16BITS(ptr
)));
286 l2tp_result_code_print(const u_char
*dat
, u_int length
)
288 u_int16_t
*ptr
= (u_int16_t
*)dat
;
290 printf("%u", EXTRACT_16BITS(ptr
)); ptr
++; /* Result Code */
291 if (length
> 2) { /* Error Code (opt) */
292 printf("/%u", EXTRACT_16BITS(ptr
)); ptr
++;
294 if (length
> 4) { /* Error Message (opt) */
296 print_string((u_char
*)ptr
, length
- 4);
301 l2tp_proto_ver_print(const u_int16_t
*dat
)
303 printf("%u.%u", (EXTRACT_16BITS(dat
) >> 8),
304 (EXTRACT_16BITS(dat
) & 0xff));
308 l2tp_framing_cap_print(const u_char
*dat
)
310 u_int32_t
*ptr
= (u_int32_t
*)dat
;
312 if (EXTRACT_32BITS(ptr
) & L2TP_FRAMING_CAP_ASYNC_MASK
) {
315 if (EXTRACT_32BITS(ptr
) & L2TP_FRAMING_CAP_SYNC_MASK
) {
321 l2tp_bearer_cap_print(const u_char
*dat
)
323 u_int32_t
*ptr
= (u_int32_t
*)dat
;
325 if (EXTRACT_32BITS(ptr
) & L2TP_BEARER_CAP_ANALOG_MASK
) {
328 if (EXTRACT_32BITS(ptr
) & L2TP_BEARER_CAP_DIGITAL_MASK
) {
334 l2tp_q931_cc_print(const u_char
*dat
, u_int length
)
336 print_16bits_val((u_int16_t
*)dat
);
337 printf(", %02x", dat
[2]);
340 print_string(dat
+3, length
-3);
345 l2tp_bearer_type_print(const u_char
*dat
)
347 u_int32_t
*ptr
= (u_int32_t
*)dat
;
349 if (EXTRACT_32BITS(ptr
) & L2TP_BEARER_TYPE_ANALOG_MASK
) {
352 if (EXTRACT_32BITS(ptr
) & L2TP_BEARER_TYPE_DIGITAL_MASK
) {
358 l2tp_framing_type_print(const u_char
*dat
)
360 u_int32_t
*ptr
= (u_int32_t
*)dat
;
362 if (EXTRACT_32BITS(ptr
) & L2TP_FRAMING_TYPE_ASYNC_MASK
) {
365 if (EXTRACT_32BITS(ptr
) & L2TP_FRAMING_TYPE_SYNC_MASK
) {
371 l2tp_packet_proc_delay_print(void)
377 l2tp_proxy_auth_type_print(const u_char
*dat
)
379 u_int16_t
*ptr
= (u_int16_t
*)dat
;
381 printf("%s", tok2str(l2tp_authentype2str
,
382 "AuthType-#%u", EXTRACT_16BITS(ptr
)));
386 l2tp_proxy_auth_id_print(const u_char
*dat
)
388 u_int16_t
*ptr
= (u_int16_t
*)dat
;
390 printf("%u", EXTRACT_16BITS(ptr
) & L2TP_PROXY_AUTH_ID_MASK
);
394 l2tp_call_errors_print(const u_char
*dat
)
396 u_int16_t
*ptr
= (u_int16_t
*)dat
;
397 u_int16_t val_h
, val_l
;
399 ptr
++; /* skip "Reserved" */
401 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
402 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
403 printf("CRCErr=%u ", (val_h
<<16) + val_l
);
405 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
406 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
407 printf("FrameErr=%u ", (val_h
<<16) + val_l
);
409 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
410 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
411 printf("HardOver=%u ", (val_h
<<16) + val_l
);
413 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
414 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
415 printf("BufOver=%u ", (val_h
<<16) + val_l
);
417 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
418 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
419 printf("Timeout=%u ", (val_h
<<16) + val_l
);
421 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
422 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
423 printf("AlignErr=%u ", (val_h
<<16) + val_l
);
427 l2tp_accm_print(const u_char
*dat
)
429 u_int16_t
*ptr
= (u_int16_t
*)dat
;
430 u_int16_t val_h
, val_l
;
432 ptr
++; /* skip "Reserved" */
434 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
435 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
436 printf("send=%08x ", (val_h
<<16) + val_l
);
438 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
439 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
440 printf("recv=%08x ", (val_h
<<16) + val_l
);
444 l2tp_ppp_discon_cc_print(const u_char
*dat
, u_int length
)
446 u_int16_t
*ptr
= (u_int16_t
*)dat
;
448 printf("%04x, ", EXTRACT_16BITS(ptr
)); ptr
++; /* Disconnect Code */
449 printf("%04x ", EXTRACT_16BITS(ptr
)); ptr
++; /* Control Protocol Number */
450 printf("%s", tok2str(l2tp_cc_direction2str
,
451 "Direction-#%u", *((u_char
*)ptr
++)));
455 print_string((const u_char
*)ptr
, length
-5);
460 l2tp_avp_print(const u_char
*dat
, int length
)
463 const u_int16_t
*ptr
= (u_int16_t
*)dat
;
473 TCHECK(*ptr
); /* Flags & Length */
474 len
= EXTRACT_16BITS(ptr
) & L2TP_AVP_HDR_LEN_MASK
;
476 /* If it is not long enough to contain the header, we'll give up. */
480 /* If it goes past the end of the remaining length of the packet,
482 if (len
> (u_int
)length
)
485 /* If it goes past the end of the remaining length of the captured
486 data, we'll give up. */
488 /* After this point, no need to worry about truncation */
490 if (EXTRACT_16BITS(ptr
) & L2TP_AVP_HDR_FLAG_MANDATORY
) {
493 if (EXTRACT_16BITS(ptr
) & L2TP_AVP_HDR_FLAG_HIDDEN
) {
499 if (EXTRACT_16BITS(ptr
)) {
500 /* Vendor Specific Attribute */
501 printf("VENDOR%04x:", EXTRACT_16BITS(ptr
)); ptr
++;
502 printf("ATTR%04x", EXTRACT_16BITS(ptr
)); ptr
++;
504 print_octets((u_char
*)ptr
, len
-6);
507 /* IETF-defined Attributes */
509 attr_type
= EXTRACT_16BITS(ptr
); ptr
++;
510 printf("%s", tok2str(l2tp_avp2str
, "AVP-#%u", attr_type
));
516 case L2TP_AVP_MSGTYPE
:
517 l2tp_msgtype_print((u_char
*)ptr
);
519 case L2TP_AVP_RESULT_CODE
:
520 l2tp_result_code_print((u_char
*)ptr
, len
-6);
522 case L2TP_AVP_PROTO_VER
:
523 l2tp_proto_ver_print(ptr
);
525 case L2TP_AVP_FRAMING_CAP
:
526 l2tp_framing_cap_print((u_char
*)ptr
);
528 case L2TP_AVP_BEARER_CAP
:
529 l2tp_bearer_cap_print((u_char
*)ptr
);
531 case L2TP_AVP_TIE_BREAKER
:
532 print_octets((u_char
*)ptr
, 8);
534 case L2TP_AVP_FIRM_VER
:
535 case L2TP_AVP_ASSND_TUN_ID
:
536 case L2TP_AVP_RECV_WIN_SIZE
:
537 case L2TP_AVP_ASSND_SESS_ID
:
538 print_16bits_val(ptr
);
540 case L2TP_AVP_HOST_NAME
:
541 case L2TP_AVP_VENDOR_NAME
:
542 case L2TP_AVP_CALLING_NUMBER
:
543 case L2TP_AVP_CALLED_NUMBER
:
544 case L2TP_AVP_SUB_ADDRESS
:
545 case L2TP_AVP_PROXY_AUTH_NAME
:
546 case L2TP_AVP_PRIVATE_GRP_ID
:
547 print_string((u_char
*)ptr
, len
-6);
549 case L2TP_AVP_CHALLENGE
:
550 case L2TP_AVP_INI_RECV_LCP
:
551 case L2TP_AVP_LAST_SENT_LCP
:
552 case L2TP_AVP_LAST_RECV_LCP
:
553 case L2TP_AVP_PROXY_AUTH_CHAL
:
554 case L2TP_AVP_PROXY_AUTH_RESP
:
555 case L2TP_AVP_RANDOM_VECTOR
:
556 print_octets((u_char
*)ptr
, len
-6);
558 case L2TP_AVP_Q931_CC
:
559 l2tp_q931_cc_print((u_char
*)ptr
, len
-6);
561 case L2TP_AVP_CHALLENGE_RESP
:
562 print_octets((u_char
*)ptr
, 16);
564 case L2TP_AVP_CALL_SER_NUM
:
565 case L2TP_AVP_MINIMUM_BPS
:
566 case L2TP_AVP_MAXIMUM_BPS
:
567 case L2TP_AVP_TX_CONN_SPEED
:
568 case L2TP_AVP_PHY_CHANNEL_ID
:
569 case L2TP_AVP_RX_CONN_SPEED
:
570 print_32bits_val((u_int32_t
*)ptr
);
572 case L2TP_AVP_BEARER_TYPE
:
573 l2tp_bearer_type_print((u_char
*)ptr
);
575 case L2TP_AVP_FRAMING_TYPE
:
576 l2tp_framing_type_print((u_char
*)ptr
);
578 case L2TP_AVP_PACKET_PROC_DELAY
:
579 l2tp_packet_proc_delay_print();
581 case L2TP_AVP_PROXY_AUTH_TYPE
:
582 l2tp_proxy_auth_type_print((u_char
*)ptr
);
584 case L2TP_AVP_PROXY_AUTH_ID
:
585 l2tp_proxy_auth_id_print((u_char
*)ptr
);
587 case L2TP_AVP_CALL_ERRORS
:
588 l2tp_call_errors_print((u_char
*)ptr
);
591 l2tp_accm_print((u_char
*)ptr
);
593 case L2TP_AVP_SEQ_REQUIRED
:
594 break; /* No Attribute Value */
595 case L2TP_AVP_PPP_DISCON_CC
:
596 l2tp_ppp_discon_cc_print((u_char
*)ptr
, len
-6);
605 l2tp_avp_print(dat
+len
, length
-len
);
614 l2tp_print(const u_char
*dat
, u_int length
)
616 const u_int16_t
*ptr
= (u_int16_t
*)dat
;
617 u_int cnt
= 0; /* total octets consumed */
619 int flag_t
, flag_l
, flag_s
, flag_o
;
622 flag_t
= flag_l
= flag_s
= flag_o
= FALSE
;
624 TCHECK(*ptr
); /* Flags & Version */
625 if ((EXTRACT_16BITS(ptr
) & L2TP_VERSION_MASK
) == L2TP_VERSION_L2TP
) {
627 } else if ((EXTRACT_16BITS(ptr
) & L2TP_VERSION_MASK
) == L2TP_VERSION_L2F
) {
629 return; /* nothing to do */
631 printf(" Unknown Version, neither L2F(1) nor L2TP(2)");
632 return; /* nothing we can do */
636 if (EXTRACT_16BITS(ptr
) & L2TP_FLAG_TYPE
) {
640 if (EXTRACT_16BITS(ptr
) & L2TP_FLAG_LENGTH
) {
644 if (EXTRACT_16BITS(ptr
) & L2TP_FLAG_SEQUENCE
) {
648 if (EXTRACT_16BITS(ptr
) & L2TP_FLAG_OFFSET
) {
652 if (EXTRACT_16BITS(ptr
) & L2TP_FLAG_PRIORITY
)
660 TCHECK(*ptr
); /* Length */
661 l2tp_len
= EXTRACT_16BITS(ptr
); ptr
++;
667 TCHECK(*ptr
); /* Tunnel ID */
668 printf("(%u/", EXTRACT_16BITS(ptr
)); ptr
++;
670 TCHECK(*ptr
); /* Session ID */
671 printf("%u)", EXTRACT_16BITS(ptr
)); ptr
++;
675 TCHECK(*ptr
); /* Ns */
676 printf("Ns=%u,", EXTRACT_16BITS(ptr
)); ptr
++;
678 TCHECK(*ptr
); /* Nr */
679 printf("Nr=%u", EXTRACT_16BITS(ptr
)); ptr
++;
684 TCHECK(*ptr
); /* Offset Size */
685 pad
= EXTRACT_16BITS(ptr
); ptr
++;
686 ptr
+= pad
/ sizeof(*ptr
);
691 if (length
< l2tp_len
) {
692 printf(" Length %u larger than packet", l2tp_len
);
698 printf(" Length %u smaller than header length", length
);
703 printf(" No length");
706 if (length
- cnt
== 0) {
709 l2tp_avp_print((u_char
*)ptr
, length
- cnt
);
713 ppp_print((u_char
*)ptr
, length
- cnt
);