Sophie

Sophie

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

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: ConnectionConvergenceLayer.cc 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>ConnectionConvergenceLayer.cc</h1><a href="ConnectionConvergenceLayer_8cc.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 Intel Corporation</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">#ifdef HAVE_CONFIG_H</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#  include &lt;<a class="code" href="dtn-config_8h.html">dtn-config.h</a>&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#endif</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;oasys/util/OptParser.h&gt;</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="ConnectionConvergenceLayer_8h.html">ConnectionConvergenceLayer.h</a>"</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="CLConnection_8h.html">CLConnection.h</a>"</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="BundleDaemon_8h.html">bundling/BundleDaemon.h</a>"</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="keyword">namespace </span>dtn {
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00030"></a><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#2042590a2c094ae95b1b3dfbe1fd88f9">00030</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#2042590a2c094ae95b1b3dfbe1fd88f9">ConnectionConvergenceLayer::LinkParams::LinkParams</a>(<span class="keywordtype">bool</span> init_defaults)
<a name="l00031"></a>00031     : reactive_frag_enabled_(true),
<a name="l00032"></a>00032       sendbuf_len_(32768),
<a name="l00033"></a>00033       recvbuf_len_(32768),
<a name="l00034"></a>00034       data_timeout_(30000), <span class="comment">// msec</span>
<a name="l00035"></a>00035       test_read_delay_(0),
<a name="l00036"></a>00036       test_write_delay_(0),
<a name="l00037"></a>00037       test_recv_delay_(0),
<a name="l00038"></a>00038       test_read_limit_(0),
<a name="l00039"></a>00039       test_write_limit_(0)
<a name="l00040"></a>00040 {
<a name="l00041"></a>00041     (void)init_defaults;
<a name="l00042"></a>00042 }
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00045"></a><a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#56ec3d4688989c2df7adecdcaff0f634">00045</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#56ec3d4688989c2df7adecdcaff0f634" title="Constructor.">ConnectionConvergenceLayer::ConnectionConvergenceLayer</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* classname,
<a name="l00046"></a>00046                                                        <span class="keyword">const</span> <span class="keywordtype">char</span>* cl_name)
<a name="l00047"></a>00047     : <a class="code" href="classdtn_1_1ConvergenceLayer.html" title="The abstract interface for a convergence layer.">ConvergenceLayer</a>(classname, cl_name)
<a name="l00048"></a>00048 {
<a name="l00049"></a>00049 }
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00052"></a>00052 <span class="keywordtype">bool</span>
<a name="l00053"></a><a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#adbf0e8a26308b4250543ff5a46e2a09">00053</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#adbf0e8a26308b4250543ff5a46e2a09" title="Parse the link parameters, returning true iff the args are valid for the given nexthop...">ConnectionConvergenceLayer::parse_link_params</a>(<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>* params,
<a name="l00054"></a>00054                                               <span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>** argv,
<a name="l00055"></a>00055                                               <span class="keyword">const</span> <span class="keywordtype">char</span>** invalidp)
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057     oasys::OptParser p;
<a name="l00058"></a>00058     
<a name="l00059"></a>00059     p.addopt(<span class="keyword">new</span> oasys::BoolOpt(<span class="stringliteral">"reactive_frag_enabled"</span>,
<a name="l00060"></a>00060                                 &amp;params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#07a52c18ea031a370e2119c9fbd20f96" title="Is reactive fragmentation enabled.">reactive_frag_enabled_</a>));
<a name="l00061"></a>00061     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"sendbuf_len"</span>, &amp;params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#92db7c734ebf35e770cf12c8730fedf6" title="Buffer size for sending data.">sendbuf_len_</a>));
<a name="l00062"></a>00062     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"recvbuf_len"</span>, &amp;params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#3c82c7605d0abdf00af2e5c476dc520b" title="Buffer size for receiving data.">recvbuf_len_</a>));
<a name="l00063"></a>00063     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"data_timeout"</span>, &amp;params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#7f819ba8a1caa690ff86ce4484ba7329" title="Msecs to wait for data arrival.">data_timeout_</a>));
<a name="l00064"></a>00064     
<a name="l00065"></a>00065     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"test_read_delay"</span>,
<a name="l00066"></a>00066                                 &amp;params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#9e10301e4342cf1319096e973d1e5ff3" title="Msecs to sleep between read calls.">test_read_delay_</a>));
<a name="l00067"></a>00067     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"test_write_delay"</span>,
<a name="l00068"></a>00068                                 &amp;params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#9b77847034f59f7688f281c78d040000" title="Msecs to sleep between write calls.">test_write_delay_</a>));
<a name="l00069"></a>00069     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"test_recv_delay"</span>,
<a name="l00070"></a>00070                                 &amp;params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#8b93b74b178da3fb95e11d0562e2d1ae" title="Msecs to sleep before recv evt.">test_recv_delay_</a>));
<a name="l00071"></a>00071     
<a name="l00072"></a>00072     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"test_read_limit"</span>,
<a name="l00073"></a>00073                                 &amp;params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#8cf6f011103e2250e2ab6d8c5e40a06e" title="Max amount to read from the channel.">test_read_limit_</a>));
<a name="l00074"></a>00074     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"test_write_limit"</span>,
<a name="l00075"></a>00075                                 &amp;params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#08a9fb0dfcc27d98a3c327ec74bb41e0" title="Max amount to write to the channel.">test_write_limit_</a>));
<a name="l00076"></a>00076     
<a name="l00077"></a>00077     <span class="keywordflow">if</span> (! p.parse(argc, argv, invalidp)) {
<a name="l00078"></a>00078         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00079"></a>00079     }
<a name="l00080"></a>00080     
<a name="l00081"></a>00081     <span class="keywordflow">if</span> (params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#92db7c734ebf35e770cf12c8730fedf6" title="Buffer size for sending data.">sendbuf_len_</a> == 0) {
<a name="l00082"></a>00082         *invalidp = <span class="stringliteral">"sendbuf_len must not be zero"</span>;
<a name="l00083"></a>00083         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00084"></a>00084     }
<a name="l00085"></a>00085 
<a name="l00086"></a>00086     <span class="keywordflow">if</span> (params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#3c82c7605d0abdf00af2e5c476dc520b" title="Buffer size for receiving data.">recvbuf_len_</a> == 0) {
<a name="l00087"></a>00087         *invalidp = <span class="stringliteral">"recvbuf_len must not be zero"</span>;
<a name="l00088"></a>00088         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00089"></a>00089     }
<a name="l00090"></a>00090     
<a name="l00091"></a>00091     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00092"></a>00092 }
<a name="l00093"></a>00093 
<a name="l00094"></a>00094 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00095"></a>00095 <span class="keywordtype">void</span>
<a name="l00096"></a><a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#c8a0955bbe61e68c1a697e62faa1e4c8">00096</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#c8a0955bbe61e68c1a697e62faa1e4c8" title="Virtual from ConvergenceLayer.">ConnectionConvergenceLayer::dump_link</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link,
<a name="l00097"></a>00097                                       oasys::StringBuffer* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>)
<a name="l00098"></a>00098 {
<a name="l00099"></a>00099     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l00100"></a>00100     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!link-&gt;isdeleted());
<a name="l00101"></a>00101     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link-&gt;cl_info() != NULL);
<a name="l00102"></a>00102         
<a name="l00103"></a>00103     <a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>* params = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>*<span class="keyword">&gt;</span>(link-&gt;cl_info());
<a name="l00104"></a>00104     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(params != NULL);
<a name="l00105"></a>00105     
<a name="l00106"></a>00106     buf-&gt;appendf(<span class="stringliteral">"reactive_frag_enabled: %u\n"</span>, params-&gt;reactive_frag_enabled_);
<a name="l00107"></a>00107     buf-&gt;appendf(<span class="stringliteral">"sendbuf_len: %u\n"</span>, params-&gt;sendbuf_len_);
<a name="l00108"></a>00108     buf-&gt;appendf(<span class="stringliteral">"recvbuf_len: %u\n"</span>, params-&gt;recvbuf_len_);
<a name="l00109"></a>00109     buf-&gt;appendf(<span class="stringliteral">"data_timeout: %u\n"</span>, params-&gt;data_timeout_);
<a name="l00110"></a>00110     buf-&gt;appendf(<span class="stringliteral">"test_read_delay: %u\n"</span>, params-&gt;test_read_delay_);
<a name="l00111"></a>00111     buf-&gt;appendf(<span class="stringliteral">"test_write_delay: %u\n"</span>, params-&gt;test_write_delay_);
<a name="l00112"></a>00112     buf-&gt;appendf(<span class="stringliteral">"test_recv_delay: %u\n"</span>,params-&gt;test_recv_delay_);
<a name="l00113"></a>00113 }
<a name="l00114"></a>00114 
<a name="l00115"></a>00115 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00116"></a>00116 <span class="keywordtype">bool</span>
<a name="l00117"></a><a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#889ff6f6005f5a8c836ce39cd0c4c2e7">00117</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#889ff6f6005f5a8c836ce39cd0c4c2e7" title="Virtual from ConvergenceLayer.">ConnectionConvergenceLayer::init_link</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link,
<a name="l00118"></a>00118                                       <span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>* argv[])
<a name="l00119"></a>00119 {
<a name="l00120"></a>00120     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l00121"></a>00121     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!link-&gt;isdeleted());
<a name="l00122"></a>00122     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link-&gt;cl_info() == NULL);
<a name="l00123"></a>00123 
<a name="l00124"></a>00124     log_debug(<span class="stringliteral">"adding %s link %s"</span>, link-&gt;type_str(), link-&gt;nexthop());
<a name="l00125"></a>00125 
<a name="l00126"></a>00126     <span class="comment">// Create a new parameters structure, parse the options, and store</span>
<a name="l00127"></a>00127     <span class="comment">// them in the link's cl info slot.</span>
<a name="l00128"></a>00128     <a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>* params = <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#c837d8f6908c2711cabdfe925bee1ac5" title="Create a new LinkParams structure.">new_link_params</a>();
<a name="l00129"></a>00129 
<a name="l00130"></a>00130     <span class="comment">// Try to parse the link's next hop, but continue on even if the</span>
<a name="l00131"></a>00131     <span class="comment">// parse fails since the hostname may not be resolvable when we</span>
<a name="l00132"></a>00132     <span class="comment">// initialize the link. Each subclass is responsible for</span>
<a name="l00133"></a>00133     <span class="comment">// re-checking when opening the link.</span>
<a name="l00134"></a>00134     <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#9f96d07f1c0cb39625c18d08fda84bfc" title="Parse and validate the nexthop address for the given link.">parse_nexthop</a>(link, params);
<a name="l00135"></a>00135     
<a name="l00136"></a>00136     <span class="keyword">const</span> <span class="keywordtype">char</span>* invalid;
<a name="l00137"></a>00137     <span class="keywordflow">if</span> (! <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#adbf0e8a26308b4250543ff5a46e2a09" title="Parse the link parameters, returning true iff the args are valid for the given nexthop...">parse_link_params</a>(params, argc, argv, &amp;invalid)) {
<a name="l00138"></a>00138         log_err(<span class="stringliteral">"error parsing link options: invalid option '%s'"</span>, invalid);
<a name="l00139"></a>00139         <span class="keyword">delete</span> params;
<a name="l00140"></a>00140         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00141"></a>00141     }
<a name="l00142"></a>00142 
<a name="l00143"></a>00143     <span class="keywordflow">if</span> (! <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#a256c77be82909fb4fede37fd347fd23" title="After the link parameters are parsed, do any initialization of the link that&amp;#39;s...">finish_init_link</a>(link, params)) {
<a name="l00144"></a>00144         log_err(<span class="stringliteral">"error in finish_init_link"</span>);
<a name="l00145"></a>00145         <span class="keyword">delete</span> params;
<a name="l00146"></a>00146         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00147"></a>00147     }
<a name="l00148"></a>00148 
<a name="l00149"></a>00149     link-&gt;set_cl_info(params);
<a name="l00150"></a>00150 
<a name="l00151"></a>00151     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00152"></a>00152 }
<a name="l00153"></a>00153 
<a name="l00154"></a>00154 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00155"></a>00155 <span class="keywordtype">void</span>
<a name="l00156"></a><a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#f0a6be1e18dbf9241f6d1d7c89ff47e8">00156</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#f0a6be1e18dbf9241f6d1d7c89ff47e8" title="Virtual from ConvergenceLayer.">ConnectionConvergenceLayer::delete_link</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link)
<a name="l00157"></a>00157 {
<a name="l00158"></a>00158     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l00159"></a>00159     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!link-&gt;isdeleted());
<a name="l00160"></a>00160 
<a name="l00161"></a>00161     log_debug(<span class="stringliteral">"ConnectionConvergenceLayer::delete_link: "</span>
<a name="l00162"></a>00162               <span class="stringliteral">"deleting link %s"</span>, link-&gt;name());
<a name="l00163"></a>00163 
<a name="l00164"></a>00164     <span class="keywordflow">if</span> (link-&gt;isopen() || link-&gt;isopening()) {
<a name="l00165"></a>00165         log_debug(<span class="stringliteral">"ConnectionConvergenceLayer::delete_link: "</span>
<a name="l00166"></a>00166                   <span class="stringliteral">"link %s open, deleting link state when contact closed"</span>,
<a name="l00167"></a>00167                   link-&gt;name());
<a name="l00168"></a>00168         <span class="keywordflow">return</span>;
<a name="l00169"></a>00169     }
<a name="l00170"></a>00170 
<a name="l00171"></a>00171     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link-&gt;contact() == NULL);
<a name="l00172"></a>00172     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link-&gt;cl_info() != NULL);
<a name="l00173"></a>00173 
<a name="l00174"></a>00174     <span class="keyword">delete</span> link-&gt;cl_info();
<a name="l00175"></a>00175     link-&gt;set_cl_info(NULL);
<a name="l00176"></a>00176 }
<a name="l00177"></a>00177 
<a name="l00178"></a>00178 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00179"></a>00179 <span class="keywordtype">bool</span>
<a name="l00180"></a><a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#a256c77be82909fb4fede37fd347fd23">00180</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#a256c77be82909fb4fede37fd347fd23" title="After the link parameters are parsed, do any initialization of the link that&amp;#39;s...">ConnectionConvergenceLayer::finish_init_link</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link,
<a name="l00181"></a>00181                                              <a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>* params)
<a name="l00182"></a>00182 {
<a name="l00183"></a>00183     (void)link;
<a name="l00184"></a>00184     (void)params;
<a name="l00185"></a>00185     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00186"></a>00186 }
<a name="l00187"></a>00187 
<a name="l00188"></a>00188 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00189"></a>00189 <span class="keywordtype">bool</span>
<a name="l00190"></a><a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#de9d1c7b1d79efaf0e93253e745aefb7">00190</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#de9d1c7b1d79efaf0e93253e745aefb7" title="Virtual from ConvergenceLayer.">ConnectionConvergenceLayer::reconfigure_link</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link,
<a name="l00191"></a>00191                                              <span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>* argv[])
<a name="l00192"></a>00192 {
<a name="l00193"></a>00193     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l00194"></a>00194     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!link-&gt;isdeleted());
<a name="l00195"></a>00195     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link-&gt;cl_info() != NULL);
<a name="l00196"></a>00196         
<a name="l00197"></a>00197     <a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>* params = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>*<span class="keyword">&gt;</span>(link-&gt;cl_info());
<a name="l00198"></a>00198     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(params != NULL);
<a name="l00199"></a>00199     
<a name="l00200"></a>00200     <span class="keyword">const</span> <span class="keywordtype">char</span>* invalid;
<a name="l00201"></a>00201     <span class="keywordflow">if</span> (! <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#adbf0e8a26308b4250543ff5a46e2a09" title="Parse the link parameters, returning true iff the args are valid for the given nexthop...">parse_link_params</a>(params, argc, argv, &amp;invalid)) {
<a name="l00202"></a>00202         log_err(<span class="stringliteral">"reconfigure_link: invalid parameter %s"</span>, invalid);
<a name="l00203"></a>00203         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00204"></a>00204     }
<a name="l00205"></a>00205 
<a name="l00206"></a>00206     <span class="keywordflow">if</span> (link-&gt;isopen()) {
<a name="l00207"></a>00207         <a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>* params = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>*<span class="keyword">&gt;</span>(link-&gt;cl_info());
<a name="l00208"></a>00208         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(params != NULL);
<a name="l00209"></a>00209         
<a name="l00210"></a>00210         <a class="code" href="classdtn_1_1CLConnection.html" title="Helper class (and thread) that manages an established connection with a peer daemon...">CLConnection</a>* conn = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classdtn_1_1CLConnection.html" title="Helper class (and thread) that manages an established connection with a peer daemon...">CLConnection</a>*<span class="keyword">&gt;</span>(link-&gt;contact()-&gt;cl_info());
<a name="l00211"></a>00211         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(conn != NULL);
<a name="l00212"></a>00212         
<a name="l00213"></a>00213         <span class="keywordflow">if</span> ((params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#92db7c734ebf35e770cf12c8730fedf6" title="Buffer size for sending data.">sendbuf_len_</a> != conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#95f89064268605c6183fa4c436a12071" title="Buffer for outgoing data.">sendbuf_</a>.size()) &amp;&amp;
<a name="l00214"></a>00214             (params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#92db7c734ebf35e770cf12c8730fedf6" title="Buffer size for sending data.">sendbuf_len_</a> &gt;= conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#95f89064268605c6183fa4c436a12071" title="Buffer for outgoing data.">sendbuf_</a>.fullbytes()))
<a name="l00215"></a>00215         {
<a name="l00216"></a>00216             log_info(<span class="stringliteral">"resizing link *%p send buffer from %zu -&gt; %u"</span>,
<a name="l00217"></a>00217                      link.object(), conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#95f89064268605c6183fa4c436a12071" title="Buffer for outgoing data.">sendbuf_</a>.size(),
<a name="l00218"></a>00218                      params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#92db7c734ebf35e770cf12c8730fedf6" title="Buffer size for sending data.">sendbuf_len_</a>);
<a name="l00219"></a>00219             conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#95f89064268605c6183fa4c436a12071" title="Buffer for outgoing data.">sendbuf_</a>.set_size(params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#92db7c734ebf35e770cf12c8730fedf6" title="Buffer size for sending data.">sendbuf_len_</a>);
<a name="l00220"></a>00220         }
<a name="l00221"></a>00221 
<a name="l00222"></a>00222         <span class="keywordflow">if</span> ((params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#3c82c7605d0abdf00af2e5c476dc520b" title="Buffer size for receiving data.">recvbuf_len_</a> != conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#483ff0dd2871a812491c16aa8d3f9124" title="Buffer for incoming data.">recvbuf_</a>.size()) &amp;&amp;
<a name="l00223"></a>00223             (params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#3c82c7605d0abdf00af2e5c476dc520b" title="Buffer size for receiving data.">recvbuf_len_</a> &gt;= conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#483ff0dd2871a812491c16aa8d3f9124" title="Buffer for incoming data.">recvbuf_</a>.fullbytes()))
<a name="l00224"></a>00224         {
<a name="l00225"></a>00225             log_info(<span class="stringliteral">"resizing link *%p recv buffer from %zu -&gt; %u"</span>,
<a name="l00226"></a>00226                      link.object(), conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#483ff0dd2871a812491c16aa8d3f9124" title="Buffer for incoming data.">recvbuf_</a>.size(),
<a name="l00227"></a>00227                      params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#3c82c7605d0abdf00af2e5c476dc520b" title="Buffer size for receiving data.">recvbuf_len_</a>);
<a name="l00228"></a>00228             conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#483ff0dd2871a812491c16aa8d3f9124" title="Buffer for incoming data.">recvbuf_</a>.set_size(params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#3c82c7605d0abdf00af2e5c476dc520b" title="Buffer size for receiving data.">recvbuf_len_</a>);
<a name="l00229"></a>00229         }
<a name="l00230"></a>00230     }
<a name="l00231"></a>00231 
<a name="l00232"></a>00232     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00233"></a>00233 }
<a name="l00234"></a>00234 
<a name="l00235"></a>00235 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00236"></a>00236 <span class="keywordtype">bool</span>
<a name="l00237"></a><a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#1c3cb9cbe18ba59ac976e19067472ad4">00237</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#1c3cb9cbe18ba59ac976e19067472ad4" title="Virtual from ConvergenceLayer.">ConnectionConvergenceLayer::open_contact</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#5f869544c85c75b5a85a14d6e90d7ff7" title="Typedef for a reference on a contact.">ContactRef</a>&amp; contact)
<a name="l00238"></a>00238 {
<a name="l00239"></a>00239     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = contact-&gt;link();
<a name="l00240"></a>00240     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l00241"></a>00241     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!link-&gt;isdeleted());
<a name="l00242"></a>00242     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link-&gt;cl_info() != NULL);
<a name="l00243"></a>00243 
<a name="l00244"></a>00244     log_debug(<span class="stringliteral">"ConnectionConvergenceLayer::open_contact: "</span>
<a name="l00245"></a>00245               <span class="stringliteral">"opening contact on link *%p"</span>, link.object());
<a name="l00246"></a>00246     
<a name="l00247"></a>00247     <a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>* params = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>*<span class="keyword">&gt;</span>(link-&gt;cl_info());
<a name="l00248"></a>00248     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(params != NULL);
<a name="l00249"></a>00249     
<a name="l00250"></a>00250     <span class="comment">// create a new connection for the contact, set up to use the</span>
<a name="l00251"></a>00251     <span class="comment">// link's configured parameters</span>
<a name="l00252"></a>00252     <a class="code" href="classdtn_1_1CLConnection.html" title="Helper class (and thread) that manages an established connection with a peer daemon...">CLConnection</a>* conn = <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#c7772a23c2ba8c47c24807e446264918" title="Create a new CL-specific connection object.">new_connection</a>(link, params);
<a name="l00253"></a>00253     conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#4104e08b78e6796beff1b46d9bdd6a31" title="Attach to the given contact.">set_contact</a>(contact);
<a name="l00254"></a>00254     contact-&gt;set_cl_info(conn);
<a name="l00255"></a>00255     conn-&gt;start();
<a name="l00256"></a>00256 
<a name="l00257"></a>00257     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00258"></a>00258 }
<a name="l00259"></a>00259 
<a name="l00260"></a>00260 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00261"></a>00261 <span class="keywordtype">bool</span>
<a name="l00262"></a><a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#e5498982de68b593fdf1985a9e7d4011">00262</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#e5498982de68b593fdf1985a9e7d4011" title="Virtual from ConvergenceLayer.">ConnectionConvergenceLayer::close_contact</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#5f869544c85c75b5a85a14d6e90d7ff7" title="Typedef for a reference on a contact.">ContactRef</a>&amp; contact)
<a name="l00263"></a>00263 {
<a name="l00264"></a>00264     log_info(<span class="stringliteral">"close_contact *%p"</span>, contact.object());
<a name="l00265"></a>00265 
<a name="l00266"></a>00266     <span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link = contact-&gt;link();
<a name="l00267"></a>00267     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l00268"></a>00268     
<a name="l00269"></a>00269     <a class="code" href="classdtn_1_1CLConnection.html" title="Helper class (and thread) that manages an established connection with a peer daemon...">CLConnection</a>* conn = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classdtn_1_1CLConnection.html" title="Helper class (and thread) that manages an established connection with a peer daemon...">CLConnection</a>*<span class="keyword">&gt;</span>(contact-&gt;cl_info());
<a name="l00270"></a>00270     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(conn != NULL);
<a name="l00271"></a>00271 
<a name="l00272"></a>00272     <span class="comment">// if the connection isn't already broken, then we need to tell it</span>
<a name="l00273"></a>00273     <span class="comment">// to do so</span>
<a name="l00274"></a>00274     <span class="keywordflow">if</span> (! conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#a61b296b02812f04b3df0c8fb09919b8" title="Contact has been broken.">contact_broken_</a>) {
<a name="l00275"></a>00275         conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#1701c536c9f5cd3d276c4b91a38ed2cf" title="Daemon/CLConnection command queue.">cmdqueue_</a>.push_back(
<a name="l00276"></a>00276             <a class="code" href="structdtn_1_1CLConnection_1_1CLMsg.html" title="struct used for messages going from the daemon thread to the connection thread.">CLConnection::CLMsg</a>(<a class="code" href="classdtn_1_1CLConnection.html#63574e52407c97761d234ee70673d6682a906c20963b066daaca910e2e6b5ffe">CLConnection::CLMSG_BREAK_CONTACT</a>));
<a name="l00277"></a>00277     }
<a name="l00278"></a>00278     
<a name="l00279"></a>00279     <span class="keywordflow">while</span> (!conn-&gt;is_stopped()) {
<a name="l00280"></a>00280         log_debug(<span class="stringliteral">"waiting for connection thread to stop..."</span>);
<a name="l00281"></a>00281         usleep(100000);
<a name="l00282"></a>00282         oasys::Thread::yield();
<a name="l00283"></a>00283     }
<a name="l00284"></a>00284 
<a name="l00285"></a>00285     <span class="comment">// now that the connection thread is stopped, clean up the in</span>
<a name="l00286"></a>00286     <span class="comment">// flight and incoming bundles</span>
<a name="l00287"></a>00287     <a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>* params = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&amp;#39;s CLInfo slot.">LinkParams</a>*<span class="keyword">&gt;</span>(link-&gt;cl_info());
<a name="l00288"></a>00288     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(params != NULL);
<a name="l00289"></a>00289     
<a name="l00290"></a>00290     <span class="keywordflow">while</span> (! conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#bb337ec089b627c417864a01a095319e" title="Bundles going out the wire.">inflight_</a>.empty()) {
<a name="l00291"></a>00291         <a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html" title="Struct used to record bundles that are in-flight along with their transmission state...">CLConnection::InFlightBundle</a>* inflight = conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#bb337ec089b627c417864a01a095319e" title="Bundles going out the wire.">inflight_</a>.front();
<a name="l00292"></a>00292         u_int32_t sent_bytes  = inflight-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#f4f89ea9800c7eefe41e51018188180a">sent_data_</a>.num_contiguous();
<a name="l00293"></a>00293         u_int32_t acked_bytes = inflight-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#7ba3f112c83aea033fab72f7759ce7f2">ack_data_</a>.num_contiguous();
<a name="l00294"></a>00294 
<a name="l00295"></a>00295         <span class="keywordflow">if</span> ((! params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#07a52c18ea031a370e2119c9fbd20f96" title="Is reactive fragmentation enabled.">reactive_frag_enabled_</a>) ||
<a name="l00296"></a>00296             (sent_bytes == 0) ||
<a name="l00297"></a>00297             (link-&gt;is_reliable() &amp;&amp; acked_bytes == 0))
<a name="l00298"></a>00298         {
<a name="l00299"></a>00299             <span class="comment">// if we've started the bundle but not gotten anything</span>
<a name="l00300"></a>00300             <span class="comment">// out, we need to push the bundle back onto the link</span>
<a name="l00301"></a>00301             <span class="comment">// queue so it's there when the link re-opens</span>
<a name="l00302"></a>00302             <span class="keywordflow">if</span> (! link-&gt;del_from_inflight(inflight-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#e0fb72eeccee446eccf8b17a3cc84b94">bundle_</a>,
<a name="l00303"></a>00303                                           inflight-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#fde31db0c5211defbb1e58d66efb8a68">total_length_</a>) ||
<a name="l00304"></a>00304                 ! link-&gt;add_to_queue(inflight-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#e0fb72eeccee446eccf8b17a3cc84b94">bundle_</a>,
<a name="l00305"></a>00305                                      inflight-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#fde31db0c5211defbb1e58d66efb8a68">total_length_</a>))
<a name="l00306"></a>00306             {
<a name="l00307"></a>00307                 log_warn(<span class="stringliteral">"inflight queue mismatch for bundle %d"</span>,
<a name="l00308"></a>00308                          inflight-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#e0fb72eeccee446eccf8b17a3cc84b94">bundle_</a>-&gt;bundleid());
<a name="l00309"></a>00309             }
<a name="l00310"></a>00310             
<a name="l00311"></a>00311         } <span class="keywordflow">else</span> {
<a name="l00312"></a>00312             <span class="comment">// otherwise, if part of the bundle has been transmitted,</span>
<a name="l00313"></a>00313             <span class="comment">// then post the event so that the core system can do</span>
<a name="l00314"></a>00314             <span class="comment">// reactive fragmentation</span>
<a name="l00315"></a>00315             <span class="keywordflow">if</span> (! inflight-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#c9159f7ebd46e2427c4095d5bcc1d3e9">transmit_event_posted_</a>) {
<a name="l00316"></a>00316                 <a class="code" href="classdtn_1_1BundleDaemon.html#370a80f7dd9fd9297e76d7f830d737a8" title="Queues the event at the tail of the queue for processing by the daemon thread.">BundleDaemon::post</a>(
<a name="l00317"></a>00317                     <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleTransmittedEvent.html" title="Event class for bundle or fragment transmission.">BundleTransmittedEvent</a>(inflight-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#e0fb72eeccee446eccf8b17a3cc84b94">bundle_</a>.object(),
<a name="l00318"></a>00318                                                contact, link,
<a name="l00319"></a>00319                                                sent_bytes, acked_bytes));
<a name="l00320"></a>00320             }
<a name="l00321"></a>00321         }
<a name="l00322"></a>00322 
<a name="l00323"></a>00323         conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#bb337ec089b627c417864a01a095319e" title="Bundles going out the wire.">inflight_</a>.pop_front();
<a name="l00324"></a>00324         <span class="keyword">delete</span> inflight;
<a name="l00325"></a>00325     }
<a name="l00326"></a>00326 
<a name="l00327"></a>00327     <span class="comment">// check the tail of the incoming queue to see if there's a</span>
<a name="l00328"></a>00328     <span class="comment">// partially-received bundle that we need to post a received event</span>
<a name="l00329"></a>00329     <span class="comment">// for (if reactive fragmentation is enabled)</span>
<a name="l00330"></a>00330     <span class="keywordflow">if</span> (! conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#d228b2004768c4ee6027823f270a816c" title="Bundles arriving on the wire.">incoming_</a>.empty()) {
<a name="l00331"></a>00331         <a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html" title="Struct used to record bundles that are in the process of being received along with...">CLConnection::IncomingBundle</a>* incoming = conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#d228b2004768c4ee6027823f270a816c" title="Bundles arriving on the wire.">incoming_</a>.back();
<a name="l00332"></a>00332         <span class="keywordflow">if</span> (!incoming-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html#414686f37abb161c1e5bc3ca9c02ad48">rcvd_data_</a>.empty())
<a name="l00333"></a>00333         {  
<a name="l00334"></a>00334             <span class="keywordtype">size_t</span> rcvd_len = incoming-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html#414686f37abb161c1e5bc3ca9c02ad48">rcvd_data_</a>.last() + 1;
<a name="l00335"></a>00335             
<a name="l00336"></a>00336             <span class="keywordtype">size_t</span> header_block_length =
<a name="l00337"></a>00337                 <a class="code" href="classdtn_1_1BundleProtocol.html#1b5ecc82d428705f3ba067622faace2c" title="Temporary helper function to find the offset of the first byte of the payload in...">BundleProtocol::payload_offset</a>(&amp;incoming-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html#7e868dff33d6868d5e42582fac3f4109">bundle_</a>-&gt;recv_blocks());
<a name="l00338"></a>00338         
<a name="l00339"></a>00339             <span class="keywordflow">if</span> ((incoming-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html#2f9d5b3f0487449503664a0429f59d33">total_length_</a> == 0) &amp;&amp; 
<a name="l00340"></a>00340                 params-&gt;<a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#07a52c18ea031a370e2119c9fbd20f96" title="Is reactive fragmentation enabled.">reactive_frag_enabled_</a> &amp;&amp;
<a name="l00341"></a>00341                 (rcvd_len &gt; header_block_length))
<a name="l00342"></a>00342             {
<a name="l00343"></a>00343                 log_debug(<span class="stringliteral">"partial arrival of bundle: "</span>
<a name="l00344"></a>00344                           <span class="stringliteral">"got %zu bytes [hdr %zu payload %zu]"</span>,
<a name="l00345"></a>00345                           rcvd_len, header_block_length,
<a name="l00346"></a>00346                           incoming-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html#7e868dff33d6868d5e42582fac3f4109">bundle_</a>-&gt;payload().length());
<a name="l00347"></a>00347              
<a name="l00348"></a>00348                 <a class="code" href="classdtn_1_1BundleDaemon.html#370a80f7dd9fd9297e76d7f830d737a8" title="Queues the event at the tail of the queue for processing by the daemon thread.">BundleDaemon::post</a>(
<a name="l00349"></a>00349                     <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a>(incoming-&gt;<a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html#7e868dff33d6868d5e42582fac3f4109">bundle_</a>.object(),
<a name="l00350"></a>00350                                             <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142bb0775776e4be46e62a0dcff6cf968059" title="a peer dtn forwarder">EVENTSRC_PEER</a>, rcvd_len,
<a name="l00351"></a>00351                                             contact-&gt;link()-&gt;remote_eid(),
<a name="l00352"></a>00352                                             contact-&gt;link().object()));
<a name="l00353"></a>00353             }
<a name="l00354"></a>00354         }
<a name="l00355"></a>00355     }
<a name="l00356"></a>00356 
<a name="l00357"></a>00357     <span class="comment">// drain the CLConnection incoming queue</span>
<a name="l00358"></a>00358     <span class="keywordflow">while</span> (! conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#d228b2004768c4ee6027823f270a816c" title="Bundles arriving on the wire.">incoming_</a>.empty()) {
<a name="l00359"></a>00359         <a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html" title="Struct used to record bundles that are in the process of being received along with...">CLConnection::IncomingBundle</a>* incoming = conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#d228b2004768c4ee6027823f270a816c" title="Bundles arriving on the wire.">incoming_</a>.back();
<a name="l00360"></a>00360         conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#d228b2004768c4ee6027823f270a816c" title="Bundles arriving on the wire.">incoming_</a>.pop_back();
<a name="l00361"></a>00361         <span class="keyword">delete</span> incoming;
<a name="l00362"></a>00362     }
<a name="l00363"></a>00363 
<a name="l00364"></a>00364     <span class="comment">// clear out the connection message queue</span>
<a name="l00365"></a>00365     <a class="code" href="structdtn_1_1CLConnection_1_1CLMsg.html" title="struct used for messages going from the daemon thread to the connection thread.">CLConnection::CLMsg</a> msg;
<a name="l00366"></a>00366     <span class="keywordflow">while</span> (conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#1701c536c9f5cd3d276c4b91a38ed2cf" title="Daemon/CLConnection command queue.">cmdqueue_</a>.try_pop(&amp;msg)) {}
<a name="l00367"></a>00367     
<a name="l00368"></a>00368     <span class="keyword">delete</span> conn;
<a name="l00369"></a>00369     
<a name="l00370"></a>00370     contact-&gt;set_cl_info(NULL);
<a name="l00371"></a>00371 
<a name="l00372"></a>00372     <span class="keywordflow">if</span> (link-&gt;isdeleted()) {
<a name="l00373"></a>00373         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link-&gt;cl_info() != NULL);
<a name="l00374"></a>00374         <span class="keyword">delete</span> link-&gt;cl_info();
<a name="l00375"></a>00375         link-&gt;set_cl_info(NULL);
<a name="l00376"></a>00376     }
<a name="l00377"></a>00377 
<a name="l00378"></a>00378     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00379"></a>00379 }
<a name="l00380"></a>00380 
<a name="l00381"></a>00381 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00382"></a>00382 <span class="keywordtype">void</span>
<a name="l00383"></a><a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#f84ad21279095a87e161a5f370b10bd2">00383</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#f84ad21279095a87e161a5f370b10bd2" title="Virtual from ConvergenceLayer.">ConnectionConvergenceLayer::bundle_queued</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link,
<a name="l00384"></a>00384                                           <span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; bundle)
<a name="l00385"></a>00385 {
<a name="l00386"></a>00386     (void)bundle;
<a name="l00387"></a>00387     log_debug(<span class="stringliteral">"ConnectionConvergenceLayer::bundle_queued: "</span>
<a name="l00388"></a>00388               <span class="stringliteral">"queued *%p on *%p"</span>, bundle.object(), link.object());
<a name="l00389"></a>00389 
<a name="l00390"></a>00390     <span class="keywordflow">if</span> (! link-&gt;isopen()) {
<a name="l00391"></a>00391         <span class="keywordflow">return</span>;
<a name="l00392"></a>00392     }
<a name="l00393"></a>00393 
<a name="l00394"></a>00394     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!link-&gt;isdeleted());
<a name="l00395"></a>00395     
<a name="l00396"></a>00396     <span class="keyword">const</span> <a class="code" href="namespacedtn.html#5f869544c85c75b5a85a14d6e90d7ff7" title="Typedef for a reference on a contact.">ContactRef</a>&amp; contact = link-&gt;contact();
<a name="l00397"></a>00397     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(contact != NULL);
<a name="l00398"></a>00398 
<a name="l00399"></a>00399     <a class="code" href="classdtn_1_1CLConnection.html" title="Helper class (and thread) that manages an established connection with a peer daemon...">CLConnection</a>* conn = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classdtn_1_1CLConnection.html" title="Helper class (and thread) that manages an established connection with a peer daemon...">CLConnection</a>*<span class="keyword">&gt;</span>(contact-&gt;cl_info());
<a name="l00400"></a>00400     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(conn != NULL);
<a name="l00401"></a>00401     
<a name="l00402"></a>00402     <span class="comment">// the bundle was previously put on the link queue, so we just</span>
<a name="l00403"></a>00403     <span class="comment">// kick the connection thread in case it's idle.</span>
<a name="l00404"></a>00404     <span class="comment">//</span>
<a name="l00405"></a>00405     <span class="comment">// note that it's possible the bundle was already picked up and</span>
<a name="l00406"></a>00406     <span class="comment">// taken off the link queue by the connection thread, so don't</span>
<a name="l00407"></a>00407     <span class="comment">// assert here.</span>
<a name="l00408"></a>00408     conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#1701c536c9f5cd3d276c4b91a38ed2cf" title="Daemon/CLConnection command queue.">cmdqueue_</a>.push_back(
<a name="l00409"></a>00409         <a class="code" href="structdtn_1_1CLConnection_1_1CLMsg.html" title="struct used for messages going from the daemon thread to the connection thread.">CLConnection::CLMsg</a>(<a class="code" href="classdtn_1_1CLConnection.html#63574e52407c97761d234ee70673d6682a3cb1958e000ece0c3b1ec62b6a6a28">CLConnection::CLMSG_BUNDLES_QUEUED</a>));
<a name="l00410"></a>00410 }
<a name="l00411"></a>00411 
<a name="l00412"></a>00412 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00413"></a>00413 <span class="keywordtype">void</span>
<a name="l00414"></a><a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#c80d202f28b43f016b56550fd8265704">00414</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer.html#c80d202f28b43f016b56550fd8265704" title="Virtual from ConvergenceLayer.">ConnectionConvergenceLayer::cancel_bundle</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link,
<a name="l00415"></a>00415                                           <span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; bundle)
<a name="l00416"></a>00416 {
<a name="l00417"></a>00417     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(! link-&gt;isdeleted());
<a name="l00418"></a>00418     
<a name="l00419"></a>00419     <span class="comment">// the bundle should be on the inflight queue for cancel_bundle to</span>
<a name="l00420"></a>00420     <span class="comment">// be called</span>
<a name="l00421"></a>00421     <span class="keywordflow">if</span> (! bundle-&gt;is_queued_on(link-&gt;inflight())) {
<a name="l00422"></a>00422         log_warn(<span class="stringliteral">"cancel_bundle *%p not on link %s inflight queue"</span>,
<a name="l00423"></a>00423                  bundle.object(), link-&gt;name());
<a name="l00424"></a>00424         <span class="keywordflow">return</span>;
<a name="l00425"></a>00425     }
<a name="l00426"></a>00426     
<a name="l00427"></a>00427     <span class="keywordflow">if</span> (!link-&gt;isopen()) {
<a name="l00428"></a>00428         <span class="comment">/* </span>
<a name="l00429"></a>00429 <span class="comment">         * (Taken from jmmikkel checkin comment on BBN source tree)</span>
<a name="l00430"></a>00430 <span class="comment">         *</span>
<a name="l00431"></a>00431 <span class="comment">         * The dtn2 internal convergence layer complains and does</span>
<a name="l00432"></a>00432 <span class="comment">         * nothing if you try to cancel a bundle after the link has</span>
<a name="l00433"></a>00433 <span class="comment">         * closed instead of just considering the send cancelled. I</span>
<a name="l00434"></a>00434 <span class="comment">         * believe that posting a BundleCancelledEvent before</span>
<a name="l00435"></a>00435 <span class="comment">         * returning is the correct way to make the cancel actually</span>
<a name="l00436"></a>00436 <span class="comment">         * happen in this situation, as the bundle is removed from the</span>
<a name="l00437"></a>00437 <span class="comment">         * link queue in that event's handler.</span>
<a name="l00438"></a>00438 <span class="comment">         */</span>
<a name="l00439"></a>00439         log_warn(<span class="stringliteral">"cancel_bundle *%p but link *%p isn't open!!"</span>,
<a name="l00440"></a>00440                  bundle.object(), link.object());
<a name="l00441"></a>00441         <a class="code" href="classdtn_1_1BundleDaemon.html#370a80f7dd9fd9297e76d7f830d737a8" title="Queues the event at the tail of the queue for processing by the daemon thread.">BundleDaemon::post</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleSendCancelledEvent.html" title="Event class for succesful cancellation of a bundle send.">BundleSendCancelledEvent</a>(bundle.object(), link));
<a name="l00442"></a>00442         <span class="keywordflow">return</span>;
<a name="l00443"></a>00443     }
<a name="l00444"></a>00444     
<a name="l00445"></a>00445     <span class="keyword">const</span> <a class="code" href="namespacedtn.html#5f869544c85c75b5a85a14d6e90d7ff7" title="Typedef for a reference on a contact.">ContactRef</a>&amp; contact = link-&gt;contact();
<a name="l00446"></a>00446     <a class="code" href="classdtn_1_1CLConnection.html" title="Helper class (and thread) that manages an established connection with a peer daemon...">CLConnection</a>* conn = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classdtn_1_1CLConnection.html" title="Helper class (and thread) that manages an established connection with a peer daemon...">CLConnection</a>*<span class="keyword">&gt;</span>(contact-&gt;cl_info());
<a name="l00447"></a>00447     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(conn != NULL);
<a name="l00448"></a>00448 
<a name="l00449"></a>00449     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(contact-&gt;link() == link);
<a name="l00450"></a>00450     log_debug(<span class="stringliteral">"ConnectionConvergenceLayer::cancel_bundle: "</span>
<a name="l00451"></a>00451               <span class="stringliteral">"cancelling *%p on *%p"</span>, bundle.object(), link.object());
<a name="l00452"></a>00452 
<a name="l00453"></a>00453     conn-&gt;<a class="code" href="classdtn_1_1CLConnection.html#1701c536c9f5cd3d276c4b91a38ed2cf" title="Daemon/CLConnection command queue.">cmdqueue_</a>.push_back(
<a name="l00454"></a>00454         <a class="code" href="structdtn_1_1CLConnection_1_1CLMsg.html" title="struct used for messages going from the daemon thread to the connection thread.">CLConnection::CLMsg</a>(<a class="code" href="classdtn_1_1CLConnection.html#63574e52407c97761d234ee70673d6687956f18d39bad128e8ec2e0b4015dd4b">CLConnection::CLMSG_CANCEL_BUNDLE</a>, bundle));
<a name="l00455"></a>00455 }
<a name="l00456"></a>00456 
<a name="l00457"></a>00457 } <span class="comment">// namespace dtn</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:53 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>