blob: a4d713d5644cd142e6ad22613072eb659eb75331 [file] [log] [blame]
The Android Open Source Project2949f582009-03-03 19:30:46 -08001/*
2 * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * PPTP support contributed by Motonori Shindo (mshindo@mshindo.net)
22 */
23
Elliott Hughese2e3bd12017-05-15 10:59:29 -070024/* \summary: Point-to-Point Tunnelling Protocol (PPTP) printer */
25
The Android Open Source Project2949f582009-03-03 19:30:46 -080026#ifdef HAVE_CONFIG_H
27#include "config.h"
28#endif
29
Elliott Hughese2e3bd12017-05-15 10:59:29 -070030#include <netdissect-stdinc.h>
The Android Open Source Project2949f582009-03-03 19:30:46 -080031
Elliott Hughese2e3bd12017-05-15 10:59:29 -070032#include "netdissect.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080033#include "extract.h"
34
Elliott Hughes892a68b2015-10-19 14:43:53 -070035static const char tstr[] = " [|pptp]";
The Android Open Source Project2949f582009-03-03 19:30:46 -080036
37#define PPTP_MSG_TYPE_CTRL 1 /* Control Message */
38#define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */
39#define PPTP_MAGIC_COOKIE 0x1a2b3c4d /* for sanity check */
40
41#define PPTP_CTRL_MSG_TYPE_SCCRQ 1
42#define PPTP_CTRL_MSG_TYPE_SCCRP 2
43#define PPTP_CTRL_MSG_TYPE_StopCCRQ 3
44#define PPTP_CTRL_MSG_TYPE_StopCCRP 4
45#define PPTP_CTRL_MSG_TYPE_ECHORQ 5
46#define PPTP_CTRL_MSG_TYPE_ECHORP 6
47#define PPTP_CTRL_MSG_TYPE_OCRQ 7
48#define PPTP_CTRL_MSG_TYPE_OCRP 8
49#define PPTP_CTRL_MSG_TYPE_ICRQ 9
50#define PPTP_CTRL_MSG_TYPE_ICRP 10
51#define PPTP_CTRL_MSG_TYPE_ICCN 11
52#define PPTP_CTRL_MSG_TYPE_CCRQ 12
53#define PPTP_CTRL_MSG_TYPE_CDN 13
54#define PPTP_CTRL_MSG_TYPE_WEN 14
55#define PPTP_CTRL_MSG_TYPE_SLI 15
56
57#define PPTP_FRAMING_CAP_ASYNC_MASK 0x00000001 /* Aynchronous */
58#define PPTP_FRAMING_CAP_SYNC_MASK 0x00000002 /* Synchronous */
59
60#define PPTP_BEARER_CAP_ANALOG_MASK 0x00000001 /* Analog */
61#define PPTP_BEARER_CAP_DIGITAL_MASK 0x00000002 /* Digital */
62
63static const char *pptp_message_type_string[] = {
64 "NOT_DEFINED", /* 0 Not defined in the RFC2637 */
65 "SCCRQ", /* 1 Start-Control-Connection-Request */
66 "SCCRP", /* 2 Start-Control-Connection-Reply */
67 "StopCCRQ", /* 3 Stop-Control-Connection-Request */
68 "StopCCRP", /* 4 Stop-Control-Connection-Reply */
69 "ECHORQ", /* 5 Echo Request */
70 "ECHORP", /* 6 Echo Reply */
71
72 "OCRQ", /* 7 Outgoing-Call-Request */
73 "OCRP", /* 8 Outgoing-Call-Reply */
74 "ICRQ", /* 9 Incoming-Call-Request */
75 "ICRP", /* 10 Incoming-Call-Reply */
76 "ICCN", /* 11 Incoming-Call-Connected */
77 "CCRQ", /* 12 Call-Clear-Request */
78 "CDN", /* 13 Call-Disconnect-Notify */
79
80 "WEN", /* 14 WAN-Error-Notify */
81
82 "SLI" /* 15 Set-Link-Info */
83#define PPTP_MAX_MSGTYPE_INDEX 16
84};
85
86/* common for all PPTP control messages */
87struct pptp_hdr {
Elliott Hughes892a68b2015-10-19 14:43:53 -070088 uint16_t length;
89 uint16_t msg_type;
90 uint32_t magic_cookie;
91 uint16_t ctrl_msg_type;
92 uint16_t reserved0;
The Android Open Source Project2949f582009-03-03 19:30:46 -080093};
94
95struct pptp_msg_sccrq {
Elliott Hughes892a68b2015-10-19 14:43:53 -070096 uint16_t proto_ver;
97 uint16_t reserved1;
98 uint32_t framing_cap;
99 uint32_t bearer_cap;
100 uint16_t max_channel;
101 uint16_t firm_rev;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800102 u_char hostname[64];
103 u_char vendor[64];
104};
105
106struct pptp_msg_sccrp {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700107 uint16_t proto_ver;
108 uint8_t result_code;
109 uint8_t err_code;
110 uint32_t framing_cap;
111 uint32_t bearer_cap;
112 uint16_t max_channel;
113 uint16_t firm_rev;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800114 u_char hostname[64];
115 u_char vendor[64];
116};
117
118struct pptp_msg_stopccrq {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700119 uint8_t reason;
120 uint8_t reserved1;
121 uint16_t reserved2;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800122};
123
124struct pptp_msg_stopccrp {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700125 uint8_t result_code;
126 uint8_t err_code;
127 uint16_t reserved1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800128};
129
130struct pptp_msg_echorq {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700131 uint32_t id;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800132};
133
134struct pptp_msg_echorp {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700135 uint32_t id;
136 uint8_t result_code;
137 uint8_t err_code;
138 uint16_t reserved1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800139};
140
141struct pptp_msg_ocrq {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700142 uint16_t call_id;
143 uint16_t call_ser;
144 uint32_t min_bps;
145 uint32_t max_bps;
146 uint32_t bearer_type;
147 uint32_t framing_type;
148 uint16_t recv_winsiz;
149 uint16_t pkt_proc_delay;
150 uint16_t phone_no_len;
151 uint16_t reserved1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800152 u_char phone_no[64];
153 u_char subaddr[64];
154};
155
156struct pptp_msg_ocrp {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700157 uint16_t call_id;
158 uint16_t peer_call_id;
159 uint8_t result_code;
160 uint8_t err_code;
161 uint16_t cause_code;
162 uint32_t conn_speed;
163 uint16_t recv_winsiz;
164 uint16_t pkt_proc_delay;
165 uint32_t phy_chan_id;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800166};
167
168struct pptp_msg_icrq {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700169 uint16_t call_id;
170 uint16_t call_ser;
171 uint32_t bearer_type;
172 uint32_t phy_chan_id;
173 uint16_t dialed_no_len;
174 uint16_t dialing_no_len;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800175 u_char dialed_no[64]; /* DNIS */
176 u_char dialing_no[64]; /* CLID */
177 u_char subaddr[64];
178};
179
180struct pptp_msg_icrp {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700181 uint16_t call_id;
182 uint16_t peer_call_id;
183 uint8_t result_code;
184 uint8_t err_code;
185 uint16_t recv_winsiz;
186 uint16_t pkt_proc_delay;
187 uint16_t reserved1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800188};
189
190struct pptp_msg_iccn {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700191 uint16_t peer_call_id;
192 uint16_t reserved1;
193 uint32_t conn_speed;
194 uint16_t recv_winsiz;
195 uint16_t pkt_proc_delay;
196 uint32_t framing_type;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800197};
198
199struct pptp_msg_ccrq {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700200 uint16_t call_id;
201 uint16_t reserved1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800202};
203
204struct pptp_msg_cdn {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700205 uint16_t call_id;
206 uint8_t result_code;
207 uint8_t err_code;
208 uint16_t cause_code;
209 uint16_t reserved1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800210 u_char call_stats[128];
211};
212
213struct pptp_msg_wen {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700214 uint16_t peer_call_id;
215 uint16_t reserved1;
216 uint32_t crc_err;
217 uint32_t framing_err;
218 uint32_t hardware_overrun;
219 uint32_t buffer_overrun;
220 uint32_t timeout_err;
221 uint32_t align_err;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800222};
223
224struct pptp_msg_sli {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700225 uint16_t peer_call_id;
226 uint16_t reserved1;
227 uint32_t send_accm;
228 uint32_t recv_accm;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800229};
230
231/* attributes that appear more than once in above messages:
232
233 Number of
234 occurence attributes
235 --------------------------------------
Elliott Hughes892a68b2015-10-19 14:43:53 -0700236 2 uint32_t bearer_cap;
237 2 uint32_t bearer_type;
238 6 uint16_t call_id;
239 2 uint16_t call_ser;
240 2 uint16_t cause_code;
241 2 uint32_t conn_speed;
242 6 uint8_t err_code;
243 2 uint16_t firm_rev;
244 2 uint32_t framing_cap;
245 2 uint32_t framing_type;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800246 2 u_char hostname[64];
Elliott Hughes892a68b2015-10-19 14:43:53 -0700247 2 uint32_t id;
248 2 uint16_t max_channel;
249 5 uint16_t peer_call_id;
250 2 uint32_t phy_chan_id;
251 4 uint16_t pkt_proc_delay;
252 2 uint16_t proto_ver;
253 4 uint16_t recv_winsiz;
254 2 uint8_t reserved1;
255 9 uint16_t reserved1;
256 6 uint8_t result_code;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800257 2 u_char subaddr[64];
258 2 u_char vendor[64];
259
260 so I will prepare print out functions for these attributes (except for
261 reserved*).
262*/
263
264/******************************************/
265/* Attribute-specific print out functions */
266/******************************************/
267
268/* In these attribute-specific print-out functions, it't not necessary
Elliott Hughes892a68b2015-10-19 14:43:53 -0700269 to do ND_TCHECK because they are already checked in the caller of
The Android Open Source Project2949f582009-03-03 19:30:46 -0800270 these functions. */
271
272static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700273pptp_bearer_cap_print(netdissect_options *ndo,
274 const uint32_t *bearer_cap)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800275{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700276 ND_PRINT((ndo, " BEARER_CAP(%s%s)",
277 EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK ? "D" : "",
278 EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK ? "A" : ""));
279}
280
281static const struct tok pptp_btype_str[] = {
282 { 1, "A" }, /* Analog */
283 { 2, "D" }, /* Digital */
284 { 3, "Any" },
285 { 0, NULL }
286};
287
288static void
289pptp_bearer_type_print(netdissect_options *ndo,
290 const uint32_t *bearer_type)
291{
292 ND_PRINT((ndo, " BEARER_TYPE(%s)",
293 tok2str(pptp_btype_str, "?", EXTRACT_32BITS(bearer_type))));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800294}
295
296static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700297pptp_call_id_print(netdissect_options *ndo,
298 const uint16_t *call_id)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800299{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700300 ND_PRINT((ndo, " CALL_ID(%u)", EXTRACT_16BITS(call_id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800301}
302
303static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700304pptp_call_ser_print(netdissect_options *ndo,
305 const uint16_t *call_ser)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800306{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700307 ND_PRINT((ndo, " CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800308}
309
310static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700311pptp_cause_code_print(netdissect_options *ndo,
312 const uint16_t *cause_code)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800313{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700314 ND_PRINT((ndo, " CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800315}
316
317static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700318pptp_conn_speed_print(netdissect_options *ndo,
319 const uint32_t *conn_speed)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800320{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700321 ND_PRINT((ndo, " CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800322}
323
Elliott Hughes892a68b2015-10-19 14:43:53 -0700324static const struct tok pptp_errcode_str[] = {
325 { 0, "None" },
326 { 1, "Not-Connected" },
327 { 2, "Bad-Format" },
328 { 3, "Bad-Value" },
329 { 4, "No-Resource" },
330 { 5, "Bad-Call-ID" },
331 { 6, "PAC-Error" },
332 { 0, NULL }
333};
The Android Open Source Project2949f582009-03-03 19:30:46 -0800334
335static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700336pptp_err_code_print(netdissect_options *ndo,
337 const uint8_t *err_code)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800338{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700339 ND_PRINT((ndo, " ERR_CODE(%u", *err_code));
340 if (ndo->ndo_vflag) {
341 ND_PRINT((ndo, ":%s", tok2str(pptp_errcode_str, "?", *err_code)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800342 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700343 ND_PRINT((ndo, ")"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800344}
345
346static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700347pptp_firm_rev_print(netdissect_options *ndo,
348 const uint16_t *firm_rev)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800349{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700350 ND_PRINT((ndo, " FIRM_REV(%u)", EXTRACT_16BITS(firm_rev)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800351}
352
353static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700354pptp_framing_cap_print(netdissect_options *ndo,
355 const uint32_t *framing_cap)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800356{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700357 ND_PRINT((ndo, " FRAME_CAP("));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800358 if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700359 ND_PRINT((ndo, "A")); /* Async */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800360 }
361 if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700362 ND_PRINT((ndo, "S")); /* Sync */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800363 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700364 ND_PRINT((ndo, ")"));
365}
366
367static const struct tok pptp_ftype_str[] = {
368 { 1, "A" }, /* Async */
369 { 2, "S" }, /* Sync */
370 { 3, "E" }, /* Either */
371 { 0, NULL }
372};
373
374static void
375pptp_framing_type_print(netdissect_options *ndo,
376 const uint32_t *framing_type)
377{
378 ND_PRINT((ndo, " FRAME_TYPE(%s)",
379 tok2str(pptp_ftype_str, "?", EXTRACT_32BITS(framing_type))));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800380}
381
382static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700383pptp_hostname_print(netdissect_options *ndo,
384 const u_char *hostname)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800385{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700386 ND_PRINT((ndo, " HOSTNAME(%.64s)", hostname));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800387}
388
389static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700390pptp_id_print(netdissect_options *ndo,
391 const uint32_t *id)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800392{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700393 ND_PRINT((ndo, " ID(%u)", EXTRACT_32BITS(id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800394}
395
396static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700397pptp_max_channel_print(netdissect_options *ndo,
398 const uint16_t *max_channel)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800399{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700400 ND_PRINT((ndo, " MAX_CHAN(%u)", EXTRACT_16BITS(max_channel)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800401}
402
403static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700404pptp_peer_call_id_print(netdissect_options *ndo,
405 const uint16_t *peer_call_id)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800406{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700407 ND_PRINT((ndo, " PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800408}
409
410static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700411pptp_phy_chan_id_print(netdissect_options *ndo,
412 const uint32_t *phy_chan_id)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800413{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700414 ND_PRINT((ndo, " PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800415}
416
417static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700418pptp_pkt_proc_delay_print(netdissect_options *ndo,
419 const uint16_t *pkt_proc_delay)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800420{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700421 ND_PRINT((ndo, " PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800422}
423
424static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700425pptp_proto_ver_print(netdissect_options *ndo,
426 const uint16_t *proto_ver)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800427{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700428 ND_PRINT((ndo, " PROTO_VER(%u.%u)", /* Version.Revision */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800429 EXTRACT_16BITS(proto_ver) >> 8,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700430 EXTRACT_16BITS(proto_ver) & 0xff));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800431}
432
433static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700434pptp_recv_winsiz_print(netdissect_options *ndo,
435 const uint16_t *recv_winsiz)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800436{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700437 ND_PRINT((ndo, " RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800438}
439
Elliott Hughes892a68b2015-10-19 14:43:53 -0700440static const struct tok pptp_scrrp_str[] = {
441 { 1, "Successful channel establishment" },
442 { 2, "General error" },
443 { 3, "Command channel already exists" },
444 { 4, "Requester is not authorized to establish a command channel" },
445 { 5, "The protocol version of the requester is not supported" },
446 { 0, NULL }
447};
448
449static const struct tok pptp_echorp_str[] = {
450 { 1, "OK" },
451 { 2, "General Error" },
452 { 0, NULL }
453};
454
455static const struct tok pptp_ocrp_str[] = {
456 { 1, "Connected" },
457 { 2, "General Error" },
458 { 3, "No Carrier" },
459 { 4, "Busy" },
460 { 5, "No Dial Tone" },
461 { 6, "Time-out" },
462 { 7, "Do Not Accept" },
463 { 0, NULL }
464};
465
466static const struct tok pptp_icrp_str[] = {
467 { 1, "Connect" },
468 { 2, "General Error" },
469 { 3, "Do Not Accept" },
470 { 0, NULL }
471};
472
473static const struct tok pptp_cdn_str[] = {
474 { 1, "Lost Carrier" },
475 { 2, "General Error" },
476 { 3, "Admin Shutdown" },
477 { 4, "Request" },
478 { 0, NULL }
479};
480
The Android Open Source Project2949f582009-03-03 19:30:46 -0800481static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700482pptp_result_code_print(netdissect_options *ndo,
483 const uint8_t *result_code, int ctrl_msg_type)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800484{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700485 ND_PRINT((ndo, " RESULT_CODE(%u", *result_code));
486 if (ndo->ndo_vflag) {
487 const struct tok *dict =
488 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_SCCRP ? pptp_scrrp_str :
489 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_StopCCRP ? pptp_echorp_str :
490 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ECHORP ? pptp_echorp_str :
491 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_OCRP ? pptp_ocrp_str :
492 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ICRP ? pptp_icrp_str :
493 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_CDN ? pptp_cdn_str :
494 NULL; /* assertion error */
495 if (dict != NULL)
496 ND_PRINT((ndo, ":%s", tok2str(dict, "?", *result_code)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800497 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700498 ND_PRINT((ndo, ")"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800499}
500
501static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700502pptp_subaddr_print(netdissect_options *ndo,
503 const u_char *subaddr)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800504{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700505 ND_PRINT((ndo, " SUB_ADDR(%.64s)", subaddr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800506}
507
508static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700509pptp_vendor_print(netdissect_options *ndo,
510 const u_char *vendor)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800511{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700512 ND_PRINT((ndo, " VENDOR(%.64s)", vendor));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800513}
514
515/************************************/
516/* PPTP message print out functions */
517/************************************/
518static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700519pptp_sccrq_print(netdissect_options *ndo,
520 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800521{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700522 const struct pptp_msg_sccrq *ptr = (const struct pptp_msg_sccrq *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800523
Elliott Hughes892a68b2015-10-19 14:43:53 -0700524 ND_TCHECK(ptr->proto_ver);
525 pptp_proto_ver_print(ndo, &ptr->proto_ver);
526 ND_TCHECK(ptr->reserved1);
527 ND_TCHECK(ptr->framing_cap);
528 pptp_framing_cap_print(ndo, &ptr->framing_cap);
529 ND_TCHECK(ptr->bearer_cap);
530 pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
531 ND_TCHECK(ptr->max_channel);
532 pptp_max_channel_print(ndo, &ptr->max_channel);
533 ND_TCHECK(ptr->firm_rev);
534 pptp_firm_rev_print(ndo, &ptr->firm_rev);
535 ND_TCHECK(ptr->hostname);
536 pptp_hostname_print(ndo, &ptr->hostname[0]);
537 ND_TCHECK(ptr->vendor);
538 pptp_vendor_print(ndo, &ptr->vendor[0]);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800539
540 return;
541
542trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700543 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800544}
545
546static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700547pptp_sccrp_print(netdissect_options *ndo,
548 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800549{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700550 const struct pptp_msg_sccrp *ptr = (const struct pptp_msg_sccrp *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800551
Elliott Hughes892a68b2015-10-19 14:43:53 -0700552 ND_TCHECK(ptr->proto_ver);
553 pptp_proto_ver_print(ndo, &ptr->proto_ver);
554 ND_TCHECK(ptr->result_code);
555 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
556 ND_TCHECK(ptr->err_code);
557 pptp_err_code_print(ndo, &ptr->err_code);
558 ND_TCHECK(ptr->framing_cap);
559 pptp_framing_cap_print(ndo, &ptr->framing_cap);
560 ND_TCHECK(ptr->bearer_cap);
561 pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
562 ND_TCHECK(ptr->max_channel);
563 pptp_max_channel_print(ndo, &ptr->max_channel);
564 ND_TCHECK(ptr->firm_rev);
565 pptp_firm_rev_print(ndo, &ptr->firm_rev);
566 ND_TCHECK(ptr->hostname);
567 pptp_hostname_print(ndo, &ptr->hostname[0]);
568 ND_TCHECK(ptr->vendor);
569 pptp_vendor_print(ndo, &ptr->vendor[0]);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800570
571 return;
572
573trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700574 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800575}
576
577static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700578pptp_stopccrq_print(netdissect_options *ndo,
579 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800580{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700581 const struct pptp_msg_stopccrq *ptr = (const struct pptp_msg_stopccrq *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800582
Elliott Hughes892a68b2015-10-19 14:43:53 -0700583 ND_TCHECK(ptr->reason);
584 ND_PRINT((ndo, " REASON(%u", ptr->reason));
585 if (ndo->ndo_vflag) {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800586 switch (ptr->reason) {
587 case 1:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700588 ND_PRINT((ndo, ":None"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800589 break;
590 case 2:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700591 ND_PRINT((ndo, ":Stop-Protocol"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800592 break;
593 case 3:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700594 ND_PRINT((ndo, ":Stop-Local-Shutdown"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800595 break;
596 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700597 ND_PRINT((ndo, ":?"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800598 break;
599 }
600 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700601 ND_PRINT((ndo, ")"));
602 ND_TCHECK(ptr->reserved1);
603 ND_TCHECK(ptr->reserved2);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800604
605 return;
606
607trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700608 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800609}
610
611static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700612pptp_stopccrp_print(netdissect_options *ndo,
613 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800614{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700615 const struct pptp_msg_stopccrp *ptr = (const struct pptp_msg_stopccrp *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800616
Elliott Hughes892a68b2015-10-19 14:43:53 -0700617 ND_TCHECK(ptr->result_code);
618 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
619 ND_TCHECK(ptr->err_code);
620 pptp_err_code_print(ndo, &ptr->err_code);
621 ND_TCHECK(ptr->reserved1);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800622
623 return;
624
625trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700626 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800627}
628
629static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700630pptp_echorq_print(netdissect_options *ndo,
631 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800632{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700633 const struct pptp_msg_echorq *ptr = (const struct pptp_msg_echorq *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800634
Elliott Hughes892a68b2015-10-19 14:43:53 -0700635 ND_TCHECK(ptr->id);
636 pptp_id_print(ndo, &ptr->id);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800637
638 return;
639
640trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700641 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800642}
643
644static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700645pptp_echorp_print(netdissect_options *ndo,
646 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800647{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700648 const struct pptp_msg_echorp *ptr = (const struct pptp_msg_echorp *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800649
Elliott Hughes892a68b2015-10-19 14:43:53 -0700650 ND_TCHECK(ptr->id);
651 pptp_id_print(ndo, &ptr->id);
652 ND_TCHECK(ptr->result_code);
653 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
654 ND_TCHECK(ptr->err_code);
655 pptp_err_code_print(ndo, &ptr->err_code);
656 ND_TCHECK(ptr->reserved1);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800657
658 return;
659
660trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700661 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800662}
663
664static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700665pptp_ocrq_print(netdissect_options *ndo,
666 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800667{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700668 const struct pptp_msg_ocrq *ptr = (const struct pptp_msg_ocrq *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800669
Elliott Hughes892a68b2015-10-19 14:43:53 -0700670 ND_TCHECK(ptr->call_id);
671 pptp_call_id_print(ndo, &ptr->call_id);
672 ND_TCHECK(ptr->call_ser);
673 pptp_call_ser_print(ndo, &ptr->call_ser);
674 ND_TCHECK(ptr->min_bps);
675 ND_PRINT((ndo, " MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps)));
676 ND_TCHECK(ptr->max_bps);
677 ND_PRINT((ndo, " MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps)));
678 ND_TCHECK(ptr->bearer_type);
679 pptp_bearer_type_print(ndo, &ptr->bearer_type);
680 ND_TCHECK(ptr->framing_type);
681 pptp_framing_type_print(ndo, &ptr->framing_type);
682 ND_TCHECK(ptr->recv_winsiz);
683 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
684 ND_TCHECK(ptr->pkt_proc_delay);
685 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
686 ND_TCHECK(ptr->phone_no_len);
687 ND_PRINT((ndo, " PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len)));
688 ND_TCHECK(ptr->reserved1);
689 ND_TCHECK(ptr->phone_no);
690 ND_PRINT((ndo, " PHONE_NO(%.64s)", ptr->phone_no));
691 ND_TCHECK(ptr->subaddr);
692 pptp_subaddr_print(ndo, &ptr->subaddr[0]);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800693
694 return;
695
696trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700697 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800698}
699
700static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700701pptp_ocrp_print(netdissect_options *ndo,
702 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800703{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700704 const struct pptp_msg_ocrp *ptr = (const struct pptp_msg_ocrp *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800705
Elliott Hughes892a68b2015-10-19 14:43:53 -0700706 ND_TCHECK(ptr->call_id);
707 pptp_call_id_print(ndo, &ptr->call_id);
708 ND_TCHECK(ptr->peer_call_id);
709 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
710 ND_TCHECK(ptr->result_code);
711 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
712 ND_TCHECK(ptr->err_code);
713 pptp_err_code_print(ndo, &ptr->err_code);
714 ND_TCHECK(ptr->cause_code);
715 pptp_cause_code_print(ndo, &ptr->cause_code);
716 ND_TCHECK(ptr->conn_speed);
717 pptp_conn_speed_print(ndo, &ptr->conn_speed);
718 ND_TCHECK(ptr->recv_winsiz);
719 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
720 ND_TCHECK(ptr->pkt_proc_delay);
721 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
722 ND_TCHECK(ptr->phy_chan_id);
723 pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800724
725 return;
726
727trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700728 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800729}
730
731static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700732pptp_icrq_print(netdissect_options *ndo,
733 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800734{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700735 const struct pptp_msg_icrq *ptr = (const struct pptp_msg_icrq *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800736
Elliott Hughes892a68b2015-10-19 14:43:53 -0700737 ND_TCHECK(ptr->call_id);
738 pptp_call_id_print(ndo, &ptr->call_id);
739 ND_TCHECK(ptr->call_ser);
740 pptp_call_ser_print(ndo, &ptr->call_ser);
741 ND_TCHECK(ptr->bearer_type);
742 pptp_bearer_type_print(ndo, &ptr->bearer_type);
743 ND_TCHECK(ptr->phy_chan_id);
744 pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
745 ND_TCHECK(ptr->dialed_no_len);
746 ND_PRINT((ndo, " DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len)));
747 ND_TCHECK(ptr->dialing_no_len);
748 ND_PRINT((ndo, " DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len)));
749 ND_TCHECK(ptr->dialed_no);
750 ND_PRINT((ndo, " DIALED_NO(%.64s)", ptr->dialed_no));
751 ND_TCHECK(ptr->dialing_no);
752 ND_PRINT((ndo, " DIALING_NO(%.64s)", ptr->dialing_no));
753 ND_TCHECK(ptr->subaddr);
754 pptp_subaddr_print(ndo, &ptr->subaddr[0]);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800755
756 return;
757
758trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700759 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800760}
761
762static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700763pptp_icrp_print(netdissect_options *ndo,
764 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800765{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700766 const struct pptp_msg_icrp *ptr = (const struct pptp_msg_icrp *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800767
Elliott Hughes892a68b2015-10-19 14:43:53 -0700768 ND_TCHECK(ptr->call_id);
769 pptp_call_id_print(ndo, &ptr->call_id);
770 ND_TCHECK(ptr->peer_call_id);
771 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
772 ND_TCHECK(ptr->result_code);
773 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
774 ND_TCHECK(ptr->err_code);
775 pptp_err_code_print(ndo, &ptr->err_code);
776 ND_TCHECK(ptr->recv_winsiz);
777 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
778 ND_TCHECK(ptr->pkt_proc_delay);
779 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
780 ND_TCHECK(ptr->reserved1);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800781
782 return;
783
784trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700785 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800786}
787
788static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700789pptp_iccn_print(netdissect_options *ndo,
790 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800791{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700792 const struct pptp_msg_iccn *ptr = (const struct pptp_msg_iccn *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800793
Elliott Hughes892a68b2015-10-19 14:43:53 -0700794 ND_TCHECK(ptr->peer_call_id);
795 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
796 ND_TCHECK(ptr->reserved1);
797 ND_TCHECK(ptr->conn_speed);
798 pptp_conn_speed_print(ndo, &ptr->conn_speed);
799 ND_TCHECK(ptr->recv_winsiz);
800 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
801 ND_TCHECK(ptr->pkt_proc_delay);
802 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
803 ND_TCHECK(ptr->framing_type);
804 pptp_framing_type_print(ndo, &ptr->framing_type);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800805
806 return;
807
808trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700809 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800810}
811
812static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700813pptp_ccrq_print(netdissect_options *ndo,
814 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800815{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700816 const struct pptp_msg_ccrq *ptr = (const struct pptp_msg_ccrq *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800817
Elliott Hughes892a68b2015-10-19 14:43:53 -0700818 ND_TCHECK(ptr->call_id);
819 pptp_call_id_print(ndo, &ptr->call_id);
820 ND_TCHECK(ptr->reserved1);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800821
822 return;
823
824trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700825 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800826}
827
828static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700829pptp_cdn_print(netdissect_options *ndo,
830 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800831{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700832 const struct pptp_msg_cdn *ptr = (const struct pptp_msg_cdn *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800833
Elliott Hughes892a68b2015-10-19 14:43:53 -0700834 ND_TCHECK(ptr->call_id);
835 pptp_call_id_print(ndo, &ptr->call_id);
836 ND_TCHECK(ptr->result_code);
837 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
838 ND_TCHECK(ptr->err_code);
839 pptp_err_code_print(ndo, &ptr->err_code);
840 ND_TCHECK(ptr->cause_code);
841 pptp_cause_code_print(ndo, &ptr->cause_code);
842 ND_TCHECK(ptr->reserved1);
843 ND_TCHECK(ptr->call_stats);
844 ND_PRINT((ndo, " CALL_STATS(%.128s)", ptr->call_stats));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800845
846 return;
847
848trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700849 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800850}
851
852static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700853pptp_wen_print(netdissect_options *ndo,
854 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800855{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700856 const struct pptp_msg_wen *ptr = (const struct pptp_msg_wen *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800857
Elliott Hughes892a68b2015-10-19 14:43:53 -0700858 ND_TCHECK(ptr->peer_call_id);
859 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
860 ND_TCHECK(ptr->reserved1);
861 ND_TCHECK(ptr->crc_err);
862 ND_PRINT((ndo, " CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err)));
863 ND_TCHECK(ptr->framing_err);
864 ND_PRINT((ndo, " FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err)));
865 ND_TCHECK(ptr->hardware_overrun);
866 ND_PRINT((ndo, " HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun)));
867 ND_TCHECK(ptr->buffer_overrun);
868 ND_PRINT((ndo, " BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun)));
869 ND_TCHECK(ptr->timeout_err);
870 ND_PRINT((ndo, " TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err)));
871 ND_TCHECK(ptr->align_err);
872 ND_PRINT((ndo, " ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800873
874 return;
875
876trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700877 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800878}
879
880static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700881pptp_sli_print(netdissect_options *ndo,
882 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800883{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700884 const struct pptp_msg_sli *ptr = (const struct pptp_msg_sli *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800885
Elliott Hughes892a68b2015-10-19 14:43:53 -0700886 ND_TCHECK(ptr->peer_call_id);
887 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
888 ND_TCHECK(ptr->reserved1);
889 ND_TCHECK(ptr->send_accm);
890 ND_PRINT((ndo, " SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm)));
891 ND_TCHECK(ptr->recv_accm);
892 ND_PRINT((ndo, " RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800893
894 return;
895
896trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700897 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800898}
899
900void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700901pptp_print(netdissect_options *ndo,
902 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800903{
904 const struct pptp_hdr *hdr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700905 uint32_t mc;
906 uint16_t ctrl_msg_type;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800907
Elliott Hughes892a68b2015-10-19 14:43:53 -0700908 ND_PRINT((ndo, ": pptp"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800909
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700910 hdr = (const struct pptp_hdr *)dat;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800911
Elliott Hughes892a68b2015-10-19 14:43:53 -0700912 ND_TCHECK(hdr->length);
913 if (ndo->ndo_vflag) {
914 ND_PRINT((ndo, " Length=%u", EXTRACT_16BITS(&hdr->length)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800915 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700916 ND_TCHECK(hdr->msg_type);
917 if (ndo->ndo_vflag) {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800918 switch(EXTRACT_16BITS(&hdr->msg_type)) {
919 case PPTP_MSG_TYPE_CTRL:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700920 ND_PRINT((ndo, " CTRL-MSG"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800921 break;
922 case PPTP_MSG_TYPE_MGMT:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700923 ND_PRINT((ndo, " MGMT-MSG"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800924 break;
925 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700926 ND_PRINT((ndo, " UNKNOWN-MSG-TYPE"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800927 break;
928 }
929 }
930
Elliott Hughes892a68b2015-10-19 14:43:53 -0700931 ND_TCHECK(hdr->magic_cookie);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800932 mc = EXTRACT_32BITS(&hdr->magic_cookie);
933 if (mc != PPTP_MAGIC_COOKIE) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700934 ND_PRINT((ndo, " UNEXPECTED Magic-Cookie!!(%08x)", mc));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800935 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700936 if (ndo->ndo_vflag || mc != PPTP_MAGIC_COOKIE) {
937 ND_PRINT((ndo, " Magic-Cookie=%08x", mc));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800938 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700939 ND_TCHECK(hdr->ctrl_msg_type);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800940 ctrl_msg_type = EXTRACT_16BITS(&hdr->ctrl_msg_type);
941 if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700942 ND_PRINT((ndo, " CTRL_MSGTYPE=%s",
943 pptp_message_type_string[ctrl_msg_type]));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800944 } else {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700945 ND_PRINT((ndo, " UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800946 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700947 ND_TCHECK(hdr->reserved0);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800948
949 dat += 12;
950
951 switch(ctrl_msg_type) {
952 case PPTP_CTRL_MSG_TYPE_SCCRQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700953 pptp_sccrq_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800954 break;
955 case PPTP_CTRL_MSG_TYPE_SCCRP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700956 pptp_sccrp_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800957 break;
958 case PPTP_CTRL_MSG_TYPE_StopCCRQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700959 pptp_stopccrq_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800960 break;
961 case PPTP_CTRL_MSG_TYPE_StopCCRP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700962 pptp_stopccrp_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800963 break;
964 case PPTP_CTRL_MSG_TYPE_ECHORQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700965 pptp_echorq_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800966 break;
967 case PPTP_CTRL_MSG_TYPE_ECHORP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700968 pptp_echorp_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800969 break;
970 case PPTP_CTRL_MSG_TYPE_OCRQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700971 pptp_ocrq_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800972 break;
973 case PPTP_CTRL_MSG_TYPE_OCRP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700974 pptp_ocrp_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800975 break;
976 case PPTP_CTRL_MSG_TYPE_ICRQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700977 pptp_icrq_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800978 break;
979 case PPTP_CTRL_MSG_TYPE_ICRP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700980 pptp_icrp_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800981 break;
982 case PPTP_CTRL_MSG_TYPE_ICCN:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700983 pptp_iccn_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800984 break;
985 case PPTP_CTRL_MSG_TYPE_CCRQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700986 pptp_ccrq_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800987 break;
988 case PPTP_CTRL_MSG_TYPE_CDN:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700989 pptp_cdn_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800990 break;
991 case PPTP_CTRL_MSG_TYPE_WEN:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700992 pptp_wen_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800993 break;
994 case PPTP_CTRL_MSG_TYPE_SLI:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700995 pptp_sli_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800996 break;
997 default:
998 /* do nothing */
999 break;
1000 }
1001
1002 return;
1003
1004trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001005 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001006}