Coverage Report

Created: 2026-07-12 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-pptp.c
Line
Count
Source
1
/* packet-pptp.c
2
 * Routines for the Point-to-Point Tunnelling Protocol (PPTP) (RFC 2637)
3
 * Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
4
 *
5
 * 10/2010 - Rework PPTP Dissector
6
 * Alexis La Goutte <alexis.lagoutte at gmail dot com>
7
 *
8
 * Wireshark - Network traffic analyzer
9
 * By Gerald Combs <gerald@wireshark.org>
10
 * Copyright 1998 Gerald Combs
11
 *
12
 * SPDX-License-Identifier: GPL-2.0-or-later
13
 */
14
15
#include "config.h"
16
17
#include <epan/packet.h>
18
#include <epan/expert.h>
19
20
void proto_register_pptp(void);
21
void proto_reg_handoff_pptp(void);
22
23
static dissector_handle_t pptp_handle;
24
25
static int proto_pptp;
26
static int hf_pptp_length;
27
static int hf_pptp_message_type;
28
static int hf_pptp_magic_cookie;
29
static int hf_pptp_control_message_type;
30
static int hf_pptp_reserved;
31
static int hf_pptp_protocol_version;
32
static int hf_pptp_framing_capabilities;
33
static int hf_pptp_bearer_capabilities;
34
static int hf_pptp_maximum_channels;
35
static int hf_pptp_firmware_revision;
36
static int hf_pptp_host_name;
37
static int hf_pptp_vendor_name;
38
static int hf_pptp_control_result;
39
static int hf_pptp_error;
40
static int hf_pptp_reason;
41
static int hf_pptp_stop_result;
42
static int hf_pptp_identifier;
43
static int hf_pptp_echo_result;
44
static int hf_pptp_call_id;
45
static int hf_pptp_call_serial_number;
46
static int hf_pptp_minimum_bps;
47
static int hf_pptp_maximum_bps;
48
static int hf_pptp_bearer_type;
49
static int hf_pptp_framing_type;
50
static int hf_pptp_packet_receive_window_size;
51
static int hf_pptp_packet_processing_delay;
52
static int hf_pptp_phone_number_length;
53
static int hf_pptp_phone_number;
54
static int hf_pptp_subaddress;
55
static int hf_pptp_peer_call_id;
56
static int hf_pptp_out_result;
57
static int hf_pptp_cause;
58
static int hf_pptp_connect_speed;
59
static int hf_pptp_physical_channel_id;
60
static int hf_pptp_dialed_number_length;
61
static int hf_pptp_dialed_number;
62
static int hf_pptp_dialing_number_length;
63
static int hf_pptp_dialing_number;
64
static int hf_pptp_in_result;
65
static int hf_pptp_disc_result;
66
static int hf_pptp_call_statistics;
67
static int hf_pptp_crc_errors;
68
static int hf_pptp_framing_errors;
69
static int hf_pptp_hardware_overruns;
70
static int hf_pptp_buffer_overruns;
71
static int hf_pptp_timeout_errors;
72
static int hf_pptp_alignment_errors;
73
static int hf_pptp_send_accm;
74
static int hf_pptp_receive_accm;
75
76
static int ett_pptp;
77
78
static expert_field ei_pptp_incorrect_magic_cookie;
79
80
15
#define TCP_PORT_PPTP           1723
81
82
3
#define MAGIC_COOKIE            0x1A2B3C4D
83
84
1
#define CNTRL_REQ       0x01
85
0
#define CNTRL_REPLY     0x02
86
0
#define STOP_REQ        0x03
87
0
#define STOP_REPLY      0x04
88
0
#define ECHO_REQ        0x05
89
1
#define ECHO_REPLY      0x06
90
0
#define OUT_REQ         0x07
91
0
#define OUT_REPLY       0x08
92
0
#define IN_REQ          0x09
93
0
#define IN_REPLY        0x0A
94
0
#define IN_CONNECTED    0x0B
95
0
#define CLEAR_REQ       0x0C
96
0
#define DISC_NOTIFY     0x0D
97
0
#define ERROR_NOTIFY    0x0E
98
0
#define SET_LINK        0x0F
99
100
static const value_string control_message_type_vals[] = {
101
  { CNTRL_REQ,    "Start-Control-Connection-Request" },
102
  { CNTRL_REPLY,  "Start-Control-Connection-Reply" },
103
  { STOP_REQ,     "Stop-Control-Connection-Request" },
104
  { STOP_REPLY,   "Stop-Control-Connection-Reply" },
105
  { ECHO_REQ,     "Echo-Request" },
106
  { ECHO_REPLY,   "Echo-Reply" },
107
  { OUT_REQ,      "Outgoing-Call-Request" },
108
  { OUT_REPLY,    "Outgoing-Call-Reply" },
109
  { IN_REQ,       "Incoming-Call-Request" },
110
  { IN_REPLY,     "Incoming-Call-Reply" },
111
  { IN_CONNECTED, "Incoming-Call-Connected" },
112
  { CLEAR_REQ,    "Call-Clear-Request" },
113
  { DISC_NOTIFY,  "Call-Disconnect-Notify" },
114
  { ERROR_NOTIFY, "WAN-Error-Notify" },
115
  { SET_LINK,     "Set-Link-Info" },
116
  { 0,  NULL },
117
};
118
static const value_string msgtype_vals[] = {
119
  { 1, "Control Message" },
120
  { 2, "Management Message" },
121
  { 0, NULL }
122
};
123
124
static const value_string frametype_vals[] = {
125
  { 1, "Asynchronous Framing supported" },
126
  { 2, "Synchronous Framing supported"},
127
  { 3, "Either Framing supported" },
128
  { 0, NULL }
129
};
130
131
static const value_string bearertype_vals[] = {
132
  { 1, "Analog access supported" },
133
  { 2, "Digital access supported" },
134
  { 3, "Either access supported" },
135
  { 0, NULL }
136
};
137
138
static const value_string control_resulttype_vals[] = {
139
  { 1, "Successful channel establishment" },
140
  { 2, "General error" },
141
  { 3, "Command channel already exists" },
142
  { 4, "Requester not authorized" },
143
  { 5, "Protocol version not supported" },
144
  { 0, NULL }
145
};
146
147
static const value_string errortype_vals[] = {
148
  { 0, "None" },
149
  { 1, "Not-Connected" },
150
  { 2, "Bad-Format" },
151
  { 3, "Bad-Value" },
152
  { 4, "No-Resource" },
153
  { 5, "Bad-Call ID" },
154
  { 6, "PAC-Error" },
155
  { 0, NULL }
156
};
157
158
static const value_string reasontype_vals[] = {
159
  { 1, "None" },
160
  { 2, "Stop-Protocol" },
161
  { 3, "Stop-Local-Shutdown" },
162
  { 0, NULL }
163
};
164
165
static const value_string stop_resulttype_vals[] = {
166
  { 1, "OK" },
167
  { 2, "General error" },
168
  { 0, NULL }
169
};
170
171
static const value_string echo_resulttype_vals[] = {
172
  { 1, "OK" },
173
  { 2, "General error" },
174
  { 0, NULL }
175
};
176
177
static const value_string out_resulttype_vals[] = {
178
  { 1, "Connected" },
179
  { 2, "General Error" },
180
  { 3, "No Carrier" },
181
  { 4, "Busy" },
182
  { 5, "No Dial Tone" },
183
  { 6, "Time-out" },
184
  { 7, "Do Not Accept" },
185
  { 0, NULL }
186
};
187
188
static const value_string in_resulttype_vals[] = {
189
  { 1, "Connect" },
190
  { 2, "General error" },
191
  { 3, "Do Not Accept" },
192
  { 0, NULL }
193
};
194
195
static const value_string disc_resulttype_vals[] = {
196
  { 1, "Lost Carrier" },
197
  { 2, "General Error" },
198
  { 3, "Admin Shutdown" },
199
  { 4, "Request" },
200
  { 0, NULL }
201
};
202
203
static void
204
dissect_unknown(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
205
1
{
206
1
  call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, tree);
207
1
}
208
209
static void
210
dissect_cntrl_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
211
1
{
212
1
  if (!tree)
213
0
    return;
214
215
1
  proto_tree_add_uint_format_value(tree, hf_pptp_protocol_version, tvb, offset,
216
1
                               2, tvb_get_ntohs(tvb, offset), "%u.%u",
217
1
                               tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset + 1));
