2 * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
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.
21 * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
25 static const char rcsid
[] _U_
=
26 "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.20 2006-06-23 02:03:09 hannes Exp $";
33 #include <tcpdump-stdinc.h>
37 #include "interface.h"
40 #define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */
41 #define L2TP_FLAG_LENGTH 0x4000 /* Length */
42 #define L2TP_FLAG_SEQUENCE 0x0800 /* Sequence */
43 #define L2TP_FLAG_OFFSET 0x0200 /* Offset */
44 #define L2TP_FLAG_PRIORITY 0x0100 /* Priority */
46 #define L2TP_VERSION_MASK 0x000f /* Version Mask */
47 #define L2TP_VERSION_L2F 0x0001 /* L2F */
48 #define L2TP_VERSION_L2TP 0x0002 /* L2TP */
50 #define L2TP_AVP_HDR_FLAG_MANDATORY 0x8000 /* Mandatory Flag */
51 #define L2TP_AVP_HDR_FLAG_HIDDEN 0x4000 /* Hidden Flag */
52 #define L2TP_AVP_HDR_LEN_MASK 0x03ff /* Length Mask */
54 #define L2TP_FRAMING_CAP_SYNC_MASK 0x00000001 /* Synchronous */
55 #define L2TP_FRAMING_CAP_ASYNC_MASK 0x00000002 /* Asynchronous */
57 #define L2TP_FRAMING_TYPE_SYNC_MASK 0x00000001 /* Synchronous */
58 #define L2TP_FRAMING_TYPE_ASYNC_MASK 0x00000002 /* Asynchronous */
60 #define L2TP_BEARER_CAP_DIGITAL_MASK 0x00000001 /* Digital */
61 #define L2TP_BEARER_CAP_ANALOG_MASK 0x00000002 /* Analog */
63 #define L2TP_BEARER_TYPE_DIGITAL_MASK 0x00000001 /* Digital */
64 #define L2TP_BEARER_TYPE_ANALOG_MASK 0x00000002 /* Analog */
67 #define L2TP_AUTHEN_TYPE_RESERVED 0x0000 /* Reserved */
68 #define L2TP_AUTHEN_TYPE_TEXTUAL 0x0001 /* Textual username/password exchange */
69 #define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */
70 #define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */
71 #define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */
72 #define L2TP_AUTHEN_TYPE_MSCHAPv1 0x0005 /* MSCHAPv1 */
74 #define L2TP_PROXY_AUTH_ID_MASK 0x00ff
76 static const char tstr
[] = " [|l2tp]";
78 #define L2TP_MSGTYPE_SCCRQ 1 /* Start-Control-Connection-Request */
79 #define L2TP_MSGTYPE_SCCRP 2 /* Start-Control-Connection-Reply */
80 #define L2TP_MSGTYPE_SCCCN 3 /* Start-Control-Connection-Connected */
81 #define L2TP_MSGTYPE_STOPCCN 4 /* Stop-Control-Connection-Notification */
82 #define L2TP_MSGTYPE_HELLO 6 /* Hello */
83 #define L2TP_MSGTYPE_OCRQ 7 /* Outgoing-Call-Request */
84 #define L2TP_MSGTYPE_OCRP 8 /* Outgoing-Call-Reply */
85 #define L2TP_MSGTYPE_OCCN 9 /* Outgoing-Call-Connected */
86 #define L2TP_MSGTYPE_ICRQ 10 /* Incoming-Call-Request */
87 #define L2TP_MSGTYPE_ICRP 11 /* Incoming-Call-Reply */
88 #define L2TP_MSGTYPE_ICCN 12 /* Incoming-Call-Connected */
89 #define L2TP_MSGTYPE_CDN 14 /* Call-Disconnect-Notify */
90 #define L2TP_MSGTYPE_WEN 15 /* WAN-Error-Notify */
91 #define L2TP_MSGTYPE_SLI 16 /* Set-Link-Info */
93 static const struct tok l2tp_msgtype2str
[] = {
94 { L2TP_MSGTYPE_SCCRQ
, "SCCRQ" },
95 { L2TP_MSGTYPE_SCCRP
, "SCCRP" },
96 { L2TP_MSGTYPE_SCCCN
, "SCCCN" },
97 { L2TP_MSGTYPE_STOPCCN
, "StopCCN" },
98 { L2TP_MSGTYPE_HELLO
, "HELLO" },
99 { L2TP_MSGTYPE_OCRQ
, "OCRQ" },
100 { L2TP_MSGTYPE_OCRP
, "OCRP" },
101 { L2TP_MSGTYPE_OCCN
, "OCCN" },
102 { L2TP_MSGTYPE_ICRQ
, "ICRQ" },
103 { L2TP_MSGTYPE_ICRP
, "ICRP" },
104 { L2TP_MSGTYPE_ICCN
, "ICCN" },
105 { L2TP_MSGTYPE_CDN
, "CDN" },
106 { L2TP_MSGTYPE_WEN
, "WEN" },
107 { L2TP_MSGTYPE_SLI
, "SLI" },
111 #define L2TP_AVP_MSGTYPE 0 /* Message Type */
112 #define L2TP_AVP_RESULT_CODE 1 /* Result Code */
113 #define L2TP_AVP_PROTO_VER 2 /* Protocol Version */
114 #define L2TP_AVP_FRAMING_CAP 3 /* Framing Capabilities */
115 #define L2TP_AVP_BEARER_CAP 4 /* Bearer Capabilities */
116 #define L2TP_AVP_TIE_BREAKER 5 /* Tie Breaker */
117 #define L2TP_AVP_FIRM_VER 6 /* Firmware Revision */
118 #define L2TP_AVP_HOST_NAME 7 /* Host Name */
119 #define L2TP_AVP_VENDOR_NAME 8 /* Vendor Name */
120 #define L2TP_AVP_ASSND_TUN_ID 9 /* Assigned Tunnel ID */
121 #define L2TP_AVP_RECV_WIN_SIZE 10 /* Receive Window Size */
122 #define L2TP_AVP_CHALLENGE 11 /* Challenge */
123 #define L2TP_AVP_Q931_CC 12 /* Q.931 Cause Code */
124 #define L2TP_AVP_CHALLENGE_RESP 13 /* Challenge Response */
125 #define L2TP_AVP_ASSND_SESS_ID 14 /* Assigned Session ID */
126 #define L2TP_AVP_CALL_SER_NUM 15 /* Call Serial Number */
127 #define L2TP_AVP_MINIMUM_BPS 16 /* Minimum BPS */
128 #define L2TP_AVP_MAXIMUM_BPS 17 /* Maximum BPS */
129 #define L2TP_AVP_BEARER_TYPE 18 /* Bearer Type */
130 #define L2TP_AVP_FRAMING_TYPE 19 /* Framing Type */
131 #define L2TP_AVP_PACKET_PROC_DELAY 20 /* Packet Processing Delay (OBSOLETE) */
132 #define L2TP_AVP_CALLED_NUMBER 21 /* Called Number */
133 #define L2TP_AVP_CALLING_NUMBER 22 /* Calling Number */
134 #define L2TP_AVP_SUB_ADDRESS 23 /* Sub-Address */
135 #define L2TP_AVP_TX_CONN_SPEED 24 /* (Tx) Connect Speed */
136 #define L2TP_AVP_PHY_CHANNEL_ID 25 /* Physical Channel ID */
137 #define L2TP_AVP_INI_RECV_LCP 26 /* Initial Received LCP CONFREQ */
138 #define L2TP_AVP_LAST_SENT_LCP 27 /* Last Sent LCP CONFREQ */
139 #define L2TP_AVP_LAST_RECV_LCP 28 /* Last Received LCP CONFREQ */
140 #define L2TP_AVP_PROXY_AUTH_TYPE 29 /* Proxy Authen Type */
141 #define L2TP_AVP_PROXY_AUTH_NAME 30 /* Proxy Authen Name */
142 #define L2TP_AVP_PROXY_AUTH_CHAL 31 /* Proxy Authen Challenge */
143 #define L2TP_AVP_PROXY_AUTH_ID 32 /* Proxy Authen ID */
144 #define L2TP_AVP_PROXY_AUTH_RESP 33 /* Proxy Authen Response */
145 #define L2TP_AVP_CALL_ERRORS 34 /* Call Errors */
146 #define L2TP_AVP_ACCM 35 /* ACCM */
147 #define L2TP_AVP_RANDOM_VECTOR 36 /* Random Vector */
148 #define L2TP_AVP_PRIVATE_GRP_ID 37 /* Private Group ID */
149 #define L2TP_AVP_RX_CONN_SPEED 38 /* (Rx) Connect Speed */
150 #define L2TP_AVP_SEQ_REQUIRED 39 /* Sequencing Required */
151 #define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code */
153 static const struct tok l2tp_avp2str
[] = {
154 { L2TP_AVP_MSGTYPE
, "MSGTYPE" },
155 { L2TP_AVP_RESULT_CODE
, "RESULT_CODE" },
156 { L2TP_AVP_PROTO_VER
, "PROTO_VER" },
157 { L2TP_AVP_FRAMING_CAP
, "FRAMING_CAP" },
158 { L2TP_AVP_BEARER_CAP
, "BEARER_CAP" },
159 { L2TP_AVP_TIE_BREAKER
, "TIE_BREAKER" },
160 { L2TP_AVP_FIRM_VER
, "FIRM_VER" },
161 { L2TP_AVP_HOST_NAME
, "HOST_NAME" },
162 { L2TP_AVP_VENDOR_NAME
, "VENDOR_NAME" },
163 { L2TP_AVP_ASSND_TUN_ID
, "ASSND_TUN_ID" },
164 { L2TP_AVP_RECV_WIN_SIZE
, "RECV_WIN_SIZE" },
165 { L2TP_AVP_CHALLENGE
, "CHALLENGE" },
166 { L2TP_AVP_Q931_CC
, "Q931_CC", },
167 { L2TP_AVP_CHALLENGE_RESP
, "CHALLENGE_RESP" },
168 { L2TP_AVP_ASSND_SESS_ID
, "ASSND_SESS_ID" },
169 { L2TP_AVP_CALL_SER_NUM
, "CALL_SER_NUM" },
170 { L2TP_AVP_MINIMUM_BPS
, "MINIMUM_BPS" },
171 { L2TP_AVP_MAXIMUM_BPS
, "MAXIMUM_BPS" },
172 { L2TP_AVP_BEARER_TYPE
, "BEARER_TYPE" },
173 { L2TP_AVP_FRAMING_TYPE
, "FRAMING_TYPE" },
174 { L2TP_AVP_PACKET_PROC_DELAY
, "PACKET_PROC_DELAY" },
175 { L2TP_AVP_CALLED_NUMBER
, "CALLED_NUMBER" },
176 { L2TP_AVP_CALLING_NUMBER
, "CALLING_NUMBER" },
177 { L2TP_AVP_SUB_ADDRESS
, "SUB_ADDRESS" },
178 { L2TP_AVP_TX_CONN_SPEED
, "TX_CONN_SPEED" },
179 { L2TP_AVP_PHY_CHANNEL_ID
, "PHY_CHANNEL_ID" },
180 { L2TP_AVP_INI_RECV_LCP
, "INI_RECV_LCP" },
181 { L2TP_AVP_LAST_SENT_LCP
, "LAST_SENT_LCP" },
182 { L2TP_AVP_LAST_RECV_LCP
, "LAST_RECV_LCP" },
183 { L2TP_AVP_PROXY_AUTH_TYPE
, "PROXY_AUTH_TYPE" },
184 { L2TP_AVP_PROXY_AUTH_NAME
, "PROXY_AUTH_NAME" },
185 { L2TP_AVP_PROXY_AUTH_CHAL
, "PROXY_AUTH_CHAL" },
186 { L2TP_AVP_PROXY_AUTH_ID
, "PROXY_AUTH_ID" },
187 { L2TP_AVP_PROXY_AUTH_RESP
, "PROXY_AUTH_RESP" },
188 { L2TP_AVP_CALL_ERRORS
, "CALL_ERRORS" },
189 { L2TP_AVP_ACCM
, "ACCM" },
190 { L2TP_AVP_RANDOM_VECTOR
, "RANDOM_VECTOR" },
191 { L2TP_AVP_PRIVATE_GRP_ID
, "PRIVATE_GRP_ID" },
192 { L2TP_AVP_RX_CONN_SPEED
, "RX_CONN_SPEED" },
193 { L2TP_AVP_SEQ_REQUIRED
, "SEQ_REQUIRED" },
194 { L2TP_AVP_PPP_DISCON_CC
, "PPP_DISCON_CC" },
198 static const struct tok l2tp_authentype2str
[] = {
199 { L2TP_AUTHEN_TYPE_RESERVED
, "Reserved" },
200 { L2TP_AUTHEN_TYPE_TEXTUAL
, "Textual" },
201 { L2TP_AUTHEN_TYPE_CHAP
, "CHAP" },
202 { L2TP_AUTHEN_TYPE_PAP
, "PAP" },
203 { L2TP_AUTHEN_TYPE_NO_AUTH
, "No Auth" },
204 { L2TP_AUTHEN_TYPE_MSCHAPv1
, "MS-CHAPv1" },
208 #define L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL 0
209 #define L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER 1
210 #define L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL 2
212 static const struct tok l2tp_cc_direction2str
[] = {
213 { L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL
, "global error" },
214 { L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER
, "at peer" },
215 { L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL
,"at local" },
220 static char *l2tp_result_code_StopCCN
[] = {
222 "General request to clear control connection",
223 "General error--Error Code indicates the problem",
224 "Control channel already exists",
225 "Requester is not authorized to establish a control channel",
226 "The protocol version of the requester is not supported",
227 "Requester is being shut down",
228 "Finite State Machine error"
229 #define L2TP_MAX_RESULT_CODE_STOPCC_INDEX 8
234 static char *l2tp_result_code_CDN
[] = {
236 "Call disconnected due to loss of carrier",
237 "Call disconnected for the reason indicated in error code",
238 "Call disconnected for administrative reasons",
239 "Call failed due to lack of appropriate facilities being " \
240 "available (temporary condition)",
241 "Call failed due to lack of appropriate facilities being " \
242 "available (permanent condition)",
243 "Invalid destination",
244 "Call failed due to no carrier detected",
245 "Call failed due to detection of a busy signal",
246 "Call failed due to lack of a dial tone",
247 "Call was not established within time allotted by LAC",
248 "Call was connected but no appropriate framing was detected"
249 #define L2TP_MAX_RESULT_CODE_CDN_INDEX 12
254 static char *l2tp_error_code_general
[] = {
256 "No control connection exists yet for this LAC-LNS pair",
258 "One of the field values was out of range or " \
259 "reserved field was non-zero"
260 "Insufficient resources to handle this operation now",
261 "The Session ID is invalid in this context",
262 "A generic vendor-specific error occurred in the LAC",
264 #define L2TP_MAX_ERROR_CODE_GENERAL_INDEX 8
268 /******************************/
269 /* generic print out routines */
270 /******************************/
272 print_string(const u_char
*dat
, u_int length
)
275 for (i
=0; i
<length
; i
++) {
276 printf("%c", *dat
++);
281 print_octets(const u_char
*dat
, u_int length
)
284 for (i
=0; i
<length
; i
++) {
285 printf("%02x", *dat
++);
290 print_16bits_val(const u_int16_t
*dat
)
292 printf("%u", EXTRACT_16BITS(dat
));
296 print_32bits_val(const u_int32_t
*dat
)
298 printf("%lu", (u_long
)EXTRACT_32BITS(dat
));
301 /***********************************/
302 /* AVP-specific print out routines */
303 /***********************************/
305 l2tp_msgtype_print(const u_char
*dat
)
307 u_int16_t
*ptr
= (u_int16_t
*)dat
;
309 printf("%s", tok2str(l2tp_msgtype2str
, "MSGTYPE-#%u",
310 EXTRACT_16BITS(ptr
)));
314 l2tp_result_code_print(const u_char
*dat
, u_int length
)
316 u_int16_t
*ptr
= (u_int16_t
*)dat
;
318 printf("%u", EXTRACT_16BITS(ptr
)); ptr
++; /* Result Code */
319 if (length
> 2) { /* Error Code (opt) */
320 printf("/%u", EXTRACT_16BITS(ptr
)); ptr
++;
322 if (length
> 4) { /* Error Message (opt) */
324 print_string((u_char
*)ptr
, length
- 4);
329 l2tp_proto_ver_print(const u_int16_t
*dat
)
331 printf("%u.%u", (EXTRACT_16BITS(dat
) >> 8),
332 (EXTRACT_16BITS(dat
) & 0xff));
336 l2tp_framing_cap_print(const u_char
*dat
)
338 u_int32_t
*ptr
= (u_int32_t
*)dat
;
340 if (EXTRACT_32BITS(ptr
) & L2TP_FRAMING_CAP_ASYNC_MASK
) {
343 if (EXTRACT_32BITS(ptr
) & L2TP_FRAMING_CAP_SYNC_MASK
) {
349 l2tp_bearer_cap_print(const u_char
*dat
)
351 u_int32_t
*ptr
= (u_int32_t
*)dat
;
353 if (EXTRACT_32BITS(ptr
) & L2TP_BEARER_CAP_ANALOG_MASK
) {
356 if (EXTRACT_32BITS(ptr
) & L2TP_BEARER_CAP_DIGITAL_MASK
) {
362 l2tp_q931_cc_print(const u_char
*dat
, u_int length
)
364 print_16bits_val((u_int16_t
*)dat
);
365 printf(", %02x", dat
[2]);
368 print_string(dat
+3, length
-3);
373 l2tp_bearer_type_print(const u_char
*dat
)
375 u_int32_t
*ptr
= (u_int32_t
*)dat
;
377 if (EXTRACT_32BITS(ptr
) & L2TP_BEARER_TYPE_ANALOG_MASK
) {
380 if (EXTRACT_32BITS(ptr
) & L2TP_BEARER_TYPE_DIGITAL_MASK
) {
386 l2tp_framing_type_print(const u_char
*dat
)
388 u_int32_t
*ptr
= (u_int32_t
*)dat
;
390 if (EXTRACT_32BITS(ptr
) & L2TP_FRAMING_TYPE_ASYNC_MASK
) {
393 if (EXTRACT_32BITS(ptr
) & L2TP_FRAMING_TYPE_SYNC_MASK
) {
399 l2tp_packet_proc_delay_print(void)
405 l2tp_proxy_auth_type_print(const u_char
*dat
)
407 u_int16_t
*ptr
= (u_int16_t
*)dat
;
409 printf("%s", tok2str(l2tp_authentype2str
,
410 "AuthType-#%u", EXTRACT_16BITS(ptr
)));
414 l2tp_proxy_auth_id_print(const u_char
*dat
)
416 u_int16_t
*ptr
= (u_int16_t
*)dat
;
418 printf("%u", EXTRACT_16BITS(ptr
) & L2TP_PROXY_AUTH_ID_MASK
);
422 l2tp_call_errors_print(const u_char
*dat
)
424 u_int16_t
*ptr
= (u_int16_t
*)dat
;
425 u_int16_t val_h
, val_l
;
427 ptr
++; /* skip "Reserved" */
429 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
430 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
431 printf("CRCErr=%u ", (val_h
<<16) + val_l
);
433 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
434 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
435 printf("FrameErr=%u ", (val_h
<<16) + val_l
);
437 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
438 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
439 printf("HardOver=%u ", (val_h
<<16) + val_l
);
441 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
442 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
443 printf("BufOver=%u ", (val_h
<<16) + val_l
);
445 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
446 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
447 printf("Timeout=%u ", (val_h
<<16) + val_l
);
449 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
450 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
451 printf("AlignErr=%u ", (val_h
<<16) + val_l
);
455 l2tp_accm_print(const u_char
*dat
)
457 u_int16_t
*ptr
= (u_int16_t
*)dat
;
458 u_int16_t val_h
, val_l
;
460 ptr
++; /* skip "Reserved" */
462 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
463 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
464 printf("send=%08x ", (val_h
<<16) + val_l
);
466 val_h
= EXTRACT_16BITS(ptr
); ptr
++;
467 val_l
= EXTRACT_16BITS(ptr
); ptr
++;
468 printf("recv=%08x ", (val_h
<<16) + val_l
);
472 l2tp_ppp_discon_cc_print(const u_char
*dat
, u_int length
)
474 u_int16_t
*ptr
= (u_int16_t
*)dat
;
476 printf("%04x, ", EXTRACT_16BITS(ptr
)); ptr
++; /* Disconnect Code */
477 printf("%04x ", EXTRACT_16BITS(ptr
)); ptr
++; /* Control Protocol Number */
478 printf("%s", tok2str(l2tp_cc_direction2str
,
479 "Direction-#%u", *((u_char
*)ptr
++)));
483 print_string((const u_char
*)ptr
, length
-5);
488 l2tp_avp_print(const u_char
*dat
, int length
)
491 const u_int16_t
*ptr
= (u_int16_t
*)dat
;
501 TCHECK(*ptr
); /* Flags & Length */
502 len
= EXTRACT_16BITS(ptr
) & L2TP_AVP_HDR_LEN_MASK
;
504 /* If it is not long enough to contain the header, we'll give up. */
508 /* If it goes past the end of the remaining length of the packet,
510 if (len
> (u_int
)length
)
513 /* If it goes past the end of the remaining length of the captured
514 data, we'll give up. */
516 /* After this point, no need to worry about truncation */
518 if (EXTRACT_16BITS(ptr
) & L2TP_AVP_HDR_FLAG_MANDATORY
) {
521 if (EXTRACT_16BITS(ptr
) & L2TP_AVP_HDR_FLAG_HIDDEN
) {
527 if (EXTRACT_16BITS(ptr
)) {
528 /* Vendor Specific Attribute */
529 printf("VENDOR%04x:", EXTRACT_16BITS(ptr
)); ptr
++;
530 printf("ATTR%04x", EXTRACT_16BITS(ptr
)); ptr
++;
532 print_octets((u_char
*)ptr
, len
-6);
535 /* IETF-defined Attributes */
537 attr_type
= EXTRACT_16BITS(ptr
); ptr
++;
538 printf("%s", tok2str(l2tp_avp2str
, "AVP-#%u", attr_type
));
544 case L2TP_AVP_MSGTYPE
:
545 l2tp_msgtype_print((u_char
*)ptr
);
547 case L2TP_AVP_RESULT_CODE
:
548 l2tp_result_code_print((u_char
*)ptr
, len
-6);
550 case L2TP_AVP_PROTO_VER
:
551 l2tp_proto_ver_print(ptr
);
553 case L2TP_AVP_FRAMING_CAP
:
554 l2tp_framing_cap_print((u_char
*)ptr
);
556 case L2TP_AVP_BEARER_CAP
:
557 l2tp_bearer_cap_print((u_char
*)ptr
);
559 case L2TP_AVP_TIE_BREAKER
:
560 print_octets((u_char
*)ptr
, 8);
562 case L2TP_AVP_FIRM_VER
:
563 case L2TP_AVP_ASSND_TUN_ID
:
564 case L2TP_AVP_RECV_WIN_SIZE
:
565 case L2TP_AVP_ASSND_SESS_ID
:
566 print_16bits_val(ptr
);
568 case L2TP_AVP_HOST_NAME
:
569 case L2TP_AVP_VENDOR_NAME
:
570 case L2TP_AVP_CALLING_NUMBER
:
571 case L2TP_AVP_CALLED_NUMBER
:
572 case L2TP_AVP_SUB_ADDRESS
:
573 case L2TP_AVP_PROXY_AUTH_NAME
:
574 case L2TP_AVP_PRIVATE_GRP_ID
:
575 print_string((u_char
*)ptr
, len
-6);
577 case L2TP_AVP_CHALLENGE
:
578 case L2TP_AVP_INI_RECV_LCP
:
579 case L2TP_AVP_LAST_SENT_LCP
:
580 case L2TP_AVP_LAST_RECV_LCP
:
581 case L2TP_AVP_PROXY_AUTH_CHAL
:
582 case L2TP_AVP_PROXY_AUTH_RESP
:
583 case L2TP_AVP_RANDOM_VECTOR
:
584 print_octets((u_char
*)ptr
, len
-6);
586 case L2TP_AVP_Q931_CC
:
587 l2tp_q931_cc_print((u_char
*)ptr
, len
-6);
589 case L2TP_AVP_CHALLENGE_RESP
:
590 print_octets((u_char
*)ptr
, 16);
592 case L2TP_AVP_CALL_SER_NUM
:
593 case L2TP_AVP_MINIMUM_BPS
:
594 case L2TP_AVP_MAXIMUM_BPS
:
595 case L2TP_AVP_TX_CONN_SPEED
:
596 case L2TP_AVP_PHY_CHANNEL_ID
:
597 case L2TP_AVP_RX_CONN_SPEED
:
598 print_32bits_val((u_int32_t
*)ptr
);
600 case L2TP_AVP_BEARER_TYPE
:
601 l2tp_bearer_type_print((u_char
*)ptr
);
603 case L2TP_AVP_FRAMING_TYPE
:
604 l2tp_framing_type_print((u_char
*)ptr
);
606 case L2TP_AVP_PACKET_PROC_DELAY
:
607 l2tp_packet_proc_delay_print();
609 case L2TP_AVP_PROXY_AUTH_TYPE
:
610 l2tp_proxy_auth_type_print((u_char
*)ptr
);
612 case L2TP_AVP_PROXY_AUTH_ID
:
613 l2tp_proxy_auth_id_print((u_char
*)ptr
);
615 case L2TP_AVP_CALL_ERRORS
:
616 l2tp_call_errors_print((u_char
*)ptr
);
619 l2tp_accm_print((u_char
*)ptr
);
621 case L2TP_AVP_SEQ_REQUIRED
:
622 break; /* No Attribute Value */
623 case L2TP_AVP_PPP_DISCON_CC
:
624 l2tp_ppp_discon_cc_print((u_char
*)ptr
, len
-6);
633 l2tp_avp_print(dat
+len
, length
-len
);
642 l2tp_print(const u_char
*dat
, u_int length
)
644 const u_char
*ptr
= dat
;
645 u_int cnt
= 0; /* total octets consumed */
647 int flag_t
, flag_l
, flag_s
, flag_o
;
650 flag_t
= flag_l
= flag_s
= flag_o
= FALSE
;
652 TCHECK2(*ptr
, 2); /* Flags & Version */
653 if ((EXTRACT_16BITS(ptr
) & L2TP_VERSION_MASK
) == L2TP_VERSION_L2TP
) {
655 } else if ((EXTRACT_16BITS(ptr
) & L2TP_VERSION_MASK
) == L2TP_VERSION_L2F
) {
657 return; /* nothing to do */
659 printf(" Unknown Version, neither L2F(1) nor L2TP(2)");
660 return; /* nothing we can do */
664 if (EXTRACT_16BITS(ptr
) & L2TP_FLAG_TYPE
) {
668 if (EXTRACT_16BITS(ptr
) & L2TP_FLAG_LENGTH
) {
672 if (EXTRACT_16BITS(ptr
) & L2TP_FLAG_SEQUENCE
) {
676 if (EXTRACT_16BITS(ptr
) & L2TP_FLAG_OFFSET
) {
680 if (EXTRACT_16BITS(ptr
) & L2TP_FLAG_PRIORITY
)
688 TCHECK2(*ptr
, 2); /* Length */
689 l2tp_len
= EXTRACT_16BITS(ptr
);
696 TCHECK2(*ptr
, 2); /* Tunnel ID */
697 printf("(%u/", EXTRACT_16BITS(ptr
));
700 TCHECK2(*ptr
, 2); /* Session ID */
701 printf("%u)", EXTRACT_16BITS(ptr
));
706 TCHECK2(*ptr
, 2); /* Ns */
707 printf("Ns=%u,", EXTRACT_16BITS(ptr
));
710 TCHECK2(*ptr
, 2); /* Nr */
711 printf("Nr=%u", EXTRACT_16BITS(ptr
));
717 TCHECK2(*ptr
, 2); /* Offset Size */
718 pad
= EXTRACT_16BITS(ptr
);
724 if (length
< l2tp_len
) {
725 printf(" Length %u larger than packet", l2tp_len
);
731 printf(" Length %u smaller than header length", length
);
736 printf(" No length");
739 if (length
- cnt
== 0) {
742 l2tp_avp_print(ptr
, length
- cnt
);
746 ppp_print(ptr
, length
- cnt
);