Sophie

Sophie

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

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: BundleRouter.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>BundleRouter.cc</h1><a href="BundleRouter_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 2004-2006 Intel Corporation</span>
<a name="l00003"></a>00003 <span class="comment"> * </span>
<a name="l00004"></a>00004 <span class="comment"> *    Licensed under the Apache License, Version 2.0 (the "License");</span>
<a name="l00005"></a>00005 <span class="comment"> *    you may not use this file except in compliance with the License.</span>
<a name="l00006"></a>00006 <span class="comment"> *    You may obtain a copy of the License at</span>
<a name="l00007"></a>00007 <span class="comment"> * </span>
<a name="l00008"></a>00008 <span class="comment"> *        http://www.apache.org/licenses/LICENSE-2.0</span>
<a name="l00009"></a>00009 <span class="comment"> * </span>
<a name="l00010"></a>00010 <span class="comment"> *    Unless required by applicable law or agreed to in writing, software</span>
<a name="l00011"></a>00011 <span class="comment"> *    distributed under the License is distributed on an "AS IS" BASIS,</span>
<a name="l00012"></a>00012 <span class="comment"> *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<a name="l00013"></a>00013 <span class="comment"> *    See the License for the specific language governing permissions and</span>
<a name="l00014"></a>00014 <span class="comment"> *    limitations under the License.</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#  include &lt;<a class="code" href="dtn-config_8h.html">dtn-config.h</a>&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#endif</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="BundleRouter_8h.html">BundleRouter.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="BundleActions_8h.html">bundling/BundleActions.h</a>"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="bundling_2BundleList_8h.html">bundling/BundleList.h</a>"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="BundleStore_8h.html">storage/BundleStore.h</a>"</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="StaticBundleRouter_8h.html">StaticBundleRouter.h</a>"</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="FloodBundleRouter_8h.html">FloodBundleRouter.h</a>"</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="ProphetRouter_8h.html">ProphetRouter.h</a>"</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="DTLSRRouter_8h.html">DTLSRRouter.h</a>"</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="ExternalRouter_8h.html">ExternalRouter.h</a>"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="TcaRouter_8h.html">TcaRouter.h</a>"</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="keyword">namespace </span>dtn {
<a name="l00037"></a>00037 
<a name="l00038"></a>00038 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00039"></a><a class="code" href="structdtn_1_1BundleRouter_1_1Config.html#41d19625934c6b5f96e132fd6568dcf8">00039</a> <a class="code" href="structdtn_1_1BundleRouter_1_1Config.html#41d19625934c6b5f96e132fd6568dcf8">BundleRouter::Config::Config</a>()
<a name="l00040"></a>00040     : type_(<span class="stringliteral">"static"</span>),
<a name="l00041"></a>00041       add_nexthop_routes_(true),
<a name="l00042"></a>00042       open_discovered_links_(true),
<a name="l00043"></a>00043       default_priority_(0),
<a name="l00044"></a>00044       max_route_to_chain_(10),
<a name="l00045"></a>00045       storage_quota_(0),
<a name="l00046"></a>00046       subscription_timeout_(600)
<a name="l00047"></a>00047 {}
<a name="l00048"></a>00048 
<a name="l00049"></a><a class="code" href="classdtn_1_1BundleRouter.html#344d85ef64a884adf9fb173a82674cca">00049</a> <a class="code" href="structdtn_1_1BundleRouter_1_1Config.html" title="Config variables.">BundleRouter::Config</a> <a class="code" href="classdtn_1_1BundleRouter.html#344d85ef64a884adf9fb173a82674cca" title="Config variables.">BundleRouter::config_</a>;
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00052"></a>00052 <a class="code" href="classdtn_1_1BundleRouter.html" title="The BundleRouter is the main decision maker for all routing decisions related to...">BundleRouter</a>*
<a name="l00053"></a><a class="code" href="classdtn_1_1BundleRouter.html#deb4dc788d0ca34bfb1e06eb49c42de4">00053</a> <a class="code" href="classdtn_1_1BundleRouter.html#deb4dc788d0ca34bfb1e06eb49c42de4" title="Factory method to create the correct subclass of BundleRouter for the registered...">BundleRouter::create_router</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* type)
<a name="l00054"></a>00054 {
<a name="l00055"></a>00055     <span class="keywordflow">if</span> (strcmp(type, <span class="stringliteral">"static"</span>) == 0) {
<a name="l00056"></a>00056         <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classdtn_1_1StaticBundleRouter.html" title="This is the implementation of the basic bundle routing algorithm that only does static...">StaticBundleRouter</a>();
<a name="l00057"></a>00057     }
<a name="l00058"></a>00058     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(type, <span class="stringliteral">"prophet"</span>) == 0) {
<a name="l00059"></a>00059         <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classdtn_1_1ProphetRouter.html">ProphetRouter</a>();
<a name="l00060"></a>00060     }
<a name="l00061"></a>00061     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(type, <span class="stringliteral">"flood"</span>) == 0) {
<a name="l00062"></a>00062         <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classdtn_1_1FloodBundleRouter.html" title="This is the implementation of a flooding based bundle router.">FloodBundleRouter</a>();
<a name="l00063"></a>00063     }
<a name="l00064"></a>00064     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(type, <span class="stringliteral">"dtlsr"</span>) == 0) {
<a name="l00065"></a>00065         <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classdtn_1_1DTLSRRouter.html" title="The DTLSRRouter uses link state announcements to build a multigraph of routing edges...">DTLSRRouter</a>();
<a name="l00066"></a>00066     }    
<a name="l00067"></a>00067     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(type, <span class="stringliteral">"tca_router"</span>)) {
<a name="l00068"></a>00068         <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classdtn_1_1TcaRouter.html" title="This is the implementation of the TCA bundle routing algorithm.">TcaRouter</a>(<a class="code" href="classdtn_1_1TcaRouter.html#7937c9ef257ad4c0d45e44947ed48b24b40fd54ee6b0189d5984e209b4082dc1">TcaRouter::TCA_ROUTER</a>);
<a name="l00069"></a>00069     }
<a name="l00070"></a>00070     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(type, <span class="stringliteral">"tca_gateway"</span>)) {
<a name="l00071"></a>00071         <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classdtn_1_1TcaRouter.html" title="This is the implementation of the TCA bundle routing algorithm.">TcaRouter</a>(<a class="code" href="classdtn_1_1TcaRouter.html#7937c9ef257ad4c0d45e44947ed48b24aa6e45693173fd8231cbdcd4a6d3c6b9">TcaRouter::TCA_GATEWAY</a>);
<a name="l00072"></a>00072     }
<a name="l00073"></a>00073 <span class="preprocessor">#if defined(XERCES_C_ENABLED) &amp;&amp; defined(EXTERNAL_DP_ENABLED)</span>
<a name="l00074"></a>00074 <span class="preprocessor"></span>    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(type, <span class="stringliteral">"external"</span>) == 0) {
<a name="l00075"></a>00075         <span class="keywordflow">return</span> <span class="keyword">new</span> ExternalRouter();
<a name="l00076"></a>00076     }    
<a name="l00077"></a>00077 <span class="preprocessor">#endif</span>
<a name="l00078"></a>00078 <span class="preprocessor"></span>    <span class="keywordflow">else</span> {
<a name="l00079"></a>00079         PANIC(<span class="stringliteral">"unknown type %s for router"</span>, type);
<a name="l00080"></a>00080     }
<a name="l00081"></a>00081 }
<a name="l00082"></a>00082 
<a name="l00083"></a>00083 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00084"></a><a class="code" href="classdtn_1_1BundleRouter.html#372135e06860e84c440fd9ee02253ea8">00084</a> <a class="code" href="classdtn_1_1BundleRouter.html#372135e06860e84c440fd9ee02253ea8" title="Constructor.">BundleRouter::BundleRouter</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* classname, <span class="keyword">const</span> std::string&amp; name)
<a name="l00085"></a>00085     : <a class="code" href="classdtn_1_1BundleEventHandler.html" title="Both the BundleDaemon and all the BundleRouter classes need to process the various...">BundleEventHandler</a>(classname, <span class="stringliteral">"/dtn/route"</span>),
<a name="l00086"></a>00086       name_(name)
<a name="l00087"></a>00087 {
<a name="l00088"></a>00088     logpathf(<span class="stringliteral">"/dtn/route/%s"</span>, name.c_str());
<a name="l00089"></a>00089     
<a name="l00090"></a>00090     <a class="code" href="classdtn_1_1BundleRouter.html#cf71e3f1982b36bafa7ac5cd45d38675" title="The actions interface, set by the BundleDaemon when the router is initialized.">actions_</a> = BundleDaemon::instance()-&gt;actions();
<a name="l00091"></a>00091     
<a name="l00092"></a>00092     <span class="comment">// XXX/demmer maybe change this?</span>
<a name="l00093"></a>00093     <a class="code" href="classdtn_1_1BundleRouter.html#06ef6e02e26e9a78a9d15619810d56dc" title="The list of all bundles still pending delivery.">pending_bundles_</a> = BundleDaemon::instance()-&gt;pending_bundles();
<a name="l00094"></a>00094     <a class="code" href="classdtn_1_1BundleRouter.html#c37671a1e74edfb709e0b0d3ca9ed2d9" title="The list of all bundles that I have custody of.">custody_bundles_</a> = BundleDaemon::instance()-&gt;custody_bundles();
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096 
<a name="l00097"></a>00097 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00098"></a>00098 <span class="keywordtype">bool</span>
<a name="l00099"></a><a class="code" href="classdtn_1_1BundleRouter.html#b30e99f427cc0526fce08b77e0ae95c7">00099</a> <a class="code" href="classdtn_1_1BundleRouter.html#b30e99f427cc0526fce08b77e0ae95c7" title="Check if the bundle should be forwarded to the given next hop.">BundleRouter::should_fwd</a>(<span class="keyword">const</span> <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; link,
<a name="l00100"></a>00100                          <a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b5947" title="The forwarding action type codes.">ForwardingInfo::action_t</a> action)
<a name="l00101"></a>00101 {
<a name="l00102"></a>00102     <a class="code" href="classdtn_1_1ForwardingInfo.html" title="Class to encapsulate bundle forwarding information.">ForwardingInfo</a> <a class="code" href="dtncat_8c.html#71f51a2e8cbe9a53031fa72596edc09f">info</a>;
<a name="l00103"></a>00103     <span class="keywordtype">bool</span> found = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#249ac137ef76e253d8e0587f2662bca7" title="Accessors.">fwdlog</a>()-&gt;<a class="code" href="classdtn_1_1ForwardingLog.html#57192cc969b46bc646ae411a8d7c27ee" title="Get the most recent entry for the given link from the log.">get_latest_entry</a>(link, &amp;info);
<a name="l00104"></a>00104 
<a name="l00105"></a>00105     <span class="keywordflow">if</span> (found) {
<a name="l00106"></a>00106         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(info.<a class="code" href="classdtn_1_1ForwardingInfo.html#9c2aa7be84c9b1f5a81d1cc19445dd53" title="Accessors.">state</a>() != <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fadb3e7fba25df11c3fce5b5a88300b0ac6" title="Return value for no entry.">ForwardingInfo::NONE</a>);
<a name="l00107"></a>00107     } <span class="keywordflow">else</span> {
<a name="l00108"></a>00108         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(info.<a class="code" href="classdtn_1_1ForwardingInfo.html#9c2aa7be84c9b1f5a81d1cc19445dd53" title="Accessors.">state</a>() == <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fadb3e7fba25df11c3fce5b5a88300b0ac6" title="Return value for no entry.">ForwardingInfo::NONE</a>);
<a name="l00109"></a>00109     }
<a name="l00110"></a>00110 
<a name="l00111"></a>00111     <span class="comment">// check if we've already sent or are in the process of sending</span>
<a name="l00112"></a>00112     <span class="comment">// the bundle on this link</span>
<a name="l00113"></a>00113     <span class="keywordflow">if</span> (info.<a class="code" href="classdtn_1_1ForwardingInfo.html#9c2aa7be84c9b1f5a81d1cc19445dd53" title="Accessors.">state</a>() == <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad4222cd2abd08c71c5b5387cf23ca6193" title="Successfully transmitted.">ForwardingInfo::TRANSMITTED</a> ||
<a name="l00114"></a>00114         info.<a class="code" href="classdtn_1_1ForwardingInfo.html#9c2aa7be84c9b1f5a81d1cc19445dd53" title="Accessors.">state</a>() == <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fade904c54b91c284fb69c0e6f6acccc99b" title="Currently queued or being sent.">ForwardingInfo::QUEUED</a>)
<a name="l00115"></a>00115     {
<a name="l00116"></a>00116         log_debug(<span class="stringliteral">"should_fwd bundle %d: "</span>
<a name="l00117"></a>00117                   <span class="stringliteral">"skip %s due to forwarding log entry %s"</span>,
<a name="l00118"></a>00118                   bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), link-&gt;name(),
<a name="l00119"></a>00119                   <a class="code" href="classdtn_1_1ForwardingInfo.html#9493021a5f38f38139a1fd5b7d0f631e">ForwardingInfo::state_to_str</a>(info.<a class="code" href="classdtn_1_1ForwardingInfo.html#9c2aa7be84c9b1f5a81d1cc19445dd53" title="Accessors.">state</a>()));
<a name="l00120"></a>00120         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00121"></a>00121     }
<a name="l00122"></a>00122 
<a name="l00123"></a>00123     <span class="comment">// check if we've already sent or are in the process of sending</span>
<a name="l00124"></a>00124     <span class="comment">// the bundle to the node via some other link</span>
<a name="l00125"></a>00125     <span class="keywordflow">if</span> (link-&gt;remote_eid() != <a class="code" href="classdtn_1_1EndpointID.html#31bd1844cae5e71cc2393a139c9bec4c" title="Return the special endpoint id used for the null endpoint, namely &amp;quot;dtn:none&amp;quot;...">EndpointID::NULL_EID</a>())
<a name="l00126"></a>00126     {
<a name="l00127"></a>00127         <span class="keywordtype">size_t</span> <a class="code" href="dtnping_8c.html#d43c3812e6d13e0518d9f8b8f463ffcf">count</a> = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#249ac137ef76e253d8e0587f2662bca7" title="Accessors.">fwdlog</a>()-&gt;<a class="code" href="classdtn_1_1ForwardingLog.html#afa0e50bb2cd435df9f883db9f8e2f20" title="Return the count of matching entries.">get_count</a>(
<a name="l00128"></a>00128             link-&gt;remote_eid(),
<a name="l00129"></a>00129             <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad4222cd2abd08c71c5b5387cf23ca6193" title="Successfully transmitted.">ForwardingInfo::TRANSMITTED</a> | <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fade904c54b91c284fb69c0e6f6acccc99b" title="Currently queued or being sent.">ForwardingInfo::QUEUED</a>);
<a name="l00130"></a>00130         
<a name="l00131"></a>00131         <span class="keywordflow">if</span> (count &gt; 0)
<a name="l00132"></a>00132         {
<a name="l00133"></a>00133             log_debug(<span class="stringliteral">"should_fwd bundle %d: "</span>
<a name="l00134"></a>00134                       <span class="stringliteral">"skip %s since already sent or queued %zu times for remote eid %s"</span>,
<a name="l00135"></a>00135                       bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), link-&gt;name(),
<a name="l00136"></a>00136                       count, link-&gt;remote_eid().c_str());
<a name="l00137"></a>00137             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00138"></a>00138         }
<a name="l00139"></a>00139 
<a name="l00140"></a>00140         <span class="comment">// check whether transmission was suppressed. this could be</span>
<a name="l00141"></a>00141         <span class="comment">// coupled with the previous one but it's better to have a</span>
<a name="l00142"></a>00142         <span class="comment">// separate log message</span>
<a name="l00143"></a>00143         count = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#249ac137ef76e253d8e0587f2662bca7" title="Accessors.">fwdlog</a>()-&gt;<a class="code" href="classdtn_1_1ForwardingLog.html#afa0e50bb2cd435df9f883db9f8e2f20" title="Return the count of matching entries.">get_count</a>(
<a name="l00144"></a>00144             link-&gt;remote_eid(),
<a name="l00145"></a>00145             <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad7e404e025c65c3b35345a69533ce48a1" title="Transmission suppressed.">ForwardingInfo::SUPPRESSED</a>);
<a name="l00146"></a>00146         
<a name="l00147"></a>00147         <span class="keywordflow">if</span> (count &gt; 0)
<a name="l00148"></a>00148         {
<a name="l00149"></a>00149             log_debug(<span class="stringliteral">"should_fwd bundle %d: "</span>
<a name="l00150"></a>00150                       <span class="stringliteral">"skip %s since transmission suppressed to remote eid %s"</span>,
<a name="l00151"></a>00151                       bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), link-&gt;name(),
<a name="l00152"></a>00152                       link-&gt;remote_eid().c_str());
<a name="l00153"></a>00153             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00154"></a>00154         }
<a name="l00155"></a>00155     }
<a name="l00156"></a>00156     
<a name="l00157"></a>00157     <span class="comment">// if the bundle has a a singleton destination endpoint, then</span>
<a name="l00158"></a>00158     <span class="comment">// check if we already forwarded it or are planning to forward it</span>
<a name="l00159"></a>00159     <span class="comment">// somewhere else. if so, we shouldn't forward it again</span>
<a name="l00160"></a>00160     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#d6ce915f55f1dcf670575642e10f6419" title="Accessors.">singleton_dest</a>() &amp;&amp; action == <a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b59471efad47dbf6015f5e4458ac355eabbaa" title="Forward the bundle to only this next hop.">ForwardingInfo::FORWARD_ACTION</a>)
<a name="l00161"></a>00161     {
<a name="l00162"></a>00162         <span class="keywordtype">size_t</span> <a class="code" href="dtnping_8c.html#d43c3812e6d13e0518d9f8b8f463ffcf">count</a> = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#249ac137ef76e253d8e0587f2662bca7" title="Accessors.">fwdlog</a>()-&gt;<a class="code" href="classdtn_1_1ForwardingLog.html#afa0e50bb2cd435df9f883db9f8e2f20" title="Return the count of matching entries.">get_count</a>(
<a name="l00163"></a>00163             <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad4222cd2abd08c71c5b5387cf23ca6193" title="Successfully transmitted.">ForwardingInfo::TRANSMITTED</a> |
<a name="l00164"></a>00164             <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fade904c54b91c284fb69c0e6f6acccc99b" title="Currently queued or being sent.">ForwardingInfo::QUEUED</a>,
<a name="l00165"></a>00165             action);
<a name="l00166"></a>00166 
<a name="l00167"></a>00167         <span class="keywordflow">if</span> (count &gt; 0) {
<a name="l00168"></a>00168             log_debug(<span class="stringliteral">"should_fwd bundle %d: "</span>
<a name="l00169"></a>00169                       <span class="stringliteral">"skip %s since already transmitted or queued (count %zu)"</span>,
<a name="l00170"></a>00170                       bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), link-&gt;name(), count);
<a name="l00171"></a>00171             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00172"></a>00172         } <span class="keywordflow">else</span> {
<a name="l00173"></a>00173             log_debug(<span class="stringliteral">"should_fwd bundle %d: "</span>
<a name="l00174"></a>00174                       <span class="stringliteral">"link %s ok since transmission count=%zu"</span>,
<a name="l00175"></a>00175                       bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), link-&gt;name(), count);
<a name="l00176"></a>00176         }
<a name="l00177"></a>00177     }
<a name="l00178"></a>00178 
<a name="l00179"></a>00179     <span class="comment">// otherwise log the reason why we should send it</span>
<a name="l00180"></a>00180     log_debug(<span class="stringliteral">"should_fwd bundle %d: "</span>
<a name="l00181"></a>00181               <span class="stringliteral">"match %s: forwarding log entry %s"</span>,
<a name="l00182"></a>00182               bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), link-&gt;name(),
<a name="l00183"></a>00183               <a class="code" href="classdtn_1_1ForwardingInfo.html#9493021a5f38f38139a1fd5b7d0f631e">ForwardingInfo::state_to_str</a>(info.<a class="code" href="classdtn_1_1ForwardingInfo.html#9c2aa7be84c9b1f5a81d1cc19445dd53" title="Accessors.">state</a>()));
<a name="l00184"></a>00184 
<a name="l00185"></a>00185     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00186"></a>00186 }
<a name="l00187"></a>00187 
<a name="l00188"></a>00188 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00189"></a>00189 <span class="keywordtype">void</span>
<a name="l00190"></a><a class="code" href="classdtn_1_1BundleRouter.html#58bdadd6a5f618d44cd4c2084acc707c">00190</a> <a class="code" href="classdtn_1_1BundleRouter.html#58bdadd6a5f618d44cd4c2084acc707c">BundleRouter::initialize</a>()
<a name="l00191"></a>00191 {
<a name="l00192"></a>00192 }
<a name="l00193"></a>00193 
<a name="l00194"></a>00194 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00195"></a><a class="code" href="classdtn_1_1BundleRouter.html#ab8365216a5adc94dbdb8f5adc9c18f8">00195</a> <a class="code" href="classdtn_1_1BundleRouter.html#ab8365216a5adc94dbdb8f5adc9c18f8" title="Destructor.">BundleRouter::~BundleRouter</a>()
<a name="l00196"></a>00196 {
<a name="l00197"></a>00197 }
<a name="l00198"></a>00198 
<a name="l00199"></a>00199 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00200"></a>00200 <span class="keywordtype">bool</span>
<a name="l00201"></a><a class="code" href="classdtn_1_1BundleRouter.html#47afbf9e1c42ae2cfb396c3895ddca45">00201</a> <a class="code" href="classdtn_1_1BundleRouter.html#47afbf9e1c42ae2cfb396c3895ddca45" title="Synchronous probe indicating whether or not this bundle should be accepted by the...">BundleRouter::accept_bundle</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <span class="keywordtype">int</span>* errp)
<a name="l00202"></a>00202 {
<a name="l00203"></a>00203     <span class="comment">// XXX/demmer this decision should be abstracted into a</span>
<a name="l00204"></a>00204     <span class="comment">// StoragePolicy class of some sort. for now just use a</span>
<a name="l00205"></a>00205     <span class="comment">// statically-configured payload limit</span>
<a name="l00206"></a>00206     <a class="code" href="classdtn_1_1BundleStore.html" title="The class for bundle storage is an instantiation of an oasys durable table to store...">BundleStore</a>* bs = BundleStore::instance();
<a name="l00207"></a>00207     <span class="keywordflow">if</span> (bs-&gt;<a class="code" href="classdtn_1_1BundleStore.html#8a503100de1f9c00d38fa66aebd78da1" title="Accessors.">payload_quota</a>() != 0 &amp;&amp;
<a name="l00208"></a>00208         (bs-&gt;<a class="code" href="classdtn_1_1BundleStore.html#b360ea44c0fbb86453a1b53174154ddb" title="Accessors.">total_size</a>() + bundle-&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>() &gt; bs-&gt;<a class="code" href="classdtn_1_1BundleStore.html#8a503100de1f9c00d38fa66aebd78da1" title="Accessors.">payload_quota</a>()))
<a name="l00209"></a>00209     {
<a name="l00210"></a>00210         log_info(<span class="stringliteral">"accept_bundle: rejecting bundle *%p since "</span>
<a name="l00211"></a>00211                  <span class="stringliteral">"cur size %llu + bundle size %zu &gt; quota %llu"</span>,
<a name="l00212"></a>00212                  bundle, U64FMT(bs-&gt;<a class="code" href="classdtn_1_1BundleStore.html#b360ea44c0fbb86453a1b53174154ddb" title="Accessors.">total_size</a>()), bundle-&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="l00213"></a>00213                  U64FMT(bs-&gt;<a class="code" href="classdtn_1_1BundleStore.html#8a503100de1f9c00d38fa66aebd78da1" title="Accessors.">payload_quota</a>()));
<a name="l00214"></a>00214         *errp = <a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f9176e886c084e3e545573e435ef04760c1a">BundleProtocol::REASON_DEPLETED_STORAGE</a>;
<a name="l00215"></a>00215         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00216"></a>00216     } 
<a name="l00217"></a>00217 
<a name="l00218"></a>00218     *errp = 0;
<a name="l00219"></a>00219     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00220"></a>00220 }
<a name="l00221"></a>00221 
<a name="l00222"></a>00222 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00223"></a>00223 <span class="keywordtype">bool</span>
<a name="l00224"></a><a class="code" href="classdtn_1_1BundleRouter.html#50702bb5cf9c4e2b9be0a7b452c94629">00224</a> <a class="code" href="classdtn_1_1BundleRouter.html#50702bb5cf9c4e2b9be0a7b452c94629" title="Synchronous probe indicating whether or not this bundle can be deleted by the system...">BundleRouter::can_delete_bundle</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; bundle)
<a name="l00225"></a>00225 {
<a name="l00226"></a>00226     <span class="keywordtype">size_t</span> num_mappings = bundle-&gt;num_mappings();
<a name="l00227"></a>00227     <span class="keywordflow">if</span> (num_mappings &gt; 1) {
<a name="l00228"></a>00228         log_debug(<span class="stringliteral">"can_delete_bundle(*%p): not deleting because "</span>
<a name="l00229"></a>00229                   <span class="stringliteral">"bundle has %zu list mappings"</span>,
<a name="l00230"></a>00230                   bundle.object(), num_mappings);
<a name="l00231"></a>00231         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00232"></a>00232     }
<a name="l00233"></a>00233     
<a name="l00234"></a>00234     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00235"></a>00235 }
<a name="l00236"></a>00236 
<a name="l00237"></a>00237 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00238"></a>00238 <span class="keywordtype">void</span>
<a name="l00239"></a><a class="code" href="classdtn_1_1BundleRouter.html#4e48a822cf5f7b143cf641d26a12091f">00239</a> <a class="code" href="classdtn_1_1BundleRouter.html#4e48a822cf5f7b143cf641d26a12091f" title="Synchronous call indicating that the bundle is being deleted from the system and...">BundleRouter::delete_bundle</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; bundle)
<a name="l00240"></a>00240 {
<a name="l00241"></a>00241     (void)bundle;
<a name="l00242"></a>00242 }
<a name="l00243"></a>00243 
<a name="l00244"></a>00244 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00245"></a>00245 <span class="keywordtype">void</span>
<a name="l00246"></a><a class="code" href="classdtn_1_1BundleRouter.html#2083fea1b1c69c671626c6e71ef78d5d">00246</a> <a class="code" href="classdtn_1_1BundleRouter.html#2083fea1b1c69c671626c6e71ef78d5d" title="Format the given StringBuffer with a tcl-parsable version of the routing state.">BundleRouter::tcl_dump_state</a>(oasys::StringBuffer* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>)
<a name="l00247"></a>00247 {
<a name="l00248"></a>00248     buf-&gt;append(<span class="stringliteral">"{}"</span>);
<a name="l00249"></a>00249 }
<a name="l00250"></a>00250 
<a name="l00251"></a>00251 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00252"></a>00252 <span class="keywordtype">void</span>
<a name="l00253"></a><a class="code" href="classdtn_1_1BundleRouter.html#b679ffe5062b9bbc936b0e6dd7c6d834">00253</a> <a class="code" href="classdtn_1_1BundleRouter.html#b679ffe5062b9bbc936b0e6dd7c6d834" title="Hook to force route recomputation from the command interpreter.">BundleRouter::recompute_routes</a>()
<a name="l00254"></a>00254 {
<a name="l00255"></a>00255 }
<a name="l00256"></a>00256 
<a name="l00257"></a>00257 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00258"></a>00258 <span class="keywordtype">void</span>
<a name="l00259"></a><a class="code" href="classdtn_1_1BundleRouter.html#0862b94502efe0e65fc1a7020532ba96">00259</a> <a class="code" href="classdtn_1_1BundleRouter.html#0862b94502efe0e65fc1a7020532ba96" title="for registration with the BundleDaemon">BundleRouter::shutdown</a>()
<a name="l00260"></a>00260 {
<a name="l00261"></a>00261 }
<a name="l00262"></a>00262 
<a name="l00263"></a>00263 } <span class="comment">// namespace dtn</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:53 2009 for DTN Reference Implementation by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>