<!-- iframe showing the search results (closed by default) -->
<divid="MSearchResultsWindow">
<iframesrc="javascript:void(0)"frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<divclass="header">
<divclass="headertitle">
<divclass="title">endianness.h</div></div>
</div><!--header-->
<divclass="contents">
<ahref="../../dc/d3e/endianness_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="comment">/* This file is part of Netsukuku</span></div>
<divclass="line"><aname="l00002"></a><spanclass="lineno"> 2</span> <spanclass="comment"> * (c) Copyright 2005 Andrea Lo Pumo aka AlpT <alpt@freaknet.org></span></div>
<divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment"> * This source code is free software; you can redistribute it and/or</span></div>
<divclass="line"><aname="l00005"></a><spanclass="lineno"> 5</span> <spanclass="comment"> * modify it under the terms of the GNU General Public License as published</span></div>
<divclass="line"><aname="l00006"></a><spanclass="lineno"> 6</span> <spanclass="comment"> * by the Free Software Foundation; either version 2 of the License,</span></div>
<divclass="line"><aname="l00007"></a><spanclass="lineno"> 7</span> <spanclass="comment"> * or (at your option) any later version.</span></div>
<divclass="line"><aname="l00009"></a><spanclass="lineno"> 9</span> <spanclass="comment"> * This source code is distributed in the hope that it will be useful,</span></div>
<divclass="line"><aname="l00010"></a><spanclass="lineno"> 10</span> <spanclass="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
<divclass="line"><aname="l00011"></a><spanclass="lineno"> 11</span> <spanclass="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</span></div>
<divclass="line"><aname="l00012"></a><spanclass="lineno"> 12</span> <spanclass="comment"> * Please refer to the GNU Public License for more details.</span></div>
<divclass="line"><aname="l00014"></a><spanclass="lineno"> 14</span> <spanclass="comment"> * You should have received a copy of the GNU Public License along with</span></div>
<divclass="line"><aname="l00015"></a><spanclass="lineno"> 15</span> <spanclass="comment"> * this source code; if not, write to:</span></div>
<divclass="line"><aname="l00016"></a><spanclass="lineno"> 16</span> <spanclass="comment"> * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span></div>
<divclass="line"><aname="l00022"></a><spanclass="lineno"><aclass="line"href="../../dc/d3e/endianness_8h.html#a4819d5c9e9bbd67177e75af5b967d07f"> 22</a></span> <spanclass="preprocessor">#define MAX_INTS_PER_STRUCT 8 </span><spanclass="comment">/* The maximum number of short/int variables </span></div>
<divclass="line"><aname="l00023"></a><spanclass="lineno"> 23</span> <spanclass="comment"> present in a struct */</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00025"></a><spanclass="lineno"><aclass="line"href="../../dc/d3e/endianness_8h.html#aab0cb83658366f074119d70b2838c7d2"> 25</a></span> <spanclass="preprocessor">#define IINFO_DYNAMIC_VALUE -1 </span><spanclass="comment">/* This define is used to fill part in a </span></div>
<divclass="line"><aname="l00026"></a><spanclass="lineno"> 26</span> <spanclass="comment"> int_info struct that must be set each time. </span></div>
<divclass="line"><aname="l00027"></a><spanclass="lineno"> 27</span> <spanclass="comment"> If that part is not set, -1 will remain, and</span></div>
<divclass="line"><aname="l00028"></a><spanclass="lineno"> 28</span> <spanclass="comment"> the int_info functions will call fatal(). </span></div>
<divclass="line"><aname="l00029"></a><spanclass="lineno"> 29</span> <spanclass="comment"> Therefore this is useful to track bugs. */</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00032"></a><spanclass="lineno"> 32</span> <spanclass="comment">/* flags for int_info.int_type */</span></div>
<divclass="line"><aname="l00033"></a><spanclass="lineno"><aclass="line"href="../../dc/d3e/endianness_8h.html#a73456c1719c10cac2a2abe52a6a616c8"> 33</a></span> <spanclass="preprocessor">#define INT_TYPE_VOID 0 </span><spanclass="comment">/* Emptiness is loneliness, and loneliness is </span></div>
<divclass="line"><aname="l00035"></a><spanclass="lineno"><aclass="line"href="../../dc/d3e/endianness_8h.html#acc663d0291dd4a32c1dfbed3167bd58b"> 35</a></span> <spanclass="preprocessor">#define INT_TYPE_32BIT 1 </span><spanclass="comment">/* The int var is of 32 bits */</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00036"></a><spanclass="lineno"><aclass="line"href="../../dc/d3e/endianness_8h.html#a66b75e81c28419f622f82e631e5da9bc"> 36</a></span> <spanclass="preprocessor">#define INT_TYPE_16BIT (1<<1) </span><spanclass="comment">/* The int var is of 16 bits */</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00037"></a><spanclass="lineno"><aclass="line"href="../../dc/d3e/endianness_8h.html#a043f68bfd6e31ca8f93c6981845da608"> 37</a></span> <spanclass="preprocessor">#define INT_TYPE_WORDS (1<<2) </span><spanclass="comment">/* The int var is composed by an array of ints,</span></div>
<divclass="line"><aname="l00038"></a><spanclass="lineno"> 38</span> <spanclass="comment"> like the ipv6 ip (struct in6_addr) */</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00039"></a><spanclass="lineno"><aclass="line"href="../../dc/d3e/endianness_8h.html#a0e1661cd778f08629b53f59a05a4c9b4"> 39</a></span> <spanclass="preprocessor">#define INT_TYPE_NETWORK (1<<3) </span><spanclass="comment">/* The int var is stored in network order */</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00042"></a><spanclass="lineno"> 42</span> <spanclass="comment"> * int_info: this struct is used to keep the information about the int/short</span></div>
<divclass="line"><aname="l00043"></a><spanclass="lineno"> 43</span> <spanclass="comment"> * variables present in a struct. It is useful to convert all the int/short</span></div>
<divclass="line"><aname="l00044"></a><spanclass="lineno"> 44</span> <spanclass="comment"> * vars in another endian format with a simple function. </span></div>
<divclass="line"><aname="l00045"></a><spanclass="lineno"> 45</span> <spanclass="comment"> * WARNING: There is a drawback: the struct must have the __packed__</span></div>
<divclass="line"><aname="l00046"></a><spanclass="lineno"> 46</span> <spanclass="comment"> * attribute (but since we are using this for packet structs we don't care).</span></div>
<divclass="line"><aname="l00048"></a><spanclass="lineno"> 48</span> <spanclass="comment"> * Here there is an example which show how to use this int_info:</span></div>
<divclass="line"><aname="l00060"></a><spanclass="lineno"> 60</span> <spanclass="comment"> * its int_info struct should be filled in this way:</span></div>
<divclass="line"><aname="l00071"></a><spanclass="lineno"> 71</span> <spanclass="comment">/* The total int/short vars present in the struct */</span></div>
<divclass="line"><aname="l00074"></a><spanclass="lineno"> 74</span> <spanclass="comment">/* Each member in the int_type array corresponds to a int/short var</span></div>
<divclass="line"><aname="l00075"></a><spanclass="lineno"> 75</span> <spanclass="comment"> * and it is set using the above INT_TYPE_ flags */</span></div>
<divclass="line"><aname="l00078"></a><spanclass="lineno"> 78</span> <spanclass="comment">/* Each member in the int_offset array specifies the amount of bytes</span></div>
<divclass="line"><aname="l00079"></a><spanclass="lineno"> 79</span> <spanclass="comment"> * to be added at the end of the struct to get the relative int/short</span></div>
<divclass="line"><aname="l00080"></a><spanclass="lineno"> 80</span> <spanclass="comment"> * var. */</span></div>
<divclass="line"><aname="l00083"></a><spanclass="lineno"> 83</span> <spanclass="comment">/* int_nmemb[x] is equal to the number of consecutive ints/shorts var,</span></div>
<divclass="line"><aname="l00084"></a><spanclass="lineno"> 84</span> <spanclass="comment"> * which start at the int_offset[x] offset. */</span></div>