Annotation of embedaddon/libnet/doc/html/libnet-macros_8h_source.html, revision 1.1.1.1

1.1       misho       1: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                      2: <html xmlns="http://www.w3.org/1999/xhtml">
                      3: <head>
                      4: <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
                      5: <title>libnet: libnet-macros.h Source File</title>
                      6: <link href="tabs.css" rel="stylesheet" type="text/css"/>
                      7: <link href="doxygen.css" rel="stylesheet" type="text/css"/>
                      8: </head>
                      9: <body>
                     10: <!-- Generated by Doxygen 1.7.4 -->
                     11: <div id="top">
                     12: <div id="titlearea">
                     13: <table cellspacing="0" cellpadding="0">
                     14:  <tbody>
                     15:  <tr style="height: 56px;">
                     16:   <td style="padding-left: 0.5em;">
                     17:    <div id="projectname">libnet&#160;<span id="projectnumber">1.1</span></div>
                     18:   </td>
                     19:  </tr>
                     20:  </tbody>
                     21: </table>
                     22: </div>
                     23:   <div id="navrow1" class="tabs">
                     24:     <ul class="tablist">
                     25:       <li><a href="index.html"><span>Main&#160;Page</span></a></li>
                     26:       <li class="current"><a href="files.html"><span>Files</span></a></li>
                     27:     </ul>
                     28:   </div>
                     29:   <div id="navrow2" class="tabs2">
                     30:     <ul class="tablist">
                     31:       <li><a href="files.html"><span>File&#160;List</span></a></li>
                     32:       <li><a href="globals.html"><span>Globals</span></a></li>
                     33:     </ul>
                     34:   </div>
                     35: <div class="header">
                     36:   <div class="headertitle">
                     37: <div class="title">libnet-macros.h</div>  </div>
                     38: </div>
                     39: <div class="contents">
                     40: <a href="libnet-macros_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
                     41: <a name="l00002"></a>00002 <span class="comment"> *  $Id: libnet-macros.h,v 1.7 2004/04/13 17:32:28 mike Exp $</span>
                     42: <a name="l00003"></a>00003 <span class="comment"> *</span>
                     43: <a name="l00004"></a>00004 <span class="comment"> *  libnet-macros.h - Network routine library macro header file</span>
                     44: <a name="l00005"></a>00005 <span class="comment"> *</span>
                     45: <a name="l00006"></a>00006 <span class="comment"> *  Copyright (c) 1998 - 2004 Mike D. Schiffman &lt;mike@infonexus.com&gt;</span>
                     46: <a name="l00007"></a>00007 <span class="comment"> *  All rights reserved.</span>
                     47: <a name="l00008"></a>00008 <span class="comment"> *</span>
                     48: <a name="l00009"></a>00009 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
                     49: <a name="l00010"></a>00010 <span class="comment"> * modification, are permitted provided that the following conditions</span>
                     50: <a name="l00011"></a>00011 <span class="comment"> * are met:</span>
                     51: <a name="l00012"></a>00012 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
                     52: <a name="l00013"></a>00013 <span class="comment"> *    notice, this list of conditions and the following disclaimer.</span>
                     53: <a name="l00014"></a>00014 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span>
                     54: <a name="l00015"></a>00015 <span class="comment"> *    notice, this list of conditions and the following disclaimer in the</span>
                     55: <a name="l00016"></a>00016 <span class="comment"> *    documentation and/or other materials provided with the distribution.</span>
                     56: <a name="l00017"></a>00017 <span class="comment"> *</span>
                     57: <a name="l00018"></a>00018 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS&#39;&#39; AND</span>
                     58: <a name="l00019"></a>00019 <span class="comment"> * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</span>
                     59: <a name="l00020"></a>00020 <span class="comment"> * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
                     60: <a name="l00021"></a>00021 <span class="comment"> * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE</span>
                     61: <a name="l00022"></a>00022 <span class="comment"> * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
                     62: <a name="l00023"></a>00023 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS</span>
                     63: <a name="l00024"></a>00024 <span class="comment"> * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</span>
                     64: <a name="l00025"></a>00025 <span class="comment"> * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</span>
                     65: <a name="l00026"></a>00026 <span class="comment"> * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY</span>
                     66: <a name="l00027"></a>00027 <span class="comment"> * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</span>
                     67: <a name="l00028"></a>00028 <span class="comment"> * SUCH DAMAGE.</span>
                     68: <a name="l00029"></a>00029 <span class="comment"> *</span>
                     69: <a name="l00030"></a>00030 <span class="comment"> */</span>
                     70: <a name="l00031"></a>00031 
                     71: <a name="l00032"></a>00032 <span class="preprocessor">#ifndef __LIBNET_MACROS_H</span>
                     72: <a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define __LIBNET_MACROS_H</span>
                     73: <a name="l00034"></a>00034 <span class="preprocessor"></span>
                     74: <a name="l00039"></a>00039 <span class="comment">/* for systems without snprintf */</span>
                     75: <a name="l00040"></a>00040 <span class="preprocessor">#if defined(NO_SNPRINTF)</span>
                     76: <a name="l00041"></a>00041 <span class="preprocessor"></span><span class="preprocessor">#define snprintf(buf, len, args...) sprintf(buf, ##args)</span>
                     77: <a name="l00042"></a>00042 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
                     78: <a name="l00043"></a>00043 <span class="preprocessor"></span>
                     79: <a name="l00044"></a>00044 
                     80: <a name="l00049"></a><a class="code" href="libnet-macros_8h.html#ac67cb6e9b00fd492cc3a9247e9477d87">00049</a> <span class="preprocessor">#define LIBNET_DONT_RESOLVE 0</span>
                     81: <a name="l00050"></a>00050 <span class="preprocessor"></span>
                     82: <a name="l00055"></a><a class="code" href="libnet-macros_8h.html#a6733960f6981f1930b2d1a489df89cc7">00055</a> <span class="preprocessor">#define LIBNET_RESOLVE      1</span>
                     83: <a name="l00056"></a>00056 <span class="preprocessor"></span>
                     84: <a name="l00060"></a><a class="code" href="libnet-macros_8h.html#a5ff9536ca9bbe6f73f69bec817962742">00060</a> <span class="preprocessor">#define LIBNET_ON   0</span>
                     85: <a name="l00061"></a>00061 <span class="preprocessor"></span>
                     86: <a name="l00065"></a><a class="code" href="libnet-macros_8h.html#af87da67c016a9791d256c2d71bf0b0ac">00065</a> <span class="preprocessor">#define LIBNET_OFF  1</span>
                     87: <a name="l00066"></a>00066 <span class="preprocessor"></span>
                     88: <a name="l00070"></a>00070 <span class="preprocessor">#ifndef IN6ADDR_ERROR_INIT</span>
                     89: <a name="l00071"></a><a class="code" href="libnet-macros_8h.html#a9c76fe8da8e411fe1db9f75583dc1b8a">00071</a> <span class="preprocessor"></span><span class="preprocessor">#define IN6ADDR_ERROR_INIT { { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \</span>
                     90: <a name="l00072"></a>00072 <span class="preprocessor">                                 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \</span>
                     91: <a name="l00073"></a>00073 <span class="preprocessor">                                 0xff, 0xff } } }</span>
                     92: <a name="l00074"></a>00074 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
                     93: <a name="l00075"></a>00075 <span class="preprocessor"></span>
                     94: <a name="l00079"></a><a class="code" href="libnet-macros_8h.html#a96a6017948aa76e5a5d415c3227348df">00079</a> <span class="preprocessor">#define LIBNET_PR2          0</span>
                     95: <a name="l00080"></a>00080 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_PR8          1</span>
                     96: <a name="l00081"></a>00081 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_PR16         2</span>
                     97: <a name="l00082"></a>00082 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_PRu16        3</span>
                     98: <a name="l00083"></a>00083 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_PR32         4</span>
                     99: <a name="l00084"></a>00084 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_PRu32        5</span>
                    100: <a name="l00085"></a>00085 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_PRAND_MAX    0xffffffff</span>
                    101: <a name="l00086"></a>00086 <span class="preprocessor"></span>
                    102: <a name="l00090"></a><a class="code" href="libnet-macros_8h.html#ac7301c95aa36d66e8904979650b5189d">00090</a> <span class="preprocessor">#define LIBNET_MAX_PACKET   0xffff</span>
                    103: <a name="l00091"></a>00091 <span class="preprocessor"></span><span class="preprocessor">#ifndef IP_MAXPACKET</span>
                    104: <a name="l00092"></a>00092 <span class="preprocessor"></span><span class="preprocessor">#define IP_MAXPACKET        0xffff</span>
                    105: <a name="l00093"></a>00093 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
                    106: <a name="l00094"></a>00094 <span class="preprocessor"></span>
                    107: <a name="l00095"></a>00095 
                    108: <a name="l00096"></a>00096 <span class="comment">/* ethernet addresses are 6 octets long */</span>
                    109: <a name="l00097"></a>00097 <span class="preprocessor">#ifndef ETHER_ADDR_LEN</span>
                    110: <a name="l00098"></a>00098 <span class="preprocessor"></span><span class="preprocessor">#define ETHER_ADDR_LEN      0x6</span>
                    111: <a name="l00099"></a>00099 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
                    112: <a name="l00100"></a>00100 <span class="preprocessor"></span>
                    113: <a name="l00101"></a>00101 <span class="comment">/* FDDI addresses are 6 octets long */</span>
                    114: <a name="l00102"></a>00102 <span class="preprocessor">#ifndef FDDI_ADDR_LEN</span>
                    115: <a name="l00103"></a>00103 <span class="preprocessor"></span><span class="preprocessor">#define FDDI_ADDR_LEN       0x6</span>
                    116: <a name="l00104"></a>00104 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
                    117: <a name="l00105"></a>00105 <span class="preprocessor"></span>
                    118: <a name="l00106"></a>00106 <span class="comment">/* token ring addresses are 6 octets long */</span>
                    119: <a name="l00107"></a>00107 <span class="preprocessor">#ifndef TOKEN_RING_ADDR_LEN</span>
                    120: <a name="l00108"></a>00108 <span class="preprocessor"></span><span class="preprocessor">#define TOKEN_RING_ADDR_LEN 0x6</span>
                    121: <a name="l00109"></a>00109 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
                    122: <a name="l00110"></a>00110 <span class="preprocessor"></span>
                    123: <a name="l00111"></a>00111 <span class="comment">/* LLC Organization Code is 3 bytes long */</span>
                    124: <a name="l00112"></a>00112 <span class="preprocessor">#define LIBNET_ORG_CODE_SIZE  0x3</span>
                    125: <a name="l00113"></a>00113 <span class="preprocessor"></span>
                    126: <a name="l00117"></a><a class="code" href="libnet-macros_8h.html#a2d720375e2ef5a85a62d6069283a5223">00117</a> <span class="preprocessor">#define LIBNET_ERRBUF_SIZE      0x100</span>
                    127: <a name="l00118"></a>00118 <span class="preprocessor"></span>
                    128: <a name="l00122"></a><a class="code" href="libnet-macros_8h.html#ae9cd154f8cb482809ee456b6ac43dea5">00122</a> <span class="preprocessor">#define LIBNET_MAXOPTION_SIZE   0x28</span>
                    129: <a name="l00123"></a>00123 <span class="preprocessor"></span>
                    130: <a name="l00124"></a>00124 <span class="comment">/* some BSD variants have this endianess problem */</span>
                    131: <a name="l00125"></a>00125 <span class="preprocessor">#if (LIBNET_BSD_BYTE_SWAP)</span>
                    132: <a name="l00126"></a>00126 <span class="preprocessor"></span><span class="preprocessor">#define FIX(n)      ntohs(n)</span>
                    133: <a name="l00127"></a>00127 <span class="preprocessor"></span><span class="preprocessor">#define UNFIX(n)    htons(n)</span>
                    134: <a name="l00128"></a>00128 <span class="preprocessor"></span><span class="preprocessor">#else</span>
                    135: <a name="l00129"></a>00129 <span class="preprocessor"></span><span class="preprocessor">#define FIX(n)      (n)</span>
                    136: <a name="l00130"></a>00130 <span class="preprocessor"></span><span class="preprocessor">#define UNFIX(n)    (n)</span>
                    137: <a name="l00131"></a>00131 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
                    138: <a name="l00132"></a>00132 <span class="preprocessor"></span>
                    139: <a name="l00133"></a>00133 <span class="comment">/* used internally for packet builders */</span>
                    140: <a name="l00134"></a>00134 <span class="preprocessor">#define LIBNET_DO_PAYLOAD(l, p)                                              \</span>
                    141: <a name="l00135"></a>00135 <span class="preprocessor">if (payload_s &amp;&amp; !payload)                                                   \</span>
                    142: <a name="l00136"></a>00136 <span class="preprocessor">{                                                                            \</span>
                    143: <a name="l00137"></a>00137 <span class="preprocessor">    snprintf(l-&gt;err_buf, LIBNET_ERRBUF_SIZE,                                 \</span>
                    144: <a name="l00138"></a>00138 <span class="preprocessor">            &quot;%s(): payload inconsistency\n&quot;, __func__);                      \</span>
                    145: <a name="l00139"></a>00139 <span class="preprocessor">    goto bad;                                                                \</span>
                    146: <a name="l00140"></a>00140 <span class="preprocessor">}                                                                            \</span>
                    147: <a name="l00141"></a>00141 <span class="preprocessor">if (payload_s)                                                               \</span>
                    148: <a name="l00142"></a>00142 <span class="preprocessor">{                                                                            \</span>
                    149: <a name="l00143"></a>00143 <span class="preprocessor">    n = libnet_pblock_append(l, p, payload, payload_s);                      \</span>
                    150: <a name="l00144"></a>00144 <span class="preprocessor">    if (n == (uint32_t) - 1)                                                 \</span>
                    151: <a name="l00145"></a>00145 <span class="preprocessor">    {                                                                        \</span>
                    152: <a name="l00146"></a>00146 <span class="preprocessor">        goto bad;                                                            \</span>
                    153: <a name="l00147"></a>00147 <span class="preprocessor">    }                                                                        \</span>
                    154: <a name="l00148"></a>00148 <span class="preprocessor">}                                                                            \</span>
                    155: <a name="l00149"></a>00149 <span class="preprocessor"></span>
                    156: <a name="l00150"></a>00150 <span class="preprocessor"></span>
                    157: <a name="l00151"></a>00151 <span class="comment">/* used internally for checksum stuff */</span>
                    158: <a name="l00152"></a>00152 <span class="preprocessor">#define LIBNET_CKSUM_CARRY(x) \</span>
                    159: <a name="l00153"></a>00153 <span class="preprocessor">    (x = (x &gt;&gt; 16) + (x &amp; 0xffff), (~(x + (x &gt;&gt; 16)) &amp; 0xffff))</span>
                    160: <a name="l00154"></a>00154 <span class="preprocessor"></span>
                    161: <a name="l00155"></a>00155 <span class="comment">/* used interally for OSPF stuff */</span>
                    162: <a name="l00156"></a>00156 <span class="preprocessor">#define LIBNET_OSPF_AUTHCPY(x, y) \</span>
                    163: <a name="l00157"></a>00157 <span class="preprocessor">    memcpy((uint8_t *)x, (uint8_t *)y, sizeof(y))</span>
                    164: <a name="l00158"></a>00158 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_OSPF_CKSUMBUF(x, y) \</span>
                    165: <a name="l00159"></a>00159 <span class="preprocessor">    memcpy((uint8_t *)x, (uint8_t *)y, sizeof(y))  </span>
                    166: <a name="l00160"></a>00160 <span class="preprocessor"></span>
                    167: <a name="l00161"></a>00161 <span class="comment">/* used internally for NTP leap indicator, version, and mode */</span>
                    168: <a name="l00162"></a>00162 <span class="preprocessor">#define LIBNET_NTP_DO_LI_VN_MODE(li, vn, md) \</span>
                    169: <a name="l00163"></a>00163 <span class="preprocessor">    ((uint8_t)((((li) &lt;&lt; 6) &amp; 0xc0) | (((vn) &lt;&lt; 3) &amp; 0x38) | ((md) &amp; 0x7)))</span>
                    170: <a name="l00164"></a>00164 <span class="preprocessor"></span>
                    171: <a name="l00165"></a>00165 <span class="comment">/* Not all systems have IFF_LOOPBACK */</span>
                    172: <a name="l00166"></a>00166 <span class="preprocessor">#ifdef IFF_LOOPBACK</span>
                    173: <a name="l00167"></a>00167 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_ISLOOPBACK(p) ((p)-&gt;ifr_flags &amp; IFF_LOOPBACK)</span>
                    174: <a name="l00168"></a>00168 <span class="preprocessor"></span><span class="preprocessor">#else</span>
                    175: <a name="l00169"></a>00169 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_ISLOOPBACK(p) (strcmp((p)-&gt;ifr_name, &quot;lo&quot;) == 0)</span>
                    176: <a name="l00170"></a>00170 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
                    177: <a name="l00171"></a>00171 <span class="preprocessor"></span>
                    178: <a name="l00172"></a>00172 <span class="comment">/* advanced mode check */</span>
                    179: <a name="l00173"></a>00173 <span class="preprocessor">#define LIBNET_ISADVMODE(x) (x &amp; 0x08)</span>
                    180: <a name="l00174"></a>00174 <span class="preprocessor"></span>
                    181: <a name="l00175"></a>00175 <span class="comment">/* context queue macros and constants */</span>
                    182: <a name="l00176"></a>00176 <span class="preprocessor">#define LIBNET_LABEL_SIZE   64</span>
                    183: <a name="l00177"></a>00177 <span class="preprocessor"></span><span class="preprocessor">#define LIBNET_LABEL_DEFAULT &quot;cardshark&quot;</span>
                    184: <a name="l00178"></a>00178 <span class="preprocessor"></span><span class="preprocessor">#define CQ_LOCK_UNLOCKED    (u_int)0x00000000</span>
                    185: <a name="l00179"></a>00179 <span class="preprocessor"></span><span class="preprocessor">#define CQ_LOCK_READ        (u_int)0x00000001</span>
                    186: <a name="l00180"></a>00180 <span class="preprocessor"></span><span class="preprocessor">#define CQ_LOCK_WRITE       (u_int)0x00000002</span>
                    187: <a name="l00181"></a>00181 <span class="preprocessor"></span>
                    188: <a name="l00187"></a><a class="code" href="libnet-macros_8h.html#af36eb84eee10c525720134cfadb50a3e">00187</a> <span class="preprocessor">#define for_each_context_in_cq(l) \</span>
                    189: <a name="l00188"></a>00188 <span class="preprocessor">    for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next())</span>
                    190: <a name="l00189"></a>00189 <span class="preprocessor"></span>
                    191: <a name="l00190"></a>00190 <span class="comment">/* return 1 if write lock is set on cq */</span>
                    192: <a name="l00191"></a>00191 <span class="preprocessor">#define cq_is_wlocked() (l_cqd.cq_lock &amp; CQ_LOCK_WRITE)</span>
                    193: <a name="l00192"></a>00192 <span class="preprocessor"></span>
                    194: <a name="l00193"></a>00193 <span class="comment">/* return 1 if read lock is set on cq */</span>
                    195: <a name="l00194"></a>00194 <span class="preprocessor">#define cq_is_rlocked() (l_cqd.cq_lock &amp; CQ_LOCK_READ)</span>
                    196: <a name="l00195"></a>00195 <span class="preprocessor"></span>
                    197: <a name="l00196"></a>00196 <span class="comment">/* return 1 if any lock is set on cq */</span>
                    198: <a name="l00197"></a>00197 <span class="preprocessor">#define cq_is_locked() (l_cqd.cq_lock &amp; (CQ_LOCK_READ | CQ_LOCK_WRITE))</span>
                    199: <a name="l00198"></a>00198 <span class="preprocessor"></span>
                    200: <a name="l00199"></a>00199 <span class="comment">/* check if a context queue is locked */</span>
                    201: <a name="l00200"></a>00200 <span class="preprocessor">#define check_cq_lock(x) (l_cqd.cq_lock &amp; x)</span>
                    202: <a name="l00201"></a>00201 <span class="preprocessor"></span>
                    203: <a name="l00202"></a>00202 <span class="preprocessor">#endif  </span><span class="comment">/* __LIBNET_MACROS_H */</span>
                    204: <a name="l00203"></a>00203 
                    205: <a name="l00204"></a>00204 <span class="comment">/* EOF */</span>
                    206: </pre></div></div>
                    207: </div>
                    208: <hr class="footer"/><address class="footer"><small>Generated on Thu Mar 29 2012 14:19:18 for libnet by&#160;
                    209: <a href="http://www.doxygen.org/index.html">
                    210: <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
                    211: </body>
                    212: </html>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>