dtn::APIClient Class Reference

#include <APIServer.h>

Inheritance diagram for dtn::APIClient:

oasys::Thread oasys::TCPClient oasys::IPClient oasys::IPSocket oasys::IOClient oasys::Logger oasys::IOHandlerBase oasys::IOHandlerBase

List of all members.


Detailed Description

Class that implements the API session.

Definition at line 64 of file APIServer.h.


Public Member Functions

 APIClient (int fd, in_addr_t remote_host, u_int16_t remote_port)
virtual ~APIClient ()
virtual void run ()
 Derived classes should implement this function which will get called in the new Thread context.
void close_session ()

Protected Member Functions

int handle_handshake ()
int handle_local_eid ()
int handle_register ()
int handle_unregister ()
int handle_find_registration ()
int handle_bind ()
int handle_unbind ()
int handle_send ()
int handle_recv ()
int handle_begin_poll ()
int handle_cancel_poll ()
int handle_close ()
int wait_for_bundle (const char *operation, dtn_timeval_t timeout, APIRegistration **reg, bool *sock_ready)
int send_response (int ret)
bool is_bound (u_int32_t regid)

Protected Attributes

char buf_ [DTN_MAX_API_MSG]
XDR xdr_encode_
XDR xdr_decode_
APIRegistrationListbindings_
oasys::Notifier notifier_

Constructor & Destructor Documentation

dtn::APIClient::APIClient ( int  fd,
in_addr_t  remote_host,
u_int16_t  remote_port 
)

Definition at line 132 of file APIServer.cc.

References bindings_, buf_, DTN_MAX_API_MSG, xdr_decode_, and xdr_encode_.

dtn::APIClient::~APIClient (  )  [virtual]

Definition at line 145 of file APIServer.cc.

References bindings_, delete_z, and log_debug.


Member Function Documentation

void dtn::APIClient::run (  )  [virtual]

Derived classes should implement this function which will get called in the new Thread context.

Implements oasys::Thread.

Definition at line 211 of file APIServer.cc.

References buf_, close_session(), DISPATCH, DTN_BEGIN_POLL, DTN_BIND, DTN_CANCEL_POLL, DTN_CLOSE, DTN_ECOMM, DTN_EMSGTYPE, DTN_FIND_REGISTRATION, DTN_LOCAL_EID, DTN_MAX_API_MSG, DTN_RECV, DTN_REGISTER, DTN_SEND, DTN_UNBIND, DTN_UNREGISTER, dtnipc_msgtoa(), errno, handle_begin_poll(), handle_bind(), handle_cancel_poll(), handle_close(), handle_find_registration(), handle_handshake(), handle_local_eid(), handle_recv(), handle_register(), handle_send(), handle_unbind(), handle_unregister(), intoa, oasys::IPSocket::local_addr(), oasys::IPSocket::local_port(), log_debug, log_err, log_info, log_warn, oasys::IPClient::read(), oasys::IPClient::readall(), oasys::IPSocket::remote_addr(), oasys::IPSocket::remote_port(), send_response(), xdr_decode_, and xdr_encode_.

void dtn::APIClient::close_session (  ) 

Definition at line 153 of file APIServer.cc.

References bindings_, dtn::Registration::expired(), log_debug, dtn::BundleDaemon::post(), dtn::Registration::regid(), and dtn::Registration::set_active().

Referenced by run(), and send_response().

int dtn::APIClient::handle_handshake (  )  [protected]

Definition at line 173 of file APIServer.cc.

References DTN_IPC_VERSION, DTN_OPEN, errno, log_err, oasys::IPClient::readall(), and oasys::IPClient::writeall().

Referenced by run().

int dtn::APIClient::handle_local_eid (  )  [protected]

Definition at line 371 of file APIServer.cc.

