Sophie

Sophie

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

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: TcaRouter.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>TcaRouter.cc</h1><a href="TcaRouter_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 2005-2006 University of Waterloo</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 "<a class="code" href="ConvergenceLayer_8h.html">conv_layers/ConvergenceLayer.h</a>"</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="BundleActions_8h.html">bundling/BundleActions.h</a>"</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="ContactManager_8h.html">contacts/ContactManager.h</a>"</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="BundleDaemon_8h.html">bundling/BundleDaemon.h</a>"</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="RouteTable_8h.html">routing/RouteTable.h</a>"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include  &lt;oasys/io/NetUtils.h&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="InterfaceTable_8h.html">contacts/InterfaceTable.h</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="TCPConvergenceLayer_8h.html">conv_layers/TCPConvergenceLayer.h</a>"</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="TcaRouter_8h.html">TcaRouter.h</a>"</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="keyword">namespace </span>dtn {
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="comment">// Consts</span>
<a name="l00037"></a>00037 
<a name="l00038"></a><a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">00038</a> <span class="keyword">static</span> <span class="keyword">const</span> std::string <a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a> = <span class="stringliteral">"tca://localhost/bundlelayer"</span>;
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 
<a name="l00042"></a>00042 <span class="comment">// Functions</span>
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 
<a name="l00045"></a>00045 <span class="comment">// get_payload_str is a convenient one-call function to get the payload</span>
<a name="l00046"></a>00046 <span class="comment">// of a simple bundle (must not contain any nulls)</span>
<a name="l00047"></a>00047 <span class="keyword">static</span> std::string
<a name="l00048"></a><a class="code" href="namespacedtn.html#a7adfaff68e09359c063ea32ec7db779">00048</a> <a class="code" href="namespacedtn.html#a7adfaff68e09359c063ea32ec7db779">get_payload_str</a>(<span class="keyword">const</span> <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b)
<a name="l00049"></a>00049 {
<a name="l00050"></a>00050     <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a> = b-&gt;<a class="code" href="classdtn_1_1Bundle.html#3bc0b88b547620b4029eba4809a73447" title="Accessors.">payload</a>().<a class="code" href="classdtn_1_1BundlePayload.html#56b3851ad789c4dbf019a32d557b7453" title="The payload length.">length</a>();
<a name="l00051"></a>00051     u_char data[len+1];
<a name="l00052"></a>00052     <span class="keyword">const</span> u_char* p = b-&gt;<a class="code" href="classdtn_1_1Bundle.html#3bc0b88b547620b4029eba4809a73447" title="Accessors.">payload</a>().<a class="code" href="classdtn_1_1BundlePayload.html#c4ce25f2d2d7ad54a9306ea2599731b4" title="Copy out a chunk of payload data into the supplied buffer.">read_data</a>(0, len, data);
<a name="l00053"></a>00053     <span class="keywordflow">return</span> (<span class="keyword">const</span> <span class="keywordtype">char</span>*)p;
<a name="l00054"></a>00054 }
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 <span class="comment">// debug: check for expected number of args in control bundle, w/ message</span>
<a name="l00058"></a>00058 <span class="keyword">static</span> <span class="keywordtype">bool</span>
<a name="l00059"></a><a class="code" href="namespacedtn.html#b1bf308761786d3b025044f2c4dd3af1">00059</a> <a class="code" href="namespacedtn.html#b1bf308761786d3b025044f2c4dd3af1">check_nargs</a>(<span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>&amp; cb, uint n_expected)
<a name="l00060"></a>00060 {
<a name="l00061"></a>00061     <span class="keywordflow">if</span> (cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>.size() != n_expected)
<a name="l00062"></a>00062     {
<a name="l00063"></a>00063         <a class="code" href="SDNV_8cc.html#3f24cadc9f28aba33472df0500092dcb">log_err_p</a>(<span class="stringliteral">"dtn/tca"</span>, <span class="stringliteral">"TcaRouter: bundle '%s' contains wrong number "</span>
<a name="l00064"></a>00064                   <span class="stringliteral">"of args. %d expected."</span>, cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#1b2e25e28170e7aea10c86c4319b2b9a">str</a>().c_str(), n_expected);
<a name="l00065"></a>00065         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00066"></a>00066     }
<a name="l00067"></a>00067     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00068"></a>00068 }
<a name="l00069"></a>00069 
<a name="l00070"></a>00070 
<a name="l00071"></a>00071 <span class="comment">// debug: log bundle wrapper (source -&gt; dest) and optionally payload too</span>
<a name="l00072"></a>00072 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00073"></a><a class="code" href="namespacedtn.html#d0d6e1a571d96d9390ba44f20e1b03b8">00073</a> <a class="code" href="namespacedtn.html#d0d6e1a571d96d9390ba44f20e1b03b8">log_bundle</a>(<span class="keyword">const</span> std::string&amp; comment, <span class="keyword">const</span> <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b, <span class="keywordtype">bool</span> include_payload)
<a name="l00074"></a>00074 {
<a name="l00075"></a>00075     (void)comment;
<a name="l00076"></a>00076     (void)b;
<a name="l00077"></a>00077     
<a name="l00078"></a>00078     <span class="keywordflow">if</span> (include_payload)
<a name="l00079"></a>00079         log_debug_p(<span class="stringliteral">"/dtn/tca"</span>, <span class="stringliteral">"%s [%s] -&gt; [%s] : '%s'"</span>, comment.c_str(),
<a name="l00080"></a>00080                     b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>().c_str(), b-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(),
<a name="l00081"></a>00081                     <a class="code" href="namespacedtn.html#a7adfaff68e09359c063ea32ec7db779">get_payload_str</a>(b).c_str());
<a name="l00082"></a>00082     <span class="keywordflow">else</span>
<a name="l00083"></a>00083         log_debug_p(<span class="stringliteral">"/dtn/tca"</span>, <span class="stringliteral">"%s [%s] -&gt; [%s]"</span>, comment.c_str(),
<a name="l00084"></a>00084                     b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>().c_str(), b-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00085"></a>00085 } 
<a name="l00086"></a>00086     
<a name="l00087"></a>00087 
<a name="l00088"></a>00088 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00089"></a><a class="code" href="namespacedtn.html#3ecf626fe4e85c7f73cde5385fa56144">00089</a> <a class="code" href="namespacedtn.html#3ecf626fe4e85c7f73cde5385fa56144">log_controlbundle</a>(<span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>&amp; cb)
<a name="l00090"></a>00090 {
<a name="l00091"></a>00091     log_debug_p(<span class="stringliteral">"/dtn/tca"</span>, <span class="stringliteral">"    code='%s', args=%d"</span>,
<a name="l00092"></a>00092                 cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#9680f349d5fc55be8b5aaa4aefae4ccd">code_</a>.c_str(), (u_int)cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>.size());
<a name="l00093"></a>00093     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>.size(); ++i)
<a name="l00094"></a>00094     {
<a name="l00095"></a>00095         log_debug_p(<span class="stringliteral">"/dtn/tca"</span>, <span class="stringliteral">"        '%s'"</span>, cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[i].c_str());
<a name="l00096"></a>00096     }
<a name="l00097"></a>00097 }
<a name="l00098"></a>00098 
<a name="l00099"></a>00099 
<a name="l00100"></a>00100 <span class="comment">/*</span>
<a name="l00101"></a>00101 <span class="comment">// get_tcp_interface gets the "tcp0" Interface object.</span>
<a name="l00102"></a>00102 <span class="comment">// No longer neeed.</span>
<a name="l00103"></a>00103 <span class="comment">static Interface* get_tcp_interface()</span>
<a name="l00104"></a>00104 <span class="comment">{</span>
<a name="l00105"></a>00105 <span class="comment">    InterfaceTable* p_iftab = InterfaceTable::instance();</span>
<a name="l00106"></a>00106 <span class="comment">    return p_iftab-&gt;find("tcp0");</span>
<a name="l00107"></a>00107 <span class="comment">}</span>
<a name="l00108"></a>00108 <span class="comment">*/</span>
<a name="l00109"></a>00109 
<a name="l00111"></a>00111 <span class="comment">// class TcaRouter</span>
<a name="l00112"></a>00112 
<a name="l00113"></a><a class="code" href="classdtn_1_1TcaRouter.html#05195a84a9e4d7bb169e449d2dd2edba">00113</a> <a class="code" href="classdtn_1_1TcaRouter.html#05195a84a9e4d7bb169e449d2dd2edba">TcaRouter::TcaRouter</a>(<a class="code" href="classdtn_1_1TcaRouter.html#7937c9ef257ad4c0d45e44947ed48b24">Role</a> <a class="code" href="tca__admin_8cc.html#61a55e29b77f88331554bca442ce7cd8">role</a>)
<a name="l00114"></a>00114     : <a class="code" href="classdtn_1_1TableBasedRouter.html" title="This is an abstract class that is intended to be used for all routing algorithms...">TableBasedRouter</a>(<span class="stringliteral">"TcaRouter"</span>, <span class="stringliteral">"TcaRouter"</span>)
<a name="l00115"></a>00115 {
<a name="l00116"></a>00116     <a class="code" href="classdtn_1_1TcaRouter.html#95d98e32fedc60c6e192fdf083c21341">role_</a> = role;
<a name="l00117"></a>00117 
<a name="l00118"></a>00118     <span class="comment">// Construct the eid of the local admin app.</span>
<a name="l00119"></a>00119     <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a> = BundleDaemon::instance()-&gt;local_eid();
<a name="l00120"></a>00120     <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>.<a class="code" href="classdtn_1_1TcaEndpointID.html#b5fb4117a3c52a00d0e09e48b5dd8424">set_app</a>(<span class="stringliteral">"admin"</span>);
<a name="l00121"></a>00121 
<a name="l00122"></a>00122     logpathf(<span class="stringliteral">"/dtn/tca"</span>);
<a name="l00123"></a>00123 
<a name="l00124"></a>00124     log_info(<span class="stringliteral">"TcaRouter started: role='%s', admin_app='%s'"</span>,
<a name="l00125"></a>00125              <a class="code" href="classdtn_1_1TcaRouter.html#3a1969acd0d8c88b00a3e83907b1846e">get_role_str</a>().c_str(), <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00126"></a>00126 }
<a name="l00127"></a>00127 
<a name="l00128"></a>00128 
<a name="l00129"></a>00129 std::string
<a name="l00130"></a><a class="code" href="classdtn_1_1TcaRouter.html#3a1969acd0d8c88b00a3e83907b1846e">00130</a> <a class="code" href="classdtn_1_1TcaRouter.html#3a1969acd0d8c88b00a3e83907b1846e">TcaRouter::get_role_str</a>()<span class="keyword"> const</span>
<a name="l00131"></a>00131 <span class="keyword"></span>{
<a name="l00132"></a>00132     <span class="keywordflow">switch</span> (<a class="code" href="classdtn_1_1TcaRouter.html#95d98e32fedc60c6e192fdf083c21341">role_</a>)
<a name="l00133"></a>00133     {
<a name="l00134"></a>00134         <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1TcaRouter.html#7937c9ef257ad4c0d45e44947ed48b241af3143a7a9f53ce46551848a9d23e1a">TCA_MOBILE</a>: <span class="keywordflow">return</span> <span class="stringliteral">"mobile"</span>;
<a name="l00135"></a>00135         <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1TcaRouter.html#7937c9ef257ad4c0d45e44947ed48b24b40fd54ee6b0189d5984e209b4082dc1">TCA_ROUTER</a>: <span class="keywordflow">return</span> <span class="stringliteral">"router"</span>;
<a name="l00136"></a>00136         <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1TcaRouter.html#7937c9ef257ad4c0d45e44947ed48b24aa6e45693173fd8231cbdcd4a6d3c6b9">TCA_GATEWAY</a>: <span class="keywordflow">return</span> <span class="stringliteral">"gateway"</span>;
<a name="l00137"></a>00137         <span class="keywordflow">default</span>: <span class="keywordflow">return</span> <span class="stringliteral">"null"</span>;
<a name="l00138"></a>00138     }
<a name="l00139"></a>00139 
<a name="l00140"></a>00140 }
<a name="l00141"></a>00141 
<a name="l00142"></a>00142 
<a name="l00143"></a>00143 <span class="keywordtype">void</span>
<a name="l00144"></a><a class="code" href="classdtn_1_1TcaRouter.html#20fc6b94067656bf6d3d32cba7d836c8">00144</a> <a class="code" href="classdtn_1_1TcaRouter.html#20fc6b94067656bf6d3d32cba7d836c8" title="Event handlers.">TcaRouter::handle_bundle_received</a>(<a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a>* event)
<a name="l00145"></a>00145 {           
<a name="l00146"></a>00146     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle = <span class="keyword">event</span>-&gt;bundleref_.object();
<a name="l00147"></a>00147     <span class="comment">// log_debug("TcaRouter: handle bundle received: *%p", bundle);</span>
<a name="l00148"></a>00148 
<a name="l00149"></a>00149     <span class="comment">// Special handling for certain TCA bundles</span>
<a name="l00150"></a>00150     <span class="comment">// Control bundles are identified by their dest eids.</span>
<a name="l00151"></a>00151     <span class="comment">// Unbound data bundles need special handling as</span>
<a name="l00152"></a>00152     <span class="comment">// TCA control bundles are the following:</span>
<a name="l00153"></a>00153     <span class="comment">// Check for control bundles here (REG, COA, ASK, ADV)</span>
<a name="l00154"></a>00154 
<a name="l00155"></a>00155     <span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a>&amp; dest = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>();
<a name="l00156"></a>00156 
<a name="l00157"></a>00157     <span class="keywordflow">if</span> (dest.<a class="code" href="classdtn_1_1EndpointID.html#2ff5cd5d95e97cac315a192676c6a057">scheme_str</a>() == <span class="stringliteral">"tca"</span>)
<a name="l00158"></a>00158     {
<a name="l00159"></a>00159         <a class="code" href="namespacedtn.html#d0d6e1a571d96d9390ba44f20e1b03b8">log_bundle</a>(<span class="stringliteral">"TcaRouter: tca bundle received"</span>, bundle, <span class="keyword">true</span>);
<a name="l00160"></a>00160 
<a name="l00161"></a>00161         <a class="code" href="classdtn_1_1TcaEndpointID.html">TcaEndpointID</a> tca_dest(dest);
<a name="l00162"></a>00162   
<a name="l00163"></a>00163         <span class="keywordflow">if</span> (tca_dest.<a class="code" href="classdtn_1_1EndpointID.html#b6aa3012f45fa87006d24413f8c1bb65">ssp</a>() == <span class="stringliteral">"//registry"</span>)
<a name="l00164"></a>00164         {
<a name="l00165"></a>00165             <a class="code" href="classdtn_1_1TcaRouter.html#a7c14a283ad6f6241529dbcbc02255cd">handle_register</a>(bundle);
<a name="l00166"></a>00166         }
<a name="l00167"></a>00167 
<a name="l00168"></a>00168         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (tca_dest.<a class="code" href="classdtn_1_1TcaEndpointID.html#239acd18c5985031ccde27d7b992a5bc">app</a>() == <span class="stringliteral">"admin.coa"</span>)
<a name="l00169"></a>00169         {
<a name="l00170"></a>00170             <a class="code" href="classdtn_1_1TcaRouter.html#d97182b3e5c3f04a0f630653d77def65">handle_coa</a>(bundle);
<a name="l00171"></a>00171         }
<a name="l00172"></a>00172 
<a name="l00173"></a>00173         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (tca_dest.<a class="code" href="classdtn_1_1EndpointID.html#b6aa3012f45fa87006d24413f8c1bb65">ssp</a>().substr(0,11) == <span class="stringliteral">"//anonymous"</span>)
<a name="l00174"></a>00174         {
<a name="l00175"></a>00175             <a class="code" href="classdtn_1_1TcaRouter.html#baee51212bd5482452dc79c9d73d6004">handle_anonymous_bundle</a>(bundle);
<a name="l00176"></a>00176         }
<a name="l00177"></a>00177 
<a name="l00178"></a>00178         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (tca_dest.<a class="code" href="classdtn_1_1EndpointID.html#b6aa3012f45fa87006d24413f8c1bb65">ssp</a>() == <span class="stringliteral">"//localhost/bundlelayer"</span>)
<a name="l00179"></a>00179         {
<a name="l00180"></a>00180             <a class="code" href="classdtn_1_1TcaRouter.html#f4894d57a18a6ee67d602b8fdb047286">handle_bl_control_bundle</a>(bundle);
<a name="l00181"></a>00181         }
<a name="l00182"></a>00182             
<a name="l00183"></a>00183         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (tca_dest.<a class="code" href="classdtn_1_1TcaEndpointID.html#4ae4e32d1fdd24a0f991fa7ee36e69b6">host</a>() != <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>.<a class="code" href="classdtn_1_1TcaEndpointID.html#4ae4e32d1fdd24a0f991fa7ee36e69b6">host</a>())
<a name="l00184"></a>00184         {
<a name="l00185"></a>00185             <span class="comment">// What we're really checking for is whether the bundle is home.</span>
<a name="l00186"></a>00186             <span class="comment">// ie. addressed to some app on the local host.</span>
<a name="l00187"></a>00187             <span class="comment">// If not, then it's a late-bound data bundle:</span>
<a name="l00188"></a>00188             <a class="code" href="classdtn_1_1TcaRouter.html#e72174b3667dd66ecc6201c2f6cfba24">handle_tca_unbound_bundle</a>(bundle);
<a name="l00189"></a>00189         }
<a name="l00190"></a>00190     }
<a name="l00191"></a>00191     
<a name="l00192"></a>00192     <span class="keywordflow">else</span>
<a name="l00193"></a>00193     {
<a name="l00194"></a>00194         <span class="comment">// Not a tca control or data bundle. Just forward the bundle.</span>
<a name="l00195"></a>00195         <a class="code" href="classdtn_1_1TcaRouter.html#4080d20ce9043bc8f1d21be0c619b99d">fwd_to_matching</a>(bundle);
<a name="l00196"></a>00196     }
<a name="l00197"></a>00197 }
<a name="l00198"></a>00198 
<a name="l00199"></a>00199 
<a name="l00200"></a>00200 <span class="keywordtype">void</span>
<a name="l00201"></a><a class="code" href="classdtn_1_1TcaRouter.html#5ac83a679cce9bf7b5025e46a3c88d65">00201</a> <a class="code" href="classdtn_1_1TcaRouter.html#5ac83a679cce9bf7b5025e46a3c88d65" title="Event handlers.">TcaRouter::handle_bundle_transmitted</a>(<a class="code" href="classdtn_1_1BundleTransmittedEvent.html" title="Event class for bundle or fragment transmission.">BundleTransmittedEvent</a>* event)
<a name="l00202"></a>00202 {
<a name="l00203"></a>00203     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b = <span class="keyword">event</span>-&gt;bundleref_.object();
<a name="l00204"></a>00204     log_debug(<span class="stringliteral">"TcaRouter: handle bundle transmitted: *%p"</span>, b);
<a name="l00205"></a>00205 
<a name="l00206"></a>00206     <span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a>&amp; dest = b-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>();
<a name="l00207"></a>00207 
<a name="l00208"></a>00208     <span class="keywordflow">if</span> (dest.<a class="code" href="classdtn_1_1EndpointID.html#2ff5cd5d95e97cac315a192676c6a057">scheme_str</a>() == <span class="stringliteral">"tca"</span>)
<a name="l00209"></a>00209     {
<a name="l00210"></a>00210         <span class="comment">// TODO: These control codes appended to app (eg. admin.coa) were</span>
<a name="l00211"></a>00211         <span class="comment">// a bad idea and should be eliminated. I did this initially so that</span>
<a name="l00212"></a>00212         <span class="comment">// we could switch on control code without inspecting bundle payload.</span>
<a name="l00213"></a>00213         <span class="comment">// However, if the bundle is addressed to an admin app, then it's</span>
<a name="l00214"></a>00214         <span class="comment">// fair to assume it is a control bundle and inspect the payload.</span>
<a name="l00215"></a>00215         <span class="comment">// The "adv" case below uses the preferred method. ask and coa should</span>
<a name="l00216"></a>00216         <span class="comment">// follow suit.</span>
<a name="l00217"></a>00217         <a class="code" href="classdtn_1_1TcaEndpointID.html">TcaEndpointID</a> tca_dest(dest);
<a name="l00218"></a>00218         <span class="keywordflow">if</span> (tca_dest.<a class="code" href="classdtn_1_1TcaEndpointID.html#239acd18c5985031ccde27d7b992a5bc">app</a>() == <span class="stringliteral">"admin.coa"</span>)
<a name="l00219"></a>00219         {
<a name="l00220"></a>00220             <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a> cb(<a class="code" href="namespacedtn.html#a7adfaff68e09359c063ea32ec7db779">get_payload_str</a>(b));
<a name="l00221"></a>00221             <a class="code" href="classdtn_1_1TcaRouter.html#fab3841fcc54865c4cfd34b83c45662d">on_coa_transmitted</a>(b, cb);
<a name="l00222"></a>00222         }
<a name="l00223"></a>00223         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (tca_dest.<a class="code" href="classdtn_1_1TcaEndpointID.html#239acd18c5985031ccde27d7b992a5bc">app</a>() == <span class="stringliteral">"admin.ask"</span>)
<a name="l00224"></a>00224         {
<a name="l00225"></a>00225             <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a> cb(<a class="code" href="namespacedtn.html#a7adfaff68e09359c063ea32ec7db779">get_payload_str</a>(b));
<a name="l00226"></a>00226             <a class="code" href="classdtn_1_1TcaRouter.html#9af48c77978fae70fc76c23e4d34992f">on_ask_transmitted</a>(b, cb);
<a name="l00227"></a>00227         }
<a name="l00228"></a>00228         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (tca_dest.<a class="code" href="classdtn_1_1TcaEndpointID.html#239acd18c5985031ccde27d7b992a5bc">app</a>() == <span class="stringliteral">"admin"</span>)
<a name="l00229"></a>00229         {
<a name="l00230"></a>00230             <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a> cb(<a class="code" href="namespacedtn.html#a7adfaff68e09359c063ea32ec7db779">get_payload_str</a>(b));
<a name="l00231"></a>00231             <span class="keywordflow">if</span> (cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#9680f349d5fc55be8b5aaa4aefae4ccd">code_</a> == <span class="stringliteral">"adv"</span>)
<a name="l00232"></a>00232             {
<a name="l00233"></a>00233                 <a class="code" href="classdtn_1_1TcaRouter.html#b6813fbb3c85d4999435f5ac06009d2e">on_adv_transmitted</a>(b, cb);
<a name="l00234"></a>00234             }
<a name="l00235"></a>00235         }
<a name="l00236"></a>00236     }
<a name="l00237"></a>00237 }   
<a name="l00238"></a>00238  
<a name="l00239"></a>00239 
<a name="l00240"></a>00240 <span class="comment">// Note: ContactUp and ContactDown are generated by a sending node when a</span>
<a name="l00241"></a>00241 <span class="comment">// connection is opened.  As such, they're probably not relevant to TCA.</span>
<a name="l00242"></a>00242 
<a name="l00243"></a>00243 <span class="keywordtype">void</span>
<a name="l00244"></a><a class="code" href="classdtn_1_1TcaRouter.html#9cac11025de364655eb960b8b549a92c">00244</a> <a class="code" href="classdtn_1_1TcaRouter.html#9cac11025de364655eb960b8b549a92c" title="Event handlers.">TcaRouter::handle_contact_up</a>(<a class="code" href="classdtn_1_1ContactUpEvent.html" title="Event class for contact up events.">ContactUpEvent</a>* event)
<a name="l00245"></a>00245 {
<a name="l00246"></a>00246     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(event-&gt;<a class="code" href="classdtn_1_1ContactUpEvent.html#10e9dd243dd15f8e5974a02df3ab8e6e" title="The contact that is up.">contact_</a>-&gt;link() != NULL);
<a name="l00247"></a>00247     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!event-&gt;<a class="code" href="classdtn_1_1ContactUpEvent.html#10e9dd243dd15f8e5974a02df3ab8e6e" title="The contact that is up.">contact_</a>-&gt;link()-&gt;isdeleted());
<a name="l00248"></a>00248 
<a name="l00249"></a>00249     <span class="comment">// Note: *must* call the base class handler so that existing bundles</span>
<a name="l00250"></a>00250     <span class="comment">// can be checked against the new contact.</span>
<a name="l00251"></a>00251     <a class="code" href="classdtn_1_1TcaRouter.html#9cac11025de364655eb960b8b549a92c" title="Event handlers.">TableBasedRouter::handle_contact_up</a>(event);
<a name="l00252"></a>00252     log_debug(<span class="stringliteral">"TcaRouter::contact up"</span>);
<a name="l00253"></a>00253     <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>, <span class="stringliteral">"contact_up"</span>);
<a name="l00254"></a>00254 }
<a name="l00255"></a>00255     
<a name="l00256"></a>00256 
<a name="l00257"></a>00257 <span class="keywordtype">void</span>
<a name="l00258"></a><a class="code" href="classdtn_1_1TcaRouter.html#87986c1aa06a4894ecf4b14f932a8442">00258</a> <a class="code" href="classdtn_1_1TcaRouter.html#87986c1aa06a4894ecf4b14f932a8442" title="Event handlers.">TcaRouter::handle_contact_down</a>(<a class="code" href="classdtn_1_1ContactDownEvent.html" title="Event class for contact down events.">ContactDownEvent</a>* event)
<a name="l00259"></a>00259 {
<a name="l00260"></a>00260     (void)event;
<a name="l00261"></a>00261     log_debug(<span class="stringliteral">"TcaRouter::contact down"</span>);
<a name="l00262"></a>00262     <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>, <span class="stringliteral">"contact_down"</span>);
<a name="l00263"></a>00263 
<a name="l00264"></a>00264 }
<a name="l00265"></a>00265 
<a name="l00266"></a>00266 
<a name="l00267"></a>00267 <span class="keywordtype">void</span>
<a name="l00268"></a><a class="code" href="classdtn_1_1TcaRouter.html#b02a4586e8162b8aec0a550113d6c6ee">00268</a> <a class="code" href="classdtn_1_1TcaRouter.html#b02a4586e8162b8aec0a550113d6c6ee" title="Event handlers.">TcaRouter::handle_link_available</a>(<a class="code" href="classdtn_1_1LinkAvailableEvent.html" title="Event class for link available events.">LinkAvailableEvent</a>* event)
<a name="l00269"></a>00269 {
<a name="l00270"></a>00270     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(event-&gt;<a class="code" href="classdtn_1_1LinkAvailableEvent.html#1c03fd085ae843493cc1318828e4e4c9" title="The link that is available.">link_</a> != NULL);
<a name="l00271"></a>00271     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!event-&gt;<a class="code" href="classdtn_1_1LinkAvailableEvent.html#1c03fd085ae843493cc1318828e4e4c9" title="The link that is available.">link_</a>-&gt;isdeleted());
<a name="l00272"></a>00272 
<a name="l00273"></a>00273     <span class="comment">// Note: *must* call the base class handler so that existing bundles</span>
<a name="l00274"></a>00274     <span class="comment">// can be checked against the new link.</span>
<a name="l00275"></a>00275     <a class="code" href="classdtn_1_1TcaRouter.html#b02a4586e8162b8aec0a550113d6c6ee" title="Event handlers.">TableBasedRouter::handle_link_available</a>(event);
<a name="l00276"></a>00276     log_debug(<span class="stringliteral">"TcaRouter::link available"</span>);
<a name="l00277"></a>00277     <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>, <span class="stringliteral">"link_available"</span>);
<a name="l00278"></a>00278 }
<a name="l00279"></a>00279 
<a name="l00280"></a>00280 
<a name="l00281"></a>00281 <span class="keywordtype">void</span>
<a name="l00282"></a><a class="code" href="classdtn_1_1TcaRouter.html#562dd2754090394f77e36afdf499277f">00282</a> <a class="code" href="classdtn_1_1TcaRouter.html#562dd2754090394f77e36afdf499277f" title="Default event handler when a link is unavailable.">TcaRouter::handle_link_unavailable</a>(<a class="code" href="classdtn_1_1LinkUnavailableEvent.html" title="Event class for link unavailable events.">LinkUnavailableEvent</a>* event)
<a name="l00283"></a>00283 {
<a name="l00284"></a>00284     (void)event;
<a name="l00285"></a>00285     log_debug(<span class="stringliteral">"TcaRouter::link unavailable"</span>);
<a name="l00286"></a>00286     <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>, <span class="stringliteral">"link_unavailable"</span>);
<a name="l00287"></a>00287 }
<a name="l00288"></a>00288 
<a name="l00289"></a>00289 
<a name="l00290"></a>00290 <span class="keywordtype">void</span>
<a name="l00291"></a><a class="code" href="classdtn_1_1TcaRouter.html#c95d8b17913afe853007097bc00b89cd">00291</a> <a class="code" href="classdtn_1_1TcaRouter.html#c95d8b17913afe853007097bc00b89cd" title="Default event handler for shutdown requests.">TcaRouter::handle_shutdown_request</a>(<a class="code" href="classdtn_1_1ShutdownRequest.html" title="Event class for shutting down a daemon.">ShutdownRequest</a>* event)
<a name="l00292"></a>00292 {
<a name="l00293"></a>00293     (void)event;
<a name="l00294"></a>00294     log_debug(<span class="stringliteral">"TcaRouter::daemon shutdown"</span>);
<a name="l00295"></a>00295     <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>, <span class="stringliteral">"daemon_shutdown"</span>);
<a name="l00296"></a>00296 }
<a name="l00297"></a>00297         
<a name="l00298"></a>00298 
<a name="l00299"></a>00299 <span class="comment">// fwd_to_all "broadcasts" a bundle to all tca routes (ie. "tca://*")</span>
<a name="l00300"></a>00300 <span class="comment">// This is dead code at the moment.</span>
<a name="l00301"></a>00301 
<a name="l00302"></a>00302 <span class="keywordtype">int</span>
<a name="l00303"></a><a class="code" href="classdtn_1_1TcaRouter.html#df87be853cdf09fd7d86ae7c5f8ebde9">00303</a> <a class="code" href="classdtn_1_1TcaRouter.html#df87be853cdf09fd7d86ae7c5f8ebde9">TcaRouter::fwd_to_all</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle)
<a name="l00304"></a>00304 {
<a name="l00305"></a>00305     <a class="code" href="classdtn_1_1RouteEntryVec.html" title="Class for a vector of route entries.">RouteEntryVec</a> matches;
<a name="l00306"></a>00306     RouteEntryVec::iterator iter;
<a name="l00307"></a>00307 
<a name="l00308"></a>00308     std::string <a class="code" href="dtnperf-client_8c.html#71808395b2460b32d8b1048e44faef6e">pattern</a> = <span class="stringliteral">"tca://*"</span>;
<a name="l00309"></a>00309     <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a> tca_all = pattern;
<a name="l00310"></a>00310 
<a name="l00311"></a>00311     <a class="code" href="classdtn_1_1TableBasedRouter.html#83939b60c495ff450a1e95787c811297" title="The routing table.">route_table_</a>-&gt;<a class="code" href="classdtn_1_1RouteTable.html#dceb882f843c17db3afd73521bc78c6d" title="Fill in the entry_vec with the list of all entries whose patterns match the given...">get_matching</a>(tca_all, &amp;matches);
<a name="l00312"></a>00312 
<a name="l00313"></a>00313     <span class="keywordtype">int</span> <a class="code" href="dtnping_8c.html#d43c3812e6d13e0518d9f8b8f463ffcf">count</a> = 0;
<a name="l00314"></a>00314     <span class="keywordflow">for</span> (iter = matches.begin(); iter != matches.end(); ++iter)
<a name="l00315"></a>00315     {
<a name="l00316"></a>00316         log_debug(<span class="stringliteral">"TcaRouter::fwd_to_all: %s"</span>,
<a name="l00317"></a>00317                   (*iter)-&gt;dest_pattern().str().c_str());
<a name="l00318"></a>00318         <a class="code" href="classdtn_1_1TableBasedRouter.html#4bac86cb57a6b1b7350f8471d890bb2f" title="Try to forward a bundle to a next hop route.">fwd_to_nexthop</a>(bundle, *iter);
<a name="l00319"></a>00319         ++count;
<a name="l00320"></a>00320     }
<a name="l00321"></a>00321 
<a name="l00322"></a>00322     log_debug(<span class="stringliteral">"TcaRouter::fwd_to_all dest='%s': %d matches"</span>,
<a name="l00323"></a>00323               bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(), count);
<a name="l00324"></a>00324     <span class="keywordflow">return</span> count;
<a name="l00325"></a>00325 }
<a name="l00326"></a>00326 
<a name="l00327"></a>00327 
<a name="l00328"></a>00328 <span class="comment">// fwd_to_matching function overridden from TableBasedRouter</span>
<a name="l00329"></a>00329 <span class="comment">// This is necessary to filter outgoing bundles. fwd_to_matching is</span>
<a name="l00330"></a>00330 <span class="comment">// called via TableBasedRouter::check_next_hop on a variety of events</span>
<a name="l00331"></a>00331 <span class="comment">// including link_available and on contact_up.</span>
<a name="l00332"></a>00332 
<a name="l00333"></a>00333 <span class="keywordtype">int</span>
<a name="l00334"></a><a class="code" href="classdtn_1_1TcaRouter.html#4080d20ce9043bc8f1d21be0c619b99d">00334</a> <a class="code" href="classdtn_1_1TcaRouter.html#4080d20ce9043bc8f1d21be0c619b99d">TcaRouter::fwd_to_matching</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; next_hop)
<a name="l00335"></a>00335 {
<a name="l00336"></a>00336     <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf82">ForwardingRule</a> fwd_rule = <a class="code" href="classdtn_1_1TcaRouter.html#a6617e273b45487a85ec11cbdb997ac0">get_forwarding_rule</a>(bundle);
<a name="l00337"></a>00337     <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#4dcc5aebccb8bc0693bcea7d78acc266">fwd_to_matching_r</a>(bundle, next_hop, fwd_rule);
<a name="l00338"></a>00338 }
<a name="l00339"></a>00339 
<a name="l00340"></a>00340 
<a name="l00341"></a>00341 <span class="comment">// Specialized fwd_to_matching function with selective default-route handling</span>
<a name="l00342"></a>00342 <span class="comment">// You can foward to the default route either never, always, or "if necessary"</span>
<a name="l00343"></a>00343 <span class="comment">// where "if necessary" means iff there are no non-default routes.</span>
<a name="l00344"></a>00344 
<a name="l00345"></a>00345 <span class="keywordtype">int</span>
<a name="l00346"></a><a class="code" href="classdtn_1_1TcaRouter.html#4dcc5aebccb8bc0693bcea7d78acc266">00346</a> <a class="code" href="classdtn_1_1TcaRouter.html#4dcc5aebccb8bc0693bcea7d78acc266">TcaRouter::fwd_to_matching_r</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; next_hop,
<a name="l00347"></a>00347                              <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf82">ForwardingRule</a> fwd_rule)
<a name="l00348"></a>00348 {
<a name="l00349"></a>00349     log_debug(<span class="stringliteral">"TcaRouter::fwd_to_matching_r: owner='%s'"</span>,
<a name="l00350"></a>00350               bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#ec416f48762e31b4ea30393f6177242e" title="Accessors.">owner</a>().c_str());
<a name="l00351"></a>00351     log_debug(<span class="stringliteral">"TcaRouter::fwd_to_matching_r: fwd_rule=%d"</span>, fwd_rule);
<a name="l00352"></a>00352 
<a name="l00353"></a>00353     <span class="keywordflow">if</span> (fwd_rule == <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf82a7ff8cbd1e8adcc7d83834c9b22c5ce9">FWD_NEVER</a>) <span class="keywordflow">return</span> 0;    <span class="comment">// no matches</span>
<a name="l00354"></a>00354 
<a name="l00355"></a>00355     <a class="code" href="classdtn_1_1RouteEntryVec.html" title="Class for a vector of route entries.">RouteEntryVec</a> matches;
<a name="l00356"></a>00356     RouteEntryVec::iterator iter;
<a name="l00357"></a>00357 
<a name="l00358"></a>00358     <a class="code" href="classdtn_1_1TableBasedRouter.html#83939b60c495ff450a1e95787c811297" title="The routing table.">route_table_</a>-&gt;<a class="code" href="classdtn_1_1RouteTable.html#dceb882f843c17db3afd73521bc78c6d" title="Fill in the entry_vec with the list of all entries whose patterns match the given...">get_matching</a>(bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>(), &amp;matches);
<a name="l00359"></a>00359 
<a name="l00360"></a>00360     <span class="comment">// First step - split out the default route</span>
<a name="l00361"></a>00361     <a class="code" href="classdtn_1_1RouteEntry.html" title="Class to represent route table entry.">RouteEntry</a>*     default_route = NULL;   
<a name="l00362"></a>00362     <a class="code" href="classdtn_1_1RouteEntryVec.html" title="Class for a vector of route entries.">RouteEntryVec</a>   hard_matches;       <span class="comment">// non-default matches</span>
<a name="l00363"></a>00363     <span class="keywordflow">for</span> (iter = matches.begin(); iter != matches.end(); ++iter)
<a name="l00364"></a>00364     {
<a name="l00365"></a>00365         <span class="keywordflow">if</span> ((*iter)-&gt;dest_pattern().str() == <span class="stringliteral">"tca://*"</span>)
<a name="l00366"></a>00366         {
<a name="l00367"></a>00367             default_route = *iter;
<a name="l00368"></a>00368         }
<a name="l00369"></a>00369         <span class="keywordflow">else</span>
<a name="l00370"></a>00370         {
<a name="l00371"></a>00371             hard_matches.push_back(*iter);
<a name="l00372"></a>00372         }
<a name="l00373"></a>00373     }
<a name="l00374"></a>00374 
<a name="l00375"></a>00375     <span class="keywordflow">if</span> (fwd_rule == <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf8245a9e3815c6eaa77c5ce35ae1b1cede1">FWD_UDR_EXCLUSIVELY</a>)
<a name="l00376"></a>00376     {
<a name="l00377"></a>00377         <span class="keywordflow">if</span> (default_route != NULL)
<a name="l00378"></a>00378         {
<a name="l00379"></a>00379             <a class="code" href="classdtn_1_1TableBasedRouter.html#4bac86cb57a6b1b7350f8471d890bb2f" title="Try to forward a bundle to a next hop route.">fwd_to_nexthop</a>(bundle, default_route);
<a name="l00380"></a>00380             <span class="keywordflow">return</span> 1;   <span class="comment">// 1 match</span>
<a name="l00381"></a>00381         }
<a name="l00382"></a>00382     }
<a name="l00383"></a>00383 
<a name="l00384"></a>00384     <span class="keywordtype">int</span> <a class="code" href="dtnping_8c.html#d43c3812e6d13e0518d9f8b8f463ffcf">count</a> = 0;
<a name="l00385"></a>00385 
<a name="l00386"></a>00386     <span class="comment">// handle default route...</span>
<a name="l00387"></a>00387     <span class="keywordflow">if</span> (fwd_rule == <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf8299689a5b013eef9e17cdc411004797d3">FWD_UDR_ALWAYS</a> || 
<a name="l00388"></a>00388             (fwd_rule == <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf829083ad4aa536bc2c6d7f0a5be4fd3604">FWD_UDR_IFNECESSARY</a> &amp;&amp; hard_matches.size() == 0))
<a name="l00389"></a>00389     {
<a name="l00390"></a>00390         <span class="keywordflow">if</span> (default_route != NULL)
<a name="l00391"></a>00391         {
<a name="l00392"></a>00392             <a class="code" href="classdtn_1_1TableBasedRouter.html#4bac86cb57a6b1b7350f8471d890bb2f" title="Try to forward a bundle to a next hop route.">fwd_to_nexthop</a>(bundle, default_route);
<a name="l00393"></a>00393             ++ count;
<a name="l00394"></a>00394         }
<a name="l00395"></a>00395     }
<a name="l00396"></a>00396 
<a name="l00397"></a>00397     <span class="comment">// handle hard matches...</span>
<a name="l00398"></a>00398     <span class="keywordflow">for</span> (iter = hard_matches.begin(); iter != hard_matches.end(); ++iter)
<a name="l00399"></a>00399     {
<a name="l00400"></a>00400         <span class="keywordflow">if</span> (next_hop == NULL || (next_hop == (*iter)-&gt;link()))
<a name="l00401"></a>00401         {
<a name="l00402"></a>00402             <a class="code" href="classdtn_1_1TableBasedRouter.html#4bac86cb57a6b1b7350f8471d890bb2f" title="Try to forward a bundle to a next hop route.">fwd_to_nexthop</a>(bundle, *iter);
<a name="l00403"></a>00403             ++count;
<a name="l00404"></a>00404         }
<a name="l00405"></a>00405         <span class="keywordflow">else</span>
<a name="l00406"></a>00406         {
<a name="l00407"></a>00407             log_debug(<span class="stringliteral">"fwd_to_matching_r dest='%s': "</span>
<a name="l00408"></a>00408                       <span class="stringliteral">"ignoring match %s since next_hop link %s set"</span>,
<a name="l00409"></a>00409                       bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(), (*iter)-&gt;link()-&gt;name(),
<a name="l00410"></a>00410                       next_hop-&gt;name());
<a name="l00411"></a>00411         }
<a name="l00412"></a>00412     }
<a name="l00413"></a>00413 
<a name="l00414"></a>00414     log_debug(<span class="stringliteral">"fwd_to_matching_r dest='%s': %d matches"</span>,
<a name="l00415"></a>00415               bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(), count);
<a name="l00416"></a>00416 
<a name="l00417"></a>00417     <span class="keywordflow">return</span> count;
<a name="l00418"></a>00418 }
<a name="l00419"></a>00419 
<a name="l00420"></a>00420 
<a name="l00421"></a>00421 <span class="keywordtype">bool</span>
<a name="l00422"></a><a class="code" href="classdtn_1_1TcaRouter.html#fab3841fcc54865c4cfd34b83c45662d">00422</a> <a class="code" href="classdtn_1_1TcaRouter.html#fab3841fcc54865c4cfd34b83c45662d">TcaRouter::on_coa_transmitted</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>&amp; cb)
<a name="l00423"></a>00423 {   
<a name="l00424"></a>00424     log_debug(<span class="stringliteral">"TcaRouter: COA bundle transmitted"</span>);
<a name="l00425"></a>00425             
<a name="l00426"></a>00426     <a class="code" href="classdtn_1_1TcaWrappedBundle.html">TcaWrappedBundle</a> wb(cb);
<a name="l00427"></a>00427     
<a name="l00428"></a>00428     log_debug(<span class="stringliteral">"    coa: source=%s, dest=%s"</span>,
<a name="l00429"></a>00429                 b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(),
<a name="l00430"></a>00430                 b-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00431"></a>00431     
<a name="l00432"></a>00432     <span class="comment">// todo: use a WrappedBundle here</span>
<a name="l00433"></a>00433     std::string coa_sent_payload = <span class="stringliteral">"coa_sent:"</span>;
<a name="l00434"></a>00434     coa_sent_payload += b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00435"></a>00435     coa_sent_payload += <span class="stringliteral">"\t"</span>;
<a name="l00436"></a>00436     coa_sent_payload += b-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00437"></a>00437     coa_sent_payload += <span class="stringliteral">"\t"</span>;
<a name="l00438"></a>00438     coa_sent_payload += cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[0]; <span class="comment">// link_addr of mobile, from body of coa</span>
<a name="l00439"></a>00439 
<a name="l00440"></a>00440     log_debug(<span class="stringliteral">"    coa_sent, payload='%s'"</span>, coa_sent_payload.c_str());
<a name="l00441"></a>00441     <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>, coa_sent_payload);
<a name="l00442"></a>00442 
<a name="l00443"></a>00443     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00444"></a>00444 }
<a name="l00445"></a>00445 
<a name="l00446"></a>00446 
<a name="l00447"></a>00447 <span class="keywordtype">bool</span>
<a name="l00448"></a><a class="code" href="classdtn_1_1TcaRouter.html#9af48c77978fae70fc76c23e4d34992f">00448</a> <a class="code" href="classdtn_1_1TcaRouter.html#9af48c77978fae70fc76c23e4d34992f">TcaRouter::on_ask_transmitted</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>&amp; cb)
<a name="l00449"></a>00449 {
<a name="l00450"></a>00450     log_debug(<span class="stringliteral">"TcaRouter: ASK bundle transmitted"</span>);
<a name="l00451"></a>00451 
<a name="l00452"></a>00452     <span class="keywordflow">if</span> (!<a class="code" href="namespacedtn.html#b1bf308761786d3b025044f2c4dd3af1">check_nargs</a>(cb, 1)) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00453"></a>00453 
<a name="l00454"></a>00454     <span class="comment">// todo: use a WrappedBundle here</span>
<a name="l00455"></a>00455     std::string ask_sent= <span class="stringliteral">"ask_sent:"</span>;
<a name="l00456"></a>00456     ask_sent += b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00457"></a>00457     ask_sent += <span class="stringliteral">"\t"</span>;
<a name="l00458"></a>00458     ask_sent += b-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00459"></a>00459     ask_sent += <span class="stringliteral">"\t"</span>;
<a name="l00460"></a>00460     ask_sent += cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[0];
<a name="l00461"></a>00461 
<a name="l00462"></a>00462     log_debug(<span class="stringliteral">"    ask sent, payload='%s'"</span>, ask_sent.c_str());
<a name="l00463"></a>00463     <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>, ask_sent);
<a name="l00464"></a>00464 
<a name="l00465"></a>00465     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00466"></a>00466 }
<a name="l00467"></a>00467 
<a name="l00468"></a>00468 
<a name="l00469"></a>00469 <span class="keywordtype">bool</span>
<a name="l00470"></a><a class="code" href="classdtn_1_1TcaRouter.html#b6813fbb3c85d4999435f5ac06009d2e">00470</a> <a class="code" href="classdtn_1_1TcaRouter.html#b6813fbb3c85d4999435f5ac06009d2e">TcaRouter::on_adv_transmitted</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>&amp; cb)
<a name="l00471"></a>00471 {
<a name="l00472"></a>00472     log_debug(<span class="stringliteral">"TcaRouter: ADV bundle transmitted"</span>);
<a name="l00473"></a>00473 
<a name="l00474"></a>00474     <span class="keywordflow">if</span> (!<a class="code" href="namespacedtn.html#b1bf308761786d3b025044f2c4dd3af1">check_nargs</a>(cb, 2)) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00475"></a>00475 
<a name="l00476"></a>00476     <span class="comment">// todo: use a WrappedBundle here</span>
<a name="l00477"></a>00477     std::string adv_sent= <span class="stringliteral">"adv_sent:"</span>;
<a name="l00478"></a>00478     adv_sent += b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00479"></a>00479     adv_sent += <span class="stringliteral">"\t"</span>;
<a name="l00480"></a>00480     adv_sent += b-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00481"></a>00481     adv_sent += <span class="stringliteral">"\t"</span>;
<a name="l00482"></a>00482     adv_sent += cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[0];
<a name="l00483"></a>00483     adv_sent += <span class="stringliteral">"\t"</span>;
<a name="l00484"></a>00484     adv_sent += cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[1];
<a name="l00485"></a>00485 
<a name="l00486"></a>00486     log_debug(<span class="stringliteral">"    adv_sent, payload='%s'"</span>, adv_sent.c_str());
<a name="l00487"></a>00487     <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>, adv_sent);
<a name="l00488"></a>00488 
<a name="l00489"></a>00489     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00490"></a>00490 }
<a name="l00491"></a>00491 
<a name="l00492"></a>00492 
<a name="l00493"></a>00493 <span class="keywordtype">bool</span>
<a name="l00494"></a><a class="code" href="classdtn_1_1TcaRouter.html#a7c14a283ad6f6241529dbcbc02255cd">00494</a> <a class="code" href="classdtn_1_1TcaRouter.html#a7c14a283ad6f6241529dbcbc02255cd">TcaRouter::handle_register</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b)
<a name="l00495"></a>00495 {
<a name="l00496"></a>00496     <span class="comment">// DK: New stuff - experimental</span>
<a name="l00497"></a>00497     <span class="comment">// Register bundles come either from</span>
<a name="l00498"></a>00498     <span class="comment">// 1) A client application (zero args, source eid important), or</span>
<a name="l00499"></a>00499     <span class="comment">// 2) An admin app (2 args)</span>
<a name="l00500"></a>00500     
<a name="l00501"></a>00501     <span class="keywordflow">if</span> (b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>() == <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>.<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>())
<a name="l00502"></a>00502     {
<a name="l00503"></a>00503         <span class="comment">// The local admin app sent this bundle. Just forward it to the</span>
<a name="l00504"></a>00504         <span class="comment">// default route:</span>
<a name="l00505"></a>00505         <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link(<span class="stringliteral">"TcaRouter::handle_register: fwd_to_matching null"</span>);
<a name="l00506"></a>00506         <a class="code" href="classdtn_1_1TcaRouter.html#4dcc5aebccb8bc0693bcea7d78acc266">fwd_to_matching_r</a>(b, link, <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf8245a9e3815c6eaa77c5ce35ae1b1cede1">FWD_UDR_EXCLUSIVELY</a>);
<a name="l00507"></a>00507     }
<a name="l00508"></a>00508     <span class="keywordflow">else</span>
<a name="l00509"></a>00509     {
<a name="l00510"></a>00510         <span class="comment">// The bundle came from either a local app (non-admin) or</span>
<a name="l00511"></a>00511         <span class="comment">// else another node. In either case, deliver it to local</span>
<a name="l00512"></a>00512         <span class="comment">// admin app.</span>
<a name="l00513"></a>00513         <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a> cb(<a class="code" href="namespacedtn.html#a7adfaff68e09359c063ea32ec7db779">get_payload_str</a>(b));
<a name="l00514"></a>00514 
<a name="l00515"></a>00515         <a class="code" href="classdtn_1_1TcaWrappedBundle.html">TcaWrappedBundle</a> reg_received(<span class="stringliteral">"reg_received"</span>,
<a name="l00516"></a>00516                 b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>(), b-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>());
<a name="l00517"></a>00517 
<a name="l00518"></a>00518         log_debug(<span class="stringliteral">"TcaRouter::handle_register:"</span>);
<a name="l00519"></a>00519         <a class="code" href="namespacedtn.html#3ecf626fe4e85c7f73cde5385fa56144">log_controlbundle</a>(cb);
<a name="l00520"></a>00520 
<a name="l00521"></a>00521         <span class="keywordflow">if</span> (cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>.size() == 2)
<a name="l00522"></a>00522         {
<a name="l00523"></a>00523             <span class="comment">// This bundle came from another node, with mobile_eid</span>
<a name="l00524"></a>00524             <span class="comment">// and last_hop fields filled in.</span>
<a name="l00525"></a>00525             reg_received.append_arg(cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[0]);
<a name="l00526"></a>00526             reg_received.append_arg(cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[1]);
<a name="l00527"></a>00527         }
<a name="l00528"></a>00528         <span class="keywordflow">else</span>
<a name="l00529"></a>00529         {
<a name="l00530"></a>00530             <span class="comment">// This bundle came from an app on the local node</span>
<a name="l00531"></a>00531             <span class="comment">// so fill in mobile_eid and NULL last_hop</span>
<a name="l00532"></a>00532             reg_received.append_arg(b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>());
<a name="l00533"></a>00533             reg_received.append_arg(<span class="stringliteral">"NULL"</span>);
<a name="l00534"></a>00534         }
<a name="l00535"></a>00535         
<a name="l00536"></a>00536         <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>, reg_received.<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>());
<a name="l00537"></a>00537     }
<a name="l00538"></a>00538 
<a name="l00539"></a>00539     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00540"></a>00540 }
<a name="l00541"></a>00541 
<a name="l00542"></a>00542 
<a name="l00543"></a>00543 <span class="keywordtype">bool</span>
<a name="l00544"></a><a class="code" href="classdtn_1_1TcaRouter.html#d97182b3e5c3f04a0f630653d77def65">00544</a> <a class="code" href="classdtn_1_1TcaRouter.html#d97182b3e5c3f04a0f630653d77def65">TcaRouter::handle_coa</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b)
<a name="l00545"></a>00545 {
<a name="l00546"></a>00546     log_debug(<span class="stringliteral">"TcaRouter: COA bundle received"</span>);
<a name="l00547"></a>00547 
<a name="l00548"></a>00548     <span class="comment">// Propagate it along the reverse path, ignoring default route:</span>
<a name="l00549"></a>00549     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link(<span class="stringliteral">"TcaRouter::handle_coa: fwd_to_matching null"</span>);
<a name="l00550"></a>00550     <a class="code" href="classdtn_1_1TcaRouter.html#4dcc5aebccb8bc0693bcea7d78acc266">fwd_to_matching_r</a>(b, link, <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf82c09b112c6e73eddf14d211043905dcab">FWD_UDR_NEVER</a>);
<a name="l00551"></a>00551 
<a name="l00552"></a>00552     <span class="comment">// The old route is deleted after the coa bundle has been</span>
<a name="l00553"></a>00553     <span class="comment">// transmitted, from on_coa_transmitted</span>
<a name="l00554"></a>00554     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00555"></a>00555 }
<a name="l00556"></a>00556 
<a name="l00557"></a>00557 
<a name="l00558"></a>00558 <span class="keywordtype">bool</span>
<a name="l00559"></a><a class="code" href="classdtn_1_1TcaRouter.html#baee51212bd5482452dc79c9d73d6004">00559</a> <a class="code" href="classdtn_1_1TcaRouter.html#baee51212bd5482452dc79c9d73d6004">TcaRouter::handle_anonymous_bundle</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b)
<a name="l00560"></a>00560 {
<a name="l00561"></a>00561     <span class="comment">// these are bundles addressed to a destination eid that begins</span>
<a name="l00562"></a>00562     <span class="comment">// with tca://anonymous</span>
<a name="l00563"></a>00563     <span class="comment">// so far, the "ask" bundle is the only one of its kind</span>
<a name="l00564"></a>00564 
<a name="l00565"></a>00565     <a class="code" href="classdtn_1_1TcaEndpointID.html">TcaEndpointID</a> dest(b-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>());
<a name="l00566"></a>00566 
<a name="l00567"></a>00567     <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a> cb(<a class="code" href="namespacedtn.html#a7adfaff68e09359c063ea32ec7db779">get_payload_str</a>(b));
<a name="l00568"></a>00568 
<a name="l00569"></a>00569     <span class="keywordflow">if</span> (cb.code_ == <span class="stringliteral">"ask"</span>)
<a name="l00570"></a>00570     {
<a name="l00571"></a>00571         <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#c3404881d57c999de16b413319835752">handle_ask</a>(b, cb);
<a name="l00572"></a>00572     }
<a name="l00573"></a>00573     <span class="keywordflow">else</span>
<a name="l00574"></a>00574     {
<a name="l00575"></a>00575         log_debug(<span class="stringliteral">"TcaRouter:: unrecognized anonymous bundle code '%s'"</span>,
<a name="l00576"></a>00576                 cb.code_.c_str());
<a name="l00577"></a>00577         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00578"></a>00578     }
<a name="l00579"></a>00579 }
<a name="l00580"></a>00580 
<a name="l00581"></a>00581 
<a name="l00582"></a>00582 <span class="keywordtype">bool</span>
<a name="l00583"></a><a class="code" href="classdtn_1_1TcaRouter.html#c3404881d57c999de16b413319835752">00583</a> <a class="code" href="classdtn_1_1TcaRouter.html#c3404881d57c999de16b413319835752">TcaRouter::handle_ask</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>&amp; cb)
<a name="l00584"></a>00584 {   
<a name="l00585"></a>00585     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1TcaRouter.html#f4924ec881e6f55024714928560fc53c">is_local_source</a>(b))
<a name="l00586"></a>00586     {
<a name="l00587"></a>00587         <span class="comment">// if the ask originated at this node, just forward it to</span>
<a name="l00588"></a>00588         <span class="comment">// matching, omitting the default route.</span>
<a name="l00589"></a>00589         <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link(<span class="stringliteral">"TcaRouter::handle_ask: fwd_to_matching null"</span>);
<a name="l00590"></a>00590         <a class="code" href="classdtn_1_1TcaRouter.html#4dcc5aebccb8bc0693bcea7d78acc266">fwd_to_matching_r</a>(b, link, <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf82c09b112c6e73eddf14d211043905dcab">FWD_UDR_NEVER</a>);
<a name="l00591"></a>00591     }
<a name="l00592"></a>00592     <span class="keywordflow">else</span>
<a name="l00593"></a>00593     {
<a name="l00594"></a>00594         <span class="keywordflow">if</span> (!<a class="code" href="namespacedtn.html#b1bf308761786d3b025044f2c4dd3af1">check_nargs</a>(cb, 1)) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00595"></a>00595     
<a name="l00596"></a>00596         <span class="comment">// generate ask_received for local admin app</span>
<a name="l00597"></a>00597         std::string payload = <span class="stringliteral">"ask_received:"</span>;
<a name="l00598"></a>00598         payload += b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00599"></a>00599         payload += <span class="stringliteral">"\t"</span>;
<a name="l00600"></a>00600         payload += b-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00601"></a>00601         payload += <span class="stringliteral">"\t"</span>;
<a name="l00602"></a>00602         payload += cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[0];
<a name="l00603"></a>00603 
<a name="l00604"></a>00604         <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>, payload);
<a name="l00605"></a>00605     }
<a name="l00606"></a>00606 
<a name="l00607"></a>00607     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00608"></a>00608 }
<a name="l00609"></a>00609 
<a name="l00610"></a>00610 
<a name="l00611"></a>00611 
<a name="l00612"></a>00612 <span class="comment">// handle_tca_control_bundle handles bundles addressed to</span>
<a name="l00613"></a>00613 <span class="comment">// "localhost/bundlelayer" from the local control application</span>
<a name="l00614"></a>00614 
<a name="l00615"></a>00615 <span class="keywordtype">bool</span>
<a name="l00616"></a><a class="code" href="classdtn_1_1TcaRouter.html#f4894d57a18a6ee67d602b8fdb047286">00616</a> <a class="code" href="classdtn_1_1TcaRouter.html#f4894d57a18a6ee67d602b8fdb047286">TcaRouter::handle_bl_control_bundle</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b)
<a name="l00617"></a>00617 {
<a name="l00618"></a>00618     <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a> cb(<a class="code" href="namespacedtn.html#a7adfaff68e09359c063ea32ec7db779">get_payload_str</a>(b));
<a name="l00619"></a>00619 
<a name="l00620"></a>00620     <span class="comment">// handle ctl bundles:</span>
<a name="l00621"></a>00621     <span class="keywordflow">if</span> (cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#9680f349d5fc55be8b5aaa4aefae4ccd">code_</a> == <span class="stringliteral">"ask"</span>)
<a name="l00622"></a>00622     {
<a name="l00623"></a>00623         <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#c3404881d57c999de16b413319835752">handle_ask</a>(b, cb);
<a name="l00624"></a>00624     }
<a name="l00625"></a>00625     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#9680f349d5fc55be8b5aaa4aefae4ccd">code_</a> == <span class="stringliteral">"get_routes"</span>)
<a name="l00626"></a>00626     {
<a name="l00627"></a>00627         <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#44b8ea0c59a125efb522f4dc59f064b4">handle_get_routes</a>(b, cb);
<a name="l00628"></a>00628     }
<a name="l00629"></a>00629     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#9680f349d5fc55be8b5aaa4aefae4ccd">code_</a> == <span class="stringliteral">"add_route"</span>)
<a name="l00630"></a>00630     {
<a name="l00631"></a>00631         <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#ffcedb6ebf00cc9bb32c961cae93ceb3">handle_add_route</a>(b, cb);
<a name="l00632"></a>00632     }
<a name="l00633"></a>00633     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#9680f349d5fc55be8b5aaa4aefae4ccd">code_</a> == <span class="stringliteral">"del_route"</span>)
<a name="l00634"></a>00634     {
<a name="l00635"></a>00635         <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#670c32c1769f2381e678d3b8e3889fba">handle_del_route</a>(b, cb);
<a name="l00636"></a>00636     }
<a name="l00637"></a>00637 
<a name="l00638"></a>00638     log_debug(<span class="stringliteral">"TcaRouter: unknown control bundle type '%s'"</span>, cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#9680f349d5fc55be8b5aaa4aefae4ccd">code_</a>.c_str());
<a name="l00639"></a>00639     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00640"></a>00640     
<a name="l00641"></a>00641 }
<a name="l00642"></a>00642 
<a name="l00643"></a>00643 
<a name="l00644"></a>00644 <span class="keywordtype">bool</span>
<a name="l00645"></a><a class="code" href="classdtn_1_1TcaRouter.html#eed6598bb8d42f6e6a31043e4d244ba2">00645</a> <a class="code" href="classdtn_1_1TcaRouter.html#eed6598bb8d42f6e6a31043e4d244ba2">TcaRouter::handle_bl_ask</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>&amp; cb)
<a name="l00646"></a>00646 {
<a name="l00647"></a>00647     (void)cb;
<a name="l00648"></a>00648     <span class="comment">// Note: We should never get here! asks should be addressed to the</span>
<a name="l00649"></a>00649     <span class="comment">// control app, not bundle layer.</span>
<a name="l00650"></a>00650     <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>(),
<a name="l00651"></a>00651         <span class="stringliteral">"adv:Don\'t ASK me. You should probably ASK the Control App,"</span>
<a name="l00652"></a>00652         <span class="stringliteral">" not the Bundle Layer."</span>);
<a name="l00653"></a>00653 }
<a name="l00654"></a>00654 
<a name="l00655"></a>00655 
<a name="l00656"></a>00656 <span class="keywordtype">bool</span>
<a name="l00657"></a><a class="code" href="classdtn_1_1TcaRouter.html#44b8ea0c59a125efb522f4dc59f064b4">00657</a> <a class="code" href="classdtn_1_1TcaRouter.html#44b8ea0c59a125efb522f4dc59f064b4">TcaRouter::handle_get_routes</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>&amp; cb)
<a name="l00658"></a>00658 {   
<a name="l00659"></a>00659     <span class="keywordflow">if</span> (!<a class="code" href="namespacedtn.html#b1bf308761786d3b025044f2c4dd3af1">check_nargs</a>(cb, 1)) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00660"></a>00660 
<a name="l00661"></a>00661     log_debug(<span class="stringliteral">"TcaRouter:: get_routes bundle received. body = '%s'"</span>,
<a name="l00662"></a>00662            cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[0].c_str());
<a name="l00663"></a>00663 
<a name="l00664"></a>00664     <a class="code" href="classdtn_1_1RouteEntryVec.html" title="Class for a vector of route entries.">RouteEntryVec</a> matches;
<a name="l00665"></a>00665     RouteEntryVec::iterator iter;
<a name="l00666"></a>00666 
<a name="l00667"></a>00667     <a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a> <a class="code" href="dtnperf-client_8c.html#71808395b2460b32d8b1048e44faef6e">pattern</a>(cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[0]);
<a name="l00668"></a>00668     <a class="code" href="classdtn_1_1TableBasedRouter.html#83939b60c495ff450a1e95787c811297" title="The routing table.">route_table_</a>-&gt;<a class="code" href="classdtn_1_1RouteTable.html#dceb882f843c17db3afd73521bc78c6d" title="Fill in the entry_vec with the list of all entries whose patterns match the given...">get_matching</a>(pattern, &amp;matches);
<a name="l00669"></a>00669 
<a name="l00670"></a>00670     std::string response = <span class="stringliteral">"routes:"</span>;
<a name="l00671"></a>00671     <span class="keywordflow">for</span> (iter = matches.begin(); iter != matches.end(); ++iter)
<a name="l00672"></a>00672     {
<a name="l00673"></a>00673         response += (*iter)-&gt;dest_pattern().str().c_str();
<a name="l00674"></a>00674         response += <span class="stringliteral">"\t"</span>;
<a name="l00675"></a>00675     }
<a name="l00676"></a>00676 
<a name="l00677"></a>00677     <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>(), response);
<a name="l00678"></a>00678 
<a name="l00679"></a>00679     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00680"></a>00680 }
<a name="l00681"></a>00681 
<a name="l00682"></a>00682 
<a name="l00683"></a>00683 <span class="keywordtype">bool</span>
<a name="l00684"></a><a class="code" href="classdtn_1_1TcaRouter.html#ffcedb6ebf00cc9bb32c961cae93ceb3">00684</a> <a class="code" href="classdtn_1_1TcaRouter.html#ffcedb6ebf00cc9bb32c961cae93ceb3">TcaRouter::handle_add_route</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>&amp; cb)
<a name="l00685"></a>00685 {
<a name="l00686"></a>00686     (void)b;
<a name="l00687"></a>00687     
<a name="l00688"></a>00688     <span class="keywordflow">if</span> (!<a class="code" href="namespacedtn.html#b1bf308761786d3b025044f2c4dd3af1">check_nargs</a>(cb, 2)) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00689"></a>00689 
<a name="l00690"></a>00690     <span class="keyword">const</span> std::string&amp; <a class="code" href="dtnperf-client_8c.html#71808395b2460b32d8b1048e44faef6e">pattern</a> = cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[0];
<a name="l00691"></a>00691     <span class="keyword">const</span> std::string&amp; link = cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[1];
<a name="l00692"></a>00692 
<a name="l00693"></a>00693     log_debug(<span class="stringliteral">"TcaRouter:: add_route bundle received. "</span>
<a name="l00694"></a>00694               <span class="stringliteral">"pattern='%s', link='%s'\n"</span>, pattern.c_str(), link.c_str());
<a name="l00695"></a>00695 
<a name="l00696"></a>00696     <span class="keywordflow">if</span> (pattern.length() == 0 || link.length() == 0) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00697"></a>00697 
<a name="l00698"></a>00698     <span class="comment">// TODO: Some syntax-checking would be a very good idea. Right now,</span>
<a name="l00699"></a>00699     <span class="comment">// just blast away:</span>
<a name="l00700"></a>00700     <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#365edc775bc1481550f313c1366040e0">create_route</a>(pattern, link);
<a name="l00701"></a>00701 }
<a name="l00702"></a>00702 
<a name="l00703"></a>00703 
<a name="l00704"></a>00704 <span class="keywordtype">bool</span>
<a name="l00705"></a><a class="code" href="classdtn_1_1TcaRouter.html#670c32c1769f2381e678d3b8e3889fba">00705</a> <a class="code" href="classdtn_1_1TcaRouter.html#670c32c1769f2381e678d3b8e3889fba">TcaRouter::handle_del_route</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">TcaControlBundle</a>&amp; cb)
<a name="l00706"></a>00706 {
<a name="l00707"></a>00707     (void)b;
<a name="l00708"></a>00708     
<a name="l00709"></a>00709     <span class="keywordflow">if</span> (!<a class="code" href="namespacedtn.html#b1bf308761786d3b025044f2c4dd3af1">check_nargs</a>(cb, 1)) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00710"></a>00710 
<a name="l00711"></a>00711     log_debug(<span class="stringliteral">"TcaRouter:: del_route bundle received. body = '%s'"</span>,
<a name="l00712"></a>00712            cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[0].c_str());
<a name="l00713"></a>00713 
<a name="l00714"></a>00714     <span class="comment">// TODO: Some syntax-checking would be a very good idea. Right now,</span>
<a name="l00715"></a>00715     <span class="comment">// just blast away:</span>
<a name="l00716"></a>00716     <a class="code" href="classdtn_1_1TableBasedRouter.html#83939b60c495ff450a1e95787c811297" title="The routing table.">route_table_</a>-&gt;<a class="code" href="classdtn_1_1RouteTable.html#f58eb380fc5a9cd31745d353d3f8baea" title="Remove all entries to the given endpoint id pattern.">del_entries</a>(cb.<a class="code" href="classdtn_1_1TcaControlBundle.html#e9497c7cf69bc9a7a2a1e05335d00d0a">args_</a>[0]);
<a name="l00717"></a>00717     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00718"></a>00718 }
<a name="l00719"></a>00719 
<a name="l00720"></a>00720 
<a name="l00721"></a>00721 <span class="comment">// handle_tca_unbound_bundle handles routing of regular late-bound tca data</span>
<a name="l00722"></a>00722 <span class="comment">// bundles.</span>
<a name="l00723"></a>00723 <span class="comment">// This function assumes that this router is not the dest endpoint.</span>
<a name="l00724"></a>00724 <span class="comment">// for the bundle. The logic goes like this:</span>
<a name="l00725"></a>00725 <span class="comment">// First, forward the bundle to any existing route to dest, using the default</span>
<a name="l00726"></a>00726 <span class="comment">// route iff there are no other matches.</span>
<a name="l00727"></a>00727 <span class="comment">// If there are no matches at all, and if the local node is a gateway,</span>
<a name="l00728"></a>00728 <span class="comment">// then push a "unb" bundle up to the control app for special handling.</span>
<a name="l00729"></a>00729 
<a name="l00730"></a>00730 <span class="keywordtype">bool</span>
<a name="l00731"></a><a class="code" href="classdtn_1_1TcaRouter.html#e72174b3667dd66ecc6201c2f6cfba24">00731</a> <a class="code" href="classdtn_1_1TcaRouter.html#e72174b3667dd66ecc6201c2f6cfba24">TcaRouter::handle_tca_unbound_bundle</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle)
<a name="l00732"></a>00732 {
<a name="l00733"></a>00733     log_debug(<span class="stringliteral">"TcaRouter::handle_tca_unbound_bundle..."</span>);
<a name="l00734"></a>00734 
<a name="l00735"></a>00735     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link(<span class="stringliteral">"TcaRouter::handle_tca_unbound_bundle: fwd_to_matching null"</span>);
<a name="l00736"></a>00736     <span class="keywordtype">int</span> n_matches = <a class="code" href="classdtn_1_1TcaRouter.html#4dcc5aebccb8bc0693bcea7d78acc266">fwd_to_matching_r</a>(bundle, link, <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf829083ad4aa536bc2c6d7f0a5be4fd3604">FWD_UDR_IFNECESSARY</a>);
<a name="l00737"></a>00737 
<a name="l00738"></a>00738     <span class="keywordflow">if</span> (n_matches == 0)
<a name="l00739"></a>00739     {
<a name="l00740"></a>00740         <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1TcaRouter.html#95d98e32fedc60c6e192fdf083c21341">role_</a> == <a class="code" href="classdtn_1_1TcaRouter.html#7937c9ef257ad4c0d45e44947ed48b24b40fd54ee6b0189d5984e209b4082dc1">TCA_ROUTER</a>)
<a name="l00741"></a>00741         {
<a name="l00742"></a>00742             <span class="comment">// If I'm a router, this is an error! All tca bundles must have</span>
<a name="l00743"></a>00743             <span class="comment">// a default route up to a gateway.</span>
<a name="l00744"></a>00744             log_err(<span class="stringliteral">"TcaRouter: Error. TCA_ROUTER has no route to dest %s"</span>,
<a name="l00745"></a>00745                     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00746"></a>00746             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00747"></a>00747         }
<a name="l00748"></a>00748         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1TcaRouter.html#95d98e32fedc60c6e192fdf083c21341">role_</a> == <a class="code" href="classdtn_1_1TcaRouter.html#7937c9ef257ad4c0d45e44947ed48b24aa6e45693173fd8231cbdcd4a6d3c6b9">TCA_GATEWAY</a>)
<a name="l00749"></a>00749         {
<a name="l00750"></a>00750             <span class="comment">// If I'm a gateway, try late-binding...</span>
<a name="l00751"></a>00751             <span class="comment">// Leave the unbound bundle alone, but push a control bundle up</span>
<a name="l00752"></a>00752             <span class="comment">// to the control app, which will get registration and create a</span>
<a name="l00753"></a>00753             <span class="comment">// route if possible.</span>
<a name="l00754"></a>00754             std::string payload = <span class="stringliteral">"unb:"</span>;
<a name="l00755"></a>00755             payload += bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00756"></a>00756             <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>, payload);
<a name="l00757"></a>00757         }
<a name="l00758"></a>00758     }
<a name="l00759"></a>00759     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00760"></a>00760 }
<a name="l00761"></a>00761 
<a name="l00762"></a>00762 
<a name="l00763"></a>00763 
<a name="l00764"></a>00764 <span class="keywordtype">bool</span>
<a name="l00765"></a><a class="code" href="classdtn_1_1TcaRouter.html#f4924ec881e6f55024714928560fc53c">00765</a> <a class="code" href="classdtn_1_1TcaRouter.html#f4924ec881e6f55024714928560fc53c">TcaRouter::is_local_source</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b)
<a name="l00766"></a>00766 {
<a name="l00767"></a>00767     <a class="code" href="classdtn_1_1TcaEndpointID.html">TcaEndpointID</a> <a class="code" href="dtnmoteproxy_8c.html#e1ade0f5a1b32f6c8be72f31a99e2a18">src</a>(b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>());
<a name="l00768"></a>00768     <span class="keywordflow">return</span> <a class="code" href="dtnmoteproxy_8c.html#e1ade0f5a1b32f6c8be72f31a99e2a18">src</a>.get_hostid() == <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>.<a class="code" href="classdtn_1_1TcaEndpointID.html#6f23dbe9ea58f98704800431083d064c">get_hostid</a>();
<a name="l00769"></a>00769 }
<a name="l00770"></a>00770 
<a name="l00771"></a>00771 
<a name="l00772"></a>00772 <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf82">TcaRouter::ForwardingRule</a>
<a name="l00773"></a><a class="code" href="classdtn_1_1TcaRouter.html#a6617e273b45487a85ec11cbdb997ac0">00773</a> <a class="code" href="classdtn_1_1TcaRouter.html#a6617e273b45487a85ec11cbdb997ac0">TcaRouter::get_forwarding_rule</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b)
<a name="l00774"></a>00774 {
<a name="l00775"></a>00775     <span class="comment">// all non-tca bundles should always be forwarded to all routes</span>
<a name="l00776"></a>00776     <span class="keywordflow">if</span> (b-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#2ff5cd5d95e97cac315a192676c6a057">scheme_str</a>() != <span class="stringliteral">"tca"</span>) <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf8299689a5b013eef9e17cdc411004797d3">FWD_UDR_ALWAYS</a>;
<a name="l00777"></a>00777     
<a name="l00778"></a>00778     <a class="code" href="classdtn_1_1TcaEndpointID.html">TcaEndpointID</a> dest(b-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>());
<a name="l00779"></a>00779 
<a name="l00780"></a>00780     <span class="keywordflow">if</span> (dest.ssp() == <span class="stringliteral">"//registry"</span>)
<a name="l00781"></a>00781     {
<a name="l00782"></a>00782         <span class="comment">// forward to default route (exclusively) iff sent by the local</span>
<a name="l00783"></a>00783         <span class="comment">// admin app</span>
<a name="l00784"></a>00784         <span class="keywordflow">if</span> (b-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>() == <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>.<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>()) <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf8245a9e3815c6eaa77c5ce35ae1b1cede1">FWD_UDR_EXCLUSIVELY</a>;
<a name="l00785"></a>00785         <span class="keywordflow">else</span> <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf82a7ff8cbd1e8adcc7d83834c9b22c5ce9">FWD_NEVER</a>;
<a name="l00786"></a>00786     }
<a name="l00787"></a>00787 
<a name="l00788"></a>00788     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dest.app() == <span class="stringliteral">"admin.coa"</span>)
<a name="l00789"></a>00789     {
<a name="l00790"></a>00790         <span class="comment">// Never us the default route for the coa bundles. They are on their</span>
<a name="l00791"></a>00791         <span class="comment">// way "down" the tree to a mobile and we don't want them getting</span>
<a name="l00792"></a>00792         <span class="comment">// forwarded back up to a gateway too.</span>
<a name="l00793"></a>00793         <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf82c09b112c6e73eddf14d211043905dcab">FWD_UDR_NEVER</a>;
<a name="l00794"></a>00794     }
<a name="l00795"></a>00795 
<a name="l00796"></a>00796     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dest.ssp().substr(0,11) == <span class="stringliteral">"//anonymous"</span>)
<a name="l00797"></a>00797     {
<a name="l00798"></a>00798         <span class="comment">// Assume this is an ask bundle. (WARNING: If there are ever any</span>
<a name="l00799"></a>00799         <span class="comment">// anonymous bundles other than ASK, this should be changed!)</span>
<a name="l00800"></a>00800         <span class="comment">// For ask, forward only if originating at local node, and never</span>
<a name="l00801"></a>00801         <span class="comment">// to the default route.</span>
<a name="l00802"></a>00802         <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1TcaRouter.html#f4924ec881e6f55024714928560fc53c">is_local_source</a>(b)) <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf82c09b112c6e73eddf14d211043905dcab">FWD_UDR_NEVER</a>;
<a name="l00803"></a>00803         <span class="keywordflow">else</span> <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf82a7ff8cbd1e8adcc7d83834c9b22c5ce9">FWD_NEVER</a>;
<a name="l00804"></a>00804     }
<a name="l00805"></a>00805 
<a name="l00806"></a>00806     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dest.ssp() == <span class="stringliteral">"//localhost/bundlelayer"</span>)
<a name="l00807"></a>00807     {
<a name="l00808"></a>00808         <span class="comment">// Never forward bundles sent to the local bundle layer</span>
<a name="l00809"></a>00809         <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf82a7ff8cbd1e8adcc7d83834c9b22c5ce9">FWD_NEVER</a>;
<a name="l00810"></a>00810     }
<a name="l00811"></a>00811 
<a name="l00812"></a>00812     <span class="comment">// These are all the special control dest cases. What remains are any</span>
<a name="l00813"></a>00813     <span class="comment">// ordinarily addressed tca bundles</span>
<a name="l00814"></a>00814     <span class="keywordflow">else</span>
<a name="l00815"></a>00815     {
<a name="l00816"></a>00816         <span class="keywordflow">if</span> (dest.host() == <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>.<a class="code" href="classdtn_1_1TcaEndpointID.html#4ae4e32d1fdd24a0f991fa7ee36e69b6">host</a>())
<a name="l00817"></a>00817         {
<a name="l00818"></a>00818             <span class="comment">// If addressed to local admin app, do not forward. This bundle</span>
<a name="l00819"></a>00819             <span class="comment">// is home.</span>
<a name="l00820"></a>00820             <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf82a7ff8cbd1e8adcc7d83834c9b22c5ce9">FWD_NEVER</a>;
<a name="l00821"></a>00821         }
<a name="l00822"></a>00822         <span class="keywordflow">else</span>
<a name="l00823"></a>00823         {
<a name="l00824"></a>00824             <span class="comment">// Treat this as an unbound tca bundle. Forward to matches, using</span>
<a name="l00825"></a>00825             <span class="comment">// default route iff no other matches.</span>
<a name="l00826"></a>00826             <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#9c0f7c470ee32d86df8ccdd6145eaf829083ad4aa536bc2c6d7f0a5be4fd3604">FWD_UDR_IFNECESSARY</a>;
<a name="l00827"></a>00827         }
<a name="l00828"></a>00828     }
<a name="l00829"></a>00829 }
<a name="l00830"></a>00830 
<a name="l00831"></a>00831 
<a name="l00832"></a>00832 <span class="comment">// create_link creates a link for the given link_addr iff it doesn't already</span>
<a name="l00833"></a>00833 <span class="comment">// exist.</span>
<a name="l00834"></a>00834 <span class="comment">// link_addr must be in the form "tcp://host:port"</span>
<a name="l00835"></a>00835 
<a name="l00836"></a>00836 <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>
<a name="l00837"></a><a class="code" href="classdtn_1_1TcaRouter.html#429cb314c948f703f5ed21a8c8820bdb">00837</a> <a class="code" href="classdtn_1_1TcaRouter.html#429cb314c948f703f5ed21a8c8820bdb">TcaRouter::create_link</a>(<span class="keyword">const</span> std::string&amp; link_addr)
<a name="l00838"></a>00838 {
<a name="l00839"></a>00839     <span class="comment">// Note that deleting the old one and re-creating it is the wrong</span>
<a name="l00840"></a>00840     <span class="comment">// thing to do, because when the link is re-created all pending</span>
<a name="l00841"></a>00841     <span class="comment">// bundles (inlcuding the register bundle that initiated this) will</span>
<a name="l00842"></a>00842     <span class="comment">// be matched and forwarded to the new link.</span>
<a name="l00843"></a>00843 
<a name="l00844"></a>00844     <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a> link_eid(link_addr);
<a name="l00845"></a>00845     std::string clayer_name = link_eid.<a class="code" href="classdtn_1_1EndpointID.html#2ff5cd5d95e97cac315a192676c6a057">scheme_str</a>();
<a name="l00846"></a>00846     <span class="keyword">const</span> std::string&amp; ssp = link_eid.<a class="code" href="classdtn_1_1EndpointID.html#b6aa3012f45fa87006d24413f8c1bb65">ssp</a>();
<a name="l00847"></a>00847     std::string host = ssp.substr(2, ssp.length()); <span class="comment">// chop off the "//"</span>
<a name="l00848"></a>00848 
<a name="l00849"></a>00849     <a class="code" href="classdtn_1_1ContactManager.html" title="A contact manager class.">ContactManager</a>* p_man = BundleDaemon::instance()-&gt;contactmgr();
<a name="l00850"></a>00850 
<a name="l00851"></a>00851     <span class="comment">// Check if there's an existing link of the same name.</span>
<a name="l00852"></a>00852     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> p_link(<span class="stringliteral">"TcaRouter::create_link: return value"</span>);
<a name="l00853"></a>00853            
<a name="l00854"></a>00854     p_link = p_man-&gt;<a class="code" href="classdtn_1_1ContactManager.html#4a31131016ed7f6b11ce6823dd7abe91" title="Finds link corresponding to this name.">find_link</a>(host.c_str());
<a name="l00855"></a>00855     <span class="keywordflow">if</span> (p_link != NULL) <span class="keywordflow">return</span> p_link;
<a name="l00856"></a>00856 
<a name="l00857"></a>00857     <a class="code" href="classdtn_1_1ConvergenceLayer.html" title="The abstract interface for a convergence layer.">ConvergenceLayer</a>* cl = <a class="code" href="classdtn_1_1ConvergenceLayer.html#6259b19bef1dd17295030b33c44c29d0" title="Find the appropriate convergence layer for the given string.">ConvergenceLayer::find_clayer</a>(clayer_name.c_str());
<a name="l00858"></a>00858     <span class="keywordflow">if</span> (!cl) {
<a name="l00859"></a>00859         log_err(<span class="stringliteral">"TcaRouter: create_link failed: invalid convergence layer"</span>
<a name="l00860"></a>00860                   <span class="stringliteral">" '%s'"</span>, clayer_name.c_str());
<a name="l00861"></a>00861         <span class="keywordflow">return</span> p_link;
<a name="l00862"></a>00862     }
<a name="l00863"></a>00863  
<a name="l00864"></a>00864     p_link = <a class="code" href="classdtn_1_1TcaRouter.html#429cb314c948f703f5ed21a8c8820bdb">Link::create_link</a>(host, <a class="code" href="classdtn_1_1Link.html#a93653796d33692c67c415afd1edf61eeacf2159ea9fd169ca07c9f9891309ec" title="The link is expected to be either always available, or can be made available easily...">Link::ONDEMAND</a>, cl, host.c_str(), 0, NULL);
<a name="l00865"></a>00865     <span class="keywordflow">if</span> (p_link == NULL) <span class="keywordflow">return</span> p_link;
<a name="l00866"></a>00866         
<a name="l00867"></a>00867     <span class="comment">// Add the link to contact manager's table, which posts a</span>
<a name="l00868"></a>00868     <span class="comment">// LinkCreatedEvent to the daemon</span>
<a name="l00869"></a>00869     <span class="keywordflow">if</span> (!p_man-&gt;<a class="code" href="classdtn_1_1ContactManager.html#c0964b1fa4e2c5fc4c841d7261cf5929" title="Add a link if the contact manager does not already have a link by the same name.">add_new_link</a>(p_link)) {
<a name="l00870"></a>00870         p_link-&gt;delete_link();
<a name="l00871"></a>00871         log_err(<span class="stringliteral">"TcaRouter::create_link: "</span>
<a name="l00872"></a>00872                 <span class="stringliteral">"failed to add new link %s"</span>, p_link-&gt;name());
<a name="l00873"></a>00873         p_link = NULL;
<a name="l00874"></a>00874         <span class="keywordflow">return</span> p_link;
<a name="l00875"></a>00875     }
<a name="l00876"></a>00876 
<a name="l00877"></a>00877     <span class="keywordflow">return</span> p_link;
<a name="l00878"></a>00878 }
<a name="l00879"></a>00879 
<a name="l00880"></a>00880 
<a name="l00881"></a>00881 <a class="code" href="classdtn_1_1RouteEntry.html" title="Class to represent route table entry.">RouteEntry</a>*
<a name="l00882"></a><a class="code" href="classdtn_1_1TcaRouter.html#365edc775bc1481550f313c1366040e0">00882</a> <a class="code" href="classdtn_1_1TcaRouter.html#365edc775bc1481550f313c1366040e0">TcaRouter::create_route</a>(<span class="keyword">const</span> std::string&amp; <a class="code" href="dtnperf-client_8c.html#71808395b2460b32d8b1048e44faef6e">pattern</a>, <span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; p_link)
<a name="l00883"></a>00883 {
<a name="l00884"></a>00884 
<a name="l00885"></a>00885     log_debug(<span class="stringliteral">"TcaRouter::create_route: pattern=%s, p_link=%p"</span>,
<a name="l00886"></a>00886             pattern.c_str(), p_link.object());
<a name="l00887"></a>00887 
<a name="l00888"></a>00888     <a class="code" href="classdtn_1_1RouteEntry.html" title="Class to represent route table entry.">RouteEntry</a>* p_entry = <span class="keyword">new</span> <a class="code" href="classdtn_1_1RouteEntry.html" title="Class to represent route table entry.">RouteEntry</a>(pattern, p_link);
<a name="l00889"></a>00889     p_entry-&gt;set_action(<a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b594777ba7ba2355d6b87536afc9ef78efeb8" title="Forward a copy of the bundle.">ForwardingInfo::COPY_ACTION</a>);
<a name="l00890"></a>00890 
<a name="l00891"></a>00891     <a class="code" href="classdtn_1_1TableBasedRouter.html#83939b60c495ff450a1e95787c811297" title="The routing table.">route_table_</a>-&gt;<a class="code" href="classdtn_1_1RouteTable.html#f4563da3a4e78c4784a72e790a831469" title="Add a route entry.">add_entry</a>(p_entry);
<a name="l00892"></a>00892 
<a name="l00893"></a>00893     <span class="keywordflow">return</span> p_entry;
<a name="l00894"></a>00894 }
<a name="l00895"></a>00895 
<a name="l00896"></a>00896 
<a name="l00897"></a>00897 <span class="keywordtype">bool</span>
<a name="l00898"></a><a class="code" href="classdtn_1_1TcaRouter.html#78ca3e01b910a56f57936c1678685a3d">00898</a> <a class="code" href="classdtn_1_1TcaRouter.html#365edc775bc1481550f313c1366040e0">TcaRouter::create_route</a>(<span class="keyword">const</span> std::string&amp; <a class="code" href="dtnperf-client_8c.html#71808395b2460b32d8b1048e44faef6e">pattern</a>,
<a name="l00899"></a>00899                         <span class="keyword">const</span> std::string&amp; link_addr)
<a name="l00900"></a>00900 {
<a name="l00901"></a>00901     <span class="comment">// First find the right link, or create a new one if necesary</span>
<a name="l00902"></a>00902     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> p_link = <a class="code" href="classdtn_1_1TcaRouter.html#429cb314c948f703f5ed21a8c8820bdb">create_link</a>(link_addr);
<a name="l00903"></a>00903     <span class="keywordflow">if</span> (p_link == NULL)
<a name="l00904"></a>00904     {
<a name="l00905"></a>00905         log_err(<span class="stringliteral">"TcaRouter::create_route: create_link failed"</span>);
<a name="l00906"></a>00906         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00907"></a>00907     }
<a name="l00908"></a>00908 
<a name="l00909"></a>00909     <span class="comment">// Now create the new route entry</span>
<a name="l00910"></a>00910     <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1TcaRouter.html#365edc775bc1481550f313c1366040e0">create_route</a>(pattern, p_link))
<a name="l00911"></a>00911     {
<a name="l00912"></a>00912         log_err(<span class="stringliteral">"TcaRouter::create_route: create_route failed"</span>);
<a name="l00913"></a>00913         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00914"></a>00914     }
<a name="l00915"></a>00915 
<a name="l00916"></a>00916     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00917"></a>00917 }
<a name="l00918"></a>00918 
<a name="l00919"></a>00919 
<a name="l00920"></a>00920 <span class="keywordtype">bool</span>
<a name="l00921"></a><a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">00921</a> <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">TcaRouter::post_bundle</a>(<span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a>&amp; <a class="code" href="dtnmoteproxy_8c.html#e1ade0f5a1b32f6c8be72f31a99e2a18">src</a>, <span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a>&amp; dest,
<a name="l00922"></a>00922                        <span class="keyword">const</span> std::string&amp; payload)
<a name="l00923"></a>00923 {
<a name="l00924"></a>00924 
<a name="l00925"></a>00925     log_debug(<span class="stringliteral">"TcaRouter::post_bundle: [%s] -&gt; [%s] : '%s'\n"</span>,
<a name="l00926"></a>00926                 src.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(), dest.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(), payload.c_str());
<a name="l00927"></a>00927 
<a name="l00928"></a>00928     <span class="comment">// Construct bundle</span>
<a name="l00929"></a>00929     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b = <span class="keyword">new</span> <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>();
<a name="l00930"></a>00930 
<a name="l00931"></a>00931     <span class="comment">// if source is unspecified, use bundlelayer</span>
<a name="l00932"></a>00932     <span class="keywordflow">if</span> (src.<a class="code" href="classdtn_1_1EndpointID.html#3ed7639ed8794ea8045bb5d16128c5f5">length</a>() == 0)
<a name="l00933"></a>00933         b-&gt;mutable_source()-&gt;assign(<span class="stringliteral">"tca://localhost/bundlelayer"</span>);
<a name="l00934"></a>00934     <span class="keywordflow">else</span>
<a name="l00935"></a>00935         b-&gt;mutable_source()-&gt;assign(src);
<a name="l00936"></a>00936 
<a name="l00937"></a>00937     b-&gt;mutable_dest()-&gt;assign(dest);
<a name="l00938"></a>00938     b-&gt;mutable_custodian()-&gt;assign(BundleDaemon::instance()-&gt;local_eid());
<a name="l00939"></a>00939     b-&gt;mutable_replyto()-&gt;assign(BundleDaemon::instance()-&gt;local_eid());
<a name="l00940"></a>00940 
<a name="l00941"></a>00941     b-&gt;mutable_payload()-&gt;set_data(payload);
<a name="l00942"></a>00942 
<a name="l00943"></a>00943     <span class="comment">// We need to set non-zero expiration or else the bundle</span>
<a name="l00944"></a>00944     <span class="comment">// expires as soon as it arrives.</span>
<a name="l00945"></a>00945     b-&gt;set_expiration(3600);
<a name="l00946"></a>00946 
<a name="l00947"></a>00947     <span class="comment">// The default values are ok for the rest of the bundle fields.</span>
<a name="l00948"></a>00948 
<a name="l00949"></a>00949     <span class="comment">// Post the bundle by generating a BundleReceivedEvent</span>
<a name="l00950"></a>00950     <a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a>* p_event = <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a>(b, <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b04a9578f3e2276d81cd632222ceb4e2e" title="the admin logic">EVENTSRC_ADMIN</a>);
<a name="l00951"></a>00951     BundleDaemon::instance()-&gt;post(p_event);
<a name="l00952"></a>00952 
<a name="l00953"></a>00953     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00954"></a>00954 }
<a name="l00955"></a>00955 
<a name="l00956"></a>00956 
<a name="l00957"></a>00957 <span class="comment">// dead code at the moment:</span>
<a name="l00958"></a>00958 <span class="keywordtype">bool</span>
<a name="l00959"></a><a class="code" href="classdtn_1_1TcaRouter.html#b26c21545be05b3acb0853135646e85f">00959</a> <a class="code" href="classdtn_1_1TcaRouter.html#b26c21545be05b3acb0853135646e85f">TcaRouter::push_wrapped_bundle</a>(<span class="keyword">const</span> std::string&amp; code,
<a name="l00960"></a>00960                                <span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a>&amp; <a class="code" href="dtnmoteproxy_8c.html#e1ade0f5a1b32f6c8be72f31a99e2a18">src</a>,
<a name="l00961"></a>00961                                <span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a>&amp; dest,
<a name="l00962"></a>00962                                <span class="keyword">const</span> std::string&amp; bsp)
<a name="l00963"></a>00963 {
<a name="l00964"></a>00964     std::string payload = code;
<a name="l00965"></a>00965     payload += <span class="stringliteral">":"</span>;
<a name="l00966"></a>00966     payload += src.<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00967"></a>00967     payload += <span class="stringliteral">"\t"</span>;
<a name="l00968"></a>00968     payload += dest.<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00969"></a>00969     payload += <span class="stringliteral">"\t"</span>;
<a name="l00970"></a>00970     payload += bsp;
<a name="l00971"></a>00971     <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TcaRouter.html#5619ce73ca0f8b6e94c0bee312d6a18f">post_bundle</a>(<a class="code" href="namespacedtn.html#dd1a28db7c04f2bc451d7d66142dba6a">BL</a>, <a class="code" href="classdtn_1_1TcaRouter.html#10687890eaf780ed184c4ec5da372666">admin_app_</a>, payload);
<a name="l00972"></a>00972 }
<a name="l00973"></a>00973 
<a name="l00974"></a>00974 
<a name="l00975"></a>00975 
<a name="l00976"></a>00976 
<a name="l00977"></a>00977 } <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:58 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>