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 <oasys/util/ScratchBuffer.h>
00022
00023 #include "PingRegistration.h"
00024 #include "RegistrationTable.h"
00025 #include "bundling/BundleDaemon.h"
00026
00027 namespace dtn {
00028
00029 PingRegistration::PingRegistration(const EndpointID& eid)
00030 : Registration(PING_REGID, eid, Registration::DEFER, 0, 0)
00031 {
00032 logpathf("/dtn/reg/ping");
00033 set_active(true);
00034 }
00035
00036 void
00037 PingRegistration::deliver_bundle(Bundle* bundle)
00038 {
00039 size_t payload_len = bundle->payload().length();
00040 log_debug("%zu byte ping from %s",
00041 payload_len, bundle->source().c_str());
00042
00043 Bundle* reply = new Bundle();
00044 reply->mutable_source()->assign(endpoint_);
00045 reply->mutable_dest()->assign(bundle->source());
00046 reply->mutable_replyto()->assign(EndpointID::NULL_EID());
00047 reply->mutable_custodian()->assign(EndpointID::NULL_EID());
00048 reply->set_expiration(bundle->expiration());
00049
00050 reply->mutable_payload()->set_length(payload_len);
00051 reply->mutable_payload()->write_data(bundle->payload(), 0, payload_len, 0);
00052
00053 BundleDaemon::post(new BundleReceivedEvent(reply, EVENTSRC_ADMIN));
00054 BundleDaemon::post(new BundleDeliveredEvent(bundle, this));
00055 }
00056
00057
00058 }