References dtn::EndpointID::append_service_tag(), dtn::EndpointID::copyto(), DTN_EINVAL, DTN_EXDR, DTN_SUCCESS, log_debug, log_err, dtn_service_tag_t::tag, xdr_decode_, xdr_dtn_endpoint_id_t(), xdr_dtn_service_tag_t(), and xdr_encode_.

Referenced by run().

int dtn::APIClient::handle_register (  )  [protected]

Definition at line 407 of file APIServer.cc.

References dtn::EndpointID::assign(), bindings_, dtn::Registration::DEFER, dtn::Registration::DROP, DTN_EBUSY, DTN_EINVAL, DTN_EXDR, DTN_REG_DEFER, DTN_REG_DROP, DTN_REG_EXEC, DTN_SUCCESS, endpoint, dtn::EVENTSRC_APP, dtn::Registration::EXEC, dtn::GlobalStore::instance(), log_err, dtn::GlobalStore::next_regid(), notifier_, dtn::BundleDaemon::post_and_wait(), regid, dtn::Registration::set_active(), dtn::EndpointID::valid(), xdr_decode_, xdr_dtn_reg_id_t(), xdr_dtn_reg_info_t(), and xdr_encode_.

Referenced by run().

int dtn::APIClient::handle_unregister (  )  [protected]

Definition at line 481 of file APIServer.cc.

References dtn::Registration::active(), ASSERT, DTN_EBUSY, DTN_EINVAL, DTN_ENOTFOUND, DTN_EXDR, DTN_SUCCESS, dtn::Registration::expired(), dtn::Registration::force_expire(), is_bound(), log_err, notifier_, dtn::BundleDaemon::post_and_wait(), dtn::Registration::regid(), regid, xdr_decode_, and xdr_dtn_reg_id_t().

Referenced by run().

int dtn::APIClient::handle_find_registration (  )  [protected]

Definition at line 526 of file APIServer.cc.

References dtn::EndpointID::assign(), DTN_EINVAL, DTN_ENOTFOUND, DTN_EXDR, DTN_SUCCESS, endpoint, log_err, dtn::Registration::regid(), regid, dtn_endpoint_id_t::uri, dtn::EndpointID::valid(), xdr_decode_, xdr_dtn_endpoint_id_t(), xdr_dtn_reg_id_t(), and xdr_encode_.

Referenced by run().

int dtn::APIClient::handle_bind (  )  [protected]

Definition at line 564 of file APIServer.cc.

References dtn::Registration::active(), bindings_, DTN_EBUSY, DTN_ENOTFOUND, DTN_EXDR, DTN_SUCCESS, dtn::RegistrationTable::get(), log_crit, log_err, log_info, dtn::Registration::regid(), regid, dtn::Registration::set_active(), xdr_decode_, and xdr_dtn_reg_id_t().

Referenced by run().

int dtn::APIClient::handle_unbind (  )  [protected]

Definition at line 612 of file APIServer.cc.

References dtn::Registration::active(), ASSERT, bindings_, DTN_ENOTFOUND, DTN_EXDR, DTN_SUCCESS, dtn::RegistrationTable::get(), log_crit, log_err, log_info, regid, dtn::Registration::set_active(), xdr_decode_, and xdr_dtn_reg_id_t().

Referenced by run().

int dtn::APIClient::handle_send (  )  [protected]

Definition at line 656 of file APIServer.cc.

