Sophie

Sophie

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

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: BundleDaemon.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>BundleDaemon.cc</h1><a href="BundleDaemon_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;oasys/io/IO.h&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;oasys/tclcmd/TclCommand.h&gt;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;oasys/util/Time.h&gt;</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="bundling_2Bundle_8h.html">Bundle.h</a>"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="BundleActions_8h.html">BundleActions.h</a>"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="BundleEvent_8h.html">BundleEvent.h</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="BundleDaemon_8h.html">BundleDaemon.h</a>"</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="BundleStatusReport_8h.html">BundleStatusReport.h</a>"</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="BundleTimestamp_8h.html">BundleTimestamp.h</a>"</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="CustodySignal_8h.html">CustodySignal.h</a>"</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="ExpirationTimer_8h.html">ExpirationTimer.h</a>"</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="FragmentManager_8h.html">FragmentManager.h</a>"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="contacts_2Link_8h.html">contacts/Link.h</a>"</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include "<a class="code" href="Contact_8h.html">contacts/Contact.h</a>"</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include "<a class="code" href="ContactManager_8h.html">contacts/ContactManager.h</a>"</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include "<a class="code" href="ConvergenceLayer_8h.html">conv_layers/ConvergenceLayer.h</a>"</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include "<a class="code" href="AdminRegistration_8h.html">reg/AdminRegistration.h</a>"</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include "<a class="code" href="APIRegistration_8h.html">reg/APIRegistration.h</a>"</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include "<a class="code" href="PingRegistration_8h.html">reg/PingRegistration.h</a>"</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include "<a class="code" href="Registration_8h.html">reg/Registration.h</a>"</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include "<a class="code" href="RegistrationTable_8h.html">reg/RegistrationTable.h</a>"</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include "<a class="code" href="BundleRouter_8h.html">routing/BundleRouter.h</a>"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "<a class="code" href="RouteTable_8h.html">routing/RouteTable.h</a>"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "<a class="code" href="Session_8h.html">session/Session.h</a>"</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include "<a class="code" href="BundleStore_8h.html">storage/BundleStore.h</a>"</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include "<a class="code" href="RegistrationStore_8h.html">storage/RegistrationStore.h</a>"</span>
<a name="l00048"></a>00048 
<a name="l00049"></a>00049 <span class="preprocessor">#ifdef BSP_ENABLED</span>
<a name="l00050"></a>00050 <span class="preprocessor"></span><span class="preprocessor">#  include "<a class="code" href="Ciphersuite_8h.html">security/Ciphersuite.h</a>"</span>
<a name="l00051"></a>00051 <span class="preprocessor">#  include "<a class="code" href="SPD_8h.html">security/SPD.h</a>"</span>
<a name="l00052"></a>00052 <span class="preprocessor">#  include "<a class="code" href="KeyDB_8h.html">security/KeyDB.h</a>"</span>
<a name="l00053"></a>00053 <span class="preprocessor">#endif</span>
<a name="l00054"></a>00054 <span class="preprocessor"></span>
<a name="l00055"></a>00055 <span class="keyword">namespace </span>dtn {
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 <span class="keyword">template</span> &lt;&gt;
<a name="l00058"></a>00058 BundleDaemon* oasys::Singleton&lt;BundleDaemon, false&gt;::instance_ = NULL;
<a name="l00059"></a>00059 
<a name="l00060"></a><a class="code" href="structdtn_1_1BundleDaemon_1_1Params.html#7d8d69e0ac04f00371dc4a9d76884ad4">00060</a> <a class="code" href="structdtn_1_1BundleDaemon_1_1Params.html#7d8d69e0ac04f00371dc4a9d76884ad4" title="Default constructor.">BundleDaemon::Params::Params</a>()
<a name="l00061"></a>00061     :  early_deletion_(true),
<a name="l00062"></a>00062        suppress_duplicates_(true),
<a name="l00063"></a>00063        accept_custody_(true),
<a name="l00064"></a>00064        reactive_frag_enabled_(true),
<a name="l00065"></a>00065        retry_reliable_unacked_(true),
<a name="l00066"></a>00066        test_permuted_delivery_(false),
<a name="l00067"></a>00067        injected_bundles_in_memory_(false) {}
<a name="l00068"></a>00068 
<a name="l00069"></a>00069 <a class="code" href="structdtn_1_1BundleDaemon_1_1Params.html" title="General daemon parameters.">BundleDaemon::Params</a> <a class="code" href="classdtn_1_1BundleDaemon.html#a18fd65ff3e11b985f3e04a4591d4a33">BundleDaemon::params_</a>;
<a name="l00070"></a>00070 
<a name="l00071"></a>00071 <span class="keywordtype">bool</span> <a class="code" href="classdtn_1_1BundleDaemon.html#ec3feb2dfa92fc492da5d5e1b85641df">BundleDaemon::shutting_down_</a> = <span class="keyword">false</span>;
<a name="l00072"></a>00072 
<a name="l00073"></a>00073 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00074"></a><a class="code" href="classdtn_1_1BundleDaemon.html#e9228d805e49a4c79603b3bf411cfbb6">00074</a> <a class="code" href="classdtn_1_1BundleDaemon.html#e9228d805e49a4c79603b3bf411cfbb6" title="Constructor.">BundleDaemon::BundleDaemon</a>()
<a name="l00075"></a>00075     : <a class="code" href="classdtn_1_1BundleEventHandler.html" title="Both the BundleDaemon and all the BundleRouter classes need to process the various...">BundleEventHandler</a>(<span class="stringliteral">"BundleDaemon"</span>, <span class="stringliteral">"/dtn/bundle/daemon"</span>),
<a name="l00076"></a>00076       Thread(<span class="stringliteral">"BundleDaemon"</span>, CREATE_JOINABLE)
<a name="l00077"></a>00077 {
<a name="l00078"></a>00078     <span class="comment">// default local eid</span>
<a name="l00079"></a>00079     <a class="code" href="classdtn_1_1BundleDaemon.html#bb461f7084ac3cf8c88ecff1a2686bcf" title="The default endpoint id for reaching this daemon, used for bundle status reports...">local_eid_</a>.<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(<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="l00080"></a>00080 
<a name="l00081"></a>00081     <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a> = NULL;
<a name="l00082"></a>00082     <a class="code" href="classdtn_1_1BundleDaemon.html#4c63dbe82dd1b3692d9748a32c859373" title="The event queue.">eventq_</a> = NULL;
<a name="l00083"></a>00083     
<a name="l00084"></a>00084     memset(&amp;<a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>));
<a name="l00085"></a>00085 
<a name="l00086"></a>00086     <a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleList.html" title="List structure for handling bundles.">BundleList</a>(<span class="stringliteral">"pending_bundles"</span>);
<a name="l00087"></a>00087     <a class="code" href="classdtn_1_1BundleDaemon.html#ce140ab25aea62199a71e73e216845a5" title="The list of all bundles that we have custody of.">custody_bundles_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleList.html" title="List structure for handling bundles.">BundleList</a>(<span class="stringliteral">"custody_bundles"</span>);
<a name="l00088"></a>00088 
<a name="l00089"></a>00089     <a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1ContactManager.html" title="A contact manager class.">ContactManager</a>();
<a name="l00090"></a>00090     <a class="code" href="classdtn_1_1BundleDaemon.html#a0a2294a38635f5f76aba4375b0c2f7d" title="The fragmentation / reassembly manager.">fragmentmgr_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1FragmentManager.html" title="The Fragment Manager maintains state for all of the fragmentary bundles, reconstructing...">FragmentManager</a>();
<a name="l00091"></a>00091     <a class="code" href="classdtn_1_1BundleDaemon.html#f0b116c3ae390f0032049f376e3a2eec" title="The table of active registrations.">reg_table_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1RegistrationTable.html" title="Class for the in-memory registration table.">RegistrationTable</a>();
<a name="l00092"></a>00092 
<a name="l00093"></a>00093     <a class="code" href="classdtn_1_1BundleDaemon.html#a5c8a244aad225987f9359ee1c2a1101" title="The active bundle router.">router_</a> = 0;
<a name="l00094"></a>00094 
<a name="l00095"></a>00095     <a class="code" href="classdtn_1_1BundleDaemon.html#ce01f407e72ff90efcd71004b36ed3a9" title="Application-specific shutdown handler.">app_shutdown_proc_</a> = NULL;
<a name="l00096"></a>00096     <a class="code" href="classdtn_1_1BundleDaemon.html#c6d3f649a1ac5650fc773106ea51361a" title="Application-specific shutdown data.">app_shutdown_data_</a> = NULL;
<a name="l00097"></a>00097 
<a name="l00098"></a>00098     <a class="code" href="classdtn_1_1BundleDaemon.html#2151ed3edaa2c4e54742d9c281d29b07" title="Router-specific shutdown handler.">rtr_shutdown_proc_</a> = 0;
<a name="l00099"></a>00099     <a class="code" href="classdtn_1_1BundleDaemon.html#74bca9e084aa2faab5a9aba4fbb5ed23" title="Router-specific shutdown data.">rtr_shutdown_data_</a> = 0;
<a name="l00100"></a>00100 }
<a name="l00101"></a>00101 
<a name="l00102"></a>00102 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00103"></a><a class="code" href="classdtn_1_1BundleDaemon.html#31f79197d40a3aa8a47647bd72184dc2">00103</a> <a class="code" href="classdtn_1_1BundleDaemon.html#31f79197d40a3aa8a47647bd72184dc2" title="Destructor (called at shutdown time).">BundleDaemon::~BundleDaemon</a>()
<a name="l00104"></a>00104 {
<a name="l00105"></a>00105     <span class="keyword">delete</span> <a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>;
<a name="l00106"></a>00106     <span class="keyword">delete</span> <a class="code" href="classdtn_1_1BundleDaemon.html#ce140ab25aea62199a71e73e216845a5" title="The list of all bundles that we have custody of.">custody_bundles_</a>;
<a name="l00107"></a>00107     
<a name="l00108"></a>00108     <span class="keyword">delete</span> <a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>;
<a name="l00109"></a>00109     <span class="keyword">delete</span> <a class="code" href="classdtn_1_1BundleDaemon.html#a0a2294a38635f5f76aba4375b0c2f7d" title="The fragmentation / reassembly manager.">fragmentmgr_</a>;
<a name="l00110"></a>00110     <span class="keyword">delete</span> <a class="code" href="classdtn_1_1BundleDaemon.html#f0b116c3ae390f0032049f376e3a2eec" title="The table of active registrations.">reg_table_</a>;
<a name="l00111"></a>00111     <span class="keyword">delete</span> <a class="code" href="classdtn_1_1BundleDaemon.html#a5c8a244aad225987f9359ee1c2a1101" title="The active bundle router.">router_</a>;
<a name="l00112"></a>00112 
<a name="l00113"></a>00113     <span class="keyword">delete</span> <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a>;
<a name="l00114"></a>00114     <span class="keyword">delete</span> <a class="code" href="classdtn_1_1BundleDaemon.html#4c63dbe82dd1b3692d9748a32c859373" title="The event queue.">eventq_</a>;
<a name="l00115"></a>00115 }
<a name="l00116"></a>00116 
<a name="l00117"></a>00117 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00118"></a>00118 <span class="keywordtype">void</span>
<a name="l00119"></a><a class="code" href="classdtn_1_1BundleDaemon.html#a4b439cac8064f409fdc44667c75cb54">00119</a> <a class="code" href="classdtn_1_1BundleDaemon.html#a4b439cac8064f409fdc44667c75cb54" title="Virtual initialization function, overridden in the simulator to install the modified...">BundleDaemon::do_init</a>()
<a name="l00120"></a>00120 {
<a name="l00121"></a>00121     <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleDaemon.html#e81b8ce094725bbc983ec42961d8032e">BundleActions</a>();
<a name="l00122"></a>00122     <a class="code" href="classdtn_1_1BundleDaemon.html#4c63dbe82dd1b3692d9748a32c859373" title="The event queue.">eventq_</a> = <span class="keyword">new</span> oasys::MsgQueue&lt;BundleEvent*&gt;(logpath_);
<a name="l00123"></a>00123     <a class="code" href="classdtn_1_1BundleDaemon.html#4c63dbe82dd1b3692d9748a32c859373" title="The event queue.">eventq_</a>-&gt;notify_when_empty();
<a name="l00124"></a>00124     <a class="code" href="classdtn_1_1BundleProtocol.html#6aa13dcc0ae96b1b832970c3f71678be" title="Initialize the default set of block processors.">BundleProtocol::init_default_processors</a>();
<a name="l00125"></a>00125 <span class="preprocessor">#ifdef BSP_ENABLED</span>
<a name="l00126"></a>00126 <span class="preprocessor"></span>    Ciphersuite::init_default_ciphersuites();
<a name="l00127"></a>00127     <a class="code" href="classdtn_1_1BundleDaemon.html#0bf8ed74f59296b161f18a1b289c6548" title="Boot time initializer.">SPD::init</a>();
<a name="l00128"></a>00128     <a class="code" href="classdtn_1_1BundleDaemon.html#0bf8ed74f59296b161f18a1b289c6548" title="Boot time initializer.">KeyDB::init</a>();
<a name="l00129"></a>00129 <span class="preprocessor">#endif</span>
<a name="l00130"></a>00130 <span class="preprocessor"></span>}
<a name="l00131"></a>00131 
<a name="l00132"></a>00132 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00133"></a>00133 <span class="keywordtype">void</span>
<a name="l00134"></a><a class="code" href="classdtn_1_1BundleDaemon.html#370a80f7dd9fd9297e76d7f830d737a8">00134</a> <a class="code" href="classdtn_1_1BundleDaemon.html#370a80f7dd9fd9297e76d7f830d737a8" title="Queues the event at the tail of the queue for processing by the daemon thread.">BundleDaemon::post</a>(<a class="code" href="classdtn_1_1BundleEvent.html" title="Event base class.">BundleEvent</a>* event)
<a name="l00135"></a>00135 {
<a name="l00136"></a>00136     instance_-&gt;post_event(event);
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138 
<a name="l00139"></a>00139 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00140"></a>00140 <span class="keywordtype">void</span>
<a name="l00141"></a><a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686">00141</a> <a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686" title="Queues the event at the head of the queue for processing by the daemon thread.">BundleDaemon::post_at_head</a>(<a class="code" href="classdtn_1_1BundleEvent.html" title="Event base class.">BundleEvent</a>* event)
<a name="l00142"></a>00142 {
<a name="l00143"></a>00143     instance_-&gt;post_event(event, <span class="keyword">false</span>);
<a name="l00144"></a>00144 }
<a name="l00145"></a>00145 
<a name="l00146"></a>00146 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00147"></a>00147 <span class="keywordtype">bool</span>
<a name="l00148"></a><a class="code" href="classdtn_1_1BundleDaemon.html#bb88ebba32e4e95a96ee76b3f91d9052">00148</a> <a class="code" href="classdtn_1_1BundleDaemon.html#bb88ebba32e4e95a96ee76b3f91d9052" title="Post the given event and wait for it to be processed by the daemon thread or for...">BundleDaemon::post_and_wait</a>(<a class="code" href="classdtn_1_1BundleEvent.html" title="Event base class.">BundleEvent</a>* event,
<a name="l00149"></a>00149                             oasys::Notifier* notifier,
<a name="l00150"></a>00150                             <span class="keywordtype">int</span> timeout, <span class="keywordtype">bool</span> at_back)
<a name="l00151"></a>00151 {
<a name="l00152"></a>00152     <span class="comment">/*</span>
<a name="l00153"></a>00153 <span class="comment">     * Make sure that we're either already started up or are about to</span>
<a name="l00154"></a>00154 <span class="comment">     * start. Otherwise the wait call below would block indefinitely.</span>
<a name="l00155"></a>00155 <span class="comment">     */</span>
<a name="l00156"></a>00156     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(! oasys::Thread::start_barrier_enabled());
<a name="l00157"></a>00157     
<a name="l00158"></a>00158     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#41422f59f627162052747049984b3cf6" title="Slot for a notifier to indicate that the event was processed.">processed_notifier_</a> == NULL);
<a name="l00159"></a>00159     <span class="keyword">event</span>-&gt;processed_notifier_ = notifier;
<a name="l00160"></a>00160     <span class="keywordflow">if</span> (at_back) {
<a name="l00161"></a>00161         <a class="code" href="classdtn_1_1BundleDaemon.html#370a80f7dd9fd9297e76d7f830d737a8" title="Queues the event at the tail of the queue for processing by the daemon thread.">post</a>(event);
<a name="l00162"></a>00162     } <span class="keywordflow">else</span> {
<a name="l00163"></a>00163         <a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686" title="Queues the event at the head of the queue for processing by the daemon thread.">post_at_head</a>(event);
<a name="l00164"></a>00164     }
<a name="l00165"></a>00165     <span class="keywordflow">return</span> notifier-&gt;wait(NULL, timeout);
<a name="l00166"></a>00166 }
<a name="l00167"></a>00167 
<a name="l00168"></a>00168 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00169"></a>00169 <span class="keywordtype">void</span>
<a name="l00170"></a><a class="code" href="classdtn_1_1BundleDaemon.html#3c63c969b96224e51d30adef9357f38c">00170</a> <a class="code" href="classdtn_1_1BundleDaemon.html#3c63c969b96224e51d30adef9357f38c" title="Virtual post_event function, overridden by the Node class in the simulator to use...">BundleDaemon::post_event</a>(<a class="code" href="classdtn_1_1BundleEvent.html" title="Event base class.">BundleEvent</a>* event, <span class="keywordtype">bool</span> at_back)
<a name="l00171"></a>00171 {
<a name="l00172"></a>00172     log_debug(<span class="stringliteral">"posting event (%p) with type %s (at %s)"</span>,
<a name="l00173"></a>00173               event, event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#34ad7fcefe5984584fe304fdecc96d4b" title="Used for printing.">type_str</a>(), at_back ? <span class="stringliteral">"back"</span> : <span class="stringliteral">"head"</span>);
<a name="l00174"></a>00174     <span class="keyword">event</span>-&gt;posted_time_.get_time();
<a name="l00175"></a>00175     <a class="code" href="classdtn_1_1BundleDaemon.html#4c63dbe82dd1b3692d9748a32c859373" title="The event queue.">eventq_</a>-&gt;push(event, at_back);
<a name="l00176"></a>00176 }
<a name="l00177"></a>00177 
<a name="l00178"></a>00178 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00179"></a>00179 <span class="keywordtype">void</span>
<a name="l00180"></a><a class="code" href="classdtn_1_1BundleDaemon.html#7f22930edb2b015bfda7c2da7bc940e4">00180</a> <a class="code" href="classdtn_1_1BundleDaemon.html#7f22930edb2b015bfda7c2da7bc940e4" title="Format the given StringBuffer with current routing info.">BundleDaemon::get_routing_state</a>(oasys::StringBuffer* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>)
<a name="l00181"></a>00181 {
<a name="l00182"></a>00182     <a class="code" href="classdtn_1_1BundleDaemon.html#a5c8a244aad225987f9359ee1c2a1101" title="The active bundle router.">router_</a>-&gt;<a class="code" href="classdtn_1_1BundleRouter.html#a0bfd372d2ae8e1c324e6beae5a31573" title="Format the given StringBuffer with current routing info.">get_routing_state</a>(buf);
<a name="l00183"></a>00183     <a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#4c93f54d72238524d5215abbac4138b9" title="Dump a string representation of the info inside contact manager.">dump</a>(buf);
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185 
<a name="l00186"></a>00186 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00187"></a>00187 <span class="keywordtype">void</span>
<a name="l00188"></a><a class="code" href="classdtn_1_1BundleDaemon.html#77bfc10515128e094c60601a5495de42">00188</a> <a class="code" href="classdtn_1_1BundleDaemon.html#77bfc10515128e094c60601a5495de42" title="Format the given StringBuffer with the current bundle statistics.">BundleDaemon::get_bundle_stats</a>(oasys::StringBuffer* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>)
<a name="l00189"></a>00189 {
<a name="l00190"></a>00190     buf-&gt;appendf(<span class="stringliteral">"%zu pending -- "</span>
<a name="l00191"></a>00191                  <span class="stringliteral">"%zu custody -- "</span>
<a name="l00192"></a>00192                  <span class="stringliteral">"%u received -- "</span>
<a name="l00193"></a>00193                  <span class="stringliteral">"%u delivered -- "</span>
<a name="l00194"></a>00194                  <span class="stringliteral">"%u generated -- "</span>
<a name="l00195"></a>00195                  <span class="stringliteral">"%u transmitted -- "</span>
<a name="l00196"></a>00196                  <span class="stringliteral">"%u expired -- "</span>
<a name="l00197"></a>00197                  <span class="stringliteral">"%u duplicate -- "</span>
<a name="l00198"></a>00198                  <span class="stringliteral">"%u deleted -- "</span>
<a name="l00199"></a>00199                  <span class="stringliteral">"%u injected"</span>,
<a name="l00200"></a>00200                  <a class="code" href="classdtn_1_1BundleDaemon.html#99030fd37a2c2b727b5e6c64962d6709" title="Accessor for the pending bundles list.">pending_bundles</a>()-&gt;size(),
<a name="l00201"></a>00201                  <a class="code" href="classdtn_1_1BundleDaemon.html#31a9fb9e637b0dfcf80d7e333ac5381d" title="Accessor for the custody bundles list.">custody_bundles</a>()-&gt;size(),
<a name="l00202"></a>00202                  <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#4ae6dc328fdd5def0bc7a321b6fe9026">received_bundles_</a>,
<a name="l00203"></a>00203                  <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#296369d7b5496abf65cb2f4b080f17d1">delivered_bundles_</a>,
<a name="l00204"></a>00204                  <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#34933ce2a013c6208e836b6b636823ca">generated_bundles_</a>,
<a name="l00205"></a>00205                  <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#989e3916cbfdbb3174962bb4ba6b041c">transmitted_bundles_</a>,
<a name="l00206"></a>00206                  <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#c85c7be254f9241a2fb610fb9e6cf4e9">expired_bundles_</a>,
<a name="l00207"></a>00207                  <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#0d5fa3f893a635a22b65ea5e9a1faea2">duplicate_bundles_</a>,
<a name="l00208"></a>00208                  <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#8eb7288e8cc5f5feaaedd5998c6cb958">deleted_bundles_</a>,
<a name="l00209"></a>00209                  <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#1ef78250580e8aa28e368d1b00e29148">injected_bundles_</a>);
<a name="l00210"></a>00210 }
<a name="l00211"></a>00211 
<a name="l00212"></a>00212 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00213"></a>00213 <span class="keywordtype">void</span>
<a name="l00214"></a><a class="code" href="classdtn_1_1BundleDaemon.html#b5e5053414a64e261406765307dc1f70">00214</a> <a class="code" href="classdtn_1_1BundleDaemon.html#b5e5053414a64e261406765307dc1f70" title="Format the given StringBuffer with the current internal statistics value.">BundleDaemon::get_daemon_stats</a>(oasys::StringBuffer* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>)
<a name="l00215"></a>00215 {
<a name="l00216"></a>00216     buf-&gt;appendf(<span class="stringliteral">"%zu pending_events -- "</span>
<a name="l00217"></a>00217                  <span class="stringliteral">"%u processed_events -- "</span>
<a name="l00218"></a>00218                  <span class="stringliteral">"%zu pending_timers"</span>,
<a name="l00219"></a>00219                  <a class="code" href="classdtn_1_1BundleDaemon.html#b73dfc9eeffef373061d4e37b7200d97" title="Return the number of events currently waiting for processing.">event_queue_size</a>(),
<a name="l00220"></a>00220                  <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#29e4ac69c2393b563da1f0557458deea">events_processed_</a>,
<a name="l00221"></a>00221                  oasys::TimerSystem::instance()-&gt;num_pending_timers());
<a name="l00222"></a>00222 }
<a name="l00223"></a>00223 
<a name="l00224"></a>00224 
<a name="l00225"></a>00225 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00226"></a>00226 <span class="keywordtype">void</span>
<a name="l00227"></a><a class="code" href="classdtn_1_1BundleDaemon.html#a0cca034eee158ec64cf4e29ba353a87">00227</a> <a class="code" href="classdtn_1_1BundleDaemon.html#a0cca034eee158ec64cf4e29ba353a87" title="Reset all internal stats.">BundleDaemon::reset_stats</a>()
<a name="l00228"></a>00228 {
<a name="l00229"></a>00229     memset(&amp;<a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>));
<a name="l00230"></a>00230 
<a name="l00231"></a>00231     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#6edebce9cf6080f854039f8df593cfec" title="Accessor for the ContactManager internal lock.">lock</a>(), <span class="stringliteral">"BundleDaemon::reset_stats"</span>);
<a name="l00232"></a>00232     
<a name="l00233"></a>00233     <span class="keyword">const</span> <a class="code" href="classdtn_1_1LinkSet.html" title="Set of links.">LinkSet</a>* links = <a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#957c6cfac0575444e0a9a04a12708cf6" title="Return the list of links.">links</a>();
<a name="l00234"></a>00234     LinkSet::const_iterator iter;
<a name="l00235"></a>00235     <span class="keywordflow">for</span> (iter = links-&gt;begin(); iter != links-&gt;end(); ++iter) {
<a name="l00236"></a>00236         (*iter)-&gt;reset_stats();
<a name="l00237"></a>00237     }
<a name="l00238"></a>00238 }
<a name="l00239"></a>00239 
<a name="l00240"></a>00240 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00241"></a>00241 <span class="keywordtype">void</span>
<a name="l00242"></a><a class="code" href="classdtn_1_1BundleDaemon.html#3847596a3b6b6a7e583947501491a87b">00242</a> <a class="code" href="classdtn_1_1BundleDaemon.html#3847596a3b6b6a7e583947501491a87b" title="Locally generate a status report for the given bundle.">BundleDaemon::generate_status_report</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* orig_bundle,
<a name="l00243"></a>00243                                      <a class="code" href="classdtn_1_1BundleStatusReport.html#b2546897ef428634d8385363b6de1499">BundleStatusReport::flag_t</a> flag,
<a name="l00244"></a>00244                                      <a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f917" title="Bundle Status Report &amp;quot;Reason Code&amp;quot; flags.">status_report_reason_t</a> reason)
<a name="l00245"></a>00245 {
<a name="l00246"></a>00246     log_debug(<span class="stringliteral">"generating return receipt status report, "</span>
<a name="l00247"></a>00247               <span class="stringliteral">"flag = 0x%x, reason = 0x%x"</span>, flag, reason);
<a name="l00248"></a>00248     
<a name="l00249"></a>00249     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* report = <span class="keyword">new</span> <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>();
<a name="l00250"></a>00250     <a class="code" href="classdtn_1_1BundleStatusReport.html#d3369fc659fbc354c26ddb769917ace8" title="Constructor-like function that fills in the bundle payload buffer with the appropriate...">BundleStatusReport::create_status_report</a>(report, orig_bundle,
<a name="l00251"></a>00251                                              <a class="code" href="classdtn_1_1BundleDaemon.html#bb461f7084ac3cf8c88ecff1a2686bcf" title="The default endpoint id for reaching this daemon, used for bundle status reports...">local_eid_</a>, flag, reason);
<a name="l00252"></a>00252     
<a name="l00253"></a>00253     <a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a> e(report, <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b04a9578f3e2276d81cd632222ceb4e2e" title="the admin logic">EVENTSRC_ADMIN</a>);
<a name="l00254"></a>00254     <a class="code" href="classdtn_1_1BundleDaemon.html#6590936f52512c792e7c26bf02ddabc8" title="Main event handling function.">handle_event</a>(&amp;e);
<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_1BundleDaemon.html#0667dcac140e535a892d962bc9b95da0">00259</a> <a class="code" href="classdtn_1_1BundleDaemon.html#0667dcac140e535a892d962bc9b95da0" title="Generate a custody signal to be sent to the current custodian.">BundleDaemon::generate_custody_signal</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <span class="keywordtype">bool</span> succeeded,
<a name="l00260"></a>00260                                       <a class="code" href="classdtn_1_1BundleProtocol.html#e339b3a1104cd188459059e46543490b" title="Custody Signal Reason Codes.">custody_signal_reason_t</a> reason)
<a name="l00261"></a>00261 {
<a name="l00262"></a>00262     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#dd00e0f0435b047bdde46c97cb513e3d" title="Accessors.">local_custody</a>()) {
<a name="l00263"></a>00263         log_err(<span class="stringliteral">"send_custody_signal(*%p): already have local custody"</span>,
<a name="l00264"></a>00264                 bundle);
<a name="l00265"></a>00265         <span class="keywordflow">return</span>;
<a name="l00266"></a>00266     }
<a name="l00267"></a>00267 
<a name="l00268"></a>00268     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#eb68ec729851c7e7221fe7cb61f19875" title="Accessors.">custodian</a>().<a class="code" href="classdtn_1_1EndpointID.html#80721c0832c08c5066e6d6276d62d70b" title="Simple equality test function.">equals</a>(<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="l00269"></a>00269         log_err(<span class="stringliteral">"send_custody_signal(*%p): current custodian is NULL_EID"</span>,
<a name="l00270"></a>00270                 bundle);
<a name="l00271"></a>00271         <span class="keywordflow">return</span>;
<a name="l00272"></a>00272     }
<a name="l00273"></a>00273     
<a name="l00274"></a>00274     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* signal = <span class="keyword">new</span> <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>();
<a name="l00275"></a>00275     <a class="code" href="classdtn_1_1CustodySignal.html#2fe29b70ddb0f7cf92d417d996c4a8e0" title="Constructor-like function to create a new custody signal bundle.">CustodySignal::create_custody_signal</a>(signal, bundle, <a class="code" href="classdtn_1_1BundleDaemon.html#bb461f7084ac3cf8c88ecff1a2686bcf" title="The default endpoint id for reaching this daemon, used for bundle status reports...">local_eid_</a>,
<a name="l00276"></a>00276                                          succeeded, reason);
<a name="l00277"></a>00277     
<a name="l00278"></a>00278     <a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a> e(signal, <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b04a9578f3e2276d81cd632222ceb4e2e" title="the admin logic">EVENTSRC_ADMIN</a>);
<a name="l00279"></a>00279     <a class="code" href="classdtn_1_1BundleDaemon.html#6590936f52512c792e7c26bf02ddabc8" title="Main event handling function.">handle_event</a>(&amp;e);
<a name="l00280"></a>00280 }
<a name="l00281"></a>00281 
<a name="l00282"></a>00282 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00283"></a>00283 <span class="keywordtype">void</span>
<a name="l00284"></a><a class="code" href="classdtn_1_1BundleDaemon.html#4e2042db32460031c50cae094a7275fe">00284</a> <a class="code" href="classdtn_1_1BundleDaemon.html#4e2042db32460031c50cae094a7275fe" title="Cancel any pending custody timers for the bundle.">BundleDaemon::cancel_custody_timers</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle)
<a name="l00285"></a>00285 {
<a name="l00286"></a>00286     oasys::ScopeLock l(bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#5152156c37574a7939c6b4740fa44c66" title="Accessors.">lock</a>(), <span class="stringliteral">"BundleDaemon::cancel_custody_timers"</span>);
<a name="l00287"></a>00287     
<a name="l00288"></a>00288     CustodyTimerVec::iterator iter;
<a name="l00289"></a>00289     <span class="keywordflow">for</span> (iter =  bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#ee3040af6e2509507fbd3380f8fcfd1a" title="Setters and mutable accessors.">custody_timers</a>()-&gt;begin();
<a name="l00290"></a>00290          iter != bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#ee3040af6e2509507fbd3380f8fcfd1a" title="Setters and mutable accessors.">custody_timers</a>()-&gt;end();
<a name="l00291"></a>00291          ++iter)
<a name="l00292"></a>00292     {
<a name="l00293"></a>00293         <span class="keywordtype">bool</span> ok = (*iter)-&gt;cancel();
<a name="l00294"></a>00294         <span class="keywordflow">if</span> (!ok) {
<a name="l00295"></a>00295             log_crit(<span class="stringliteral">"unexpected error cancelling custody timer for bundle *%p"</span>,
<a name="l00296"></a>00296                      bundle);
<a name="l00297"></a>00297         }
<a name="l00298"></a>00298         
<a name="l00299"></a>00299         <span class="comment">// the timer will be deleted when it bubbles to the top of the</span>
<a name="l00300"></a>00300         <span class="comment">// timer queue</span>
<a name="l00301"></a>00301     }
<a name="l00302"></a>00302     
<a name="l00303"></a>00303     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#ee3040af6e2509507fbd3380f8fcfd1a" title="Setters and mutable accessors.">custody_timers</a>()-&gt;clear();
<a name="l00304"></a>00304 }
<a name="l00305"></a>00305 
<a name="l00306"></a>00306 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00307"></a>00307 <span class="keywordtype">void</span>
<a name="l00308"></a><a class="code" href="classdtn_1_1BundleDaemon.html#cd91a9612a25c23580b75a951a382267">00308</a> <a class="code" href="classdtn_1_1BundleDaemon.html#cd91a9612a25c23580b75a951a382267" title="Take custody for the given bundle, sending the appropriate signal to the current...">BundleDaemon::accept_custody</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle)
<a name="l00309"></a>00309 {
<a name="l00310"></a>00310     log_info(<span class="stringliteral">"accept_custody *%p"</span>, bundle);
<a name="l00311"></a>00311     
<a name="l00312"></a>00312     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#dd00e0f0435b047bdde46c97cb513e3d" title="Accessors.">local_custody</a>()) {
<a name="l00313"></a>00313         log_err(<span class="stringliteral">"accept_custody(*%p): already have local custody"</span>,
<a name="l00314"></a>00314                 bundle);
<a name="l00315"></a>00315         <span class="keywordflow">return</span>;
<a name="l00316"></a>00316     }
<a name="l00317"></a>00317 
<a name="l00318"></a>00318     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#eb68ec729851c7e7221fe7cb61f19875" title="Accessors.">custodian</a>().<a class="code" href="classdtn_1_1EndpointID.html#80721c0832c08c5066e6d6276d62d70b" title="Simple equality test function.">equals</a>(<a class="code" href="classdtn_1_1BundleDaemon.html#bb461f7084ac3cf8c88ecff1a2686bcf" title="The default endpoint id for reaching this daemon, used for bundle status reports...">local_eid_</a>)) {
<a name="l00319"></a>00319         log_err(<span class="stringliteral">"send_custody_signal(*%p): "</span>
<a name="l00320"></a>00320                 <span class="stringliteral">"current custodian is already local_eid"</span>,
<a name="l00321"></a>00321                 bundle);
<a name="l00322"></a>00322         <span class="keywordflow">return</span>;
<a name="l00323"></a>00323     }
<a name="l00324"></a>00324     
<a name="l00325"></a>00325     <span class="comment">// send a custody acceptance signal to the current custodian (if</span>
<a name="l00326"></a>00326     <span class="comment">// it is someone, and not the null eid)</span>
<a name="l00327"></a>00327     <span class="keywordflow">if</span> (! bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#eb68ec729851c7e7221fe7cb61f19875" title="Accessors.">custodian</a>().<a class="code" href="classdtn_1_1EndpointID.html#80721c0832c08c5066e6d6276d62d70b" title="Simple equality test function.">equals</a>(<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="l00328"></a>00328         <a class="code" href="classdtn_1_1BundleDaemon.html#0667dcac140e535a892d962bc9b95da0" title="Generate a custody signal to be sent to the current custodian.">generate_custody_signal</a>(bundle, <span class="keyword">true</span>, <a class="code" href="classdtn_1_1BundleProtocol.html#e339b3a1104cd188459059e46543490bf974eaaa8cbe4e66aeaf238a454cecf1">BundleProtocol::CUSTODY_NO_ADDTL_INFO</a>);
<a name="l00329"></a>00329     }
<a name="l00330"></a>00330 
<a name="l00331"></a>00331     <span class="comment">// now we mark the bundle to indicate that we have custody and add</span>
<a name="l00332"></a>00332     <span class="comment">// it to the custody bundles list</span>
<a name="l00333"></a>00333     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#96698085719d88c0b5c86d4cb388324c" title="Setters and mutable accessors.">mutable_custodian</a>()-&gt;<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(<a class="code" href="classdtn_1_1BundleDaemon.html#bb461f7084ac3cf8c88ecff1a2686bcf" title="The default endpoint id for reaching this daemon, used for bundle status reports...">local_eid_</a>);
<a name="l00334"></a>00334     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#1574534ce46a32052b604c3cdf5a5921" title="Setters and mutable accessors.">set_local_custody</a>(<span class="keyword">true</span>);
<a name="l00335"></a>00335     <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a>-&gt;<a class="code" href="classdtn_1_1BundleActions.html#ae6c692e776bdde10921c307b57b203d" title="Update the on-disk version of the given bundle, after it&amp;#39;s bookkeeping or header...">store_update</a>(bundle);
<a name="l00336"></a>00336     
<a name="l00337"></a>00337     <a class="code" href="classdtn_1_1BundleDaemon.html#ce140ab25aea62199a71e73e216845a5" title="The list of all bundles that we have custody of.">custody_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#9f3efd0593739e89ed478fd4bbccd3e0" title="Add a new bundle to the back of the list.">push_back</a>(bundle);
<a name="l00338"></a>00338 
<a name="l00339"></a>00339     <span class="comment">// finally, if the bundle requested custody acknowledgements,</span>
<a name="l00340"></a>00340     <span class="comment">// deliver them now</span>
<a name="l00341"></a>00341     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#108fb7cb162dcc1fdcfdad3ca477692d" title="Accessors.">custody_rcpt</a>()) {
<a name="l00342"></a>00342         <a class="code" href="classdtn_1_1BundleDaemon.html#3847596a3b6b6a7e583947501491a87b" title="Locally generate a status report for the given bundle.">generate_status_report</a>(bundle, 
<a name="l00343"></a>00343                                <a class="code" href="classdtn_1_1BundleStatusReport.html#b2546897ef428634d8385363b6de1499064bcecfb056e6fb69163c02c178e16d">BundleStatusReport::STATUS_CUSTODY_ACCEPTED</a>);
<a name="l00344"></a>00344     }
<a name="l00345"></a>00345 }
<a name="l00346"></a>00346 
<a name="l00347"></a>00347 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00348"></a>00348 <span class="keywordtype">void</span>
<a name="l00349"></a><a class="code" href="classdtn_1_1BundleDaemon.html#94f9a6f6615e0249f679b4dccee7e1a3">00349</a> <a class="code" href="classdtn_1_1BundleDaemon.html#94f9a6f6615e0249f679b4dccee7e1a3" title="Release custody of the given bundle, sending the appropriate signal to the current...">BundleDaemon::release_custody</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle)
<a name="l00350"></a>00350 {
<a name="l00351"></a>00351     log_info(<span class="stringliteral">"release_custody *%p"</span>, bundle);
<a name="l00352"></a>00352     
<a name="l00353"></a>00353     <span class="keywordflow">if</span> (!bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#dd00e0f0435b047bdde46c97cb513e3d" title="Accessors.">local_custody</a>()) {
<a name="l00354"></a>00354         log_err(<span class="stringliteral">"release_custody(*%p): don't have local custody"</span>,
<a name="l00355"></a>00355                 bundle);
<a name="l00356"></a>00356         <span class="keywordflow">return</span>;
<a name="l00357"></a>00357     }
<a name="l00358"></a>00358 
<a name="l00359"></a>00359     <a class="code" href="classdtn_1_1BundleDaemon.html#4e2042db32460031c50cae094a7275fe" title="Cancel any pending custody timers for the bundle.">cancel_custody_timers</a>(bundle);
<a name="l00360"></a>00360 
<a name="l00361"></a>00361     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#96698085719d88c0b5c86d4cb388324c" title="Setters and mutable accessors.">mutable_custodian</a>()-&gt;<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(<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="l00362"></a>00362     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#1574534ce46a32052b604c3cdf5a5921" title="Setters and mutable accessors.">set_local_custody</a>(<span class="keyword">false</span>);
<a name="l00363"></a>00363     <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a>-&gt;<a class="code" href="classdtn_1_1BundleActions.html#ae6c692e776bdde10921c307b57b203d" title="Update the on-disk version of the given bundle, after it&amp;#39;s bookkeeping or header...">store_update</a>(bundle);
<a name="l00364"></a>00364 
<a name="l00365"></a>00365     <a class="code" href="classdtn_1_1BundleDaemon.html#ce140ab25aea62199a71e73e216845a5" title="The list of all bundles that we have custody of.">custody_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#b0171458e14d67307b74f98447062d68" title="Remove the given bundle from the list.">erase</a>(bundle);
<a name="l00366"></a>00366 }
<a name="l00367"></a>00367 
<a name="l00368"></a>00368 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00369"></a>00369 <span class="keywordtype">void</span>
<a name="l00370"></a><a class="code" href="classdtn_1_1BundleDaemon.html#d604277d857c5ea54de0718f20b677fd">00370</a> <a class="code" href="classdtn_1_1BundleDaemon.html#d604277d857c5ea54de0718f20b677fd" title="Deliver the bundle to the given registration.">BundleDaemon::deliver_to_registration</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle,
<a name="l00371"></a>00371                                       <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>* registration)
<a name="l00372"></a>00372 {
<a name="l00373"></a>00373     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#d6c74eba219bfe55854cf7a90e210cca" title="Accessors.">is_fragment</a>());
<a name="l00374"></a>00374 
<a name="l00375"></a>00375     <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad" title="The forwarding log state codes.">ForwardingInfo::state_t</a> state = 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>(registration);
<a name="l00376"></a>00376     <span class="keywordflow">if</span> (state != <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fadb3e7fba25df11c3fce5b5a88300b0ac6" title="Return value for no entry.">ForwardingInfo::NONE</a>)
<a name="l00377"></a>00377     {
<a name="l00378"></a>00378         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(state == <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad6798e2dfb4df40155322b92d6e002fb4" title="Delivered to local registration.">ForwardingInfo::DELIVERED</a>);
<a name="l00379"></a>00379         log_debug(<span class="stringliteral">"not delivering bundle *%p to registration %d (%s) "</span>
<a name="l00380"></a>00380                   <span class="stringliteral">"since already delivered"</span>,
<a name="l00381"></a>00381                   bundle, registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>(),
<a name="l00382"></a>00382                   registration-&gt;<a class="code" href="classdtn_1_1Registration.html#590e683ae3d0a33456e7f0fa0a2a89d5" title="Accessors.">endpoint</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00383"></a>00383         <span class="keywordflow">return</span>;
<a name="l00384"></a>00384     }
<a name="l00385"></a>00385 
<a name="l00386"></a>00386     
<a name="l00387"></a>00387     <span class="comment">// if this is a session registration and doesn't have either the</span>
<a name="l00388"></a>00388     <span class="comment">// SUBSCRIBE or CUSTODY bits (i.e. it's publish-only), don't</span>
<a name="l00389"></a>00389     <span class="comment">// deliver the bundle</span>
<a name="l00390"></a>00390     <span class="keywordflow">if</span> (registration-&gt;<a class="code" href="classdtn_1_1Registration.html#577ef221608a47ba828daad128c2b263" title="Accessors.">session_flags</a>() == <a class="code" href="classdtn_1_1Session.html#a795473f389a203d6e15058da8d9498c1978e38ca305c80fe009dd50fe24a3be">Session::PUBLISH</a>)
<a name="l00391"></a>00391     {
<a name="l00392"></a>00392         log_debug(<span class="stringliteral">"not delivering bundle *%p to registration %d (%s) "</span>
<a name="l00393"></a>00393                   <span class="stringliteral">"since it's a publish-only session registration"</span>,
<a name="l00394"></a>00394                   bundle, registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>(),
<a name="l00395"></a>00395                   registration-&gt;<a class="code" href="classdtn_1_1Registration.html#590e683ae3d0a33456e7f0fa0a2a89d5" title="Accessors.">endpoint</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00396"></a>00396         <span class="keywordflow">return</span>;
<a name="l00397"></a>00397     }
<a name="l00398"></a>00398 
<a name="l00399"></a>00399     log_debug(<span class="stringliteral">"delivering bundle *%p to registration %d (%s)"</span>,
<a name="l00400"></a>00400               bundle, registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>(),
<a name="l00401"></a>00401               registration-&gt;<a class="code" href="classdtn_1_1Registration.html#590e683ae3d0a33456e7f0fa0a2a89d5" title="Accessors.">endpoint</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00402"></a>00402 
<a name="l00403"></a>00403     <span class="keywordflow">if</span> (registration-&gt;<a class="code" href="classdtn_1_1Registration.html#4cc4d8035b434305b500a76ba7b7b446" title="Deliver the bundle if it isn&amp;#39;t a duplicate.">deliver_if_not_duplicate</a>(bundle)) {
<a name="l00404"></a>00404         <span class="comment">// XXX/demmer this action could be taken from a registration</span>
<a name="l00405"></a>00405         <span class="comment">// flag, i.e. does it want to take a copy or the actual</span>
<a name="l00406"></a>00406         <span class="comment">// delivery of the bundle</span>
<a name="l00407"></a>00407         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#249ac137ef76e253d8e0587f2662bca7" title="Accessors.">fwdlog</a>()-&gt;<a class="code" href="classdtn_1_1ForwardingLog.html#3a0080cfb70b95af31a780bf71910004" title="Add a new forwarding info entry for the given link.">add_entry</a>(registration,
<a name="l00408"></a>00408                                     <a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b59471efad47dbf6015f5e4458ac355eabbaa" title="Forward the bundle to only this next hop.">ForwardingInfo::FORWARD_ACTION</a>,
<a name="l00409"></a>00409                                     <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad6798e2dfb4df40155322b92d6e002fb4" title="Delivered to local registration.">ForwardingInfo::DELIVERED</a>);
<a name="l00410"></a>00410     } <span class="keywordflow">else</span> {
<a name="l00411"></a>00411         log_notice(<span class="stringliteral">"suppressing duplicate delivery of bundle *%p "</span>
<a name="l00412"></a>00412                    <span class="stringliteral">"to registration %d (%s)"</span>,
<a name="l00413"></a>00413                    bundle, registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>(),
<a name="l00414"></a>00414                    registration-&gt;<a class="code" href="classdtn_1_1Registration.html#590e683ae3d0a33456e7f0fa0a2a89d5" title="Accessors.">endpoint</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00415"></a>00415     }
<a name="l00416"></a>00416 }
<a name="l00417"></a>00417 
<a name="l00418"></a>00418 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00419"></a>00419 <span class="keywordtype">bool</span>
<a name="l00420"></a><a class="code" href="classdtn_1_1BundleDaemon.html#f3a66691215ba378336f8241b111d364">00420</a> <a class="code" href="classdtn_1_1BundleDaemon.html#f3a66691215ba378336f8241b111d364" title="Check the registration table and optionally deliver the bundle to any that match...">BundleDaemon::check_local_delivery</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <span class="keywordtype">bool</span> deliver)
<a name="l00421"></a>00421 {
<a name="l00422"></a>00422     log_debug(<span class="stringliteral">"checking for matching registrations for bundle *%p"</span>, bundle);
<a name="l00423"></a>00423 
<a name="l00424"></a>00424     <a class="code" href="classdtn_1_1RegistrationList.html" title="Typedef for a list of Registrations.">RegistrationList</a> matches;
<a name="l00425"></a>00425     RegistrationList::iterator iter;
<a name="l00426"></a>00426 
<a name="l00427"></a>00427     <a class="code" href="classdtn_1_1BundleDaemon.html#f0b116c3ae390f0032049f376e3a2eec" title="The table of active registrations.">reg_table_</a>-&gt;<a class="code" href="classdtn_1_1RegistrationTable.html#334df3b83d924f97cc547f39372380ed" title="Populate the given reglist with all registrations with an endpoint id that matches...">get_matching</a>(bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>(), &amp;matches);
<a name="l00428"></a>00428 
<a name="l00429"></a>00429     <span class="keywordflow">if</span> (deliver) {
<a name="l00430"></a>00430         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#d6c74eba219bfe55854cf7a90e210cca" title="Accessors.">is_fragment</a>());
<a name="l00431"></a>00431         <span class="keywordflow">for</span> (iter = matches.begin(); iter != matches.end(); ++iter) {
<a name="l00432"></a>00432             <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>* registration = *iter;
<a name="l00433"></a>00433             <a class="code" href="classdtn_1_1BundleDaemon.html#d604277d857c5ea54de0718f20b677fd" title="Deliver the bundle to the given registration.">deliver_to_registration</a>(bundle, registration);
<a name="l00434"></a>00434         }
<a name="l00435"></a>00435     }
<a name="l00436"></a>00436 
<a name="l00437"></a>00437     <span class="keywordflow">return</span> (matches.size() &gt; 0) || bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#383dd8603c0bfddb5eab9b52d3d2d506" title="@ return true if the given EndpointID is contained within this EndpointID; otherwise...">subsume</a>(<a class="code" href="classdtn_1_1BundleDaemon.html#bb461f7084ac3cf8c88ecff1a2686bcf" title="The default endpoint id for reaching this daemon, used for bundle status reports...">local_eid_</a>);
<a name="l00438"></a>00438 }
<a name="l00439"></a>00439 
<a name="l00440"></a>00440 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00441"></a>00441 <span class="keywordtype">void</span>
<a name="l00442"></a><a class="code" href="classdtn_1_1BundleDaemon.html#7a0890bcd94e1b7390ca9f03aab45e60">00442</a> <a class="code" href="classdtn_1_1BundleDaemon.html#7a0890bcd94e1b7390ca9f03aab45e60" title="This is used for delivering bundle to app by Late Binding.">BundleDaemon::check_and_deliver_to_registrations</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="classdtn_1_1EndpointID.html">EndpointID</a>&amp; reg_eid)
<a name="l00443"></a>00443 {
<a name="l00444"></a>00444     <span class="keywordtype">int</span> num;
<a name="l00445"></a>00445     log_debug(<span class="stringliteral">"checking for matching entries in table for %s"</span>, reg_eid.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00446"></a>00446 
<a name="l00447"></a>00447     <a class="code" href="classdtn_1_1RegistrationList.html" title="Typedef for a list of Registrations.">RegistrationList</a> matches;
<a name="l00448"></a>00448     RegistrationList::iterator iter;
<a name="l00449"></a>00449 
<a name="l00450"></a>00450     num = <a class="code" href="classdtn_1_1BundleDaemon.html#f0b116c3ae390f0032049f376e3a2eec" title="The table of active registrations.">reg_table_</a>-&gt;<a class="code" href="classdtn_1_1RegistrationTable.html#334df3b83d924f97cc547f39372380ed" title="Populate the given reglist with all registrations with an endpoint id that matches...">get_matching</a>(reg_eid, &amp;matches);
<a name="l00451"></a>00451 
<a name="l00452"></a>00452     <span class="keywordflow">for</span> (iter = matches.begin(); iter != matches.end(); ++iter)
<a name="l00453"></a>00453     {
<a name="l00454"></a>00454         <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>* registration = *iter;
<a name="l00455"></a>00455         <a class="code" href="classdtn_1_1BundleDaemon.html#d604277d857c5ea54de0718f20b677fd" title="Deliver the bundle to the given registration.">deliver_to_registration</a>(bundle, registration);
<a name="l00456"></a>00456     }
<a name="l00457"></a>00457 }
<a name="l00458"></a>00458 
<a name="l00459"></a>00459 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00460"></a>00460 <span class="keywordtype">void</span>
<a name="l00461"></a><a class="code" href="classdtn_1_1BundleDaemon.html#674c2e1a5ac8a448734443f019a77b94">00461</a> <a class="code" href="classdtn_1_1BundleDaemon.html#674c2e1a5ac8a448734443f019a77b94" title="Event type specific handlers.">BundleDaemon::handle_bundle_delete</a>(<a class="code" href="classdtn_1_1BundleDeleteRequest.html" title="Event class for requestion deletion of a bundle.">BundleDeleteRequest</a>* request)
<a name="l00462"></a>00462 {
<a name="l00463"></a>00463     <span class="keywordflow">if</span> (request-&gt;<a class="code" href="classdtn_1_1BundleDeleteRequest.html#fb28d427230456a4b010b28aa8074c68">bundle_</a>.object()) {
<a name="l00464"></a>00464         log_info(<span class="stringliteral">"BUNDLE_DELETE: bundle *%p (reason %s)"</span>,
<a name="l00465"></a>00465                  request-&gt;<a class="code" href="classdtn_1_1BundleDeleteRequest.html#fb28d427230456a4b010b28aa8074c68">bundle_</a>.object(),
<a name="l00466"></a>00466                  <a class="code" href="classdtn_1_1BundleStatusReport.html#c01eebd70430ee5eaf44240097a765cf" title="Return a string version of the reason code.">BundleStatusReport::reason_to_str</a>(request-&gt;<a class="code" href="classdtn_1_1BundleDeleteRequest.html#d4372c23bdd68c1be0e8d5b3dba02263" title="The reason code.">reason_</a>));
<a name="l00467"></a>00467         <a class="code" href="classdtn_1_1BundleDaemon.html#cf4244174dd62d8a39d80bc77915d23c" title="Delete (rather than silently discard) a bundle, e.g., an expired bundle.">delete_bundle</a>(request-&gt;<a class="code" href="classdtn_1_1BundleDeleteRequest.html#fb28d427230456a4b010b28aa8074c68">bundle_</a>, request-&gt;<a class="code" href="classdtn_1_1BundleDeleteRequest.html#d4372c23bdd68c1be0e8d5b3dba02263" title="The reason code.">reason_</a>);
<a name="l00468"></a>00468     }
<a name="l00469"></a>00469 }
<a name="l00470"></a>00470 
<a name="l00471"></a>00471 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00472"></a>00472 <span class="keywordtype">void</span>
<a name="l00473"></a><a class="code" href="classdtn_1_1BundleDaemon.html#f7fba3e62c379bb61637fe1b9866dd5f">00473</a> <a class="code" href="classdtn_1_1BundleDaemon.html#f7fba3e62c379bb61637fe1b9866dd5f" title="Event type specific handlers.">BundleDaemon::handle_bundle_accept</a>(<a class="code" href="classdtn_1_1BundleAcceptRequest.html" title="Event class to optionally probe if a bundle can be accepted by the system before...">BundleAcceptRequest</a>* request)
<a name="l00474"></a>00474 {
<a name="l00475"></a>00475     *request-&gt;<a class="code" href="classdtn_1_1BundleAcceptRequest.html#dbde34d7d9dc5d665c873a5be2286f0e" title="Pointer to the expected result.">result_</a> =
<a name="l00476"></a>00476         <a class="code" href="classdtn_1_1BundleDaemon.html#a5c8a244aad225987f9359ee1c2a1101" title="The active bundle router.">router_</a>-&gt;<a class="code" href="classdtn_1_1BundleRouter.html#47afbf9e1c42ae2cfb396c3895ddca45" title="Synchronous probe indicating whether or not this bundle should be accepted by the...">accept_bundle</a>(request-&gt;<a class="code" href="classdtn_1_1BundleAcceptRequest.html#93006028c70fa765114d5c8355e0f9fb" title="The newly arrived bundle.">bundle_</a>.object(), request-&gt;<a class="code" href="classdtn_1_1BundleAcceptRequest.html#3eddff9e019d3950b5ca58d60b65a842" title="Pointer to the reason code.">reason_</a>);
<a name="l00477"></a>00477 
<a name="l00478"></a>00478     log_info(<span class="stringliteral">"BUNDLE_ACCEPT_REQUEST: bundle *%p %s (reason %s)"</span>,
<a name="l00479"></a>00479              request-&gt;<a class="code" href="classdtn_1_1BundleAcceptRequest.html#93006028c70fa765114d5c8355e0f9fb" title="The newly arrived bundle.">bundle_</a>.object(),
<a name="l00480"></a>00480              *request-&gt;<a class="code" href="classdtn_1_1BundleAcceptRequest.html#dbde34d7d9dc5d665c873a5be2286f0e" title="Pointer to the expected result.">result_</a> ? <span class="stringliteral">"accepted"</span> : <span class="stringliteral">"not accepted"</span>,
<a name="l00481"></a>00481              <a class="code" href="classdtn_1_1BundleStatusReport.html#c01eebd70430ee5eaf44240097a765cf" title="Return a string version of the reason code.">BundleStatusReport::reason_to_str</a>(*request-&gt;<a class="code" href="classdtn_1_1BundleAcceptRequest.html#3eddff9e019d3950b5ca58d60b65a842" title="Pointer to the reason code.">reason_</a>));
<a name="l00482"></a>00482 }
<a name="l00483"></a>00483     
<a name="l00484"></a>00484 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00485"></a>00485 <span class="keywordtype">void</span>
<a name="l00486"></a><a class="code" href="classdtn_1_1BundleDaemon.html#9a75270d0ed9943c5b7afe78a70caed1">00486</a> <a class="code" href="classdtn_1_1BundleDaemon.html#9a75270d0ed9943c5b7afe78a70caed1" title="Event type specific handlers.">BundleDaemon::handle_bundle_received</a>(<a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a>* event)
<a name="l00487"></a>00487 {
<a name="l00488"></a>00488     <span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; bundleref = <span class="keyword">event</span>-&gt;bundleref_;
<a name="l00489"></a>00489     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle = bundleref.object();
<a name="l00490"></a>00490 
<a name="l00491"></a>00491     <span class="comment">// update statistics and store an appropriate event descriptor</span>
<a name="l00492"></a>00492     <span class="keyword">const</span> <span class="keywordtype">char</span>* source_str = <span class="stringliteral">""</span>;
<a name="l00493"></a>00493     <span class="keywordflow">switch</span> (event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#c65ff559e593a79e83d71978265a0407" title="The source of the bundle.">source_</a>) {
<a name="l00494"></a>00494     <span class="keywordflow">case</span> <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142bb0775776e4be46e62a0dcff6cf968059" title="a peer dtn forwarder">EVENTSRC_PEER</a>:
<a name="l00495"></a>00495         <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#4ae6dc328fdd5def0bc7a321b6fe9026">received_bundles_</a>++;
<a name="l00496"></a>00496         <span class="keywordflow">break</span>;
<a name="l00497"></a>00497         
<a name="l00498"></a>00498     <span class="keywordflow">case</span> <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142bf3e56dfb4e624d4f62d7099b60472072" title="a local application">EVENTSRC_APP</a>:
<a name="l00499"></a>00499         <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#4ae6dc328fdd5def0bc7a321b6fe9026">received_bundles_</a>++;
<a name="l00500"></a>00500         source_str = <span class="stringliteral">" (from app)"</span>;
<a name="l00501"></a>00501         <span class="keywordflow">break</span>;
<a name="l00502"></a>00502         
<a name="l00503"></a>00503     <span class="keywordflow">case</span> <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b8fb8e6004d0ab350daca47bdcc106866" title="the data store">EVENTSRC_STORE</a>:
<a name="l00504"></a>00504         source_str = <span class="stringliteral">" (from data store)"</span>;
<a name="l00505"></a>00505         <span class="keywordflow">break</span>;
<a name="l00506"></a>00506         
<a name="l00507"></a>00507     <span class="keywordflow">case</span> <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b04a9578f3e2276d81cd632222ceb4e2e" title="the admin logic">EVENTSRC_ADMIN</a>:
<a name="l00508"></a>00508         <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#34933ce2a013c6208e836b6b636823ca">generated_bundles_</a>++;
<a name="l00509"></a>00509         source_str = <span class="stringliteral">" (generated)"</span>;
<a name="l00510"></a>00510         <span class="keywordflow">break</span>;
<a name="l00511"></a>00511         
<a name="l00512"></a>00512     <span class="keywordflow">case</span> <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b9b7a83778d3a7c1243e8f95c6445c88a" title="the fragmentation engine">EVENTSRC_FRAGMENTATION</a>:
<a name="l00513"></a>00513         <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#34933ce2a013c6208e836b6b636823ca">generated_bundles_</a>++;
<a name="l00514"></a>00514         source_str = <span class="stringliteral">" (from fragmentation)"</span>;
<a name="l00515"></a>00515         <span class="keywordflow">break</span>;
<a name="l00516"></a>00516 
<a name="l00517"></a>00517     <span class="keywordflow">case</span> <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b25abe58c828214d9857f0fa1249db869" title="the routing logic">EVENTSRC_ROUTER</a>:
<a name="l00518"></a>00518         <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#34933ce2a013c6208e836b6b636823ca">generated_bundles_</a>++;
<a name="l00519"></a>00519         source_str = <span class="stringliteral">" (from router)"</span>;
<a name="l00520"></a>00520         <span class="keywordflow">break</span>;
<a name="l00521"></a>00521 
<a name="l00522"></a>00522     <span class="keywordflow">default</span>:
<a name="l00523"></a>00523         NOTREACHED;
<a name="l00524"></a>00524     }
<a name="l00525"></a>00525 
<a name="l00526"></a>00526     <span class="comment">// if debug logging is enabled, dump out a verbose printing of the</span>
<a name="l00527"></a>00527     <span class="comment">// bundle, including all options, otherwise, a more terse log</span>
<a name="l00528"></a>00528     <span class="keywordflow">if</span> (log_enabled(oasys::LOG_DEBUG)) {
<a name="l00529"></a>00529         oasys::StaticStringBuffer&lt;1024&gt; <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>;
<a name="l00530"></a>00530         buf.appendf(<span class="stringliteral">"BUNDLE_RECEIVED%s: prevhop %s (%u bytes recvd)\n"</span>,
<a name="l00531"></a>00531                     source_str, event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#c1567b9080660f7b95fcd74047f8b399" title="Previous hop endpoint id.">prevhop_</a>.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(), <span class="keyword">event</span>-&gt;bytes_received_);
<a name="l00532"></a>00532         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#9b410ec89fc28040e52d3b0892cd3694" title="Virtual from formatter.">format_verbose</a>(&amp;buf);
<a name="l00533"></a>00533         log_multiline(oasys::LOG_DEBUG, buf.c_str());
<a name="l00534"></a>00534     } <span class="keywordflow">else</span> {
<a name="l00535"></a>00535         log_info(<span class="stringliteral">"BUNDLE_RECEIVED%s *%p prevhop %s (%u bytes recvd)"</span>,
<a name="l00536"></a>00536                  source_str, bundle, event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#c1567b9080660f7b95fcd74047f8b399" title="Previous hop endpoint id.">prevhop_</a>.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(), <span class="keyword">event</span>-&gt;bytes_received_);
<a name="l00537"></a>00537     }
<a name="l00538"></a>00538     
<a name="l00539"></a>00539     <span class="comment">// log the reception in the bundle's forwarding log</span>
<a name="l00540"></a>00540     <span class="keywordflow">if</span> (event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#c65ff559e593a79e83d71978265a0407" title="The source of the bundle.">source_</a> == <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142bb0775776e4be46e62a0dcff6cf968059" title="a peer dtn forwarder">EVENTSRC_PEER</a> &amp;&amp; event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#b851addef235e605411198e7bb3d9677" title="Link from which bundle was received, if applicable.">link_</a> != NULL)
<a name="l00541"></a>00541     {
<a name="l00542"></a>00542         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#249ac137ef76e253d8e0587f2662bca7" title="Accessors.">fwdlog</a>()-&gt;<a class="code" href="classdtn_1_1ForwardingLog.html#3a0080cfb70b95af31a780bf71910004" title="Add a new forwarding info entry for the given link.">add_entry</a>(event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#b851addef235e605411198e7bb3d9677" title="Link from which bundle was received, if applicable.">link_</a>,
<a name="l00543"></a>00543                                     <a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b59471efad47dbf6015f5e4458ac355eabbaa" title="Forward the bundle to only this next hop.">ForwardingInfo::FORWARD_ACTION</a>,
<a name="l00544"></a>00544                                     <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad94bcd632696a41842e2e5871933a8a66" title="Where the bundle came from.">ForwardingInfo::RECEIVED</a>);
<a name="l00545"></a>00545     }
<a name="l00546"></a>00546     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#c65ff559e593a79e83d71978265a0407" title="The source of the bundle.">source_</a> == <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142bf3e56dfb4e624d4f62d7099b60472072" title="a local application">EVENTSRC_APP</a>)
<a name="l00547"></a>00547     {
<a name="l00548"></a>00548         <span class="keywordflow">if</span> (event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#0fa6ec97834e4592666ecde59b870d75" title="Registration where the bundle arrived.">registration_</a> != NULL) {
<a name="l00549"></a>00549             bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#249ac137ef76e253d8e0587f2662bca7" title="Accessors.">fwdlog</a>()-&gt;<a class="code" href="classdtn_1_1ForwardingLog.html#3a0080cfb70b95af31a780bf71910004" title="Add a new forwarding info entry for the given link.">add_entry</a>(event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#0fa6ec97834e4592666ecde59b870d75" title="Registration where the bundle arrived.">registration_</a>,
<a name="l00550"></a>00550                                         <a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b59471efad47dbf6015f5e4458ac355eabbaa" title="Forward the bundle to only this next hop.">ForwardingInfo::FORWARD_ACTION</a>,
<a name="l00551"></a>00551                                         <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad94bcd632696a41842e2e5871933a8a66" title="Where the bundle came from.">ForwardingInfo::RECEIVED</a>);
<a name="l00552"></a>00552         }
<a name="l00553"></a>00553     }
<a name="l00554"></a>00554 
<a name="l00555"></a>00555     <span class="comment">// log a warning if the bundle doesn't have any expiration time or</span>
<a name="l00556"></a>00556     <span class="comment">// has a creation time that's in the future. in either case, we</span>
<a name="l00557"></a>00557     <span class="comment">// proceed as normal</span>
<a name="l00558"></a>00558     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#21879e67b7f065975cbd942807500746" title="Accessors.">expiration</a>() == 0) {
<a name="l00559"></a>00559         log_warn(<span class="stringliteral">"bundle id %d arrived with zero expiration time"</span>,
<a name="l00560"></a>00560                  bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>());
<a name="l00561"></a>00561     }
<a name="l00562"></a>00562 
<a name="l00563"></a>00563     u_int32_t now = <a class="code" href="structdtn_1_1BundleTimestamp.html#27af1dd8ce1c3d9f361a0149aba6cb0c" title="Return the current time in the correct format for the bundle protocol, i.e.">BundleTimestamp::get_current_time</a>();
<a name="l00564"></a>00564     <span class="keywordflow">if</span> ((bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a> &gt; now) &amp;&amp;
<a name="l00565"></a>00565         (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a> - now &gt; 30000))
<a name="l00566"></a>00566     {
<a name="l00567"></a>00567         log_warn(<span class="stringliteral">"bundle id %d arrived with creation time in the future "</span>
<a name="l00568"></a>00568                  <span class="stringliteral">"(%u &gt; %u)"</span>,
<a name="l00569"></a>00569                  bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a>, now);
<a name="l00570"></a>00570     }
<a name="l00571"></a>00571 
<a name="l00572"></a>00572     <span class="comment">/*</span>
<a name="l00573"></a>00573 <span class="comment">     * If a previous hop block wasn't included, but we know the remote</span>
<a name="l00574"></a>00574 <span class="comment">     * endpoint id of the link where the bundle arrived, assign the</span>
<a name="l00575"></a>00575 <span class="comment">     * prevhop_ field in the bundle so it's available for routing.</span>
<a name="l00576"></a>00576 <span class="comment">     */</span>
<a name="l00577"></a>00577     <span class="keywordflow">if</span> (event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#c65ff559e593a79e83d71978265a0407" title="The source of the bundle.">source_</a> == <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142bb0775776e4be46e62a0dcff6cf968059" title="a peer dtn forwarder">EVENTSRC_PEER</a>)
<a name="l00578"></a>00578     {
<a name="l00579"></a>00579         <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#04a51974754438d555bf8a7b0216cd38" title="Accessors.">prevhop</a>()       == <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="l00580"></a>00580             bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#04a51974754438d555bf8a7b0216cd38" title="Accessors.">prevhop</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>() == <span class="stringliteral">""</span>)
<a name="l00581"></a>00581         {
<a name="l00582"></a>00582             bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#dc7d3639afc306668bd1d649c398b5d5" title="Setters and mutable accessors.">mutable_prevhop</a>()-&gt;<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#c1567b9080660f7b95fcd74047f8b399" title="Previous hop endpoint id.">prevhop_</a>);
<a name="l00583"></a>00583         }
<a name="l00584"></a>00584 
<a name="l00585"></a>00585         <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#04a51974754438d555bf8a7b0216cd38" title="Accessors.">prevhop</a>() != <span class="keyword">event</span>-&gt;prevhop_)
<a name="l00586"></a>00586         {
<a name="l00587"></a>00587             log_warn(<span class="stringliteral">"previous hop mismatch: prevhop header contains '%s' but "</span>
<a name="l00588"></a>00588                      <span class="stringliteral">"convergence layer indicates prevhop is '%s'"</span>,
<a name="l00589"></a>00589                      bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#04a51974754438d555bf8a7b0216cd38" title="Accessors.">prevhop</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(),
<a name="l00590"></a>00590                      <span class="keyword">event</span>-&gt;prevhop_.c_str());
<a name="l00591"></a>00591         }
<a name="l00592"></a>00592     }
<a name="l00593"></a>00593     
<a name="l00594"></a>00594     <span class="comment">/*</span>
<a name="l00595"></a>00595 <span class="comment">     * Check if the bundle isn't complete. If so, do reactive</span>
<a name="l00596"></a>00596 <span class="comment">     * fragmentation.</span>
<a name="l00597"></a>00597 <span class="comment">     */</span>
<a name="l00598"></a>00598     <span class="keywordflow">if</span> (event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#c65ff559e593a79e83d71978265a0407" title="The source of the bundle.">source_</a> == <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142bb0775776e4be46e62a0dcff6cf968059" title="a peer dtn forwarder">EVENTSRC_PEER</a>) {
<a name="l00599"></a>00599         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#3ba3870dc6faf048604b40979d347057" title="The total bytes actually received.">bytes_received_</a> != 0);
<a name="l00600"></a>00600         <a class="code" href="classdtn_1_1BundleDaemon.html#a0a2294a38635f5f76aba4375b0c2f7d" title="The fragmentation / reassembly manager.">fragmentmgr_</a>-&gt;<a class="code" href="classdtn_1_1FragmentManager.html#d3a2b8e4ecd2838da9caee845f47dccb" title="Convert a partially received bundle into a fragment.">try_to_convert_to_fragment</a>(bundle);
<a name="l00601"></a>00601     }
<a name="l00602"></a>00602 
<a name="l00603"></a>00603     <span class="comment">/*</span>
<a name="l00604"></a>00604 <span class="comment">     * validate a bundle, including all bundle blocks, received from a peer</span>
<a name="l00605"></a>00605 <span class="comment">     */</span>
<a name="l00606"></a>00606     <span class="keywordflow">if</span> (event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#c65ff559e593a79e83d71978265a0407" title="The source of the bundle.">source_</a> == <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142bb0775776e4be46e62a0dcff6cf968059" title="a peer dtn forwarder">EVENTSRC_PEER</a>) { 
<a name="l00607"></a>00607 
<a name="l00608"></a>00608         <span class="comment">/*</span>
<a name="l00609"></a>00609 <span class="comment">         * Check all BlockProcessors to validate the bundle.</span>
<a name="l00610"></a>00610 <span class="comment">         */</span>
<a name="l00611"></a>00611         <a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f917" title="Bundle Status Report &amp;quot;Reason Code&amp;quot; flags.">status_report_reason_t</a>
<a name="l00612"></a>00612             reception_reason = <a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f917eac137290a0338e66ed4a0c1cc09c2f2">BundleProtocol::REASON_NO_ADDTL_INFO</a>,
<a name="l00613"></a>00613             deletion_reason = <a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f917eac137290a0338e66ed4a0c1cc09c2f2">BundleProtocol::REASON_NO_ADDTL_INFO</a>;
<a name="l00614"></a>00614 
<a name="l00615"></a>00615         <span class="keywordtype">bool</span> valid = <a class="code" href="classdtn_1_1BundleProtocol.html#403d237e6ea6655a5e19b6c8f45dae3b" title="Loop through the bundle&amp;#39;s received block list to validate each entry.">BundleProtocol::validate</a>(bundle,
<a name="l00616"></a>00616                                               &amp;reception_reason,
<a name="l00617"></a>00617                                               &amp;deletion_reason);
<a name="l00618"></a>00618         
<a name="l00619"></a>00619         <span class="comment">/*</span>
<a name="l00620"></a>00620 <span class="comment">         * Send the reception receipt if requested within the primary</span>
<a name="l00621"></a>00621 <span class="comment">         * block or some other error occurs that requires a reception</span>
<a name="l00622"></a>00622 <span class="comment">         * status report but may or may not require deleting the whole</span>
<a name="l00623"></a>00623 <span class="comment">         * bundle.</span>
<a name="l00624"></a>00624 <span class="comment">         */</span>
<a name="l00625"></a>00625         <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#62e71f87a0f72127045bf18a0284843b" title="Accessors.">receive_rcpt</a>() ||
<a name="l00626"></a>00626             reception_reason != <a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f917eac137290a0338e66ed4a0c1cc09c2f2">BundleProtocol::REASON_NO_ADDTL_INFO</a>)
<a name="l00627"></a>00627         {
<a name="l00628"></a>00628             <a class="code" href="classdtn_1_1BundleDaemon.html#3847596a3b6b6a7e583947501491a87b" title="Locally generate a status report for the given bundle.">generate_status_report</a>(bundle, <a class="code" href="classdtn_1_1BundleStatusReport.html#b2546897ef428634d8385363b6de149923a02b797429c4a3cf6c5e89f65ee036">BundleStatusReport::STATUS_RECEIVED</a>,
<a name="l00629"></a>00629                                    reception_reason);
<a name="l00630"></a>00630         }
<a name="l00631"></a>00631 
<a name="l00632"></a>00632         <span class="comment">/*</span>
<a name="l00633"></a>00633 <span class="comment">         * If the bundle is valid, probe the router to see if it wants</span>
<a name="l00634"></a>00634 <span class="comment">         * to accept the bundle.</span>
<a name="l00635"></a>00635 <span class="comment">         */</span>
<a name="l00636"></a>00636         <span class="keywordtype">bool</span> accept_bundle = <span class="keyword">false</span>;
<a name="l00637"></a>00637         <span class="keywordflow">if</span> (valid) {
<a name="l00638"></a>00638             <span class="keywordtype">int</span> reason = <a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f917eac137290a0338e66ed4a0c1cc09c2f2">BundleProtocol::REASON_NO_ADDTL_INFO</a>;
<a name="l00639"></a>00639             accept_bundle = <a class="code" href="classdtn_1_1BundleDaemon.html#a5c8a244aad225987f9359ee1c2a1101" title="The active bundle router.">router_</a>-&gt;<a class="code" href="classdtn_1_1BundleRouter.html#47afbf9e1c42ae2cfb396c3895ddca45" title="Synchronous probe indicating whether or not this bundle should be accepted by the...">accept_bundle</a>(bundle, &amp;reason);
<a name="l00640"></a>00640             deletion_reason = <span class="keyword">static_cast&lt;</span><a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f917" title="Bundle Status Report &amp;quot;Reason Code&amp;quot; flags.">BundleProtocol::status_report_reason_t</a><span class="keyword">&gt;</span>(reason);
<a name="l00641"></a>00641         }
<a name="l00642"></a>00642         
<a name="l00643"></a>00643         <span class="comment">/*</span>
<a name="l00644"></a>00644 <span class="comment">         * Delete a bundle if a validation error was encountered or</span>
<a name="l00645"></a>00645 <span class="comment">         * the router doesn't want to accept the bundle, in both cases</span>
<a name="l00646"></a>00646 <span class="comment">         * not giving the reception event to the router.</span>
<a name="l00647"></a>00647 <span class="comment">         */</span>
<a name="l00648"></a>00648         <span class="keywordflow">if</span> (!accept_bundle) {
<a name="l00649"></a>00649             <a class="code" href="classdtn_1_1BundleDaemon.html#cf4244174dd62d8a39d80bc77915d23c" title="Delete (rather than silently discard) a bundle, e.g., an expired bundle.">delete_bundle</a>(bundleref, deletion_reason);
<a name="l00650"></a>00650             <span class="keyword">event</span>-&gt;daemon_only_ = <span class="keyword">true</span>;
<a name="l00651"></a>00651             <span class="keywordflow">return</span>;
<a name="l00652"></a>00652         }
<a name="l00653"></a>00653     }
<a name="l00654"></a>00654     
<a name="l00655"></a>00655     <span class="comment">/*</span>
<a name="l00656"></a>00656 <span class="comment">     * Check if the bundle is a duplicate, i.e. shares a source id,</span>
<a name="l00657"></a>00657 <span class="comment">     * timestamp, and fragmentation information with some other bundle</span>
<a name="l00658"></a>00658 <span class="comment">     * in the system.</span>
<a name="l00659"></a>00659 <span class="comment">     */</span>
<a name="l00660"></a>00660     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* duplicate = <a class="code" href="classdtn_1_1BundleDaemon.html#feb7761e0df0015e0af4dca266d7bd47" title="Check if there are any bundles in the pending queue that match the source id, timestamp...">find_duplicate</a>(bundle);
<a name="l00661"></a>00661     <span class="keywordflow">if</span> (duplicate != NULL) {
<a name="l00662"></a>00662         log_notice(<span class="stringliteral">"got duplicate bundle: %s -&gt; %s creation %u.%u"</span>,
<a name="l00663"></a>00663                    bundle-&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="l00664"></a>00664                    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="l00665"></a>00665                    bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a>,
<a name="l00666"></a>00666                    bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#ebc8cea66862d7f6056da450db410347" title="Sub-second sequence number.">seqno_</a>);
<a name="l00667"></a>00667 
<a name="l00668"></a>00668         <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#0d5fa3f893a635a22b65ea5e9a1faea2">duplicate_bundles_</a>++;
<a name="l00669"></a>00669         
<a name="l00670"></a>00670         <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#2261b28c9315c50a85bc35c1bcb6ace4" title="Accessors.">custody_requested</a>() &amp;&amp; duplicate-&gt;<a class="code" href="classdtn_1_1Bundle.html#dd00e0f0435b047bdde46c97cb513e3d" title="Accessors.">local_custody</a>())
<a name="l00671"></a>00671         {
<a name="l00672"></a>00672             <a class="code" href="classdtn_1_1BundleDaemon.html#0667dcac140e535a892d962bc9b95da0" title="Generate a custody signal to be sent to the current custodian.">generate_custody_signal</a>(bundle, <span class="keyword">false</span>,
<a name="l00673"></a>00673                                     <a class="code" href="classdtn_1_1BundleProtocol.html#e339b3a1104cd188459059e46543490b0a6d60329683ef33d75edbce647fb245">BundleProtocol::CUSTODY_REDUNDANT_RECEPTION</a>);
<a name="l00674"></a>00674         }
<a name="l00675"></a>00675 
<a name="l00676"></a>00676         <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleDaemon.html#a18fd65ff3e11b985f3e04a4591d4a33">params_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Params.html#44979b5e20d25f2cf0e1203bd89519f4" title="Whether or not to skip routing decisions for and delete duplicate bundles.">suppress_duplicates_</a>) {
<a name="l00677"></a>00677             <span class="comment">// since we don't want the bundle to be processed by the rest</span>
<a name="l00678"></a>00678             <span class="comment">// of the system, we mark the event as daemon_only (meaning it</span>
<a name="l00679"></a>00679             <span class="comment">// won't be forwarded to routers) and return, which should</span>
<a name="l00680"></a>00680             <span class="comment">// eventually remove all references on the bundle and then it</span>
<a name="l00681"></a>00681             <span class="comment">// will be deleted</span>
<a name="l00682"></a>00682             <span class="keyword">event</span>-&gt;daemon_only_ = <span class="keyword">true</span>;
<a name="l00683"></a>00683             <span class="keywordflow">return</span>;
<a name="l00684"></a>00684         }
<a name="l00685"></a>00685 
<a name="l00686"></a>00686         <span class="comment">// The BP says that the "dispatch pending" retention constraint</span>
<a name="l00687"></a>00687         <span class="comment">// must be removed from this bundle if there is a duplicate we</span>
<a name="l00688"></a>00688         <span class="comment">// currently have custody of. This would cause the bundle to have</span>
<a name="l00689"></a>00689         <span class="comment">// no retention constraints and it now "may" be discarded. Assuming</span>
<a name="l00690"></a>00690         <span class="comment">// this means it is supposed to be discarded, we have to suppress</span>
<a name="l00691"></a>00691         <span class="comment">// a duplicate in this situation regardless of the parameter</span>
<a name="l00692"></a>00692         <span class="comment">// setting. We would then be relying on the custody transfer timer</span>
<a name="l00693"></a>00693         <span class="comment">// to cause a new forwarding attempt in the case of routing loops</span>
<a name="l00694"></a>00694         <span class="comment">// instead of the receipt of a duplicate, so in theory we can indeed</span>
<a name="l00695"></a>00695         <span class="comment">// suppress this bundle. It may not be strictly required to do so,</span>
<a name="l00696"></a>00696         <span class="comment">// in which case we can remove the following block.</span>
<a name="l00697"></a>00697         <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#2261b28c9315c50a85bc35c1bcb6ace4" title="Accessors.">custody_requested</a>() &amp;&amp; duplicate-&gt;<a class="code" href="classdtn_1_1Bundle.html#dd00e0f0435b047bdde46c97cb513e3d" title="Accessors.">local_custody</a>()) {
<a name="l00698"></a>00698             <span class="keyword">event</span>-&gt;daemon_only_ = <span class="keyword">true</span>;
<a name="l00699"></a>00699             <span class="keywordflow">return</span>;
<a name="l00700"></a>00700         }
<a name="l00701"></a>00701 
<a name="l00702"></a>00702     }
<a name="l00703"></a>00703 
<a name="l00704"></a>00704     <span class="comment">/*</span>
<a name="l00705"></a>00705 <span class="comment">     * Add the bundle to the master pending queue and the data store</span>
<a name="l00706"></a>00706 <span class="comment">     * (unless the bundle was just reread from the data store on startup)</span>
<a name="l00707"></a>00707 <span class="comment">     *</span>
<a name="l00708"></a>00708 <span class="comment">     * Note that if add_to_pending returns false, the bundle has</span>
<a name="l00709"></a>00709 <span class="comment">     * already expired so we immediately return instead of trying to</span>
<a name="l00710"></a>00710 <span class="comment">     * deliver and/or forward the bundle. Otherwise there's a chance</span>
<a name="l00711"></a>00711 <span class="comment">     * that expired bundles will persist in the network.</span>
<a name="l00712"></a>00712 <span class="comment">     */</span>
<a name="l00713"></a>00713     <span class="keywordtype">bool</span> ok_to_route =
<a name="l00714"></a>00714         <a class="code" href="classdtn_1_1BundleDaemon.html#d488c6c663e4692388b21bf16416a2d2" title="Add the bundle to the pending list and (optionally) the persistent store, and set...">add_to_pending</a>(bundle, (event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#c65ff559e593a79e83d71978265a0407" title="The source of the bundle.">source_</a> != <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b8fb8e6004d0ab350daca47bdcc106866" title="the data store">EVENTSRC_STORE</a>));
<a name="l00715"></a>00715 
<a name="l00716"></a>00716     <span class="keywordflow">if</span> (!ok_to_route) {
<a name="l00717"></a>00717         <span class="keyword">event</span>-&gt;daemon_only_ = <span class="keyword">true</span>;
<a name="l00718"></a>00718         <span class="keywordflow">return</span>;
<a name="l00719"></a>00719     }
<a name="l00720"></a>00720     
<a name="l00721"></a>00721     <span class="comment">/*</span>
<a name="l00722"></a>00722 <span class="comment">     * If the bundle is a custody bundle and we're configured to take</span>
<a name="l00723"></a>00723 <span class="comment">     * custody, then do so. In case the event was delivered due to a</span>
<a name="l00724"></a>00724 <span class="comment">     * reload from the data store, then if we have local custody, make</span>
<a name="l00725"></a>00725 <span class="comment">     * sure it's added to the custody bundles list.</span>
<a name="l00726"></a>00726 <span class="comment">     */</span>
<a name="l00727"></a>00727     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#2261b28c9315c50a85bc35c1bcb6ace4" title="Accessors.">custody_requested</a>() &amp;&amp; <a class="code" href="classdtn_1_1BundleDaemon.html#a18fd65ff3e11b985f3e04a4591d4a33">params_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Params.html#59df7c4162a660666ad6bc047cda72df" title="Whether or not to accept custody when requested.">accept_custody_</a>
<a name="l00728"></a>00728         &amp;&amp; (duplicate == NULL || !duplicate-&gt;<a class="code" href="classdtn_1_1Bundle.html#dd00e0f0435b047bdde46c97cb513e3d" title="Accessors.">local_custody</a>()))
<a name="l00729"></a>00729     {
<a name="l00730"></a>00730         <span class="keywordflow">if</span> (event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#c65ff559e593a79e83d71978265a0407" title="The source of the bundle.">source_</a> != <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b8fb8e6004d0ab350daca47bdcc106866" title="the data store">EVENTSRC_STORE</a>) {
<a name="l00731"></a>00731             <a class="code" href="classdtn_1_1BundleDaemon.html#cd91a9612a25c23580b75a951a382267" title="Take custody for the given bundle, sending the appropriate signal to the current...">accept_custody</a>(bundle);
<a name="l00732"></a>00732         
<a name="l00733"></a>00733         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#dd00e0f0435b047bdde46c97cb513e3d" title="Accessors.">local_custody</a>()) {
<a name="l00734"></a>00734             <a class="code" href="classdtn_1_1BundleDaemon.html#ce140ab25aea62199a71e73e216845a5" title="The list of all bundles that we have custody of.">custody_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#9f3efd0593739e89ed478fd4bbccd3e0" title="Add a new bundle to the back of the list.">push_back</a>(bundle);
<a name="l00735"></a>00735         }
<a name="l00736"></a>00736     }
<a name="l00737"></a>00737 
<a name="l00738"></a>00738     <span class="comment">/*</span>
<a name="l00739"></a>00739 <span class="comment">     * If this bundle is a duplicate and it has not been suppressed, we</span>
<a name="l00740"></a>00740 <span class="comment">     * can assume the bundle it duplicates has already been delivered or</span>
<a name="l00741"></a>00741 <span class="comment">     * added to the fragment manager if required, so do not do so again.</span>
<a name="l00742"></a>00742 <span class="comment">     * We can bounce out now.</span>
<a name="l00743"></a>00743 <span class="comment">     * XXX/jmmikkel If the extension blocks differ and we care to</span>
<a name="l00744"></a>00744 <span class="comment">     * do something with them, we can't bounce out quite yet.</span>
<a name="l00745"></a>00745 <span class="comment">     */</span>
<a name="l00746"></a>00746     <span class="keywordflow">if</span> (duplicate != NULL) {
<a name="l00747"></a>00747         <span class="keywordflow">return</span>;
<a name="l00748"></a>00748     }
<a name="l00749"></a>00749 
<a name="l00750"></a>00750     <span class="comment">/*</span>
<a name="l00751"></a>00751 <span class="comment">     * Check if this is a complete (non-fragment) bundle that</span>
<a name="l00752"></a>00752 <span class="comment">     * obsoletes any fragments that we know about.</span>
<a name="l00753"></a>00753 <span class="comment">     */</span>
<a name="l00754"></a>00754     <span class="keywordflow">if</span> (! bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#d6c74eba219bfe55854cf7a90e210cca" title="Accessors.">is_fragment</a>()) {
<a name="l00755"></a>00755         <a class="code" href="classdtn_1_1BundleDaemon.html#a0a2294a38635f5f76aba4375b0c2f7d" title="The fragmentation / reassembly manager.">fragmentmgr_</a>-&gt;<a class="code" href="classdtn_1_1FragmentManager.html#900e9f477dc6ff5aac6cd6621daf04d9" title="Delete any fragments that are no longer needed given the incoming (non-fragment)...">delete_obsoleted_fragments</a>(bundle);
<a name="l00756"></a>00756     }
<a name="l00757"></a>00757 
<a name="l00758"></a>00758     <span class="comment">/*</span>
<a name="l00759"></a>00759 <span class="comment">     * Deliver the bundle to any local registrations that it matches,</span>
<a name="l00760"></a>00760 <span class="comment">     * unless it's generated by the router or is a bundle fragment.</span>
<a name="l00761"></a>00761 <span class="comment">     * Delivery of bundle fragments is deferred until after re-assembly.</span>
<a name="l00762"></a>00762 <span class="comment">     */</span>
<a name="l00763"></a>00763     <span class="keywordtype">bool</span> is_local =
<a name="l00764"></a>00764         <a class="code" href="classdtn_1_1BundleDaemon.html#f3a66691215ba378336f8241b111d364" title="Check the registration table and optionally deliver the bundle to any that match...">check_local_delivery</a>(bundle,
<a name="l00765"></a>00765                              (event-&gt;<a class="code" href="classdtn_1_1BundleReceivedEvent.html#c65ff559e593a79e83d71978265a0407" title="The source of the bundle.">source_</a>       != <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b25abe58c828214d9857f0fa1249db869" title="the routing logic">EVENTSRC_ROUTER</a>) &amp;&amp;
<a name="l00766"></a>00766                              (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#d6c74eba219bfe55854cf7a90e210cca" title="Accessors.">is_fragment</a>() == <span class="keyword">false</span>));
<a name="l00767"></a>00767     
<a name="l00768"></a>00768     <span class="comment">/*</span>
<a name="l00769"></a>00769 <span class="comment">     * Re-assemble bundle fragments that are destined to the local node.</span>
<a name="l00770"></a>00770 <span class="comment">     */</span>
<a name="l00771"></a>00771     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#d6c74eba219bfe55854cf7a90e210cca" title="Accessors.">is_fragment</a>() &amp;&amp; is_local) {
<a name="l00772"></a>00772         log_debug(<span class="stringliteral">"deferring delivery of bundle *%p "</span>
<a name="l00773"></a>00773                   <span class="stringliteral">"since bundle is a fragment"</span>, bundle);
<a name="l00774"></a>00774         <a class="code" href="classdtn_1_1BundleDaemon.html#a0a2294a38635f5f76aba4375b0c2f7d" title="The fragmentation / reassembly manager.">fragmentmgr_</a>-&gt;<a class="code" href="classdtn_1_1FragmentManager.html#06ba9686e9d9a7fca8cdc31c3ffca187" title="Given a newly arrived bundle fragment, append it to the table of fragments and see...">process_for_reassembly</a>(bundle);
<a name="l00775"></a>00775     }
<a name="l00776"></a>00776 
<a name="l00777"></a>00777     <span class="comment">/*</span>
<a name="l00778"></a>00778 <span class="comment">     * Finally, bounce out so the router(s) can do something further</span>
<a name="l00779"></a>00779 <span class="comment">     * with the bundle in response to the event.</span>
<a name="l00780"></a>00780 <span class="comment">     */</span>
<a name="l00781"></a>00781 }
<a name="l00782"></a>00782 
<a name="l00783"></a>00783 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00784"></a>00784 <span class="keywordtype">void</span>
<a name="l00785"></a><a class="code" href="classdtn_1_1BundleDaemon.html#6187e4abcac29a42afe340983a15c91c">00785</a> <a class="code" href="classdtn_1_1BundleDaemon.html#6187e4abcac29a42afe340983a15c91c" title="Event type specific handlers.">BundleDaemon::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="l00786"></a>00786 {
<a name="l00787"></a>00787     <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="l00788"></a>00788 
<a name="l00789"></a>00789     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = <span class="keyword">event</span>-&gt;link_;
<a name="l00790"></a>00790     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l00791"></a>00791     
<a name="l00792"></a>00792     log_debug(<span class="stringliteral">"trying to find xmit blocks for bundle id:%d on link %s"</span>,
<a name="l00793"></a>00793               bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(),link-&gt;name());
<a name="l00794"></a>00794     <a class="code" href="classdtn_1_1BlockInfoVec.html" title="Class for a vector of BlockInfo structures.">BlockInfoVec</a>* blocks = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#0ce0961036dd0da1fd322721cbb794aa" title="Setters and mutable accessors.">xmit_blocks</a>()-&gt;<a class="code" href="classdtn_1_1LinkBlockSet.html#07658a9543619b3ab3f1493a2dd68e85" title="Find the BlockInfoVec for the given link.">find_blocks</a>(link);
<a name="l00795"></a>00795     
<a name="l00796"></a>00796     <span class="comment">// Because a CL is running in another thread or process (External CLs),</span>
<a name="l00797"></a>00797     <span class="comment">// we cannot prevent all redundant transmit/cancel/transmit_failed messages.</span>
<a name="l00798"></a>00798     <span class="comment">// If an event about a bundle bound for particular link is posted after another,</span>
<a name="l00799"></a>00799     <span class="comment">// which it might contradict, the BundleDaemon need not reprocess the event.</span>
<a name="l00800"></a>00800     <span class="comment">// The router (DP) might, however, be interested in the new status of the send.</span>
<a name="l00801"></a>00801     <span class="keywordflow">if</span>(blocks == NULL)
<a name="l00802"></a>00802     {
<a name="l00803"></a>00803         log_info(<span class="stringliteral">"received a redundant/conflicting bundle_transmit event about "</span>
<a name="l00804"></a>00804                  <span class="stringliteral">"bundle id:%d -&gt; %s (%s)"</span>,
<a name="l00805"></a>00805                  bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(),
<a name="l00806"></a>00806                  link-&gt;name(),
<a name="l00807"></a>00807                  link-&gt;nexthop());
<a name="l00808"></a>00808         <span class="keywordflow">return</span>;
<a name="l00809"></a>00809     }
<a name="l00810"></a>00810     
<a name="l00811"></a>00811     <span class="comment">/*</span>
<a name="l00812"></a>00812 <span class="comment">     * Update statistics and remove the bundle from the link inflight</span>
<a name="l00813"></a>00813 <span class="comment">     * queue. Note that the link's queued length statistics must</span>
<a name="l00814"></a>00814 <span class="comment">     * always be decremented by the full formatted size of the bundle,</span>
<a name="l00815"></a>00815 <span class="comment">     * yet the transmitted length is only the amount reported by the</span>
<a name="l00816"></a>00816 <span class="comment">     * event.</span>
<a name="l00817"></a>00817 <span class="comment">     */</span>
<a name="l00818"></a>00818     <span class="keywordtype">size_t</span> total_len = <a class="code" href="classdtn_1_1BundleProtocol.html#a1dedd9ea4300339bc2a3f7a231ca5dd" title="Return the total length of the formatted bundle block data.">BundleProtocol::total_length</a>(blocks);
<a name="l00819"></a>00819     
<a name="l00820"></a>00820     <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#989e3916cbfdbb3174962bb4ba6b041c">transmitted_bundles_</a>++;
<a name="l00821"></a>00821     
<a name="l00822"></a>00822     link-&gt;stats()-&gt;bundles_transmitted_++;
<a name="l00823"></a>00823     link-&gt;stats()-&gt;bytes_transmitted_ += <span class="keyword">event</span>-&gt;bytes_sent_;
<a name="l00824"></a>00824 
<a name="l00825"></a>00825     <span class="comment">// remove the bundle from the link's in flight queue</span>
<a name="l00826"></a>00826     <span class="keywordflow">if</span> (link-&gt;del_from_inflight(event-&gt;<a class="code" href="classdtn_1_1BundleTransmittedEvent.html#1d7eb733d3768632525dc99663473b2c" title="The transmitted bundle.">bundleref_</a>, total_len)) {
<a name="l00827"></a>00827         log_debug(<span class="stringliteral">"removed bundle id:%d from link %s inflight queue"</span>,
<a name="l00828"></a>00828                  bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(),
<a name="l00829"></a>00829                  link-&gt;name());
<a name="l00830"></a>00830     } <span class="keywordflow">else</span> {
<a name="l00831"></a>00831         log_warn(<span class="stringliteral">"bundle id:%d not on link %s inflight queue"</span>,
<a name="l00832"></a>00832                  bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(),
<a name="l00833"></a>00833                  link-&gt;name());
<a name="l00834"></a>00834     }
<a name="l00835"></a>00835     
<a name="l00836"></a>00836     <span class="comment">// verify that the bundle is not on the link's to-be-sent queue</span>
<a name="l00837"></a>00837     <span class="keywordflow">if</span> (link-&gt;del_from_queue(event-&gt;<a class="code" href="classdtn_1_1BundleTransmittedEvent.html#1d7eb733d3768632525dc99663473b2c" title="The transmitted bundle.">bundleref_</a>, total_len)) {
<a name="l00838"></a>00838         log_warn(<span class="stringliteral">"bundle id:%d unexpectedly on link %s queue in transmitted event"</span>,
<a name="l00839"></a>00839                  bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(),
<a name="l00840"></a>00840                  link-&gt;name());
<a name="l00841"></a>00841     }
<a name="l00842"></a>00842     
<a name="l00843"></a>00843     log_info(<span class="stringliteral">"BUNDLE_TRANSMITTED id:%d (%u bytes_sent/%u reliable) -&gt; %s (%s)"</span>,
<a name="l00844"></a>00844              bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(),
<a name="l00845"></a>00845              <span class="keyword">event</span>-&gt;bytes_sent_,
<a name="l00846"></a>00846              <span class="keyword">event</span>-&gt;reliably_sent_,
<a name="l00847"></a>00847              link-&gt;name(),
<a name="l00848"></a>00848              link-&gt;nexthop());
<a name="l00849"></a>00849 
<a name="l00850"></a>00850     <span class="comment">/*</span>
<a name="l00851"></a>00851 <span class="comment">     * If we're configured to wait for reliable transmission, then</span>
<a name="l00852"></a>00852 <span class="comment">     * check the special case where we transmitted some or all a</span>
<a name="l00853"></a>00853 <span class="comment">     * bundle but nothing was acked. In this case, we create a</span>
<a name="l00854"></a>00854 <span class="comment">     * transmission failed event in the forwarding log and don't do</span>
<a name="l00855"></a>00855 <span class="comment">     * any of the rest of the processing below.</span>
<a name="l00856"></a>00856 <span class="comment">     *</span>
<a name="l00857"></a>00857 <span class="comment">     * Note also the special care taken to handle a zero-length</span>
<a name="l00858"></a>00858 <span class="comment">     * bundle. XXX/demmer this should all go away when the lengths</span>
<a name="l00859"></a>00859 <span class="comment">     * include both the header length and the payload length (in which</span>
<a name="l00860"></a>00860 <span class="comment">     * case it's never zero).</span>
<a name="l00861"></a>00861 <span class="comment">     *</span>
<a name="l00862"></a>00862 <span class="comment">     * XXX/demmer a better thing to do (maybe) would be to record the</span>
<a name="l00863"></a>00863 <span class="comment">     * lengths in the forwarding log as part of the transmitted entry.</span>
<a name="l00864"></a>00864 <span class="comment">     */</span>
<a name="l00865"></a>00865     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleDaemon.html#a18fd65ff3e11b985f3e04a4591d4a33">params_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Params.html#8ef371f4a6139e23d45997659c24542a" title="Whether or not to retry unacked transmissions on reliable CLs.">retry_reliable_unacked_</a> &amp;&amp;
<a name="l00866"></a>00866         link-&gt;is_reliable() &amp;&amp;
<a name="l00867"></a>00867         (<span class="keyword">event</span>-&gt;bytes_sent_ != <span class="keyword">event</span>-&gt;reliably_sent_) &amp;&amp;
<a name="l00868"></a>00868         (event-&gt;<a class="code" href="classdtn_1_1BundleTransmittedEvent.html#e6305d411cf9910d910adfc8922e3ffd" title="If the convergence layer that we sent on is reliable, this is the count of the bytes...">reliably_sent_</a> == 0))
<a name="l00869"></a>00869     {
<a name="l00870"></a>00870         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#249ac137ef76e253d8e0587f2662bca7" title="Accessors.">fwdlog</a>()-&gt;<a class="code" href="classdtn_1_1ForwardingLog.html#a6d756d62a3007192f415a35607e5f38" title="Update the state for the latest forwarding info entry for the given link.">update</a>(link, <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad8762bec07606b49265941702199630e9" title="Transmission failed.">ForwardingInfo::TRANSMIT_FAILED</a>);
<a name="l00871"></a>00871         log_debug(<span class="stringliteral">"trying to delete xmit blocks for bundle id:%d on link %s"</span>,
<a name="l00872"></a>00872                   bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(),link-&gt;name());
<a name="l00873"></a>00873         <a class="code" href="classdtn_1_1BundleProtocol.html#df59b9b818853e07bfb7464312ca7092">BundleProtocol::delete_blocks</a>(bundle, link);
<a name="l00874"></a>00874 
<a name="l00875"></a>00875         log_warn(<span class="stringliteral">"XXX/demmer fixme transmitted special case"</span>);
<a name="l00876"></a>00876         
<a name="l00877"></a>00877         <span class="keywordflow">return</span>;
<a name="l00878"></a>00878     }
<a name="l00879"></a>00879 
<a name="l00880"></a>00880     <span class="comment">/*</span>
<a name="l00881"></a>00881 <span class="comment">     * Grab the latest forwarding log state so we can find the custody</span>
<a name="l00882"></a>00882 <span class="comment">     * timer information (if any).</span>
<a name="l00883"></a>00883 <span class="comment">     */</span>
<a name="l00884"></a>00884     <a class="code" href="classdtn_1_1ForwardingInfo.html" title="Class to encapsulate bundle forwarding information.">ForwardingInfo</a> fwdinfo;
<a name="l00885"></a>00885     <span class="keywordtype">bool</span> ok = 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;fwdinfo);
<a name="l00886"></a>00886     <span class="keywordflow">if</span>(!ok)
<a name="l00887"></a>00887     {
<a name="l00888"></a>00888         oasys::StringBuffer <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>;
<a name="l00889"></a>00889         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#249ac137ef76e253d8e0587f2662bca7" title="Accessors.">fwdlog</a>()-&gt;<a class="code" href="classdtn_1_1ForwardingLog.html#43e4efb3eeb1a479bf2afefdfe1def4f" title="Dump a string representation of the log.">dump</a>(&amp;buf);
<a name="l00890"></a>00890         log_debug(<span class="stringliteral">"%s"</span>,buf.c_str());
<a name="l00891"></a>00891     }
<a name="l00892"></a>00892     ASSERTF(ok, <span class="stringliteral">"no forwarding log entry for transmission"</span>);
<a name="l00893"></a>00893     <span class="comment">// ASSERT(fwdinfo.state() == ForwardingInfo::QUEUED);</span>
<a name="l00894"></a>00894     <span class="keywordflow">if</span> (fwdinfo.<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="l00895"></a>00895         log_err(<span class="stringliteral">"*%p fwdinfo state %s != expected QUEUED"</span>,
<a name="l00896"></a>00896                 bundle, <a class="code" href="classdtn_1_1ForwardingInfo.html#9493021a5f38f38139a1fd5b7d0f631e">ForwardingInfo::state_to_str</a>(fwdinfo.<a class="code" href="classdtn_1_1ForwardingInfo.html#9c2aa7be84c9b1f5a81d1cc19445dd53" title="Accessors.">state</a>()));
<a name="l00897"></a>00897     }
<a name="l00898"></a>00898     
<a name="l00899"></a>00899     <span class="comment">/*</span>
<a name="l00900"></a>00900 <span class="comment">     * Update the forwarding log indicating that the bundle is no</span>
<a name="l00901"></a>00901 <span class="comment">     * longer in flight.</span>
<a name="l00902"></a>00902 <span class="comment">     */</span>
<a name="l00903"></a>00903     log_debug(<span class="stringliteral">"updating forwarding log entry on *%p for *%p to TRANSMITTED"</span>,
<a name="l00904"></a>00904               bundle, link.object());
<a name="l00905"></a>00905     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#249ac137ef76e253d8e0587f2662bca7" title="Accessors.">fwdlog</a>()-&gt;<a class="code" href="classdtn_1_1ForwardingLog.html#a6d756d62a3007192f415a35607e5f38" title="Update the state for the latest forwarding info entry for the given link.">update</a>(link, <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad4222cd2abd08c71c5b5387cf23ca6193" title="Successfully transmitted.">ForwardingInfo::TRANSMITTED</a>);
<a name="l00906"></a>00906                             
<a name="l00907"></a>00907     <span class="comment">/*</span>
<a name="l00908"></a>00908 <span class="comment">     * Check for reactive fragmentation. If the bundle was only</span>
<a name="l00909"></a>00909 <span class="comment">     * partially sent, then a new bundle received event for the tail</span>
<a name="l00910"></a>00910 <span class="comment">     * part of the bundle will be processed immediately after this</span>
<a name="l00911"></a>00911 <span class="comment">     * event.</span>
<a name="l00912"></a>00912 <span class="comment">     */</span>
<a name="l00913"></a>00913     <span class="keywordflow">if</span> (link-&gt;reliable_) {
<a name="l00914"></a>00914         <a class="code" href="classdtn_1_1BundleDaemon.html#a0a2294a38635f5f76aba4375b0c2f7d" title="The fragmentation / reassembly manager.">fragmentmgr_</a>-&gt;<a class="code" href="classdtn_1_1FragmentManager.html#2f9394ef9f40337b95fed1f6cca381ac" title="If only part of the given bundle was sent successfully, split it into two.">try_to_reactively_fragment</a>(bundle,
<a name="l00915"></a>00915                                                  blocks,
<a name="l00916"></a>00916                                                  event-&gt;<a class="code" href="classdtn_1_1BundleTransmittedEvent.html#e6305d411cf9910d910adfc8922e3ffd" title="If the convergence layer that we sent on is reliable, this is the count of the bytes...">reliably_sent_</a>);
<a name="l00917"></a>00917     } <span class="keywordflow">else</span> {
<a name="l00918"></a>00918         <a class="code" href="classdtn_1_1BundleDaemon.html#a0a2294a38635f5f76aba4375b0c2f7d" title="The fragmentation / reassembly manager.">fragmentmgr_</a>-&gt;<a class="code" href="classdtn_1_1FragmentManager.html#2f9394ef9f40337b95fed1f6cca381ac" title="If only part of the given bundle was sent successfully, split it into two.">try_to_reactively_fragment</a>(bundle,
<a name="l00919"></a>00919                                                  blocks,
<a name="l00920"></a>00920                                                  event-&gt;<a class="code" href="classdtn_1_1BundleTransmittedEvent.html#1fefef8bfc399dcb0ecb0a5ba7c74f3c" title="Total number of bytes sent.">bytes_sent_</a>);
<a name="l00921"></a>00921     }
<a name="l00922"></a>00922 
<a name="l00923"></a>00923     <span class="comment">/*</span>
<a name="l00924"></a>00924 <span class="comment">     * Remove the formatted block info from the bundle since we don't</span>
<a name="l00925"></a>00925 <span class="comment">     * need it any more.</span>
<a name="l00926"></a>00926 <span class="comment">     */</span>
<a name="l00927"></a>00927     log_debug(<span class="stringliteral">"trying to delete xmit blocks for bundle id:%d on link %s"</span>,
<a name="l00928"></a>00928               bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(),link-&gt;name());
<a name="l00929"></a>00929     <a class="code" href="classdtn_1_1BundleProtocol.html#df59b9b818853e07bfb7464312ca7092">BundleProtocol::delete_blocks</a>(bundle, link);
<a name="l00930"></a>00930     blocks = NULL;
<a name="l00931"></a>00931 
<a name="l00932"></a>00932     <span class="comment">/*</span>
<a name="l00933"></a>00933 <span class="comment">     * Generate the forwarding status report if requested</span>
<a name="l00934"></a>00934 <span class="comment">     */</span>
<a name="l00935"></a>00935     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#93c641bdb9a4beda553d8f28e60c99fd" title="Accessors.">forward_rcpt</a>()) {
<a name="l00936"></a>00936         <a class="code" href="classdtn_1_1BundleDaemon.html#3847596a3b6b6a7e583947501491a87b" title="Locally generate a status report for the given bundle.">generate_status_report</a>(bundle, <a class="code" href="classdtn_1_1BundleStatusReport.html#b2546897ef428634d8385363b6de14990bf1d45c8cccd8402bde14ee94f6547f">BundleStatusReport::STATUS_FORWARDED</a>);
<a name="l00937"></a>00937     }
<a name="l00938"></a>00938     
<a name="l00939"></a>00939     <span class="comment">/*</span>
<a name="l00940"></a>00940 <span class="comment">     * Schedule a custody timer if we have custody.</span>
<a name="l00941"></a>00941 <span class="comment">     */</span>
<a name="l00942"></a>00942     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#dd00e0f0435b047bdde46c97cb513e3d" title="Accessors.">local_custody</a>()) {
<a name="l00943"></a>00943         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#ee3040af6e2509507fbd3380f8fcfd1a" title="Setters and mutable accessors.">custody_timers</a>()-&gt;push_back(
<a name="l00944"></a>00944             <span class="keyword">new</span> <a class="code" href="classdtn_1_1CustodyTimer.html" title="A custody transfer timer.">CustodyTimer</a>(fwdinfo.<a class="code" href="classdtn_1_1ForwardingInfo.html#1d648dda9ea1894f9e7fd355a8fd412e" title="Accessors.">timestamp</a>(),
<a name="l00945"></a>00945                              fwdinfo.<a class="code" href="classdtn_1_1ForwardingInfo.html#0c917dfbc2952c2c827609b5a27b5d92" title="Accessors.">custody_spec</a>(),
<a name="l00946"></a>00946                              bundle, link));
<a name="l00947"></a>00947         
<a name="l00948"></a>00948         <span class="comment">// XXX/TODO: generate failed custodial signal for "forwarded</span>
<a name="l00949"></a>00949         <span class="comment">// over unidirectional link" if the bundle has the retention</span>
<a name="l00950"></a>00950         <span class="comment">// constraint "custody accepted" and all of the nodes in the</span>
<a name="l00951"></a>00951         <span class="comment">// minimum reception group of the endpoint selected for</span>
<a name="l00952"></a>00952         <span class="comment">// forwarding are known to be unable to send bundles back to</span>
<a name="l00953"></a>00953         <span class="comment">// this node</span>
<a name="l00954"></a>00954     }
<a name="l00955"></a>00955 }
<a name="l00956"></a>00956 
<a name="l00957"></a>00957 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00958"></a>00958 <span class="keywordtype">void</span>
<a name="l00959"></a><a class="code" href="classdtn_1_1BundleDaemon.html#9f29ae16ab60d2e9950a15cbffd1d9ab">00959</a> <a class="code" href="classdtn_1_1BundleDaemon.html#9f29ae16ab60d2e9950a15cbffd1d9ab" title="Event type specific handlers.">BundleDaemon::handle_bundle_delivered</a>(<a class="code" href="classdtn_1_1BundleDeliveredEvent.html" title="Event class for local bundle delivery.">BundleDeliveredEvent</a>* event)
<a name="l00960"></a>00960 {
<a name="l00961"></a>00961     <span class="comment">// update statistics</span>
<a name="l00962"></a>00962     <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#296369d7b5496abf65cb2f4b080f17d1">delivered_bundles_</a>++;
<a name="l00963"></a>00963     
<a name="l00964"></a>00964     <span class="comment">/*</span>
<a name="l00965"></a>00965 <span class="comment">     * The bundle was delivered to a registration.</span>
<a name="l00966"></a>00966 <span class="comment">     */</span>
<a name="l00967"></a>00967     <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="l00968"></a>00968 
<a name="l00969"></a>00969     log_info(<span class="stringliteral">"BUNDLE_DELIVERED id:%d (%zu bytes) -&gt; regid %d (%s)"</span>,
<a name="l00970"></a>00970              bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</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="l00971"></a>00971              <span class="keyword">event</span>-&gt;registration_-&gt;regid(),
<a name="l00972"></a>00972              <span class="keyword">event</span>-&gt;registration_-&gt;endpoint().c_str());
<a name="l00973"></a>00973 
<a name="l00974"></a>00974     <span class="comment">/*</span>
<a name="l00975"></a>00975 <span class="comment">     * Generate the delivery status report if requested.</span>
<a name="l00976"></a>00976 <span class="comment">     */</span>
<a name="l00977"></a>00977     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#a48fd652ab931a694f79cc1c6e47985d" title="Accessors.">delivery_rcpt</a>())
<a name="l00978"></a>00978     {
<a name="l00979"></a>00979         <a class="code" href="classdtn_1_1BundleDaemon.html#3847596a3b6b6a7e583947501491a87b" title="Locally generate a status report for the given bundle.">generate_status_report</a>(bundle, <a class="code" href="classdtn_1_1BundleStatusReport.html#b2546897ef428634d8385363b6de1499c3d5b382fe3e58a9ef8a7ad98203e9f0">BundleStatusReport::STATUS_DELIVERED</a>);
<a name="l00980"></a>00980     }
<a name="l00981"></a>00981 
<a name="l00982"></a>00982     <span class="comment">/*</span>
<a name="l00983"></a>00983 <span class="comment">     * If this is a custodial bundle and it was delivered, we either</span>
<a name="l00984"></a>00984 <span class="comment">     * release custody (if we have it), or send a custody signal to</span>
<a name="l00985"></a>00985 <span class="comment">     * the current custodian indicating that the bundle was</span>
<a name="l00986"></a>00986 <span class="comment">     * successfully delivered, unless there is no current custodian</span>
<a name="l00987"></a>00987 <span class="comment">     * (the eid is still dtn:none).</span>
<a name="l00988"></a>00988 <span class="comment">     */</span>
<a name="l00989"></a>00989     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#2261b28c9315c50a85bc35c1bcb6ace4" title="Accessors.">custody_requested</a>())
<a name="l00990"></a>00990     {
<a name="l00991"></a>00991         <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#dd00e0f0435b047bdde46c97cb513e3d" title="Accessors.">local_custody</a>()) {
<a name="l00992"></a>00992             <a class="code" href="classdtn_1_1BundleDaemon.html#94f9a6f6615e0249f679b4dccee7e1a3" title="Release custody of the given bundle, sending the appropriate signal to the current...">release_custody</a>(bundle);
<a name="l00993"></a>00993 
<a name="l00994"></a>00994         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#eb68ec729851c7e7221fe7cb61f19875" title="Accessors.">custodian</a>().<a class="code" href="classdtn_1_1EndpointID.html#80721c0832c08c5066e6d6276d62d70b" title="Simple equality test function.">equals</a>(<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="l00995"></a>00995             log_info(<span class="stringliteral">"custodial bundle *%p delivered before custody accepted"</span>,
<a name="l00996"></a>00996                      bundle);
<a name="l00997"></a>00997 
<a name="l00998"></a>00998         } <span class="keywordflow">else</span> {
<a name="l00999"></a>00999             <a class="code" href="classdtn_1_1BundleDaemon.html#0667dcac140e535a892d962bc9b95da0" title="Generate a custody signal to be sent to the current custodian.">generate_custody_signal</a>(bundle, <span class="keyword">true</span>,
<a name="l01000"></a>01000                                     <a class="code" href="classdtn_1_1BundleProtocol.html#e339b3a1104cd188459059e46543490bf974eaaa8cbe4e66aeaf238a454cecf1">BundleProtocol::CUSTODY_NO_ADDTL_INFO</a>);
<a name="l01001"></a>01001         }
<a name="l01002"></a>01002     }
<a name="l01003"></a>01003 }
<a name="l01004"></a>01004 
<a name="l01005"></a>01005 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01006"></a>01006 <span class="keywordtype">void</span>
<a name="l01007"></a><a class="code" href="classdtn_1_1BundleDaemon.html#1b71603aec2f9ce0745b9552a09cf9a2">01007</a> <a class="code" href="classdtn_1_1BundleDaemon.html#1b71603aec2f9ce0745b9552a09cf9a2" title="Event type specific handlers.">BundleDaemon::handle_bundle_expired</a>(<a class="code" href="classdtn_1_1BundleExpiredEvent.html" title="Event class for bundle expiration.">BundleExpiredEvent</a>* event)
<a name="l01008"></a>01008 {
<a name="l01009"></a>01009     <span class="comment">// update statistics</span>
<a name="l01010"></a>01010     <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#c85c7be254f9241a2fb610fb9e6cf4e9">expired_bundles_</a>++;
<a name="l01011"></a>01011     
<a name="l01012"></a>01012     <span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; bundle = <span class="keyword">event</span>-&gt;bundleref_;
<a name="l01013"></a>01013 
<a name="l01014"></a>01014     log_info(<span class="stringliteral">"BUNDLE_EXPIRED *%p"</span>, bundle.object());
<a name="l01015"></a>01015 
<a name="l01016"></a>01016     <span class="comment">// note that there may or may not still be a pending expiration</span>
<a name="l01017"></a>01017     <span class="comment">// timer, since this event may be coming from the console, so we</span>
<a name="l01018"></a>01018     <span class="comment">// just fall through to delete_bundle which will cancel the timer</span>
<a name="l01019"></a>01019 
<a name="l01020"></a>01020     <a class="code" href="classdtn_1_1BundleDaemon.html#cf4244174dd62d8a39d80bc77915d23c" title="Delete (rather than silently discard) a bundle, e.g., an expired bundle.">delete_bundle</a>(bundle, <a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f91773f35a814d405ad151db78f95422a394">BundleProtocol::REASON_LIFETIME_EXPIRED</a>);
<a name="l01021"></a>01021     
<a name="l01022"></a>01022     <span class="comment">// fall through to notify the routers</span>
<a name="l01023"></a>01023 }
<a name="l01024"></a>01024 
<a name="l01025"></a>01025 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01026"></a>01026 <span class="keywordtype">void</span>
<a name="l01027"></a><a class="code" href="classdtn_1_1BundleDaemon.html#0505c770df7cfe33110db8df28013b33">01027</a> <a class="code" href="classdtn_1_1BundleDaemon.html#0505c770df7cfe33110db8df28013b33" title="Event type specific handlers.">BundleDaemon::handle_bundle_send</a>(<a class="code" href="classdtn_1_1BundleSendRequest.html" title="Event class for sending a bundle.">BundleSendRequest</a>* event)
<a name="l01028"></a>01028 {
<a name="l01029"></a>01029     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = <a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#4a31131016ed7f6b11ce6823dd7abe91" title="Finds link corresponding to this name.">find_link</a>(event-&gt;<a class="code" href="classdtn_1_1BundleSendRequest.html#35bca6bb33ae76e0b9879a1bbfce0131" title="Forwarding action to use when sending bundle.">link_</a>.c_str());
<a name="l01030"></a>01030     <span class="keywordflow">if</span> (link == NULL){
<a name="l01031"></a>01031         log_err(<span class="stringliteral">"Cannot send bundle on unknown link %s"</span>, event-&gt;<a class="code" href="classdtn_1_1BundleSendRequest.html#35bca6bb33ae76e0b9879a1bbfce0131" title="Forwarding action to use when sending bundle.">link_</a>.c_str()); 
<a name="l01032"></a>01032         <span class="keywordflow">return</span>;
<a name="l01033"></a>01033     }
<a name="l01034"></a>01034 
<a name="l01035"></a>01035     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> br = <span class="keyword">event</span>-&gt;bundle_;
<a name="l01036"></a>01036     <span class="keywordflow">if</span> (! br.object()){
<a name="l01037"></a>01037         log_err(<span class="stringliteral">"NULL bundle object in BundleSendRequest"</span>);
<a name="l01038"></a>01038         <span class="keywordflow">return</span>;
<a name="l01039"></a>01039     }
<a name="l01040"></a>01040 
<a name="l01041"></a>01041     <a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b5947" title="The forwarding action type codes.">ForwardingInfo::action_t</a> fwd_action =
<a name="l01042"></a>01042         (<a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b5947" title="The forwarding action type codes.">ForwardingInfo::action_t</a>)event-&gt;<a class="code" href="classdtn_1_1BundleSendRequest.html#71882d55fd353ff4e3cab96294a65a92">action_</a>;
<a name="l01043"></a>01043 
<a name="l01044"></a>01044     <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a>-&gt;<a class="code" href="classdtn_1_1BundleActions.html#7a75826fd1b4515b9d9aa2b98acbde68" title="Queue the bundle for transmission on the given link.">queue_bundle</a>(br.object(), link,
<a name="l01045"></a>01045         fwd_action, <a class="code" href="classdtn_1_1CustodyTimerSpec.html#c6d5e712cc94e4eb00f712c85065ac5c" title="Custody timer defaults, values set in the static initializer.">CustodyTimerSpec::defaults_</a>);
<a name="l01046"></a>01046 }
<a name="l01047"></a>01047 
<a name="l01048"></a>01048 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01049"></a>01049 <span class="keywordtype">void</span>
<a name="l01050"></a><a class="code" href="classdtn_1_1BundleDaemon.html#bc696ea4c1a2268d757fd40db13359ef">01050</a> <a class="code" href="classdtn_1_1BundleDaemon.html#bc696ea4c1a2268d757fd40db13359ef" title="Event type specific handlers.">BundleDaemon::handle_bundle_cancel</a>(<a class="code" href="classdtn_1_1BundleCancelRequest.html" title="Event class for canceling a bundle transmission.">BundleCancelRequest</a>* event)
<a name="l01051"></a>01051 {
<a name="l01052"></a>01052     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> br = <span class="keyword">event</span>-&gt;bundle_;
<a name="l01053"></a>01053 
<a name="l01054"></a>01054     <span class="keywordflow">if</span>(!br.object()) {
<a name="l01055"></a>01055         log_err(<span class="stringliteral">"NULL bundle object in BundleCancelRequest"</span>);
<a name="l01056"></a>01056         <span class="keywordflow">return</span>;
<a name="l01057"></a>01057     }
<a name="l01058"></a>01058 
<a name="l01059"></a>01059     <span class="comment">// If the request has a link name, we are just canceling the send on</span>
<a name="l01060"></a>01060     <span class="comment">// that link.</span>
<a name="l01061"></a>01061     <span class="keywordflow">if</span> (!event-&gt;<a class="code" href="classdtn_1_1BundleCancelRequest.html#8482d30afc61a89eaf7879510ae98849">link_</a>.empty()) {
<a name="l01062"></a>01062         <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = <a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#4a31131016ed7f6b11ce6823dd7abe91" title="Finds link corresponding to this name.">find_link</a>(event-&gt;<a class="code" href="classdtn_1_1BundleCancelRequest.html#8482d30afc61a89eaf7879510ae98849">link_</a>.c_str());
<a name="l01063"></a>01063         <span class="keywordflow">if</span> (link == NULL) {
<a name="l01064"></a>01064             log_err(<span class="stringliteral">"BUNDLE_CANCEL no link with name %s"</span>, event-&gt;<a class="code" href="classdtn_1_1BundleCancelRequest.html#8482d30afc61a89eaf7879510ae98849">link_</a>.c_str());
<a name="l01065"></a>01065             <span class="keywordflow">return</span>;
<a name="l01066"></a>01066         }
<a name="l01067"></a>01067 
<a name="l01068"></a>01068         log_info(<span class="stringliteral">"BUNDLE_CANCEL bundle %d on link %s"</span>, br-&gt;bundleid(),
<a name="l01069"></a>01069                 <span class="keyword">event</span>-&gt;link_.c_str());
<a name="l01070"></a>01070         
<a name="l01071"></a>01071         <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a>-&gt;<a class="code" href="classdtn_1_1BundleActions.html#3835034086b8a07e5a767fa028104830" title="Attempt to cancel transmission of a bundle on the given link.">cancel_bundle</a>(br.object(), link);
<a name="l01072"></a>01072     }
<a name="l01073"></a>01073     
<a name="l01074"></a>01074     <span class="comment">// If the request does not have a link name, the bundle itself has been</span>
<a name="l01075"></a>01075     <span class="comment">// canceled (probably by an application).</span>
<a name="l01076"></a>01076     <span class="keywordflow">else</span> {
<a name="l01077"></a>01077         <a class="code" href="classdtn_1_1BundleDaemon.html#cf4244174dd62d8a39d80bc77915d23c" title="Delete (rather than silently discard) a bundle, e.g., an expired bundle.">delete_bundle</a>(br);
<a name="l01078"></a>01078     }
<a name="l01079"></a>01079 }
<a name="l01080"></a>01080 
<a name="l01081"></a>01081 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01082"></a>01082 <span class="keywordtype">void</span>
<a name="l01083"></a><a class="code" href="classdtn_1_1BundleDaemon.html#c48d60e1f5e4934c9fc6ea3ff224b530">01083</a> <a class="code" href="classdtn_1_1BundleDaemon.html#c48d60e1f5e4934c9fc6ea3ff224b530" title="Event type specific handlers.">BundleDaemon::handle_bundle_cancelled</a>(<a class="code" href="classdtn_1_1BundleSendCancelledEvent.html" title="Event class for succesful cancellation of a bundle send.">BundleSendCancelledEvent</a>* event)
<a name="l01084"></a>01084 {
<a name="l01085"></a>01085     <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="l01086"></a>01086     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = <span class="keyword">event</span>-&gt;link_;
<a name="l01087"></a>01087     
<a name="l01088"></a>01088     log_info(<span class="stringliteral">"BUNDLE_CANCELLED id:%d -&gt; %s (%s)"</span>,
<a name="l01089"></a>01089             bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(),
<a name="l01090"></a>01090             link-&gt;name(),
<a name="l01091"></a>01091             link-&gt;nexthop());
<a name="l01092"></a>01092     
<a name="l01093"></a>01093     log_debug(<span class="stringliteral">"trying to find xmit blocks for bundle id:%d on link %s"</span>,
<a name="l01094"></a>01094               bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), link-&gt;name());
<a name="l01095"></a>01095     <a class="code" href="classdtn_1_1BlockInfoVec.html" title="Class for a vector of BlockInfo structures.">BlockInfoVec</a>* blocks = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#0ce0961036dd0da1fd322721cbb794aa" title="Setters and mutable accessors.">xmit_blocks</a>()-&gt;<a class="code" href="classdtn_1_1LinkBlockSet.html#07658a9543619b3ab3f1493a2dd68e85" title="Find the BlockInfoVec for the given link.">find_blocks</a>(link);
<a name="l01096"></a>01096     
<a name="l01097"></a>01097     <span class="comment">// Because a CL is running in another thread or process (External CLs),</span>
<a name="l01098"></a>01098     <span class="comment">// we cannot prevent all redundant transmit/cancel/transmit_failed </span>
<a name="l01099"></a>01099     <span class="comment">// messages. If an event about a bundle bound for particular link is </span>
<a name="l01100"></a>01100     <span class="comment">// posted after  another, which it might contradict, the BundleDaemon </span>
<a name="l01101"></a>01101     <span class="comment">// need not reprocess the event. The router (DP) might, however, be </span>
<a name="l01102"></a>01102     <span class="comment">// interested in the new status of the send.</span>
<a name="l01103"></a>01103     <span class="keywordflow">if</span> (blocks == NULL)
<a name="l01104"></a>01104     {
<a name="l01105"></a>01105         log_info(<span class="stringliteral">"received a redundant/conflicting bundle_cancelled event "</span>
<a name="l01106"></a>01106                  <span class="stringliteral">"about bundle id:%d -&gt; %s (%s)"</span>,
<a name="l01107"></a>01107                  bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(),
<a name="l01108"></a>01108                  link-&gt;name(),
<a name="l01109"></a>01109                  link-&gt;nexthop());
<a name="l01110"></a>01110         <span class="keywordflow">return</span>;
<a name="l01111"></a>01111     }
<a name="l01112"></a>01112 
<a name="l01113"></a>01113     <span class="comment">/*</span>
<a name="l01114"></a>01114 <span class="comment">     * The bundle should no longer be on the link queue or on the</span>
<a name="l01115"></a>01115 <span class="comment">     * inflight queue if it was cancelled.</span>
<a name="l01116"></a>01116 <span class="comment">     */</span>
<a name="l01117"></a>01117     <span class="keywordflow">if</span> (link-&gt;queue()-&gt;contains(bundle))
<a name="l01118"></a>01118     {
<a name="l01119"></a>01119         log_warn(<span class="stringliteral">"cancelled bundle id:%d still on link %s queue"</span>,
<a name="l01120"></a>01120                  bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), link-&gt;name());
<a name="l01121"></a>01121     }
<a name="l01122"></a>01122 
<a name="l01123"></a>01123     <span class="comment">/*</span>
<a name="l01124"></a>01124 <span class="comment">     * The bundle should no longer be on the link queue or on the</span>
<a name="l01125"></a>01125 <span class="comment">     * inflight queue if it was cancelled.</span>
<a name="l01126"></a>01126 <span class="comment">     */</span>
<a name="l01127"></a>01127     <span class="keywordflow">if</span> (link-&gt;inflight()-&gt;contains(bundle))
<a name="l01128"></a>01128     {
<a name="l01129"></a>01129         log_warn(<span class="stringliteral">"cancelled bundle id:%d still on link %s inflight list"</span>,
<a name="l01130"></a>01130                  bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), link-&gt;name());
<a name="l01131"></a>01131     }
<a name="l01132"></a>01132 
<a name="l01133"></a>01133     <span class="comment">/*</span>
<a name="l01134"></a>01134 <span class="comment">     * Update statistics. Note that the link's queued length must</span>
<a name="l01135"></a>01135 <span class="comment">     * always be decremented by the full formatted size of the bundle.</span>
<a name="l01136"></a>01136 <span class="comment">     */</span>
<a name="l01137"></a>01137     link-&gt;stats()-&gt;bundles_cancelled_++;
<a name="l01138"></a>01138     
<a name="l01139"></a>01139     <span class="comment">/*</span>
<a name="l01140"></a>01140 <span class="comment">     * Remove the formatted block info from the bundle since we don't</span>
<a name="l01141"></a>01141 <span class="comment">     * need it any more.</span>
<a name="l01142"></a>01142 <span class="comment">     */</span>
<a name="l01143"></a>01143     log_debug(<span class="stringliteral">"trying to delete xmit blocks for bundle id:%d on link %s"</span>,
<a name="l01144"></a>01144               bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), link-&gt;name());
<a name="l01145"></a>01145     <a class="code" href="classdtn_1_1BundleProtocol.html#df59b9b818853e07bfb7464312ca7092">BundleProtocol::delete_blocks</a>(bundle, link);
<a name="l01146"></a>01146     blocks = NULL;
<a name="l01147"></a>01147 
<a name="l01148"></a>01148     <span class="comment">/*</span>
<a name="l01149"></a>01149 <span class="comment">     * Update the forwarding log.</span>
<a name="l01150"></a>01150 <span class="comment">     */</span>
<a name="l01151"></a>01151     log_debug(<span class="stringliteral">"trying to update the forwarding log for "</span>
<a name="l01152"></a>01152               <span class="stringliteral">"bundle id:%d on link %s to state CANCELLED"</span>,
<a name="l01153"></a>01153               bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), link-&gt;name());
<a name="l01154"></a>01154     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#249ac137ef76e253d8e0587f2662bca7" title="Accessors.">fwdlog</a>()-&gt;<a class="code" href="classdtn_1_1ForwardingLog.html#a6d756d62a3007192f415a35607e5f38" title="Update the state for the latest forwarding info entry for the given link.">update</a>(link, <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fadeb6a0b0b2a5b406be9d18a0da0a7268f" title="Transmission cancelled.">ForwardingInfo::CANCELLED</a>);
<a name="l01155"></a>01155 }
<a name="l01156"></a>01156 
<a name="l01157"></a>01157 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01158"></a>01158 <span class="keywordtype">void</span>
<a name="l01159"></a><a class="code" href="classdtn_1_1BundleDaemon.html#01fb5cb7cca5e781b87f9e2a5174d8c9">01159</a> <a class="code" href="classdtn_1_1BundleDaemon.html#01fb5cb7cca5e781b87f9e2a5174d8c9" title="Event type specific handlers.">BundleDaemon::handle_bundle_inject</a>(<a class="code" href="classdtn_1_1BundleInjectRequest.html" title="Event class for injecting a bundle.">BundleInjectRequest</a>* event)
<a name="l01160"></a>01160 {
<a name="l01161"></a>01161     <span class="comment">// link isn't used at the moment, so don't bother searching for</span>
<a name="l01162"></a>01162     <span class="comment">// it.  TODO:  either remove link ID and forward action from</span>
<a name="l01163"></a>01163     <span class="comment">// RequestInjectBundle, or make link ID optional and send the</span>
<a name="l01164"></a>01164     <span class="comment">// bundle on the link if specified.</span>
<a name="l01165"></a>01165     <span class="comment">/*</span>
<a name="l01166"></a>01166 <span class="comment">      LinkRef link = contactmgr_-&gt;find_link(event-&gt;link_.c_str());</span>
<a name="l01167"></a>01167 <span class="comment">      if (link == NULL) return;</span>
<a name="l01168"></a>01168 <span class="comment">    */</span>
<a name="l01169"></a>01169 
<a name="l01170"></a>01170     <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a> <a class="code" href="dtnmoteproxy_8c.html#e1ade0f5a1b32f6c8be72f31a99e2a18">src</a>(event-&gt;<a class="code" href="classdtn_1_1BundleInjectRequest.html#6e2a627f426b03591fe06d88815794ea">src_</a>); 
<a name="l01171"></a>01171     <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a> dest(event-&gt;<a class="code" href="classdtn_1_1BundleInjectRequest.html#ea26f55d1b4ac027b62f24bd4f7735ea">dest_</a>); 
<a name="l01172"></a>01172     <span class="keywordflow">if</span> ((! src.<a class="code" href="classdtn_1_1EndpointID.html#bbf47839fe5cc8cb425af9a257a92ef5">valid</a>()) || (! dest.<a class="code" href="classdtn_1_1EndpointID.html#bbf47839fe5cc8cb425af9a257a92ef5">valid</a>())) <span class="keywordflow">return</span>;
<a name="l01173"></a>01173     
<a name="l01174"></a>01174     <span class="comment">// The bundle's source EID must be either dtn:none or an EID </span>
<a name="l01175"></a>01175     <span class="comment">// registered at this node.</span>
<a name="l01176"></a>01176     <span class="keyword">const</span> <a class="code" href="classdtn_1_1RegistrationTable.html" title="Class for the in-memory registration table.">RegistrationTable</a>* <a class="code" href="classdtn_1_1BundleDaemon.html#ad2af770f1002bb8b3a15e11704928de" title="Accessor for the registration table.">reg_table</a> = 
<a name="l01177"></a>01177             BundleDaemon::instance()-&gt;reg_table();
<a name="l01178"></a>01178     std::string base_reg_str = src.<a class="code" href="classdtn_1_1EndpointID.html#b33fc19cda5561ca189e2051d6561db7">uri</a>().scheme() + <span class="stringliteral">"://"</span> + src.<a class="code" href="classdtn_1_1EndpointID.html#b33fc19cda5561ca189e2051d6561db7">uri</a>().host();
<a name="l01179"></a>01179     
<a name="l01180"></a>01180     <span class="keywordflow">if</span> (!reg_table-&gt;<a class="code" href="classdtn_1_1RegistrationTable.html#f8d5a24ad0b05ab853f80cfea3a1fce1" title="Look up a matching registration.">get</a>(<a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a>(base_reg_str)) &amp;&amp; 
<a name="l01181"></a>01181          src != <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="l01182"></a>01182         log_err(<span class="stringliteral">"this node is not a member of the injected bundle's source "</span>
<a name="l01183"></a>01183                 <span class="stringliteral">"EID (%s)"</span>, src.<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>().c_str());
<a name="l01184"></a>01184         <span class="keywordflow">return</span>;
<a name="l01185"></a>01185     }
<a name="l01186"></a>01186     
<a name="l01187"></a>01187     <span class="comment">// The new bundle is placed on the pending queue but not</span>
<a name="l01188"></a>01188     <span class="comment">// in durable storage (no call to BundleActions::inject_bundle)</span>
<a name="l01189"></a>01189     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle = <span class="keyword">new</span> <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>(<a class="code" href="classdtn_1_1BundleDaemon.html#a18fd65ff3e11b985f3e04a4591d4a33">params_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Params.html#a489cee8dad886e60025720b7d1162cb" title="Whether or not injected bundles are held in memory by default.">injected_bundles_in_memory_</a> ? 
<a name="l01190"></a>01190                                 <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae35251755f9b50eab4ee0e32bf01f38d7309">BundlePayload::MEMORY</a> : <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae35202b4113a9944175cde826707be98e89e" title="in memory only (TempBundle)">BundlePayload::DISK</a>);
<a name="l01191"></a>01191     
<a name="l01192"></a>01192     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#69c35928ca050eb4bb2ec67641f1b6bb" title="Setters and mutable accessors.">mutable_source</a>()-&gt;<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(src);
<a name="l01193"></a>01193     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#fedf6ad0537f7e3a3f958162d1fc935e" title="Setters and mutable accessors.">mutable_dest</a>()-&gt;<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(dest);
<a name="l01194"></a>01194     
<a name="l01195"></a>01195     <span class="keywordflow">if</span> (! bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7c2091e44637889b9ad6f94a82ae7f83" title="Setters and mutable accessors.">mutable_replyto</a>()-&gt;<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(event-&gt;<a class="code" href="classdtn_1_1BundleInjectRequest.html#de9da59e8eedfe7c206dabee82e0230c">replyto_</a>))
<a name="l01196"></a>01196         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7c2091e44637889b9ad6f94a82ae7f83" title="Setters and mutable accessors.">mutable_replyto</a>()-&gt;<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(<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="l01197"></a>01197 
<a name="l01198"></a>01198     <span class="keywordflow">if</span> (! bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#96698085719d88c0b5c86d4cb388324c" title="Setters and mutable accessors.">mutable_custodian</a>()-&gt;<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(event-&gt;<a class="code" href="classdtn_1_1BundleInjectRequest.html#c21edfe2956fc70957e5887ef1527fcd">custodian_</a>))
<a name="l01199"></a>01199         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#96698085719d88c0b5c86d4cb388324c" title="Setters and mutable accessors.">mutable_custodian</a>()-&gt;<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(<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="l01200"></a>01200 
<a name="l01201"></a>01201     <span class="comment">// bundle COS defaults to COS_BULK</span>
<a name="l01202"></a>01202     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#6025475ff9104e2720ddb5ecbc9ec923" title="Setters and mutable accessors.">set_priority</a>(event-&gt;<a class="code" href="classdtn_1_1BundleInjectRequest.html#10cb7a219b517f6c711796b4da38d4ad">priority_</a>);
<a name="l01203"></a>01203 
<a name="l01204"></a>01204     <span class="comment">// bundle expiration on remote dtn nodes</span>
<a name="l01205"></a>01205     <span class="comment">// defaults to 5 minutes</span>
<a name="l01206"></a>01206     <span class="keywordflow">if</span>(event-&gt;<a class="code" href="classdtn_1_1BundleInjectRequest.html#6fbf691ac155d57ba6f07c768e2bea3f">expiration_</a> == 0)
<a name="l01207"></a>01207         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7623ecfe9e47e5dc075ebd872fb9a237" title="Setters and mutable accessors.">set_expiration</a>(300);
<a name="l01208"></a>01208     <span class="keywordflow">else</span>
<a name="l01209"></a>01209         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7623ecfe9e47e5dc075ebd872fb9a237" title="Setters and mutable accessors.">set_expiration</a>(event-&gt;<a class="code" href="classdtn_1_1BundleInjectRequest.html#6fbf691ac155d57ba6f07c768e2bea3f">expiration_</a>);
<a name="l01210"></a>01210     
<a name="l01211"></a>01211     <span class="comment">// set the payload (by hard linking, then removing original)</span>
<a name="l01212"></a>01212     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#857079bad68497626f75c2985b69052f" title="Setters and mutable accessors.">mutable_payload</a>()-&gt;
<a name="l01213"></a>01213         replace_with_file(event-&gt;<a class="code" href="classdtn_1_1BundleInjectRequest.html#2d73b593decc0cf54dbd9f8cec93a823">payload_file_</a>.c_str());
<a name="l01214"></a>01214     log_debug(<span class="stringliteral">"bundle payload size after replace_with_file(): %zd"</span>, 
<a name="l01215"></a>01215               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="l01216"></a>01216     oasys::IO::unlink(event-&gt;<a class="code" href="classdtn_1_1BundleInjectRequest.html#2d73b593decc0cf54dbd9f8cec93a823">payload_file_</a>.c_str(), logpath_);
<a name="l01217"></a>01217 
<a name="l01218"></a>01218     <span class="comment">/*</span>
<a name="l01219"></a>01219 <span class="comment">     * Deliver the bundle to any local registrations that it matches,</span>
<a name="l01220"></a>01220 <span class="comment">     * unless it's generated by the router or is a bundle fragment.</span>
<a name="l01221"></a>01221 <span class="comment">     * Delivery of bundle fragments is deferred until after re-assembly.</span>
<a name="l01222"></a>01222 <span class="comment">     */</span>
<a name="l01223"></a>01223     <span class="keywordtype">bool</span> is_local = <a class="code" href="classdtn_1_1BundleDaemon.html#f3a66691215ba378336f8241b111d364" title="Check the registration table and optionally deliver the bundle to any that match...">check_local_delivery</a>(bundle, !bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#d6c74eba219bfe55854cf7a90e210cca" title="Accessors.">is_fragment</a>());
<a name="l01224"></a>01224     
<a name="l01225"></a>01225     <span class="comment">/*</span>
<a name="l01226"></a>01226 <span class="comment">     * Re-assemble bundle fragments that are destined to the local node.</span>
<a name="l01227"></a>01227 <span class="comment">     */</span>
<a name="l01228"></a>01228     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#d6c74eba219bfe55854cf7a90e210cca" title="Accessors.">is_fragment</a>() &amp;&amp; is_local) {
<a name="l01229"></a>01229         log_debug(<span class="stringliteral">"deferring delivery of injected bundle *%p "</span>
<a name="l01230"></a>01230                   <span class="stringliteral">"since bundle is a fragment"</span>, bundle);
<a name="l01231"></a>01231         <a class="code" href="classdtn_1_1BundleDaemon.html#a0a2294a38635f5f76aba4375b0c2f7d" title="The fragmentation / reassembly manager.">fragmentmgr_</a>-&gt;<a class="code" href="classdtn_1_1FragmentManager.html#06ba9686e9d9a7fca8cdc31c3ffca187" title="Given a newly arrived bundle fragment, append it to the table of fragments and see...">process_for_reassembly</a>(bundle);
<a name="l01232"></a>01232     }
<a name="l01233"></a>01233 
<a name="l01234"></a>01234     <span class="comment">// The injected bundle is no longer sent automatically. It is</span>
<a name="l01235"></a>01235     <span class="comment">// instead added to the pending queue so that it can be resent</span>
<a name="l01236"></a>01236     <span class="comment">// or sent on multiple links.</span>
<a name="l01237"></a>01237 
<a name="l01238"></a>01238     <span class="comment">// If add_to_pending returns false, the bundle has already expired</span>
<a name="l01239"></a>01239     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleDaemon.html#d488c6c663e4692388b21bf16416a2d2" title="Add the bundle to the pending list and (optionally) the persistent store, and set...">add_to_pending</a>(bundle, 0))
<a name="l01240"></a>01240         <a class="code" href="classdtn_1_1BundleDaemon.html#370a80f7dd9fd9297e76d7f830d737a8" title="Queues the event at the tail of the queue for processing by the daemon thread.">BundleDaemon::post</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleInjectedEvent.html" title="Event class for a succesful bundle injection.">BundleInjectedEvent</a>(bundle, event-&gt;<a class="code" href="classdtn_1_1BundleInjectRequest.html#4b4cf94829257b967457bf2c49b31eb0">request_id_</a>));
<a name="l01241"></a>01241     
<a name="l01242"></a>01242     ++<a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#1ef78250580e8aa28e368d1b00e29148">injected_bundles_</a>;
<a name="l01243"></a>01243 }
<a name="l01244"></a>01244 
<a name="l01245"></a>01245 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01246"></a>01246 <span class="keywordtype">void</span>
<a name="l01247"></a><a class="code" href="classdtn_1_1BundleDaemon.html#476ddaae905ba315b8daf3c0704981a5">01247</a> <a class="code" href="classdtn_1_1BundleDaemon.html#476ddaae905ba315b8daf3c0704981a5" title="Event type specific handlers.">BundleDaemon::handle_bundle_query</a>(<a class="code" href="classdtn_1_1BundleQueryRequest.html" title="Event classes for bundle queries and responses.">BundleQueryRequest</a>*)
<a name="l01248"></a>01248 {
<a name="l01249"></a>01249     <a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686" title="Queues the event at the head of the queue for processing by the daemon thread.">BundleDaemon::post_at_head</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleReportEvent.html">BundleReportEvent</a>());
<a name="l01250"></a>01250 }
<a name="l01251"></a>01251 
<a name="l01252"></a>01252 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01253"></a>01253 <span class="keywordtype">void</span>
<a name="l01254"></a><a class="code" href="classdtn_1_1BundleDaemon.html#3f934b7e07b3db7708ada33438877204">01254</a> <a class="code" href="classdtn_1_1BundleDaemon.html#3f934b7e07b3db7708ada33438877204" title="Event type specific handlers.">BundleDaemon::handle_bundle_report</a>(<a class="code" href="classdtn_1_1BundleReportEvent.html">BundleReportEvent</a>*)
<a name="l01255"></a>01255 {
<a name="l01256"></a>01256 }
<a name="l01257"></a>01257 
<a name="l01258"></a>01258 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01259"></a>01259 <span class="keywordtype">void</span>
<a name="l01260"></a><a class="code" href="classdtn_1_1BundleDaemon.html#de5efdec7bec54eb72f388296c3b2abf">01260</a> <a class="code" href="classdtn_1_1BundleDaemon.html#de5efdec7bec54eb72f388296c3b2abf" title="Event type specific handlers.">BundleDaemon::handle_bundle_attributes_query</a>(<a class="code" href="classdtn_1_1BundleAttributesQueryRequest.html">BundleAttributesQueryRequest</a>* request)
<a name="l01261"></a>01261 {
<a name="l01262"></a>01262     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> &amp;br = request-&gt;<a class="code" href="classdtn_1_1BundleAttributesQueryRequest.html#394378f4b31c807c715ea8b09e5c20f5">bundle_</a>;
<a name="l01263"></a>01263     <span class="keywordflow">if</span> (! br.object()) <span class="keywordflow">return</span>; <span class="comment">// XXX or should it post an empty report?</span>
<a name="l01264"></a>01264 
<a name="l01265"></a>01265     log_debug(
<a name="l01266"></a>01266         <span class="stringliteral">"BundleDaemon::handle_bundle_attributes_query: query %s, bundle *%p"</span>,
<a name="l01267"></a>01267         request-&gt;<a class="code" href="classdtn_1_1BundleAttributesQueryRequest.html#b984f6782ad1271ed8b729d2642a851b" title="Query Identifier.">query_id_</a>.c_str(), br.object());
<a name="l01268"></a>01268 
<a name="l01269"></a>01269     <span class="comment">// we need to keep a reference to the bundle because otherwise it may</span>
<a name="l01270"></a>01270     <span class="comment">// be deleted before the event is handled</span>
<a name="l01271"></a>01271     <a class="code" href="classdtn_1_1BundleDaemon.html#370a80f7dd9fd9297e76d7f830d737a8" title="Queues the event at the tail of the queue for processing by the daemon thread.">BundleDaemon::post</a>(
<a name="l01272"></a>01272         <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleAttributesReportEvent.html">BundleAttributesReportEvent</a>(request-&gt;<a class="code" href="classdtn_1_1BundleAttributesQueryRequest.html#b984f6782ad1271ed8b729d2642a851b" title="Query Identifier.">query_id_</a>,
<a name="l01273"></a>01273                                         br,
<a name="l01274"></a>01274                                         request-&gt;<a class="code" href="classdtn_1_1BundleAttributesQueryRequest.html#c0ed1cf4dc89e70b0710ef99b0db62bb" title="bundle attributes requested by name.">attribute_names_</a>,
<a name="l01275"></a>01275                                         request-&gt;<a class="code" href="classdtn_1_1BundleAttributesQueryRequest.html#a94a9896b5cee2ec2983b2fbb2739cca" title="metadata blocks requested by type/identifier">metadata_blocks_</a>));
<a name="l01276"></a>01276 }
<a name="l01277"></a>01277 
<a name="l01278"></a>01278 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01279"></a>01279 <span class="keywordtype">void</span>
<a name="l01280"></a><a class="code" href="classdtn_1_1BundleDaemon.html#00d62bde4d3fd1e21ddce4b272416d7b">01280</a> <a class="code" href="classdtn_1_1BundleDaemon.html#00d62bde4d3fd1e21ddce4b272416d7b" title="Event type specific handlers.">BundleDaemon::handle_bundle_attributes_report</a>(<a class="code" href="classdtn_1_1BundleAttributesReportEvent.html">BundleAttributesReportEvent</a>* event)
<a name="l01281"></a>01281 {
<a name="l01282"></a>01282     (void)event;
<a name="l01283"></a>01283     log_debug(<span class="stringliteral">"BundleDaemon::handle_bundle_attributes_report: query %s"</span>,
<a name="l01284"></a>01284               event-&gt;<a class="code" href="classdtn_1_1BundleAttributesReportEvent.html#3f615b0b14b013b4341d0d37e4656ad1" title="Query Identifier.">query_id_</a>.c_str());
<a name="l01285"></a>01285 }
<a name="l01286"></a>01286 
<a name="l01287"></a>01287 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01288"></a>01288 <span class="keywordtype">void</span>
<a name="l01289"></a><a class="code" href="classdtn_1_1BundleDaemon.html#072d127866507f846d25f5a03ff27933">01289</a> <a class="code" href="classdtn_1_1BundleDaemon.html#072d127866507f846d25f5a03ff27933" title="Event type specific handlers.">BundleDaemon::handle_registration_added</a>(<a class="code" href="classdtn_1_1RegistrationAddedEvent.html" title="Event class for new registration arrivals.">RegistrationAddedEvent</a>* event)
<a name="l01290"></a>01290 {
<a name="l01291"></a>01291     <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>* registration = <span class="keyword">event</span>-&gt;registration_;
<a name="l01292"></a>01292     log_info(<span class="stringliteral">"REGISTRATION_ADDED %d %s"</span>,
<a name="l01293"></a>01293              registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>(), registration-&gt;<a class="code" href="classdtn_1_1Registration.html#590e683ae3d0a33456e7f0fa0a2a89d5" title="Accessors.">endpoint</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l01294"></a>01294 
<a name="l01295"></a>01295     <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1BundleDaemon.html#f0b116c3ae390f0032049f376e3a2eec" title="The table of active registrations.">reg_table_</a>-&gt;<a class="code" href="classdtn_1_1RegistrationTable.html#a360f9cc20ad946876613e0747211ef0" title="Add a new registration to the database.">add</a>(registration,
<a name="l01296"></a>01296                          (event-&gt;<a class="code" href="classdtn_1_1RegistrationAddedEvent.html#499e9dd753cb21852134a8f1f2d54a57" title="Why is the registration added.">source_</a> == <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142bf3e56dfb4e624d4f62d7099b60472072" title="a local application">EVENTSRC_APP</a>) ? <span class="keyword">true</span> : <span class="keyword">false</span>))
<a name="l01297"></a>01297     {
<a name="l01298"></a>01298         log_err(<span class="stringliteral">"error adding registration %d to table"</span>,
<a name="l01299"></a>01299                 registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>());
<a name="l01300"></a>01300     }
<a name="l01301"></a>01301     
<a name="l01302"></a>01302     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#0d0c9f789f0f7f7d1cda3b4ecf32d2bc" title="Return the internal lock on this list.">lock</a>(), 
<a name="l01303"></a>01303                        <span class="stringliteral">"BundleDaemon::handle_registration_added"</span>);
<a name="l01304"></a>01304     <a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">BundleList::iterator</a> iter;
<a name="l01305"></a>01305     <span class="keywordflow">for</span> (iter = <a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf" title="Iterator used to iterate through the list.">begin</a>();
<a name="l01306"></a>01306          iter != <a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1" title="Iterator used to mark the end of the list.">end</a>();
<a name="l01307"></a>01307          ++iter)
<a name="l01308"></a>01308     {
<a name="l01309"></a>01309         <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle = *iter;
<a name="l01310"></a>01310 
<a name="l01311"></a>01311         <span class="keywordflow">if</span> (!bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#d6c74eba219bfe55854cf7a90e210cca" title="Accessors.">is_fragment</a>() &amp;&amp;
<a name="l01312"></a>01312             registration-&gt;<a class="code" href="classdtn_1_1Registration.html#590e683ae3d0a33456e7f0fa0a2a89d5" title="Accessors.">endpoint</a>().<a class="code" href="classdtn_1_1EndpointIDPattern.html#551ee984666d2079f9ccdc5514dcbdc6" title="Shortcut to the matching functionality implemented by the scheme.">match</a>(bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>())) {
<a name="l01313"></a>01313             <a class="code" href="classdtn_1_1BundleDaemon.html#d604277d857c5ea54de0718f20b677fd" title="Deliver the bundle to the given registration.">deliver_to_registration</a>(bundle, registration);
<a name="l01314"></a>01314         }
<a name="l01315"></a>01315     }
<a name="l01316"></a>01316 }
<a name="l01317"></a>01317 
<a name="l01318"></a>01318 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01319"></a>01319 <span class="keywordtype">void</span>
<a name="l01320"></a><a class="code" href="classdtn_1_1BundleDaemon.html#73e01866efdce9bb5910424f0419e0e7">01320</a> <a class="code" href="classdtn_1_1BundleDaemon.html#73e01866efdce9bb5910424f0419e0e7" title="Event type specific handlers.">BundleDaemon::handle_registration_removed</a>(<a class="code" href="classdtn_1_1RegistrationRemovedEvent.html" title="Event class for registration removals.">RegistrationRemovedEvent</a>* event)
<a name="l01321"></a>01321 {
<a name="l01322"></a>01322     <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>* registration = <span class="keyword">event</span>-&gt;registration_;
<a name="l01323"></a>01323     log_info(<span class="stringliteral">"REGISTRATION_REMOVED %d %s"</span>,
<a name="l01324"></a>01324              registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>(), registration-&gt;<a class="code" href="classdtn_1_1Registration.html#590e683ae3d0a33456e7f0fa0a2a89d5" title="Accessors.">endpoint</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l01325"></a>01325     
<a name="l01326"></a>01326     <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1BundleDaemon.html#f0b116c3ae390f0032049f376e3a2eec" title="The table of active registrations.">reg_table_</a>-&gt;<a class="code" href="classdtn_1_1RegistrationTable.html#e69fe9f82af4c5a16973881693d450f1" title="Remove the registration from the database, returns true if successful, false if the...">del</a>(registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>())) {
<a name="l01327"></a>01327         log_err(<span class="stringliteral">"error removing registration %d from table"</span>,
<a name="l01328"></a>01328                 registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>());
<a name="l01329"></a>01329         <span class="keywordflow">return</span>;
<a name="l01330"></a>01330     }
<a name="l01331"></a>01331 
<a name="l01332"></a>01332     <a class="code" href="classdtn_1_1BundleDaemon.html#370a80f7dd9fd9297e76d7f830d737a8" title="Queues the event at the tail of the queue for processing by the daemon thread.">post</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1RegistrationDeleteRequest.html" title="Daemon-only event class used to delete a registration after it&amp;#39;s removed or expired...">RegistrationDeleteRequest</a>(registration));
<a name="l01333"></a>01333 }
<a name="l01334"></a>01334 
<a name="l01335"></a>01335 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01336"></a>01336 <span class="keywordtype">void</span>
<a name="l01337"></a><a class="code" href="classdtn_1_1BundleDaemon.html#4a46bf2498dc38611ed5be11c9cfb887">01337</a> <a class="code" href="classdtn_1_1BundleDaemon.html#4a46bf2498dc38611ed5be11c9cfb887" title="Event type specific handlers.">BundleDaemon::handle_registration_expired</a>(<a class="code" href="classdtn_1_1RegistrationExpiredEvent.html" title="Event class for registration expiration.">RegistrationExpiredEvent</a>* event)
<a name="l01338"></a>01338 {
<a name="l01339"></a>01339     <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>* registration = <span class="keyword">event</span>-&gt;registration_;
<a name="l01340"></a>01340 
<a name="l01341"></a>01341     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleDaemon.html#f0b116c3ae390f0032049f376e3a2eec" title="The table of active registrations.">reg_table_</a>-&gt;<a class="code" href="classdtn_1_1RegistrationTable.html#f8d5a24ad0b05ab853f80cfea3a1fce1" title="Look up a matching registration.">get</a>(registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>()) == NULL) {
<a name="l01342"></a>01342         <span class="comment">// this shouldn't ever happen</span>
<a name="l01343"></a>01343         log_err(<span class="stringliteral">"REGISTRATION_EXPIRED -- dead regid %d"</span>, registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>());
<a name="l01344"></a>01344         <span class="keywordflow">return</span>;
<a name="l01345"></a>01345     }
<a name="l01346"></a>01346     
<a name="l01347"></a>01347     registration-&gt;<a class="code" href="classdtn_1_1Registration.html#978fc4d494afebbdc602d9383b08b40c" title="Accessors.">set_expired</a>(<span class="keyword">true</span>);
<a name="l01348"></a>01348     
<a name="l01349"></a>01349     <span class="keywordflow">if</span> (registration-&gt;<a class="code" href="classdtn_1_1Registration.html#76d7e69abd93971f58ef49eee4b9abfc" title="Accessors.">active</a>()) {
<a name="l01350"></a>01350         <span class="comment">// if the registration is currently active (i.e. has a</span>
<a name="l01351"></a>01351         <span class="comment">// binding), we wait for the binding to clear, which will then</span>
<a name="l01352"></a>01352         <span class="comment">// clean up the registration</span>
<a name="l01353"></a>01353         log_info(<span class="stringliteral">"REGISTRATION_EXPIRED %d -- deferred until binding clears"</span>,
<a name="l01354"></a>01354                  registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>());
<a name="l01355"></a>01355     } <span class="keywordflow">else</span> {
<a name="l01356"></a>01356         <span class="comment">// otherwise remove the registration from the table</span>
<a name="l01357"></a>01357         log_info(<span class="stringliteral">"REGISTRATION_EXPIRED %d"</span>, registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>());
<a name="l01358"></a>01358         <a class="code" href="classdtn_1_1BundleDaemon.html#f0b116c3ae390f0032049f376e3a2eec" title="The table of active registrations.">reg_table_</a>-&gt;<a class="code" href="classdtn_1_1RegistrationTable.html#e69fe9f82af4c5a16973881693d450f1" title="Remove the registration from the database, returns true if successful, false if the...">del</a>(registration-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>());
<a name="l01359"></a>01359         <a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686" title="Queues the event at the head of the queue for processing by the daemon thread.">post_at_head</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1RegistrationDeleteRequest.html" title="Daemon-only event class used to delete a registration after it&amp;#39;s removed or expired...">RegistrationDeleteRequest</a>(registration));
<a name="l01360"></a>01360     }
<a name="l01361"></a>01361 }
<a name="l01362"></a>01362 
<a name="l01363"></a>01363 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01364"></a>01364 <span class="keywordtype">void</span>
<a name="l01365"></a><a class="code" href="classdtn_1_1BundleDaemon.html#c72bb7eaf61d1470b729788bfed16a9b">01365</a> <a class="code" href="classdtn_1_1BundleDaemon.html#c72bb7eaf61d1470b729788bfed16a9b" title="Event type specific handlers.">BundleDaemon::handle_registration_delete</a>(<a class="code" href="classdtn_1_1RegistrationDeleteRequest.html" title="Daemon-only event class used to delete a registration after it&amp;#39;s removed or expired...">RegistrationDeleteRequest</a>* request)
<a name="l01366"></a>01366 {
<a name="l01367"></a>01367     log_info(<span class="stringliteral">"REGISTRATION_DELETE %d"</span>, request-&gt;<a class="code" href="classdtn_1_1RegistrationDeleteRequest.html#ec286f91722f517c3cf834703c074f94" title="The registration to be deleted.">registration_</a>-&gt;<a class="code" href="classdtn_1_1Registration.html#d1cd25dd8e4c512591849f44e7c8090b" title="Accessors.">regid</a>());
<a name="l01368"></a>01368     <span class="keyword">delete</span> request-&gt;<a class="code" href="classdtn_1_1RegistrationDeleteRequest.html#ec286f91722f517c3cf834703c074f94" title="The registration to be deleted.">registration_</a>;
<a name="l01369"></a>01369 }
<a name="l01370"></a>01370 
<a name="l01371"></a>01371 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01372"></a>01372 <span class="keywordtype">void</span>
<a name="l01373"></a><a class="code" href="classdtn_1_1BundleDaemon.html#966615d7f834f8758890e5d5cd07f8d0">01373</a> <a class="code" href="classdtn_1_1BundleDaemon.html#966615d7f834f8758890e5d5cd07f8d0" title="Event type specific handlers.">BundleDaemon::handle_link_created</a>(<a class="code" href="classdtn_1_1LinkCreatedEvent.html" title="Event class for link creation events.">LinkCreatedEvent</a>* event)
<a name="l01374"></a>01374 {
<a name="l01375"></a>01375     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = <span class="keyword">event</span>-&gt;link_;
<a name="l01376"></a>01376     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l01377"></a>01377 
<a name="l01378"></a>01378     <span class="keywordflow">if</span> (link-&gt;isdeleted()) {
<a name="l01379"></a>01379         log_warn(<span class="stringliteral">"BundleDaemon::handle_link_created: "</span>
<a name="l01380"></a>01380                  <span class="stringliteral">"link %s deleted prior to full creation"</span>, link-&gt;name());
<a name="l01381"></a>01381         <span class="keyword">event</span>-&gt;daemon_only_ = <span class="keyword">true</span>;
<a name="l01382"></a>01382         <span class="keywordflow">return</span>;
<a name="l01383"></a>01383     }
<a name="l01384"></a>01384 
<a name="l01385"></a>01385     log_info(<span class="stringliteral">"LINK_CREATED *%p"</span>, link.object());
<a name="l01386"></a>01386 }
<a name="l01387"></a>01387 
<a name="l01388"></a>01388 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01389"></a>01389 <span class="keywordtype">void</span>
<a name="l01390"></a><a class="code" href="classdtn_1_1BundleDaemon.html#e99e03c521a44c15404150a16cc54ca6">01390</a> <a class="code" href="classdtn_1_1BundleDaemon.html#e99e03c521a44c15404150a16cc54ca6" title="Event type specific handlers.">BundleDaemon::handle_link_deleted</a>(<a class="code" href="classdtn_1_1LinkDeletedEvent.html" title="Event class for link deletion events.">LinkDeletedEvent</a>* event)
<a name="l01391"></a>01391 {
<a name="l01392"></a>01392     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = <span class="keyword">event</span>-&gt;link_;
<a name="l01393"></a>01393     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l01394"></a>01394 
<a name="l01395"></a>01395     log_info(<span class="stringliteral">"LINK_DELETED *%p"</span>, link.object());
<a name="l01396"></a>01396 }
<a name="l01397"></a>01397 
<a name="l01398"></a>01398 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01399"></a>01399 <span class="keywordtype">void</span>
<a name="l01400"></a><a class="code" href="classdtn_1_1BundleDaemon.html#3145457e992ded99bd3516e52a1f3ecf">01400</a> <a class="code" href="classdtn_1_1BundleDaemon.html#3145457e992ded99bd3516e52a1f3ecf" title="Event type specific handlers.">BundleDaemon::handle_link_available</a>(<a class="code" href="classdtn_1_1LinkAvailableEvent.html" title="Event class for link available events.">LinkAvailableEvent</a>* event)
<a name="l01401"></a>01401 {
<a name="l01402"></a>01402     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = <span class="keyword">event</span>-&gt;link_;
<a name="l01403"></a>01403     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l01404"></a>01404     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link-&gt;isavailable());
<a name="l01405"></a>01405 
<a name="l01406"></a>01406     <span class="keywordflow">if</span> (link-&gt;isdeleted()) {
<a name="l01407"></a>01407         log_warn(<span class="stringliteral">"BundleDaemon::handle_link_available: "</span>
<a name="l01408"></a>01408                  <span class="stringliteral">"link %s already deleted"</span>, link-&gt;name());
<a name="l01409"></a>01409         <span class="keyword">event</span>-&gt;daemon_only_ = <span class="keyword">true</span>;
<a name="l01410"></a>01410         <span class="keywordflow">return</span>;
<a name="l01411"></a>01411     }
<a name="l01412"></a>01412 
<a name="l01413"></a>01413     log_info(<span class="stringliteral">"LINK_AVAILABLE *%p"</span>, link.object());
<a name="l01414"></a>01414 }
<a name="l01415"></a>01415 
<a name="l01416"></a>01416 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01417"></a>01417 <span class="keywordtype">void</span>
<a name="l01418"></a><a class="code" href="classdtn_1_1BundleDaemon.html#db6620b992b82b268f6dc5e9fc2c5899">01418</a> <a class="code" href="classdtn_1_1BundleDaemon.html#db6620b992b82b268f6dc5e9fc2c5899" title="Event type specific handlers.">BundleDaemon::handle_link_unavailable</a>(<a class="code" href="classdtn_1_1LinkUnavailableEvent.html" title="Event class for link unavailable events.">LinkUnavailableEvent</a>* event)
<a name="l01419"></a>01419 {
<a name="l01420"></a>01420     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = <span class="keyword">event</span>-&gt;link_;
<a name="l01421"></a>01421     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l01422"></a>01422     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!link-&gt;isavailable());
<a name="l01423"></a>01423     
<a name="l01424"></a>01424     log_info(<span class="stringliteral">"LINK UNAVAILABLE *%p"</span>, link.object());
<a name="l01425"></a>01425 }
<a name="l01426"></a>01426 
<a name="l01427"></a>01427 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01428"></a>01428 <span class="keywordtype">void</span>
<a name="l01429"></a><a class="code" href="classdtn_1_1BundleDaemon.html#cc60ec6782a9210d5d3e17ed6bc03db6">01429</a> <a class="code" href="classdtn_1_1BundleDaemon.html#cc60ec6782a9210d5d3e17ed6bc03db6" title="Event type specific handlers.">BundleDaemon::handle_link_state_change_request</a>(<a class="code" href="classdtn_1_1LinkStateChangeRequest.html" title="Request class for link state change requests that are sent to the daemon thread for...">LinkStateChangeRequest</a>* request)
<a name="l01430"></a>01430 {
<a name="l01431"></a>01431     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = request-&gt;<a class="code" href="classdtn_1_1LinkStateChangeRequest.html#3b6057ed8b14cba7502c4eafcf4196df" title="The link to be changed.">link_</a>;
<a name="l01432"></a>01432     <span class="keywordflow">if</span> (link == NULL) {
<a name="l01433"></a>01433         log_warn(<span class="stringliteral">"LINK_STATE_CHANGE_REQUEST received invalid link"</span>);
<a name="l01434"></a>01434         <span class="keywordflow">return</span>;
<a name="l01435"></a>01435     }
<a name="l01436"></a>01436 
<a name="l01437"></a>01437     <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3" title="The possible states for a link.">Link::state_t</a> new_state = <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3" title="The possible states for a link.">Link::state_t</a>(request-&gt;<a class="code" href="classdtn_1_1LinkStateChangeRequest.html#72db012e138c6aa153bdb630b96c0cac" title="Requested state.">state_</a>);
<a name="l01438"></a>01438     <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3" title="The possible states for a link.">Link::state_t</a> old_state = <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3" title="The possible states for a link.">Link::state_t</a>(request-&gt;<a class="code" href="classdtn_1_1LinkStateChangeRequest.html#0e15f7f1c02630a6fd88f34f14630361" title="State when the request was made.">old_state_</a>);
<a name="l01439"></a>01439     <span class="keywordtype">int</span> reason = request-&gt;<a class="code" href="classdtn_1_1ContactEvent.html#1f6f825ff0051afb3432f2983adc8abf" title="reason code for the event">reason_</a>;
<a name="l01440"></a>01440 
<a name="l01441"></a>01441     <span class="keywordflow">if</span> (link-&gt;isdeleted() &amp;&amp; new_state != <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a32e48e0c707487f143c54dd1cd5185323" title="Bogus state that&amp;#39;s never actually used in the Link state_ variable, but is used...">Link::CLOSED</a>) {
<a name="l01442"></a>01442         log_warn(<span class="stringliteral">"BundleDaemon::handle_link_state_change_request: "</span>
<a name="l01443"></a>01443                  <span class="stringliteral">"link %s already deleted; cannot change link state to %s"</span>,
<a name="l01444"></a>01444                  link-&gt;name(), <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">Link::state_to_str</a>(new_state));
<a name="l01445"></a>01445         <span class="keywordflow">return</span>;
<a name="l01446"></a>01446     }
<a name="l01447"></a>01447     
<a name="l01448"></a>01448     <span class="keywordflow">if</span> (link-&gt;contact() != request-&gt;<a class="code" href="classdtn_1_1LinkStateChangeRequest.html#a0e4195a754df83ec6f30c4a378b3203" title="The active Contact when the request was made.">contact_</a>) {
<a name="l01449"></a>01449         log_warn(<span class="stringliteral">"stale LINK_STATE_CHANGE_REQUEST [%s -&gt; %s] (%s) for "</span>
<a name="l01450"></a>01450                  <span class="stringliteral">"link *%p: contact %p != current contact %p"</span>, 
<a name="l01451"></a>01451                  <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">Link::state_to_str</a>(old_state), <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">Link::state_to_str</a>(new_state),
<a name="l01452"></a>01452                  <a class="code" href="classdtn_1_1ContactEvent.html#9ce1fd3e3d0a1c675a90423eefac8a6e" title="Reason to string conversion.">ContactEvent::reason_to_str</a>(reason), link.object(),
<a name="l01453"></a>01453                  request-&gt;<a class="code" href="classdtn_1_1LinkStateChangeRequest.html#a0e4195a754df83ec6f30c4a378b3203" title="The active Contact when the request was made.">contact_</a>.object(), link-&gt;contact().object());
<a name="l01454"></a>01454         <span class="keywordflow">return</span>;
<a name="l01455"></a>01455     }
<a name="l01456"></a>01456 
<a name="l01457"></a>01457     log_info(<span class="stringliteral">"LINK_STATE_CHANGE_REQUEST [%s -&gt; %s] (%s) for link *%p"</span>,
<a name="l01458"></a>01458              <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">Link::state_to_str</a>(old_state), <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">Link::state_to_str</a>(new_state),
<a name="l01459"></a>01459              <a class="code" href="classdtn_1_1ContactEvent.html#9ce1fd3e3d0a1c675a90423eefac8a6e" title="Reason to string conversion.">ContactEvent::reason_to_str</a>(reason), link.object());
<a name="l01460"></a>01460 
<a name="l01461"></a>01461     <span class="comment">//avoid a race condition caused by opening a partially closed link</span>
<a name="l01462"></a>01462     oasys::ScopeLock l;
<a name="l01463"></a>01463     <span class="keywordflow">if</span> (new_state == <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3ec7a744ed0ed07ccb2b255a0d76192c8" title="A convergence layer session has been established, and the link has capacity for a...">Link::OPEN</a>)
<a name="l01464"></a>01464     {
<a name="l01465"></a>01465         l.set_lock(<a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#6edebce9cf6080f854039f8df593cfec" title="Accessor for the ContactManager internal lock.">lock</a>(), <span class="stringliteral">"BundleDaemon::handle_link_state_change_request"</span>);
<a name="l01466"></a>01466     }
<a name="l01467"></a>01467     
<a name="l01468"></a>01468     <span class="keywordflow">switch</span>(new_state) {
<a name="l01469"></a>01469     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3fcb80aea04644bdc565b13fa371b2e1e" title="The link is closed and not able to be opened currently.">Link::UNAVAILABLE</a>:
<a name="l01470"></a>01470         <span class="keywordflow">if</span> (link-&gt;state() != <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a36a3d11409342e7987b0ffe9c532d6e51" title="The link is closed but is able to be opened, either because it is an on demand link...">Link::AVAILABLE</a>) {
<a name="l01471"></a>01471             log_err(<span class="stringliteral">"LINK_STATE_CHANGE_REQUEST *%p: "</span>
<a name="l01472"></a>01472                     <span class="stringliteral">"tried to set state UNAVAILABLE in state %s"</span>,
<a name="l01473"></a>01473                     link.object(), <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">Link::state_to_str</a>(link-&gt;state()));
<a name="l01474"></a>01474             <span class="keywordflow">return</span>;
<a name="l01475"></a>01475         }
<a name="l01476"></a>01476         link-&gt;set_state(new_state);
<a name="l01477"></a>01477         <a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686" title="Queues the event at the head of the queue for processing by the daemon thread.">post_at_head</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1LinkUnavailableEvent.html" title="Event class for link unavailable events.">LinkUnavailableEvent</a>(link,
<a name="l01478"></a>01478                      <a class="code" href="classdtn_1_1ContactEvent.html#e20f7357509a2bcca3d8e6c8daf552f7" title="Reason codes for contact state operations.">ContactEvent::reason_t</a>(reason)));
<a name="l01479"></a>01479         <span class="keywordflow">break</span>;
<a name="l01480"></a>01480 
<a name="l01481"></a>01481     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a36a3d11409342e7987b0ffe9c532d6e51" title="The link is closed but is able to be opened, either because it is an on demand link...">Link::AVAILABLE</a>:
<a name="l01482"></a>01482         <span class="keywordflow">if</span> (link-&gt;state() == <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3fcb80aea04644bdc565b13fa371b2e1e" title="The link is closed and not able to be opened currently.">Link::UNAVAILABLE</a>) {
<a name="l01483"></a>01483             link-&gt;set_state(<a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a36a3d11409342e7987b0ffe9c532d6e51" title="The link is closed but is able to be opened, either because it is an on demand link...">Link::AVAILABLE</a>);
<a name="l01484"></a>01484             
<a name="l01485"></a>01485         } <span class="keywordflow">else</span> {
<a name="l01486"></a>01486             log_err(<span class="stringliteral">"LINK_STATE_CHANGE_REQUEST *%p: "</span>
<a name="l01487"></a>01487                     <span class="stringliteral">"tried to set state AVAILABLE in state %s"</span>,
<a name="l01488"></a>01488                     link.object(), <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">Link::state_to_str</a>(link-&gt;state()));
<a name="l01489"></a>01489             <span class="keywordflow">return</span>;
<a name="l01490"></a>01490         }
<a name="l01491"></a>01491 
<a name="l01492"></a>01492         <a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686" title="Queues the event at the head of the queue for processing by the daemon thread.">post_at_head</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1LinkAvailableEvent.html" title="Event class for link available events.">LinkAvailableEvent</a>(link,
<a name="l01493"></a>01493                      <a class="code" href="classdtn_1_1ContactEvent.html#e20f7357509a2bcca3d8e6c8daf552f7" title="Reason codes for contact state operations.">ContactEvent::reason_t</a>(reason)));
<a name="l01494"></a>01494         <span class="keywordflow">break</span>;
<a name="l01495"></a>01495         
<a name="l01496"></a>01496     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a335e8afe56056fd46352661764b8982df" title="A convergence layer session is in the process of being established.">Link::OPENING</a>:
<a name="l01497"></a>01497     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3ec7a744ed0ed07ccb2b255a0d76192c8" title="A convergence layer session has been established, and the link has capacity for a...">Link::OPEN</a>:
<a name="l01498"></a>01498         <span class="comment">// force the link to be available, since someone really wants it open</span>
<a name="l01499"></a>01499         <span class="keywordflow">if</span> (link-&gt;state() == <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3fcb80aea04644bdc565b13fa371b2e1e" title="The link is closed and not able to be opened currently.">Link::UNAVAILABLE</a>) {
<a name="l01500"></a>01500             link-&gt;set_state(<a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a36a3d11409342e7987b0ffe9c532d6e51" title="The link is closed but is able to be opened, either because it is an on demand link...">Link::AVAILABLE</a>);
<a name="l01501"></a>01501         }
<a name="l01502"></a>01502         <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a>-&gt;<a class="code" href="classdtn_1_1BundleActions.html#0cb4ef96c172a1943d32d19747a00438" title="Open a link for bundle transmission.">open_link</a>(link);
<a name="l01503"></a>01503         <span class="keywordflow">break</span>;
<a name="l01504"></a>01504 
<a name="l01505"></a>01505     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a32e48e0c707487f143c54dd1cd5185323" title="Bogus state that&amp;#39;s never actually used in the Link state_ variable, but is used...">Link::CLOSED</a>:
<a name="l01506"></a>01506         <span class="comment">// The only case where we should get this event when the link</span>
<a name="l01507"></a>01507         <span class="comment">// is not actually open is if it's in the process of being</span>
<a name="l01508"></a>01508         <span class="comment">// opened but the CL can't actually open it.</span>
<a name="l01509"></a>01509         <span class="keywordflow">if</span> (! link-&gt;isopen() &amp;&amp; ! link-&gt;isopening()) {
<a name="l01510"></a>01510             log_err(<span class="stringliteral">"LINK_STATE_CHANGE_REQUEST *%p: "</span>
<a name="l01511"></a>01511                     <span class="stringliteral">"setting state CLOSED (%s) in unexpected state %s"</span>,
<a name="l01512"></a>01512                     link.object(), <a class="code" href="classdtn_1_1ContactEvent.html#9ce1fd3e3d0a1c675a90423eefac8a6e" title="Reason to string conversion.">ContactEvent::reason_to_str</a>(reason),
<a name="l01513"></a>01513                     <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">Link::state_to_str</a>(link-&gt;state()));
<a name="l01514"></a>01514             <span class="keywordflow">break</span>;
<a name="l01515"></a>01515         }
<a name="l01516"></a>01516 
<a name="l01517"></a>01517         <span class="comment">// If the link is open (not OPENING), we need a ContactDownEvent</span>
<a name="l01518"></a>01518         <span class="keywordflow">if</span> (link-&gt;isopen()) {
<a name="l01519"></a>01519             <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link-&gt;contact() != NULL);
<a name="l01520"></a>01520             <a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686" title="Queues the event at the head of the queue for processing by the daemon thread.">post_at_head</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1ContactDownEvent.html" title="Event class for contact down events.">ContactDownEvent</a>(link-&gt;contact(),
<a name="l01521"></a>01521                          <a class="code" href="classdtn_1_1ContactEvent.html#e20f7357509a2bcca3d8e6c8daf552f7" title="Reason codes for contact state operations.">ContactEvent::reason_t</a>(reason)));
<a name="l01522"></a>01522         }
<a name="l01523"></a>01523 
<a name="l01524"></a>01524         <span class="comment">// close the link</span>
<a name="l01525"></a>01525         <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a>-&gt;<a class="code" href="classdtn_1_1BundleActions.html#7785a114a3789ffb4eda31e3dbb19f1e" title="Open a link for bundle transmission.">close_link</a>(link);
<a name="l01526"></a>01526         
<a name="l01527"></a>01527         <span class="comment">// now, based on the reason code, update the link availability</span>
<a name="l01528"></a>01528         <span class="comment">// and set state accordingly</span>
<a name="l01529"></a>01529         <span class="keywordflow">if</span> (reason == <a class="code" href="classdtn_1_1ContactEvent.html#e20f7357509a2bcca3d8e6c8daf552f7cc4b8963a82f22c0d9b61c37e06e877e" title="Idle connection shut down by the CL.">ContactEvent::IDLE</a>) {
<a name="l01530"></a>01530             link-&gt;set_state(<a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a36a3d11409342e7987b0ffe9c532d6e51" title="The link is closed but is able to be opened, either because it is an on demand link...">Link::AVAILABLE</a>);
<a name="l01531"></a>01531         } <span class="keywordflow">else</span> {
<a name="l01532"></a>01532             link-&gt;set_state(<a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3fcb80aea04644bdc565b13fa371b2e1e" title="The link is closed and not able to be opened currently.">Link::UNAVAILABLE</a>);
<a name="l01533"></a>01533             <a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686" title="Queues the event at the head of the queue for processing by the daemon thread.">post_at_head</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1LinkUnavailableEvent.html" title="Event class for link unavailable events.">LinkUnavailableEvent</a>(link,
<a name="l01534"></a>01534                          <a class="code" href="classdtn_1_1ContactEvent.html#e20f7357509a2bcca3d8e6c8daf552f7" title="Reason codes for contact state operations.">ContactEvent::reason_t</a>(reason)));
<a name="l01535"></a>01535         }
<a name="l01536"></a>01536     
<a name="l01537"></a>01537         <span class="keywordflow">break</span>;
<a name="l01538"></a>01538 
<a name="l01539"></a>01539     <span class="keywordflow">default</span>:
<a name="l01540"></a>01540         PANIC(<span class="stringliteral">"unhandled state %s"</span>, <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">Link::state_to_str</a>(new_state));
<a name="l01541"></a>01541     }
<a name="l01542"></a>01542 }
<a name="l01543"></a>01543 
<a name="l01544"></a>01544 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01545"></a>01545 <span class="keywordtype">void</span>
<a name="l01546"></a><a class="code" href="classdtn_1_1BundleDaemon.html#8ac0bfe44ece0d767c851444c64fefc5">01546</a> <a class="code" href="classdtn_1_1BundleDaemon.html#8ac0bfe44ece0d767c851444c64fefc5" title="Event type specific handlers.">BundleDaemon::handle_link_create</a>(<a class="code" href="classdtn_1_1LinkCreateRequest.html" title="Event class for creating and opening a link.">LinkCreateRequest</a>* request)
<a name="l01547"></a>01547 {
<a name="l01548"></a>01548     <span class="comment">//lock the contact manager so no one creates a link before we do</span>
<a name="l01549"></a>01549     <a class="code" href="classdtn_1_1ContactManager.html" title="A contact manager class.">ContactManager</a>* cm = BundleDaemon::instance()-&gt;contactmgr();
<a name="l01550"></a>01550     oasys::ScopeLock l(cm-&gt;<a class="code" href="classdtn_1_1ContactManager.html#6edebce9cf6080f854039f8df593cfec" title="Accessor for the ContactManager internal lock.">lock</a>(), <span class="stringliteral">"BundleDaemon::handle_link_create"</span>);
<a name="l01551"></a>01551     <span class="comment">//check for an existing link with that name</span>
<a name="l01552"></a>01552     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> linkCheck = cm-&gt;<a class="code" href="classdtn_1_1ContactManager.html#4a31131016ed7f6b11ce6823dd7abe91" title="Finds link corresponding to this name.">find_link</a>(request-&gt;<a class="code" href="classdtn_1_1LinkCreateRequest.html#1387d4c4458a0db983f5867c3db6b281" title="Next hop EID.">name_</a>.c_str());
<a name="l01553"></a>01553     <span class="keywordflow">if</span>(linkCheck != NULL)
<a name="l01554"></a>01554     {
<a name="l01555"></a>01555         log_err( <span class="stringliteral">"Link already exists with name %s, aborting create"</span>, request-&gt;<a class="code" href="classdtn_1_1LinkCreateRequest.html#1387d4c4458a0db983f5867c3db6b281" title="Next hop EID.">name_</a>.c_str());
<a name="l01556"></a>01556         request-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#4de9b57df34c041e8b313234d69ae6e9" title="Bit indicating whether this event is for the daemon only or if it should be propagated...">daemon_only_</a> = <span class="keyword">true</span>;
<a name="l01557"></a>01557         <span class="keywordflow">return</span>;
<a name="l01558"></a>01558     }
<a name="l01559"></a>01559   
<a name="l01560"></a>01560     std::string nexthop(<span class="stringliteral">""</span>);
<a name="l01561"></a>01561 
<a name="l01562"></a>01562     <span class="keywordtype">int</span> argc = request-&gt;<a class="code" href="classdtn_1_1LinkCreateRequest.html#d668defa5e42c1ba0d4630b632cb582c">parameters_</a>.size();
<a name="l01563"></a>01563     <span class="keywordtype">char</span>* argv[argc];
<a name="l01564"></a>01564     AttributeVector::iterator iter;
<a name="l01565"></a>01565     <span class="keywordtype">int</span> i = 0;
<a name="l01566"></a>01566     <span class="keywordflow">for</span> (iter = request-&gt;<a class="code" href="classdtn_1_1LinkCreateRequest.html#d668defa5e42c1ba0d4630b632cb582c">parameters_</a>.begin();
<a name="l01567"></a>01567          iter != request-&gt;<a class="code" href="classdtn_1_1LinkCreateRequest.html#d668defa5e42c1ba0d4630b632cb582c">parameters_</a>.end();
<a name="l01568"></a>01568          iter++)
<a name="l01569"></a>01569     {
<a name="l01570"></a>01570         <span class="keywordflow">if</span> (iter-&gt;name() == <span class="stringliteral">"nexthop"</span>) {
<a name="l01571"></a>01571             nexthop = iter-&gt;string_val();
<a name="l01572"></a>01572         }
<a name="l01573"></a>01573         <span class="keywordflow">else</span> {
<a name="l01574"></a>01574             std::string arg = iter-&gt;name() + iter-&gt;string_val();
<a name="l01575"></a>01575             argv[i] = <span class="keyword">new</span> <span class="keywordtype">char</span>[arg.length()+1];
<a name="l01576"></a>01576             memcpy(argv[i], arg.c_str(), arg.length()+1);
<a name="l01577"></a>01577             i++;
<a name="l01578"></a>01578         }
<a name="l01579"></a>01579     }
<a name="l01580"></a>01580     argc = i+1;
<a name="l01581"></a>01581 
<a name="l01582"></a>01582     <span class="keyword">const</span> <span class="keywordtype">char</span> *invalidp;
<a name="l01583"></a>01583     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = <a class="code" href="classdtn_1_1Link.html#caf84c89199fccadfaecfc85a46d96f7" title="Static function to create appropriate link object from link type.">Link::create_link</a>(request-&gt;<a class="code" href="classdtn_1_1LinkCreateRequest.html#1387d4c4458a0db983f5867c3db6b281" title="Next hop EID.">name_</a>, request-&gt;<a class="code" href="classdtn_1_1LinkCreateRequest.html#7070a6e143338a86e224ba8f5807ceaf" title="CL to use.">link_type_</a>,
<a name="l01584"></a>01584                                      request-&gt;<a class="code" href="classdtn_1_1LinkCreateRequest.html#036b096b49bf6668b062533115766edd" title="An optional set of key, value pairs.">cla_</a>, nexthop.c_str(), argc,
<a name="l01585"></a>01585                                      (<span class="keyword">const</span> <span class="keywordtype">char</span>**)argv, &amp;invalidp);
<a name="l01586"></a>01586     <span class="keywordflow">for</span> (i = 0; i &lt; argc; i++) {
<a name="l01587"></a>01587         <span class="keyword">delete</span> argv[i];
<a name="l01588"></a>01588     }
<a name="l01589"></a>01589 
<a name="l01590"></a>01590     <span class="keywordflow">if</span> (link == NULL) {
<a name="l01591"></a>01591         log_err(<span class="stringliteral">"LINK_CREATE %s failed"</span>, request-&gt;<a class="code" href="classdtn_1_1LinkCreateRequest.html#1387d4c4458a0db983f5867c3db6b281" title="Next hop EID.">name_</a>.c_str());
<a name="l01592"></a>01592         <span class="keywordflow">return</span>;
<a name="l01593"></a>01593     }
<a name="l01594"></a>01594     <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&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>(link)) {
<a name="l01595"></a>01595         log_err(<span class="stringliteral">"LINK_CREATE %s failed, already exists"</span>,
<a name="l01596"></a>01596                 request-&gt;<a class="code" href="classdtn_1_1LinkCreateRequest.html#1387d4c4458a0db983f5867c3db6b281" title="Next hop EID.">name_</a>.c_str());
<a name="l01597"></a>01597         link-&gt;delete_link();
<a name="l01598"></a>01598         <span class="keywordflow">return</span>;
<a name="l01599"></a>01599     }
<a name="l01600"></a>01600     log_info(<span class="stringliteral">"LINK_CREATE %s: *%p"</span>, request-&gt;<a class="code" href="classdtn_1_1LinkCreateRequest.html#1387d4c4458a0db983f5867c3db6b281" title="Next hop EID.">name_</a>.c_str(), link.object());
<a name="l01601"></a>01601 }
<a name="l01602"></a>01602 
<a name="l01603"></a>01603 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01604"></a>01604 <span class="keywordtype">void</span>
<a name="l01605"></a><a class="code" href="classdtn_1_1BundleDaemon.html#a3abbb2cd35bd4a46b5ee4b0b3f2fe6b">01605</a> <a class="code" href="classdtn_1_1BundleDaemon.html#a3abbb2cd35bd4a46b5ee4b0b3f2fe6b" title="Event type specific handlers.">BundleDaemon::handle_link_delete</a>(<a class="code" href="classdtn_1_1LinkDeleteRequest.html" title="Event class for requesting deletion of a link.">LinkDeleteRequest</a>* request)
<a name="l01606"></a>01606 {
<a name="l01607"></a>01607     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = request-&gt;<a class="code" href="classdtn_1_1LinkDeleteRequest.html#5ba337fff460d600d9879a39aada8d91">link_</a>;
<a name="l01608"></a>01608     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l01609"></a>01609 
<a name="l01610"></a>01610     log_info(<span class="stringliteral">"LINK_DELETE *%p"</span>, link.object());
<a name="l01611"></a>01611     <span class="keywordflow">if</span> (!link-&gt;isdeleted()) {
<a name="l01612"></a>01612         <a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#54d224d2c2a8436d06f44d8880975cd5" title="Delete a link.">del_link</a>(link);
<a name="l01613"></a>01613     }
<a name="l01614"></a>01614 }
<a name="l01615"></a>01615 
<a name="l01616"></a>01616 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01617"></a>01617 <span class="keywordtype">void</span>
<a name="l01618"></a><a class="code" href="classdtn_1_1BundleDaemon.html#1793c9a5228d582e93355c1ee612b44c">01618</a> <a class="code" href="classdtn_1_1BundleDaemon.html#1793c9a5228d582e93355c1ee612b44c" title="Event type specific handlers.">BundleDaemon::handle_link_reconfigure</a>(<a class="code" href="classdtn_1_1LinkReconfigureRequest.html" title="Event class for reconfiguring an existing link.">LinkReconfigureRequest</a> *request)
<a name="l01619"></a>01619 {
<a name="l01620"></a>01620     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = request-&gt;<a class="code" href="classdtn_1_1LinkReconfigureRequest.html#aca112706c4bc9eae7763160242d715c" title="Set of key, value pairs.">link_</a>;
<a name="l01621"></a>01621     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l01622"></a>01622 
<a name="l01623"></a>01623     link-&gt;reconfigure_link(request-&gt;<a class="code" href="classdtn_1_1LinkReconfigureRequest.html#a0956a99740fdf97afa8e0bf30ae5ae5">parameters_</a>);
<a name="l01624"></a>01624     log_info(<span class="stringliteral">"LINK_RECONFIGURE *%p"</span>, link.object());
<a name="l01625"></a>01625 }
<a name="l01626"></a>01626 
<a name="l01627"></a>01627 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01628"></a>01628 <span class="keywordtype">void</span>
<a name="l01629"></a><a class="code" href="classdtn_1_1BundleDaemon.html#b0d92ae30025468fccc631d295f32ed3">01629</a> <a class="code" href="classdtn_1_1BundleDaemon.html#b0d92ae30025468fccc631d295f32ed3" title="Event type specific handlers.">BundleDaemon::handle_link_query</a>(<a class="code" href="classdtn_1_1LinkQueryRequest.html" title="Event classes for link queries and responses.">LinkQueryRequest</a>*)
<a name="l01630"></a>01630 {
<a name="l01631"></a>01631     <a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686" title="Queues the event at the head of the queue for processing by the daemon thread.">BundleDaemon::post_at_head</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1LinkReportEvent.html">LinkReportEvent</a>());
<a name="l01632"></a>01632 }
<a name="l01633"></a>01633 
<a name="l01634"></a>01634 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01635"></a>01635 <span class="keywordtype">void</span>
<a name="l01636"></a><a class="code" href="classdtn_1_1BundleDaemon.html#ee9d1ecd83b366b7681c43d89f53b56d">01636</a> <a class="code" href="classdtn_1_1BundleDaemon.html#ee9d1ecd83b366b7681c43d89f53b56d" title="Event type specific handlers.">BundleDaemon::handle_link_report</a>(<a class="code" href="classdtn_1_1LinkReportEvent.html">LinkReportEvent</a>*)
<a name="l01637"></a>01637 {
<a name="l01638"></a>01638 }
<a name="l01639"></a>01639 
<a name="l01640"></a>01640 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01641"></a>01641 <span class="keywordtype">void</span>
<a name="l01642"></a><a class="code" href="classdtn_1_1BundleDaemon.html#e7914673f00b483468071e5fe203e021">01642</a> <a class="code" href="classdtn_1_1BundleDaemon.html#e7914673f00b483468071e5fe203e021" title="Event type specific handlers.">BundleDaemon::handle_bundle_queued_query</a>(<a class="code" href="classdtn_1_1BundleQueuedQueryRequest.html">BundleQueuedQueryRequest</a>* request)
<a name="l01643"></a>01643 {
<a name="l01644"></a>01644     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = request-&gt;<a class="code" href="classdtn_1_1BundleQueuedQueryRequest.html#c6306fc8cb2966763a5dd42258a6ab58" title="Link on which to check if the given bundle is queued.">link_</a>;
<a name="l01645"></a>01645     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l01646"></a>01646     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link-&gt;clayer() != NULL);
<a name="l01647"></a>01647 
<a name="l01648"></a>01648     log_debug(<span class="stringliteral">"BundleDaemon::handle_bundle_queued_query: "</span>
<a name="l01649"></a>01649               <span class="stringliteral">"query %s, checking if bundle *%p is queued on link *%p"</span>,
<a name="l01650"></a>01650               request-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>.c_str(),
<a name="l01651"></a>01651               request-&gt;<a class="code" href="classdtn_1_1BundleQueuedQueryRequest.html#26bc5c71f9634f9edc1a381bb979206c" title="Bundle to be checked for queued status.">bundle_</a>.object(), link.object());
<a name="l01652"></a>01652     
<a name="l01653"></a>01653     <span class="keywordtype">bool</span> is_queued = request-&gt;<a class="code" href="classdtn_1_1BundleQueuedQueryRequest.html#26bc5c71f9634f9edc1a381bb979206c" title="Bundle to be checked for queued status.">bundle_</a>-&gt;is_queued_on(link-&gt;queue());
<a name="l01654"></a>01654     <a class="code" href="classdtn_1_1BundleDaemon.html#370a80f7dd9fd9297e76d7f830d737a8" title="Queues the event at the tail of the queue for processing by the daemon thread.">BundleDaemon::post</a>(
<a name="l01655"></a>01655         <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleQueuedReportEvent.html">BundleQueuedReportEvent</a>(request-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>, is_queued));
<a name="l01656"></a>01656 }
<a name="l01657"></a>01657 
<a name="l01658"></a>01658 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01659"></a>01659 <span class="keywordtype">void</span>
<a name="l01660"></a><a class="code" href="classdtn_1_1BundleDaemon.html#1b30b9173206e0a65014481af3f258ce">01660</a> <a class="code" href="classdtn_1_1BundleDaemon.html#1b30b9173206e0a65014481af3f258ce" title="Event type specific handlers.">BundleDaemon::handle_bundle_queued_report</a>(<a class="code" href="classdtn_1_1BundleQueuedReportEvent.html">BundleQueuedReportEvent</a>* event)
<a name="l01661"></a>01661 {
<a name="l01662"></a>01662     (void)event;
<a name="l01663"></a>01663     log_debug(<span class="stringliteral">"BundleDaemon::handle_bundle_queued_report: query %s, %s"</span>,
<a name="l01664"></a>01664               event-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>.c_str(),
<a name="l01665"></a>01665               (<span class="keyword">event</span>-&gt;is_queued_? <span class="stringliteral">"true"</span> : <span class="stringliteral">"false"</span>));
<a name="l01666"></a>01666 }
<a name="l01667"></a>01667 
<a name="l01668"></a>01668 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01669"></a>01669 <span class="keywordtype">void</span>
<a name="l01670"></a><a class="code" href="classdtn_1_1BundleDaemon.html#4327afa70d4e476705ba288c7c174f7a">01670</a> <a class="code" href="classdtn_1_1BundleDaemon.html#4327afa70d4e476705ba288c7c174f7a" title="Event type specific handlers.">BundleDaemon::handle_eid_reachable_query</a>(<a class="code" href="classdtn_1_1EIDReachableQueryRequest.html">EIDReachableQueryRequest</a>* request)
<a name="l01671"></a>01671 {
<a name="l01672"></a>01672     <a class="code" href="classdtn_1_1Interface.html" title="Abstraction of a local dtn interface.">Interface</a> *iface = request-&gt;<a class="code" href="classdtn_1_1EIDReachableQueryRequest.html#b89bcb8201c70c499692ed78b1a9d8a8" title="Interface on which to check if the given endpoint is reachable.">iface_</a>;
<a name="l01673"></a>01673     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(iface != NULL);
<a name="l01674"></a>01674     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(iface-&gt;<a class="code" href="classdtn_1_1Interface.html#a66e0906d6d60bca99d8d31049db7f85">clayer</a>() != NULL);
<a name="l01675"></a>01675 
<a name="l01676"></a>01676     log_debug(<span class="stringliteral">"BundleDaemon::handle_eid_reachable_query: query %s, "</span>
<a name="l01677"></a>01677               <span class="stringliteral">"checking if endpoint %s is reachable via interface *%p"</span>,
<a name="l01678"></a>01678               request-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>.c_str(), request-&gt;<a class="code" href="classdtn_1_1EIDReachableQueryRequest.html#54f6d5a0630fa255e981fd2fb5b36cb3" title="Endpoint to be checked for reachable status.">endpoint_</a>.c_str(), iface);
<a name="l01679"></a>01679 
<a name="l01680"></a>01680     iface-&gt;<a class="code" href="classdtn_1_1Interface.html#a66e0906d6d60bca99d8d31049db7f85">clayer</a>()-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#6d587dec33bf6ae24717c4a124009c46" title="Report if the given endpoint is reachable via the given interface.">is_eid_reachable</a>(request-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>,
<a name="l01681"></a>01681                                       iface,
<a name="l01682"></a>01682                                       request-&gt;<a class="code" href="classdtn_1_1EIDReachableQueryRequest.html#54f6d5a0630fa255e981fd2fb5b36cb3" title="Endpoint to be checked for reachable status.">endpoint_</a>);
<a name="l01683"></a>01683 }
<a name="l01684"></a>01684 
<a name="l01685"></a>01685 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01686"></a>01686 <span class="keywordtype">void</span>
<a name="l01687"></a><a class="code" href="classdtn_1_1BundleDaemon.html#440ea076fa8a609f0c0161eaefcd3ad9">01687</a> <a class="code" href="classdtn_1_1BundleDaemon.html#440ea076fa8a609f0c0161eaefcd3ad9" title="Event type specific handlers.">BundleDaemon::handle_eid_reachable_report</a>(<a class="code" href="classdtn_1_1EIDReachableReportEvent.html">EIDReachableReportEvent</a>* event)
<a name="l01688"></a>01688 {
<a name="l01689"></a>01689     (void)event;
<a name="l01690"></a>01690     log_debug(<span class="stringliteral">"BundleDaemon::handle_eid_reachable_report: query %s, %s"</span>,
<a name="l01691"></a>01691               event-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>.c_str(),
<a name="l01692"></a>01692               (<span class="keyword">event</span>-&gt;is_reachable_? <span class="stringliteral">"true"</span> : <span class="stringliteral">"false"</span>));
<a name="l01693"></a>01693 }
<a name="l01694"></a>01694 
<a name="l01695"></a>01695 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01696"></a>01696 <span class="keywordtype">void</span>
<a name="l01697"></a><a class="code" href="classdtn_1_1BundleDaemon.html#199242dd6b951e665ec498472e1bc193">01697</a> <a class="code" href="classdtn_1_1BundleDaemon.html#199242dd6b951e665ec498472e1bc193" title="Event type specific handlers.">BundleDaemon::handle_link_attribute_changed</a>(<a class="code" href="classdtn_1_1LinkAttributeChangedEvent.html" title="Event class for a change in link attributes.">LinkAttributeChangedEvent</a> *event)
<a name="l01698"></a>01698 {
<a name="l01699"></a>01699     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = <span class="keyword">event</span>-&gt;link_;
<a name="l01700"></a>01700 
<a name="l01701"></a>01701     <span class="keywordflow">if</span> (link-&gt;isdeleted()) {
<a name="l01702"></a>01702         log_debug(<span class="stringliteral">"BundleDaemon::handle_link_attribute_changed: "</span>
<a name="l01703"></a>01703                   <span class="stringliteral">"link %s deleted"</span>, link-&gt;name());
<a name="l01704"></a>01704         <span class="keyword">event</span>-&gt;daemon_only_ = <span class="keyword">true</span>;
<a name="l01705"></a>01705         <span class="keywordflow">return</span>;
<a name="l01706"></a>01706     }
<a name="l01707"></a>01707 
<a name="l01708"></a>01708     <span class="comment">// Update any state as necessary</span>
<a name="l01709"></a>01709     AttributeVector::iterator iter;
<a name="l01710"></a>01710     <span class="keywordflow">for</span> (iter = event-&gt;<a class="code" href="classdtn_1_1LinkAttributeChangedEvent.html#50fd84fb38096fb51a8a883eada80187">attributes_</a>.begin();
<a name="l01711"></a>01711          iter != <span class="keyword">event</span>-&gt;attributes_.end();
<a name="l01712"></a>01712          iter++)
<a name="l01713"></a>01713     {
<a name="l01714"></a>01714         <span class="keywordflow">if</span> (iter-&gt;name() == <span class="stringliteral">"nexthop"</span>) {
<a name="l01715"></a>01715             link-&gt;set_nexthop(iter-&gt;string_val());
<a name="l01716"></a>01716         }
<a name="l01717"></a>01717         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (iter-&gt;name() == <span class="stringliteral">"how_reliable"</span>) {
<a name="l01718"></a>01718             link-&gt;stats()-&gt;reliability_ = iter-&gt;u_int_val();
<a name="l01719"></a>01719         }
<a name="l01720"></a>01720         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (iter-&gt;name() == <span class="stringliteral">"how_available"</span>) {
<a name="l01721"></a>01721             link-&gt;stats()-&gt;availability_ = iter-&gt;u_int_val();
<a name="l01722"></a>01722         }
<a name="l01723"></a>01723     }
<a name="l01724"></a>01724     log_info(<span class="stringliteral">"LINK_ATTRIB_CHANGED *%p"</span>, link.object());
<a name="l01725"></a>01725 }
<a name="l01726"></a>01726   
<a name="l01727"></a>01727 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01728"></a>01728 <span class="keywordtype">void</span>
<a name="l01729"></a><a class="code" href="classdtn_1_1BundleDaemon.html#97bf54b1dc65be56bbdbe0ffe37eae5b">01729</a> <a class="code" href="classdtn_1_1BundleDaemon.html#97bf54b1dc65be56bbdbe0ffe37eae5b" title="Event type specific handlers.">BundleDaemon::handle_link_attributes_query</a>(<a class="code" href="classdtn_1_1LinkAttributesQueryRequest.html">LinkAttributesQueryRequest</a>* request)
<a name="l01730"></a>01730 {
<a name="l01731"></a>01731     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = request-&gt;<a class="code" href="classdtn_1_1LinkAttributesQueryRequest.html#03115f0c433acf27f4c2472cb0ddf34d" title="Link for which the given attributes are requested.">link_</a>;
<a name="l01732"></a>01732     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l01733"></a>01733     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link-&gt;clayer() != NULL);
<a name="l01734"></a>01734 
<a name="l01735"></a>01735     log_debug(<span class="stringliteral">"BundleDaemon::handle_link_attributes_query: query %s, link *%p"</span>,
<a name="l01736"></a>01736               request-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>.c_str(), link.object());
<a name="l01737"></a>01737 
<a name="l01738"></a>01738     link-&gt;clayer()-&gt;query_link_attributes(request-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>,
<a name="l01739"></a>01739                                           link,
<a name="l01740"></a>01740                                           request-&gt;<a class="code" href="classdtn_1_1LinkAttributesQueryRequest.html#8c1126624d376588320555bd49b869da" title="Link attributes requested by name.">attribute_names_</a>);
<a name="l01741"></a>01741 }
<a name="l01742"></a>01742 
<a name="l01743"></a>01743 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01744"></a>01744 <span class="keywordtype">void</span>
<a name="l01745"></a><a class="code" href="classdtn_1_1BundleDaemon.html#7e6f3ec8c6ed9585853dbbdfdc1865d7">01745</a> <a class="code" href="classdtn_1_1BundleDaemon.html#7e6f3ec8c6ed9585853dbbdfdc1865d7" title="Event type specific handlers.">BundleDaemon::handle_link_attributes_report</a>(<a class="code" href="classdtn_1_1LinkAttributesReportEvent.html">LinkAttributesReportEvent</a>* event)
<a name="l01746"></a>01746 {
<a name="l01747"></a>01747     (void)event;
<a name="l01748"></a>01748     log_debug(<span class="stringliteral">"BundleDaemon::handle_link_attributes_report: query %s"</span>,
<a name="l01749"></a>01749               event-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>.c_str());
<a name="l01750"></a>01750 }
<a name="l01751"></a>01751 
<a name="l01752"></a>01752 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01753"></a>01753 <span class="keywordtype">void</span>
<a name="l01754"></a><a class="code" href="classdtn_1_1BundleDaemon.html#e1527b74330d767f21d4b8fde8473a74">01754</a> <a class="code" href="classdtn_1_1BundleDaemon.html#e1527b74330d767f21d4b8fde8473a74" title="Event type specific handlers.">BundleDaemon::handle_iface_attributes_query</a>(
<a name="l01755"></a>01755                   <a class="code" href="classdtn_1_1IfaceAttributesQueryRequest.html">IfaceAttributesQueryRequest</a>* request)
<a name="l01756"></a>01756 {
<a name="l01757"></a>01757     <a class="code" href="classdtn_1_1Interface.html" title="Abstraction of a local dtn interface.">Interface</a> *iface = request-&gt;<a class="code" href="classdtn_1_1IfaceAttributesQueryRequest.html#92dc56a71add9e3a535de59719793659" title="Interface for which the given attributes are requested.">iface_</a>;
<a name="l01758"></a>01758     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(iface != NULL);
<a name="l01759"></a>01759     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(iface-&gt;<a class="code" href="classdtn_1_1Interface.html#a66e0906d6d60bca99d8d31049db7f85">clayer</a>() != NULL);
<a name="l01760"></a>01760 
<a name="l01761"></a>01761     log_debug(<span class="stringliteral">"BundleDaemon::handle_iface_attributes_query: "</span>
<a name="l01762"></a>01762               <span class="stringliteral">"query %s, interface *%p"</span>, request-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>.c_str(), iface);
<a name="l01763"></a>01763 
<a name="l01764"></a>01764     iface-&gt;<a class="code" href="classdtn_1_1Interface.html#a66e0906d6d60bca99d8d31049db7f85">clayer</a>()-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#75f748919a650159c42e58d8f039661b" title="Report the values of the given interface attributes.">query_iface_attributes</a>(request-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>,
<a name="l01765"></a>01765                                             iface,
<a name="l01766"></a>01766                                             request-&gt;<a class="code" href="classdtn_1_1IfaceAttributesQueryRequest.html#d57f2b047c8424b1ee98f64f68af295b" title="Link attributes requested by name.">attribute_names_</a>);
<a name="l01767"></a>01767 }
<a name="l01768"></a>01768 
<a name="l01769"></a>01769 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01770"></a>01770 <span class="keywordtype">void</span>
<a name="l01771"></a><a class="code" href="classdtn_1_1BundleDaemon.html#614fa1c601f36961959ef3688d38110f">01771</a> <a class="code" href="classdtn_1_1BundleDaemon.html#614fa1c601f36961959ef3688d38110f" title="Event type specific handlers.">BundleDaemon::handle_iface_attributes_report</a>(<a class="code" href="classdtn_1_1IfaceAttributesReportEvent.html">IfaceAttributesReportEvent</a>* event)
<a name="l01772"></a>01772 {
<a name="l01773"></a>01773     (void)event;
<a name="l01774"></a>01774     log_debug(<span class="stringliteral">"BundleDaemon::handle_iface_attributes_report: query %s"</span>,
<a name="l01775"></a>01775               event-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>.c_str());
<a name="l01776"></a>01776 }
<a name="l01777"></a>01777 
<a name="l01778"></a>01778 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01779"></a>01779 <span class="keywordtype">void</span>
<a name="l01780"></a><a class="code" href="classdtn_1_1BundleDaemon.html#6c5915346cf61c1b3dd5917fe4ffd5f3">01780</a> <a class="code" href="classdtn_1_1BundleDaemon.html#6c5915346cf61c1b3dd5917fe4ffd5f3" title="Event type specific handlers.">BundleDaemon::handle_cla_parameters_query</a>(<a class="code" href="classdtn_1_1CLAParametersQueryRequest.html">CLAParametersQueryRequest</a>* request)
<a name="l01781"></a>01781 {
<a name="l01782"></a>01782     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(request-&gt;<a class="code" href="classdtn_1_1CLAParametersQueryRequest.html#db950ba37b9546ea7b45b9f4423263b5" title="Convergence layer for which the given parameters are requested.">cla_</a> != NULL);
<a name="l01783"></a>01783 
<a name="l01784"></a>01784     log_debug(<span class="stringliteral">"BundleDaemon::handle_cla_parameters_query: "</span>
<a name="l01785"></a>01785               <span class="stringliteral">"query %s, convergence layer %s"</span>,
<a name="l01786"></a>01786               request-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>.c_str(), request-&gt;<a class="code" href="classdtn_1_1CLAParametersQueryRequest.html#db950ba37b9546ea7b45b9f4423263b5" title="Convergence layer for which the given parameters are requested.">cla_</a>-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#1030bc8bf5d5ca898fad2433e30e44cf" title="Accessor for the convergence layer name.">name</a>());
<a name="l01787"></a>01787 
<a name="l01788"></a>01788     request-&gt;<a class="code" href="classdtn_1_1CLAParametersQueryRequest.html#db950ba37b9546ea7b45b9f4423263b5" title="Convergence layer for which the given parameters are requested.">cla_</a>-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#c833c214503b51dfd401f706eea2da7d" title="Report the values of the convergence layer parameters.">query_cla_parameters</a>(request-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>,
<a name="l01789"></a>01789                                         request-&gt;<a class="code" href="classdtn_1_1CLAParametersQueryRequest.html#a12ed8e0d7d224094ec6d9699878bfef" title="Convergence layer parameters requested by name.">parameter_names_</a>);
<a name="l01790"></a>01790 }
<a name="l01791"></a>01791 
<a name="l01792"></a>01792 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01793"></a>01793 <span class="keywordtype">void</span>
<a name="l01794"></a><a class="code" href="classdtn_1_1BundleDaemon.html#c55e3d4419402bd62ccef1d3984f5bd9">01794</a> <a class="code" href="classdtn_1_1BundleDaemon.html#c55e3d4419402bd62ccef1d3984f5bd9" title="Event type specific handlers.">BundleDaemon::handle_cla_parameters_report</a>(<a class="code" href="classdtn_1_1CLAParametersReportEvent.html">CLAParametersReportEvent</a>* event)
<a name="l01795"></a>01795 {
<a name="l01796"></a>01796     (void)event;
<a name="l01797"></a>01797     log_debug(<span class="stringliteral">"Bundledaemon::handle_cla_parameters_report: query %s"</span>,
<a name="l01798"></a>01798               event-&gt;<a class="code" href="classdtn_1_1CLAQueryReport.html#2ffcf428918bdfa35c54376f742afcff" title="Query Identifier.">query_id_</a>.c_str());
<a name="l01799"></a>01799 }
<a name="l01800"></a>01800 
<a name="l01801"></a>01801 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01802"></a>01802 <span class="keywordtype">void</span>
<a name="l01803"></a><a class="code" href="classdtn_1_1BundleDaemon.html#e20844ca59a005572f332cb7824b9155">01803</a> <a class="code" href="classdtn_1_1BundleDaemon.html#e20844ca59a005572f332cb7824b9155" title="Event type specific handlers.">BundleDaemon::handle_contact_up</a>(<a class="code" href="classdtn_1_1ContactUpEvent.html" title="Event class for contact up events.">ContactUpEvent</a>* event)
<a name="l01804"></a>01804 {
<a name="l01805"></a>01805     <span class="keyword">const</span> <a class="code" href="namespacedtn.html#5f869544c85c75b5a85a14d6e90d7ff7" title="Typedef for a reference on a contact.">ContactRef</a>&amp; contact = <span class="keyword">event</span>-&gt;contact_;
<a name="l01806"></a>01806     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = contact-&gt;link();
<a name="l01807"></a>01807     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l01808"></a>01808 
<a name="l01809"></a>01809     <span class="keywordflow">if</span> (link-&gt;isdeleted()) {
<a name="l01810"></a>01810         log_debug(<span class="stringliteral">"BundleDaemon::handle_contact_up: "</span>
<a name="l01811"></a>01811                   <span class="stringliteral">"cannot bring contact up on deleted link %s"</span>, link-&gt;name());
<a name="l01812"></a>01812         <span class="keyword">event</span>-&gt;daemon_only_ = <span class="keyword">true</span>;
<a name="l01813"></a>01813         <span class="keywordflow">return</span>;
<a name="l01814"></a>01814     }
<a name="l01815"></a>01815 
<a name="l01816"></a>01816     <span class="comment">//ignore stale notifications that an old contact is up</span>
<a name="l01817"></a>01817     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#6edebce9cf6080f854039f8df593cfec" title="Accessor for the ContactManager internal lock.">lock</a>(), <span class="stringliteral">"BundleDaemon::handle_contact_up"</span>);
<a name="l01818"></a>01818     <span class="keywordflow">if</span> (link-&gt;contact() != contact)
<a name="l01819"></a>01819     {
<a name="l01820"></a>01820         log_info(<span class="stringliteral">"CONTACT_UP *%p (contact %p) being ignored (old contact)"</span>,
<a name="l01821"></a>01821                  link.object(), contact.object());
<a name="l01822"></a>01822         <span class="keywordflow">return</span>;
<a name="l01823"></a>01823     }
<a name="l01824"></a>01824     
<a name="l01825"></a>01825     log_info(<span class="stringliteral">"CONTACT_UP *%p (contact %p)"</span>, link.object(), contact.object());
<a name="l01826"></a>01826     link-&gt;set_state(<a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3ec7a744ed0ed07ccb2b255a0d76192c8" title="A convergence layer session has been established, and the link has capacity for a...">Link::OPEN</a>);
<a name="l01827"></a>01827     link-&gt;stats_.contacts_++;
<a name="l01828"></a>01828 }
<a name="l01829"></a>01829 
<a name="l01830"></a>01830 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01831"></a>01831 <span class="keywordtype">void</span>
<a name="l01832"></a><a class="code" href="classdtn_1_1BundleDaemon.html#51618e52870b57d0fbfebde04a61d9f7">01832</a> <a class="code" href="classdtn_1_1BundleDaemon.html#51618e52870b57d0fbfebde04a61d9f7" title="Event type specific handlers.">BundleDaemon::handle_contact_down</a>(<a class="code" href="classdtn_1_1ContactDownEvent.html" title="Event class for contact down events.">ContactDownEvent</a>* event)
<a name="l01833"></a>01833 {
<a name="l01834"></a>01834     <span class="keyword">const</span> <a class="code" href="namespacedtn.html#5f869544c85c75b5a85a14d6e90d7ff7" title="Typedef for a reference on a contact.">ContactRef</a>&amp; contact = <span class="keyword">event</span>-&gt;contact_;
<a name="l01835"></a>01835     <span class="keywordtype">int</span> reason = <span class="keyword">event</span>-&gt;reason_;
<a name="l01836"></a>01836     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = contact-&gt;link();
<a name="l01837"></a>01837     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l01838"></a>01838     
<a name="l01839"></a>01839     log_info(<span class="stringliteral">"CONTACT_DOWN *%p (%s) (contact %p)"</span>,
<a name="l01840"></a>01840              link.object(), <a class="code" href="classdtn_1_1ContactEvent.html#9ce1fd3e3d0a1c675a90423eefac8a6e" title="Reason to string conversion.">ContactEvent::reason_to_str</a>(reason),
<a name="l01841"></a>01841              contact.object());
<a name="l01842"></a>01842 
<a name="l01843"></a>01843     <span class="comment">// update the link stats</span>
<a name="l01844"></a>01844     link-&gt;stats_.uptime_ += (contact-&gt;start_time().elapsed_ms() / 1000);
<a name="l01845"></a>01845 }
<a name="l01846"></a>01846 
<a name="l01847"></a>01847 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01848"></a>01848 <span class="keywordtype">void</span>
<a name="l01849"></a><a class="code" href="classdtn_1_1BundleDaemon.html#ddda7798f027f63a131a0f50bfda2d87">01849</a> <a class="code" href="classdtn_1_1BundleDaemon.html#ddda7798f027f63a131a0f50bfda2d87" title="Event type specific handlers.">BundleDaemon::handle_contact_query</a>(<a class="code" href="classdtn_1_1ContactQueryRequest.html" title="Event classes for contact queries and responses.">ContactQueryRequest</a>*)
<a name="l01850"></a>01850 {
<a name="l01851"></a>01851     <a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686" title="Queues the event at the head of the queue for processing by the daemon thread.">BundleDaemon::post_at_head</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1ContactReportEvent.html">ContactReportEvent</a>());
<a name="l01852"></a>01852 }
<a name="l01853"></a>01853 
<a name="l01854"></a>01854 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01855"></a>01855 <span class="keywordtype">void</span>
<a name="l01856"></a><a class="code" href="classdtn_1_1BundleDaemon.html#97c78fa296a2f05ce08d5fae133b494c">01856</a> <a class="code" href="classdtn_1_1BundleDaemon.html#97c78fa296a2f05ce08d5fae133b494c" title="Event type specific handlers.">BundleDaemon::handle_contact_report</a>(<a class="code" href="classdtn_1_1ContactReportEvent.html">ContactReportEvent</a>*)
<a name="l01857"></a>01857 {
<a name="l01858"></a>01858 }
<a name="l01859"></a>01859 
<a name="l01860"></a>01860 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01861"></a>01861 <span class="keywordtype">void</span>
<a name="l01862"></a><a class="code" href="classdtn_1_1BundleDaemon.html#0517aafb2630f3e6223b4b72a0a49816">01862</a> <a class="code" href="classdtn_1_1BundleDaemon.html#0517aafb2630f3e6223b4b72a0a49816" title="Event type specific handlers.">BundleDaemon::handle_reassembly_completed</a>(<a class="code" href="classdtn_1_1ReassemblyCompletedEvent.html" title="Event class for reassembly completion.">ReassemblyCompletedEvent</a>* event)
<a name="l01863"></a>01863 {
<a name="l01864"></a>01864     log_info(<span class="stringliteral">"REASSEMBLY_COMPLETED bundle id %d"</span>,
<a name="l01865"></a>01865              event-&gt;<a class="code" href="classdtn_1_1ReassemblyCompletedEvent.html#5085867cad4f678045621fed9c7e74ba" title="The newly reassembled bundle.">bundle_</a>-&gt;bundleid());
<a name="l01866"></a>01866 
<a name="l01867"></a>01867     <span class="comment">// remove all the fragments from the pending list</span>
<a name="l01868"></a>01868     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> ref(<span class="stringliteral">"BundleDaemon::handle_reassembly_completed temporary"</span>);
<a name="l01869"></a>01869     <span class="keywordflow">while</span> ((ref = event-&gt;<a class="code" href="classdtn_1_1ReassemblyCompletedEvent.html#0ae412c91aec747a4525233f71742be6" title="The list of bundle fragments.">fragments_</a>.<a class="code" href="classdtn_1_1BundleList.html#265a9efd0831be3094f815eed22aec42" title="Remove (and return) a reference to the first bundle on the list.">pop_front</a>()) != NULL) {
<a name="l01870"></a>01870         <a class="code" href="classdtn_1_1BundleDaemon.html#cf4244174dd62d8a39d80bc77915d23c" title="Delete (rather than silently discard) a bundle, e.g., an expired bundle.">delete_bundle</a>(ref);
<a name="l01871"></a>01871     }
<a name="l01872"></a>01872 
<a name="l01873"></a>01873     <span class="comment">// post a new event for the newly reassembled bundle</span>
<a name="l01874"></a>01874     <a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686" title="Queues the event at the head of the queue for processing by the daemon thread.">post_at_head</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a>(event-&gt;<a class="code" href="classdtn_1_1ReassemblyCompletedEvent.html#5085867cad4f678045621fed9c7e74ba" title="The newly reassembled bundle.">bundle_</a>.object(),
<a name="l01875"></a>01875                                          <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b9b7a83778d3a7c1243e8f95c6445c88a" title="the fragmentation engine">EVENTSRC_FRAGMENTATION</a>));
<a name="l01876"></a>01876 }
<a name="l01877"></a>01877 
<a name="l01878"></a>01878 
<a name="l01879"></a>01879 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01880"></a>01880 <span class="keywordtype">void</span>
<a name="l01881"></a><a class="code" href="classdtn_1_1BundleDaemon.html#b37f8080a7e27ed714bb52d1a2c5e9dc">01881</a> <a class="code" href="classdtn_1_1BundleDaemon.html#b37f8080a7e27ed714bb52d1a2c5e9dc" title="Event type specific handlers.">BundleDaemon::handle_route_add</a>(<a class="code" href="classdtn_1_1RouteAddEvent.html" title="Event class for route add events.">RouteAddEvent</a>* event)
<a name="l01882"></a>01882 {
<a name="l01883"></a>01883     log_info(<span class="stringliteral">"ROUTE_ADD *%p"</span>, event-&gt;<a class="code" href="classdtn_1_1RouteAddEvent.html#d8232b538e9a7e47a1ca281deb3090de" title="The route table entry to be added.">entry_</a>);
<a name="l01884"></a>01884 }
<a name="l01885"></a>01885 
<a name="l01886"></a>01886 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01887"></a>01887 <span class="keywordtype">void</span>
<a name="l01888"></a><a class="code" href="classdtn_1_1BundleDaemon.html#7225e9d4f12ddf3566e19549ebf60b79">01888</a> <a class="code" href="classdtn_1_1BundleDaemon.html#7225e9d4f12ddf3566e19549ebf60b79" title="Event type specific handlers.">BundleDaemon::handle_route_del</a>(<a class="code" href="classdtn_1_1RouteDelEvent.html" title="Event class for route delete events.">RouteDelEvent</a>* event)
<a name="l01889"></a>01889 {
<a name="l01890"></a>01890     log_info(<span class="stringliteral">"ROUTE_DEL %s"</span>, event-&gt;<a class="code" href="classdtn_1_1RouteDelEvent.html#06c9654845c46f06a4518895e990e733" title="The destination eid to be removed.">dest_</a>.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l01891"></a>01891 }
<a name="l01892"></a>01892 
<a name="l01893"></a>01893 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01894"></a>01894 <span class="keywordtype">void</span>
<a name="l01895"></a><a class="code" href="classdtn_1_1BundleDaemon.html#98b63f4d84f21a810569e7582698c556">01895</a> <a class="code" href="classdtn_1_1BundleDaemon.html#98b63f4d84f21a810569e7582698c556" title="Event type specific handlers.">BundleDaemon::handle_route_query</a>(<a class="code" href="classdtn_1_1RouteQueryRequest.html" title="Event classes for static route queries and responses.">RouteQueryRequest</a>*)
<a name="l01896"></a>01896 {
<a name="l01897"></a>01897     <a class="code" href="classdtn_1_1BundleDaemon.html#c7f41d180e271e74b1c7cd71f2577686" title="Queues the event at the head of the queue for processing by the daemon thread.">BundleDaemon::post_at_head</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1RouteReportEvent.html">RouteReportEvent</a>());
<a name="l01898"></a>01898 }
<a name="l01899"></a>01899 
<a name="l01900"></a>01900 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01901"></a>01901 <span class="keywordtype">void</span>
<a name="l01902"></a><a class="code" href="classdtn_1_1BundleDaemon.html#15d3d0e8e26cb4241eddc11e5c1378c3">01902</a> <a class="code" href="classdtn_1_1BundleDaemon.html#15d3d0e8e26cb4241eddc11e5c1378c3" title="Event type specific handlers.">BundleDaemon::handle_route_report</a>(<a class="code" href="classdtn_1_1RouteReportEvent.html">RouteReportEvent</a>*)
<a name="l01903"></a>01903 {
<a name="l01904"></a>01904 }
<a name="l01905"></a>01905 
<a name="l01906"></a>01906 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01907"></a>01907 <span class="keywordtype">void</span>
<a name="l01908"></a><a class="code" href="classdtn_1_1BundleDaemon.html#2f1cb26e6de5de8ab9118a4a4738390d">01908</a> <a class="code" href="classdtn_1_1BundleDaemon.html#2f1cb26e6de5de8ab9118a4a4738390d" title="Event type specific handlers.">BundleDaemon::handle_custody_signal</a>(<a class="code" href="classdtn_1_1CustodySignalEvent.html" title="Event class for custody transfer signal arrivals.">CustodySignalEvent</a>* event)
<a name="l01909"></a>01909 {
<a name="l01910"></a>01910     log_info(<span class="stringliteral">"CUSTODY_SIGNAL: %s %u.%u %s (%s)"</span>,
<a name="l01911"></a>01911              event-&gt;<a class="code" href="classdtn_1_1CustodySignalEvent.html#fe742b21fcb94e8b225c09f54530eaf3" title="The parsed data from the custody transfer signal.">data_</a>.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#9860d72ca710bc0ccddcab64bf97155f">orig_source_eid_</a>.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(),
<a name="l01912"></a>01912              <span class="keyword">event</span>-&gt;data_.orig_creation_tv_.seconds_,
<a name="l01913"></a>01913              <span class="keyword">event</span>-&gt;data_.orig_creation_tv_.seqno_,
<a name="l01914"></a>01914              <span class="keyword">event</span>-&gt;data_.succeeded_ ? <span class="stringliteral">"succeeded"</span> : <span class="stringliteral">"failed"</span>,
<a name="l01915"></a>01915              <a class="code" href="classdtn_1_1CustodySignal.html#af7a2262319a7b2a348d1f8dc5415c2f" title="Pretty printer for custody signal reasons.">CustodySignal::reason_to_str</a>(event-&gt;<a class="code" href="classdtn_1_1CustodySignalEvent.html#fe742b21fcb94e8b225c09f54530eaf3" title="The parsed data from the custody transfer signal.">data_</a>.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#d7f8295055a7d8b4619cf2908b753ff7">reason_</a>));
<a name="l01916"></a>01916 
<a name="l01917"></a>01917     <a class="code" href="classdtn_1_1GbofId.html" title="Class definition for a GBOF ID (Global Bundle Or Fragment ID).">GbofId</a> gbof_id;
<a name="l01918"></a>01918     gbof_id.source_ = <span class="keyword">event</span>-&gt;data_.orig_source_eid_;
<a name="l01919"></a>01919     gbof_id.creation_ts_ = <span class="keyword">event</span>-&gt;data_.orig_creation_tv_;
<a name="l01920"></a>01920     gbof_id.is_fragment_
<a name="l01921"></a>01921         = <span class="keyword">event</span>-&gt;data_.admin_flags_ &amp; <a class="code" href="classdtn_1_1BundleProtocol.html#f827c0a9dff8115434bc273dc53b7df1951511bc017d452550ea77dd9a15306b">BundleProtocol::ADMIN_IS_FRAGMENT</a>;
<a name="l01922"></a>01922     gbof_id.frag_length_
<a name="l01923"></a>01923         = gbof_id.is_fragment_ ? <span class="keyword">event</span>-&gt;data_.orig_frag_length_ : 0;
<a name="l01924"></a>01924     gbof_id.frag_offset_
<a name="l01925"></a>01925         = gbof_id.is_fragment_ ? <span class="keyword">event</span>-&gt;data_.orig_frag_offset_ : 0;
<a name="l01926"></a>01926 
<a name="l01927"></a>01927     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> orig_bundle =
<a name="l01928"></a>01928         <a class="code" href="classdtn_1_1BundleDaemon.html#ce140ab25aea62199a71e73e216845a5" title="The list of all bundles that we have custody of.">custody_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#2958520b5b132bb3ed3f3e26c1eb295e" title="Search the list for a bundle with the given id.">find</a>(gbof_id);
<a name="l01929"></a>01929     
<a name="l01930"></a>01930     <span class="keywordflow">if</span> (orig_bundle == NULL) {
<a name="l01931"></a>01931         log_warn(<span class="stringliteral">"received custody signal for bundle %s %u.%u "</span>
<a name="l01932"></a>01932                  <span class="stringliteral">"but don't have custody"</span>,
<a name="l01933"></a>01933                  event-&gt;<a class="code" href="classdtn_1_1CustodySignalEvent.html#fe742b21fcb94e8b225c09f54530eaf3" title="The parsed data from the custody transfer signal.">data_</a>.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#9860d72ca710bc0ccddcab64bf97155f">orig_source_eid_</a>.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(),
<a name="l01934"></a>01934                  <span class="keyword">event</span>-&gt;data_.orig_creation_tv_.seconds_,
<a name="l01935"></a>01935                  <span class="keyword">event</span>-&gt;data_.orig_creation_tv_.seqno_);
<a name="l01936"></a>01936         <span class="keywordflow">return</span>;
<a name="l01937"></a>01937     }
<a name="l01938"></a>01938 
<a name="l01939"></a>01939     <span class="comment">// release custody if either the signal succeded or if it</span>
<a name="l01940"></a>01940     <span class="comment">// (paradoxically) failed due to duplicate transmission</span>
<a name="l01941"></a>01941     <span class="keywordtype">bool</span> release = <span class="keyword">event</span>-&gt;data_.succeeded_;
<a name="l01942"></a>01942     <span class="keywordflow">if</span> ((event-&gt;<a class="code" href="classdtn_1_1CustodySignalEvent.html#fe742b21fcb94e8b225c09f54530eaf3" title="The parsed data from the custody transfer signal.">data_</a>.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#7c392e35fc540d23ab2605b06a9514fe">succeeded_</a> == <span class="keyword">false</span>) &amp;&amp;
<a name="l01943"></a>01943         (<span class="keyword">event</span>-&gt;data_.reason_ == <a class="code" href="classdtn_1_1BundleProtocol.html#e339b3a1104cd188459059e46543490b0a6d60329683ef33d75edbce647fb245">BundleProtocol::CUSTODY_REDUNDANT_RECEPTION</a>))
<a name="l01944"></a>01944     {
<a name="l01945"></a>01945         log_notice(<span class="stringliteral">"releasing custody for bundle %s %u.%u "</span>
<a name="l01946"></a>01946                    <span class="stringliteral">"due to redundant reception"</span>,
<a name="l01947"></a>01947                    event-&gt;<a class="code" href="classdtn_1_1CustodySignalEvent.html#fe742b21fcb94e8b225c09f54530eaf3" title="The parsed data from the custody transfer signal.">data_</a>.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#9860d72ca710bc0ccddcab64bf97155f">orig_source_eid_</a>.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(),
<a name="l01948"></a>01948                    <span class="keyword">event</span>-&gt;data_.orig_creation_tv_.seconds_,
<a name="l01949"></a>01949                    <span class="keyword">event</span>-&gt;data_.orig_creation_tv_.seqno_);
<a name="l01950"></a>01950         
<a name="l01951"></a>01951         release = <span class="keyword">true</span>;
<a name="l01952"></a>01952     }
<a name="l01953"></a>01953     
<a name="l01954"></a>01954     <span class="keywordflow">if</span> (release) {
<a name="l01955"></a>01955         <a class="code" href="classdtn_1_1BundleDaemon.html#94f9a6f6615e0249f679b4dccee7e1a3" title="Release custody of the given bundle, sending the appropriate signal to the current...">release_custody</a>(orig_bundle.object());
<a name="l01956"></a>01956         <a class="code" href="classdtn_1_1BundleDaemon.html#6bf50404ffdda5e66a110f1a64f63958" title="Check if we should delete this bundle, called just after arrival, once it&amp;#39;s been...">try_to_delete</a>(orig_bundle);
<a name="l01957"></a>01957     }
<a name="l01958"></a>01958 }
<a name="l01959"></a>01959 
<a name="l01960"></a>01960 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l01961"></a>01961 <span class="keywordtype">void</span>
<a name="l01962"></a><a class="code" href="classdtn_1_1BundleDaemon.html#37a3b07c8ee49e69279dd2e6845d24be">01962</a> <a class="code" href="classdtn_1_1BundleDaemon.html#37a3b07c8ee49e69279dd2e6845d24be" title="Event type specific handlers.">BundleDaemon::handle_custody_timeout</a>(<a class="code" href="classdtn_1_1CustodyTimeoutEvent.html" title="Event class for custody transfer timeout events.">CustodyTimeoutEvent</a>* event)
<a name="l01963"></a>01963 {
<a name="l01964"></a>01964     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle = <span class="keyword">event</span>-&gt;bundle_.object();
<a name="l01965"></a>01965     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link   = <span class="keyword">event</span>-&gt;link_;
<a name="l01966"></a>01966     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l01967"></a>01967     
<a name="l01968"></a>01968     log_info(<span class="stringliteral">"CUSTODY_TIMEOUT *%p, *%p"</span>, bundle, link.object());
<a name="l01969"></a>01969     
<a name="l01970"></a>01970     <span class="comment">// remove and delete the expired timer from the bundle</span>
<a name="l01971"></a>01971     oasys::ScopeLock l(bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#5152156c37574a7939c6b4740fa44c66" title="Accessors.">lock</a>(), <span class="stringliteral">"BundleDaemon::handle_custody_timeout"</span>);
<a name="l01972"></a>01972 
<a name="l01973"></a>01973     <span class="keywordtype">bool</span> found = <span class="keyword">false</span>;
<a name="l01974"></a>01974     <a class="code" href="classdtn_1_1CustodyTimer.html" title="A custody transfer timer.">CustodyTimer</a>* timer = NULL;
<a name="l01975"></a>01975     CustodyTimerVec::iterator iter;
<a name="l01976"></a>01976     <span class="keywordflow">for</span> (iter = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#ee3040af6e2509507fbd3380f8fcfd1a" title="Setters and mutable accessors.">custody_timers</a>()-&gt;begin();
<a name="l01977"></a>01977          iter != bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#ee3040af6e2509507fbd3380f8fcfd1a" title="Setters and mutable accessors.">custody_timers</a>()-&gt;end();
<a name="l01978"></a>01978          ++iter)
<a name="l01979"></a>01979     {
<a name="l01980"></a>01980         timer = *iter;
<a name="l01981"></a>01981         <span class="keywordflow">if</span> (timer-&gt;<a class="code" href="classdtn_1_1CustodyTimer.html#c56d45a08c165fa2d0a6c3d2ea1b82aa">link_</a> == link)
<a name="l01982"></a>01982         {
<a name="l01983"></a>01983             <span class="keywordflow">if</span> (timer-&gt;pending()) {
<a name="l01984"></a>01984                 log_err(<span class="stringliteral">"multiple pending custody timers for link %s"</span>,
<a name="l01985"></a>01985                         link-&gt;nexthop());
<a name="l01986"></a>01986                 <span class="keywordflow">continue</span>;
<a name="l01987"></a>01987             }
<a name="l01988"></a>01988             
<a name="l01989"></a>01989             found = <span class="keyword">true</span>;
<a name="l01990"></a>01990             bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#ee3040af6e2509507fbd3380f8fcfd1a" title="Setters and mutable accessors.">custody_timers</a>()-&gt;erase(iter);
<a name="l01991"></a>01991             <span class="keywordflow">break</span>;
<a name="l01992"></a>01992         }
<a name="l01993"></a>01993     }
<a name="l01994"></a>01994 
<a name="l01995"></a>01995     <span class="keywordflow">if</span> (!found) {
<a name="l01996"></a>01996         log_err(<span class="stringliteral">"custody timeout for *%p *%p: timer not found in bundle list"</span>,
<a name="l01997"></a>01997                 bundle, link.object());
<a name="l01998"></a>01998         <span class="keywordflow">return</span>;
<a name="l01999"></a>01999     }
<a name="l02000"></a>02000 
<a name="l02001"></a>02001     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!timer-&gt;cancelled());
<a name="l02002"></a>02002     
<a name="l02003"></a>02003     <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#6398bb64194aa88b63e7d0e89e141883" title="Search the list for the given bundle.">contains</a>(bundle)) {
<a name="l02004"></a>02004         log_err(<span class="stringliteral">"custody timeout for *%p *%p: bundle not in pending list"</span>,
<a name="l02005"></a>02005                 bundle, link.object());
<a name="l02006"></a>02006     }
<a name="l02007"></a>02007 
<a name="l02008"></a>02008     <span class="comment">// modify the TRANSMITTED entry in the forwarding log to indicate</span>
<a name="l02009"></a>02009     <span class="comment">// that we got a custody timeout. then when the routers go through</span>
<a name="l02010"></a>02010     <span class="comment">// to figure out whether the bundle needs to be re-sent, the</span>
<a name="l02011"></a>02011     <span class="comment">// TRANSMITTED entry is no longer in there</span>
<a name="l02012"></a>02012     <span class="keywordtype">bool</span> ok = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#249ac137ef76e253d8e0587f2662bca7" title="Accessors.">fwdlog</a>()-&gt;<a class="code" href="classdtn_1_1ForwardingLog.html#a6d756d62a3007192f415a35607e5f38" title="Update the state for the latest forwarding info entry for the given link.">update</a>(link, <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad061138016cc0cda30307ee3b5332974f" title="Custody transfer timeout.">ForwardingInfo::CUSTODY_TIMEOUT</a>);
<a name="l02013"></a>02013     <span class="keywordflow">if</span> (!ok) {
<a name="l02014"></a>02014         log_err(<span class="stringliteral">"custody timeout can't find ForwardingLog entry for link *%p"</span>,
<a name="l02015"></a>02015                 link.object());
<a name="l02016"></a>02016     }
<a name="l02017"></a>02017     
<a name="l02018"></a>02018     <span class="keyword">delete</span> timer;
<a name="l02019"></a>02019 
<a name="l02020"></a>02020     <span class="comment">// now fall through to let the router handle the event, typically</span>
<a name="l02021"></a>02021     <span class="comment">// triggering a retransmission to the link in the event</span>
<a name="l02022"></a>02022 }
<a name="l02023"></a>02023 
<a name="l02024"></a>02024 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02025"></a>02025 <span class="keywordtype">void</span>
<a name="l02026"></a><a class="code" href="classdtn_1_1BundleDaemon.html#daf3a0bc4a5038be22d3c1ded40fa69f">02026</a> <a class="code" href="classdtn_1_1BundleDaemon.html#daf3a0bc4a5038be22d3c1ded40fa69f" title="Event type specific handlers.">BundleDaemon::handle_shutdown_request</a>(<a class="code" href="classdtn_1_1ShutdownRequest.html" title="Event class for shutting down a daemon.">ShutdownRequest</a>* request)
<a name="l02027"></a>02027 {
<a name="l02028"></a>02028     <a class="code" href="classdtn_1_1BundleDaemon.html#ec3feb2dfa92fc492da5d5e1b85641df">shutting_down_</a> = <span class="keyword">true</span>;
<a name="l02029"></a>02029 
<a name="l02030"></a>02030     (void)request;
<a name="l02031"></a>02031 
<a name="l02032"></a>02032     log_notice(<span class="stringliteral">"Received shutdown request"</span>);
<a name="l02033"></a>02033 
<a name="l02034"></a>02034     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#6edebce9cf6080f854039f8df593cfec" title="Accessor for the ContactManager internal lock.">lock</a>(), <span class="stringliteral">"BundleDaemon::handle_shutdown"</span>);
<a name="l02035"></a>02035 
<a name="l02036"></a>02036     <span class="keyword">const</span> <a class="code" href="classdtn_1_1LinkSet.html" title="Set of links.">LinkSet</a>* links = <a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#957c6cfac0575444e0a9a04a12708cf6" title="Return the list of links.">links</a>();
<a name="l02037"></a>02037     LinkSet::const_iterator iter;
<a name="l02038"></a>02038 
<a name="l02039"></a>02039     <span class="comment">// close any open links</span>
<a name="l02040"></a>02040     <span class="keywordflow">for</span> (iter = links-&gt;begin(); iter != links-&gt;end(); ++iter)
<a name="l02041"></a>02041     {
<a name="l02042"></a>02042         <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = *iter;
<a name="l02043"></a>02043         <span class="keywordflow">if</span> (link-&gt;isopen()) {
<a name="l02044"></a>02044             log_debug(<span class="stringliteral">"Shutdown: closing link *%p\n"</span>, link.object());
<a name="l02045"></a>02045             link-&gt;close();
<a name="l02046"></a>02046         }
<a name="l02047"></a>02047     }
<a name="l02048"></a>02048 
<a name="l02049"></a>02049     <span class="comment">// Shutdown all actively registered convergence layers.</span>
<a name="l02050"></a>02050     <a class="code" href="classdtn_1_1ConvergenceLayer.html#359f67804e595204e8436ae853e3aacc" title="Shutdown all registerd convergence layers.">ConvergenceLayer::shutdown_clayers</a>();
<a name="l02051"></a>02051 
<a name="l02052"></a>02052     <span class="comment">// call the rtr shutdown procedure</span>
<a name="l02053"></a>02053     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleDaemon.html#2151ed3edaa2c4e54742d9c281d29b07" title="Router-specific shutdown handler.">rtr_shutdown_proc_</a>) {
<a name="l02054"></a>02054         (*rtr_shutdown_proc_)(<a class="code" href="classdtn_1_1BundleDaemon.html#74bca9e084aa2faab5a9aba4fbb5ed23" title="Router-specific shutdown data.">rtr_shutdown_data_</a>);
<a name="l02055"></a>02055     }
<a name="l02056"></a>02056 
<a name="l02057"></a>02057     <span class="comment">// call the app shutdown procedure</span>
<a name="l02058"></a>02058     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleDaemon.html#ce01f407e72ff90efcd71004b36ed3a9" title="Application-specific shutdown handler.">app_shutdown_proc_</a>) {
<a name="l02059"></a>02059         (*app_shutdown_proc_)(<a class="code" href="classdtn_1_1BundleDaemon.html#c6d3f649a1ac5650fc773106ea51361a" title="Application-specific shutdown data.">app_shutdown_data_</a>);
<a name="l02060"></a>02060     }
<a name="l02061"></a>02061 
<a name="l02062"></a>02062     <span class="comment">// signal to the main loop to bail</span>
<a name="l02063"></a>02063     set_should_stop();
<a name="l02064"></a>02064 
<a name="l02065"></a>02065     <span class="comment">// fall through -- the DTNServer will close and flush all the data</span>
<a name="l02066"></a>02066     <span class="comment">// stores</span>
<a name="l02067"></a>02067 }
<a name="l02068"></a>02068 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02069"></a>02069 
<a name="l02070"></a>02070 <span class="keywordtype">void</span>
<a name="l02071"></a><a class="code" href="classdtn_1_1BundleDaemon.html#4b56442fe4bad675dabf166f08d6fd2b">02071</a> <a class="code" href="classdtn_1_1BundleDaemon.html#4b56442fe4bad675dabf166f08d6fd2b" title="Event type specific handlers.">BundleDaemon::handle_cla_set_params</a>(<a class="code" href="classdtn_1_1CLASetParamsRequest.html" title="Event class for DP-originated CLA parameter change requests.">CLASetParamsRequest</a>* request)
<a name="l02072"></a>02072 {
<a name="l02073"></a>02073     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(request-&gt;<a class="code" href="classdtn_1_1CLASetParamsRequest.html#07a8b094541cd6e85bd7de34cbda6a1d" title="Set of key, value pairs.">cla_</a> != NULL);
<a name="l02074"></a>02074     request-&gt;<a class="code" href="classdtn_1_1CLASetParamsRequest.html#07a8b094541cd6e85bd7de34cbda6a1d" title="Set of key, value pairs.">cla_</a>-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#8d7b613e7ef5d4018d0b8fba866559c1" title="Set CL-specific options.">set_cla_parameters</a>(request-&gt;<a class="code" href="classdtn_1_1CLASetParamsRequest.html#315085879b6bac4d335dcf3f697f931b">parameters_</a>);
<a name="l02075"></a>02075 }
<a name="l02076"></a>02076 
<a name="l02077"></a>02077 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02078"></a>02078 <span class="keywordtype">void</span>
<a name="l02079"></a><a class="code" href="classdtn_1_1BundleDaemon.html#d9b03d083d47e4c311193b966d3f6f9e">02079</a> <a class="code" href="classdtn_1_1BundleDaemon.html#d9b03d083d47e4c311193b966d3f6f9e" title="Event type specific handlers.">BundleDaemon::handle_status_request</a>(<a class="code" href="classdtn_1_1StatusRequest.html" title="Event class for checking that the daemon is still running.">StatusRequest</a>* request)
<a name="l02080"></a>02080 {
<a name="l02081"></a>02081     (void)request;
<a name="l02082"></a>02082     log_info(<span class="stringliteral">"Received status request"</span>);
<a name="l02083"></a>02083 }
<a name="l02084"></a>02084 
<a name="l02085"></a>02085 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02086"></a>02086 <span class="keywordtype">void</span>
<a name="l02087"></a><a class="code" href="classdtn_1_1BundleDaemon.html#3f472d3d6702c3529d8b4c0650fd08c3">02087</a> <a class="code" href="classdtn_1_1BundleDaemon.html#3f472d3d6702c3529d8b4c0650fd08c3">BundleDaemon::event_handlers_completed</a>(<a class="code" href="classdtn_1_1BundleEvent.html" title="Event base class.">BundleEvent</a>* event)
<a name="l02088"></a>02088 {
<a name="l02089"></a>02089     log_debug(<span class="stringliteral">"event handlers completed for (%p) %s"</span>, event, event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#34ad7fcefe5984584fe304fdecc96d4b" title="Used for printing.">type_str</a>());
<a name="l02090"></a>02090     
<a name="l02096"></a>02096     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> bundle(<span class="stringliteral">"BundleDaemon::event_handlers_completed"</span>);
<a name="l02097"></a>02097     <span class="keywordflow">if</span> (event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#b0087dbde563796221ed76540112708d" title="The event type code.">type_</a> == <a class="code" href="namespacedtn.html#c5c552f91168793347acabfc567715e37204ed52440255eefd29ffac09f4f8f7" title="New bundle arrival.">BUNDLE_RECEIVED</a>) {
<a name="l02098"></a>02098         bundle = ((<a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a>*)event)-&gt;bundleref_;
<a name="l02099"></a>02099     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#b0087dbde563796221ed76540112708d" title="The event type code.">type_</a> == <a class="code" href="namespacedtn.html#c5c552f91168793347acabfc567715e3041f481e5cf6c25786d39cc61516fe40" title="Bundle or fragment successfully sent.">BUNDLE_TRANSMITTED</a>) {
<a name="l02100"></a>02100         bundle = ((<a class="code" href="classdtn_1_1BundleTransmittedEvent.html" title="Event class for bundle or fragment transmission.">BundleTransmittedEvent</a>*)event)-&gt;bundleref_;
<a name="l02101"></a>02101     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#b0087dbde563796221ed76540112708d" title="The event type code.">type_</a> == <a class="code" href="namespacedtn.html#c5c552f91168793347acabfc567715e3722041e5e757539837366b863f37b3c9" title="Bundle locally delivered.">BUNDLE_DELIVERED</a>) {
<a name="l02102"></a>02102         bundle = ((<a class="code" href="classdtn_1_1BundleTransmittedEvent.html" title="Event class for bundle or fragment transmission.">BundleTransmittedEvent</a>*)event)-&gt;bundleref_;
<a name="l02103"></a>02103     }
<a name="l02104"></a>02104 
<a name="l02105"></a>02105     <span class="keywordflow">if</span> (bundle != NULL) {
<a name="l02106"></a>02106         <a class="code" href="classdtn_1_1BundleDaemon.html#6bf50404ffdda5e66a110f1a64f63958" title="Check if we should delete this bundle, called just after arrival, once it&amp;#39;s been...">try_to_delete</a>(bundle);
<a name="l02107"></a>02107     }
<a name="l02108"></a>02108 
<a name="l02113"></a>02113     <span class="keywordflow">if</span> (event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#b0087dbde563796221ed76540112708d" title="The event type code.">type_</a> == <a class="code" href="namespacedtn.html#c5c552f91168793347acabfc567715e3d68c6ba79de029761802805b4f5b0f84" title="Bundle expired.">BUNDLE_EXPIRED</a>) {
<a name="l02114"></a>02114         bundle = ((<a class="code" href="classdtn_1_1BundleExpiredEvent.html" title="Event class for bundle expiration.">BundleExpiredEvent</a>*)event)-&gt;bundleref_.object();
<a name="l02115"></a>02115         <span class="keywordtype">size_t</span> num_mappings = bundle-&gt;num_mappings();
<a name="l02116"></a>02116         <span class="keywordflow">if</span> (num_mappings != 0) {
<a name="l02117"></a>02117             log_warn(<span class="stringliteral">"expired bundle *%p still has %zu mappings"</span>,
<a name="l02118"></a>02118                      bundle.object(), num_mappings);
<a name="l02119"></a>02119         }
<a name="l02120"></a>02120     }
<a name="l02121"></a>02121 }
<a name="l02122"></a>02122 
<a name="l02123"></a>02123 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02124"></a>02124 <span class="keywordtype">bool</span>
<a name="l02125"></a><a class="code" href="classdtn_1_1BundleDaemon.html#d488c6c663e4692388b21bf16416a2d2">02125</a> <a class="code" href="classdtn_1_1BundleDaemon.html#d488c6c663e4692388b21bf16416a2d2" title="Add the bundle to the pending list and (optionally) the persistent store, and set...">BundleDaemon::add_to_pending</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <span class="keywordtype">bool</span> add_to_store)
<a name="l02126"></a>02126 {
<a name="l02127"></a>02127     log_debug(<span class="stringliteral">"adding bundle *%p to pending list"</span>, bundle);
<a name="l02128"></a>02128     
<a name="l02129"></a>02129     <a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#9f3efd0593739e89ed478fd4bbccd3e0" title="Add a new bundle to the back of the list.">push_back</a>(bundle);
<a name="l02130"></a>02130     
<a name="l02131"></a>02131     <span class="keywordflow">if</span> (add_to_store) {
<a name="l02132"></a>02132         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#657235d527f722a449ddc3c254e345c1" title="Setters and mutable accessors.">set_in_datastore</a>(<span class="keyword">true</span>);
<a name="l02133"></a>02133         <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a>-&gt;<a class="code" href="classdtn_1_1BundleActions.html#b7f86cdfb095c0fd9705f7b7605ca578" title="Add the given bundle to the data store.">store_add</a>(bundle);
<a name="l02134"></a>02134     }
<a name="l02135"></a>02135 
<a name="l02136"></a>02136     <span class="keyword">struct </span>timeval now;
<a name="l02137"></a>02137     <a class="code" href="namespacedtnsim.html#372b0bd474085f20b38efbbade7ce72a" title="Override gettimeofday to return the simulator time.">gettimeofday</a>(&amp;now, 0);
<a name="l02138"></a>02138     
<a name="l02139"></a>02139     <span class="comment">// schedule the bundle expiration timer</span>
<a name="l02140"></a>02140     <span class="keyword">struct </span>timeval expiration_time;
<a name="l02141"></a>02141     expiration_time.tv_sec =
<a name="l02142"></a>02142         <a class="code" href="structdtn_1_1BundleTimestamp.html#f6d62d5c9d0a4dc2d4848ccbc925b497" title="The number of seconds between 1/1/1970 and 1/1/2000.">BundleTimestamp::TIMEVAL_CONVERSION</a> +
<a name="l02143"></a>02143         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a> + 
<a name="l02144"></a>02144         bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#21879e67b7f065975cbd942807500746" title="Accessors.">expiration</a>();
<a name="l02145"></a>02145     
<a name="l02146"></a>02146     expiration_time.tv_usec = now.tv_usec;
<a name="l02147"></a>02147     
<a name="l02148"></a>02148     <span class="keywordtype">long</span> <span class="keywordtype">int</span> when = expiration_time.tv_sec - now.tv_sec;
<a name="l02149"></a>02149 
<a name="l02150"></a>02150     <span class="keywordtype">bool</span> ok_to_route = <span class="keyword">true</span>;
<a name="l02151"></a>02151     
<a name="l02152"></a>02152     <span class="keywordflow">if</span> (when &gt; 0) {
<a name="l02153"></a>02153         log_debug_p(<span class="stringliteral">"/dtn/bundle/expiration"</span>,
<a name="l02154"></a>02154                     <span class="stringliteral">"scheduling expiration for bundle id %d at %u.%u "</span>
<a name="l02155"></a>02155                     <span class="stringliteral">"(in %lu seconds)"</span>,
<a name="l02156"></a>02156                     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(),
<a name="l02157"></a>02157                     (u_int)expiration_time.tv_sec, (u_int)expiration_time.tv_usec,
<a name="l02158"></a>02158                     when);
<a name="l02159"></a>02159     } <span class="keywordflow">else</span> {
<a name="l02160"></a>02160         log_warn_p(<span class="stringliteral">"/dtn/bundle/expiration"</span>,
<a name="l02161"></a>02161                    <span class="stringliteral">"scheduling IMMEDIATE expiration for bundle id %d: "</span>
<a name="l02162"></a>02162                    <span class="stringliteral">"[expiration %u, creation time %u.%u, offset %u, now %u.%u]"</span>,
<a name="l02163"></a>02163                    bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#21879e67b7f065975cbd942807500746" title="Accessors.">expiration</a>(),
<a name="l02164"></a>02164                    (u_int)bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a>,
<a name="l02165"></a>02165                    (u_int)bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#ebc8cea66862d7f6056da450db410347" title="Sub-second sequence number.">seqno_</a>,
<a name="l02166"></a>02166                    <a class="code" href="structdtn_1_1BundleTimestamp.html#f6d62d5c9d0a4dc2d4848ccbc925b497" title="The number of seconds between 1/1/1970 and 1/1/2000.">BundleTimestamp::TIMEVAL_CONVERSION</a>,
<a name="l02167"></a>02167                    (u_int)now.tv_sec, (u_int)now.tv_usec);
<a name="l02168"></a>02168         expiration_time = now;
<a name="l02169"></a>02169         ok_to_route = <span class="keyword">false</span>;
<a name="l02170"></a>02170     }
<a name="l02171"></a>02171 
<a name="l02172"></a>02172     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#e3456ce3a39f06459ddb250f2a121afb" title="Setters and mutable accessors.">set_expiration_timer</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1ExpirationTimer.html" title="Bundle expiration timer class.">ExpirationTimer</a>(bundle));
<a name="l02173"></a>02173     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#68faab77677efadfb3605d36f9e84f42" title="Setters and mutable accessors.">expiration_timer</a>()-&gt;schedule_at(&amp;expiration_time);
<a name="l02174"></a>02174 
<a name="l02175"></a>02175     <span class="keywordflow">return</span> ok_to_route;
<a name="l02176"></a>02176 }
<a name="l02177"></a>02177 
<a name="l02178"></a>02178 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02179"></a>02179 <span class="keywordtype">bool</span>
<a name="l02180"></a><a class="code" href="classdtn_1_1BundleDaemon.html#8c35932db2a660b4205aa3c4795b8308">02180</a> <a class="code" href="classdtn_1_1BundleDaemon.html#8c35932db2a660b4205aa3c4795b8308" title="Remove the bundle from the pending list and data store, and cancel the expiration...">BundleDaemon::delete_from_pending</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="l02181"></a>02181 {
<a name="l02182"></a>02182     log_debug(<span class="stringliteral">"removing bundle *%p from pending list"</span>, bundle.object());
<a name="l02183"></a>02183 
<a name="l02184"></a>02184     <span class="comment">// first try to cancel the expiration timer if it's still</span>
<a name="l02185"></a>02185     <span class="comment">// around</span>
<a name="l02186"></a>02186     <span class="keywordflow">if</span> (bundle-&gt;expiration_timer()) {
<a name="l02187"></a>02187         log_debug(<span class="stringliteral">"cancelling expiration timer for bundle id %d"</span>,
<a name="l02188"></a>02188                   bundle-&gt;bundleid());
<a name="l02189"></a>02189         
<a name="l02190"></a>02190         <span class="keywordtype">bool</span> cancelled = bundle-&gt;expiration_timer()-&gt;cancel();
<a name="l02191"></a>02191         <span class="keywordflow">if</span> (!cancelled) {
<a name="l02192"></a>02192             log_crit(<span class="stringliteral">"unexpected error cancelling expiration timer "</span>
<a name="l02193"></a>02193                      <span class="stringliteral">"for bundle *%p"</span>, bundle.object());
<a name="l02194"></a>02194         }
<a name="l02195"></a>02195         
<a name="l02196"></a>02196         bundle-&gt;expiration_timer()-&gt;bundleref_.release();
<a name="l02197"></a>02197         bundle-&gt;set_expiration_timer(NULL);
<a name="l02198"></a>02198     }
<a name="l02199"></a>02199 
<a name="l02200"></a>02200     <span class="comment">// XXX/demmer the whole BundleDaemon core should be changed to use</span>
<a name="l02201"></a>02201     <span class="comment">// BundleRefs instead of Bundle*, as should the BundleList API, as</span>
<a name="l02202"></a>02202     <span class="comment">// should the whole system, really...</span>
<a name="l02203"></a>02203     log_debug(<span class="stringliteral">"pending_bundles size %zd"</span>, <a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#3c50c6f421631a4dd72b7b77b0660bc3" title="Return the size of the list.">size</a>());
<a name="l02204"></a>02204     
<a name="l02205"></a>02205     oasys::Time now;
<a name="l02206"></a>02206     now.get_time();
<a name="l02207"></a>02207     
<a name="l02208"></a>02208     <span class="keywordtype">bool</span> erased = <a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#b0171458e14d67307b74f98447062d68" title="Remove the given bundle from the list.">erase</a>(bundle);
<a name="l02209"></a>02209 
<a name="l02210"></a>02210     log_debug(<span class="stringliteral">"BundleDaemon: pending_bundles erasure took %u ms"</span>,
<a name="l02211"></a>02211               now.elapsed_ms());
<a name="l02212"></a>02212 
<a name="l02213"></a>02213     <span class="keywordflow">if</span> (!erased) {
<a name="l02214"></a>02214         log_err(<span class="stringliteral">"unexpected error removing bundle from pending list"</span>);
<a name="l02215"></a>02215     }
<a name="l02216"></a>02216 
<a name="l02217"></a>02217     <span class="keywordflow">return</span> erased;
<a name="l02218"></a>02218 }
<a name="l02219"></a>02219 
<a name="l02220"></a>02220 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02221"></a>02221 <span class="keywordtype">bool</span>
<a name="l02222"></a><a class="code" href="classdtn_1_1BundleDaemon.html#6bf50404ffdda5e66a110f1a64f63958">02222</a> <a class="code" href="classdtn_1_1BundleDaemon.html#6bf50404ffdda5e66a110f1a64f63958" title="Check if we should delete this bundle, called just after arrival, once it&amp;#39;s been...">BundleDaemon::try_to_delete</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="l02223"></a>02223 {
<a name="l02224"></a>02224     <span class="comment">/*</span>
<a name="l02225"></a>02225 <span class="comment">     * Check to see if we should remove the bundle from the system.</span>
<a name="l02226"></a>02226 <span class="comment">     * </span>
<a name="l02227"></a>02227 <span class="comment">     * If we're not configured for early deletion, this never does</span>
<a name="l02228"></a>02228 <span class="comment">     * anything. Otherwise it relies on the router saying that the</span>
<a name="l02229"></a>02229 <span class="comment">     * bundle can be deleted.</span>
<a name="l02230"></a>02230 <span class="comment">     */</span>
<a name="l02231"></a>02231 
<a name="l02232"></a>02232     log_debug(<span class="stringliteral">"pending_bundles size %zd"</span>, <a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#3c50c6f421631a4dd72b7b77b0660bc3" title="Return the size of the list.">size</a>());
<a name="l02233"></a>02233     <span class="keywordflow">if</span> (! bundle-&gt;is_queued_on(<a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>))
<a name="l02234"></a>02234     {
<a name="l02235"></a>02235         <span class="keywordflow">if</span> (bundle-&gt;expired()) {
<a name="l02236"></a>02236             log_debug(<span class="stringliteral">"try_to_delete(*%p): bundle already expired"</span>,
<a name="l02237"></a>02237                       bundle.object());
<a name="l02238"></a>02238             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l02239"></a>02239         }
<a name="l02240"></a>02240         
<a name="l02241"></a>02241         log_err(<span class="stringliteral">"try_to_delete(*%p): bundle not in pending list!"</span>,
<a name="l02242"></a>02242                 bundle.object());
<a name="l02243"></a>02243         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l02244"></a>02244     }
<a name="l02245"></a>02245 
<a name="l02246"></a>02246     <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1BundleDaemon.html#a18fd65ff3e11b985f3e04a4591d4a33">params_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Params.html#709968d52fafe93f350b02a202e3b6d4" title="Whether or not to delete bundles before they&amp;#39;re expired if all routers / registrations...">early_deletion_</a>) {
<a name="l02247"></a>02247         log_debug(<span class="stringliteral">"try_to_delete(*%p): not deleting because "</span>
<a name="l02248"></a>02248                   <span class="stringliteral">"early deletion disabled"</span>,
<a name="l02249"></a>02249                   bundle.object());
<a name="l02250"></a>02250         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l02251"></a>02251     }
<a name="l02252"></a>02252 
<a name="l02253"></a>02253     <span class="keywordflow">if</span> (! <a class="code" href="classdtn_1_1BundleDaemon.html#a5c8a244aad225987f9359ee1c2a1101" title="The active bundle router.">router_</a>-&gt;<a class="code" href="classdtn_1_1BundleRouter.html#50702bb5cf9c4e2b9be0a7b452c94629" title="Synchronous probe indicating whether or not this bundle can be deleted by the system...">can_delete_bundle</a>(bundle)) {
<a name="l02254"></a>02254         log_debug(<span class="stringliteral">"try_to_delete(*%p): not deleting because "</span>
<a name="l02255"></a>02255                   <span class="stringliteral">"router wants to keep bundle"</span>,
<a name="l02256"></a>02256                   bundle.object());
<a name="l02257"></a>02257         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l02258"></a>02258     }
<a name="l02259"></a>02259     
<a name="l02260"></a>02260     <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1BundleDaemon.html#cf4244174dd62d8a39d80bc77915d23c" title="Delete (rather than silently discard) a bundle, e.g., an expired bundle.">delete_bundle</a>(bundle, <a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f917eac137290a0338e66ed4a0c1cc09c2f2">BundleProtocol::REASON_NO_ADDTL_INFO</a>);
<a name="l02261"></a>02261 }
<a name="l02262"></a>02262 
<a name="l02263"></a>02263 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02264"></a>02264 <span class="keywordtype">bool</span>
<a name="l02265"></a><a class="code" href="classdtn_1_1BundleDaemon.html#cf4244174dd62d8a39d80bc77915d23c">02265</a> <a class="code" href="classdtn_1_1BundleDaemon.html#cf4244174dd62d8a39d80bc77915d23c" title="Delete (rather than silently discard) a bundle, e.g., an expired bundle.">BundleDaemon::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; bundleref,
<a name="l02266"></a>02266                             <a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f917" title="Bundle Status Report &amp;quot;Reason Code&amp;quot; flags.">status_report_reason_t</a> reason)
<a name="l02267"></a>02267 {
<a name="l02268"></a>02268     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle = bundleref.object();
<a name="l02269"></a>02269     
<a name="l02270"></a>02270     ++<a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#8eb7288e8cc5f5feaaedd5998c6cb958">deleted_bundles_</a>;
<a name="l02271"></a>02271     
<a name="l02272"></a>02272     <span class="comment">// send a bundle deletion status report if we have custody or the</span>
<a name="l02273"></a>02273     <span class="comment">// bundle's deletion status report request flag is set and a reason</span>
<a name="l02274"></a>02274     <span class="comment">// for deletion is provided</span>
<a name="l02275"></a>02275     <span class="keywordtype">bool</span> send_status = (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#dd00e0f0435b047bdde46c97cb513e3d" title="Accessors.">local_custody</a>() ||
<a name="l02276"></a>02276                        (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#fa1f7ffd4437c3a9213c60e7bbef39d3" title="Accessors.">deletion_rcpt</a>() &amp;&amp;
<a name="l02277"></a>02277                         reason != <a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f917eac137290a0338e66ed4a0c1cc09c2f2">BundleProtocol::REASON_NO_ADDTL_INFO</a>));
<a name="l02278"></a>02278         
<a name="l02279"></a>02279     <span class="comment">// check if we have custody, if so, remove it</span>
<a name="l02280"></a>02280     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#dd00e0f0435b047bdde46c97cb513e3d" title="Accessors.">local_custody</a>()) {
<a name="l02281"></a>02281         <a class="code" href="classdtn_1_1BundleDaemon.html#94f9a6f6615e0249f679b4dccee7e1a3" title="Release custody of the given bundle, sending the appropriate signal to the current...">release_custody</a>(bundle);
<a name="l02282"></a>02282     }
<a name="l02283"></a>02283 
<a name="l02284"></a>02284     <span class="comment">// XXX/demmer if custody was requested but we didn't take it yet</span>
<a name="l02285"></a>02285     <span class="comment">// (due to a validation error, space constraints, etc), then we</span>
<a name="l02286"></a>02286     <span class="comment">// should send a custody failed signal here</span>
<a name="l02287"></a>02287 
<a name="l02288"></a>02288     <span class="comment">// check if bundle is a fragment, if so, remove any fragmentation state</span>
<a name="l02289"></a>02289     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#d6c74eba219bfe55854cf7a90e210cca" title="Accessors.">is_fragment</a>()) {
<a name="l02290"></a>02290         <a class="code" href="classdtn_1_1BundleDaemon.html#a0a2294a38635f5f76aba4375b0c2f7d" title="The fragmentation / reassembly manager.">fragmentmgr_</a>-&gt;<a class="code" href="classdtn_1_1FragmentManager.html#3cf63b648553dda12d36e0f05d17380e" title="Delete reassembly state for a bundle.">delete_fragment</a>(bundle);
<a name="l02291"></a>02291     }
<a name="l02292"></a>02292 
<a name="l02293"></a>02293     <span class="comment">// notify the router that it's time to delete the bundle</span>
<a name="l02294"></a>02294     <a class="code" href="classdtn_1_1BundleDaemon.html#a5c8a244aad225987f9359ee1c2a1101" title="The active bundle router.">router_</a>-&gt;<a class="code" href="classdtn_1_1BundleRouter.html#4e48a822cf5f7b143cf641d26a12091f" title="Synchronous call indicating that the bundle is being deleted from the system and...">delete_bundle</a>(bundleref);
<a name="l02295"></a>02295 
<a name="l02296"></a>02296     <span class="comment">// delete the bundle from the pending list</span>
<a name="l02297"></a>02297     log_debug(<span class="stringliteral">"pending_bundles size %zd"</span>, <a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#3c50c6f421631a4dd72b7b77b0660bc3" title="Return the size of the list.">size</a>());
<a name="l02298"></a>02298     <span class="keywordtype">bool</span> erased = <span class="keyword">true</span>;
<a name="l02299"></a>02299     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#13d641b5d6a6617a8c37ab28a0a6c843" title="Return true if the bundle is on the given list.">is_queued_on</a>(<a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>)) {
<a name="l02300"></a>02300         erased = <a class="code" href="classdtn_1_1BundleDaemon.html#8c35932db2a660b4205aa3c4795b8308" title="Remove the bundle from the pending list and data store, and cancel the expiration...">delete_from_pending</a>(bundleref);
<a name="l02301"></a>02301     }
<a name="l02302"></a>02302 
<a name="l02303"></a>02303     <span class="keywordflow">if</span> (erased &amp;&amp; send_status) {
<a name="l02304"></a>02304         <a class="code" href="classdtn_1_1BundleDaemon.html#3847596a3b6b6a7e583947501491a87b" title="Locally generate a status report for the given bundle.">generate_status_report</a>(bundle, <a class="code" href="classdtn_1_1BundleStatusReport.html#b2546897ef428634d8385363b6de14990b94e9bc2f3ff0bb55a9920a9a5058f2">BundleStatusReport::STATUS_DELETED</a>, reason);
<a name="l02305"></a>02305     }
<a name="l02306"></a>02306 
<a name="l02307"></a>02307     <span class="comment">// cancel the bundle on all links where it is queued or in flight</span>
<a name="l02308"></a>02308     oasys::Time now;
<a name="l02309"></a>02309     now.get_time();
<a name="l02310"></a>02310     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#6edebce9cf6080f854039f8df593cfec" title="Accessor for the ContactManager internal lock.">lock</a>(), <span class="stringliteral">"BundleDaemon::delete_bundle"</span>);
<a name="l02311"></a>02311     <span class="keyword">const</span> <a class="code" href="classdtn_1_1LinkSet.html" title="Set of links.">LinkSet</a>* links = <a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#957c6cfac0575444e0a9a04a12708cf6" title="Return the list of links.">links</a>();
<a name="l02312"></a>02312     LinkSet::const_iterator iter;
<a name="l02313"></a>02313     <span class="keywordflow">for</span> (iter = links-&gt;begin(); iter != links-&gt;end(); ++iter) {
<a name="l02314"></a>02314         <span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link = *iter;
<a name="l02315"></a>02315         
<a name="l02316"></a>02316         <span class="keywordflow">if</span> (link-&gt;queue()-&gt;contains(bundle) ||
<a name="l02317"></a>02317             link-&gt;inflight()-&gt;contains(bundle))
<a name="l02318"></a>02318         {
<a name="l02319"></a>02319             <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a>-&gt;<a class="code" href="classdtn_1_1BundleActions.html#3835034086b8a07e5a767fa028104830" title="Attempt to cancel transmission of a bundle on the given link.">cancel_bundle</a>(bundle, link);
<a name="l02320"></a>02320         }
<a name="l02321"></a>02321     }
<a name="l02322"></a>02322 
<a name="l02323"></a>02323     <span class="comment">// XXX/demmer there may be other lists where the bundle is still</span>
<a name="l02324"></a>02324     <span class="comment">// referenced so the router needs to be told what to do...</span>
<a name="l02325"></a>02325     
<a name="l02326"></a>02326     log_debug(<span class="stringliteral">"BundleDaemon: canceling deleted bundle on all links took %u ms"</span>,
<a name="l02327"></a>02327                now.elapsed_ms());
<a name="l02328"></a>02328 
<a name="l02329"></a>02329     <span class="keywordflow">return</span> erased;
<a name="l02330"></a>02330 }
<a name="l02331"></a>02331 
<a name="l02332"></a>02332 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02333"></a>02333 <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>*
<a name="l02334"></a><a class="code" href="classdtn_1_1BundleDaemon.html#feb7761e0df0015e0af4dca266d7bd47">02334</a> <a class="code" href="classdtn_1_1BundleDaemon.html#feb7761e0df0015e0af4dca266d7bd47" title="Check if there are any bundles in the pending queue that match the source id, timestamp...">BundleDaemon::find_duplicate</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b)
<a name="l02335"></a>02335 {
<a name="l02336"></a>02336     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#0d0c9f789f0f7f7d1cda3b4ecf32d2bc" title="Return the internal lock on this list.">lock</a>(), 
<a name="l02337"></a>02337                        <span class="stringliteral">"BundleDaemon::find_duplicate"</span>);
<a name="l02338"></a>02338     log_debug(<span class="stringliteral">"pending_bundles size %zd"</span>, <a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#3c50c6f421631a4dd72b7b77b0660bc3" title="Return the size of the list.">size</a>());
<a name="l02339"></a>02339     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a> *found = NULL;
<a name="l02340"></a>02340     <a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">BundleList::iterator</a> iter;
<a name="l02341"></a>02341     <span class="keywordflow">for</span> (iter = <a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf" title="Iterator used to iterate through the list.">begin</a>();
<a name="l02342"></a>02342          iter != <a class="code" href="classdtn_1_1BundleDaemon.html#48dbdf23301f10dc3f1121913a023195" title="The list of all bundles still pending delivery.">pending_bundles_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1" title="Iterator used to mark the end of the list.">end</a>();
<a name="l02343"></a>02343          ++iter)
<a name="l02344"></a>02344     {
<a name="l02345"></a>02345         <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b2 = *iter;
<a name="l02346"></a>02346         
<a name="l02347"></a>02347         <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#80721c0832c08c5066e6d6276d62d70b" title="Simple equality test function.">equals</a>(b2-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>())) &amp;&amp;
<a name="l02348"></a>02348             (b-&gt;<a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a> == b2-&gt;<a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a>) &amp;&amp;
<a name="l02349"></a>02349             (b-&gt;<a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#ebc8cea66862d7f6056da450db410347" title="Sub-second sequence number.">seqno_</a>   == b2-&gt;<a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#ebc8cea66862d7f6056da450db410347" title="Sub-second sequence number.">seqno_</a>) &amp;&amp;
<a name="l02350"></a>02350             (b-&gt;<a class="code" href="classdtn_1_1Bundle.html#d6c74eba219bfe55854cf7a90e210cca" title="Accessors.">is_fragment</a>()          == b2-&gt;<a class="code" href="classdtn_1_1Bundle.html#d6c74eba219bfe55854cf7a90e210cca" title="Accessors.">is_fragment</a>()) &amp;&amp;
<a name="l02351"></a>02351             (b-&gt;<a class="code" href="classdtn_1_1Bundle.html#76cf6a44f566aa22e2a98007bf233ee2" title="Accessors.">frag_offset</a>()          == b2-&gt;<a class="code" href="classdtn_1_1Bundle.html#76cf6a44f566aa22e2a98007bf233ee2" title="Accessors.">frag_offset</a>()) &amp;&amp;
<a name="l02352"></a>02352             <span class="comment">/*(b-&gt;orig_length()          == b2-&gt;orig_length()) &amp;&amp;*/</span>
<a name="l02353"></a>02353             (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>()     == b2-&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="l02354"></a>02354         {
<a name="l02355"></a>02355             <span class="comment">// b is a duplicate of b2</span>
<a name="l02356"></a>02356             found = b2;
<a name="l02357"></a>02357             <span class="comment">/*</span>
<a name="l02358"></a>02358 <span class="comment">             * If we are not suppressing duplicates, we might have custody of</span>
<a name="l02359"></a>02359 <span class="comment">             * one of any number of duplicates, so if this one does not have</span>
<a name="l02360"></a>02360 <span class="comment">             * custody, keep looking until we find one that does have custody</span>
<a name="l02361"></a>02361 <span class="comment">             * or we run out of choices. If we are suppressing duplicates</span>
<a name="l02362"></a>02362 <span class="comment">             * there's no need to keep looking.</span>
<a name="l02363"></a>02363 <span class="comment">             */</span>
<a name="l02364"></a>02364             <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleDaemon.html#a18fd65ff3e11b985f3e04a4591d4a33">params_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Params.html#44979b5e20d25f2cf0e1203bd89519f4" title="Whether or not to skip routing decisions for and delete duplicate bundles.">suppress_duplicates_</a> || b2-&gt;<a class="code" href="classdtn_1_1Bundle.html#dd00e0f0435b047bdde46c97cb513e3d" title="Accessors.">local_custody</a>()) {
<a name="l02365"></a>02365                 <span class="keywordflow">break</span>;
<a name="l02366"></a>02366             }
<a name="l02367"></a>02367         }
<a name="l02368"></a>02368     }
<a name="l02369"></a>02369 
<a name="l02370"></a>02370     <span class="keywordflow">return</span> found;
<a name="l02371"></a>02371 }
<a name="l02372"></a>02372 
<a name="l02373"></a>02373 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02374"></a>02374 <span class="keywordtype">void</span>
<a name="l02375"></a><a class="code" href="classdtn_1_1BundleDaemon.html#fb08800567318dc1c0c855266a5d2ec0">02375</a> <a class="code" href="classdtn_1_1BundleDaemon.html#fb08800567318dc1c0c855266a5d2ec0" title="Event type specific handlers.">BundleDaemon::handle_bundle_free</a>(<a class="code" href="classdtn_1_1BundleFreeEvent.html" title="Event class for bundles that have no more references to them.">BundleFreeEvent</a>* event)
<a name="l02376"></a>02376 {
<a name="l02377"></a>02377     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle = <span class="keyword">event</span>-&gt;bundle_;
<a name="l02378"></a>02378     <span class="keyword">event</span>-&gt;bundle_ = NULL;
<a name="l02379"></a>02379     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#3c2267a4f6f2dfed9dd01ffbf3703bb7" title="Return the bundle&amp;#39;s reference count, corresponding to the number of entries in...">refcount</a>() == 0);
<a name="l02380"></a>02380     
<a name="l02381"></a>02381     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#5152156c37574a7939c6b4740fa44c66" title="Accessors.">lock</a>()-&gt;lock(<span class="stringliteral">"BundleDaemon::handle_bundle_free"</span>);
<a name="l02382"></a>02382 
<a name="l02383"></a>02383     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#3df9106fb836721e37cca7b019dd5e16" title="Accessors.">in_datastore</a>()) {
<a name="l02384"></a>02384         log_debug(<span class="stringliteral">"removing freed bundle from data store"</span>);
<a name="l02385"></a>02385         <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a>-&gt;<a class="code" href="classdtn_1_1BundleActions.html#fdbaada645504895226a83f8a92c2a40" title="Remove the given bundle from the data store.">store_del</a>(bundle);
<a name="l02386"></a>02386     }
<a name="l02387"></a>02387     log_debug(<span class="stringliteral">"deleting freed bundle"</span>);
<a name="l02388"></a>02388     <span class="keyword">delete</span> bundle;
<a name="l02389"></a>02389 }
<a name="l02390"></a>02390 
<a name="l02391"></a>02391 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02392"></a>02392 <span class="keywordtype">void</span>
<a name="l02393"></a><a class="code" href="classdtn_1_1BundleDaemon.html#6590936f52512c792e7c26bf02ddabc8">02393</a> <a class="code" href="classdtn_1_1BundleDaemon.html#6590936f52512c792e7c26bf02ddabc8" title="Main event handling function.">BundleDaemon::handle_event</a>(<a class="code" href="classdtn_1_1BundleEvent.html" title="Event base class.">BundleEvent</a>* event)
<a name="l02394"></a>02394 {
<a name="l02395"></a>02395     <a class="code" href="classdtn_1_1BundleEventHandler.html#ff1afd1aab4f62d6dfccfc855968206d" title="Dispatch the event by type code to one of the event-specific handler functions below...">dispatch_event</a>(event);
<a name="l02396"></a>02396     
<a name="l02397"></a>02397     <span class="keywordflow">if</span> (! event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#4de9b57df34c041e8b313234d69ae6e9" title="Bit indicating whether this event is for the daemon only or if it should be propagated...">daemon_only_</a>) {
<a name="l02398"></a>02398         <span class="comment">// dispatch the event to the router(s) and the contact manager</span>
<a name="l02399"></a>02399         <a class="code" href="classdtn_1_1BundleDaemon.html#a5c8a244aad225987f9359ee1c2a1101" title="The active bundle router.">router_</a>-&gt;<a class="code" href="classdtn_1_1BundleRouter.html#8c592e5d57adf8287f2b886ba39d5d93" title="Pure virtual event handler function (copied from BundleEventHandler for clarity)...">handle_event</a>(event);
<a name="l02400"></a>02400         <a class="code" href="classdtn_1_1BundleDaemon.html#032fa1c5998c5e037ed54d4734f6807f" title="The contact manager.">contactmgr_</a>-&gt;<a class="code" href="classdtn_1_1ContactManager.html#5b2577e0713d1d7882e2355d5077d86c" title="Generic event handler.">handle_event</a>(event);
<a name="l02401"></a>02401     }
<a name="l02402"></a>02402 
<a name="l02403"></a>02403     <a class="code" href="classdtn_1_1BundleDaemon.html#3f472d3d6702c3529d8b4c0650fd08c3">event_handlers_completed</a>(event);
<a name="l02404"></a>02404 
<a name="l02405"></a>02405     <a class="code" href="classdtn_1_1BundleDaemon.html#ae65fea1f23a7f4d1bd7315014f8627c" title="Stats instance.">stats_</a>.<a class="code" href="structdtn_1_1BundleDaemon_1_1Stats.html#29e4ac69c2393b563da1f0557458deea">events_processed_</a>++;
<a name="l02406"></a>02406 
<a name="l02407"></a>02407     <span class="keywordflow">if</span> (event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#41422f59f627162052747049984b3cf6" title="Slot for a notifier to indicate that the event was processed.">processed_notifier_</a>) {
<a name="l02408"></a>02408         <span class="keyword">event</span>-&gt;processed_notifier_-&gt;notify();
<a name="l02409"></a>02409     }
<a name="l02410"></a>02410 }
<a name="l02411"></a>02411 
<a name="l02412"></a>02412 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02413"></a>02413 <span class="keywordtype">void</span>
<a name="l02414"></a><a class="code" href="classdtn_1_1BundleDaemon.html#7573e0c2e16cf579386f7e51e17c71dd">02414</a> <a class="code" href="classdtn_1_1BundleDaemon.html#7573e0c2e16cf579386f7e51e17c71dd" title="Initialize and load in the registrations.">BundleDaemon::load_registrations</a>()
<a name="l02415"></a>02415 {
<a name="l02416"></a>02416     <a class="code" href="classdtn_1_1BundleDaemon.html#1f45d824bd4047fe46d280c4b17d9d77" title="The administrative registration.">admin_reg_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1AdminRegistration.html" title="Internal registration that recieves all administrative bundles destined for the router...">AdminRegistration</a>();
<a name="l02417"></a>02417     {
<a name="l02418"></a>02418         <a class="code" href="classdtn_1_1RegistrationAddedEvent.html" title="Event class for new registration arrivals.">RegistrationAddedEvent</a> e(<a class="code" href="classdtn_1_1BundleDaemon.html#1f45d824bd4047fe46d280c4b17d9d77" title="The administrative registration.">admin_reg_</a>, <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b04a9578f3e2276d81cd632222ceb4e2e" title="the admin logic">EVENTSRC_ADMIN</a>);
<a name="l02419"></a>02419         <a class="code" href="classdtn_1_1BundleDaemon.html#6590936f52512c792e7c26bf02ddabc8" title="Main event handling function.">handle_event</a>(&amp;e);
<a name="l02420"></a>02420     }
<a name="l02421"></a>02421 
<a name="l02422"></a>02422     <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a> ping_eid(<a class="code" href="classdtn_1_1BundleDaemon.html#f606a71844413e32918c9c3e98b8ce3f" title="Return the local endpoint identifier.">local_eid</a>());
<a name="l02423"></a>02423     <span class="keywordtype">bool</span> ok = ping_eid.<a class="code" href="classdtn_1_1EndpointID.html#41d5be95b3068c4c2fa7a4b28f18ee8a" title="Append the specified service tag (in a scheme-specific manner) to the ssp.">append_service_tag</a>(<span class="stringliteral">"ping"</span>);
<a name="l02424"></a>02424     <span class="keywordflow">if</span> (!ok) {
<a name="l02425"></a>02425         log_crit(<span class="stringliteral">"local eid (%s) scheme must be able to append service tags"</span>,
<a name="l02426"></a>02426                  <a class="code" href="classdtn_1_1BundleDaemon.html#f606a71844413e32918c9c3e98b8ce3f" title="Return the local endpoint identifier.">local_eid</a>().c_str());
<a name="l02427"></a>02427         exit(1);
<a name="l02428"></a>02428     }
<a name="l02429"></a>02429     
<a name="l02430"></a>02430     <a class="code" href="classdtn_1_1BundleDaemon.html#61f93eca77176bb879f85a92ff04eeb1" title="The ping registration.">ping_reg_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1PingRegistration.html" title="Internal registration for the dtnping application.">PingRegistration</a>(ping_eid);
<a name="l02431"></a>02431     {
<a name="l02432"></a>02432         <a class="code" href="classdtn_1_1RegistrationAddedEvent.html" title="Event class for new registration arrivals.">RegistrationAddedEvent</a> e(<a class="code" href="classdtn_1_1BundleDaemon.html#61f93eca77176bb879f85a92ff04eeb1" title="The ping registration.">ping_reg_</a>, <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b04a9578f3e2276d81cd632222ceb4e2e" title="the admin logic">EVENTSRC_ADMIN</a>);
<a name="l02433"></a>02433         <a class="code" href="classdtn_1_1BundleDaemon.html#6590936f52512c792e7c26bf02ddabc8" title="Main event handling function.">handle_event</a>(&amp;e);
<a name="l02434"></a>02434     }
<a name="l02435"></a>02435 
<a name="l02436"></a>02436     <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>* reg;
<a name="l02437"></a>02437     <a class="code" href="classdtn_1_1RegistrationStore.html" title="The class for registration storage is simply an instantiation of the generic oasys...">RegistrationStore</a>* reg_store = RegistrationStore::instance();
<a name="l02438"></a>02438     RegistrationStore::iterator* iter = reg_store-&gt;new_iterator();
<a name="l02439"></a>02439 
<a name="l02440"></a>02440     <span class="keywordflow">while</span> (iter-&gt;next() == 0) {
<a name="l02441"></a>02441         reg = reg_store-&gt;get(iter-&gt;cur_val());
<a name="l02442"></a>02442         <span class="keywordflow">if</span> (reg == NULL) {
<a name="l02443"></a>02443             log_err(<span class="stringliteral">"error loading registration %d from data store"</span>,
<a name="l02444"></a>02444                     iter-&gt;cur_val());
<a name="l02445"></a>02445             <span class="keywordflow">continue</span>;
<a name="l02446"></a>02446         }
<a name="l02447"></a>02447         
<a name="l02448"></a>02448         <a class="code" href="classdtn_1_1RegistrationAddedEvent.html" title="Event class for new registration arrivals.">RegistrationAddedEvent</a> e(reg, <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b8fb8e6004d0ab350daca47bdcc106866" title="the data store">EVENTSRC_STORE</a>);
<a name="l02449"></a>02449         <a class="code" href="classdtn_1_1BundleDaemon.html#6590936f52512c792e7c26bf02ddabc8" title="Main event handling function.">handle_event</a>(&amp;e);
<a name="l02450"></a>02450     }
<a name="l02451"></a>02451 
<a name="l02452"></a>02452     <span class="keyword">delete</span> iter;
<a name="l02453"></a>02453 }
<a name="l02454"></a>02454 
<a name="l02455"></a>02455 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02456"></a>02456 <span class="keywordtype">void</span>
<a name="l02457"></a><a class="code" href="classdtn_1_1BundleDaemon.html#ed3a9ab9c97bfcc502830c508ed83af4">02457</a> <a class="code" href="classdtn_1_1BundleDaemon.html#ed3a9ab9c97bfcc502830c508ed83af4" title="Initialize and load in stored bundles.">BundleDaemon::load_bundles</a>()
<a name="l02458"></a>02458 {
<a name="l02459"></a>02459     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle;
<a name="l02460"></a>02460     <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>* bundle_store = BundleStore::instance();
<a name="l02461"></a>02461     <a class="code" href="classdtn_1_1BundleStore.html#fb4b85e14a877a86628c0b6bcf619e68">BundleStore::iterator</a>* iter = bundle_store-&gt;<a class="code" href="classdtn_1_1BundleStore.html#2018d15d04bd544f78dc8bb4b23c4df2" title="Return a new iterator.">new_iterator</a>();
<a name="l02462"></a>02462 
<a name="l02463"></a>02463     log_notice(<span class="stringliteral">"loading bundles from data store"</span>);
<a name="l02464"></a>02464 
<a name="l02465"></a>02465     u_int64_t total_size = 0;
<a name="l02466"></a>02466 
<a name="l02467"></a>02467     std::vector&lt;Bundle*&gt; doa_bundles;
<a name="l02468"></a>02468     
<a name="l02469"></a>02469     <span class="keywordflow">for</span> (iter-&gt;begin(); iter-&gt;more(); iter-&gt;next()) {
<a name="l02470"></a>02470         bundle = bundle_store-&gt;<a class="code" href="classdtn_1_1BundleStore.html#dc21e162bbb18024768467a8005048ac" title="Retrieve a bundle.">get</a>(iter-&gt;cur_val());
<a name="l02471"></a>02471         
<a name="l02472"></a>02472         <span class="keywordflow">if</span> (bundle == NULL) {
<a name="l02473"></a>02473             log_err(<span class="stringliteral">"error loading bundle %d from data store"</span>,
<a name="l02474"></a>02474                     iter-&gt;cur_val());
<a name="l02475"></a>02475             <span class="keywordflow">continue</span>;
<a name="l02476"></a>02476         }
<a name="l02477"></a>02477 
<a name="l02478"></a>02478         total_size += bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#cf6279b83a4c0addf41a8d7d33ab5dcd" title="Hook for the bundle store implementation to count the storage impact of this bundle...">durable_size</a>();
<a name="l02479"></a>02479         
<a name="l02480"></a>02480         <span class="comment">// if the bundle payload file is missing, we need to kill the</span>
<a name="l02481"></a>02481         <span class="comment">// bundle, but we can't do so while holding the durable</span>
<a name="l02482"></a>02482         <span class="comment">// iterator or it may deadlock, so cleanup is deferred </span>
<a name="l02483"></a>02483         <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#3bc0b88b547620b4029eba4809a73447" title="Accessors.">payload</a>().<a class="code" href="classdtn_1_1BundlePayload.html#d6d6293001575473f0a1a3df3d83ed85" title="The payload location.">location</a>() != <a class="code" href="classdtn_1_1BundlePayload.html#f87102863631e39f673458a7527ae35202b4113a9944175cde826707be98e89e" title="in memory only (TempBundle)">BundlePayload::DISK</a>) {
<a name="l02484"></a>02484             log_err(<span class="stringliteral">"error loading payload for *%p from data store"</span>,
<a name="l02485"></a>02485                     bundle);
<a name="l02486"></a>02486             doa_bundles.push_back(bundle);
<a name="l02487"></a>02487             <span class="keywordflow">continue</span>;
<a name="l02488"></a>02488         }
<a name="l02489"></a>02489 
<a name="l02490"></a>02490         <a class="code" href="classdtn_1_1BundleProtocol.html#77c2dbd79cef726e0234e639e19a34f4" title="Give the processors a chance to chew on the bundle after reloading from disk.">BundleProtocol::reload_post_process</a>(bundle);
<a name="l02491"></a>02491 
<a name="l02492"></a>02492         <a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a> e(bundle, <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b8fb8e6004d0ab350daca47bdcc106866" title="the data store">EVENTSRC_STORE</a>);
<a name="l02493"></a>02493         <a class="code" href="classdtn_1_1BundleDaemon.html#6590936f52512c792e7c26bf02ddabc8" title="Main event handling function.">handle_event</a>(&amp;e);
<a name="l02494"></a>02494 
<a name="l02495"></a>02495         <span class="comment">// in the constructor, we disabled notifiers on the event</span>
<a name="l02496"></a>02496         <span class="comment">// queue, so in case loading triggers other events, we just</span>
<a name="l02497"></a>02497         <span class="comment">// let them queue up and handle them later when we're done</span>
<a name="l02498"></a>02498         <span class="comment">// loading all the bundles</span>
<a name="l02499"></a>02499     }
<a name="l02500"></a>02500     
<a name="l02501"></a>02501     bundle_store-&gt;<a class="code" href="classdtn_1_1BundleStore.html#e353ebf2181c93689adde1ba532192e0" title="When the bundle store is loaded at boot time, we need to reset the in-memory total_size_...">set_total_size</a>(total_size);
<a name="l02502"></a>02502 
<a name="l02503"></a>02503     <span class="keyword">delete</span> iter;
<a name="l02504"></a>02504 
<a name="l02505"></a>02505     <span class="comment">// now that the durable iterator is gone, purge the doa bundles</span>
<a name="l02506"></a>02506     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; doa_bundles.size(); ++i) {
<a name="l02507"></a>02507         <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a>-&gt;<a class="code" href="classdtn_1_1BundleActions.html#fdbaada645504895226a83f8a92c2a40" title="Remove the given bundle from the data store.">store_del</a>(doa_bundles[i]);
<a name="l02508"></a>02508         <span class="keyword">delete</span> doa_bundles[i];
<a name="l02509"></a>02509     }
<a name="l02510"></a>02510 }
<a name="l02511"></a>02511 
<a name="l02512"></a>02512 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02513"></a>02513 <span class="keywordtype">bool</span>
<a name="l02514"></a><a class="code" href="structdtn_1_1BundleDaemon_1_1DaemonIdleExit.html#0d1700a28c5dda2e109228050542d652">02514</a> <a class="code" href="structdtn_1_1BundleDaemon_1_1DaemonIdleExit.html#0d1700a28c5dda2e109228050542d652">BundleDaemon::DaemonIdleExit::is_idle</a>(<span class="keyword">const</span> <span class="keyword">struct</span> timeval&amp; tv)
<a name="l02515"></a>02515 {
<a name="l02516"></a>02516     oasys::Time now(tv.tv_sec, tv.tv_usec);
<a name="l02517"></a>02517     u_int elapsed = (now - BundleDaemon::instance()-&gt;last_event_).in_milliseconds();
<a name="l02518"></a>02518 
<a name="l02519"></a>02519     <a class="code" href="classdtn_1_1BundleDaemon.html" title="Class that handles the basic event / action mechanism.">BundleDaemon</a>* d = BundleDaemon::instance();
<a name="l02520"></a>02520     d-&gt;logf(oasys::LOG_DEBUG,
<a name="l02521"></a>02521             <span class="stringliteral">"checking if is_idle -- last event was %u msecs ago"</span>,
<a name="l02522"></a>02522             elapsed);
<a name="l02523"></a>02523 
<a name="l02524"></a>02524     <span class="comment">// fudge</span>
<a name="l02525"></a>02525     <span class="keywordflow">if</span> (elapsed + 500 &gt; interval_ * 1000) {
<a name="l02526"></a>02526         d-&gt;logf(oasys::LOG_NOTICE,
<a name="l02527"></a>02527                 <span class="stringliteral">"more than %u seconds since last event, "</span>
<a name="l02528"></a>02528                 <span class="stringliteral">"shutting down daemon due to idle timer"</span>,
<a name="l02529"></a>02529                 interval_);
<a name="l02530"></a>02530         
<a name="l02531"></a>02531         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l02532"></a>02532     } <span class="keywordflow">else</span> {
<a name="l02533"></a>02533         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l02534"></a>02534     }
<a name="l02535"></a>02535 }
<a name="l02536"></a>02536 
<a name="l02537"></a>02537 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02538"></a>02538 <span class="keywordtype">void</span>
<a name="l02539"></a><a class="code" href="classdtn_1_1BundleDaemon.html#eaafd0a0f3dc7c337e923332c9a84844">02539</a> <a class="code" href="classdtn_1_1BundleDaemon.html#eaafd0a0f3dc7c337e923332c9a84844" title="Initialize an idle shutdown handler that will cleanly exit the tcl event loop whenever...">BundleDaemon::init_idle_shutdown</a>(<span class="keywordtype">int</span> <a class="code" href="dtnping_8c.html#e0c690118932b32ef40a74bb6a259acd">interval</a>)
<a name="l02540"></a>02540 {
<a name="l02541"></a>02541     <a class="code" href="classdtn_1_1BundleDaemon.html#63d018c1a65e0941407258434eba13bc" title="Pointer to the idle exit handler (if any).">idle_exit_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleDaemon.html#cc90cfa85026d0af9fbdbeb28388edba">DaemonIdleExit</a>(interval);
<a name="l02542"></a>02542 }
<a name="l02543"></a>02543 
<a name="l02544"></a>02544 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l02545"></a>02545 <span class="keywordtype">void</span>
<a name="l02546"></a><a class="code" href="classdtn_1_1BundleDaemon.html#28671879d7f3cf36a03e54cf18b59414">02546</a> <a class="code" href="classdtn_1_1BundleDaemon.html#28671879d7f3cf36a03e54cf18b59414" title="Main thread function that dispatches events.">BundleDaemon::run</a>()
<a name="l02547"></a>02547 {
<a name="l02548"></a>02548     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* LOOP_LOG = <span class="stringliteral">"/dtn/bundle/daemon/loop"</span>;
<a name="l02549"></a>02549     
<a name="l02550"></a>02550     <span class="keywordflow">if</span> (! <a class="code" href="structdtn_1_1BundleTimestamp.html#a67a3fee3de9c0817df2a084a901401c" title="Check that the local clock setting is valid (i.e.">BundleTimestamp::check_local_clock</a>()) {
<a name="l02551"></a>02551         exit(1);
<a name="l02552"></a>02552     }
<a name="l02553"></a>02553     
<a name="l02554"></a>02554     <a class="code" href="classdtn_1_1BundleDaemon.html#a5c8a244aad225987f9359ee1c2a1101" title="The active bundle router.">router_</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>(<a class="code" href="classdtn_1_1BundleRouter.html#344d85ef64a884adf9fb173a82674cca" title="Config variables.">BundleRouter::config_</a>.type_.c_str());
<a name="l02555"></a>02555     <a class="code" href="classdtn_1_1BundleDaemon.html#a5c8a244aad225987f9359ee1c2a1101" title="The active bundle router.">router_</a>-&gt;<a class="code" href="classdtn_1_1BundleRouter.html#58bdadd6a5f618d44cd4c2084acc707c">initialize</a>();
<a name="l02556"></a>02556     
<a name="l02557"></a>02557     <a class="code" href="classdtn_1_1BundleDaemon.html#7573e0c2e16cf579386f7e51e17c71dd" title="Initialize and load in the registrations.">load_registrations</a>();
<a name="l02558"></a>02558     <a class="code" href="classdtn_1_1BundleDaemon.html#ed3a9ab9c97bfcc502830c508ed83af4" title="Initialize and load in stored bundles.">load_bundles</a>();
<a name="l02559"></a>02559 
<a name="l02560"></a>02560     <a class="code" href="classdtn_1_1BundleEvent.html" title="Event base class.">BundleEvent</a>* event;
<a name="l02561"></a>02561 
<a name="l02562"></a>02562     oasys::TimerSystem* timersys = oasys::TimerSystem::instance();
<a name="l02563"></a>02563 
<a name="l02564"></a>02564     <a class="code" href="classdtn_1_1BundleDaemon.html#3e7aeb62b7e60ae2f6a81ad6844168e7" title="Time value when the last event was handled.">last_event_</a>.get_time();
<a name="l02565"></a>02565     
<a name="l02566"></a>02566     <span class="keyword">struct </span>pollfd pollfds[2];
<a name="l02567"></a>02567     <span class="keyword">struct </span>pollfd* event_poll = &amp;pollfds[0];
<a name="l02568"></a>02568     <span class="keyword">struct </span>pollfd* timer_poll = &amp;pollfds[1];
<a name="l02569"></a>02569     
<a name="l02570"></a>02570     event_poll-&gt;fd     = <a class="code" href="classdtn_1_1BundleDaemon.html#4c63dbe82dd1b3692d9748a32c859373" title="The event queue.">eventq_</a>-&gt;read_fd();
<a name="l02571"></a>02571     event_poll-&gt;events = POLLIN;
<a name="l02572"></a>02572 
<a name="l02573"></a>02573     timer_poll-&gt;fd     = timersys-&gt;notifier()-&gt;read_fd();
<a name="l02574"></a>02574     timer_poll-&gt;events = POLLIN;
<a name="l02575"></a>02575     
<a name="l02576"></a>02576     <span class="keywordflow">while</span> (1) {
<a name="l02577"></a>02577         <span class="keywordflow">if</span> (should_stop()) {
<a name="l02578"></a>02578             log_debug(<span class="stringliteral">"BundleDaemon: stopping"</span>);
<a name="l02579"></a>02579             <span class="keywordflow">break</span>;
<a name="l02580"></a>02580         }
<a name="l02581"></a>02581 
<a name="l02582"></a>02582         <span class="keywordtype">int</span> timeout = timersys-&gt;run_expired_timers();
<a name="l02583"></a>02583 
<a name="l02584"></a>02584         log_debug_p(LOOP_LOG, 
<a name="l02585"></a>02585                     <span class="stringliteral">"BundleDaemon: checking eventq_-&gt;size() &gt; 0, its size is %zu"</span>, 
<a name="l02586"></a>02586                     <a class="code" href="classdtn_1_1BundleDaemon.html#4c63dbe82dd1b3692d9748a32c859373" title="The event queue.">eventq_</a>-&gt;size());
<a name="l02587"></a>02587 
<a name="l02588"></a>02588         <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleDaemon.html#4c63dbe82dd1b3692d9748a32c859373" title="The event queue.">eventq_</a>-&gt;size() &gt; 0) {
<a name="l02589"></a>02589             <span class="keywordtype">bool</span> ok = <a class="code" href="classdtn_1_1BundleDaemon.html#4c63dbe82dd1b3692d9748a32c859373" title="The event queue.">eventq_</a>-&gt;try_pop(&amp;event);
<a name="l02590"></a>02590             <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(ok);
<a name="l02591"></a>02591             
<a name="l02592"></a>02592             oasys::Time now;
<a name="l02593"></a>02593             now.get_time();
<a name="l02594"></a>02594 
<a name="l02595"></a>02595             
<a name="l02596"></a>02596             <span class="keywordflow">if</span> (now &gt;= event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#1b27378270993aa0eb4d90b31fcd7f10" title="Slot to record the time that the event was put into the queue.">posted_time_</a>) {
<a name="l02597"></a>02597                 oasys::Time in_queue;
<a name="l02598"></a>02598                 in_queue = now - <span class="keyword">event</span>-&gt;posted_time_;
<a name="l02599"></a>02599                 <span class="keywordflow">if</span> (in_queue.sec_ &gt; 2) {
<a name="l02600"></a>02600                     log_warn_p(LOOP_LOG, <span class="stringliteral">"event %s was in queue for %u.%u seconds"</span>,
<a name="l02601"></a>02601                                event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#34ad7fcefe5984584fe304fdecc96d4b" title="Used for printing.">type_str</a>(), in_queue.sec_, in_queue.usec_);
<a name="l02602"></a>02602                 }
<a name="l02603"></a>02603             } <span class="keywordflow">else</span> {
<a name="l02604"></a>02604                 log_warn_p(LOOP_LOG, <span class="stringliteral">"time moved backwards: "</span>
<a name="l02605"></a>02605                            <span class="stringliteral">"now %u.%u, event posted_time %u.%u"</span>,
<a name="l02606"></a>02606                            now.sec_, now.usec_,
<a name="l02607"></a>02607                            event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#1b27378270993aa0eb4d90b31fcd7f10" title="Slot to record the time that the event was put into the queue.">posted_time_</a>.sec_, event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#1b27378270993aa0eb4d90b31fcd7f10" title="Slot to record the time that the event was put into the queue.">posted_time_</a>.usec_);
<a name="l02608"></a>02608             }
<a name="l02609"></a>02609             
<a name="l02610"></a>02610             
<a name="l02611"></a>02611             log_debug_p(LOOP_LOG, <span class="stringliteral">"BundleDaemon: handling event %s"</span>,
<a name="l02612"></a>02612                         event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#34ad7fcefe5984584fe304fdecc96d4b" title="Used for printing.">type_str</a>());
<a name="l02613"></a>02613             <span class="comment">// handle the event</span>
<a name="l02614"></a>02614             <a class="code" href="classdtn_1_1BundleDaemon.html#6590936f52512c792e7c26bf02ddabc8" title="Main event handling function.">handle_event</a>(event);
<a name="l02615"></a>02615 
<a name="l02616"></a>02616             <span class="keywordtype">int</span> elapsed = now.elapsed_ms();
<a name="l02617"></a>02617             <span class="keywordflow">if</span> (elapsed &gt; 2000) {
<a name="l02618"></a>02618                 log_warn_p(LOOP_LOG, <span class="stringliteral">"event %s took %u ms to process"</span>,
<a name="l02619"></a>02619                            event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#34ad7fcefe5984584fe304fdecc96d4b" title="Used for printing.">type_str</a>(), elapsed);
<a name="l02620"></a>02620             }
<a name="l02621"></a>02621 
<a name="l02622"></a>02622             <span class="comment">// record the last event time</span>
<a name="l02623"></a>02623             <a class="code" href="classdtn_1_1BundleDaemon.html#3e7aeb62b7e60ae2f6a81ad6844168e7" title="Time value when the last event was handled.">last_event_</a>.get_time();
<a name="l02624"></a>02624 
<a name="l02625"></a>02625             log_debug_p(LOOP_LOG, <span class="stringliteral">"BundleDaemon: deleting event %s"</span>,
<a name="l02626"></a>02626                         event-&gt;<a class="code" href="classdtn_1_1BundleEvent.html#34ad7fcefe5984584fe304fdecc96d4b" title="Used for printing.">type_str</a>());
<a name="l02627"></a>02627             <span class="comment">// clean up the event</span>
<a name="l02628"></a>02628             <span class="keyword">delete</span> event;
<a name="l02629"></a>02629             
<a name="l02630"></a>02630             <span class="keywordflow">continue</span>; <span class="comment">// no reason to poll</span>
<a name="l02631"></a>02631         }
<a name="l02632"></a>02632         
<a name="l02633"></a>02633         pollfds[0].revents = 0;
<a name="l02634"></a>02634         pollfds[1].revents = 0;
<a name="l02635"></a>02635 
<a name="l02636"></a>02636         log_debug_p(LOOP_LOG, <span class="stringliteral">"BundleDaemon: poll_multiple waiting for %d ms"</span>, 
<a name="l02637"></a>02637                     timeout);
<a name="l02638"></a>02638         <span class="keywordtype">int</span> cc = oasys::IO::poll_multiple(pollfds, 2, timeout);
<a name="l02639"></a>02639         log_debug_p(LOOP_LOG, <span class="stringliteral">"poll returned %d"</span>, cc);
<a name="l02640"></a>02640 
<a name="l02641"></a>02641         <span class="keywordflow">if</span> (cc == oasys::IOTIMEOUT) {
<a name="l02642"></a>02642             log_debug_p(LOOP_LOG, <span class="stringliteral">"poll timeout"</span>);
<a name="l02643"></a>02643             <span class="keywordflow">continue</span>;
<a name="l02644"></a>02644 
<a name="l02645"></a>02645         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cc &lt;= 0) {
<a name="l02646"></a>02646             <a class="code" href="SDNV_8cc.html#3f24cadc9f28aba33472df0500092dcb">log_err_p</a>(LOOP_LOG, <span class="stringliteral">"unexpected return %d from poll_multiple!"</span>, cc);
<a name="l02647"></a>02647             <span class="keywordflow">continue</span>;
<a name="l02648"></a>02648         }
<a name="l02649"></a>02649 
<a name="l02650"></a>02650         <span class="comment">// if the event poll fired, we just go back to the top of the</span>
<a name="l02651"></a>02651         <span class="comment">// loop to drain the queue</span>
<a name="l02652"></a>02652         <span class="keywordflow">if</span> (event_poll-&gt;revents != 0) {
<a name="l02653"></a>02653             log_debug_p(LOOP_LOG, <span class="stringliteral">"poll returned new event to handle"</span>);
<a name="l02654"></a>02654         }
<a name="l02655"></a>02655 
<a name="l02656"></a>02656         <span class="comment">// if the timer notifier fired, then someone just scheduled a</span>
<a name="l02657"></a>02657         <span class="comment">// new timer, so we just continue, which will call</span>
<a name="l02658"></a>02658         <span class="comment">// run_expired_timers and handle it</span>
<a name="l02659"></a>02659         <span class="keywordflow">if</span> (timer_poll-&gt;revents != 0) {
<a name="l02660"></a>02660             log_debug_p(LOOP_LOG, <span class="stringliteral">"poll returned new timers to handle"</span>);
<a name="l02661"></a>02661             timersys-&gt;notifier()-&gt;clear();
<a name="l02662"></a>02662         }
<a name="l02663"></a>02663     }
<a name="l02664"></a>02664 }
<a name="l02665"></a>02665 
<a name="l02666"></a>02666 } <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:52 2009 for DTN Reference Implementation by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>