218
1
  offset += 2;
219
220
1
  proto_tree_add_item(tree, hf_pptp_reserved,             tvb, offset, 2, ENC_NA);
221
1
  offset += 2;
222
223
1
  proto_tree_add_item(tree, hf_pptp_framing_capabilities, tvb, offset, 4, ENC_BIG_ENDIAN);
224
1
  offset += 4;
225
226
1
  proto_tree_add_item(tree, hf_pptp_bearer_capabilities,  tvb, offset, 4, ENC_BIG_ENDIAN);
227
1
  offset += 4;
228
229
1
  proto_tree_add_item(tree, hf_pptp_maximum_channels,     tvb, offset, 2, ENC_BIG_ENDIAN);
230
1
  offset += 2;
231
232
1
  proto_tree_add_item(tree, hf_pptp_firmware_revision,    tvb, offset, 2, ENC_BIG_ENDIAN);
233
1
  offset += 2;
234
235
1
  proto_tree_add_item(tree, hf_pptp_host_name,            tvb, offset, 64, ENC_ASCII);
236
1
  offset += 64;
237
238
1
  proto_tree_add_item(tree, hf_pptp_vendor_name,          tvb, offset, 64, ENC_ASCII);
239
1
}
240
241
static void
242
dissect_cntrl_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
243
0
{
244
0
  if (!tree)
245
0
    return;
246
247
0
  proto_tree_add_uint_format_value(tree, hf_pptp_protocol_version, tvb, offset,
248
0
                               2, tvb_get_ntohs(tvb, offset), "%u.%u",
249
0
                               tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset + 1));
250
0
  offset += 2;
251
252
0
  proto_tree_add_item(tree, hf_pptp_control_result,       tvb, offset, 1, ENC_BIG_ENDIAN);
253
0
  offset += 1;
254
255
0
  proto_tree_add_item(tree, hf_pptp_error,                tvb, offset, 1, ENC_BIG_ENDIAN);
256
0
  offset += 1;
257
258
0
  proto_tree_add_item(tree, hf_pptp_framing_capabilities, tvb, offset, 4, ENC_BIG_ENDIAN);
259
0
  offset += 4;
260
261
0
  proto_tree_add_item(tree, hf_pptp_bearer_capabilities,  tvb, offset, 4, ENC_BIG_ENDIAN);
262
0
  offset += 4;
263
264
0
  proto_tree_add_item(tree, hf_pptp_maximum_channels,     tvb, offset, 2, ENC_BIG_ENDIAN);
265
0
  offset += 2;
266
267
0
  proto_tree_add_item(tree, hf_pptp_firmware_revision,    tvb, offset, 2, ENC_BIG_ENDIAN);
268
0
  offset += 2;
269
270
0
  proto_tree_add_item(tree, hf_pptp_host_name,            tvb, offset, 64, ENC_ASCII);
271
0
  offset += 64;
