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