1b0453382SBill Fenner /* 2b0453382SBill Fenner * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 3b0453382SBill Fenner * The Regents of the University of California. All rights reserved. 4b0453382SBill Fenner * 5b0453382SBill Fenner * Redistribution and use in source and binary forms, with or without 6b0453382SBill Fenner * modification, are permitted provided that: (1) source code distributions 7b0453382SBill Fenner * retain the above copyright notice and this paragraph in its entirety, (2) 8b0453382SBill Fenner * distributions including binary code include the above copyright notice and 9b0453382SBill Fenner * this paragraph in its entirety in the documentation or other materials 10b0453382SBill Fenner * provided with the distribution, and (3) all advertising materials mentioning 11b0453382SBill Fenner * features or use of this software display the following acknowledgement: 12b0453382SBill Fenner * ``This product includes software developed by the University of California, 13b0453382SBill Fenner * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14b0453382SBill Fenner * the University nor the names of its contributors may be used to endorse 15b0453382SBill Fenner * or promote products derived from this software without specific prior 16b0453382SBill Fenner * written permission. 17b0453382SBill Fenner * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18b0453382SBill Fenner * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19b0453382SBill Fenner * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20b0453382SBill Fenner */ 21b0453382SBill Fenner 22*3c602fabSXin LI #define NETDISSECT_REWORKED 23b0453382SBill Fenner #ifdef HAVE_CONFIG_H 24b0453382SBill Fenner #include "config.h" 25b0453382SBill Fenner #endif 26b0453382SBill Fenner 275b0fe478SBruce M Simpson #include <tcpdump-stdinc.h> 28b0453382SBill Fenner 29b0453382SBill Fenner #include "interface.h" 30685295f4SBill Fenner #include "slcompress.h" 31685295f4SBill Fenner #include "ppp.h" 32685295f4SBill Fenner 335b0fe478SBruce M Simpson /* 345b0fe478SBruce M Simpson * XXX - for BSD/OS PPP, what packets get supplied with a PPP header type 355b0fe478SBruce M Simpson * of PPP_VJC and what packets get supplied with a PPP header type of 365b0fe478SBruce M Simpson * PPP_VJNC? PPP_VJNC is for "UNCOMPRESSED_TCP" packets, and PPP_VJC 375b0fe478SBruce M Simpson * is for COMPRESSED_TCP packets (PPP_IP is used for TYPE_IP packets). 385b0fe478SBruce M Simpson * 395b0fe478SBruce M Simpson * RFC 1144 implies that, on the wire, the packet type is *not* needed 405b0fe478SBruce M Simpson * for PPP, as different PPP protocol types can be used; it only needs 415b0fe478SBruce M Simpson * to be put on the wire for SLIP. 425b0fe478SBruce M Simpson * 435b0fe478SBruce M Simpson * It also indicates that, for compressed SLIP: 445b0fe478SBruce M Simpson * 455b0fe478SBruce M Simpson * If the COMPRESSED_TCP bit is set in the first byte, it's 465b0fe478SBruce M Simpson * a COMPRESSED_TCP packet; that byte is the change byte, and 475b0fe478SBruce M Simpson * the COMPRESSED_TCP bit, 0x80, isn't used in the change byte. 485b0fe478SBruce M Simpson * 495b0fe478SBruce M Simpson * If the upper 4 bits of the first byte are 7, it's an 505b0fe478SBruce M Simpson * UNCOMPRESSED_TCP packet; that byte is the first byte of 515b0fe478SBruce M Simpson * the UNCOMPRESSED_TCP modified IP header, with a connection 525b0fe478SBruce M Simpson * number in the protocol field, and with the version field 535b0fe478SBruce M Simpson * being 7, not 4. 545b0fe478SBruce M Simpson * 555b0fe478SBruce M Simpson * Otherwise, the packet is an IPv4 packet (where the upper 4 bits 565b0fe478SBruce M Simpson * of the packet are 4). 575b0fe478SBruce M Simpson * 585b0fe478SBruce M Simpson * So this routine looks as if it's sort-of intended to handle 595b0fe478SBruce M Simpson * compressed SLIP, although it doesn't handle UNCOMPRESSED_TCP 605b0fe478SBruce M Simpson * correctly for that (it doesn't fix the version number and doesn't 615b0fe478SBruce M Simpson * do anything to the protocol field), and doesn't check for COMPRESSED_TCP 625b0fe478SBruce M Simpson * packets correctly for that (you only check the first bit - see 635b0fe478SBruce M Simpson * B.1 in RFC 1144). 645b0fe478SBruce M Simpson * 655b0fe478SBruce M Simpson * But it's called for BSD/OS PPP, not SLIP - perhaps BSD/OS does weird 665b0fe478SBruce M Simpson * things with the headers? 675b0fe478SBruce M Simpson * 685b0fe478SBruce M Simpson * Without a BSD/OS VJC-compressed PPP trace, or knowledge of what the 695b0fe478SBruce M Simpson * BSD/OS VJC code does, we can't say what's the case. 705b0fe478SBruce M Simpson * 715b0fe478SBruce M Simpson * We therefore leave "proto" - which is the PPP protocol type - in place, 725b0fe478SBruce M Simpson * *not* marked as unused, for now, so that GCC warnings about the 735b0fe478SBruce M Simpson * unused argument remind us that we should fix this some day. 745b0fe478SBruce M Simpson */ 75b0453382SBill Fenner int 76*3c602fabSXin LI vjc_print(netdissect_options *ndo, register const char *bp, u_short proto _U_) 77b0453382SBill Fenner { 78b0453382SBill Fenner int i; 79b0453382SBill Fenner 80b0453382SBill Fenner switch (bp[0] & 0xf0) { 81b0453382SBill Fenner case TYPE_IP: 82*3c602fabSXin LI if (ndo->ndo_eflag) 83*3c602fabSXin LI ND_PRINT((ndo, "(vjc type=IP) ")); 84b0453382SBill Fenner return PPP_IP; 85b0453382SBill Fenner case TYPE_UNCOMPRESSED_TCP: 86*3c602fabSXin LI if (ndo->ndo_eflag) 87*3c602fabSXin LI ND_PRINT((ndo, "(vjc type=raw TCP) ")); 88b0453382SBill Fenner return PPP_IP; 89b0453382SBill Fenner case TYPE_COMPRESSED_TCP: 90*3c602fabSXin LI if (ndo->ndo_eflag) 91*3c602fabSXin LI ND_PRINT((ndo, "(vjc type=compressed TCP) ")); 92b0453382SBill Fenner for (i = 0; i < 8; i++) { 93b0453382SBill Fenner if (bp[1] & (0x80 >> i)) 94*3c602fabSXin LI ND_PRINT((ndo, "%c", "?CI?SAWU"[i])); 95b0453382SBill Fenner } 96b0453382SBill Fenner if (bp[1]) 97*3c602fabSXin LI ND_PRINT((ndo, " ")); 98*3c602fabSXin LI ND_PRINT((ndo, "C=0x%02x ", bp[2])); 99*3c602fabSXin LI ND_PRINT((ndo, "sum=0x%04x ", *(u_short *)&bp[3])); 100b0453382SBill Fenner return -1; 101b0453382SBill Fenner case TYPE_ERROR: 102*3c602fabSXin LI if (ndo->ndo_eflag) 103*3c602fabSXin LI ND_PRINT((ndo, "(vjc type=error) ")); 104b0453382SBill Fenner return -1; 105b0453382SBill Fenner default: 106*3c602fabSXin LI if (ndo->ndo_eflag) 107*3c602fabSXin LI ND_PRINT((ndo, "(vjc type=0x%02x) ", bp[0] & 0xf0)); 108b0453382SBill Fenner return -1; 109b0453382SBill Fenner } 110b0453382SBill Fenner } 111