X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/bdc2d70ffa46816d6c03d92be47582bd29e52db2..0b3880c91e169db7cfbdce1b18ef4f1e3fd277de:/print-pptp.c?ds=sidebyside diff --git a/print-pptp.c b/print-pptp.c index 949d4a4a..7bdc7d82 100644 --- a/print-pptp.c +++ b/print-pptp.c @@ -26,15 +26,14 @@ /* specification: RFC 2637 */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif -#include +#include "netdissect-stdinc.h" #include "netdissect.h" #include "extract.h" -static const char tstr[] = " [|pptp]"; #define PPTP_MSG_TYPE_CTRL 1 /* Control Message */ #define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */ @@ -120,13 +119,13 @@ struct pptp_msg_sccrp { struct pptp_msg_stopccrq { nd_uint8_t reason; nd_uint8_t reserved1; - nd_uint16_t reserved2; + nd_uint16_t reserved2; }; struct pptp_msg_stopccrp { nd_uint8_t result_code; nd_uint8_t err_code; - nd_uint16_t reserved1; + nd_uint16_t reserved1; }; struct pptp_msg_echorq { @@ -137,7 +136,7 @@ struct pptp_msg_echorp { nd_uint32_t id; nd_uint8_t result_code; nd_uint8_t err_code; - nd_uint16_t reserved1; + nd_uint16_t reserved1; }; struct pptp_msg_ocrq { @@ -186,7 +185,7 @@ struct pptp_msg_icrp { nd_uint8_t err_code; nd_uint16_t recv_winsiz; nd_uint16_t pkt_proc_delay; - nd_uint16_t reserved1; + nd_uint16_t reserved1; }; struct pptp_msg_iccn { @@ -214,7 +213,7 @@ struct pptp_msg_cdn { struct pptp_msg_wen { nd_uint16_t peer_call_id; - nd_uint16_t reserved1; + nd_uint16_t reserved1; nd_uint32_t crc_err; nd_uint32_t framing_err; nd_uint32_t hardware_overrun; @@ -233,7 +232,7 @@ struct pptp_msg_sli { /* attributes that appear more than once in above messages: Number of - occurence attributes + occurrence attributes -------------------------------------- 2 uint32_t bearer_cap; 2 uint32_t bearer_type; @@ -263,6 +262,16 @@ struct pptp_msg_sli { reserved*). */ +#define PRINT_RESERVED_IF_NOT_ZERO_1(reserved) \ + if (EXTRACT_U_1(reserved)) \ + ND_PRINT(" [ERROR: reserved=%u must be zero]", \ + EXTRACT_U_1(reserved)); + +#define PRINT_RESERVED_IF_NOT_ZERO_2(reserved) \ + if (EXTRACT_BE_U_2(reserved)) \ + ND_PRINT(" [ERROR: reserved=%u must be zero]", \ + EXTRACT_BE_U_2(reserved)); + /******************************************/ /* Attribute-specific print out functions */ /******************************************/ @@ -526,6 +535,7 @@ pptp_sccrq_print(netdissect_options *ndo, ND_TCHECK_2(ptr->proto_ver); pptp_proto_ver_print(ndo, &ptr->proto_ver); ND_TCHECK_2(ptr->reserved1); + PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1); ND_TCHECK_4(ptr->framing_cap); pptp_framing_cap_print(ndo, &ptr->framing_cap); ND_TCHECK_4(ptr->bearer_cap); @@ -534,15 +544,15 @@ pptp_sccrq_print(netdissect_options *ndo, pptp_max_channel_print(ndo, &ptr->max_channel); ND_TCHECK_2(ptr->firm_rev); pptp_firm_rev_print(ndo, &ptr->firm_rev); - ND_TCHECK(ptr->hostname); + ND_TCHECK_SIZE(&ptr->hostname); pptp_hostname_print(ndo, &ptr->hostname[0]); - ND_TCHECK(ptr->vendor); + ND_TCHECK_SIZE(&ptr->vendor); pptp_vendor_print(ndo, &ptr->vendor[0]); return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -565,15 +575,15 @@ pptp_sccrp_print(netdissect_options *ndo, pptp_max_channel_print(ndo, &ptr->max_channel); ND_TCHECK_2(ptr->firm_rev); pptp_firm_rev_print(ndo, &ptr->firm_rev); - ND_TCHECK(ptr->hostname); + ND_TCHECK_SIZE(&ptr->hostname); pptp_hostname_print(ndo, &ptr->hostname[0]); - ND_TCHECK(ptr->vendor); + ND_TCHECK_SIZE(&ptr->vendor); pptp_vendor_print(ndo, &ptr->vendor[0]); return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -602,12 +612,14 @@ pptp_stopccrq_print(netdissect_options *ndo, } ND_PRINT(")"); ND_TCHECK_1(ptr->reserved1); + PRINT_RESERVED_IF_NOT_ZERO_1(ptr->reserved1); ND_TCHECK_2(ptr->reserved2); + PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved2); return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -621,11 +633,12 @@ pptp_stopccrp_print(netdissect_options *ndo, ND_TCHECK_1(ptr->err_code); pptp_err_code_print(ndo, &ptr->err_code); ND_TCHECK_2(ptr->reserved1); + PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1); return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -640,7 +653,7 @@ pptp_echorq_print(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -656,11 +669,12 @@ pptp_echorp_print(netdissect_options *ndo, ND_TCHECK_1(ptr->err_code); pptp_err_code_print(ndo, &ptr->err_code); ND_TCHECK_2(ptr->reserved1); + PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1); return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -688,15 +702,16 @@ pptp_ocrq_print(netdissect_options *ndo, ND_TCHECK_2(ptr->phone_no_len); ND_PRINT(" PHONE_NO_LEN(%u)", EXTRACT_BE_U_2(ptr->phone_no_len)); ND_TCHECK_2(ptr->reserved1); - ND_TCHECK(ptr->phone_no); + PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1); + ND_TCHECK_SIZE(&ptr->phone_no); ND_PRINT(" PHONE_NO(%.64s)", ptr->phone_no); - ND_TCHECK(ptr->subaddr); + ND_TCHECK_SIZE(&ptr->subaddr); pptp_subaddr_print(ndo, &ptr->subaddr[0]); return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -727,7 +742,7 @@ pptp_ocrp_print(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -748,17 +763,17 @@ pptp_icrq_print(netdissect_options *ndo, ND_PRINT(" DIALED_NO_LEN(%u)", EXTRACT_BE_U_2(ptr->dialed_no_len)); ND_TCHECK_2(ptr->dialing_no_len); ND_PRINT(" DIALING_NO_LEN(%u)", EXTRACT_BE_U_2(ptr->dialing_no_len)); - ND_TCHECK(ptr->dialed_no); + ND_TCHECK_SIZE(&ptr->dialed_no); ND_PRINT(" DIALED_NO(%.64s)", ptr->dialed_no); - ND_TCHECK(ptr->dialing_no); + ND_TCHECK_SIZE(&ptr->dialing_no); ND_PRINT(" DIALING_NO(%.64s)", ptr->dialing_no); - ND_TCHECK(ptr->subaddr); + ND_TCHECK_SIZE(&ptr->subaddr); pptp_subaddr_print(ndo, &ptr->subaddr[0]); return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -780,11 +795,12 @@ pptp_icrp_print(netdissect_options *ndo, ND_TCHECK_2(ptr->pkt_proc_delay); pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay); ND_TCHECK_2(ptr->reserved1); + PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1); return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -796,6 +812,7 @@ pptp_iccn_print(netdissect_options *ndo, ND_TCHECK_2(ptr->peer_call_id); pptp_peer_call_id_print(ndo, &ptr->peer_call_id); ND_TCHECK_2(ptr->reserved1); + PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1); ND_TCHECK_4(ptr->conn_speed); pptp_conn_speed_print(ndo, &ptr->conn_speed); ND_TCHECK_2(ptr->recv_winsiz); @@ -808,7 +825,7 @@ pptp_iccn_print(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -820,11 +837,12 @@ pptp_ccrq_print(netdissect_options *ndo, ND_TCHECK_2(ptr->call_id); pptp_call_id_print(ndo, &ptr->call_id); ND_TCHECK_2(ptr->reserved1); + PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1); return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -842,13 +860,14 @@ pptp_cdn_print(netdissect_options *ndo, ND_TCHECK_2(ptr->cause_code); pptp_cause_code_print(ndo, &ptr->cause_code); ND_TCHECK_2(ptr->reserved1); - ND_TCHECK(ptr->call_stats); + PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1); + ND_TCHECK_SIZE(&ptr->call_stats); ND_PRINT(" CALL_STATS(%.128s)", ptr->call_stats); return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -860,6 +879,7 @@ pptp_wen_print(netdissect_options *ndo, ND_TCHECK_2(ptr->peer_call_id); pptp_peer_call_id_print(ndo, &ptr->peer_call_id); ND_TCHECK_2(ptr->reserved1); + PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1); ND_TCHECK_4(ptr->crc_err); ND_PRINT(" CRC_ERR(%u)", EXTRACT_BE_U_4(ptr->crc_err)); ND_TCHECK_4(ptr->framing_err); @@ -876,7 +896,7 @@ pptp_wen_print(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } static void @@ -888,6 +908,7 @@ pptp_sli_print(netdissect_options *ndo, ND_TCHECK_2(ptr->peer_call_id); pptp_peer_call_id_print(ndo, &ptr->peer_call_id); ND_TCHECK_2(ptr->reserved1); + PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1); ND_TCHECK_4(ptr->send_accm); ND_PRINT(" SEND_ACCM(0x%08x)", EXTRACT_BE_U_4(ptr->send_accm)); ND_TCHECK_4(ptr->recv_accm); @@ -896,7 +917,7 @@ pptp_sli_print(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); } void @@ -907,6 +928,7 @@ pptp_print(netdissect_options *ndo, uint32_t mc; uint16_t ctrl_msg_type; + ndo->ndo_protocol = "pptp"; ND_PRINT(": pptp"); hdr = (const struct pptp_hdr *)dat; @@ -947,6 +969,7 @@ pptp_print(netdissect_options *ndo, ND_PRINT(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type); } ND_TCHECK_2(hdr->reserved0); + PRINT_RESERVED_IF_NOT_ZERO_2(hdr->reserved0); dat += 12; @@ -1004,5 +1027,5 @@ pptp_print(netdissect_options *ndo, return; trunc: - ND_PRINT("%s", tstr); + nd_print_trunc(ndo); }