Sophie

Sophie

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

libdtn-devel-2.6.0-2mdv2009.1.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>DTN Reference Implementation: TcaController.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&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>TcaController.h</h1><a href="TcaController_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 2005-2006 University of Waterloo</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 
<a name="l00018"></a>00018 <span class="comment">//#include &lt;stdio.h&gt;</span>
<a name="l00019"></a>00019 <span class="comment">//#include &lt;unistd.h&gt;</span>
<a name="l00020"></a>00020 <span class="comment">//#include &lt;errno.h&gt;</span>
<a name="l00021"></a>00021 <span class="comment">//#include &lt;strings.h&gt;</span>
<a name="l00022"></a>00022 <span class="comment">//#include &lt;stdlib.h&gt;</span>
<a name="l00023"></a>00023 <span class="comment">//#include &lt;sys/time.h&gt;</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00026"></a>00026 <span class="comment">//#include "dtn_api.h"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="apps_2tca__admin_2TcaEndpointID_8h.html">TcaEndpointID.h</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "../../servlib/routing/TcaControlBundle.h"</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="TcaRegistry_8h.html">TcaRegistry.h</a>"</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 
<a name="l00032"></a><a class="code" href="classTcaController.html">00032</a> <span class="keyword">class </span><a class="code" href="classTcaController.html">TcaController</a>
<a name="l00033"></a>00033 {
<a name="l00034"></a>00034 <span class="keyword">public</span>:
<a name="l00035"></a>00035 
<a name="l00036"></a><a class="code" href="classTcaController.html#6065b68cf7e913529a0351051211b7a8d0091d82b024466078fb44c6fe43785f">00036</a>     <span class="keyword">enum</span> <a class="code" href="classTcaController.html#6065b68cf7e913529a0351051211b7a8">Role</a> { <a class="code" href="classTcaController.html#6065b68cf7e913529a0351051211b7a8459c28598b31e7abed139354a852eb1e">TCA_MOBILE</a>, <a class="code" href="classTcaController.html#6065b68cf7e913529a0351051211b7a8d0091d82b024466078fb44c6fe43785f">TCA_ROUTER</a>, <a class="code" href="classTcaController.html#6065b68cf7e913529a0351051211b7a8bc4e9e3265e93fd4f9484c8f615672d3">TCA_GATEWAY</a> };
<a name="l00037"></a>00037         
<a name="l00038"></a>00038     <a class="code" href="classTcaController.html#bf3f7acd6d1845417b013c65cb13ceee">TcaController</a>(<a class="code" href="classTcaController.html#6065b68cf7e913529a0351051211b7a8">Role</a> <a class="code" href="tca__admin_8cc.html#61a55e29b77f88331554bca442ce7cd8">role</a>, <span class="keyword">const</span> std::string&amp; <a class="code" href="tca__admin_8cc.html#e26b9e69c0e6369f50ebaf8dceed7d7d">link_id</a>,
<a name="l00039"></a>00039                   <span class="keyword">const</span> std::string&amp; <a class="code" href="tca__admin_8cc.html#5983f9d6181f4bb1f4ba67adb3e9cf5c">ask_addr</a>, <span class="keyword">const</span> std::string&amp; adv_str,
<a name="l00040"></a>00040                   <span class="keywordtype">int</span> <a class="code" href="tca__admin_8cc.html#b4a945b027f5da413185040e54fca502">registry_ttl</a>, <span class="keywordtype">int</span> <a class="code" href="tca__admin_8cc.html#2f2aa12f5485607ff7a108bb619f3340">control_ttl</a>);
<a name="l00041"></a>00041 
<a name="l00042"></a>00042     <span class="keyword">virtual</span> <a class="code" href="classTcaController.html#f74afd5d1080ed3bbb235e8e40dadfda">~TcaController</a>();
<a name="l00043"></a>00043 
<a name="l00044"></a>00044     <span class="comment">// open dtn, initialize class members</span>
<a name="l00045"></a>00045     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#25e94a9aa364d764abc3081899ccc68a">init</a>(<span class="keywordtype">bool</span> <a class="code" href="tca__admin_8cc.html#04b41ab4fff58f9fe3e097839f18b5d5">tidy</a>);   
<a name="l00046"></a>00046 
<a name="l00047"></a>00047     <span class="comment">// process incoming bundles</span>
<a name="l00048"></a>00048     <span class="keywordtype">void</span> <a class="code" href="classTcaController.html#673694fa6d554a187086d0b88df007ed">run</a>();
<a name="l00049"></a>00049 
<a name="l00050"></a>00050     <span class="comment">// low-level send/recv functions</span>
<a name="l00051"></a>00051     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#c0c07b7427bb190871fc75b357601c7b">send_bundle</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec, <span class="keyword">const</span> std::string&amp; payload);
<a name="l00052"></a>00052     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#ef574d237daad310d9e9fb0eed5c36eb">recv_bundle</a>(<a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec, std::string&amp; payload,
<a name="l00053"></a>00053                      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> timeout=0);
<a name="l00054"></a>00054 
<a name="l00055"></a>00055     <span class="comment">// a more convenient send, using reasonable defaults for most args</span>
<a name="l00056"></a>00056     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#c0c07b7427bb190871fc75b357601c7b">send_bundle</a>(<span class="keyword">const</span> std::string&amp; dest, <span class="keyword">const</span> std::string&amp; payload);
<a name="l00057"></a>00057 
<a name="l00058"></a>00058 <span class="keyword">protected</span>:
<a name="l00059"></a>00059     
<a name="l00060"></a><a class="code" href="classTcaController.html#5fe13558c0fd6b677ea3351c7db7c7a9">00060</a>     <a class="code" href="classTcaController.html#6065b68cf7e913529a0351051211b7a8">Role</a>                    <a class="code" href="classTcaController.html#5fe13558c0fd6b677ea3351c7db7c7a9">role_</a>;
<a name="l00061"></a><a class="code" href="classTcaController.html#168a2e93061fa90c4281b379a4256895">00061</a>     std::string             <a class="code" href="classTcaController.html#168a2e93061fa90c4281b379a4256895">link_id_</a>;
<a name="l00062"></a><a class="code" href="classTcaController.html#b9de59674cd29facb48c60c60f999e1c">00062</a>     std::string             <a class="code" href="classTcaController.html#b9de59674cd29facb48c60c60f999e1c">ask_addr_</a>;      <span class="comment">// address to send ask to</span>
<a name="l00063"></a><a class="code" href="classTcaController.html#3a9ffabeafd696557c5df5daaaf8eb2d">00063</a>     std::string             <a class="code" href="classTcaController.html#3a9ffabeafd696557c5df5daaaf8eb2d">adv_str_</a>;
<a name="l00064"></a><a class="code" href="classTcaController.html#700c1a4b636290ad2e1fd4aa9d725be3">00064</a>     <span class="keywordtype">int</span>                     <a class="code" href="classTcaController.html#700c1a4b636290ad2e1fd4aa9d725be3">registry_ttl_</a>;
<a name="l00065"></a><a class="code" href="classTcaController.html#a4a97611ac28e1ae6f235ff12118bda2">00065</a>     <span class="keywordtype">int</span>                     <a class="code" href="classTcaController.html#a4a97611ac28e1ae6f235ff12118bda2">control_ttl_</a>;
<a name="l00066"></a>00066 
<a name="l00067"></a><a class="code" href="classTcaController.html#675bc13bb46386a123747e8ef9758c11">00067</a>     <a class="code" href="classTcaRegistry.html">TcaRegistry</a>             <a class="code" href="classTcaController.html#675bc13bb46386a123747e8ef9758c11">registry_</a>;      <span class="comment">// the DHT registry (gateway only)</span>
<a name="l00068"></a><a class="code" href="classTcaController.html#92d3ca7aa6abe45823166f5286cdb74b">00068</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="classTcaController.html#92d3ca7aa6abe45823166f5286cdb74b">handle_</a>;
<a name="l00069"></a><a class="code" href="classTcaController.html#7cf3bdaa873e2f9364e2d8ae494917b0">00069</a>     <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="classTcaController.html#7cf3bdaa873e2f9364e2d8ae494917b0">local_eid_</a>;
<a name="l00070"></a>00070 
<a name="l00071"></a>00071     <span class="comment">// register an endpoint id with the daemon and bind it to handle_</span>
<a name="l00072"></a>00072     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#8880346db628c5dd35ce3d34a790af2a">dtn_reg</a>(<a class="code" href="structdtn__endpoint__id__t.html" title="Specification of a dtn endpoint id, i.e.">dtn_endpoint_id_t</a>&amp; eid, <a class="code" href="dtn__types_8h.html#d9378ff6ab7ee699568e037a8105f9b6" title="A registration cookie.">dtn_reg_id_t</a>&amp; <span class="keywordtype">id</span>);
<a name="l00073"></a>00073 
<a name="l00074"></a>00074     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#10d65a95cd5c4de5873d84c499392df9">handle_bundle_received</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec,
<a name="l00075"></a>00075                                 <span class="keyword">const</span> std::string&amp; payload);
<a name="l00076"></a>00076 
<a name="l00077"></a>00077     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#c835008a5810c703982509da5c464a1a">handle_reg_received</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec,
<a name="l00078"></a>00078                              <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">dtn::TcaControlBundle</a>&amp; cb);
<a name="l00079"></a>00079     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#6c86674cf475cc7ec769a876a047590f">route_reg</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">dtn::TcaControlBundle</a>&amp; cb);
<a name="l00080"></a>00080     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#13fe5dee57c765a0c33a12f17bbe9e15">gate_reg</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">dtn::TcaControlBundle</a>&amp; cb);
<a name="l00081"></a>00081 
<a name="l00082"></a>00082     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#3eea197644db5cbf669075065872e357">handle_unb</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">dtn::TcaControlBundle</a>&amp; cb);
<a name="l00083"></a>00083 
<a name="l00084"></a>00084     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#aca6de8af48b6b6e8c04296ee9687a54">handle_coa_sent</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec,
<a name="l00085"></a>00085                          <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">dtn::TcaControlBundle</a>&amp; cb);
<a name="l00086"></a>00086 
<a name="l00087"></a>00087     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#d2028ffc6742625ab9148b59dbe50ac7">handle_link_announce</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec,
<a name="l00088"></a>00088                               <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">dtn::TcaControlBundle</a>&amp; cb);
<a name="l00089"></a>00089 
<a name="l00090"></a>00090     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#7975eedcd985c76937e963a2ec822f43">handle_ask</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">dtn::TcaControlBundle</a>&amp; cb);
<a name="l00091"></a>00091 
<a name="l00092"></a>00092     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#4d1fb0d176f54ca19c175dc312817b2f">handle_ask_received</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec,
<a name="l00093"></a>00093                              <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">dtn::TcaControlBundle</a>&amp; cb);
<a name="l00094"></a>00094 
<a name="l00095"></a>00095     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#b342df9e3f1c8a6f787254906166bdd3">handle_ask_sent</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec,
<a name="l00096"></a>00096                          <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">dtn::TcaControlBundle</a>&amp; cb);
<a name="l00097"></a>00097 
<a name="l00098"></a>00098     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#0fc2190e80788f924c5c6e7519ddda79">handle_adv</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec, <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">dtn::TcaControlBundle</a>&amp; cb);
<a name="l00099"></a>00099 
<a name="l00100"></a>00100     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#70ed743c435d74184891b2138c22f35c">handle_adv_sent</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec,
<a name="l00101"></a>00101                          <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">dtn::TcaControlBundle</a>&amp; cb);
<a name="l00102"></a>00102 
<a name="l00103"></a>00103     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#8ac49d6419bb7a13964e14849c20e168">handle_routes</a>(<span class="keyword">const</span> <a class="code" href="structdtn__bundle__spec__t.html" title="Bundle metadata.">dtn_bundle_spec_t</a>&amp; spec,
<a name="l00104"></a>00104                        <span class="keyword">const</span> <a class="code" href="classdtn_1_1TcaControlBundle.html">dtn::TcaControlBundle</a>&amp; cb);
<a name="l00105"></a>00105 
<a name="l00106"></a>00106     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#aa71a7f87d04fa4882a822784095d7c2">ask</a>(<span class="keyword">const</span> std::string&amp; link);  <span class="comment">// experimental</span>
<a name="l00107"></a>00107     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#83f104f544ae9e0ba8c1424cf1729f4f">get_routes</a>();
<a name="l00108"></a>00108     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#393c49f6b040129a5ef2527cd31451c7">add_route</a>(<span class="keyword">const</span> std::string&amp; route_pattern, <span class="keyword">const</span> std::string&amp; link);
<a name="l00109"></a>00109     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#6976d25ddb8ce95d0266c38ae71291c6">del_route</a>(<span class="keyword">const</span> std::string&amp; route_pattern);
<a name="l00110"></a>00110 
<a name="l00111"></a>00111 
<a name="l00112"></a>00112     <span class="comment">// lookup existing registration info for the given endpoint</span>
<a name="l00113"></a>00113     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#a3f584822db3b5849279f5104bd0101b">get_registration</a>(<span class="keyword">const</span> <a class="code" href="classTcaEndpointID.html">TcaEndpointID</a>&amp; eid, <a class="code" href="classRegRecord.html">RegRecord</a>&amp; rr);
<a name="l00114"></a>00114 
<a name="l00115"></a>00115     <span class="comment">// update DHT registry for given endpoint</span>
<a name="l00116"></a>00116     <span class="comment">// link_addr is the link addr of the endpoint's new gateway</span>
<a name="l00117"></a>00117     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#6d4f7abe8827a35ed31af39d448de05a">do_registration</a>(<span class="keyword">const</span> <a class="code" href="classTcaEndpointID.html">TcaEndpointID</a>&amp; eid,
<a name="l00118"></a>00118                          <span class="keyword">const</span> std::string&amp; link_addr);
<a name="l00119"></a>00119 
<a name="l00120"></a>00120     <span class="comment">// Testing functions for various parts of the protocol</span>
<a name="l00121"></a>00121     <span class="comment">// These generally send a query bundle, get the response, and check</span>
<a name="l00122"></a>00122     <span class="comment">// that it's correct.</span>
<a name="l00123"></a>00123 
<a name="l00124"></a>00124     <span class="keywordtype">bool</span> <a class="code" href="classTcaController.html#c4aa87a351f76bcf94df135e8a0ac8c4">test_all</a>();
<a name="l00125"></a>00125     
<a name="l00126"></a>00126     <span class="comment">// recv and discard all pending bundles</span>
<a name="l00127"></a>00127     <span class="keywordtype">void</span> <a class="code" href="classTcaController.html#76c47ed1b44f6520c02aa75c23818ddb">eat_bundles</a>(<span class="keywordtype">bool</span> <a class="code" href="dtncat_8c.html#0b2caeb4b6f130be43e5a2f0267dd453">verbose</a> = <span class="keyword">true</span>);
<a name="l00128"></a>00128 };
<a name="l00129"></a>00129 
<a name="l00130"></a>00130 
<a name="l00131"></a>00131 
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:58 2009 for DTN Reference Implementation by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>