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