* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * L2TP support contributed by Motonori Shindo (mshindo@ascend.co.jp)
+ * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.2 1999-10-30 23:45:51 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.8 2000-08-18 07:44:46 itojun Exp $";
#endif
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>
#include <netinet/in.h>
#define FALSE 0
#endif
-static u_char *l2tp_message_type_string[] = {
+static char *l2tp_message_type_string[] = {
"RESERVED_0", /* 0 Reserved */
"SCCRQ", /* 1 Start-Control-Connection-Request */
"SCCRP", /* 2 Start-Control-Connection-Reply */
#define L2TP_MAX_AVP_INDEX 40
};
+#if 0
static char *l2tp_result_code_StopCCN[] = {
"Reserved",
"General request to clear control connection",
"Finite State Machine error"
#define L2TP_MAX_RESULT_CODE_STOPCC_INDEX 8
};
+#endif
+#if 0
static char *l2tp_result_code_CDN[] = {
"Reserved",
"Call disconnected due to loss of carrier",
"Call was connected but no appropriate framing was detected"
#define L2TP_MAX_RESULT_CODE_CDN_INDEX 12
};
+#endif
+#if 0
static char *l2tp_error_code_general[] = {
"No general error",
"No control connection exists yet for this LAC-LNS pair",
"Try another"
#define L2TP_MAX_ERROR_CODE_GENERAL_INDEX 8
};
+#endif
/******************************/
/* generic print out routines */
static void
print_short(const u_short *dat)
{
- printf("%d", ntohs(*dat));
+ printf("%u", ntohs(*dat));
}
static void
print_int(const u_int *dat)
{
- printf("%d", ntohl(*dat));
+ printf("%lu", (u_long)ntohl(*dat));
}
/**********************************/
u_short *ptr = (u_short *)dat;
if (length == 2) { /* result code */
- printf("%d", ntohs(*ptr));
+ printf("%u", ntohs(*ptr));
} else if (length == 4) { /* result & error code */
- printf("%d/%d", ntohs(*ptr), ntohs(*(ptr+1)));
+ printf("%u/%u", ntohs(*ptr), ntohs(*(ptr+1)));
} else if (length > 4) { /* result & error code & msg */
- printf("%d/%d %s", ntohs(*ptr), ntohs(*(ptr+1)));
+ printf("%u/%u ", ntohs(*ptr), ntohs(*(ptr+1)));
print_string((u_char *)(ptr+2), length - 4);
}
}
static void
l2tp_tie_breaker_print(const u_char *dat, u_int length)
{
- printf("%lx", *(u_long *)dat); /* XXX */
+ print_octets(dat, 8); /* Tie Break Value is 64bits long */
}
static void
l2tp_q931_cc_print(const u_char *dat, u_int length)
{
print_short((u_short *)dat);
- printf(",%02x", dat+2);
+ printf(", %02x", dat[2]);
if (length > 3) {
printf(" ");
print_string(dat+3, length-3);
{
u_short *ptr = (u_short *)dat;
- printf("%d", ntohs(*ptr) & L2TP_PROXY_AUTH_ID_MASK);
+ printf("%u", ntohs(*ptr) & L2TP_PROXY_AUTH_ID_MASK);
}
static void
}
ptr++;
- if (ntohs(*ptr)) { /* IETF == 0 */
- printf("vendor=%04x", ntohs(*ptr));
- }
- ptr++;
-
- if (ntohs(*ptr) < L2TP_MAX_AVP_INDEX) {
- printf("%s", l2tp_avp[ntohs(*ptr)].name);
+ if (ntohs(*ptr)) {
+ /* Vendor Specific Attribute */
+ printf("VENDOR%04x:", ntohs(*ptr));
+ ptr++;
+ printf("ATTR%04x", ntohs(*ptr));
printf("(");
- if (!hidden) {
- (l2tp_avp[ntohs(*ptr)].print)
- ((u_char *)ptr+2, len-6);
- } else {
- printf("???");
- }
+ print_octets((u_char *)ptr+2, len-6);
printf(")");
} else {
- printf(" invalid AVP %s", ntohs(*ptr));
+ /* IETF-defined Attribute */
+ ptr++;
+ if (ntohs(*ptr) < L2TP_MAX_AVP_INDEX) {
+ printf("%s", l2tp_avp[ntohs(*ptr)].name);
+ printf("(");
+ if (!hidden) {
+ (l2tp_avp[ntohs(*ptr)].print)
+ ((u_char *)ptr+2, len-6);
+ } else {
+ printf("???");
+ }
+ printf(")");
+ } else {
+ printf(" invalid AVP %u", ntohs(*ptr));
+ }
}
l2tp_avp_print(dat + len, length - len);
l2tp_len = 0;
}
- printf("(%d/", ntohs(*ptr++)); /* Tunnel ID */
- printf("%d)", ntohs(*ptr++)); /* Session ID */
+ printf("(%u/", ntohs(*ptr++)); /* Tunnel ID */
+ printf("%u)", ntohs(*ptr++)); /* Session ID */
cnt += 4;
if (flag_s) {
- printf("Ns=%d,", ntohs(*ptr++));
- printf("Nr=%d", ntohs(*ptr++));
+ printf("Ns=%u,", ntohs(*ptr++));
+ printf("Nr=%u", ntohs(*ptr++));
cnt += 4;
}
if (flag_o) {
pad = ntohs(*ptr++);
- (u_char *)ptr += pad;
+ ptr += pad / sizeof(*ptr);
cnt += (2 + pad);
}
l2tp_avp_print((u_char *)ptr, length - cnt);
}
} else {
-#if 0
printf(" {");
- ppp_hdlc_print((u_char *)ptr, length - cnt);
+ ppp_print((u_char *)ptr, length - cnt);
printf("}");
-#else
- printf("[hdlc|]");
-#endif
}
}