Sophie

Sophie

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

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: FloodBundleRouter.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>FloodBundleRouter.cc</h1><a href="FloodBundleRouter_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 "<a class="code" href="BundleRouter_8h.html">BundleRouter.h</a>"</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="RouteTable_8h.html">RouteTable.h</a>"</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="bundling_2Bundle_8h.html">bundling/Bundle.h</a>"</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="BundleActions_8h.html">bundling/BundleActions.h</a>"</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="BundleDaemon_8h.html">bundling/BundleDaemon.h</a>"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="bundling_2BundleList_8h.html">bundling/BundleList.h</a>"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="Contact_8h.html">contacts/Contact.h</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="Registration_8h.html">reg/Registration.h</a>"</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="FloodBundleRouter_8h.html">FloodBundleRouter.h</a>"</span>
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <span class="keyword">namespace </span>dtn {
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00036"></a><a class="code" href="classdtn_1_1FloodBundleRouter.html#660a62aff9ec2ac9229830513d425fd7">00036</a> <a class="code" href="classdtn_1_1FloodBundleRouter.html#660a62aff9ec2ac9229830513d425fd7" title="Constructor.">FloodBundleRouter::FloodBundleRouter</a>()
<a name="l00037"></a>00037     : <a class="code" href="classdtn_1_1TableBasedRouter.html" title="This is an abstract class that is intended to be used for all routing algorithms...">TableBasedRouter</a>(<span class="stringliteral">"FloodBundleRouter"</span>, <span class="stringliteral">"flood"</span>),
<a name="l00038"></a>00038       all_bundles_(<span class="stringliteral">"FloodBundleRouter::all_bundles"</span>),
<a name="l00039"></a>00039       all_eids_(<a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a>::WILDCARD_EID())
<a name="l00040"></a>00040 {
<a name="l00041"></a>00041     log_info(<span class="stringliteral">"FloodBundleRouter initialized"</span>);
<a name="l00042"></a>00042     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1FloodBundleRouter.html#0825d406aa6c89dae23648642a3102f9" title="Wildcard pattern to match all bundles.">all_eids_</a>.<a class="code" href="classdtn_1_1EndpointID.html#bbf47839fe5cc8cb425af9a257a92ef5">valid</a>());
<a name="l00043"></a>00043 }
<a name="l00044"></a>00044 
<a name="l00045"></a>00045 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00046"></a>00046 <span class="keywordtype">void</span>
<a name="l00047"></a><a class="code" href="classdtn_1_1FloodBundleRouter.html#c64fdfc35227035b64312f6271317381">00047</a> <a class="code" href="classdtn_1_1FloodBundleRouter.html#c64fdfc35227035b64312f6271317381" title="Initializer.">FloodBundleRouter::initialize</a>()
<a name="l00048"></a>00048 {
<a name="l00049"></a>00049     <a class="code" href="classdtn_1_1FloodBundleRouter.html#c64fdfc35227035b64312f6271317381" title="Initializer.">TableBasedRouter::initialize</a>();
<a name="l00050"></a>00050     <a class="code" href="classdtn_1_1BundleRouter.html#344d85ef64a884adf9fb173a82674cca" title="Config variables.">config_</a>.<a class="code" href="structdtn_1_1BundleRouter_1_1Config.html#790fe839395fd2d7e0a199958c6e923c" title="Whether or not to add routes for nexthop links that know the remote endpoint id (default...">add_nexthop_routes_</a> = <span class="keyword">false</span>;
<a name="l00051"></a>00051 }
<a name="l00052"></a>00052 
<a name="l00053"></a>00053 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00054"></a>00054 <span class="keywordtype">void</span>
<a name="l00055"></a><a class="code" href="classdtn_1_1FloodBundleRouter.html#d0c23759201e076aec5b7a4d070ef3a0">00055</a> <a class="code" href="classdtn_1_1FloodBundleRouter.html#d0c23759201e076aec5b7a4d070ef3a0" title="Event handler for new bundle arrivals.">FloodBundleRouter::handle_bundle_received</a>(<a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a>* event)
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057     <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="l00058"></a>00058     log_debug(<span class="stringliteral">"bundle received *%p"</span>, bundle);
<a name="l00059"></a>00059     <a class="code" href="classdtn_1_1FloodBundleRouter.html#d812770c10ca652fbaf21779920e6f91" title="To ensure bundles aren&amp;#39;t deleted by the system just after they are forwarded...">all_bundles_</a>.<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="l00060"></a>00060 
<a name="l00061"></a>00061     <a class="code" href="classdtn_1_1FloodBundleRouter.html#d0c23759201e076aec5b7a4d070ef3a0" title="Event handler for new bundle arrivals.">TableBasedRouter::handle_bundle_received</a>(event);
<a name="l00062"></a>00062 }
<a name="l00063"></a>00063 
<a name="l00064"></a>00064 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00065"></a>00065 <span class="keywordtype">void</span>
<a name="l00066"></a><a class="code" href="classdtn_1_1FloodBundleRouter.html#211fac9393649fc76ecfd366da0e2a21">00066</a> <a class="code" href="classdtn_1_1FloodBundleRouter.html#211fac9393649fc76ecfd366da0e2a21" title="When a link is created, add a new route for it.">FloodBundleRouter::handle_link_created</a>(<a class="code" href="classdtn_1_1LinkCreatedEvent.html" title="Event class for link creation events.">LinkCreatedEvent</a>* event)
<a name="l00067"></a>00067 {
<a name="l00068"></a>00068     <a class="code" href="classdtn_1_1FloodBundleRouter.html#211fac9393649fc76ecfd366da0e2a21" title="When a link is created, add a new route for it.">TableBasedRouter::handle_link_created</a>(event);
<a name="l00069"></a>00069     
<a name="l00070"></a>00070     <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="l00071"></a>00071     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l00072"></a>00072     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!link-&gt;isdeleted());
<a name="l00073"></a>00073 
<a name="l00074"></a>00074     log_debug(<span class="stringliteral">"FloodBundleRouter::handle_link_created: "</span>
<a name="l00075"></a>00075               <span class="stringliteral">"link_created *%p"</span>, link.object());
<a name="l00076"></a>00076 
<a name="l00077"></a>00077     <a class="code" href="classdtn_1_1RouteEntry.html" title="Class to represent route table entry.">RouteEntry</a>* entry = <span class="keyword">new</span> <a class="code" href="classdtn_1_1RouteEntry.html" title="Class to represent route table entry.">RouteEntry</a>(<a class="code" href="classdtn_1_1FloodBundleRouter.html#0825d406aa6c89dae23648642a3102f9" title="Wildcard pattern to match all bundles.">all_eids_</a>, link);
<a name="l00078"></a>00078     entry-&gt;set_action(<a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b594777ba7ba2355d6b87536afc9ef78efeb8" title="Forward a copy of the bundle.">ForwardingInfo::COPY_ACTION</a>);
<a name="l00079"></a>00079 
<a name="l00080"></a>00080     <span class="comment">// adds the route to the table and checks for bundles that may</span>
<a name="l00081"></a>00081     <span class="comment">// need to be sent to the new link</span>
<a name="l00082"></a>00082     <a class="code" href="classdtn_1_1TableBasedRouter.html#118c2a374824c8ba1fcf2e7388c0af74" title="Add a route entry to the routing table.">add_route</a>(entry);
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084 
<a name="l00085"></a>00085 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00086"></a>00086 <span class="keywordtype">void</span>
<a name="l00087"></a><a class="code" href="classdtn_1_1FloodBundleRouter.html#6e544673088731fde3512406d2266942">00087</a> <a class="code" href="classdtn_1_1FloodBundleRouter.html#6e544673088731fde3512406d2266942" title="Default event handler when bundles expire.">FloodBundleRouter::handle_bundle_expired</a>(<a class="code" href="classdtn_1_1BundleExpiredEvent.html" title="Event class for bundle expiration.">BundleExpiredEvent</a>* event)
<a name="l00088"></a>00088 {
<a name="l00089"></a>00089     <a class="code" href="classdtn_1_1FloodBundleRouter.html#6e544673088731fde3512406d2266942" title="Default event handler when bundles expire.">TableBasedRouter::handle_bundle_expired</a>(event);
<a name="l00090"></a>00090     
<a name="l00091"></a>00091     <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="l00092"></a>00092     log_debug(<span class="stringliteral">"bundle_expired *%p"</span>, bundle);
<a name="l00093"></a>00093     <a class="code" href="classdtn_1_1FloodBundleRouter.html#d812770c10ca652fbaf21779920e6f91" title="To ensure bundles aren&amp;#39;t deleted by the system just after they are forwarded...">all_bundles_</a>.<a class="code" href="classdtn_1_1BundleList.html#b0171458e14d67307b74f98447062d68" title="Remove the given bundle from the list.">erase</a>(bundle);
<a name="l00094"></a>00094 }
<a name="l00095"></a>00095 
<a name="l00096"></a>00096 } <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:56 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>