Sophie

Sophie

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

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: dtntraceroute.c 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>dtntraceroute.c</h1><a href="dtntraceroute_8c.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;stdio.h&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;unistd.h&gt;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;errno.h&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;strings.h&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;time.h&gt;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;sys/time.h&gt;</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="dtn__api_8h.html">dtn_api.h</a>"</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="dtnping_8h.html">dtnping.h</a>"</span>
<a name="l00032"></a>00032 
<a name="l00033"></a><a class="code" href="dtntraceroute_8c.html#d785d8a8f8ff378aa21eb1fa7a6085df">00033</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="dtncat_8c.html#b9e1449fd00c98428516f0b41eddcb10">progname</a>;
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="keywordtype">void</span>
<a name="l00036"></a><a class="code" href="dtntraceroute_8c.html#2ef30c42cbc289d899a8be5d2d8f77d0">00036</a> <a class="code" href="dtncpd_8c.html#2ef30c42cbc289d899a8be5d2d8f77d0">usage</a>()
<a name="l00037"></a>00037 {
<a name="l00038"></a>00038     fprintf(stderr, <span class="stringliteral">"usage: %s [-c count] [-i interval] [-e expiration] [-w waittime] eid\n"</span>,
<a name="l00039"></a>00039             <a class="code" href="dtncat_8c.html#b9e1449fd00c98428516f0b41eddcb10">progname</a>);
<a name="l00040"></a>00040     exit(1);
<a name="l00041"></a>00041 }
<a name="l00042"></a>00042 
<a name="l00043"></a>00043 <span class="keywordtype">void</span> <a class="code" href="dtnping_8c.html#5f259759586f432182213d868b41ebf2">doOptions</a>(<span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span> **argv);
<a name="l00044"></a>00044 
<a name="l00045"></a><a class="code" href="dtntraceroute_8c.html#d6057e40387509de502bdc91007d3238">00045</a> <span class="keywordtype">int</span> <a class="code" href="dtncat_8c.html#d6057e40387509de502bdc91007d3238">expiration</a> = 30;
<a name="l00046"></a><a class="code" href="dtntraceroute_8c.html#382355580ada4027bb3d418c025c5a0d">00046</a> <span class="keywordtype">int</span> <a class="code" href="dtnreporter_8c.html#382355580ada4027bb3d418c025c5a0d">wait_after_done</a> = 0;
<a name="l00047"></a><a class="code" href="dtntraceroute_8c.html#e72d481891d4934c8776b5eea04907d3">00047</a> <span class="keywordtype">char</span> <a class="code" href="dtnping_8c.html#e72d481891d4934c8776b5eea04907d3">dest_eid_str</a>[<a class="code" href="dtn__types_8h.html#20ab5e3c8f53edfd21543ca9cb49d20e">DTN_MAX_ENDPOINT_ID</a>] = <span class="stringliteral">""</span>;
<a name="l00048"></a><a class="code" href="dtntraceroute_8c.html#418fa3d53d395e28ed37f9e304759dd0">00048</a> <span class="keywordtype">char</span> <a class="code" href="dtnping_8c.html#418fa3d53d395e28ed37f9e304759dd0">source_eid_str</a>[<a class="code" href="dtn__types_8h.html#20ab5e3c8f53edfd21543ca9cb49d20e">DTN_MAX_ENDPOINT_ID</a>] = <span class="stringliteral">""</span>;
<a name="l00049"></a><a class="code" href="dtntraceroute_8c.html#1e9a5877f9d311f896ab8ba5fc95532c">00049</a> <span class="keywordtype">char</span> <a class="code" href="dtnping_8c.html#1e9a5877f9d311f896ab8ba5fc95532c">replyto_eid_str</a>[<a class="code" href="dtn__types_8h.html#20ab5e3c8f53edfd21543ca9cb49d20e">DTN_MAX_ENDPOINT_ID</a>] = <span class="stringliteral">""</span>;
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 
<a name="l00052"></a>00052 <span class="keywordtype">int</span>
<a name="l00053"></a><a class="code" href="dtntraceroute_8c.html#217dbf8b442f20279ea00b898af96f52">00053</a> <a class="code" href="dtncat_8c.html#3c04138a5bfe5d72780bb7e82a18e627">main</a>(<span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>** argv)
<a name="l00054"></a>00054 {
<a name="l00055"></a>00055     <span class="keywordtype">int</span> ret;
<a name="l00056"></a>00056     <a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a>;
<a name="l00057"></a>00057     <a class="code" href="structdtn__endpoint__id__t.html" title="Specification of a dtn endpoint id, i.e.">dtn_endpoint_id_t</a> source_eid;
<a name="l00058"></a>00058     <a class="code" href="structdtn__endpoint__id__t.html" title="Specification of a dtn endpoint id, i.e.">dtn_endpoint_id_t</a> replyto_eid;
<a name="l00059"></a>00059     <a class="code" href="structdtn__reg__info__t.html" title="Registration state.">dtn_reg_info_t</a> reginfo;
<a name="l00060"></a>00060     <a class="code" href="dtn__types_8h.html#d9378ff6ab7ee699568e037a8105f9b6" title="A registration cookie.">dtn_reg_id_t</a> <a class="code" href="dtncat_8c.html#8eb0c3e35c1feb7baf9802f03bf42e41">regid</a>;
<a name="l00061"></a>00061     <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a> ping_spec;
<a name="l00062"></a>00062     <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a> <a class="code" href="dtncat_8c.html#cad3457d57f7286e1e4e7caa1a619e25">reply_spec</a>;
<a name="l00063"></a>00063     <a class="code" href="structdtn__bundle__payload__t.html">dtn_bundle_payload_t</a> ping_payload;
<a name="l00064"></a>00064     <a class="code" href="structping__payload__t.html">ping_payload_t</a> payload_contents;
<a name="l00065"></a>00065     <a class="code" href="structping__payload__t.html">ping_payload_t</a> recv_contents;
<a name="l00066"></a>00066     <a class="code" href="structdtn__bundle__payload__t.html">dtn_bundle_payload_t</a> <a class="code" href="dtncat_8c.html#f6ba744d4931e7c678cf04716560bfca">reply_payload</a>;
<a name="l00067"></a>00067     <a class="code" href="structdtn__bundle__status__report__t.html" title="Type definition for a bundle status report.">dtn_bundle_status_report_t</a>* sr_data;
<a name="l00068"></a>00068     <a class="code" href="structdtn__bundle__id__t.html" title="Type definition for a unique bundle identifier.">dtn_bundle_id_t</a> <a class="code" href="dtncat_8c.html#0d43174f8d3844aa5df38af2712ccb00">bundle_id</a>;
<a name="l00069"></a>00069     <span class="keywordtype">int</span> <a class="code" href="dtnmoteproxy_8c.html#ae6a9b084de32dbd181692c52c5e97de">debug</a> = 1;
<a name="l00070"></a>00070     <span class="keywordtype">char</span> demux[64];
<a name="l00071"></a>00071     <span class="keywordtype">int</span> dest_len = 0;
<a name="l00072"></a>00072     <span class="keyword">struct </span>timeval send_time, now;
<a name="l00073"></a>00073     u_int32_t nonce;
<a name="l00074"></a>00074     <span class="keywordtype">int</span> done;
<a name="l00075"></a>00075     time_t clock;
<a name="l00076"></a>00076     <span class="keyword">struct </span>tm* tm_buf;
<a name="l00077"></a>00077     
<a name="l00078"></a>00078     <span class="comment">// force stdout to always be line buffered, even if output is</span>
<a name="l00079"></a>00079     <span class="comment">// redirected to a pipe or file</span>
<a name="l00080"></a>00080     setvbuf(stdout, (<span class="keywordtype">char</span> *)NULL, _IOLBF, 0);
<a name="l00081"></a>00081     
<a name="l00082"></a>00082     <a class="code" href="dtnping_8c.html#5f259759586f432182213d868b41ebf2">doOptions</a>(argc, argv);
<a name="l00083"></a>00083 
<a name="l00084"></a>00084     memset(&amp;ping_spec, 0, <span class="keyword">sizeof</span>(ping_spec));
<a name="l00085"></a>00085 
<a name="l00086"></a>00086     <a class="code" href="namespacedtnsim.html#372b0bd474085f20b38efbbade7ce72a" title="Override gettimeofday to return the simulator time.">gettimeofday</a>(&amp;now, 0);
<a name="l00087"></a>00087     srand(now.tv_sec);
<a name="l00088"></a>00088     nonce = rand();
<a name="l00089"></a>00089     
<a name="l00090"></a>00090     <span class="comment">// open the ipc handle</span>
<a name="l00091"></a>00091     <span class="keywordtype">int</span> err = <a class="code" href="dtn__api_8c.html#3afc66b2e2c75fae07a45467df9f74e9" title="Open a new connection to the router.">dtn_open</a>(&amp;handle);
<a name="l00092"></a>00092     <span class="keywordflow">if</span> (err != <a class="code" href="dtn__errno_8h.html#3723251cb5d056b6ace3e22561da1e11" title="DTN API error codes.">DTN_SUCCESS</a>) {
<a name="l00093"></a>00093         fprintf(stderr, <span class="stringliteral">"fatal error opening dtn handle: %s\n"</span>,
<a name="l00094"></a>00094                 <a class="code" href="dtn__errno_8c.html#1b23d549407e59e3ce2a1c32e3885b1d" title="Get a string value associated with the dtn error code.">dtn_strerror</a>(err));
<a name="l00095"></a>00095         exit(1);
<a name="l00096"></a>00096     }
<a name="l00097"></a>00097 
<a name="l00098"></a>00098     <span class="comment">// make sure they supplied a valid destination eid or</span>
<a name="l00099"></a>00099     <span class="comment">// "localhost", in which case we just use the local daemon</span>
<a name="l00100"></a>00100     <span class="keywordflow">if</span> (strcmp(<a class="code" href="dtnping_8c.html#e72d481891d4934c8776b5eea04907d3">dest_eid_str</a>, <span class="stringliteral">"localhost"</span>) == 0) {
<a name="l00101"></a>00101         <a class="code" href="dtn__api_8c.html#0947b9119c69984edf25df43ead8858b" title="Build an appropriate local endpoint id by appending the specified service tag to...">dtn_build_local_eid</a>(handle, &amp;ping_spec.<a class="code" href="structdtn__bundle__spec__t.html#8c2816b3ce9b92489b3b34c325a4cb4c">dest</a>, <span class="stringliteral">"ping"</span>);
<a name="l00102"></a>00102         
<a name="l00103"></a>00103     } <span class="keywordflow">else</span> {
<a name="l00104"></a>00104         <span class="keywordflow">if</span> (<a class="code" href="dtn__api_8c.html#055c8bb8eaa570aacbe6a164ff123c84" title="Parse a string into an endpoint id structure, validating that it is in fact a valid...">dtn_parse_eid_string</a>(&amp;ping_spec.<a class="code" href="structdtn__bundle__spec__t.html#8c2816b3ce9b92489b3b34c325a4cb4c">dest</a>, <a class="code" href="dtnping_8c.html#e72d481891d4934c8776b5eea04907d3">dest_eid_str</a>)) {
<a name="l00105"></a>00105             fprintf(stderr, <span class="stringliteral">"invalid destination eid string '%s'\n"</span>,
<a name="l00106"></a>00106                     <a class="code" href="dtnping_8c.html#e72d481891d4934c8776b5eea04907d3">dest_eid_str</a>);
<a name="l00107"></a>00107             exit(1);
<a name="l00108"></a>00108         }
<a name="l00109"></a>00109     }
<a name="l00110"></a>00110 
<a name="l00111"></a>00111     dest_len = strlen(ping_spec.<a class="code" href="structdtn__bundle__spec__t.html#8c2816b3ce9b92489b3b34c325a4cb4c">dest</a>.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>);
<a name="l00112"></a>00112     <span class="keywordflow">if</span> ((dest_len &lt; 4) ||
<a name="l00113"></a>00113         (strcmp(ping_spec.<a class="code" href="structdtn__bundle__spec__t.html#8c2816b3ce9b92489b3b34c325a4cb4c">dest</a>.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a> + dest_len - 4, <span class="stringliteral">"ping"</span>) != 0))
<a name="l00114"></a>00114     {
<a name="l00115"></a>00115         fprintf(stderr, <span class="stringliteral">"\nWARNING: ping destination does not end in \"ping\"\n\n"</span>);
<a name="l00116"></a>00116     }
<a name="l00117"></a>00117     
<a name="l00118"></a>00118     <span class="comment">// if the user specified a source eid, register on it.</span>
<a name="l00119"></a>00119     <span class="comment">// otherwise, build a local eid based on the configuration of</span>
<a name="l00120"></a>00120     <span class="comment">// our dtn router plus the demux string</span>
<a name="l00121"></a>00121     snprintf(demux, <span class="keyword">sizeof</span>(demux), <span class="stringliteral">"/traceroute.%d"</span>, getpid());
<a name="l00122"></a>00122     <span class="keywordflow">if</span> (<a class="code" href="dtnping_8c.html#418fa3d53d395e28ed37f9e304759dd0">source_eid_str</a>[0] != <span class="charliteral">'\0'</span>) {
<a name="l00123"></a>00123         <span class="keywordflow">if</span> (<a class="code" href="dtn__api_8c.html#055c8bb8eaa570aacbe6a164ff123c84" title="Parse a string into an endpoint id structure, validating that it is in fact a valid...">dtn_parse_eid_string</a>(&amp;source_eid, <a class="code" href="dtnping_8c.html#418fa3d53d395e28ed37f9e304759dd0">source_eid_str</a>)) {
<a name="l00124"></a>00124             fprintf(stderr, <span class="stringliteral">"invalid source eid string '%s'\n"</span>,
<a name="l00125"></a>00125                     <a class="code" href="dtnping_8c.html#418fa3d53d395e28ed37f9e304759dd0">source_eid_str</a>);
<a name="l00126"></a>00126             exit(1);
<a name="l00127"></a>00127         }
<a name="l00128"></a>00128     } <span class="keywordflow">else</span> {
<a name="l00129"></a>00129         <a class="code" href="dtn__api_8c.html#0947b9119c69984edf25df43ead8858b" title="Build an appropriate local endpoint id by appending the specified service tag to...">dtn_build_local_eid</a>(handle, &amp;source_eid, demux);
<a name="l00130"></a>00130     }
<a name="l00131"></a>00131 
<a name="l00132"></a>00132     <span class="keywordflow">if</span> (debug) printf(<span class="stringliteral">"source_eid [%s]\n"</span>, source_eid.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>);
<a name="l00133"></a>00133     <a class="code" href="dtn__api_8c.html#b2935a9a7f4ade630f7d2ad1fec5c615" title="Copy the contents of one eid into another.">dtn_copy_eid</a>(&amp;ping_spec.<a class="code" href="structdtn__bundle__spec__t.html#3e0a3530457d11bea38b06d00dea30fa">source</a>, &amp;source_eid);
<a name="l00134"></a>00134     
<a name="l00135"></a>00135     <span class="comment">// Make the replyto EID</span>
<a name="l00136"></a>00136     <span class="keywordflow">if</span> ( <a class="code" href="dtnping_8c.html#1e9a5877f9d311f896ab8ba5fc95532c">replyto_eid_str</a>[0]!=0 ) {
<a name="l00137"></a>00137         <span class="keywordflow">if</span> (<a class="code" href="dtn__api_8c.html#055c8bb8eaa570aacbe6a164ff123c84" title="Parse a string into an endpoint id structure, validating that it is in fact a valid...">dtn_parse_eid_string</a>(&amp;replyto_eid, <a class="code" href="dtnping_8c.html#1e9a5877f9d311f896ab8ba5fc95532c">replyto_eid_str</a>)) {
<a name="l00138"></a>00138             fprintf(stderr, <span class="stringliteral">"invalid replyto eid string '%s'\n"</span>,
<a name="l00139"></a>00139                     <a class="code" href="dtnping_8c.html#1e9a5877f9d311f896ab8ba5fc95532c">replyto_eid_str</a>);
<a name="l00140"></a>00140             exit(1);
<a name="l00141"></a>00141         }
<a name="l00142"></a>00142         <a class="code" href="dtn__api_8c.html#b2935a9a7f4ade630f7d2ad1fec5c615" title="Copy the contents of one eid into another.">dtn_copy_eid</a>(&amp;ping_spec.<a class="code" href="structdtn__bundle__spec__t.html#f76b43d28b76b155d48df0abe82c6913">replyto</a>, &amp;replyto_eid);
<a name="l00143"></a>00143         printf(<span class="stringliteral">"using user-supplied replyto\n"</span>);
<a name="l00144"></a>00144     } <span class="keywordflow">else</span> {
<a name="l00145"></a>00145         <a class="code" href="dtn__api_8c.html#b2935a9a7f4ade630f7d2ad1fec5c615" title="Copy the contents of one eid into another.">dtn_copy_eid</a>(&amp;ping_spec.<a class="code" href="structdtn__bundle__spec__t.html#f76b43d28b76b155d48df0abe82c6913">replyto</a>, &amp;source_eid);
<a name="l00146"></a>00146         printf(<span class="stringliteral">"using default replyto\n"</span>);
<a name="l00147"></a>00147     }
<a name="l00148"></a>00148 
<a name="l00149"></a>00149     <span class="comment">// now create a new registration based on the source</span>
<a name="l00150"></a>00150     <span class="comment">// if the replyto EID is unspecified or the same as the</span>
<a name="l00151"></a>00151     <span class="comment">// source EID then we'll get status reports, otherwise</span>
<a name="l00152"></a>00152     <span class="comment">// they'll go somewhere else.</span>
<a name="l00153"></a>00153     memset(&amp;reginfo, 0, <span class="keyword">sizeof</span>(reginfo));
<a name="l00154"></a>00154     <a class="code" href="dtn__api_8c.html#b2935a9a7f4ade630f7d2ad1fec5c615" title="Copy the contents of one eid into another.">dtn_copy_eid</a>(&amp;reginfo.<a class="code" href="structdtn__reg__info__t.html#07df1822e2808b2127710a8b54acd07f">endpoint</a>, &amp;source_eid);
<a name="l00155"></a>00155     reginfo.<a class="code" href="structdtn__reg__info__t.html#7bf2e33b713b585bfe1792c40fa8cd6c">flags</a> = <a class="code" href="dtn__types_8h.html#a6d0071f396dd4ef85f6ad6332e37f0067a5f773775540e3dbe22a87105d571e">DTN_REG_DROP</a>;
<a name="l00156"></a>00156     reginfo.<a class="code" href="structdtn__reg__info__t.html#6909a69cc63e748899cf4f9fe8c8901a">regid</a> = <a class="code" href="dtn__types_8h.html#f96cd9cebfff24e37ccececf05ebb4e6" title="Value for an unspecified registration cookie (i.e.">DTN_REGID_NONE</a>;
<a name="l00157"></a>00157     reginfo.<a class="code" href="structdtn__reg__info__t.html#dd4b3b0c9f27a0375369f35e33be686d">expiration</a> = 0;
<a name="l00158"></a>00158     <span class="keywordflow">if</span> ((ret = <a class="code" href="dtn__api_8c.html#7384bf592d4aff0892ff948aafa98b0c" title="Create a dtn registration.">dtn_register</a>(handle, &amp;reginfo, &amp;regid)) != 0) {
<a name="l00159"></a>00159         fprintf(stderr, <span class="stringliteral">"error creating registration: %d (%s)\n"</span>,
<a name="l00160"></a>00160                 ret, <a class="code" href="dtn__errno_8c.html#1b23d549407e59e3ce2a1c32e3885b1d" title="Get a string value associated with the dtn error code.">dtn_strerror</a>(<a class="code" href="dtn__api_8c.html#6183d81d5f742d13e1fdee26423d94b4" title="Get the error associated with the given handle.">dtn_errno</a>(handle)));
<a name="l00161"></a>00161         exit(1);
<a name="l00162"></a>00162     }    
<a name="l00163"></a>00163     <span class="keywordflow">if</span> (debug) printf(<span class="stringliteral">"dtn_register succeeded, regid %d\n"</span>, regid);
<a name="l00164"></a>00164 
<a name="l00165"></a>00165     <span class="comment">// set the expiration time and request a bunch of status reports</span>
<a name="l00166"></a>00166     ping_spec.<a class="code" href="structdtn__bundle__spec__t.html#57f2d6068db6a5b38a73416ea721e814">expiration</a> = <a class="code" href="dtncat_8c.html#d6057e40387509de502bdc91007d3238">expiration</a>;
<a name="l00167"></a>00167     ping_spec.<a class="code" href="structdtn__bundle__spec__t.html#476482803410f3a19b40cbff91e1e56c">dopts</a> = <a class="code" href="dtn__types_8h.html#ed7af5cc4e44a2ced1acdee4e441f000649fe8cc9d73bd2d36f2da1f322fa0c2">DOPTS_DELETE_RCPT</a> |
<a name="l00168"></a>00168                       <a class="code" href="dtn__types_8h.html#ed7af5cc4e44a2ced1acdee4e441f0001240065bb26608579eedd4b022f3397f">DOPTS_RECEIVE_RCPT</a> |
<a name="l00169"></a>00169                       <a class="code" href="dtn__types_8h.html#ed7af5cc4e44a2ced1acdee4e441f000f1140b2789c648d104e6ec8a78bc3cea">DOPTS_FORWARD_RCPT</a> |
<a name="l00170"></a>00170                       <a class="code" href="dtn__types_8h.html#ed7af5cc4e44a2ced1acdee4e441f000961c42551cde98aaccb2272d32f0a06c">DOPTS_DELIVERY_RCPT</a>;
<a name="l00171"></a>00171 
<a name="l00172"></a>00172     <span class="comment">// loop, sending pings and polling for activity</span>
<a name="l00173"></a>00173     <a class="code" href="namespacedtnsim.html#372b0bd474085f20b38efbbade7ce72a" title="Override gettimeofday to return the simulator time.">gettimeofday</a>(&amp;send_time, NULL);
<a name="l00174"></a>00174         
<a name="l00175"></a>00175     <span class="comment">// fill in a short payload string, a nonce, and a sequence number</span>
<a name="l00176"></a>00176     <span class="comment">// to verify the echo feature and make sure we're not getting</span>
<a name="l00177"></a>00177     <span class="comment">// duplicate responses or ping responses from another app</span>
<a name="l00178"></a>00178     memcpy(&amp;payload_contents.<a class="code" href="structping__payload__t.html#01708f48283edfb7285207b4ccdcf04c">ping</a>, <a class="code" href="dtnping_8h.html#c582fb27a00ea192e5ce1f4dfe2065cc">PING_STR</a>, 8);
<a name="l00179"></a>00179     payload_contents.<a class="code" href="structping__payload__t.html#1594108b720b35699d578ccf56853899">seqno</a> = 0;
<a name="l00180"></a>00180     payload_contents.<a class="code" href="structping__payload__t.html#f5279ac20bc140a9736f5147cedda22a">nonce</a> = nonce;
<a name="l00181"></a>00181     payload_contents.<a class="code" href="structping__payload__t.html#0714fbcdb878430e858ca1f04b42c737">time</a>  = send_time.tv_sec;
<a name="l00182"></a>00182         
<a name="l00183"></a>00183     memset(&amp;ping_payload, 0, <span class="keyword">sizeof</span>(ping_payload));
<a name="l00184"></a>00184     <a class="code" href="dtn__api_8c.html#21b6d705673aae970524972aca3db99f" title="Sets the value of the given payload structure to either a memory buffer or a file...">dtn_set_payload</a>(&amp;ping_payload, <a class="code" href="dtn__types_8h.html#3dcfddc1b850a71a18d8a0868f67e7628f773bbfb80857bd5a11f09665fa9b03">DTN_PAYLOAD_MEM</a>,
<a name="l00185"></a>00185                     (<span class="keywordtype">char</span>*)&amp;payload_contents, <span class="keyword">sizeof</span>(payload_contents));
<a name="l00186"></a>00186         
<a name="l00187"></a>00187     memset(&amp;bundle_id, 0, <span class="keyword">sizeof</span>(bundle_id));
<a name="l00188"></a>00188     <span class="keywordflow">if</span> ((ret = <a class="code" href="dtn__api_8c.html#9bcce797cfff268e49c0f5b2e5f21788" title="Send a bundle either from memory or from a file.">dtn_send</a>(handle, regid, &amp;ping_spec, &amp;ping_payload, &amp;bundle_id)) != 0) {
<a name="l00189"></a>00189         fprintf(stderr, <span class="stringliteral">"error sending bundle: %d (%s)\n"</span>,
<a name="l00190"></a>00190                 ret, <a class="code" href="dtn__errno_8c.html#1b23d549407e59e3ce2a1c32e3885b1d" title="Get a string value associated with the dtn error code.">dtn_strerror</a>(<a class="code" href="dtn__api_8c.html#6183d81d5f742d13e1fdee26423d94b4" title="Get the error associated with the given handle.">dtn_errno</a>(handle)));
<a name="l00191"></a>00191         exit(1);
<a name="l00192"></a>00192     }
<a name="l00193"></a>00193         
<a name="l00194"></a>00194     memset(&amp;reply_spec, 0, <span class="keyword">sizeof</span>(reply_spec));
<a name="l00195"></a>00195     memset(&amp;reply_payload, 0, <span class="keyword">sizeof</span>(reply_payload));
<a name="l00196"></a>00196 
<a name="l00197"></a>00197     clock = time(&amp;clock);
<a name="l00198"></a>00198     tm_buf = gmtime(&amp;clock);
<a name="l00199"></a>00199     printf(<span class="stringliteral">"%s: sent at %.*s UTC\n"</span>,
<a name="l00200"></a>00200            ping_spec.<a class="code" href="structdtn__bundle__spec__t.html#3e0a3530457d11bea38b06d00dea30fa">source</a>.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>, 24, asctime(tm_buf));
<a name="l00201"></a>00201     
<a name="l00202"></a>00202     <span class="comment">// now loop waiting for replies / status reports until we're done</span>
<a name="l00203"></a>00203     done = 0;
<a name="l00204"></a>00204     <span class="keywordflow">while</span> (1) {
<a name="l00205"></a>00205         <span class="keywordtype">int</span> timeout = done ? <a class="code" href="dtnreporter_8c.html#382355580ada4027bb3d418c025c5a0d">wait_after_done</a> * 1000 : -1;
<a name="l00206"></a>00206         <span class="keywordflow">if</span> ((ret = <a class="code" href="dtn__api_8c.html#7005346bb34aabb5b6332690871fe3f4" title="Blocking receive for a bundle, filling in the spec and payload structures with the...">dtn_recv</a>(handle, &amp;reply_spec,
<a name="l00207"></a>00207                             <a class="code" href="dtn__types_8h.html#3dcfddc1b850a71a18d8a0868f67e7628f773bbfb80857bd5a11f09665fa9b03">DTN_PAYLOAD_MEM</a>, &amp;reply_payload, timeout)) &lt; 0)
<a name="l00208"></a>00208         {
<a name="l00209"></a>00209             <span class="keywordflow">if</span> (done &amp;&amp; <a class="code" href="dtn__api_8c.html#6183d81d5f742d13e1fdee26423d94b4" title="Get the error associated with the given handle.">dtn_errno</a>(handle) == <a class="code" href="dtn__errno_8h.html#35b24187121ca003154518bba0a35e75">DTN_ETIMEOUT</a>) {
<a name="l00210"></a>00210                 <span class="keywordflow">break</span>;
<a name="l00211"></a>00211             }
<a name="l00212"></a>00212             fprintf(stderr, <span class="stringliteral">"error getting ping reply: %d (%s)\n"</span>,
<a name="l00213"></a>00213                     ret, <a class="code" href="dtn__errno_8c.html#1b23d549407e59e3ce2a1c32e3885b1d" title="Get a string value associated with the dtn error code.">dtn_strerror</a>(<a class="code" href="dtn__api_8c.html#6183d81d5f742d13e1fdee26423d94b4" title="Get the error associated with the given handle.">dtn_errno</a>(handle)));
<a name="l00214"></a>00214             exit(1);
<a name="l00215"></a>00215         }
<a name="l00216"></a>00216 
<a name="l00217"></a>00217         <a class="code" href="namespacedtnsim.html#372b0bd474085f20b38efbbade7ce72a" title="Override gettimeofday to return the simulator time.">gettimeofday</a>(&amp;now, 0);
<a name="l00218"></a>00218             
<a name="l00219"></a>00219         <span class="keywordflow">if</span> (reply_payload.<a class="code" href="structdtn__bundle__payload__t.html#2f104cdd7e463ca104b468fa98527f84">status_report</a> != NULL)
<a name="l00220"></a>00220         {
<a name="l00221"></a>00221             sr_data = reply_payload.<a class="code" href="structdtn__bundle__payload__t.html#2f104cdd7e463ca104b468fa98527f84">status_report</a>;
<a name="l00222"></a>00222             <span class="keywordflow">if</span> (sr_data-&gt;<a class="code" href="structdtn__bundle__status__report__t.html#106f245fab47da2abee3d5b0fb413315">flags</a> &amp; <a class="code" href="dtn__types_8h.html#6d9484ac5d0ab5f3fd7383af0c7b99198d50a4d6db1ab5232afc0d5cd55deb93">STATUS_RECEIVED</a>)
<a name="l00223"></a>00223             {
<a name="l00224"></a>00224                 clock = sr_data-&gt;<a class="code" href="structdtn__bundle__status__report__t.html#5acf2262f0099eb9f5be29921a5a94dd">receipt_ts</a>.<a class="code" href="structdtn__timestamp__t.html#68d91d87e4f7e4d1c17b68338331609b">secs</a> + <a class="code" href="dtnping_8h.html#d2bce832ca7276f1f2eeba215e2a4132">DTNTIME_OFFSET</a>;
<a name="l00225"></a>00225                 tm_buf = gmtime(&amp;clock);
<a name="l00226"></a>00226                 printf(<span class="stringliteral">"%s: received at %.*s UTC (%ld ms rtt)\n"</span>,
<a name="l00227"></a>00227                        reply_spec.<a class="code" href="structdtn__bundle__spec__t.html#3e0a3530457d11bea38b06d00dea30fa">source</a>.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>, 24, asctime(tm_buf),
<a name="l00228"></a>00228                        <a class="code" href="dtnping_8h.html#78237999c2659b5d28c1a90a2123607f">TIMEVAL_DIFF_MSEC</a>(now, send_time));
<a name="l00229"></a>00229             }
<a name="l00230"></a>00230             <span class="keywordflow">if</span> (sr_data-&gt;<a class="code" href="structdtn__bundle__status__report__t.html#106f245fab47da2abee3d5b0fb413315">flags</a> &amp; <a class="code" href="dtn__types_8h.html#6d9484ac5d0ab5f3fd7383af0c7b991925211f0e0706cbc8981285126ac621b2">STATUS_FORWARDED</a>)
<a name="l00231"></a>00231             {
<a name="l00232"></a>00232                 clock = sr_data-&gt;<a class="code" href="structdtn__bundle__status__report__t.html#d951191b5dc254cf1a5e7beaf53f1b08">forwarding_ts</a>.<a class="code" href="structdtn__timestamp__t.html#68d91d87e4f7e4d1c17b68338331609b">secs</a> + <a class="code" href="dtnping_8h.html#d2bce832ca7276f1f2eeba215e2a4132">DTNTIME_OFFSET</a>;
<a name="l00233"></a>00233                 tm_buf = gmtime(&amp;clock);
<a name="l00234"></a>00234                 printf(<span class="stringliteral">"%s: forwarded at %.*s UTC (%ld ms rtt)\n"</span>,
<a name="l00235"></a>00235                        reply_spec.<a class="code" href="structdtn__bundle__spec__t.html#3e0a3530457d11bea38b06d00dea30fa">source</a>.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>, 24, asctime(tm_buf),
<a name="l00236"></a>00236                        <a class="code" href="dtnping_8h.html#78237999c2659b5d28c1a90a2123607f">TIMEVAL_DIFF_MSEC</a>(now, send_time));
<a name="l00237"></a>00237             }
<a name="l00238"></a>00238             <span class="keywordflow">if</span> (sr_data-&gt;<a class="code" href="structdtn__bundle__status__report__t.html#106f245fab47da2abee3d5b0fb413315">flags</a> &amp; <a class="code" href="dtn__types_8h.html#6d9484ac5d0ab5f3fd7383af0c7b9919c0ac4c503dd8586dca17b9d5c1e9f30d">STATUS_DELIVERED</a>)
<a name="l00239"></a>00239             {
<a name="l00240"></a>00240                 clock = sr_data-&gt;<a class="code" href="structdtn__bundle__status__report__t.html#25d8c3507f8643f0b8be0e3aba50da31">delivery_ts</a>.<a class="code" href="structdtn__timestamp__t.html#68d91d87e4f7e4d1c17b68338331609b">secs</a> + <a class="code" href="dtnping_8h.html#d2bce832ca7276f1f2eeba215e2a4132">DTNTIME_OFFSET</a>;
<a name="l00241"></a>00241                 tm_buf = gmtime(&amp;clock);
<a name="l00242"></a>00242                 printf(<span class="stringliteral">"%s: delivered at %.*s UTC (%ld ms rtt)\n"</span>,
<a name="l00243"></a>00243                        reply_spec.<a class="code" href="structdtn__bundle__spec__t.html#3e0a3530457d11bea38b06d00dea30fa">source</a>.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>, 24, asctime(tm_buf),
<a name="l00244"></a>00244                        <a class="code" href="dtnping_8h.html#78237999c2659b5d28c1a90a2123607f">TIMEVAL_DIFF_MSEC</a>(now, send_time));
<a name="l00245"></a>00245             }
<a name="l00246"></a>00246             <span class="keywordflow">if</span> (sr_data-&gt;<a class="code" href="structdtn__bundle__status__report__t.html#106f245fab47da2abee3d5b0fb413315">flags</a> &amp; <a class="code" href="dtn__types_8h.html#6d9484ac5d0ab5f3fd7383af0c7b99193f1e22c771850e7a7cdfafbda38cc14e">STATUS_DELETED</a>)
<a name="l00247"></a>00247             {
<a name="l00248"></a>00248                 clock = sr_data-&gt;<a class="code" href="structdtn__bundle__status__report__t.html#391eb127c1b32e0fa25a14840b2155b0">deletion_ts</a>.<a class="code" href="structdtn__timestamp__t.html#68d91d87e4f7e4d1c17b68338331609b">secs</a> + <a class="code" href="dtnping_8h.html#d2bce832ca7276f1f2eeba215e2a4132">DTNTIME_OFFSET</a>;
<a name="l00249"></a>00249                 tm_buf = gmtime(&amp;clock);
<a name="l00250"></a>00250                 printf(<span class="stringliteral">"%s: deleted at %.*s UTC (%s) (%ld ms rtt)\n"</span>,
<a name="l00251"></a>00251                        reply_spec.<a class="code" href="structdtn__bundle__spec__t.html#3e0a3530457d11bea38b06d00dea30fa">source</a>.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>, 24, asctime(tm_buf),
<a name="l00252"></a>00252                        <a class="code" href="dtn__api_8c.html#8bb5dd6e64e8cfaaa4b80e1373785cc2" title="Return a string version of a status report reason code.">dtn_status_report_reason_to_str</a>(sr_data-&gt;<a class="code" href="structdtn__bundle__status__report__t.html#3de5598dc702b9375ed43c4f7335cf39">reason</a>),
<a name="l00253"></a>00253                        <a class="code" href="dtnping_8h.html#78237999c2659b5d28c1a90a2123607f">TIMEVAL_DIFF_MSEC</a>(now, send_time));
<a name="l00254"></a>00254                 <span class="keywordflow">break</span>;
<a name="l00255"></a>00255             }
<a name="l00256"></a>00256         }
<a name="l00257"></a>00257         <span class="keywordflow">else</span> {
<a name="l00258"></a>00258             <span class="keywordflow">if</span> (reply_payload.<a class="code" href="structdtn__bundle__payload__t.html#04e8c46c5b40f187e1fefed80853cc5c">buf</a>.<a class="code" href="structdtn__bundle__payload__t.html#c20a1cf6010dbd5855140373da5ce8c3">buf_len</a> != <span class="keyword">sizeof</span>(<a class="code" href="structping__payload__t.html">ping_payload_t</a>))
<a name="l00259"></a>00259             {
<a name="l00260"></a>00260                 printf(<span class="stringliteral">"%d bytes from [%s]: ERROR: length != %zu\n"</span>,
<a name="l00261"></a>00261                        reply_payload.<a class="code" href="structdtn__bundle__payload__t.html#04e8c46c5b40f187e1fefed80853cc5c">buf</a>.<a class="code" href="structdtn__bundle__payload__t.html#c20a1cf6010dbd5855140373da5ce8c3">buf_len</a>,
<a name="l00262"></a>00262                        reply_spec.<a class="code" href="structdtn__bundle__spec__t.html#3e0a3530457d11bea38b06d00dea30fa">source</a>.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>,
<a name="l00263"></a>00263                        <span class="keyword">sizeof</span>(<a class="code" href="structping__payload__t.html">ping_payload_t</a>));
<a name="l00264"></a>00264                 <span class="keywordflow">break</span>;
<a name="l00265"></a>00265             }
<a name="l00266"></a>00266 
<a name="l00267"></a>00267             memcpy(&amp;recv_contents, reply_payload.<a class="code" href="structdtn__bundle__payload__t.html#04e8c46c5b40f187e1fefed80853cc5c">buf</a>.<a class="code" href="structdtn__bundle__payload__t.html#45cd21fd96fced99995450f0fca848d5">buf_val</a>,
<a name="l00268"></a>00268                    <span class="keyword">sizeof</span>(recv_contents));
<a name="l00269"></a>00269                 
<a name="l00270"></a>00270             <span class="keywordflow">if</span> (recv_contents.<a class="code" href="structping__payload__t.html#1594108b720b35699d578ccf56853899">seqno</a> != 0)
<a name="l00271"></a>00271             {
<a name="l00272"></a>00272                 printf(<span class="stringliteral">"%d bytes from [%s]: ERROR: invalid seqno %d\n"</span>,
<a name="l00273"></a>00273                        reply_payload.<a class="code" href="structdtn__bundle__payload__t.html#04e8c46c5b40f187e1fefed80853cc5c">buf</a>.<a class="code" href="structdtn__bundle__payload__t.html#c20a1cf6010dbd5855140373da5ce8c3">buf_len</a>,
<a name="l00274"></a>00274                        reply_spec.<a class="code" href="structdtn__bundle__spec__t.html#3e0a3530457d11bea38b06d00dea30fa">source</a>.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>,
<a name="l00275"></a>00275                        recv_contents.<a class="code" href="structping__payload__t.html#1594108b720b35699d578ccf56853899">seqno</a>);
<a name="l00276"></a>00276                 <span class="keywordflow">break</span>;
<a name="l00277"></a>00277             }
<a name="l00278"></a>00278 
<a name="l00279"></a>00279             <span class="keywordflow">if</span> (recv_contents.<a class="code" href="structping__payload__t.html#f5279ac20bc140a9736f5147cedda22a">nonce</a> != nonce)
<a name="l00280"></a>00280             {
<a name="l00281"></a>00281                 printf(<span class="stringliteral">"%d bytes from [%s]: ERROR: invalid nonce %u != %u\n"</span>,
<a name="l00282"></a>00282                        reply_payload.<a class="code" href="structdtn__bundle__payload__t.html#04e8c46c5b40f187e1fefed80853cc5c">buf</a>.<a class="code" href="structdtn__bundle__payload__t.html#c20a1cf6010dbd5855140373da5ce8c3">buf_len</a>,
<a name="l00283"></a>00283                        reply_spec.<a class="code" href="structdtn__bundle__spec__t.html#3e0a3530457d11bea38b06d00dea30fa">source</a>.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>,
<a name="l00284"></a>00284                        recv_contents.<a class="code" href="structping__payload__t.html#f5279ac20bc140a9736f5147cedda22a">nonce</a>, nonce);
<a name="l00285"></a>00285                 <span class="keywordflow">break</span>;
<a name="l00286"></a>00286             }
<a name="l00287"></a>00287 
<a name="l00288"></a>00288             <span class="keywordflow">if</span> ((<span class="keywordtype">int</span>)recv_contents.<a class="code" href="structping__payload__t.html#0714fbcdb878430e858ca1f04b42c737">time</a> != (<span class="keywordtype">int</span>)send_time.tv_sec)
<a name="l00289"></a>00289             {
<a name="l00290"></a>00290                 printf(<span class="stringliteral">"%d bytes from [%s]: ERROR: time mismatch %u != %lu\n"</span>,
<a name="l00291"></a>00291                        reply_payload.<a class="code" href="structdtn__bundle__payload__t.html#04e8c46c5b40f187e1fefed80853cc5c">buf</a>.<a class="code" href="structdtn__bundle__payload__t.html#c20a1cf6010dbd5855140373da5ce8c3">buf_len</a>,
<a name="l00292"></a>00292                        reply_spec.<a class="code" href="structdtn__bundle__spec__t.html#3e0a3530457d11bea38b06d00dea30fa">source</a>.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>,
<a name="l00293"></a>00293                        recv_contents.<a class="code" href="structping__payload__t.html#0714fbcdb878430e858ca1f04b42c737">time</a>,
<a name="l00294"></a>00294                        (<span class="keywordtype">long</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)send_time.tv_sec);
<a name="l00295"></a>00295             }
<a name="l00296"></a>00296                 
<a name="l00297"></a>00297             clock = reply_spec.<a class="code" href="structdtn__bundle__spec__t.html#5289539985d68cbbac8ff80d18b0170e">creation_ts</a>.<a class="code" href="structdtn__timestamp__t.html#68d91d87e4f7e4d1c17b68338331609b">secs</a> + <a class="code" href="dtnping_8h.html#d2bce832ca7276f1f2eeba215e2a4132">DTNTIME_OFFSET</a>;
<a name="l00298"></a>00298             tm_buf = gmtime(&amp;clock);
<a name="l00299"></a>00299             printf(<span class="stringliteral">"%s: echo reply at %.*s UTC (%ld ms rtt)\n"</span>,
<a name="l00300"></a>00300                    reply_spec.<a class="code" href="structdtn__bundle__spec__t.html#3e0a3530457d11bea38b06d00dea30fa">source</a>.<a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>, 24, asctime(tm_buf),
<a name="l00301"></a>00301                    <a class="code" href="dtnping_8h.html#78237999c2659b5d28c1a90a2123607f">TIMEVAL_DIFF_MSEC</a>(now, send_time));
<a name="l00302"></a>00302             done = 1;
<a name="l00303"></a>00303         }
<a name="l00304"></a>00304         
<a name="l00305"></a>00305         <a class="code" href="dtn__api_8c.html#50a363bf1bf2803892afc1438ab62cff" title="Frees dynamic storage allocated by the xdr for a bundle payload in dtn_recv.">dtn_free_payload</a>(&amp;reply_payload);
<a name="l00306"></a>00306     }
<a name="l00307"></a>00307     
<a name="l00308"></a>00308     <a class="code" href="dtn__api_8c.html#887c16260463d6057bf5b03a1ff0e224" title="Close an open dtn handle.">dtn_close</a>(handle);
<a name="l00309"></a>00309     
<a name="l00310"></a>00310     <span class="keywordflow">return</span> 0;
<a name="l00311"></a>00311 }
<a name="l00312"></a>00312 
<a name="l00313"></a>00313 <span class="keywordtype">void</span>
<a name="l00314"></a>00314 <a class="code" href="dtnping_8c.html#5f259759586f432182213d868b41ebf2">doOptions</a>(<span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span> **argv)
<a name="l00315"></a>00315 {
<a name="l00316"></a>00316     <span class="keywordtype">int</span> c;
<a name="l00317"></a>00317 
<a name="l00318"></a>00318     <a class="code" href="dtncat_8c.html#b9e1449fd00c98428516f0b41eddcb10">progname</a> = argv[0];
<a name="l00319"></a>00319 
<a name="l00320"></a>00320     <span class="keywordflow">while</span> ( (c=getopt(argc, (<span class="keywordtype">char</span> **) argv, <span class="stringliteral">"he:d:s:r:w:"</span>)) !=EOF ) {
<a name="l00321"></a>00321         <span class="keywordflow">switch</span> (c) {
<a name="l00322"></a>00322         <span class="keywordflow">case</span> <span class="charliteral">'e'</span>:
<a name="l00323"></a>00323             <a class="code" href="dtncat_8c.html#d6057e40387509de502bdc91007d3238">expiration</a> = atoi(optarg);
<a name="l00324"></a>00324             <span class="keywordflow">break</span>;
<a name="l00325"></a>00325         <span class="keywordflow">case</span> <span class="charliteral">'r'</span>:
<a name="l00326"></a>00326             strcpy(<a class="code" href="dtnping_8c.html#1e9a5877f9d311f896ab8ba5fc95532c">replyto_eid_str</a>, optarg);
<a name="l00327"></a>00327             printf(<span class="stringliteral">"Setting replyto_eid_str to: %s\n"</span>, <a class="code" href="dtnping_8c.html#1e9a5877f9d311f896ab8ba5fc95532c">replyto_eid_str</a>);
<a name="l00328"></a>00328             <span class="keywordflow">break</span>;
<a name="l00329"></a>00329         <span class="keywordflow">case</span> <span class="charliteral">'d'</span>:
<a name="l00330"></a>00330             strcpy(<a class="code" href="dtnping_8c.html#e72d481891d4934c8776b5eea04907d3">dest_eid_str</a>, optarg);
<a name="l00331"></a>00331             <span class="keywordflow">break</span>;
<a name="l00332"></a>00332         <span class="keywordflow">case</span> <span class="charliteral">'s'</span>:
<a name="l00333"></a>00333             strcpy(<a class="code" href="dtnping_8c.html#418fa3d53d395e28ed37f9e304759dd0">source_eid_str</a>, optarg);
<a name="l00334"></a>00334             <span class="keywordflow">break</span>;
<a name="l00335"></a>00335         <span class="keywordflow">case</span> <span class="charliteral">'h'</span>:
<a name="l00336"></a>00336             <a class="code" href="dtncpd_8c.html#2ef30c42cbc289d899a8be5d2d8f77d0">usage</a>();
<a name="l00337"></a>00337             <span class="keywordflow">break</span>;
<a name="l00338"></a>00338         <span class="keywordflow">case</span> <span class="charliteral">'w'</span>:
<a name="l00339"></a>00339             <a class="code" href="dtnreporter_8c.html#382355580ada4027bb3d418c025c5a0d">wait_after_done</a> = atoi(optarg);
<a name="l00340"></a>00340             <span class="keywordflow">break</span>;
<a name="l00341"></a>00341         <span class="keywordflow">default</span>:
<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 
<a name="l00346"></a>00346     <span class="keywordflow">if</span> ((optind &lt; argc) &amp;&amp; (strlen(<a class="code" href="dtnping_8c.html#e72d481891d4934c8776b5eea04907d3">dest_eid_str</a>) == 0)) {
<a name="l00347"></a>00347         strcpy(<a class="code" href="dtnping_8c.html#e72d481891d4934c8776b5eea04907d3">dest_eid_str</a>, argv[optind++]);
<a name="l00348"></a>00348     }
<a name="l00349"></a>00349 
<a name="l00350"></a>00350     <span class="keywordflow">if</span> (optind &lt; argc) {
<a name="l00351"></a>00351         fprintf(stderr, <span class="stringliteral">"unsupported argument '%s'\n"</span>, argv[optind]);
<a name="l00352"></a>00352         exit(1);
<a name="l00353"></a>00353     }
<a name="l00354"></a>00354 
<a name="l00355"></a>00355     <span class="keywordflow">if</span> (<a class="code" href="dtnping_8c.html#e72d481891d4934c8776b5eea04907d3">dest_eid_str</a>[0] == <span class="charliteral">'\0'</span>) {
<a name="l00356"></a>00356         fprintf(stderr, <span class="stringliteral">"must supply a destination eid (or 'localhost')\n"</span>);
<a name="l00357"></a>00357         exit(1);
<a name="l00358"></a>00358     }
<a name="l00359"></a>00359 }
<a name="l00360"></a>00360 
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:56 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>