<!-- 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">map.h</div></div>
</div><!--header-->
<divclass="contents">
<ahref="../../dc/db7/map_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 system</span></div>
<divclass="line"><aname="l00002"></a><spanclass="lineno"> 2</span> <spanclass="comment"> * (c) Copyright 2004 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="l00032"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#ab07fd06dfacd35ea0eda590a587e16de"> 32</a></span> <spanclass="preprocessor">#define MAP_ME 1 </span><spanclass="comment">/*The root_node, in other words, me ;)*/</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00033"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#a489c6023a9eb85ea80d386b7a883ee79"> 33</a></span> <spanclass="preprocessor">#define MAP_VOID (1<<1) </span><spanclass="comment">/*It indicates a non existent node*/</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00034"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#afdb9f404423b33ba9146aa8ca7a212a6"> 34</a></span> <spanclass="preprocessor">#define MAP_HNODE (1<<2) </span><spanclass="comment">/*Hooking node. The node is currently </span></div>
<divclass="line"><aname="l00036"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#a78da69344afe13ff516dffd4c4f9ae9d"> 36</a></span> <spanclass="preprocessor">#define MAP_BNODE (1<<3) </span><spanclass="comment">/*The node is a border_node. If this </span></div>
<divclass="line"><aname="l00037"></a><spanclass="lineno"> 37</span> <spanclass="comment"> flag is set to a root_node, this means </span></div>
<divclass="line"><aname="l00038"></a><spanclass="lineno"> 38</span> <spanclass="comment"> that we are a bnode at the root_node's </span></div>
<divclass="line"><aname="l00040"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#a9027b163f510219d4ffc89d66e458dce"> 40</a></span> <spanclass="preprocessor">#define MAP_ERNODE (1<<4) </span><spanclass="comment">/*It is an External Rnode*/</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00041"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#ac58470daf4e2889a210a352c205a9a09"> 41</a></span> <spanclass="preprocessor">#define MAP_GNODE (1<<5) </span><spanclass="comment">/*It is a gnode*/</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00042"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#a16c0ab03275a4f091ceee7bd7485afe7"> 42</a></span> <spanclass="preprocessor">#define MAP_RNODE (1<<6) </span><spanclass="comment">/*If a node has this set, it is one of the rnodes*/</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00043"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#a1a37271e61f2d3b0006a9ef003de3a93"> 43</a></span> <spanclass="preprocessor">#define MAP_UPDATE (1<<7) </span><spanclass="comment">/*If it is set, the corresponding route </span></div>
<divclass="line"><aname="l00044"></a><spanclass="lineno"> 44</span> <spanclass="comment"> in the krnl will be updated*/</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00045"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#a833e7d52f37340bf5b73d7467a1f55da"> 45</a></span> <spanclass="preprocessor">#define QSPN_CLOSED (1<<8) </span><spanclass="comment">/*This flag is set only to the rnodes, </span></div>
<divclass="line"><aname="l00046"></a><spanclass="lineno"> 46</span> <spanclass="comment"> it puts a link in a QSPN_CLOSED state*/</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00047"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#aeb2cab81af7de11090e177074ccb4991"> 47</a></span> <spanclass="preprocessor">#define QSPN_OPENED (1<<9) </span><spanclass="comment">/*It puts a link in a QSPN_OPEN state*/</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00048"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#a9e6b553ca3da299019f5cda91673e8b0"> 48</a></span> <spanclass="preprocessor">#define QSPN_OLD (1<<10) </span><spanclass="comment">/*If a node isn't updated by the current</span></div>
<divclass="line"><aname="l00049"></a><spanclass="lineno"> 49</span> <spanclass="comment"> qspn_round it is marked with QSPN_ROUND.</span></div>
<divclass="line"><aname="l00050"></a><spanclass="lineno"> 50</span> <spanclass="comment"> If in the next qspn_round the same node </span></div>
<divclass="line"><aname="l00051"></a><spanclass="lineno"> 51</span> <spanclass="comment"> isn't updated it is removed from the map.*/</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00052"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#a315a6384282db027ef71f3e0e8749b9d"> 52</a></span> <spanclass="preprocessor">#define QSPN_STARTER (1<<11) </span><spanclass="comment">/*The root node is marked with this flag</span></div>
<divclass="line"><aname="l00053"></a><spanclass="lineno"> 53</span> <spanclass="comment"> if it is a qspn_starter*/</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00054"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#afcf13f21445269106ab5f8fbcc2ea623"> 54</a></span> <spanclass="preprocessor">#define QSPN_OPENER (1<<12) </span><spanclass="comment">/*If the root_node sent a new qspn_open</span></div>
<divclass="line"><aname="l00055"></a><spanclass="lineno"> 55</span> <spanclass="comment"> it is a qspn_opener*/</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00056"></a><spanclass="lineno"><aclass="line"href="../../dc/db7/map_8h.html#a90db079e6ace4de99fa5d84b97c726f4"> 56</a></span> <spanclass="preprocessor">#define MAP_IGW (1<<13) </span><spanclass="comment">/*This node is an Internet gateway*/</span><spanclass="preprocessor"></span></div>
<divclass="line"><aname="l00062"></a><spanclass="lineno"> 62</span> <spanclass="comment"> * The map is an array of MAXGROUPNODE map_node structs. It is a generic map </span></div>
<divclass="line"><aname="l00063"></a><spanclass="lineno"> 63</span> <spanclass="comment"> * and it is used to keep the qspn_map, the internal map and the external map.</span></div>
<divclass="line"><aname="l00064"></a><spanclass="lineno"> 64</span> <spanclass="comment"> * The position in the map of each struct corresponds to its relative ip.</span></div>
<divclass="line"><aname="l00065"></a><spanclass="lineno"> 65</span> <spanclass="comment"> * For example, if the map goes from 192.128.1.0 to 192.128.3.0, the map will</span></div>
<divclass="line"><aname="l00066"></a><spanclass="lineno"> 66</span> <spanclass="comment"> * have 512 structs, the first one will correspond to 192.168.1.0, the 50th to</span></div>
<divclass="line"><aname="l00067"></a><spanclass="lineno"> 67</span> <spanclass="comment"> * 192.168.1.50 and so on.</span></div>
<divclass="line"><aname="l00068"></a><spanclass="lineno"> 68</span> <spanclass="comment"> * Note: because MAXGROUPNODE is 256, we can use an u_char for the index of the</span></div>
<divclass="line"><aname="l00073"></a><spanclass="lineno"> 73</span> <spanclass="comment">/* map_rnode is what map_node.r_node points to. (read struct map_node below) */</span></div>
<divclass="line"><aname="l00076"></a><spanclass="lineno"><aclass="line"href="../../d8/d81/structmap__rnode.html#ac08c86886ffddade1ea563e64ca360c7"> 76</a></span> <spanclass="keywordtype">int</span> *<aclass="code"href="../../d8/d81/structmap__rnode.html#ac08c86886ffddade1ea563e64ca360c7">r_node</a>; <spanclass="comment">/*It's the pointer to the struct of the</span></div>
<divclass="line"><aname="l00077"></a><spanclass="lineno"> 77</span> <spanclass="comment"> r_node in the map*/</span></div>
<divclass="line"><aname="l00080"></a><spanclass="lineno"> 80</span> <spanclass="comment"> * node <-> root_node total rtt: The rtt to reach the root_node </span></div>
<divclass="line"><aname="l00081"></a><spanclass="lineno"> 81</span> <spanclass="comment"> * starting from the node which uses this rnode (in millisec). </span></div>
<divclass="line"><aname="l00082"></a><spanclass="lineno"> 82</span> <spanclass="comment"> * Cuz I've explained it in such a bad way I make an example:</span></div>
<divclass="line"><aname="l00083"></a><spanclass="lineno"> 83</span> <spanclass="comment"> * map_node node_A; From node_A "node_A.links"th routes to the root_node</span></div>
<divclass="line"><aname="l00084"></a><spanclass="lineno"> 84</span> <spanclass="comment"> * start. So I have "node_A.links"th node_A.r_node[s], each of them is a</span></div>
<divclass="line"><aname="l00085"></a><spanclass="lineno"> 85</span> <spanclass="comment"> * different route to reach the root_node. </span></div>
<divclass="line"><aname="l00086"></a><spanclass="lineno"> 86</span> <spanclass="comment"> * With the node_A.r_node[route_number_to_follow].trtt I can get the rtt </span></div>
<divclass="line"><aname="l00087"></a><spanclass="lineno"> 87</span> <spanclass="comment"> * needed to reach the root_node starting from the node_A using the </span></div>
<divclass="line"><aname="l00088"></a><spanclass="lineno"> 88</span> <spanclass="comment"> * route_number_to_follow. Gotcha? I hope so.</span></div>
<divclass="line"><aname="l00089"></a><spanclass="lineno"> 89</span> <spanclass="comment"> * Note: The trtt is mainly used to sort the routes</span></div>
<divclass="line"><aname="l00093"></a><spanclass="lineno"> 93</span> <spanclass="comment">/* Note: This int_info is used for the pack of a map_rnode struct (see </span></div>
<divclass="line"><aname="l00095"></a><spanclass="lineno"> 95</span> <spanclass="comment"> * Since the r_node pointer, in the pack, is an integer, we add it in the</span></div>
<divclass="line"><aname="l00096"></a><spanclass="lineno"> 96</span> <spanclass="comment"> * int_info as a normal 32bit int. */</span></div>
<divclass="line"><aname="l00107"></a><spanclass="lineno"> 107</span> <spanclass="comment"> * - map_node.r_node points to the r_node of the root_node to be used as </span></div>
<divclass="line"><aname="l00108"></a><spanclass="lineno"> 108</span> <spanclass="comment"> * gateway to reach map_node. So map_node.r_node stores only the gateway </span></div>
<divclass="line"><aname="l00109"></a><spanclass="lineno"> 109</span> <spanclass="comment"> * needed to reach map_node from the root_node.</span></div>
<divclass="line"><aname="l00110"></a><spanclass="lineno"> 110</span> <spanclass="comment"> * The only execption is the root_node itself. The root_node's </span></div>
<divclass="line"><aname="l00111"></a><spanclass="lineno"> 111</span> <spanclass="comment"> * map_node.r_node keeps all its rnodes as a normal (non qspn) map would.</span></div>
<divclass="line"><aname="l00113"></a><spanclass="lineno"> 113</span> <spanclass="comment"> * The only exception is the root_node. Its rnodes have a different meaning: </span></div>
<divclass="line"><aname="l00114"></a><spanclass="lineno"> 114</span> <spanclass="comment"> * they are its effective rnodes, so each map_node.r_node points to the node </span></div>
<divclass="line"><aname="l00115"></a><spanclass="lineno"> 115</span> <spanclass="comment"> * which is the real rnode of the root_node.</span></div>
<divclass="line"><aname="l00116"></a><spanclass="lineno"> 116</span> <spanclass="comment"> * The root_node at level 0 may have also rnode of a different gnode </span></div>
<divclass="line"><aname="l00117"></a><spanclass="lineno"> 117</span> <spanclass="comment"> * (it is a border node).</span></div>
<divclass="line"><aname="l00118"></a><spanclass="lineno"> 118</span> <spanclass="comment"> * To store these external rnodes in root_node.r_node[x], the </span></div>
<divclass="line"><aname="l00119"></a><spanclass="lineno"> 119</span> <spanclass="comment"> * root_node.r_node[x].r_node will point to the relative ext_rnode struct </span></div>
<divclass="line"><aname="l00120"></a><spanclass="lineno"> 120</span> <spanclass="comment"> * (see gmap.h) and the MAP_GNODE | MAP_ERNODE flags will be set in </span></div>
<divclass="line"><aname="l00122"></a><spanclass="lineno"> 122</span> <spanclass="comment"> * The rnodes of the root_node of 0 level are updated by the radar(), </span></div>
<divclass="line"><aname="l00123"></a><spanclass="lineno"> 123</span> <spanclass="comment"> * instead the root_nodes of greater levels are updated by the qspn.</span></div>
<divclass="line"><aname="l00128"></a><spanclass="lineno"><aclass="line"href="../../d6/d1c/structmap__node.html#a44e866f83a5a137c7b94b9631f2c86c9"> 128</a></span>  u_int <aclass="code"href="../../d6/d1c/structmap__node.html#a44e866f83a5a137c7b94b9631f2c86c9">brdcast</a>; <spanclass="comment">/*Pkt_id of the last brdcast_pkt sent by this node*/</span></div>
<divclass="line"><aname="l00129"></a><spanclass="lineno"><aclass="line"href="../../d6/d1c/structmap__node.html#a872db1dec6f12a9db7cd56687bd437f2"> 129</a></span>  u_short <aclass="code"href="../../d6/d1c/structmap__node.html#a872db1dec6f12a9db7cd56687bd437f2">links</a>; <spanclass="comment">/*Number of r_nodes*/</span></div>
<divclass="line"><aname="l00130"></a><spanclass="lineno"><aclass="line"href="../../d6/d1c/structmap__node.html#a85d8d6d3d98c159e9469f6809d3df01b"> 130</a></span> <aclass="code"href="../../d8/d81/structmap__rnode.html">map_rnode</a> *<aclass="code"href="../../d6/d1c/structmap__node.html#a85d8d6d3d98c159e9469f6809d3df01b">r_node</a>; <spanclass="comment">/*These structs will be kept in ascending</span></div>
<divclass="line"><aname="l00131"></a><spanclass="lineno"> 131</span> <spanclass="comment"> order considering their rnode_t.rtt*/</span></div>
<divclass="line"><aname="l00134"></a><spanclass="lineno"> 134</span> <spanclass="comment">/* Note: This int_info is used for the pack of a map_rnode struct (see</span></div>
<divclass="line"><aname="l00148"></a><spanclass="lineno"> 148</span> <spanclass="comment">/*This block is used to send/save the int_map and the bnode_map*/</span></div>
<divclass="ttc"id="map_8h_html_aa1c547a1395ad23dae8112e8d330f45c"><divclass="ttname"><ahref="../../dc/db7/map_8h.html#aa1c547a1395ad23dae8112e8d330f45c">unpack_map</a></div><divclass="ttdeci">map_node * unpack_map(char *pack, int *addr_map, map_node **new_root, int maxgroupnode, int maxrnodeblock)</div><divclass="ttdef"><b>Definition:</b> map.c:661</div></div>
<divclass="ttc"id="map_8h_html_afd130c0ea144d2a64ee21c1bf55ff1c3"><divclass="ttname"><ahref="../../dc/db7/map_8h.html#afd130c0ea144d2a64ee21c1bf55ff1c3">verify_int_map_hdr</a></div><divclass="ttdeci">int verify_int_map_hdr(struct int_map_hdr *imap_hdr, int maxgroupnode, int maxrnodeblock)</div><divclass="ttdef"><b>Definition:</b> map.c:538</div></div>
<divclass="ttc"id="map_8h_html_ae05ce79c778db16a12a555449a0507e4"><divclass="ttname"><ahref="../../dc/db7/map_8h.html#ae05ce79c778db16a12a555449a0507e4">mod_rnode_addr</a></div><divclass="ttdeci">int mod_rnode_addr(map_rnode *node, int *map_start, int *new_start)</div><divclass="ttdef"><b>Definition:</b> map.c:420</div></div>
<divclass="ttc"id="map_8h_html_a60d1cd92a769d9904614fced266f4493"><divclass="ttname"><ahref="../../dc/db7/map_8h.html#a60d1cd92a769d9904614fced266f4493">map_get_rblock</a></div><divclass="ttdeci">map_rnode * map_get_rblock(map_node *map, int *addr_map, int maxgroupnode, int *count)</div><divclass="ttdef"><b>Definition:</b> map.c:468</div></div>
<divclass="ttc"id="map_8h_html_aa2f4ae7cc3ee65da6c79ef32f3becd49"><divclass="ttname"><ahref="../../dc/db7/map_8h.html#aa2f4ae7cc3ee65da6c79ef32f3becd49">reset_int_map</a></div><divclass="ttdeci">void reset_int_map(map_node *map, int maxgroupnode)</div><divclass="ttdef"><b>Definition:</b> map.c:233</div></div>
<divclass="ttc"id="map_8h_html_acd0dc47da9ba8cdf24563b13b6edb8ad"><divclass="ttname"><ahref="../../dc/db7/map_8h.html#acd0dc47da9ba8cdf24563b13b6edb8ad">map_store_rblock</a></div><divclass="ttdeci">int map_store_rblock(map_node *map, int *addr_map, int maxgroupnode, map_rnode *rblock)</div><divclass="ttdef"><b>Definition:</b> map.c:525</div></div>