PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <title>print-vjc.c</title>
  6. <style type="text/css">
  7. .enscript-comment { font-style: italic; color: rgb(178,34,34); }
  8. .enscript-function-name { font-weight: bold; color: rgb(0,0,255); }
  9. .enscript-variable-name { font-weight: bold; color: rgb(184,134,11); }
  10. .enscript-keyword { font-weight: bold; color: rgb(160,32,240); }
  11. .enscript-reference { font-weight: bold; color: rgb(95,158,160); }
  12. .enscript-string { font-weight: bold; color: rgb(188,143,143); }
  13. .enscript-builtin { font-weight: bold; color: rgb(218,112,214); }
  14. .enscript-type { font-weight: bold; color: rgb(34,139,34); }
  15. .enscript-highlight { text-decoration: underline; color: 0; }
  16. </style>
  17. </head>
  18. <body id="top">
  19. <h1 style="margin:8px;" id="f1">print-vjc.c&nbsp;&nbsp;&nbsp;<span style="font-weight: normal; font-size: 0.5em;">[<a href="?txt">plain text</a>]</span></h1>
  20. <hr/>
  21. <div></div>
  22. <pre>
  23. <span class="enscript-comment">/*
  24. * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
  25. * The Regents of the University of California. All rights reserved.
  26. *
  27. * Redistribution and use in source and binary forms, with or without
  28. * modification, are permitted provided that: (1) source code distributions
  29. * retain the above copyright notice and this paragraph in its entirety, (2)
  30. * distributions including binary code include the above copyright notice and
  31. * this paragraph in its entirety in the documentation or other materials
  32. * provided with the distribution, and (3) all advertising materials mentioning
  33. * features or use of this software display the following acknowledgement:
  34. * ``This product includes software developed by the University of California,
  35. * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
  36. * the University nor the names of its contributors may be used to endorse
  37. * or promote products derived from this software without specific prior
  38. * written permission.
  39. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  40. * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  41. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  42. */</span>
  43. #<span class="enscript-reference">ifdef</span> <span class="enscript-variable-name">HAVE_CONFIG_H</span>
  44. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;config.h&quot;</span>
  45. #<span class="enscript-reference">endif</span>
  46. #<span class="enscript-reference">ifndef</span> <span class="enscript-variable-name">lint</span>
  47. <span class="enscript-type">static</span> <span class="enscript-type">const</span> <span class="enscript-type">char</span> rcsid[] =
  48. <span class="enscript-string">&quot;@(#) $Header: /cvs/root/tcpdump/tcpdump/print-vjc.c,v 1.1.1.2 2003/03/17 18:42:20 rbraun Exp $ (LBL)&quot;</span>;
  49. #<span class="enscript-reference">endif</span>
  50. #<span class="enscript-reference">include</span> <span class="enscript-string">&lt;tcpdump-stdinc.h&gt;</span>
  51. #<span class="enscript-reference">include</span> <span class="enscript-string">&lt;pcap.h&gt;</span>
  52. #<span class="enscript-reference">include</span> <span class="enscript-string">&lt;stdio.h&gt;</span>
  53. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;interface.h&quot;</span>
  54. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;addrtoname.h&quot;</span>
  55. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;slcompress.h&quot;</span>
  56. #<span class="enscript-reference">include</span> <span class="enscript-string">&quot;ppp.h&quot;</span>
  57. <span class="enscript-type">int</span>
  58. <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)
  59. {
  60. <span class="enscript-type">int</span> i;
  61. <span class="enscript-keyword">switch</span> (bp[0] &amp; 0xf0) {
  62. <span class="enscript-keyword">case</span> <span class="enscript-reference">TYPE_IP</span>:
  63. <span class="enscript-keyword">if</span> (eflag)
  64. printf(<span class="enscript-string">&quot;(vjc type=IP) &quot;</span>);
  65. <span class="enscript-keyword">return</span> PPP_IP;
  66. <span class="enscript-keyword">case</span> <span class="enscript-reference">TYPE_UNCOMPRESSED_TCP</span>:
  67. <span class="enscript-keyword">if</span> (eflag)
  68. printf(<span class="enscript-string">&quot;(vjc type=raw TCP) &quot;</span>);
  69. <span class="enscript-keyword">return</span> PPP_IP;
  70. <span class="enscript-keyword">case</span> <span class="enscript-reference">TYPE_COMPRESSED_TCP</span>:
  71. <span class="enscript-keyword">if</span> (eflag)
  72. printf(<span class="enscript-string">&quot;(vjc type=compressed TCP) &quot;</span>);
  73. <span class="enscript-keyword">for</span> (i = 0; i &lt; 8; i++) {
  74. <span class="enscript-keyword">if</span> (bp[1] &amp; (0x80 &gt;&gt; i))
  75. printf(<span class="enscript-string">&quot;%c&quot;</span>, <span class="enscript-string">&quot;?CI?SAWU&quot;</span>[i]);
  76. }
  77. <span class="enscript-keyword">if</span> (bp[1])
  78. printf(<span class="enscript-string">&quot; &quot;</span>);
  79. printf(<span class="enscript-string">&quot;C=0x%02x &quot;</span>, bp[2]);
  80. printf(<span class="enscript-string">&quot;sum=0x%04x &quot;</span>, *(u_short *)&amp;bp[3]);
  81. <span class="enscript-keyword">return</span> -1;
  82. <span class="enscript-keyword">case</span> <span class="enscript-reference">TYPE_ERROR</span>:
  83. <span class="enscript-keyword">if</span> (eflag)
  84. printf(<span class="enscript-string">&quot;(vjc type=error) &quot;</span>);
  85. <span class="enscript-keyword">return</span> -1;
  86. <span class="enscript-reference">default</span>:
  87. <span class="enscript-keyword">if</span> (eflag)
  88. printf(<span class="enscript-string">&quot;(vjc type=0x%02x) &quot;</span>, bp[0] &amp; 0xf0);
  89. <span class="enscript-keyword">return</span> -1;
  90. }
  91. }
  92. </pre>
  93. <hr />
  94. </body></html>