<!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: BundleCommand.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 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 List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>BundleCommand.cc</h1><a href="BundleCommand_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 <<a class="code" href="dtn-config_8h.html">dtn-config.h</a>></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 <climits></span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="preprocessor">#include <oasys/util/HexDumpBuffer.h></span> <a name="l00024"></a>00024 <span class="preprocessor">#include <oasys/util/StringBuffer.h></span> <a name="l00025"></a>00025 <span class="preprocessor">#include <oasys/util/OptParser.h></span> <a name="l00026"></a>00026 <a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="BundleCommand_8h.html">BundleCommand.h</a>"</span> <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="CompletionNotifier_8h.html">CompletionNotifier.h</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="bundling_2Bundle_8h.html">bundling/Bundle.h</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="BundleEvent_8h.html">bundling/BundleEvent.h</a>"</span> <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="BundleDaemon_8h.html">bundling/BundleDaemon.h</a>"</span> <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="RegistrationTable_8h.html">reg/RegistrationTable.h</a>"</span> <a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="TclRegistration_8h.html">reg/TclRegistration.h</a>"</span> <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="keyword">namespace </span>dtn { <a name="l00036"></a>00036 <a name="l00037"></a><a class="code" href="classdtn_1_1BundleCommand.html#d6640f655c8f04999307a9f2a1baec15">00037</a> <a class="code" href="classdtn_1_1BundleCommand.html#d6640f655c8f04999307a9f2a1baec15">BundleCommand::BundleCommand</a>() <a name="l00038"></a>00038 : TclCommand(<span class="stringliteral">"bundle"</span>) <a name="l00039"></a>00039 { <a name="l00040"></a>00040 add_to_help(<span class="stringliteral">"inject <src> <dst> <payload> <opt1=val1> .. <optN=valN>"</span>, <a name="l00041"></a>00041 <span class="stringliteral">"valid options:\n"</span> <a name="l00042"></a>00042 <span class="stringliteral">" custody_xfer\n"</span> <a name="l00043"></a>00043 <span class="stringliteral">" receive_rcpt\n"</span> <a name="l00044"></a>00044 <span class="stringliteral">" custody_rcpt\n"</span> <a name="l00045"></a>00045 <span class="stringliteral">" forward_rcpt\n"</span> <a name="l00046"></a>00046 <span class="stringliteral">" delivery_rcpt\n"</span> <a name="l00047"></a>00047 <span class="stringliteral">" deletion_rcpt\n"</span> <a name="l00048"></a>00048 <span class="stringliteral">" expiration=integer\n"</span> <a name="l00049"></a>00049 <span class="stringliteral">" length=integer\n"</span>); <a name="l00050"></a>00050 add_to_help(<span class="stringliteral">"stats"</span>, <span class="stringliteral">"get statistics on the bundles"</span>); <a name="l00051"></a>00051 add_to_help(<span class="stringliteral">"daemon_stats"</span>, <span class="stringliteral">"daemon stats"</span>); <a name="l00052"></a>00052 add_to_help(<span class="stringliteral">"reset_stats"</span>, <span class="stringliteral">"reset currently maintained statistics"</span>); <a name="l00053"></a>00053 add_to_help(<span class="stringliteral">"list"</span>, <span class="stringliteral">"list all of the bundles in the system"</span>); <a name="l00054"></a>00054 add_to_help(<span class="stringliteral">"ids"</span>, <span class="stringliteral">"list the ids of all bundles the system"</span>); <a name="l00055"></a>00055 add_to_help(<span class="stringliteral">"info <id>"</span>, <span class="stringliteral">"get info on a specific bundle"</span>); <a name="l00056"></a>00056 add_to_help(<span class="stringliteral">"dump <id>"</span>, <span class="stringliteral">"dump a specific bundle"</span>); <a name="l00057"></a>00057 add_to_help(<span class="stringliteral">"dump_tcl <id>"</span>, <span class="stringliteral">"dump a bundle as a tcl list"</span>); <a name="l00058"></a>00058 add_to_help(<span class="stringliteral">"dump_ascii <id>"</span>, <span class="stringliteral">"dump the bundle in ascii"</span>); <a name="l00059"></a>00059 add_to_help(<span class="stringliteral">"expire <id>"</span>, <span class="stringliteral">"force a specific bundle to expire"</span>); <a name="l00060"></a>00060 add_to_help(<span class="stringliteral">"cancel <id> <link>"</span>, <span class="stringliteral">"cancel a bundle being sent on a link"</span>); <a name="l00061"></a>00061 add_to_help(<span class="stringliteral">"clear_fwdlog <id>"</span>, <span class="stringliteral">"clear the forwarding log for a bundle"</span>); <a name="l00062"></a>00062 add_to_help(<span class="stringliteral">"daemon_idle_shutdown <secs>"</span>, <a name="l00063"></a>00063 <span class="stringliteral">"shut down the bundle daemon after an idle period"</span>); <a name="l00064"></a>00064 } <a name="l00065"></a>00065 <a name="l00066"></a><a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#7b324d764a867179143dea1dbdd4e0b6">00066</a> <a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#7b324d764a867179143dea1dbdd4e0b6">BundleCommand::InjectOpts::InjectOpts</a>() <a name="l00067"></a>00067 : custody_xfer_(false), <a name="l00068"></a>00068 receive_rcpt_(false), <a name="l00069"></a>00069 custody_rcpt_(false), <a name="l00070"></a>00070 forward_rcpt_(false), <a name="l00071"></a>00071 delivery_rcpt_(false), <a name="l00072"></a>00072 deletion_rcpt_(false), <a name="l00073"></a>00073 expiration_(60), <span class="comment">// bundle TTL</span> <a name="l00074"></a>00074 length_(0), <span class="comment">// bundle payload length</span> <a name="l00075"></a>00075 replyto_(<span class="stringliteral">""</span>) <a name="l00076"></a>00076 {} <a name="l00077"></a>00077 <a name="l00078"></a>00078 <span class="keywordtype">bool</span> <a name="l00079"></a><a class="code" href="classdtn_1_1BundleCommand.html#fec43bb9744433921b10572d115789de">00079</a> <a class="code" href="classdtn_1_1BundleCommand.html#fec43bb9744433921b10572d115789de" title="Parse the &quot;bundle inject&quot; command line options.">BundleCommand::parse_inject_options</a>(<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html" title="&quot;bundle inject&quot; command parameters/options">InjectOpts</a>* options, <a name="l00080"></a>00080 <span class="keywordtype">int</span> objc, Tcl_Obj** objv, <a name="l00081"></a>00081 <span class="keyword">const</span> <span class="keywordtype">char</span>** invalidp) <a name="l00082"></a>00082 { <a name="l00083"></a>00083 <span class="comment">// no options specified:</span> <a name="l00084"></a>00084 <span class="keywordflow">if</span> (objc < 6) { <a name="l00085"></a>00085 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00086"></a>00086 } <a name="l00087"></a>00087 <a name="l00088"></a>00088 oasys::OptParser p; <a name="l00089"></a>00089 <a name="l00090"></a>00090 p.addopt(<span class="keyword">new</span> oasys::BoolOpt(<span class="stringliteral">"custody_xfer"</span>, &options-><a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#96cd8b41ae9ee0d6c150ebf79a4d1448" title="Custody xfer requested.">custody_xfer_</a>)); <a name="l00091"></a>00091 p.addopt(<span class="keyword">new</span> oasys::BoolOpt(<span class="stringliteral">"receive_rcpt"</span>, &options-><a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#581ef43cdaa41ff6813701abfe2889e8" title="Hop by hop reception receipt.">receive_rcpt_</a>)); <a name="l00092"></a>00092 p.addopt(<span class="keyword">new</span> oasys::BoolOpt(<span class="stringliteral">"custody_rcpt"</span>, &options-><a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#9c2adf06b7edba7ba8f9aa39407033fe" title="Custody xfer reporting.">custody_rcpt_</a>)); <a name="l00093"></a>00093 p.addopt(<span class="keyword">new</span> oasys::BoolOpt(<span class="stringliteral">"forward_rcpt"</span>, &options-><a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#6ae8210d1da56bb72a8deeb210ca404c" title="Hop by hop forwarding reporting.">forward_rcpt_</a>)); <a name="l00094"></a>00094 p.addopt(<span class="keyword">new</span> oasys::BoolOpt(<span class="stringliteral">"delivery_rcpt"</span>, &options-><a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#ec393095a1b01a39d46f4246685cd9d0" title="End-to-end delivery reporting.">delivery_rcpt_</a>)); <a name="l00095"></a>00095 p.addopt(<span class="keyword">new</span> oasys::BoolOpt(<span class="stringliteral">"deletion_rcpt"</span>, &options-><a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#7bddaabf3b3bf52ab224c82ea019f5aa" title="Bundle deletion reporting.">deletion_rcpt_</a>)); <a name="l00096"></a>00096 p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"expiration"</span>, &options-><a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#74ef77dfd24ff15bbfeb3fd6f72facbd" title="Bundle TTL.">expiration_</a>)); <a name="l00097"></a>00097 p.addopt(<span class="keyword">new</span> oasys::UIntOpt(<span class="stringliteral">"length"</span>, &options-><a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#4709d817c13a46072aa24a40a6141a3d" title="Bundle payload length.">length_</a>)); <a name="l00098"></a>00098 p.addopt(<span class="keyword">new</span> oasys::StringOpt(<span class="stringliteral">"replyto"</span>, &options-><a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#f01372889b473a7afcea78008e7250c3" title="Bundle Reply-To EID.">replyto_</a>)); <a name="l00099"></a>00099 <a name="l00100"></a>00100 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=5; i<objc; i++) { <a name="l00101"></a>00101 <span class="keywordtype">int</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>; <a name="l00102"></a>00102 <span class="keyword">const</span> <span class="keywordtype">char</span>* option_name = Tcl_GetStringFromObj(objv[i], &len); <a name="l00103"></a>00103 <span class="keywordflow">if</span> (! p.parse_opt(option_name, len)) { <a name="l00104"></a>00104 *invalidp = option_name; <a name="l00105"></a>00105 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00106"></a>00106 } <a name="l00107"></a>00107 } <a name="l00108"></a>00108 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00109"></a>00109 } <a name="l00110"></a>00110 <a name="l00111"></a>00111 <span class="keywordtype">int</span> <a name="l00112"></a><a class="code" href="classdtn_1_1BundleCommand.html#32ac39e7f71d7ba7657ac5cd6bc5ac0f">00112</a> <a class="code" href="classdtn_1_1BundleCommand.html#32ac39e7f71d7ba7657ac5cd6bc5ac0f" title="Virtual from CommandModule.">BundleCommand::exec</a>(<span class="keywordtype">int</span> objc, Tcl_Obj** objv, Tcl_Interp* interp) <a name="l00113"></a>00113 { <a name="l00114"></a>00114 <span class="comment">// need a subcommand</span> <a name="l00115"></a>00115 <span class="keywordflow">if</span> (objc < 2) { <a name="l00116"></a>00116 wrong_num_args(objc, objv, 1, 2, INT_MAX); <a name="l00117"></a>00117 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00118"></a>00118 } <a name="l00119"></a>00119 <a name="l00120"></a>00120 <span class="keyword">const</span> <span class="keywordtype">char</span>* cmd = Tcl_GetStringFromObj(objv[1], 0); <a name="l00121"></a>00121 <a name="l00122"></a>00122 <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"inject"</span>) == 0) { <a name="l00123"></a>00123 <span class="comment">// bundle inject <source> <dest> <payload> <param1<=value1?>?> ... <paramN<=valueN?>?></span> <a name="l00124"></a>00124 <span class="keywordflow">if</span> (objc < 5) { <a name="l00125"></a>00125 wrong_num_args(objc, objv, 2, 5, INT_MAX); <a name="l00126"></a>00126 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00127"></a>00127 } <a name="l00128"></a>00128 <a name="l00129"></a>00129 <span class="keywordtype">bool</span> eids_valid = <span class="keyword">true</span>; <a name="l00130"></a>00130 <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b = <span class="keyword">new</span> <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>(); <a name="l00131"></a>00131 eids_valid &= b-><a class="code" href="classdtn_1_1Bundle.html#69c35928ca050eb4bb2ec67641f1b6bb" title="Setters and mutable accessors.">mutable_source</a>()-><a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(Tcl_GetStringFromObj(objv[2], 0)); <a name="l00132"></a>00132 eids_valid &= b-><a class="code" href="classdtn_1_1Bundle.html#7c2091e44637889b9ad6f94a82ae7f83" title="Setters and mutable accessors.">mutable_replyto</a>()-><a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(Tcl_GetStringFromObj(objv[2], 0)); <a name="l00133"></a>00133 eids_valid &= b-><a class="code" href="classdtn_1_1Bundle.html#fedf6ad0537f7e3a3f958162d1fc935e" title="Setters and mutable accessors.">mutable_dest</a>()-><a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(Tcl_GetStringFromObj(objv[3], 0)); <a name="l00134"></a>00134 b-><a class="code" href="classdtn_1_1Bundle.html#96698085719d88c0b5c86d4cb388324c" title="Setters and mutable accessors.">mutable_custodian</a>()-><a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(<a class="code" href="classdtn_1_1EndpointID.html#31bd1844cae5e71cc2393a139c9bec4c" title="Return the special endpoint id used for the null endpoint, namely &quot;dtn:none&quot;...">EndpointID::NULL_EID</a>()); <a name="l00135"></a>00135 <a name="l00136"></a>00136 <a class="code" href="classdtn_1_1EndpointID.html#43d537f639ac64ca9b401701dae46f28" title="Typedef for the return value possibilities from is_singleton.">EndpointID::singleton_info_t</a> <a class="code" href="dtncat_8c.html#71f51a2e8cbe9a53031fa72596edc09f">info</a> = b-><a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#c6c7ec257f460d69bce4b1530b136323" title="Return an indication of whether or not the scheme is known.">known_scheme</a>() ? <a name="l00137"></a>00137 b-><a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#4c418327f77aef4f420961377799b5e2" title="Return whether or not this endpoint id is a singleton or a multi-node endpoint.">is_singleton</a>() : <a name="l00138"></a>00138 <a class="code" href="classdtn_1_1EndpointID.html#c94e40b9c0eb93b7dc8d9aed1574ffda" title="Default setting for endpoint ids in unknown schemes.">EndpointID::is_singleton_default_</a>; <a name="l00139"></a>00139 <span class="keywordflow">switch</span> (info) { <a name="l00140"></a>00140 <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1EndpointID.html#43d537f639ac64ca9b401701dae46f287fc9114949151beb443fe5b9b92eac2d">EndpointID::SINGLETON</a>: <a name="l00141"></a>00141 b-><a class="code" href="classdtn_1_1Bundle.html#3b35e450cfd2504a5980d379f71f222c" title="Setters and mutable accessors.">set_singleton_dest</a>(<span class="keyword">true</span>); <a name="l00142"></a>00142 <span class="keywordflow">break</span>; <a name="l00143"></a>00143 <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1EndpointID.html#43d537f639ac64ca9b401701dae46f28bc86c59b022718d9c03053b5f9600707">EndpointID::MULTINODE</a>: <a name="l00144"></a>00144 b-><a class="code" href="classdtn_1_1Bundle.html#3b35e450cfd2504a5980d379f71f222c" title="Setters and mutable accessors.">set_singleton_dest</a>(<span class="keyword">false</span>); <a name="l00145"></a>00145 <span class="keywordflow">break</span>; <a name="l00146"></a>00146 <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1EndpointID.html#43d537f639ac64ca9b401701dae46f2856402133ecae8d16614aafc9f7e8d62d">EndpointID::UNKNOWN</a>: <a name="l00147"></a>00147 resultf(<span class="stringliteral">"can't determine is_singleton for destination %s"</span>, <a name="l00148"></a>00148 b-><a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>()); <a name="l00149"></a>00149 <span class="keyword">delete</span> b; <a name="l00150"></a>00150 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00151"></a>00151 } <a name="l00152"></a>00152 <a name="l00153"></a>00153 <span class="keywordflow">if</span> (!eids_valid) { <a name="l00154"></a>00154 resultf(<span class="stringliteral">"bad value for one or more EIDs"</span>); <a name="l00155"></a>00155 <span class="keyword">delete</span> b; <a name="l00156"></a>00156 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00157"></a>00157 } <a name="l00158"></a>00158 <a name="l00159"></a>00159 <span class="keywordtype">int</span> payload_len; <a name="l00160"></a>00160 u_char* payload_data = Tcl_GetByteArrayFromObj(objv[4], &payload_len); <a name="l00161"></a>00161 <a name="l00162"></a>00162 <span class="comment">// now process any optional parameters:</span> <a name="l00163"></a>00163 <a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html" title="&quot;bundle inject&quot; command parameters/options">InjectOpts</a> options; <a name="l00164"></a>00164 <span class="keyword">const</span> <span class="keywordtype">char</span>* invalid; <a name="l00165"></a>00165 <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1BundleCommand.html#fec43bb9744433921b10572d115789de" title="Parse the &quot;bundle inject&quot; command line options.">parse_inject_options</a>(&options, objc, objv, &invalid)) { <a name="l00166"></a>00166 resultf(<span class="stringliteral">"error parsing bundle inject options: invalid option '%s'"</span>, <a name="l00167"></a>00167 invalid); <a name="l00168"></a>00168 <span class="keyword">delete</span> b; <a name="l00169"></a>00169 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00170"></a>00170 } <a name="l00171"></a>00171 <a name="l00172"></a>00172 b-><a class="code" href="classdtn_1_1Bundle.html#ac195072e859df4e1e8ae28dd299d03e" title="Setters and mutable accessors.">set_custody_requested</a>(options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#96cd8b41ae9ee0d6c150ebf79a4d1448" title="Custody xfer requested.">custody_xfer_</a>); <a name="l00173"></a>00173 b-><a class="code" href="classdtn_1_1Bundle.html#ddbc653176fbf0ba1bf7702a72a55321" title="Setters and mutable accessors.">set_receive_rcpt</a>(options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#581ef43cdaa41ff6813701abfe2889e8" title="Hop by hop reception receipt.">receive_rcpt_</a>); <a name="l00174"></a>00174 b-><a class="code" href="classdtn_1_1Bundle.html#8ed9f01350133711a4cd23aef1f4e941" title="Setters and mutable accessors.">set_custody_rcpt</a>(options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#9c2adf06b7edba7ba8f9aa39407033fe" title="Custody xfer reporting.">custody_rcpt_</a>); <a name="l00175"></a>00175 b-><a class="code" href="classdtn_1_1Bundle.html#398c69ef798e99ea2f82e03f460d4aff" title="Setters and mutable accessors.">set_forward_rcpt</a>(options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#6ae8210d1da56bb72a8deeb210ca404c" title="Hop by hop forwarding reporting.">forward_rcpt_</a>); <a name="l00176"></a>00176 b-><a class="code" href="classdtn_1_1Bundle.html#fc9cb55b202687f98d31f4bba7859f73" title="Setters and mutable accessors.">set_delivery_rcpt</a>(options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#ec393095a1b01a39d46f4246685cd9d0" title="End-to-end delivery reporting.">delivery_rcpt_</a>); <a name="l00177"></a>00177 b-><a class="code" href="classdtn_1_1Bundle.html#c59da17a98c6ac9f32da043dc967f151" title="Setters and mutable accessors.">set_deletion_rcpt</a>(options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#7bddaabf3b3bf52ab224c82ea019f5aa" title="Bundle deletion reporting.">deletion_rcpt_</a>); <a name="l00178"></a>00178 b-><a class="code" href="classdtn_1_1Bundle.html#7623ecfe9e47e5dc075ebd872fb9a237" title="Setters and mutable accessors.">set_expiration</a>(options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#74ef77dfd24ff15bbfeb3fd6f72facbd" title="Bundle TTL.">expiration_</a>); <a name="l00179"></a>00179 <a name="l00180"></a>00180 <span class="comment">// Bundles with a null source EID are not allowed to request reports or</span> <a name="l00181"></a>00181 <span class="comment">// custody transfer, and must not be fragmented.</span> <a name="l00182"></a>00182 <span class="keywordflow">if</span> (b-><a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>() == <a class="code" href="classdtn_1_1EndpointID.html#31bd1844cae5e71cc2393a139c9bec4c" title="Return the special endpoint id used for the null endpoint, namely &quot;dtn:none&quot;...">EndpointID::NULL_EID</a>()) { <a name="l00183"></a>00183 <span class="keywordflow">if</span> ( b-><a class="code" href="classdtn_1_1Bundle.html#2261b28c9315c50a85bc35c1bcb6ace4" title="Accessors.">custody_requested</a>() || <a name="l00184"></a>00184 b-><a class="code" href="classdtn_1_1Bundle.html#9630433ec71903457f7b1429daade560" title="True if any return receipt fields are set.">receipt_requested</a>() || <a name="l00185"></a>00185 b-><a class="code" href="classdtn_1_1Bundle.html#7af80fedd28d8a8f7b8b947ec134a310" title="Accessors.">app_acked_rcpt</a>() ) <a name="l00186"></a>00186 { <a name="l00187"></a>00187 log_err(<span class="stringliteral">"bundle with null source EID cannot request reports or "</span> <a name="l00188"></a>00188 <span class="stringliteral">"custody transfer"</span>); <a name="l00189"></a>00189 <span class="keyword">delete</span> b; <a name="l00190"></a>00190 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00191"></a>00191 } <a name="l00192"></a>00192 <a name="l00193"></a>00193 b-><a class="code" href="classdtn_1_1Bundle.html#ce75b35784c110dc09986632e9d9eba1" title="Setters and mutable accessors.">set_do_not_fragment</a>(<span class="keyword">true</span>); <a name="l00194"></a>00194 } <a name="l00195"></a>00195 <a name="l00196"></a>00196 <span class="keywordflow">else</span> { <a name="l00197"></a>00197 <span class="comment">// The bundle's source EID must be either dtn:none or an EID </span> <a name="l00198"></a>00198 <span class="comment">// registered at this node.</span> <a name="l00199"></a>00199 <span class="keyword">const</span> <a class="code" href="classdtn_1_1RegistrationTable.html" title="Class for the in-memory registration table.">RegistrationTable</a>* reg_table = <a name="l00200"></a>00200 BundleDaemon::instance()->reg_table(); <a name="l00201"></a>00201 std::string base_reg_str = b-><a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#b33fc19cda5561ca189e2051d6561db7">uri</a>().scheme() + <span class="stringliteral">"://"</span> + <a name="l00202"></a>00202 b-><a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#b33fc19cda5561ca189e2051d6561db7">uri</a>().host(); <a name="l00203"></a>00203 <a name="l00204"></a>00204 <span class="keywordflow">if</span> (!reg_table-><a class="code" href="classdtn_1_1RegistrationTable.html#f8d5a24ad0b05ab853f80cfea3a1fce1" title="Look up a matching registration.">get</a>(<a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a>(base_reg_str)) && <a name="l00205"></a>00205 !reg_table-><a class="code" href="classdtn_1_1RegistrationTable.html#f8d5a24ad0b05ab853f80cfea3a1fce1" title="Look up a matching registration.">get</a>(<a class="code" href="classdtn_1_1EndpointIDPattern.html" title="A Distinct class for endpoint patterns (i.e.">EndpointIDPattern</a>(b-><a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>()))) <a name="l00206"></a>00206 { <a name="l00207"></a>00207 log_err(<span class="stringliteral">"this node is not a member of the bundle's source EID (%s)"</span>, <a name="l00208"></a>00208 b-><a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#e214dda88bf43a3576cfcdf76c77c5a9">str</a>().c_str()); <a name="l00209"></a>00209 <span class="keyword">delete</span> b; <a name="l00210"></a>00210 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00211"></a>00211 } <a name="l00212"></a>00212 } <a name="l00213"></a>00213 <a name="l00214"></a>00214 <span class="keywordflow">if</span> (options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#4709d817c13a46072aa24a40a6141a3d" title="Bundle payload length.">length_</a> != 0) { <a name="l00215"></a>00215 <span class="comment">// explicit length but some of the data may just be left</span> <a name="l00216"></a>00216 <span class="comment">// as garbage. </span> <a name="l00217"></a>00217 b-><a class="code" href="classdtn_1_1Bundle.html#857079bad68497626f75c2985b69052f" title="Setters and mutable accessors.">mutable_payload</a>()-><a class="code" href="classdtn_1_1BundlePayload.html#af1ede6096a6d625fb83c001a9d490d6" title="Set the payload length in preparation for filling in with data.">set_length</a>(options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#4709d817c13a46072aa24a40a6141a3d" title="Bundle payload length.">length_</a>); <a name="l00218"></a>00218 <span class="keywordflow">if</span> (payload_len != 0) { <a name="l00219"></a>00219 b-><a class="code" href="classdtn_1_1Bundle.html#857079bad68497626f75c2985b69052f" title="Setters and mutable accessors.">mutable_payload</a>()-><a class="code" href="classdtn_1_1BundlePayload.html#7f5185039b03f0c875a12136b6b24862" title="Write a chunk of payload data at the specified offset.">write_data</a>(payload_data, payload_len, 0); <a name="l00220"></a>00220 } <a name="l00221"></a>00221 <a name="l00222"></a>00222 <span class="comment">// make sure to write a byte at the end of the payload to</span> <a name="l00223"></a>00223 <span class="comment">// properly fool the BundlePayload into thinking that we</span> <a name="l00224"></a>00224 <span class="comment">// actually got all the data</span> <a name="l00225"></a>00225 u_char byte = 0; <a name="l00226"></a>00226 b-><a class="code" href="classdtn_1_1Bundle.html#857079bad68497626f75c2985b69052f" title="Setters and mutable accessors.">mutable_payload</a>()-><a class="code" href="classdtn_1_1BundlePayload.html#7f5185039b03f0c875a12136b6b24862" title="Write a chunk of payload data at the specified offset.">write_data</a>(&byte, options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#4709d817c13a46072aa24a40a6141a3d" title="Bundle payload length.">length_</a> - 1, 1); <a name="l00227"></a>00227 <a name="l00228"></a>00228 payload_len = options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#4709d817c13a46072aa24a40a6141a3d" title="Bundle payload length.">length_</a>; <a name="l00229"></a>00229 } <span class="keywordflow">else</span> { <a name="l00230"></a>00230 <span class="comment">// use the object length</span> <a name="l00231"></a>00231 b-><a class="code" href="classdtn_1_1Bundle.html#857079bad68497626f75c2985b69052f" title="Setters and mutable accessors.">mutable_payload</a>()-><a class="code" href="classdtn_1_1BundlePayload.html#8abce553a70ab4bff48443d3faf49b2e" title="Set the payload data and length.">set_data</a>(payload_data, payload_len); <a name="l00232"></a>00232 } <a name="l00233"></a>00233 <a name="l00234"></a>00234 <span class="keywordflow">if</span> (options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#f01372889b473a7afcea78008e7250c3" title="Bundle Reply-To EID.">replyto_</a> != <span class="stringliteral">""</span>) { <a name="l00235"></a>00235 b-><a class="code" href="classdtn_1_1Bundle.html#7c2091e44637889b9ad6f94a82ae7f83" title="Setters and mutable accessors.">mutable_replyto</a>()-><a class="code" href="classdtn_1_1EndpointID.html#ec39752e4da3107b16ff5da58d2aa5ab" title="Assign this endpoint ID as a copy of the other.">assign</a>(options.<a class="code" href="classdtn_1_1BundleCommand_1_1InjectOpts.html#f01372889b473a7afcea78008e7250c3" title="Bundle Reply-To EID.">replyto_</a>.c_str()); <a name="l00236"></a>00236 } <a name="l00237"></a>00237 <a name="l00238"></a>00238 oasys::StringBuffer error; <a name="l00239"></a>00239 <span class="keywordflow">if</span> (!b-><a class="code" href="classdtn_1_1Bundle.html#0205e1c4938ecfd753295c61f2002a48" title="Validate the bundle&#39;s fields.">validate</a>(&error)) { <a name="l00240"></a>00240 resultf(<span class="stringliteral">"bundle validation failed: %s"</span>, error.data()); <a name="l00241"></a>00241 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00242"></a>00242 } <a name="l00243"></a>00243 <a name="l00244"></a>00244 log_debug(<span class="stringliteral">"inject %d byte bundle %s->%s"</span>, payload_len, <a name="l00245"></a>00245 b-><a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(), b-><a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>()); <a name="l00246"></a>00246 <a name="l00247"></a>00247 <a class="code" href="classdtn_1_1BundleDaemon.html#370a80f7dd9fd9297e76d7f830d737a8" title="Queues the event at the tail of the queue for processing by the daemon thread.">BundleDaemon::post</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a>(b, <a class="code" href="namespacedtn.html#60ee39c9672604f59fe1b12d4e1d142bf3e56dfb4e624d4f62d7099b60472072" title="a local application">EVENTSRC_APP</a>)); <a name="l00248"></a>00248 <a name="l00249"></a>00249 <span class="comment">// return the creation timestamp (can use with source EID to</span> <a name="l00250"></a>00250 <span class="comment">// create a globally unique bundle identifier</span> <a name="l00251"></a>00251 resultf(<span class="stringliteral">"%u.%u"</span>, b-><a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a>, b-><a class="code" href="classdtn_1_1Bundle.html#13cd9ab7b010f09562170e2a57242209" title="Accessors.">creation_ts</a>().<a class="code" href="structdtn_1_1BundleTimestamp.html#ebc8cea66862d7f6056da450db410347" title="Sub-second sequence number.">seqno_</a>); <a name="l00252"></a>00252 <span class="keywordflow">return</span> TCL_OK; <a name="l00253"></a>00253 <a name="l00254"></a>00254 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(cmd, <span class="stringliteral">"stats"</span>)) { <a name="l00255"></a>00255 oasys::StringBuffer <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>(<span class="stringliteral">"Bundle Statistics: "</span>); <a name="l00256"></a>00256 BundleDaemon::instance()->get_bundle_stats(&buf); <a name="l00257"></a>00257 set_result(buf.c_str()); <a name="l00258"></a>00258 <span class="keywordflow">return</span> TCL_OK; <a name="l00259"></a>00259 <a name="l00260"></a>00260 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(cmd, <span class="stringliteral">"daemon_stats"</span>)) { <a name="l00261"></a>00261 oasys::StringBuffer <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>(<span class="stringliteral">"Bundle Daemon Statistics: "</span>); <a name="l00262"></a>00262 BundleDaemon::instance()->get_daemon_stats(&buf); <a name="l00263"></a>00263 set_result(buf.c_str()); <a name="l00264"></a>00264 <span class="keywordflow">return</span> TCL_OK; <a name="l00265"></a>00265 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(cmd, <span class="stringliteral">"daemon_status"</span>)) { <a name="l00266"></a>00266 <a class="code" href="classdtn_1_1BundleDaemon.html#bb88ebba32e4e95a96ee76b3f91d9052" title="Post the given event and wait for it to be processed by the daemon thread or for...">BundleDaemon::post_and_wait</a>(<span class="keyword">new</span> <a class="code" href="classdtn_1_1StatusRequest.html" title="Event class for checking that the daemon is still running.">StatusRequest</a>(), <a name="l00267"></a>00267 <a class="code" href="classdtn_1_1CompletionNotifier.html#ead90cdea24269e08f427cab1e856dcc">CompletionNotifier::notifier</a>()); <a name="l00268"></a>00268 set_result(<span class="stringliteral">"DTN daemon ok"</span>); <a name="l00269"></a>00269 <span class="keywordflow">return</span> TCL_OK; <a name="l00270"></a>00270 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(cmd, <span class="stringliteral">"reset_stats"</span>)) { <a name="l00271"></a>00271 BundleDaemon::instance()->reset_stats(); <a name="l00272"></a>00272 <span class="keywordflow">return</span> TCL_OK; <a name="l00273"></a>00273 <a name="l00274"></a>00274 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(cmd, <span class="stringliteral">"list"</span>)) { <a name="l00275"></a>00275 <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b; <a name="l00276"></a>00276 <a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">BundleList::iterator</a> iter; <a name="l00277"></a>00277 oasys::StringBuffer <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>; <a name="l00278"></a>00278 <a class="code" href="classdtn_1_1BundleList.html" title="List structure for handling bundles.">BundleList</a>* pending = <a name="l00279"></a>00279 BundleDaemon::instance()->pending_bundles(); <a name="l00280"></a>00280 <a name="l00281"></a>00281 oasys::ScopeLock l(pending-><a class="code" href="classdtn_1_1BundleList.html#0d0c9f789f0f7f7d1cda3b4ecf32d2bc" title="Return the internal lock on this list.">lock</a>(), <span class="stringliteral">"BundleCommand::exec"</span>); <a name="l00282"></a>00282 buf.appendf(<span class="stringliteral">"Currently Pending Bundles (%zu): \n"</span>, pending-><a class="code" href="classdtn_1_1BundleList.html#3c50c6f421631a4dd72b7b77b0660bc3" title="Return the size of the list.">size</a>()); <a name="l00283"></a>00283 <a name="l00284"></a>00284 <span class="keywordflow">for</span> (iter = pending-><a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf" title="Iterator used to iterate through the list.">begin</a>(); iter != pending-><a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1" title="Iterator used to mark the end of the list.">end</a>(); ++iter) { <a name="l00285"></a>00285 b = *iter; <a name="l00286"></a>00286 buf.appendf(<span class="stringliteral">"\t%-3d: %s -> %s length %zu\n"</span>, <a name="l00287"></a>00287 b-><a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), <a name="l00288"></a>00288 b-><a class="code" href="classdtn_1_1Bundle.html#2dae8a97270a95799acf45d859eaf866" title="Accessors.">source</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(), <a name="l00289"></a>00289 b-><a class="code" href="classdtn_1_1Bundle.html#507241e8ac766e1900009ed6243e2aa3" title="Accessors.">dest</a>().<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>(), <a name="l00290"></a>00290 b-><a class="code" href="classdtn_1_1Bundle.html#3bc0b88b547620b4029eba4809a73447" title="Accessors.">payload</a>().<a class="code" href="classdtn_1_1BundlePayload.html#56b3851ad789c4dbf019a32d557b7453" title="The payload length.">length</a>()); <a name="l00291"></a>00291 } <a name="l00292"></a>00292 <a name="l00293"></a>00293 set_result(buf.c_str()); <a name="l00294"></a>00294 <a name="l00295"></a>00295 <span class="keywordflow">return</span> TCL_OK; <a name="l00296"></a>00296 <a name="l00297"></a>00297 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(cmd, <span class="stringliteral">"ids"</span>)) { <a name="l00298"></a>00298 <a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">BundleList::iterator</a> iter; <a name="l00299"></a>00299 <a class="code" href="classdtn_1_1BundleList.html" title="List structure for handling bundles.">BundleList</a>* pending = <a name="l00300"></a>00300 BundleDaemon::instance()->pending_bundles(); <a name="l00301"></a>00301 <a name="l00302"></a>00302 oasys::ScopeLock l(pending-><a class="code" href="classdtn_1_1BundleList.html#0d0c9f789f0f7f7d1cda3b4ecf32d2bc" title="Return the internal lock on this list.">lock</a>(), <span class="stringliteral">"BundleCommand::exec"</span>); <a name="l00303"></a>00303 <a name="l00304"></a>00304 <span class="keywordflow">for</span> (iter = pending-><a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf" title="Iterator used to iterate through the list.">begin</a>(); iter != pending-><a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1" title="Iterator used to mark the end of the list.">end</a>(); ++iter) { <a name="l00305"></a>00305 append_resultf(<span class="stringliteral">"%d "</span>, (*iter)->bundleid()); <a name="l00306"></a>00306 } <a name="l00307"></a>00307 <a name="l00308"></a>00308 <span class="keywordflow">return</span> TCL_OK; <a name="l00309"></a>00309 <a name="l00310"></a>00310 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(cmd, <span class="stringliteral">"info"</span>) || <a name="l00311"></a>00311 !strcmp(cmd, <span class="stringliteral">"dump"</span>) || <a name="l00312"></a>00312 !strcmp(cmd, <span class="stringliteral">"dump_tcl"</span>) || <a name="l00313"></a>00313 !strcmp(cmd, <span class="stringliteral">"dump_ascii"</span>) || <a name="l00314"></a>00314 !strcmp(cmd, <span class="stringliteral">"expire"</span>)) <a name="l00315"></a>00315 { <a name="l00316"></a>00316 <span class="comment">// bundle [info|dump|dump_ascii|expire] <id></span> <a name="l00317"></a>00317 <span class="keywordflow">if</span> (objc != 3) { <a name="l00318"></a>00318 wrong_num_args(objc, objv, 2, 3, 3); <a name="l00319"></a>00319 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00320"></a>00320 } <a name="l00321"></a>00321 <a name="l00322"></a>00322 <span class="keywordtype">int</span> bundleid; <a name="l00323"></a>00323 <span class="keywordflow">if</span> (Tcl_GetIntFromObj(interp, objv[2], &bundleid) != TCL_OK) { <a name="l00324"></a>00324 resultf(<span class="stringliteral">"invalid bundle id %s"</span>, <a name="l00325"></a>00325 Tcl_GetStringFromObj(objv[2], 0)); <a name="l00326"></a>00326 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00327"></a>00327 } <a name="l00328"></a>00328 <a name="l00329"></a>00329 <a class="code" href="classdtn_1_1BundleList.html" title="List structure for handling bundles.">BundleList</a>* pending = <a name="l00330"></a>00330 BundleDaemon::instance()->pending_bundles(); <a name="l00331"></a>00331 <a name="l00332"></a>00332 <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> bundle = pending-><a class="code" href="classdtn_1_1BundleList.html#2958520b5b132bb3ed3f3e26c1eb295e" title="Search the list for a bundle with the given id.">find</a>(bundleid); <a name="l00333"></a>00333 <a name="l00334"></a>00334 <span class="keywordflow">if</span> (bundle == NULL) { <a name="l00335"></a>00335 resultf(<span class="stringliteral">"no bundle with id %d"</span>, bundleid); <a name="l00336"></a>00336 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00337"></a>00337 } <a name="l00338"></a>00338 <a name="l00339"></a>00339 <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"info"</span>) == 0) { <a name="l00340"></a>00340 oasys::StringBuffer <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>; <a name="l00341"></a>00341 bundle->format_verbose(&buf); <a name="l00342"></a>00342 set_result(buf.c_str()); <a name="l00343"></a>00343 <a name="l00344"></a>00344 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"dump_tcl"</span>) == 0) { <a name="l00345"></a>00345 Tcl_Obj* result = NULL; <a name="l00346"></a>00346 <span class="keywordtype">int</span> ok = <a name="l00347"></a>00347 <a class="code" href="classdtn_1_1TclRegistration.html#a879c3eab74c90a32c3a88d59a3d0b54" title="Parse the given bundle&#39;s internals into a new tcl list object (or an error if...">TclRegistration::parse_bundle_data</a>(interp, bundle, &result); <a name="l00348"></a>00348 <a name="l00349"></a>00349 set_objresult(result); <a name="l00350"></a>00350 <span class="keywordflow">return</span> ok; <a name="l00351"></a>00351 <a name="l00352"></a>00352 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"dump_ascii"</span>) == 0) { <a name="l00353"></a>00353 <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a> = bundle->payload().length(); <a name="l00354"></a>00354 oasys::StringBuffer <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>(len); <a name="l00355"></a>00355 <span class="keyword">const</span> u_char* bp = <a name="l00356"></a>00356 bundle->payload().read_data(0, len, (u_char*)buf.data()); <a name="l00357"></a>00357 <a name="l00358"></a>00358 buf.append((<span class="keyword">const</span> <span class="keywordtype">char</span>*)bp, len); <a name="l00359"></a>00359 set_result(buf.c_str()); <a name="l00360"></a>00360 <a name="l00361"></a>00361 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"dump"</span>) == 0) { <a name="l00362"></a>00362 <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a> = bundle->payload().length(); <a name="l00363"></a>00363 oasys::HexDumpBuffer <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>(len); <a name="l00364"></a>00364 <a name="l00365"></a>00365 bundle->payload().read_data(0, len, (u_char*)buf.tail_buf(len)); <a name="l00366"></a>00366 buf.incr_len(len); <a name="l00367"></a>00367 <a name="l00368"></a>00368 set_result(buf.hexify().c_str()); <a name="l00369"></a>00369 <a name="l00370"></a>00370 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(cmd, <span class="stringliteral">"expire"</span>) == 0) { <a name="l00371"></a>00371 BundleDaemon::instance()->post_at_head( <a name="l00372"></a>00372 <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleExpiredEvent.html" title="Event class for bundle expiration.">BundleExpiredEvent</a>(bundle.object())); <a name="l00373"></a>00373 <span class="keywordflow">return</span> TCL_OK; <a name="l00374"></a>00374 } <a name="l00375"></a>00375 <a name="l00376"></a>00376 <span class="keywordflow">return</span> TCL_OK; <a name="l00377"></a>00377 <a name="l00378"></a>00378 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(cmd, <span class="stringliteral">"cancel"</span>)) { <a name="l00379"></a>00379 <span class="comment">// bundle cancel <id> <link></span> <a name="l00380"></a>00380 <span class="keywordflow">if</span> (objc != 4) { <a name="l00381"></a>00381 wrong_num_args(objc, objv, 2, 4, 4); <a name="l00382"></a>00382 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00383"></a>00383 } <a name="l00384"></a>00384 <a name="l00385"></a>00385 <span class="keywordtype">int</span> bundleid; <a name="l00386"></a>00386 <span class="keywordflow">if</span> (Tcl_GetIntFromObj(interp, objv[2], &bundleid) != TCL_OK) { <a name="l00387"></a>00387 resultf(<span class="stringliteral">"invalid bundle id %s"</span>, <a name="l00388"></a>00388 Tcl_GetStringFromObj(objv[2], 0)); <a name="l00389"></a>00389 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00390"></a>00390 } <a name="l00391"></a>00391 <a name="l00392"></a>00392 <span class="keyword">const</span> <span class="keywordtype">char</span>* name = Tcl_GetStringFromObj(objv[3], 0); <a name="l00393"></a>00393 <a name="l00394"></a>00394 <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> br <a name="l00395"></a>00395 = BundleDaemon::instance()->pending_bundles()->find(bundleid); <a name="l00396"></a>00396 <a name="l00397"></a>00397 BundleDaemon::instance()->post_at_head( <a name="l00398"></a>00398 <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleCancelRequest.html" title="Event class for canceling a bundle transmission.">BundleCancelRequest</a>(br, name)); <a name="l00399"></a>00399 <a name="l00400"></a>00400 <span class="keywordflow">return</span> TCL_OK; <a name="l00401"></a>00401 <a name="l00402"></a>00402 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(cmd, <span class="stringliteral">"clear_fwdlog"</span>)) { <a name="l00403"></a>00403 <span class="comment">// bundle clear_fwdlog <id></span> <a name="l00404"></a>00404 <span class="keywordflow">if</span> (objc != 3) { <a name="l00405"></a>00405 wrong_num_args(objc, objv, 2, 3, 3); <a name="l00406"></a>00406 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00407"></a>00407 } <a name="l00408"></a>00408 <a name="l00409"></a>00409 <span class="keywordtype">int</span> bundleid; <a name="l00410"></a>00410 <span class="keywordflow">if</span> (Tcl_GetIntFromObj(interp, objv[2], &bundleid) != TCL_OK) { <a name="l00411"></a>00411 resultf(<span class="stringliteral">"invalid bundle id %s"</span>, <a name="l00412"></a>00412 Tcl_GetStringFromObj(objv[2], 0)); <a name="l00413"></a>00413 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00414"></a>00414 } <a name="l00415"></a>00415 <a name="l00416"></a>00416 <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> br <a name="l00417"></a>00417 = BundleDaemon::instance()->pending_bundles()->find(bundleid); <a name="l00418"></a>00418 <a name="l00419"></a>00419 br->fwdlog()->clear(); <a name="l00420"></a>00420 <a name="l00421"></a>00421 <span class="keywordflow">return</span> TCL_OK; <a name="l00422"></a>00422 <a name="l00423"></a>00423 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(cmd, <span class="stringliteral">"daemon_idle_shutdown"</span>)) { <a name="l00424"></a>00424 oasys::StringBuffer <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>(<span class="stringliteral">"Bundle Daemon Statistics: "</span>); <a name="l00425"></a>00425 <a name="l00426"></a>00426 <span class="keywordflow">if</span> (objc != 3) { <a name="l00427"></a>00427 wrong_num_args(objc, objv, 2, 3, 3); <a name="l00428"></a>00428 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00429"></a>00429 } <a name="l00430"></a>00430 <a name="l00431"></a>00431 <span class="keywordtype">int</span> <a class="code" href="dtnping_8c.html#e0c690118932b32ef40a74bb6a259acd">interval</a>; <a name="l00432"></a>00432 <span class="keywordflow">if</span> (Tcl_GetIntFromObj(interp, objv[2], &interval) != TCL_OK) { <a name="l00433"></a>00433 resultf(<span class="stringliteral">"invalid interval %s"</span>, <a name="l00434"></a>00434 Tcl_GetStringFromObj(objv[2], 0)); <a name="l00435"></a>00435 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00436"></a>00436 } <a name="l00437"></a>00437 <a name="l00438"></a>00438 BundleDaemon::instance()->init_idle_shutdown(interval); <a name="l00439"></a>00439 <span class="keywordflow">return</span> TCL_OK; <a name="l00440"></a>00440 <a name="l00441"></a>00441 } <span class="keywordflow">else</span> { <a name="l00442"></a>00442 resultf(<span class="stringliteral">"unknown bundle subcommand %s"</span>, cmd); <a name="l00443"></a>00443 <span class="keywordflow">return</span> TCL_ERROR; <a name="l00444"></a>00444 } <a name="l00445"></a>00445 } <a name="l00446"></a>00446 <a name="l00447"></a>00447 <a name="l00448"></a>00448 } <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:52 2009 for DTN Reference Implementation by <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>