00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifdef HAVE_CONFIG_H
00018 # include <dtn-config.h>
00019 #endif
00020
00021 #include "conv_layers/ConvergenceLayer.h"
00022 #include "bundling/BundleActions.h"
00023 #include "contacts/ContactManager.h"
00024 #include "bundling/BundleDaemon.h"
00025 #include "routing/RouteTable.h"
00026 #include <oasys/io/NetUtils.h>
00027 #include "contacts/InterfaceTable.h"
00028 #include "conv_layers/TCPConvergenceLayer.h"
00029
00030 #include "TcaRouter.h"
00031
00032 namespace dtn {
00033
00034
00035
00036
00037
00038 static const std::string BL = "tca://localhost/bundlelayer";
00039
00040
00042
00043
00044
00045
00046
00047 static std::string
00048 get_payload_str(const Bundle* b)
00049 {
00050 size_t len = b->payload().length();
00051 u_char data[len+1];
00052 const u_char* p = b->payload().read_data(0, len, data);
00053 return (const char*)p;
00054 }
00055
00056
00057
00058 static bool
00059 check_nargs(const TcaControlBundle& cb, uint n_expected)
00060 {
00061 if (cb.args_.size() != n_expected)
00062 {
00063 log_err_p("dtn/tca", "TcaRouter: bundle '%s' contains wrong number "
00064 "of args. %d expected.", cb.str().c_str(), n_expected);
00065 return false;
00066 }
00067 return true;
00068 }
00069
00070
00071
00072 static void
00073 log_bundle(const std::string& comment, const Bundle* b, bool include_payload)
00074 {
00075 (void)comment;
00076 (void)b;
00077
00078 if (include_payload)
00079 log_debug_p("/dtn/tca", "%s [%s] -> [%s] : '%s'", comment.c_str(),
00080 b->source().str().c_str(), b->dest().c_str(),
00081 get_payload_str(b).c_str());
00082 else
00083 log_debug_p("/dtn/tca", "%s [%s] -> [%s]", comment.c_str(),
00084 b->source().str().c_str(), b->dest().c_str());
00085 }
00086
00087
00088 static void
00089 log_controlbundle(const TcaControlBundle& cb)
00090 {
00091 log_debug_p("/dtn/tca", " code='%s', args=%d",
00092 cb.code_.c_str(), (u_int)cb.args_.size());
00093 for (unsigned int i=0; i<cb.args_.size(); ++i)
00094 {
00095 log_debug_p("/dtn/tca", " '%s'", cb.args_[i].c_str());
00096 }
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00111
00112
00113 TcaRouter::TcaRouter(Role role)
00114 : TableBasedRouter("TcaRouter", "TcaRouter")
00115 {
00116 role_ = role;
00117
00118
00119 admin_app_ = BundleDaemon::instance()->local_eid();
00120 admin_app_.set_app("admin");
00121
00122 logpathf("/dtn/tca");
00123
00124 log_info("TcaRouter started: role='%s', admin_app='%s'",
00125 get_role_str().c_str(), admin_app_.c_str());
00126 }
00127
00128
00129 std::string
00130 TcaRouter::get_role_str() const
00131 {
00132 switch (role_)
00133 {
00134 case TCA_MOBILE: return "mobile";
00135 case TCA_ROUTER: return "router";
00136 case TCA_GATEWAY: return "gateway";
00137 default: return "null";
00138 }
00139
00140 }
00141
00142
00143 void
00144 TcaRouter::handle_bundle_received(BundleReceivedEvent* event)
00145 {
00146 Bundle* bundle = event->bundleref_.object();
00147
00148
00149
00150
00151
00152
00153
00154
00155 const EndpointID& dest = bundle->dest();
00156
00157 if (dest.scheme_str() == "tca")
00158 {
00159 log_bundle("TcaRouter: tca bundle received", bundle, true);
00160
00161 TcaEndpointID tca_dest(dest);
00162
00163 if (tca_dest.ssp() == "//registry")
00164 {
00165 handle_register(bundle);
00166 }
00167
00168 else if (tca_dest.app() == "admin.coa")
00169 {
00170 handle_coa(bundle);
00171 }
00172
00173 else if (tca_dest.ssp().substr(0,11) == "//anonymous")
00174 {
00175 handle_anonymous_bundle(bundle);
00176 }
00177
00178 else if (tca_dest.ssp() == "//localhost/bundlelayer")
00179 {
00180 handle_bl_control_bundle(bundle);
00181 }
00182
00183 else if (tca_dest.host() != admin_app_.host())
00184 {
00185
00186
00187
00188 handle_tca_unbound_bundle(bundle);
00189 }
00190 }
00191
00192 else
00193 {
00194
00195 fwd_to_matching(bundle);
00196 }
00197 }
00198
00199
00200 void
00201 TcaRouter::handle_bundle_transmitted(BundleTransmittedEvent* event)
00202 {
00203 Bundle* b = event->bundleref_.object();
00204 log_debug("TcaRouter: handle bundle transmitted: *%p", b);
00205
00206 const EndpointID& dest = b->dest();
00207
00208 if (dest.scheme_str() == "tca")
00209 {
00210
00211
00212
00213
00214
00215
00216
00217 TcaEndpointID tca_dest(dest);
00218 if (tca_dest.app() == "admin.coa")
00219 {
00220 TcaControlBundle cb(get_payload_str(b));
00221 on_coa_transmitted(b, cb);
00222 }
00223 else if (tca_dest.app() == "admin.ask")
00224 {
00225 TcaControlBundle cb(get_payload_str(b));
00226 on_ask_transmitted(b, cb);
00227 }
00228 else if (tca_dest.app() == "admin")
00229 {
00230 TcaControlBundle cb(get_payload_str(b));
00231 if (cb.code_ == "adv")
00232 {
00233 on_adv_transmitted(b, cb);
00234 }
00235 }
00236 }
00237 }
00238
00239
00240
00241
00242
00243 void
00244 TcaRouter::handle_contact_up(ContactUpEvent* event)
00245 {
00246 ASSERT(event->contact_->link() != NULL);
00247 ASSERT(!event->contact_->link()->isdeleted());
00248
00249
00250
00251 TableBasedRouter::handle_contact_up(event);
00252 log_debug("TcaRouter::contact up");
00253 post_bundle(BL, admin_app_, "contact_up");
00254 }
00255
00256
00257 void
00258 TcaRouter::handle_contact_down(ContactDownEvent* event)
00259 {
00260 (void)event;
00261 log_debug("TcaRouter::contact down");
00262 post_bundle(BL, admin_app_, "contact_down");
00263
00264 }
00265
00266
00267 void
00268 TcaRouter::handle_link_available(LinkAvailableEvent* event)
00269 {
00270 ASSERT(event->link_ != NULL);
00271 ASSERT(!event->link_->isdeleted());
00272
00273
00274
00275 TableBasedRouter::handle_link_available(event);
00276 log_debug("TcaRouter::link available");
00277 post_bundle(BL, admin_app_, "link_available");
00278 }
00279
00280
00281 void
00282 TcaRouter::handle_link_unavailable(LinkUnavailableEvent* event)
00283 {
00284 (void)event;
00285 log_debug("TcaRouter::link unavailable");
00286 post_bundle(BL, admin_app_, "link_unavailable");
00287 }
00288
00289
00290 void
00291 TcaRouter::handle_shutdown_request(ShutdownRequest* event)
00292 {
00293 (void)event;
00294 log_debug("TcaRouter::daemon shutdown");
00295 post_bundle(BL, admin_app_, "daemon_shutdown");
00296 }
00297
00298
00299
00300
00301
00302 int
00303 TcaRouter::fwd_to_all(Bundle* bundle)
00304 {
00305 RouteEntryVec matches;
00306 RouteEntryVec::iterator iter;
00307
00308 std::string pattern = "tca://*";
00309 EndpointID tca_all = pattern;
00310
00311 route_table_->get_matching(tca_all, &matches);
00312
00313 int count = 0;
00314 for (iter = matches.begin(); iter != matches.end(); ++iter)
00315 {
00316 log_debug("TcaRouter::fwd_to_all: %s",
00317 (*iter)->dest_pattern().str().c_str());
00318 fwd_to_nexthop(bundle, *iter);
00319 ++count;
00320 }
00321
00322 log_debug("TcaRouter::fwd_to_all dest='%s': %d matches",
00323 bundle->dest().c_str(), count);
00324 return count;
00325 }
00326
00327
00328
00329
00330
00331
00332
00333 int
00334 TcaRouter::fwd_to_matching(Bundle* bundle, const LinkRef& next_hop)
00335 {
00336 ForwardingRule fwd_rule = get_forwarding_rule(bundle);
00337 return fwd_to_matching_r(bundle, next_hop, fwd_rule);
00338 }
00339
00340
00341
00342
00343
00344
00345 int
00346 TcaRouter::fwd_to_matching_r(Bundle* bundle, const LinkRef& next_hop,
00347 ForwardingRule fwd_rule)
00348 {
00349 log_debug("TcaRouter::fwd_to_matching_r: owner='%s'",
00350 bundle->owner().c_str());
00351 log_debug("TcaRouter::fwd_to_matching_r: fwd_rule=%d", fwd_rule);
00352
00353 if (fwd_rule == FWD_NEVER) return 0;
00354
00355 RouteEntryVec matches;
00356 RouteEntryVec::iterator iter;
00357
00358 route_table_->get_matching(bundle->dest(), &matches);
00359
00360
00361 RouteEntry* default_route = NULL;
00362 RouteEntryVec hard_matches;
00363 for (iter = matches.begin(); iter != matches.end(); ++iter)
00364 {
00365 if ((*iter)->dest_pattern().str() == "tca://*")
00366 {
00367 default_route = *iter;
00368 }
00369 else
00370 {
00371 hard_matches.push_back(*iter);
00372 }
00373 }
00374
00375 if (fwd_rule == FWD_UDR_EXCLUSIVELY)
00376 {
00377 if (default_route != NULL)
00378 {
00379 fwd_to_nexthop(bundle, default_route);
00380 return 1;
00381 }
00382 }
00383
00384 int count = 0;
00385
00386
00387 if (fwd_rule == FWD_UDR_ALWAYS ||
00388 (fwd_rule == FWD_UDR_IFNECESSARY && hard_matches.size() == 0))
00389 {
00390 if (default_route != NULL)
00391 {
00392 fwd_to_nexthop(bundle, default_route);
00393 ++ count;
00394 }
00395 }
00396
00397
00398 for (iter = hard_matches.begin(); iter != hard_matches.end(); ++iter)
00399 {
00400 if (next_hop == NULL || (next_hop == (*iter)->link()))
00401 {
00402 fwd_to_nexthop(bundle, *iter);
00403 ++count;
00404 }
00405 else
00406 {
00407 log_debug("fwd_to_matching_r dest='%s': "
00408 "ignoring match %s since next_hop link %s set",
00409 bundle->dest().c_str(), (*iter)->link()->name(),
00410 next_hop->name());
00411 }
00412 }
00413
00414 log_debug("fwd_to_matching_r dest='%s': %d matches",
00415 bundle->dest().c_str(), count);
00416
00417 return count;
00418 }
00419
00420
00421 bool
00422 TcaRouter::on_coa_transmitted(Bundle* b, const TcaControlBundle& cb)
00423 {
00424 log_debug("TcaRouter: COA bundle transmitted");
00425
00426 TcaWrappedBundle wb(cb);
00427
00428 log_debug(" coa: source=%s, dest=%s",
00429 b->source().c_str(),
00430 b->dest().c_str());
00431
00432
00433 std::string coa_sent_payload = "coa_sent:";
00434 coa_sent_payload += b->source().str();
00435 coa_sent_payload += "\t";
00436 coa_sent_payload += b->dest().str();
00437 coa_sent_payload += "\t";
00438 coa_sent_payload += cb.args_[0];
00439
00440 log_debug(" coa_sent, payload='%s'", coa_sent_payload.c_str());
00441 post_bundle(BL, admin_app_, coa_sent_payload);
00442
00443 return true;
00444 }
00445
00446
00447 bool
00448 TcaRouter::on_ask_transmitted(Bundle* b, const TcaControlBundle& cb)
00449 {
00450 log_debug("TcaRouter: ASK bundle transmitted");
00451
00452 if (!check_nargs(cb, 1)) return false;
00453
00454
00455 std::string ask_sent= "ask_sent:";
00456 ask_sent += b->source().str();
00457 ask_sent += "\t";
00458 ask_sent += b->dest().str();
00459 ask_sent += "\t";
00460 ask_sent += cb.args_[0];
00461
00462 log_debug(" ask sent, payload='%s'", ask_sent.c_str());
00463 post_bundle(BL, admin_app_, ask_sent);
00464
00465 return false;
00466 }
00467
00468
00469 bool
00470 TcaRouter::on_adv_transmitted(Bundle* b, const TcaControlBundle& cb)
00471 {
00472 log_debug("TcaRouter: ADV bundle transmitted");
00473
00474 if (!check_nargs(cb, 2)) return false;
00475
00476
00477 std::string adv_sent= "adv_sent:";
00478 adv_sent += b->source().str();
00479 adv_sent += "\t";
00480 adv_sent += b->dest().str();
00481 adv_sent += "\t";
00482 adv_sent += cb.args_[0];
00483 adv_sent += "\t";
00484 adv_sent += cb.args_[1];
00485
00486 log_debug(" adv_sent, payload='%s'", adv_sent.c_str());
00487 post_bundle(BL, admin_app_, adv_sent);
00488
00489 return false;
00490 }
00491
00492
00493 bool
00494 TcaRouter::handle_register(Bundle* b)
00495 {
00496
00497
00498
00499
00500
00501 if (b->source().str() == admin_app_.str())
00502 {
00503
00504
00505 LinkRef link("TcaRouter::handle_register: fwd_to_matching null");
00506 fwd_to_matching_r(b, link, FWD_UDR_EXCLUSIVELY);
00507 }
00508 else
00509 {
00510
00511
00512
00513 TcaControlBundle cb(get_payload_str(b));
00514
00515 TcaWrappedBundle reg_received("reg_received",
00516 b->source().str(), b->dest().str());
00517
00518 log_debug("TcaRouter::handle_register:");
00519 log_controlbundle(cb);
00520
00521 if (cb.args_.size() == 2)
00522 {
00523
00524
00525 reg_received.append_arg(cb.args_[0]);
00526 reg_received.append_arg(cb.args_[1]);
00527 }
00528 else
00529 {
00530
00531
00532 reg_received.append_arg(b->source().str());
00533 reg_received.append_arg("NULL");
00534 }
00535
00536 post_bundle(BL, admin_app_, reg_received.str());
00537 }
00538
00539 return true;
00540 }
00541
00542
00543 bool
00544 TcaRouter::handle_coa(Bundle* b)
00545 {
00546 log_debug("TcaRouter: COA bundle received");
00547
00548
00549 LinkRef link("TcaRouter::handle_coa: fwd_to_matching null");
00550 fwd_to_matching_r(b, link, FWD_UDR_NEVER);
00551
00552
00553
00554 return true;
00555 }
00556
00557
00558 bool
00559 TcaRouter::handle_anonymous_bundle(Bundle* b)
00560 {
00561
00562
00563
00564
00565 TcaEndpointID dest(b->dest());
00566
00567 TcaControlBundle cb(get_payload_str(b));
00568
00569 if (cb.code_ == "ask")
00570 {
00571 return handle_ask(b, cb);
00572 }
00573 else
00574 {
00575 log_debug("TcaRouter:: unrecognized anonymous bundle code '%s'",
00576 cb.code_.c_str());
00577 return false;
00578 }
00579 }
00580
00581
00582 bool
00583 TcaRouter::handle_ask(Bundle* b, const TcaControlBundle& cb)
00584 {
00585 if (is_local_source(b))
00586 {
00587
00588
00589 LinkRef link("TcaRouter::handle_ask: fwd_to_matching null");
00590 fwd_to_matching_r(b, link, FWD_UDR_NEVER);
00591 }
00592 else
00593 {
00594 if (!check_nargs(cb, 1)) return false;
00595
00596
00597 std::string payload = "ask_received:";
00598 payload += b->source().str();
00599 payload += "\t";
00600 payload += b->dest().str();
00601 payload += "\t";
00602 payload += cb.args_[0];
00603
00604 post_bundle(BL, admin_app_, payload);
00605 }
00606
00607 return true;
00608 }
00609
00610
00611
00612
00613
00614
00615 bool
00616 TcaRouter::handle_bl_control_bundle(Bundle* b)
00617 {
00618 TcaControlBundle cb(get_payload_str(b));
00619
00620
00621 if (cb.code_ == "ask")
00622 {
00623 return handle_ask(b, cb);
00624 }
00625 else if (cb.code_ == "get_routes")
00626 {
00627 return handle_get_routes(b, cb);
00628 }
00629 else if (cb.code_ == "add_route")
00630 {
00631 return handle_add_route(b, cb);
00632 }
00633 else if (cb.code_ == "del_route")
00634 {
00635 return handle_del_route(b, cb);
00636 }
00637
00638 log_debug("TcaRouter: unknown control bundle type '%s'", cb.code_.c_str());
00639 return false;
00640
00641 }
00642
00643
00644 bool
00645 TcaRouter::handle_bl_ask(Bundle* b, const TcaControlBundle& cb)
00646 {
00647 (void)cb;
00648
00649
00650 return post_bundle(BL, b->source(),
00651 "adv:Don\'t ASK me. You should probably ASK the Control App,"
00652 " not the Bundle Layer.");
00653 }
00654
00655
00656 bool
00657 TcaRouter::handle_get_routes(Bundle* b, const TcaControlBundle& cb)
00658 {
00659 if (!check_nargs(cb, 1)) return false;
00660
00661 log_debug("TcaRouter:: get_routes bundle received. body = '%s'",
00662 cb.args_[0].c_str());
00663
00664 RouteEntryVec matches;
00665 RouteEntryVec::iterator iter;
00666
00667 EndpointIDPattern pattern(cb.args_[0]);
00668 route_table_->get_matching(pattern, &matches);
00669
00670 std::string response = "routes:";
00671 for (iter = matches.begin(); iter != matches.end(); ++iter)
00672 {
00673 response += (*iter)->dest_pattern().str().c_str();
00674 response += "\t";
00675 }
00676
00677 post_bundle(BL, b->source(), response);
00678
00679 return true;
00680 }
00681
00682
00683 bool
00684 TcaRouter::handle_add_route(Bundle* b, const TcaControlBundle& cb)
00685 {
00686 (void)b;
00687
00688 if (!check_nargs(cb, 2)) return false;
00689
00690 const std::string& pattern = cb.args_[0];
00691 const std::string& link = cb.args_[1];
00692
00693 log_debug("TcaRouter:: add_route bundle received. "
00694 "pattern='%s', link='%s'\n", pattern.c_str(), link.c_str());
00695
00696 if (pattern.length() == 0 || link.length() == 0) return false;
00697
00698
00699
00700 return create_route(pattern, link);
00701 }
00702
00703
00704 bool
00705 TcaRouter::handle_del_route(Bundle* b, const TcaControlBundle& cb)
00706 {
00707 (void)b;
00708
00709 if (!check_nargs(cb, 1)) return false;
00710
00711 log_debug("TcaRouter:: del_route bundle received. body = '%s'",
00712 cb.args_[0].c_str());
00713
00714
00715
00716 route_table_->del_entries(cb.args_[0]);
00717 return true;
00718 }
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730 bool
00731 TcaRouter::handle_tca_unbound_bundle(Bundle* bundle)
00732 {
00733 log_debug("TcaRouter::handle_tca_unbound_bundle...");
00734
00735 LinkRef link("TcaRouter::handle_tca_unbound_bundle: fwd_to_matching null");
00736 int n_matches = fwd_to_matching_r(bundle, link, FWD_UDR_IFNECESSARY);
00737
00738 if (n_matches == 0)
00739 {
00740 if (role_ == TCA_ROUTER)
00741 {
00742
00743
00744 log_err("TcaRouter: Error. TCA_ROUTER has no route to dest %s",
00745 bundle->dest().c_str());
00746 return false;
00747 }
00748 else if (role_ == TCA_GATEWAY)
00749 {
00750
00751
00752
00753
00754 std::string payload = "unb:";
00755 payload += bundle->dest().str();
00756 post_bundle(BL, admin_app_, payload);
00757 }
00758 }
00759 return true;
00760 }
00761
00762
00763
00764 bool
00765 TcaRouter::is_local_source(Bundle* b)
00766 {
00767 TcaEndpointID src(b->source());
00768 return src.get_hostid() == admin_app_.get_hostid();
00769 }
00770
00771
00772 TcaRouter::ForwardingRule
00773 TcaRouter::get_forwarding_rule(Bundle* b)
00774 {
00775
00776 if (b->dest().scheme_str() != "tca") return FWD_UDR_ALWAYS;
00777
00778 TcaEndpointID dest(b->dest());
00779
00780 if (dest.ssp() == "//registry")
00781 {
00782
00783
00784 if (b->source().str() == admin_app_.str()) return FWD_UDR_EXCLUSIVELY;
00785 else return FWD_NEVER;
00786 }
00787
00788 else if (dest.app() == "admin.coa")
00789 {
00790
00791
00792
00793 return FWD_UDR_NEVER;
00794 }
00795
00796 else if (dest.ssp().substr(0,11) == "//anonymous")
00797 {
00798
00799
00800
00801
00802 if (is_local_source(b)) return FWD_UDR_NEVER;
00803 else return FWD_NEVER;
00804 }
00805
00806 else if (dest.ssp() == "//localhost/bundlelayer")
00807 {
00808
00809 return FWD_NEVER;
00810 }
00811
00812
00813
00814 else
00815 {
00816 if (dest.host() == admin_app_.host())
00817 {
00818
00819
00820 return FWD_NEVER;
00821 }
00822 else
00823 {
00824
00825
00826 return FWD_UDR_IFNECESSARY;
00827 }
00828 }
00829 }
00830
00831
00832
00833
00834
00835
00836 LinkRef
00837 TcaRouter::create_link(const std::string& link_addr)
00838 {
00839
00840
00841
00842
00843
00844 EndpointID link_eid(link_addr);
00845 std::string clayer_name = link_eid.scheme_str();
00846 const std::string& ssp = link_eid.ssp();
00847 std::string host = ssp.substr(2, ssp.length());
00848
00849 ContactManager* p_man = BundleDaemon::instance()->contactmgr();
00850
00851
00852 LinkRef p_link("TcaRouter::create_link: return value");
00853
00854 p_link = p_man->find_link(host.c_str());
00855 if (p_link != NULL) return p_link;
00856
00857 ConvergenceLayer* cl = ConvergenceLayer::find_clayer(clayer_name.c_str());
00858 if (!cl) {
00859 log_err("TcaRouter: create_link failed: invalid convergence layer"
00860 " '%s'", clayer_name.c_str());
00861 return p_link;
00862 }
00863
00864 p_link = Link::create_link(host, Link::ONDEMAND, cl, host.c_str(), 0, NULL);
00865 if (p_link == NULL) return p_link;
00866
00867
00868
00869 if (!p_man->add_new_link(p_link)) {
00870 p_link->delete_link();
00871 log_err("TcaRouter::create_link: "
00872 "failed to add new link %s", p_link->name());
00873 p_link = NULL;
00874 return p_link;
00875 }
00876
00877 return p_link;
00878 }
00879
00880
00881 RouteEntry*
00882 TcaRouter::create_route(const std::string& pattern, const LinkRef& p_link)
00883 {
00884
00885 log_debug("TcaRouter::create_route: pattern=%s, p_link=%p",
00886 pattern.c_str(), p_link.object());
00887
00888 RouteEntry* p_entry = new RouteEntry(pattern, p_link);
00889 p_entry->set_action(ForwardingInfo::COPY_ACTION);
00890
00891 route_table_->add_entry(p_entry);
00892
00893 return p_entry;
00894 }
00895
00896
00897 bool
00898 TcaRouter::create_route(const std::string& pattern,
00899 const std::string& link_addr)
00900 {
00901
00902 LinkRef p_link = create_link(link_addr);
00903 if (p_link == NULL)
00904 {
00905 log_err("TcaRouter::create_route: create_link failed");
00906 return false;
00907 }
00908
00909
00910 if (!create_route(pattern, p_link))
00911 {
00912 log_err("TcaRouter::create_route: create_route failed");
00913 return false;
00914 }
00915
00916 return true;
00917 }
00918
00919
00920 bool
00921 TcaRouter::post_bundle(const EndpointID& src, const EndpointID& dest,
00922 const std::string& payload)
00923 {
00924
00925 log_debug("TcaRouter::post_bundle: [%s] -> [%s] : '%s'\n",
00926 src.c_str(), dest.c_str(), payload.c_str());
00927
00928
00929 Bundle* b = new Bundle();
00930
00931
00932 if (src.length() == 0)
00933 b->mutable_source()->assign("tca://localhost/bundlelayer");
00934 else
00935 b->mutable_source()->assign(src);
00936
00937 b->mutable_dest()->assign(dest);
00938 b->mutable_custodian()->assign(BundleDaemon::instance()->local_eid());
00939 b->mutable_replyto()->assign(BundleDaemon::instance()->local_eid());
00940
00941 b->mutable_payload()->set_data(payload);
00942
00943
00944
00945 b->set_expiration(3600);
00946
00947
00948
00949
00950 BundleReceivedEvent* p_event = new BundleReceivedEvent(b, EVENTSRC_ADMIN);
00951 BundleDaemon::instance()->post(p_event);
00952
00953 return true;
00954 }
00955
00956
00957
00958 bool
00959 TcaRouter::push_wrapped_bundle(const std::string& code,
00960 const EndpointID& src,
00961 const EndpointID& dest,
00962 const std::string& bsp)
00963 {
00964 std::string payload = code;
00965 payload += ":";
00966 payload += src.str();
00967 payload += "\t";
00968 payload += dest.str();
00969 payload += "\t";
00970 payload += bsp;
00971 return post_bundle(BL, admin_app_, payload);
00972 }
00973
00974
00975
00976
00977 }