<!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="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.6 --> <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> <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 <<a class="code" href="dtn-config_8h.html">dtn-config.h</a>></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 <oasys/util/OptParser.h></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#9d3b5e0755b03c9c4ad1730cb0654a4a">00030</a> <a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#9d3b5e0755b03c9c4ad1730cb0654a4a">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> ConnectionConvergenceLayer::ConnectionConvergenceLayer(<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&#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 &params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#79b0142dedcbe59f6e5a98aca31bab8f" 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>, &params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#c5ca778da8a9f0fda86d83057ccda6aa" 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>, &params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#2ad6f369e6bdf7e153ddebc606ecb4fd" 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>, &params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#d9a4cbe17b7dea4a086e688f35be83b8" 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 &params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#4cbb97db307b4014d0316ba799d61360" 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 &params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#afc9760cfe60df3967cf328878f32f33" 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 &params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#26202dc16d24aacee98b6ae6cf689cba" 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 &params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#93366f294f3d618da32a454057e46f44" 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 &params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#8064b479cfbd48ce1548fe41e1a6c6a6" 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-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#c5ca778da8a9f0fda86d83057ccda6aa" 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-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#2ad6f369e6bdf7e153ddebc606ecb4fd" 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>& 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->isdeleted()); <a name="l00101"></a>00101 <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link->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&#39;s CLInfo slot.">LinkParams</a>* params = <span class="keyword">dynamic_cast<</span><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&#39;s CLInfo slot.">LinkParams</a>*<span class="keyword">></span>(link->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->appendf(<span class="stringliteral">"reactive_frag_enabled: %u\n"</span>, params->reactive_frag_enabled_); <a name="l00107"></a>00107 buf->appendf(<span class="stringliteral">"sendbuf_len: %u\n"</span>, params->sendbuf_len_); <a name="l00108"></a>00108 buf->appendf(<span class="stringliteral">"recvbuf_len: %u\n"</span>, params->recvbuf_len_); <a name="l00109"></a>00109 buf->appendf(<span class="stringliteral">"data_timeout: %u\n"</span>, params->data_timeout_); <a name="l00110"></a>00110 buf->appendf(<span class="stringliteral">"test_read_delay: %u\n"</span>, params->test_read_delay_); <a name="l00111"></a>00111 buf->appendf(<span class="stringliteral">"test_write_delay: %u\n"</span>, params->test_write_delay_); <a name="l00112"></a>00112 buf->appendf(<span class="stringliteral">"test_recv_delay: %u\n"</span>,params->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>& 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->isdeleted()); <a name="l00122"></a>00122 <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link->cl_info() == NULL); <a name="l00123"></a>00123 <a name="l00124"></a>00124 log_debug(<span class="stringliteral">"adding %s link %s"</span>, link->type_str(), link->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&#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, &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&#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->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>& 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->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->name()); <a name="l00163"></a>00163 <a name="l00164"></a>00164 <span class="keywordflow">if</span> (link->isopen() || link->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->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->contact() == NULL); <a name="l00172"></a>00172 <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link->cl_info() != NULL); <a name="l00173"></a>00173 <a name="l00174"></a>00174 <span class="keyword">delete</span> link->cl_info(); <a name="l00175"></a>00175 link->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&#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>& link, <a name="l00181"></a>00181 <a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&#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>& 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->isdeleted()); <a name="l00195"></a>00195 <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link->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&#39;s CLInfo slot.">LinkParams</a>* params = <span class="keyword">dynamic_cast<</span><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&#39;s CLInfo slot.">LinkParams</a>*<span class="keyword">></span>(link->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, &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->isopen()) { <a name="l00207"></a>00207 <a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&#39;s CLInfo slot.">LinkParams</a>* params = <span class="keyword">dynamic_cast<</span><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&#39;s CLInfo slot.">LinkParams</a>*<span class="keyword">></span>(link->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<</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">></span>(link->contact()->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-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#c5ca778da8a9f0fda86d83057ccda6aa" title="Buffer size for sending data.">sendbuf_len_</a> != conn-><a class="code" href="classdtn_1_1CLConnection.html#95f89064268605c6183fa4c436a12071" title="Buffer for outgoing data.">sendbuf_</a>.size()) && <a name="l00214"></a>00214 (params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#c5ca778da8a9f0fda86d83057ccda6aa" title="Buffer size for sending data.">sendbuf_len_</a> >= conn-><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 -> %u"</span>, <a name="l00217"></a>00217 link.object(), conn-><a class="code" href="classdtn_1_1CLConnection.html#95f89064268605c6183fa4c436a12071" title="Buffer for outgoing data.">sendbuf_</a>.size(), <a name="l00218"></a>00218 params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#c5ca778da8a9f0fda86d83057ccda6aa" title="Buffer size for sending data.">sendbuf_len_</a>); <a name="l00219"></a>00219 conn-><a class="code" href="classdtn_1_1CLConnection.html#95f89064268605c6183fa4c436a12071" title="Buffer for outgoing data.">sendbuf_</a>.set_size(params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#c5ca778da8a9f0fda86d83057ccda6aa" 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-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#2ad6f369e6bdf7e153ddebc606ecb4fd" title="Buffer size for receiving data.">recvbuf_len_</a> != conn-><a class="code" href="classdtn_1_1CLConnection.html#483ff0dd2871a812491c16aa8d3f9124" title="Buffer for incoming data.">recvbuf_</a>.size()) && <a name="l00223"></a>00223 (params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#2ad6f369e6bdf7e153ddebc606ecb4fd" title="Buffer size for receiving data.">recvbuf_len_</a> >= conn-><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 -> %u"</span>, <a name="l00226"></a>00226 link.object(), conn-><a class="code" href="classdtn_1_1CLConnection.html#483ff0dd2871a812491c16aa8d3f9124" title="Buffer for incoming data.">recvbuf_</a>.size(), <a name="l00227"></a>00227 params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#2ad6f369e6bdf7e153ddebc606ecb4fd" title="Buffer size for receiving data.">recvbuf_len_</a>); <a name="l00228"></a>00228 conn-><a class="code" href="classdtn_1_1CLConnection.html#483ff0dd2871a812491c16aa8d3f9124" title="Buffer for incoming data.">recvbuf_</a>.set_size(params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#2ad6f369e6bdf7e153ddebc606ecb4fd" 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>& 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->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->isdeleted()); <a name="l00242"></a>00242 <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link->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&#39;s CLInfo slot.">LinkParams</a>* params = <span class="keyword">dynamic_cast<</span><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&#39;s CLInfo slot.">LinkParams</a>*<span class="keyword">></span>(link->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-><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->set_cl_info(conn); <a name="l00255"></a>00255 conn->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>& 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>& link = contact->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<</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">></span>(contact->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-><a class="code" href="classdtn_1_1CLConnection.html#a61b296b02812f04b3df0c8fb09919b8" title="Contact has been broken.">contact_broken_</a>) { <a name="l00275"></a>00275 conn-><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->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&#39;s CLInfo slot.">LinkParams</a>* params = <span class="keyword">dynamic_cast<</span><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html" title="Tunable parameter structure stored in each Link&#39;s CLInfo slot.">LinkParams</a>*<span class="keyword">></span>(link->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-><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-><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-><a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#7d08b207e28d4a152f2de57e339344e3">sent_data_</a>.num_contiguous(); <a name="l00293"></a>00293 u_int32_t acked_bytes = inflight-><a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#9ba02557f15de6cb0a940f52bb5047f3">ack_data_</a>.num_contiguous(); <a name="l00294"></a>00294 <a name="l00295"></a>00295 <span class="keywordflow">if</span> ((! params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#79b0142dedcbe59f6e5a98aca31bab8f" title="Is reactive fragmentation enabled.">reactive_frag_enabled_</a>) || <a name="l00296"></a>00296 (sent_bytes == 0) || <a name="l00297"></a>00297 (link->is_reliable() && 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->del_from_inflight(inflight-><a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#2eb68612bcb8804afc3b75e5dad25a0c">bundle_</a>, <a name="l00303"></a>00303 inflight-><a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#4cdc65aeca8877e05638afb1a83ebba5">total_length_</a>) || <a name="l00304"></a>00304 ! link->add_to_queue(inflight-><a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#2eb68612bcb8804afc3b75e5dad25a0c">bundle_</a>, <a name="l00305"></a>00305 inflight-><a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#4cdc65aeca8877e05638afb1a83ebba5">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-><a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#2eb68612bcb8804afc3b75e5dad25a0c">bundle_</a>->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-><a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#27409f5cfcc59c7a5f9d0c9e89bf09d0">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-><a class="code" href="classdtn_1_1CLConnection_1_1InFlightBundle.html#2eb68612bcb8804afc3b75e5dad25a0c">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-><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-><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-><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-><a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html#2b14e2468a7b5adec9d6ed1317a1fdc4">rcvd_data_</a>.empty()) <a name="l00333"></a>00333 { <a name="l00334"></a>00334 <span class="keywordtype">size_t</span> rcvd_len = incoming-><a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html#2b14e2468a7b5adec9d6ed1317a1fdc4">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>(&incoming-><a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html#b2fa6334c3db6832cbdfc0f506e9015a">bundle_</a>->recv_blocks()); <a name="l00338"></a>00338 <a name="l00339"></a>00339 <span class="keywordflow">if</span> ((incoming-><a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html#687a8d56d754f1d9bd01e3b395dfb837">total_length_</a> == 0) && <a name="l00340"></a>00340 params-><a class="code" href="classdtn_1_1ConnectionConvergenceLayer_1_1LinkParams.html#79b0142dedcbe59f6e5a98aca31bab8f" title="Is reactive fragmentation enabled.">reactive_frag_enabled_</a> && <a name="l00341"></a>00341 (rcvd_len > 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-><a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html#b2fa6334c3db6832cbdfc0f506e9015a">bundle_</a>->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-><a class="code" href="classdtn_1_1CLConnection_1_1IncomingBundle.html#b2fa6334c3db6832cbdfc0f506e9015a">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->link()->remote_eid(), <a name="l00352"></a>00352 contact->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-><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-><a class="code" href="classdtn_1_1CLConnection.html#d228b2004768c4ee6027823f270a816c" title="Bundles arriving on the wire.">incoming_</a>.back(); <a name="l00360"></a>00360 conn-><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-><a class="code" href="classdtn_1_1CLConnection.html#1701c536c9f5cd3d276c4b91a38ed2cf" title="Daemon/CLConnection command queue.">cmdqueue_</a>.try_pop(&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->set_cl_info(NULL); <a name="l00371"></a>00371 <a name="l00372"></a>00372 <span class="keywordflow">if</span> (link->isdeleted()) { <a name="l00373"></a>00373 <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link->cl_info() != NULL); <a name="l00374"></a>00374 <span class="keyword">delete</span> link->cl_info(); <a name="l00375"></a>00375 link->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>& 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>& 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->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->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>& contact = link->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<</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">></span>(contact->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-><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>& 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>& bundle) <a name="l00416"></a>00416 { <a name="l00417"></a>00417 <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(! link->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->is_queued_on(link->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->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->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>& contact = link->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<</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">></span>(contact->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->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-><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 Mon Jul 21 14:09:38 2008 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.6 </small></address> </body> </html>