dtn::TclRegistration Class Reference

#include <TclRegistration.h>

Inheritance diagram for dtn::TclRegistration:

dtn::Registration oasys::SerializableObject oasys::Logger

List of all members.


Detailed Description

A simple utility class used mostly for testing registrations.

When created, this sets up a new registration within the daemon, and for any bundles that arrive, outputs logs of the bundle header fields as well as the payload data (if ascii). The implementation is structured as a thread that blocks (forever) waiting for bundles to arrive on the registration's bundle list, then tcl the bundles and looping again.

Definition at line 42 of file TclRegistration.h.


Public Member Functions

 TclRegistration (const EndpointIDPattern &endpoint, Tcl_Interp *interp)
int exec (int argc, const char **argv, Tcl_Interp *interp)
int get_list_channel (Tcl_Interp *interp)
 Return in the tcl result a Tcl_Channel to wrap the BundleList's notifier pipe.
int get_bundle_data (Tcl_Interp *interp)
 Assuming the list channel has been notified, pops a bundle off the list and then returns in the tcl result a list of the relevant metadata and the payload data.
void deliver_bundle (Bundle *bundle)
 virtual from Registration

Static Public Member Functions

static int parse_bundle_data (Tcl_Interp *interp, const BundleRef &b, Tcl_Obj **result)
 Parse the given bundle's internals into a new tcl list object (or an error if parsing fails).

Protected Attributes

BlockingBundleListbundle_list_
Tcl_Channel notifier_channel_

Constructor & Destructor Documentation

dtn::TclRegistration::TclRegistration ( const EndpointIDPattern endpoint,
Tcl_Interp *  interp 
)

Definition at line 31 of file TclRegistration.cc.

References bundle_list_, dtn::EndpointID::c_str(), fd, log_debug, log_err, log_info, oasys::Logger::logpath_, oasys::Logger::logpathf(), notifier_channel_, dtn::Registration::regid_, and dtn::Registration::set_active().


Member Function Documentation

int dtn::TclRegistration::exec ( int  argc,
const char **  argv,
Tcl_Interp *  interp 
)

Definition at line 62 of file TclRegistration.cc.

References get_bundle_data(), get_list_channel(), oasys::TclCommandInterp::instance(), oasys::TclCommandInterp::resultf(), and oasys::TclCommandInterp::wrong_num_args().

Referenced by dtn::RegistrationCommand::exec().

int dtn::TclRegistration::get_list_channel ( Tcl_Interp *  interp  ) 

Return in the tcl result a Tcl_Channel to wrap the BundleList's notifier pipe.

Definition at line 87 of file TclRegistration.cc.

References oasys::TclCommandInterp::instance(), notifier_channel_, and oasys::TclCommandInterp::set_result().

Referenced by exec().

int dtn::TclRegistration::get_bundle_data ( Tcl_Interp *  interp  ) 

Assuming the list channel has been notified, pops a bundle off the list and then returns in the tcl result a list of the relevant metadata and the payload data.

Definition at line 97 of file TclRegistration.cc.

References bundle_list_, oasys::TclCommandInterp::instance(), oasys::Ref< _Type >::object(), parse_bundle_data(), dtn::BundleList::pop_front(), dtn::BundleDaemon::post(), and oasys::TclCommandInterp::set_objresult().

Referenced by exec().

int dtn::TclRegistration::parse_bundle_data ( Tcl_Interp *  interp,
const BundleRef b,
Tcl_Obj **  result 
) [static]

Parse the given bundle's internals into a new tcl list object (or an error if parsing fails).

Return a Tcl list key-value pairs detailing bundle contents to a registered procedure each time a bundle arrives.

The returned TCL list is suitable for assigning to an array, e.g. array set b $bundle_info

Using the TclListSerialize class, all fields that are serialized in Bundle::serialize will be present in the returned tcl list.

ADMIN-BUNDLE-ONLY KEY-VALUE PAIRS:

admin_type : the Admin Type (the following pairs are only defined if the admin_type = "Stauts Report") reason_code : Reason Code string orig_creation_ts : creation timestamp of original bundle orig_source : EID of the original bundle's source

ADMIN-BUNDLE-ONLY OPTIONAL KEY-VALUE PAIRS:

orig_frag_offset : Offset of fragment orig_frag_length : Length of original bundle

