]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-l2tp.c
Add program_name field in the netdissect_options structure
[tcpdump] / print-l2tp.c
index 346dae9d52c661b12ae181697affd5e6fd02ebae..0c7d5114c0a77b16fcd8efcdbbc96fc31cc6627d 100644 (file)
  * L2TP support contributed by Motonori Shindo ([email protected])
  */
 
-#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) */
@@ -298,7 +297,7 @@ print_32bits_val(netdissect_options *ndo, const uint32_t *dat)
 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))));
@@ -307,7 +306,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)
 {
-       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) */
@@ -315,7 +314,7 @@ 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);
        }
 }
 
@@ -329,7 +328,7 @@ l2tp_proto_ver_print(netdissect_options *ndo, const uint16_t *dat)
 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"));
@@ -342,7 +341,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)
 {
-       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"));
@@ -355,7 +354,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, (uint16_t *)dat);
+       print_16bits_val(ndo, (const uint16_t *)dat);
        ND_PRINT((ndo, ", %02x", dat[2]));
        if (length > 3) {
                ND_PRINT((ndo, " "));
@@ -366,7 +365,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)
 {
-       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"));
@@ -379,7 +378,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)
 {
-       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"));
@@ -398,7 +397,7 @@ l2tp_packet_proc_delay_print(netdissect_options *ndo)
 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))));
@@ -407,7 +406,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)
 {
-       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));
 }
@@ -415,7 +414,7 @@ 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)
 {
-       uint16_t *ptr = (uint16_t *)dat;
+       const uint16_t *ptr = (const uint16_t *)dat;
        uint16_t val_h, val_l;
 
        ptr++;          /* skip "Reserved" */
@@ -448,7 +447,7 @@ l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat)
 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" */
@@ -465,12 +464,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)
 {
-       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, " "));
@@ -482,7 +481,7 @@ static void
 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;
 
@@ -523,7 +522,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 +535,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 +565,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 +574,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 +588,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, (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;