References oasys::Ref< _Type >::assign(), COS, COS_BULK, COS_EXPEDITED, COS_NORMAL, COS_RESERVED, dtn_extension_block_t::data, oasys::StringBuffer::data(), dtn_extension_block_t::data_len, dtn_extension_block_t::data_val, DOPTS_CUSTODY, DOPTS_CUSTODY_RCPT, DOPTS_DELETE_RCPT, DOPTS_DELIVERY_RCPT, DOPTS_FORWARD_RCPT, DOPTS_RECEIVE_RCPT, DTN_EINTERNAL, DTN_EINVAL, DTN_ENOSPACE, DTN_EXDR, DTN_PAYLOAD_FILE, DTN_PAYLOAD_MEM, DTN_PAYLOAD_TEMP_FILE, DTN_SUCCESS, errno, dtn::EVENTSRC_APP, dtn_extension_block_t::flags, info, log_err, log_info, notifier_, dtn::EndpointID::NULL_EID(), oasys::Ref< _Type >::object(), dtn::BundleDaemon::post_and_wait(), dtn::BundleProtocol::REASON_DEPLETED_STORAGE, dtn::BundleStatusReport::reason_to_str(), dtn_extension_block_t::type, xdr_decode_, xdr_dtn_bundle_id_t(), xdr_dtn_bundle_payload_t(), xdr_dtn_bundle_spec_t(), and xdr_encode_.

Referenced by run().

int dtn::APIClient::handle_recv (  )  [protected]

Definition at line 875 of file APIServer.cc.

References ASSERT, oasys::ScratchBuffer< _memory_t, _static_size >::buf(), dtn_bundle_payload_t::buf, dtn_bundle_payload_t::buf_len, dtn_bundle_payload_t::buf_val, dtn_bundle_status_report_t::bundle_id, dtn::APIRegistration::bundle_list(), dtn::Bundle::bundleid_, oasys::FileIOClient::close(), dtn::BundlePayload::copy_file(), dtn::EndpointID::copyto(), dtn_bundle_id_t::creation_ts, dtn::Bundle::custody_rcpt_, dtn::Bundle::custody_requested_, dtn::Bundle::deletion_rcpt_, dtn::Bundle::delivery_rcpt_, dtn_bundle_spec_t::dest, dtn::Bundle::dest_, dtn_bundle_spec_t::dopts, DOPTS_CUSTODY, DOPTS_CUSTODY_RCPT, DOPTS_DELETE_RCPT, DOPTS_DELIVERY_RCPT, DOPTS_FORWARD_RCPT, DOPTS_RECEIVE_RCPT, DTN_ECOMM, DTN_EINTERNAL, DTN_EINVAL, DTN_EXDR, DTN_PAYLOAD_FILE, DTN_PAYLOAD_MEM, DTN_SUCCESS, dtn_bundle_spec_t::expiration, dtn::Bundle::expiration_, dtn_bundle_payload_t::filename, dtn_bundle_payload_t::filename_len, dtn_bundle_payload_t::filename_val, dtn_bundle_status_report_t::flags, dtn::Bundle::forward_rcpt_, dtn_bundle_id_t::frag_offset, dtn::BundlePayload::length(), dtn::BundlePayload::location(), dtn_bundle_payload_t::location, log_debug, log_err, log_info, dtn::BundlePayload::MEMORY, dtn::BundlePayload::memory_data(), oasys::FileIOClient::mkstemp(), oasys::Ref< _Type >::object(), dtn::BundleStatusReport::data_t::orig_creation_tv_, dtn::BundleStatusReport::data_t::orig_frag_length_, dtn::BundleStatusReport::data_t::orig_frag_offset_, dtn_bundle_id_t::orig_length, dtn::BundleStatusReport::data_t::orig_source_eid_, dtn::BundleStatusReport::parse_status_report(), oasys::FileIOClient::path(), oasys::FileIOClient::path_len(), dtn::Bundle::payload_, dtn::BundleList::pop_front(), dtn::BundleDaemon::post(), oasys::IPClient::read(), dtn::BundlePayload::read_data(), dtn_bundle_status_report_t::reason, dtn::BundleStatusReport::data_t::reason_code_, dtn::Bundle::receive_rcpt_, dtn::Registration::regid(), dtn_bundle_spec_t::replyto, dtn::Bundle::replyto_, oasys::ScratchBuffer< _memory_t, _static_size >::reserve(), dtn::BundleTimestamp::seconds_, dtn_timestamp_t::secs, dtn_timestamp_t::seqno, dtn::BundleTimestamp::seqno_, snprintf(), dtn_bundle_id_t::source, dtn_bundle_spec_t::source, dtn::Bundle::source_, dtn::BundleStatusReport::data_t::status_flags_, dtn_bundle_payload_t::status_report, wait_for_bundle(), oasys::FdIOClient::writeall(), xdr_decode_, xdr_dtn_bundle_payload_location_t(), xdr_dtn_bundle_payload_t(), xdr_dtn_bundle_spec_t(), xdr_dtn_timeval_t(), and xdr_encode_.