272
273
0
  proto_tree_add_item(tree, hf_pptp_vendor_name,          tvb, offset, 64, ENC_ASCII);
274
275
0
}
276
277
static void
278
dissect_stop_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
279
0
{
280
0
  if (!tree)
281
0
    return;
282
283
0
  proto_tree_add_item(tree, hf_pptp_reason,   tvb, offset, 1, ENC_BIG_ENDIAN);
284
0
  offset += 1;
285
  /* Reserved1 */
286
0
  proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 1, ENC_NA);
287
0
  offset += 1;
288
  /* Reserved2 */
289
0
  proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
290
0
}
291
292
static void
293
dissect_stop_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
294
0
{
295
0
  if (!tree)
296
0
    return;
297
298
0
  proto_tree_add_item(tree, hf_pptp_stop_result, tvb, offset, 1, ENC_BIG_ENDIAN);
299
0
  offset += 1;
300
301
0
  proto_tree_add_item(tree, hf_pptp_error,       tvb, offset, 1, ENC_BIG_ENDIAN);
302
0
  offset += 1;
303
304
0
  proto_tree_add_item(tree, hf_pptp_reserved,    tvb, offset, 2, ENC_NA);
305
306
0
}
307
308
static void
309
dissect_echo_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
310
0
{
311
0
  if (!tree)
312
0
    return;
313
314
0
  proto_tree_add_item(tree, hf_pptp_identifier, tvb, offset, 4, ENC_BIG_ENDIAN);
315
0
}
316
317
static void
318
dissect_echo_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
319
1
{
320
1
  if (!tree)
321
0
    return;
322
323
1
  proto_tree_add_item(tree, hf_pptp_identifier,  tvb, offset, 4, ENC_BIG_ENDIAN);
324
1
  offset += 4;
325
326
1
  proto_tree_add_item(tree, hf_pptp_echo_result, tvb, offset, 1, ENC_BIG_ENDIAN);
327
1
  offset += 1;
328
329
1
  proto_tree_add_item(tree, hf_pptp_error,       tvb, offset, 1, ENC_BIG_ENDIAN);
330
1
  offset += 1;
331
332
1
  proto_tree_add_item(tree, hf_pptp_reserved,    tvb, offset, 2, ENC_NA);
333
1
}
334
335
static void
336
dissect_out_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
337
0
{
338
0
  if (!tree)
339
0
    return;
340
341
0
  proto_tree_add_item(tree, hf_pptp_call_id,                    tvb, offset, 2, ENC_BIG_ENDIAN);
342
0
  offset += 2;
343
344
0
  proto_tree_add_item(tree, hf_pptp_call_serial_number,         tvb, offset, 2, ENC_BIG_ENDIAN);
345
0
  offset += 2;
346
347
0
  proto_tree_add_item(tree, hf_pptp_minimum_bps,                tvb, offset, 4, ENC_BIG_ENDIAN);
348
0
  offset += 4;
349
350
0
  proto_tree_add_item(tree, hf_pptp_maximum_bps,                tvb, offset, 4, ENC_BIG_ENDIAN);
351
0
  offset += 4;
352
353
0
  proto_tree_add_item(tree, hf_pptp_bearer_type,                tvb, offset, 4, ENC_BIG_ENDIAN);
354
0
  offset += 4;
355
356
0
  proto_tree_add_item(tree, hf_pptp_framing_type,               tvb, offset, 4, ENC_BIG_ENDIAN);
357
0
  offset += 4;
358
359
0
  proto_tree_add_item(tree, hf_pptp_packet_receive_window_size, tvb, offset, 2, ENC_BIG_ENDIAN);
360
0
  offset += 2;
361
362
0
  proto_tree_add_item(tree, hf_pptp_packet_processing_delay,    tvb, offset, 2, ENC_BIG_ENDIAN);
363
0
  offset += 2;
364
365
0
  proto_tree_add_item(tree, hf_pptp_phone_number_length,        tvb, offset, 2, ENC_BIG_ENDIAN);
366
0
  offset += 2;
367
368
0
  proto_tree_add_item(tree, hf_pptp_reserved,                   tvb, offset, 2, ENC_NA);
369
0
  offset += 2;
370
371
0
  proto_tree_add_item(tree, hf_pptp_phone_number,               tvb, offset, 64, ENC_ASCII);
372
0
  offset += 64;
373
374
0
  proto_tree_add_item(tree, hf_pptp_subaddress,                 tvb, offset, 64, ENC_ASCII);
375
0
}
376
377
static void
378
dissect_out_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
379
0
{
380
0
  if (!tree)
381
0
    return;
382
383
0
  proto_tree_add_item(tree, hf_pptp_call_id,                    tvb, offset, 2, ENC_BIG_ENDIAN);
384
0
  offset += 2;
385
386
0
  proto_tree_add_item(tree, hf_pptp_peer_call_id,               tvb, offset, 2, ENC_BIG_ENDIAN);
387
0
  offset += 2;
388
389
0
  proto_tree_add_item(tree, hf_pptp_out_result,                 tvb, offset, 1, ENC_BIG_ENDIAN);
390
0
  offset += 1;
391
392
0
  proto_tree_add_item(tree, hf_pptp_error,                      tvb, offset, 1, ENC_BIG_ENDIAN);
393
0
  offset += 1;
394
395
0
  proto_tree_add_item(tree, hf_pptp_cause,                      tvb, offset, 2, ENC_BIG_ENDIAN);
396
0
  offset += 2;
397
398
0
  proto_tree_add_item(tree, hf_pptp_connect_speed,              tvb, offset, 4, ENC_BIG_ENDIAN);
399
0
  offset += 4;
400
401
0
  proto_tree_add_item(tree, hf_pptp_packet_receive_window_size, tvb, offset, 2, ENC_BIG_ENDIAN);
402
0
  offset += 2;
403
404
0
  proto_tree_add_item(tree, hf_pptp_packet_processing_delay,    tvb, offset, 2, ENC_BIG_ENDIAN);
405
0
  offset += 2;
406
407
0
  proto_tree_add_item(tree, hf_pptp_physical_channel_id,        tvb, offset, 4, ENC_BIG_ENDIAN);
408
0
}
409
410
static void
411
dissect_in_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
412
0
{
413
0
  if (!tree)
414
0
    return;
415
416
0
  proto_tree_add_item(tree, hf_pptp_call_id,               tvb, offset, 2, ENC_BIG_ENDIAN);
417
0
  offset += 2;
418
419
0
  proto_tree_add_item(tree, hf_pptp_call_serial_number,    tvb, offset, 2, ENC_BIG_ENDIAN);
420
0
  offset += 2;
421
422
0
  proto_tree_add_item(tree, hf_pptp_bearer_type,           tvb, offset, 4, ENC_BIG_ENDIAN);
423
0
  offset += 4;
424
425
0
  proto_tree_add_item(tree, hf_pptp_physical_channel_id,   tvb, offset, 4, ENC_BIG_ENDIAN);
426
0
  offset += 4;
427
428
0
  proto_tree_add_item(tree, hf_pptp_dialed_number_length,  tvb, offset, 2, ENC_BIG_ENDIAN);
429
0
  offset += 2;
430
431
0
  proto_tree_add_item(tree, hf_pptp_dialing_number_length, tvb, offset, 2, ENC_BIG_ENDIAN);
432
0
  offset += 2;
433
434
0
  proto_tree_add_item(tree, hf_pptp_dialed_number,         tvb, offset, 64, ENC_ASCII);
435
0
  offset += 64;
436
437
0
  proto_tree_add_item(tree, hf_pptp_dialing_number,        tvb, offset, 64, ENC_ASCII);
438
0
  offset += 64;
439
440
0
  proto_tree_add_item(tree, hf_pptp_subaddress,            tvb, offset, 64, ENC_ASCII);
441
0
}
442
443
static void
444
dissect_in_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
445
0
{
446
0
  if (!tree)
447
0
    return;
448
449
0
  proto_tree_add_item(tree, hf_pptp_call_id,                    tvb, offset, 2, ENC_BIG_ENDIAN);
450
0
  offset += 2;
451
452
0
  proto_tree_add_item(tree, hf_pptp_peer_call_id,               tvb, offset, 2, ENC_BIG_ENDIAN);
453
0
  offset += 2;
454
455
0
  proto_tree_add_item(tree, hf_pptp_in_result,                  tvb, offset, 1, ENC_BIG_ENDIAN);
456
0
  offset += 1;
457
458
0
  proto_tree_add_item(tree, hf_pptp_error,                      tvb, offset, 1, ENC_BIG_ENDIAN);
459
0
  offset += 1;
460
461
0
  proto_tree_add_item(tree, hf_pptp_packet_receive_window_size, tvb, offset, 2, ENC_BIG_ENDIAN);
462
0
  offset += 2;
463
464
0
  proto_tree_add_item(tree, hf_pptp_packet_processing_delay,    tvb, offset, 2, ENC_BIG_ENDIAN);
465
0
  offset += 2;
466
467
0
  proto_tree_add_item(tree, hf_pptp_reserved,                   tvb, offset, 2, ENC_NA);
468
0
}
469
470
static void
471
dissect_in_connected(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
472
0
{
473
0
  if (!tree)
474
0
    return;
475
476
0
  proto_tree_add_item(tree, hf_pptp_peer_call_id,               tvb, offset, 2, ENC_BIG_ENDIAN);
477
0
  offset += 2;
478
479
0
  proto_tree_add_item(tree, hf_pptp_reserved,                   tvb, offset, 2, ENC_NA);
480
0
  offset += 2;
481
482
0
  proto_tree_add_item(tree, hf_pptp_connect_speed,              tvb, offset, 4, ENC_BIG_ENDIAN);
483
0
  offset += 4;
484
485
0
  proto_tree_add_item(tree, hf_pptp_packet_receive_window_size, tvb, offset, 2, ENC_BIG_ENDIAN);
486
0
  offset += 2;
487
488
0
  proto_tree_add_item(tree, hf_pptp_packet_processing_delay,    tvb, offset, 2, ENC_BIG_ENDIAN);
489
0
  offset += 2;
490
491
0
  proto_tree_add_item(tree, hf_pptp_framing_type,               tvb, offset, 4, ENC_BIG_ENDIAN);
492
0
}
493
494
static void
495
dissect_clear_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
496
0
{
497
0
  if (!tree)
498
0
    return;
499
500
0
  proto_tree_add_item(tree, hf_pptp_call_id,  tvb, offset, 2, ENC_BIG_ENDIAN);
501
0
  offset += 2;
502
503
0
  proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
504
0
}
505
506
static void
507
dissect_disc_notify(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
508
0
{
509
0
  if (!tree)
510
0
    return;
511
512
0
  proto_tree_add_item(tree, hf_pptp_call_id,         tvb, offset, 2, ENC_BIG_ENDIAN);
513
0
  offset += 2;
514
515
0
  proto_tree_add_item(tree, hf_pptp_disc_result,     tvb, offset, 1, ENC_BIG_ENDIAN);
516
0
  offset += 1;
517
518
0
  proto_tree_add_item(tree, hf_pptp_error,           tvb, offset, 1, ENC_BIG_ENDIAN);
519
0
  offset += 1;
520
521
0
  proto_tree_add_item(tree, hf_pptp_cause,           tvb, offset, 2, ENC_BIG_ENDIAN);
522
0
  offset += 2;
523
524
0
  proto_tree_add_item(tree, hf_pptp_reserved,        tvb, offset, 2, ENC_NA);
525
0
  offset += 2;
526
527
0
  proto_tree_add_item(tree, hf_pptp_call_statistics, tvb, offset, 64, ENC_ASCII);
528
0
}
529
530
static void
531
dissect_error_notify(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
532
0
{
533
0
  if (!tree)
534
0
    return;
535
536
0
  proto_tree_add_item(tree, hf_pptp_peer_call_id,      tvb, offset, 2, ENC_BIG_ENDIAN);
537
0
  offset += 2;
538
539
0
  proto_tree_add_item(tree, hf_pptp_reserved,          tvb, offset, 2, ENC_NA);
540
0
  offset += 2;
541
542
0
  proto_tree_add_item(tree, hf_pptp_crc_errors,        tvb, offset, 4, ENC_BIG_ENDIAN);
543
0
  offset += 4;
544
545
0
  proto_tree_add_item(tree, hf_pptp_framing_errors,    tvb, offset, 4, ENC_BIG_ENDIAN);
546
0
  offset += 4;
547
548
0
  proto_tree_add_item(tree, hf_pptp_hardware_overruns, tvb, offset, 4, ENC_BIG_ENDIAN);
549
0
  offset += 4;
550
551
0
  proto_tree_add_item(tree, hf_pptp_buffer_overruns,   tvb, offset, 4, ENC_BIG_ENDIAN);
552
0
  offset += 4;
553
554
0
  proto_tree_add_item(tree, hf_pptp_timeout_errors,    tvb, offset, 4, ENC_BIG_ENDIAN);
555
0
  offset += 4;
556
557
0
  proto_tree_add_item(tree, hf_pptp_alignment_errors,  tvb, offset, 4, ENC_BIG_ENDIAN);
558
0
}
559
560
static void
561
dissect_set_link(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
562
0
{
563
0
  if (!tree)
564
0
      return;
565
566
0
  proto_tree_add_item(tree, hf_pptp_peer_call_id, tvb, offset, 2, ENC_BIG_ENDIAN);
567
0
  offset += 2;
568
569
0
  proto_tree_add_item(tree, hf_pptp_reserved,     tvb, offset, 2, ENC_NA);
570
0
  offset += 2;
571
572
0
  proto_tree_add_item(tree, hf_pptp_send_accm,    tvb, offset, 4, ENC_BIG_ENDIAN);
573
0
  offset += 4;
574
575
0
  proto_tree_add_item(tree, hf_pptp_receive_accm, tvb, offset, 4, ENC_BIG_ENDIAN);
576
0
}
577
578
static int
579
dissect_pptp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
580
3
{
581
3
  proto_tree *pptp_tree = NULL;
582
3
  proto_item *item      = NULL;
583
3
  int         offset    = 0;
584
3
  uint16_t    len;
585
3
  uint16_t    control_message_type;
586
587
3
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPTP");
588
3
  col_clear(pinfo->cinfo, COL_INFO);
589
590
3
  len        = tvb_get_ntohs(tvb, offset);
591
3
  control_message_type = tvb_get_ntohs(tvb, offset + 8);
592
593
3
  col_add_str(pinfo->cinfo, COL_INFO,
594
3
              val_to_str(pinfo->pool, control_message_type, control_message_type_vals,
595
3
                         "Unknown control type (%d)"));
596
597
3
  if (tree) {
598
3
    proto_item *ti;
599
600
3
    ti = proto_tree_add_item(tree, proto_pptp, tvb, offset, len, ENC_NA);
601
3
    pptp_tree = proto_item_add_subtree(ti, ett_pptp);
602
603
3
    proto_tree_add_item(pptp_tree, hf_pptp_length, tvb, offset, 2, ENC_BIG_ENDIAN);
604
605
3
    proto_tree_add_item(pptp_tree, hf_pptp_message_type, tvb, offset+2, 2, ENC_BIG_ENDIAN);
606
607
3
    item = proto_tree_add_item(pptp_tree, hf_pptp_magic_cookie, tvb, offset+4, 4, ENC_BIG_ENDIAN);
608
3
  }
609
610
3
  if (tvb_get_ntohl(tvb, offset+4) == MAGIC_COOKIE)
611
0
    proto_item_append_text(item," (correct)");
612
3
  else {
613
3
    proto_item_append_text(item," (incorrect)");
614
3
    expert_add_info(pinfo, item, &ei_pptp_incorrect_magic_cookie);
615
3
  }
616
617
3
  if (tree) {
618
3
    proto_tree_add_item(pptp_tree, hf_pptp_control_message_type, tvb, offset+8, 2, ENC_BIG_ENDIAN);
619
620
3
    proto_tree_add_item(pptp_tree, hf_pptp_reserved, tvb, offset+10, 2, ENC_NA);
621
3
  }
622
623
3
  offset += offset + 12;
624
625
3
  switch(control_message_type){
626
1
    case CNTRL_REQ: /* Start-Control-Connection-Request */
627
1
      dissect_cntrl_req(tvb, offset, pinfo, pptp_tree);
628
1
      break;
629
0
    case CNTRL_REPLY: /* Start-Control-Connection-Reply */
630
0
      dissect_cntrl_reply(tvb, offset, pinfo, pptp_tree);
631
0
      break;
632
0
    case STOP_REQ: /* Stop-Control-Connection-Request */
633
0
      dissect_stop_req(tvb, offset, pinfo, pptp_tree);
634
0
      break;
635
0
    case STOP_REPLY: /* Stop-Control-Connection-Reply */
636
0
      dissect_stop_reply(tvb, offset, pinfo, pptp_tree);
637
0
      break;
638
0
    case ECHO_REQ: /* Echo-Request */
639
0
      dissect_echo_req(tvb, offset, pinfo, pptp_tree);
640
0
      break;
641
1
    case ECHO_REPLY: /* Echo-Reply */
642
1
      dissect_echo_reply(tvb, offset, pinfo, pptp_tree);
643
1
      break;
644
0
    case OUT_REQ: /* Outgoing-Call-Request */
645
0
      dissect_out_req(tvb, offset, pinfo, pptp_tree);
646
0
      break;
647
0
    case OUT_REPLY: /* Outgoing-Call-Reply */
648
0
      dissect_out_reply(tvb, offset, pinfo, pptp_tree);
649
0
      break;
650
0
    case IN_REQ: /* Incoming-Call-Request */
651
0
      dissect_in_req(tvb, offset, pinfo, pptp_tree);
652
0
      break;
653
0
    case IN_REPLY: /* Incoming-Call-Reply */
654
0
      dissect_in_reply(tvb, offset, pinfo, pptp_tree);
655
0
      break;
656
0
    case IN_CONNECTED: /* Incoming-Call-Connected */
657
0
      dissect_in_connected(tvb, offset, pinfo, pptp_tree);
658
0
      break;
659
0
    case CLEAR_REQ: /* Call-Clear-Request */
660
0
      dissect_clear_req(tvb, offset, pinfo, pptp_tree);
661
0
      break;
662
0
    case DISC_NOTIFY: /* Call-Disconnect-Notify */
663
0
      dissect_disc_notify(tvb, offset, pinfo, pptp_tree);
664
0
      break;
665
0
    case ERROR_NOTIFY: /* WAN-Error-Notify */
666
0
      dissect_error_notify(tvb, offset, pinfo, pptp_tree);
667
0
      break;
668
0
    case SET_LINK: /* Set-Link-Info */
669
0
      dissect_set_link(tvb, offset, pinfo, pptp_tree);
670
0
      break;
671
1
    default: /* Unknown Type... */
672
1
      dissect_unknown(tvb, offset, pinfo, pptp_tree);
673
1
      break;
674
3
  }
675
2
  return tvb_captured_length(tvb);
676
3
}
677
678
void
679
proto_register_pptp(void)
680
15
{
681
15
  static int *ett[] = {
682
15
    &ett_pptp,
683
15
  };
684
685
15
  static hf_register_info hf[] = {
686
15
    { &hf_pptp_length,
687
15
      { "Length", "pptp.length",
688
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
689
15
        "Total length in octets of this PPTP message", HFILL }
690
15
    },
691
15
    { &hf_pptp_message_type,
692
15
      { "Message type", "pptp.type",
693
15
        FT_UINT16, BASE_DEC, VALS(msgtype_vals), 0x0,
694
15
        "PPTP message type", HFILL }
695
15
    },
696
15
    { &hf_pptp_magic_cookie,
697
15
      { "Magic Cookie", "pptp.magic_cookie",
698
15
        FT_UINT32, BASE_HEX, NULL, 0x0,
699
15
        "This constant value is used as a sanity check on received messages", HFILL }
700
15
    },
701
15
    { &hf_pptp_control_message_type,
702
15
      { "Control Message Type", "pptp.control_message_type",
703
15
        FT_UINT16, BASE_DEC, VALS(control_message_type_vals), 0x0,
704
15
        NULL, HFILL }
705
15
    },
706
15
    { &hf_pptp_reserved,
707
15
      { "Reserved", "pptp.reserved",
708
15
        FT_BYTES, BASE_NONE, NULL, 0x0,
709
15
        "This field MUST be 0", HFILL }
710
15
    },
711
15
    { &hf_pptp_protocol_version,
712
15
      { "Protocol version", "pptp.protocol_version",
713
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
714
15
        "The version of the PPTP protocol", HFILL }
715
15
    },
716
15
    { &hf_pptp_framing_capabilities,
717
15
      { "Framing Capabilities", "pptp.framing_capabilities",
718
15
        FT_UINT32, BASE_DEC, VALS(frametype_vals), 0x0,
719
15
        "A set of bits indicating the type of framing", HFILL }
720
15
    },
721
15
    { &hf_pptp_bearer_capabilities,
722
15
      { "Bearer Capabilities", "pptp.bearer_capabilities",
723
15
        FT_UINT32, BASE_DEC, VALS(bearertype_vals), 0x0,
724
15
        "A set of bits indicating the type of bearer", HFILL }
725
15
    },
726
15
    { &hf_pptp_maximum_channels,
727
15
      { "Maximum Channels", "pptp.maximum_channels",
728
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
729
15
        "The total number of individual PPP sessions this PAC can support", HFILL }
730
15
    },
731
15
    { &hf_pptp_firmware_revision,
732
15
      { "Firmware Revision", "pptp.firmware_revision",
733
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
734
15
        "This field contains the firmware revision", HFILL }
735
15
    },
736
15
    { &hf_pptp_host_name,
737
15
      { "Host Name", "pptp.host_name",
738
15
        FT_STRING, BASE_NONE, NULL, 0x0,
739
15
        "A 64 octet field containing the DNS name", HFILL }
740
15
    },
741
15
    { &hf_pptp_vendor_name,
742
15
      { "Vendor Name", "pptp.vendor_name",
743
15
        FT_STRING, BASE_NONE, NULL, 0x0,
744
15
        "A 64 octet field containing a vendor", HFILL }
745
15
    },
746
15
    { &hf_pptp_control_result,
747
15
      { "Result Code", "pptp.control_result",
748
15
        FT_UINT8, BASE_DEC, VALS(control_resulttype_vals), 0x0,
749
15
        "Indicates the result of the command channel establishment attempt", HFILL }
750
15
    },
751
15
    { &hf_pptp_error,
752
15
      { "Error Code", "pptp.error",
753
15
        FT_UINT8, BASE_DEC, VALS(errortype_vals), 0x0,
754
15
        NULL, HFILL }
755
15
    },
756
15
    { &hf_pptp_reason,
757
15
      { "Reason", "pptp.reason",
758
15
        FT_UINT8, BASE_DEC, VALS(reasontype_vals), 0x0,
759
15
        "Indicates the reason for the control connection being close", HFILL }
760
15
    },
761
15
    { &hf_pptp_stop_result,
762
15
      { "Result Code", "pptp.stop_result",
763
15
        FT_UINT8, BASE_DEC, VALS(stop_resulttype_vals), 0x0,
764
15
        "Indicates the result of the attempt to close the control connection", HFILL }
765
15
    },
766
15
    { &hf_pptp_identifier,
767
15
      { "Identifier", "pptp.identifier",
768
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
769
15
        NULL, HFILL }
770
15
    },
771
15
    { &hf_pptp_echo_result,
772
15
      { "Result Code", "pptp.echo_result",
773
15
        FT_UINT8, BASE_DEC, VALS(echo_resulttype_vals), 0x0,
774
15
        "Indicates the result of the receipt of the Echo-Request", HFILL }
775
15
    },
776
15
    { &hf_pptp_call_id,
777
15
      { "Call ID", "pptp.call_id",
778
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
779
15
        "A unique identifier, unique to a particular PAC-PNS pair assigned by the PNS", HFILL }
780
15
    },
781
15
    { &hf_pptp_call_serial_number,
782
15
      { "Call Serial Number", "pptp.call_serial_number",
783
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
784
15
        "An identifier assigned by the PNS to this session for the purpose of identifying this particular session in logged session information", HFILL }
785
15
    },
786
15
   { &hf_pptp_minimum_bps,
787
15
     { "Minimum BPS", "pptp.minimum_bps",
788
15
       FT_UINT32, BASE_DEC, NULL, 0x0,
789
15
       "The lowest acceptable line speed (in bits/second) for this session", HFILL }
790
15
   },
791
15
   { &hf_pptp_maximum_bps,
792
15
     { "Maximum BPS", "pptp.maximum_bps",
793
15
       FT_UINT32, BASE_DEC, NULL, 0x0,
794
15
       "The highest acceptable line speed (in bits/second) for this session", HFILL }
795
15
   },
796
15
    { &hf_pptp_framing_type,
797
15
      { "Framing Type", "pptp.framing_type",
798
15
        FT_UINT32, BASE_DEC, VALS(frametype_vals), 0x0,
799
15
        "A value indicating the type of PPP framing to be used for this outgoing call", HFILL }
800
15
    },
801
15
    { &hf_pptp_bearer_type,
802
15
      { "Bearer Type", "pptp.bearer_type",
803
15
        FT_UINT32, BASE_DEC, VALS(bearertype_vals), 0x0,
804
15
        "A value indicating the bearer capability required for this outgoing call", HFILL }
805
15
    },
806
15
    { &hf_pptp_packet_receive_window_size,
807
15
      { "Packet Receive Window Size", "pptp.packet_receive_window_size",
808
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
809
15
        "A unique identifier, unique to a particular PAC-PNS pair assigned by the PNS", HFILL }
810
15
    },
811
15
    { &hf_pptp_packet_processing_delay,
812
15
      { "Packet Processing Delay", "pptp.packet_processing_delay",
813
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
814
15
        "A measure of the packet processing delay that might be imposed on data sent to the PNS from the PAC", HFILL }
815
15
    },
816
15
    { &hf_pptp_phone_number_length,
817
15
      { "Phone Number Length", "pptp.phone_number_length",
818
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
819
15
        "The actual number of valid digits in the Phone Number field", HFILL }
820
15
    },
821
15
    { &hf_pptp_phone_number,
822
15
      { "Phone Number", "pptp.phone_number",
823
15
        FT_STRING, BASE_NONE, NULL, 0x0,
824
15
        "The number to be dialed to establish the outgoing session", HFILL }
825
15
    },
826
15
    { &hf_pptp_subaddress,
827
15
      { "Subaddress", "pptp.subaddress",
828
15
        FT_STRING, BASE_NONE, NULL, 0x0,
829
15
        "A 64 octet field used to specify additional dialing information.", HFILL }
830
15
    },
831
15
    { &hf_pptp_peer_call_id,
832
15
      { "Peer Call ID", "pptp.peer_call_id",
833
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
834
15
        "This field is set to the value received in the Call ID field of the corresponding Outgoing-Call-Request message", HFILL }
835
15
    },
836
15
    { &hf_pptp_out_result,
837
15
      { "Result Code", "pptp.out_result",
838
15
        FT_UINT8, BASE_DEC, VALS(out_resulttype_vals), 0x0,
839
15
        "Indicates the result of the receipt of the Outgoing-Call-Request attempt", HFILL }
840
15
    },
841
15
    { &hf_pptp_cause,
842
15
      { "Cause Code", "pptp.cause",
843
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
844
15
        "This field gives additional information", HFILL }
845
15
    },
846
15
    { &hf_pptp_connect_speed,
847
15
      { "Connect Speed", "pptp.connect_speed",
848
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
849
15
        "The actual connection speed used, in bits/second.", HFILL }
850
15
    },
851
15
    { &hf_pptp_physical_channel_id,
852
15
      { "Physical Channel ID", "pptp.physical_channel_id",
853
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
854
15
        "This field is set by the PAC in a vendor-specific manner to the physical channel number used to place this call", HFILL }
855
15
    },
856
15
    { &hf_pptp_dialed_number_length,
857
15
      { "Dialed Number Length", "pptp.dialed_number_length",
858
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
859
15
        "The actual number of valid digits in the Dialed Number field", HFILL }
860
15
    },
861
15
    { &hf_pptp_dialed_number,
862
15
      { "Dialed Number", "pptp.dialed_number",
863
15
        FT_STRING, BASE_NONE, NULL, 0x0,
864
15
        "The number that was dialed by the caller", HFILL }
865
15
    },
866
867
15
    { &hf_pptp_dialing_number_length,
868
15
      { "Dialing Number Length", "pptp.dialing_number_length",
869
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
870
15
        "The actual number of valid digits in the Dialing Number field", HFILL }
871
15
    },
872
15
    { &hf_pptp_dialing_number,
873
15
      { "Dialing Number", "pptp.dialing_number",
874
15
        FT_STRING, BASE_NONE, NULL, 0x0,
875
15
        "The number from which the call was placed", HFILL }
876
15
    },
877
15
    { &hf_pptp_in_result,
878
15
      { "Result Code", "pptp.in_result",
879
15
        FT_UINT8, BASE_DEC, VALS(in_resulttype_vals), 0x0,
880
15
        "This value indicates the result of the Incoming-Call-Request attempt", HFILL }
881
15
    },
882
15
    { &hf_pptp_disc_result,
883
15
      { "Result Code", "pptp.disc_result",
884
15
        FT_UINT8, BASE_DEC, VALS(disc_resulttype_vals), 0x0,
885
15
        "This value indicates the reason for the disconnect", HFILL }
886
15
    },
887
15
    { &hf_pptp_call_statistics,
888
15
      { "Call Statistics", "pptp.call_Statistics",
889
15
        FT_STRING, BASE_NONE, NULL, 0x0,
890
15
        "This field is an ASCII string containing vendor-specific call statistics that can be logged for diagnostic purpose", HFILL }
891
15
    },
892
15
    { &hf_pptp_crc_errors,
893
15
      { "CRC Errors", "pptp.crc_errors",
894
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
895
15
        "Number of PPP frames received with CRC errors since session was established", HFILL }
896
15
    },
897
15
    { &hf_pptp_framing_errors,
898
15
      { "Framing Errors", "pptp.framing_errors",
899
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
900
15
        "Number of improperly framed PPP packets received", HFILL }
901
15
    },
902
15
    { &hf_pptp_hardware_overruns,
903
15
      { "Hardware overruns", "pptp.hardware_overruns",
904
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
905
15
        "Number of receive buffer over-runs since session was established", HFILL }
906
15
    },
907
15
    { &hf_pptp_buffer_overruns,
908
15
      { "Buffer overruns", "pptp.buffer_overruns",
909
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
910
15
        "Number of buffer over-runs detected since session was established", HFILL }
911
15
    },
912
15
    { &hf_pptp_timeout_errors,
913
15
      { "Time-out Errors", "pptp.timeout_errors",
914
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
915
15
        "Number of time-outs since call was established", HFILL }
916
15
    },
917
15
    { &hf_pptp_alignment_errors,
918
15
      { "Alignment Errors", "pptp.alignment_errors",
919
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
920
15
        "Number of Alignment errors since call was established", HFILL }
921
15
    },
922
15
    { &hf_pptp_send_accm,
923
15
      { "Send ACCM", "pptp.send_accm",
924
15
        FT_UINT32, BASE_HEX, NULL, 0x0,
925
15
        "The send ACCM value the client should use to process outgoing PPP packets", HFILL }
926
15
    },
927
15
    { &hf_pptp_receive_accm,
928
15
      { "Receive ACCM", "pptp.receive_accm",
929
15
        FT_UINT32, BASE_HEX, NULL, 0x0,
930
15
        "The Receive ACCM value the client should use to process incoming PPP packets", HFILL }
931
15
    },
932
15
  };
933
934
15
  static ei_register_info ei[] = {
935
15
     { &ei_pptp_incorrect_magic_cookie, { "pptp.magic_cookie.incorrect", PI_PROTOCOL, PI_WARN, "Incorrect Magic Cookie", EXPFILL }},
936
15
  };
937
938
15
  expert_module_t* expert_pptp;
939
940
15
  proto_pptp = proto_register_protocol("Point-to-Point Tunnelling Protocol",
941
15
                                       "PPTP", "pptp");
942
15
  pptp_handle = register_dissector("pptp", dissect_pptp, proto_pptp);
943
15
  proto_register_field_array(proto_pptp, hf, array_length(hf));
944
15
  proto_register_subtree_array(ett, array_length(ett));
945
15
  expert_pptp = expert_register_protocol(proto_pptp);
946
15
  expert_register_field_array(expert_pptp, ei, array_length(ei));
947
15
}
948
949
void
950
proto_reg_handoff_pptp(void)
951
15
{
952
15
  dissector_add_uint_with_preference("tcp.port", TCP_PORT_PPTP, pptp_handle);
953
15
}
954
955
/*
956
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
957
 *
958
 * Local Variables:
959
 * c-basic-offset: 2
960
 * tab-width: 8
961
 * indent-tabs-mode: nil
962
 * End:
963
 *
964
 * ex: set shiftwidth=2 tabstop=8 expandtab:
965
 * :indentSize=2:tabSize=8:noTabs=true:
966
 */