<!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: dtn_api.c Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.6 --> <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> <h1>dtn_api.c</h1><a href="dtn__api_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 <<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 <errno.h></span> <a name="l00022"></a>00022 <span class="preprocessor">#include <stdio.h></span> <a name="l00023"></a>00023 <span class="preprocessor">#include <stdlib.h></span> <a name="l00024"></a>00024 <span class="preprocessor">#include <fcntl.h></span> <a name="l00025"></a>00025 <span class="preprocessor">#include <string.h></span> <a name="l00026"></a>00026 <span class="preprocessor">#include <limits.h></span> <a name="l00027"></a>00027 <span class="preprocessor">#include <sys/types.h></span> <a name="l00028"></a>00028 <span class="preprocessor">#include <sys/socket.h></span> <a name="l00029"></a>00029 <span class="preprocessor">#include <sys/stat.h></span> <a name="l00030"></a>00030 <span class="preprocessor">#include <netinet/in.h></span> <a name="l00031"></a>00031 <span class="preprocessor">#include <stdlib.h></span> <a name="l00032"></a>00032 <span class="preprocessor">#include <unistd.h></span> <a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="dtn__api_8h.html">dtn_api.h</a>"</span> <a name="l00035"></a>00035 <span class="preprocessor">#include "<a class="code" href="dtn__ipc_8h.html">dtn_ipc.h</a>"</span> <a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00038"></a>00038 <span class="keywordtype">int</span> <a name="l00039"></a><a class="code" href="dtn__api_8h.html#468806988bcbe04038d7d201181d0cc3">00039</a> <a class="code" href="dtn__api_8c.html#3afc66b2e2c75fae07a45467df9f74e9" title="Open a new connection to the router.">dtn_open</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a>* h) <a name="l00040"></a>00040 { <a name="l00041"></a>00041 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a>; <a name="l00042"></a>00042 <a name="l00043"></a>00043 handle = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a> *) malloc(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle</a>)); <a name="l00044"></a>00044 <span class="keywordflow">if</span> (!handle) { <a name="l00045"></a>00045 *h = NULL; <a name="l00046"></a>00046 <span class="keywordflow">return</span> <a class="code" href="dtn__errno_8h.html#951a074861ce082706b57c300413042b">DTN_EINTERNAL</a>; <a name="l00047"></a>00047 } <a name="l00048"></a>00048 <a name="l00049"></a>00049 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#0a70871adbaca23a535c898f854be3a8">dtnipc_open</a>(handle) != 0) { <a name="l00050"></a>00050 <span class="keywordtype">int</span> ret = handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a>; <a name="l00051"></a>00051 free(handle); <a name="l00052"></a>00052 *h = NULL; <a name="l00053"></a>00053 <span class="keywordflow">return</span> ret; <a name="l00054"></a>00054 } <a name="l00055"></a>00055 <a name="l00056"></a>00056 xdr_setpos(&handle-><a class="code" href="structdtnipc__handle.html#ded5c2335049e780a4ee8ab2b2356f95" title="XDR encoder.">xdr_encode</a>, 0); <a name="l00057"></a>00057 xdr_setpos(&handle-><a class="code" href="structdtnipc__handle.html#c09f26354224257a07c51d45f92725fd" title="XDR decoder.">xdr_decode</a>, 0); <a name="l00058"></a>00058 <a name="l00059"></a>00059 *h = (<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a>)handle; <a name="l00060"></a>00060 <span class="keywordflow">return</span> <a class="code" href="dtn__errno_8h.html#3723251cb5d056b6ace3e22561da1e11" title="DTN API error codes.">DTN_SUCCESS</a>; <a name="l00061"></a>00061 } <a name="l00062"></a>00062 <a name="l00063"></a>00063 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00064"></a>00064 <span class="keywordtype">int</span> <a name="l00065"></a><a class="code" href="dtn__api_8h.html#887c16260463d6057bf5b03a1ff0e224">00065</a> <a class="code" href="dtn__api_8c.html#887c16260463d6057bf5b03a1ff0e224" title="Close an open dtn handle.">dtn_close</a>(<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="l00066"></a>00066 { <a name="l00067"></a>00067 <a class="code" href="dtn__ipc_8c.html#ca3de731f1395d03269a608a915d7539">dtnipc_close</a>((<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a> *)handle); <a name="l00068"></a>00068 free(handle); <a name="l00069"></a>00069 <span class="keywordflow">return</span> <a class="code" href="dtn__errno_8h.html#3723251cb5d056b6ace3e22561da1e11" title="DTN API error codes.">DTN_SUCCESS</a>; <a name="l00070"></a>00070 } <a name="l00071"></a>00071 <a name="l00072"></a>00072 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00073"></a>00073 <span class="keywordtype">int</span> <a name="l00074"></a><a class="code" href="dtn__api_8h.html#6183d81d5f742d13e1fdee26423d94b4">00074</a> <a class="code" href="dtn__api_8c.html#6183d81d5f742d13e1fdee26423d94b4" title="Get the error associated with the given handle.">dtn_errno</a>(<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="l00075"></a>00075 { <a name="l00076"></a>00076 <span class="keywordflow">return</span> ((<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)handle)->err; <a name="l00077"></a>00077 } <a name="l00078"></a>00078 <a name="l00079"></a>00079 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00080"></a>00080 <span class="keywordtype">void</span> <a name="l00081"></a><a class="code" href="dtn__api_8h.html#e87d5715259043c2490d71b80dd78f81">00081</a> <a class="code" href="dtn__api_8c.html#e87d5715259043c2490d71b80dd78f81" title="Set the error associated with the given handle.">dtn_set_errno</a>(<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>, <span class="keywordtype">int</span> err) <a name="l00082"></a>00082 { <a name="l00083"></a>00083 ((<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)handle)->err = err; <a name="l00084"></a>00084 } <a name="l00085"></a>00085 <a name="l00086"></a>00086 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00087"></a>00087 <span class="keywordtype">int</span> <a name="l00088"></a><a class="code" href="dtn__api_8h.html#b1f6eb20a2388dbae1c04b3a56db3131">00088</a> <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>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h, <a name="l00089"></a>00089 <a class="code" href="structdtn__endpoint__id__t.html" title="Specification of a dtn endpoint id, i.e.">dtn_endpoint_id_t</a>* local_eid, <a name="l00090"></a>00090 <span class="keyword">const</span> <span class="keywordtype">char</span>* tag) <a name="l00091"></a>00091 { <a name="l00092"></a>00092 <span class="keywordtype">int</span> status; <a name="l00093"></a>00093 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00094"></a>00094 XDR* xdr_encode = &handle-><a class="code" href="structdtnipc__handle.html#ded5c2335049e780a4ee8ab2b2356f95" title="XDR encoder.">xdr_encode</a>; <a name="l00095"></a>00095 XDR* xdr_decode = &handle-><a class="code" href="structdtnipc__handle.html#c09f26354224257a07c51d45f92725fd" title="XDR decoder.">xdr_decode</a>; <a name="l00096"></a>00096 <span class="keyword">struct </span><a class="code" href="structdtn__service__tag__t.html" title="Specification of a service tag used in building a local endpoint identifier.">dtn_service_tag_t</a> service_tag; <a name="l00097"></a>00097 <a name="l00098"></a>00098 <span class="comment">// check if the handle is in the middle of poll</span> <a name="l00099"></a>00099 <span class="keywordflow">if</span> (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>) { <a name="l00100"></a>00100 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#a2e25b980431aabe8f0c208ae97bf295">DTN_EINPOLL</a>; <a name="l00101"></a>00101 <span class="keywordflow">return</span> -1; <a name="l00102"></a>00102 } <a name="l00103"></a>00103 <a name="l00104"></a>00104 <span class="comment">// validate the tag length</span> <a name="l00105"></a>00105 <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a> = strlen(tag) + 1; <a name="l00106"></a>00106 <span class="keywordflow">if</span> (len > <a class="code" href="dtn__types_8h.html#20ab5e3c8f53edfd21543ca9cb49d20e">DTN_MAX_ENDPOINT_ID</a>) { <a name="l00107"></a>00107 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#8db3fceccf291cdfc226b9bea2316346">DTN_EINVAL</a>; <a name="l00108"></a>00108 <span class="keywordflow">return</span> -1; <a name="l00109"></a>00109 } <a name="l00110"></a>00110 <a name="l00111"></a>00111 <span class="comment">// pack the request</span> <a name="l00112"></a>00112 memset(&service_tag, 0, <span class="keyword">sizeof</span>(service_tag)); <a name="l00113"></a>00113 memcpy(&service_tag.<a class="code" href="structdtn__service__tag__t.html#63652556ffb523aed8804d87fa99eb58">tag</a>[0], tag, len); <a name="l00114"></a>00114 <span class="keywordflow">if</span> (!<a class="code" href="dtn__types_8h.html#9797727a4d9f870dfd962cd25d1a84de">xdr_dtn_service_tag_t</a>(xdr_encode, &service_tag)) { <a name="l00115"></a>00115 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00116"></a>00116 <span class="keywordflow">return</span> -1; <a name="l00117"></a>00117 } <a name="l00118"></a>00118 <a name="l00119"></a>00119 <span class="comment">// send the message</span> <a name="l00120"></a>00120 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#0c513c4c8a2438b359d7b53cec93e491">dtnipc_send</a>(handle, <a class="code" href="dtn__ipc_8h.html#c05301bf9560764f5e97fba507ef9e5d92dab95353850a6e914e4008347f07c7">DTN_LOCAL_EID</a>) != 0) { <a name="l00121"></a>00121 <span class="keywordflow">return</span> -1; <a name="l00122"></a>00122 } <a name="l00123"></a>00123 <a name="l00124"></a>00124 <span class="comment">// get the reply</span> <a name="l00125"></a>00125 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#92414569c9a91e622d91bfcb8d711045">dtnipc_recv</a>(handle, &status) < 0) { <a name="l00126"></a>00126 <span class="keywordflow">return</span> -1; <a name="l00127"></a>00127 } <a name="l00128"></a>00128 <a name="l00129"></a>00129 <span class="comment">// handle server-side errors</span> <a name="l00130"></a>00130 <span class="keywordflow">if</span> (status != <a class="code" href="dtn__errno_8h.html#3723251cb5d056b6ace3e22561da1e11" title="DTN API error codes.">DTN_SUCCESS</a>) { <a name="l00131"></a>00131 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = status; <a name="l00132"></a>00132 <span class="keywordflow">return</span> -1; <a name="l00133"></a>00133 } <a name="l00134"></a>00134 <a name="l00135"></a>00135 <span class="comment">// unpack the response</span> <a name="l00136"></a>00136 memset(local_eid, 0, <span class="keyword">sizeof</span>(*local_eid)); <a name="l00137"></a>00137 <span class="keywordflow">if</span> (!<a class="code" href="dtn__types_8h.html#16c5a6f4fcdc988f54f034bb1961b342">xdr_dtn_endpoint_id_t</a>(xdr_decode, local_eid)) { <a name="l00138"></a>00138 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00139"></a>00139 <span class="keywordflow">return</span> -1; <a name="l00140"></a>00140 } <a name="l00141"></a>00141 <a name="l00142"></a>00142 <span class="keywordflow">return</span> 0; <a name="l00143"></a>00143 } <a name="l00144"></a>00144 <a name="l00145"></a>00145 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00146"></a>00146 <span class="keywordtype">int</span> <a name="l00147"></a><a class="code" href="dtn__api_8h.html#383d25d1f6b8f9b5015d20f6f74bbecd">00147</a> <a class="code" href="dtn__api_8c.html#7384bf592d4aff0892ff948aafa98b0c" title="Create a dtn registration.">dtn_register</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h, <a name="l00148"></a>00148 <a class="code" href="structdtn__reg__info__t.html" title="Registration state.">dtn_reg_info_t</a> *reginfo, <a name="l00149"></a>00149 <a class="code" href="dtn__types_8h.html#d9378ff6ab7ee699568e037a8105f9b6" title="A registration cookie.">dtn_reg_id_t</a>* newregid) <a name="l00150"></a>00150 { <a name="l00151"></a>00151 <span class="keywordtype">int</span> status; <a name="l00152"></a>00152 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00153"></a>00153 XDR* xdr_encode = &handle-><a class="code" href="structdtnipc__handle.html#ded5c2335049e780a4ee8ab2b2356f95" title="XDR encoder.">xdr_encode</a>; <a name="l00154"></a>00154 XDR* xdr_decode = &handle-><a class="code" href="structdtnipc__handle.html#c09f26354224257a07c51d45f92725fd" title="XDR decoder.">xdr_decode</a>; <a name="l00155"></a>00155 <a name="l00156"></a>00156 <span class="comment">// check if the handle is in the middle of poll</span> <a name="l00157"></a>00157 <span class="keywordflow">if</span> (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>) { <a name="l00158"></a>00158 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#a2e25b980431aabe8f0c208ae97bf295">DTN_EINPOLL</a>; <a name="l00159"></a>00159 <span class="keywordflow">return</span> -1; <a name="l00160"></a>00160 } <a name="l00161"></a>00161 <a name="l00162"></a>00162 <span class="comment">// pack the request</span> <a name="l00163"></a>00163 <span class="keywordflow">if</span> (!<a class="code" href="dtn__types_8h.html#b71cd0713a2f102c11345bb032ee09d3">xdr_dtn_reg_info_t</a>(xdr_encode, reginfo)) { <a name="l00164"></a>00164 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00165"></a>00165 <span class="keywordflow">return</span> -1; <a name="l00166"></a>00166 } <a name="l00167"></a>00167 <a name="l00168"></a>00168 <span class="comment">// send the message</span> <a name="l00169"></a>00169 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#0c513c4c8a2438b359d7b53cec93e491">dtnipc_send</a>(handle, <a class="code" href="dtn__ipc_8h.html#c05301bf9560764f5e97fba507ef9e5de7933a4eff1b95879d4a353df40b195f">DTN_REGISTER</a>) != 0) { <a name="l00170"></a>00170 <span class="keywordflow">return</span> -1; <a name="l00171"></a>00171 } <a name="l00172"></a>00172 <a name="l00173"></a>00173 <span class="comment">// get the reply</span> <a name="l00174"></a>00174 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#92414569c9a91e622d91bfcb8d711045">dtnipc_recv</a>(handle, &status) < 0) { <a name="l00175"></a>00175 <span class="keywordflow">return</span> -1; <a name="l00176"></a>00176 } <a name="l00177"></a>00177 <a name="l00178"></a>00178 <span class="comment">// handle server-side errors</span> <a name="l00179"></a>00179 <span class="keywordflow">if</span> (status != <a class="code" href="dtn__errno_8h.html#3723251cb5d056b6ace3e22561da1e11" title="DTN API error codes.">DTN_SUCCESS</a>) { <a name="l00180"></a>00180 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = status; <a name="l00181"></a>00181 <span class="keywordflow">return</span> -1; <a name="l00182"></a>00182 } <a name="l00183"></a>00183 <a name="l00184"></a>00184 <span class="comment">// unpack the response</span> <a name="l00185"></a>00185 <span class="keywordflow">if</span> (!<a class="code" href="dtn__types_8h.html#9fa23bbd89d3ddf6df49a4fae6ebf28e">xdr_dtn_reg_id_t</a>(xdr_decode, newregid)) { <a name="l00186"></a>00186 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00187"></a>00187 <span class="keywordflow">return</span> -1; <a name="l00188"></a>00188 } <a name="l00189"></a>00189 <a name="l00190"></a>00190 <span class="keywordflow">return</span> 0; <a name="l00191"></a>00191 } <a name="l00192"></a>00192 <a name="l00193"></a>00193 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00194"></a>00194 <span class="keywordtype">int</span> <a name="l00195"></a><a class="code" href="dtn__api_8h.html#35bfbe9258dacb87a17580fb3e73416a">00195</a> <a class="code" href="dtn__api_8c.html#8c0647069233d858f0cefb57859a0b0e" title="Remove a dtn registration.">dtn_unregister</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h, <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="l00196"></a>00196 { <a name="l00197"></a>00197 <span class="keywordtype">int</span> status; <a name="l00198"></a>00198 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00199"></a>00199 <a name="l00200"></a>00200 XDR* xdr_encode = &handle-><a class="code" href="structdtnipc__handle.html#ded5c2335049e780a4ee8ab2b2356f95" title="XDR encoder.">xdr_encode</a>; <a name="l00201"></a>00201 <a name="l00202"></a>00202 <span class="comment">// check if the handle is in the middle of poll</span> <a name="l00203"></a>00203 <span class="keywordflow">if</span> (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>) { <a name="l00204"></a>00204 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#a2e25b980431aabe8f0c208ae97bf295">DTN_EINPOLL</a>; <a name="l00205"></a>00205 <span class="keywordflow">return</span> -1; <a name="l00206"></a>00206 } <a name="l00207"></a>00207 <a name="l00208"></a>00208 <span class="comment">// pack the request</span> <a name="l00209"></a>00209 <span class="keywordflow">if</span> (!<a class="code" href="dtn__types_8h.html#9fa23bbd89d3ddf6df49a4fae6ebf28e">xdr_dtn_reg_id_t</a>(xdr_encode, &regid)) { <a name="l00210"></a>00210 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00211"></a>00211 <span class="keywordflow">return</span> -1; <a name="l00212"></a>00212 } <a name="l00213"></a>00213 <a name="l00214"></a>00214 <span class="comment">// send the message</span> <a name="l00215"></a>00215 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#0c513c4c8a2438b359d7b53cec93e491">dtnipc_send</a>(handle, <a class="code" href="dtn__ipc_8h.html#c05301bf9560764f5e97fba507ef9e5d1e3888bf2ac2f73a90c6c142080279f5">DTN_UNREGISTER</a>) != 0) { <a name="l00216"></a>00216 <span class="keywordflow">return</span> -1; <a name="l00217"></a>00217 } <a name="l00218"></a>00218 <a name="l00219"></a>00219 <span class="comment">// get the reply</span> <a name="l00220"></a>00220 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#92414569c9a91e622d91bfcb8d711045">dtnipc_recv</a>(handle, &status) < 0) { <a name="l00221"></a>00221 <span class="keywordflow">return</span> -1; <a name="l00222"></a>00222 } <a name="l00223"></a>00223 <a name="l00224"></a>00224 <span class="comment">// handle server-side errors</span> <a name="l00225"></a>00225 <span class="keywordflow">if</span> (status != <a class="code" href="dtn__errno_8h.html#3723251cb5d056b6ace3e22561da1e11" title="DTN API error codes.">DTN_SUCCESS</a>) { <a name="l00226"></a>00226 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = status; <a name="l00227"></a>00227 <span class="keywordflow">return</span> -1; <a name="l00228"></a>00228 } <a name="l00229"></a>00229 <a name="l00230"></a>00230 <span class="keywordflow">return</span> 0; <a name="l00231"></a>00231 } <a name="l00232"></a>00232 <a name="l00233"></a>00233 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00234"></a>00234 <span class="keywordtype">int</span> <a name="l00235"></a><a class="code" href="dtn__api_8h.html#2e3457827ae6e670eada24be3536d477">00235</a> <a class="code" href="dtn__api_8c.html#add060907ae0beceeebb75ac61a8f552" title="Check for an existing registration on the given endpoint id, returning DTN_SUCCSS...">dtn_find_registration</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h, <a name="l00236"></a>00236 <a class="code" href="structdtn__endpoint__id__t.html" title="Specification of a dtn endpoint id, i.e.">dtn_endpoint_id_t</a> *eid, <a name="l00237"></a>00237 <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="l00238"></a>00238 { <a name="l00239"></a>00239 <span class="keywordtype">int</span> status; <a name="l00240"></a>00240 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00241"></a>00241 XDR* xdr_encode = &handle-><a class="code" href="structdtnipc__handle.html#ded5c2335049e780a4ee8ab2b2356f95" title="XDR encoder.">xdr_encode</a>; <a name="l00242"></a>00242 XDR* xdr_decode = &handle-><a class="code" href="structdtnipc__handle.html#c09f26354224257a07c51d45f92725fd" title="XDR decoder.">xdr_decode</a>; <a name="l00243"></a>00243 <a name="l00244"></a>00244 <span class="comment">// check if the handle is in the middle of poll</span> <a name="l00245"></a>00245 <span class="keywordflow">if</span> (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>) { <a name="l00246"></a>00246 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#a2e25b980431aabe8f0c208ae97bf295">DTN_EINPOLL</a>; <a name="l00247"></a>00247 <span class="keywordflow">return</span> -1; <a name="l00248"></a>00248 } <a name="l00249"></a>00249 <a name="l00250"></a>00250 <span class="comment">// pack the request</span> <a name="l00251"></a>00251 <span class="keywordflow">if</span> (!<a class="code" href="dtn__types_8h.html#16c5a6f4fcdc988f54f034bb1961b342">xdr_dtn_endpoint_id_t</a>(xdr_encode, eid)) { <a name="l00252"></a>00252 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00253"></a>00253 <span class="keywordflow">return</span> -1; <a name="l00254"></a>00254 } <a name="l00255"></a>00255 <a name="l00256"></a>00256 <span class="comment">// send the message</span> <a name="l00257"></a>00257 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#0c513c4c8a2438b359d7b53cec93e491">dtnipc_send</a>(handle, <a class="code" href="dtn__ipc_8h.html#c05301bf9560764f5e97fba507ef9e5df41ecaa2e442e281718ce6c7cd88fe30">DTN_FIND_REGISTRATION</a>) != 0) { <a name="l00258"></a>00258 <span class="keywordflow">return</span> -1; <a name="l00259"></a>00259 } <a name="l00260"></a>00260 <a name="l00261"></a>00261 <span class="comment">// get the reply</span> <a name="l00262"></a>00262 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#92414569c9a91e622d91bfcb8d711045">dtnipc_recv</a>(handle, &status) < 0) { <a name="l00263"></a>00263 <span class="keywordflow">return</span> -1; <a name="l00264"></a>00264 } <a name="l00265"></a>00265 <a name="l00266"></a>00266 <span class="comment">// handle server-side errors</span> <a name="l00267"></a>00267 <span class="keywordflow">if</span> (status != <a class="code" href="dtn__errno_8h.html#3723251cb5d056b6ace3e22561da1e11" title="DTN API error codes.">DTN_SUCCESS</a>) { <a name="l00268"></a>00268 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = status; <a name="l00269"></a>00269 <span class="keywordflow">return</span> -1; <a name="l00270"></a>00270 } <a name="l00271"></a>00271 <a name="l00272"></a>00272 <span class="comment">// unpack the response</span> <a name="l00273"></a>00273 <span class="keywordflow">if</span> (!<a class="code" href="dtn__types_8h.html#9fa23bbd89d3ddf6df49a4fae6ebf28e">xdr_dtn_reg_id_t</a>(xdr_decode, regid)) { <a name="l00274"></a>00274 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00275"></a>00275 <span class="keywordflow">return</span> -1; <a name="l00276"></a>00276 } <a name="l00277"></a>00277 <a name="l00278"></a>00278 <span class="keywordflow">return</span> 0; <a name="l00279"></a>00279 } <a name="l00280"></a>00280 <a name="l00281"></a>00281 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00282"></a>00282 <span class="keywordtype">int</span> <a name="l00283"></a><a class="code" href="dtn__api_8h.html#17453cd0fd905210e3fcf5210fc2a5b1">00283</a> <a class="code" href="dtn__api_8c.html#d65700cde584399bad4abe2536b2bc24" title="Modify an existing registration.">dtn_change_registration</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h, <a name="l00284"></a>00284 <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="l00285"></a>00285 <a class="code" href="structdtn__reg__info__t.html" title="Registration state.">dtn_reg_info_t</a> *reginfo) <a name="l00286"></a>00286 { <a name="l00287"></a>00287 (void)regid; <a name="l00288"></a>00288 (void)reginfo; <a name="l00289"></a>00289 <a name="l00290"></a>00290 <span class="comment">// XXX/demmer implement me</span> <a name="l00291"></a>00291 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00292"></a>00292 <a name="l00293"></a>00293 <span class="comment">// check if the handle is in the middle of poll</span> <a name="l00294"></a>00294 <span class="keywordflow">if</span> (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>) { <a name="l00295"></a>00295 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#a2e25b980431aabe8f0c208ae97bf295">DTN_EINPOLL</a>; <a name="l00296"></a>00296 <span class="keywordflow">return</span> -1; <a name="l00297"></a>00297 } <a name="l00298"></a>00298 <a name="l00299"></a>00299 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#951a074861ce082706b57c300413042b">DTN_EINTERNAL</a>; <a name="l00300"></a>00300 <span class="keywordflow">return</span> -1; <a name="l00301"></a>00301 } <a name="l00302"></a>00302 <a name="l00303"></a>00303 <span class="comment">//---------------------------------------------------------------------- </span> <a name="l00304"></a>00304 <span class="keywordtype">int</span> <a name="l00305"></a><a class="code" href="dtn__api_8h.html#3454bed440eb5848b6ac4017c51fe886">00305</a> <a class="code" href="dtn__api_8c.html#ab949d76f4c34a202aea5bac853b310b" title="Associate a registration with the current ipc channel.">dtn_bind</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h, <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="l00306"></a>00306 { <a name="l00307"></a>00307 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00308"></a>00308 XDR* xdr_encode = &handle-><a class="code" href="structdtnipc__handle.html#ded5c2335049e780a4ee8ab2b2356f95" title="XDR encoder.">xdr_encode</a>; <a name="l00309"></a>00309 <a name="l00310"></a>00310 <span class="comment">// check if the handle is in the middle of poll</span> <a name="l00311"></a>00311 <span class="keywordflow">if</span> (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>) { <a name="l00312"></a>00312 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#a2e25b980431aabe8f0c208ae97bf295">DTN_EINPOLL</a>; <a name="l00313"></a>00313 <span class="keywordflow">return</span> -1; <a name="l00314"></a>00314 } <a name="l00315"></a>00315 <a name="l00316"></a>00316 <span class="comment">// pack the request</span> <a name="l00317"></a>00317 <span class="keywordflow">if</span> (!<a class="code" href="dtn__types_8h.html#9fa23bbd89d3ddf6df49a4fae6ebf28e">xdr_dtn_reg_id_t</a>(xdr_encode, &regid)) { <a name="l00318"></a>00318 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00319"></a>00319 <span class="keywordflow">return</span> -1; <a name="l00320"></a>00320 } <a name="l00321"></a>00321 <a name="l00322"></a>00322 <span class="comment">// send the message</span> <a name="l00323"></a>00323 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#2e471ca046cc85566e16b9f60ef9937e" title="Send a message and wait for a response over the dtn ipc protocol.">dtnipc_send_recv</a>(handle, <a class="code" href="dtn__ipc_8h.html#c05301bf9560764f5e97fba507ef9e5d59676a9e0dd2cf2a2ebb493721f50198">DTN_BIND</a>) < 0) { <a name="l00324"></a>00324 <span class="keywordflow">return</span> -1; <a name="l00325"></a>00325 } <a name="l00326"></a>00326 <a name="l00327"></a>00327 <span class="keywordflow">return</span> 0; <a name="l00328"></a>00328 } <a name="l00329"></a>00329 <a name="l00330"></a>00330 <span class="comment">//---------------------------------------------------------------------- </span> <a name="l00331"></a>00331 <span class="keywordtype">int</span> <a name="l00332"></a><a class="code" href="dtn__api_8h.html#919dd7d4475d6d7bcedfbdfb1d129f6c">00332</a> <a class="code" href="dtn__api_8c.html#25e6dc7a917a193cd9dd2d28caee7f31" title="Explicitly remove an association from the current ipc handle.">dtn_unbind</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h, <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="l00333"></a>00333 { <a name="l00334"></a>00334 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00335"></a>00335 XDR* xdr_encode = &handle-><a class="code" href="structdtnipc__handle.html#ded5c2335049e780a4ee8ab2b2356f95" title="XDR encoder.">xdr_encode</a>; <a name="l00336"></a>00336 <a name="l00337"></a>00337 <span class="comment">// check if the handle is in the middle of poll</span> <a name="l00338"></a>00338 <span class="keywordflow">if</span> (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>) { <a name="l00339"></a>00339 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#a2e25b980431aabe8f0c208ae97bf295">DTN_EINPOLL</a>; <a name="l00340"></a>00340 <span class="keywordflow">return</span> -1; <a name="l00341"></a>00341 } <a name="l00342"></a>00342 <a name="l00343"></a>00343 <span class="comment">// pack the request</span> <a name="l00344"></a>00344 <span class="keywordflow">if</span> (!<a class="code" href="dtn__types_8h.html#9fa23bbd89d3ddf6df49a4fae6ebf28e">xdr_dtn_reg_id_t</a>(xdr_encode, &regid)) { <a name="l00345"></a>00345 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00346"></a>00346 <span class="keywordflow">return</span> -1; <a name="l00347"></a>00347 } <a name="l00348"></a>00348 <a name="l00349"></a>00349 <span class="comment">// send the message</span> <a name="l00350"></a>00350 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#2e471ca046cc85566e16b9f60ef9937e" title="Send a message and wait for a response over the dtn ipc protocol.">dtnipc_send_recv</a>(handle, <a class="code" href="dtn__ipc_8h.html#c05301bf9560764f5e97fba507ef9e5d801be28596a84f1a0ec58c57eac06b5b">DTN_UNBIND</a>) < 0) { <a name="l00351"></a>00351 <span class="keywordflow">return</span> -1; <a name="l00352"></a>00352 } <a name="l00353"></a>00353 <a name="l00354"></a>00354 <span class="keywordflow">return</span> 0; <a name="l00355"></a>00355 } <a name="l00356"></a>00356 <a name="l00357"></a>00357 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00358"></a>00358 <span class="keywordtype">int</span> <a name="l00359"></a><a class="code" href="dtn__api_8h.html#3996e6553cb38f6cf857b512492b14e2">00359</a> <a class="code" href="dtn__api_8c.html#9bcce797cfff268e49c0f5b2e5f21788" title="Send a bundle either from memory or from a file.">dtn_send</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h, <a name="l00360"></a>00360 <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="l00361"></a>00361 <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>* spec, <a name="l00362"></a>00362 <a class="code" href="structdtn__bundle__payload__t.html">dtn_bundle_payload_t</a>* payload, <a name="l00363"></a>00363 <a class="code" href="structdtn__bundle__id__t.html" title="Type definition for a unique bundle identifier.">dtn_bundle_id_t</a>* <span class="keywordtype">id</span>) <a name="l00364"></a>00364 { <a name="l00365"></a>00365 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00366"></a>00366 XDR* xdr_encode = &handle-><a class="code" href="structdtnipc__handle.html#ded5c2335049e780a4ee8ab2b2356f95" title="XDR encoder.">xdr_encode</a>; <a name="l00367"></a>00367 XDR* xdr_decode = &handle-><a class="code" href="structdtnipc__handle.html#c09f26354224257a07c51d45f92725fd" title="XDR decoder.">xdr_decode</a>; <a name="l00368"></a>00368 <a name="l00369"></a>00369 <span class="comment">// check if the handle is in the middle of poll</span> <a name="l00370"></a>00370 <span class="keywordflow">if</span> (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>) { <a name="l00371"></a>00371 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#a2e25b980431aabe8f0c208ae97bf295">DTN_EINPOLL</a>; <a name="l00372"></a>00372 <span class="keywordflow">return</span> -1; <a name="l00373"></a>00373 } <a name="l00374"></a>00374 <a name="l00375"></a>00375 <span class="comment">// pack the arguments</span> <a name="l00376"></a>00376 <span class="keywordflow">if</span> ((!<a class="code" href="dtn__types_8h.html#9fa23bbd89d3ddf6df49a4fae6ebf28e">xdr_dtn_reg_id_t</a>(xdr_encode, &regid)) || <a name="l00377"></a>00377 (!<a class="code" href="dtn__types_8h.html#54a4fbc50daeb79cc615af82793cbdc8">xdr_dtn_bundle_spec_t</a>(xdr_encode, spec)) || <a name="l00378"></a>00378 (!<a class="code" href="dtn__types_8h.html#52d9e9ef1e11bf39693baced9c591d67">xdr_dtn_bundle_payload_t</a>(xdr_encode, payload))) { <a name="l00379"></a>00379 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00380"></a>00380 <span class="keywordflow">return</span> -1; <a name="l00381"></a>00381 } <a name="l00382"></a>00382 <a name="l00383"></a>00383 <span class="comment">// send the message</span> <a name="l00384"></a>00384 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#2e471ca046cc85566e16b9f60ef9937e" title="Send a message and wait for a response over the dtn ipc protocol.">dtnipc_send_recv</a>(handle, <a class="code" href="dtn__ipc_8h.html#c05301bf9560764f5e97fba507ef9e5d00609e70cdd50ac4a6d989603c2976bf">DTN_SEND</a>) < 0) { <a name="l00385"></a>00385 <span class="keywordflow">return</span> -1; <a name="l00386"></a>00386 } <a name="l00387"></a>00387 <a name="l00388"></a>00388 <span class="comment">// unpack the bundle id return value</span> <a name="l00389"></a>00389 memset(<span class="keywordtype">id</span>, 0, <span class="keyword">sizeof</span>(<span class="keywordtype">id</span>)); <a name="l00390"></a>00390 <a name="l00391"></a>00391 <span class="keywordflow">if</span> (!<a class="code" href="dtn__types_8h.html#c51906327f0c0e0571243a5dceffc0af">xdr_dtn_bundle_id_t</a>(xdr_decode, <span class="keywordtype">id</span>)) <a name="l00392"></a>00392 { <a name="l00393"></a>00393 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00394"></a>00394 <span class="keywordflow">return</span> <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00395"></a>00395 } <a name="l00396"></a>00396 <a name="l00397"></a>00397 <span class="keywordflow">return</span> 0; <a name="l00398"></a>00398 } <a name="l00399"></a>00399 <a name="l00400"></a>00400 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00401"></a>00401 <span class="keywordtype">int</span> <a name="l00402"></a><a class="code" href="dtn__api_8h.html#4b733bdb9b4670e3392bd5e72a1dabdc">00402</a> <a class="code" href="dtn__api_8c.html#aebe24341617dde06219462c0aac77a0" title="Cancel a bundle transmission.">dtn_cancel</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h, <a name="l00403"></a>00403 <a class="code" href="structdtn__bundle__id__t.html" title="Type definition for a unique bundle identifier.">dtn_bundle_id_t</a>* <span class="keywordtype">id</span>) <a name="l00404"></a>00404 { <a name="l00405"></a>00405 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00406"></a>00406 XDR* xdr_encode = &handle-><a class="code" href="structdtnipc__handle.html#ded5c2335049e780a4ee8ab2b2356f95" title="XDR encoder.">xdr_encode</a>; <a name="l00407"></a>00407 <a name="l00408"></a>00408 <span class="comment">// check if the handle is in the middle of poll</span> <a name="l00409"></a>00409 <span class="keywordflow">if</span> (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>) { <a name="l00410"></a>00410 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#a2e25b980431aabe8f0c208ae97bf295">DTN_EINPOLL</a>; <a name="l00411"></a>00411 <span class="keywordflow">return</span> -1; <a name="l00412"></a>00412 } <a name="l00413"></a>00413 <a name="l00414"></a>00414 <span class="comment">// pack the arguments</span> <a name="l00415"></a>00415 <span class="keywordflow">if</span> (!<a class="code" href="dtn__types_8h.html#c51906327f0c0e0571243a5dceffc0af">xdr_dtn_bundle_id_t</a>(xdr_encode, <span class="keywordtype">id</span>)) { <a name="l00416"></a>00416 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00417"></a>00417 <span class="keywordflow">return</span> -1; <a name="l00418"></a>00418 } <a name="l00419"></a>00419 <a name="l00420"></a>00420 <span class="comment">// send the message</span> <a name="l00421"></a>00421 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#2e471ca046cc85566e16b9f60ef9937e" title="Send a message and wait for a response over the dtn ipc protocol.">dtnipc_send_recv</a>(handle, <a class="code" href="dtn__ipc_8h.html#c05301bf9560764f5e97fba507ef9e5d8ac916eaefdf27a024e85c5a71ef7caf">DTN_CANCEL</a>) < 0) { <a name="l00422"></a>00422 <span class="keywordflow">return</span> -1; <a name="l00423"></a>00423 } <a name="l00424"></a>00424 <a name="l00425"></a>00425 <span class="keywordflow">return</span> 0; <a name="l00426"></a>00426 } <a name="l00427"></a>00427 <a name="l00428"></a>00428 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00429"></a>00429 <span class="keywordtype">int</span> <a name="l00430"></a><a class="code" href="dtn__api_8h.html#1377dbe76849d8852400a9278e4b8df1">00430</a> <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>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h, <a name="l00431"></a>00431 <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>* spec, <a name="l00432"></a>00432 <a class="code" href="dtn__types_8h.html#3dcfddc1b850a71a18d8a0868f67e762" title="The payload of a bundle can be sent or received either in a file, in which case the...">dtn_bundle_payload_location_t</a> location, <a name="l00433"></a>00433 <a class="code" href="structdtn__bundle__payload__t.html">dtn_bundle_payload_t</a>* payload, <a name="l00434"></a>00434 <a class="code" href="dtn__types_8h.html#8865a20f2e713bb38e35736e32e1653c" title="DTN timeouts are specified in seconds.">dtn_timeval_t</a> timeout) <a name="l00435"></a>00435 { <a name="l00436"></a>00436 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00437"></a>00437 XDR* xdr_encode = &handle-><a class="code" href="structdtnipc__handle.html#ded5c2335049e780a4ee8ab2b2356f95" title="XDR encoder.">xdr_encode</a>; <a name="l00438"></a>00438 XDR* xdr_decode = &handle-><a class="code" href="structdtnipc__handle.html#c09f26354224257a07c51d45f92725fd" title="XDR decoder.">xdr_decode</a>; <a name="l00439"></a>00439 <a name="l00440"></a>00440 <span class="keywordflow">if</span> (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>) { <a name="l00441"></a>00441 handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a> = 0; <a name="l00442"></a>00442 <a name="l00443"></a>00443 <span class="keywordtype">int</span> poll_status = 0; <a name="l00444"></a>00444 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#92414569c9a91e622d91bfcb8d711045">dtnipc_recv</a>(handle, &poll_status) != 0) { <a name="l00445"></a>00445 <span class="keywordflow">return</span> -1; <a name="l00446"></a>00446 } <a name="l00447"></a>00447 <a name="l00448"></a>00448 <span class="keywordflow">if</span> (poll_status != <a class="code" href="dtn__errno_8h.html#3723251cb5d056b6ace3e22561da1e11" title="DTN API error codes.">DTN_SUCCESS</a>) { <a name="l00449"></a>00449 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = poll_status; <a name="l00450"></a>00450 <span class="keywordflow">return</span> -1; <a name="l00451"></a>00451 } <a name="l00452"></a>00452 } <a name="l00453"></a>00453 <a name="l00454"></a>00454 <span class="comment">// zero out the spec and payload structures</span> <a name="l00455"></a>00455 memset(spec, 0, <span class="keyword">sizeof</span>(*spec)); <a name="l00456"></a>00456 memset(payload, 0, <span class="keyword">sizeof</span>(*payload)); <a name="l00457"></a>00457 <a name="l00458"></a>00458 <span class="comment">// pack the arguments</span> <a name="l00459"></a>00459 <span class="keywordflow">if</span> ((!<a class="code" href="dtn__types_8h.html#d98f93d0953484b7b74e2bf33aa0d3a7">xdr_dtn_bundle_payload_location_t</a>(xdr_encode, &location)) || <a name="l00460"></a>00460 (!<a class="code" href="dtn__types_8h.html#62ea0edc92ab755946bef6dcfaf1f611">xdr_dtn_timeval_t</a>(xdr_encode, &timeout))) <a name="l00461"></a>00461 { <a name="l00462"></a>00462 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00463"></a>00463 <span class="keywordflow">return</span> -1; <a name="l00464"></a>00464 } <a name="l00465"></a>00465 <a name="l00466"></a>00466 <span class="comment">// send the message</span> <a name="l00467"></a>00467 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#2e471ca046cc85566e16b9f60ef9937e" title="Send a message and wait for a response over the dtn ipc protocol.">dtnipc_send_recv</a>(handle, <a class="code" href="dtn__ipc_8h.html#c05301bf9560764f5e97fba507ef9e5da5a90d9130e7ad725dede5a0c4110495">DTN_RECV</a>) < 0) { <a name="l00468"></a>00468 <span class="keywordflow">return</span> -1; <a name="l00469"></a>00469 } <a name="l00470"></a>00470 <a name="l00471"></a>00471 <span class="comment">// unpack the bundle</span> <a name="l00472"></a>00472 <span class="keywordflow">if</span> (!<a class="code" href="dtn__types_8h.html#54a4fbc50daeb79cc615af82793cbdc8">xdr_dtn_bundle_spec_t</a>(xdr_decode, spec) || <a name="l00473"></a>00473 !<a class="code" href="dtn__types_8h.html#52d9e9ef1e11bf39693baced9c591d67">xdr_dtn_bundle_payload_t</a>(xdr_decode, payload)) <a name="l00474"></a>00474 { <a name="l00475"></a>00475 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00476"></a>00476 <span class="keywordflow">return</span> -1; <a name="l00477"></a>00477 } <a name="l00478"></a>00478 <a name="l00479"></a>00479 <span class="comment">// if the app requested memory delivery but the payload was too</span> <a name="l00480"></a>00480 <span class="comment">// big, then the API server delivered the bundle in a file</span> <a name="l00481"></a>00481 <span class="comment">// instead, so read in the data here</span> <a name="l00482"></a>00482 <span class="keywordflow">if</span> (location == <a class="code" href="dtn__types_8h.html#3dcfddc1b850a71a18d8a0868f67e7628f773bbfb80857bd5a11f09665fa9b03">DTN_PAYLOAD_MEM</a> && payload-><a class="code" href="structdtn__bundle__payload__t.html#4877c653f99a90c38ae8fdb4a1774247">location</a> == <a class="code" href="dtn__types_8h.html#3dcfddc1b850a71a18d8a0868f67e7621ff9272291ffe7d9f8083e7c5a548909">DTN_PAYLOAD_FILE</a>) <a name="l00483"></a>00483 { <a name="l00484"></a>00484 <span class="keywordtype">char</span> <a class="code" href="dtnrecv_8c.html#b49244970ed5ca30989c2dab2129de34">filename</a>[<a class="code" href="dtnrecv_8c.html#e688d728e1acdfe5988c7db45d6f0166">PATH_MAX</a>]; <a name="l00485"></a>00485 strncpy(filename, payload-><a class="code" href="structdtn__bundle__payload__t.html#f3a33fd2ae2b3b8eae2e675f1a038cec">filename</a>.<a class="code" href="structdtn__bundle__payload__t.html#0d824d13c3225cb59fa2e34623608b2a">filename_val</a>, <a class="code" href="dtnrecv_8c.html#e688d728e1acdfe5988c7db45d6f0166">PATH_MAX</a>); <a name="l00486"></a>00486 <a name="l00487"></a>00487 <span class="keywordtype">int</span> <a class="code" href="dtnperf-client_8c.html#6f8059414f0228f0256115e024eeed4b">fd</a> = open(filename, O_RDONLY, 0); <a name="l00488"></a>00488 <span class="keywordflow">if</span> (fd <= 0) { <a name="l00489"></a>00489 fprintf(stderr, <span class="stringliteral">"DTN API internal error opening payload file %s: %s\n"</span>, <a name="l00490"></a>00490 filename, strerror(<a class="code" href="IPDiscovery_8cc.html#d65a8842cc674e3ddf69355898c0ecbf">errno</a>)); <a name="l00491"></a>00491 <span class="keywordflow">return</span> <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00492"></a>00492 } <a name="l00493"></a>00493 <a name="l00494"></a>00494 <span class="keyword">struct </span>stat st; <a name="l00495"></a>00495 <span class="keywordflow">if</span> (fstat(fd, &st) != 0) { <a name="l00496"></a>00496 fprintf(stderr, <span class="stringliteral">"DTN API internal error getting stat of payload file: %s\n"</span>, <a name="l00497"></a>00497 strerror(<a class="code" href="IPDiscovery_8cc.html#d65a8842cc674e3ddf69355898c0ecbf">errno</a>)); <a name="l00498"></a>00498 <span class="keywordflow">return</span> <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00499"></a>00499 } <a name="l00500"></a>00500 <a name="l00501"></a>00501 <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>(payload); <a name="l00502"></a>00502 <a name="l00503"></a>00503 payload-><a class="code" href="structdtn__bundle__payload__t.html#4877c653f99a90c38ae8fdb4a1774247">location</a> = <a class="code" href="dtn__types_8h.html#3dcfddc1b850a71a18d8a0868f67e7628f773bbfb80857bd5a11f09665fa9b03">DTN_PAYLOAD_MEM</a>; <a name="l00504"></a>00504 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a> = st.st_size; <a name="l00505"></a>00505 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> = len; <a name="l00506"></a>00506 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> = (<span class="keywordtype">char</span>*)malloc(len); <a name="l00507"></a>00507 <a name="l00508"></a>00508 <span class="keywordtype">char</span>* bp = 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="l00509"></a>00509 <span class="keywordflow">do</span> { <a name="l00510"></a>00510 <span class="keywordtype">int</span> n = read(fd, bp, len); <a name="l00511"></a>00511 <a name="l00512"></a>00512 <span class="keywordflow">if</span> (n <= 0) { <a name="l00513"></a>00513 fprintf(stderr, <a name="l00514"></a>00514 <span class="stringliteral">"DTN API internal error reading payload file (%d/%u): %s\n"</span>, <a name="l00515"></a>00515 n, len, strerror(<a class="code" href="IPDiscovery_8cc.html#d65a8842cc674e3ddf69355898c0ecbf">errno</a>)); <a name="l00516"></a>00516 <span class="keywordflow">return</span> <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00517"></a>00517 } <a name="l00518"></a>00518 <a name="l00519"></a>00519 len -= n; <a name="l00520"></a>00520 bp += n; <a name="l00521"></a>00521 } <span class="keywordflow">while</span> (len > 0); <a name="l00522"></a>00522 <a name="l00523"></a>00523 close(fd); <a name="l00524"></a>00524 <a name="l00525"></a>00525 <span class="keywordflow">if</span> (unlink(filename) != 0) { <a name="l00526"></a>00526 fprintf(stderr, <span class="stringliteral">"DTN API internal error removing payload file %s: %s\n"</span>, <a name="l00527"></a>00527 filename, strerror(<a class="code" href="IPDiscovery_8cc.html#d65a8842cc674e3ddf69355898c0ecbf">errno</a>)); <a name="l00528"></a>00528 <span class="keywordflow">return</span> <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00529"></a>00529 } <a name="l00530"></a>00530 } <a name="l00531"></a>00531 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (location != payload-><a class="code" href="structdtn__bundle__payload__t.html#4877c653f99a90c38ae8fdb4a1774247">location</a>) <a name="l00532"></a>00532 { <a name="l00533"></a>00533 fprintf(stderr, <a name="l00534"></a>00534 <span class="stringliteral">"DTN API internal error: location != payload location\n"</span>); <a name="l00535"></a>00535 <span class="comment">// shouldn't happen</span> <a name="l00536"></a>00536 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00537"></a>00537 <span class="keywordflow">return</span> -1; <a name="l00538"></a>00538 } <a name="l00539"></a>00539 <a name="l00540"></a>00540 <span class="keywordflow">return</span> 0; <a name="l00541"></a>00541 } <a name="l00542"></a>00542 <a name="l00543"></a>00543 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00544"></a>00544 <span class="keywordtype">int</span> <a name="l00545"></a><a class="code" href="dtn__api_8h.html#74afc602b7d95c9b6ed1f03c351691b3">00545</a> <a class="code" href="dtn__api_8c.html#5f6c1134fae89446725b57516748a737" title="Blocking query for new subscribers on a session.">dtn_session_update</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h, <a name="l00546"></a>00546 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>* status, <a name="l00547"></a>00547 <a class="code" href="structdtn__endpoint__id__t.html" title="Specification of a dtn endpoint id, i.e.">dtn_endpoint_id_t</a>* session, <a name="l00548"></a>00548 <a class="code" href="dtn__types_8h.html#8865a20f2e713bb38e35736e32e1653c" title="DTN timeouts are specified in seconds.">dtn_timeval_t</a> timeout) <a name="l00549"></a>00549 { <a name="l00550"></a>00550 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00551"></a>00551 XDR* xdr_encode = &handle-><a class="code" href="structdtnipc__handle.html#ded5c2335049e780a4ee8ab2b2356f95" title="XDR encoder.">xdr_encode</a>; <a name="l00552"></a>00552 XDR* xdr_decode = &handle-><a class="code" href="structdtnipc__handle.html#c09f26354224257a07c51d45f92725fd" title="XDR decoder.">xdr_decode</a>; <a name="l00553"></a>00553 <a name="l00554"></a>00554 <span class="keywordflow">if</span> (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>) { <a name="l00555"></a>00555 handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a> = 0; <a name="l00556"></a>00556 <a name="l00557"></a>00557 <span class="keywordtype">int</span> poll_status = 0; <a name="l00558"></a>00558 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#92414569c9a91e622d91bfcb8d711045">dtnipc_recv</a>(handle, &poll_status) != 0) { <a name="l00559"></a>00559 <span class="keywordflow">return</span> -1; <a name="l00560"></a>00560 } <a name="l00561"></a>00561 <a name="l00562"></a>00562 <span class="keywordflow">if</span> (poll_status != <a class="code" href="dtn__errno_8h.html#3723251cb5d056b6ace3e22561da1e11" title="DTN API error codes.">DTN_SUCCESS</a>) { <a name="l00563"></a>00563 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = poll_status; <a name="l00564"></a>00564 <span class="keywordflow">return</span> -1; <a name="l00565"></a>00565 } <a name="l00566"></a>00566 } <a name="l00567"></a>00567 <a name="l00568"></a>00568 <span class="comment">// pack the arguments</span> <a name="l00569"></a>00569 <span class="keywordflow">if</span> ((!<a class="code" href="dtn__types_8h.html#62ea0edc92ab755946bef6dcfaf1f611">xdr_dtn_timeval_t</a>(xdr_encode, &timeout))) <a name="l00570"></a>00570 { <a name="l00571"></a>00571 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00572"></a>00572 <span class="keywordflow">return</span> -1; <a name="l00573"></a>00573 } <a name="l00574"></a>00574 <a name="l00575"></a>00575 <span class="comment">// send the message</span> <a name="l00576"></a>00576 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#2e471ca046cc85566e16b9f60ef9937e" title="Send a message and wait for a response over the dtn ipc protocol.">dtnipc_send_recv</a>(handle, <a class="code" href="dtn__ipc_8h.html#c05301bf9560764f5e97fba507ef9e5d7f9ec4960a1d48ce448a1f7c2dfc0d5a">DTN_SESSION_UPDATE</a>) < 0) { <a name="l00577"></a>00577 <span class="keywordflow">return</span> -1; <a name="l00578"></a>00578 } <a name="l00579"></a>00579 <a name="l00580"></a>00580 memset(status, 0, <span class="keyword">sizeof</span>(*status)); <a name="l00581"></a>00581 memset(session, 0, <span class="keyword">sizeof</span>(*session)); <a name="l00582"></a>00582 <a name="l00583"></a>00583 <span class="comment">// unpack the status / session</span> <a name="l00584"></a>00584 <span class="keywordflow">if</span> (!xdr_u_int(xdr_decode, status) || <a name="l00585"></a>00585 !<a class="code" href="dtn__types_8h.html#16c5a6f4fcdc988f54f034bb1961b342">xdr_dtn_endpoint_id_t</a>(xdr_decode, session)) <a name="l00586"></a>00586 { <a name="l00587"></a>00587 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00588"></a>00588 <span class="keywordflow">return</span> -1; <a name="l00589"></a>00589 } <a name="l00590"></a>00590 <a name="l00591"></a>00591 <span class="keywordflow">return</span> 0; <a name="l00592"></a>00592 } <a name="l00593"></a>00593 <a name="l00594"></a>00594 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00595"></a>00595 <span class="keywordtype">int</span> <a name="l00596"></a><a class="code" href="dtn__api_8h.html#dea67e5fa38121aaaa8526c02f9ebfbf">00596</a> <a class="code" href="dtn__api_8c.html#4d6380561a5b032ca5f84031926c5d40" title="Return a file descriptor for the given handle suitable for calling poll() or select()...">dtn_poll_fd</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h) <a name="l00597"></a>00597 { <a name="l00598"></a>00598 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00599"></a>00599 <span class="keywordflow">return</span> handle-><a class="code" href="structdtnipc__handle.html#d7e67a3808764e8217255940427204bc" title="Socket file descriptor.">sock</a>; <a name="l00600"></a>00600 } <a name="l00601"></a>00601 <a name="l00602"></a>00602 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00603"></a>00603 <span class="keywordtype">int</span> <a name="l00604"></a><a class="code" href="dtn__api_8h.html#5678c8136cde3d2f6ee98e0d9f051c87">00604</a> <a class="code" href="dtn__api_8c.html#24563d1e420ea738e7d456a58e3ec152" title="Begin a polling period for incoming bundles.">dtn_begin_poll</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h, <a class="code" href="dtn__types_8h.html#8865a20f2e713bb38e35736e32e1653c" title="DTN timeouts are specified in seconds.">dtn_timeval_t</a> timeout) <a name="l00605"></a>00605 { <a name="l00606"></a>00606 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00607"></a>00607 XDR* xdr_encode = &handle-><a class="code" href="structdtnipc__handle.html#ded5c2335049e780a4ee8ab2b2356f95" title="XDR encoder.">xdr_encode</a>; <a name="l00608"></a>00608 <a name="l00609"></a>00609 <span class="comment">// check if the handle is already in the middle of poll</span> <a name="l00610"></a>00610 <span class="keywordflow">if</span> (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>) { <a name="l00611"></a>00611 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#a2e25b980431aabe8f0c208ae97bf295">DTN_EINPOLL</a>; <a name="l00612"></a>00612 <span class="keywordflow">return</span> -1; <a name="l00613"></a>00613 } <a name="l00614"></a>00614 <a name="l00615"></a>00615 handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a> = 1; <a name="l00616"></a>00616 <a name="l00617"></a>00617 <span class="keywordflow">if</span> ((!<a class="code" href="dtn__types_8h.html#62ea0edc92ab755946bef6dcfaf1f611">xdr_dtn_timeval_t</a>(xdr_encode, &timeout))) <a name="l00618"></a>00618 { <a name="l00619"></a>00619 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#2121e3f0d822e257e8d2e843a3524ef0">DTN_EXDR</a>; <a name="l00620"></a>00620 <span class="keywordflow">return</span> -1; <a name="l00621"></a>00621 } <a name="l00622"></a>00622 <a name="l00623"></a>00623 <span class="comment">// send the message but don't block for the response code -- we'll</span> <a name="l00624"></a>00624 <span class="comment">// grab it in dtn_recv or dtn_cancel_poll</span> <a name="l00625"></a>00625 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#0c513c4c8a2438b359d7b53cec93e491">dtnipc_send</a>(handle, <a class="code" href="dtn__ipc_8h.html#c05301bf9560764f5e97fba507ef9e5d5f4461d4add4e2832436f9c8ae25e61e">DTN_BEGIN_POLL</a>) < 0) { <a name="l00626"></a>00626 <span class="keywordflow">return</span> -1; <a name="l00627"></a>00627 } <a name="l00628"></a>00628 <a name="l00629"></a>00629 <span class="keywordflow">return</span> handle-><a class="code" href="structdtnipc__handle.html#d7e67a3808764e8217255940427204bc" title="Socket file descriptor.">sock</a>; <a name="l00630"></a>00630 } <a name="l00631"></a>00631 <a name="l00632"></a>00632 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00633"></a>00633 <span class="keywordtype">int</span> <a name="l00634"></a><a class="code" href="dtn__api_8h.html#b1937510417914fe7741e6d4767683e5">00634</a> <a class="code" href="dtn__api_8c.html#ad48e265c83879125870207dc2fe3c55" title="Cancel a polling interval.">dtn_cancel_poll</a>(<a class="code" href="dtn__api_8h.html#566289d829b69370d7635c21364bfe18" title="The basic handle for communication with the dtn router.">dtn_handle_t</a> h) <a name="l00635"></a>00635 { <a name="l00636"></a>00636 <a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>* <a class="code" href="dtncat_8c.html#01daea96255bb21a8979b3b45f5bbb70">handle</a> = (<a class="code" href="structdtnipc__handle.html" title="State of a DTN IPC channel.">dtnipc_handle_t</a>*)h; <a name="l00637"></a>00637 <a name="l00638"></a>00638 <span class="comment">// make sure the handle is already in the middle of poll</span> <a name="l00639"></a>00639 <span class="keywordflow">if</span> (! (handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a>)) { <a name="l00640"></a>00640 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = <a class="code" href="dtn__errno_8h.html#8db3fceccf291cdfc226b9bea2316346">DTN_EINVAL</a>; <a name="l00641"></a>00641 <span class="keywordflow">return</span> -1; <a name="l00642"></a>00642 } <a name="l00643"></a>00643 <a name="l00644"></a>00644 <span class="comment">// clear the poll flag</span> <a name="l00645"></a>00645 handle-><a class="code" href="structdtnipc__handle.html#789e27232c351dc8367fe7d81ca3e32d" title="Flag to register a call to poll().">in_poll</a> = 0; <a name="l00646"></a>00646 <a name="l00647"></a>00647 <span class="comment">// send the message and get two response codes, one from poll</span> <a name="l00648"></a>00648 <span class="comment">// command, and one from the cancel request.</span> <a name="l00649"></a>00649 <span class="keywordtype">int</span> poll_status = <a class="code" href="dtn__ipc_8c.html#2e471ca046cc85566e16b9f60ef9937e" title="Send a message and wait for a response over the dtn ipc protocol.">dtnipc_send_recv</a>(handle, <a class="code" href="dtn__ipc_8h.html#c05301bf9560764f5e97fba507ef9e5df37b9c7e51b4309e5f3ca74a8b743c3b">DTN_CANCEL_POLL</a>); <a name="l00650"></a>00650 <span class="keywordflow">if</span> (poll_status != <a class="code" href="dtn__errno_8h.html#3723251cb5d056b6ace3e22561da1e11" title="DTN API error codes.">DTN_SUCCESS</a> && poll_status != <a class="code" href="dtn__errno_8h.html#35b24187121ca003154518bba0a35e75">DTN_ETIMEOUT</a>) { <a name="l00651"></a>00651 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = poll_status; <a name="l00652"></a>00652 <span class="keywordflow">return</span> -1; <a name="l00653"></a>00653 } <a name="l00654"></a>00654 <a name="l00655"></a>00655 <span class="keywordtype">int</span> cancel_status; <a name="l00656"></a>00656 <span class="keywordflow">if</span> (<a class="code" href="dtn__ipc_8c.html#92414569c9a91e622d91bfcb8d711045">dtnipc_recv</a>(handle, &cancel_status) != 0) { <a name="l00657"></a>00657 <span class="keywordflow">return</span> -1; <a name="l00658"></a>00658 } <a name="l00659"></a>00659 handle-><a class="code" href="structdtnipc__handle.html#b76f241bd49850e48c051fde495d0a78" title="Error code.">err</a> = cancel_status; <a name="l00660"></a>00660 <a name="l00661"></a>00661 <span class="keywordflow">if</span> (cancel_status != <a class="code" href="dtn__errno_8h.html#3723251cb5d056b6ace3e22561da1e11" title="DTN API error codes.">DTN_SUCCESS</a>) { <a name="l00662"></a>00662 <span class="keywordflow">return</span> -1; <a name="l00663"></a>00663 } <a name="l00664"></a>00664 <a name="l00665"></a>00665 <span class="keywordflow">return</span> 0; <a name="l00666"></a>00666 } <a name="l00667"></a>00667 <a name="l00668"></a>00668 <span class="comment">/*************************************************************</span> <a name="l00669"></a>00669 <span class="comment"> *</span> <a name="l00670"></a>00670 <span class="comment"> * Utility Functions</span> <a name="l00671"></a>00671 <span class="comment"> *</span> <a name="l00672"></a>00672 <span class="comment"> *************************************************************/</span> <a name="l00673"></a>00673 <span class="keywordtype">void</span> <a name="l00674"></a><a class="code" href="dtn__api_8h.html#b2935a9a7f4ade630f7d2ad1fec5c615">00674</a> <a class="code" href="dtn__api_8c.html#b2935a9a7f4ade630f7d2ad1fec5c615" title="Copy the contents of one eid into another.">dtn_copy_eid</a>(<a class="code" href="structdtn__endpoint__id__t.html" title="Specification of a dtn endpoint id, i.e.">dtn_endpoint_id_t</a>* dst, <a class="code" href="structdtn__endpoint__id__t.html" title="Specification of a dtn endpoint id, i.e.">dtn_endpoint_id_t</a>* <a class="code" href="dtnmoteproxy_8c.html#e1ade0f5a1b32f6c8be72f31a99e2a18">src</a>) <a name="l00675"></a>00675 { <a name="l00676"></a>00676 memcpy(dst-><a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>, src-><a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>, <a class="code" href="dtn__types_8h.html#20ab5e3c8f53edfd21543ca9cb49d20e">DTN_MAX_ENDPOINT_ID</a>); <a name="l00677"></a>00677 } <a name="l00678"></a>00678 <a name="l00679"></a>00679 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00680"></a>00680 <span class="keywordtype">int</span> <a name="l00681"></a><a class="code" href="dtn__api_8h.html#055c8bb8eaa570aacbe6a164ff123c84">00681</a> <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>(<a class="code" href="structdtn__endpoint__id__t.html" title="Specification of a dtn endpoint id, i.e.">dtn_endpoint_id_t</a>* eid, <span class="keyword">const</span> <span class="keywordtype">char</span>* str) <a name="l00682"></a>00682 { <a name="l00683"></a>00683 <span class="keywordtype">char</span> *s; <a name="l00684"></a>00684 <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>; <a name="l00685"></a>00685 <a name="l00686"></a>00686 len = strlen(str) + 1; <a name="l00687"></a>00687 <a name="l00688"></a>00688 <span class="comment">// check string length</span> <a name="l00689"></a>00689 <span class="keywordflow">if</span> (len > <a class="code" href="dtn__types_8h.html#20ab5e3c8f53edfd21543ca9cb49d20e">DTN_MAX_ENDPOINT_ID</a>) { <a name="l00690"></a>00690 <span class="keywordflow">return</span> <a class="code" href="dtn__errno_8h.html#dfbc45377fa7c17b849e79a015975a79">DTN_ESIZE</a>; <a name="l00691"></a>00691 } <a name="l00692"></a>00692 <a name="l00693"></a>00693 <span class="comment">// make sure there's a colon</span> <a name="l00694"></a>00694 s = strchr(str, <span class="charliteral">':'</span>); <a name="l00695"></a>00695 <span class="keywordflow">if</span> (!s) { <a name="l00696"></a>00696 <span class="keywordflow">return</span> <a class="code" href="dtn__errno_8h.html#8db3fceccf291cdfc226b9bea2316346">DTN_EINVAL</a>; <a name="l00697"></a>00697 } <a name="l00698"></a>00698 <a name="l00699"></a>00699 <span class="comment">// XXX/demmer make sure the scheme / ssp are comprised only of</span> <a name="l00700"></a>00700 <span class="comment">// legal URI characters</span> <a name="l00701"></a>00701 memcpy(&eid-><a class="code" href="structdtn__endpoint__id__t.html#d2e7d5788ae778c77b4041f1f8b1dc80">uri</a>[0], str, len); <a name="l00702"></a>00702 <a name="l00703"></a>00703 <span class="keywordflow">return</span> 0; <a name="l00704"></a>00704 } <a name="l00705"></a>00705 <a name="l00706"></a>00706 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00707"></a>00707 <span class="keywordtype">int</span> <a name="l00708"></a><a class="code" href="dtn__api_8h.html#21b6d705673aae970524972aca3db99f">00708</a> <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>(<a class="code" href="structdtn__bundle__payload__t.html">dtn_bundle_payload_t</a>* payload, <a name="l00709"></a>00709 <a class="code" href="dtn__types_8h.html#3dcfddc1b850a71a18d8a0868f67e762" title="The payload of a bundle can be sent or received either in a file, in which case the...">dtn_bundle_payload_location_t</a> location, <a name="l00710"></a>00710 <span class="keywordtype">char</span>* <a class="code" href="num2sdnv_8c.html#455b3605dc605fe8e055b9c1470535cf">val</a>, <span class="keywordtype">int</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>) <a name="l00711"></a>00711 { <a name="l00712"></a>00712 memset(payload, 0, <span class="keyword">sizeof</span>(<a class="code" href="structdtn__bundle__payload__t.html">dtn_bundle_payload_t</a>)); <a name="l00713"></a>00713 payload-><a class="code" href="structdtn__bundle__payload__t.html#4877c653f99a90c38ae8fdb4a1774247">location</a> = location; <a name="l00714"></a>00714 <a name="l00715"></a>00715 <span class="keywordflow">if</span> (location == <a class="code" href="dtn__types_8h.html#3dcfddc1b850a71a18d8a0868f67e7628f773bbfb80857bd5a11f09665fa9b03">DTN_PAYLOAD_MEM</a> && len > <a class="code" href="dtn__types_8h.html#35e670e5d1e8d12cc3c644b748fbef31">DTN_MAX_BUNDLE_MEM</a>) { <a name="l00716"></a>00716 <span class="keywordflow">return</span> <a class="code" href="dtn__errno_8h.html#dfbc45377fa7c17b849e79a015975a79">DTN_ESIZE</a>; <a name="l00717"></a>00717 } <a name="l00718"></a>00718 <a name="l00719"></a>00719 <span class="keywordflow">switch</span> (location) { <a name="l00720"></a>00720 <span class="keywordflow">case</span> <a class="code" href="dtn__types_8h.html#3dcfddc1b850a71a18d8a0868f67e7628f773bbfb80857bd5a11f09665fa9b03">DTN_PAYLOAD_MEM</a>: <a name="l00721"></a>00721 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> = val; <a name="l00722"></a>00722 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> = len; <a name="l00723"></a>00723 <span class="keywordflow">break</span>; <a name="l00724"></a>00724 <span class="keywordflow">case</span> <a class="code" href="dtn__types_8h.html#3dcfddc1b850a71a18d8a0868f67e7621ff9272291ffe7d9f8083e7c5a548909">DTN_PAYLOAD_FILE</a>: <a name="l00725"></a>00725 <span class="keywordflow">case</span> <a class="code" href="dtn__types_8h.html#3dcfddc1b850a71a18d8a0868f67e7621630b57529624e53a8f257763ad78503">DTN_PAYLOAD_TEMP_FILE</a>: <a name="l00726"></a>00726 payload-><a class="code" href="structdtn__bundle__payload__t.html#f3a33fd2ae2b3b8eae2e675f1a038cec">filename</a>.<a class="code" href="structdtn__bundle__payload__t.html#0d824d13c3225cb59fa2e34623608b2a">filename_val</a> = val; <a name="l00727"></a>00727 payload-><a class="code" href="structdtn__bundle__payload__t.html#f3a33fd2ae2b3b8eae2e675f1a038cec">filename</a>.<a class="code" href="structdtn__bundle__payload__t.html#19a9fb6ab21fdc57d29fbdb0e61d0bbf">filename_len</a> = len; <a name="l00728"></a>00728 <span class="keywordflow">break</span>; <a name="l00729"></a>00729 } <a name="l00730"></a>00730 <a name="l00731"></a>00731 <span class="keywordflow">return</span> 0; <a name="l00732"></a>00732 } <a name="l00733"></a>00733 <a name="l00734"></a>00734 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00735"></a>00735 <span class="keywordtype">void</span> <a name="l00736"></a><a class="code" href="dtn__api_8h.html#50a363bf1bf2803892afc1438ab62cff">00736</a> <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>(<a class="code" href="structdtn__bundle__payload__t.html">dtn_bundle_payload_t</a>* payload) <a name="l00737"></a>00737 { <a name="l00738"></a>00738 xdr_free((xdrproc_t)<a class="code" href="dtn__types_8h.html#52d9e9ef1e11bf39693baced9c591d67">xdr_dtn_bundle_payload_t</a>, (<span class="keywordtype">char</span>*)payload); <a name="l00739"></a>00739 } <a name="l00740"></a>00740 <a name="l00741"></a>00741 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00742"></a>00742 <span class="keyword">const</span> <span class="keywordtype">char</span>* <a name="l00743"></a><a class="code" href="dtn__api_8h.html#15b2dcc9b16beb1b91ead827b4ee2ca5">00743</a> <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>(<a class="code" href="dtn__types_8h.html#87e1a70c1e1b7872a0337ed40dc4f134" title="Bundle Status Report &quot;Reason Code&quot; flags.">dtn_status_report_reason_t</a> reason) <a name="l00744"></a>00744 { <a name="l00745"></a>00745 <span class="keywordflow">switch</span> (reason) { <a name="l00746"></a>00746 <span class="keywordflow">case</span> <a class="code" href="dtn__types_8h.html#87e1a70c1e1b7872a0337ed40dc4f13416d88f39c81b62a35f5450c470e084af">REASON_NO_ADDTL_INFO</a>: <a name="l00747"></a>00747 <span class="keywordflow">return</span> <span class="stringliteral">"no additional information"</span>; <a name="l00748"></a>00748 <a name="l00749"></a>00749 <span class="keywordflow">case</span> <a class="code" href="dtn__types_8h.html#87e1a70c1e1b7872a0337ed40dc4f13461e9a218d8a281765b19fc3ffea6e94d">REASON_LIFETIME_EXPIRED</a>: <a name="l00750"></a>00750 <span class="keywordflow">return</span> <span class="stringliteral">"lifetime expired"</span>; <a name="l00751"></a>00751 <a name="l00752"></a>00752 <span class="keywordflow">case</span> <a class="code" href="dtn__types_8h.html#87e1a70c1e1b7872a0337ed40dc4f134c10862557998c6bfa19d4fbdc0ac028d">REASON_FORWARDED_UNIDIR_LINK</a>: <a name="l00753"></a>00753 <span class="keywordflow">return</span> <span class="stringliteral">"forwarded over unidirectional link"</span>; <a name="l00754"></a>00754 <a name="l00755"></a>00755 <span class="keywordflow">case</span> <a class="code" href="dtn__types_8h.html#87e1a70c1e1b7872a0337ed40dc4f1346f4c44342c9b3dc134e6771aff9dfa19">REASON_TRANSMISSION_CANCELLED</a>: <a name="l00756"></a>00756 <span class="keywordflow">return</span> <span class="stringliteral">"transmission cancelled"</span>; <a name="l00757"></a>00757 <a name="l00758"></a>00758 <span class="keywordflow">case</span> <a class="code" href="dtn__types_8h.html#87e1a70c1e1b7872a0337ed40dc4f13431936ba86bf146b098f537d4c310b617">REASON_DEPLETED_STORAGE</a>: <a name="l00759"></a>00759 <span class="keywordflow">return</span> <span class="stringliteral">"depleted storage"</span>; <a name="l00760"></a>00760 <a name="l00761"></a>00761 <span class="keywordflow">case</span> <a class="code" href="dtn__types_8h.html#87e1a70c1e1b7872a0337ed40dc4f1349c4a7aa375534b9eee3fbfb97560bb57">REASON_ENDPOINT_ID_UNINTELLIGIBLE</a>: <a name="l00762"></a>00762 <span class="keywordflow">return</span> <span class="stringliteral">"endpoint id unintelligible"</span>; <a name="l00763"></a>00763 <a name="l00764"></a>00764 <span class="keywordflow">case</span> <a class="code" href="dtn__types_8h.html#87e1a70c1e1b7872a0337ed40dc4f1348b2ece31c413ace1fec226565ee0702a">REASON_NO_ROUTE_TO_DEST</a>: <a name="l00765"></a>00765 <span class="keywordflow">return</span> <span class="stringliteral">"no known route to destination"</span>; <a name="l00766"></a>00766 <a name="l00767"></a>00767 <span class="keywordflow">case</span> <a class="code" href="dtn__types_8h.html#87e1a70c1e1b7872a0337ed40dc4f1345f95c548ccf8376c8b3b80700046021d">REASON_NO_TIMELY_CONTACT</a>: <a name="l00768"></a>00768 <span class="keywordflow">return</span> <span class="stringliteral">"no timely contact"</span>; <a name="l00769"></a>00769 <a name="l00770"></a>00770 <span class="keywordflow">case</span> <a class="code" href="dtn__types_8h.html#87e1a70c1e1b7872a0337ed40dc4f134ee5e34172bb22be335def670d9e5503b">REASON_BLOCK_UNINTELLIGIBLE</a>: <a name="l00771"></a>00771 <span class="keywordflow">return</span> <span class="stringliteral">"block unintelligible"</span>; <a name="l00772"></a>00772 <a name="l00773"></a>00773 <span class="keywordflow">default</span>: <a name="l00774"></a>00774 <span class="keywordflow">return</span> <span class="stringliteral">"(unknown reason)"</span>; <a name="l00775"></a>00775 } <a name="l00776"></a>00776 } </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Mon Jul 21 14:09:39 2008 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.6 </small></address> </body> </html>