Sophie

Sophie

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

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: NodeCommand.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>NodeCommand.cc</h1><a href="NodeCommand_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 2005-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;stdlib.h&gt;</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="sim_2Node_8h.html">Node.h</a>"</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="NodeCommand_8h.html">NodeCommand.h</a>"</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="SimConvergenceLayer_8h.html">SimConvergenceLayer.h</a>"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="SimRegistration_8h.html">SimRegistration.h</a>"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="Simulator_8h.html">Simulator.h</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="Topology_8h.html">Topology.h</a>"</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="TrAgent_8h.html">TrAgent.h</a>"</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="bundling_2Bundle_8h.html">bundling/Bundle.h</a>"</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="ContactManager_8h.html">contacts/ContactManager.h</a>"</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="contacts_2Link_8h.html">contacts/Link.h</a>"</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="EndpointID_8h.html">naming/EndpointID.h</a>"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="BundleRouter_8h.html">routing/BundleRouter.h</a>"</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include "<a class="code" href="RouteTable_8h.html">routing/RouteTable.h</a>"</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include "<a class="code" href="RegistrationTable_8h.html">reg/RegistrationTable.h</a>"</span>
<a name="l00037"></a>00037 
<a name="l00038"></a>00038 <span class="keyword">using namespace </span>dtn;
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 <span class="keyword">namespace </span>dtnsim {
<a name="l00041"></a>00041 
<a name="l00042"></a><a class="code" href="classdtnsim_1_1NodeCommand.html#52c77080064abb559695d5c6be18db1e">00042</a> <a class="code" href="classdtnsim_1_1NodeCommand.html#52c77080064abb559695d5c6be18db1e">NodeCommand::NodeCommand</a>(<a class="code" href="classdtnsim_1_1Node.html" title="Class representing a node in the simulator (i.e.">Node</a>* node)
<a name="l00043"></a>00043     : TclCommand(node-&gt;name()), node_(node),
<a name="l00044"></a>00044       storage_cmd_(node-&gt;storage_config())
<a name="l00045"></a>00045 {
<a name="l00046"></a>00046 }
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 <span class="keywordtype">int</span>
<a name="l00049"></a><a class="code" href="classdtnsim_1_1NodeCommand.html#8ca12cec68791bbb93690d73e85d306a">00049</a> <a class="code" href="classdtnsim_1_1NodeCommand.html#8ca12cec68791bbb93690d73e85d306a" title="virtual from TclCommand">NodeCommand::exec</a>(<span class="keywordtype">int</span> objc, Tcl_Obj** objv, Tcl_Interp* interp)
<a name="l00050"></a>00050 {
<a name="l00051"></a>00051     <span class="keywordtype">int</span> argc = objc;
<a name="l00052"></a>00052     <span class="keyword">const</span> <span class="keywordtype">char</span>* argv[objc];
<a name="l00053"></a>00053     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; objc; ++i) {
<a name="l00054"></a>00054         argv[i] = Tcl_GetStringFromObj(objv[i], NULL);
<a name="l00055"></a>00055     }
<a name="l00056"></a>00056     
<a name="l00057"></a>00057     <span class="keywordflow">if</span> (argc &lt; 2) {
<a name="l00058"></a>00058         wrong_num_args(argc, argv, 1, 2, INT_MAX);
<a name="l00059"></a>00059         add_to_help(<span class="stringliteral">"bundle"</span>, <span class="stringliteral">"XXX"</span>);
<a name="l00060"></a>00060         add_to_help(<span class="stringliteral">"param"</span>, <span class="stringliteral">"XXX"</span>);
<a name="l00061"></a>00061         add_to_help(<span class="stringliteral">"link"</span>, <span class="stringliteral">"XXX"</span>);
<a name="l00062"></a>00062         add_to_help(<span class="stringliteral">"route"</span>, <span class="stringliteral">"XXX"</span>);
<a name="l00063"></a>00063         add_to_help(<span class="stringliteral">"tragent"</span>, <span class="stringliteral">"XXX"</span>);
<a name="l00064"></a>00064         add_to_help(<span class="stringliteral">"registration"</span>, <span class="stringliteral">"XXX"</span>);
<a name="l00065"></a>00065         <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00066"></a>00066     }
<a name="l00067"></a>00067 
<a name="l00068"></a>00068     <span class="comment">// for all commands and their side-effects, install the node as</span>
<a name="l00069"></a>00069     <span class="comment">// the "singleton" BundleDaemon instance, and store the command</span>
<a name="l00070"></a>00070     <span class="comment">// time in the node so any posted events happen in the future</span>
<a name="l00071"></a>00071     <a class="code" href="classdtnsim_1_1NodeCommand.html#6961dddee8ec073d6bf4ac1b821ca6ac">node_</a>-&gt;<a class="code" href="classdtnsim_1_1Node.html#5f8ad70a765bbb1b8d8e8d07ef502036" title="Set the node as the &amp;quot;active&amp;quot; node in the simulation.">set_active</a>();
<a name="l00072"></a>00072 
<a name="l00073"></a>00073     <span class="keyword">const</span> <span class="keywordtype">char</span>* cmd = argv[1];
<a name="l00074"></a>00074     <span class="keyword">const</span> <span class="keywordtype">char</span>* subcmd = NULL;
<a name="l00075"></a>00075     <span class="keywordflow">if</span> (objc &gt;= 3) {
<a name="l00076"></a>00076         subcmd = argv[2];
<a name="l00077"></a>00077     }
<a name="l00078"></a>00078 
<a name="l00079"></a>00079     <span class="comment">// first we need to handle the set command since it's normally</span>
<a name="l00080"></a>00080     <span class="comment">// handled by the TclCommand base class</span>
<a name="l00081"></a>00081     <span class="keywordflow">if</span> (subcmd != NULL &amp;&amp; strcmp(subcmd, <span class="stringliteral">"set"</span>) == 0) {
<a name="l00082"></a>00082         TclCommand* cmdobj = NULL;
<a name="l00083"></a>00083         <span class="keywordflow">if</span>      (strcmp(cmd, <span class="stringliteral">"bundle"</span>)  == 0) cmdobj = &amp;<a class="code" href="classdtnsim_1_1NodeCommand.html#75d5407a191af384dd820c98b651a904">bundle_cmd_</a>;
<a name="l00084"></a>00084         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"link"</span>)    == 0) cmdobj = &amp;<a class="code" href="classdtnsim_1_1NodeCommand.html#98e9baef2880a0eab62121a4be77bd3b">link_cmd_</a>;
<a name="l00085"></a>00085         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"param"</span>)   == 0) cmdobj = &amp;<a class="code" href="classdtnsim_1_1NodeCommand.html#68701ac625d9278d99952645d18851d1">param_cmd_</a>;
<a name="l00086"></a>00086         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"route"</span>)   == 0) cmdobj = &amp;<a class="code" href="classdtnsim_1_1NodeCommand.html#0d490aeeb6686dc564f30c9a35528afd">route_cmd_</a>;
<a name="l00087"></a>00087         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"storage"</span>) == 0) cmdobj = &amp;<a class="code" href="classdtnsim_1_1NodeCommand.html#d9e4e859f2138f99a34a33e0838015a0">storage_cmd_</a>;
<a name="l00088"></a>00088         <span class="keywordflow">else</span> 
<a name="l00089"></a>00089         {
<a name="l00090"></a>00090             resultf(<span class="stringliteral">"node: unsupported subcommand %s"</span>, cmd);
<a name="l00091"></a>00091             <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00092"></a>00092         }
<a name="l00093"></a>00093         
<a name="l00094"></a>00094         <span class="keywordflow">return</span> cmdobj-&gt;cmd_set(objc - 1, objv + 1, interp);
<a name="l00095"></a>00095     }
<a name="l00096"></a>00096         
<a name="l00097"></a>00097     <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"bundle"</span>) == 0)
<a name="l00098"></a>00098     {
<a name="l00099"></a>00099         <span class="keywordflow">return</span> <a class="code" href="classdtnsim_1_1NodeCommand.html#75d5407a191af384dd820c98b651a904">bundle_cmd_</a>.<a class="code" href="classdtn_1_1BundleCommand.html#32ac39e7f71d7ba7657ac5cd6bc5ac0f" title="Virtual from CommandModule.">exec</a>(objc - 1, objv + 1, interp);
<a name="l00100"></a>00100     }
<a name="l00101"></a>00101     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"link"</span>) == 0)
<a name="l00102"></a>00102     {
<a name="l00103"></a>00103         <span class="keywordflow">return</span> <a class="code" href="classdtnsim_1_1NodeCommand.html#98e9baef2880a0eab62121a4be77bd3b">link_cmd_</a>.<a class="code" href="classdtn_1_1LinkCommand.html#b2084df741e78d87a0692b0e593546ec" title="Virtual from CommandModule.">exec</a>(argc - 1, argv + 1, interp);
<a name="l00104"></a>00104     }
<a name="l00105"></a>00105     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"param"</span>) == 0)
<a name="l00106"></a>00106     {
<a name="l00107"></a>00107         <span class="keywordflow">return</span> <a class="code" href="classdtnsim_1_1NodeCommand.html#68701ac625d9278d99952645d18851d1">param_cmd_</a>.exec(argc - 1, argv + 1, interp);
<a name="l00108"></a>00108     }
<a name="l00109"></a>00109     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"route"</span>) == 0)
<a name="l00110"></a>00110     {
<a name="l00111"></a>00111         <span class="keywordflow">return</span> <a class="code" href="classdtnsim_1_1NodeCommand.html#0d490aeeb6686dc564f30c9a35528afd">route_cmd_</a>.<a class="code" href="classdtn_1_1RouteCommand.html#69e85b4e32b8cab59f9808ec647c0fcf" title="Virtual from CommandModule.">exec</a>(argc - 1, argv + 1, interp);
<a name="l00112"></a>00112     }
<a name="l00113"></a>00113     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"storage"</span>) == 0)
<a name="l00114"></a>00114     {
<a name="l00115"></a>00115         <span class="keywordflow">if</span> (subcmd != NULL &amp;&amp; !strcmp(subcmd, <span class="stringliteral">"set"</span>)) {
<a name="l00116"></a>00116             <span class="keywordflow">return</span> <a class="code" href="classdtnsim_1_1NodeCommand.html#d9e4e859f2138f99a34a33e0838015a0">storage_cmd_</a>.cmd_set(objc - 1, objv + 1, interp);
<a name="l00117"></a>00117         }
<a name="l00118"></a>00118         <span class="keywordflow">return</span> <a class="code" href="classdtnsim_1_1NodeCommand.html#d9e4e859f2138f99a34a33e0838015a0">storage_cmd_</a>.<a class="code" href="classdtn_1_1StorageCommand.html#24cdd8b0bc786969721b8146cbf3cae5">exec</a>(argc - 1, argv + 1, interp);
<a name="l00119"></a>00119     }
<a name="l00120"></a>00120     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"registration"</span>) == 0)
<a name="l00121"></a>00121     {
<a name="l00122"></a>00122         <span class="keywordflow">if</span> (strcmp(subcmd, <span class="stringliteral">"add"</span>) == 0) {
<a name="l00123"></a>00123             <span class="comment">// &lt;node&gt; registration add &lt;eid&gt;</span>
<a name="l00124"></a>00124             <span class="keyword">const</span> <span class="keywordtype">char</span>* eid_str = argv[3];
<a name="l00125"></a>00125             <a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a> eid(eid_str);
<a name="l00126"></a>00126 
<a name="l00127"></a>00127             <span class="keywordflow">if</span> (!eid.<a class="code" href="classdtn_1_1EndpointID.html#bbf47839fe5cc8cb425af9a257a92ef5">valid</a>()) {
<a name="l00128"></a>00128                 resultf(<span class="stringliteral">"error in node registration add %s: "</span>
<a name="l00129"></a>00129                         <span class="stringliteral">"invalid demux eid"</span>, eid_str);
<a name="l00130"></a>00130                 <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00131"></a>00131             }
<a name="l00132"></a>00132 
<a name="l00133"></a>00133             <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>* r = <span class="keyword">new</span> <a class="code" href="classdtnsim_1_1SimRegistration.html" title="Registration used for the simulator.">SimRegistration</a>(<a class="code" href="classdtnsim_1_1NodeCommand.html#6961dddee8ec073d6bf4ac1b821ca6ac">node_</a>, eid);
<a name="l00134"></a>00134             <a class="code" href="classdtn_1_1RegistrationAddedEvent.html" title="Event class for new registration arrivals.">RegistrationAddedEvent</a>* e =
<a name="l00135"></a>00135                 <span class="keyword">new</span> <a class="code" href="classdtn_1_1RegistrationAddedEvent.html" title="Event class for new registration arrivals.">RegistrationAddedEvent</a>(r, <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142b04a9578f3e2276d81cd632222ceb4e2e" title="the admin logic">EVENTSRC_ADMIN</a>);
<a name="l00136"></a>00136 
<a name="l00137"></a>00137             <a class="code" href="classdtnsim_1_1NodeCommand.html#6961dddee8ec073d6bf4ac1b821ca6ac">node_</a>-&gt;<a class="code" href="classdtnsim_1_1Node.html#0986c0f6d3eeec3fba7779a3d6d38513" title="Virtual post function, overridden in the simulator to use the modified event queue...">post_event</a>(e);
<a name="l00138"></a>00138             
<a name="l00139"></a>00139             <span class="keywordflow">return</span> TCL_OK;
<a name="l00140"></a>00140         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(subcmd, <span class="stringliteral">"list"</span>) == 0 || strcmp(subcmd, <span class="stringliteral">"dump"</span>) == 0) {
<a name="l00141"></a>00141             oasys::StringBuffer <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>;
<a name="l00142"></a>00142             <a class="code" href="classdtnsim_1_1NodeCommand.html#6961dddee8ec073d6bf4ac1b821ca6ac">node_</a>-&gt;<a class="code" href="classdtn_1_1BundleDaemon.html#ad2af770f1002bb8b3a15e11704928de" title="Accessor for the registration table.">reg_table</a>()-&gt;<a class="code" href="classdtn_1_1RegistrationTable.html#821a1182a88b6ec542b37e84d91a11f5" title="Dump out the registration database.">dump</a>(&amp;buf);
<a name="l00143"></a>00143             set_result(buf.c_str());
<a name="l00144"></a>00144             <span class="keywordflow">return</span> TCL_OK;
<a name="l00145"></a>00145         
<a name="l00146"></a>00146         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(subcmd, <span class="stringliteral">"del"</span>) == 0) {
<a name="l00147"></a>00147             <span class="keyword">const</span> <a class="code" href="classdtn_1_1RegistrationTable.html" title="Class for the in-memory registration table.">RegistrationTable</a>* regtable = <a class="code" href="classdtnsim_1_1NodeCommand.html#6961dddee8ec073d6bf4ac1b821ca6ac">node_</a>-&gt;<a class="code" href="classdtn_1_1BundleDaemon.html#ad2af770f1002bb8b3a15e11704928de" title="Accessor for the registration table.">reg_table</a>();
<a name="l00148"></a>00148 
<a name="l00149"></a>00149             <span class="keyword">const</span> <span class="keywordtype">char</span>* regid_str = argv[2];
<a name="l00150"></a>00150             <span class="keywordtype">int</span> <a class="code" href="dtncat_8c.html#8eb0c3e35c1feb7baf9802f03bf42e41">regid</a> = atoi(regid_str);
<a name="l00151"></a>00151 
<a name="l00152"></a>00152             <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>* reg = regtable-&gt;<a class="code" href="classdtn_1_1RegistrationTable.html#f8d5a24ad0b05ab853f80cfea3a1fce1" title="Look up a matching registration.">get</a>(regid);
<a name="l00153"></a>00153             <span class="keywordflow">if</span> (!reg) {
<a name="l00154"></a>00154                 resultf(<span class="stringliteral">"no registration exists with id %d"</span>, regid);
<a name="l00155"></a>00155                 <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00156"></a>00156             }
<a name="l00157"></a>00157 
<a name="l00158"></a>00158             <a class="code" href="classdtnsim_1_1NodeCommand.html#6961dddee8ec073d6bf4ac1b821ca6ac">node_</a>-&gt;<a class="code" href="classdtnsim_1_1Node.html#0986c0f6d3eeec3fba7779a3d6d38513" title="Virtual post function, overridden in the simulator to use the modified event queue...">post_event</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1RegistrationRemovedEvent.html" title="Event class for registration removals.">RegistrationRemovedEvent</a>(reg));
<a name="l00159"></a>00159             <span class="keywordflow">return</span> TCL_OK;
<a name="l00160"></a>00160 
<a name="l00161"></a>00161         }
<a name="l00162"></a>00162         resultf(<span class="stringliteral">"node registration: unsupported subcommand %s"</span>, subcmd);
<a name="l00163"></a>00163         <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00164"></a>00164     }
<a name="l00165"></a>00165     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"tragent"</span>) == 0)
<a name="l00166"></a>00166     {
<a name="l00167"></a>00167         <span class="comment">// &lt;node&gt; tragent &lt;src&gt; &lt;dst&gt; &lt;args&gt;</span>
<a name="l00168"></a>00168         <span class="keywordflow">if</span> (argc &lt; 5) {
<a name="l00169"></a>00169             wrong_num_args(argc, argv, 3, 5, INT_MAX);
<a name="l00170"></a>00170             <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00171"></a>00171         }
<a name="l00172"></a>00172         
<a name="l00173"></a>00173         <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="dtnmoteproxy_8c.html#e1ade0f5a1b32f6c8be72f31a99e2a18">src</a> = argv[2];
<a name="l00174"></a>00174         <span class="keyword">const</span> <span class="keywordtype">char</span>* dst = argv[3];
<a name="l00175"></a>00175 
<a name="l00176"></a>00176         <span class="comment">// see if src/dest are node names, in which case we use its</span>
<a name="l00177"></a>00177         <span class="comment">// local eid as the source address</span>
<a name="l00178"></a>00178         <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a> src_eid;
<a name="l00179"></a>00179         <a class="code" href="classdtnsim_1_1Node.html" title="Class representing a node in the simulator (i.e.">Node</a>* src_node = <a class="code" href="classdtnsim_1_1Topology.html#47925759729cb97284a5bb032941b132">Topology::find_node</a>(src);
<a name="l00180"></a>00180         <span class="keywordflow">if</span> (src_node) {
<a name="l00181"></a>00181             src_eid.<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(src_node-&gt;<a class="code" href="classdtn_1_1BundleDaemon.html#f606a71844413e32918c9c3e98b8ce3f" title="Return the local endpoint identifier.">local_eid</a>());
<a name="l00182"></a>00182         } <span class="keywordflow">else</span> {
<a name="l00183"></a>00183             src_eid.<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(src);
<a name="l00184"></a>00184             <span class="keywordflow">if</span> (!src_eid.<a class="code" href="classdtn_1_1EndpointID.html#bbf47839fe5cc8cb425af9a257a92ef5">valid</a>()) {
<a name="l00185"></a>00185                 resultf(<span class="stringliteral">"node tragent: invalid src eid %s"</span>, src);
<a name="l00186"></a>00186                 <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00187"></a>00187             }
<a name="l00188"></a>00188         }
<a name="l00189"></a>00189         
<a name="l00190"></a>00190         <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a> dst_eid;
<a name="l00191"></a>00191         <a class="code" href="classdtnsim_1_1Node.html" title="Class representing a node in the simulator (i.e.">Node</a>* dst_node = <a class="code" href="classdtnsim_1_1Topology.html#47925759729cb97284a5bb032941b132">Topology::find_node</a>(dst);
<a name="l00192"></a>00192         <span class="keywordflow">if</span> (dst_node) {
<a name="l00193"></a>00193             dst_eid.<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(dst_node-&gt;<a class="code" href="classdtn_1_1BundleDaemon.html#f606a71844413e32918c9c3e98b8ce3f" title="Return the local endpoint identifier.">local_eid</a>());
<a name="l00194"></a>00194         } <span class="keywordflow">else</span> {
<a name="l00195"></a>00195             dst_eid.<a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(dst);
<a name="l00196"></a>00196             <span class="keywordflow">if</span> (!dst_eid.<a class="code" href="classdtn_1_1EndpointID.html#bbf47839fe5cc8cb425af9a257a92ef5">valid</a>()) {
<a name="l00197"></a>00197                 resultf(<span class="stringliteral">"node tragent: invalid dst eid %s"</span>, dst);
<a name="l00198"></a>00198                 <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00199"></a>00199             }
<a name="l00200"></a>00200         }
<a name="l00201"></a>00201         
<a name="l00202"></a>00202         <a class="code" href="classdtnsim_1_1TrAgent.html">TrAgent</a>* a = <a class="code" href="classdtnsim_1_1TrAgent.html#fd95a265bd004460b9e650aaf409f101">TrAgent::init</a>(src_eid, dst_eid,
<a name="l00203"></a>00203                                    argc - 4, argv + 4);
<a name="l00204"></a>00204         <span class="keywordflow">if</span> (!a) {
<a name="l00205"></a>00205             resultf(<span class="stringliteral">"error in tragent config"</span>);
<a name="l00206"></a>00206             <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00207"></a>00207         }
<a name="l00208"></a>00208         
<a name="l00209"></a>00209         <span class="keywordflow">return</span> TCL_OK;
<a name="l00210"></a>00210 
<a name="l00211"></a>00211     } <span class="keywordflow">else</span> {
<a name="l00212"></a>00212         resultf(<span class="stringliteral">"node: unsupported subcommand %s"</span>, cmd);
<a name="l00213"></a>00213         <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00214"></a>00214     }
<a name="l00215"></a>00215 }
<a name="l00216"></a>00216 
<a name="l00217"></a>00217 } <span class="comment">// namespace dtnsim</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>