Return to libnet-macros_8h-source.html CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / libnet / doc / html |
1.1 ! misho 1: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> ! 2: <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> ! 3: <title>libnet: libnet-macros.h Source File</title> ! 4: <link href="doxygen.css" rel="stylesheet" type="text/css"> ! 5: </head><body> ! 6: <!-- Generated by Doxygen 1.3.4 --> ! 7: <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a></div> ! 8: <h1>libnet-macros.h</h1><a href="libnet-macros_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*</span> ! 9: 00002 <span class="comment"> * $Id: libnet-macros.h,v 1.6 2004/03/01 20:26:12 mike Exp $</span> ! 10: 00003 <span class="comment"> *</span> ! 11: 00004 <span class="comment"> * libnet-macros.h - Network routine library macro header file</span> ! 12: 00005 <span class="comment"> *</span> ! 13: 00006 <span class="comment"> * Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com></span> ! 14: 00007 <span class="comment"> * All rights reserved.</span> ! 15: 00008 <span class="comment"> *</span> ! 16: 00009 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span> ! 17: 00010 <span class="comment"> * modification, are permitted provided that the following conditions</span> ! 18: 00011 <span class="comment"> * are met:</span> ! 19: 00012 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span> ! 20: 00013 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span> ! 21: 00014 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span> ! 22: 00015 <span class="comment"> * notice, this list of conditions and the following disclaimer in the</span> ! 23: 00016 <span class="comment"> * documentation and/or other materials provided with the distribution.</span> ! 24: 00017 <span class="comment"> *</span> ! 25: 00018 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND</span> ! 26: 00019 <span class="comment"> * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</span> ! 27: 00020 <span class="comment"> * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span> ! 28: 00021 <span class="comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE</span> ! 29: 00022 <span class="comment"> * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span> ! 30: 00023 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS</span> ! 31: 00024 <span class="comment"> * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</span> ! 32: 00025 <span class="comment"> * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</span> ! 33: 00026 <span class="comment"> * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY</span> ! 34: 00027 <span class="comment"> * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</span> ! 35: 00028 <span class="comment"> * SUCH DAMAGE.</span> ! 36: 00029 <span class="comment"> *</span> ! 37: 00030 <span class="comment"> */</span> ! 38: 00031 ! 39: 00032 <span class="preprocessor">#ifndef __LIBNET_MACROS_H</span> ! 40: 00033 <span class="preprocessor"></span><span class="preprocessor">#define __LIBNET_MACROS_H</span> ! 41: 00034 <span class="preprocessor"></span> ! 42: 00039 <span class="comment">/* for systems without snprintf */</span> ! 43: 00040 <span class="preprocessor">#if defined(NO_SNPRINTF)</span> ! 44: 00041 <span class="preprocessor"></span><span class="preprocessor">#define snprintf(buf, len, args...) sprintf(buf, ##args)</span> ! 45: 00042 <span class="preprocessor"></span><span class="preprocessor">#endif</span> ! 46: 00043 <span class="preprocessor"></span> ! 47: 00044 ! 48: <a name="l00049"></a><a class="code" href="libnet-macros_8h.html#a0">00049</a> <span class="preprocessor">#define LIBNET_DONT_RESOLVE 0</span> ! 49: 00050 <span class="preprocessor"></span> ! 50: <a name="l00055"></a><a class="code" href="libnet-macros_8h.html#a1">00055</a> <span class="preprocessor">#define LIBNET_RESOLVE 1</span> ! 51: 00056 <span class="preprocessor"></span> ! 52: <a name="l00060"></a><a class="code" href="libnet-macros_8h.html#a2">00060</a> <span class="preprocessor">#define LIBNET_ON 0</span> ! 53: 00061 <span class="preprocessor"></span> ! 54: <a name="l00065"></a><a class="code" href="libnet-macros_8h.html#a3">00065</a> <span class="preprocessor">#define LIBNET_OFF 1</span> ! 55: 00066 <span class="preprocessor"></span> ! 56: 00070 <span class="preprocessor">#ifndef IN6ADDR_ERROR_INIT</span> ! 57: <a name="l00071"></a><a class="code" href="libnet-macros_8h.html#a4">00071</a> <span class="preprocessor"></span><span class="preprocessor">#define IN6ADDR_ERROR_INIT { { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \</span> ! 58: 00072 <span class="preprocessor"> 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \</span> ! 59: 00073 <span class="preprocessor"> 0xff, 0xff } } }</span> ! 60: 00074 <span class="preprocessor"></span><span class="preprocessor">#endif</span> ! 61: 00075 <span class="preprocessor"></span> ! 62: <a name="l00079"></a><a class="code" href="libnet-macros_8h.html#a5">00079</a> <span class="preprocessor">#define LIBNET_PR2 0</span> ! 63: 00080 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_PR8 1</span> ! 64: 00081 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_PR16 2</span> ! 65: 00082 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_PRu16 3</span> ! 66: 00083 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_PR32 4</span> ! 67: 00084 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_PRu32 5</span> ! 68: 00085 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_PRAND_MAX 0xffffffff</span> ! 69: 00086 <span class="preprocessor"></span> ! 70: <a name="l00090"></a><a class="code" href="libnet-macros_8h.html#a12">00090</a> <span class="preprocessor">#define LIBNET_MAX_PACKET 0xffff</span> ! 71: 00091 <span class="preprocessor"></span><span class="preprocessor">#ifndef IP_MAXPACKET</span> ! 72: 00092 <span class="preprocessor"></span><span class="preprocessor">#define IP_MAXPACKET 0xffff</span> ! 73: 00093 <span class="preprocessor"></span><span class="preprocessor">#endif</span> ! 74: 00094 <span class="preprocessor"></span> ! 75: 00095 ! 76: 00096 <span class="comment">/* ethernet addresses are 6 octets long */</span> ! 77: 00097 <span class="preprocessor">#ifndef ETHER_ADDR_LEN</span> ! 78: 00098 <span class="preprocessor"></span><span class="preprocessor">#define ETHER_ADDR_LEN 0x6</span> ! 79: 00099 <span class="preprocessor"></span><span class="preprocessor">#endif</span> ! 80: 00100 <span class="preprocessor"></span> ! 81: 00101 <span class="comment">/* FDDI addresses are 6 octets long */</span> ! 82: 00102 <span class="preprocessor">#ifndef FDDI_ADDR_LEN</span> ! 83: 00103 <span class="preprocessor"></span><span class="preprocessor">#define FDDI_ADDR_LEN 0x6</span> ! 84: 00104 <span class="preprocessor"></span><span class="preprocessor">#endif</span> ! 85: 00105 <span class="preprocessor"></span> ! 86: 00106 <span class="comment">/* token ring addresses are 6 octets long */</span> ! 87: 00107 <span class="preprocessor">#ifndef TOKEN_RING_ADDR_LEN</span> ! 88: 00108 <span class="preprocessor"></span><span class="preprocessor">#define TOKEN_RING_ADDR_LEN 0x6</span> ! 89: 00109 <span class="preprocessor"></span><span class="preprocessor">#endif</span> ! 90: 00110 <span class="preprocessor"></span> ! 91: 00111 <span class="comment">/* LLC Organization Code is 3 bytes long */</span> ! 92: 00112 <span class="preprocessor">#define LIBNET_ORG_CODE_SIZE 0x3</span> ! 93: 00113 <span class="preprocessor"></span> ! 94: <a name="l00117"></a><a class="code" href="libnet-macros_8h.html#a18">00117</a> <span class="preprocessor">#define LIBNET_ERRBUF_SIZE 0x100</span> ! 95: 00118 <span class="preprocessor"></span> ! 96: <a name="l00122"></a><a class="code" href="libnet-macros_8h.html#a19">00122</a> <span class="preprocessor">#define LIBNET_MAXOPTION_SIZE 0x28</span> ! 97: 00123 <span class="preprocessor"></span> ! 98: 00124 <span class="comment">/* some BSD variants have this endianess problem */</span> ! 99: 00125 <span class="preprocessor">#if (LIBNET_BSD_BYTE_SWAP)</span> ! 100: 00126 <span class="preprocessor"></span><span class="preprocessor">#define FIX(n) ntohs(n)</span> ! 101: 00127 <span class="preprocessor"></span><span class="preprocessor">#define UNFIX(n) htons(n)</span> ! 102: 00128 <span class="preprocessor"></span><span class="preprocessor">#else</span> ! 103: 00129 <span class="preprocessor"></span><span class="preprocessor">#define FIX(n) (n)</span> ! 104: 00130 <span class="preprocessor"></span><span class="preprocessor">#define UNFIX(n) (n)</span> ! 105: 00131 <span class="preprocessor"></span><span class="preprocessor">#endif</span> ! 106: 00132 <span class="preprocessor"></span> ! 107: 00133 <span class="comment">/* used internally for checksum stuff */</span> ! 108: 00134 <span class="preprocessor">#define LIBNET_CKSUM_CARRY(x) \</span> ! 109: 00135 <span class="preprocessor"> (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff))</span> ! 110: 00136 <span class="preprocessor"></span> ! 111: 00137 <span class="comment">/* used interally for OSPF stuff */</span> ! 112: 00138 <span class="preprocessor">#define LIBNET_OSPF_AUTHCPY(x, y) \</span> ! 113: 00139 <span class="preprocessor"> memcpy((u_int8_t *)x, (u_int8_t *)y, sizeof(y))</span> ! 114: 00140 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_OSPF_CKSUMBUF(x, y) \</span> ! 115: 00141 <span class="preprocessor"> memcpy((u_int8_t *)x, (u_int8_t *)y, sizeof(y)) </span> ! 116: 00142 <span class="preprocessor"></span> ! 117: 00143 <span class="comment">/* used internally for NTP leap indicator, version, and mode */</span> ! 118: 00144 <span class="preprocessor">#define LIBNET_NTP_DO_LI_VN_MODE(li, vn, md) \</span> ! 119: 00145 <span class="preprocessor"> ((u_int8_t)((((li) << 6) & 0xc0) | (((vn) << 3) & 0x38) | ((md) & 0x7)))</span> ! 120: 00146 <span class="preprocessor"></span> ! 121: 00147 <span class="comment">/* Not all systems have IFF_LOOPBACK */</span> ! 122: 00148 <span class="preprocessor">#ifdef IFF_LOOPBACK</span> ! 123: 00149 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK)</span> ! 124: 00150 <span class="preprocessor"></span><span class="preprocessor">#else</span> ! 125: 00151 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_ISLOOPBACK(p) (strcmp((p)->ifr_name, "lo0") == 0)</span> ! 126: 00152 <span class="preprocessor"></span><span class="preprocessor">#endif</span> ! 127: 00153 <span class="preprocessor"></span> ! 128: 00154 <span class="comment">/* advanced mode check */</span> ! 129: 00155 <span class="preprocessor">#define LIBNET_ISADVMODE(x) (x & 0x08)</span> ! 130: 00156 <span class="preprocessor"></span> ! 131: 00157 <span class="comment">/* context queue macros and constants */</span> ! 132: 00158 <span class="preprocessor">#define LIBNET_LABEL_SIZE 64</span> ! 133: 00159 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_LABEL_DEFAULT "cardshark"</span> ! 134: 00160 <span class="preprocessor"></span><span class="preprocessor">#define CQ_LOCK_UNLOCKED (u_int)0x00000000</span> ! 135: 00161 <span class="preprocessor"></span><span class="preprocessor">#define CQ_LOCK_READ (u_int)0x00000001</span> ! 136: 00162 <span class="preprocessor"></span><span class="preprocessor">#define CQ_LOCK_WRITE (u_int)0x00000002</span> ! 137: 00163 <span class="preprocessor"></span> ! 138: <a name="l00169"></a><a class="code" href="libnet-macros_8h.html#a33">00169</a> <span class="preprocessor">#define for_each_context_in_cq(l) \</span> ! 139: 00170 <span class="preprocessor"> for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next())</span> ! 140: 00171 <span class="preprocessor"></span> ! 141: 00172 <span class="comment">/* return 1 if write lock is set on cq */</span> ! 142: 00173 <span class="preprocessor">#define cq_is_wlocked() (l_cqd.cq_lock & CQ_LOCK_WRITE)</span> ! 143: 00174 <span class="preprocessor"></span> ! 144: 00175 <span class="comment">/* return 1 if read lock is set on cq */</span> ! 145: 00176 <span class="preprocessor">#define cq_is_rlocked() (l_cqd.cq_lock & CQ_LOCK_READ)</span> ! 146: 00177 <span class="preprocessor"></span> ! 147: 00178 <span class="comment">/* return 1 if any lock is set on cq */</span> ! 148: 00179 <span class="preprocessor">#define cq_is_locked() (l_cqd.cq_lock & (CQ_LOCK_READ | CQ_LOCK_WRITE))</span> ! 149: 00180 <span class="preprocessor"></span> ! 150: 00181 <span class="comment">/* check if a context queue is locked */</span> ! 151: 00182 <span class="preprocessor">#define check_cq_lock(x) (l_cqd.cq_lock & x)</span> ! 152: 00183 <span class="preprocessor"></span> ! 153: 00184 <span class="preprocessor">#endif </span><span class="comment">/* __LIBNET_MACROS_H */</span> ! 154: 00185 ! 155: 00186 <span class="comment">/* EOF */</span> ! 156: </pre></div><hr size="1"><address style="align: right;"><small>Generated on Wed Mar 10 13:23:37 2004 for libnet by ! 157: <a href="http://www.doxygen.org/index.html"> ! 158: <img src="doxygen.png" alt="doxygen" align="middle" border=0 > ! 159: </a>1.3.4 </small></address> ! 160: </body> ! 161: </html>