Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-pptp.c
blobea9662590fb48a75bfd22f9a536deebad5ed62ed
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>
5 * 10/2010 - Rework PPTP Dissector
6 * Alexis La Goutte <alexis.lagoutte at gmail dot com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include "config.h"
17 #include <epan/packet.h>
18 #include <epan/expert.h>
20 void proto_register_pptp(void);
21 void proto_reg_handoff_pptp(void);
23 static dissector_handle_t pptp_handle;
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;
76 static int ett_pptp;
78 static expert_field ei_pptp_incorrect_magic_cookie;
80 #define TCP_PORT_PPTP 1723
82 #define MAGIC_COOKIE 0x1A2B3C4D
84 #define CNTRL_REQ 0x01
85 #define CNTRL_REPLY 0x02
86 #define STOP_REQ 0x03
87 #define STOP_REPLY 0x04
88 #define ECHO_REQ 0x05
89 #define ECHO_REPLY 0x06
90 #define OUT_REQ 0x07
91 #define OUT_REPLY 0x08
92 #define IN_REQ 0x09
93 #define IN_REPLY 0x0A
94 #define IN_CONNECTED 0x0B
95 #define CLEAR_REQ 0x0C
96 #define DISC_NOTIFY 0x0D
97 #define ERROR_NOTIFY 0x0E
98 #define SET_LINK 0x0F
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 },
118 static const value_string msgtype_vals[] = {
119 { 1, "Control Message" },
120 { 2, "Management Message" },
121 { 0, NULL }
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 }
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 }
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 }
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 }
158 static const value_string reasontype_vals[] = {
159 { 1, "None" },
160 { 2, "Stop-Protocol" },
161 { 3, "Stop-Local-Shutdown" },
162 { 0, NULL }
165 static const value_string stop_resulttype_vals[] = {
166 { 1, "OK" },
167 { 2, "General error" },
168 { 0, NULL }
171 static const value_string echo_resulttype_vals[] = {
172 { 1, "OK" },
173 { 2, "General error" },
174 { 0, NULL }
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 }
188 static const value_string in_resulttype_vals[] = {
189 { 1, "Connect" },
190 { 2, "General error" },
191 { 3, "Do Not Accept" },
192 { 0, NULL }
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 }
203 static void
204 dissect_unknown(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
206 call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, tree);
209 static void
210 dissect_cntrl_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
212 if (!tree)
213 return;
215 proto_tree_add_uint_format_value(tree, hf_pptp_protocol_version, tvb, offset,
216 2, tvb_get_ntohs(tvb, offset), "%u.%u",
217 tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset + 1));
218 offset += 2;
220 proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
221 offset += 2;
223 proto_tree_add_item(tree, hf_pptp_framing_capabilities, tvb, offset, 4, ENC_BIG_ENDIAN);
224 offset += 4;
226 proto_tree_add_item(tree, hf_pptp_bearer_capabilities, tvb, offset, 4, ENC_BIG_ENDIAN);
227 offset += 4;
229 proto_tree_add_item(tree, hf_pptp_maximum_channels, tvb, offset, 2, ENC_BIG_ENDIAN);
230 offset += 2;
232 proto_tree_add_item(tree, hf_pptp_firmware_revision, tvb, offset, 2, ENC_BIG_ENDIAN);
233 offset += 2;
235 proto_tree_add_item(tree, hf_pptp_host_name, tvb, offset, 64, ENC_ASCII);
236 offset += 64;
238 proto_tree_add_item(tree, hf_pptp_vendor_name, tvb, offset, 64, ENC_ASCII);
241 static void
242 dissect_cntrl_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
244 if (!tree)
245 return;
247 proto_tree_add_uint_format_value(tree, hf_pptp_protocol_version, tvb, offset,
248 2, tvb_get_ntohs(tvb, offset), "%u.%u",
249 tvb_get_uint8(tvb, offset), tvb_get_uint8(tvb, offset + 1));
250 offset += 2;
252 proto_tree_add_item(tree, hf_pptp_control_result, tvb, offset, 1, ENC_BIG_ENDIAN);
253 offset += 1;
255 proto_tree_add_item(tree, hf_pptp_error, tvb, offset, 1, ENC_BIG_ENDIAN);
256 offset += 1;
258 proto_tree_add_item(tree, hf_pptp_framing_capabilities, tvb, offset, 4, ENC_BIG_ENDIAN);
259 offset += 4;
261 proto_tree_add_item(tree, hf_pptp_bearer_capabilities, tvb, offset, 4, ENC_BIG_ENDIAN);
262 offset += 4;
264 proto_tree_add_item(tree, hf_pptp_maximum_channels, tvb, offset, 2, ENC_BIG_ENDIAN);
265 offset += 2;
267 proto_tree_add_item(tree, hf_pptp_firmware_revision, tvb, offset, 2, ENC_BIG_ENDIAN);
268 offset += 2;
270 proto_tree_add_item(tree, hf_pptp_host_name, tvb, offset, 64, ENC_ASCII);
271 offset += 64;
273 proto_tree_add_item(tree, hf_pptp_vendor_name, tvb, offset, 64, ENC_ASCII);
277 static void
278 dissect_stop_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
280 if (!tree)
281 return;
283 proto_tree_add_item(tree, hf_pptp_reason, tvb, offset, 1, ENC_BIG_ENDIAN);
284 offset += 1;
285 /* Reserved1 */
286 proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 1, ENC_NA);
287 offset += 1;
288 /* Reserved2 */
289 proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
292 static void
293 dissect_stop_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
295 if (!tree)
296 return;
298 proto_tree_add_item(tree, hf_pptp_stop_result, tvb, offset, 1, ENC_BIG_ENDIAN);
299 offset += 1;
301 proto_tree_add_item(tree, hf_pptp_error, tvb, offset, 1, ENC_BIG_ENDIAN);
302 offset += 1;
304 proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
308 static void
309 dissect_echo_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
311 if (!tree)
312 return;
314 proto_tree_add_item(tree, hf_pptp_identifier, tvb, offset, 4, ENC_BIG_ENDIAN);
317 static void
318 dissect_echo_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
320 if (!tree)
321 return;
323 proto_tree_add_item(tree, hf_pptp_identifier, tvb, offset, 4, ENC_BIG_ENDIAN);
324 offset += 4;
326 proto_tree_add_item(tree, hf_pptp_echo_result, tvb, offset, 1, ENC_BIG_ENDIAN);
327 offset += 1;
329 proto_tree_add_item(tree, hf_pptp_error, tvb, offset, 1, ENC_BIG_ENDIAN);
330 offset += 1;
332 proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
335 static void
336 dissect_out_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
338 if (!tree)
339 return;
341 proto_tree_add_item(tree, hf_pptp_call_id, tvb, offset, 2, ENC_BIG_ENDIAN);
342 offset += 2;
344 proto_tree_add_item(tree, hf_pptp_call_serial_number, tvb, offset, 2, ENC_BIG_ENDIAN);
345 offset += 2;
347 proto_tree_add_item(tree, hf_pptp_minimum_bps, tvb, offset, 4, ENC_BIG_ENDIAN);
348 offset += 4;
350 proto_tree_add_item(tree, hf_pptp_maximum_bps, tvb, offset, 4, ENC_BIG_ENDIAN);
351 offset += 4;
353 proto_tree_add_item(tree, hf_pptp_bearer_type, tvb, offset, 4, ENC_BIG_ENDIAN);
354 offset += 4;
356 proto_tree_add_item(tree, hf_pptp_framing_type, tvb, offset, 4, ENC_BIG_ENDIAN);
357 offset += 4;
359 proto_tree_add_item(tree, hf_pptp_packet_receive_window_size, tvb, offset, 2, ENC_BIG_ENDIAN);
360 offset += 2;
362 proto_tree_add_item(tree, hf_pptp_packet_processing_delay, tvb, offset, 2, ENC_BIG_ENDIAN);
363 offset += 2;
365 proto_tree_add_item(tree, hf_pptp_phone_number_length, tvb, offset, 2, ENC_BIG_ENDIAN);
366 offset += 2;
368 proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
369 offset += 2;
371 proto_tree_add_item(tree, hf_pptp_phone_number, tvb, offset, 64, ENC_ASCII);
372 offset += 64;
374 proto_tree_add_item(tree, hf_pptp_subaddress, tvb, offset, 64, ENC_ASCII);
377 static void
378 dissect_out_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
380 if (!tree)
381 return;
383 proto_tree_add_item(tree, hf_pptp_call_id, tvb, offset, 2, ENC_BIG_ENDIAN);
384 offset += 2;
386 proto_tree_add_item(tree, hf_pptp_peer_call_id, tvb, offset, 2, ENC_BIG_ENDIAN);
387 offset += 2;
389 proto_tree_add_item(tree, hf_pptp_out_result, tvb, offset, 1, ENC_BIG_ENDIAN);
390 offset += 1;
392 proto_tree_add_item(tree, hf_pptp_error, tvb, offset, 1, ENC_BIG_ENDIAN);
393 offset += 1;
395 proto_tree_add_item(tree, hf_pptp_cause, tvb, offset, 2, ENC_BIG_ENDIAN);
396 offset += 2;
398 proto_tree_add_item(tree, hf_pptp_connect_speed, tvb, offset, 4, ENC_BIG_ENDIAN);
399 offset += 4;
401 proto_tree_add_item(tree, hf_pptp_packet_receive_window_size, tvb, offset, 2, ENC_BIG_ENDIAN);
402 offset += 2;
404 proto_tree_add_item(tree, hf_pptp_packet_processing_delay, tvb, offset, 2, ENC_BIG_ENDIAN);
405 offset += 2;
407 proto_tree_add_item(tree, hf_pptp_physical_channel_id, tvb, offset, 4, ENC_BIG_ENDIAN);
410 static void
411 dissect_in_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
413 if (!tree)
414 return;
416 proto_tree_add_item(tree, hf_pptp_call_id, tvb, offset, 2, ENC_BIG_ENDIAN);
417 offset += 2;
419 proto_tree_add_item(tree, hf_pptp_call_serial_number, tvb, offset, 2, ENC_BIG_ENDIAN);
420 offset += 2;
422 proto_tree_add_item(tree, hf_pptp_bearer_type, tvb, offset, 4, ENC_BIG_ENDIAN);
423 offset += 4;
425 proto_tree_add_item(tree, hf_pptp_physical_channel_id, tvb, offset, 4, ENC_BIG_ENDIAN);
426 offset += 4;
428 proto_tree_add_item(tree, hf_pptp_dialed_number_length, tvb, offset, 2, ENC_BIG_ENDIAN);
429 offset += 2;
431 proto_tree_add_item(tree, hf_pptp_dialing_number_length, tvb, offset, 2, ENC_BIG_ENDIAN);
432 offset += 2;
434 proto_tree_add_item(tree, hf_pptp_dialed_number, tvb, offset, 64, ENC_ASCII);
435 offset += 64;
437 proto_tree_add_item(tree, hf_pptp_dialing_number, tvb, offset, 64, ENC_ASCII);
438 offset += 64;
440 proto_tree_add_item(tree, hf_pptp_subaddress, tvb, offset, 64, ENC_ASCII);
443 static void
444 dissect_in_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
446 if (!tree)
447 return;
449 proto_tree_add_item(tree, hf_pptp_call_id, tvb, offset, 2, ENC_BIG_ENDIAN);
450 offset += 2;
452 proto_tree_add_item(tree, hf_pptp_peer_call_id, tvb, offset, 2, ENC_BIG_ENDIAN);
453 offset += 2;
455 proto_tree_add_item(tree, hf_pptp_in_result, tvb, offset, 1, ENC_BIG_ENDIAN);
456 offset += 1;
458 proto_tree_add_item(tree, hf_pptp_error, tvb, offset, 1, ENC_BIG_ENDIAN);
459 offset += 1;
461 proto_tree_add_item(tree, hf_pptp_packet_receive_window_size, tvb, offset, 2, ENC_BIG_ENDIAN);
462 offset += 2;
464 proto_tree_add_item(tree, hf_pptp_packet_processing_delay, tvb, offset, 2, ENC_BIG_ENDIAN);
465 offset += 2;
467 proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
470 static void
471 dissect_in_connected(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
473 if (!tree)
474 return;
476 proto_tree_add_item(tree, hf_pptp_peer_call_id, tvb, offset, 2, ENC_BIG_ENDIAN);
477 offset += 2;
479 proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
480 offset += 2;
482 proto_tree_add_item(tree, hf_pptp_connect_speed, tvb, offset, 4, ENC_BIG_ENDIAN);
483 offset += 4;
485 proto_tree_add_item(tree, hf_pptp_packet_receive_window_size, tvb, offset, 2, ENC_BIG_ENDIAN);
486 offset += 2;
488 proto_tree_add_item(tree, hf_pptp_packet_processing_delay, tvb, offset, 2, ENC_BIG_ENDIAN);
489 offset += 2;
491 proto_tree_add_item(tree, hf_pptp_framing_type, tvb, offset, 4, ENC_BIG_ENDIAN);
494 static void
495 dissect_clear_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
497 if (!tree)
498 return;
500 proto_tree_add_item(tree, hf_pptp_call_id, tvb, offset, 2, ENC_BIG_ENDIAN);
501 offset += 2;
503 proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
506 static void
507 dissect_disc_notify(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
509 if (!tree)
510 return;
512 proto_tree_add_item(tree, hf_pptp_call_id, tvb, offset, 2, ENC_BIG_ENDIAN);
513 offset += 2;
515 proto_tree_add_item(tree, hf_pptp_disc_result, tvb, offset, 1, ENC_BIG_ENDIAN);
516 offset += 1;
518 proto_tree_add_item(tree, hf_pptp_error, tvb, offset, 1, ENC_BIG_ENDIAN);
519 offset += 1;
521 proto_tree_add_item(tree, hf_pptp_cause, tvb, offset, 2, ENC_BIG_ENDIAN);
522 offset += 2;
524 proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
525 offset += 2;
527 proto_tree_add_item(tree, hf_pptp_call_statistics, tvb, offset, 64, ENC_ASCII);
530 static void
531 dissect_error_notify(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
533 if (!tree)
534 return;
536 proto_tree_add_item(tree, hf_pptp_peer_call_id, tvb, offset, 2, ENC_BIG_ENDIAN);
537 offset += 2;
539 proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
540 offset += 2;
542 proto_tree_add_item(tree, hf_pptp_crc_errors, tvb, offset, 4, ENC_BIG_ENDIAN);
543 offset += 4;
545 proto_tree_add_item(tree, hf_pptp_framing_errors, tvb, offset, 4, ENC_BIG_ENDIAN);
546 offset += 4;
548 proto_tree_add_item(tree, hf_pptp_hardware_overruns, tvb, offset, 4, ENC_BIG_ENDIAN);
549 offset += 4;
551 proto_tree_add_item(tree, hf_pptp_buffer_overruns, tvb, offset, 4, ENC_BIG_ENDIAN);
552 offset += 4;
554 proto_tree_add_item(tree, hf_pptp_timeout_errors, tvb, offset, 4, ENC_BIG_ENDIAN);
555 offset += 4;
557 proto_tree_add_item(tree, hf_pptp_alignment_errors, tvb, offset, 4, ENC_BIG_ENDIAN);
560 static void
561 dissect_set_link(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
563 if (!tree)
564 return;
566 proto_tree_add_item(tree, hf_pptp_peer_call_id, tvb, offset, 2, ENC_BIG_ENDIAN);
567 offset += 2;
569 proto_tree_add_item(tree, hf_pptp_reserved, tvb, offset, 2, ENC_NA);
570 offset += 2;
572 proto_tree_add_item(tree, hf_pptp_send_accm, tvb, offset, 4, ENC_BIG_ENDIAN);
573 offset += 4;
575 proto_tree_add_item(tree, hf_pptp_receive_accm, tvb, offset, 4, ENC_BIG_ENDIAN);
578 static int
579 dissect_pptp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
581 proto_tree *pptp_tree = NULL;
582 proto_item *item = NULL;
583 int offset = 0;
584 uint16_t len;
585 uint16_t control_message_type;
587 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPTP");
588 col_clear(pinfo->cinfo, COL_INFO);
590 len = tvb_get_ntohs(tvb, offset);
591 control_message_type = tvb_get_ntohs(tvb, offset + 8);
593 col_add_str(pinfo->cinfo, COL_INFO,
594 val_to_str(control_message_type, control_message_type_vals,
595 "Unknown control type (%d)"));
597 if (tree) {
598 proto_item *ti;
600 ti = proto_tree_add_item(tree, proto_pptp, tvb, offset, len, ENC_NA);
601 pptp_tree = proto_item_add_subtree(ti, ett_pptp);
603 proto_tree_add_item(pptp_tree, hf_pptp_length, tvb, offset, 2, ENC_BIG_ENDIAN);
605 proto_tree_add_item(pptp_tree, hf_pptp_message_type, tvb, offset+2, 2, ENC_BIG_ENDIAN);
607 item = proto_tree_add_item(pptp_tree, hf_pptp_magic_cookie, tvb, offset+4, 4, ENC_BIG_ENDIAN);
610 if (tvb_get_ntohl(tvb, offset+4) == MAGIC_COOKIE)
611 proto_item_append_text(item," (correct)");
612 else {
613 proto_item_append_text(item," (incorrect)");
614 expert_add_info(pinfo, item, &ei_pptp_incorrect_magic_cookie);
617 if (tree) {
618 proto_tree_add_item(pptp_tree, hf_pptp_control_message_type, tvb, offset+8, 2, ENC_BIG_ENDIAN);
620 proto_tree_add_item(pptp_tree, hf_pptp_reserved, tvb, offset+10, 2, ENC_NA);
623 offset += offset + 12;
625 switch(control_message_type){
626 case CNTRL_REQ: /* Start-Control-Connection-Request */
627 dissect_cntrl_req(tvb, offset, pinfo, pptp_tree);
628 break;
629 case CNTRL_REPLY: /* Start-Control-Connection-Reply */
630 dissect_cntrl_reply(tvb, offset, pinfo, pptp_tree);
631 break;
632 case STOP_REQ: /* Stop-Control-Connection-Request */
633 dissect_stop_req(tvb, offset, pinfo, pptp_tree);
634 break;
635 case STOP_REPLY: /* Stop-Control-Connection-Reply */
636 dissect_stop_reply(tvb, offset, pinfo, pptp_tree);
637 break;
638 case ECHO_REQ: /* Echo-Request */
639 dissect_echo_req(tvb, offset, pinfo, pptp_tree);
640 break;
641 case ECHO_REPLY: /* Echo-Reply */
642 dissect_echo_reply(tvb, offset, pinfo, pptp_tree);
643 break;
644 case OUT_REQ: /* Outgoing-Call-Request */
645 dissect_out_req(tvb, offset, pinfo, pptp_tree);
646 break;
647 case OUT_REPLY: /* Outgoing-Call-Reply */
648 dissect_out_reply(tvb, offset, pinfo, pptp_tree);
649 break;
650 case IN_REQ: /* Incoming-Call-Request */
651 dissect_in_req(tvb, offset, pinfo, pptp_tree);
652 break;
653 case IN_REPLY: /* Incoming-Call-Reply */
654 dissect_in_reply(tvb, offset, pinfo, pptp_tree);
655 break;
656 case IN_CONNECTED: /* Incoming-Call-Connected */
657 dissect_in_connected(tvb, offset, pinfo, pptp_tree);
658 break;
659 case CLEAR_REQ: /* Call-Clear-Request */
660 dissect_clear_req(tvb, offset, pinfo, pptp_tree);
661 break;
662 case DISC_NOTIFY: /* Call-Disconnect-Notify */
663 dissect_disc_notify(tvb, offset, pinfo, pptp_tree);
664 break;
665 case ERROR_NOTIFY: /* WAN-Error-Notify */
666 dissect_error_notify(tvb, offset, pinfo, pptp_tree);
667 break;
668 case SET_LINK: /* Set-Link-Info */
669 dissect_set_link(tvb, offset, pinfo, pptp_tree);
670 break;
671 default: /* Unknown Type... */
672 dissect_unknown(tvb, offset, pinfo, pptp_tree);
673 break;
675 return tvb_captured_length(tvb);
678 void
679 proto_register_pptp(void)
681 static int *ett[] = {
682 &ett_pptp,
685 static hf_register_info hf[] = {
686 { &hf_pptp_length,
687 { "Length", "pptp.length",
688 FT_UINT16, BASE_DEC, NULL, 0x0,
689 "Total length in octets of this PPTP message", HFILL }
691 { &hf_pptp_message_type,
692 { "Message type", "pptp.type",
693 FT_UINT16, BASE_DEC, VALS(msgtype_vals), 0x0,
694 "PPTP message type", HFILL }
696 { &hf_pptp_magic_cookie,
697 { "Magic Cookie", "pptp.magic_cookie",
698 FT_UINT32, BASE_HEX, NULL, 0x0,
699 "This constant value is used as a sanity check on received messages", HFILL }
701 { &hf_pptp_control_message_type,
702 { "Control Message Type", "pptp.control_message_type",
703 FT_UINT16, BASE_DEC, VALS(control_message_type_vals), 0x0,
704 NULL, HFILL }
706 { &hf_pptp_reserved,
707 { "Reserved", "pptp.reserved",
708 FT_BYTES, BASE_NONE, NULL, 0x0,
709 "This field MUST be 0", HFILL }
711 { &hf_pptp_protocol_version,
712 { "Protocol version", "pptp.protocol_version",
713 FT_UINT16, BASE_DEC, NULL, 0x0,
714 "The version of the PPTP protocol", HFILL }
716 { &hf_pptp_framing_capabilities,
717 { "Framing Capabilities", "pptp.framing_capabilities",
718 FT_UINT32, BASE_DEC, VALS(frametype_vals), 0x0,
719 "A set of bits indicating the type of framing", HFILL }
721 { &hf_pptp_bearer_capabilities,
722 { "Bearer Capabilities", "pptp.bearer_capabilities",
723 FT_UINT32, BASE_DEC, VALS(bearertype_vals), 0x0,
724 "A set of bits indicating the type of bearer", HFILL }
726 { &hf_pptp_maximum_channels,
727 { "Maximum Channels", "pptp.maximum_channels",
728 FT_UINT16, BASE_DEC, NULL, 0x0,
729 "The total number of individual PPP sessions this PAC can support", HFILL }
731 { &hf_pptp_firmware_revision,
732 { "Firmware Revision", "pptp.firmware_revision",
733 FT_UINT16, BASE_DEC, NULL, 0x0,
734 "This field contains the firmware revision", HFILL }
736 { &hf_pptp_host_name,
737 { "Host Name", "pptp.host_name",
738 FT_STRING, BASE_NONE, NULL, 0x0,
739 "A 64 octet field containing the DNS name", HFILL }
741 { &hf_pptp_vendor_name,
742 { "Vendor Name", "pptp.vendor_name",
743 FT_STRING, BASE_NONE, NULL, 0x0,
744 "A 64 octet field containing a vendor", HFILL }
746 { &hf_pptp_control_result,
747 { "Result Code", "pptp.control_result",
748 FT_UINT8, BASE_DEC, VALS(control_resulttype_vals), 0x0,
749 "Indicates the result of the command channel establishment attempt", HFILL }
751 { &hf_pptp_error,
752 { "Error Code", "pptp.error",
753 FT_UINT8, BASE_DEC, VALS(errortype_vals), 0x0,
754 NULL, HFILL }
756 { &hf_pptp_reason,
757 { "Reason", "pptp.reason",
758 FT_UINT8, BASE_DEC, VALS(reasontype_vals), 0x0,
759 "Indicates the reason for the control connection being close", HFILL }
761 { &hf_pptp_stop_result,
762 { "Result Code", "pptp.stop_result",
763 FT_UINT8, BASE_DEC, VALS(stop_resulttype_vals), 0x0,
764 "Indicates the result of the attempt to close the control connection", HFILL }
766 { &hf_pptp_identifier,
767 { "Identifier", "pptp.identifier",
768 FT_UINT32, BASE_DEC, NULL, 0x0,
769 NULL, HFILL }
771 { &hf_pptp_echo_result,
772 { "Result Code", "pptp.echo_result",
773 FT_UINT8, BASE_DEC, VALS(echo_resulttype_vals), 0x0,
774 "Indicates the result of the receipt of the Echo-Request", HFILL }
776 { &hf_pptp_call_id,
777 { "Call ID", "pptp.call_id",
778 FT_UINT16, BASE_DEC, NULL, 0x0,
779 "A unique identifier, unique to a particular PAC-PNS pair assigned by the PNS", HFILL }
781 { &hf_pptp_call_serial_number,
782 { "Call Serial Number", "pptp.call_serial_number",
783 FT_UINT16, BASE_DEC, NULL, 0x0,
784 "An identifier assigned by the PNS to this session for the purpose of identifying this particular session in logged session information", HFILL }
786 { &hf_pptp_minimum_bps,
787 { "Minimum BPS", "pptp.minimum_bps",
788 FT_UINT32, BASE_DEC, NULL, 0x0,
789 "The lowest acceptable line speed (in bits/second) for this session", HFILL }
791 { &hf_pptp_maximum_bps,
792 { "Maximum BPS", "pptp.maximum_bps",
793 FT_UINT32, BASE_DEC, NULL, 0x0,
794 "The highest acceptable line speed (in bits/second) for this session", HFILL }
796 { &hf_pptp_framing_type,
797 { "Framing Type", "pptp.framing_type",
798 FT_UINT32, BASE_DEC, VALS(frametype_vals), 0x0,
799 "A value indicating the type of PPP framing to be used for this outgoing call", HFILL }
801 { &hf_pptp_bearer_type,
802 { "Bearer Type", "pptp.bearer_type",
803 FT_UINT32, BASE_DEC, VALS(bearertype_vals), 0x0,
804 "A value indicating the bearer capability required for this outgoing call", HFILL }
806 { &hf_pptp_packet_receive_window_size,
807 { "Packet Receive Window Size", "pptp.packet_receive_window_size",
808 FT_UINT16, BASE_DEC, NULL, 0x0,
809 "A unique identifier, unique to a particular PAC-PNS pair assigned by the PNS", HFILL }
811 { &hf_pptp_packet_processing_delay,
812 { "Packet Processing Delay", "pptp.packet_processing_delay",
813 FT_UINT16, BASE_DEC, NULL, 0x0,
814 "A measure of the packet processing delay that might be imposed on data sent to the PNS from the PAC", HFILL }
816 { &hf_pptp_phone_number_length,
817 { "Phone Number Length", "pptp.phone_number_length",
818 FT_UINT16, BASE_DEC, NULL, 0x0,
819 "The actual number of valid digits in the Phone Number field", HFILL }
821 { &hf_pptp_phone_number,
822 { "Phone Number", "pptp.phone_number",
823 FT_STRING, BASE_NONE, NULL, 0x0,
824 "The number to be dialed to establish the outgoing session", HFILL }
826 { &hf_pptp_subaddress,
827 { "Subaddress", "pptp.subaddress",
828 FT_STRING, BASE_NONE, NULL, 0x0,
829 "A 64 octet field used to specify additional dialing information.", HFILL }
831 { &hf_pptp_peer_call_id,
832 { "Peer Call ID", "pptp.peer_call_id",
833 FT_UINT16, BASE_DEC, NULL, 0x0,
834 "This field is set to the value received in the Call ID field of the corresponding Outgoing-Call-Request message", HFILL }
836 { &hf_pptp_out_result,
837 { "Result Code", "pptp.out_result",
838 FT_UINT8, BASE_DEC, VALS(out_resulttype_vals), 0x0,
839 "Indicates the result of the receipt of the Outgoing-Call-Request attempt", HFILL }
841 { &hf_pptp_cause,
842 { "Cause Code", "pptp.cause",
843 FT_UINT16, BASE_DEC, NULL, 0x0,
844 "This field gives additional information", HFILL }
846 { &hf_pptp_connect_speed,
847 { "Connect Speed", "pptp.connect_speed",
848 FT_UINT32, BASE_DEC, NULL, 0x0,
849 "The actual connection speed used, in bits/second.", HFILL }
851 { &hf_pptp_physical_channel_id,
852 { "Physical Channel ID", "pptp.physical_channel_id",
853 FT_UINT32, BASE_DEC, NULL, 0x0,
854 "This field is set by the PAC in a vendor-specific manner to the physical channel number used to place this call", HFILL }
856 { &hf_pptp_dialed_number_length,
857 { "Dialed Number Length", "pptp.dialed_number_length",
858 FT_UINT16, BASE_DEC, NULL, 0x0,
859 "The actual number of valid digits in the Dialed Number field", HFILL }
861 { &hf_pptp_dialed_number,
862 { "Dialed Number", "pptp.dialed_number",
863 FT_STRING, BASE_NONE, NULL, 0x0,
864 "The number that was dialed by the caller", HFILL }
867 { &hf_pptp_dialing_number_length,
868 { "Dialing Number Length", "pptp.dialing_number_length",
869 FT_UINT16, BASE_DEC, NULL, 0x0,
870 "The actual number of valid digits in the Dialing Number field", HFILL }
872 { &hf_pptp_dialing_number,
873 { "Dialing Number", "pptp.dialing_number",
874 FT_STRING, BASE_NONE, NULL, 0x0,
875 "The number from which the call was placed", HFILL }
877 { &hf_pptp_in_result,
878 { "Result Code", "pptp.in_result",
879 FT_UINT8, BASE_DEC, VALS(in_resulttype_vals), 0x0,
880 "This value indicates the result of the Incoming-Call-Request attempt", HFILL }
882 { &hf_pptp_disc_result,
883 { "Result Code", "pptp.disc_result",
884 FT_UINT8, BASE_DEC, VALS(disc_resulttype_vals), 0x0,
885 "This value indicates the reason for the disconnect", HFILL }
887 { &hf_pptp_call_statistics,
888 { "Call Statistics", "pptp.call_Statistics",
889 FT_STRING, BASE_NONE, NULL, 0x0,
890 "This field is an ASCII string containing vendor-specific call statistics that can be logged for diagnostic purpose", HFILL }
892 { &hf_pptp_crc_errors,
893 { "CRC Errors", "pptp.crc_errors",
894 FT_UINT32, BASE_DEC, NULL, 0x0,
895 "Number of PPP frames received with CRC errors since session was established", HFILL }
897 { &hf_pptp_framing_errors,
898 { "Framing Errors", "pptp.framing_errors",
899 FT_UINT32, BASE_DEC, NULL, 0x0,
900 "Number of improperly framed PPP packets received", HFILL }
902 { &hf_pptp_hardware_overruns,
903 { "Hardware overruns", "pptp.hardware_overruns",
904 FT_UINT32, BASE_DEC, NULL, 0x0,
905 "Number of receive buffer over-runs since session was established", HFILL }
907 { &hf_pptp_buffer_overruns,
908 { "Buffer overruns", "pptp.buffer_overruns",
909 FT_UINT32, BASE_DEC, NULL, 0x0,
910 "Number of buffer over-runs detected since session was established", HFILL }
912 { &hf_pptp_timeout_errors,
913 { "Time-out Errors", "pptp.timeout_errors",
914 FT_UINT32, BASE_DEC, NULL, 0x0,
915 "Number of time-outs since call was established", HFILL }
917 { &hf_pptp_alignment_errors,
918 { "Alignment Errors", "pptp.alignment_errors",
919 FT_UINT32, BASE_DEC, NULL, 0x0,
920 "Number of Alignment errors since call was established", HFILL }
922 { &hf_pptp_send_accm,
923 { "Send ACCM", "pptp.send_accm",
924 FT_UINT32, BASE_HEX, NULL, 0x0,
925 "The send ACCM value the client should use to process outgoing PPP packets", HFILL }
927 { &hf_pptp_receive_accm,
928 { "Receive ACCM", "pptp.receive_accm",
929 FT_UINT32, BASE_HEX, NULL, 0x0,
930 "The Receive ACCM value the client should use to process incoming PPP packets", HFILL }
934 static ei_register_info ei[] = {
935 { &ei_pptp_incorrect_magic_cookie, { "pptp.magic_cookie.incorrect", PI_PROTOCOL, PI_WARN, "Incorrect Magic Cookie", EXPFILL }},
938 expert_module_t* expert_pptp;
940 proto_pptp = proto_register_protocol("Point-to-Point Tunnelling Protocol",
941 "PPTP", "pptp");
942 pptp_handle = register_dissector("pptp", dissect_pptp, proto_pptp);
943 proto_register_field_array(proto_pptp, hf, array_length(hf));
944 proto_register_subtree_array(ett, array_length(ett));
945 expert_pptp = expert_register_protocol(proto_pptp);
946 expert_register_field_array(expert_pptp, ei, array_length(ei));
949 void
950 proto_reg_handoff_pptp(void)
952 dissector_add_uint_with_preference("tcp.port", TCP_PORT_PPTP, pptp_handle);
956 * Editor modelines - https://www.wireshark.org/tools/modelines.html
958 * Local Variables:
959 * c-basic-offset: 2
960 * tab-width: 8
961 * indent-tabs-mode: nil
962 * End:
964 * ex: set shiftwidth=2 tabstop=8 expandtab:
965 * :indentSize=2:tabSize=8:noTabs=true: