/opensource.apple.com/source/tcpdump/tcpdump-7/tcpdump/print-vjc.c
C | 102 lines | 76 code | 8 blank | 18 comment | 0 complexity | 7eb8c46dacbe4cc6e3b1d3b12619b777 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, GPL-2.0, BSD-3-Clause, GPL-3.0, MPL-2.0, LGPL-2.0, LGPL-2.1, CC-BY-SA-3.0, IPL-1.0, ISC, AGPL-1.0, AGPL-3.0, JSON, Apache-2.0, 0BSD
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>print-vjc.c</title>
- <style type="text/css">
- .enscript-comment { font-style: italic; color: rgb(178,34,34); }
- .enscript-function-name { font-weight: bold; color: rgb(0,0,255); }
- .enscript-variable-name { font-weight: bold; color: rgb(184,134,11); }
- .enscript-keyword { font-weight: bold; color: rgb(160,32,240); }
- .enscript-reference { font-weight: bold; color: rgb(95,158,160); }
- .enscript-string { font-weight: bold; color: rgb(188,143,143); }
- .enscript-builtin { font-weight: bold; color: rgb(218,112,214); }
- .enscript-type { font-weight: bold; color: rgb(34,139,34); }
- .enscript-highlight { text-decoration: underline; color: 0; }
- </style>
- </head>
- <body id="top">
- <h1 style="margin:8px;" id="f1">print-vjc.c <span style="font-weight: normal; font-size: 0.5em;">[<a href="?txt">plain text</a>]</span></h1>
- <hr/>
- <div></div>
- <pre>
- <span class="enscript-comment">/*
- * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */</span>
- #<span class="enscript-reference">ifdef</span> <span class="enscript-variable-name">HAVE_CONFIG_H</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"config.h"</span>
- #<span class="enscript-reference">endif</span>
- #<span class="enscript-reference">ifndef</span> <span class="enscript-variable-name">lint</span>
- <span class="enscript-type">static</span> <span class="enscript-type">const</span> <span class="enscript-type">char</span> rcsid[] =
- <span class="enscript-string">"@(#) $Header: /cvs/root/tcpdump/tcpdump/print-vjc.c,v 1.1.1.2 2003/03/17 18:42:20 rbraun Exp $ (LBL)"</span>;
- #<span class="enscript-reference">endif</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string"><tcpdump-stdinc.h></span>
- #<span class="enscript-reference">include</span> <span class="enscript-string"><pcap.h></span>
- #<span class="enscript-reference">include</span> <span class="enscript-string"><stdio.h></span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"interface.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"addrtoname.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"slcompress.h"</span>
- #<span class="enscript-reference">include</span> <span class="enscript-string">"ppp.h"</span>
- <span class="enscript-type">int</span>
- <span class="enscript-function-name">vjc_print</span>(<span class="enscript-type">register</span> <span class="enscript-type">const</span> <span class="enscript-type">char</span> *bp, u_short proto)
- {
- <span class="enscript-type">int</span> i;
- <span class="enscript-keyword">switch</span> (bp[0] & 0xf0) {
- <span class="enscript-keyword">case</span> <span class="enscript-reference">TYPE_IP</span>:
- <span class="enscript-keyword">if</span> (eflag)
- printf(<span class="enscript-string">"(vjc type=IP) "</span>);
- <span class="enscript-keyword">return</span> PPP_IP;
- <span class="enscript-keyword">case</span> <span class="enscript-reference">TYPE_UNCOMPRESSED_TCP</span>:
- <span class="enscript-keyword">if</span> (eflag)
- printf(<span class="enscript-string">"(vjc type=raw TCP) "</span>);
- <span class="enscript-keyword">return</span> PPP_IP;
- <span class="enscript-keyword">case</span> <span class="enscript-reference">TYPE_COMPRESSED_TCP</span>:
- <span class="enscript-keyword">if</span> (eflag)
- printf(<span class="enscript-string">"(vjc type=compressed TCP) "</span>);
- <span class="enscript-keyword">for</span> (i = 0; i < 8; i++) {
- <span class="enscript-keyword">if</span> (bp[1] & (0x80 >> i))
- printf(<span class="enscript-string">"%c"</span>, <span class="enscript-string">"?CI?SAWU"</span>[i]);
- }
- <span class="enscript-keyword">if</span> (bp[1])
- printf(<span class="enscript-string">" "</span>);
- printf(<span class="enscript-string">"C=0x%02x "</span>, bp[2]);
- printf(<span class="enscript-string">"sum=0x%04x "</span>, *(u_short *)&bp[3]);
- <span class="enscript-keyword">return</span> -1;
- <span class="enscript-keyword">case</span> <span class="enscript-reference">TYPE_ERROR</span>:
- <span class="enscript-keyword">if</span> (eflag)
- printf(<span class="enscript-string">"(vjc type=error) "</span>);
- <span class="enscript-keyword">return</span> -1;
- <span class="enscript-reference">default</span>:
- <span class="enscript-keyword">if</span> (eflag)
- printf(<span class="enscript-string">"(vjc type=0x%02x) "</span>, bp[0] & 0xf0);
- <span class="enscript-keyword">return</span> -1;
- }
- }
- </pre>
- <hr />
- </body></html>