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