<!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: BundleCore.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.8 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>BundleCore.h</h1><a href="BundleCore_8h.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 2007 Baylor University</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">#ifndef _PROPHET_BUNDLE_CORE_FACADE_H_</span> <a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _PROPHET_BUNDLE_CORE_FACADE_H_</span> <a name="l00019"></a>00019 <span class="preprocessor"></span> <a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="Alarm_8h.html">Alarm.h</a>"</span> <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="servlib_2prophet_2Node_8h.html">Node.h</a>"</span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="prophet_2Bundle_8h.html">Bundle.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="BundleImpl_8h.html">BundleImpl.h</a>"</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="prophet_2BundleList_8h.html">BundleList.h</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="prophet_2Link_8h.html">Link.h</a>"</span> <a name="l00026"></a>00026 <a name="l00027"></a>00027 <span class="preprocessor">#include <stdarg.h></span> <a name="l00028"></a>00028 <span class="preprocessor">#include <string></span> <a name="l00029"></a>00029 <span class="preprocessor">#include <list></span> <a name="l00030"></a>00030 <a name="l00031"></a>00031 <span class="preprocessor">#if defined(__GNUC__)</span> <a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor"># define PRINTFLIKE(fmt, arg) __attribute__((format (printf, fmt, arg)))</span> <a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#else</span> <a name="l00034"></a><a class="code" href="BundleCore_8h.html#f2200d91c2af569b1e7c99405045640e">00034</a> <span class="preprocessor"></span><span class="preprocessor"># define PRINTFLIKE(a, b)</span> <a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00036"></a>00036 <span class="preprocessor"></span> <a name="l00037"></a>00037 <span class="keyword">namespace </span>prophet <a name="l00038"></a>00038 { <a name="l00039"></a>00039 <a name="l00048"></a><a class="code" href="classprophet_1_1BundleCore.html">00048</a> <span class="keyword">class </span><a class="code" href="classprophet_1_1BundleCore.html" title="Prophet facade&#39;s abstract interface into DTN host&#39;s bundle core.">BundleCore</a> <a name="l00049"></a>00049 { <a name="l00050"></a>00050 <span class="keyword">public</span>: <a name="l00051"></a>00051 <a name="l00055"></a><a class="code" href="classprophet_1_1BundleCore.html#097b224442dd5ad1a4913a96d47a5a44">00055</a> <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1BundleCore.html#097b224442dd5ad1a4913a96d47a5a44" title="Destructor.">~BundleCore</a>() {} <a name="l00056"></a>00056 <a name="l00060"></a>00060 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleCore.html#5e824264e8b32a0628c0f913f98641c5" title="Answers whether dest_id matches route.">is_route</a>(<span class="keyword">const</span> std::string& dest_id, <a name="l00061"></a>00061 <span class="keyword">const</span> std::string& route) <span class="keyword">const</span> = 0; <a name="l00062"></a>00062 <a name="l00066"></a>00066 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleCore.html#650956d33fee47c1248dc12d52eedaaf" title="Query the Bundle core for route status.">should_fwd</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* bundle, <a name="l00067"></a>00067 <span class="keyword">const</span> <a class="code" href="classprophet_1_1Link.html">Link</a>* link) <span class="keyword">const</span> = 0; <a name="l00068"></a>00068 <a name="l00072"></a>00072 <span class="keyword">virtual</span> std::string <a class="code" href="classprophet_1_1BundleCore.html#5ee789c3c5a49bbcb0624658e7f524c6" title="Given a Bundle&#39;s destination, return the route.">get_route</a>(<span class="keyword">const</span> std::string& dest_id) <span class="keyword">const</span> = 0; <a name="l00073"></a>00073 <a name="l00077"></a>00077 <span class="keyword">virtual</span> std::string <a class="code" href="classprophet_1_1BundleCore.html#815e1260c74a81dae5097a6a6b7a8490" title="Given a Bundle&#39;s destination, return the route pattern.">get_route_pattern</a>(<span class="keyword">const</span> std::string& dest_id) <span class="keyword">const</span> = 0; <a name="l00078"></a>00078 <a name="l00082"></a>00082 <span class="keyword">virtual</span> u_int64_t <a class="code" href="classprophet_1_1BundleCore.html#fada528d72ff3e773f0b65fef41d6e95" title="Callback method for Prophet to query storage_quota().">max_bundle_quota</a>() <span class="keyword">const</span> = 0; <a name="l00083"></a>00083 <a name="l00088"></a>00088 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleCore.html#ffd383db5ed0821c36856bc38b74a398" title="Callback method for Prophet to query whether Bundle host is willing to accept custody...">custody_accepted</a>() <span class="keyword">const</span> = 0; <a name="l00089"></a>00089 <a name="l00093"></a>00093 <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classprophet_1_1BundleList.html" title="List of Prophet&#39;s Bundle facade objects.">BundleList</a>& <a class="code" href="classprophet_1_1BundleCore.html#a156b55d2608ca3afabd0d8b2d6a6eed" title="Enumerate Bundles in host&#39;s store.">bundles</a>() <span class="keyword">const</span> = 0; <a name="l00094"></a>00094 <a name="l00099"></a>00099 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1BundleCore.html#f8fd7decf0b2a558bae75feb006dcc55" title="Callback method for Prophet to request for a bundle to be deleted; required by Repository&#39;s...">drop_bundle</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* bundle) = 0; <a name="l00100"></a>00100 <a name="l00104"></a>00104 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleCore.html#b70b98a3464dbe553705ac2d19d27e7c" title="Given a Bundle and a candidate Link, attempt to send a Bundle.">send_bundle</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* bundle, <a name="l00105"></a>00105 <span class="keyword">const</span> <a class="code" href="classprophet_1_1Link.html">Link</a>* link) = 0; <a name="l00106"></a>00106 <a name="l00113"></a>00113 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleCore.html#d49a3399ed8255db84ef114da4a9ce37" title="Transfer buffer into Bundle&#39;s payload.">write_bundle</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* bundle, <a name="l00114"></a>00114 <span class="keyword">const</span> u_char* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>, <a name="l00115"></a>00115 <span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>) = 0; <a name="l00116"></a>00116 <a name="l00125"></a>00125 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleCore.html#fe02f454860601b5d9f1823d8608f5ed" title="Request a Bundle&#39;s payload from Bundle host.">read_bundle</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* bundle, <a name="l00126"></a>00126 u_char* buffer, <a name="l00127"></a>00127 <span class="keywordtype">size_t</span>& <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>) <span class="keyword">const</span> = 0; <a name="l00128"></a>00128 <a name="l00135"></a>00135 <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* <a class="code" href="classprophet_1_1BundleCore.html#642382193c7db88ad80e13a7c6aec9de" title="Factory method to request new Bundle from bundle host.">create_bundle</a>(<span class="keyword">const</span> std::string& <a class="code" href="dtnmoteproxy_8c.html#e1ade0f5a1b32f6c8be72f31a99e2a18">src</a>, <a name="l00136"></a>00136 <span class="keyword">const</span> std::string& dst, <a name="l00137"></a>00137 u_int exp) = 0; <a name="l00138"></a>00138 <a name="l00143"></a>00143 <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* <a class="code" href="classprophet_1_1BundleCore.html#832e66fc3b84631e20e086e766ecd0a7" title="Given a BundleList, a route, a creation ts, and a sequence number, find the Bundle...">find</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1BundleList.html" title="List of Prophet&#39;s Bundle facade objects.">BundleList</a>& list, <span class="keyword">const</span> std::string& eid, <a name="l00144"></a>00144 u_int32_t creation_ts, u_int32_t seqno) <span class="keyword">const</span> = 0; <a name="l00145"></a>00145 <a name="l00149"></a>00149 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1BundleCore.html#9a18d0c8e3f692d4dd7cc81022177933" title="Update (or create) a persistent Node to reflect handle&#39;s info.">update_node</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* node) = 0; <a name="l00150"></a>00150 <a name="l00154"></a>00154 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1BundleCore.html#e799b610b984ebd900dcf1c0bb9e9afc" title="Remove this Node from persistent storage.">delete_node</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>* node) = 0; <a name="l00155"></a>00155 <a name="l00159"></a>00159 <span class="keyword">virtual</span> std::string <a class="code" href="classprophet_1_1BundleCore.html#6c838e6ee0d2b4fd4c069259786de5a5" title="Query the local endpoint ID.">local_eid</a>() <span class="keyword">const</span> = 0; <a name="l00160"></a>00160 <a name="l00165"></a>00165 <span class="keyword">virtual</span> std::string <a class="code" href="classprophet_1_1BundleCore.html#be11e2096b64c414ae1cc8bbe4e2edab" title="Query for the endpoint ID to the local Prophet instance.">prophet_id</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Link.html">Link</a>* link) <span class="keyword">const</span> = 0; <a name="l00166"></a>00166 <a name="l00170"></a>00170 <span class="keyword">virtual</span> std::string <a class="code" href="classprophet_1_1BundleCore.html#be11e2096b64c414ae1cc8bbe4e2edab" title="Query for the endpoint ID to the local Prophet instance.">prophet_id</a>() <span class="keyword">const</span> = 0; <a name="l00171"></a>00171 <a name="l00177"></a>00177 <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1Alarm.html" title="Alarm registration.">Alarm</a>* <a class="code" href="classprophet_1_1BundleCore.html#e3c7647861e87e6d3563231f3548c093" title="Factory method to allocate memory for and return pointer to new Alarm object that...">create_alarm</a>(<a class="code" href="classprophet_1_1ExpirationHandler.html" title="Alarm expiration handler.">ExpirationHandler</a>* handler, <a name="l00178"></a>00178 u_int timeout, <span class="keywordtype">bool</span> jitter = <span class="keyword">false</span>) = 0; <a name="l00179"></a>00179 <a name="l00181"></a><a class="code" href="classprophet_1_1BundleCore.html#494b3a7c2b761b5b79873ea016ab8cc8">00181</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classprophet_1_1BundleCore.html#494b3a7c2b761b5b79873ea016ab8cc8" title="Log level.">LOG_DEBUG</a> = 1; <a name="l00182"></a><a class="code" href="classprophet_1_1BundleCore.html#8dc0db4bcd5c66a3645483d1f965538e">00182</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classprophet_1_1BundleCore.html#8dc0db4bcd5c66a3645483d1f965538e" title="Log level.">LOG_INFO</a> = 2; <a name="l00183"></a><a class="code" href="classprophet_1_1BundleCore.html#a66c2439e291e2a9bd474c5bd3f148bd">00183</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classprophet_1_1BundleCore.html#a66c2439e291e2a9bd474c5bd3f148bd" title="Log level.">LOG_NOTICE</a> = 3; <a name="l00184"></a><a class="code" href="classprophet_1_1BundleCore.html#14d5632cd3bc4a67c13ee2a037ae389c">00184</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classprophet_1_1BundleCore.html#14d5632cd3bc4a67c13ee2a037ae389c" title="Log level.">LOG_WARN</a> = 4; <a name="l00185"></a><a class="code" href="classprophet_1_1BundleCore.html#93059ed93100c378c019b05d3adf5029">00185</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classprophet_1_1BundleCore.html#93059ed93100c378c019b05d3adf5029" title="Log level.">LOG_ERR</a> = 5; <a name="l00186"></a><a class="code" href="classprophet_1_1BundleCore.html#c14ce5abdaf56396aba6b0a2d378cf36">00186</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classprophet_1_1BundleCore.html#c14ce5abdaf56396aba6b0a2d378cf36" title="Log level.">LOG_CRIT</a> = 6; <a name="l00187"></a><a class="code" href="classprophet_1_1BundleCore.html#fdbc5c653fd620a81ffb9f31f6667c0e">00187</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classprophet_1_1BundleCore.html#fdbc5c653fd620a81ffb9f31f6667c0e" title="Log level.">LOG_ALWAYS</a> = 7; <a name="l00189"></a>00189 <a name="l00194"></a>00194 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1BundleCore.html#b5b505b3d20c6302ae818426cf27f35d" title="Defer implementation of logging to host system .">print_log</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">int</span> level, <span class="keyword">const</span> <span class="keywordtype">char</span>* fmt, ...) <a name="l00195"></a>00195 <a class="code" href="BundleCore_8h.html#f2200d91c2af569b1e7c99405045640e">PRINTFLIKE</a>(4,5) = 0; <a name="l00196"></a>00196 <a name="l00197"></a>00197 }; <span class="comment">// class BundleCore</span> <a name="l00198"></a>00198 <a name="l00202"></a><a class="code" href="classprophet_1_1AlarmImpl.html">00202</a> class <a class="code" href="classprophet_1_1AlarmImpl.html" title="Mock object for use in testing.">AlarmImpl</a> : public <a class="code" href="classprophet_1_1Alarm.html" title="Alarm registration.">Alarm</a> <a name="l00203"></a>00203 { <a name="l00204"></a>00204 <span class="keyword">public</span>: <a name="l00205"></a><a class="code" href="classprophet_1_1AlarmImpl.html#ade59086ac9c76e5dc6944da8ef1a645">00205</a> <a class="code" href="classprophet_1_1AlarmImpl.html" title="Mock object for use in testing.">AlarmImpl</a>(<a class="code" href="classprophet_1_1ExpirationHandler.html" title="Alarm expiration handler.">ExpirationHandler</a>* h) <a name="l00206"></a>00206 : Alarm(h), pending_(false), cancelled_(false) {} <a name="l00207"></a>00207 <a name="l00208"></a><a class="code" href="classprophet_1_1AlarmImpl.html#043f65b2e6722ed861303fcb6535ae92">00208</a> <span class="keyword">virtual</span> <a class="code" href="classprophet_1_1AlarmImpl.html#043f65b2e6722ed861303fcb6535ae92">~AlarmImpl</a>() {} <a name="l00209"></a>00209 <a name="l00210"></a><a class="code" href="classprophet_1_1AlarmImpl.html#c86500213de92091f72d5f35a9b35c82">00210</a> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1AlarmImpl.html#c86500213de92091f72d5f35a9b35c82" title="How many milliseconds in the future to schedule this alarm.">schedule</a>(u_int) { pending_ = <span class="keyword">true</span>; } <a name="l00211"></a><a class="code" href="classprophet_1_1AlarmImpl.html#ef9f3f3b8acd7154e06e6855dbe7a1fa">00211</a> u_int <a class="code" href="classprophet_1_1AlarmImpl.html#ef9f3f3b8acd7154e06e6855dbe7a1fa" title="Milliseconds remaining until alarm expires.">time_remaining</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 0; } <a name="l00212"></a><a class="code" href="classprophet_1_1AlarmImpl.html#2a94ed60883985747d3e6fec362bdb6c">00212</a> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1AlarmImpl.html#2a94ed60883985747d3e6fec362bdb6c" title="Disable the alarm; do not execute the handler.">cancel</a>() { cancelled_ = <span class="keyword">true</span>; } <a name="l00213"></a><a class="code" href="classprophet_1_1AlarmImpl.html#7b8cb7f5c70feda6849b8bc9be6ec510">00213</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1AlarmImpl.html#7b8cb7f5c70feda6849b8bc9be6ec510" title="Accessors.">pending</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> pending_; } <a name="l00214"></a><a class="code" href="classprophet_1_1AlarmImpl.html#830a40308b1fcb2696b44a89fcb7be93">00214</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1AlarmImpl.html#830a40308b1fcb2696b44a89fcb7be93" title="Accessors.">cancelled</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> cancelled_; } <a name="l00215"></a><a class="code" href="classprophet_1_1AlarmImpl.html#32f24b7f024973c48059b4876131bff1">00215</a> <span class="keywordtype">bool</span> pending_, cancelled_; <a name="l00216"></a>00216 }; <span class="comment">// class AlarmImpl</span> <a name="l00217"></a>00217 <a name="l00222"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html">00222</a> <span class="keyword">class </span><a class="code" href="classprophet_1_1BundleCoreTestImpl.html" title="Mock object for use in unit testing; this doesn&#39;t really do anything other than...">BundleCoreTestImpl</a> : <span class="keyword">public</span> <a class="code" href="classprophet_1_1BundleCore.html" title="Prophet facade&#39;s abstract interface into DTN host&#39;s bundle core.">BundleCore</a> <a name="l00223"></a>00223 { <a name="l00224"></a>00224 <span class="keyword">public</span>: <a name="l00225"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#ca8c10cc7c45ae5108791a5d17ee9bb7">00225</a> <span class="keyword">typedef</span> std::string BundleBuffer; <a name="l00226"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#f592c9634f4b85b6f878e6e165993612">00226</a> <a class="code" href="classprophet_1_1BundleCoreTestImpl.html" title="Mock object for use in unit testing; this doesn&#39;t really do anything other than...">BundleCoreTestImpl</a>(<span class="keyword">const</span> std::string& str = <span class="stringliteral">"dtn://somehost"</span>) <a name="l00227"></a>00227 : str_(str), max_(0xffff) {} <a name="l00228"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#aaf02e47d3fd73ebad82360caa076fc8">00228</a> <span class="keyword">virtual</span> ~<a class="code" href="classprophet_1_1BundleCoreTestImpl.html" title="Mock object for use in unit testing; this doesn&#39;t really do anything other than...">BundleCoreTestImpl</a>() <a name="l00229"></a>00229 { <a name="l00230"></a>00230 <span class="keywordflow">while</span> (!alarms_.empty()) <a name="l00231"></a>00231 { <a name="l00232"></a>00232 <span class="keyword">delete</span> alarms_.front(); <a name="l00233"></a>00233 alarms_.pop_front(); <a name="l00234"></a>00234 } <a name="l00235"></a>00235 } <a name="l00237"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#36fb50a55469d088c223e0c9cd1959db">00237</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleCore.html#5e824264e8b32a0628c0f913f98641c5" title="Answers whether dest_id matches route.">is_route</a>(<span class="keyword">const</span> std::string& dest,<span class="keyword">const</span> std::string& route)<span class="keyword"> const</span> <a name="l00238"></a>00238 <span class="keyword"> </span>{ <a name="l00239"></a>00239 <span class="keywordflow">if</span> (route.length() > dest.length()) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00240"></a>00240 <span class="keywordflow">return</span> route.compare(0,route.length(),dest) == 0; <a name="l00241"></a>00241 } <a name="l00242"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#c1f88ebc5929179d04fe08cd5f2f02b2">00242</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleCoreTestImpl.html#c1f88ebc5929179d04fe08cd5f2f02b2" title="virtual from BundleCore">should_fwd</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>*,<span class="keyword">const</span> <a class="code" href="classprophet_1_1Link.html">Link</a>*)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">true</span>; } <a name="l00243"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#813d77f4af7f59d4eec153ecd5896002">00243</a> std::string <a class="code" href="classprophet_1_1BundleCoreTestImpl.html#813d77f4af7f59d4eec153ecd5896002" title="virtual from BundleCore">get_route</a>(<span class="keyword">const</span> std::string& str )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> str; } <a name="l00244"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#b2653ab7d4a230a59dd32d142c1cd048">00244</a> std::string <a class="code" href="classprophet_1_1BundleCoreTestImpl.html#b2653ab7d4a230a59dd32d142c1cd048" title="virtual from BundleCore">get_route_pattern</a>(<span class="keyword">const</span> std::string& str )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> str + <span class="stringliteral">"/*"</span>; } <a name="l00245"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#849e4ff47c3e591d807a3c9a233d075f">00245</a> u_int64_t <a class="code" href="classprophet_1_1BundleCoreTestImpl.html#849e4ff47c3e591d807a3c9a233d075f" title="virtual from BundleCore">max_bundle_quota</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> max_; } <a name="l00246"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#8da6b9cd62aa539e3a3b08b11e19c721">00246</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleCoreTestImpl.html#8da6b9cd62aa539e3a3b08b11e19c721" title="virtual from BundleCore">custody_accepted</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">true</span>; } <a name="l00247"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#67a5fe8f2b6c7df6420c50a11e329764">00247</a> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1BundleCore.html#f8fd7decf0b2a558bae75feb006dcc55" title="Callback method for Prophet to request for a bundle to be deleted; required by Repository&#39;s...">drop_bundle</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* b) <a name="l00248"></a>00248 { <a name="l00249"></a>00249 <span class="keywordflow">for</span> (std::list<bundle>::iterator i = rcvd_.begin(); <a name="l00250"></a>00250 i != rcvd_.end(); i++) <a name="l00251"></a>00251 { <a name="l00252"></a>00252 <span class="keywordflow">if</span> (b-><a class="code" href="classprophet_1_1Bundle.html#81f0a95589809a157829bacb4d3c5989" title="Accessors.">destination_id</a>() == (*i).first->destination_id() && <a name="l00253"></a>00253 b-><a class="code" href="classprophet_1_1Bundle.html#df5ff9aa8aba7ddd7a741d6143fe3d88" title="Accessors.">creation_ts</a>() == (*i).first->creation_ts() && <a name="l00254"></a>00254 b-><a class="code" href="classprophet_1_1Bundle.html#8f4fad2c83696237207ba7a19acb9ca4" title="Accessors.">sequence_num</a>() == (*i).first->sequence_num()) <a name="l00255"></a>00255 { <a name="l00256"></a>00256 rcvd_.erase(i); <a name="l00257"></a>00257 <span class="keywordflow">break</span>; <a name="l00258"></a>00258 } <a name="l00259"></a>00259 } <a name="l00260"></a>00260 } <a name="l00261"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#db480cf167caa39713c260c0e338fef4">00261</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleCore.html#b70b98a3464dbe553705ac2d19d27e7c" title="Given a Bundle and a candidate Link, attempt to send a Bundle.">send_bundle</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* b,<span class="keyword">const</span> <a class="code" href="classprophet_1_1Link.html">Link</a>*) <a name="l00262"></a>00262 { <a name="l00263"></a>00263 sent_.push_back(b); <a name="l00264"></a>00264 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00265"></a>00265 } <a name="l00266"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#ff98dc2c96bdd8d51554fdb108be3711">00266</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleCore.html#d49a3399ed8255db84ef114da4a9ce37" title="Transfer buffer into Bundle&#39;s payload.">write_bundle</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* b,<span class="keyword">const</span> u_char* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>,<span class="keywordtype">size_t</span> <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>) <a name="l00267"></a>00267 { <a name="l00268"></a>00268 BundleBuffer bunbuf((<span class="keywordtype">char</span>*)buf,len); <a name="l00269"></a>00269 written_.push_back(std::make_pair<const Bundle*,BundleBuffer>(b,bunbuf)); <a name="l00270"></a>00270 <span class="keywordflow">return</span> written_.back().second.size() <= len; <a name="l00271"></a>00271 } <a name="l00272"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#28081fde0b0be4348edc2f13db7c5280">00272</a> <span class="keywordtype">bool</span> <a class="code" href="classprophet_1_1BundleCore.html#fe02f454860601b5d9f1823d8608f5ed" title="Request a Bundle&#39;s payload from Bundle host.">read_bundle</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* b,u_char* <a class="code" href="num2sdnv_8c.html#a81cdcc7ff6987bc85c073253e32715f">buf</a>,<span class="keywordtype">size_t</span>& <a class="code" href="num2sdnv_8c.html#fed088663f8704004425cdae2120b9b3">len</a>)<span class="keyword"> const</span> <a name="l00273"></a>00273 <span class="keyword"> </span>{ <a name="l00274"></a>00274 <span class="keywordflow">for</span> (std::list<bundle>::const_iterator i = rcvd_.begin(); <a name="l00275"></a>00275 i != rcvd_.end(); i++) <a name="l00276"></a>00276 { <a name="l00277"></a>00277 <span class="keywordflow">if</span> (b-><a class="code" href="classprophet_1_1Bundle.html#81f0a95589809a157829bacb4d3c5989" title="Accessors.">destination_id</a>() == (*i).first->destination_id() && <a name="l00278"></a>00278 b-><a class="code" href="classprophet_1_1Bundle.html#df5ff9aa8aba7ddd7a741d6143fe3d88" title="Accessors.">creation_ts</a>() == (*i).first->creation_ts() && <a name="l00279"></a>00279 b-><a class="code" href="classprophet_1_1Bundle.html#8f4fad2c83696237207ba7a19acb9ca4" title="Accessors.">sequence_num</a>() == (*i).first->sequence_num()) <a name="l00280"></a>00280 { <a name="l00281"></a>00281 <span class="keywordtype">size_t</span> blen = (*i).second.size(); <a name="l00282"></a>00282 <span class="keywordflow">if</span> (blen < len) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00283"></a>00283 len = blen; <a name="l00284"></a>00284 memcpy(buf,(*i).second.data(),len); <a name="l00285"></a>00285 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00286"></a>00286 } <a name="l00287"></a>00287 } <a name="l00288"></a>00288 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00289"></a>00289 } <a name="l00290"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#2757539f7652d15192cfb02e41683795">00290</a> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* <a class="code" href="classprophet_1_1BundleCore.html#642382193c7db88ad80e13a7c6aec9de" title="Factory method to request new Bundle from bundle host.">create_bundle</a>(<span class="keyword">const</span> std::string& <a class="code" href="dtnmoteproxy_8c.html#e1ade0f5a1b32f6c8be72f31a99e2a18">src</a>, <span class="keyword">const</span> std::string& dst,u_int exp=3600) <a name="l00291"></a>00291 { <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classprophet_1_1BundleImpl.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">BundleImpl</a>(src,dst,0,0,exp); } <a name="l00292"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#1fa48f495ad79af86831bd4645011865">00292</a> <span class="keyword">const</span> <a class="code" href="classprophet_1_1Bundle.html" title="Facade interface between Prophet router and host implmentation&#39;s Bundle representation...">Bundle</a>* <a class="code" href="classprophet_1_1BundleCore.html#832e66fc3b84631e20e086e766ecd0a7" title="Given a BundleList, a route, a creation ts, and a sequence number, find the Bundle...">find</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1BundleList.html" title="List of Prophet&#39;s Bundle facade objects.">BundleList</a>&,<span class="keyword">const</span> std::string&,u_int32_t, <a name="l00293"></a>00293 u_int32_t)<span class="keyword"> const</span> <a name="l00294"></a>00294 <span class="keyword"> </span>{ <span class="keywordflow">return</span> NULL; } <a name="l00295"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#708f677b31c0016f84c0dbd68f4ea4dd">00295</a> <span class="keyword">const</span> <a class="code" href="classprophet_1_1BundleList.html" title="List of Prophet&#39;s Bundle facade objects.">BundleList</a>& <a class="code" href="classprophet_1_1BundleCoreTestImpl.html#708f677b31c0016f84c0dbd68f4ea4dd" title="virtual from BundleCore">bundles</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> list_; } <a name="l00296"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#344d8427ecc8717507c1bd18373f9b06">00296</a> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1BundleCoreTestImpl.html#344d8427ecc8717507c1bd18373f9b06" title="virtual from BundleCore">update_node</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>*) {} <a name="l00297"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#d62f1bfcb1636e09cc00fcc4afbba00f">00297</a> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1BundleCoreTestImpl.html#d62f1bfcb1636e09cc00fcc4afbba00f" title="virtual from BundleCore">delete_node</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Node.html" title="Node represents a route to another Prophet node, and as such, tracks destination...">Node</a>*) {} <a name="l00298"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#83883585ab8f644eab630539dcf1fbc0">00298</a> std::string <a class="code" href="classprophet_1_1BundleCoreTestImpl.html#83883585ab8f644eab630539dcf1fbc0" title="virtual from BundleCore">local_eid</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> str_; } <a name="l00299"></a><a class="code" href="BundleCore_8h.html#869ca666cb685078655755b4adf82776">00299</a> <span class="preprocessor">#define PROPHESY(_str) do { \</span> <a name="l00300"></a>00300 <span class="preprocessor"> size_t pos = _str.size() - 1; \</span> <a name="l00301"></a>00301 <span class="preprocessor"> if (_str[pos] == '/') \</span> <a name="l00302"></a>00302 <span class="preprocessor"> _str += "prophet"; \</span> <a name="l00303"></a>00303 <span class="preprocessor"> else \</span> <a name="l00304"></a>00304 <span class="preprocessor"> _str += "/prophet"; \</span> <a name="l00305"></a>00305 <span class="preprocessor"> } while (0)</span> <a name="l00306"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#221800394f0b3eeede0a06a305c15855">00306</a> <span class="preprocessor"></span> std::string <a class="code" href="classprophet_1_1BundleCore.html#be11e2096b64c414ae1cc8bbe4e2edab" title="Query for the endpoint ID to the local Prophet instance.">prophet_id</a>(<span class="keyword">const</span> <a class="code" href="classprophet_1_1Link.html">Link</a>* link)<span class="keyword"> const</span> <a name="l00307"></a>00307 <span class="keyword"> </span>{ <a name="l00308"></a>00308 remote_.assign(link-><a class="code" href="classprophet_1_1Link.html#0631513a99a2b44d821161512fdabfe2" title="Accessors.">nexthop</a>()); <a name="l00309"></a>00309 <a class="code" href="BundleCore_8h.html#869ca666cb685078655755b4adf82776">PROPHESY</a>(remote_); <a name="l00310"></a>00310 <span class="keywordflow">return</span> remote_; <a name="l00311"></a>00311 } <a name="l00312"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#220967e9f1b214eaf354a864f517ad55">00312</a> std::string <a class="code" href="classprophet_1_1BundleCore.html#be11e2096b64c414ae1cc8bbe4e2edab" title="Query for the endpoint ID to the local Prophet instance.">prophet_id</a>()<span class="keyword"> const</span> <a name="l00313"></a>00313 <span class="keyword"> </span>{ <a name="l00314"></a>00314 <span class="keywordflow">if</span> (local_ == <span class="stringliteral">""</span>) <a name="l00315"></a>00315 { <a name="l00316"></a>00316 local_.assign(str_); <a name="l00317"></a>00317 <a class="code" href="BundleCore_8h.html#869ca666cb685078655755b4adf82776">PROPHESY</a>(local_); <a name="l00318"></a>00318 } <a name="l00319"></a>00319 <span class="keywordflow">return</span> local_; <a name="l00320"></a>00320 } <a name="l00321"></a>00321 <span class="preprocessor">#undef PROPHESY</span> <a name="l00322"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#b0b938ccb50f384873ae18336ab42a6a">00322</a> <span class="preprocessor"></span> <a class="code" href="classprophet_1_1Alarm.html" title="Alarm registration.">Alarm</a>* <a class="code" href="classprophet_1_1BundleCore.html#e3c7647861e87e6d3563231f3548c093" title="Factory method to allocate memory for and return pointer to new Alarm object that...">create_alarm</a>(<a class="code" href="classprophet_1_1ExpirationHandler.html" title="Alarm expiration handler.">ExpirationHandler</a>* handler, u_int timeout,<span class="keywordtype">bool</span>) <a name="l00323"></a>00323 { <a name="l00324"></a>00324 <a class="code" href="classprophet_1_1AlarmImpl.html" title="Mock object for use in testing.">AlarmImpl</a>* alarm = <span class="keyword">new</span> <a class="code" href="classprophet_1_1AlarmImpl.html" title="Mock object for use in testing.">AlarmImpl</a>(handler); <a name="l00325"></a>00325 alarm-><a class="code" href="classprophet_1_1AlarmImpl.html#c86500213de92091f72d5f35a9b35c82" title="How many milliseconds in the future to schedule this alarm.">schedule</a>(timeout); <a name="l00326"></a>00326 alarms_.push_back(alarm); <a name="l00327"></a>00327 <span class="keywordflow">return</span> alarm; <a name="l00328"></a>00328 } <a name="l00329"></a>00329 <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1BundleCore.html#b5b505b3d20c6302ae818426cf27f35d" title="Defer implementation of logging to host system .">print_log</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">int</span> level, <span class="keyword">const</span> <span class="keywordtype">char</span>* fmt, ...) <a name="l00330"></a>00330 <a class="code" href="BundleCore_8h.html#f2200d91c2af569b1e7c99405045640e">PRINTFLIKE</a>(4,5); <a name="l00331"></a>00331 <a name="l00333"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#324c642806bb69a72717e3ac1ab13b56">00333</a> <span class="keywordtype">void</span> set_max(u_int64_t max) { max_ = max; } <a name="l00334"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#77e9befd69bb0e55f65022d8664a9b8b">00334</a> <span class="keywordtype">void</span> <a class="code" href="classprophet_1_1BundleCoreTestImpl.html#77e9befd69bb0e55f65022d8664a9b8b">set_eid</a>(<span class="keyword">const</span> std::string& <span class="keywordtype">id</span>) { str_.assign(<span class="keywordtype">id</span>); } <a name="l00335"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#f67c32e440e2b0696f3c1f15edd91c46">00335</a> std::string str_; <a name="l00336"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#f342891084811a7c2e904728fd596612">00336</a> <span class="keyword">mutable</span> std::string local_, remote_; <a name="l00337"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#c72d48e547e5ab83f0f6473b9f85a186">00337</a> u_int64_t max_; <a name="l00338"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#17cf8144714df604bc86760d74e88aa6">00338</a> std::list<const Bundle*> sent_; <a name="l00339"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#475ebb3435f00af20ca8008d6dcbd2cf">00339</a> <span class="keyword">typedef</span> std::pair<const Bundle*,BundleBuffer> bundle; <a name="l00340"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#0a3e085968fab6d707af540f2f47ecfa">00340</a> std::list<bundle> written_; <a name="l00341"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#4d5f0e043d8b854dbc03f51f17523dfa">00341</a> std::list<bundle> rcvd_; <a name="l00342"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#19f9aaf4aafd7b67a30e29e9a828b063">00342</a> std::list<Alarm*> alarms_; <a name="l00343"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#093813dcaed78fed15623980fc904fc1">00343</a> <a class="code" href="classprophet_1_1BundleList.html" title="List of Prophet&#39;s Bundle facade objects.">prophet::BundleList</a> list_; <a name="l00344"></a>00344 }; <span class="comment">// class BundleCoreTestImpl</span> <a name="l00345"></a>00345 <a name="l00346"></a>00346 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a name="l00347"></a><a class="code" href="classprophet_1_1BundleCoreTestImpl.html#f3a09501640bcdce8b64d16220abe5dc">00347</a> <a class="code" href="classprophet_1_1BundleCore.html#b5b505b3d20c6302ae818426cf27f35d" title="Defer implementation of logging to host system .">BundleCoreTestImpl::print_log</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* name, <span class="keywordtype">int</span> level, <span class="keyword">const</span> <span class="keywordtype">char</span>* fmt, ...) <a name="l00348"></a>00348 { <a name="l00349"></a>00349 printf(<span class="stringliteral">"[%s][%d]\n"</span>,name,level); <a name="l00350"></a>00350 va_list ap; <a name="l00351"></a>00351 va_start(ap, fmt); <a name="l00352"></a>00352 vprintf(fmt, ap); <a name="l00353"></a>00353 va_end(ap); <a name="l00354"></a>00354 printf(<span class="stringliteral">"\n"</span>); <a name="l00355"></a>00355 } <a name="l00356"></a>00356 <a name="l00357"></a>00357 }; <span class="comment">// namespace prophet</span> <a name="l00358"></a>00358 <a name="l00359"></a>00359 <span class="preprocessor">#endif // _PROPHET_BUNDLE_CORE_FACADE_H_</span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:52 2009 for DTN Reference Implementation by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address> </body> </html>