STATUS-REPORT-ONLY OPTIONAL KEY-VALUE PAIRS

(Note that the presence of timestamp keys implies a corresponding flag has been set true. For example if forwarded_time is returned the Bundle Forwarded status flag was set; if frag_offset and frag_length are returned the ACK'ed bundle was fragmented.)

sr_reason : status report reason code sr_received_time : bundle reception timestamp sr_custody_time : bundle custody transfer timestamp sr_forwarded_time : bundle forwarding timestamp sr_delivered_time : bundle delivery timestamp sr_deletion_time : bundle deletion timestamp

CUSTODY-SIGNAL-ONLY OPTIONAL KEY-VALUE PAIRS

custody_succeeded : boolean if custody transfer succeeded custody_reason : reason information custody_signal_time : custody transfer time

Definition at line 163 of file TclRegistration.cc.

References addElement, dtn::BundleProtocol::ADMIN_CUSTODY_SIGNAL, dtn::CustodySignal::data_t::admin_flags_, dtn::BundleStatusReport::data_t::admin_flags_, dtn::BundleProtocol::ADMIN_IS_FRAGMENT, dtn::BundleProtocol::ADMIN_STATUS_REPORT, APPEND_TIMESTAMP, oasys::ScratchBuffer< _memory_t, _static_size >::buf(), oasys::Serialize::CONTEXT_LOCAL, dtn::BundleProtocol::CUSTODY_BLOCK_UNINTELLIGIBLE, dtn::BundleProtocol::CUSTODY_DEPLETED_STORAGE, dtn::BundleProtocol::CUSTODY_ENDPOINT_ID_UNINTELLIGIBLE, dtn::BundleProtocol::CUSTODY_NO_ADDTL_INFO, dtn::BundleProtocol::CUSTODY_NO_ROUTE_TO_DEST, dtn::BundleProtocol::CUSTODY_NO_TIMELY_CONTACT, dtn::BundleProtocol::CUSTODY_REDUNDANT_RECEPTION, dtn::CustodySignal::data_t::custody_signal_tv_, dtn::EndpointID::data(), dtn::BundleProtocol::get_admin_type(), dtn::EndpointID::length(), oasys::Ref< _Type >::object(), dtn::CustodySignal::data_t::orig_creation_tv_, dtn::BundleStatusReport::data_t::orig_creation_tv_, dtn::CustodySignal::data_t::orig_frag_length_, dtn::BundleStatusReport::data_t::orig_frag_length_, dtn::CustodySignal::data_t::orig_frag_offset_, dtn::BundleStatusReport::data_t::orig_frag_offset_, dtn::CustodySignal::data_t::orig_source_eid_, dtn::BundleStatusReport::data_t::orig_source_eid_, dtn::CustodySignal::parse_custody_signal(), dtn::BundleStatusReport::parse_status_report(), payload_buf, dtn::CustodySignal::data_t::reason_, dtn::BundleStatusReport::data_t::reason_code_, dtn::BundleStatusReport::reason_to_str(), dtn::BundleTimestamp::seconds_, dtn::BundleTimestamp::seqno_, STATUS_ACKED_BY_APP, STATUS_CUSTODY_ACCEPTED, STATUS_DELETED, STATUS_DELIVERED, STATUS_FORWARDED, STATUS_RECEIVED, and dtn::CustodySignal::data_t::succeeded_.

Referenced by dtn::BundleCommand::exec(), and get_bundle_data().

void dtn::TclRegistration::deliver_bundle ( Bundle bundle  )  [virtual]

virtual from Registration

Implements dtn::Registration.

Definition at line 56 of file TclRegistration.cc.

References bundle_list_, and dtn::BundleList::push_back().


Member Data Documentation

BlockingBundleList* dtn::TclRegistration::bundle_list_ [protected]

Definition at line 73 of file TclRegistration.h.

Referenced by deliver_bundle(), get_bundle_data(), and TclRegistration().

Tcl_Channel dtn::TclRegistration::notifier_channel_ [protected]

Definition at line 74 of file TclRegistration.h.

Referenced by get_list_channel(), and TclRegistration().


The documentation for this class was generated from the following files:
Generated on Sat Sep 8 08:36:22 2007 for DTN Reference Implementation by  doxygen 1.5.3