Class that implements the API session. More...
#include <APIServer.h>
Public Member Functions | |
APIClient (int fd, in_addr_t remote_host, u_int16_t remote_port, APIServer *parent) | |
virtual | ~APIClient () |
virtual void | run () |
void | close_client () |
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_cancel () |
int | handle_recv () |
int | handle_begin_poll () |
int | handle_cancel_poll () |
int | handle_close () |
int | handle_session_update () |
int | wait_for_notify (const char *operation, dtn_timeval_t timeout, APIRegistration **recv_ready_reg, APIRegistration **session_ready_reg, bool *sock_ready) |
int | handle_unexpected_data (const char *operation) |
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_ |
APIRegistrationList * | bindings_ |
APIRegistrationList * | sessions_ |
oasys::Notifier | notifier_ |
APIServer * | parent_ |
size_t | total_sent_ |
size_t | total_rcvd_ |
Class that implements the API session.
Definition at line 82 of file APIServer.h.
dtn::APIClient::APIClient | ( | int | fd, | |
in_addr_t | remote_host, | |||
u_int16_t | remote_port, | |||
APIServer * | parent | |||
) |
Definition at line 185 of file APIServer.cc.
References bindings_, buf_, DTN_MAX_API_MSG, sessions_, xdr_decode_, and xdr_encode_.
dtn::APIClient::~APIClient | ( | ) | [virtual] |
Definition at line 202 of file APIServer.cc.
void dtn::APIClient::close_client | ( | ) |
Definition at line 211 of file APIServer.cc.
References bindings_, dtn::Registration::expired(), parent_, dtn::BundleDaemon::post(), dtn::Registration::regid(), sessions_, dtn::Registration::set_active(), and dtn::APIServer::unregister_client().
Referenced by run(), and send_response().
int dtn::APIClient::handle_begin_poll | ( | ) | [protected] |
Definition at line 1454 of file APIServer.cc.
References DTN_CANCEL_POLL, DTN_ECOMM, DTN_EXDR, DTN_SUCCESS, dtnipc_msgtoa(), len, send_response(), total_rcvd_, wait_for_notify(), xdr_decode_, and xdr_dtn_timeval_t().
Referenced by run().
int dtn::APIClient::handle_bind | ( | ) | [protected] |
Definition at line 685 of file APIServer.cc.
References dtn::Registration::active(), bindings_, DTN_EBUSY, DTN_ENOTFOUND, DTN_EXDR, DTN_SUCCESS, dtn::RegistrationTable::get(), dtn::Registration::regid(), regid, dtn::Registration::set_active(), xdr_decode_, and xdr_dtn_reg_id_t().
Referenced by run().
int dtn::APIClient::handle_cancel | ( | ) | [protected] |
Definition at line 1143 of file APIServer.cc.
References dtn::GbofId::creation_ts_, DTN_ENOTFOUND, DTN_EXDR, DTN_SUCCESS, dtn::GbofId::frag_length_, dtn::GbofId::frag_offset_, dtn::GbofId::is_fragment_, dtn::BundleDaemon::post(), dtn::BundleTimestamp::seconds_, dtn::BundleTimestamp::seqno_, dtn::GbofId::source_, dtn::GbofId::str(), xdr_decode_, and xdr_dtn_bundle_id_t().
Referenced by run().
int dtn::APIClient::handle_cancel_poll | ( | ) | [protected] |
int dtn::APIClient::handle_close | ( | ) | [protected] |
Definition at line 1544 of file APIServer.cc.
Referenced by run().
int dtn::APIClient::handle_find_registration | ( | ) | [protected] |
Definition at line 647 of file APIServer.cc.
References dtn::EndpointID::assign(), DTN_EINVAL, DTN_ENOTFOUND, DTN_EXDR, DTN_SUCCESS, endpoint, 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_handshake | ( | ) | [protected] |
Definition at line 236 of file APIServer.cc.
References DTN_IPC_VERSION, DTN_OPEN, errno, total_rcvd_, and total_sent_.
Referenced by run().
int dtn::APIClient::handle_local_eid | ( | ) | [protected] |
Definition at line 470 of file APIServer.cc.
References dtn::EndpointID::append_service_tag(), dtn::EndpointID::copyto(), DTN_EINVAL, DTN_EXDR, DTN_SUCCESS, 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_recv | ( | ) | [protected] |
Definition at line 1187 of file APIServer.cc.
References dtn_bundle_status_report_t::ack_by_app_ts, dtn::BundleStatusReport::data_t::ack_by_app_tv_, ASSERT, dtn_bundle_spec_t::blocks, dtn_bundle_spec_t::blocks_len, dtn_bundle_spec_t::blocks_val, dtn_bundle_payload_t::buf, 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(), dtn::BundlePayload::copy_file(), dtn::EndpointID::copyto(), dtn_bundle_id_t::creation_ts, dtn::Bundle::creation_ts(), dtn_bundle_spec_t::creation_ts, dtn::Bundle::custody_rcpt(), dtn::Bundle::custody_requested(), dtn_bundle_status_report_t::custody_ts, dtn::BundleStatusReport::data_t::custody_tv_, dtn_extension_block_t::data, dtn_sequence_id_t::data, dtn_extension_block_t::data_len, dtn_sequence_id_t::data_len, dtn_extension_block_t::data_val, dtn_sequence_id_t::data_val, dtn::Bundle::deletion_rcpt(), dtn_bundle_status_report_t::deletion_ts, dtn::BundleStatusReport::data_t::deletion_tv_, dtn::Bundle::delivery_rcpt(), dtn_bundle_spec_t::delivery_regid, dtn_bundle_status_report_t::delivery_ts, dtn::BundleStatusReport::data_t::delivery_tv_, 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_EINTERNAL, DTN_EINVAL, DTN_EXDR, DTN_MAX_BUNDLE_MEM, DTN_PAYLOAD_FILE, DTN_PAYLOAD_MEM, DTN_SUCCESS, dtn::SequenceID::empty(), errno, dtn::Bundle::expiration(), dtn_bundle_spec_t::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_extension_block_t::flags, dtn::Bundle::forward_rcpt(), dtn_bundle_status_report_t::forwarding_ts, dtn::BundleStatusReport::data_t::forwarding_tv_, dtn_bundle_id_t::frag_offset, handle_unexpected_data(), dtn::BundlePayload::length(), dtn_bundle_payload_t::location, dtn_bundle_spec_t::metadata, dtn::BundleProtocol::METADATA_BLOCK, dtn_bundle_spec_t::metadata_len, dtn_bundle_spec_t::metadata_val, dtn_bundle_spec_t::obsoletes_id, dtn::Bundle::obsoletes_id(), 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(), dtn::Bundle::payload(), dtn::BundleProtocol::PAYLOAD_BLOCK, dtn::BundleList::pop_front(), dtn::BundleDaemon::post(), dtn::BundleProtocol::PRIMARY_BLOCK, dtn::BundlePayload::read_data(), dtn_bundle_status_report_t::reason, dtn::BundleStatusReport::data_t::reason_code_, dtn_bundle_status_report_t::receipt_ts, dtn::BundleStatusReport::data_t::receipt_tv_, dtn::Bundle::receive_rcpt(), dtn::Bundle::recv_blocks(), dtn::Bundle::recv_metadata(), dtn::Registration::regid(), dtn_bundle_spec_t::replyto, dtn::Bundle::replyto(), dtn::BundleTimestamp::seconds_, dtn_timestamp_t::secs, dtn_timestamp_t::seqno, dtn::BundleTimestamp::seqno_, dtn_bundle_spec_t::sequence_id, dtn::Bundle::sequence_id(), 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, dtn::SequenceID::to_str(), dtn_extension_block_t::type, wait_for_notify(), 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_register | ( | ) | [protected] |
Definition at line 506 of file APIServer.cc.
References ASSERT, dtn::EndpointID::assign(), bindings_, dtn::Session::CUSTODY, dtn::Registration::DEFER, dtn::Registration::DROP, DTN_EINVAL, DTN_EXDR, DTN_REG_DEFER, DTN_REG_DROP, DTN_REG_EXEC, DTN_SESSION_CUSTODY, DTN_SESSION_PUBLISH, DTN_SESSION_SUBSCRIBE, DTN_SUCCESS, endpoint, dtn::EVENTSRC_APP, dtn::Registration::EXEC, failure_action, dtn::GlobalStore::instance(), dtn::GlobalStore::next_regid(), notifier_, dtn::BundleDaemon::post_and_wait(), dtn::Session::PUBLISH, regid, session_flags, dtn::APIRegistration::session_notify_list(), sessions_, dtn::Registration::set_active(), dtn::Session::SUBSCRIBE, 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_send | ( | ) | [protected] |
Definition at line 776 of file APIServer.cc.
References ASSERT, COS, COS_BULK, COS_EXPEDITED, COS_NORMAL, COS_RESERVED, dtn_extension_block_t::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_DO_NOT_FRAGMENT, DOPTS_FORWARD_RCPT, DOPTS_MULTINODE_DEST, DOPTS_RECEIVE_RCPT, DOPTS_SINGLETON_DEST, DTN_EINTERNAL, DTN_EINVAL, DTN_ENOSPACE, DTN_EXDR, DTN_PAYLOAD_FILE, DTN_PAYLOAD_MEM, DTN_PAYLOAD_TEMP_FILE, DTN_SUCCESS, dtn::Registration::endpoint(), errno, dtn::EVENTSRC_APP, filename, dtn_extension_block_t::flags, dtn::RegistrationTable::get(), dtn::RegistrationTable::get_matching(), info, dtn::EndpointID::is_singleton_default_, dtn::EndpointID::MULTINODE, notifier_, dtn::EndpointID::NULL_EID(), dtn::BundleDaemon::post_and_wait(), dtn::MetadataVec::push_back(), dtn::BundleProtocol::REASON_DEPLETED_STORAGE, dtn::BundleStatusReport::reason_to_str(), regid, dtn::Registration::session_flags(), dtn::MetadataBlock::set_flags(), dtn::EndpointID::SINGLETON, dtn::EndpointID::str(), dtn_extension_block_t::type, dtn::EndpointID::UNKNOWN, xdr_decode_, xdr_dtn_bundle_id_t(), xdr_dtn_bundle_payload_t(), xdr_dtn_bundle_spec_t(), xdr_dtn_reg_id_t(), and xdr_encode_.
Referenced by run().
int dtn::APIClient::handle_session_update | ( | ) | [protected] |
Definition at line 1553 of file APIServer.cc.
References ASSERT, dtn::EndpointID::c_str(), dtn::EndpointID::copyto(), DTN_EXDR, DTN_SESSION_SUBSCRIBE, DTN_SUCCESS, dtn::Session::flag_str(), handle_unexpected_data(), dtn::BundleList::pop_front(), dtn::BundleDaemon::post(), dtn::Registration::regid(), dtn::Bundle::session_eid(), session_flags, dtn::Bundle::session_flags(), dtn::APIRegistration::session_notify_list(), dtn::Session::SUBSCRIBE, wait_for_notify(), xdr_decode_, xdr_dtn_endpoint_id_t(), xdr_dtn_timeval_t(), and xdr_encode_.
Referenced by run().
int dtn::APIClient::handle_unbind | ( | ) | [protected] |
Definition at line 727 of file APIServer.cc.
References dtn::Registration::active(), ASSERT, bindings_, DTN_ENOTFOUND, DTN_EXDR, DTN_SUCCESS, dtn::Registration::expired(), dtn::RegistrationTable::get(), dtn::BundleDaemon::post(), dtn::Registration::regid(), regid, dtn::Registration::set_active(), xdr_decode_, and xdr_dtn_reg_id_t().
Referenced by run().
int dtn::APIClient::handle_unexpected_data | ( | const char * | operation | ) | [protected] |
Definition at line 1789 of file APIServer.cc.
References DTN_ECOMM.
Referenced by handle_recv(), and handle_session_update().
int dtn::APIClient::handle_unregister | ( | ) | [protected] |
Definition at line 602 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(), notifier_, dtn::BundleDaemon::post_and_wait(), dtn::Registration::regid(), regid, xdr_decode_, and xdr_dtn_reg_id_t().
Referenced by run().
bool dtn::APIClient::is_bound | ( | u_int32_t | regid | ) | [protected] |
Definition at line 456 of file APIServer.cc.
References bindings_.
Referenced by handle_unregister().
void dtn::APIClient::run | ( | ) | [virtual] |
Definition at line 283 of file APIServer.cc.
References buf_, close_client(), DISPATCH, DTN_BEGIN_POLL, DTN_BIND, DTN_CANCEL, DTN_CANCEL_POLL, DTN_CLOSE, DTN_ECOMM, DTN_EMSGTYPE, DTN_FIND_REGISTRATION, DTN_LOCAL_EID, DTN_RECV, DTN_REGISTER, DTN_SEND, DTN_SESSION_UPDATE, DTN_UNBIND, DTN_UNREGISTER, dtnipc_msgtoa(), errno, handle_begin_poll(), handle_bind(), handle_cancel(), handle_cancel_poll(), handle_close(), handle_find_registration(), handle_handshake(), handle_local_eid(), handle_recv(), handle_register(), handle_send(), handle_session_update(), handle_unbind(), handle_unregister(), len, send_response(), total_rcvd_, total_sent_, xdr_decode_, and xdr_encode_.
int dtn::APIClient::send_response | ( | int | ret | ) | [protected] |
Definition at line 417 of file APIServer.cc.
References ASSERT, buf_, close_client(), DTN_ERRBASE, DTN_ERRMAX, dtn_strerror(), DTN_SUCCESS, errno, len, total_rcvd_, total_sent_, and xdr_encode_.
Referenced by handle_begin_poll(), and run().
int dtn::APIClient::wait_for_notify | ( | const char * | operation, | |
dtn_timeval_t | timeout, | |||
APIRegistration ** | recv_ready_reg, | |||
APIRegistration ** | session_ready_reg, | |||
bool * | sock_ready | |||
) | [protected] |
Definition at line 1620 of file APIServer.cc.
References ASSERT, bindings_, dtn::APIRegistration::bundle_list(), DTN_EINTERNAL, DTN_EINVAL, DTN_ETIMEOUT, dtn::BundleList::empty(), dtn::BlockingBundleList::notifier(), dtn::Registration::regid(), dtn::APIRegistration::session_notify_list(), and sessions_.
Referenced by handle_begin_poll(), handle_recv(), and handle_session_update().
APIRegistrationList* dtn::APIClient::bindings_ [protected] |
Definition at line 130 of file APIServer.h.
Referenced by APIClient(), close_client(), handle_bind(), handle_register(), handle_unbind(), is_bound(), wait_for_notify(), and ~APIClient().
char dtn::APIClient::buf_[DTN_MAX_API_MSG] [protected] |
Definition at line 127 of file APIServer.h.
Referenced by APIClient(), run(), and send_response().
oasys::Notifier dtn::APIClient::notifier_ [protected] |
Definition at line 132 of file APIServer.h.
Referenced by handle_register(), handle_send(), and handle_unregister().
APIServer* dtn::APIClient::parent_ [protected] |
Definition at line 133 of file APIServer.h.
Referenced by close_client().
APIRegistrationList* dtn::APIClient::sessions_ [protected] |
Definition at line 131 of file APIServer.h.
Referenced by APIClient(), close_client(), handle_register(), wait_for_notify(), and ~APIClient().
size_t dtn::APIClient::total_rcvd_ [protected] |
Definition at line 135 of file APIServer.h.
Referenced by handle_begin_poll(), handle_handshake(), run(), and send_response().
size_t dtn::APIClient::total_sent_ [protected] |
Definition at line 134 of file APIServer.h.
Referenced by handle_handshake(), run(), and send_response().
XDR dtn::APIClient::xdr_decode_ [protected] |
Definition at line 129 of file APIServer.h.
Referenced by APIClient(), handle_begin_poll(), handle_bind(), handle_cancel(), handle_find_registration(), handle_local_eid(), handle_recv(), handle_register(), handle_send(), handle_session_update(), handle_unbind(), handle_unregister(), and run().
XDR dtn::APIClient::xdr_encode_ [protected] |
Definition at line 128 of file APIServer.h.
Referenced by APIClient(), handle_find_registration(), handle_local_eid(), handle_recv(), handle_register(), handle_send(), handle_session_update(), run(), and send_response().