1 /* $OpenBSD: pptp_local.h,v 1.5 2021/03/29 03:54:40 yasuoka Exp $ */ 2 3 /*- 4 * Copyright (c) 2009 Internet Initiative Japan Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 #ifndef PPTP_LOCAL_H 29 #define PPTP_LOCAL_H 1 30 31 #ifndef countof 32 #define countof(x) (sizeof(x) / sizeof((x)[0])) 33 #endif 34 35 struct pptp_gre_header { 36 #if BYTE_ORDER == LITTLE_ENDIAN 37 uint8_t recur:3, 38 s:1, 39 S:1, 40 K:1, 41 R:1, 42 C:1; 43 uint8_t ver:3, 44 flags:4, 45 A:1; 46 #else 47 uint8_t C:1, 48 R:1, 49 K:1, 50 S:1, 51 s:1, 52 recur:3; 53 uint8_t A:1, 54 flags:4, 55 ver:3; 56 #endif 57 uint16_t protocol_type; 58 uint16_t payload_length; 59 uint16_t call_id; 60 } __attribute__((__packed__)); 61 62 63 /* Common part of the PPTP control packet */ 64 struct pptp_ctrl_header { 65 uint16_t length; 66 uint16_t pptp_message_type; 67 uint32_t magic_cookie; 68 uint16_t control_message_type; 69 uint16_t reserved0; 70 } __attribute__((__packed__)); 71 72 /* Start-Control-Connection-{Request,Reply} packet */ 73 struct pptp_scc { 74 struct pptp_ctrl_header header; 75 uint16_t protocol_version; 76 uint8_t result_code; 77 uint8_t error_code; 78 uint32_t framing_caps; 79 uint32_t bearer_caps; 80 uint16_t max_channels; 81 uint16_t firmware_revision; 82 u_char host_name[64]; 83 u_char vendor_string[64]; 84 } __attribute__((__packed__)); 85 86 /* Outgoing-Call-Request packet */ 87 struct pptp_ocrq { 88 struct pptp_ctrl_header header; 89 uint16_t call_id; 90 uint16_t call_serial_number; 91 uint32_t maximum_bps; 92 uint32_t minimum_bps; 93 uint32_t bearer_type; 94 uint32_t framing_type; 95 uint16_t recv_winsz; 96 uint16_t packet_proccessing_delay; 97 uint16_t phone_number_length; 98 uint16_t reservied1; 99 u_char phone_number[64]; 100 u_char subaddress[64]; 101 } __attribute__((__packed__)); 102 103 /* Outgoing-Call-Reply packet */ 104 struct pptp_ocrp { 105 struct pptp_ctrl_header header; 106 uint16_t call_id; 107 uint16_t peers_call_id; 108 uint8_t result_code; 109 uint8_t error_code; 110 uint16_t cause_code; 111 uint32_t connect_speed; 112 uint16_t recv_winsz; 113 uint16_t packet_proccessing_delay; 114 uint32_t physical_channel_id; 115 } __attribute__((__packed__)); 116 117 /* Echo-Request packet */ 118 struct pptp_echo_rq { 119 struct pptp_ctrl_header header; 120 uint32_t identifier; 121 } __attribute__((__packed__)); 122 123 /* Echo-Reply packet */ 124 struct pptp_echo_rp { 125 struct pptp_ctrl_header header; 126 uint32_t identifier; 127 uint8_t result_code; 128 uint8_t error_code; 129 uint16_t reserved1; 130 } __attribute__((__packed__)); 131 132 /* Set-Link-Info packet */ 133 struct pptp_sli { 134 struct pptp_ctrl_header header; 135 uint16_t peers_call_id; 136 uint16_t reserved; 137 uint32_t send_accm; 138 uint32_t recv_accm; 139 } __attribute__((__packed__)); 140 141 struct pptp_stop_ccrq { 142 struct pptp_ctrl_header header; 143 uint8_t reason; 144 uint8_t reserved1; 145 uint16_t reserved2; 146 } __attribute__((__packed__)); 147 148 struct pptp_stop_ccrp { 149 struct pptp_ctrl_header header; 150 uint8_t result; 151 uint8_t error; 152 uint16_t reserved2; 153 } __attribute__((__packed__)); 154 155 156 /* Call-Clear-Request packet */ 157 struct pptp_ccr { 158 struct pptp_ctrl_header header; 159 uint16_t call_id; 160 uint16_t reserved1; 161 } __attribute__((__packed__)); 162 163 /* Call-Disconnect-Notify packet */ 164 struct pptp_cdn { 165 struct pptp_ctrl_header header; 166 uint16_t call_id; 167 uint8_t result_code; 168 uint8_t error_code; 169 uint16_t cause_code; 170 uint16_t reserved1; 171 char statistics[128]; 172 } __attribute__((__packed__)); 173 174 175 #define PPTP_GRE_PKT_SEQ_PRESENT 0x0001 176 #define PPTP_GRE_PKT_ACK_PRESENT 0x0002 177 178 #endif 179 180