#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.6 1999-12-22 06:27:21 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);
}
}
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
}
printf(")");
} else {
- printf(" invalid AVP %s", ntohs(*ptr));
+ 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);
}