]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-l2tp.c
Regenerate config files.
[tcpdump] / print-l2tp.c
index 8dde75d1e7e7f5338fac0ff4cfde5ffc06354f20..42ae39107372188f368885c992f063f31d596c9a 100644 (file)
  * L2TP support contributed by Motonori Shindo ([email protected])
  */
 
-#define NETDISSECT_REWORKED
+/* \summary: Layer Two Tunneling Protocol (L2TP) printer */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 
 #define L2TP_FLAG_TYPE         0x8000  /* Type (0=Data, 1=Control) */
@@ -281,13 +282,13 @@ print_octets(netdissect_options *ndo, const u_char *dat, u_int length)
 }
 
 static void
-print_16bits_val(netdissect_options *ndo, const u_int16_t *dat)
+print_16bits_val(netdissect_options *ndo, const uint16_t *dat)
 {
        ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat)));
 }
 
 static void
-print_32bits_val(netdissect_options *ndo, const u_int32_t *dat)
+print_32bits_val(netdissect_options *ndo, const uint32_t *dat)
 {
        ND_PRINT((ndo, "%lu", (u_long)EXTRACT_32BITS(dat)));
 }
@@ -298,7 +299,7 @@ print_32bits_val(netdissect_options *ndo, const u_int32_t *dat)
 static void
 l2tp_msgtype_print(netdissect_options *ndo, const u_char *dat)
 {
-       u_int16_t *ptr = (u_int16_t*)dat;
+       const uint16_t *ptr = (const uint16_t *)dat;
 
        ND_PRINT((ndo, "%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
            EXTRACT_16BITS(ptr))));
@@ -307,7 +308,7 @@ l2tp_msgtype_print(netdissect_options *ndo, const u_char *dat)
 static void
 l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       u_int16_t *ptr = (u_int16_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) */
@@ -315,12 +316,12 @@ l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length)
        }
        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_proto_ver_print(netdissect_options *ndo, const u_int16_t *dat)
