]> The Tcpdump Group git mirrors - tcpdump/blob - print-vjc.c
From Neil Spring:
[tcpdump] / print-vjc.c
1 /*
2 * Copyright (c) 1990, 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
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26
27 #include <tcpdump-stdinc.h>
28
29 #include <pcap.h>
30 #include <stdio.h>
31
32 #include "interface.h"
33 #include "addrtoname.h"
34
35 #ifndef lint
36 static const char rcsid[] _U_ =
37 "@(#) $Header: /tcpdump/master/tcpdump/print-vjc.c,v 1.12 2003-11-15 00:39:43 guy Exp $ (LBL)";
38 #endif
39 #include "slcompress.h"
40 #include "ppp.h"
41
42 int
43 vjc_print(register const char *bp, u_short proto)
44 {
45 int i;
46
47 switch (bp[0] & 0xf0) {
48 case TYPE_IP:
49 if (eflag)
50 printf("(vjc type=IP) ");
51 return PPP_IP;
52 case TYPE_UNCOMPRESSED_TCP:
53 if (eflag)
54 printf("(vjc type=raw TCP) ");
55 return PPP_IP;
56 case TYPE_COMPRESSED_TCP:
57 if (eflag)
58 printf("(vjc type=compressed TCP) ");
59 for (i = 0; i < 8; i++) {
60 if (bp[1] & (0x80 >> i))
61 printf("%c", "?CI?SAWU"[i]);
62 }
63 if (bp[1])
64 printf(" ");
65 printf("C=0x%02x ", bp[2]);
66 printf("sum=0x%04x ", *(u_short *)&bp[3]);
67 return -1;
68 case TYPE_ERROR:
69 if (eflag)
70 printf("(vjc type=error) ");
71 return -1;
72 default:
73 if (eflag)
74 printf("(vjc type=0x%02x) ", bp[0] & 0xf0);
75 return -1;
76 }
77 }