*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */
static void
l2tp_msgtype_print(netdissect_options *ndo, const u_char *dat)
{
- uint16_t *ptr = (uint16_t*)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
ND_PRINT((ndo, "%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
EXTRACT_16BITS(ptr))));
static void
l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
- uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr))); ptr++; /* Result Code */
if (length > 2) { /* Error Code (opt) */
}
if (length > 4) { /* Error Message (opt) */
ND_PRINT((ndo, " "));
- print_string(ndo, (u_char *)ptr, length - 4);
+ print_string(ndo, (const u_char *)ptr, length - 4);
}
}
static void
l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat)
{
- uint32_t *ptr = (uint32_t *)dat;
+ const uint32_t *ptr = (const uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_ASYNC_MASK) {
ND_PRINT((ndo, "A"));
static void
l2tp_bearer_cap_print(netdissect_options *ndo, const u_char *dat)
{
- uint32_t *ptr = (uint32_t *)dat;
+ const uint32_t *ptr = (const uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_ANALOG_MASK) {
ND_PRINT((ndo, "A"));
static void
l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
- print_16bits_val(ndo, (uint16_t *)dat);
+ print_16bits_val(ndo, (const uint16_t *)dat);
ND_PRINT((ndo, ", %02x", dat[2]));
if (length > 3) {
ND_PRINT((ndo, " "));
static void
l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat)
{
- uint32_t *ptr = (uint32_t *)dat;
+ const uint32_t *ptr = (const uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) {
ND_PRINT((ndo, "A"));
static void
l2tp_framing_type_print(netdissect_options *ndo, const u_char *dat)
{
- uint32_t *ptr = (uint32_t *)dat;
+ const uint32_t *ptr = (const uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) {
ND_PRINT((ndo, "A"));
static void
l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat)
{
- uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
ND_PRINT((ndo, "%s", tok2str(l2tp_authentype2str,
"AuthType-#%u", EXTRACT_16BITS(ptr))));
static void
l2tp_proxy_auth_id_print(netdissect_options *ndo, const u_char *dat)
{
- uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK));
}
static void
l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat)
{
- uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
uint16_t val_h, val_l;
ptr++; /* skip "Reserved" */
static void
l2tp_accm_print(netdissect_options *ndo, const u_char *dat)
{
- uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
uint16_t val_h, val_l;
ptr++; /* skip "Reserved" */
static void
l2tp_ppp_discon_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
- uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
ND_PRINT((ndo, "%04x, ", EXTRACT_16BITS(ptr))); ptr++; /* Disconnect Code */
ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(ptr))); ptr++; /* Control Protocol Number */
ND_PRINT((ndo, "%s", tok2str(l2tp_cc_direction2str,
- "Direction-#%u", *((u_char *)ptr++))));
+ "Direction-#%u", *((const u_char *)ptr++))));
if (length > 5) {
ND_PRINT((ndo, " "));
l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
{
u_int len;
- const uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
uint16_t attr_type;
int hidden = FALSE;
ND_PRINT((ndo, "VENDOR%04x:", EXTRACT_16BITS(ptr))); ptr++;
ND_PRINT((ndo, "ATTR%04x", EXTRACT_16BITS(ptr))); ptr++;
ND_PRINT((ndo, "("));
- print_octets(ndo, (u_char *)ptr, len-6);
+ print_octets(ndo, (const u_char *)ptr, len-6);
ND_PRINT((ndo, ")"));
} else {
/* IETF-defined Attributes */
} else {
switch (attr_type) {
case L2TP_AVP_MSGTYPE:
- l2tp_msgtype_print(ndo, (u_char *)ptr);
+ l2tp_msgtype_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_RESULT_CODE:
- l2tp_result_code_print(ndo, (u_char *)ptr, len-6);
+ l2tp_result_code_print(ndo, (const u_char *)ptr, len-6);
break;
case L2TP_AVP_PROTO_VER:
l2tp_proto_ver_print(ndo, ptr);
break;
case L2TP_AVP_FRAMING_CAP:
- l2tp_framing_cap_print(ndo, (u_char *)ptr);
+ l2tp_framing_cap_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_BEARER_CAP:
- l2tp_bearer_cap_print(ndo, (u_char *)ptr);
+ l2tp_bearer_cap_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_TIE_BREAKER:
- print_octets(ndo, (u_char *)ptr, 8);
+ print_octets(ndo, (const u_char *)ptr, 8);
break;
case L2TP_AVP_FIRM_VER:
case L2TP_AVP_ASSND_TUN_ID:
case L2TP_AVP_SUB_ADDRESS:
case L2TP_AVP_PROXY_AUTH_NAME:
case L2TP_AVP_PRIVATE_GRP_ID:
- print_string(ndo, (u_char *)ptr, len-6);
+ print_string(ndo, (const u_char *)ptr, len-6);
break;
case L2TP_AVP_CHALLENGE:
case L2TP_AVP_INI_RECV_LCP:
case L2TP_AVP_PROXY_AUTH_CHAL:
case L2TP_AVP_PROXY_AUTH_RESP:
case L2TP_AVP_RANDOM_VECTOR:
- print_octets(ndo, (u_char *)ptr, len-6);
+ print_octets(ndo, (const u_char *)ptr, len-6);
break;
case L2TP_AVP_Q931_CC:
- l2tp_q931_cc_print(ndo, (u_char *)ptr, len-6);
+ l2tp_q931_cc_print(ndo, (const u_char *)ptr, len-6);
break;
case L2TP_AVP_CHALLENGE_RESP:
- print_octets(ndo, (u_char *)ptr, 16);
+ print_octets(ndo, (const u_char *)ptr, 16);
break;
case L2TP_AVP_CALL_SER_NUM:
case L2TP_AVP_MINIMUM_BPS:
case L2TP_AVP_TX_CONN_SPEED:
case L2TP_AVP_PHY_CHANNEL_ID:
case L2TP_AVP_RX_CONN_SPEED:
- print_32bits_val(ndo, (uint32_t *)ptr);
+ print_32bits_val(ndo, (const uint32_t *)ptr);
break;
case L2TP_AVP_BEARER_TYPE:
- l2tp_bearer_type_print(ndo, (u_char *)ptr);
+ l2tp_bearer_type_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_FRAMING_TYPE:
- l2tp_framing_type_print(ndo, (u_char *)ptr);
+ l2tp_framing_type_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_PACKET_PROC_DELAY:
l2tp_packet_proc_delay_print(ndo);
break;
case L2TP_AVP_PROXY_AUTH_TYPE:
- l2tp_proxy_auth_type_print(ndo, (u_char *)ptr);
+ l2tp_proxy_auth_type_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_PROXY_AUTH_ID:
- l2tp_proxy_auth_id_print(ndo, (u_char *)ptr);
+ l2tp_proxy_auth_id_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_CALL_ERRORS:
- l2tp_call_errors_print(ndo, (u_char *)ptr);
+ l2tp_call_errors_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_ACCM:
- l2tp_accm_print(ndo, (u_char *)ptr);
+ l2tp_accm_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_SEQ_REQUIRED:
break; /* No Attribute Value */
case L2TP_AVP_PPP_DISCON_CC:
- l2tp_ppp_discon_cc_print(ndo, (u_char *)ptr, len-6);
+ l2tp_ppp_discon_cc_print(ndo, (const u_char *)ptr, len-6);
break;
default:
break;