aboutsummaryrefslogtreecommitdiff
path: root/print-l2tp.c
diff options
context:
space:
mode:
Diffstat (limited to 'print-l2tp.c')
-rw-r--r--print-l2tp.c303
1 files changed, 149 insertions, 154 deletions
diff --git a/print-l2tp.c b/print-l2tp.c
index 7622bf3e672b..895efd21f008 100644
--- a/print-l2tp.c
+++ b/print-l2tp.c
@@ -26,10 +26,10 @@
/* specification: RFC 2661 */
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "extract.h"
@@ -70,7 +70,6 @@
#define L2TP_PROXY_AUTH_ID_MASK 0x00ff
-static const char tstr[] = " [|l2tp]";
#define L2TP_MSGTYPE_SCCRQ 1 /* Start-Control-Connection-Request */
#define L2TP_MSGTYPE_SCCRP 2 /* Start-Control-Connection-Reply */
@@ -88,7 +87,7 @@ static const char tstr[] = " [|l2tp]";
#define L2TP_MSGTYPE_SLI 16 /* Set-Link-Info */
static const struct tok l2tp_msgtype2str[] = {
- { L2TP_MSGTYPE_SCCRQ, "SCCRQ" },
+ { L2TP_MSGTYPE_SCCRQ, "SCCRQ" },
{ L2TP_MSGTYPE_SCCRP, "SCCRP" },
{ L2TP_MSGTYPE_SCCCN, "SCCCN" },
{ L2TP_MSGTYPE_STOPCCN, "StopCCN" },
@@ -114,17 +113,17 @@ static const struct tok l2tp_msgtype2str[] = {
#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_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_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_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 */
@@ -144,7 +143,7 @@ static const struct tok l2tp_msgtype2str[] = {
#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_SEQ_REQUIRED 39 /* Sequencing Required */
#define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code - RFC 3145 */
static const struct tok l2tp_avp2str[] = {
@@ -233,9 +232,9 @@ static char *l2tp_result_code_CDN[] = {
"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 " \
+ "Call failed due to lack of appropriate facilities being "
"available (temporary condition)",
- "Call failed due to lack of appropriate facilities being " \
+ "Call failed due to lack of appropriate facilities being "
"available (permanent condition)",
"Invalid destination",
"Call failed due to no carrier detected",
@@ -252,7 +251,7 @@ 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 " \
+ "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",
@@ -270,7 +269,8 @@ print_string(netdissect_options *ndo, const u_char *dat, u_int length)
{
u_int i;
for (i=0; i<length; i++) {
- ND_PRINT((ndo, "%c", *dat++));
+ fn_print_char(ndo, GET_U_1(dat));
+ dat++;
}
}
@@ -279,20 +279,21 @@ print_octets(netdissect_options *ndo, const u_char *dat, u_int length)
{
u_int i;
for (i=0; i<length; i++) {
- ND_PRINT((ndo, "%02x", *dat++));
+ ND_PRINT("%02x", GET_U_1(dat));
+ dat++;
}
}
static void
print_16bits_val(netdissect_options *ndo, const uint8_t *dat)
{
- ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat)));
+ ND_PRINT("%u", GET_BE_U_2(dat));
}
static void
print_32bits_val(netdissect_options *ndo, const uint8_t *dat)
{
- ND_PRINT((ndo, "%u", EXTRACT_32BITS(dat)));
+ ND_PRINT("%u", GET_BE_U_4(dat));
}
/***********************************/
@@ -302,11 +303,11 @@ static void
l2tp_msgtype_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
if (length < 2) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- ND_PRINT((ndo, "%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
- EXTRACT_16BITS(dat))));
+ ND_PRINT("%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
+ GET_BE_U_2(dat)));
}
static void
@@ -314,10 +315,10 @@ l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
/* Result Code */
if (length < 2) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat)));
+ ND_PRINT("%u", GET_BE_U_2(dat));
dat += 2;
length -= 2;
@@ -325,17 +326,17 @@ l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length)
if (length == 0)
return;
if (length < 2) {
- ND_PRINT((ndo, " AVP too short"));
+ ND_PRINT(" AVP too short");
return;
}
- ND_PRINT((ndo, "/%u", EXTRACT_16BITS(dat)));
+ ND_PRINT("/%u", GET_BE_U_2(dat));
dat += 2;
length -= 2;
/* Error Message (opt) */
if (length == 0)
return;
- ND_PRINT((ndo, " "));
+ ND_PRINT(" ");
print_string(ndo, dat, length);
}
@@ -343,25 +344,25 @@ static void
l2tp_proto_ver_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
if (length < 2) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- ND_PRINT((ndo, "%u.%u", (EXTRACT_16BITS(dat) >> 8),
- (EXTRACT_16BITS(dat) & 0xff)));
+ ND_PRINT("%u.%u", (GET_BE_U_2(dat) >> 8),
+ (GET_BE_U_2(dat) & 0xff));
}
static void
l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
if (length < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- if (EXTRACT_32BITS(dat) & L2TP_FRAMING_CAP_ASYNC_MASK) {
- ND_PRINT((ndo, "A"));
+ if (GET_BE_U_4(dat) & L2TP_FRAMING_CAP_ASYNC_MASK) {
+ ND_PRINT("A");
}
- if (EXTRACT_32BITS(dat) & L2TP_FRAMING_CAP_SYNC_MASK) {
- ND_PRINT((ndo, "S"));
+ if (GET_BE_U_4(dat) & L2TP_FRAMING_CAP_SYNC_MASK) {
+ ND_PRINT("S");
}
}
@@ -369,14 +370,14 @@ static void
l2tp_bearer_cap_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
if (length < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- if (EXTRACT_32BITS(dat) & L2TP_BEARER_CAP_ANALOG_MASK) {
- ND_PRINT((ndo, "A"));
+ if (GET_BE_U_4(dat) & L2TP_BEARER_CAP_ANALOG_MASK) {
+ ND_PRINT("A");
}
- if (EXTRACT_32BITS(dat) & L2TP_BEARER_CAP_DIGITAL_MASK) {
- ND_PRINT((ndo, "D"));
+ if (GET_BE_U_4(dat) & L2TP_BEARER_CAP_DIGITAL_MASK) {
+ ND_PRINT("D");
}
}
@@ -384,15 +385,15 @@ static void
l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
if (length < 3) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
print_16bits_val(ndo, dat);
- ND_PRINT((ndo, ", %02x", EXTRACT_8BITS(dat + 2)));
+ ND_PRINT(", %02x", GET_U_1(dat + 2));
dat += 3;
length -= 3;
if (length != 0) {
- ND_PRINT((ndo, " "));
+ ND_PRINT(" ");
print_string(ndo, dat, length);
}
}
@@ -401,14 +402,14 @@ static void
l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
if (length < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- if (EXTRACT_32BITS(dat) & L2TP_BEARER_TYPE_ANALOG_MASK) {
- ND_PRINT((ndo, "A"));
+ if (GET_BE_U_4(dat) & L2TP_BEARER_TYPE_ANALOG_MASK) {
+ ND_PRINT("A");
}
- if (EXTRACT_32BITS(dat) & L2TP_BEARER_TYPE_DIGITAL_MASK) {
- ND_PRINT((ndo, "D"));
+ if (GET_BE_U_4(dat) & L2TP_BEARER_TYPE_DIGITAL_MASK) {
+ ND_PRINT("D");
}
}
@@ -416,42 +417,42 @@ static void
l2tp_framing_type_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
if (length < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- if (EXTRACT_32BITS(dat) & L2TP_FRAMING_TYPE_ASYNC_MASK) {
- ND_PRINT((ndo, "A"));
+ if (GET_BE_U_4(dat) & L2TP_FRAMING_TYPE_ASYNC_MASK) {
+ ND_PRINT("A");
}
- if (EXTRACT_32BITS(dat) & L2TP_FRAMING_TYPE_SYNC_MASK) {
- ND_PRINT((ndo, "S"));
+ if (GET_BE_U_4(dat) & L2TP_FRAMING_TYPE_SYNC_MASK) {
+ ND_PRINT("S");
}
}
static void
l2tp_packet_proc_delay_print(netdissect_options *ndo)
{
- ND_PRINT((ndo, "obsolete"));
+ ND_PRINT("obsolete");
}
static void
l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
if (length < 2) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- ND_PRINT((ndo, "%s", tok2str(l2tp_authentype2str,
- "AuthType-#%u", EXTRACT_16BITS(dat))));
+ ND_PRINT("%s", tok2str(l2tp_authentype2str,
+ "AuthType-#%u", GET_BE_U_2(dat)));
}
static void
l2tp_proxy_auth_id_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
if (length < 2) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat) & L2TP_PROXY_AUTH_ID_MASK));
+ ND_PRINT("%u", GET_BE_U_2(dat) & L2TP_PROXY_AUTH_ID_MASK);
}
static void
@@ -460,53 +461,53 @@ l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat, u_int length)
uint32_t val;
if (length < 2) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
dat += 2; /* skip "Reserved" */
length -= 2;
if (length < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
- ND_PRINT((ndo, "CRCErr=%u ", val));
+ val = GET_BE_U_4(dat); dat += 4; length -= 4;
+ ND_PRINT("CRCErr=%u ", val);
if (length < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
- ND_PRINT((ndo, "FrameErr=%u ", val));
+ val = GET_BE_U_4(dat); dat += 4; length -= 4;
+ ND_PRINT("FrameErr=%u ", val);
if (length < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
- ND_PRINT((ndo, "HardOver=%u ", val));
+ val = GET_BE_U_4(dat); dat += 4; length -= 4;
+ ND_PRINT("HardOver=%u ", val);
if (length < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
- ND_PRINT((ndo, "BufOver=%u ", val));
+ val = GET_BE_U_4(dat); dat += 4; length -= 4;
+ ND_PRINT("BufOver=%u ", val);
if (length < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
- ND_PRINT((ndo, "Timeout=%u ", val));
+ val = GET_BE_U_4(dat); dat += 4; length -= 4;
+ ND_PRINT("Timeout=%u ", val);
if (length < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
- ND_PRINT((ndo, "AlignErr=%u ", val));
+ val = GET_BE_U_4(dat); dat += 4; length -= 4;
+ ND_PRINT("AlignErr=%u ", val);
}
static void
@@ -515,50 +516,50 @@ l2tp_accm_print(netdissect_options *ndo, const u_char *dat, u_int length)
uint32_t val;
if (length < 2) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
dat += 2; /* skip "Reserved" */
length -= 2;
if (length < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
- ND_PRINT((ndo, "send=%08x ", val));
+ val = GET_BE_U_4(dat); dat += 4; length -= 4;
+ ND_PRINT("send=%08x ", val);
if (length < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
- val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
- ND_PRINT((ndo, "recv=%08x ", val));
+ val = GET_BE_U_4(dat); dat += 4; length -= 4;
+ ND_PRINT("recv=%08x ", val);
}
static void
l2tp_ppp_discon_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
if (length < 5) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
return;
}
/* Disconnect Code */
- ND_PRINT((ndo, "%04x, ", EXTRACT_16BITS(dat)));
+ ND_PRINT("%04x, ", GET_BE_U_2(dat));
dat += 2;
length -= 2;
/* Control Protocol Number */
- ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(dat)));
+ ND_PRINT("%04x ", GET_BE_U_2(dat));
dat += 2;
length -= 2;
/* Direction */
- ND_PRINT((ndo, "%s", tok2str(l2tp_cc_direction2str,
- "Direction-#%u", EXTRACT_8BITS(dat))));
+ ND_PRINT("%s", tok2str(l2tp_cc_direction2str,
+ "Direction-#%u", GET_U_1(dat)));
dat++;
length--;
if (length != 0) {
- ND_PRINT((ndo, " "));
+ ND_PRINT(" ");
print_string(ndo, (const u_char *)dat, length);
}
}
@@ -570,10 +571,9 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length)
uint16_t attr_type;
int hidden = FALSE;
- ND_PRINT((ndo, " "));
-
- ND_TCHECK_16BITS(dat); /* Flags & Length */
- len = EXTRACT_16BITS(dat) & L2TP_AVP_HDR_LEN_MASK;
+ ND_PRINT(" ");
+ /* Flags & Length */
+ len = GET_BE_U_2(dat) & L2TP_AVP_HDR_LEN_MASK;
/* If it is not long enough to contain the header, we'll give up. */
if (len < 6)
@@ -586,7 +586,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length)
/* If it goes past the end of the remaining length of the captured
data, we'll give up. */
- ND_TCHECK2(*dat, len);
+ ND_TCHECK_LEN(dat, len);
/*
* After this point, we don't need to check whether we go past
@@ -594,30 +594,30 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length)
* check whether we go past the end of the AVP.
*/
- if (EXTRACT_16BITS(dat) & L2TP_AVP_HDR_FLAG_MANDATORY) {
- ND_PRINT((ndo, "*"));
+ if (GET_BE_U_2(dat) & L2TP_AVP_HDR_FLAG_MANDATORY) {
+ ND_PRINT("*");
}
- if (EXTRACT_16BITS(dat) & L2TP_AVP_HDR_FLAG_HIDDEN) {
+ if (GET_BE_U_2(dat) & L2TP_AVP_HDR_FLAG_HIDDEN) {
hidden = TRUE;
- ND_PRINT((ndo, "?"));
+ ND_PRINT("?");
}
dat += 2;
- if (EXTRACT_16BITS(dat)) {
+ if (GET_BE_U_2(dat)) {
/* Vendor Specific Attribute */
- ND_PRINT((ndo, "VENDOR%04x:", EXTRACT_16BITS(dat))); dat += 2;
- ND_PRINT((ndo, "ATTR%04x", EXTRACT_16BITS(dat))); dat += 2;
- ND_PRINT((ndo, "("));
+ ND_PRINT("VENDOR%04x:", GET_BE_U_2(dat)); dat += 2;
+ ND_PRINT("ATTR%04x", GET_BE_U_2(dat)); dat += 2;
+ ND_PRINT("(");
print_octets(ndo, dat, len-6);
- ND_PRINT((ndo, ")"));
+ ND_PRINT(")");
} else {
/* IETF-defined Attributes */
dat += 2;
- attr_type = EXTRACT_16BITS(dat); dat += 2;
- ND_PRINT((ndo, "%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type)));
- ND_PRINT((ndo, "("));
+ attr_type = GET_BE_U_2(dat); dat += 2;
+ ND_PRINT("%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type));
+ ND_PRINT("(");
if (hidden) {
- ND_PRINT((ndo, "???"));
+ ND_PRINT("???");
} else {
switch (attr_type) {
case L2TP_AVP_MSGTYPE:
@@ -637,7 +637,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length)
break;
case L2TP_AVP_TIE_BREAKER:
if (len-6 < 8) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
break;
}
print_octets(ndo, dat, 8);
@@ -647,7 +647,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length)
case L2TP_AVP_RECV_WIN_SIZE:
case L2TP_AVP_ASSND_SESS_ID:
if (len-6 < 2) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
break;
}
print_16bits_val(ndo, dat);
@@ -675,7 +675,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length)
break;
case L2TP_AVP_CHALLENGE_RESP:
if (len-6 < 16) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
break;
}
print_octets(ndo, dat, 16);
@@ -687,7 +687,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length)
case L2TP_AVP_PHY_CHANNEL_ID:
case L2TP_AVP_RX_CONN_SPEED:
if (len-6 < 4) {
- ND_PRINT((ndo, "AVP too short"));
+ ND_PRINT("AVP too short");
break;
}
print_32bits_val(ndo, dat);
@@ -722,13 +722,13 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length)
break;
}
}
- ND_PRINT((ndo, ")"));
+ ND_PRINT(")");
}
return (len);
trunc:
- ND_PRINT((ndo, "|..."));
+ nd_print_trunc(ndo);
return (0);
}
@@ -742,97 +742,94 @@ l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length)
int flag_t, flag_l, flag_s, flag_o;
uint16_t l2tp_len;
+ ndo->ndo_protocol = "l2tp";
flag_t = flag_l = flag_s = flag_o = FALSE;
- ND_TCHECK2(*ptr, 2); /* Flags & Version */
- if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) {
- ND_PRINT((ndo, " l2tp:"));
- } else if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) {
- ND_PRINT((ndo, " l2f:"));
+ if ((GET_BE_U_2(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) {
+ ND_PRINT(" l2tp:");
+ } else if ((GET_BE_U_2(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) {
+ ND_PRINT(" l2f:");
return; /* nothing to do */
} else {
- ND_PRINT((ndo, " Unknown Version, neither L2F(1) nor L2TP(2)"));
+ ND_PRINT(" Unknown Version, neither L2F(1) nor L2TP(2)");
return; /* nothing we can do */
}
- ND_PRINT((ndo, "["));
- if (EXTRACT_16BITS(ptr) & L2TP_FLAG_TYPE) {
+ ND_PRINT("[");
+ if (GET_BE_U_2(ptr) & L2TP_FLAG_TYPE) {
flag_t = TRUE;
- ND_PRINT((ndo, "T"));
+ ND_PRINT("T");
}
- if (EXTRACT_16BITS(ptr) & L2TP_FLAG_LENGTH) {
+ if (GET_BE_U_2(ptr) & L2TP_FLAG_LENGTH) {
flag_l = TRUE;
- ND_PRINT((ndo, "L"));
+ ND_PRINT("L");
}
- if (EXTRACT_16BITS(ptr) & L2TP_FLAG_SEQUENCE) {
+ if (GET_BE_U_2(ptr) & L2TP_FLAG_SEQUENCE) {
flag_s = TRUE;
- ND_PRINT((ndo, "S"));
+ ND_PRINT("S");
}
- if (EXTRACT_16BITS(ptr) & L2TP_FLAG_OFFSET) {
+ if (GET_BE_U_2(ptr) & L2TP_FLAG_OFFSET) {
flag_o = TRUE;
- ND_PRINT((ndo, "O"));
+ ND_PRINT("O");
}
- if (EXTRACT_16BITS(ptr) & L2TP_FLAG_PRIORITY)
- ND_PRINT((ndo, "P"));
- ND_PRINT((ndo, "]"));
+ if (GET_BE_U_2(ptr) & L2TP_FLAG_PRIORITY)
+ ND_PRINT("P");
+ ND_PRINT("]");
ptr += 2;
cnt += 2;
if (flag_l) {
- ND_TCHECK2(*ptr, 2); /* Length */
- l2tp_len = EXTRACT_16BITS(ptr);
+ l2tp_len = GET_BE_U_2(ptr);
ptr += 2;
cnt += 2;
} else {
l2tp_len = 0;
}
-
- ND_TCHECK2(*ptr, 2); /* Tunnel ID */
- ND_PRINT((ndo, "(%u/", EXTRACT_16BITS(ptr)));
+ /* Tunnel ID */
+ ND_PRINT("(%u/", GET_BE_U_2(ptr));
ptr += 2;
cnt += 2;
- ND_TCHECK2(*ptr, 2); /* Session ID */
- ND_PRINT((ndo, "%u)", EXTRACT_16BITS(ptr)));
+ /* Session ID */
+ ND_PRINT("%u)", GET_BE_U_2(ptr));
ptr += 2;
cnt += 2;
if (flag_s) {
- ND_TCHECK2(*ptr, 2); /* Ns */
- ND_PRINT((ndo, "Ns=%u,", EXTRACT_16BITS(ptr)));
+ ND_PRINT("Ns=%u,", GET_BE_U_2(ptr));
ptr += 2;
cnt += 2;
- ND_TCHECK2(*ptr, 2); /* Nr */
- ND_PRINT((ndo, "Nr=%u", EXTRACT_16BITS(ptr)));
+ ND_PRINT("Nr=%u", GET_BE_U_2(ptr));
ptr += 2;
cnt += 2;
}
- if (flag_o) {
- ND_TCHECK2(*ptr, 2); /* Offset Size */
- pad = EXTRACT_16BITS(ptr);
+ if (flag_o) { /* Offset Size */
+ pad = GET_BE_U_2(ptr);
+ /* Offset padding octets in packet buffer? */
+ ND_TCHECK_LEN(ptr + 2, pad);
ptr += (2 + pad);
cnt += (2 + pad);
}
if (flag_l) {
if (length < l2tp_len) {
- ND_PRINT((ndo, " Length %u larger than packet", l2tp_len));
+ ND_PRINT(" Length %u larger than packet", l2tp_len);
return;
}
length = l2tp_len;
}
if (length < cnt) {
- ND_PRINT((ndo, " Length %u smaller than header length", length));
+ ND_PRINT(" Length %u smaller than header length", length);
return;
}
if (flag_t) {
if (!flag_l) {
- ND_PRINT((ndo, " No length"));
+ ND_PRINT(" No length");
return;
}
if (length - cnt == 0) {
- ND_PRINT((ndo, " ZLB"));
+ ND_PRINT(" ZLB");
} else {
/*
* Print AVPs.
@@ -852,13 +849,11 @@ l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length)
}
}
} else {
- ND_PRINT((ndo, " {"));
+ ND_PRINT(" {");
ppp_print(ndo, ptr, length - cnt);
- ND_PRINT((ndo, "}"));
+ ND_PRINT("}");
}
-
return;
-
- trunc:
- ND_PRINT((ndo, "%s", tstr));
+trunc:
+ nd_print_trunc(ndo);
}