Referenced by run().

int dtn::APIClient::handle_begin_poll (  )  [protected]

Definition at line 1047 of file APIServer.cc.

References DTN_CANCEL_POLL, DTN_ECOMM, DTN_EXDR, DTN_SUCCESS, dtnipc_msgtoa(), log_debug, log_err, log_info, oasys::IPClient::read(), send_response(), wait_for_bundle(), xdr_decode_, and xdr_dtn_timeval_t().

Referenced by run().

int dtn::APIClient::handle_cancel_poll (  )  [protected]

Definition at line 1111 of file APIServer.cc.

References DTN_SUCCESS.

Referenced by run().

int dtn::APIClient::handle_close (  )  [protected]

Definition at line 1215 of file APIServer.cc.

References log_info.

Referenced by run().

int dtn::APIClient::wait_for_bundle ( const char *  operation,
dtn_timeval_t  timeout,
APIRegistration **  reg,
bool sock_ready 
) [protected]

Definition at line 1123 of file APIServer.cc.

References ASSERT, bindings_, dtn::APIRegistration::bundle_list(), DTN_EINTERNAL, DTN_EINVAL, DTN_ETIMEOUT, oasys::IOTIMEOUT, log_crit, log_debug, log_err, oasys::Logger::logpath_, dtn::BlockingBundleList::notifier(), oasys::IO::poll_multiple(), oasys::Notifier::read_fd(), dtn::Registration::regid(), and dtn::BundleList::size().

Referenced by handle_begin_poll(), and handle_recv().

int dtn::APIClient::send_response ( int  ret  )  [protected]

Definition at line 322 of file APIServer.cc.

References ASSERT, buf_, close_session(), DTN_ERRBASE, DTN_ERRMAX, DTN_SUCCESS, dtnipc_msgtoa(), errno, log_debug, log_err, oasys::IPClient::writeall(), and xdr_encode_.

Referenced by handle_begin_poll(), and run().

bool dtn::APIClient::is_bound ( u_int32_t  regid  )  [protected]

Definition at line 357 of file APIServer.cc.

References bindings_.

Referenced by handle_unregister().


Member Data Documentation

char dtn::APIClient::buf_[DTN_MAX_API_MSG] [protected]

Definition at line 100 of file APIServer.h.

Referenced by APIClient(), run(), and send_response().

XDR dtn::APIClient::xdr_encode_ [protected]

Definition at line 101 of file APIServer.h.

Referenced by APIClient(), handle_find_registration(), handle_local_eid(), handle_recv(), handle_register(), handle_send(), run(), and send_response().

XDR dtn::APIClient::xdr_decode_ [protected]

Definition at line 102 of file APIServer.h.

Referenced by APIClient(), handle_begin_poll(), handle_bind(), handle_find_registration(), handle_local_eid(), handle_recv(), handle_register(), handle_send(), handle_unbind(), handle_unregister(), and run().

APIRegistrationList* dtn::APIClient::bindings_ [protected]

Definition at line 103 of file APIServer.h.

Referenced by APIClient(), close_session(), handle_bind(), handle_register(), handle_unbind(), is_bound(), wait_for_bundle(), and ~APIClient().

oasys::Notifier dtn::APIClient::notifier_ [protected]

Definition at line 104 of file APIServer.h.

Referenced by handle_register(), handle_send(), and handle_unregister().


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