Sophie

Sophie

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

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: RouteEntry.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>RouteEntry.cc</h1><a href="RouteEntry_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 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 <span class="preprocessor">#include &lt;oasys/util/StringBuffer.h&gt;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="BundleRouter_8h.html">BundleRouter.h</a>"</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="RouteEntry_8h.html">RouteEntry.h</a>"</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="EndpointIDOpt_8h.html">naming/EndpointIDOpt.h</a>"</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="keyword">namespace </span>dtn {
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00030"></a><a class="code" href="classdtn_1_1RouteEntry.html#d8728109a6a145f40faa939f551860d1">00030</a> <a class="code" href="classdtn_1_1RouteEntry.html#d8728109a6a145f40faa939f551860d1" title="First constructor requires a destination pattern and a next hop link.">RouteEntry::RouteEntry</a>(<span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a>&amp; dest_pattern,
<a name="l00031"></a>00031                        <span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>&amp; link)
<a name="l00032"></a>00032     : dest_pattern_(dest_pattern),
<a name="l00033"></a>00033       source_pattern_(<a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a>::WILDCARD_EID()),
<a name="l00034"></a>00034       bundle_cos_((1 &lt;&lt; <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>::<a class="code" href="dtn__types_8h.html#993858e35739619750a07d5dc1c275e06779af0a27e4d14a809e52f4810cdddb">COS_BULK</a>) |
<a name="l00035"></a>00035                   (1 &lt;&lt; <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>::<a class="code" href="dtn__types_8h.html#993858e35739619750a07d5dc1c275e0f5a0479d0c742791ecd3827d8bf82bfc">COS_NORMAL</a>) |
<a name="l00036"></a>00036                   (1 &lt;&lt; <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>::<a class="code" href="dtn__types_8h.html#993858e35739619750a07d5dc1c275e0c926b03ca05898bf8c5d655c29d82935">COS_EXPEDITED</a>)),
<a name="l00037"></a>00037       priority_(<a class="code" href="classdtn_1_1BundleRouter.html" title="The BundleRouter is the main decision maker for all routing decisions related to...">BundleRouter</a>::config_.default_priority_),
<a name="l00038"></a>00038       link_(link.object(), <span class="stringliteral">"RouteEntry"</span>),
<a name="l00039"></a>00039       route_to_(),
<a name="l00040"></a>00040       action_(<a class="code" href="classdtn_1_1ForwardingInfo.html" title="Class to encapsulate bundle forwarding information.">ForwardingInfo</a>::FORWARD_ACTION),
<a name="l00041"></a>00041       custody_spec_(),
<a name="l00042"></a>00042       info_(NULL)
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045 
<a name="l00046"></a>00046 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00047"></a><a class="code" href="classdtn_1_1RouteEntry.html#6c88fb5f1079a83b8a42d1a013aa0a1e">00047</a> <a class="code" href="classdtn_1_1RouteEntry.html#d8728109a6a145f40faa939f551860d1" title="First constructor requires a destination pattern and a next hop link.">RouteEntry::RouteEntry</a>(<span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a>&amp; dest_pattern,
<a name="l00048"></a>00048                        <span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a>&amp; route_to)
<a name="l00049"></a>00049     : dest_pattern_(dest_pattern),
<a name="l00050"></a>00050       source_pattern_(<a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a>::WILDCARD_EID()),
<a name="l00051"></a>00051       bundle_cos_((1 &lt;&lt; <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>::<a class="code" href="dtn__types_8h.html#993858e35739619750a07d5dc1c275e06779af0a27e4d14a809e52f4810cdddb">COS_BULK</a>) |
<a name="l00052"></a>00052                   (1 &lt;&lt; <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>::<a class="code" href="dtn__types_8h.html#993858e35739619750a07d5dc1c275e0f5a0479d0c742791ecd3827d8bf82bfc">COS_NORMAL</a>) |
<a name="l00053"></a>00053                   (1 &lt;&lt; <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>::<a class="code" href="dtn__types_8h.html#993858e35739619750a07d5dc1c275e0c926b03ca05898bf8c5d655c29d82935">COS_EXPEDITED</a>)),
<a name="l00054"></a>00054       priority_(<a class="code" href="classdtn_1_1BundleRouter.html" title="The BundleRouter is the main decision maker for all routing decisions related to...">BundleRouter</a>::config_.default_priority_),
<a name="l00055"></a>00055       link_(<span class="stringliteral">"RouteEntry"</span>),
<a name="l00056"></a>00056       route_to_(route_to),
<a name="l00057"></a>00057       action_(<a class="code" href="classdtn_1_1ForwardingInfo.html" title="Class to encapsulate bundle forwarding information.">ForwardingInfo</a>::FORWARD_ACTION),
<a name="l00058"></a>00058       custody_spec_(),
<a name="l00059"></a>00059       info_(NULL)
<a name="l00060"></a>00060 {
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062 
<a name="l00063"></a>00063 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00064"></a><a class="code" href="classdtn_1_1RouteEntry.html#ad64e0b789ad44c9780a4e1d0eb18f7b">00064</a> <a class="code" href="classdtn_1_1RouteEntry.html#ad64e0b789ad44c9780a4e1d0eb18f7b" title="Destructor.">RouteEntry::~RouteEntry</a>()
<a name="l00065"></a>00065 {
<a name="l00066"></a>00066     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1RouteEntry.html#5f04afd6e9a916896cbc470eff50277b" title="Abstract pointer to any algorithm-specific state that needs to be stored in the route...">info_</a>)
<a name="l00067"></a>00067         <span class="keyword">delete</span> <a class="code" href="classdtn_1_1RouteEntry.html#5f04afd6e9a916896cbc470eff50277b" title="Abstract pointer to any algorithm-specific state that needs to be stored in the route...">info_</a>;
<a name="l00068"></a>00068 }
<a name="l00069"></a>00069 
<a name="l00070"></a>00070 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00071"></a>00071 <span class="keywordtype">int</span>
<a name="l00072"></a><a class="code" href="classdtn_1_1RouteEntry.html#b337f3c19e9fab98b57bbcd286477483">00072</a> <a class="code" href="classdtn_1_1RouteEntry.html#b337f3c19e9fab98b57bbcd286477483" title="Hook to parse route configuration options.">RouteEntry::parse_options</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="l00073"></a>00073 {
<a name="l00074"></a>00074     <span class="keywordtype">int</span> num = <a class="code" href="classdtn_1_1RouteEntry.html#45ff6870afdd5b071f427b2800365348" title="Custody timer specification.">custody_spec_</a>.<a class="code" href="classdtn_1_1CustodyTimerSpec.html#8d26dd3fc0961ed3d0bf558f86342cc9" title="Parse options to set the fields of the custody timer.">parse_options</a>(argc, argv, invalidp);
<a name="l00075"></a>00075     <span class="keywordflow">if</span> (num == -1) {
<a name="l00076"></a>00076         <span class="keywordflow">return</span> -1;
<a name="l00077"></a>00077     }
<a name="l00078"></a>00078     
<a name="l00079"></a>00079     argc -= num;
<a name="l00080"></a>00080     
<a name="l00081"></a>00081     oasys::OptParser p;
<a name="l00082"></a>00082 
<a name="l00083"></a>00083     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...">EndpointIDOpt</a>(<span class="stringliteral">"source_eid"</span>, &amp;<a class="code" href="classdtn_1_1RouteEntry.html#a108b70c5f570cc67b7063f8221d47e4" title="The pattern that matches bundles&amp;#39; source eid.">source_pattern_</a>));
<a name="l00084"></a>00084     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"route_priority"</span>, &amp;<a class="code" href="classdtn_1_1RouteEntry.html#acdebef93f58893dc9e951248180e0ef" title="Route priority.">priority_</a>));
<a name="l00085"></a>00085     p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"cos_flags"</span>, &amp;<a class="code" href="classdtn_1_1RouteEntry.html#8d62a270bf39c7951038dfd0b59a6f56" title="Bit vector of the bundle priority classes that should match this route.">bundle_cos_</a>));
<a name="l00086"></a>00086     oasys::EnumOpt::Case fwdopts[] = {
<a name="l00087"></a>00087         {<span class="stringliteral">"forward"</span>, <a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b59471efad47dbf6015f5e4458ac355eabbaa" title="Forward the bundle to only this next hop.">ForwardingInfo::FORWARD_ACTION</a>},
<a name="l00088"></a>00088         {<span class="stringliteral">"copy"</span>,    <a class="code" href="classdtn_1_1ForwardingInfo.html#18ec95dc1b1b8a7e9df9873a0d9b594777ba7ba2355d6b87536afc9ef78efeb8" title="Forward a copy of the bundle.">ForwardingInfo::COPY_ACTION</a>},
<a name="l00089"></a>00089         {0, 0}
<a name="l00090"></a>00090     };
<a name="l00091"></a>00091 
<a name="l00092"></a>00092     <span class="comment">// default is to not change the action</span>
<a name="l00093"></a>00093     <span class="keywordtype">int</span> <a class="code" href="classdtn_1_1RouteEntry.html#0fe979e29165c5bdad1a126f1a0fb04f" title="Accessors.">action</a> = <a class="code" href="classdtn_1_1RouteEntry.html#abaeac9b828ebf22e8dc8ccfc2564d01" title="Forwarding action code.">action_</a>;
<a name="l00094"></a>00094     p.addopt(<span class="keyword">new</span> oasys::EnumOpt(<span class="stringliteral">"action"</span>, fwdopts, &amp;action));
<a name="l00095"></a>00095 
<a name="l00096"></a>00096     <span class="keywordtype">int</span> num2 = p.parse_and_shift(argc, argv, invalidp);
<a name="l00097"></a>00097     <span class="keywordflow">if</span> (num2 == -1) {
<a name="l00098"></a>00098         <span class="keywordflow">return</span> -1;
<a name="l00099"></a>00099     }
<a name="l00100"></a>00100 
<a name="l00101"></a>00101     <span class="comment">// this is paranoid, but action_ needs to be a u_int32_t since it's</span>
<a name="l00102"></a>00102     <span class="comment">// serialized, but EnumOpt takes an int*</span>
<a name="l00103"></a>00103     <a class="code" href="classdtn_1_1RouteEntry.html#abaeac9b828ebf22e8dc8ccfc2564d01" title="Forwarding action code.">action_</a> = action;
<a name="l00104"></a>00104     
<a name="l00105"></a>00105     <span class="keywordflow">if</span> ((<a class="code" href="classdtn_1_1RouteEntry.html#8d62a270bf39c7951038dfd0b59a6f56" title="Bit vector of the bundle priority classes that should match this route.">bundle_cos_</a> == 0) || (<a class="code" href="classdtn_1_1RouteEntry.html#8d62a270bf39c7951038dfd0b59a6f56" title="Bit vector of the bundle priority classes that should match this route.">bundle_cos_</a> &gt;= (1 &lt;&lt; 3))) {
<a name="l00106"></a>00106         <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* s = <span class="stringliteral">"invalid cos flags"</span>;
<a name="l00107"></a>00107         invalidp = &amp;s;
<a name="l00108"></a>00108         <span class="keywordflow">return</span> -1;
<a name="l00109"></a>00109     }
<a name="l00110"></a>00110 
<a name="l00111"></a>00111     <span class="keywordflow">return</span> num + num2;
<a name="l00112"></a>00112 }
<a name="l00113"></a>00113 
<a name="l00114"></a>00114 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00115"></a>00115 <span class="keywordtype">int</span>
<a name="l00116"></a><a class="code" href="classdtn_1_1RouteEntry.html#d22539a3948433218b8cf9695c512ce7">00116</a> <a class="code" href="classdtn_1_1RouteEntry.html#d22539a3948433218b8cf9695c512ce7" title="Virtual from formatter.">RouteEntry::format</a>(<span class="keywordtype">char</span>* bp, <span class="keywordtype">size_t</span> sz)<span class="keyword"> const</span>
<a name="l00117"></a>00117 <span class="keyword"></span>{
<a name="l00118"></a>00118     <span class="comment">// XXX/demmer when the route table is serialized, add an integer</span>
<a name="l00119"></a>00119     <span class="comment">// id for the route entry and include it here.</span>
<a name="l00120"></a>00120     <span class="keywordflow">return</span> snprintf(bp, sz, <span class="stringliteral">"%s -&gt; %s (%s)"</span>,
<a name="l00121"></a>00121                     <a class="code" href="classdtn_1_1RouteEntry.html#70826ec32537a2f6b08c8359d59a105d" title="Accessors.">dest_pattern</a>().c_str(),
<a name="l00122"></a>00122                     <a class="code" href="classdtn_1_1RouteEntry.html#41c79b5f1b69681a2ae73dfdf064138f" title="Accessors.">next_hop_str</a>().c_str(),
<a name="l00123"></a>00123                     <a class="code" href="classdtn_1_1ForwardingInfo.html#9b424d4d2985beeffbcd55d6be8cd937">ForwardingInfo::action_to_str</a>(<a class="code" href="classdtn_1_1RouteEntry.html#0fe979e29165c5bdad1a126f1a0fb04f" title="Accessors.">action</a>()));
<a name="l00124"></a>00124 }
<a name="l00125"></a>00125 
<a name="l00126"></a><a class="code" href="namespacedtn.html#735f952f46920b78c8b3e922f29e0ec4">00126</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="namespacedtn.html#735f952f46920b78c8b3e922f29e0ec4">DASHES</a> =
<a name="l00127"></a>00127     <span class="stringliteral">"---------------------------------------------"</span>
<a name="l00128"></a>00128     <span class="stringliteral">"---------------------------------------------"</span>
<a name="l00129"></a>00129     <span class="stringliteral">"---------------------------------------------"</span>
<a name="l00130"></a>00130     <span class="stringliteral">"---------------------------------------------"</span>
<a name="l00131"></a>00131     <span class="stringliteral">"---------------------------------------------"</span>
<a name="l00132"></a>00132     <span class="stringliteral">"---------------------------------------------"</span>;
<a name="l00133"></a>00133 
<a name="l00134"></a>00134 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00135"></a>00135 <span class="keywordtype">void</span>
<a name="l00136"></a><a class="code" href="classdtn_1_1RouteEntry.html#7e8875141f778f47b65f6e79c456ffa6">00136</a> <a class="code" href="classdtn_1_1RouteEntry.html#7e8875141f778f47b65f6e79c456ffa6" title="Dump a header string in preparation for subsequent calls to dump();.">RouteEntry::dump_header</a>(oasys::StringBuffer* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>,
<a name="l00137"></a>00137                         <span class="keywordtype">int</span> dest_eid_width,
<a name="l00138"></a>00138                         <span class="keywordtype">int</span> source_eid_width,
<a name="l00139"></a>00139                         <span class="keywordtype">int</span> next_hop_width)
<a name="l00140"></a>00140 {
<a name="l00141"></a>00141     <span class="comment">// though this is a less efficient way of appending this data, it</span>
<a name="l00142"></a>00142     <span class="comment">// makes it much easier to copy the format string to the ::dump</span>
<a name="l00143"></a>00143     <span class="comment">// method, and given that it's only used for diagnostics, the</span>
<a name="l00144"></a>00144     <span class="comment">// performance impact is negligible</span>
<a name="l00145"></a>00145     buf-&gt;appendf(<span class="stringliteral">"%-*.*s %-*.*s %3s    %-*.*s %-7s %5s [%-15s]\n"</span>
<a name="l00146"></a>00146                  <span class="stringliteral">"%-*.*s %-*.*s %3s    %-*.*s %-7s %5s [%-5s %-3s %-5s]\n"</span>
<a name="l00147"></a>00147                  <span class="stringliteral">"%.*s\n"</span>,
<a name="l00148"></a>00148                  dest_eid_width, dest_eid_width, <span class="stringliteral">"destination"</span>,
<a name="l00149"></a>00149                  source_eid_width, source_eid_width, <span class="stringliteral">"source"</span>,
<a name="l00150"></a>00150                  <span class="stringliteral">"COS"</span>,
<a name="l00151"></a>00151                  next_hop_width, next_hop_width, <span class="stringliteral">"next hop"</span>,
<a name="l00152"></a>00152                  <span class="stringliteral">" fwd  "</span>,
<a name="l00153"></a>00153                  <span class="stringliteral">"route"</span>,
<a name="l00154"></a>00154                  <span class="stringliteral">"custody timeout"</span>,
<a name="l00155"></a>00155                  
<a name="l00156"></a>00156                  dest_eid_width, dest_eid_width, <span class="stringliteral">"endpoint id"</span>,
<a name="l00157"></a>00157                  source_eid_width, source_eid_width, <span class="stringliteral">" eid"</span>,
<a name="l00158"></a>00158                  <span class="stringliteral">"BNE"</span>,
<a name="l00159"></a>00159                  next_hop_width, next_hop_width, <span class="stringliteral">"link/eid"</span>,
<a name="l00160"></a>00160                  <span class="stringliteral">"action"</span>,
<a name="l00161"></a>00161                  <span class="stringliteral">"prio"</span>,
<a name="l00162"></a>00162                  <span class="stringliteral">"min"</span>,
<a name="l00163"></a>00163                  <span class="stringliteral">"pct"</span>,
<a name="l00164"></a>00164                  <span class="stringliteral">"  max"</span>,
<a name="l00165"></a>00165                  
<a name="l00166"></a>00166                  dest_eid_width + source_eid_width + next_hop_width + 51,
<a name="l00167"></a>00167                  <a class="code" href="namespacedtn.html#735f952f46920b78c8b3e922f29e0ec4">DASHES</a>);
<a name="l00168"></a>00168 }
<a name="l00169"></a>00169 
<a name="l00170"></a>00170 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00171"></a>00171 <span class="keywordtype">void</span>
<a name="l00172"></a><a class="code" href="classdtn_1_1RouteEntry.html#e6b63fd89814524f9eb1efbaf09657e9">00172</a> <a class="code" href="classdtn_1_1RouteEntry.html#e6b63fd89814524f9eb1efbaf09657e9" title="Helper for dump().">RouteEntry::append_long_string</a>(oasys::StringBuffer* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>,
<a name="l00173"></a>00173                                oasys::StringVector* long_strings,
<a name="l00174"></a>00174                                <span class="keywordtype">int</span> width, <span class="keyword">const</span> std::string&amp; str)
<a name="l00175"></a>00175 {
<a name="l00176"></a>00176     <span class="keywordtype">size_t</span> tmplen;
<a name="l00177"></a>00177     <span class="keywordtype">char</span> tmp[64];
<a name="l00178"></a>00178     
<a name="l00179"></a>00179     <span class="keywordflow">if</span> (str.length() &lt;= (size_t)width) {
<a name="l00180"></a>00180         buf-&gt;appendf(<span class="stringliteral">"%-*.*s "</span>, width, width, str.c_str());
<a name="l00181"></a>00181     } <span class="keywordflow">else</span> {
<a name="l00182"></a>00182         <span class="keywordtype">size_t</span> index;
<a name="l00183"></a>00183         <span class="keywordflow">for</span> (index = 0; index &lt; long_strings-&gt;size(); ++index) {
<a name="l00184"></a>00184             <span class="keywordflow">if</span> ((*long_strings)[index] == str) <span class="keywordflow">break</span>;
<a name="l00185"></a>00185         }
<a name="l00186"></a>00186         <span class="keywordflow">if</span> (index == long_strings-&gt;size()) {
<a name="l00187"></a>00187             long_strings-&gt;push_back(str);
<a name="l00188"></a>00188         }
<a name="l00189"></a>00189             
<a name="l00190"></a>00190         tmplen = snprintf(tmp, <span class="keyword">sizeof</span>(tmp), <span class="stringliteral">"[%zu] "</span>, index);
<a name="l00191"></a>00191         buf-&gt;appendf(<span class="stringliteral">"%.*s... %s"</span>,
<a name="l00192"></a>00192                      width - 3 - (<span class="keywordtype">int</span>)tmplen, str.c_str(), tmp);
<a name="l00193"></a>00193 
<a name="l00194"></a>00194     }
<a name="l00195"></a>00195 }
<a name="l00196"></a>00196 
<a name="l00197"></a>00197 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00198"></a>00198 <span class="keywordtype">void</span>
<a name="l00199"></a><a class="code" href="classdtn_1_1RouteEntry.html#83527de99091b10b59d0ec3742194514">00199</a> <a class="code" href="classdtn_1_1RouteEntry.html#83527de99091b10b59d0ec3742194514" title="Dump a string representation of the route entry.">RouteEntry::dump</a>(oasys::StringBuffer* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>,
<a name="l00200"></a>00200                  oasys::StringVector* long_strings,
<a name="l00201"></a>00201                  <span class="keywordtype">int</span> dest_eid_width,
<a name="l00202"></a>00202                  <span class="keywordtype">int</span> source_eid_width,
<a name="l00203"></a>00203                  <span class="keywordtype">int</span> next_hop_width)<span class="keyword"> const</span>
<a name="l00204"></a>00204 <span class="keyword"></span>{
<a name="l00205"></a>00205     <a class="code" href="classdtn_1_1RouteEntry.html#e6b63fd89814524f9eb1efbaf09657e9" title="Helper for dump().">append_long_string</a>(buf, long_strings, dest_eid_width, <a class="code" href="classdtn_1_1RouteEntry.html#70826ec32537a2f6b08c8359d59a105d" title="Accessors.">dest_pattern</a>().str());
<a name="l00206"></a>00206     <a class="code" href="classdtn_1_1RouteEntry.html#e6b63fd89814524f9eb1efbaf09657e9" title="Helper for dump().">append_long_string</a>(buf, long_strings, source_eid_width, <a class="code" href="classdtn_1_1RouteEntry.html#ed80ef80b6cfb5c19f128fe346090707" title="Accessors.">source_pattern</a>().str());
<a name="l00207"></a>00207 
<a name="l00208"></a>00208     buf-&gt;appendf(<span class="stringliteral">"%c%c%c -&gt; "</span>,
<a name="l00209"></a>00209                  (<a class="code" href="classdtn_1_1RouteEntry.html#8d62a270bf39c7951038dfd0b59a6f56" title="Bit vector of the bundle priority classes that should match this route.">bundle_cos_</a> &amp; (1 &lt;&lt; <a class="code" href="classdtn_1_1Bundle.html#ee1ec0a9c045adc48dc8751f54f59e64cdd03b2fd0d69a8085cbce1d8941690f" title="lowest priority">Bundle::COS_BULK</a>))      ? <span class="charliteral">'1'</span> : <span class="charliteral">'0'</span>,
<a name="l00210"></a>00210                  (<a class="code" href="classdtn_1_1RouteEntry.html#8d62a270bf39c7951038dfd0b59a6f56" title="Bit vector of the bundle priority classes that should match this route.">bundle_cos_</a> &amp; (1 &lt;&lt; <a class="code" href="classdtn_1_1Bundle.html#ee1ec0a9c045adc48dc8751f54f59e649acfb0603df69344a00cae0aa885d78f" title="regular priority">Bundle::COS_NORMAL</a>))    ? <span class="charliteral">'1'</span> : <span class="charliteral">'0'</span>,
<a name="l00211"></a>00211                  (<a class="code" href="classdtn_1_1RouteEntry.html#8d62a270bf39c7951038dfd0b59a6f56" title="Bit vector of the bundle priority classes that should match this route.">bundle_cos_</a> &amp; (1 &lt;&lt; <a class="code" href="classdtn_1_1Bundle.html#ee1ec0a9c045adc48dc8751f54f59e64ae2b7023d5a38cf3497e08a4db9e907d" title="important">Bundle::COS_EXPEDITED</a>)) ? <span class="charliteral">'1'</span> : <span class="charliteral">'0'</span>);
<a name="l00212"></a>00212 
<a name="l00213"></a>00213     <a class="code" href="classdtn_1_1RouteEntry.html#e6b63fd89814524f9eb1efbaf09657e9" title="Helper for dump().">append_long_string</a>(buf, long_strings, next_hop_width, <a class="code" href="classdtn_1_1RouteEntry.html#41c79b5f1b69681a2ae73dfdf064138f" title="Accessors.">next_hop_str</a>());
<a name="l00214"></a>00214     
<a name="l00215"></a>00215     buf-&gt;appendf(<span class="stringliteral">"%7s %5d [%-5d %3d %5d]\n"</span>,
<a name="l00216"></a>00216                  <a class="code" href="classdtn_1_1ForwardingInfo.html#9b424d4d2985beeffbcd55d6be8cd937">ForwardingInfo::action_to_str</a>(<a class="code" href="classdtn_1_1RouteEntry.html#0fe979e29165c5bdad1a126f1a0fb04f" title="Accessors.">action</a>()),
<a name="l00217"></a>00217                  <a class="code" href="classdtn_1_1RouteEntry.html#3d1340ea310acb204795bd634893c8f0" title="Accessors.">priority</a>(),
<a name="l00218"></a>00218                  <a class="code" href="classdtn_1_1RouteEntry.html#846eaa2c3a7324662a346c6bc0e5a69b" title="Accessors.">custody_spec</a>().min_,
<a name="l00219"></a>00219                  <a class="code" href="classdtn_1_1RouteEntry.html#846eaa2c3a7324662a346c6bc0e5a69b" title="Accessors.">custody_spec</a>().lifetime_pct_,
<a name="l00220"></a>00220                  <a class="code" href="classdtn_1_1RouteEntry.html#846eaa2c3a7324662a346c6bc0e5a69b" title="Accessors.">custody_spec</a>().max_);
<a name="l00221"></a>00221 }
<a name="l00222"></a>00222 
<a name="l00223"></a>00223 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00224"></a>00224 <span class="keywordtype">void</span>
<a name="l00225"></a><a class="code" href="classdtn_1_1RouteEntry.html#f634f73246c9500322ce03b129762ca6">00225</a> <a class="code" href="classdtn_1_1RouteEntry.html#f634f73246c9500322ce03b129762ca6" title="Virtual from SerializableObject.">RouteEntry::serialize</a>(oasys::SerializeAction *a)
<a name="l00226"></a>00226 {
<a name="l00227"></a>00227     a-&gt;process(<span class="stringliteral">"dest_pattern"</span>, &amp;<a class="code" href="classdtn_1_1RouteEntry.html#8958daa0e1afa57c10eb86ac84cbff7f" title="The pattern that matches bundles&amp;#39; destination eid.">dest_pattern_</a>);
<a name="l00228"></a>00228     a-&gt;process(<span class="stringliteral">"source_pattern"</span>, &amp;<a class="code" href="classdtn_1_1RouteEntry.html#a108b70c5f570cc67b7063f8221d47e4" title="The pattern that matches bundles&amp;#39; source eid.">source_pattern_</a>);
<a name="l00229"></a>00229     a-&gt;process(<span class="stringliteral">"bundle_cos"</span>, &amp;<a class="code" href="classdtn_1_1RouteEntry.html#8d62a270bf39c7951038dfd0b59a6f56" title="Bit vector of the bundle priority classes that should match this route.">bundle_cos_</a>);
<a name="l00230"></a>00230     a-&gt;process(<span class="stringliteral">"priority"</span>, &amp;<a class="code" href="classdtn_1_1RouteEntry.html#acdebef93f58893dc9e951248180e0ef" title="Route priority.">priority_</a>);
<a name="l00231"></a>00231     a-&gt;process(<span class="stringliteral">"link"</span>, const_cast&lt;std::string *&gt;(&amp;<a class="code" href="classdtn_1_1RouteEntry.html#176d090ea00dc64ede6503dff98b955f" title="Next hop link if known.">link_</a>-&gt;name_str()));
<a name="l00232"></a>00232     a-&gt;process(<span class="stringliteral">"route_to"</span>, &amp;<a class="code" href="classdtn_1_1RouteEntry.html#50b5f49c41d0385b5fc31b98ce0efe69" title="Route destination for recursive lookups.">route_to_</a>);
<a name="l00233"></a>00233     a-&gt;process(<span class="stringliteral">"action"</span>, &amp;<a class="code" href="classdtn_1_1RouteEntry.html#abaeac9b828ebf22e8dc8ccfc2564d01" title="Forwarding action code.">action_</a>);
<a name="l00234"></a>00234     a-&gt;process(<span class="stringliteral">"custody_spec"</span>, &amp;<a class="code" href="classdtn_1_1RouteEntry.html#45ff6870afdd5b071f427b2800365348" title="Custody timer specification.">custody_spec_</a>);
<a name="l00235"></a>00235 
<a name="l00236"></a>00236     <span class="comment">// XXX/demmer handle serialization of info</span>
<a name="l00237"></a>00237 }
<a name="l00238"></a>00238 
<a name="l00239"></a>00239 } <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>