Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 29c369053a983cc5d8c880dc6e0a2237 > files > 528

libdtn-devel-2.6.0-2mdv2009.1.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>DTN Reference Implementation: RIBTLV.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>RIBTLV.h</h1><a href="RIBTLV_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>
<a name="l00002"></a>00002 <span class="comment"> *    Copyright 2007 Baylor University</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> *    Licensed under the Apache License, Version 2.0 (the "License");</span>
<a name="l00005"></a>00005 <span class="comment"> *    you may not use this file except in compliance with the License.</span>
<a name="l00006"></a>00006 <span class="comment"> *    You may obtain a copy of the License at</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> *        http://www.apache.org/licenses/LICENSE-2.0</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> *    Unless required by applicable law or agreed to in writing, software</span>
<a name="l00011"></a>00011 <span class="comment"> *    distributed under the License is distributed on an "AS IS" BASIS,</span>
<a name="l00012"></a>00012 <span class="comment"> *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<a name="l00013"></a>00013 <span class="comment"> *    See the License for the specific language governing permissions and</span>
<a name="l00014"></a>00014 <span class="comment"> *    limitations under the License.</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#ifndef _PROPHET_RIB_TLV_H_</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _PROPHET_RIB_TLV_H_</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span>
<a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="PointerList_8h.html">PointerList.h</a>"</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="servlib_2prophet_2Node_8h.html">Node.h</a>"</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="BaseTLV_8h.html">BaseTLV.h</a>"</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="keyword">namespace </span>prophet
<a name="l00025"></a>00025 {
<a name="l00026"></a>00026 
<a name="l00027"></a><a class="code" href="classprophet_1_1RIBTLV.html">00027</a> <span class="keyword">class </span><a class="code" href="classprophet_1_1RIBTLV.html">RIBTLV</a> : <span class="keyword">public</span> <a class="code" href="classprophet_1_1BaseTLV.html" title="The Prophet I-D (March 2006) dictates five bytecodes for router state exchange messages...">BaseTLV</a>
<a name="l00028"></a>00028 {
<a name="l00029"></a>00029 <span class="keyword">public</span>:
<a name="l00030"></a>00030 
<a name="l00031"></a><a class="code" href="classprophet_1_1RIBTLV.html#51c1c0177057ba2576bfd4a2a3fcbf44">00031</a>     <span class="keyword">typedef</span> <a class="code" href="classprophet_1_1PointerList.html#4592d269227296c2bd509fd8f4089589">RIBNodeList::iterator</a>       <a class="code" href="classprophet_1_1RIBTLV.html#51c1c0177057ba2576bfd4a2a3fcbf44">iterator</a>;
<a name="l00032"></a><a class="code" href="classprophet_1_1RIBTLV.html#5f6c403eb1a75ab229ebb8214ebbacfd">00032</a>     <span class="keyword">typedef</span> <a class="code" href="classprophet_1_1PointerList.html#06e35a2ecc4bda2286b6e3f3685b9a9e">RIBNodeList::const_iterator</a> <a class="code" href="classprophet_1_1RIBTLV.html#5f6c403eb1a75ab229ebb8214ebbacfd">const_iterator</a>;
<a name="l00033"></a>00033 
<a name="l00038"></a><a class="code" href="classprophet_1_1RIBTLV.html#b822f9c4c9f1bbfde21215cc137b2ce9">00038</a>     <span class="keyword">typedef</span> <span class="keyword">enum</span> {
<a name="l00039"></a><a class="code" href="classprophet_1_1RIBTLV.html#b822f9c4c9f1bbfde21215cc137b2ce907986bd40834cfcf54f8a40aa6ce3b79">00039</a>         <a class="code" href="classprophet_1_1RIBTLV.html#b822f9c4c9f1bbfde21215cc137b2ce907986bd40834cfcf54f8a40aa6ce3b79">RELAY_NODE</a>       = 1 &lt;&lt; 0,
<a name="l00040"></a><a class="code" href="classprophet_1_1RIBTLV.html#b822f9c4c9f1bbfde21215cc137b2ce99fac89806e29c2fa236bbac89fa5483d">00040</a>         <a class="code" href="classprophet_1_1RIBTLV.html#b822f9c4c9f1bbfde21215cc137b2ce99fac89806e29c2fa236bbac89fa5483d">CUSTODY_NODE</a>     = 1 &lt;&lt; 1,
<a name="l00041"></a><a class="code" href="classprophet_1_1RIBTLV.html#b822f9c4c9f1bbfde21215cc137b2ce95f74aeab69c1736cea20e0fc9e18b48e">00041</a>         <a class="code" href="classprophet_1_1RIBTLV.html#b822f9c4c9f1bbfde21215cc137b2ce95f74aeab69c1736cea20e0fc9e18b48e">INTERNET_GW_NODE</a> = 1 &lt;&lt; 2
<a name="l00042"></a>00042     } <a class="code" href="classprophet_1_1RIBTLV.html#b822f9c4c9f1bbfde21215cc137b2ce9" title="RIB Header Flags p.">rib_header_flag_t</a>;
<a name="l00043"></a>00043 
<a name="l00053"></a><a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html">00053</a>     <span class="keyword">struct </span><a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html" title="Routing Information Base TLV   p.">RIBTLVHeader</a> {
<a name="l00054"></a><a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html#db7a7beb67758dda3c48d61f040cdb79">00054</a>         u_int8_t <a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html#db7a7beb67758dda3c48d61f040cdb79" title="defined as 0xA1">type</a>; 
<a name="l00055"></a>00055 
<a name="l00068"></a><a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html#6ee7de8ff9df37d5db6823e41c7ece69">00068</a>         u_int8_t <a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html#6ee7de8ff9df37d5db6823e41c7ece69" title="The encoding of the Header flag field relates to the capabilities of the Source node...">flags</a>;
<a name="l00073"></a><a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html#ec1efe4a9c808953b0cc107b42cc40d9">00073</a>         u_int16_t <a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html#ec1efe4a9c808953b0cc107b42cc40d9" title="Length of the TLV in octets, including the TLV header and any nested TLVs.">length</a>;
<a name="l00074"></a><a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html#48ebbee6e355aa41e417f3b585518ee7">00074</a>         u_int16_t <a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html#48ebbee6e355aa41e417f3b585518ee7" title="Number of routing entries in the TLV.">rib_string_count</a>; 
<a name="l00075"></a><a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html#40f119bde1070483b6167d435cf035f9">00075</a>         u_int16_t <a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html#40f119bde1070483b6167d435cf035f9">unused__</a>;
<a name="l00076"></a>00076     } __attribute__((<a class="code" href="classprophet_1_1RIBTLV.html#e59b2fde572f5d8680503d0eb838afa9" title="Routing Information Base TLV   p.">packed</a>));
<a name="l00077"></a>00077 
<a name="l00082"></a><a class="code" href="structprophet_1_1RIBTLV_1_1RIBEntry.html">00082</a>     <span class="keyword">struct </span><a class="code" href="structprophet_1_1RIBTLV_1_1RIBEntry.html" title="Routing Information Base entry p.">RIBEntry</a> {
<a name="l00086"></a><a class="code" href="structprophet_1_1RIBTLV_1_1RIBEntry.html#1ce76a60ed33e980a54bd7571e2ca97e">00086</a>         u_int16_t <a class="code" href="structprophet_1_1RIBTLV_1_1RIBEntry.html#1ce76a60ed33e980a54bd7571e2ca97e" title="ID string as predefined in the dictionary TLV.">string_id</a>;
<a name="l00093"></a><a class="code" href="structprophet_1_1RIBTLV_1_1RIBEntry.html#2039f77099dbe998c1289694eeb5136b">00093</a>         u_int8_t <a class="code" href="structprophet_1_1RIBTLV_1_1RIBEntry.html#2039f77099dbe998c1289694eeb5136b" title="Delivery predictability for the destination of this entry as calculated according...">pvalue</a>;
<a name="l00106"></a><a class="code" href="structprophet_1_1RIBTLV_1_1RIBEntry.html#ceff2d13cb03114648c39cbbcf2d23bf">00106</a>         u_int8_t <a class="code" href="structprophet_1_1RIBTLV_1_1RIBEntry.html#ceff2d13cb03114648c39cbbcf2d23bf" title="The encoding of the RIB flag field is    Flag 0: Relay Node 0b1   Flag 1: Custody...">flags</a>;
<a name="l00107"></a>00107     } __attribute__((<a class="code" href="classprophet_1_1RIBTLV.html#e59b2fde572f5d8680503d0eb838afa9" title="Routing Information Base TLV   p.">packed</a>));
<a name="l00108"></a>00108 
<a name="l00109"></a><a class="code" href="classprophet_1_1RIBTLV.html#c8cc286d0b6f4322a5c1e4beff758d72">00109</a>     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">size_t</span> <a class="code" href="classprophet_1_1RIBTLV.html#c8cc286d0b6f4322a5c1e4beff758d72">RIBTLVHeaderSize</a> = <span class="keyword">sizeof</span>(<span class="keyword">struct </span><a class="code" href="structprophet_1_1RIBTLV_1_1RIBTLVHeader.html" title="Routing Information Base TLV   p.">RIBTLVHeader</a>);
<a name="l00110"></a>00110 
<a name="l00111"></a><a class="code" href="classprophet_1_1RIBTLV.html#c7119b733e1ac4b3cf22a1ce5a7f0062">00111</a>     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">size_t</span> <a class="code" href="classprophet_1_1RIBTLV.html#c7119b733e1ac4b3cf22a1ce5a7f0062">RIBEntrySize</a> = <span class="keyword">sizeof</span>(<span class="keyword">struct </span><a class="code" href="structprophet_1_1RIBTLV_1_1RIBEntry.html" title="Routing Information Base entry p.">RIBEntry</a>);
<a name="l00112"></a>00112 
<a name="l00116"></a>00116     <a class="code" href="classprophet_1_1RIBTLV.html#8bbe4d6a0baf33591fee36cf282191a7" title="Constructor.">RIBTLV</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1PointerList.html">RIBNodeList</a>&amp; <a class="code" href="classprophet_1_1RIBTLV.html#da2c41e4216a0ddb40c52001084af457" title="Accessors.">nodes</a>,
<a name="l00117"></a>00117            <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#fd92d49a23da8ee5a9ef1349b1f85bfa" title="Accessors.">relay</a>,
<a name="l00118"></a>00118            <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#3c4a5b5a78ca2cd299952914f540f3e8" title="Accessors.">custody</a>,
<a name="l00119"></a>00119            <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#25507e2237efebdcccd2f2800464cb8d" title="Accessors.">internet</a>=<span class="keyword">false</span>);
<a name="l00120"></a>00120 
<a name="l00124"></a><a class="code" href="classprophet_1_1RIBTLV.html#01d06f4772aa350a858397a00911d4d6">00124</a>     <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1RIBTLV.html#01d06f4772aa350a858397a00911d4d6" title="Destructor.">~RIBTLV</a>() {}
<a name="l00125"></a>00125 
<a name="l00129"></a>00129     <span class="keywordtype">size_t</span> <a class="code" href="classprophet_1_1RIBTLV.html#ce56f1f66c8a973d7a59b0c2bfa4812c" title="Virtual from BaseTLV.">serialize</a>(u_char* bp, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>) <span class="keyword">const</span>;
<a name="l00130"></a>00130 
<a name="l00132"></a><a class="code" href="classprophet_1_1RIBTLV.html#da2c41e4216a0ddb40c52001084af457">00132</a>     <span class="keyword">const</span> <a class="code" href="classprophet_1_1PointerList.html">RIBNodeList</a>&amp; <a class="code" href="classprophet_1_1RIBTLV.html#da2c41e4216a0ddb40c52001084af457" title="Accessors.">nodes</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1RIBTLV.html#7f42b25b00f4418988b449e5b7ad0609" title="List of RIB entries.">nodes_</a>; }
<a name="l00133"></a><a class="code" href="classprophet_1_1RIBTLV.html#fd92d49a23da8ee5a9ef1349b1f85bfa">00133</a>     <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#fd92d49a23da8ee5a9ef1349b1f85bfa" title="Accessors.">relay</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1RIBTLV.html#c4f10f023f5ca5f98644576888cf178d" title="Whether this node accepts bundles for relay to other nodes.">relay_</a>; }
<a name="l00134"></a><a class="code" href="classprophet_1_1RIBTLV.html#3c4a5b5a78ca2cd299952914f540f3e8">00134</a>     <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#3c4a5b5a78ca2cd299952914f540f3e8" title="Accessors.">custody</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1RIBTLV.html#66d56083be8dfcb832ad1016ed2ee95b" title="Whether this node accepts custody transfers.">custody_</a>; }
<a name="l00135"></a><a class="code" href="classprophet_1_1RIBTLV.html#25507e2237efebdcccd2f2800464cb8d">00135</a>     <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#25507e2237efebdcccd2f2800464cb8d" title="Accessors.">internet</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1RIBTLV.html#a77ff503c9891ef67c02cb09fabd4aed" title="Whether this node bridges to the Internet.">internet_</a>; }
<a name="l00137"></a>00137 
<a name="l00138"></a>00138 <span class="keyword">protected</span>:
<a name="l00139"></a><a class="code" href="classprophet_1_1RIBTLV.html#7a64341ce4495d9b958714b112b45b26">00139</a>     <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="structprophet_1_1TLVFactory.html">TLVFactory</a>&lt;<a class="code" href="classprophet_1_1RIBTLV.html">RIBTLV</a>&gt;;
<a name="l00140"></a>00140 
<a name="l00144"></a>00144     <a class="code" href="classprophet_1_1RIBTLV.html#8bbe4d6a0baf33591fee36cf282191a7" title="Constructor.">RIBTLV</a>();
<a name="l00145"></a>00145 
<a name="l00149"></a>00149     <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1RIBTLV.html#be1b38891666e6c09f5cf4df07287e88" title="Utility function for decoding RIB header flags.">decode_flags</a>(u_int8_t <a class="code" href="classprophet_1_1BaseTLV.html#85ccaab1420732e2f1e327798b8899ed" title="Accessors.">flags</a>, <span class="keywordtype">bool</span>* <a class="code" href="classprophet_1_1RIBTLV.html#fd92d49a23da8ee5a9ef1349b1f85bfa" title="Accessors.">relay</a>,
<a name="l00150"></a>00150                              <span class="keywordtype">bool</span>* <a class="code" href="classprophet_1_1RIBTLV.html#3c4a5b5a78ca2cd299952914f540f3e8" title="Accessors.">custody</a>, <span class="keywordtype">bool</span>* <a class="code" href="classprophet_1_1RIBTLV.html#25507e2237efebdcccd2f2800464cb8d" title="Accessors.">internet</a>);
<a name="l00151"></a>00151 
<a name="l00156"></a>00156     <span class="keywordtype">size_t</span> <a class="code" href="classprophet_1_1RIBTLV.html#89c4ff6df76ed8241a3fd7d0745f3b2d" title="Serialize routing information base entry out to no more than len bytes of buffer...">write_rib_entry</a>(u_int16_t sid, <span class="keywordtype">double</span> pvalue, <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#fd92d49a23da8ee5a9ef1349b1f85bfa" title="Accessors.">relay</a>,
<a name="l00157"></a>00157                            <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#3c4a5b5a78ca2cd299952914f540f3e8" title="Accessors.">custody</a>, <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#25507e2237efebdcccd2f2800464cb8d" title="Accessors.">internet</a>,
<a name="l00158"></a>00158                            u_char* bp, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>) <span class="keyword">const</span>;
<a name="l00159"></a>00159 
<a name="l00164"></a>00164     <span class="keywordtype">size_t</span> <a class="code" href="classprophet_1_1RIBTLV.html#27007d75c45d2e5cb300fabe19d0de5c" title="Deserialize RIBEntry struct from transport into memory, reading no more than len...">read_rib_entry</a>(u_int16_t* sid, <span class="keywordtype">double</span>* pvalue,
<a name="l00165"></a>00165                           <span class="keywordtype">bool</span>* <a class="code" href="classprophet_1_1RIBTLV.html#fd92d49a23da8ee5a9ef1349b1f85bfa" title="Accessors.">relay</a>, <span class="keywordtype">bool</span>* <a class="code" href="classprophet_1_1RIBTLV.html#3c4a5b5a78ca2cd299952914f540f3e8" title="Accessors.">custody</a>, <span class="keywordtype">bool</span>* <a class="code" href="classprophet_1_1RIBTLV.html#25507e2237efebdcccd2f2800464cb8d" title="Accessors.">internet</a>,
<a name="l00166"></a>00166                           <span class="keyword">const</span> u_char* bp, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>);
<a name="l00167"></a>00167 
<a name="l00171"></a>00171     <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#2ef063b460e46038ff251775cb621a9c" title="Virtual from BaseTLV.">deserialize</a>(<span class="keyword">const</span> u_char* bp, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>);
<a name="l00172"></a>00172 
<a name="l00173"></a><a class="code" href="classprophet_1_1RIBTLV.html#7f42b25b00f4418988b449e5b7ad0609">00173</a>     <a class="code" href="classprophet_1_1PointerList.html">RIBNodeList</a> <a class="code" href="classprophet_1_1RIBTLV.html#7f42b25b00f4418988b449e5b7ad0609" title="List of RIB entries.">nodes_</a>; 
<a name="l00174"></a><a class="code" href="classprophet_1_1RIBTLV.html#c4f10f023f5ca5f98644576888cf178d">00174</a>     <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#c4f10f023f5ca5f98644576888cf178d" title="Whether this node accepts bundles for relay to other nodes.">relay_</a>; 
<a name="l00175"></a>00175 
<a name="l00176"></a><a class="code" href="classprophet_1_1RIBTLV.html#66d56083be8dfcb832ad1016ed2ee95b">00176</a>     <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#66d56083be8dfcb832ad1016ed2ee95b" title="Whether this node accepts custody transfers.">custody_</a>; 
<a name="l00177"></a><a class="code" href="classprophet_1_1RIBTLV.html#a77ff503c9891ef67c02cb09fabd4aed">00177</a>     <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1RIBTLV.html#a77ff503c9891ef67c02cb09fabd4aed" title="Whether this node bridges to the Internet.">internet_</a>; 
<a name="l00178"></a>00178 
<a name="l00179"></a>00179 }; <span class="comment">// class RIBTLV</span>
<a name="l00180"></a>00180 
<a name="l00181"></a>00181 }; <span class="comment">// namespace prophet</span>
<a name="l00182"></a>00182 
<a name="l00183"></a>00183 <span class="preprocessor">#endif // _PROPHET_RIB_TLV_H_</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:57 2009 for DTN Reference Implementation by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>