Sophie

Sophie

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

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: Announce.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>Announce.h</h1><a href="Announce_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 2006 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 _ANNOUNCE_H_</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _ANNOUNCE_H_</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;oasys/debug/Log.h&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;oasys/thread/Timer.h&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="EndpointID_8h.html">naming/EndpointID.h</a>"</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="ConvergenceLayer_8h.html">conv_layers/ConvergenceLayer.h</a>"</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="preprocessor">#ifndef FOUR_BYTE_ALIGN</span>
<a name="l00027"></a><a class="code" href="Announce_8h.html#10fb10f052238243f08749f41a8374a6">00027</a> <span class="preprocessor"></span><span class="preprocessor">#define FOUR_BYTE_ALIGN(x) (((x) % 4) != 0) ? ((x) + (4 - ((x) % 4))) : (x)</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span>
<a name="l00030"></a>00030 <span class="keyword">namespace </span>dtn {
<a name="l00031"></a>00031 
<a name="l00042"></a><a class="code" href="classdtn_1_1Announce.html">00042</a> <span class="keyword">class </span><a class="code" href="classdtn_1_1Announce.html" title="Announce represents a ConvergenceLayer (Interface).">Announce</a> : <span class="keyword">public</span> oasys::<a class="code" href="classoasys_1_1Logger.html">Logger</a>
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044 <span class="keyword">public</span>:
<a name="l00045"></a>00045 
<a name="l00049"></a><a class="code" href="classdtn_1_1Announce.html#7cea29d4c3796920f6d8cb4c943570eb">00049</a>     <span class="keyword">const</span> std::string&amp; <a class="code" href="classdtn_1_1Announce.html#7cea29d4c3796920f6d8cb4c943570eb" title="The name of this Announce instance.">name</a>() { <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1Announce.html#1acf55ea37c38026a963a8a7ab5f5063" title="name for this beacon instance">name_</a>; }
<a name="l00050"></a>00050 
<a name="l00054"></a><a class="code" href="classdtn_1_1Announce.html#ace9d8bfc9824adb417ee56f3935e652">00054</a>     <span class="keyword">const</span> std::string&amp; <a class="code" href="classdtn_1_1Announce.html#ace9d8bfc9824adb417ee56f3935e652" title="Which type of CL is represented by this Announce.">type</a>() { <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1Announce.html#7dfeaeaf96b1904c710bdb09a7a52c3f" title="pulled from cl_">type_</a>; }
<a name="l00055"></a>00055 
<a name="l00060"></a><a class="code" href="classdtn_1_1Announce.html#4cfa7eef803f45fbdd4d41d85514e021">00060</a>     <span class="keyword">const</span> std::string&amp; <a class="code" href="classdtn_1_1Announce.html#4cfa7eef803f45fbdd4d41d85514e021" title="Return a string representation of the ConvergenceLayer address info to be advertised...">local_addr</a>() { <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1Announce.html#e0381b20267e347d8ef914a1931e5e28" title="Beacon info to advertise.">local_</a>; }
<a name="l00061"></a>00061     
<a name="l00065"></a>00065     <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> <a class="code" href="classdtn_1_1Announce.html#f335fed7a9baee08d1b02cf1697ea845" title="Hook for derived classes to format information to be advertised.">format_advertisement</a>(u_char* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>, <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>) = 0;
<a name="l00066"></a>00066 
<a name="l00067"></a><a class="code" href="classdtn_1_1Announce.html#d527f21832f1cae13c7676791a5867d3">00067</a>     <span class="keyword">virtual</span> <a class="code" href="classdtn_1_1Announce.html#d527f21832f1cae13c7676791a5867d3">~Announce</a>() {}
<a name="l00068"></a>00068 
<a name="l00073"></a><a class="code" href="classdtn_1_1Announce.html#381c7961b5b0d78fcc58d1d64a1d84ca">00073</a>     u_int <a class="code" href="classdtn_1_1Announce.html#381c7961b5b0d78fcc58d1d64a1d84ca" title="Return the number of milliseconds remaining until the interval expires, or 0 if it&amp;#39;s...">interval_remaining</a>()
<a name="l00074"></a>00074     {
<a name="l00075"></a>00075         <span class="keyword">struct </span>timeval now;<a class="code" href="namespacedtnsim.html#372b0bd474085f20b38efbbade7ce72a" title="Override gettimeofday to return the simulator time."></a>
<a name="l00076"></a>00076 <a class="code" href="namespacedtnsim.html#372b0bd474085f20b38efbbade7ce72a" title="Override gettimeofday to return the simulator time.">        ::gettimeofday</a>(&amp;now,0);
<a name="l00077"></a>00077         u_int timediff = <a class="code" href="dtnping_8h.html#78237999c2659b5d28c1a90a2123607f">TIMEVAL_DIFF_MSEC</a>(now,<a class="code" href="classdtn_1_1Announce.html#25191d7733447aa55b2c092d61f6af35" title="mark each time data is sent">data_sent_</a>);
<a name="l00078"></a>00078         <span class="keywordflow">if</span> (timediff &gt; <a class="code" href="classdtn_1_1Announce.html#e81359675347762ba29a3f9ea9968cc4" title="interval (in milliseconds) for beacon header">interval_</a>)
<a name="l00079"></a>00079             <span class="keywordflow">return</span> 0;
<a name="l00080"></a>00080 
<a name="l00081"></a>00081         <span class="keywordflow">return</span> (<a class="code" href="classdtn_1_1Announce.html#e81359675347762ba29a3f9ea9968cc4" title="interval (in milliseconds) for beacon header">interval_</a> - timediff);
<a name="l00082"></a>00082     }
<a name="l00083"></a>00083 
<a name="l00087"></a>00087     <span class="keyword">static</span> <a class="code" href="classdtn_1_1Announce.html" title="Announce represents a ConvergenceLayer (Interface).">Announce</a>* <a class="code" href="classdtn_1_1Announce.html#01b945f189453cdd16eefaa50f2e2dab" title="Factory method for creating instances of derived classes.">create_announce</a>(<span class="keyword">const</span> std::string&amp; <a class="code" href="classdtn_1_1Announce.html#7cea29d4c3796920f6d8cb4c943570eb" title="The name of this Announce instance.">name</a>,
<a name="l00088"></a>00088                                      <a class="code" href="classdtn_1_1ConvergenceLayer.html" title="The abstract interface for a convergence layer.">ConvergenceLayer</a>* cl,
<a name="l00089"></a>00089                                      <span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>* argv[]);
<a name="l00090"></a>00090 
<a name="l00094"></a><a class="code" href="classdtn_1_1Announce.html#ea3deb5caedf6d291d0f60630d9be883">00094</a>     u_int <a class="code" href="classdtn_1_1Announce.html#ea3deb5caedf6d291d0f60630d9be883" title="Number of milliseconds between announcements.">interval</a>() { <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1Announce.html#e81359675347762ba29a3f9ea9968cc4" title="interval (in milliseconds) for beacon header">interval_</a>; }
<a name="l00095"></a>00095 
<a name="l00096"></a>00096 <span class="keyword">protected</span>:
<a name="l00097"></a><a class="code" href="classdtn_1_1Announce.html#53ac7813f7c1e61b31b1ce3596b29ff8">00097</a>     <a class="code" href="classdtn_1_1Announce.html#53ac7813f7c1e61b31b1ce3596b29ff8">Announce</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* logpath = <span class="stringliteral">"/dtn/discovery/announce"</span>)
<a name="l00098"></a>00098         : oasys::<a class="code" href="classoasys_1_1Logger.html">Logger</a>(<span class="stringliteral">"Announce"</span>,<span class="stringliteral">"%s"</span>,logpath),
<a name="l00099"></a>00099           <a class="code" href="classdtn_1_1Announce.html#65066d3cb11b61adc07b9440e337f269" title="CL represented by this Announce.">cl_</a>(NULL), <a class="code" href="classdtn_1_1Announce.html#e81359675347762ba29a3f9ea9968cc4" title="interval (in milliseconds) for beacon header">interval_</a>(0)
<a name="l00100"></a>00100     {<a class="code" href="namespacedtnsim.html#372b0bd474085f20b38efbbade7ce72a" title="Override gettimeofday to return the simulator time."></a>
<a name="l00101"></a>00101 <a class="code" href="namespacedtnsim.html#372b0bd474085f20b38efbbade7ce72a" title="Override gettimeofday to return the simulator time.">        ::gettimeofday</a>(&amp;<a class="code" href="classdtn_1_1Announce.html#25191d7733447aa55b2c092d61f6af35" title="mark each time data is sent">data_sent_</a>,0);
<a name="l00102"></a>00102     }
<a name="l00103"></a>00103 
<a name="l00104"></a>00104     <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classdtn_1_1Announce.html#005ba1185dabf18c7d40a349350013ef">configure</a>(<span class="keyword">const</span> std::string&amp; <a class="code" href="classdtn_1_1Announce.html#7cea29d4c3796920f6d8cb4c943570eb" title="The name of this Announce instance.">name</a>,
<a name="l00105"></a>00105                            <a class="code" href="classdtn_1_1ConvergenceLayer.html" title="The abstract interface for a convergence layer.">ConvergenceLayer</a>* cl,
<a name="l00106"></a>00106                            <span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>* argv[]) = 0;
<a name="l00107"></a>00107 
<a name="l00108"></a><a class="code" href="classdtn_1_1Announce.html#65066d3cb11b61adc07b9440e337f269">00108</a>     <a class="code" href="classdtn_1_1ConvergenceLayer.html" title="The abstract interface for a convergence layer.">ConvergenceLayer</a>* <a class="code" href="classdtn_1_1Announce.html#65066d3cb11b61adc07b9440e337f269" title="CL represented by this Announce.">cl_</a>; 
<a name="l00109"></a><a class="code" href="classdtn_1_1Announce.html#e0381b20267e347d8ef914a1931e5e28">00109</a>     std::string <a class="code" href="classdtn_1_1Announce.html#e0381b20267e347d8ef914a1931e5e28" title="Beacon info to advertise.">local_</a>; 
<a name="l00110"></a><a class="code" href="classdtn_1_1Announce.html#1acf55ea37c38026a963a8a7ab5f5063">00110</a>     std::string <a class="code" href="classdtn_1_1Announce.html#1acf55ea37c38026a963a8a7ab5f5063" title="name for this beacon instance">name_</a>;  
<a name="l00111"></a><a class="code" href="classdtn_1_1Announce.html#7dfeaeaf96b1904c710bdb09a7a52c3f">00111</a>     std::string <a class="code" href="classdtn_1_1Announce.html#7dfeaeaf96b1904c710bdb09a7a52c3f" title="pulled from cl_">type_</a>;  
<a name="l00112"></a><a class="code" href="classdtn_1_1Announce.html#e81359675347762ba29a3f9ea9968cc4">00112</a>     u_int <a class="code" href="classdtn_1_1Announce.html#e81359675347762ba29a3f9ea9968cc4" title="interval (in milliseconds) for beacon header">interval_</a>;    
<a name="l00113"></a>00113 
<a name="l00114"></a><a class="code" href="classdtn_1_1Announce.html#25191d7733447aa55b2c092d61f6af35">00114</a>     <span class="keyword">struct </span>timeval <a class="code" href="classdtn_1_1Announce.html#25191d7733447aa55b2c092d61f6af35" title="mark each time data is sent">data_sent_</a>; 
<a name="l00115"></a>00115 <span class="keyword">private</span>:
<a name="l00116"></a><a class="code" href="classdtn_1_1Announce.html#295a26618b70be16462a3cfad94df27f">00116</a>     <a class="code" href="classdtn_1_1Announce.html#53ac7813f7c1e61b31b1ce3596b29ff8">Announce</a>(<span class="keyword">const</span> <a class="code" href="classdtn_1_1Announce.html" title="Announce represents a ConvergenceLayer (Interface).">Announce</a>&amp;)
<a name="l00117"></a>00117         : oasys::<a class="code" href="classoasys_1_1Logger.html">Logger</a>(<span class="stringliteral">"Announce"</span>,<span class="stringliteral">"/dtn/discovery/beacon"</span>) {}
<a name="l00118"></a>00118 }; <span class="comment">// Announce</span>
<a name="l00119"></a>00119 
<a name="l00120"></a>00120 } <span class="comment">// dtn</span>
<a name="l00121"></a>00121 
<a name="l00122"></a>00122 <span class="preprocessor">#endif // _ANNOUNCE_H_</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:52 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>