1999-10-30 13:11:06 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that: (1) source code distributions
|
|
|
|
* retain the above copyright notice and this paragraph in its entirety, (2)
|
|
|
|
* distributions including binary code include the above copyright notice and
|
|
|
|
* this paragraph in its entirety in the documentation or other materials
|
|
|
|
* provided with the distribution, and (3) all advertising materials mentioning
|
|
|
|
* features or use of this software display the following acknowledgement:
|
|
|
|
* ``This product includes software developed by the University of California,
|
|
|
|
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
|
|
|
* the University nor the names of its contributors may be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
2000-07-01 11:48:44 +08:00
|
|
|
* L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
|
1999-10-30 13:11:06 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef lint
|
|
|
|
static const char rcsid[] =
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
"@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.14 2002-09-05 00:00:14 guy Exp $";
|
1999-11-21 17:36:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
1999-10-30 13:11:06 +08:00
|
|
|
#endif
|
|
|
|
|
2002-08-01 16:52:55 +08:00
|
|
|
#include <tcpdump-stdinc.h>
|
|
|
|
|
1999-12-15 14:55:43 +08:00
|
|
|
#include <stdio.h>
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
#include "l2tp.h"
|
|
|
|
#include "interface.h"
|
2002-05-25 17:41:06 +08:00
|
|
|
#include "extract.h"
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
static char tstr[] = " [|l2tp]";
|
|
|
|
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef FALSE
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
|
|
|
|
2001-11-05 18:03:27 +08:00
|
|
|
#define L2TP_MSGTYPE_SCCRQ 1 /* Start-Control-Connection-Request */
|
|
|
|
#define L2TP_MSGTYPE_SCCRP 2 /* Start-Control-Connection-Reply */
|
|
|
|
#define L2TP_MSGTYPE_SCCCN 3 /* Start-Control-Connection-Connected */
|
|
|
|
#define L2TP_MSGTYPE_STOPCCN 4 /* Stop-Control-Connection-Notification */
|
|
|
|
#define L2TP_MSGTYPE_HELLO 6 /* Hello */
|
|
|
|
#define L2TP_MSGTYPE_OCRQ 7 /* Outgoing-Call-Request */
|
|
|
|
#define L2TP_MSGTYPE_OCRP 8 /* Outgoing-Call-Reply */
|
|
|
|
#define L2TP_MSGTYPE_OCCN 9 /* Outgoing-Call-Connected */
|
|
|
|
#define L2TP_MSGTYPE_ICRQ 10 /* Incoming-Call-Request */
|
|
|
|
#define L2TP_MSGTYPE_ICRP 11 /* Incoming-Call-Reply */
|
|
|
|
#define L2TP_MSGTYPE_ICCN 12 /* Incoming-Call-Connected */
|
|
|
|
#define L2TP_MSGTYPE_CDN 14 /* Call-Disconnect-Notify */
|
|
|
|
#define L2TP_MSGTYPE_WEN 15 /* WAN-Error-Notify */
|
|
|
|
#define L2TP_MSGTYPE_SLI 16 /* Set-Link-Info */
|
|
|
|
|
|
|
|
static struct tok l2tp_msgtype2str[] = {
|
|
|
|
{ L2TP_MSGTYPE_SCCRQ, "SCCRQ" },
|
|
|
|
{ L2TP_MSGTYPE_SCCRP, "SCCRP" },
|
|
|
|
{ L2TP_MSGTYPE_SCCCN, "SCCCN" },
|
|
|
|
{ L2TP_MSGTYPE_STOPCCN, "StopCCN" },
|
|
|
|
{ L2TP_MSGTYPE_HELLO, "HELLO" },
|
|
|
|
{ L2TP_MSGTYPE_OCRQ, "OCRQ" },
|
|
|
|
{ L2TP_MSGTYPE_OCRP, "OCRP" },
|
|
|
|
{ L2TP_MSGTYPE_OCCN, "OCCN" },
|
|
|
|
{ L2TP_MSGTYPE_ICRQ, "ICRQ" },
|
|
|
|
{ L2TP_MSGTYPE_ICRP, "ICRP" },
|
|
|
|
{ L2TP_MSGTYPE_ICCN, "ICCN" },
|
|
|
|
{ L2TP_MSGTYPE_CDN, "CDN" },
|
|
|
|
{ L2TP_MSGTYPE_WEN, "WEN" },
|
|
|
|
{ L2TP_MSGTYPE_SLI, "SLI" },
|
|
|
|
{ 0, NULL }
|
1999-10-30 13:11:06 +08:00
|
|
|
};
|
|
|
|
|
2001-11-05 18:03:27 +08:00
|
|
|
#define L2TP_AVP_MSGTYPE 0 /* Message Type */
|
|
|
|
#define L2TP_AVP_RESULT_CODE 1 /* Result Code */
|
|
|
|
#define L2TP_AVP_PROTO_VER 2 /* Protocol Version */
|
|
|
|
#define L2TP_AVP_FRAMING_CAP 3 /* Framing Capabilities */
|
|
|
|
#define L2TP_AVP_BEARER_CAP 4 /* Bearer Capabilities */
|
|
|
|
#define L2TP_AVP_TIE_BREAKER 5 /* Tie Breaker */
|
|
|
|
#define L2TP_AVP_FIRM_VER 6 /* Firmware Revision */
|
|
|
|
#define L2TP_AVP_HOST_NAME 7 /* Host Name */
|
|
|
|
#define L2TP_AVP_VENDOR_NAME 8 /* Vendor Name */
|
|
|
|
#define L2TP_AVP_ASSND_TUN_ID 9 /* Assigned Tunnel ID */
|
|
|
|
#define L2TP_AVP_RECV_WIN_SIZE 10 /* Receive Window Size */
|
|
|
|
#define L2TP_AVP_CHALLENGE 11 /* Challenge */
|
|
|
|
#define L2TP_AVP_Q931_CC 12 /* Q.931 Cause Code */
|
|
|
|
#define L2TP_AVP_CHALLENGE_RESP 13 /* Challenge Response */
|
|
|
|
#define L2TP_AVP_ASSND_SESS_ID 14 /* Assigned Session ID */
|
|
|
|
#define L2TP_AVP_CALL_SER_NUM 15 /* Call Serial Number */
|
|
|
|
#define L2TP_AVP_MINIMUM_BPS 16 /* Minimum BPS */
|
|
|
|
#define L2TP_AVP_MAXIMUM_BPS 17 /* Maximum BPS */
|
|
|
|
#define L2TP_AVP_BEARER_TYPE 18 /* Bearer Type */
|
|
|
|
#define L2TP_AVP_FRAMING_TYPE 19 /* Framing Type */
|
|
|
|
#define L2TP_AVP_PACKET_PROC_DELAY 20 /* Packet Processing Delay (OBSOLETE) */
|
|
|
|
#define L2TP_AVP_CALLED_NUMBER 21 /* Called Number */
|
|
|
|
#define L2TP_AVP_CALLING_NUMBER 22 /* Calling Number */
|
|
|
|
#define L2TP_AVP_SUB_ADDRESS 23 /* Sub-Address */
|
|
|
|
#define L2TP_AVP_TX_CONN_SPEED 24 /* (Tx) Connect Speed */
|
|
|
|
#define L2TP_AVP_PHY_CHANNEL_ID 25 /* Physical Channel ID */
|
|
|
|
#define L2TP_AVP_INI_RECV_LCP 26 /* Initial Received LCP CONFREQ */
|
|
|
|
#define L2TP_AVP_LAST_SENT_LCP 27 /* Last Sent LCP CONFREQ */
|
|
|
|
#define L2TP_AVP_LAST_RECV_LCP 28 /* Last Received LCP CONFREQ */
|
|
|
|
#define L2TP_AVP_PROXY_AUTH_TYPE 29 /* Proxy Authen Type */
|
|
|
|
#define L2TP_AVP_PROXY_AUTH_NAME 30 /* Proxy Authen Name */
|
|
|
|
#define L2TP_AVP_PROXY_AUTH_CHAL 31 /* Proxy Authen Challenge */
|
|
|
|
#define L2TP_AVP_PROXY_AUTH_ID 32 /* Proxy Authen ID */
|
|
|
|
#define L2TP_AVP_PROXY_AUTH_RESP 33 /* Proxy Authen Response */
|
|
|
|
#define L2TP_AVP_CALL_ERRORS 34 /* Call Errors */
|
|
|
|
#define L2TP_AVP_ACCM 35 /* ACCM */
|
|
|
|
#define L2TP_AVP_RANDOM_VECTOR 36 /* Random Vector */
|
|
|
|
#define L2TP_AVP_PRIVATE_GRP_ID 37 /* Private Group ID */
|
|
|
|
#define L2TP_AVP_RX_CONN_SPEED 38 /* (Rx) Connect Speed */
|
|
|
|
#define L2TP_AVP_SEQ_REQUIRED 39 /* Sequencing Required */
|
|
|
|
#define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code */
|
|
|
|
|
|
|
|
static struct tok l2tp_avp2str[] = {
|
|
|
|
{ L2TP_AVP_MSGTYPE, "MSGTYPE" },
|
|
|
|
{ L2TP_AVP_RESULT_CODE, "RESULT_CODE" },
|
|
|
|
{ L2TP_AVP_PROTO_VER, "PROTO_VER" },
|
|
|
|
{ L2TP_AVP_FRAMING_CAP, "FRAMING_CAP" },
|
|
|
|
{ L2TP_AVP_BEARER_CAP, "BEARER_CAP" },
|
|
|
|
{ L2TP_AVP_TIE_BREAKER, "TIE_BREAKER" },
|
|
|
|
{ L2TP_AVP_FIRM_VER, "FIRM_VER" },
|
|
|
|
{ L2TP_AVP_HOST_NAME, "HOST_NAME" },
|
|
|
|
{ L2TP_AVP_VENDOR_NAME, "VENDOR_NAME" },
|
|
|
|
{ L2TP_AVP_ASSND_TUN_ID, "ASSND_TUN_ID" },
|
|
|
|
{ L2TP_AVP_RECV_WIN_SIZE, "RECV_WIN_SIZE" },
|
|
|
|
{ L2TP_AVP_CHALLENGE, "CHALLENGE" },
|
|
|
|
{ L2TP_AVP_Q931_CC, "Q931_CC", },
|
|
|
|
{ L2TP_AVP_CHALLENGE_RESP, "CHALLENGE_RESP" },
|
|
|
|
{ L2TP_AVP_ASSND_SESS_ID, "ASSND_SESS_ID" },
|
|
|
|
{ L2TP_AVP_CALL_SER_NUM, "CALL_SER_NUM" },
|
|
|
|
{ L2TP_AVP_MINIMUM_BPS, "MINIMUM_BPS" },
|
|
|
|
{ L2TP_AVP_MAXIMUM_BPS, "MAXIMUM_BPS" },
|
|
|
|
{ L2TP_AVP_BEARER_TYPE, "BEARER_TYPE" },
|
|
|
|
{ L2TP_AVP_FRAMING_TYPE, "FRAMING_TYPE" },
|
2002-06-12 01:08:37 +08:00
|
|
|
{ L2TP_AVP_PACKET_PROC_DELAY, "PACKET_PROC_DELAY" },
|
2001-11-05 18:03:27 +08:00
|
|
|
{ L2TP_AVP_CALLED_NUMBER, "CALLED_NUMBER" },
|
|
|
|
{ L2TP_AVP_CALLING_NUMBER, "CALLING_NUMBER" },
|
|
|
|
{ L2TP_AVP_SUB_ADDRESS, "SUB_ADDRESS" },
|
|
|
|
{ L2TP_AVP_TX_CONN_SPEED, "TX_CONN_SPEED" },
|
|
|
|
{ L2TP_AVP_PHY_CHANNEL_ID, "PHY_CHANNEL_ID" },
|
|
|
|
{ L2TP_AVP_INI_RECV_LCP, "INI_RECV_LCP" },
|
2002-06-12 01:08:37 +08:00
|
|
|
{ L2TP_AVP_LAST_SENT_LCP, "LAST_SENT_LCP" },
|
|
|
|
{ L2TP_AVP_LAST_RECV_LCP, "LAST_RECV_LCP" },
|
|
|
|
{ L2TP_AVP_PROXY_AUTH_TYPE, "PROXY_AUTH_TYPE" },
|
2001-11-05 18:03:27 +08:00
|
|
|
{ L2TP_AVP_PROXY_AUTH_NAME, "PROXY_AUTH_NAME" },
|
2002-06-12 01:08:37 +08:00
|
|
|
{ L2TP_AVP_PROXY_AUTH_CHAL, "PROXY_AUTH_CHAL" },
|
2001-11-05 18:03:27 +08:00
|
|
|
{ L2TP_AVP_PROXY_AUTH_ID, "PROXY_AUTH_ID" },
|
|
|
|
{ L2TP_AVP_PROXY_AUTH_RESP, "PROXY_AUTH_RESP" },
|
|
|
|
{ L2TP_AVP_CALL_ERRORS, "CALL_ERRORS" },
|
2002-06-12 01:08:37 +08:00
|
|
|
{ L2TP_AVP_ACCM, "ACCM" },
|
|
|
|
{ L2TP_AVP_RANDOM_VECTOR, "RANDOM_VECTOR" },
|
2001-11-05 18:03:27 +08:00
|
|
|
{ L2TP_AVP_PRIVATE_GRP_ID, "PRIVATE_GRP_ID" },
|
2002-06-12 01:08:37 +08:00
|
|
|
{ L2TP_AVP_RX_CONN_SPEED, "RX_CONN_SPEED" },
|
|
|
|
{ L2TP_AVP_SEQ_REQUIRED, "SEQ_REQUIRED" },
|
|
|
|
{ L2TP_AVP_PPP_DISCON_CC, "PPP_DISCON_CC" },
|
2001-11-05 18:03:27 +08:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct tok l2tp_authentype2str[] = {
|
|
|
|
{ L2TP_AUTHEN_TYPE_RESERVED, "Reserved" },
|
|
|
|
{ L2TP_AUTHEN_TYPE_TEXTUAL, "Textual" },
|
|
|
|
{ L2TP_AUTHEN_TYPE_CHAP, "CHAP" },
|
|
|
|
{ L2TP_AUTHEN_TYPE_PAP, "PAP" },
|
|
|
|
{ L2TP_AUTHEN_TYPE_NO_AUTH, "No Auth" },
|
|
|
|
{ L2TP_AUTHEN_TYPE_MSCHAPv1, "MS-CHAPv1" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
#define L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL 0
|
|
|
|
#define L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER 1
|
|
|
|
#define L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL 2
|
|
|
|
|
|
|
|
static struct tok l2tp_cc_direction2str[] = {
|
|
|
|
{ L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL, "global error" },
|
|
|
|
{ L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER, "at peer" },
|
|
|
|
{ L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL,"at local" },
|
|
|
|
{ 0, NULL }
|
1999-10-30 13:11:06 +08:00
|
|
|
};
|
|
|
|
|
1999-12-22 14:27:19 +08:00
|
|
|
#if 0
|
1999-10-30 13:11:06 +08:00
|
|
|
static char *l2tp_result_code_StopCCN[] = {
|
|
|
|
"Reserved",
|
|
|
|
"General request to clear control connection",
|
|
|
|
"General error--Error Code indicates the problem",
|
|
|
|
"Control channel already exists",
|
|
|
|
"Requester is not authorized to establish a control channel",
|
|
|
|
"The protocol version of the requester is not supported",
|
|
|
|
"Requester is being shut down",
|
|
|
|
"Finite State Machine error"
|
|
|
|
#define L2TP_MAX_RESULT_CODE_STOPCC_INDEX 8
|
|
|
|
};
|
1999-12-22 14:27:19 +08:00
|
|
|
#endif
|
1999-10-30 13:11:06 +08:00
|
|
|
|
1999-12-22 14:27:19 +08:00
|
|
|
#if 0
|
1999-10-30 13:11:06 +08:00
|
|
|
static char *l2tp_result_code_CDN[] = {
|
|
|
|
"Reserved",
|
|
|
|
"Call disconnected due to loss of carrier",
|
|
|
|
"Call disconnected for the reason indicated in error code",
|
|
|
|
"Call disconnected for administrative reasons",
|
|
|
|
"Call failed due to lack of appropriate facilities being " \
|
|
|
|
"available (temporary condition)",
|
|
|
|
"Call failed due to lack of appropriate facilities being " \
|
|
|
|
"available (permanent condition)",
|
|
|
|
"Invalid destination",
|
|
|
|
"Call failed due to no carrier detected",
|
|
|
|
"Call failed due to detection of a busy signal",
|
|
|
|
"Call failed due to lack of a dial tone",
|
|
|
|
"Call was not established within time allotted by LAC",
|
|
|
|
"Call was connected but no appropriate framing was detected"
|
|
|
|
#define L2TP_MAX_RESULT_CODE_CDN_INDEX 12
|
|
|
|
};
|
1999-12-22 14:27:19 +08:00
|
|
|
#endif
|
1999-10-30 13:11:06 +08:00
|
|
|
|
1999-12-22 14:27:19 +08:00
|
|
|
#if 0
|
1999-10-30 13:11:06 +08:00
|
|
|
static char *l2tp_error_code_general[] = {
|
|
|
|
"No general error",
|
|
|
|
"No control connection exists yet for this LAC-LNS pair",
|
|
|
|
"Length is wrong",
|
|
|
|
"One of the field values was out of range or " \
|
|
|
|
"reserved field was non-zero"
|
|
|
|
"Insufficient resources to handle this operation now",
|
|
|
|
"The Session ID is invalid in this context",
|
|
|
|
"A generic vendor-specific error occurred in the LAC",
|
|
|
|
"Try another"
|
|
|
|
#define L2TP_MAX_ERROR_CODE_GENERAL_INDEX 8
|
|
|
|
};
|
1999-12-22 14:27:19 +08:00
|
|
|
#endif
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
/******************************/
|
|
|
|
/* generic print out routines */
|
|
|
|
/******************************/
|
2002-06-12 01:08:37 +08:00
|
|
|
static void
|
1999-10-30 13:11:06 +08:00
|
|
|
print_string(const u_char *dat, u_int length)
|
|
|
|
{
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
u_int i;
|
1999-10-30 13:11:06 +08:00
|
|
|
for (i=0; i<length; i++) {
|
|
|
|
printf("%c", *dat++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-12 01:08:37 +08:00
|
|
|
static void
|
1999-10-30 13:11:06 +08:00
|
|
|
print_octets(const u_char *dat, u_int length)
|
|
|
|
{
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
u_int i;
|
1999-10-30 13:11:06 +08:00
|
|
|
for (i=0; i<length; i++) {
|
|
|
|
printf("%02x", *dat++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
print_16bits_val(const u_int16_t *dat)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2002-05-25 17:41:06 +08:00
|
|
|
printf("%u", EXTRACT_16BITS(dat));
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
print_32bits_val(const u_int32_t *dat)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2002-05-25 17:41:06 +08:00
|
|
|
printf("%lu", (u_long)EXTRACT_32BITS(dat));
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
2001-11-05 18:03:27 +08:00
|
|
|
/***********************************/
|
|
|
|
/* AVP-specific print out routines */
|
|
|
|
/***********************************/
|
1999-10-30 13:11:06 +08:00
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
l2tp_msgtype_print(const u_char *dat)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int16_t *ptr = (u_int16_t*)dat;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
printf("%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
|
|
|
|
EXTRACT_16BITS(ptr)));
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2tp_result_code_print(const u_char *dat, u_int length)
|
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int16_t *ptr = (u_int16_t *)dat;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
printf("%u", EXTRACT_16BITS(ptr)); ptr++; /* Result Code */
|
|
|
|
if (length > 2) { /* Error Code (opt) */
|
|
|
|
printf("/%u", EXTRACT_16BITS(ptr)); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
}
|
2002-05-25 17:41:06 +08:00
|
|
|
if (length > 4) { /* Error Message (opt) */
|
2001-11-05 18:03:27 +08:00
|
|
|
printf(" ");
|
|
|
|
print_string((u_char *)ptr, length - 4);
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
l2tp_proto_ver_print(const u_int16_t *dat)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2002-05-25 17:41:06 +08:00
|
|
|
printf("%u.%u", (EXTRACT_16BITS(dat) >> 8),
|
|
|
|
(EXTRACT_16BITS(dat) & 0xff));
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
l2tp_framing_cap_print(const u_char *dat)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int32_t *ptr = (u_int32_t *)dat;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_ASYNC_MASK) {
|
1999-10-30 13:11:06 +08:00
|
|
|
printf("A");
|
|
|
|
}
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_SYNC_MASK) {
|
1999-10-30 13:11:06 +08:00
|
|
|
printf("S");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
l2tp_bearer_cap_print(const u_char *dat)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int32_t *ptr = (u_int32_t *)dat;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_ANALOG_MASK) {
|
1999-10-30 13:11:06 +08:00
|
|
|
printf("A");
|
|
|
|
}
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_DIGITAL_MASK) {
|
1999-10-30 13:11:06 +08:00
|
|
|
printf("D");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2tp_q931_cc_print(const u_char *dat, u_int length)
|
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
print_16bits_val((u_int16_t *)dat);
|
1999-12-22 14:27:19 +08:00
|
|
|
printf(", %02x", dat[2]);
|
1999-10-30 13:11:06 +08:00
|
|
|
if (length > 3) {
|
|
|
|
printf(" ");
|
|
|
|
print_string(dat+3, length-3);
|
2002-06-12 01:08:37 +08:00
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
l2tp_bearer_type_print(const u_char *dat)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int32_t *ptr = (u_int32_t *)dat;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) {
|
1999-10-30 13:11:06 +08:00
|
|
|
printf("A");
|
|
|
|
}
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_DIGITAL_MASK) {
|
1999-10-30 13:11:06 +08:00
|
|
|
printf("D");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
l2tp_framing_type_print(const u_char *dat)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int32_t *ptr = (u_int32_t *)dat;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) {
|
1999-10-30 13:11:06 +08:00
|
|
|
printf("A");
|
|
|
|
}
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_SYNC_MASK) {
|
1999-10-30 13:11:06 +08:00
|
|
|
printf("S");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-11 05:37:58 +08:00
|
|
|
l2tp_packet_proc_delay_print(void)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
|
|
|
printf("obsolete");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
l2tp_proxy_auth_type_print(const u_char *dat)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int16_t *ptr = (u_int16_t *)dat;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-06-12 01:08:37 +08:00
|
|
|
printf("%s", tok2str(l2tp_authentype2str,
|
2002-05-25 17:41:06 +08:00
|
|
|
"AuthType-#%u", EXTRACT_16BITS(ptr)));
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
l2tp_proxy_auth_id_print(const u_char *dat)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int16_t *ptr = (u_int16_t *)dat;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
printf("%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK);
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
l2tp_call_errors_print(const u_char *dat)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int16_t *ptr = (u_int16_t *)dat;
|
|
|
|
u_int16_t val_h, val_l;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2001-11-05 18:03:27 +08:00
|
|
|
ptr++; /* skip "Reserved" */
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
val_h = EXTRACT_16BITS(ptr); ptr++;
|
|
|
|
val_l = EXTRACT_16BITS(ptr); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
printf("CRCErr=%u ", (val_h<<16) + val_l);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
val_h = EXTRACT_16BITS(ptr); ptr++;
|
|
|
|
val_l = EXTRACT_16BITS(ptr); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
printf("FrameErr=%u ", (val_h<<16) + val_l);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
val_h = EXTRACT_16BITS(ptr); ptr++;
|
|
|
|
val_l = EXTRACT_16BITS(ptr); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
printf("HardOver=%u ", (val_h<<16) + val_l);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
val_h = EXTRACT_16BITS(ptr); ptr++;
|
|
|
|
val_l = EXTRACT_16BITS(ptr); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
printf("BufOver=%u ", (val_h<<16) + val_l);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
val_h = EXTRACT_16BITS(ptr); ptr++;
|
|
|
|
val_l = EXTRACT_16BITS(ptr); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
printf("Timeout=%u ", (val_h<<16) + val_l);
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
val_h = EXTRACT_16BITS(ptr); ptr++;
|
|
|
|
val_l = EXTRACT_16BITS(ptr); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
printf("AlignErr=%u ", (val_h<<16) + val_l);
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
l2tp_accm_print(const u_char *dat)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int16_t *ptr = (u_int16_t *)dat;
|
|
|
|
u_int16_t val_h, val_l;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2001-11-05 18:03:27 +08:00
|
|
|
ptr++; /* skip "Reserved" */
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
val_h = EXTRACT_16BITS(ptr); ptr++;
|
|
|
|
val_l = EXTRACT_16BITS(ptr); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
printf("send=%08x ", (val_h<<16) + val_l);
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
val_h = EXTRACT_16BITS(ptr); ptr++;
|
|
|
|
val_l = EXTRACT_16BITS(ptr); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
printf("recv=%08x ", (val_h<<16) + val_l);
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
l2tp_ppp_discon_cc_print(const u_char *dat, u_int length)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int16_t *ptr = (u_int16_t *)dat;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
printf("%04x, ", EXTRACT_16BITS(ptr)); ptr++; /* Disconnect Code */
|
|
|
|
printf("%04x ", EXTRACT_16BITS(ptr)); ptr++; /* Control Protocol Number */
|
2002-06-12 01:08:37 +08:00
|
|
|
printf("%s", tok2str(l2tp_cc_direction2str,
|
2001-11-05 18:03:27 +08:00
|
|
|
"Direction-#%u", *((u_char *)ptr++)));
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2001-11-05 18:03:27 +08:00
|
|
|
if (length > 5) {
|
|
|
|
printf(" ");
|
|
|
|
print_string((const u_char *)ptr, length-5);
|
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-05 18:03:27 +08:00
|
|
|
l2tp_avp_print(const u_char *dat, int length)
|
1999-10-30 13:11:06 +08:00
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int len;
|
|
|
|
const u_int16_t *ptr = (u_int16_t *)dat;
|
|
|
|
u_int16_t attr_type;
|
|
|
|
int hidden = FALSE;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2001-11-05 18:03:27 +08:00
|
|
|
if (length <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2001-11-05 18:03:27 +08:00
|
|
|
printf(" ");
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2001-11-05 18:03:27 +08:00
|
|
|
TCHECK(*ptr); /* Flags & Length */
|
2002-05-25 17:41:06 +08:00
|
|
|
len = EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_LEN_MASK;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-06-12 01:08:37 +08:00
|
|
|
/* If it is not long enough to decode the entire AVP, we'll
|
2001-11-05 18:03:27 +08:00
|
|
|
abandon. */
|
|
|
|
TCHECK2(*ptr, len);
|
|
|
|
/* After this point, no need to worry about truncation */
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) {
|
2001-11-05 18:03:27 +08:00
|
|
|
printf("*");
|
|
|
|
}
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) {
|
2001-11-05 18:03:27 +08:00
|
|
|
hidden = TRUE;
|
|
|
|
printf("?");
|
|
|
|
}
|
|
|
|
ptr++;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_16BITS(ptr)) {
|
2001-11-05 18:03:27 +08:00
|
|
|
/* Vendor Specific Attribute */
|
2002-05-25 17:41:06 +08:00
|
|
|
printf("VENDOR%04x:", EXTRACT_16BITS(ptr)); ptr++;
|
|
|
|
printf("ATTR%04x", EXTRACT_16BITS(ptr)); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
printf("(");
|
|
|
|
print_octets((u_char *)ptr, len-6);
|
|
|
|
printf(")");
|
|
|
|
} else {
|
2002-06-12 01:08:37 +08:00
|
|
|
/* IETF-defined Attributes */
|
2001-11-05 18:03:27 +08:00
|
|
|
ptr++;
|
2002-05-25 17:41:06 +08:00
|
|
|
attr_type = EXTRACT_16BITS(ptr); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
printf("%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type));
|
|
|
|
printf("(");
|
|
|
|
if (hidden) {
|
|
|
|
printf("???");
|
1999-10-30 13:11:06 +08:00
|
|
|
} else {
|
2001-11-05 18:03:27 +08:00
|
|
|
switch (attr_type) {
|
|
|
|
case L2TP_AVP_MSGTYPE:
|
|
|
|
l2tp_msgtype_print((u_char *)ptr);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_RESULT_CODE:
|
|
|
|
l2tp_result_code_print((u_char *)ptr, len-6);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_PROTO_VER:
|
|
|
|
l2tp_proto_ver_print(ptr);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_FRAMING_CAP:
|
|
|
|
l2tp_framing_cap_print((u_char *)ptr);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_BEARER_CAP:
|
|
|
|
l2tp_bearer_cap_print((u_char *)ptr);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_TIE_BREAKER:
|
|
|
|
print_octets((u_char *)ptr, 8);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_FIRM_VER:
|
|
|
|
case L2TP_AVP_ASSND_TUN_ID:
|
|
|
|
case L2TP_AVP_RECV_WIN_SIZE:
|
|
|
|
case L2TP_AVP_ASSND_SESS_ID:
|
|
|
|
print_16bits_val(ptr);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_HOST_NAME:
|
|
|
|
case L2TP_AVP_VENDOR_NAME:
|
|
|
|
case L2TP_AVP_CALLING_NUMBER:
|
|
|
|
case L2TP_AVP_CALLED_NUMBER:
|
|
|
|
case L2TP_AVP_SUB_ADDRESS:
|
|
|
|
case L2TP_AVP_PROXY_AUTH_NAME:
|
2002-06-12 01:08:37 +08:00
|
|
|
case L2TP_AVP_PRIVATE_GRP_ID:
|
2001-11-05 18:03:27 +08:00
|
|
|
print_string((u_char *)ptr, len-6);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_CHALLENGE:
|
|
|
|
case L2TP_AVP_INI_RECV_LCP:
|
|
|
|
case L2TP_AVP_LAST_SENT_LCP:
|
|
|
|
case L2TP_AVP_LAST_RECV_LCP:
|
|
|
|
case L2TP_AVP_PROXY_AUTH_CHAL:
|
|
|
|
case L2TP_AVP_PROXY_AUTH_RESP:
|
|
|
|
case L2TP_AVP_RANDOM_VECTOR:
|
|
|
|
print_octets((u_char *)ptr, len-6);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_Q931_CC:
|
|
|
|
l2tp_q931_cc_print((u_char *)ptr, len-6);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_CHALLENGE_RESP:
|
|
|
|
print_octets((u_char *)ptr, 16);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_CALL_SER_NUM:
|
|
|
|
case L2TP_AVP_MINIMUM_BPS:
|
|
|
|
case L2TP_AVP_MAXIMUM_BPS:
|
|
|
|
case L2TP_AVP_TX_CONN_SPEED:
|
|
|
|
case L2TP_AVP_PHY_CHANNEL_ID:
|
|
|
|
case L2TP_AVP_RX_CONN_SPEED:
|
|
|
|
print_32bits_val((u_int32_t *)ptr);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_BEARER_TYPE:
|
|
|
|
l2tp_bearer_type_print((u_char *)ptr);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_FRAMING_TYPE:
|
|
|
|
l2tp_framing_type_print((u_char *)ptr);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_PACKET_PROC_DELAY:
|
|
|
|
l2tp_packet_proc_delay_print();
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_PROXY_AUTH_TYPE:
|
|
|
|
l2tp_proxy_auth_type_print((u_char *)ptr);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_PROXY_AUTH_ID:
|
|
|
|
l2tp_proxy_auth_id_print((u_char *)ptr);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_CALL_ERRORS:
|
|
|
|
l2tp_call_errors_print((u_char *)ptr);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_ACCM:
|
|
|
|
l2tp_accm_print((u_char *)ptr);
|
|
|
|
break;
|
|
|
|
case L2TP_AVP_SEQ_REQUIRED:
|
|
|
|
break; /* No Attribute Value */
|
|
|
|
case L2TP_AVP_PPP_DISCON_CC:
|
|
|
|
l2tp_ppp_discon_cc_print((u_char *)ptr, len-6);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2000-07-01 11:48:44 +08:00
|
|
|
}
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2001-11-05 18:03:27 +08:00
|
|
|
printf(")");
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
2001-11-05 18:03:27 +08:00
|
|
|
|
|
|
|
l2tp_avp_print(dat+len, length-len);
|
|
|
|
return;
|
|
|
|
|
|
|
|
trunc:
|
|
|
|
printf("|...");
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
l2tp_print(const u_char *dat, u_int length)
|
|
|
|
{
|
2001-11-05 18:03:27 +08:00
|
|
|
const u_int16_t *ptr = (u_int16_t *)dat;
|
1999-10-30 13:11:06 +08:00
|
|
|
u_int cnt = 0; /* total octets consumed */
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int16_t pad;
|
1999-10-30 13:11:06 +08:00
|
|
|
int flag_t, flag_l, flag_s, flag_o, flag_p;
|
2001-11-05 18:03:27 +08:00
|
|
|
u_int16_t l2tp_len;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
flag_t = flag_l = flag_s = flag_o = flag_p = FALSE;
|
|
|
|
|
2001-11-05 18:03:27 +08:00
|
|
|
TCHECK(*ptr); /* Flags & Version */
|
2002-05-25 17:41:06 +08:00
|
|
|
if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) {
|
1999-10-30 13:11:06 +08:00
|
|
|
printf(" l2tp:");
|
2002-05-25 17:41:06 +08:00
|
|
|
} else if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) {
|
1999-10-30 13:11:06 +08:00
|
|
|
printf(" l2f:");
|
|
|
|
return; /* nothing to do */
|
|
|
|
} else {
|
|
|
|
printf(" Unknown Version, neither L2F(1) nor L2TP(2)");
|
|
|
|
return; /* nothing we can do */
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("[");
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_TYPE) {
|
1999-10-30 13:11:06 +08:00
|
|
|
flag_t = TRUE;
|
|
|
|
printf("T");
|
|
|
|
}
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_LENGTH) {
|
1999-10-30 13:11:06 +08:00
|
|
|
flag_l = TRUE;
|
|
|
|
printf("L");
|
|
|
|
}
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_SEQUENCE) {
|
1999-10-30 13:11:06 +08:00
|
|
|
flag_s = TRUE;
|
|
|
|
printf("S");
|
|
|
|
}
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_OFFSET) {
|
1999-10-30 13:11:06 +08:00
|
|
|
flag_o = TRUE;
|
|
|
|
printf("O");
|
|
|
|
}
|
2002-05-25 17:41:06 +08:00
|
|
|
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_PRIORITY) {
|
1999-10-30 13:11:06 +08:00
|
|
|
flag_p = TRUE;
|
|
|
|
printf("P");
|
|
|
|
}
|
|
|
|
printf("]");
|
|
|
|
|
|
|
|
ptr++;
|
|
|
|
cnt += 2;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
1999-10-30 13:11:06 +08:00
|
|
|
if (flag_l) {
|
2001-11-05 18:03:27 +08:00
|
|
|
TCHECK(*ptr); /* Length */
|
2002-05-25 17:41:06 +08:00
|
|
|
l2tp_len = EXTRACT_16BITS(ptr); ptr++;
|
1999-10-30 13:11:06 +08:00
|
|
|
cnt += 2;
|
|
|
|
} else {
|
|
|
|
l2tp_len = 0;
|
|
|
|
}
|
|
|
|
|
2001-11-05 18:03:27 +08:00
|
|
|
TCHECK(*ptr); /* Tunnel ID */
|
2002-05-25 17:41:06 +08:00
|
|
|
printf("(%u/", EXTRACT_16BITS(ptr)); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
cnt += 2;
|
|
|
|
TCHECK(*ptr); /* Session ID */
|
2002-05-25 17:41:06 +08:00
|
|
|
printf("%u)", EXTRACT_16BITS(ptr)); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
cnt += 2;
|
1999-10-30 13:11:06 +08:00
|
|
|
|
|
|
|
if (flag_s) {
|
2001-11-05 18:03:27 +08:00
|
|
|
TCHECK(*ptr); /* Ns */
|
2002-05-25 17:41:06 +08:00
|
|
|
printf("Ns=%u,", EXTRACT_16BITS(ptr)); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
cnt += 2;
|
|
|
|
TCHECK(*ptr); /* Nr */
|
2002-05-25 17:41:06 +08:00
|
|
|
printf("Nr=%u", EXTRACT_16BITS(ptr)); ptr++;
|
2001-11-05 18:03:27 +08:00
|
|
|
cnt += 2;
|
1999-10-30 13:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flag_o) {
|
2001-11-05 18:03:27 +08:00
|
|
|
TCHECK(*ptr); /* Offset Size */
|
2002-05-25 17:41:06 +08:00
|
|
|
pad = EXTRACT_16BITS(ptr); ptr++;
|
1999-11-17 12:14:50 +08:00
|
|
|
ptr += pad / sizeof(*ptr);
|
1999-10-30 13:11:06 +08:00
|
|
|
cnt += (2 + pad);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag_t) {
|
|
|
|
if (length - cnt == 0) {
|
|
|
|
printf(" ZLB");
|
|
|
|
} else {
|
|
|
|
l2tp_avp_print((u_char *)ptr, length - cnt);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printf(" {");
|
2000-08-18 15:44:45 +08:00
|
|
|
ppp_print((u_char *)ptr, length - cnt);
|
1999-10-30 13:11:06 +08:00
|
|
|
printf("}");
|
|
|
|
}
|
2001-11-05 18:03:27 +08:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
trunc:
|
|
|
|
printf("%s", tstr);
|
2002-06-12 01:08:37 +08:00
|
|
|
}
|