<!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: HelloTLV.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 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 List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>HelloTLV.h</h1><a href="HelloTLV_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_HELLO_TLV_H_</span> <a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _PROPHET_HELLO_TLV_H_</span> <a name="l00019"></a>00019 <span class="preprocessor"></span> <a name="l00020"></a>00020 <span class="preprocessor">#include <string></span> <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="BaseTLV_8h.html">BaseTLV.h</a>"</span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="keyword">namespace </span>prophet <a name="l00024"></a>00024 { <a name="l00025"></a>00025 <a name="l00026"></a><a class="code" href="classprophet_1_1HelloTLV.html">00026</a> <span class="keyword">class </span><a class="code" href="classprophet_1_1HelloTLV.html">HelloTLV</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="l00027"></a>00027 { <a name="l00028"></a>00028 <span class="keyword">public</span>: <a name="l00046"></a><a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html">00046</a> <span class="keyword">struct </span><a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html" title="Hello TLV header p.">HelloTLVHeader</a> { <a name="l00047"></a><a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#513bc49f8d1a6e806a650517f6471d15">00047</a> u_int8_t <a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#513bc49f8d1a6e806a650517f6471d15" title="defined as 0x01">type</a>; <a name="l00048"></a><a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#589e9232d9661c4fcc1cfbaa53d08ad4">00048</a> u_int8_t <a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#589e9232d9661c4fcc1cfbaa53d08ad4">unused__</a>:5; <a name="l00058"></a><a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#85c54dfa4ea89f4ae200afb45cea70c2">00058</a> u_int8_t <a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#85c54dfa4ea89f4ae200afb45cea70c2" title="Specifies the function of the Hello TLV.">HF</a>:3; <a name="l00063"></a><a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#c59a042c129b1c47d3cf70c87a568aa5">00063</a> u_int16_t <a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#c59a042c129b1c47d3cf70c87a568aa5" title="Length of the TLV in octets, including the TLV header and any nested TLVs.">length</a>; <a name="l00071"></a><a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#8eb2e541478ff9c9ac55be7e14e33122">00071</a> u_int8_t <a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#8eb2e541478ff9c9ac55be7e14e33122" title="The Timer field is used to inform the receiver of the timer value used in the Hello...">timer</a>; <a name="l00079"></a><a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#c5bb79ac345207caba9632b79c0d4e47">00079</a> u_int8_t <a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#c5bb79ac345207caba9632b79c0d4e47" title="The Name Length field is used to specify the length of the Sender Name field in octets...">name_length</a>; <a name="l00085"></a><a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#98dc6bf1dd164c7568386a29f5e3b8f5">00085</a> u_char <a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html#98dc6bf1dd164c7568386a29f5e3b8f5" title="The Sender Name field specifies the routable DTN name of the sender that is to be...">sender_name</a>[0]; <a name="l00086"></a>00086 } __attribute__((<a class="code" href="classprophet_1_1HelloTLV.html#a7054b721184bab1b38a732e308cbc94" title="Hello TLV header p.">packed</a>)); <a name="l00087"></a>00087 <a name="l00088"></a><a class="code" href="classprophet_1_1HelloTLV.html#4e64147af7636a37a2160d485ac7e97f">00088</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">size_t</span> <a class="code" href="classprophet_1_1HelloTLV.html#4e64147af7636a37a2160d485ac7e97f">HelloTLVHeaderSize</a> = <span class="keyword">sizeof</span>(<span class="keyword">struct </span><a class="code" href="structprophet_1_1HelloTLV_1_1HelloTLVHeader.html" title="Hello TLV header p.">HelloTLVHeader</a>); <a name="l00089"></a>00089 <a name="l00094"></a><a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08">00094</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> { <a name="l00095"></a><a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba081956a637415514e2f5b129221fe544a0">00095</a> <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba081956a637415514e2f5b129221fe544a0">HF_UNKNOWN</a> = 0x0, <a name="l00096"></a><a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba0800121f8315b9798dc602a5d2779b0b0d">00096</a> <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba0800121f8315b9798dc602a5d2779b0b0d">SYN</a> = 0x1, <a name="l00097"></a><a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08ab3f4be155b2bf0adb0832d7492b5082">00097</a> <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08ab3f4be155b2bf0adb0832d7492b5082">SYNACK</a> = 0x2, <a name="l00098"></a><a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08288d8aeb7f9f87a7a8bb4742242618a8">00098</a> <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08288d8aeb7f9f87a7a8bb4742242618a8">ACK</a> = 0x3, <a name="l00099"></a><a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08534d7962f263ce41bc0a71b73b9b7c71">00099</a> <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08534d7962f263ce41bc0a71b73b9b7c71">RSTACK</a> = 0x4 <a name="l00100"></a>00100 } <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08" title="Legal values for HelloTLVHeader.HF (hello function) p.">hello_hf_t</a>; <a name="l00101"></a>00101 <a name="l00102"></a>00102 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a name="l00103"></a><a class="code" href="classprophet_1_1HelloTLV.html#4582d1ad0ea1cb93cea0bd7bfc2b6bb5">00103</a> <a class="code" href="classprophet_1_1HelloTLV.html#4582d1ad0ea1cb93cea0bd7bfc2b6bb5">hf_to_str</a>(<a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08" title="Legal values for HelloTLVHeader.HF (hello function) p.">hello_hf_t</a> <a class="code" href="classprophet_1_1HelloTLV.html#98534984f2a41633872c7a5f9d8f3af3" title="Accessors.">hf</a>) <a name="l00104"></a>00104 { <a name="l00105"></a>00105 <span class="keywordflow">switch</span>(hf) { <a name="l00106"></a>00106 <span class="keywordflow">case</span> <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba0800121f8315b9798dc602a5d2779b0b0d">SYN</a>: <span class="keywordflow">return</span> <span class="stringliteral">"SYN"</span>; <a name="l00107"></a>00107 <span class="keywordflow">case</span> <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08ab3f4be155b2bf0adb0832d7492b5082">SYNACK</a>: <span class="keywordflow">return</span> <span class="stringliteral">"SYNACK"</span>; <a name="l00108"></a>00108 <span class="keywordflow">case</span> <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08288d8aeb7f9f87a7a8bb4742242618a8">ACK</a>: <span class="keywordflow">return</span> <span class="stringliteral">"ACK"</span>; <a name="l00109"></a>00109 <span class="keywordflow">case</span> <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08534d7962f263ce41bc0a71b73b9b7c71">RSTACK</a>: <span class="keywordflow">return</span> <span class="stringliteral">"RSTACK"</span>; <a name="l00110"></a>00110 <span class="keywordflow">case</span> <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba081956a637415514e2f5b129221fe544a0">HF_UNKNOWN</a>: <a name="l00111"></a>00111 <span class="keywordflow">default</span>: <span class="keywordflow">return</span> <span class="stringliteral">"Unrecognized prophet HF code"</span>; <a name="l00112"></a>00112 } <a name="l00113"></a>00113 } <a name="l00114"></a>00114 <a name="l00118"></a>00118 <a class="code" href="classprophet_1_1HelloTLV.html#0be11ca3691c6c28b4990f077874f45f" title="Constructor.">HelloTLV</a>(<a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08" title="Legal values for HelloTLVHeader.HF (hello function) p.">hello_hf_t</a> <a class="code" href="classprophet_1_1HelloTLV.html#98534984f2a41633872c7a5f9d8f3af3" title="Accessors.">hf</a>, <a name="l00119"></a>00119 u_int8_t <a class="code" href="classprophet_1_1HelloTLV.html#9ac6e43621e0ab5c01b8b61b20236f9e" title="Accessors.">timer</a>, <a name="l00120"></a>00120 <span class="keyword">const</span> std::string& <a class="code" href="classprophet_1_1HelloTLV.html#e2cd6b4b3df40ad18b622a7fa6103d6e" title="Accessors.">sender</a>); <a name="l00121"></a>00121 <a name="l00125"></a><a class="code" href="classprophet_1_1HelloTLV.html#4ef4874456ea8b2c4c80433f7c8adc89">00125</a> <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1HelloTLV.html#4ef4874456ea8b2c4c80433f7c8adc89" title="Destructor.">~HelloTLV</a>() {} <a name="l00126"></a>00126 <a name="l00130"></a>00130 <span class="keywordtype">size_t</span> <a class="code" href="classprophet_1_1HelloTLV.html#606643bb367524d8407c54500ffe1fc8" 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="l00131"></a>00131 <a name="l00133"></a><a class="code" href="classprophet_1_1HelloTLV.html#98534984f2a41633872c7a5f9d8f3af3">00133</a> <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08" title="Legal values for HelloTLVHeader.HF (hello function) p.">hello_hf_t</a> <a class="code" href="classprophet_1_1HelloTLV.html#98534984f2a41633872c7a5f9d8f3af3" title="Accessors.">hf</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1HelloTLV.html#9d15e2e2b2e33eb244f4e221a11ab3e3" title="Hello function bytecode.">hf_</a>; } <a name="l00134"></a><a class="code" href="classprophet_1_1HelloTLV.html#dc4a9cf0a425acc17d0cf04f3a3f8f8b">00134</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classprophet_1_1HelloTLV.html#dc4a9cf0a425acc17d0cf04f3a3f8f8b" title="Accessors.">hf_str</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1HelloTLV.html#4582d1ad0ea1cb93cea0bd7bfc2b6bb5">hf_to_str</a>(<a class="code" href="classprophet_1_1HelloTLV.html#9d15e2e2b2e33eb244f4e221a11ab3e3" title="Hello function bytecode.">hf_</a>); } <a name="l00135"></a><a class="code" href="classprophet_1_1HelloTLV.html#9ac6e43621e0ab5c01b8b61b20236f9e">00135</a> u_int8_t <a class="code" href="classprophet_1_1HelloTLV.html#9ac6e43621e0ab5c01b8b61b20236f9e" title="Accessors.">timer</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1HelloTLV.html#f8b902c92e8b9c29aa55313c5b681a3f" title="Units of 100ms between Hello messages.">timer_</a>; } <a name="l00136"></a><a class="code" href="classprophet_1_1HelloTLV.html#e2cd6b4b3df40ad18b622a7fa6103d6e">00136</a> std::string <a class="code" href="classprophet_1_1HelloTLV.html#e2cd6b4b3df40ad18b622a7fa6103d6e" title="Accessors.">sender</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classprophet_1_1HelloTLV.html#56e59f80cae3daf0bb6196605b653b3a" title="endpoint id of sender">sender_</a>; } <a name="l00138"></a>00138 <a name="l00139"></a>00139 <span class="keyword">protected</span>: <a name="l00140"></a><a class="code" href="classprophet_1_1HelloTLV.html#c45b358eb2ff6dc12f982238f1627910">00140</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="structprophet_1_1TLVFactory.html">TLVFactory</a><<a class="code" href="classprophet_1_1HelloTLV.html">HelloTLV</a>>; <a name="l00141"></a>00141 <a name="l00145"></a>00145 <a class="code" href="classprophet_1_1HelloTLV.html#0be11ca3691c6c28b4990f077874f45f" title="Constructor.">HelloTLV</a>(); <a name="l00146"></a>00146 <a name="l00150"></a>00150 <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1HelloTLV.html#a5c9b27b0f314b9ddc24e8550792a1f4" 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="l00151"></a>00151 <a name="l00152"></a><a class="code" href="classprophet_1_1HelloTLV.html#9d15e2e2b2e33eb244f4e221a11ab3e3">00152</a> <a class="code" href="classprophet_1_1HelloTLV.html#4b04d76a4e7cc392b21552173c2bba08" title="Legal values for HelloTLVHeader.HF (hello function) p.">hello_hf_t</a> <a class="code" href="classprophet_1_1HelloTLV.html#9d15e2e2b2e33eb244f4e221a11ab3e3" title="Hello function bytecode.">hf_</a>; <a name="l00153"></a><a class="code" href="classprophet_1_1HelloTLV.html#f8b902c92e8b9c29aa55313c5b681a3f">00153</a> u_int8_t <a class="code" href="classprophet_1_1HelloTLV.html#f8b902c92e8b9c29aa55313c5b681a3f" title="Units of 100ms between Hello messages.">timer_</a>; <a name="l00154"></a><a class="code" href="classprophet_1_1HelloTLV.html#56e59f80cae3daf0bb6196605b653b3a">00154</a> std::string <a class="code" href="classprophet_1_1HelloTLV.html#56e59f80cae3daf0bb6196605b653b3a" title="endpoint id of sender">sender_</a>; <a name="l00155"></a>00155 }; <span class="comment">// class HelloTLV</span> <a name="l00156"></a>00156 <a name="l00157"></a>00157 }; <span class="comment">// namespace prophet</span> <a name="l00158"></a>00158 <a name="l00159"></a>00159 <span class="preprocessor">#endif // _PROPHET_HELLO_TLV_H_</span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:56 2009 for DTN Reference Implementation by <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>