Sophie

Sophie

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

libdtn-devel-2.6.0-2mdv2009.1.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>DTN Reference Implementation: Link.cc Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>Link.cc</h1><a href="Link_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> *    Copyright 2004-2006 Intel Corporation</span>
<a name="l00003"></a>00003 <span class="comment"> * </span>
<a name="l00004"></a>00004 <span class="comment"> *    Licensed under the Apache License, Version 2.0 (the "License");</span>
<a name="l00005"></a>00005 <span class="comment"> *    you may not use this file except in compliance with the License.</span>
<a name="l00006"></a>00006 <span class="comment"> *    You may obtain a copy of the License at</span>
<a name="l00007"></a>00007 <span class="comment"> * </span>
<a name="l00008"></a>00008 <span class="comment"> *        http://www.apache.org/licenses/LICENSE-2.0</span>
<a name="l00009"></a>00009 <span class="comment"> * </span>
<a name="l00010"></a>00010 <span class="comment"> *    Unless required by applicable law or agreed to in writing, software</span>
<a name="l00011"></a>00011 <span class="comment"> *    distributed under the License is distributed on an "AS IS" BASIS,</span>
<a name="l00012"></a>00012 <span class="comment"> *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<a name="l00013"></a>00013 <span class="comment"> *    See the License for the specific language governing permissions and</span>
<a name="l00014"></a>00014 <span class="comment"> *    limitations under the License.</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#  include &lt;<a class="code" href="dtn-config_8h.html">dtn-config.h</a>&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#endif</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;oasys/util/OptParser.h&gt;</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="contacts_2Link_8h.html">Link.h</a>"</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="ContactManager_8h.html">ContactManager.h</a>"</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="AlwaysOnLink_8h.html">AlwaysOnLink.h</a>"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="OndemandLink_8h.html">OndemandLink.h</a>"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="ScheduledLink_8h.html">ScheduledLink.h</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="OpportunisticLink_8h.html">OpportunisticLink.h</a>"</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="BundleDaemon_8h.html">bundling/BundleDaemon.h</a>"</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="BundleEvent_8h.html">bundling/BundleEvent.h</a>"</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="ConvergenceLayer_8h.html">conv_layers/ConvergenceLayer.h</a>"</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="EndpointIDOpt_8h.html">naming/EndpointIDOpt.h</a>"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="RouterInfo_8h.html">routing/RouterInfo.h</a>"</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="keyword">namespace </span>dtn {
<a name="l00037"></a>00037 
<a name="l00038"></a>00038 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00040"></a><a class="code" href="structdtn_1_1Link_1_1Params.html#a66a80828fbe8645786f21a2f4e38837">00040</a> <span class="comment"></span><a class="code" href="structdtn_1_1Link_1_1Params.html#a66a80828fbe8645786f21a2f4e38837" title="Default constructor.">Link::Params::Params</a>()
<a name="l00041"></a>00041     : mtu_(0),
<a name="l00042"></a>00042       min_retry_interval_(5),
<a name="l00043"></a>00043       max_retry_interval_(10 * 60),
<a name="l00044"></a>00044       idle_close_time_(0),
<a name="l00045"></a>00045       potential_downtime_(30),
<a name="l00046"></a>00046       prevhop_hdr_(false),
<a name="l00047"></a>00047       cost_(100),
<a name="l00048"></a>00048       qlimit_bundles_high_(10),
<a name="l00049"></a>00049       qlimit_bytes_high_(1024*1024), <span class="comment">// 1M</span>
<a name="l00050"></a>00050       qlimit_bundles_low_(5),
<a name="l00051"></a>00051       qlimit_bytes_low_(512*1024) <span class="comment">// 512K</span>
<a name="l00052"></a>00052 {}
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <a class="code" href="structdtn_1_1Link_1_1Params.html">Link::Params</a> <a class="code" href="classdtn_1_1Link.html#02dff1dc43dfca75fc4ecdef8ed08845" title="Default parameters of the link.">Link::default_params_</a>;
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00057"></a>00057 <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>
<a name="l00058"></a><a class="code" href="classdtn_1_1Link.html#caf84c89199fccadfaecfc85a46d96f7">00058</a> <a class="code" href="classdtn_1_1Link.html#caf84c89199fccadfaecfc85a46d96f7" title="Static function to create appropriate link object from link type.">Link::create_link</a>(<span class="keyword">const</span> std::string&amp; <a class="code" href="classdtn_1_1Link.html#e4cad7d0449f9a5c9cb3ea9693df09c4" title="Accessor to this links name.">name</a>, <a class="code" href="classdtn_1_1Link.html#a93653796d33692c67c415afd1edf61e" title="Valid types for a link.">link_type_t</a> <a class="code" href="classdtn_1_1Link.html#75dad1b5cff2bd5e84b06ffc57504c65" title="Return the type of the link.">type</a>,
<a name="l00059"></a>00059                   <a class="code" href="classdtn_1_1ConvergenceLayer.html" title="The abstract interface for a convergence layer.">ConvergenceLayer</a>* cl, <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classdtn_1_1Link.html#5bffae252da80b32679686d826f4d4cf" title="Accessor to next hop string.">nexthop</a>,
<a name="l00060"></a>00060                   <span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>* argv[],
<a name="l00061"></a>00061                   <span class="keyword">const</span> <span class="keywordtype">char</span>** invalid_argp)
<a name="l00062"></a>00062 {
<a name="l00063"></a>00063     <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a> link(<span class="stringliteral">"Link::create_link: return value"</span>);
<a name="l00064"></a>00064     <span class="keywordflow">switch</span>(type) {
<a name="l00065"></a>00065     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#a93653796d33692c67c415afd1edf61eb2b2a3f569e0a11e5277b2428253137d" title="The link is expected to be ALWAYS available, and any convergence layer connection...">ALWAYSON</a>:      link = <span class="keyword">new</span> <a class="code" href="classdtn_1_1AlwaysOnLink.html" title="Abstraction for an always on link.">AlwaysOnLink</a>(name, cl, nexthop); <span class="keywordflow">break</span>;
<a name="l00066"></a>00066     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#a93653796d33692c67c415afd1edf61eeacf2159ea9fd169ca07c9f9891309ec" title="The link is expected to be either always available, or can be made available easily...">ONDEMAND</a>:      link = <span class="keyword">new</span> <a class="code" href="classdtn_1_1OndemandLink.html" title="Abstraction for a ONDEMAND link.">OndemandLink</a>(name, cl, nexthop); <span class="keywordflow">break</span>;
<a name="l00067"></a>00067     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#a93653796d33692c67c415afd1edf61e801d9aeea31cb25c67e25914a461db38" title="The link is only available at pre-determined times.">SCHEDULED</a>:     link = <span class="keyword">new</span> <a class="code" href="classdtn_1_1ScheduledLink.html">ScheduledLink</a>(name, cl, nexthop); <span class="keywordflow">break</span>;
<a name="l00068"></a>00068     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#a93653796d33692c67c415afd1edf61e692792332b57aa903a769cb33e3d366b" title="The link may or may not be available, based on uncontrollable factors.">OPPORTUNISTIC</a>: link = <span class="keyword">new</span> <a class="code" href="classdtn_1_1OpportunisticLink.html" title="Abstraction for a OPPORTUNISTIC link.">OpportunisticLink</a>(name, cl, nexthop); <span class="keywordflow">break</span>;
<a name="l00069"></a>00069     <span class="keywordflow">default</span>:            PANIC(<span class="stringliteral">"bogus link_type_t"</span>);
<a name="l00070"></a>00070     }
<a name="l00071"></a>00071 
<a name="l00072"></a>00072     <span class="comment">// hook for the link subclass that parses any arguments and shifts</span>
<a name="l00073"></a>00073     <span class="comment">// argv appropriately</span>
<a name="l00074"></a>00074     <span class="keywordtype">int</span> <a class="code" href="dtnping_8c.html#d43c3812e6d13e0518d9f8b8f463ffcf">count</a> = link-&gt;parse_args(argc, argv, invalid_argp);
<a name="l00075"></a>00075     <span class="keywordflow">if</span> (count == -1) {
<a name="l00076"></a>00076         link-&gt;deleted_ = <span class="keyword">true</span>;
<a name="l00077"></a>00077         link = NULL;
<a name="l00078"></a>00078         <span class="keywordflow">return</span> link;
<a name="l00079"></a>00079     }
<a name="l00080"></a>00080 
<a name="l00081"></a>00081     argc -= count;
<a name="l00082"></a>00082 
<a name="l00083"></a>00083     <span class="comment">// XXX/demmer need to pass invalid_argp to the convergence layer</span>
<a name="l00084"></a>00084 
<a name="l00085"></a>00085     <span class="comment">// notify the convergence layer, which parses the rest of the</span>
<a name="l00086"></a>00086     <span class="comment">// arguments</span>
<a name="l00087"></a>00087     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(link-&gt;clayer_);
<a name="l00088"></a>00088     <span class="keywordflow">if</span> (!link-&gt;clayer_-&gt;init_link(link, argc, argv)) {
<a name="l00089"></a>00089         link-&gt;deleted_ = <span class="keyword">true</span>;
<a name="l00090"></a>00090         link = NULL;
<a name="l00091"></a>00091         <span class="keywordflow">return</span> link;
<a name="l00092"></a>00092     }
<a name="l00093"></a>00093     
<a name="l00094"></a>00094     link-&gt;logf(oasys::LOG_INFO, <span class="stringliteral">"new link *%p"</span>, link.object());
<a name="l00095"></a>00095 
<a name="l00096"></a>00096     <span class="comment">// now dispatch to the subclass for any initial state events that</span>
<a name="l00097"></a>00097     <span class="comment">// need to be posted. this needs to be done after all the above is</span>
<a name="l00098"></a>00098     <span class="comment">// completed to avoid potential race conditions if the core of the</span>
<a name="l00099"></a>00099     <span class="comment">// system tries to use the link before its completely created</span>
<a name="l00100"></a>00100     <span class="comment">// MOVED to ContactManager::handle_link_created()</span>
<a name="l00101"></a>00101     <span class="comment">// link-&gt;set_initial_state();</span>
<a name="l00102"></a>00102 
<a name="l00103"></a>00103     <span class="keywordflow">return</span> link;
<a name="l00104"></a>00104 }
<a name="l00105"></a>00105 
<a name="l00106"></a>00106 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00107"></a><a class="code" href="classdtn_1_1Link.html#d505d6b5230f402ad22687c00f494afe">00107</a> <a class="code" href="classdtn_1_1Link.html#d505d6b5230f402ad22687c00f494afe" title="Constructor / Destructor.">Link::Link</a>(<span class="keyword">const</span> std::string&amp; name, <a class="code" href="classdtn_1_1Link.html#a93653796d33692c67c415afd1edf61e" title="Valid types for a link.">link_type_t</a> type,
<a name="l00108"></a>00108            <a class="code" href="classdtn_1_1ConvergenceLayer.html" title="The abstract interface for a convergence layer.">ConvergenceLayer</a>* cl, <span class="keyword">const</span> <span class="keywordtype">char</span>* nexthop)
<a name="l00109"></a>00109     : RefCountedObject(<span class="stringliteral">"/dtn/link/refs"</span>),
<a name="l00110"></a>00110       <a class="code" href="classoasys_1_1Logger.html">Logger</a>(<span class="stringliteral">"Link"</span>, <span class="stringliteral">"/dtn/link/%s"</span>, name.c_str()),
<a name="l00111"></a>00111       type_(type),
<a name="l00112"></a>00112       state_(UNAVAILABLE),
<a name="l00113"></a>00113       deleted_(false),
<a name="l00114"></a>00114       create_pending_(false),
<a name="l00115"></a>00115       usable_(true),
<a name="l00116"></a>00116       nexthop_(nexthop),
<a name="l00117"></a>00117       name_(name),
<a name="l00118"></a>00118       reliable_(false),
<a name="l00119"></a>00119       lock_(),
<a name="l00120"></a>00120       queue_(name + <span class="stringliteral">":queue"</span>, &amp;lock_),
<a name="l00121"></a>00121       inflight_(name + <span class="stringliteral">":inflight"</span>, &amp;lock_),
<a name="l00122"></a>00122       bundles_queued_(0),
<a name="l00123"></a>00123       bytes_queued_(0),
<a name="l00124"></a>00124       bundles_inflight_(0),
<a name="l00125"></a>00125       bytes_inflight_(0),
<a name="l00126"></a>00126       contact_(<span class="stringliteral">"Link"</span>),
<a name="l00127"></a>00127       clayer_(cl),
<a name="l00128"></a>00128       cl_info_(NULL),
<a name="l00129"></a>00129       router_info_(NULL),
<a name="l00130"></a>00130       remote_eid_(<a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a>::NULL_EID())
<a name="l00131"></a>00131 {
<a name="l00132"></a>00132     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a>);
<a name="l00133"></a>00133 
<a name="l00134"></a>00134     <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>         = <a class="code" href="classdtn_1_1Link.html#02dff1dc43dfca75fc4ecdef8ed08845" title="Default parameters of the link.">default_params_</a>;
<a name="l00135"></a>00135     <a class="code" href="classdtn_1_1Link.html#6e687c4d55d6b65efef17dcc27ccbc76" title="Seconds to wait between attempts to re-open an unavailable link.">retry_interval_</a> = 0; <span class="comment">// set in ContactManager</span>
<a name="l00136"></a>00136 
<a name="l00137"></a>00137     memset(&amp;<a class="code" href="classdtn_1_1Link.html#8f66801a2de483d745b7a0b619e12f0f" title="Stats for the link.">stats_</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="structdtn_1_1Link_1_1Stats.html">Stats</a>));
<a name="l00138"></a>00138 }
<a name="l00139"></a>00139 
<a name="l00140"></a>00140 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00141"></a><a class="code" href="classdtn_1_1Link.html#791828780ab0da55bac9c6ad693dff07">00141</a> <a class="code" href="classdtn_1_1Link.html#d505d6b5230f402ad22687c00f494afe" title="Constructor / Destructor.">Link::Link</a>(<span class="keyword">const</span> oasys::Builder&amp;)
<a name="l00142"></a>00142     : RefCountedObject(<span class="stringliteral">"/dtn/link/refs"</span>),
<a name="l00143"></a>00143       <a class="code" href="classoasys_1_1Logger.html">Logger</a>(<span class="stringliteral">"Link"</span>, <span class="stringliteral">"/dtn/link/UNKNOWN!!!"</span>),
<a name="l00144"></a>00144       type_(LINK_INVALID),
<a name="l00145"></a>00145       state_(UNAVAILABLE),
<a name="l00146"></a>00146       deleted_(false),
<a name="l00147"></a>00147       create_pending_(false),
<a name="l00148"></a>00148       usable_(false),
<a name="l00149"></a>00149       nexthop_(<span class="stringliteral">""</span>),
<a name="l00150"></a>00150       name_(<span class="stringliteral">""</span>),
<a name="l00151"></a>00151       reliable_(false),
<a name="l00152"></a>00152       lock_(),
<a name="l00153"></a>00153       queue_(<span class="stringliteral">""</span>, &amp;lock_),
<a name="l00154"></a>00154       inflight_(<span class="stringliteral">""</span>, &amp;lock_),
<a name="l00155"></a>00155       bundles_queued_(0),
<a name="l00156"></a>00156       bytes_queued_(0),
<a name="l00157"></a>00157       bundles_inflight_(0),
<a name="l00158"></a>00158       bytes_inflight_(0),
<a name="l00159"></a>00159       contact_(<span class="stringliteral">"Link"</span>),
<a name="l00160"></a>00160       clayer_(NULL),
<a name="l00161"></a>00161       cl_info_(NULL),
<a name="l00162"></a>00162       router_info_(NULL),
<a name="l00163"></a>00163       remote_eid_(<a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a>::NULL_EID())
<a name="l00164"></a>00164 {
<a name="l00165"></a>00165 }
<a name="l00166"></a>00166 
<a name="l00167"></a>00167 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00168"></a>00168 <span class="keywordtype">void</span>
<a name="l00169"></a><a class="code" href="classdtn_1_1Link.html#73e9b7a34c33222155522b991b03b27f">00169</a> <a class="code" href="classdtn_1_1Link.html#73e9b7a34c33222155522b991b03b27f" title="Handle and mark deleted link.">Link::delete_link</a>()
<a name="l00170"></a>00170 {
<a name="l00171"></a>00171     oasys::ScopeLock l(&amp;<a class="code" href="classdtn_1_1Link.html#9a028608b541c0e3d3c4af3aa3fb8712" title="Lock to protect internal data structures and state.">lock_</a>, <span class="stringliteral">"Link::delete_link"</span>);
<a name="l00172"></a>00172 
<a name="l00173"></a>00173     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!<a class="code" href="classdtn_1_1Link.html#da00d64fecd9930c831718421533de0d" title="Returns true if the link has been deleted; otherwise returns false.">isdeleted</a>());
<a name="l00174"></a>00174     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a> != NULL);
<a name="l00175"></a>00175 
<a name="l00176"></a>00176     <a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a>-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#c25b42069cd41f9f07bebb93205a0426" title="Delete any CL-specific components of the link (requests pertaining to this link must...">delete_link</a>(<a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>(<span class="keyword">this</span>, <span class="stringliteral">"Link::delete_link"</span>));
<a name="l00177"></a>00177     <a class="code" href="classdtn_1_1Link.html#72c1c919069f37959273f9a0379679d5" title="Flag, that when set to true, indicates that the link has been deleted.">deleted_</a> = <span class="keyword">true</span>;
<a name="l00178"></a>00178 }
<a name="l00179"></a>00179 
<a name="l00180"></a>00180 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00181"></a>00181 <span class="keywordtype">bool</span>
<a name="l00182"></a><a class="code" href="classdtn_1_1Link.html#da00d64fecd9930c831718421533de0d">00182</a> <a class="code" href="classdtn_1_1Link.html#da00d64fecd9930c831718421533de0d" title="Returns true if the link has been deleted; otherwise returns false.">Link::isdeleted</a>()<span class="keyword"> const</span>
<a name="l00183"></a>00183 <span class="keyword"></span>{
<a name="l00184"></a>00184     oasys::ScopeLock l(&amp;<a class="code" href="classdtn_1_1Link.html#9a028608b541c0e3d3c4af3aa3fb8712" title="Lock to protect internal data structures and state.">lock_</a>, <span class="stringliteral">"Link::delete_link"</span>);
<a name="l00185"></a>00185     <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1Link.html#72c1c919069f37959273f9a0379679d5" title="Flag, that when set to true, indicates that the link has been deleted.">deleted_</a>;
<a name="l00186"></a>00186 }
<a name="l00187"></a>00187 
<a name="l00188"></a>00188 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00189"></a>00189 <span class="keywordtype">bool</span>
<a name="l00190"></a><a class="code" href="classdtn_1_1Link.html#825053cfdbfb055728d4da96e1e50fb2">00190</a> <a class="code" href="classdtn_1_1Link.html#825053cfdbfb055728d4da96e1e50fb2" title="Reconfigure the link parameters.">Link::reconfigure_link</a>(<span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>* argv[])
<a name="l00191"></a>00191 {
<a name="l00192"></a>00192     oasys::ScopeLock l(&amp;<a class="code" href="classdtn_1_1Link.html#9a028608b541c0e3d3c4af3aa3fb8712" title="Lock to protect internal data structures and state.">lock_</a>, <span class="stringliteral">"Link::reconfigure_link"</span>);
<a name="l00193"></a>00193 
<a name="l00194"></a>00194     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#da00d64fecd9930c831718421533de0d" title="Returns true if the link has been deleted; otherwise returns false.">isdeleted</a>()) {
<a name="l00195"></a>00195         log_debug(<span class="stringliteral">"Link::reconfigure_link: "</span>
<a name="l00196"></a>00196                   <span class="stringliteral">"cannot reconfigure deleted link %s"</span>, <a class="code" href="classdtn_1_1Link.html#e4cad7d0449f9a5c9cb3ea9693df09c4" title="Accessor to this links name.">name</a>());
<a name="l00197"></a>00197         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00198"></a>00198     }
<a name="l00199"></a>00199 
<a name="l00200"></a>00200     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a> != NULL);
<a name="l00201"></a>00201     <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a>-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#665759ded6a613414b1c8826208b2f5d" title="Post-initialization, parse any CL-specific options for the link.">reconfigure_link</a>(<a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>(<span class="keyword">this</span>, <span class="stringliteral">"Link::reconfigure_link"</span>),
<a name="l00202"></a>00202                                      argc, argv);
<a name="l00203"></a>00203 }
<a name="l00204"></a>00204 
<a name="l00205"></a>00205 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00206"></a>00206 <span class="keywordtype">void</span>
<a name="l00207"></a><a class="code" href="classdtn_1_1Link.html#a5c789e744e51174d1e4a2725824ed69">00207</a> <a class="code" href="classdtn_1_1Link.html#825053cfdbfb055728d4da96e1e50fb2" title="Reconfigure the link parameters.">Link::reconfigure_link</a>(<a class="code" href="namespacedtn.html#e203c4f515b9e88e9e3462100c257314">AttributeVector</a>&amp; params)
<a name="l00208"></a>00208 {
<a name="l00209"></a>00209     oasys::ScopeLock l(&amp;<a class="code" href="classdtn_1_1Link.html#9a028608b541c0e3d3c4af3aa3fb8712" title="Lock to protect internal data structures and state.">lock_</a>, <span class="stringliteral">"Link::reconfigure_link"</span>);
<a name="l00210"></a>00210 
<a name="l00211"></a>00211     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#da00d64fecd9930c831718421533de0d" title="Returns true if the link has been deleted; otherwise returns false.">isdeleted</a>()) {
<a name="l00212"></a>00212         log_debug(<span class="stringliteral">"Link::reconfigure_link: "</span>
<a name="l00213"></a>00213                   <span class="stringliteral">"cannot reconfigure deleted link %s"</span>, <a class="code" href="classdtn_1_1Link.html#e4cad7d0449f9a5c9cb3ea9693df09c4" title="Accessor to this links name.">name</a>());
<a name="l00214"></a>00214         <span class="keywordflow">return</span>;
<a name="l00215"></a>00215     }
<a name="l00216"></a>00216 
<a name="l00217"></a>00217     AttributeVector::iterator iter;
<a name="l00218"></a>00218     <span class="keywordflow">for</span> (iter = params.begin(); iter != params.end(); ) {
<a name="l00219"></a>00219         <span class="keywordflow">if</span> (iter-&gt;name() == <span class="stringliteral">"is_usable"</span>) {
<a name="l00220"></a>00220             <span class="keywordflow">if</span> (iter-&gt;bool_val()) {
<a name="l00221"></a>00221                 <a class="code" href="classdtn_1_1Link.html#24dff10247d4ac8271c2c6dd7bf38d10" title="Set/get the usable_ flag on the link.">set_usable</a>(<span class="keyword">true</span>);
<a name="l00222"></a>00222             } <span class="keywordflow">else</span> {
<a name="l00223"></a>00223                 <a class="code" href="classdtn_1_1Link.html#24dff10247d4ac8271c2c6dd7bf38d10" title="Set/get the usable_ flag on the link.">set_usable</a>(<span class="keyword">false</span>);
<a name="l00224"></a>00224             }
<a name="l00225"></a>00225             ++iter;
<a name="l00226"></a>00226 
<a name="l00227"></a>00227         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (iter-&gt;name() == <span class="stringliteral">"nexthop"</span>) {
<a name="l00228"></a>00228             <a class="code" href="classdtn_1_1Link.html#a832ad2297fd784fe6e70ee5dd7a8dab" title="Override for the next hop string.">set_nexthop</a>(iter-&gt;string_val());
<a name="l00229"></a>00229             ++iter;
<a name="l00230"></a>00230 
<a name="l00231"></a>00231         <span class="comment">// Following are DTN2 parameters not listed in the DP interface.</span>
<a name="l00232"></a>00232         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (iter-&gt;name() == <span class="stringliteral">"min_retry_interval"</span>) {
<a name="l00233"></a>00233             <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#fad825e84db3cb9e92ea0862e7cdf609" title="Minimum amount to wait between attempts to re-open the link (in seconds).">min_retry_interval_</a> = iter-&gt;u_int_val();
<a name="l00234"></a>00234             iter = params.erase(iter);
<a name="l00235"></a>00235 
<a name="l00236"></a>00236         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (iter-&gt;name() == <span class="stringliteral">"max_retry_interval"</span>) {
<a name="l00237"></a>00237             <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#814873f095484897985d1b79cb218f01" title="Maximum amount to wait between attempts to re-open the link (in seconds).">max_retry_interval_</a> = iter-&gt;u_int_val();
<a name="l00238"></a>00238             iter = params.erase(iter);
<a name="l00239"></a>00239 
<a name="l00240"></a>00240         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (iter-&gt;name() == <span class="stringliteral">"idle_close_time"</span>) {
<a name="l00241"></a>00241             <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#b234c93dc26fd078732abdb4746822e6" title="Seconds of idle time before the link is closed.">idle_close_time_</a> = iter-&gt;u_int_val();
<a name="l00242"></a>00242             iter = params.erase(iter);
<a name="l00243"></a>00243             
<a name="l00244"></a>00244         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (iter-&gt;name() == <span class="stringliteral">"potential_downtime"</span>) {
<a name="l00245"></a>00245             <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#836d9ef17e5ff0bb45b16826cc52e9c5" title="Conservative estimate of the maximum amount of time that the link may be down during...">potential_downtime_</a> = iter-&gt;u_int_val();
<a name="l00246"></a>00246             iter = params.erase(iter);
<a name="l00247"></a>00247 
<a name="l00248"></a>00248         } <span class="keywordflow">else</span> {
<a name="l00249"></a>00249             ++iter;
<a name="l00250"></a>00250         }
<a name="l00251"></a>00251     }
<a name="l00252"></a>00252     
<a name="l00253"></a>00253     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a> != NULL);
<a name="l00254"></a>00254     <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a>-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#665759ded6a613414b1c8826208b2f5d" title="Post-initialization, parse any CL-specific options for the link.">reconfigure_link</a>(
<a name="l00255"></a>00255                         <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>(<span class="keyword">this</span>, <span class="stringliteral">"Link::reconfigure_link"</span>), params);
<a name="l00256"></a>00256 }
<a name="l00257"></a>00257 
<a name="l00258"></a>00258 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00259"></a>00259 <span class="keywordtype">void</span>
<a name="l00260"></a><a class="code" href="classdtn_1_1Link.html#2c0b330264926a57c63208bf1d6f04df">00260</a> <a class="code" href="classdtn_1_1Link.html#2c0b330264926a57c63208bf1d6f04df" title="Virtual from SerializableObject.">Link::serialize</a>(oasys::SerializeAction* a)
<a name="l00261"></a>00261 {
<a name="l00262"></a>00262     std::string cl_name;
<a name="l00263"></a>00263     std::string <a class="code" href="classdtn_1_1Link.html#53848e2ba98690abd334c658c3edc10c" title="Return the string for of the link.">type_str</a>;
<a name="l00264"></a>00264 
<a name="l00265"></a>00265     <span class="keywordflow">if</span> (a-&gt;action_code() == oasys::Serialize::UNMARSHAL) {
<a name="l00266"></a>00266         a-&gt;process(<span class="stringliteral">"type"</span>,     &amp;type_str);
<a name="l00267"></a>00267         <a class="code" href="classdtn_1_1Link.html#356a205fda65a385edee00dafd6aa546" title="Type of the link.">type_</a> = <a class="code" href="classdtn_1_1Link.html#fbe02d3b95149fd1fcf9d08f0d4a3518">str_to_link_type</a>(type_str.c_str());
<a name="l00268"></a>00268         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#356a205fda65a385edee00dafd6aa546" title="Type of the link.">type_</a> != <a class="code" href="classdtn_1_1Link.html#a93653796d33692c67c415afd1edf61e16f74d8b58f067027e718650590deef1">LINK_INVALID</a>);
<a name="l00269"></a>00269     } <span class="keywordflow">else</span> {
<a name="l00270"></a>00270         type_str = <a class="code" href="classdtn_1_1Link.html#405aaca77bb12b2611ee49a8184b7829" title="Link type string conversion.">link_type_to_str</a>(<a class="code" href="classdtn_1_1Link.html#75dad1b5cff2bd5e84b06ffc57504c65" title="Return the type of the link.">type</a>());
<a name="l00271"></a>00271         a-&gt;process(<span class="stringliteral">"type"</span>,     &amp;type_str);
<a name="l00272"></a>00272     }
<a name="l00273"></a>00273     
<a name="l00274"></a>00274     a-&gt;process(<span class="stringliteral">"nexthop"</span>,  &amp;<a class="code" href="classdtn_1_1Link.html#4a0317c260c70581ef1a81a23bc27fba" title="Next hop address.">nexthop_</a>);
<a name="l00275"></a>00275     a-&gt;process(<span class="stringliteral">"name"</span>,     &amp;<a class="code" href="classdtn_1_1Link.html#18fba654bb084c0d68d5442579393439" title="Internal name of the link.">name_</a>);
<a name="l00276"></a>00276     a-&gt;process(<span class="stringliteral">"state"</span>,    &amp;<a class="code" href="classdtn_1_1Link.html#19d118d1c518d09ac42bd97b9c917169" title="State of the link.">state_</a>);
<a name="l00277"></a>00277     a-&gt;process(<span class="stringliteral">"deleted"</span>,  &amp;<a class="code" href="classdtn_1_1Link.html#72c1c919069f37959273f9a0379679d5" title="Flag, that when set to true, indicates that the link has been deleted.">deleted_</a>);
<a name="l00278"></a>00278     a-&gt;process(<span class="stringliteral">"usable"</span>,   &amp;<a class="code" href="classdtn_1_1Link.html#00910520baf6369869bb3ae6988172fd" title="Flag, that when set to true, indicates that the link is allowed to be used to transmit...">usable_</a>);
<a name="l00279"></a>00279     a-&gt;process(<span class="stringliteral">"reliable"</span>, &amp;<a class="code" href="classdtn_1_1Link.html#713c78c93785b2e3a6462892d52b550d" title="Whether or not this link is reliable.">reliable_</a>);
<a name="l00280"></a>00280 
<a name="l00281"></a>00281     <span class="keywordflow">if</span> (a-&gt;action_code() == oasys::Serialize::UNMARSHAL) {
<a name="l00282"></a>00282         a-&gt;process(<span class="stringliteral">"clayer"</span>, &amp;cl_name);
<a name="l00283"></a>00283         <a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a> = <a class="code" href="classdtn_1_1ConvergenceLayer.html#6259b19bef1dd17295030b33c44c29d0" title="Find the appropriate convergence layer for the given string.">ConvergenceLayer::find_clayer</a>(cl_name.c_str());
<a name="l00284"></a>00284         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a>);
<a name="l00285"></a>00285     } <span class="keywordflow">else</span> {
<a name="l00286"></a>00286         cl_name = <a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a>-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#1030bc8bf5d5ca898fad2433e30e44cf" title="Accessor for the convergence layer name.">name</a>();
<a name="l00287"></a>00287         a-&gt;process(<span class="stringliteral">"clayer"</span>, &amp;cl_name);
<a name="l00288"></a>00288         <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#19d118d1c518d09ac42bd97b9c917169" title="State of the link.">state_</a> == <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3ec7a744ed0ed07ccb2b255a0d76192c8" title="A convergence layer session has been established, and the link has capacity for a...">OPEN</a>)
<a name="l00289"></a>00289             a-&gt;process(<span class="stringliteral">"clinfo"</span>, <a class="code" href="classdtn_1_1Link.html#71c79dccb9b64a80879000ba232f7e9a" title="Current contact. contact_ != null iff link is open.">contact_</a>-&gt;cl_info());
<a name="l00290"></a>00290     }
<a name="l00291"></a>00291 
<a name="l00292"></a>00292     <span class="comment">// XXX/demmer router_info_??</span>
<a name="l00293"></a>00293 
<a name="l00294"></a>00294     a-&gt;process(<span class="stringliteral">"remote_eid"</span>,         &amp;<a class="code" href="classdtn_1_1Link.html#1db82aaa68166ce7029df32710ee58f1" title="Remote&amp;#39;s endpoint ID (eg, dtn://hostname.dtn).">remote_eid_</a>);
<a name="l00295"></a>00295     a-&gt;process(<span class="stringliteral">"min_retry_interval"</span>, &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#fad825e84db3cb9e92ea0862e7cdf609" title="Minimum amount to wait between attempts to re-open the link (in seconds).">min_retry_interval_</a>);
<a name="l00296"></a>00296     a-&gt;process(<span class="stringliteral">"max_retry_interval"</span>, &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#814873f095484897985d1b79cb218f01" title="Maximum amount to wait between attempts to re-open the link (in seconds).">max_retry_interval_</a>);
<a name="l00297"></a>00297     a-&gt;process(<span class="stringliteral">"idle_close_time"</span>,    &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#b234c93dc26fd078732abdb4746822e6" title="Seconds of idle time before the link is closed.">idle_close_time_</a>);
<a name="l00298"></a>00298     a-&gt;process(<span class="stringliteral">"potential_downtime"</span>, &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#836d9ef17e5ff0bb45b16826cc52e9c5" title="Conservative estimate of the maximum amount of time that the link may be down during...">potential_downtime_</a>);
<a name="l00299"></a>00299     a-&gt;process(<span class="stringliteral">"cost"</span>,               &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#ed0e0d6c0df908fd1d94da3aa752a8e6" title="Abstract cost of the link, used by routing algorithms.">cost_</a>);
<a name="l00300"></a>00300 
<a name="l00301"></a>00301     <span class="keywordflow">if</span> (a-&gt;action_code() == oasys::Serialize::UNMARSHAL) {
<a name="l00302"></a>00302         logpathf(<span class="stringliteral">"/dtn/link/%s"</span>, <a class="code" href="classdtn_1_1Link.html#18fba654bb084c0d68d5442579393439" title="Internal name of the link.">name_</a>.c_str());
<a name="l00303"></a>00303     }
<a name="l00304"></a>00304 }
<a name="l00305"></a>00305 
<a name="l00306"></a>00306 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00307"></a>00307 <span class="keywordtype">int</span>
<a name="l00308"></a><a class="code" href="classdtn_1_1Link.html#5e85022a6ac79a3879fb1bf2f8b759ed">00308</a> <a class="code" href="classdtn_1_1Link.html#5e85022a6ac79a3879fb1bf2f8b759ed" title="Hook for subclass to parse arguments.">Link::parse_args</a>(<span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>* argv[], <span class="keyword">const</span> <span class="keywordtype">char</span>** invalidp)
<a name="l00309"></a>00309 {
<a name="l00310"></a>00310     oasys::OptParser p;
<a name="l00311"></a>00311 
<a name="l00312"></a>00312     p.addopt(<span class="keyword">new</span> <a class="code" href="classdtn_1_1EndpointIDOpt.html" title="Extension class to the oasys Opt hierarchy that validates that the option is a DTN...">dtn::EndpointIDOpt</a>(<span class="stringliteral">"remote_eid"</span>, &amp;<a class="code" href="classdtn_1_1Link.html#1db82aaa68166ce7029df32710ee58f1" title="Remote&amp;#39;s endpoint ID (eg, dtn://hostname.dtn).">remote_eid_</a>));
<a name="l00313"></a>00313     p.addopt(<span class="keyword">new</span> oasys::BoolOpt(<span class="stringliteral">"reliable"</span>, &amp;<a class="code" href="classdtn_1_1Link.html#713c78c93785b2e3a6462892d52b550d" title="Whether or not this link is reliable.">reliable_</a>));
<a name="l00314"></a>00314     p.addopt(<span class="keyword">new</span> oasys::StringOpt(<span class="stringliteral">"nexthop"</span>, &amp;<a class="code" href="classdtn_1_1Link.html#4a0317c260c70581ef1a81a23bc27fba" title="Next hop address.">nexthop_</a>));
<a name="l00315"></a>00315     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"mtu"</span>, &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#333734265a2a17aa4edcb97fbae31400" title="MTU of the link, used to control proactive fragmentation.">mtu_</a>));
<a name="l00316"></a>00316     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"min_retry_interval"</span>,
<a name="l00317"></a>00317                                 &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#fad825e84db3cb9e92ea0862e7cdf609" title="Minimum amount to wait between attempts to re-open the link (in seconds).">min_retry_interval_</a>));
<a name="l00318"></a>00318     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"max_retry_interval"</span>,
<a name="l00319"></a>00319                                 &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#814873f095484897985d1b79cb218f01" title="Maximum amount to wait between attempts to re-open the link (in seconds).">max_retry_interval_</a>));
<a name="l00320"></a>00320     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"idle_close_time"</span>,
<a name="l00321"></a>00321                                 &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#b234c93dc26fd078732abdb4746822e6" title="Seconds of idle time before the link is closed.">idle_close_time_</a>));
<a name="l00322"></a>00322     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"potential_downtime"</span>,
<a name="l00323"></a>00323                                 &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#836d9ef17e5ff0bb45b16826cc52e9c5" title="Conservative estimate of the maximum amount of time that the link may be down during...">potential_downtime_</a>));
<a name="l00324"></a>00324     p.addopt(<span class="keyword">new</span> oasys::BoolOpt(<span class="stringliteral">"prevhop_hdr"</span>, &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#826790ff03eba2149cefc18802cdf6d5" title="Whether or not to send the previous hop header on this link.">prevhop_hdr_</a>));
<a name="l00325"></a>00325     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"cost"</span>, &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#ed0e0d6c0df908fd1d94da3aa752a8e6" title="Abstract cost of the link, used by routing algorithms.">cost_</a>));
<a name="l00326"></a>00326     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"qlimit_bundles_high"</span>,
<a name="l00327"></a>00327                                 &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#f5d23c371d36b35ed9bb1776baa2b178">qlimit_bundles_high_</a>));
<a name="l00328"></a>00328     p.addopt(<span class="keyword">new</span> oasys::SizeOpt(<span class="stringliteral">"qlimit_bytes_high"</span>,
<a name="l00329"></a>00329                                 &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#54e55c9e4458ec7037f59db593193ff8">qlimit_bytes_high_</a>));
<a name="l00330"></a>00330     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"qlimit_bundles_low"</span>,
<a name="l00331"></a>00331                                 &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#dffd607e6951f941ac2165a84d1fe2ec">qlimit_bundles_low_</a>));
<a name="l00332"></a>00332     p.addopt(<span class="keyword">new</span> oasys::SizeOpt(<span class="stringliteral">"qlimit_bytes_low"</span>,
<a name="l00333"></a>00333                                 &amp;<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#6319c3d9e5366cfe75cfd5f02a5702fe">qlimit_bytes_low_</a>));
<a name="l00334"></a>00334     
<a name="l00335"></a>00335     <span class="keywordtype">int</span> ret = p.parse_and_shift(argc, argv, invalidp);
<a name="l00336"></a>00336     <span class="keywordflow">if</span> (ret == -1) {
<a name="l00337"></a>00337         <span class="keywordflow">return</span> -1;
<a name="l00338"></a>00338     }
<a name="l00339"></a>00339 
<a name="l00340"></a>00340     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#fad825e84db3cb9e92ea0862e7cdf609" title="Minimum amount to wait between attempts to re-open the link (in seconds).">min_retry_interval_</a> == 0 ||
<a name="l00341"></a>00341         <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#814873f095484897985d1b79cb218f01" title="Maximum amount to wait between attempts to re-open the link (in seconds).">max_retry_interval_</a> == 0)
<a name="l00342"></a>00342     {
<a name="l00343"></a>00343         *invalidp = <span class="stringliteral">"invalid retry interval"</span>;
<a name="l00344"></a>00344         <span class="keywordflow">return</span> -1;
<a name="l00345"></a>00345     }
<a name="l00346"></a>00346     
<a name="l00347"></a>00347     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#b234c93dc26fd078732abdb4746822e6" title="Seconds of idle time before the link is closed.">idle_close_time_</a> != 0 &amp;&amp; <a class="code" href="classdtn_1_1Link.html#356a205fda65a385edee00dafd6aa546" title="Type of the link.">type_</a> == <a class="code" href="classdtn_1_1Link.html#a93653796d33692c67c415afd1edf61eb2b2a3f569e0a11e5277b2428253137d" title="The link is expected to be ALWAYS available, and any convergence layer connection...">ALWAYSON</a>)
<a name="l00348"></a>00348     {
<a name="l00349"></a>00349         *invalidp = <span class="stringliteral">"idle_close_time must be zero for always on link"</span>;
<a name="l00350"></a>00350         <span class="keywordflow">return</span> -1;
<a name="l00351"></a>00351     }
<a name="l00352"></a>00352     
<a name="l00353"></a>00353     <span class="keywordflow">return</span> ret;
<a name="l00354"></a>00354 }
<a name="l00355"></a>00355 
<a name="l00356"></a>00356 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00357"></a>00357 <span class="keywordtype">void</span>
<a name="l00358"></a><a class="code" href="classdtn_1_1Link.html#56ec91ab095a6a47bc70e3e03a400f94">00358</a> <a class="code" href="classdtn_1_1Link.html#56ec91ab095a6a47bc70e3e03a400f94" title="Hook for subclass to post events to control the initial link state, after all initialization...">Link::set_initial_state</a>()
<a name="l00359"></a>00359 {
<a name="l00360"></a>00360 }
<a name="l00361"></a>00361 
<a name="l00362"></a>00362 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00363"></a><a class="code" href="classdtn_1_1Link.html#9aed1d330a9d5e5bd09e0a18e06f2d95">00363</a> <a class="code" href="classdtn_1_1Link.html#9aed1d330a9d5e5bd09e0a18e06f2d95" title="Destructor -- protected since links shouldn&amp;#39;t be deleted.">Link::~Link</a>()
<a name="l00364"></a>00364 {
<a name="l00365"></a>00365     log_debug(<span class="stringliteral">"destroying link %s"</span>, <a class="code" href="classdtn_1_1Link.html#e4cad7d0449f9a5c9cb3ea9693df09c4" title="Accessor to this links name.">name</a>());
<a name="l00366"></a>00366         
<a name="l00367"></a>00367     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!<a class="code" href="classdtn_1_1Link.html#952e9b3539ca5200c04daeb248dc4180" title="Return whether or not the link is open.">isopen</a>());
<a name="l00368"></a>00368     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#b0c8d7b3a270bb4ec6d7f018ed70aa94" title="Convergence layer specific info, if needed.">cl_info_</a> == NULL);
<a name="l00369"></a>00369     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#2dd58ea037907dc2a5e5fe30d61414b2" title="Router specific info, if needed.">router_info_</a> == NULL);
<a name="l00370"></a>00370 }
<a name="l00371"></a>00371 
<a name="l00372"></a>00372 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00373"></a>00373 <span class="keywordtype">void</span>
<a name="l00374"></a><a class="code" href="classdtn_1_1Link.html#771d7e1e57ec743d6c38b11a09274771">00374</a> <a class="code" href="classdtn_1_1Link.html#771d7e1e57ec743d6c38b11a09274771" title="Sets the state of the link.">Link::set_state</a>(<a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3" title="The possible states for a link.">state_t</a> new_state)
<a name="l00375"></a>00375 {
<a name="l00376"></a>00376     log_debug(<span class="stringliteral">"set_state %s -&gt; %s"</span>,
<a name="l00377"></a>00377               <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">state_to_str</a>(<a class="code" href="classdtn_1_1Link.html#71a8fdd921fb0e93fd4c21f08da28a8b" title="Return the actual state.">state</a>()),
<a name="l00378"></a>00378               <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">state_to_str</a>(new_state));
<a name="l00379"></a>00379 
<a name="l00380"></a>00380 <span class="preprocessor">#define ASSERT_STATE(condition)                             \</span>
<a name="l00381"></a>00381 <span class="preprocessor">    if (!(condition)) {                                     \</span>
<a name="l00382"></a>00382 <span class="preprocessor">        log_err("set_state %s -&gt; %s: expected %s",          \</span>
<a name="l00383"></a>00383 <span class="preprocessor">                state_to_str(state()), \</span>
<a name="l00384"></a>00384 <span class="preprocessor">                state_to_str(new_state),                    \</span>
<a name="l00385"></a>00385 <span class="preprocessor">                #condition);                                \</span>
<a name="l00386"></a>00386 <span class="preprocessor">    }</span>
<a name="l00387"></a>00387 <span class="preprocessor"></span>
<a name="l00388"></a>00388     <span class="keywordflow">switch</span>(new_state) {
<a name="l00389"></a>00389     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3fcb80aea04644bdc565b13fa371b2e1e" title="The link is closed and not able to be opened currently.">UNAVAILABLE</a>:
<a name="l00390"></a>00390         <span class="keywordflow">break</span>; <span class="comment">// any old state is valid</span>
<a name="l00391"></a>00391 
<a name="l00392"></a>00392     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a36a3d11409342e7987b0ffe9c532d6e51" title="The link is closed but is able to be opened, either because it is an on demand link...">AVAILABLE</a>:
<a name="l00393"></a>00393         <a class="code" href="Link_8cc.html#2137b31c0de0208360eb8bc51f2b0bfd">ASSERT_STATE</a>(<a class="code" href="classdtn_1_1Link.html#19d118d1c518d09ac42bd97b9c917169" title="State of the link.">state_</a> == <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3ec7a744ed0ed07ccb2b255a0d76192c8" title="A convergence layer session has been established, and the link has capacity for a...">OPEN</a> || <a class="code" href="classdtn_1_1Link.html#19d118d1c518d09ac42bd97b9c917169" title="State of the link.">state_</a> == <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3fcb80aea04644bdc565b13fa371b2e1e" title="The link is closed and not able to be opened currently.">UNAVAILABLE</a>);
<a name="l00394"></a>00394         <span class="keywordflow">break</span>;
<a name="l00395"></a>00395 
<a name="l00396"></a>00396     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a335e8afe56056fd46352661764b8982df" title="A convergence layer session is in the process of being established.">OPENING</a>:
<a name="l00397"></a>00397         <a class="code" href="Link_8cc.html#2137b31c0de0208360eb8bc51f2b0bfd">ASSERT_STATE</a>(<a class="code" href="classdtn_1_1Link.html#19d118d1c518d09ac42bd97b9c917169" title="State of the link.">state_</a> == <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a36a3d11409342e7987b0ffe9c532d6e51" title="The link is closed but is able to be opened, either because it is an on demand link...">AVAILABLE</a> || <a class="code" href="classdtn_1_1Link.html#19d118d1c518d09ac42bd97b9c917169" title="State of the link.">state_</a> == <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3fcb80aea04644bdc565b13fa371b2e1e" title="The link is closed and not able to be opened currently.">UNAVAILABLE</a>);
<a name="l00398"></a>00398         <span class="keywordflow">break</span>;
<a name="l00399"></a>00399         
<a name="l00400"></a>00400     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3ec7a744ed0ed07ccb2b255a0d76192c8" title="A convergence layer session has been established, and the link has capacity for a...">OPEN</a>:
<a name="l00401"></a>00401         <a class="code" href="Link_8cc.html#2137b31c0de0208360eb8bc51f2b0bfd">ASSERT_STATE</a>(<a class="code" href="classdtn_1_1Link.html#19d118d1c518d09ac42bd97b9c917169" title="State of the link.">state_</a> == <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a335e8afe56056fd46352661764b8982df" title="A convergence layer session is in the process of being established.">OPENING</a> ||
<a name="l00402"></a>00402                      <a class="code" href="classdtn_1_1Link.html#19d118d1c518d09ac42bd97b9c917169" title="State of the link.">state_</a> == <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a3fcb80aea04644bdc565b13fa371b2e1e" title="The link is closed and not able to be opened currently.">UNAVAILABLE</a> <span class="comment">/* for opportunistic links */</span>);
<a name="l00403"></a>00403         <span class="keywordflow">break</span>;
<a name="l00404"></a>00404 
<a name="l00405"></a>00405     <span class="keywordflow">default</span>:
<a name="l00406"></a>00406         NOTREACHED;
<a name="l00407"></a>00407     }
<a name="l00408"></a>00408 <span class="preprocessor">#undef ASSERT_STATE</span>
<a name="l00409"></a>00409 <span class="preprocessor"></span>
<a name="l00410"></a>00410     <a class="code" href="classdtn_1_1Link.html#19d118d1c518d09ac42bd97b9c917169" title="State of the link.">state_</a> = new_state;
<a name="l00411"></a>00411 }
<a name="l00412"></a>00412 
<a name="l00413"></a>00413 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00414"></a>00414 <span class="keywordtype">void</span>
<a name="l00415"></a><a class="code" href="classdtn_1_1Link.html#9397d41bdf415c846610343e15b4b503">00415</a> <a class="code" href="classdtn_1_1Link.html#9397d41bdf415c846610343e15b4b503" title="Open the link.">Link::open</a>()
<a name="l00416"></a>00416 {
<a name="l00417"></a>00417     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!<a class="code" href="classdtn_1_1Link.html#da00d64fecd9930c831718421533de0d" title="Returns true if the link has been deleted; otherwise returns false.">isdeleted</a>());
<a name="l00418"></a>00418 
<a name="l00419"></a>00419     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#19d118d1c518d09ac42bd97b9c917169" title="State of the link.">state_</a> != <a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a36a3d11409342e7987b0ffe9c532d6e51" title="The link is closed but is able to be opened, either because it is an on demand link...">AVAILABLE</a>) {
<a name="l00420"></a>00420         log_crit(<span class="stringliteral">"Link::open: in state %s: expected state AVAILABLE"</span>,
<a name="l00421"></a>00421                  <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">state_to_str</a>(<a class="code" href="classdtn_1_1Link.html#71a8fdd921fb0e93fd4c21f08da28a8b" title="Return the actual state.">state</a>()));
<a name="l00422"></a>00422         <span class="keywordflow">return</span>;
<a name="l00423"></a>00423     }
<a name="l00424"></a>00424 
<a name="l00425"></a>00425     <a class="code" href="classdtn_1_1Link.html#771d7e1e57ec743d6c38b11a09274771" title="Sets the state of the link.">set_state</a>(<a class="code" href="classdtn_1_1Link.html#1bf2479a21276737f73204a3c46508a335e8afe56056fd46352661764b8982df" title="A convergence layer session is in the process of being established.">OPENING</a>);
<a name="l00426"></a>00426 
<a name="l00427"></a>00427     <span class="comment">// tell the convergence layer to establish a new session however</span>
<a name="l00428"></a>00428     <span class="comment">// it needs to, it will set the Link state to OPEN and post a</span>
<a name="l00429"></a>00429     <span class="comment">// ContactUpEvent when it has done the deed</span>
<a name="l00430"></a>00430     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#71c79dccb9b64a80879000ba232f7e9a" title="Current contact. contact_ != null iff link is open.">contact_</a> == NULL);
<a name="l00431"></a>00431     <a class="code" href="classdtn_1_1Link.html#71c79dccb9b64a80879000ba232f7e9a" title="Current contact. contact_ != null iff link is open.">contact_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1Contact.html" title="Encapsulation of an active connection to a next-hop DTN contact.">Contact</a>(<a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>(<span class="keyword">this</span>, <span class="stringliteral">"Link::open"</span>));
<a name="l00432"></a>00432     <a class="code" href="classdtn_1_1Link.html#f909b48bf21f49b5646e22cb51151869" title="Accessor to this contact&amp;#39;s convergence layer.">clayer</a>()-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#0bc4483b3956e082a17f79bd9b488780" title="Open a new contact for the given link.">open_contact</a>(<a class="code" href="classdtn_1_1Link.html#71c79dccb9b64a80879000ba232f7e9a" title="Current contact. contact_ != null iff link is open.">contact_</a>);
<a name="l00433"></a>00433 
<a name="l00434"></a>00434     <a class="code" href="classdtn_1_1Link.html#8f66801a2de483d745b7a0b619e12f0f" title="Stats for the link.">stats_</a>.<a class="code" href="structdtn_1_1Link_1_1Stats.html#6e3d627044f1947e6df365ac31831cd6" title="Number of times the link attempted to be opened.">contact_attempts_</a>++;
<a name="l00435"></a>00435 
<a name="l00436"></a>00436     log_debug(<span class="stringliteral">"Link::open: *%p new contact %p"</span>, <span class="keyword">this</span>, <a class="code" href="classdtn_1_1Link.html#71c79dccb9b64a80879000ba232f7e9a" title="Current contact. contact_ != null iff link is open.">contact_</a>.object());
<a name="l00437"></a>00437 }
<a name="l00438"></a>00438     
<a name="l00439"></a>00439 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00440"></a>00440 <span class="keywordtype">void</span>
<a name="l00441"></a><a class="code" href="classdtn_1_1Link.html#415c96b4d171484971a6946eb231195a">00441</a> <a class="code" href="classdtn_1_1Link.html#415c96b4d171484971a6946eb231195a" title="Close the link.">Link::close</a>()
<a name="l00442"></a>00442 {
<a name="l00443"></a>00443     log_debug(<span class="stringliteral">"Link::close"</span>);
<a name="l00444"></a>00444 
<a name="l00445"></a>00445     <span class="comment">// we should always be open, therefore we must have a contact</span>
<a name="l00446"></a>00446     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#71c79dccb9b64a80879000ba232f7e9a" title="Current contact. contact_ != null iff link is open.">contact_</a> == NULL) {
<a name="l00447"></a>00447         log_err(<span class="stringliteral">"Link::close with no contact"</span>);
<a name="l00448"></a>00448         <span class="keywordflow">return</span>;
<a name="l00449"></a>00449     }
<a name="l00450"></a>00450     
<a name="l00451"></a>00451     <span class="comment">// Kick the convergence layer to close the contact and make sure</span>
<a name="l00452"></a>00452     <span class="comment">// it cleaned up its state</span>
<a name="l00453"></a>00453     <a class="code" href="classdtn_1_1Link.html#f909b48bf21f49b5646e22cb51151869" title="Accessor to this contact&amp;#39;s convergence layer.">clayer</a>()-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#0667833468ff83fd60b4f96307c26618" title="Close the open contact.">close_contact</a>(<a class="code" href="classdtn_1_1Link.html#71c79dccb9b64a80879000ba232f7e9a" title="Current contact. contact_ != null iff link is open.">contact_</a>);
<a name="l00454"></a>00454     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#71c79dccb9b64a80879000ba232f7e9a" title="Current contact. contact_ != null iff link is open.">contact_</a>-&gt;cl_info() == NULL);
<a name="l00455"></a>00455 
<a name="l00456"></a>00456     <span class="comment">// Remove the reference from the link, which will clean up the</span>
<a name="l00457"></a>00457     <span class="comment">// object eventually</span>
<a name="l00458"></a>00458     <a class="code" href="classdtn_1_1Link.html#71c79dccb9b64a80879000ba232f7e9a" title="Current contact. contact_ != null iff link is open.">contact_</a> = NULL;
<a name="l00459"></a>00459 
<a name="l00460"></a>00460     log_debug(<span class="stringliteral">"Link::close complete"</span>);
<a name="l00461"></a>00461 }
<a name="l00462"></a>00462 
<a name="l00463"></a>00463 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00464"></a>00464 <span class="keywordtype">bool</span>
<a name="l00465"></a><a class="code" href="classdtn_1_1Link.html#969754e20c9dd4b9995f681703c4d963">00465</a> <a class="code" href="classdtn_1_1Link.html#969754e20c9dd4b9995f681703c4d963" title="Return whether or not the queue is full, based on the configured queue limits.">Link::queue_is_full</a>()<span class="keyword"> const</span>
<a name="l00466"></a>00466 <span class="keyword"></span>{
<a name="l00467"></a>00467     <span class="keywordflow">return</span> ((<a class="code" href="classdtn_1_1Link.html#a1c555412ff256489d257a6c838f7b2a">bundles_queued_</a> &gt; <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#f5d23c371d36b35ed9bb1776baa2b178">qlimit_bundles_high_</a>) ||
<a name="l00468"></a>00468             (<a class="code" href="classdtn_1_1Link.html#611750c82a1ae0fe8d2c9d22097b5bbf">bytes_queued_</a>   &gt; <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#54e55c9e4458ec7037f59db593193ff8">qlimit_bytes_high_</a>));
<a name="l00469"></a>00469 }
<a name="l00470"></a>00470 
<a name="l00471"></a>00471 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00472"></a>00472 <span class="keywordtype">bool</span>
<a name="l00473"></a><a class="code" href="classdtn_1_1Link.html#f81761808229e409927bee19494b878c">00473</a> <a class="code" href="classdtn_1_1Link.html#f81761808229e409927bee19494b878c" title="Return whether or not the queue has space, based on the configured queue limits.">Link::queue_has_space</a>()<span class="keyword"> const</span>
<a name="l00474"></a>00474 <span class="keyword"></span>{
<a name="l00475"></a>00475     <span class="keywordflow">return</span> ((<a class="code" href="classdtn_1_1Link.html#a1c555412ff256489d257a6c838f7b2a">bundles_queued_</a> &lt; <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#dffd607e6951f941ac2165a84d1fe2ec">qlimit_bundles_low_</a>) &amp;&amp;
<a name="l00476"></a>00476             (<a class="code" href="classdtn_1_1Link.html#611750c82a1ae0fe8d2c9d22097b5bbf">bytes_queued_</a>   &lt; <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#6319c3d9e5366cfe75cfd5f02a5702fe">qlimit_bytes_low_</a>));
<a name="l00477"></a>00477 }
<a name="l00478"></a>00478 
<a name="l00479"></a>00479 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00480"></a>00480 <span class="keywordtype">bool</span>
<a name="l00481"></a><a class="code" href="classdtn_1_1Link.html#4145ce871e553f7135550b2c2227b9c3">00481</a> <a class="code" href="classdtn_1_1Link.html#4145ce871e553f7135550b2c2227b9c3" title="Accessor functions to add/remove bundles from the link queue and inflight list, keeping...">Link::add_to_queue</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; bundle, <span class="keywordtype">size_t</span> total_len)
<a name="l00482"></a>00482 {
<a name="l00483"></a>00483     oasys::ScopeLock l(&amp;<a class="code" href="classdtn_1_1Link.html#9a028608b541c0e3d3c4af3aa3fb8712" title="Lock to protect internal data structures and state.">lock_</a>, <span class="stringliteral">"Link::add_to_queue"</span>);
<a name="l00484"></a>00484     
<a name="l00485"></a>00485     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#f7bef65eadb08fc8370eaf235b9af22a" title="Queue of bundles currently active or pending transmission on the Link.">queue_</a>.<a class="code" href="classdtn_1_1BundleList.html#6398bb64194aa88b63e7d0e89e141883" title="Search the list for the given bundle.">contains</a>(bundle)) {
<a name="l00486"></a>00486         log_err(<span class="stringliteral">"add_to_queue: bundle *%p already in queue for link %s"</span>,
<a name="l00487"></a>00487                 bundle.object(), <a class="code" href="classdtn_1_1Link.html#18fba654bb084c0d68d5442579393439" title="Internal name of the link.">name_</a>.c_str());
<a name="l00488"></a>00488         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00489"></a>00489     }
<a name="l00490"></a>00490     
<a name="l00491"></a>00491     log_debug(<span class="stringliteral">"adding *%p to queue (length %u)"</span>,
<a name="l00492"></a>00492               bundle.object(), <a class="code" href="classdtn_1_1Link.html#a1c555412ff256489d257a6c838f7b2a">bundles_queued_</a>);
<a name="l00493"></a>00493     <a class="code" href="classdtn_1_1Link.html#a1c555412ff256489d257a6c838f7b2a">bundles_queued_</a>++;
<a name="l00494"></a>00494     <a class="code" href="classdtn_1_1Link.html#611750c82a1ae0fe8d2c9d22097b5bbf">bytes_queued_</a> += total_len;
<a name="l00495"></a>00495     <a class="code" href="classdtn_1_1Link.html#f7bef65eadb08fc8370eaf235b9af22a" title="Queue of bundles currently active or pending transmission on the Link.">queue_</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="l00496"></a>00496 
<a name="l00497"></a>00497     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00498"></a>00498 }
<a name="l00499"></a>00499 
<a name="l00500"></a>00500 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00501"></a>00501 <span class="keywordtype">bool</span>
<a name="l00502"></a><a class="code" href="classdtn_1_1Link.html#351b48d6422e54c1e1761de089ddcee1">00502</a> <a class="code" href="classdtn_1_1Link.html#351b48d6422e54c1e1761de089ddcee1" title="Accessor functions to add/remove bundles from the link queue and inflight list, keeping...">Link::del_from_queue</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; bundle, <span class="keywordtype">size_t</span> total_len)
<a name="l00503"></a>00503 {
<a name="l00504"></a>00504     oasys::ScopeLock l(&amp;<a class="code" href="classdtn_1_1Link.html#9a028608b541c0e3d3c4af3aa3fb8712" title="Lock to protect internal data structures and state.">lock_</a>, <span class="stringliteral">"Link::del_from_queue"</span>);
<a name="l00505"></a>00505     
<a name="l00506"></a>00506     <span class="keywordflow">if</span> (! <a class="code" href="classdtn_1_1Link.html#f7bef65eadb08fc8370eaf235b9af22a" title="Queue of bundles currently active or pending transmission on the Link.">queue_</a>.<a class="code" href="classdtn_1_1BundleList.html#b0171458e14d67307b74f98447062d68" title="Remove the given bundle from the list.">erase</a>(bundle)) {
<a name="l00507"></a>00507         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00508"></a>00508     }
<a name="l00509"></a>00509 
<a name="l00510"></a>00510     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#a1c555412ff256489d257a6c838f7b2a">bundles_queued_</a> &gt; 0);
<a name="l00511"></a>00511     <a class="code" href="classdtn_1_1Link.html#a1c555412ff256489d257a6c838f7b2a">bundles_queued_</a>--;
<a name="l00512"></a>00512     
<a name="l00513"></a>00513     <span class="comment">// sanity checks</span>
<a name="l00514"></a>00514     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(total_len != 0);
<a name="l00515"></a>00515     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#611750c82a1ae0fe8d2c9d22097b5bbf">bytes_queued_</a> &gt;= total_len) {
<a name="l00516"></a>00516         <a class="code" href="classdtn_1_1Link.html#611750c82a1ae0fe8d2c9d22097b5bbf">bytes_queued_</a> -= total_len;
<a name="l00517"></a>00517 
<a name="l00518"></a>00518     } <span class="keywordflow">else</span> {
<a name="l00519"></a>00519         log_err(<span class="stringliteral">"del_from_queue: *%p bytes_queued %u &lt; total_len %zu"</span>,
<a name="l00520"></a>00520                 bundle.object(), <a class="code" href="classdtn_1_1Link.html#611750c82a1ae0fe8d2c9d22097b5bbf">bytes_queued_</a>, total_len);
<a name="l00521"></a>00521     }
<a name="l00522"></a>00522     
<a name="l00523"></a>00523     log_debug(<span class="stringliteral">"removed *%p from queue (length %u)"</span>,
<a name="l00524"></a>00524               bundle.object(), <a class="code" href="classdtn_1_1Link.html#a1c555412ff256489d257a6c838f7b2a">bundles_queued_</a>);
<a name="l00525"></a>00525     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00526"></a>00526 }
<a name="l00527"></a>00527 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00528"></a>00528 <span class="keywordtype">bool</span>
<a name="l00529"></a><a class="code" href="classdtn_1_1Link.html#48b8de62d4415d0d1d2214515bdfc9ac">00529</a> <a class="code" href="classdtn_1_1Link.html#48b8de62d4415d0d1d2214515bdfc9ac" title="Accessor functions to add/remove bundles from the link queue and inflight list, keeping...">Link::add_to_inflight</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; bundle, <span class="keywordtype">size_t</span> total_len)
<a name="l00530"></a>00530 {
<a name="l00531"></a>00531     oasys::ScopeLock l(&amp;<a class="code" href="classdtn_1_1Link.html#9a028608b541c0e3d3c4af3aa3fb8712" title="Lock to protect internal data structures and state.">lock_</a>, <span class="stringliteral">"Link::add_to_inflight"</span>);
<a name="l00532"></a>00532 
<a name="l00533"></a>00533     <span class="keywordflow">if</span> (bundle-&gt;is_queued_on(&amp;<a class="code" href="classdtn_1_1Link.html#fc4fe98181a47e648d7133898949d631" title="Queue of bundles that have been sent but not yet acknowledged.">inflight_</a>)) {
<a name="l00534"></a>00534         log_err(<span class="stringliteral">"bundle *%p already in flight for link %s"</span>,
<a name="l00535"></a>00535                 bundle.object(), <a class="code" href="classdtn_1_1Link.html#18fba654bb084c0d68d5442579393439" title="Internal name of the link.">name_</a>.c_str());
<a name="l00536"></a>00536         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00537"></a>00537     }
<a name="l00538"></a>00538     
<a name="l00539"></a>00539     log_debug(<span class="stringliteral">"adding *%p to in flight list for link %s"</span>,
<a name="l00540"></a>00540               bundle.object(), <a class="code" href="classdtn_1_1Link.html#18fba654bb084c0d68d5442579393439" title="Internal name of the link.">name_</a>.c_str());
<a name="l00541"></a>00541     
<a name="l00542"></a>00542     <a class="code" href="classdtn_1_1Link.html#fc4fe98181a47e648d7133898949d631" title="Queue of bundles that have been sent but not yet acknowledged.">inflight_</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.object());
<a name="l00543"></a>00543 
<a name="l00544"></a>00544     <a class="code" href="classdtn_1_1Link.html#a6e3ac679e8ef5bc7ad158a8487a6497">bundles_inflight_</a>++;
<a name="l00545"></a>00545     <a class="code" href="classdtn_1_1Link.html#bfdb39a4c12069033a21c50f12a4a0ef">bytes_inflight_</a> += total_len;
<a name="l00546"></a>00546 
<a name="l00547"></a>00547     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00548"></a>00548 }
<a name="l00549"></a>00549 
<a name="l00550"></a>00550 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00551"></a>00551 <span class="keywordtype">bool</span>
<a name="l00552"></a><a class="code" href="classdtn_1_1Link.html#db1a66a1c3d5b23ef362151326120bbb">00552</a> <a class="code" href="classdtn_1_1Link.html#db1a66a1c3d5b23ef362151326120bbb" title="Accessor functions to add/remove bundles from the link queue and inflight list, keeping...">Link::del_from_inflight</a>(<span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; bundle, <span class="keywordtype">size_t</span> total_len)
<a name="l00553"></a>00553 {
<a name="l00554"></a>00554     oasys::ScopeLock l(&amp;<a class="code" href="classdtn_1_1Link.html#9a028608b541c0e3d3c4af3aa3fb8712" title="Lock to protect internal data structures and state.">lock_</a>, <span class="stringliteral">"Link::del_from_inflight"</span>);
<a name="l00555"></a>00555 
<a name="l00556"></a>00556     <span class="keywordflow">if</span> (! <a class="code" href="classdtn_1_1Link.html#fc4fe98181a47e648d7133898949d631" title="Queue of bundles that have been sent but not yet acknowledged.">inflight_</a>.<a class="code" href="classdtn_1_1BundleList.html#b0171458e14d67307b74f98447062d68" title="Remove the given bundle from the list.">erase</a>(bundle)) {
<a name="l00557"></a>00557         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00558"></a>00558     }
<a name="l00559"></a>00559 
<a name="l00560"></a>00560     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#a6e3ac679e8ef5bc7ad158a8487a6497">bundles_inflight_</a> &gt; 0);
<a name="l00561"></a>00561     <a class="code" href="classdtn_1_1Link.html#a6e3ac679e8ef5bc7ad158a8487a6497">bundles_inflight_</a>--;
<a name="l00562"></a>00562     
<a name="l00563"></a>00563     <span class="comment">// sanity checks</span>
<a name="l00564"></a>00564     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(total_len != 0);
<a name="l00565"></a>00565     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#bfdb39a4c12069033a21c50f12a4a0ef">bytes_inflight_</a> &gt;= total_len) {
<a name="l00566"></a>00566         <a class="code" href="classdtn_1_1Link.html#bfdb39a4c12069033a21c50f12a4a0ef">bytes_inflight_</a> -= total_len;
<a name="l00567"></a>00567 
<a name="l00568"></a>00568     } <span class="keywordflow">else</span> {
<a name="l00569"></a>00569         log_err(<span class="stringliteral">"del_from_inflight: *%p bytes_inflight %u &lt; total_len %zu"</span>,
<a name="l00570"></a>00570                 bundle.object(), <a class="code" href="classdtn_1_1Link.html#bfdb39a4c12069033a21c50f12a4a0ef">bytes_inflight_</a>, total_len);
<a name="l00571"></a>00571     }
<a name="l00572"></a>00572     
<a name="l00573"></a>00573     log_debug(<span class="stringliteral">"removed *%p from inflight list (length %u)"</span>,
<a name="l00574"></a>00574               bundle.object(), <a class="code" href="classdtn_1_1Link.html#a6e3ac679e8ef5bc7ad158a8487a6497">bundles_inflight_</a>);
<a name="l00575"></a>00575     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00576"></a>00576 }
<a name="l00577"></a>00577 
<a name="l00578"></a>00578 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00579"></a>00579 <span class="keywordtype">int</span>
<a name="l00580"></a><a class="code" href="classdtn_1_1Link.html#03accdcb516ca16ba1c5c67fc64a2fa8">00580</a> <a class="code" href="classdtn_1_1Link.html#03accdcb516ca16ba1c5c67fc64a2fa8" title="Virtual from formatter.">Link::format</a>(<span class="keywordtype">char</span>* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>, <span class="keywordtype">size_t</span> sz)<span class="keyword"> const</span>
<a name="l00581"></a>00581 <span class="keyword"></span>{
<a name="l00582"></a>00582     <span class="keywordflow">return</span> snprintf(buf, sz, <span class="stringliteral">"%s [%s %s %s %s state=%s]"</span>,
<a name="l00583"></a>00583                     <a class="code" href="classdtn_1_1Link.html#e4cad7d0449f9a5c9cb3ea9693df09c4" title="Accessor to this links name.">name</a>(), <a class="code" href="classdtn_1_1Link.html#5bffae252da80b32679686d826f4d4cf" title="Accessor to next hop string.">nexthop</a>(), <a class="code" href="classdtn_1_1Link.html#1db82aaa68166ce7029df32710ee58f1" title="Remote&amp;#39;s endpoint ID (eg, dtn://hostname.dtn).">remote_eid_</a>.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(),
<a name="l00584"></a>00584                     <a class="code" href="classdtn_1_1Link.html#405aaca77bb12b2611ee49a8184b7829" title="Link type string conversion.">link_type_to_str</a>(<a class="code" href="classdtn_1_1Link.html#75dad1b5cff2bd5e84b06ffc57504c65" title="Return the type of the link.">type</a>()),
<a name="l00585"></a>00585                     <a class="code" href="classdtn_1_1Link.html#f909b48bf21f49b5646e22cb51151869" title="Accessor to this contact&amp;#39;s convergence layer.">clayer</a>()-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#1030bc8bf5d5ca898fad2433e30e44cf" title="Accessor for the convergence layer name.">name</a>(),
<a name="l00586"></a>00586                     <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">state_to_str</a>(<a class="code" href="classdtn_1_1Link.html#71a8fdd921fb0e93fd4c21f08da28a8b" title="Return the actual state.">state</a>()));
<a name="l00587"></a>00587 }
<a name="l00588"></a>00588 
<a name="l00589"></a>00589 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00590"></a>00590 <span class="keywordtype">void</span>
<a name="l00591"></a><a class="code" href="classdtn_1_1Link.html#92625abc0b8424f763824f099eee055d">00591</a> <a class="code" href="classdtn_1_1Link.html#92625abc0b8424f763824f099eee055d" title="Debugging printout.">Link::dump</a>(oasys::StringBuffer* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>)
<a name="l00592"></a>00592 {
<a name="l00593"></a>00593     oasys::ScopeLock l(&amp;<a class="code" href="classdtn_1_1Link.html#9a028608b541c0e3d3c4af3aa3fb8712" title="Lock to protect internal data structures and state.">lock_</a>, <span class="stringliteral">"Link::dump"</span>);
<a name="l00594"></a>00594 
<a name="l00595"></a>00595     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#da00d64fecd9930c831718421533de0d" title="Returns true if the link has been deleted; otherwise returns false.">isdeleted</a>()) {
<a name="l00596"></a>00596         log_debug(<span class="stringliteral">"Link::dump: cannot dump deleted link %s"</span>, <a class="code" href="classdtn_1_1Link.html#e4cad7d0449f9a5c9cb3ea9693df09c4" title="Accessor to this links name.">name</a>());
<a name="l00597"></a>00597         <span class="keywordflow">return</span>;
<a name="l00598"></a>00598     }
<a name="l00599"></a>00599 
<a name="l00600"></a>00600     buf-&gt;appendf(<span class="stringliteral">"Link %s:\n"</span>
<a name="l00601"></a>00601                  <span class="stringliteral">"clayer: %s\n"</span>
<a name="l00602"></a>00602                  <span class="stringliteral">"type: %s\n"</span>
<a name="l00603"></a>00603                  <span class="stringliteral">"state: %s\n"</span>
<a name="l00604"></a>00604                  <span class="stringliteral">"deleted: %s\n"</span>
<a name="l00605"></a>00605                  <span class="stringliteral">"nexthop: %s\n"</span>
<a name="l00606"></a>00606                  <span class="stringliteral">"remote eid: %s\n"</span>
<a name="l00607"></a>00607                  <span class="stringliteral">"mtu: %u\n"</span>
<a name="l00608"></a>00608                  <span class="stringliteral">"min_retry_interval: %u\n"</span>
<a name="l00609"></a>00609                  <span class="stringliteral">"max_retry_interval: %u\n"</span>
<a name="l00610"></a>00610                  <span class="stringliteral">"idle_close_time: %u\n"</span>
<a name="l00611"></a>00611                  <span class="stringliteral">"potential_downtime: %u\n"</span>
<a name="l00612"></a>00612                  <span class="stringliteral">"prevhop_hdr: %s\n"</span>,
<a name="l00613"></a>00613                  <a class="code" href="classdtn_1_1Link.html#e4cad7d0449f9a5c9cb3ea9693df09c4" title="Accessor to this links name.">name</a>(),
<a name="l00614"></a>00614                  <a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a>-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#1030bc8bf5d5ca898fad2433e30e44cf" title="Accessor for the convergence layer name.">name</a>(),
<a name="l00615"></a>00615                  <a class="code" href="classdtn_1_1Link.html#405aaca77bb12b2611ee49a8184b7829" title="Link type string conversion.">link_type_to_str</a>(<a class="code" href="classdtn_1_1Link.html#75dad1b5cff2bd5e84b06ffc57504c65" title="Return the type of the link.">type</a>()),
<a name="l00616"></a>00616                  <a class="code" href="classdtn_1_1Link.html#9681a1ea52ef3c5db6dcf37b04e5c280" title="Convert a link state into a string.">state_to_str</a>(<a class="code" href="classdtn_1_1Link.html#71a8fdd921fb0e93fd4c21f08da28a8b" title="Return the actual state.">state</a>()),
<a name="l00617"></a>00617                  (<a class="code" href="classdtn_1_1Link.html#72c1c919069f37959273f9a0379679d5" title="Flag, that when set to true, indicates that the link has been deleted.">deleted_</a>? <span class="stringliteral">"true"</span> : <span class="stringliteral">"false"</span>),
<a name="l00618"></a>00618                  <a class="code" href="classdtn_1_1Link.html#5bffae252da80b32679686d826f4d4cf" title="Accessor to next hop string.">nexthop</a>(),
<a name="l00619"></a>00619                  <a class="code" href="classdtn_1_1Link.html#1db82aaa68166ce7029df32710ee58f1" title="Remote&amp;#39;s endpoint ID (eg, dtn://hostname.dtn).">remote_eid_</a>.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(),
<a name="l00620"></a>00620                  <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#333734265a2a17aa4edcb97fbae31400" title="MTU of the link, used to control proactive fragmentation.">mtu_</a>,
<a name="l00621"></a>00621                  <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#fad825e84db3cb9e92ea0862e7cdf609" title="Minimum amount to wait between attempts to re-open the link (in seconds).">min_retry_interval_</a>,
<a name="l00622"></a>00622                  <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#814873f095484897985d1b79cb218f01" title="Maximum amount to wait between attempts to re-open the link (in seconds).">max_retry_interval_</a>,
<a name="l00623"></a>00623                  <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#b234c93dc26fd078732abdb4746822e6" title="Seconds of idle time before the link is closed.">idle_close_time_</a>,
<a name="l00624"></a>00624                  <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#836d9ef17e5ff0bb45b16826cc52e9c5" title="Conservative estimate of the maximum amount of time that the link may be down during...">potential_downtime_</a>,
<a name="l00625"></a>00625                  <a class="code" href="classdtn_1_1Link.html#f2c2e7e9451ceb7a0363b3a52b38b4d8" title="Parameters of the link.">params_</a>.<a class="code" href="structdtn_1_1Link_1_1Params.html#826790ff03eba2149cefc18802cdf6d5" title="Whether or not to send the previous hop header on this link.">prevhop_hdr_</a> ? <span class="stringliteral">"true"</span> : <span class="stringliteral">"false"</span>);
<a name="l00626"></a>00626 
<a name="l00627"></a>00627     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a> != NULL);
<a name="l00628"></a>00628     <a class="code" href="classdtn_1_1Link.html#07ec2bd779b594270491dd15e03127d2" title="Pointer to convergence layer.">clayer_</a>-&gt;<a class="code" href="classdtn_1_1ConvergenceLayer.html#852d2ac184b8701d53d2ae8a04a776df" title="Dump out CL specific link information.">dump_link</a>(<a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>(<span class="keyword">this</span>, <span class="stringliteral">"Link::dump"</span>), buf);
<a name="l00629"></a>00629 }
<a name="l00630"></a>00630 
<a name="l00631"></a>00631 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00632"></a>00632 <span class="keywordtype">void</span>
<a name="l00633"></a><a class="code" href="classdtn_1_1Link.html#ebb1e9d3bcc734ddf3263652d9f7cc14">00633</a> <a class="code" href="classdtn_1_1Link.html#ebb1e9d3bcc734ddf3263652d9f7cc14" title="Dump a printable version of the stats.">Link::dump_stats</a>(oasys::StringBuffer* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>)
<a name="l00634"></a>00634 {
<a name="l00635"></a>00635     oasys::ScopeLock l(&amp;<a class="code" href="classdtn_1_1Link.html#9a028608b541c0e3d3c4af3aa3fb8712" title="Lock to protect internal data structures and state.">lock_</a>, <span class="stringliteral">"Link::dump_stats"</span>);
<a name="l00636"></a>00636 
<a name="l00637"></a>00637     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#da00d64fecd9930c831718421533de0d" title="Returns true if the link has been deleted; otherwise returns false.">isdeleted</a>()) {
<a name="l00638"></a>00638         log_debug(<span class="stringliteral">"Link::dump_stats: "</span>
<a name="l00639"></a>00639                   <span class="stringliteral">"cannot dump stats for deleted link %s"</span>, <a class="code" href="classdtn_1_1Link.html#e4cad7d0449f9a5c9cb3ea9693df09c4" title="Accessor to this links name.">name</a>());
<a name="l00640"></a>00640         <span class="keywordflow">return</span>;
<a name="l00641"></a>00641     }
<a name="l00642"></a>00642 
<a name="l00643"></a>00643     u_int32_t uptime = <a class="code" href="classdtn_1_1Link.html#8f66801a2de483d745b7a0b619e12f0f" title="Stats for the link.">stats_</a>.<a class="code" href="structdtn_1_1Link_1_1Stats.html#7f8bb95c2198e76cbde8486f2751a154" title="The total uptime of the link, not counting the current contact.">uptime_</a>;
<a name="l00644"></a>00644     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#71c79dccb9b64a80879000ba232f7e9a" title="Current contact. contact_ != null iff link is open.">contact_</a> != NULL) {
<a name="l00645"></a>00645         uptime += (<a class="code" href="classdtn_1_1Link.html#71c79dccb9b64a80879000ba232f7e9a" title="Current contact. contact_ != null iff link is open.">contact_</a>-&gt;start_time().elapsed_ms() / 1000);
<a name="l00646"></a>00646     }
<a name="l00647"></a>00647 
<a name="l00648"></a>00648     u_int32_t throughput = 0;
<a name="l00649"></a>00649     <span class="keywordflow">if</span> (uptime != 0) {
<a name="l00650"></a>00650         throughput = (<a class="code" href="classdtn_1_1Link.html#8f66801a2de483d745b7a0b619e12f0f" title="Stats for the link.">stats_</a>.<a class="code" href="structdtn_1_1Link_1_1Stats.html#c91d69628ecb52abe58c54959da71593" title="Total byte count transmitted over the link.">bytes_transmitted_</a> * 8) / uptime;
<a name="l00651"></a>00651     }
<a name="l00652"></a>00652         
<a name="l00653"></a>00653     buf-&gt;appendf(<span class="stringliteral">"%u contact_attempts -- "</span>
<a name="l00654"></a>00654                  <span class="stringliteral">"%u contacts -- "</span>
<a name="l00655"></a>00655                  <span class="stringliteral">"%u bundles_transmitted -- "</span>
<a name="l00656"></a>00656                  <span class="stringliteral">"%u bytes_transmitted -- "</span>
<a name="l00657"></a>00657                  <span class="stringliteral">"%u bundles_queued -- "</span>
<a name="l00658"></a>00658                  <span class="stringliteral">"%u bytes_queued -- "</span>
<a name="l00659"></a>00659                  <span class="stringliteral">"%u bundles_inflight -- "</span>
<a name="l00660"></a>00660                  <span class="stringliteral">"%u bytes_inflight -- "</span>
<a name="l00661"></a>00661                  <span class="stringliteral">"%u bundles_cancelled -- "</span>
<a name="l00662"></a>00662                  <span class="stringliteral">"%u uptime -- "</span>
<a name="l00663"></a>00663                  <span class="stringliteral">"%u throughput_bps"</span>,
<a name="l00664"></a>00664                  <a class="code" href="classdtn_1_1Link.html#8f66801a2de483d745b7a0b619e12f0f" title="Stats for the link.">stats_</a>.<a class="code" href="structdtn_1_1Link_1_1Stats.html#6e3d627044f1947e6df365ac31831cd6" title="Number of times the link attempted to be opened.">contact_attempts_</a>,
<a name="l00665"></a>00665                  <a class="code" href="classdtn_1_1Link.html#8f66801a2de483d745b7a0b619e12f0f" title="Stats for the link.">stats_</a>.<a class="code" href="structdtn_1_1Link_1_1Stats.html#28eede330812cec5fb3e60fcdde013ff" title="Number of contacts ever successfully opened on the link (equivalent to the number...">contacts_</a>,
<a name="l00666"></a>00666                  <a class="code" href="classdtn_1_1Link.html#8f66801a2de483d745b7a0b619e12f0f" title="Stats for the link.">stats_</a>.<a class="code" href="structdtn_1_1Link_1_1Stats.html#dcfb18ecf12e47b7ed71c4f984e06c7a" title="Number of bundles transmitted over the link.">bundles_transmitted_</a>,
<a name="l00667"></a>00667                  <a class="code" href="classdtn_1_1Link.html#8f66801a2de483d745b7a0b619e12f0f" title="Stats for the link.">stats_</a>.<a class="code" href="structdtn_1_1Link_1_1Stats.html#c91d69628ecb52abe58c54959da71593" title="Total byte count transmitted over the link.">bytes_transmitted_</a>,
<a name="l00668"></a>00668                  <a class="code" href="classdtn_1_1Link.html#a1c555412ff256489d257a6c838f7b2a">bundles_queued_</a>,
<a name="l00669"></a>00669                  <a class="code" href="classdtn_1_1Link.html#611750c82a1ae0fe8d2c9d22097b5bbf">bytes_queued_</a>,
<a name="l00670"></a>00670                  <a class="code" href="classdtn_1_1Link.html#a6e3ac679e8ef5bc7ad158a8487a6497">bundles_inflight_</a>,
<a name="l00671"></a>00671                  <a class="code" href="classdtn_1_1Link.html#bfdb39a4c12069033a21c50f12a4a0ef">bytes_inflight_</a>,
<a name="l00672"></a>00672                  <a class="code" href="classdtn_1_1Link.html#8f66801a2de483d745b7a0b619e12f0f" title="Stats for the link.">stats_</a>.<a class="code" href="structdtn_1_1Link_1_1Stats.html#5dca4758e24ed07e14c25f928330c340" title="Number of bundles with cancelled transmission.">bundles_cancelled_</a>,
<a name="l00673"></a>00673                  uptime,
<a name="l00674"></a>00674                  throughput);
<a name="l00675"></a>00675 
<a name="l00676"></a>00676     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1Link.html#2dd58ea037907dc2a5e5fe30d61414b2" title="Router specific info, if needed.">router_info_</a>) {
<a name="l00677"></a>00677         <a class="code" href="classdtn_1_1Link.html#2dd58ea037907dc2a5e5fe30d61414b2" title="Router specific info, if needed.">router_info_</a>-&gt;<a class="code" href="classdtn_1_1RouterInfo.html#86479d019124cc509ac711b397257c23">dump_stats</a>(buf);
<a name="l00678"></a>00678     }
<a name="l00679"></a>00679 }
<a name="l00680"></a>00680 
<a name="l00681"></a>00681 } <span class="comment">// namespace dtn</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:57 2009 for DTN Reference Implementation by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>