1a90e161bSBill Fenner /* 2a90e161bSBill Fenner * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 3a90e161bSBill Fenner * The Regents of the University of California. All rights reserved. 4a90e161bSBill Fenner * 5a90e161bSBill Fenner * Redistribution and use in source and binary forms, with or without 6a90e161bSBill Fenner * modification, are permitted provided that: (1) source code distributions 7a90e161bSBill Fenner * retain the above copyright notice and this paragraph in its entirety, (2) 8a90e161bSBill Fenner * distributions including binary code include the above copyright notice and 9a90e161bSBill Fenner * this paragraph in its entirety in the documentation or other materials 10a90e161bSBill Fenner * provided with the distribution, and (3) all advertising materials mentioning 11a90e161bSBill Fenner * features or use of this software display the following acknowledgement: 12a90e161bSBill Fenner * ``This product includes software developed by the University of California, 13a90e161bSBill Fenner * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14a90e161bSBill Fenner * the University nor the names of its contributors may be used to endorse 15a90e161bSBill Fenner * or promote products derived from this software without specific prior 16a90e161bSBill Fenner * written permission. 17a90e161bSBill Fenner * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18a90e161bSBill Fenner * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19a90e161bSBill Fenner * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20a90e161bSBill Fenner * 21a90e161bSBill Fenner * PPTP support contributed by Motonori Shindo (mshindo@mshindo.net) 22a90e161bSBill Fenner */ 23a90e161bSBill Fenner 24a90e161bSBill Fenner 25a90e161bSBill Fenner #ifndef lint 265b0fe478SBruce M Simpson static const char rcsid[] _U_ = 275b0fe478SBruce M Simpson "@(#) $Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.9.2.2 2003/11/16 08:51:39 guy Exp $"; 28a90e161bSBill Fenner #endif 29a90e161bSBill Fenner 30a90e161bSBill Fenner #ifdef HAVE_CONFIG_H 31a90e161bSBill Fenner #include "config.h" 32a90e161bSBill Fenner #endif 33a90e161bSBill Fenner 345b0fe478SBruce M Simpson #include <tcpdump-stdinc.h> 355b0fe478SBruce M Simpson 36a90e161bSBill Fenner #include <stdio.h> 37a90e161bSBill Fenner 38a90e161bSBill Fenner #include "interface.h" 395b0fe478SBruce M Simpson #include "extract.h" 40a90e161bSBill Fenner 41a90e161bSBill Fenner static char tstr[] = " [|pptp]"; 42a90e161bSBill Fenner 43a90e161bSBill Fenner #ifndef TRUE 44a90e161bSBill Fenner #define TRUE 1 45a90e161bSBill Fenner #endif 46a90e161bSBill Fenner 47a90e161bSBill Fenner #ifndef FALSE 48a90e161bSBill Fenner #define FALSE 0 49a90e161bSBill Fenner #endif 50a90e161bSBill Fenner 51a90e161bSBill Fenner #define PPTP_MSG_TYPE_CTRL 1 /* Control Message */ 52a90e161bSBill Fenner #define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */ 53a90e161bSBill Fenner #define PPTP_MAGIC_COOKIE 0x1a2b3c4d /* for sanity check */ 54a90e161bSBill Fenner 55a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_SCCRQ 1 56a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_SCCRP 2 57a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_StopCCRQ 3 58a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_StopCCRP 4 59a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_ECHORQ 5 60a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_ECHORP 6 61a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_OCRQ 7 62a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_OCRP 8 63a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_ICRQ 9 64a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_ICRP 10 65a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_ICCN 11 66a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_CCRQ 12 67a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_CDN 13 68a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_WEN 14 69a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_SLI 15 70a90e161bSBill Fenner 71a90e161bSBill Fenner #define PPTP_FRAMING_CAP_ASYNC_MASK 0x00000001 /* Aynchronous */ 72a90e161bSBill Fenner #define PPTP_FRAMING_CAP_SYNC_MASK 0x00000002 /* Synchronous */ 73a90e161bSBill Fenner 74a90e161bSBill Fenner #define PPTP_BEARER_CAP_ANALOG_MASK 0x00000001 /* Analog */ 75a90e161bSBill Fenner #define PPTP_BEARER_CAP_DIGITAL_MASK 0x00000002 /* Digital */ 76a90e161bSBill Fenner 775b0fe478SBruce M Simpson static const char *pptp_message_type_string[] = { 78a90e161bSBill Fenner "NOT_DEFINED", /* 0 Not defined in the RFC2637 */ 79a90e161bSBill Fenner "SCCRQ", /* 1 Start-Control-Connection-Request */ 80a90e161bSBill Fenner "SCCRP", /* 2 Start-Control-Connection-Reply */ 81a90e161bSBill Fenner "StopCCRQ", /* 3 Stop-Control-Connection-Request */ 82a90e161bSBill Fenner "StopCCRP", /* 4 Stop-Control-Connection-Reply */ 83a90e161bSBill Fenner "ECHORQ", /* 5 Echo Request */ 84a90e161bSBill Fenner "ECHORP", /* 6 Echo Reply */ 85a90e161bSBill Fenner 86a90e161bSBill Fenner "OCRQ", /* 7 Outgoing-Call-Request */ 87a90e161bSBill Fenner "OCRP", /* 8 Outgoing-Call-Reply */ 88a90e161bSBill Fenner "ICRQ", /* 9 Incoming-Call-Request */ 89a90e161bSBill Fenner "ICRP", /* 10 Incoming-Call-Reply */ 90a90e161bSBill Fenner "ICCN", /* 11 Incoming-Call-Connected */ 91a90e161bSBill Fenner "CCRQ", /* 12 Call-Clear-Request */ 92a90e161bSBill Fenner "CDN", /* 13 Call-Disconnect-Notify */ 93a90e161bSBill Fenner 94a90e161bSBill Fenner "WEN", /* 14 WAN-Error-Notify */ 95a90e161bSBill Fenner 96a90e161bSBill Fenner "SLI" /* 15 Set-Link-Info */ 97a90e161bSBill Fenner #define PPTP_MAX_MSGTYPE_INDEX 16 98a90e161bSBill Fenner }; 99a90e161bSBill Fenner 100a90e161bSBill Fenner /* common for all PPTP control messages */ 101a90e161bSBill Fenner struct pptp_hdr { 102a90e161bSBill Fenner u_int16_t length; 103a90e161bSBill Fenner u_int16_t msg_type; 104a90e161bSBill Fenner u_int32_t magic_cookie; 105a90e161bSBill Fenner u_int16_t ctrl_msg_type; 106a90e161bSBill Fenner u_int16_t reserved0; 107a90e161bSBill Fenner }; 108a90e161bSBill Fenner 109a90e161bSBill Fenner struct pptp_msg_sccrq { 110a90e161bSBill Fenner u_int16_t proto_ver; 111a90e161bSBill Fenner u_int16_t reserved1; 112a90e161bSBill Fenner u_int32_t framing_cap; 113a90e161bSBill Fenner u_int32_t bearer_cap; 114a90e161bSBill Fenner u_int16_t max_channel; 115a90e161bSBill Fenner u_int16_t firm_rev; 116a90e161bSBill Fenner u_char hostname[64]; 117a90e161bSBill Fenner u_char vendor[64]; 118a90e161bSBill Fenner }; 119a90e161bSBill Fenner 120a90e161bSBill Fenner struct pptp_msg_sccrp { 121a90e161bSBill Fenner u_int16_t proto_ver; 122a90e161bSBill Fenner u_int8_t result_code; 123a90e161bSBill Fenner u_int8_t err_code; 124a90e161bSBill Fenner u_int32_t framing_cap; 125a90e161bSBill Fenner u_int32_t bearer_cap; 126a90e161bSBill Fenner u_int16_t max_channel; 127a90e161bSBill Fenner u_int16_t firm_rev; 128a90e161bSBill Fenner u_char hostname[64]; 129a90e161bSBill Fenner u_char vendor[64]; 130a90e161bSBill Fenner }; 131a90e161bSBill Fenner 132a90e161bSBill Fenner struct pptp_msg_stopccrq { 133a90e161bSBill Fenner u_int8_t reason; 134a90e161bSBill Fenner u_int8_t reserved1; 135a90e161bSBill Fenner u_int16_t reserved2; 136a90e161bSBill Fenner }; 137a90e161bSBill Fenner 138a90e161bSBill Fenner struct pptp_msg_stopccrp { 139a90e161bSBill Fenner u_int8_t result_code; 140a90e161bSBill Fenner u_int8_t err_code; 141a90e161bSBill Fenner u_int16_t reserved1; 142a90e161bSBill Fenner }; 143a90e161bSBill Fenner 144a90e161bSBill Fenner struct pptp_msg_echorq { 145a90e161bSBill Fenner u_int32_t id; 146a90e161bSBill Fenner }; 147a90e161bSBill Fenner 148a90e161bSBill Fenner struct pptp_msg_echorp { 149a90e161bSBill Fenner u_int32_t id; 150a90e161bSBill Fenner u_int8_t result_code; 151a90e161bSBill Fenner u_int8_t err_code; 152a90e161bSBill Fenner u_int16_t reserved1; 153a90e161bSBill Fenner }; 154a90e161bSBill Fenner 155a90e161bSBill Fenner struct pptp_msg_ocrq { 156a90e161bSBill Fenner u_int16_t call_id; 157a90e161bSBill Fenner u_int16_t call_ser; 158a90e161bSBill Fenner u_int32_t min_bps; 159a90e161bSBill Fenner u_int32_t max_bps; 160a90e161bSBill Fenner u_int32_t bearer_type; 161a90e161bSBill Fenner u_int32_t framing_type; 162a90e161bSBill Fenner u_int16_t recv_winsiz; 163a90e161bSBill Fenner u_int16_t pkt_proc_delay; 164a90e161bSBill Fenner u_int16_t phone_no_len; 165a90e161bSBill Fenner u_int16_t reserved1; 166a90e161bSBill Fenner u_char phone_no[64]; 167a90e161bSBill Fenner u_char subaddr[64]; 168a90e161bSBill Fenner }; 169a90e161bSBill Fenner 170a90e161bSBill Fenner struct pptp_msg_ocrp { 171a90e161bSBill Fenner u_int16_t call_id; 172a90e161bSBill Fenner u_int16_t peer_call_id; 173a90e161bSBill Fenner u_int8_t result_code; 174a90e161bSBill Fenner u_int8_t err_code; 175a90e161bSBill Fenner u_int16_t cause_code; 176a90e161bSBill Fenner u_int32_t conn_speed; 177a90e161bSBill Fenner u_int16_t recv_winsiz; 178a90e161bSBill Fenner u_int16_t pkt_proc_delay; 179a90e161bSBill Fenner u_int32_t phy_chan_id; 180a90e161bSBill Fenner }; 181a90e161bSBill Fenner 182a90e161bSBill Fenner struct pptp_msg_icrq { 183a90e161bSBill Fenner u_int16_t call_id; 184a90e161bSBill Fenner u_int16_t call_ser; 185a90e161bSBill Fenner u_int32_t bearer_type; 186a90e161bSBill Fenner u_int32_t phy_chan_id; 187a90e161bSBill Fenner u_int16_t dialed_no_len; 188a90e161bSBill Fenner u_int16_t dialing_no_len; 189a90e161bSBill Fenner u_char dialed_no[64]; /* DNIS */ 190a90e161bSBill Fenner u_char dialing_no[64]; /* CLID */ 191a90e161bSBill Fenner u_char subaddr[64]; 192a90e161bSBill Fenner }; 193a90e161bSBill Fenner 194a90e161bSBill Fenner struct pptp_msg_icrp { 195a90e161bSBill Fenner u_int16_t call_id; 196a90e161bSBill Fenner u_int16_t peer_call_id; 197a90e161bSBill Fenner u_int8_t result_code; 198a90e161bSBill Fenner u_int8_t err_code; 199a90e161bSBill Fenner u_int16_t recv_winsiz; 200a90e161bSBill Fenner u_int16_t pkt_proc_delay; 201a90e161bSBill Fenner u_int16_t reserved1; 202a90e161bSBill Fenner }; 203a90e161bSBill Fenner 204a90e161bSBill Fenner struct pptp_msg_iccn { 205a90e161bSBill Fenner u_int16_t peer_call_id; 206a90e161bSBill Fenner u_int16_t reserved1; 207a90e161bSBill Fenner u_int32_t conn_speed; 208a90e161bSBill Fenner u_int16_t recv_winsiz; 209a90e161bSBill Fenner u_int16_t pkt_proc_delay; 210a90e161bSBill Fenner u_int32_t framing_type; 211a90e161bSBill Fenner }; 212a90e161bSBill Fenner 213a90e161bSBill Fenner struct pptp_msg_ccrq { 214a90e161bSBill Fenner u_int16_t call_id; 215a90e161bSBill Fenner u_int16_t reserved1; 216a90e161bSBill Fenner }; 217a90e161bSBill Fenner 218a90e161bSBill Fenner struct pptp_msg_cdn { 219a90e161bSBill Fenner u_int16_t call_id; 220a90e161bSBill Fenner u_int8_t result_code; 221a90e161bSBill Fenner u_int8_t err_code; 222a90e161bSBill Fenner u_int16_t cause_code; 223a90e161bSBill Fenner u_int16_t reserved1; 224a90e161bSBill Fenner u_char call_stats[128]; 225a90e161bSBill Fenner }; 226a90e161bSBill Fenner 227a90e161bSBill Fenner struct pptp_msg_wen { 228a90e161bSBill Fenner u_int16_t peer_call_id; 229a90e161bSBill Fenner u_int16_t reserved1; 230a90e161bSBill Fenner u_int32_t crc_err; 231a90e161bSBill Fenner u_int32_t framing_err; 232a90e161bSBill Fenner u_int32_t hardware_overrun; 233a90e161bSBill Fenner u_int32_t buffer_overrun; 234a90e161bSBill Fenner u_int32_t timeout_err; 235a90e161bSBill Fenner u_int32_t align_err; 236a90e161bSBill Fenner }; 237a90e161bSBill Fenner 238a90e161bSBill Fenner struct pptp_msg_sli { 239a90e161bSBill Fenner u_int16_t peer_call_id; 240a90e161bSBill Fenner u_int16_t reserved1; 241a90e161bSBill Fenner u_int32_t send_accm; 242a90e161bSBill Fenner u_int32_t recv_accm; 243a90e161bSBill Fenner }; 244a90e161bSBill Fenner 245a90e161bSBill Fenner /* attributes that appear more than once in above messages: 246a90e161bSBill Fenner 247a90e161bSBill Fenner Number of 248a90e161bSBill Fenner occurence attributes 249a90e161bSBill Fenner -------------------------------------- 250a90e161bSBill Fenner 2 u_int32_t bearer_cap; 251a90e161bSBill Fenner 2 u_int32_t bearer_type; 252a90e161bSBill Fenner 6 u_int16_t call_id; 253a90e161bSBill Fenner 2 u_int16_t call_ser; 254a90e161bSBill Fenner 2 u_int16_t cause_code; 255a90e161bSBill Fenner 2 u_int32_t conn_speed; 256a90e161bSBill Fenner 6 u_int8_t err_code; 257a90e161bSBill Fenner 2 u_int16_t firm_rev; 258a90e161bSBill Fenner 2 u_int32_t framing_cap; 259a90e161bSBill Fenner 2 u_int32_t framing_type; 260a90e161bSBill Fenner 2 u_char hostname[64]; 261a90e161bSBill Fenner 2 u_int32_t id; 262a90e161bSBill Fenner 2 u_int16_t max_channel; 263a90e161bSBill Fenner 5 u_int16_t peer_call_id; 264a90e161bSBill Fenner 2 u_int32_t phy_chan_id; 265a90e161bSBill Fenner 4 u_int16_t pkt_proc_delay; 266a90e161bSBill Fenner 2 u_int16_t proto_ver; 267a90e161bSBill Fenner 4 u_int16_t recv_winsiz; 268a90e161bSBill Fenner 2 u_int8_t reserved1; 269a90e161bSBill Fenner 9 u_int16_t reserved1; 270a90e161bSBill Fenner 6 u_int8_t result_code; 271a90e161bSBill Fenner 2 u_char subaddr[64]; 272a90e161bSBill Fenner 2 u_char vendor[64]; 273a90e161bSBill Fenner 274a90e161bSBill Fenner so I will prepare print out functions for these attributes (except for 275a90e161bSBill Fenner reserved*). 276a90e161bSBill Fenner */ 277a90e161bSBill Fenner 278a90e161bSBill Fenner /******************************************/ 279a90e161bSBill Fenner /* Attribute-specific print out functions */ 280a90e161bSBill Fenner /******************************************/ 281a90e161bSBill Fenner 282a90e161bSBill Fenner /* In these attribute-specific print-out functions, it't not necessary 283a90e161bSBill Fenner to do TCHECK because they are already checked in the caller of 284a90e161bSBill Fenner these functions. */ 285a90e161bSBill Fenner 286a90e161bSBill Fenner static void 287a90e161bSBill Fenner pptp_bearer_cap_print(const u_int32_t *bearer_cap) 288a90e161bSBill Fenner { 289a90e161bSBill Fenner printf(" BEARER_CAP("); 2905b0fe478SBruce M Simpson if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK) { 291a90e161bSBill Fenner printf("D"); 292a90e161bSBill Fenner } 2935b0fe478SBruce M Simpson if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK) { 294a90e161bSBill Fenner printf("A"); 295a90e161bSBill Fenner } 296a90e161bSBill Fenner printf(")"); 297a90e161bSBill Fenner } 298a90e161bSBill Fenner 299a90e161bSBill Fenner static void 300a90e161bSBill Fenner pptp_bearer_type_print(const u_int32_t *bearer_type) 301a90e161bSBill Fenner { 302a90e161bSBill Fenner printf(" BEARER_TYPE("); 3035b0fe478SBruce M Simpson switch (EXTRACT_32BITS(bearer_type)) { 304a90e161bSBill Fenner case 1: 305a90e161bSBill Fenner printf("A"); /* Analog */ 306a90e161bSBill Fenner break; 307a90e161bSBill Fenner case 2: 308a90e161bSBill Fenner printf("D"); /* Digital */ 309a90e161bSBill Fenner break; 310a90e161bSBill Fenner case 3: 311a90e161bSBill Fenner printf("Any"); 312a90e161bSBill Fenner break; 313a90e161bSBill Fenner default: 314a90e161bSBill Fenner printf("?"); 315a90e161bSBill Fenner break; 316a90e161bSBill Fenner } 317a90e161bSBill Fenner printf(")"); 318a90e161bSBill Fenner } 319a90e161bSBill Fenner 320a90e161bSBill Fenner static void 321a90e161bSBill Fenner pptp_call_id_print(const u_int16_t *call_id) 322a90e161bSBill Fenner { 3235b0fe478SBruce M Simpson printf(" CALL_ID(%u)", EXTRACT_16BITS(call_id)); 324a90e161bSBill Fenner } 325a90e161bSBill Fenner 326a90e161bSBill Fenner static void 327a90e161bSBill Fenner pptp_call_ser_print(const u_int16_t *call_ser) 328a90e161bSBill Fenner { 3295b0fe478SBruce M Simpson printf(" CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser)); 330a90e161bSBill Fenner } 331a90e161bSBill Fenner 332a90e161bSBill Fenner static void 333a90e161bSBill Fenner pptp_cause_code_print(const u_int16_t *cause_code) 334a90e161bSBill Fenner { 3355b0fe478SBruce M Simpson printf(" CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code)); 336a90e161bSBill Fenner } 337a90e161bSBill Fenner 338a90e161bSBill Fenner static void 339a90e161bSBill Fenner pptp_conn_speed_print(const u_int32_t *conn_speed) 340a90e161bSBill Fenner { 3415b0fe478SBruce M Simpson printf(" CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed)); 342a90e161bSBill Fenner } 343a90e161bSBill Fenner 344a90e161bSBill Fenner static void 345a90e161bSBill Fenner pptp_err_code_print(const u_int8_t *err_code) 346a90e161bSBill Fenner { 347a90e161bSBill Fenner printf(" ERR_CODE(%u", *err_code); 348a90e161bSBill Fenner if (vflag) { 349a90e161bSBill Fenner switch (*err_code) { 350a90e161bSBill Fenner case 0: 351a90e161bSBill Fenner printf(":None"); 352a90e161bSBill Fenner break; 353a90e161bSBill Fenner case 1: 354a90e161bSBill Fenner printf(":Not-Connected"); 355a90e161bSBill Fenner break; 356a90e161bSBill Fenner case 2: 357a90e161bSBill Fenner printf(":Bad-Format"); 358a90e161bSBill Fenner break; 359a90e161bSBill Fenner case 3: 360a90e161bSBill Fenner printf(":Bad-Valude"); 361a90e161bSBill Fenner break; 362a90e161bSBill Fenner case 4: 363a90e161bSBill Fenner printf(":No-Resource"); 364a90e161bSBill Fenner break; 365a90e161bSBill Fenner case 5: 366a90e161bSBill Fenner printf(":Bad-Call-ID"); 367a90e161bSBill Fenner break; 368a90e161bSBill Fenner case 6: 369a90e161bSBill Fenner printf(":PAC-Error"); 370a90e161bSBill Fenner break; 371a90e161bSBill Fenner default: 372a90e161bSBill Fenner printf(":?"); 373a90e161bSBill Fenner break; 374a90e161bSBill Fenner } 375a90e161bSBill Fenner } 376a90e161bSBill Fenner printf(")"); 377a90e161bSBill Fenner } 378a90e161bSBill Fenner 379a90e161bSBill Fenner static void 380a90e161bSBill Fenner pptp_firm_rev_print(const u_int16_t *firm_rev) 381a90e161bSBill Fenner { 3825b0fe478SBruce M Simpson printf(" FIRM_REV(%u)", EXTRACT_16BITS(firm_rev)); 383a90e161bSBill Fenner } 384a90e161bSBill Fenner 385a90e161bSBill Fenner static void 386a90e161bSBill Fenner pptp_framing_cap_print(const u_int32_t *framing_cap) 387a90e161bSBill Fenner { 388a90e161bSBill Fenner printf(" FRAME_CAP("); 3895b0fe478SBruce M Simpson if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) { 390a90e161bSBill Fenner printf("A"); /* Async */ 391a90e161bSBill Fenner } 3925b0fe478SBruce M Simpson if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) { 393a90e161bSBill Fenner printf("S"); /* Sync */ 394a90e161bSBill Fenner } 395a90e161bSBill Fenner printf(")"); 396a90e161bSBill Fenner } 397a90e161bSBill Fenner 398a90e161bSBill Fenner static void 399a90e161bSBill Fenner pptp_framing_type_print(const u_int32_t *framing_type) 400a90e161bSBill Fenner { 401a90e161bSBill Fenner printf(" FRAME_TYPE("); 4025b0fe478SBruce M Simpson switch (EXTRACT_32BITS(framing_type)) { 403a90e161bSBill Fenner case 1: 404a90e161bSBill Fenner printf("A"); /* Async */ 405a90e161bSBill Fenner break; 406a90e161bSBill Fenner case 2: 407a90e161bSBill Fenner printf("S"); /* Sync */ 408a90e161bSBill Fenner break; 409a90e161bSBill Fenner case 3: 410a90e161bSBill Fenner printf("E"); /* Either */ 411a90e161bSBill Fenner break; 412a90e161bSBill Fenner default: 413a90e161bSBill Fenner printf("?"); 414a90e161bSBill Fenner break; 415a90e161bSBill Fenner } 416a90e161bSBill Fenner printf(")"); 417a90e161bSBill Fenner } 418a90e161bSBill Fenner 419a90e161bSBill Fenner static void 420a90e161bSBill Fenner pptp_hostname_print(const u_char *hostname) 421a90e161bSBill Fenner { 422a90e161bSBill Fenner printf(" HOSTNAME(%.64s)", hostname); 423a90e161bSBill Fenner } 424a90e161bSBill Fenner 425a90e161bSBill Fenner static void 426a90e161bSBill Fenner pptp_id_print(const u_int32_t *id) 427a90e161bSBill Fenner { 4285b0fe478SBruce M Simpson printf(" ID(%u)", EXTRACT_32BITS(id)); 429a90e161bSBill Fenner } 430a90e161bSBill Fenner 431a90e161bSBill Fenner static void 432a90e161bSBill Fenner pptp_max_channel_print(const u_int16_t *max_channel) 433a90e161bSBill Fenner { 4345b0fe478SBruce M Simpson printf(" MAX_CHAN(%u)", EXTRACT_16BITS(max_channel)); 435a90e161bSBill Fenner } 436a90e161bSBill Fenner 437a90e161bSBill Fenner static void 438a90e161bSBill Fenner pptp_peer_call_id_print(const u_int16_t *peer_call_id) 439a90e161bSBill Fenner { 4405b0fe478SBruce M Simpson printf(" PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id)); 441a90e161bSBill Fenner } 442a90e161bSBill Fenner 443a90e161bSBill Fenner static void 444a90e161bSBill Fenner pptp_phy_chan_id_print(const u_int32_t *phy_chan_id) 445a90e161bSBill Fenner { 4465b0fe478SBruce M Simpson printf(" PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id)); 447a90e161bSBill Fenner } 448a90e161bSBill Fenner 449a90e161bSBill Fenner static void 450a90e161bSBill Fenner pptp_pkt_proc_delay_print(const u_int16_t *pkt_proc_delay) 451a90e161bSBill Fenner { 4525b0fe478SBruce M Simpson printf(" PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay)); 453a90e161bSBill Fenner } 454a90e161bSBill Fenner 455a90e161bSBill Fenner static void 456a90e161bSBill Fenner pptp_proto_ver_print(const u_int16_t *proto_ver) 457a90e161bSBill Fenner { 458a90e161bSBill Fenner printf(" PROTO_VER(%u.%u)", /* Version.Revision */ 4595b0fe478SBruce M Simpson EXTRACT_16BITS(proto_ver) >> 8, 4605b0fe478SBruce M Simpson EXTRACT_16BITS(proto_ver) & 0xff); 461a90e161bSBill Fenner } 462a90e161bSBill Fenner 463a90e161bSBill Fenner static void 464a90e161bSBill Fenner pptp_recv_winsiz_print(const u_int16_t *recv_winsiz) 465a90e161bSBill Fenner { 4665b0fe478SBruce M Simpson printf(" RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz)); 467a90e161bSBill Fenner } 468a90e161bSBill Fenner 469a90e161bSBill Fenner static void 470a90e161bSBill Fenner pptp_result_code_print(const u_int8_t *result_code, int ctrl_msg_type) 471a90e161bSBill Fenner { 472a90e161bSBill Fenner printf(" RESULT_CODE(%u", *result_code); 473a90e161bSBill Fenner if (vflag) { 474a90e161bSBill Fenner switch (ctrl_msg_type) { 475a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_SCCRP: 476a90e161bSBill Fenner switch (*result_code) { 477a90e161bSBill Fenner case 1: 478a90e161bSBill Fenner printf(":Successful channel establishment"); 479a90e161bSBill Fenner break; 480a90e161bSBill Fenner case 2: 481a90e161bSBill Fenner printf(":General error"); 482a90e161bSBill Fenner break; 483a90e161bSBill Fenner case 3: 484a90e161bSBill Fenner printf(":Command channel already exists"); 485a90e161bSBill Fenner break; 486a90e161bSBill Fenner case 4: 487a90e161bSBill Fenner printf(":Requester is not authorized to establish a command channel"); 488a90e161bSBill Fenner break; 489a90e161bSBill Fenner case 5: 490a90e161bSBill Fenner printf(":The protocol version of the requester is not supported"); 491a90e161bSBill Fenner break; 492a90e161bSBill Fenner default: 493a90e161bSBill Fenner printf(":?"); 494a90e161bSBill Fenner break; 495a90e161bSBill Fenner } 496a90e161bSBill Fenner break; 497a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_StopCCRP: 498a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_ECHORP: 499a90e161bSBill Fenner switch (*result_code) { 500a90e161bSBill Fenner case 1: 501a90e161bSBill Fenner printf(":OK"); 502a90e161bSBill Fenner break; 503a90e161bSBill Fenner case 2: 504a90e161bSBill Fenner printf(":General Error"); 505a90e161bSBill Fenner break; 506a90e161bSBill Fenner default: 507a90e161bSBill Fenner printf(":?"); 508a90e161bSBill Fenner break; 509a90e161bSBill Fenner } 510a90e161bSBill Fenner break; 511a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_OCRP: 512a90e161bSBill Fenner switch (*result_code) { 513a90e161bSBill Fenner case 1: 514a90e161bSBill Fenner printf(":Connected"); 515a90e161bSBill Fenner break; 516a90e161bSBill Fenner case 2: 517a90e161bSBill Fenner printf(":General Error"); 518a90e161bSBill Fenner break; 519a90e161bSBill Fenner case 3: 520a90e161bSBill Fenner printf(":No Carrier"); 521a90e161bSBill Fenner break; 522a90e161bSBill Fenner case 4: 523a90e161bSBill Fenner printf(":Busy"); 524a90e161bSBill Fenner break; 525a90e161bSBill Fenner case 5: 526a90e161bSBill Fenner printf(":No Dial Tone"); 527a90e161bSBill Fenner break; 528a90e161bSBill Fenner case 6: 529a90e161bSBill Fenner printf(":Time-out"); 530a90e161bSBill Fenner break; 531a90e161bSBill Fenner case 7: 532a90e161bSBill Fenner printf(":Do Not Accept"); 533a90e161bSBill Fenner break; 534a90e161bSBill Fenner default: 535a90e161bSBill Fenner printf(":?"); 536a90e161bSBill Fenner break; 537a90e161bSBill Fenner } 538a90e161bSBill Fenner break; 539a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_ICRP: 540a90e161bSBill Fenner switch (*result_code) { 541a90e161bSBill Fenner case 1: 542a90e161bSBill Fenner printf(":Connect"); 543a90e161bSBill Fenner break; 544a90e161bSBill Fenner case 2: 545a90e161bSBill Fenner printf(":General Error"); 546a90e161bSBill Fenner break; 547a90e161bSBill Fenner case 3: 548a90e161bSBill Fenner printf(":Do Not Accept"); 549a90e161bSBill Fenner break; 550a90e161bSBill Fenner default: 551a90e161bSBill Fenner printf(":?"); 552a90e161bSBill Fenner break; 553a90e161bSBill Fenner } 554a90e161bSBill Fenner break; 555a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_CDN: 556a90e161bSBill Fenner switch (*result_code) { 557a90e161bSBill Fenner case 1: 558a90e161bSBill Fenner printf(":Lost Carrier"); 559a90e161bSBill Fenner break; 560a90e161bSBill Fenner case 2: 561a90e161bSBill Fenner printf(":General Error"); 562a90e161bSBill Fenner break; 563a90e161bSBill Fenner case 3: 564a90e161bSBill Fenner printf(":Admin Shutdown"); 565a90e161bSBill Fenner break; 566a90e161bSBill Fenner case 4: 567a90e161bSBill Fenner printf(":Request"); 568a90e161bSBill Fenner default: 569a90e161bSBill Fenner printf(":?"); 570a90e161bSBill Fenner break; 571a90e161bSBill Fenner break; 572a90e161bSBill Fenner } 573a90e161bSBill Fenner default: 574a90e161bSBill Fenner /* assertion error */ 575a90e161bSBill Fenner break; 576a90e161bSBill Fenner } 577a90e161bSBill Fenner } 578a90e161bSBill Fenner printf(")"); 579a90e161bSBill Fenner } 580a90e161bSBill Fenner 581a90e161bSBill Fenner static void 582a90e161bSBill Fenner pptp_subaddr_print(const u_char *subaddr) 583a90e161bSBill Fenner { 584a90e161bSBill Fenner printf(" SUB_ADDR(%.64s)", subaddr); 585a90e161bSBill Fenner } 586a90e161bSBill Fenner 587a90e161bSBill Fenner static void 588a90e161bSBill Fenner pptp_vendor_print(const u_char *vendor) 589a90e161bSBill Fenner { 590a90e161bSBill Fenner printf(" VENDOR(%.64s)", vendor); 591a90e161bSBill Fenner } 592a90e161bSBill Fenner 593a90e161bSBill Fenner /************************************/ 594a90e161bSBill Fenner /* PPTP message print out functions */ 595a90e161bSBill Fenner /************************************/ 596a90e161bSBill Fenner static void 597a90e161bSBill Fenner pptp_sccrq_print(const u_char *dat) 598a90e161bSBill Fenner { 599a90e161bSBill Fenner struct pptp_msg_sccrq *ptr = (struct pptp_msg_sccrq *)dat; 600a90e161bSBill Fenner 601a90e161bSBill Fenner TCHECK(ptr->proto_ver); 602a90e161bSBill Fenner pptp_proto_ver_print(&ptr->proto_ver); 603a90e161bSBill Fenner TCHECK(ptr->reserved1); 604a90e161bSBill Fenner TCHECK(ptr->framing_cap); 605a90e161bSBill Fenner pptp_framing_cap_print(&ptr->framing_cap); 606a90e161bSBill Fenner TCHECK(ptr->bearer_cap); 607a90e161bSBill Fenner pptp_bearer_cap_print(&ptr->bearer_cap); 608a90e161bSBill Fenner TCHECK(ptr->max_channel); 609a90e161bSBill Fenner pptp_max_channel_print(&ptr->max_channel); 610a90e161bSBill Fenner TCHECK(ptr->firm_rev); 611a90e161bSBill Fenner pptp_firm_rev_print(&ptr->firm_rev); 612a90e161bSBill Fenner TCHECK(ptr->hostname); 613a90e161bSBill Fenner pptp_hostname_print(&ptr->hostname[0]); 614a90e161bSBill Fenner TCHECK(ptr->vendor); 615a90e161bSBill Fenner pptp_vendor_print(&ptr->vendor[0]); 616a90e161bSBill Fenner 617a90e161bSBill Fenner return; 618a90e161bSBill Fenner 619a90e161bSBill Fenner trunc: 620a90e161bSBill Fenner printf("%s", tstr); 621a90e161bSBill Fenner } 622a90e161bSBill Fenner 623a90e161bSBill Fenner static void 624a90e161bSBill Fenner pptp_sccrp_print(const u_char *dat) 625a90e161bSBill Fenner { 626a90e161bSBill Fenner struct pptp_msg_sccrp *ptr = (struct pptp_msg_sccrp *)dat; 627a90e161bSBill Fenner 628a90e161bSBill Fenner TCHECK(ptr->proto_ver); 629a90e161bSBill Fenner pptp_proto_ver_print(&ptr->proto_ver); 630a90e161bSBill Fenner TCHECK(ptr->result_code); 631a90e161bSBill Fenner pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP); 632a90e161bSBill Fenner TCHECK(ptr->err_code); 633a90e161bSBill Fenner pptp_err_code_print(&ptr->err_code); 634a90e161bSBill Fenner TCHECK(ptr->framing_cap); 635a90e161bSBill Fenner pptp_framing_cap_print(&ptr->framing_cap); 636a90e161bSBill Fenner TCHECK(ptr->bearer_cap); 637a90e161bSBill Fenner pptp_bearer_cap_print(&ptr->bearer_cap); 638a90e161bSBill Fenner TCHECK(ptr->max_channel); 639a90e161bSBill Fenner pptp_max_channel_print(&ptr->max_channel); 640a90e161bSBill Fenner TCHECK(ptr->firm_rev); 641a90e161bSBill Fenner pptp_firm_rev_print(&ptr->firm_rev); 642a90e161bSBill Fenner TCHECK(ptr->hostname); 643a90e161bSBill Fenner pptp_hostname_print(&ptr->hostname[0]); 644a90e161bSBill Fenner TCHECK(ptr->vendor); 645a90e161bSBill Fenner pptp_vendor_print(&ptr->vendor[0]); 646a90e161bSBill Fenner 647a90e161bSBill Fenner return; 648a90e161bSBill Fenner 649a90e161bSBill Fenner trunc: 650a90e161bSBill Fenner printf("%s", tstr); 651a90e161bSBill Fenner } 652a90e161bSBill Fenner 653a90e161bSBill Fenner static void 654a90e161bSBill Fenner pptp_stopccrq_print(const u_char *dat) 655a90e161bSBill Fenner { 656a90e161bSBill Fenner struct pptp_msg_stopccrq *ptr = (struct pptp_msg_stopccrq *)dat; 657a90e161bSBill Fenner 658a90e161bSBill Fenner TCHECK(ptr->reason); 659a90e161bSBill Fenner printf(" REASON(%u", ptr->reason); 660a90e161bSBill Fenner if (vflag) { 661a90e161bSBill Fenner switch (ptr->reason) { 662a90e161bSBill Fenner case 1: 663a90e161bSBill Fenner printf(":None"); 664a90e161bSBill Fenner break; 665a90e161bSBill Fenner case 2: 666a90e161bSBill Fenner printf(":Stop-Protocol"); 667a90e161bSBill Fenner break; 668a90e161bSBill Fenner case 3: 669a90e161bSBill Fenner printf(":Stop-Local-Shutdown"); 670a90e161bSBill Fenner break; 671a90e161bSBill Fenner default: 672a90e161bSBill Fenner printf(":?"); 673a90e161bSBill Fenner break; 674a90e161bSBill Fenner } 675a90e161bSBill Fenner } 676a90e161bSBill Fenner printf(")"); 677a90e161bSBill Fenner TCHECK(ptr->reserved1); 678a90e161bSBill Fenner TCHECK(ptr->reserved2); 679a90e161bSBill Fenner 680a90e161bSBill Fenner return; 681a90e161bSBill Fenner 682a90e161bSBill Fenner trunc: 683a90e161bSBill Fenner printf("%s", tstr); 684a90e161bSBill Fenner } 685a90e161bSBill Fenner 686a90e161bSBill Fenner static void 687a90e161bSBill Fenner pptp_stopccrp_print(const u_char *dat) 688a90e161bSBill Fenner { 689a90e161bSBill Fenner struct pptp_msg_stopccrp *ptr = (struct pptp_msg_stopccrp *)dat; 690a90e161bSBill Fenner 691a90e161bSBill Fenner TCHECK(ptr->result_code); 692a90e161bSBill Fenner pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP); 693a90e161bSBill Fenner TCHECK(ptr->err_code); 694a90e161bSBill Fenner pptp_err_code_print(&ptr->err_code); 695a90e161bSBill Fenner TCHECK(ptr->reserved1); 696a90e161bSBill Fenner 697a90e161bSBill Fenner return; 698a90e161bSBill Fenner 699a90e161bSBill Fenner trunc: 700a90e161bSBill Fenner printf("%s", tstr); 701a90e161bSBill Fenner } 702a90e161bSBill Fenner 703a90e161bSBill Fenner static void 704a90e161bSBill Fenner pptp_echorq_print(const u_char *dat) 705a90e161bSBill Fenner { 706a90e161bSBill Fenner struct pptp_msg_echorq *ptr = (struct pptp_msg_echorq *)dat; 707a90e161bSBill Fenner 708a90e161bSBill Fenner TCHECK(ptr->id); 709a90e161bSBill Fenner pptp_id_print(&ptr->id); 710a90e161bSBill Fenner 711a90e161bSBill Fenner return; 712a90e161bSBill Fenner 713a90e161bSBill Fenner trunc: 714a90e161bSBill Fenner printf("%s", tstr); 715a90e161bSBill Fenner } 716a90e161bSBill Fenner 717a90e161bSBill Fenner static void 718a90e161bSBill Fenner pptp_echorp_print(const u_char *dat) 719a90e161bSBill Fenner { 720a90e161bSBill Fenner struct pptp_msg_echorp *ptr = (struct pptp_msg_echorp *)dat; 721a90e161bSBill Fenner 722a90e161bSBill Fenner TCHECK(ptr->id); 723a90e161bSBill Fenner pptp_id_print(&ptr->id); 724a90e161bSBill Fenner TCHECK(ptr->result_code); 725a90e161bSBill Fenner pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP); 726a90e161bSBill Fenner TCHECK(ptr->err_code); 727a90e161bSBill Fenner pptp_err_code_print(&ptr->err_code); 728a90e161bSBill Fenner TCHECK(ptr->reserved1); 729a90e161bSBill Fenner 730a90e161bSBill Fenner return; 731a90e161bSBill Fenner 732a90e161bSBill Fenner trunc: 733a90e161bSBill Fenner printf("%s", tstr); 734a90e161bSBill Fenner } 735a90e161bSBill Fenner 736a90e161bSBill Fenner static void 737a90e161bSBill Fenner pptp_ocrq_print(const u_char *dat) 738a90e161bSBill Fenner { 739a90e161bSBill Fenner struct pptp_msg_ocrq *ptr = (struct pptp_msg_ocrq *)dat; 740a90e161bSBill Fenner 741a90e161bSBill Fenner TCHECK(ptr->call_id); 742a90e161bSBill Fenner pptp_call_id_print(&ptr->call_id); 743a90e161bSBill Fenner TCHECK(ptr->call_ser); 744a90e161bSBill Fenner pptp_call_ser_print(&ptr->call_ser); 745a90e161bSBill Fenner TCHECK(ptr->min_bps); 7465b0fe478SBruce M Simpson printf(" MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps)); 747a90e161bSBill Fenner TCHECK(ptr->max_bps); 7485b0fe478SBruce M Simpson printf(" MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps)); 749a90e161bSBill Fenner TCHECK(ptr->bearer_type); 750a90e161bSBill Fenner pptp_bearer_type_print(&ptr->bearer_type); 751a90e161bSBill Fenner TCHECK(ptr->framing_type); 752a90e161bSBill Fenner pptp_framing_type_print(&ptr->framing_type); 753a90e161bSBill Fenner TCHECK(ptr->recv_winsiz); 754a90e161bSBill Fenner pptp_recv_winsiz_print(&ptr->recv_winsiz); 755a90e161bSBill Fenner TCHECK(ptr->pkt_proc_delay); 756a90e161bSBill Fenner pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay); 757a90e161bSBill Fenner TCHECK(ptr->phone_no_len); 7585b0fe478SBruce M Simpson printf(" PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len)); 759a90e161bSBill Fenner TCHECK(ptr->reserved1); 760a90e161bSBill Fenner TCHECK(ptr->phone_no); 761a90e161bSBill Fenner printf(" PHONE_NO(%.64s)", ptr->phone_no); 762a90e161bSBill Fenner TCHECK(ptr->subaddr); 763a90e161bSBill Fenner pptp_subaddr_print(&ptr->subaddr[0]); 764a90e161bSBill Fenner 765a90e161bSBill Fenner return; 766a90e161bSBill Fenner 767a90e161bSBill Fenner trunc: 768a90e161bSBill Fenner printf("%s", tstr); 769a90e161bSBill Fenner } 770a90e161bSBill Fenner 771a90e161bSBill Fenner static void 772a90e161bSBill Fenner pptp_ocrp_print(const u_char *dat) 773a90e161bSBill Fenner { 774a90e161bSBill Fenner struct pptp_msg_ocrp *ptr = (struct pptp_msg_ocrp *)dat; 775a90e161bSBill Fenner 776a90e161bSBill Fenner TCHECK(ptr->call_id); 777a90e161bSBill Fenner pptp_call_id_print(&ptr->call_id); 778a90e161bSBill Fenner TCHECK(ptr->peer_call_id); 779a90e161bSBill Fenner pptp_peer_call_id_print(&ptr->peer_call_id); 780a90e161bSBill Fenner TCHECK(ptr->result_code); 781a90e161bSBill Fenner pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP); 782a90e161bSBill Fenner TCHECK(ptr->err_code); 783a90e161bSBill Fenner pptp_err_code_print(&ptr->err_code); 784a90e161bSBill Fenner TCHECK(ptr->cause_code); 785a90e161bSBill Fenner pptp_cause_code_print(&ptr->cause_code); 786a90e161bSBill Fenner TCHECK(ptr->conn_speed); 787a90e161bSBill Fenner pptp_conn_speed_print(&ptr->conn_speed); 788a90e161bSBill Fenner TCHECK(ptr->recv_winsiz); 789a90e161bSBill Fenner pptp_recv_winsiz_print(&ptr->recv_winsiz); 790a90e161bSBill Fenner TCHECK(ptr->pkt_proc_delay); 791a90e161bSBill Fenner pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay); 792a90e161bSBill Fenner TCHECK(ptr->phy_chan_id); 793a90e161bSBill Fenner pptp_phy_chan_id_print(&ptr->phy_chan_id); 794a90e161bSBill Fenner 795a90e161bSBill Fenner return; 796a90e161bSBill Fenner 797a90e161bSBill Fenner trunc: 798a90e161bSBill Fenner printf("%s", tstr); 799a90e161bSBill Fenner } 800a90e161bSBill Fenner 801a90e161bSBill Fenner static void 802a90e161bSBill Fenner pptp_icrq_print(const u_char *dat) 803a90e161bSBill Fenner { 804a90e161bSBill Fenner struct pptp_msg_icrq *ptr = (struct pptp_msg_icrq *)dat; 805a90e161bSBill Fenner 806a90e161bSBill Fenner TCHECK(ptr->call_id); 807a90e161bSBill Fenner pptp_call_id_print(&ptr->call_id); 808a90e161bSBill Fenner TCHECK(ptr->call_ser); 809a90e161bSBill Fenner pptp_call_ser_print(&ptr->call_ser); 810a90e161bSBill Fenner TCHECK(ptr->bearer_type); 811a90e161bSBill Fenner pptp_bearer_type_print(&ptr->bearer_type); 812a90e161bSBill Fenner TCHECK(ptr->phy_chan_id); 813a90e161bSBill Fenner pptp_phy_chan_id_print(&ptr->phy_chan_id); 814a90e161bSBill Fenner TCHECK(ptr->dialed_no_len); 8155b0fe478SBruce M Simpson printf(" DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len)); 816a90e161bSBill Fenner TCHECK(ptr->dialing_no_len); 8175b0fe478SBruce M Simpson printf(" DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len)); 818a90e161bSBill Fenner TCHECK(ptr->dialed_no); 819a90e161bSBill Fenner printf(" DIALED_NO(%.64s)", ptr->dialed_no); 820a90e161bSBill Fenner TCHECK(ptr->dialing_no); 821a90e161bSBill Fenner printf(" DIALING_NO(%.64s)", ptr->dialing_no); 822a90e161bSBill Fenner TCHECK(ptr->subaddr); 823a90e161bSBill Fenner pptp_subaddr_print(&ptr->subaddr[0]); 824a90e161bSBill Fenner 825a90e161bSBill Fenner return; 826a90e161bSBill Fenner 827a90e161bSBill Fenner trunc: 828a90e161bSBill Fenner printf("%s", tstr); 829a90e161bSBill Fenner } 830a90e161bSBill Fenner 831a90e161bSBill Fenner static void 832a90e161bSBill Fenner pptp_icrp_print(const u_char *dat) 833a90e161bSBill Fenner { 834a90e161bSBill Fenner struct pptp_msg_icrp *ptr = (struct pptp_msg_icrp *)dat; 835a90e161bSBill Fenner 836a90e161bSBill Fenner TCHECK(ptr->call_id); 837a90e161bSBill Fenner pptp_call_id_print(&ptr->call_id); 838a90e161bSBill Fenner TCHECK(ptr->peer_call_id); 839a90e161bSBill Fenner pptp_peer_call_id_print(&ptr->peer_call_id); 840a90e161bSBill Fenner TCHECK(ptr->result_code); 841a90e161bSBill Fenner pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP); 842a90e161bSBill Fenner TCHECK(ptr->err_code); 843a90e161bSBill Fenner pptp_err_code_print(&ptr->err_code); 844a90e161bSBill Fenner TCHECK(ptr->recv_winsiz); 845a90e161bSBill Fenner pptp_recv_winsiz_print(&ptr->recv_winsiz); 846a90e161bSBill Fenner TCHECK(ptr->pkt_proc_delay); 847a90e161bSBill Fenner pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay); 848a90e161bSBill Fenner TCHECK(ptr->reserved1); 849a90e161bSBill Fenner 850a90e161bSBill Fenner return; 851a90e161bSBill Fenner 852a90e161bSBill Fenner trunc: 853a90e161bSBill Fenner printf("%s", tstr); 854a90e161bSBill Fenner } 855a90e161bSBill Fenner 856a90e161bSBill Fenner static void 857a90e161bSBill Fenner pptp_iccn_print(const u_char *dat) 858a90e161bSBill Fenner { 859a90e161bSBill Fenner struct pptp_msg_iccn *ptr = (struct pptp_msg_iccn *)dat; 860a90e161bSBill Fenner 861a90e161bSBill Fenner TCHECK(ptr->peer_call_id); 862a90e161bSBill Fenner pptp_peer_call_id_print(&ptr->peer_call_id); 863a90e161bSBill Fenner TCHECK(ptr->reserved1); 864a90e161bSBill Fenner TCHECK(ptr->conn_speed); 865a90e161bSBill Fenner pptp_conn_speed_print(&ptr->conn_speed); 866a90e161bSBill Fenner TCHECK(ptr->recv_winsiz); 867a90e161bSBill Fenner pptp_recv_winsiz_print(&ptr->recv_winsiz); 868a90e161bSBill Fenner TCHECK(ptr->pkt_proc_delay); 869a90e161bSBill Fenner pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay); 870a90e161bSBill Fenner TCHECK(ptr->framing_type); 871a90e161bSBill Fenner pptp_framing_type_print(&ptr->framing_type); 872a90e161bSBill Fenner 873a90e161bSBill Fenner return; 874a90e161bSBill Fenner 875a90e161bSBill Fenner trunc: 876a90e161bSBill Fenner printf("%s", tstr); 877a90e161bSBill Fenner } 878a90e161bSBill Fenner 879a90e161bSBill Fenner static void 880a90e161bSBill Fenner pptp_ccrq_print(const u_char *dat) 881a90e161bSBill Fenner { 882a90e161bSBill Fenner struct pptp_msg_ccrq *ptr = (struct pptp_msg_ccrq *)dat; 883a90e161bSBill Fenner 884a90e161bSBill Fenner TCHECK(ptr->call_id); 885a90e161bSBill Fenner pptp_call_id_print(&ptr->call_id); 886a90e161bSBill Fenner TCHECK(ptr->reserved1); 887a90e161bSBill Fenner 888a90e161bSBill Fenner return; 889a90e161bSBill Fenner 890a90e161bSBill Fenner trunc: 891a90e161bSBill Fenner printf("%s", tstr); 892a90e161bSBill Fenner } 893a90e161bSBill Fenner 894a90e161bSBill Fenner static void 895a90e161bSBill Fenner pptp_cdn_print(const u_char *dat) 896a90e161bSBill Fenner { 897a90e161bSBill Fenner struct pptp_msg_cdn *ptr = (struct pptp_msg_cdn *)dat; 898a90e161bSBill Fenner 899a90e161bSBill Fenner TCHECK(ptr->call_id); 900a90e161bSBill Fenner pptp_call_id_print(&ptr->call_id); 901a90e161bSBill Fenner TCHECK(ptr->result_code); 902a90e161bSBill Fenner pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN); 903a90e161bSBill Fenner TCHECK(ptr->err_code); 904a90e161bSBill Fenner pptp_err_code_print(&ptr->err_code); 905a90e161bSBill Fenner TCHECK(ptr->cause_code); 906a90e161bSBill Fenner pptp_cause_code_print(&ptr->cause_code); 907a90e161bSBill Fenner TCHECK(ptr->reserved1); 908a90e161bSBill Fenner TCHECK(ptr->call_stats); 909a90e161bSBill Fenner printf(" CALL_STATS(%.128s)", ptr->call_stats); 910a90e161bSBill Fenner 911a90e161bSBill Fenner return; 912a90e161bSBill Fenner 913a90e161bSBill Fenner trunc: 914a90e161bSBill Fenner printf("%s", tstr); 915a90e161bSBill Fenner } 916a90e161bSBill Fenner 917a90e161bSBill Fenner static void 918a90e161bSBill Fenner pptp_wen_print(const u_char *dat) 919a90e161bSBill Fenner { 920a90e161bSBill Fenner struct pptp_msg_wen *ptr = (struct pptp_msg_wen *)dat; 921a90e161bSBill Fenner 922a90e161bSBill Fenner TCHECK(ptr->peer_call_id); 923a90e161bSBill Fenner pptp_peer_call_id_print(&ptr->peer_call_id); 924a90e161bSBill Fenner TCHECK(ptr->reserved1); 925a90e161bSBill Fenner TCHECK(ptr->crc_err); 9265b0fe478SBruce M Simpson printf(" CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err)); 927a90e161bSBill Fenner TCHECK(ptr->framing_err); 9285b0fe478SBruce M Simpson printf(" FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err)); 929a90e161bSBill Fenner TCHECK(ptr->hardware_overrun); 9305b0fe478SBruce M Simpson printf(" HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun)); 931a90e161bSBill Fenner TCHECK(ptr->buffer_overrun); 9325b0fe478SBruce M Simpson printf(" BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun)); 933a90e161bSBill Fenner TCHECK(ptr->timeout_err); 9345b0fe478SBruce M Simpson printf(" TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err)); 935a90e161bSBill Fenner TCHECK(ptr->align_err); 9365b0fe478SBruce M Simpson printf(" ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err)); 937a90e161bSBill Fenner 938a90e161bSBill Fenner return; 939a90e161bSBill Fenner 940a90e161bSBill Fenner trunc: 941a90e161bSBill Fenner printf("%s", tstr); 942a90e161bSBill Fenner } 943a90e161bSBill Fenner 944a90e161bSBill Fenner static void 945a90e161bSBill Fenner pptp_sli_print(const u_char *dat) 946a90e161bSBill Fenner { 947a90e161bSBill Fenner struct pptp_msg_sli *ptr = (struct pptp_msg_sli *)dat; 948a90e161bSBill Fenner 949a90e161bSBill Fenner TCHECK(ptr->peer_call_id); 950a90e161bSBill Fenner pptp_peer_call_id_print(&ptr->peer_call_id); 951a90e161bSBill Fenner TCHECK(ptr->reserved1); 952a90e161bSBill Fenner TCHECK(ptr->send_accm); 9535b0fe478SBruce M Simpson printf(" SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm)); 954a90e161bSBill Fenner TCHECK(ptr->recv_accm); 9555b0fe478SBruce M Simpson printf(" RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm)); 956a90e161bSBill Fenner 957a90e161bSBill Fenner return; 958a90e161bSBill Fenner 959a90e161bSBill Fenner trunc: 960a90e161bSBill Fenner printf("%s", tstr); 961a90e161bSBill Fenner } 962a90e161bSBill Fenner 963a90e161bSBill Fenner void 9645b0fe478SBruce M Simpson pptp_print(const u_char *dat) 965a90e161bSBill Fenner { 966a90e161bSBill Fenner const struct pptp_hdr *hdr; 967a90e161bSBill Fenner u_int32_t mc; 968a90e161bSBill Fenner u_int16_t ctrl_msg_type; 969a90e161bSBill Fenner 970a90e161bSBill Fenner printf(": pptp"); 971a90e161bSBill Fenner 972a90e161bSBill Fenner hdr = (struct pptp_hdr *)dat; 973a90e161bSBill Fenner 974a90e161bSBill Fenner TCHECK(hdr->length); 975a90e161bSBill Fenner if (vflag) { 9765b0fe478SBruce M Simpson printf(" Length=%u", EXTRACT_16BITS(&hdr->length)); 977a90e161bSBill Fenner } 978a90e161bSBill Fenner TCHECK(hdr->msg_type); 979a90e161bSBill Fenner if (vflag) { 9805b0fe478SBruce M Simpson switch(EXTRACT_16BITS(&hdr->msg_type)) { 981a90e161bSBill Fenner case PPTP_MSG_TYPE_CTRL: 982a90e161bSBill Fenner printf(" CTRL-MSG"); 983a90e161bSBill Fenner break; 984a90e161bSBill Fenner case PPTP_MSG_TYPE_MGMT: 985a90e161bSBill Fenner printf(" MGMT-MSG"); 986a90e161bSBill Fenner break; 987a90e161bSBill Fenner default: 988a90e161bSBill Fenner printf(" UNKNOWN-MSG-TYPE"); 989a90e161bSBill Fenner break; 990a90e161bSBill Fenner } 991a90e161bSBill Fenner } 992a90e161bSBill Fenner 993a90e161bSBill Fenner TCHECK(hdr->magic_cookie); 9945b0fe478SBruce M Simpson mc = EXTRACT_32BITS(&hdr->magic_cookie); 995a90e161bSBill Fenner if (mc != PPTP_MAGIC_COOKIE) { 996a90e161bSBill Fenner printf(" UNEXPECTED Magic-Cookie!!(%08x)", mc); 997a90e161bSBill Fenner } 998a90e161bSBill Fenner if (vflag || mc != PPTP_MAGIC_COOKIE) { 999a90e161bSBill Fenner printf(" Magic-Cookie=%08x", mc); 1000a90e161bSBill Fenner } 1001a90e161bSBill Fenner TCHECK(hdr->ctrl_msg_type); 10025b0fe478SBruce M Simpson ctrl_msg_type = EXTRACT_16BITS(&hdr->ctrl_msg_type); 1003a90e161bSBill Fenner if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) { 1004a90e161bSBill Fenner printf(" CTRL_MSGTYPE=%s", 1005a90e161bSBill Fenner pptp_message_type_string[ctrl_msg_type]); 1006a90e161bSBill Fenner } else { 1007a90e161bSBill Fenner printf(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type); 1008a90e161bSBill Fenner } 1009a90e161bSBill Fenner TCHECK(hdr->reserved0); 1010a90e161bSBill Fenner 1011a90e161bSBill Fenner dat += 12; 1012a90e161bSBill Fenner 1013a90e161bSBill Fenner switch(ctrl_msg_type) { 1014a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_SCCRQ: 1015a90e161bSBill Fenner pptp_sccrq_print(dat); 1016a90e161bSBill Fenner break; 1017a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_SCCRP: 1018a90e161bSBill Fenner pptp_sccrp_print(dat); 1019a90e161bSBill Fenner break; 1020a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_StopCCRQ: 1021a90e161bSBill Fenner pptp_stopccrq_print(dat); 1022a90e161bSBill Fenner break; 1023a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_StopCCRP: 1024a90e161bSBill Fenner pptp_stopccrp_print(dat); 1025a90e161bSBill Fenner break; 1026a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_ECHORQ: 1027a90e161bSBill Fenner pptp_echorq_print(dat); 1028a90e161bSBill Fenner break; 1029a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_ECHORP: 1030a90e161bSBill Fenner pptp_echorp_print(dat); 1031a90e161bSBill Fenner break; 1032a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_OCRQ: 1033a90e161bSBill Fenner pptp_ocrq_print(dat); 1034a90e161bSBill Fenner break; 1035a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_OCRP: 1036a90e161bSBill Fenner pptp_ocrp_print(dat); 1037a90e161bSBill Fenner break; 1038a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_ICRQ: 1039a90e161bSBill Fenner pptp_icrq_print(dat); 1040a90e161bSBill Fenner break; 1041a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_ICRP: 1042a90e161bSBill Fenner pptp_icrp_print(dat); 1043a90e161bSBill Fenner break; 1044a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_ICCN: 1045a90e161bSBill Fenner pptp_iccn_print(dat); 1046a90e161bSBill Fenner break; 1047a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_CCRQ: 1048a90e161bSBill Fenner pptp_ccrq_print(dat); 1049a90e161bSBill Fenner break; 1050a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_CDN: 1051a90e161bSBill Fenner pptp_cdn_print(dat); 1052a90e161bSBill Fenner break; 1053a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_WEN: 1054a90e161bSBill Fenner pptp_wen_print(dat); 1055a90e161bSBill Fenner break; 1056a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_SLI: 1057a90e161bSBill Fenner pptp_sli_print(dat); 1058a90e161bSBill Fenner break; 1059a90e161bSBill Fenner default: 1060a90e161bSBill Fenner /* do nothing */ 1061a90e161bSBill Fenner break; 1062a90e161bSBill Fenner } 1063a90e161bSBill Fenner 1064a90e161bSBill Fenner return; 1065a90e161bSBill Fenner 1066a90e161bSBill Fenner trunc: 1067a90e161bSBill Fenner printf("%s", tstr); 1068a90e161bSBill Fenner } 1069