+l2tp_proto_ver_print(netdissect_options *ndo, const uint16_t *dat)
 {
        ND_PRINT((ndo, "%u.%u", (EXTRACT_16BITS(dat) >> 8),
            (EXTRACT_16BITS(dat) & 0xff)));
@@ -329,7 +330,7 @@ l2tp_proto_ver_print(netdissect_options *ndo, const u_int16_t *dat)
 static void
 l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat)
 {
-       u_int32_t *ptr = (u_int32_t *)dat;
+       const uint32_t *ptr = (const uint32_t *)dat;
 
        if (EXTRACT_32BITS(ptr) &  L2TP_FRAMING_CAP_ASYNC_MASK) {
                ND_PRINT((ndo, "A"));
@@ -342,7 +343,7 @@ l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat)
 static void
 l2tp_bearer_cap_print(netdissect_options *ndo, const u_char *dat)
 {
-       u_int32_t *ptr = (u_int32_t *)dat;
+       const uint32_t *ptr = (const uint32_t *)dat;
 
        if (EXTRACT_32BITS(ptr) &  L2TP_BEARER_CAP_ANALOG_MASK) {
                ND_PRINT((ndo, "A"));
@@ -355,7 +356,7 @@ l2tp_bearer_cap_print(netdissect_options *ndo, const u_char *dat)
 static void
 l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       print_16bits_val(ndo, (u_int16_t *)dat);
+       print_16bits_val(ndo, (const uint16_t *)dat);
        ND_PRINT((ndo, ", %02x", dat[2]));
        if (length > 3) {
                ND_PRINT((ndo, " "));
@@ -366,7 +367,7 @@ l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
 static void
 l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat)
 {
-       u_int32_t *ptr = (u_int32_t *)dat;
+       const uint32_t *ptr = (const uint32_t *)dat;
 
        if (EXTRACT_32BITS(ptr) &  L2TP_BEARER_TYPE_ANALOG_MASK) {
                ND_PRINT((ndo, "A"));
@@ -379,7 +380,7 @@ l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat)
 static void
 l2tp_framing_type_print(netdissect_options *ndo, const u_char *dat)
 {
-       u_int32_t *ptr = (u_int32_t *)dat;
+       const uint32_t *ptr = (const uint32_t *)dat;
 
        if (EXTRACT_32BITS(ptr) &  L2TP_FRAMING_TYPE_ASYNC_MASK) {
                ND_PRINT((ndo, "A"));
@@ -398,7 +399,7 @@ l2tp_packet_proc_delay_print(netdissect_options *ndo)
 static void
 l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat)
 {
-       u_int16_t *ptr = (u_int16_t *)dat;
+       const uint16_t *ptr = (const uint16_t *)dat;
 
        ND_PRINT((ndo, "%s", tok2str(l2tp_authentype2str,
                             "AuthType-#%u", EXTRACT_16BITS(ptr))));
@@ -407,7 +408,7 @@ l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat)
 static void
 l2tp_proxy_auth_id_print(netdissect_options *ndo, const u_char *dat)
 {
-       u_int16_t *ptr = (u_int16_t *)dat;
+       const uint16_t *ptr = (const uint16_t *)dat;
 
        ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK));
 }
@@ -415,8 +416,8 @@ l2tp_proxy_auth_id_print(netdissect_options *ndo, const u_char *dat)
 static void
 l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat)
 {
-       u_int16_t *ptr = (u_int16_t *)dat;
-       u_int16_t val_h, val_l;
+       const uint16_t *ptr = (const uint16_t *)dat;
+       uint16_t val_h, val_l;
 
        ptr++;          /* skip "Reserved" */
 
@@ -448,8 +449,8 @@ l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat)
 static void
 l2tp_accm_print(netdissect_options *ndo, const u_char *dat)
 {
-       u_int16_t *ptr = (u_int16_t *)dat;
-       u_int16_t val_h, val_l;
+       const uint16_t *ptr = (const uint16_t *)dat;
+       uint16_t val_h, val_l;
 
        ptr++;          /* skip "Reserved" */
 
@@ -465,12 +466,12 @@ l2tp_accm_print(netdissect_options *ndo, const u_char *dat)
 static void
 l2tp_ppp_discon_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       u_int16_t *ptr = (u_int16_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, " "));
@@ -482,8 +483,8 @@ static void
 l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
 {
        u_int len;
-       const u_int16_t *ptr = (u_int16_t *)dat;
-       u_int16_t attr_type;
+       const uint16_t *ptr = (const uint16_t *)dat;
+       uint16_t attr_type;
        int hidden = FALSE;
 
        if (length <= 0) {
@@ -523,7 +524,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
                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 */
@@ -536,22 +537,22 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
                } 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:
@@ -566,7 +567,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
                        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:
@@ -575,13 +576,13 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
                        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:
@@ -589,33 +590,33 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
                        case L2TP_AVP_TX_CONN_SPEED:
                        case L2TP_AVP_PHY_CHANNEL_ID:
                        case L2TP_AVP_RX_CONN_SPEED:
-                               print_32bits_val(ndo, (u_int32_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;
@@ -637,9 +638,9 @@ l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
        const u_char *ptr = dat;
        u_int cnt = 0;                  /* total octets consumed */
-       u_int16_t pad;
+       uint16_t pad;
        int flag_t, flag_l, flag_s, flag_o;
-       u_int16_t l2tp_len;
+       uint16_t l2tp_len;
 
        flag_t = flag_l = flag_s = flag_o = FALSE;
 
@@ -737,7 +738,7 @@ l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length)
                }
        } else {
                ND_PRINT((ndo, " {"));
-               ppp_print(ptr, length - cnt);
+               ppp_print(ndo, ptr, length - cnt);
                ND_PRINT((ndo, "}"));
        }