Sophie

Sophie

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

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: TclRegistration.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>TclRegistration.cc</h1><a href="TclRegistration_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> *    Copyright 2004-2006 Intel Corporation</span>
<a name="l00003"></a>00003 <span class="comment"> * </span>
<a name="l00004"></a>00004 <span class="comment"> *    Licensed under the Apache License, Version 2.0 (the "License");</span>
<a name="l00005"></a>00005 <span class="comment"> *    you may not use this file except in compliance with the License.</span>
<a name="l00006"></a>00006 <span class="comment"> *    You may obtain a copy of the License at</span>
<a name="l00007"></a>00007 <span class="comment"> * </span>
<a name="l00008"></a>00008 <span class="comment"> *        http://www.apache.org/licenses/LICENSE-2.0</span>
<a name="l00009"></a>00009 <span class="comment"> * </span>
<a name="l00010"></a>00010 <span class="comment"> *    Unless required by applicable law or agreed to in writing, software</span>
<a name="l00011"></a>00011 <span class="comment"> *    distributed under the License is distributed on an "AS IS" BASIS,</span>
<a name="l00012"></a>00012 <span class="comment"> *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<a name="l00013"></a>00013 <span class="comment"> *    See the License for the specific language governing permissions and</span>
<a name="l00014"></a>00014 <span class="comment"> *    limitations under the License.</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#  include &lt;<a class="code" href="dtn-config_8h.html">dtn-config.h</a>&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#endif</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;limits.h&gt;</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;oasys/serialize/TclListSerialize.h&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;oasys/util/ScratchBuffer.h&gt;</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="TclRegistration_8h.html">TclRegistration.h</a>"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="BundleEvent_8h.html">bundling/BundleEvent.h</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="BundleDaemon_8h.html">bundling/BundleDaemon.h</a>"</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="bundling_2BundleList_8h.html">bundling/BundleList.h</a>"</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="BundleStatusReport_8h.html">bundling/BundleStatusReport.h</a>"</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="CustodySignal_8h.html">bundling/CustodySignal.h</a>"</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="GlobalStore_8h.html">storage/GlobalStore.h</a>"</span>
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="keyword">namespace </span>dtn {
<a name="l00035"></a>00035 
<a name="l00036"></a><a class="code" href="classdtn_1_1TclRegistration.html#2b86aafbcfc0c7de659cf73fd8834463">00036</a> <a class="code" href="classdtn_1_1TclRegistration.html#2b86aafbcfc0c7de659cf73fd8834463">TclRegistration::TclRegistration</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; <a class="code" href="dtnperf-server_8c.html#6d2d1c31529bee906473fcabaffff34f">endpoint</a>,
<a name="l00037"></a>00037                                  Tcl_Interp* interp)
<a name="l00038"></a>00038     
<a name="l00039"></a>00039     : <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>(<a class="code" href="classdtn_1_1GlobalStore.html" title="Class for those elements of the router that need to be persistently stored but are...">GlobalStore</a>::instance()-&gt;next_regid(),
<a name="l00040"></a>00040                    endpoint, <a class="code" href="classdtn_1_1Registration.html" title="Class used to represent an &amp;quot;application&amp;quot; registration, loosely defined...">Registration</a>::DEFER, 0, 0) <span class="comment">// XXX/demmer expiration??</span>
<a name="l00041"></a>00041 {
<a name="l00042"></a>00042     (void)interp;
<a name="l00043"></a>00043     
<a name="l00044"></a>00044     logpathf(<span class="stringliteral">"/dtn/registration/tcl/%d"</span>, <a class="code" href="classdtn_1_1Registration.html#0df345d8c181f4380604d07c196474e2">regid_</a>);
<a name="l00045"></a>00045     <a class="code" href="classdtn_1_1Registration.html#ab703ed5afcd162fd7295954867a3fba" title="Accessors.">set_active</a>(<span class="keyword">true</span>);
<a name="l00046"></a>00046 
<a name="l00047"></a>00047     log_info(<span class="stringliteral">"new tcl registration on endpoint %s"</span>, endpoint.<a class="code" href="classdtn_1_1EndpointID.html#c9d8a72806359621f4d2850c1e78269c">c_str</a>());
<a name="l00048"></a>00048 
<a name="l00049"></a>00049     <a class="code" href="classdtn_1_1TclRegistration.html#b07bf65618d663c58539470e56f14127">bundle_list_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1BlockingBundleList.html" title="A simple derivative to the BundleList class that hooks in an oasys Notifier, which...">BlockingBundleList</a>(logpath_);
<a name="l00050"></a>00050     <span class="keywordtype">int</span> <a class="code" href="dtnperf-client_8c.html#6f8059414f0228f0256115e024eeed4b">fd</a> = bundle_list_-&gt;notifier()-&gt;read_fd();
<a name="l00051"></a>00051     <a class="code" href="classdtn_1_1TclRegistration.html#b38ce785b3a28b5505939ade74b0a102">notifier_channel_</a> = oasys::TclCommandInterp::instance()-&gt;
<a name="l00052"></a>00052                         register_file_channel((ClientData)fd, TCL_READABLE);
<a name="l00053"></a>00053     log_debug(<span class="stringliteral">"notifier_channel_ is %p"</span>, <a class="code" href="classdtn_1_1TclRegistration.html#b38ce785b3a28b5505939ade74b0a102">notifier_channel_</a>);
<a name="l00054"></a>00054 }
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 <span class="keywordtype">void</span>
<a name="l00057"></a><a class="code" href="classdtn_1_1TclRegistration.html#5c5cec7028f74dd9139d86e283ec6747">00057</a> <a class="code" href="classdtn_1_1TclRegistration.html#5c5cec7028f74dd9139d86e283ec6747" title="virtual from Registration">TclRegistration::deliver_bundle</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle)
<a name="l00058"></a>00058 {
<a name="l00059"></a>00059     <a class="code" href="classdtn_1_1TclRegistration.html#b07bf65618d663c58539470e56f14127">bundle_list_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#9f3efd0593739e89ed478fd4bbccd3e0" title="Add a new bundle to the back of the list.">push_back</a>(bundle);
<a name="l00060"></a>00060 }
<a name="l00061"></a>00061 
<a name="l00062"></a>00062 <span class="keywordtype">int</span>
<a name="l00063"></a><a class="code" href="classdtn_1_1TclRegistration.html#1ea43d80d4b6eb10501eb6d8bdd556f7">00063</a> <a class="code" href="classdtn_1_1TclRegistration.html#1ea43d80d4b6eb10501eb6d8bdd556f7">TclRegistration::exec</a>(<span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>** argv, Tcl_Interp* interp)
<a name="l00064"></a>00064 {
<a name="l00065"></a>00065     oasys::TclCommandInterp* cmdinterp = oasys::TclCommandInterp::instance();
<a name="l00066"></a>00066     <span class="keywordflow">if</span> (argc &lt; 1) {
<a name="l00067"></a>00067         cmdinterp-&gt;wrong_num_args(argc, argv, 0, 1, INT_MAX);
<a name="l00068"></a>00068         <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00069"></a>00069     }
<a name="l00070"></a>00070     <span class="keyword">const</span> <span class="keywordtype">char</span>* op = argv[0];
<a name="l00071"></a>00071 
<a name="l00072"></a>00072     <span class="keywordflow">if</span> (strcmp(op, <span class="stringliteral">"get_list_channel"</span>) == 0)
<a name="l00073"></a>00073     {
<a name="l00074"></a>00074         <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TclRegistration.html#6c3fb4b81530ccf51f43d89ab237ffd9" title="Return in the tcl result a Tcl_Channel to wrap the BundleList&amp;#39;s notifier pipe...">get_list_channel</a>(interp);
<a name="l00075"></a>00075     }
<a name="l00076"></a>00076     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp(op, <span class="stringliteral">"get_bundle_data"</span>) == 0)
<a name="l00077"></a>00077     {
<a name="l00078"></a>00078         <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1TclRegistration.html#15bf5116da663ff3a2138f8014bea480" title="Assuming the list channel has been notified, pops a bundle off the list and then...">get_bundle_data</a>(interp);
<a name="l00079"></a>00079     }
<a name="l00080"></a>00080     <span class="keywordflow">else</span>
<a name="l00081"></a>00081     {
<a name="l00082"></a>00082         cmdinterp-&gt;resultf(<span class="stringliteral">"invalid operation '%s'"</span>, op);
<a name="l00083"></a>00083         <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00084"></a>00084     }
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 
<a name="l00087"></a>00087 <span class="keywordtype">int</span>
<a name="l00088"></a><a class="code" href="classdtn_1_1TclRegistration.html#6c3fb4b81530ccf51f43d89ab237ffd9">00088</a> <a class="code" href="classdtn_1_1TclRegistration.html#6c3fb4b81530ccf51f43d89ab237ffd9" title="Return in the tcl result a Tcl_Channel to wrap the BundleList&amp;#39;s notifier pipe...">TclRegistration::get_list_channel</a>(Tcl_Interp* interp)
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090     (void)interp;
<a name="l00091"></a>00091     oasys::TclCommandInterp* cmdinterp = oasys::TclCommandInterp::instance();
<a name="l00092"></a>00092     cmdinterp-&gt;set_result(Tcl_GetChannelName(<a class="code" href="classdtn_1_1TclRegistration.html#b38ce785b3a28b5505939ade74b0a102">notifier_channel_</a>));
<a name="l00093"></a>00093     <span class="keywordflow">return</span> TCL_OK;
<a name="l00094"></a>00094 }
<a name="l00095"></a>00095 
<a name="l00096"></a>00096 
<a name="l00097"></a>00097 <span class="keywordtype">int</span>
<a name="l00098"></a><a class="code" href="classdtn_1_1TclRegistration.html#15bf5116da663ff3a2138f8014bea480">00098</a> <a class="code" href="classdtn_1_1TclRegistration.html#15bf5116da663ff3a2138f8014bea480" title="Assuming the list channel has been notified, pops a bundle off the list and then...">TclRegistration::get_bundle_data</a>(Tcl_Interp* interp)
<a name="l00099"></a>00099 {
<a name="l00100"></a>00100     oasys::TclCommandInterp* cmdinterp = oasys::TclCommandInterp::instance();
<a name="l00101"></a>00101     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> b(<span class="stringliteral">"TclRegistration::get_bundle_data temporary"</span>);
<a name="l00102"></a>00102     b = <a class="code" href="classdtn_1_1TclRegistration.html#b07bf65618d663c58539470e56f14127">bundle_list_</a>-&gt;<a class="code" href="classdtn_1_1BundleList.html#265a9efd0831be3094f815eed22aec42" title="Remove (and return) a reference to the first bundle on the list.">pop_front</a>();
<a name="l00103"></a>00103     <span class="keywordflow">if</span> (b == NULL) {
<a name="l00104"></a>00104         cmdinterp-&gt;set_objresult(Tcl_NewListObj(0, 0));
<a name="l00105"></a>00105         <span class="keywordflow">return</span> TCL_OK; <span class="comment">// empty list</span>
<a name="l00106"></a>00106     }
<a name="l00107"></a>00107 
<a name="l00108"></a>00108     Tcl_Obj* result;
<a name="l00109"></a>00109     <span class="keywordtype">int</span> ok = <a class="code" href="classdtn_1_1TclRegistration.html#a879c3eab74c90a32c3a88d59a3d0b54" title="Parse the given bundle&amp;#39;s internals into a new tcl list object (or an error if...">parse_bundle_data</a>(interp, b, &amp;result);
<a name="l00110"></a>00110     cmdinterp-&gt;set_objresult(result);
<a name="l00111"></a>00111 
<a name="l00112"></a>00112     <span class="keywordflow">if</span> (ok != TCL_OK) {
<a name="l00113"></a>00113         <span class="keywordflow">return</span> ok;
<a name="l00114"></a>00114     }
<a name="l00115"></a>00115     
<a name="l00116"></a>00116     <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_1BundleDeliveredEvent.html" title="Event class for local bundle delivery.">BundleDeliveredEvent</a>(b.object(), <span class="keyword">this</span>));
<a name="l00117"></a>00117     <span class="keywordflow">return</span> TCL_OK;
<a name="l00118"></a>00118     
<a name="l00119"></a>00119 }
<a name="l00120"></a>00120 
<a name="l00163"></a>00163 <span class="keywordtype">int</span>
<a name="l00164"></a><a class="code" href="classdtn_1_1TclRegistration.html#a879c3eab74c90a32c3a88d59a3d0b54">00164</a> <a class="code" href="classdtn_1_1TclRegistration.html#a879c3eab74c90a32c3a88d59a3d0b54" title="Parse the given bundle&amp;#39;s internals into a new tcl list object (or an error if...">TclRegistration::parse_bundle_data</a>(Tcl_Interp* interp,
<a name="l00165"></a>00165                                    <span class="keyword">const</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>&amp; b,
<a name="l00166"></a>00166                                    Tcl_Obj** result)
<a name="l00167"></a>00167 {
<a name="l00168"></a>00168     <span class="comment">// Using the tcl based serializer, grab all the serialized</span>
<a name="l00169"></a>00169     <span class="comment">// metadata fields into a new list object</span>
<a name="l00170"></a>00170     Tcl_Obj* objv = Tcl_NewListObj(0, 0);
<a name="l00171"></a>00171     oasys::TclListSerialize s(interp, objv,
<a name="l00172"></a>00172                               oasys::Serialize::CONTEXT_LOCAL,
<a name="l00173"></a>00173                               0);
<a name="l00174"></a>00174     b-&gt;serialize(&amp;s);
<a name="l00175"></a>00175 
<a name="l00176"></a>00176     <span class="comment">// read in all the payload data (XXX/demmer this will not be nice</span>
<a name="l00177"></a>00177     <span class="comment">// for big bundles)</span>
<a name="l00178"></a>00178     <span class="keywordtype">size_t</span> payload_len = b-&gt;payload().length();
<a name="l00179"></a>00179     oasys::ScratchBuffer&lt;u_char*&gt; <a class="code" href="dtncat_8c.html#5287cc892023d51088dd91a9b78de7c5">payload_buf</a>;
<a name="l00180"></a>00180     <span class="keyword">const</span> u_char* payload_data = (<span class="keyword">const</span> u_char*)<span class="stringliteral">""</span>;
<a name="l00181"></a>00181     <span class="keywordflow">if</span> (payload_len != 0) {
<a name="l00182"></a>00182         payload_data = b-&gt;payload().read_data(0, payload_len, 
<a name="l00183"></a>00183                                               payload_buf.buf(payload_len));
<a name="l00184"></a>00184     }
<a name="l00185"></a>00185 
<a name="l00186"></a>00186     <span class="keywordtype">char</span> tmp_buf[128];              <span class="comment">// used for sprintf strings</span>
<a name="l00187"></a>00187 
<a name="l00188"></a>00188 <span class="preprocessor">#define addElement(e)                                                      \</span>
<a name="l00189"></a>00189 <span class="preprocessor">    if (Tcl_ListObjAppendElement(interp, objv, (e)) != TCL_OK) {           \</span>
<a name="l00190"></a>00190 <span class="preprocessor">        *result = Tcl_NewStringObj("Tcl_ListObjAppendElement failed", -1); \</span>
<a name="l00191"></a>00191 <span class="preprocessor">        return TCL_ERROR;                                                  \</span>
<a name="l00192"></a>00192 <span class="preprocessor">    }</span>
<a name="l00193"></a>00193 <span class="preprocessor"></span>    
<a name="l00194"></a>00194     <span class="comment">// stick in the payload</span>
<a name="l00195"></a>00195     <a class="code" href="TclRegistration_8cc.html#a024694ddf465c751fed01e4bb4f8bb4">addElement</a>(Tcl_NewStringObj(<span class="stringliteral">"payload_len"</span>, -1));
<a name="l00196"></a>00196     <a class="code" href="TclRegistration_8cc.html#a024694ddf465c751fed01e4bb4f8bb4">addElement</a>(Tcl_NewIntObj(payload_len));
<a name="l00197"></a>00197     
<a name="l00198"></a>00198     <a class="code" href="TclRegistration_8cc.html#a024694ddf465c751fed01e4bb4f8bb4">addElement</a>(Tcl_NewStringObj(<span class="stringliteral">"payload_data"</span>, -1));
<a name="l00199"></a>00199     <a class="code" href="TclRegistration_8cc.html#a024694ddf465c751fed01e4bb4f8bb4">addElement</a>(Tcl_NewByteArrayObj(const_cast&lt;u_char*&gt;(payload_data), 
<a name="l00200"></a>00200                                    payload_len));
<a name="l00201"></a>00201 
<a name="l00202"></a>00202     <span class="comment">// and a pretty formatted creation timestamp</span>
<a name="l00203"></a>00203     <a class="code" href="TclRegistration_8cc.html#a024694ddf465c751fed01e4bb4f8bb4">addElement</a>(Tcl_NewStringObj(<span class="stringliteral">"creation_ts"</span>, -1));
<a name="l00204"></a>00204     sprintf(tmp_buf, <span class="stringliteral">"%d.%d"</span>, b-&gt;creation_ts().seconds_, b-&gt;creation_ts().seqno_);
<a name="l00205"></a>00205     <a class="code" href="TclRegistration_8cc.html#a024694ddf465c751fed01e4bb4f8bb4">addElement</a>(Tcl_NewStringObj(tmp_buf, -1));
<a name="l00206"></a>00206 
<a name="l00207"></a>00207     <span class="comment">// If we're not an admin bundle, we're done</span>
<a name="l00208"></a>00208     <span class="keywordflow">if</span> (!b-&gt;is_admin()) {
<a name="l00209"></a>00209         <span class="keywordflow">goto</span> done;
<a name="l00210"></a>00210     }
<a name="l00211"></a>00211 
<a name="l00212"></a>00212     <span class="comment">// Admin Type:</span>
<a name="l00213"></a>00213     addElement(Tcl_NewStringObj(<span class="stringliteral">"admin_type"</span>, -1));
<a name="l00214"></a>00214     <a class="code" href="classdtn_1_1BundleProtocol.html#35e3c05cad3ebc9ec0f4d9b0f88ece20" title="Administrative Record Type Codes.">BundleProtocol::admin_record_type_t</a> admin_type;
<a name="l00215"></a>00215     <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1BundleProtocol.html#0100870ed71be16830543b822cfffd2c" title="Assuming the given bundle is an administrative bundle, extract the admin bundle type...">BundleProtocol::get_admin_type</a>(b.object(), &amp;admin_type)) {
<a name="l00216"></a>00216         <span class="keywordflow">goto</span> done;
<a name="l00217"></a>00217     }
<a name="l00218"></a>00218 
<a name="l00219"></a>00219     <span class="comment">// Now for each type of admin bundle, first append the string to</span>
<a name="l00220"></a>00220     <span class="comment">// define that type, then all the relevant fields of the type</span>
<a name="l00221"></a>00221     <span class="keywordflow">switch</span> (admin_type) {
<a name="l00222"></a>00222     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1BundleProtocol.html#35e3c05cad3ebc9ec0f4d9b0f88ece20e4dc69cfbb7fd68487cffea427db7f7f">BundleProtocol::ADMIN_STATUS_REPORT</a>:
<a name="l00223"></a>00223     {
<a name="l00224"></a>00224         addElement(Tcl_NewStringObj(<span class="stringliteral">"Status Report"</span>, -1));
<a name="l00225"></a>00225 
<a name="l00226"></a>00226         <a class="code" href="structdtn_1_1BundleStatusReport_1_1data__t.html" title="Specification of the contents of a Bundle Status Report.">BundleStatusReport::data_t</a> sr;
<a name="l00227"></a>00227         <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1BundleStatusReport.html#a9e6e466cf356e0550bd1f36def1f4dc" title="Parse a byte stream containing a Status Report Payload and store the fields in the...">BundleStatusReport::parse_status_report</a>(&amp;sr, payload_data,
<a name="l00228"></a>00228                                                      payload_len)) {
<a name="l00229"></a>00229             *result =
<a name="l00230"></a>00230                 Tcl_NewStringObj(<span class="stringliteral">"Admin Bundle Status Report parsing failed"</span>, -1);
<a name="l00231"></a>00231             <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00232"></a>00232         }
<a name="l00233"></a>00233 
<a name="l00234"></a>00234         <span class="comment">// Fragment fields</span>
<a name="l00235"></a>00235         <span class="keywordflow">if</span> (sr.<a class="code" href="structdtn_1_1BundleStatusReport_1_1data__t.html#66afe45290d69ee0c6a1ca11240fd7ae">admin_flags_</a> &amp; <a class="code" href="classdtn_1_1BundleProtocol.html#f827c0a9dff8115434bc273dc53b7df1951511bc017d452550ea77dd9a15306b">BundleProtocol::ADMIN_IS_FRAGMENT</a>) {
<a name="l00236"></a>00236             addElement(Tcl_NewStringObj(<span class="stringliteral">"orig_frag_offset"</span>, -1));
<a name="l00237"></a>00237             addElement(Tcl_NewLongObj(sr.<a class="code" href="structdtn_1_1BundleStatusReport_1_1data__t.html#7be8a5bd64a37ef4fb01e179b14c5368">orig_frag_offset_</a>));
<a name="l00238"></a>00238             addElement(Tcl_NewStringObj(<span class="stringliteral">"orig_frag_length"</span>, -1));
<a name="l00239"></a>00239             addElement(Tcl_NewLongObj(sr.<a class="code" href="structdtn_1_1BundleStatusReport_1_1data__t.html#db7f27ef465b4c583c68c455bc7da808">orig_frag_length_</a>));
<a name="l00240"></a>00240         }
<a name="l00241"></a>00241 
<a name="l00242"></a>00242         <span class="comment">// Status fields with timestamps:</span>
<a name="l00243"></a>00243 <span class="preprocessor">#define APPEND_TIMESTAMP(_flag, _what, _field)                          \</span>
<a name="l00244"></a>00244 <span class="preprocessor">        if (sr.status_flags_ &amp; BundleStatusReport::_flag) {                 \</span>
<a name="l00245"></a>00245 <span class="preprocessor">            addElement(Tcl_NewStringObj(_what, -1));                    \</span>
<a name="l00246"></a>00246 <span class="preprocessor">            sprintf(tmp_buf, "%u.%u",                                   \</span>
<a name="l00247"></a>00247 <span class="preprocessor">                    sr._field.seconds_, sr._field.seqno_);              \</span>
<a name="l00248"></a>00248 <span class="preprocessor">            addElement(Tcl_NewStringObj(tmp_buf, -1));                  \</span>
<a name="l00249"></a>00249 <span class="preprocessor">        }</span>
<a name="l00250"></a>00250 <span class="preprocessor"></span>
<a name="l00251"></a>00251         <a class="code" href="TclRegistration_8cc.html#1e5592d4b940371371b5957a0c37c7f0">APPEND_TIMESTAMP</a>(<a class="code" href="dtn__types_8h.html#6d9484ac5d0ab5f3fd7383af0c7b99198d50a4d6db1ab5232afc0d5cd55deb93">STATUS_RECEIVED</a>,
<a name="l00252"></a>00252                          <span class="stringliteral">"sr_received_time"</span>, receipt_tv_);
<a name="l00253"></a>00253         <a class="code" href="TclRegistration_8cc.html#1e5592d4b940371371b5957a0c37c7f0">APPEND_TIMESTAMP</a>(<a class="code" href="dtn__types_8h.html#6d9484ac5d0ab5f3fd7383af0c7b9919a88133ae1757925b880c6fd1a395a0fb">STATUS_CUSTODY_ACCEPTED</a>,
<a name="l00254"></a>00254                          <span class="stringliteral">"sr_custody_time"</span>,      custody_tv_);
<a name="l00255"></a>00255         <a class="code" href="TclRegistration_8cc.html#1e5592d4b940371371b5957a0c37c7f0">APPEND_TIMESTAMP</a>(<a class="code" href="dtn__types_8h.html#6d9484ac5d0ab5f3fd7383af0c7b991925211f0e0706cbc8981285126ac621b2">STATUS_FORWARDED</a>,
<a name="l00256"></a>00256                          <span class="stringliteral">"sr_forwarded_time"</span>,    forwarding_tv_);
<a name="l00257"></a>00257         <a class="code" href="TclRegistration_8cc.html#1e5592d4b940371371b5957a0c37c7f0">APPEND_TIMESTAMP</a>(<a class="code" href="dtn__types_8h.html#6d9484ac5d0ab5f3fd7383af0c7b9919c0ac4c503dd8586dca17b9d5c1e9f30d">STATUS_DELIVERED</a>,
<a name="l00258"></a>00258                          <span class="stringliteral">"sr_delivered_time"</span>,    delivery_tv_);
<a name="l00259"></a>00259         <a class="code" href="TclRegistration_8cc.html#1e5592d4b940371371b5957a0c37c7f0">APPEND_TIMESTAMP</a>(<a class="code" href="dtn__types_8h.html#6d9484ac5d0ab5f3fd7383af0c7b99193f1e22c771850e7a7cdfafbda38cc14e">STATUS_DELETED</a>,
<a name="l00260"></a>00260                          <span class="stringliteral">"sr_deleted_time"</span>,      deletion_tv_);
<a name="l00261"></a>00261         <a class="code" href="TclRegistration_8cc.html#1e5592d4b940371371b5957a0c37c7f0">APPEND_TIMESTAMP</a>(<a class="code" href="dtn__types_8h.html#6d9484ac5d0ab5f3fd7383af0c7b9919e930c2985c34c1847df57506aa8af0f1">STATUS_ACKED_BY_APP</a>,
<a name="l00262"></a>00262                          <span class="stringliteral">"sr_acked_by_app_time"</span>, ack_by_app_tv_);
<a name="l00263"></a>00263 <span class="preprocessor">#undef APPEND_TIMESTAMP</span>
<a name="l00264"></a>00264 <span class="preprocessor"></span>        
<a name="l00265"></a>00265         <span class="comment">// Reason Code:</span>
<a name="l00266"></a>00266         addElement(Tcl_NewStringObj(<span class="stringliteral">"sr_reason"</span>, -1));
<a name="l00267"></a>00267         addElement(Tcl_NewStringObj(<a class="code" href="classdtn_1_1BundleStatusReport.html#c01eebd70430ee5eaf44240097a765cf" title="Return a string version of the reason code.">BundleStatusReport::reason_to_str</a>(sr.<a class="code" href="structdtn_1_1BundleStatusReport_1_1data__t.html#9f0eb101ebea16d3a0c1e0dbf805e79e">reason_code_</a>), -1));
<a name="l00268"></a>00268         
<a name="l00269"></a>00269         <span class="comment">// Bundle creation timestamp</span>
<a name="l00270"></a>00270         addElement(Tcl_NewStringObj(<span class="stringliteral">"orig_creation_ts"</span>, -1));
<a name="l00271"></a>00271         sprintf(tmp_buf, <span class="stringliteral">"%u.%u"</span>,
<a name="l00272"></a>00272                 sr.<a class="code" href="structdtn_1_1BundleStatusReport_1_1data__t.html#a2b2f113db3c501a596df36112d55fcd">orig_creation_tv_</a>.<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a>,
<a name="l00273"></a>00273                 sr.<a class="code" href="structdtn_1_1BundleStatusReport_1_1data__t.html#a2b2f113db3c501a596df36112d55fcd">orig_creation_tv_</a>.<a class="code" href="structdtn_1_1BundleTimestamp.html#ebc8cea66862d7f6056da450db410347" title="Sub-second sequence number.">seqno_</a>);
<a name="l00274"></a>00274         addElement(Tcl_NewStringObj(tmp_buf, -1));
<a name="l00275"></a>00275 
<a name="l00276"></a>00276         <span class="comment">// Status Report's Source EID:</span>
<a name="l00277"></a>00277         addElement(Tcl_NewStringObj(<span class="stringliteral">"orig_source"</span>, -1));
<a name="l00278"></a>00278         addElement(Tcl_NewStringObj(sr.<a class="code" href="structdtn_1_1BundleStatusReport_1_1data__t.html#1808645df3767cb60f1b4bbaf14544f8">orig_source_eid_</a>.<a class="code" href="classdtn_1_1EndpointID.html#e88d5a7398d69c8deb9730cf8edfcf29">data</a>(),
<a name="l00279"></a>00279                                     sr.<a class="code" href="structdtn_1_1BundleStatusReport_1_1data__t.html#1808645df3767cb60f1b4bbaf14544f8">orig_source_eid_</a>.<a class="code" href="classdtn_1_1EndpointID.html#3ed7639ed8794ea8045bb5d16128c5f5">length</a>()));
<a name="l00280"></a>00280         <span class="keywordflow">break</span>;
<a name="l00281"></a>00281     }
<a name="l00282"></a>00282 
<a name="l00283"></a>00283     <span class="comment">//-------------------------------------------</span>
<a name="l00284"></a>00284 
<a name="l00285"></a>00285     <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1BundleProtocol.html#35e3c05cad3ebc9ec0f4d9b0f88ece207e6e1a30d0fed8a953bc65802798f7dd">BundleProtocol::ADMIN_CUSTODY_SIGNAL</a>:
<a name="l00286"></a>00286     {
<a name="l00287"></a>00287         addElement(Tcl_NewStringObj(<span class="stringliteral">"Custody Signal"</span>, -1));
<a name="l00288"></a>00288 
<a name="l00289"></a>00289         <a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html" title="Struct to hold the payload data of the custody signal.">CustodySignal::data_t</a> cs;
<a name="l00290"></a>00290         <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1CustodySignal.html#854ca4797421b5399d6260d1ab9efcb4" title="Parsing function for custody signal bundles.">CustodySignal::parse_custody_signal</a>(&amp;cs, payload_data,
<a name="l00291"></a>00291                                                  payload_len))
<a name="l00292"></a>00292         {
<a name="l00293"></a>00293             *result = Tcl_NewStringObj(<span class="stringliteral">"Admin Custody Signal parsing failed"</span>, -1);
<a name="l00294"></a>00294             <span class="keywordflow">return</span> TCL_ERROR;
<a name="l00295"></a>00295         }
<a name="l00296"></a>00296 
<a name="l00297"></a>00297         <span class="comment">// Fragment fields</span>
<a name="l00298"></a>00298         <span class="keywordflow">if</span> (cs.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#b01fd765a5e2081ebca3271c1cf8130b">admin_flags_</a> &amp; <a class="code" href="classdtn_1_1BundleProtocol.html#f827c0a9dff8115434bc273dc53b7df1951511bc017d452550ea77dd9a15306b">BundleProtocol::ADMIN_IS_FRAGMENT</a>) {
<a name="l00299"></a>00299             addElement(Tcl_NewStringObj(<span class="stringliteral">"orig_frag_offset"</span>, -1));
<a name="l00300"></a>00300             addElement(Tcl_NewLongObj(cs.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#8286664342d04a1f19fde5de0e4385b0">orig_frag_offset_</a>));
<a name="l00301"></a>00301             addElement(Tcl_NewStringObj(<span class="stringliteral">"orig_frag_length"</span>, -1));
<a name="l00302"></a>00302             addElement(Tcl_NewLongObj(cs.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#ad742743039ac6a300ebe8e82bce6370">orig_frag_length_</a>));
<a name="l00303"></a>00303         }
<a name="l00304"></a>00304         
<a name="l00305"></a>00305         addElement(Tcl_NewStringObj(<span class="stringliteral">"custody_succeeded"</span>, -1));
<a name="l00306"></a>00306         addElement(Tcl_NewBooleanObj(cs.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#7c392e35fc540d23ab2605b06a9514fe">succeeded_</a>));
<a name="l00307"></a>00307 
<a name="l00308"></a>00308         addElement(Tcl_NewStringObj(<span class="stringliteral">"custody_reason"</span>, -1));
<a name="l00309"></a>00309         <span class="keywordflow">switch</span>(cs.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#d7f8295055a7d8b4619cf2908b753ff7">reason_</a>) {
<a name="l00310"></a>00310         <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1BundleProtocol.html#e339b3a1104cd188459059e46543490bf974eaaa8cbe4e66aeaf238a454cecf1">BundleProtocol::CUSTODY_NO_ADDTL_INFO</a>:
<a name="l00311"></a>00311             addElement(Tcl_NewStringObj(<span class="stringliteral">"No additional information."</span>, -1));
<a name="l00312"></a>00312             <span class="keywordflow">break</span>;
<a name="l00313"></a>00313             
<a name="l00314"></a>00314         <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1BundleProtocol.html#e339b3a1104cd188459059e46543490b0a6d60329683ef33d75edbce647fb245">BundleProtocol::CUSTODY_REDUNDANT_RECEPTION</a>:
<a name="l00315"></a>00315             addElement(Tcl_NewStringObj(<span class="stringliteral">"Redundant bundle reception."</span>, -1));
<a name="l00316"></a>00316             <span class="keywordflow">break</span>;
<a name="l00317"></a>00317             
<a name="l00318"></a>00318         <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1BundleProtocol.html#e339b3a1104cd188459059e46543490b870861df82a7d42686c4b64887e2e8e7">BundleProtocol::CUSTODY_DEPLETED_STORAGE</a>:
<a name="l00319"></a>00319             addElement(Tcl_NewStringObj(<span class="stringliteral">"Depleted Storage."</span>, -1));
<a name="l00320"></a>00320             <span class="keywordflow">break</span>;
<a name="l00321"></a>00321             
<a name="l00322"></a>00322         <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1BundleProtocol.html#e339b3a1104cd188459059e46543490bf04d881f698e458b945dbefb9163a7a4">BundleProtocol::CUSTODY_ENDPOINT_ID_UNINTELLIGIBLE</a>:
<a name="l00323"></a>00323             addElement(Tcl_NewStringObj(<span class="stringliteral">"Destination endpoint ID unintelligible."</span>, -1));
<a name="l00324"></a>00324             <span class="keywordflow">break</span>;
<a name="l00325"></a>00325             
<a name="l00326"></a>00326         <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1BundleProtocol.html#e339b3a1104cd188459059e46543490bae630a36e16e37e3aec296c18f1a12b2">BundleProtocol::CUSTODY_NO_ROUTE_TO_DEST</a>:
<a name="l00327"></a>00327             addElement(Tcl_NewStringObj(<span class="stringliteral">"No known route to destination from here"</span>, -1));
<a name="l00328"></a>00328             <span class="keywordflow">break</span>;
<a name="l00329"></a>00329             
<a name="l00330"></a>00330         <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1BundleProtocol.html#e339b3a1104cd188459059e46543490bbb74fb4f2a0579bd6b56206cfeffaec2">BundleProtocol::CUSTODY_NO_TIMELY_CONTACT</a>:
<a name="l00331"></a>00331             addElement(Tcl_NewStringObj(<span class="stringliteral">"No timely contact with next node en route."</span>, -1));
<a name="l00332"></a>00332             <span class="keywordflow">break</span>;
<a name="l00333"></a>00333             
<a name="l00334"></a>00334         <span class="keywordflow">case</span> <a class="code" href="classdtn_1_1BundleProtocol.html#e339b3a1104cd188459059e46543490bf28ea7f5e87b6196687b5d0f3bf57d4f">BundleProtocol::CUSTODY_BLOCK_UNINTELLIGIBLE</a>:
<a name="l00335"></a>00335             addElement(Tcl_NewStringObj(<span class="stringliteral">"Block unintelligible."</span>, -1));
<a name="l00336"></a>00336             <span class="keywordflow">break</span>;
<a name="l00337"></a>00337             
<a name="l00338"></a>00338         <span class="keywordflow">default</span>:
<a name="l00339"></a>00339             sprintf(tmp_buf, <span class="stringliteral">"Error: Unknown Custody Signal Reason Code 0x%x"</span>,
<a name="l00340"></a>00340                     cs.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#d7f8295055a7d8b4619cf2908b753ff7">reason_</a>);
<a name="l00341"></a>00341             addElement(Tcl_NewStringObj(tmp_buf, -1));
<a name="l00342"></a>00342             <span class="keywordflow">break</span>;
<a name="l00343"></a>00343         }
<a name="l00344"></a>00344 
<a name="l00345"></a>00345         <span class="comment">// Custody signal timestamp</span>
<a name="l00346"></a>00346         addElement(Tcl_NewStringObj(<span class="stringliteral">"custody_signal_time"</span>, -1));
<a name="l00347"></a>00347         sprintf(tmp_buf, <span class="stringliteral">"%u.%u"</span>,
<a name="l00348"></a>00348                 cs.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#3977165d34fe9c5f0f0abd1a0d923134">custody_signal_tv_</a>.<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a>,
<a name="l00349"></a>00349                 cs.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#3977165d34fe9c5f0f0abd1a0d923134">custody_signal_tv_</a>.<a class="code" href="structdtn_1_1BundleTimestamp.html#ebc8cea66862d7f6056da450db410347" title="Sub-second sequence number.">seqno_</a>);
<a name="l00350"></a>00350         addElement(Tcl_NewStringObj(tmp_buf, -1));
<a name="l00351"></a>00351         
<a name="l00352"></a>00352         <span class="comment">// Bundle creation timestamp</span>
<a name="l00353"></a>00353         addElement(Tcl_NewStringObj(<span class="stringliteral">"orig_creation_ts"</span>, -1));
<a name="l00354"></a>00354         sprintf(tmp_buf, <span class="stringliteral">"%u.%u"</span>,
<a name="l00355"></a>00355                 cs.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#edc95b93052b9266ab6a411c54a28588">orig_creation_tv_</a>.<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a>,
<a name="l00356"></a>00356                 cs.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#edc95b93052b9266ab6a411c54a28588">orig_creation_tv_</a>.<a class="code" href="structdtn_1_1BundleTimestamp.html#ebc8cea66862d7f6056da450db410347" title="Sub-second sequence number.">seqno_</a>);
<a name="l00357"></a>00357         addElement(Tcl_NewStringObj(tmp_buf, -1));
<a name="l00358"></a>00358 
<a name="l00359"></a>00359         <span class="comment">// Original source eid</span>
<a name="l00360"></a>00360         addElement(Tcl_NewStringObj(<span class="stringliteral">"orig_source"</span>, -1));
<a name="l00361"></a>00361         addElement(Tcl_NewStringObj(cs.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#9860d72ca710bc0ccddcab64bf97155f">orig_source_eid_</a>.<a class="code" href="classdtn_1_1EndpointID.html#e88d5a7398d69c8deb9730cf8edfcf29">data</a>(),
<a name="l00362"></a>00362                                     cs.<a class="code" href="structdtn_1_1CustodySignal_1_1data__t.html#9860d72ca710bc0ccddcab64bf97155f">orig_source_eid_</a>.<a class="code" href="classdtn_1_1EndpointID.html#3ed7639ed8794ea8045bb5d16128c5f5">length</a>()));
<a name="l00363"></a>00363         <span class="keywordflow">break</span>;
<a name="l00364"></a>00364     }
<a name="l00365"></a>00365 
<a name="l00366"></a>00366     <span class="comment">//-------------------------------------------</span>
<a name="l00367"></a>00367 
<a name="l00368"></a>00368     <span class="keywordflow">default</span>:
<a name="l00369"></a>00369         sprintf(tmp_buf,
<a name="l00370"></a>00370                 <span class="stringliteral">"Error: Unknown Status Report Type 0x%x"</span>, admin_type);
<a name="l00371"></a>00371         addElement(Tcl_NewStringObj(tmp_buf, -1));
<a name="l00372"></a>00372         <span class="keywordflow">break</span>;
<a name="l00373"></a>00373     }
<a name="l00374"></a>00374 
<a name="l00375"></a>00375     <span class="comment">// all done</span>
<a name="l00376"></a>00376  done:
<a name="l00377"></a>00377     *result = objv;
<a name="l00378"></a>00378     <span class="keywordflow">return</span> TCL_OK;
<a name="l00379"></a>00379 }
<a name="l00380"></a>00380 
<a name="l00381"></a>00381 } <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:58 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>