Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > d9faa203c2b0b6fbb179d93daaea81b7 > files > 230

libdtn-devel-2.6.0-1mdv2009.0.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: DTLSRRouter.cc Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&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>
<h1>DTLSRRouter.cc</h1><a href="DTLSRRouter_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 2007 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;algorithm&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;oasys/debug/DebugUtils.h&gt;</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="DTLSRRouter_8h.html">DTLSRRouter.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="SDNV_8h.html">bundling/SDNV.h</a>"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="TempBundle_8h.html">bundling/TempBundle.h</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="ContactManager_8h.html">contacts/ContactManager.h</a>"</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="RouteTable_8h.html">routing/RouteTable.h</a>"</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="Session_8h.html">session/Session.h</a>"</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="keyword">namespace </span>oasys {
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00035"></a>00035 <span class="keyword">template</span>&lt;&gt;
<a name="l00036"></a>00036 <span class="keyword">const</span> <span class="keywordtype">char</span>*
<a name="l00037"></a>00037 InlineFormatter&lt;dtn::DTLSRRouter::EdgeInfo&gt;
<a name="l00038"></a>00038   ::format(<span class="keyword">const</span> <a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html" title="Class used for per-edge state in the graph (the link).">dtn::DTLSRRouter::EdgeInfo</a>&amp; ei)
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040     <span class="keyword">const</span> <span class="keywordtype">char</span>* state_str;
<a name="l00041"></a>00041     <span class="keywordflow">if</span> (ei.<a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html#df107e4fc22874f3a8b83885b9b74264" title="link params">params_</a>.state_ == <a class="code" href="classdtn_1_1DTLSR_1_1LinkParams.html#4c7cf89ca787aaa76d10dd64444590b19c37d3bb69e70835da132c4b62fee73b">dtn::DTLSRRouter::LinkParams::LINK_UP</a>) {
<a name="l00042"></a>00042          state_str = <span class="stringliteral">"UP"</span>;
<a name="l00043"></a>00043     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ei.<a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html#df107e4fc22874f3a8b83885b9b74264" title="link params">params_</a>.state_ == <a class="code" href="classdtn_1_1DTLSR_1_1LinkParams.html#4c7cf89ca787aaa76d10dd64444590b17d9dbd6b1d445d156cf94ca355a0b0a1">dtn::DTLSRRouter::LinkParams::LINK_DOWN</a>) {
<a name="l00044"></a>00044         state_str = <span class="stringliteral">"DOWN"</span>;
<a name="l00045"></a>00045     } <span class="keywordflow">else</span> {
<a name="l00046"></a>00046         state_str = <span class="stringliteral">"__UNKNOWN__"</span>;
<a name="l00047"></a>00047     }
<a name="l00048"></a>00048 
<a name="l00049"></a>00049     buf_.appendf(<span class="stringliteral">"%s: state=%s cost=%u delay=%u bw=%u"</span>,
<a name="l00050"></a>00050                  ei.<a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html#8d99e7ce3d0db06107c104d8bd858b4e" title="link name">id_</a>.c_str(), state_str,
<a name="l00051"></a>00051                  ei.<a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html#df107e4fc22874f3a8b83885b9b74264" title="link params">params_</a>.cost_, ei.<a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html#df107e4fc22874f3a8b83885b9b74264" title="link params">params_</a>.delay_, ei.<a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html#df107e4fc22874f3a8b83885b9b74264" title="link params">params_</a>.bw_);
<a name="l00052"></a>00052     <span class="keywordflow">return</span> buf_.c_str();
<a name="l00053"></a>00053 }
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 } <span class="comment">// namespace oasys</span>
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 <span class="keyword">namespace </span>dtn {
<a name="l00058"></a>00058 
<a name="l00059"></a>00059 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00060"></a><a class="code" href="classdtn_1_1DTLSRRouter_1_1CostWeightFn.html">00060</a> <span class="keyword">class </span><a class="code" href="classdtn_1_1DTLSRRouter_1_1CostWeightFn.html">DTLSRRouter::CostWeightFn</a> : <span class="keyword">public</span> <a class="code" href="classdtn_1_1MultiGraph.html" title="Data structure to represent a multigraph.">RoutingGraph</a>::WeightFn {
<a name="l00061"></a>00061 <span class="keyword">public</span>:
<a name="l00062"></a><a class="code" href="classdtn_1_1DTLSRRouter_1_1CostWeightFn.html#3133ff54e34bc5fbf550e12ed6c5f35e">00062</a>     u_int32_t <a class="code" href="classdtn_1_1DTLSRRouter_1_1CostWeightFn.html#3133ff54e34bc5fbf550e12ed6c5f35e">operator()</a>(<span class="keyword">const</span> <a class="code" href="structdtn_1_1MultiGraph_1_1SearchInfo.html" title="Struct used to encapsulate state that may be needed by weight functors and which...">RoutingGraph::SearchInfo</a>&amp; <a class="code" href="dtncat_8c.html#71f51a2e8cbe9a53031fa72596edc09f">info</a>,
<a name="l00063"></a>00063                          <span class="keyword">const</span> <a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html" title="The edge class.">RoutingGraph::Edge</a>* edge)
<a name="l00064"></a>00064     {
<a name="l00065"></a>00065         (void)info;
<a name="l00066"></a>00066         <span class="keywordflow">if</span> (edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_.state_ == <a class="code" href="classdtn_1_1DTLSR_1_1LinkParams.html#4c7cf89ca787aaa76d10dd64444590b17d9dbd6b1d445d156cf94ca355a0b0a1">LinkParams::LINK_DOWN</a>) {
<a name="l00067"></a>00067             <span class="keywordflow">return</span> 0xffffffff;
<a name="l00068"></a>00068         }
<a name="l00069"></a>00069         <span class="keywordflow">return</span> edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_.cost_;
<a name="l00070"></a>00070     }
<a name="l00071"></a>00071 };
<a name="l00072"></a>00072 
<a name="l00073"></a>00073 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00074"></a><a class="code" href="classdtn_1_1DTLSRRouter_1_1DelayWeightFn.html">00074</a> <span class="keyword">class </span><a class="code" href="classdtn_1_1DTLSRRouter_1_1DelayWeightFn.html">DTLSRRouter::DelayWeightFn</a> : <span class="keyword">public</span> <a class="code" href="classdtn_1_1MultiGraph.html" title="Data structure to represent a multigraph.">RoutingGraph</a>::WeightFn {
<a name="l00075"></a>00075 <span class="keyword">public</span>:
<a name="l00076"></a><a class="code" href="classdtn_1_1DTLSRRouter_1_1DelayWeightFn.html#fa945e4d89232fc72971d5e0e5079b36">00076</a>     u_int32_t <a class="code" href="classdtn_1_1DTLSRRouter_1_1DelayWeightFn.html#fa945e4d89232fc72971d5e0e5079b36">operator()</a>(<span class="keyword">const</span> <a class="code" href="structdtn_1_1MultiGraph_1_1SearchInfo.html" title="Struct used to encapsulate state that may be needed by weight functors and which...">RoutingGraph::SearchInfo</a>&amp; <a class="code" href="dtncat_8c.html#71f51a2e8cbe9a53031fa72596edc09f">info</a>,
<a name="l00077"></a>00077                          <span class="keyword">const</span> <a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html" title="The edge class.">RoutingGraph::Edge</a>* edge)
<a name="l00078"></a>00078     {
<a name="l00079"></a>00079         (void)info;
<a name="l00080"></a>00080 
<a name="l00081"></a>00081         u_int32_t downtime = (info.<a class="code" href="structdtn_1_1MultiGraph_1_1SearchInfo.html#0771afe20f821866802568b7ead09d81">now_</a> - edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().last_update_).sec_;
<a name="l00082"></a>00082         <span class="keywordflow">if</span> (DTLSRConfig::instance()-&gt;lsa_interval_ != 0 &amp;&amp;
<a name="l00083"></a>00083             downtime &gt; (2 * DTLSRConfig::instance()-&gt;lsa_interval_))
<a name="l00084"></a>00084         {
<a name="l00085"></a>00085             <span class="comment">// don't know anything implies the link is "down"</span>
<a name="l00086"></a>00086             <span class="keywordflow">return</span> 0xffffffff;
<a name="l00087"></a>00087         }
<a name="l00088"></a>00088             
<a name="l00089"></a>00089         <span class="keywordflow">if</span> (edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_.state_ == <a class="code" href="classdtn_1_1DTLSR_1_1LinkParams.html#4c7cf89ca787aaa76d10dd64444590b17d9dbd6b1d445d156cf94ca355a0b0a1">LinkParams::LINK_DOWN</a>) {
<a name="l00090"></a>00090             <span class="keywordflow">return</span> 0xffffffff;
<a name="l00091"></a>00091         }
<a name="l00092"></a>00092         <span class="keywordflow">return</span> edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_.delay_;
<a name="l00093"></a>00093     }
<a name="l00094"></a>00094 };
<a name="l00095"></a>00095 
<a name="l00096"></a>00096 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00097"></a><a class="code" href="classdtn_1_1DTLSRRouter_1_1EstimatedDelayWeightFn.html">00097</a> <span class="keyword">class </span><a class="code" href="classdtn_1_1DTLSRRouter_1_1EstimatedDelayWeightFn.html">DTLSRRouter::EstimatedDelayWeightFn</a> : <span class="keyword">public</span> <a class="code" href="classdtn_1_1MultiGraph.html" title="Data structure to represent a multigraph.">RoutingGraph</a>::WeightFn {
<a name="l00098"></a>00098 <span class="keyword">public</span>:
<a name="l00099"></a><a class="code" href="classdtn_1_1DTLSRRouter_1_1EstimatedDelayWeightFn.html#8d0e3c132e8811fe46e490d06361d1bf">00099</a>     <a class="code" href="classdtn_1_1DTLSRRouter_1_1EstimatedDelayWeightFn.html#8d0e3c132e8811fe46e490d06361d1bf">EstimatedDelayWeightFn</a>(<a class="code" href="classdtn_1_1DTLSRRouter.html" title="The DTLSRRouter uses link state announcements to build a multigraph of routing edges...">DTLSRRouter</a>* rtr)
<a name="l00100"></a>00100         : <a class="code" href="classdtn_1_1DTLSRRouter_1_1EstimatedDelayWeightFn.html#51b8fbdf95b318b97e32e79a00ab87e8">router_</a>(rtr) {}
<a name="l00101"></a>00101     
<a name="l00102"></a><a class="code" href="classdtn_1_1DTLSRRouter_1_1EstimatedDelayWeightFn.html#8cb81d6a0608f3600b99b4c70b3c32b6">00102</a>     u_int32_t <a class="code" href="classdtn_1_1DTLSRRouter_1_1EstimatedDelayWeightFn.html#8cb81d6a0608f3600b99b4c70b3c32b6">operator()</a>(<span class="keyword">const</span> <a class="code" href="structdtn_1_1MultiGraph_1_1SearchInfo.html" title="Struct used to encapsulate state that may be needed by weight functors and which...">RoutingGraph::SearchInfo</a>&amp; <a class="code" href="dtncat_8c.html#71f51a2e8cbe9a53031fa72596edc09f">info</a>,
<a name="l00103"></a>00103                          <span class="keyword">const</span> <a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html" title="The edge class.">RoutingGraph::Edge</a>* edge)
<a name="l00104"></a>00104     {
<a name="l00105"></a>00105         <span class="keywordflow">if</span> (edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_.state_ == <a class="code" href="classdtn_1_1DTLSR_1_1LinkParams.html#4c7cf89ca787aaa76d10dd64444590b17d9dbd6b1d445d156cf94ca355a0b0a1">LinkParams::LINK_DOWN</a>) {
<a name="l00106"></a>00106 
<a name="l00107"></a>00107             <span class="comment">// adjust the delay based on the uptime / downtime</span>
<a name="l00108"></a>00108             u_int32_t downtime = (info.<a class="code" href="structdtn_1_1MultiGraph_1_1SearchInfo.html#0771afe20f821866802568b7ead09d81">now_</a> - edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().last_update_).sec_;
<a name="l00109"></a>00109             
<a name="l00110"></a>00110             <span class="comment">// XXX/demmer for now make the bogus silly assumption that</span>
<a name="l00111"></a>00111             <span class="comment">// it will take just as long to come back up as it's been</span>
<a name="l00112"></a>00112             <span class="comment">// down for, plus a constant factor of 5 seconds to</span>
<a name="l00113"></a>00113             <span class="comment">// establish the link, capped at 1 day</span>
<a name="l00114"></a>00114             <span class="comment">//</span>
<a name="l00115"></a>00115             <span class="comment">// really, we need a good way of succinctly characterizing</span>
<a name="l00116"></a>00116             <span class="comment">// delay in a way that can be decayed but also take into</span>
<a name="l00117"></a>00117             <span class="comment">// account historical data, i.e. a number that</span>
<a name="l00118"></a>00118             <span class="comment">// grows/shrinks as the link gets worse but where a router</span>
<a name="l00119"></a>00119             <span class="comment">// can take into account that some outages are expected</span>
<a name="l00120"></a>00120             u_int32_t ret = (downtime + 5) &gt;&gt; DTLSRConfig::instance()-&gt;weight_shift_;
<a name="l00121"></a>00121 
<a name="l00122"></a>00122             <span class="keywordflow">if</span> (ret &lt; 24*60*60) {
<a name="l00123"></a>00123                 log_debug_p(<span class="stringliteral">"/dtn/route/graph"</span>,
<a name="l00124"></a>00124                             <span class="stringliteral">"weight of edge %s=%u (downtime %u + 5)"</span>,
<a name="l00125"></a>00125                             edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().id_.c_str(), ret, downtime);
<a name="l00126"></a>00126             } <span class="keywordflow">else</span> {
<a name="l00127"></a>00127                 ret = 24*60*60;
<a name="l00128"></a>00128                 log_warn_p(<span class="stringliteral">"/dtn/route/graph"</span>,
<a name="l00129"></a>00129                            <span class="stringliteral">"weight of edge %s=%u: (downtime %u exceeded max)"</span>,
<a name="l00130"></a>00130                            edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().id_.c_str(), ret, downtime);
<a name="l00131"></a>00131             }
<a name="l00132"></a>00132 
<a name="l00133"></a>00133             <span class="keywordflow">return</span> ret;
<a name="l00134"></a>00134         }
<a name="l00135"></a>00135 
<a name="l00136"></a>00136         u_int32_t qlen, qsize;
<a name="l00137"></a>00137         <span class="comment">// XXX/demmer use the link queue length if it's a local link</span>
<a name="l00138"></a>00138         qlen  = edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_.qcount_;
<a name="l00139"></a>00139         qsize = edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_.qsize_;
<a name="l00140"></a>00140         
<a name="l00141"></a>00141         <span class="comment">// based on the queue length and link estimates, calculate the</span>
<a name="l00142"></a>00142         <span class="comment">// forwarding delay</span>
<a name="l00143"></a>00143         u_int32_t qdelay = (qlen + 1) * edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_.delay_ / 1000;
<a name="l00144"></a>00144         u_int32_t bwdelay = 0;
<a name="l00145"></a>00145         <span class="keywordflow">if</span> (edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_.bw_ != 0) {
<a name="l00146"></a>00146             <span class="comment">// XXX/demmer is bw bits or bytes?</span>
<a name="l00147"></a>00147             bwdelay = qsize / edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_.bw_;
<a name="l00148"></a>00148         }
<a name="l00149"></a>00149         
<a name="l00150"></a>00150         u_int32_t delay = qdelay + bwdelay;
<a name="l00151"></a>00151         log_debug_p(<span class="stringliteral">"/dtn/route/graph"</span>, <span class="stringliteral">"weight of edge %s=%u "</span>
<a name="l00152"></a>00152                     <span class="stringliteral">"(qlen %u delay %u qdelay %u qsize %u bw %u bwdelay %u)"</span>,
<a name="l00153"></a>00153                     edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().id_.c_str(), delay,
<a name="l00154"></a>00154                     qlen, edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_.delay_, qdelay,
<a name="l00155"></a>00155                     qsize, edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_.bw_, bwdelay);
<a name="l00156"></a>00156         
<a name="l00157"></a>00157         <span class="comment">// XXX/demmer we might want to have an estimator for bundles</span>
<a name="l00158"></a>00158         <span class="comment">// that we've sent out en route to the destination along with</span>
<a name="l00159"></a>00159         <span class="comment">// where and when those bundles will be at different routers.</span>
<a name="l00160"></a>00160         <span class="comment">// then when LSAs come in, we adjust our estimates accordingly</span>
<a name="l00161"></a>00161 
<a name="l00162"></a>00162         <span class="keywordflow">return</span> delay;
<a name="l00163"></a>00163     }
<a name="l00164"></a>00164 
<a name="l00165"></a><a class="code" href="classdtn_1_1DTLSRRouter_1_1EstimatedDelayWeightFn.html#51b8fbdf95b318b97e32e79a00ab87e8">00165</a>     <a class="code" href="classdtn_1_1DTLSRRouter.html" title="The DTLSRRouter uses link state announcements to build a multigraph of routing edges...">DTLSRRouter</a>* <a class="code" href="classdtn_1_1DTLSRRouter_1_1EstimatedDelayWeightFn.html#51b8fbdf95b318b97e32e79a00ab87e8">router_</a>;
<a name="l00166"></a>00166 };
<a name="l00167"></a>00167 
<a name="l00168"></a>00168 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00169"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#8e65ff1560846d436bd8199329ee06f3">00169</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#8e65ff1560846d436bd8199329ee06f3" title="Constructor.">DTLSRRouter::DTLSRRouter</a>()
<a name="l00170"></a>00170     : <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">"DTLSRRouter"</span>, <span class="stringliteral">"dtlsr"</span>),
<a name="l00171"></a>00171       announce_tag_(<span class="stringliteral">"dtlsr"</span>),
<a name="l00172"></a>00172       announce_eid_(<span class="stringliteral">"dtn://*/dtlsr?*"</span>),
<a name="l00173"></a>00173       current_lsas_(<span class="stringliteral">"DTLSRRouter::current_lsas"</span>),
<a name="l00174"></a>00174       periodic_lsa_timer_(this),
<a name="l00175"></a>00175       delayed_lsa_timer_(this)
<a name="l00176"></a>00176 {
<a name="l00177"></a>00177     <span class="comment">// override add_nexthop_routes since it just confuses things</span>
<a name="l00178"></a>00178     <a class="code" href="classdtn_1_1BundleRouter.html#344d85ef64a884adf9fb173a82674cca" title="Config variables.">config_</a>.<a class="code" href="structdtn_1_1BundleRouter_1_1Config.html#55da03509e99dfeb6918d9114f4c9773" 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="l00179"></a>00179 }
<a name="l00180"></a>00180 
<a name="l00181"></a>00181 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00182"></a>00182 <span class="keywordtype">void</span>
<a name="l00183"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#525e06e163b70b76792ea4ad4f08f23c">00183</a> DTLSRRouter::initialize()
<a name="l00184"></a>00184 {
<a name="l00185"></a>00185     <a class="code" href="classdtn_1_1BundleRouter.html#58bdadd6a5f618d44cd4c2084acc707c">TableBasedRouter::initialize</a>();
<a name="l00186"></a>00186     
<a name="l00187"></a>00187     <span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a>&amp; local_eid = BundleDaemon::instance()-&gt;local_eid();
<a name="l00188"></a>00188 
<a name="l00189"></a>00189     <span class="keywordflow">if</span> (local_eid.<a class="code" href="classdtn_1_1EndpointID.html#2ff5cd5d95e97cac315a192676c6a057">scheme_str</a>() != <span class="stringliteral">"dtn"</span>) {
<a name="l00190"></a>00190         log_crit(<span class="stringliteral">"cannot use DTLSR with a local eid not in the 'dtn' scheme"</span>);
<a name="l00191"></a>00191         exit(1);
<a name="l00192"></a>00192     }
<a name="l00193"></a>00193     
<a name="l00194"></a>00194     <a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a> = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#c250f8c8d1b8970870067c6e73058ee9" title="Add a new node.">add_node</a>(local_eid.<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>(), <a class="code" href="structdtn_1_1DTLSRRouter_1_1NodeInfo.html" title="Class used for per-node state in the graph.">NodeInfo</a>());
<a name="l00195"></a>00195 
<a name="l00196"></a>00196     <a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a> admin_eid = local_eid;
<a name="l00197"></a>00197     admin_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>(<a class="code" href="classdtn_1_1DTLSRRouter.html#b3f0a5fcd3705357b8aaa607d2ebf59e" title="Service tag used for routing announcements.">announce_tag_</a>);
<a name="l00198"></a>00198     <a class="code" href="classdtn_1_1DTLSRRouter.html#3faf9ad30f422f4d13d30cd95fe344df" title="The registration to receive lsa and eida announcements.">reg_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1DTLSRRouter_1_1Reg.html" title="Registration used to grab announcements.">Reg</a>(<span class="keyword">this</span>, admin_eid);
<a name="l00199"></a>00199     
<a name="l00200"></a>00200     log_info(<span class="stringliteral">"initializing: local_eid %s weight_fn %s"</span>,
<a name="l00201"></a>00201              local_eid.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(),
<a name="l00202"></a>00202              <a class="code" href="classdtn_1_1DTLSRConfig.html#dffea7ce81d249ad941840ed03f379f1" title="Stringified version of the weight function.">DTLSRConfig::weight_fn_to_str</a>(<a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;<a class="code" href="classdtn_1_1DTLSRRouter.html#7ef8fce5d163ec975fa3d6b004d5e23f">weight_fn_</a>));
<a name="l00203"></a>00203              
<a name="l00204"></a>00204     <span class="keywordflow">switch</span> (<a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;<a class="code" href="classdtn_1_1DTLSRConfig.html#0f95dcac0b9214116c56755028d87a44" title="Configurable weight function.">weight_fn_</a>) {
<a name="l00205"></a>00205     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1DTLSRConfig.html#960e3ba5917434f174db307459a0b107ec4802b85ea307cdeee9076616b84a4e">DTLSRConfig::COST</a>:
<a name="l00206"></a>00206         <a class="code" href="classdtn_1_1DTLSRRouter.html#7ef8fce5d163ec975fa3d6b004d5e23f">weight_fn_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1DTLSRRouter_1_1CostWeightFn.html">CostWeightFn</a>();
<a name="l00207"></a>00207         <span class="keywordflow">break</span>;
<a name="l00208"></a>00208         
<a name="l00209"></a>00209     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1DTLSRConfig.html#960e3ba5917434f174db307459a0b1072dc6f5e7867c5407cae1fee8b18f5dad">DTLSRConfig::DELAY</a>:
<a name="l00210"></a>00210         <a class="code" href="classdtn_1_1DTLSRRouter.html#7ef8fce5d163ec975fa3d6b004d5e23f">weight_fn_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1DTLSRRouter_1_1DelayWeightFn.html">DelayWeightFn</a>();
<a name="l00211"></a>00211         <span class="keywordflow">break</span>;
<a name="l00212"></a>00212 
<a name="l00213"></a>00213     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1DTLSRConfig.html#960e3ba5917434f174db307459a0b107c761d81c6d4cec5e26df68c741dcec22">DTLSRConfig::ESTIMATED_DELAY</a>:
<a name="l00214"></a>00214         <a class="code" href="classdtn_1_1DTLSRRouter.html#7ef8fce5d163ec975fa3d6b004d5e23f">weight_fn_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1DTLSRRouter_1_1EstimatedDelayWeightFn.html">EstimatedDelayWeightFn</a>(<span class="keyword">this</span>);
<a name="l00215"></a>00215         <span class="keywordflow">break</span>;
<a name="l00216"></a>00216     }
<a name="l00217"></a>00217     
<a name="l00218"></a>00218     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;lsa_interval_ != 0) {
<a name="l00219"></a>00219         <a class="code" href="classdtn_1_1DTLSRRouter.html#04c638e58aa00f3fdd422db9eee51022" title="Timer to periodically rebroadcast LSAs.">periodic_lsa_timer_</a>.<a class="code" href="classdtn_1_1DTLSRRouter_1_1TransmitLSATimer.html#99565495f790ea990744a1677a1556b7">set_interval</a>(<a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;lsa_interval_ * 1000);
<a name="l00220"></a>00220         <a class="code" href="classdtn_1_1DTLSRRouter.html#04c638e58aa00f3fdd422db9eee51022" title="Timer to periodically rebroadcast LSAs.">periodic_lsa_timer_</a>.schedule_in(<a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;lsa_interval_ * 1000);
<a name="l00221"></a>00221     }
<a name="l00222"></a>00222 }
<a name="l00223"></a>00223 
<a name="l00224"></a>00224 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00225"></a>00225 <span class="keywordtype">void</span>
<a name="l00226"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#3f070b730307f39d2febe44628495606">00226</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#3f070b730307f39d2febe44628495606" title="Virtual from BundleRouter.">DTLSRRouter::get_routing_state</a>(oasys::StringBuffer* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>)
<a name="l00227"></a>00227 {
<a name="l00228"></a>00228 <span class="comment">//     invalidate_routes();</span>
<a name="l00229"></a>00229 <span class="comment">//     recompute_routes();</span>
<a name="l00230"></a>00230     
<a name="l00231"></a>00231     buf-&gt;appendf(<span class="stringliteral">"DTLSR Routing Graph:\n*%p"</span>, &amp;<a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>);
<a name="l00232"></a>00232     buf-&gt;appendf(<span class="stringliteral">"Current routing table:\n"</span>);
<a name="l00233"></a>00233     <a class="code" href="classdtn_1_1TableBasedRouter.html#c7e05bea7fada765cb85bc589e8fe9ab" title="Dump the routing state.">TableBasedRouter::get_routing_state</a>(buf);
<a name="l00234"></a>00234 }
<a name="l00235"></a>00235 
<a name="l00236"></a>00236 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00237"></a>00237 <span class="keywordtype">bool</span>
<a name="l00238"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#2820245e08b955fa33bf8b5dbaaca00c">00238</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#2820245e08b955fa33bf8b5dbaaca00c" title="Virtual from BundleRouter.">DTLSRRouter::can_delete_bundle</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; bundle)
<a name="l00239"></a>00239 {
<a name="l00240"></a>00240     <span class="keywordflow">if</span> (! <a class="code" href="classdtn_1_1TableBasedRouter.html#feb96189b85d0035ad08874204bdc86b" title="Hook to ask the router if the bundle can be deleted.">TableBasedRouter::can_delete_bundle</a>(bundle)) {
<a name="l00241"></a>00241         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00242"></a>00242     }
<a name="l00243"></a>00243 
<a name="l00244"></a>00244     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1DTLSRRouter.html#9a17528fb94f4bd8abcee4ce5280c444" title="Bundle lists used to hold onto the most recent LSA from all other nodes.">current_lsas_</a>.<a class="code" href="classdtn_1_1BundleList.html#6398bb64194aa88b63e7d0e89e141883" title="Search the list for the given bundle.">contains</a>(bundle)) {
<a name="l00245"></a>00245         log_debug(<span class="stringliteral">"can_delete_bundle(%u): current lsa"</span>, bundle-&gt;bundleid());
<a name="l00246"></a>00246         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00247"></a>00247     }
<a name="l00248"></a>00248 
<a name="l00249"></a>00249     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00250"></a>00250 }
<a name="l00251"></a>00251 
<a name="l00252"></a>00252 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00253"></a>00253 <span class="keywordtype">void</span>
<a name="l00254"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#819cff8c7468bbcf0fe6ec13f386e7e0">00254</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#819cff8c7468bbcf0fe6ec13f386e7e0" title="Virtual from BundleRouter.">DTLSRRouter::delete_bundle</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; bundle)
<a name="l00255"></a>00255 {
<a name="l00256"></a>00256     <a class="code" href="classdtn_1_1TableBasedRouter.html#469390b9ba77d858ed51d5d80176407e" title="Hook to tell the router that the bundle should be deleted.">TableBasedRouter::delete_bundle</a>(bundle);
<a name="l00257"></a>00257 
<a name="l00258"></a>00258     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1DTLSRRouter.html#9a17528fb94f4bd8abcee4ce5280c444" title="Bundle lists used to hold onto the most recent LSA from all other nodes.">current_lsas_</a>.<a class="code" href="classdtn_1_1BundleList.html#6398bb64194aa88b63e7d0e89e141883" title="Search the list for the given bundle.">contains</a>(bundle))
<a name="l00259"></a>00259     {
<a name="l00260"></a>00260         log_crit(<span class="stringliteral">"deleting bundle id %u whilea still on current lsas list"</span>,
<a name="l00261"></a>00261                  bundle-&gt;bundleid());
<a name="l00262"></a>00262         <a class="code" href="classdtn_1_1DTLSRRouter.html#9a17528fb94f4bd8abcee4ce5280c444" title="Bundle lists used to hold onto the most recent LSA from all other nodes.">current_lsas_</a>.<a class="code" href="classdtn_1_1BundleList.html#b0171458e14d67307b74f98447062d68" title="Remove the given bundle from the list.">erase</a>(bundle);
<a name="l00263"></a>00263     }
<a name="l00264"></a>00264 }
<a name="l00265"></a>00265 
<a name="l00266"></a>00266 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00267"></a>00267 <span class="keywordtype">void</span>
<a name="l00268"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#dec1ea9bcb9c1ef40b596a3a3223d236">00268</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#dec1ea9bcb9c1ef40b596a3a3223d236" title="Event handlers.">DTLSRRouter::handle_link_created</a>(<a class="code" href="classdtn_1_1LinkCreatedEvent.html" title="Event class for link creation events.">LinkCreatedEvent</a>* e)
<a name="l00269"></a>00269 {
<a name="l00270"></a>00270     <span class="comment">// XXX/demmer TODO: add the edge and initialize downtime_pct based</span>
<a name="l00271"></a>00271     <span class="comment">// on the link type.</span>
<a name="l00272"></a>00272 
<a name="l00273"></a>00273     <a class="code" href="classdtn_1_1DTLSRRouter.html#21f4a9e720ac26adc47f7838fc1060a5" title="Helper functions.">invalidate_routes</a>();
<a name="l00274"></a>00274     <a class="code" href="classdtn_1_1DTLSRRouter.html#526947e56ad2813e93b07ba2c4ce1aca" title="Helper functions.">recompute_routes</a>();
<a name="l00275"></a>00275     <a class="code" href="classdtn_1_1TableBasedRouter.html#15d6e91c5362005ef5f5ee2cc9b667b8" title="Event handlers.">TableBasedRouter::handle_link_created</a>(e);
<a name="l00276"></a>00276 }
<a name="l00277"></a>00277 
<a name="l00278"></a>00278 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00279"></a>00279 <span class="keywordtype">void</span>
<a name="l00280"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#d48eeddd0bcaaf710690b0eccc863168">00280</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#d48eeddd0bcaaf710690b0eccc863168" title="Event handlers.">DTLSRRouter::handle_bundle_received</a>(<a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a>* e)
<a name="l00281"></a>00281 {
<a name="l00282"></a>00282 <span class="comment">//     if (time_to_age_routes()) {</span>
<a name="l00283"></a>00283 <span class="comment">//         recompute_routes();</span>
<a name="l00284"></a>00284 <span class="comment">//     }</span>
<a name="l00285"></a>00285 
<a name="l00286"></a>00286     <a class="code" href="classdtn_1_1TableBasedRouter.html#f85d95a59fe4ae2217ed2c9b0c6cb662" title="Event handlers.">TableBasedRouter::handle_bundle_received</a>(e);
<a name="l00287"></a>00287 }
<a name="l00288"></a>00288 
<a name="l00289"></a>00289 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00290"></a>00290 <span class="keywordtype">void</span>
<a name="l00291"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#7b7ec5b21655ce89ad018484aa31219e">00291</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#7b7ec5b21655ce89ad018484aa31219e" title="Event handlers.">DTLSRRouter::handle_bundle_expired</a>(<a class="code" href="classdtn_1_1BundleExpiredEvent.html" title="Event class for bundle expiration.">BundleExpiredEvent</a>* e)
<a name="l00292"></a>00292 {
<a name="l00293"></a>00293     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle = e-&gt;<a class="code" href="classdtn_1_1BundleExpiredEvent.html#ff03d709b5e05b88f372b75d8644c7eb" title="The expired bundle.">bundleref_</a>.object();
<a name="l00294"></a>00294 
<a name="l00295"></a>00295     <span class="comment">// check if this is one of the current LSAs if so, we</span>
<a name="l00296"></a>00296     <span class="comment">// need to drop our retention constraint and let it expire</span>
<a name="l00297"></a>00297     <span class="comment">//</span>
<a name="l00298"></a>00298     <span class="comment">// XXX/demmer perhaps we should do something more drastic like</span>
<a name="l00299"></a>00299     <span class="comment">// remove the node from the routing graph?</span>
<a name="l00300"></a>00300     oasys::ScopeLock l(<a class="code" href="classdtn_1_1DTLSRRouter.html#9a17528fb94f4bd8abcee4ce5280c444" title="Bundle lists used to hold onto the most recent LSA from all other nodes.">current_lsas_</a>.<a class="code" href="classdtn_1_1BundleList.html#0d0c9f789f0f7f7d1cda3b4ecf32d2bc" title="Return the internal lock on this list.">lock</a>(),
<a name="l00301"></a>00301                        <span class="stringliteral">"DTLSRRouter::handle_bundle_expired"</span>);
<a name="l00302"></a>00302 
<a name="l00303"></a>00303     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1DTLSRRouter.html#9a17528fb94f4bd8abcee4ce5280c444" title="Bundle lists used to hold onto the most recent LSA from all other nodes.">current_lsas_</a>.<a class="code" href="classdtn_1_1BundleList.html#6398bb64194aa88b63e7d0e89e141883" title="Search the list for the given bundle.">contains</a>(bundle))
<a name="l00304"></a>00304     {
<a name="l00305"></a>00305         log_notice(<span class="stringliteral">"current lsa for %s expired... kicking links"</span>,
<a name="l00306"></a>00306                    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="l00307"></a>00307         <a class="code" href="classdtn_1_1DTLSRRouter.html#33ff8b18e340274d8dea045215467067" title="Helper functions.">handle_lsa_expired</a>(bundle);
<a name="l00308"></a>00308         <a class="code" href="classdtn_1_1DTLSRRouter.html#9a17528fb94f4bd8abcee4ce5280c444" title="Bundle lists used to hold onto the most recent LSA from all other nodes.">current_lsas_</a>.<a class="code" href="classdtn_1_1BundleList.html#b0171458e14d67307b74f98447062d68" title="Remove the given bundle from the list.">erase</a>(bundle);
<a name="l00309"></a>00309     }
<a name="l00310"></a>00310     
<a name="l00311"></a>00311     <a class="code" href="classdtn_1_1BundleEventHandler.html#2f61bf0d5f85f029b3bd67adacb03ea1" title="Default event handler when bundles expire.">TableBasedRouter::handle_bundle_expired</a>(e);
<a name="l00312"></a>00312 }
<a name="l00313"></a>00313     
<a name="l00314"></a>00314 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00315"></a>00315 <span class="keywordtype">void</span>
<a name="l00316"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#538d08d46a2361111fb37c2aca223ca4">00316</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#538d08d46a2361111fb37c2aca223ca4" title="Event handlers.">DTLSRRouter::handle_contact_up</a>(<a class="code" href="classdtn_1_1ContactUpEvent.html" title="Event class for contact up events.">ContactUpEvent</a>* e)
<a name="l00317"></a>00317 {
<a name="l00318"></a>00318     <span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link = e-&gt;<a class="code" href="classdtn_1_1ContactUpEvent.html#10e9dd243dd15f8e5974a02df3ab8e6e" title="The contact that is up.">contact_</a>-&gt;link();
<a name="l00319"></a>00319     <span class="keywordflow">if</span> (link-&gt;remote_eid() == <a class="code" href="classdtn_1_1EndpointID.html#31bd1844cae5e71cc2393a139c9bec4c" title="Return the special endpoint id used for the null endpoint, namely &amp;quot;dtn:none&amp;quot;...">EndpointID::NULL_EID</a>()) {
<a name="l00320"></a>00320         log_warn(<span class="stringliteral">"can't handle link %s: no remote endpoint id"</span>,
<a name="l00321"></a>00321                  link-&gt;name());
<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     <a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html" title="Class used for per-edge state in the graph (the link).">EdgeInfo</a> ei(link-&gt;name());
<a name="l00326"></a>00326     <span class="comment">// XXX/demmer what about bw/delay/capacity?</span>
<a name="l00327"></a>00327     ei.<a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html#df107e4fc22874f3a8b83885b9b74264" title="link params">params_</a>.<a class="code" href="classdtn_1_1DTLSR_1_1LinkParams.html#6a9731573600356c822ac8183558f1db" title="configured link cost">cost_</a> = link-&gt;params().cost_;
<a name="l00328"></a>00328     
<a name="l00329"></a>00329     <a class="code" href="classdtn_1_1MultiGraph_1_1Node.html" title="The node class.">RoutingGraph::Node</a>* remote_node =
<a name="l00330"></a>00330         <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#a9a0d61ec5663bc8954b0db5969b68f4" title="Find a node with the given id.">find_node</a>(link-&gt;remote_eid().str());
<a name="l00331"></a>00331 
<a name="l00332"></a>00332     <span class="keywordflow">if</span> (remote_node == NULL) {
<a name="l00333"></a>00333         remote_node = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#c250f8c8d1b8970870067c6e73058ee9" title="Add a new node.">add_node</a>(link-&gt;remote_eid().str(), <a class="code" href="structdtn_1_1DTLSRRouter_1_1NodeInfo.html" title="Class used for per-node state in the graph.">NodeInfo</a>());
<a name="l00334"></a>00334     }
<a name="l00335"></a>00335 
<a name="l00336"></a>00336     <a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html" title="The edge class.">RoutingGraph::Edge</a>* edge = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#45b321b90cabaab2d960b50bfa65f3ab" title="Find an edge.">find_edge</a>(<a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>, remote_node, ei);
<a name="l00337"></a>00337     <span class="keywordflow">if</span> (edge == NULL) {
<a name="l00338"></a>00338         edge = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#059a319c2a8018b46b292b3dbc01ce8a" title="Add an edge.">add_edge</a>(<a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>, remote_node, ei);
<a name="l00339"></a>00339     } <span class="keywordflow">else</span> {
<a name="l00340"></a>00340         edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#9919f41c989d9e9bfe28dbf26a3dd81e">mutable_info</a>().params_.state_ = <a class="code" href="classdtn_1_1DTLSR_1_1LinkParams.html#4c7cf89ca787aaa76d10dd64444590b19c37d3bb69e70835da132c4b62fee73b">LinkParams::LINK_UP</a>;
<a name="l00341"></a>00341     }
<a name="l00342"></a>00342 
<a name="l00343"></a>00343     <span class="comment">// always calculate the new routing graph now</span>
<a name="l00344"></a>00344     <a class="code" href="classdtn_1_1DTLSRRouter.html#21f4a9e720ac26adc47f7838fc1060a5" title="Helper functions.">invalidate_routes</a>();
<a name="l00345"></a>00345     <a class="code" href="classdtn_1_1DTLSRRouter.html#526947e56ad2813e93b07ba2c4ce1aca" title="Helper functions.">recompute_routes</a>();
<a name="l00346"></a>00346     
<a name="l00347"></a>00347     <span class="comment">// schedule a new lsa to include the new link</span>
<a name="l00348"></a>00348     <a class="code" href="classdtn_1_1DTLSRRouter.html#0e900cf00e2cf4715ef54f18406eeef6" title="Helper functions.">schedule_lsa</a>();
<a name="l00349"></a>00349 
<a name="l00350"></a>00350     <span class="comment">// now let the superclass have a turn at the event</span>
<a name="l00351"></a>00351     <a class="code" href="classdtn_1_1TableBasedRouter.html#898f2c517d6c8b0635c2ac19a5c3425a" title="Event handlers.">TableBasedRouter::handle_contact_up</a>(e);
<a name="l00352"></a>00352 }
<a name="l00353"></a>00353 
<a name="l00354"></a>00354 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00355"></a>00355 <span class="keywordtype">void</span>
<a name="l00356"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#db62776ace5c4b42f033031f30a66259">00356</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#db62776ace5c4b42f033031f30a66259" title="Event handlers.">DTLSRRouter::handle_contact_down</a>(<a class="code" href="classdtn_1_1ContactDownEvent.html" title="Event class for contact down events.">ContactDownEvent</a>* e)
<a name="l00357"></a>00357 {
<a name="l00358"></a>00358     <span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link = e-&gt;<a class="code" href="classdtn_1_1ContactDownEvent.html#cc4067480bd6af7023cb6d4c99122a7e" title="The contact that is now down.">contact_</a>-&gt;link();
<a name="l00359"></a>00359 
<a name="l00360"></a>00360     <a class="code" href="classdtn_1_1MultiGraph_1_1Node.html" title="The node class.">RoutingGraph::Node</a>* remote_node =
<a name="l00361"></a>00361         <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#a9a0d61ec5663bc8954b0db5969b68f4" title="Find a node with the given id.">find_node</a>(link-&gt;remote_eid().str());
<a name="l00362"></a>00362 
<a name="l00363"></a>00363     <span class="keywordflow">if</span> (remote_node == NULL) {
<a name="l00364"></a>00364         log_err(<span class="stringliteral">"contact down event for link %s: node not in routing graph"</span>,
<a name="l00365"></a>00365                 link-&gt;name());
<a name="l00366"></a>00366         <span class="keywordflow">return</span>;
<a name="l00367"></a>00367     }
<a name="l00368"></a>00368 
<a name="l00369"></a>00369     <a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html" title="The edge class.">RoutingGraph::Edge</a>* edge = NULL;
<a name="l00370"></a>00370     RoutingGraph::EdgeVector::const_iterator iter;
<a name="l00371"></a>00371     <span class="keywordflow">for</span> (iter = <a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#f17f73294b7a81c08f78398f3088bac4">out_edges</a>().begin();
<a name="l00372"></a>00372          iter != <a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#f17f73294b7a81c08f78398f3088bac4">out_edges</a>().end(); ++iter)
<a name="l00373"></a>00373     {
<a name="l00374"></a>00374         <span class="keywordflow">if</span> ((*iter)-&gt;info().id_ == link-&gt;name_str()) {
<a name="l00375"></a>00375             edge = *iter;
<a name="l00376"></a>00376             <span class="keywordflow">break</span>;
<a name="l00377"></a>00377         }
<a name="l00378"></a>00378     }
<a name="l00379"></a>00379     
<a name="l00380"></a>00380     <span class="keywordflow">if</span> (edge == NULL) {
<a name="l00381"></a>00381         log_err(<span class="stringliteral">"handle_contact_down: can't find link *%p"</span>, link.object());
<a name="l00382"></a>00382         <span class="keywordflow">return</span>;
<a name="l00383"></a>00383     }
<a name="l00384"></a>00384         
<a name="l00385"></a>00385     edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#9919f41c989d9e9bfe28dbf26a3dd81e">mutable_info</a>().params_.state_ = <a class="code" href="classdtn_1_1DTLSR_1_1LinkParams.html#4c7cf89ca787aaa76d10dd64444590b17d9dbd6b1d445d156cf94ca355a0b0a1">LinkParams::LINK_DOWN</a>;
<a name="l00386"></a>00386 
<a name="l00387"></a>00387     <span class="comment">// calculate the new routing graph</span>
<a name="l00388"></a>00388     <a class="code" href="classdtn_1_1DTLSRRouter.html#21f4a9e720ac26adc47f7838fc1060a5" title="Helper functions.">invalidate_routes</a>();
<a name="l00389"></a>00389     <a class="code" href="classdtn_1_1DTLSRRouter.html#526947e56ad2813e93b07ba2c4ce1aca" title="Helper functions.">recompute_routes</a>();
<a name="l00390"></a>00390 
<a name="l00391"></a>00391     <span class="comment">// inform peers</span>
<a name="l00392"></a>00392     <a class="code" href="classdtn_1_1DTLSRRouter.html#0e900cf00e2cf4715ef54f18406eeef6" title="Helper functions.">schedule_lsa</a>();
<a name="l00393"></a>00393     
<a name="l00394"></a>00394     <span class="keywordflow">if</span> (! <a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;keep_down_links_) {
<a name="l00395"></a>00395         <a class="code" href="classdtn_1_1DTLSRRouter.html#a13137e7dff6ba68db9b1bad9c76bfc9" title="Helper functions.">remove_edge</a>(edge);
<a name="l00396"></a>00396     }
<a name="l00397"></a>00397     
<a name="l00398"></a>00398     <a class="code" href="classdtn_1_1TableBasedRouter.html#5b9a452a306adc7f97c998f3e7c585e3" title="Event handlers.">TableBasedRouter::handle_contact_down</a>(e);
<a name="l00399"></a>00399 }
<a name="l00400"></a>00400 
<a name="l00401"></a>00401 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00402"></a>00402 <span class="keywordtype">void</span>
<a name="l00403"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#ec18a31e07eed67073f7e0fe6a52a8ba">00403</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#ec18a31e07eed67073f7e0fe6a52a8ba" title="Event handlers.">DTLSRRouter::handle_link_deleted</a>(<a class="code" href="classdtn_1_1LinkDeletedEvent.html" title="Event class for link deletion events.">LinkDeletedEvent</a>* e)
<a name="l00404"></a>00404 {
<a name="l00405"></a>00405     <a class="code" href="classdtn_1_1TableBasedRouter.html#f18906e5ecdbe1dc6ff76b3d74bc41b0" title="Event handlers.">TableBasedRouter::handle_link_deleted</a>(e);
<a name="l00406"></a>00406     NOTREACHED;
<a name="l00407"></a>00407     
<a name="l00408"></a>00408     <span class="comment">// XXX/demmer fixme</span>
<a name="l00409"></a>00409     
<a name="l00410"></a>00410     RoutingGraph::EdgeVector::const_iterator iter;
<a name="l00411"></a>00411     <span class="keywordflow">for</span> (iter = <a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#f17f73294b7a81c08f78398f3088bac4">out_edges</a>().begin();
<a name="l00412"></a>00412          iter != <a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#f17f73294b7a81c08f78398f3088bac4">out_edges</a>().end(); ++iter)
<a name="l00413"></a>00413     {
<a name="l00414"></a>00414         <span class="keywordflow">if</span> ((*iter)-&gt;info().id_ == e-&gt;<a class="code" href="classdtn_1_1LinkDeletedEvent.html#a3d4aa1b85c8b9b52b478e68fa814e03" title="The link that was deleted.">link_</a>-&gt;name()) {
<a name="l00415"></a>00415             <a class="code" href="classdtn_1_1DTLSRRouter.html#a13137e7dff6ba68db9b1bad9c76bfc9" title="Helper functions.">remove_edge</a>(*iter);
<a name="l00416"></a>00416             <span class="keywordflow">return</span>;
<a name="l00417"></a>00417         }
<a name="l00418"></a>00418     }
<a name="l00419"></a>00419 
<a name="l00420"></a>00420     log_err(<span class="stringliteral">"handle_link_deleted: can't find link *%p"</span>, e-&gt;<a class="code" href="classdtn_1_1LinkDeletedEvent.html#a3d4aa1b85c8b9b52b478e68fa814e03" title="The link that was deleted.">link_</a>.object());
<a name="l00421"></a>00421 }
<a name="l00422"></a>00422 
<a name="l00423"></a>00423 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00424"></a>00424 <span class="keywordtype">void</span>
<a name="l00425"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#f3483073a5dba77af83cadbee6654100">00425</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#f3483073a5dba77af83cadbee6654100" title="Event handlers.">DTLSRRouter::handle_registration_added</a>(<a class="code" href="classdtn_1_1RegistrationAddedEvent.html" title="Event class for new registration arrivals.">RegistrationAddedEvent</a>* event)
<a name="l00426"></a>00426 {
<a name="l00427"></a>00427     <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 = <span class="keyword">event</span>-&gt;registration_;
<a name="l00428"></a>00428     <span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a>&amp; local_eid = BundleDaemon::instance()-&gt;local_eid();
<a name="l00429"></a>00429     
<a name="l00430"></a>00430     <a class="code" href="classdtn_1_1TableBasedRouter.html#fab4ded007eddf5b49c3ff75eea74dd8" title="Event handlers.">TableBasedRouter::handle_registration_added</a>(event);
<a name="l00431"></a>00431 
<a name="l00432"></a>00432     <span class="comment">// to handle registration for endpoint identifiers that aren't</span>
<a name="l00433"></a>00433     <span class="comment">// covered by our local_eid pattern, we add a node to the graph</span>
<a name="l00434"></a>00434     <span class="comment">// with an infinite-bandwidth edge from our local node to it.</span>
<a name="l00435"></a>00435     <span class="comment">//</span>
<a name="l00436"></a>00436     <span class="comment">// session registrations don't get announced, except for custody</span>
<a name="l00437"></a>00437     <span class="comment">// ones which get the 'dtn-session:' prefix added on</span>
<a name="l00438"></a>00438     <span class="keywordflow">if</span> (reg-&gt;<a class="code" href="classdtn_1_1Registration.html#590e683ae3d0a33456e7f0fa0a2a89d5" title="Accessors.">endpoint</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>(local_eid)) {
<a name="l00439"></a>00439         <span class="keywordflow">return</span>; <span class="comment">// nothing to do</span>
<a name="l00440"></a>00440     }
<a name="l00441"></a>00441 
<a name="l00442"></a>00442     std::string eid;
<a name="l00443"></a>00443     <span class="keywordflow">if</span> (reg-&gt;<a class="code" href="classdtn_1_1Registration.html#577ef221608a47ba828daad128c2b263" title="Accessors.">session_flags</a>() == 0)
<a name="l00444"></a>00444     {
<a name="l00445"></a>00445         eid = reg-&gt;<a class="code" href="classdtn_1_1Registration.html#590e683ae3d0a33456e7f0fa0a2a89d5" title="Accessors.">endpoint</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00446"></a>00446     }
<a name="l00447"></a>00447     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (reg-&gt;<a class="code" href="classdtn_1_1Registration.html#577ef221608a47ba828daad128c2b263" title="Accessors.">session_flags</a>() &amp; <a class="code" href="classdtn_1_1Session.html#a795473f389a203d6e15058da8d9498c1ccfadd042afba693bbcf1e5980667d9">Session::CUSTODY</a>)
<a name="l00448"></a>00448     {
<a name="l00449"></a>00449         eid = std::string(<span class="stringliteral">"dtn-session:"</span>) + reg-&gt;<a class="code" href="classdtn_1_1Registration.html#590e683ae3d0a33456e7f0fa0a2a89d5" title="Accessors.">endpoint</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>();
<a name="l00450"></a>00450     }
<a name="l00451"></a>00451     <span class="keywordflow">else</span>
<a name="l00452"></a>00452     {
<a name="l00453"></a>00453         <span class="keywordflow">return</span>; <span class="comment">// ignore non-custody registrations</span>
<a name="l00454"></a>00454     }
<a name="l00455"></a>00455     
<a name="l00456"></a>00456     <a class="code" href="classdtn_1_1MultiGraph_1_1Node.html" title="The node class.">RoutingGraph::Node</a>* node = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#a9a0d61ec5663bc8954b0db5969b68f4" title="Find a node with the given id.">find_node</a>(eid);
<a name="l00457"></a>00457     <span class="keywordflow">if</span> (node == NULL) {
<a name="l00458"></a>00458         log_debug(<span class="stringliteral">"handle_registration added: adding new graph node for %s"</span>,
<a name="l00459"></a>00459                   eid.c_str());
<a name="l00460"></a>00460         node = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#c250f8c8d1b8970870067c6e73058ee9" title="Add a new node.">add_node</a>(eid, <a class="code" href="structdtn_1_1DTLSRRouter_1_1NodeInfo.html" title="Class used for per-node state in the graph.">NodeInfo</a>());
<a name="l00461"></a>00461     }
<a name="l00462"></a>00462 
<a name="l00463"></a>00463     <a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html" title="Class used for per-edge state in the graph (the link).">EdgeInfo</a> ei(std::string(<span class="stringliteral">"reg-"</span>) + eid);
<a name="l00464"></a>00464     ei.<a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html#047ffc1050847632416726647dda383c" title="whether edge is local">is_registration_</a> = <span class="keyword">true</span>;
<a name="l00465"></a>00465     ei.<a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html#df107e4fc22874f3a8b83885b9b74264" title="link params">params_</a>.<a class="code" href="classdtn_1_1DTLSR_1_1LinkParams.html#75c55d4068481ab09b2b78c773ce92fb" title="estimated link bandwidth">bw_</a>      = 0xffffffff;
<a name="l00466"></a>00466     
<a name="l00467"></a>00467     <a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html" title="The edge class.">RoutingGraph::Edge</a>* edge = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#45b321b90cabaab2d960b50bfa65f3ab" title="Find an edge.">find_edge</a>(<a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>, node, ei);
<a name="l00468"></a>00468     <span class="keywordflow">if</span> (edge == NULL) {
<a name="l00469"></a>00469         log_debug(<span class="stringliteral">"handle_registration added: adding new edge node for %s"</span>,
<a name="l00470"></a>00470                   ei.<a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html#8d99e7ce3d0db06107c104d8bd858b4e" title="link name">id_</a>.c_str());
<a name="l00471"></a>00471         edge = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#059a319c2a8018b46b292b3dbc01ce8a" title="Add an edge.">add_edge</a>(<a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>, node, ei);
<a name="l00472"></a>00472         
<a name="l00473"></a>00473         <span class="comment">// send a new lsa to announce the new edge</span>
<a name="l00474"></a>00474         <a class="code" href="classdtn_1_1DTLSRRouter.html#0e900cf00e2cf4715ef54f18406eeef6" title="Helper functions.">schedule_lsa</a>();
<a name="l00475"></a>00475     }
<a name="l00476"></a>00476 }
<a name="l00477"></a>00477 
<a name="l00478"></a>00478 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00479"></a>00479 <span class="keywordtype">void</span>
<a name="l00480"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#a13137e7dff6ba68db9b1bad9c76bfc9">00480</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#a13137e7dff6ba68db9b1bad9c76bfc9" title="Helper functions.">DTLSRRouter::remove_edge</a>(<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html" title="The edge class.">RoutingGraph::Edge</a>* edge)
<a name="l00481"></a>00481 {
<a name="l00482"></a>00482     log_debug(<span class="stringliteral">"remove_edge %s"</span>, edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().id_.c_str());
<a name="l00483"></a>00483     <span class="keywordtype">bool</span> ok = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#32aff4a713436864c2f147c03393bbbe" title="Remove the specified edge from the given node, deleting the Edge object.">del_edge</a>(<a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>, edge);
<a name="l00484"></a>00484     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(ok);
<a name="l00485"></a>00485 }
<a name="l00486"></a>00486 
<a name="l00487"></a>00487 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00488"></a>00488 <span class="keywordtype">bool</span>
<a name="l00489"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#99e0d7074adb02f6e4db90eeade028cf">00489</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#99e0d7074adb02f6e4db90eeade028cf" title="Helper functions.">DTLSRRouter::time_to_age_routes</a>()
<a name="l00490"></a>00490 {
<a name="l00491"></a>00491     u_int32_t elapsed = <a class="code" href="classdtn_1_1DTLSRRouter.html#3888b9c80d3a9b7fc40ebd36a7f56ecf" title="Time of the last update of local graph.">last_update_</a>.elapsed_ms() / 1000;
<a name="l00492"></a>00492     <span class="keywordflow">if</span> (elapsed &gt; <a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;aging_interval_) {
<a name="l00493"></a>00493         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00494"></a>00494     }
<a name="l00495"></a>00495     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00496"></a>00496 }
<a name="l00497"></a>00497 
<a name="l00498"></a>00498 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00499"></a>00499 <span class="keywordtype">void</span>
<a name="l00500"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#21f4a9e720ac26adc47f7838fc1060a5">00500</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#21f4a9e720ac26adc47f7838fc1060a5" title="Helper functions.">DTLSRRouter::invalidate_routes</a>()
<a name="l00501"></a>00501 {
<a name="l00502"></a>00502     log_debug(<span class="stringliteral">"invalidating routes"</span>);
<a name="l00503"></a>00503     <a class="code" href="classdtn_1_1DTLSRRouter.html#3888b9c80d3a9b7fc40ebd36a7f56ecf" title="Time of the last update of local graph.">last_update_</a>.sec_ = 0;
<a name="l00504"></a>00504 }
<a name="l00505"></a>00505 
<a name="l00506"></a>00506 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00507"></a>00507 <span class="keywordtype">bool</span>
<a name="l00508"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#b75c4f21736df06014c4b9dfcf85d8fa">00508</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#b75c4f21736df06014c4b9dfcf85d8fa" title="Helper functions.">DTLSRRouter::is_dynamic_route</a>(<a class="code" href="classdtn_1_1RouteEntry.html" title="Class to represent route table entry.">RouteEntry</a>* entry)
<a name="l00509"></a>00509 {
<a name="l00510"></a>00510     <span class="keywordflow">if</span> (entry-&gt;<a class="code" href="classdtn_1_1RouteEntry.html#9052c114bd00cc367914c754526ba561" title="Accessors.">info</a>() == NULL) {
<a name="l00511"></a>00511         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00512"></a>00512     }
<a name="l00513"></a>00513     
<a name="l00514"></a>00514     <a class="code" href="structdtn_1_1DTLSRRouter_1_1RouteInfo.html" title="Class used for router-specific state in the routing table.">RouteInfo</a>* <a class="code" href="dtncat_8c.html#71f51a2e8cbe9a53031fa72596edc09f">info</a> = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="structdtn_1_1DTLSRRouter_1_1RouteInfo.html" title="Class used for router-specific state in the routing table.">RouteInfo</a>*<span class="keyword">&gt;</span>(entry-&gt;<a class="code" href="classdtn_1_1RouteEntry.html#9052c114bd00cc367914c754526ba561" title="Accessors.">info</a>());
<a name="l00515"></a>00515     <span class="keywordflow">if</span> (info != NULL) {
<a name="l00516"></a>00516         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00517"></a>00517     }
<a name="l00518"></a>00518     
<a name="l00519"></a>00519     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00520"></a>00520 }
<a name="l00521"></a>00521 
<a name="l00522"></a>00522 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00523"></a>00523 <span class="keywordtype">void</span>
<a name="l00524"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#526947e56ad2813e93b07ba2c4ce1aca">00524</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#526947e56ad2813e93b07ba2c4ce1aca" title="Helper functions.">DTLSRRouter::recompute_routes</a>()
<a name="l00525"></a>00525 {
<a name="l00526"></a>00526 <span class="comment">//     // XXX/demmer make this a parameter</span>
<a name="l00527"></a>00527 <span class="comment">//     u_int32_t elapsed = last_update_.elapsed_ms() / 1000;</span>
<a name="l00528"></a>00528 <span class="comment">//     if (elapsed &lt; config()-&gt;recompute_delay_) {</span>
<a name="l00529"></a>00529 <span class="comment">//         log_debug("not recomputing routes since %u ms elapsed since last update",</span>
<a name="l00530"></a>00530 <span class="comment">//                   elapsed);</span>
<a name="l00531"></a>00531 <span class="comment">//         return;</span>
<a name="l00532"></a>00532 <span class="comment">//     }</span>
<a name="l00533"></a>00533 
<a name="l00534"></a>00534     log_debug(<span class="stringliteral">"recomputing all routes"</span>);
<a name="l00535"></a>00535     <a class="code" href="classdtn_1_1DTLSRRouter.html#3888b9c80d3a9b7fc40ebd36a7f56ecf" title="Time of the last update of local graph.">last_update_</a>.get_time();
<a name="l00536"></a>00536 
<a name="l00537"></a>00537     <a class="code" href="classdtn_1_1TableBasedRouter.html#83939b60c495ff450a1e95787c811297" title="The routing table.">route_table_</a>-&gt;<a class="code" href="classdtn_1_1RouteTable.html#737932d31320acd50d7c58f61128baaa" title="Remove entries that match the given predicate.">del_matching_entries</a>(<a class="code" href="classdtn_1_1DTLSRRouter.html#b75c4f21736df06014c4b9dfcf85d8fa" title="Helper functions.">is_dynamic_route</a>);
<a name="l00538"></a>00538 
<a name="l00539"></a>00539     <span class="comment">// loop through all the nodes in the graph, finding the right</span>
<a name="l00540"></a>00540     <span class="comment">// route and re-adding it</span>
<a name="l00541"></a>00541     RoutingGraph::NodeVector::const_iterator iter;
<a name="l00542"></a>00542     <span class="keywordflow">for</span> (iter = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#105482907b76044f8faa3720c8c97c4c" title="Accessor for the nodes array.">nodes</a>().begin(); iter != <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#105482907b76044f8faa3720c8c97c4c" title="Accessor for the nodes array.">nodes</a>().end(); ++iter) {
<a name="l00543"></a>00543         <span class="keyword">const</span> <a class="code" href="classdtn_1_1MultiGraph_1_1Node.html" title="The node class.">RoutingGraph::Node</a>* dest = *iter;
<a name="l00544"></a>00544 
<a name="l00545"></a>00545         <span class="keywordflow">if</span> (dest == <a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>) {
<a name="l00546"></a>00546             <span class="keywordflow">continue</span>;
<a name="l00547"></a>00547         }
<a name="l00548"></a>00548 
<a name="l00549"></a>00549         <a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a> dest_eid(dest-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#5e8016f9c2e46fe81258cc4c3eb597ee">id</a>());
<a name="l00550"></a>00550         dest_eid.append_service_tag(<span class="stringliteral">"*"</span>);
<a name="l00551"></a>00551         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(dest_eid.valid());
<a name="l00552"></a>00552 
<a name="l00553"></a>00553         <span class="comment">// XXX/demmer this should include more criteria for</span>
<a name="l00554"></a>00554         <span class="comment">// classification, i.e. the priority class, perhaps the size</span>
<a name="l00555"></a>00555         <span class="comment">// limit, etc</span>
<a name="l00556"></a>00556         <a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html" title="The edge class.">RoutingGraph::Edge</a>* edge = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#05257dfbccf2c15813faef76b0a8ff6c" title="More limited version of the shortest path that just returns the next hop edge.">best_next_hop</a>(<a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>, dest,
<a name="l00557"></a>00557                                                         <a class="code" href="classdtn_1_1DTLSRRouter.html#7ef8fce5d163ec975fa3d6b004d5e23f">weight_fn_</a>);
<a name="l00558"></a>00558         <span class="keywordflow">if</span> (edge == NULL) {
<a name="l00559"></a>00559 <span class="comment">//            log_warn("no route to destination %s", dest-&gt;id().c_str());</span>
<a name="l00560"></a>00560             <span class="keywordflow">continue</span>;
<a name="l00561"></a>00561         }
<a name="l00562"></a>00562 
<a name="l00563"></a>00563         <a class="code" href="classdtn_1_1ContactManager.html" title="A contact manager class.">ContactManager</a>* cm = BundleDaemon::instance()-&gt;contactmgr();
<a name="l00564"></a>00564         <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link = cm-&gt;<a class="code" href="classdtn_1_1ContactManager.html#4a31131016ed7f6b11ce6823dd7abe91" title="Finds link corresponding to this name.">find_link</a>(edge-&gt;info().id_.c_str());
<a name="l00565"></a>00565         <span class="keywordflow">if</span> (link == NULL) {
<a name="l00566"></a>00566 
<a name="l00567"></a>00567             <span class="comment">// it's possible that this is a local registration link,</span>
<a name="l00568"></a>00568             <span class="comment">// so just ignore it</span>
<a name="l00569"></a>00569             log_debug(<span class="stringliteral">"link %s not in local link table... ignoring it"</span>,
<a name="l00570"></a>00570                       edge-&gt;info().id_.c_str());
<a name="l00571"></a>00571             <span class="keywordflow">continue</span>;
<a name="l00572"></a>00572         }
<a name="l00573"></a>00573 
<a name="l00574"></a>00574         log_debug(<span class="stringliteral">"recompute_routes: adding route for %s to link %s"</span>,
<a name="l00575"></a>00575                   dest_eid.c_str(), link-&gt;name());
<a name="l00576"></a>00576 
<a name="l00577"></a>00577         <span class="comment">// XXX/demmer shouldn't this call check_next_hop??</span>
<a name="l00578"></a>00578         <a class="code" href="classdtn_1_1RouteEntry.html" title="Class to represent route table entry.">RouteEntry</a>* e = <span class="keyword">new</span> <a class="code" href="classdtn_1_1RouteEntry.html" title="Class to represent route table entry.">RouteEntry</a>(dest_eid, link);
<a name="l00579"></a>00579         e-&gt;set_info(<span class="keyword">new</span> <a class="code" href="structdtn_1_1DTLSRRouter_1_1RouteInfo.html" title="Class used for router-specific state in the routing table.">RouteInfo</a>(edge));
<a name="l00580"></a>00580         <a class="code" href="classdtn_1_1TableBasedRouter.html#83939b60c495ff450a1e95787c811297" title="The routing table.">route_table_</a>-&gt;<a class="code" href="classdtn_1_1RouteTable.html#f4563da3a4e78c4784a72e790a831469" title="Add a route entry.">add_entry</a>(e);
<a name="l00581"></a>00581     }
<a name="l00582"></a>00582 
<a name="l00583"></a>00583     <span class="comment">// go through all bundles and re-route them</span>
<a name="l00584"></a>00584     <a class="code" href="classdtn_1_1TableBasedRouter.html#d5d66b2ef80180677d4cf5093bcaf009" title="Update forwarding state due to changed routes.">handle_changed_routes</a>();
<a name="l00585"></a>00585 }
<a name="l00586"></a>00586 
<a name="l00587"></a>00587 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00588"></a><a class="code" href="classdtn_1_1DTLSRRouter_1_1Reg.html#fe1dfb90b1c5e3020e2af5c3fa870ea3">00588</a> <a class="code" href="classdtn_1_1DTLSRRouter_1_1Reg.html#fe1dfb90b1c5e3020e2af5c3fa870ea3">DTLSRRouter::Reg::Reg</a>(<a class="code" href="classdtn_1_1DTLSRRouter.html" title="The DTLSRRouter uses link state announcements to build a multigraph of routing edges...">DTLSRRouter</a>* router,
<a name="l00589"></a>00589                       <span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a>&amp; eid)
<a name="l00590"></a>00590     : <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>(DTLSR_REGID, eid, <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>::DEFER,
<a name="l00591"></a>00591                    <span class="comment">/* XXX/demmer session_flags */</span> 0, 0),
<a name="l00592"></a>00592                    
<a name="l00593"></a>00593       router_(router)
<a name="l00594"></a>00594 {
<a name="l00595"></a>00595     logpathf(<span class="stringliteral">"%s/reg"</span>, router-&gt;logpath()),
<a name="l00596"></a>00596     <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_1RegistrationAddedEvent.html" title="Event class for new registration arrivals.">RegistrationAddedEvent</a>(<span class="keyword">this</span>, <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b04a9578f3e2276d81cd632222ceb4e2e" title="the admin logic">EVENTSRC_ADMIN</a>));
<a name="l00597"></a>00597 }
<a name="l00598"></a>00598 
<a name="l00599"></a>00599 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00600"></a>00600 <span class="keywordtype">void</span>
<a name="l00601"></a><a class="code" href="classdtn_1_1DTLSRRouter_1_1Reg.html#281486350ce4658f52d821e8ef8e2d0d">00601</a> <a class="code" href="classdtn_1_1DTLSRRouter_1_1Reg.html#281486350ce4658f52d821e8ef8e2d0d" title="Abstract hook for subclasses to deliver a bundle to this registration.">DTLSRRouter::Reg::deliver_bundle</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle)
<a name="l00602"></a>00602 {
<a name="l00603"></a>00603     <span class="comment">// XXX/demmer yuck</span>
<a name="l00604"></a>00604     <span class="keywordflow">if</span> (bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>() == BundleDaemon::instance()-&gt;local_eid()) {
<a name="l00605"></a>00605         log_info(<span class="stringliteral">"ignoring bundle sent by self"</span>);
<a name="l00606"></a>00606         <span class="keywordflow">return</span>;
<a name="l00607"></a>00607     }
<a name="l00608"></a>00608 
<a name="l00609"></a>00609     u_char type;
<a name="l00610"></a>00610     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#3bc0b88b547620b4029eba4809a73447" title="Accessors.">payload</a>().<a class="code" href="classdtn_1_1BundlePayload.html#c4ce25f2d2d7ad54a9306ea2599731b4" title="Copy out a chunk of payload data into the supplied buffer.">read_data</a>(0, 1, &amp;type);
<a name="l00611"></a>00611 
<a name="l00612"></a>00612     <span class="keywordflow">if</span> (type == <a class="code" href="classdtn_1_1DTLSR.html#d0a6df53eaef2a9ef1d3576e3ac0005cbed7dff6b128f3fa540411dfa25d6ec5">DTLSR::MSG_LSA</a>) {
<a name="l00613"></a>00613         log_info(<span class="stringliteral">"got LSA bundle *%p"</span>,bundle);
<a name="l00614"></a>00614         
<a name="l00615"></a>00615         <a class="code" href="classdtn_1_1DTLSR_1_1LSA.html" title="The LSA that&amp;#39;s sent over the network.">LSA</a> lsa;
<a name="l00616"></a>00616         <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1DTLSR.html#09838e294dee8194df4ee5069c91584a" title="Parse an LSA bundle.">DTLSR::parse_lsa_bundle</a>(bundle, &amp;lsa)) {
<a name="l00617"></a>00617             log_warn(<span class="stringliteral">"error parsing LSA"</span>);
<a name="l00618"></a>00618             <span class="keywordflow">goto</span> bail;
<a name="l00619"></a>00619         }
<a name="l00620"></a>00620         
<a name="l00621"></a>00621         <a class="code" href="classdtn_1_1DTLSRRouter_1_1Reg.html#c2a8eddf522444bc1cb229fb7779caeb">router_</a>-&gt;<a class="code" href="classdtn_1_1DTLSRRouter.html#b3092487e5d5f434b589caa0e24811b9" title="Helper functions.">handle_lsa</a>(bundle, &amp;lsa);
<a name="l00622"></a>00622     } <span class="keywordflow">else</span> {
<a name="l00623"></a>00623         log_err(<span class="stringliteral">"unknown message type %d"</span>, type);
<a name="l00624"></a>00624     }
<a name="l00625"></a>00625 
<a name="l00626"></a>00626 bail:
<a name="l00627"></a>00627     <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_1BundleDeliveredEvent.html" title="Event class for local bundle delivery.">BundleDeliveredEvent</a>(bundle, <span class="keyword">this</span>));
<a name="l00628"></a>00628 }
<a name="l00629"></a>00629 
<a name="l00630"></a>00630 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00631"></a>00631 <span class="keywordtype">bool</span>
<a name="l00632"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#09b94b657d9dd30d07804f8336992d06">00632</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#09b94b657d9dd30d07804f8336992d06" title="Helper functions.">DTLSRRouter::update_current_lsa</a>(<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html" title="The node class.">RoutingGraph::Node</a>* node,
<a name="l00633"></a>00633                                 <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, u_int32_t seqno)
<a name="l00634"></a>00634 {
<a name="l00635"></a>00635     <span class="keywordtype">bool</span> found_stale_lsa = <span class="keyword">false</span>;
<a name="l00636"></a>00636     <span class="keywordflow">if</span> (seqno &lt;= node-&gt;<a class="code" href="dtncat_8c.html#71f51a2e8cbe9a53031fa72596edc09f">info</a>().last_lsa_seqno_ &amp;&amp;
<a name="l00637"></a>00637         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> &lt; node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#96c7bd3d7f08a00f695b76d210890f37">info</a>().last_lsa_creation_ts_)
<a name="l00638"></a>00638     {
<a name="l00639"></a>00639         log_info(<span class="stringliteral">"update_current_lsa: "</span>
<a name="l00640"></a>00640                  <span class="stringliteral">"ignoring stale LSA (seqno %u &lt;= last %u, "</span>
<a name="l00641"></a>00641                  <span class="stringliteral">"creation_ts %u &lt;= last %u)"</span>,
<a name="l00642"></a>00642                  seqno, node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#96c7bd3d7f08a00f695b76d210890f37">info</a>().last_lsa_seqno_,
<a name="l00643"></a>00643                  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="l00644"></a>00644                  node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#96c7bd3d7f08a00f695b76d210890f37">info</a>().last_lsa_creation_ts_);
<a name="l00645"></a>00645 
<a name="l00646"></a>00646         <span class="comment">// suppress forwarding of the stale LSA</span>
<a name="l00647"></a>00647         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>(<a class="code" href="classdtn_1_1EndpointIDPattern.html#9f872c8e701944c46b8989257d3188f2" title="Return the special wildcard Endpoint ID.">EndpointIDPattern::WILDCARD_EID</a>(),
<a name="l00648"></a>00648                                     <a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b59471efad47dbf6015f5e4458ac355eabbaa" title="Forward the bundle to only this next hop.">ForwardingInfo::FORWARD_ACTION</a>,
<a name="l00649"></a>00649                                     <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad7e404e025c65c3b35345a69533ce48a1" title="Transmission suppressed.">ForwardingInfo::SUPPRESSED</a>);
<a name="l00650"></a>00650         
<a name="l00651"></a>00651         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00652"></a>00652     }
<a name="l00653"></a>00653     <span class="keywordflow">else</span>
<a name="l00654"></a>00654     {
<a name="l00655"></a>00655         log_info(<span class="stringliteral">"update_current_lsa: "</span>
<a name="l00656"></a>00656                  <span class="stringliteral">"got new LSA (seqno %u &gt; last %u || "</span>
<a name="l00657"></a>00657                  <span class="stringliteral">"creation_ts %u &gt; last %u)"</span>,
<a name="l00658"></a>00658                  seqno, node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#96c7bd3d7f08a00f695b76d210890f37">info</a>().last_lsa_seqno_,
<a name="l00659"></a>00659                  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="l00660"></a>00660                  node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#96c7bd3d7f08a00f695b76d210890f37">info</a>().last_lsa_creation_ts_);
<a name="l00661"></a>00661     }
<a name="l00662"></a>00662 
<a name="l00663"></a>00663     oasys::ScopeLock l(<a class="code" href="classdtn_1_1DTLSRRouter.html#9a17528fb94f4bd8abcee4ce5280c444" title="Bundle lists used to hold onto the most recent LSA from all other nodes.">current_lsas_</a>.<a class="code" href="classdtn_1_1BundleList.html#0d0c9f789f0f7f7d1cda3b4ecf32d2bc" title="Return the internal lock on this list.">lock</a>(),
<a name="l00664"></a>00664                        <span class="stringliteral">"DTLSRRouter::update_current_lsa"</span>);
<a name="l00665"></a>00665     <span class="keywordflow">for</span> (<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 class="code" href="classdtn_1_1DTLSRRouter.html#9a17528fb94f4bd8abcee4ce5280c444" title="Bundle lists used to hold onto the most recent LSA from all other nodes.">current_lsas_</a>.<a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf" title="Iterator used to iterate through the list.">begin</a>();
<a name="l00666"></a>00666          iter != <a class="code" href="classdtn_1_1DTLSRRouter.html#9a17528fb94f4bd8abcee4ce5280c444" title="Bundle lists used to hold onto the most recent LSA from all other nodes.">current_lsas_</a>.<a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1" title="Iterator used to mark the end of the list.">end</a>(); ++iter)
<a name="l00667"></a>00667     {
<a name="l00668"></a>00668         <span class="keywordflow">if</span> ((*iter)-&gt;source() == node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#5e8016f9c2e46fe81258cc4c3eb597ee">id</a>()) {
<a name="l00669"></a>00669             <span class="comment">// be careful not to let the bundle reference count drop</span>
<a name="l00670"></a>00670             <span class="comment">// to zero by keeping a local reference until we can make</span>
<a name="l00671"></a>00671             <span class="comment">// sure it's at least in the NotNeededEvent</span>
<a name="l00672"></a>00672             <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> stale_lsa(<span class="stringliteral">"DTLSRRouter::update_current_lsa"</span>);
<a name="l00673"></a>00673             stale_lsa = *iter;
<a name="l00674"></a>00674 
<a name="l00675"></a>00675             <a class="code" href="classdtn_1_1DTLSRRouter.html#9a17528fb94f4bd8abcee4ce5280c444" title="Bundle lists used to hold onto the most recent LSA from all other nodes.">current_lsas_</a>.<a class="code" href="classdtn_1_1BundleList.html#b0171458e14d67307b74f98447062d68" title="Remove the given bundle from the list.">erase</a>(iter);
<a name="l00676"></a>00676 
<a name="l00677"></a>00677             log_debug(<span class="stringliteral">"cancelling pending transmissions for *%p"</span>,
<a name="l00678"></a>00678                       stale_lsa.object());
<a name="l00679"></a>00679 
<a name="l00680"></a>00680             stale_lsa-&gt;fwdlog()-&gt;add_entry(<a class="code" href="classdtn_1_1EndpointIDPattern.html#9f872c8e701944c46b8989257d3188f2" title="Return the special wildcard Endpoint ID.">EndpointIDPattern::WILDCARD_EID</a>(),
<a name="l00681"></a>00681                                            <a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b59471efad47dbf6015f5e4458ac355eabbaa" title="Forward the bundle to only this next hop.">ForwardingInfo::FORWARD_ACTION</a>,
<a name="l00682"></a>00682                                            <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad7e404e025c65c3b35345a69533ce48a1" title="Transmission suppressed.">ForwardingInfo::SUPPRESSED</a>);
<a name="l00683"></a>00683             
<a name="l00684"></a>00684             <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 name="l00685"></a>00685                 <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleDeleteRequest.html" title="Event class for requestion deletion of a bundle.">BundleDeleteRequest</a>(stale_lsa.object(),
<a name="l00686"></a>00686                                         <a class="code" href="classdtn_1_1BundleProtocol.html#37b000d94172c06970bb8af32889f917eac137290a0338e66ed4a0c1cc09c2f2">BundleProtocol::REASON_NO_ADDTL_INFO</a>));
<a name="l00687"></a>00687             found_stale_lsa = <span class="keyword">true</span>;
<a name="l00688"></a>00688             
<a name="l00689"></a>00689 <span class="comment">//             oasys::StringBuffer buf("Stale LSA: ");</span>
<a name="l00690"></a>00690 <span class="comment">//             bundle-&gt;format_verbose(&amp;buf);</span>
<a name="l00691"></a>00691 <span class="comment">//             log_multiline(oasys::LOG_INFO, buf.c_str());</span>
<a name="l00692"></a>00692             
<a name="l00693"></a>00693             <span class="keywordflow">if</span> (node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#96c7bd3d7f08a00f695b76d210890f37">info</a>().last_lsa_seqno_ == 0) {
<a name="l00694"></a>00694                 NOTREACHED;
<a name="l00695"></a>00695             }
<a name="l00696"></a>00696             <span class="keywordflow">break</span>;
<a name="l00697"></a>00697         }
<a name="l00698"></a>00698     }
<a name="l00699"></a>00699 
<a name="l00700"></a>00700     <span class="keywordflow">if</span> (node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#96c7bd3d7f08a00f695b76d210890f37">info</a>().last_lsa_seqno_ == 0) {
<a name="l00701"></a>00701         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!found_stale_lsa);
<a name="l00702"></a>00702         log_info(<span class="stringliteral">"update_current_lsa: "</span>
<a name="l00703"></a>00703                  <span class="stringliteral">"first LSA from %s (seqno %u)"</span>,
<a name="l00704"></a>00704                  node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#5e8016f9c2e46fe81258cc4c3eb597ee">id</a>().c_str(), seqno);
<a name="l00705"></a>00705     } <span class="keywordflow">else</span> {
<a name="l00706"></a>00706         log_info(<span class="stringliteral">"update_current_lsa: "</span>
<a name="l00707"></a>00707                  <span class="stringliteral">"replaced %s LSA from %s (seqno %u) with latest (%u)"</span>,
<a name="l00708"></a>00708                  found_stale_lsa ? <span class="stringliteral">"stale"</span> : <span class="stringliteral">"expired"</span>,
<a name="l00709"></a>00709                  node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#5e8016f9c2e46fe81258cc4c3eb597ee">id</a>().c_str(), node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#96c7bd3d7f08a00f695b76d210890f37">info</a>().last_lsa_seqno_, seqno);
<a name="l00710"></a>00710     }
<a name="l00711"></a>00711 
<a name="l00712"></a>00712     node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#3316aa822c760f05026daac68753a838">mutable_info</a>().last_lsa_seqno_ = seqno;
<a name="l00713"></a>00713     node-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#3316aa822c760f05026daac68753a838">mutable_info</a>().last_lsa_creation_ts_ = 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="l00714"></a>00714     <a class="code" href="classdtn_1_1DTLSRRouter.html#9a17528fb94f4bd8abcee4ce5280c444" title="Bundle lists used to hold onto the most recent LSA from all other nodes.">current_lsas_</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="l00715"></a>00715     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00716"></a>00716 }
<a name="l00717"></a>00717 
<a name="l00718"></a>00718 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00719"></a>00719 <span class="keywordtype">void</span>
<a name="l00720"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#b3092487e5d5f434b589caa0e24811b9">00720</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#b3092487e5d5f434b589caa0e24811b9" title="Helper functions.">DTLSRRouter::handle_lsa</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <a class="code" href="classdtn_1_1DTLSR_1_1LSA.html" title="The LSA that&amp;#39;s sent over the network.">LSA</a>* lsa)
<a name="l00721"></a>00721 {
<a name="l00722"></a>00722     <span class="comment">// First check the LSA bundle destination to see if the sender is</span>
<a name="l00723"></a>00723     <span class="comment">// in a different area</span>
<a name="l00724"></a>00724     std::string lsa_area = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#b33fc19cda5561ca189e2051d6561db7">uri</a>().query_value(<span class="stringliteral">"area"</span>);
<a name="l00725"></a>00725     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;area_ != lsa_area) {
<a name="l00726"></a>00726         log_debug(<span class="stringliteral">"handle_lsa: ignoring LSA since area %s != local area %s"</span>,
<a name="l00727"></a>00727                   lsa_area.c_str(), <a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;<a class="code" href="classdtn_1_1DTLSRConfig.html#07882047fee03e6bdbc9e65ba36e059e" title="Administratively assigned area.">area_</a>.c_str());
<a name="l00728"></a>00728 
<a name="l00729"></a>00729         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>(<a class="code" href="classdtn_1_1EndpointIDPattern.html#9f872c8e701944c46b8989257d3188f2" title="Return the special wildcard Endpoint ID.">EndpointIDPattern::WILDCARD_EID</a>(),
<a name="l00730"></a>00730                                     <a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b59471efad47dbf6015f5e4458ac355eabbaa" title="Forward the bundle to only this next hop.">ForwardingInfo::FORWARD_ACTION</a>,
<a name="l00731"></a>00731                                     <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad7e404e025c65c3b35345a69533ce48a1" title="Transmission suppressed.">ForwardingInfo::SUPPRESSED</a>);
<a name="l00732"></a>00732         <span class="keywordflow">return</span>;
<a name="l00733"></a>00733     }
<a name="l00734"></a>00734     
<a name="l00735"></a>00735     <span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a>&amp; source = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>();
<a name="l00736"></a>00736     
<a name="l00737"></a>00737     <a class="code" href="classdtn_1_1MultiGraph_1_1Node.html" title="The node class.">RoutingGraph::Node</a>* a = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#a9a0d61ec5663bc8954b0db5969b68f4" title="Find a node with the given id.">find_node</a>(source.<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>());
<a name="l00738"></a>00738     <span class="keywordflow">if</span> (a == NULL) {
<a name="l00739"></a>00739         log_debug(<span class="stringliteral">"handle_lsa: adding new source node %s"</span>,
<a name="l00740"></a>00740                   source.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00741"></a>00741         a = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#c250f8c8d1b8970870067c6e73058ee9" title="Add a new node.">add_node</a>(source.<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>(), <a class="code" href="structdtn_1_1DTLSRRouter_1_1NodeInfo.html" title="Class used for per-node state in the graph.">NodeInfo</a>());
<a name="l00742"></a>00742     }
<a name="l00743"></a>00743 
<a name="l00744"></a>00744     <span class="keywordflow">if</span> (! <a class="code" href="classdtn_1_1DTLSRRouter.html#09b94b657d9dd30d07804f8336992d06" title="Helper functions.">update_current_lsa</a>(a, bundle, lsa-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LSA.html#19f56b2fc67e7d5e08be8437feecf157" title="Strictly increasing sequence number for this source.">seqno_</a>)) {
<a name="l00745"></a>00745         <span class="keywordflow">return</span>; <span class="comment">// stale lsa</span>
<a name="l00746"></a>00746     }
<a name="l00747"></a>00747 
<a name="l00748"></a>00748     <span class="comment">// don't send the LSA back where we got it from</span>
<a name="l00749"></a>00749     <a class="code" href="classdtn_1_1ForwardingInfo.html" title="Class to encapsulate bundle forwarding information.">ForwardingInfo</a> <a class="code" href="dtncat_8c.html#71f51a2e8cbe9a53031fa72596edc09f">info</a>;
<a name="l00750"></a>00750     <span class="keywordflow">if</span> (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>(<a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad94bcd632696a41842e2e5871933a8a66" title="Where the bundle came from.">ForwardingInfo::RECEIVED</a>, &amp;info))
<a name="l00751"></a>00751     {
<a name="l00752"></a>00752         log_debug(<span class="stringliteral">"handle_lsa: suppressing transmission back to %s"</span>,
<a name="l00753"></a>00753                   info.<a class="code" href="classdtn_1_1ForwardingInfo.html#3045bac79c0f4727c7d246c7a6409b51" title="Accessors.">remote_eid</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00754"></a>00754         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>(info.<a class="code" href="classdtn_1_1ForwardingInfo.html#3045bac79c0f4727c7d246c7a6409b51" title="Accessors.">remote_eid</a>(),
<a name="l00755"></a>00755                                     <a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b59471efad47dbf6015f5e4458ac355eabbaa" title="Forward the bundle to only this next hop.">ForwardingInfo::FORWARD_ACTION</a>,
<a name="l00756"></a>00756                                     <a class="code" href="classdtn_1_1ForwardingInfo.html#acf01ca8a774e80f6f7bf56c2b099fad7e404e025c65c3b35345a69533ce48a1" title="Transmission suppressed.">ForwardingInfo::SUPPRESSED</a>);
<a name="l00757"></a>00757     }
<a name="l00758"></a>00758     
<a name="l00759"></a>00759     <span class="comment">// XXX/demmer here we should drop all the links that aren't</span>
<a name="l00760"></a>00760     <span class="comment">// present in the LSA...</span>
<a name="l00761"></a>00761 
<a name="l00762"></a>00762     <span class="comment">// Handle all the link announcements</span>
<a name="l00763"></a>00763     <span class="keywordflow">for</span> (LinkStateVec::iterator iter = lsa-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LSA.html#364545c39a3a6757326788cf08c70b8d" title="Vector of link states.">links_</a>.begin();
<a name="l00764"></a>00764          iter != lsa-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LSA.html#364545c39a3a6757326788cf08c70b8d" title="Vector of link states.">links_</a>.end(); ++iter)
<a name="l00765"></a>00765     {
<a name="l00766"></a>00766         <a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html" title="Structure used in LSAs for link state announcement.">LinkState</a>* ls = &amp;(*iter);
<a name="l00767"></a>00767 
<a name="l00768"></a>00768         <span class="comment">// check for the case where we're re-receiving an LSA that was</span>
<a name="l00769"></a>00769         <span class="comment">// sent previously, but our link configuration has changed so</span>
<a name="l00770"></a>00770         <span class="comment">// we no longer have the link</span>
<a name="l00771"></a>00771         <span class="keywordflow">if</span> (a == <a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>) {
<a name="l00772"></a>00772             <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link(<span class="stringliteral">"DTLSRRouter::handle_lsa"</span>);
<a name="l00773"></a>00773             link = BundleDaemon::instance()-&gt;contactmgr()-&gt;
<a name="l00774"></a>00774                    find_link(ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#9d67cd93d0399fdd5423ca0408e08a12" title="Link name.">id_</a>.c_str());
<a name="l00775"></a>00775             <span class="keywordflow">if</span> (link == NULL) {
<a name="l00776"></a>00776                 log_warn(<span class="stringliteral">"local link %s in LSA but no longer exists, ignoring..."</span>,
<a name="l00777"></a>00777                          ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#9d67cd93d0399fdd5423ca0408e08a12" title="Link name.">id_</a>.c_str());
<a name="l00778"></a>00778                 <span class="keywordflow">continue</span>;
<a name="l00779"></a>00779             }
<a name="l00780"></a>00780         }
<a name="l00781"></a>00781 
<a name="l00782"></a>00782         <span class="comment">// find or add the node</span>
<a name="l00783"></a>00783         <a class="code" href="classdtn_1_1MultiGraph_1_1Node.html" title="The node class.">RoutingGraph::Node</a>* b = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#a9a0d61ec5663bc8954b0db5969b68f4" title="Find a node with the given id.">find_node</a>(ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#36adc23dc208ebfa1ae131ead61bcc89" title="Destination node.">dest_</a>.<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>());
<a name="l00784"></a>00784         <span class="keywordflow">if</span> (!b) {
<a name="l00785"></a>00785             log_debug(<span class="stringliteral">"handle_lsa: %s adding new dest node %s"</span>,
<a name="l00786"></a>00786                       source.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(), ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#36adc23dc208ebfa1ae131ead61bcc89" title="Destination node.">dest_</a>.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00787"></a>00787             b = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#c250f8c8d1b8970870067c6e73058ee9" title="Add a new node.">add_node</a>(ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#36adc23dc208ebfa1ae131ead61bcc89" title="Destination node.">dest_</a>.<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>(), <a class="code" href="structdtn_1_1DTLSRRouter_1_1NodeInfo.html" title="Class used for per-node state in the graph.">NodeInfo</a>());
<a name="l00788"></a>00788         }
<a name="l00789"></a>00789 
<a name="l00790"></a>00790         <span class="comment">// try to find and update the edge in the graph, otherwise add it</span>
<a name="l00791"></a>00791         <a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html" title="The edge class.">RoutingGraph::Edge</a> *e = NULL;
<a name="l00792"></a>00792         RoutingGraph::EdgeVector::const_iterator ei;
<a name="l00793"></a>00793         <span class="keywordflow">for</span> (ei = a-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#f17f73294b7a81c08f78398f3088bac4">out_edges</a>().begin(); ei != a-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#f17f73294b7a81c08f78398f3088bac4">out_edges</a>().end(); ++ei) {
<a name="l00794"></a>00794             <span class="keywordflow">if</span> ((*ei)-&gt;info().id_ == ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#9d67cd93d0399fdd5423ca0408e08a12" title="Link name.">id_</a>) {
<a name="l00795"></a>00795                 e = *ei;
<a name="l00796"></a>00796                 <span class="keywordflow">break</span>;
<a name="l00797"></a>00797             }
<a name="l00798"></a>00798         }
<a name="l00799"></a>00799 
<a name="l00800"></a>00800         <span class="keywordflow">if</span> (e == NULL) {
<a name="l00801"></a>00801             e = <a class="code" href="classdtn_1_1DTLSRRouter.html#3a1ca3cc5c476ac85ce6d9b4fec5c5e9" title="Routing Graph info.">graph_</a>.<a class="code" href="classdtn_1_1MultiGraph.html#059a319c2a8018b46b292b3dbc01ce8a" title="Add an edge.">add_edge</a>(a, b, <a class="code" href="structdtn_1_1DTLSRRouter_1_1EdgeInfo.html" title="Class used for per-edge state in the graph (the link).">EdgeInfo</a>(ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#9d67cd93d0399fdd5423ca0408e08a12" title="Link name.">id_</a>, ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#dedf27793dde79806fcd87a09797525e" title="Parameters of the link.">params_</a>));
<a name="l00802"></a>00802             
<a name="l00803"></a>00803             log_debug(<span class="stringliteral">"handle_lsa: added new edge %s from %s -&gt; %s"</span>,
<a name="l00804"></a>00804                       oasys::InlineFormatter&lt;EdgeInfo&gt;().format(e-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>()),
<a name="l00805"></a>00805                       a-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#5e8016f9c2e46fe81258cc4c3eb597ee">id</a>().c_str(), b-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#5e8016f9c2e46fe81258cc4c3eb597ee">id</a>().c_str());
<a name="l00806"></a>00806         } <span class="keywordflow">else</span> {
<a name="l00807"></a>00807             e-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#9919f41c989d9e9bfe28dbf26a3dd81e">mutable_info</a>().params_ = ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#dedf27793dde79806fcd87a09797525e" title="Parameters of the link.">params_</a>;
<a name="l00808"></a>00808             
<a name="l00809"></a>00809             log_debug(<span class="stringliteral">"handle_lsa: updated edge %s from %s -&gt; %s"</span>,
<a name="l00810"></a>00810                       oasys::InlineFormatter&lt;EdgeInfo&gt;().format(e-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>()),
<a name="l00811"></a>00811                       a-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#5e8016f9c2e46fe81258cc4c3eb597ee">id</a>().c_str(), b-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#5e8016f9c2e46fe81258cc4c3eb597ee">id</a>().c_str());
<a name="l00812"></a>00812         }
<a name="l00813"></a>00813 
<a name="l00814"></a>00814         <span class="comment">// XXX/demmer fold this into a parameter update method</span>
<a name="l00815"></a>00815         e-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#9919f41c989d9e9bfe28dbf26a3dd81e">mutable_info</a>().last_update_.get_time();
<a name="l00816"></a>00816     }
<a name="l00817"></a>00817 
<a name="l00818"></a>00818     <a class="code" href="classdtn_1_1DTLSRRouter.html#526947e56ad2813e93b07ba2c4ce1aca" title="Helper functions.">recompute_routes</a>();
<a name="l00819"></a>00819 }
<a name="l00820"></a>00820 
<a name="l00821"></a>00821 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00822"></a>00822 <span class="keywordtype">void</span>
<a name="l00823"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#33ff8b18e340274d8dea045215467067">00823</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#33ff8b18e340274d8dea045215467067" title="Helper functions.">DTLSRRouter::handle_lsa_expired</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle)
<a name="l00824"></a>00824 {
<a name="l00825"></a>00825     <span class="comment">// XXX/demmer this is bogus -- we don't want to drop all routes</span>
<a name="l00826"></a>00826     <span class="comment">// just b/c we lost an LSA in all cases, only when we're using the</span>
<a name="l00827"></a>00827     <span class="comment">// long-lived LSA bundles</span>
<a name="l00828"></a>00828     (void)bundle;
<a name="l00829"></a>00829     
<a name="l00830"></a>00830     <span class="comment">/*</span>
<a name="l00831"></a>00831 <span class="comment">    const EndpointID&amp; source = bundle-&gt;source_;</span>
<a name="l00832"></a>00832 <span class="comment">    </span>
<a name="l00833"></a>00833 <span class="comment">    RoutingGraph::Node* a = graph_.find_node(source.str());</span>
<a name="l00834"></a>00834 <span class="comment">    ASSERT(a != NULL);</span>
<a name="l00835"></a>00835 <span class="comment"></span>
<a name="l00836"></a>00836 <span class="comment">    RoutingGraph::EdgeVector::const_iterator ei;</span>
<a name="l00837"></a>00837 <span class="comment">    for (ei = a-&gt;out_edges().begin(); ei != a-&gt;out_edges().end(); ++ei) {</span>
<a name="l00838"></a>00838 <span class="comment">        (*ei)-&gt;mutable_info().params_.state_ = LinkParams::LINK_DOWN;</span>
<a name="l00839"></a>00839 <span class="comment">    }</span>
<a name="l00840"></a>00840 <span class="comment"></span>
<a name="l00841"></a>00841 <span class="comment">    recompute_routes();</span>
<a name="l00842"></a>00842 <span class="comment">    */</span>
<a name="l00843"></a>00843 }
<a name="l00844"></a>00844 
<a name="l00845"></a>00845 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00846"></a>00846 <span class="keywordtype">void</span>
<a name="l00847"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#746a82f9618b70aba0d88e974575cff9">00847</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#746a82f9618b70aba0d88e974575cff9" title="Helper functions.">DTLSRRouter::generate_link_state</a>(<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html" title="Structure used in LSAs for link state announcement.">LinkState</a>* ls,
<a name="l00848"></a>00848                                  <a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html" title="The edge class.">RoutingGraph::Edge</a>* edge,
<a name="l00849"></a>00849                                  <span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link)
<a name="l00850"></a>00850 {
<a name="l00851"></a>00851     ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#36adc23dc208ebfa1ae131ead61bcc89" title="Destination node.">dest_</a>.<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#2ee41e994c997f93e43a62cb97e48b4a">dest</a>()-&gt;id());
<a name="l00852"></a>00852     ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#9d67cd93d0399fdd5423ca0408e08a12" title="Link name.">id_</a>.assign(edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().id_);
<a name="l00853"></a>00853     ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#dedf27793dde79806fcd87a09797525e" title="Parameters of the link.">params_</a> = edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().params_;
<a name="l00854"></a>00854 
<a name="l00855"></a>00855     <span class="comment">// XXX/demmer maybe the edge info should be tied to the link</span>
<a name="l00856"></a>00856     <span class="comment">// itself somehow?</span>
<a name="l00857"></a>00857     <span class="keywordflow">if</span> (link != NULL) {
<a name="l00858"></a>00858         ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#dedf27793dde79806fcd87a09797525e" title="Parameters of the link.">params_</a>.<a class="code" href="classdtn_1_1DTLSR_1_1LinkParams.html#469b77434631d6b148ad34fc28318785" title="number of bundles in queue">qcount_</a> = link-&gt;bundles_queued();
<a name="l00859"></a>00859         ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#dedf27793dde79806fcd87a09797525e" title="Parameters of the link.">params_</a>.<a class="code" href="classdtn_1_1DTLSR_1_1LinkParams.html#56d1db5d5b0a41362aab90f3d2f1a9c3" title="total size of bundles in queue">qsize_</a>  = link-&gt;bytes_queued();
<a name="l00860"></a>00860     }
<a name="l00861"></a>00861     
<a name="l00862"></a>00862     <span class="keywordflow">if</span> (edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().last_update_.sec_ != 0) {
<a name="l00863"></a>00863         ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#648a377d6e71b9efd15c3141e3308344" title="Time since last state change for this link.">elapsed_</a> = edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#a4b05c6e17d0b34e1b129c40c48ec094">info</a>().last_update_.elapsed_ms();
<a name="l00864"></a>00864     } <span class="keywordflow">else</span> {
<a name="l00865"></a>00865         ls-&gt;<a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html#648a377d6e71b9efd15c3141e3308344" title="Time since last state change for this link.">elapsed_</a> = 0;
<a name="l00866"></a>00866     }
<a name="l00867"></a>00867     edge-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Edge.html#9919f41c989d9e9bfe28dbf26a3dd81e">mutable_info</a>().last_update_.get_time();
<a name="l00868"></a>00868 }
<a name="l00869"></a>00869 
<a name="l00870"></a>00870 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00871"></a>00871 <span class="keywordtype">void</span>
<a name="l00872"></a><a class="code" href="classdtn_1_1DTLSRRouter_1_1TransmitLSATimer.html#21fa242a82472c12195c27ea885ae113">00872</a> <a class="code" href="classdtn_1_1DTLSRRouter_1_1TransmitLSATimer.html#21fa242a82472c12195c27ea885ae113">DTLSRRouter::TransmitLSATimer::timeout</a>(<span class="keyword">const</span> <span class="keyword">struct</span> timeval&amp; now)
<a name="l00873"></a>00873 {
<a name="l00874"></a>00874     (void)now;
<a name="l00875"></a>00875     <a class="code" href="classdtn_1_1DTLSRRouter_1_1TransmitLSATimer.html#70d61d09b668184b8e211e8dbc97e1b8">router_</a>-&gt;<a class="code" href="classdtn_1_1DTLSRRouter.html#5b01fe9ba677217ff8a385e656d8f8d2" title="Helper functions.">send_lsa</a>();
<a name="l00876"></a>00876     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1DTLSRRouter_1_1TransmitLSATimer.html#3fdf526430fef4653e60fab4cb923c33">interval_</a> != 0) {
<a name="l00877"></a>00877         schedule_in(<a class="code" href="classdtn_1_1DTLSRRouter_1_1TransmitLSATimer.html#3fdf526430fef4653e60fab4cb923c33">interval_</a>);
<a name="l00878"></a>00878     }
<a name="l00879"></a>00879 }
<a name="l00880"></a>00880 
<a name="l00881"></a>00881 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00882"></a>00882 <span class="keywordtype">void</span>
<a name="l00883"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#0e900cf00e2cf4715ef54f18406eeef6">00883</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#0e900cf00e2cf4715ef54f18406eeef6" title="Helper functions.">DTLSRRouter::schedule_lsa</a>()
<a name="l00884"></a>00884 {
<a name="l00885"></a>00885     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1DTLSRRouter.html#0ff98fd13b27500e7f52cf50c5a78228" title="Timer used for a deferred LSA transmission, waiting for the minimum interval.">delayed_lsa_timer_</a>.pending()) {
<a name="l00886"></a>00886         log_debug(<span class="stringliteral">"schedule_lsa: delayed LSA transmission already pending"</span>);
<a name="l00887"></a>00887         <span class="keywordflow">return</span>;
<a name="l00888"></a>00888     }
<a name="l00889"></a>00889 
<a name="l00890"></a>00890     u_int elapsed = (oasys::Time::now() - <a class="code" href="classdtn_1_1DTLSRRouter.html#89376ebee5c3e0eb134c963047786333" title="Time of the last LSA transmission.">last_lsa_transmit_</a>).sec_;
<a name="l00891"></a>00891     <span class="keywordflow">if</span> (elapsed &gt; <a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;<a class="code" href="classdtn_1_1DTLSRConfig.html#110f499ffb000617c6681ac7b523b417" title="Minimum interval (in seconds) between LSA transmission.">min_lsa_interval_</a>)
<a name="l00892"></a>00892     {
<a name="l00893"></a>00893         log_debug(<span class="stringliteral">"schedule_lsa: %u seconds since last LSA transmission, "</span>
<a name="l00894"></a>00894                   <span class="stringliteral">"sending one immediately"</span>, elapsed);
<a name="l00895"></a>00895         <a class="code" href="classdtn_1_1DTLSRRouter.html#5b01fe9ba677217ff8a385e656d8f8d2" title="Helper functions.">send_lsa</a>();
<a name="l00896"></a>00896     }
<a name="l00897"></a>00897     <span class="keywordflow">else</span>
<a name="l00898"></a>00898     {
<a name="l00899"></a>00899         u_int delay = std::min(<a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;min_lsa_interval_,
<a name="l00900"></a>00900                                <a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;min_lsa_interval_ - elapsed);
<a name="l00901"></a>00901         log_debug(<span class="stringliteral">"schedule_lsa: %u seconds since last LSA transmission, "</span>
<a name="l00902"></a>00902                   <span class="stringliteral">"min interval %u, delaying LSA for %u seconds"</span>,
<a name="l00903"></a>00903                   elapsed, <a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;min_lsa_interval_, delay);
<a name="l00904"></a>00904         <a class="code" href="classdtn_1_1DTLSRRouter.html#0ff98fd13b27500e7f52cf50c5a78228" title="Timer used for a deferred LSA transmission, waiting for the minimum interval.">delayed_lsa_timer_</a>.schedule_in(delay * 1000);
<a name="l00905"></a>00905     }
<a name="l00906"></a>00906 }
<a name="l00907"></a>00907 
<a name="l00908"></a>00908 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00909"></a>00909 <span class="keywordtype">void</span>
<a name="l00910"></a><a class="code" href="classdtn_1_1DTLSRRouter.html#5b01fe9ba677217ff8a385e656d8f8d2">00910</a> <a class="code" href="classdtn_1_1DTLSRRouter.html#5b01fe9ba677217ff8a385e656d8f8d2" title="Helper functions.">DTLSRRouter::send_lsa</a>()
<a name="l00911"></a>00911 {
<a name="l00912"></a>00912     <span class="keywordtype">char</span> tmp[64]; (void)tmp;
<a name="l00913"></a>00913     <a class="code" href="classdtn_1_1DTLSR_1_1LSA.html" title="The LSA that&amp;#39;s sent over the network.">LSA</a> lsa;
<a name="l00914"></a>00914 
<a name="l00915"></a>00915     <span class="comment">// the contents of last_lsa_seqno get updated in the call to</span>
<a name="l00916"></a>00916     <span class="comment">// update_current_lsa below</span>
<a name="l00917"></a>00917     lsa.<a class="code" href="classdtn_1_1DTLSR_1_1LSA.html#19f56b2fc67e7d5e08be8437feecf157" title="Strictly increasing sequence number for this source.">seqno_</a> = <a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#96c7bd3d7f08a00f695b76d210890f37">info</a>().last_lsa_seqno_ + 1;
<a name="l00918"></a>00918     
<a name="l00919"></a>00919     RoutingGraph::EdgeVector::iterator ei;
<a name="l00920"></a>00920     <span class="keywordflow">for</span> (ei = <a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#f17f73294b7a81c08f78398f3088bac4">out_edges</a>().begin();
<a name="l00921"></a>00921          ei != <a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>-&gt;<a class="code" href="classdtn_1_1MultiGraph_1_1Node.html#f17f73294b7a81c08f78398f3088bac4">out_edges</a>().end();
<a name="l00922"></a>00922          ++ei)
<a name="l00923"></a>00923     {
<a name="l00924"></a>00924         <a class="code" href="classdtn_1_1DTLSR_1_1LinkState.html" title="Structure used in LSAs for link state announcement.">LinkState</a> ls;
<a name="l00925"></a>00925         <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link(<span class="stringliteral">"DTLSRRouter::send_lsa"</span>);
<a name="l00926"></a>00926 
<a name="l00927"></a>00927         <span class="comment">// if the edge is a local registration, there's no link, we</span>
<a name="l00928"></a>00928         <span class="comment">// just pretend there's a zero-delay, infinite-bandwidth link</span>
<a name="l00929"></a>00929         <span class="comment">// to the other endpoint</span>
<a name="l00930"></a>00930         <span class="keywordflow">if</span> (! (*ei)-&gt;info().is_registration_) {
<a name="l00931"></a>00931             link = BundleDaemon::instance()-&gt;contactmgr()-&gt;
<a name="l00932"></a>00932                    find_link((*ei)-&gt;info().id_.c_str());
<a name="l00933"></a>00933             <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link != NULL);
<a name="l00934"></a>00934         }
<a name="l00935"></a>00935         
<a name="l00936"></a>00936         <a class="code" href="classdtn_1_1DTLSRRouter.html#746a82f9618b70aba0d88e974575cff9" title="Helper functions.">generate_link_state</a>(&amp;ls, *ei, link);
<a name="l00937"></a>00937         lsa.<a class="code" href="classdtn_1_1DTLSR_1_1LSA.html#364545c39a3a6757326788cf08c70b8d" title="Vector of link states.">links_</a>.push_back(ls);
<a name="l00938"></a>00938     }
<a name="l00939"></a>00939 
<a name="l00940"></a>00940     log_debug(<span class="stringliteral">"send_lsa: generated %zu link states for local node"</span>,
<a name="l00941"></a>00941               lsa.<a class="code" href="classdtn_1_1DTLSR_1_1LSA.html#364545c39a3a6757326788cf08c70b8d" title="Vector of link states.">links_</a>.size());
<a name="l00942"></a>00942 
<a name="l00943"></a>00943     <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_1TempBundle.html" title="Class to represent a temporary bundle -- i.e.">TempBundle</a>();
<a name="l00944"></a>00944 
<a name="l00945"></a>00945     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;area_ != <span class="stringliteral">""</span>) {
<a name="l00946"></a>00946         snprintf(tmp, <span class="keyword">sizeof</span>(tmp), <span class="stringliteral">"dtn://*/%s?area=%s;lsa_seqno=%u"</span>,
<a name="l00947"></a>00947                  <a class="code" href="classdtn_1_1DTLSRRouter.html#b3f0a5fcd3705357b8aaa607d2ebf59e" title="Service tag used for routing announcements.">announce_tag_</a>, <a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;area_.c_str(), lsa.<a class="code" href="classdtn_1_1DTLSR_1_1LSA.html#19f56b2fc67e7d5e08be8437feecf157" title="Strictly increasing sequence number for this source.">seqno_</a>);
<a name="l00948"></a>00948     } <span class="keywordflow">else</span> {
<a name="l00949"></a>00949         snprintf(tmp, <span class="keyword">sizeof</span>(tmp), <span class="stringliteral">"dtn://*/%s?lsa_seqno=%u"</span>,
<a name="l00950"></a>00950                  <a class="code" href="classdtn_1_1DTLSRRouter.html#b3f0a5fcd3705357b8aaa607d2ebf59e" title="Service tag used for routing announcements.">announce_tag_</a>, lsa.<a class="code" href="classdtn_1_1DTLSR_1_1LSA.html#19f56b2fc67e7d5e08be8437feecf157" title="Strictly increasing sequence number for this source.">seqno_</a>);
<a name="l00951"></a>00951     }
<a name="l00952"></a>00952     bundle-&gt;mutable_dest()-&gt;assign(tmp);
<a name="l00953"></a>00953     
<a name="l00954"></a>00954     bundle-&gt;mutable_source()-&gt;assign(BundleDaemon::instance()-&gt;local_eid());
<a name="l00955"></a>00955     bundle-&gt;mutable_replyto()-&gt;assign(<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="l00956"></a>00956     bundle-&gt;mutable_custodian()-&gt;assign(<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="l00957"></a>00957     bundle-&gt;set_expiration(<a class="code" href="classdtn_1_1DTLSRRouter.html#cd46eb0b7cd684542d62d24ac9ab36a7" title="Helper functions.">config</a>()-&gt;lsa_lifetime_);
<a name="l00958"></a>00958     bundle-&gt;set_singleton_dest(<span class="keyword">false</span>);
<a name="l00959"></a>00959     <a class="code" href="classdtn_1_1DTLSR.html#699d051e60ee419630bffd22bdd2a739" title="Format the LSA into the given bundle&amp;#39;s payload.">DTLSR::format_lsa_bundle</a>(bundle, &amp;lsa);
<a name="l00960"></a>00960 
<a name="l00961"></a>00961     <a class="code" href="classdtn_1_1DTLSRRouter.html#09b94b657d9dd30d07804f8336992d06" title="Helper functions.">update_current_lsa</a>(<a class="code" href="classdtn_1_1DTLSRRouter.html#5b758b15441182d85a3b71361e389063">local_node_</a>, bundle, lsa.<a class="code" href="classdtn_1_1DTLSR_1_1LSA.html#19f56b2fc67e7d5e08be8437feecf157" title="Strictly increasing sequence number for this source.">seqno_</a>);
<a name="l00962"></a>00962     
<a name="l00963"></a>00963     log_debug(<span class="stringliteral">"send_lsa: formatted LSA bundle *%p"</span>, bundle);
<a name="l00964"></a>00964 
<a name="l00965"></a>00965     <span class="comment">// XXX/demmer this would really be better done with</span>
<a name="l00966"></a>00966     <span class="comment">// BundleActions::inject_bundle</span>
<a name="l00967"></a>00967     <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_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a>(bundle, <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b25abe58c828214d9857f0fa1249db869" title="the routing logic">EVENTSRC_ROUTER</a>));
<a name="l00968"></a>00968 
<a name="l00969"></a>00969     <a class="code" href="classdtn_1_1DTLSRRouter.html#89376ebee5c3e0eb134c963047786333" title="Time of the last LSA transmission.">last_lsa_transmit_</a>.get_time();
<a name="l00970"></a>00970 }
<a name="l00971"></a>00971 
<a name="l00972"></a>00972 } <span class="comment">// namespace dtn</span>
<a name="l00973"></a>00973 
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Mon Jul 21 14:09:39 2008 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.6 </small></address>
</body>
</html>