#include <BundleProtocol.h>
Definition at line 54 of file BundleProtocol.h.
Public Types | |
enum | bundle_processing_flag_t { BUNDLE_IS_FRAGMENT = 1 << 0, BUNDLE_IS_ADMIN = 1 << 1, BUNDLE_DO_NOT_FRAGMENT = 1 << 2, BUNDLE_CUSTODY_XFER_REQUESTED = 1 << 3, BUNDLE_SINGLETON_DESTINATION = 1 << 4 } |
Values for bundle processing flags that appear in the primary block. More... | |
enum | bundle_block_type_t { PAYLOAD_BLOCK = 0x01 } |
Valid type codes for bundle blocks other than the primary block. More... | |
enum | block_flag_t { BLOCK_FLAG_REPLICATE = 1 << 0, BLOCK_FLAG_REPORT_ONERROR = 1 << 1, BLOCK_FLAG_DISCARD_ONERROR = 1 << 2, BLOCK_FLAG_LAST_BLOCK = 1 << 3 } |
Values for block processing flags that appear in all blocks except the primary block. More... | |
enum | admin_record_type_t { ADMIN_STATUS_REPORT = 0x01, ADMIN_CUSTODY_SIGNAL = 0x02, ADMIN_ECHO = 0x03, ADMIN_NULL = 0x04, ADMIN_ANNOUNCE = 0x05 } |
Administrative Record Type Codes. More... | |
enum | admin_record_flags_t { ADMIN_IS_FRAGMENT = 0x01 } |
Administrative Record Flags. More... | |
enum | status_report_flag_t { STATUS_RECEIVED = 0x01, STATUS_CUSTODY_ACCEPTED = 0x02, STATUS_FORWARDED = 0x04, STATUS_DELIVERED = 0x08, STATUS_DELETED = 0x10, STATUS_ACKED_BY_APP = 0x20, STATUS_UNUSED = 0x40, STATUS_UNUSED2 = 0x80 } |
Bundle Status Report Status Flags. More... | |
enum | status_report_reason_t { REASON_NO_ADDTL_INFO = 0x00, REASON_LIFETIME_EXPIRED = 0x01, REASON_FORWARDED_UNIDIR_LINK = 0x02, REASON_TRANSMISSION_CANCELLED = 0x03, REASON_DEPLETED_STORAGE = 0x04, REASON_ENDPOINT_ID_UNINTELLIGIBLE = 0x05, REASON_NO_ROUTE_TO_DEST = 0x06, REASON_NO_TIMELY_CONTACT = 0x07, REASON_BLOCK_UNINTELLIGIBLE = 0x08 } |
Bundle Status Report "Reason Code" flags. More... | |
enum | custody_signal_reason_t { CUSTODY_NO_ADDTL_INFO = 0x00, CUSTODY_REDUNDANT_RECEPTION = 0x03, CUSTODY_DEPLETED_STORAGE = 0x04, CUSTODY_ENDPOINT_ID_UNINTELLIGIBLE = 0x05, CUSTODY_NO_ROUTE_TO_DEST = 0x06, CUSTODY_NO_TIMELY_CONTACT = 0x07, CUSTODY_BLOCK_UNINTELLIGIBLE = 0x08 } |
Custody Signal Reason Codes. More... | |
Static Public Member Functions | |
static int | format_header_blocks (const Bundle *bundle, u_char *buf, size_t len) |
Fill in the given buffer with the formatted bundle blocks that should go before the payload data, including the payload block header (i.e. | |
static int | parse_header_blocks (Bundle *bundle, u_char *buf, size_t len) |
Parse the received blocks, filling in the bundle with the relevant data if successful. | |
static int | format_tail_blocks (const Bundle *bundle, u_char *buf, size_t len) |
Fill in the given buffer with the formatted bundle blocks that should go after the payload data. | |
static int | parse_tail_blocks (Bundle *bundle, u_char *buf, size_t len) |
Parse the blocks received after the payload data, filling in the bundle with the relevant data if successful. | |
static size_t | header_block_length (const Bundle *bundle) |
Return the length of the header blocks. | |
static size_t | tail_block_length (const Bundle *bundle) |
Return the length of the tail blocks. | |
static size_t | formatted_length (const Bundle *bundle) |
Return the length of the on-the-wire bundle protocol format for the whole bundle, i.e. | |
static int | format_bundle (const Bundle *bundle, u_char *buf, size_t len) |
Format the whole bundle, stuffing it in the supplied buffer. | |
static int | parse_bundle (Bundle *bundle, u_char *buf, size_t len) |
Parse a whole bundle. | |
static void | set_timestamp (u_char *bp, const BundleTimestamp *tv) |
Store a DTN timestamp into a 64-bit timestamp suitable for transmission over the network. | |
static void | set_timestamp (u_int64_t *bp, const BundleTimestamp *tv) |
Store a struct timeval into a 64-bit timestamp suitable for transmission over the network. | |
static void | get_timestamp (BundleTimestamp *tv, const u_char *bp) |
Retrieve a struct timeval from a 64-bit timestamp that was transmitted over the network. | |
static void | get_timestamp (BundleTimestamp *tv, const u_int64_t *bp) |
Retrieve a struct timeval from a 64-bit timestamp that was transmitted over the network. | |
static bool | get_admin_type (const Bundle *bundle, admin_record_type_t *type) |
Assuming the given bundle is an administrative bundle, extract the admin bundle type code from the bundle's payload. | |
Public Attributes | |
dtn::BundleProtocol::PrimaryBlock1 | packed |
The first fixed-field portion of the primary bundle block preamble structure. | |
dtn::BundleProtocol::PrimaryBlock2 | packed |
The remainder of the fixed-length part of the primary bundle block that immediately follows the block length. | |
dtn::BundleProtocol::BlockPreamble | packed |
The basic block preamble that's common to all blocks (including the payload block but not the primary block). | |
Static Public Attributes | |
static const int | CURRENT_VERSION = 0x04 |
The current version of the bundling protocol. | |
Static Protected Member Functions | |
static size_t | get_primary_len (const Bundle *bundle, DictionaryVector *dict, size_t *dictionary_len, size_t *primary_var_len) |
static size_t | get_payload_block_len (const Bundle *bundle) |
static void | add_to_dictionary (const EndpointID &eid, DictionaryVector *dict, size_t *dictlen) |
static void | get_dictionary_offsets (DictionaryVector *dict, EndpointID eid, u_int16_t *scheme_offset, u_int16_t *ssp_offset) |
static u_int8_t | format_bundle_flags (const Bundle *bundle) |
static void | parse_bundle_flags (Bundle *bundle, u_int8_t flags) |
static u_int8_t | format_cos_flags (const Bundle *bundle) |
static void | parse_cos_flags (Bundle *bundle, u_int8_t cos_flags) |
static u_int8_t | format_srr_flags (const Bundle *bundle) |
static void | parse_srr_flags (Bundle *bundle, u_int8_t srr_flags) |
Classes | |
struct | BlockPreamble |
The basic block preamble that's common to all blocks (including the payload block but not the primary block). More... | |
struct | PrimaryBlock1 |
The first fixed-field portion of the primary bundle block preamble structure. More... | |
struct | PrimaryBlock2 |
The remainder of the fixed-length part of the primary bundle block that immediately follows the block length. More... |
Values for bundle processing flags that appear in the primary block.
BUNDLE_IS_FRAGMENT | |
BUNDLE_IS_ADMIN | |
BUNDLE_DO_NOT_FRAGMENT | |
BUNDLE_CUSTODY_XFER_REQUESTED | |
BUNDLE_SINGLETON_DESTINATION |
Definition at line 193 of file BundleProtocol.h.
Valid type codes for bundle blocks other than the primary block.
Definition at line 235 of file BundleProtocol.h.
Values for block processing flags that appear in all blocks except the primary block.
BLOCK_FLAG_REPLICATE | |
BLOCK_FLAG_REPORT_ONERROR | |
BLOCK_FLAG_DISCARD_ONERROR | |
BLOCK_FLAG_LAST_BLOCK |
Definition at line 243 of file BundleProtocol.h.
Bundle Status Report Status Flags.
STATUS_RECEIVED | |
STATUS_CUSTODY_ACCEPTED | |
STATUS_FORWARDED | |
STATUS_DELIVERED | |
STATUS_DELETED | |
STATUS_ACKED_BY_APP | |
STATUS_UNUSED | |
STATUS_UNUSED2 |
Definition at line 281 of file BundleProtocol.h.
Bundle Status Report "Reason Code" flags.
Definition at line 295 of file BundleProtocol.h.
Custody Signal Reason Codes.
CUSTODY_NO_ADDTL_INFO | |
CUSTODY_REDUNDANT_RECEPTION | |
CUSTODY_DEPLETED_STORAGE | |
CUSTODY_ENDPOINT_ID_UNINTELLIGIBLE | |
CUSTODY_NO_ROUTE_TO_DEST | |
CUSTODY_NO_TIMELY_CONTACT | |
CUSTODY_BLOCK_UNINTELLIGIBLE |
Definition at line 310 of file BundleProtocol.h.
int dtn::BundleProtocol::format_header_blocks | ( | const Bundle * | bundle, | |
u_char * | buf, | |||
size_t | len | |||
) | [static] |
Fill in the given buffer with the formatted bundle blocks that should go before the payload data, including the payload block header (i.e.
typecode, flags, and length) but none of the payload data.
Definition at line 192 of file BundleProtocol.cc.
References oasys::__log_enabled(), oasys::StringBuffer::appendf(), ASSERT, BLOCK_FLAG_LAST_BLOCK, dtn::BundleProtocol::PrimaryBlock1::block_length, dtn::BundleProtocol::PrimaryBlock1::bundle_processing_flags, oasys::StringBuffer::c_str(), dtn::BundleProtocol::PrimaryBlock1::class_of_service_flags, dtn::BundleProtocol::PrimaryBlock2::creation_ts, dtn::Bundle::creation_ts_, CURRENT_VERSION, dtn::Bundle::custodian_, dtn::BundleProtocol::PrimaryBlock2::custodian_scheme_offset, dtn::BundleProtocol::PrimaryBlock2::custodian_ssp_offset, dtn::Bundle::dest_, dtn::BundleProtocol::PrimaryBlock2::dest_scheme_offset, dtn::BundleProtocol::PrimaryBlock2::dest_ssp_offset, dtn::SDNV::encode(), dtn::SDNV::encoding_len(), dtn::Bundle::expiration_, dtn::BundleProtocol::BlockPreamble::flags, format_bundle_flags(), format_cos_flags(), format_srr_flags(), dtn::Bundle::frag_offset_, get_dictionary_offsets(), get_primary_len(), dtn::Bundle::is_fragment_, dtn::BundlePayload::length(), dtn::BundleProtocol::PrimaryBlock2::lifetime, oasys::LOG_DEBUG, log_debug, dtn::Bundle::orig_length_, dtn::Bundle::payload_, PAYLOAD_BLOCK, dtn::Bundle::replyto_, dtn::BundleProtocol::PrimaryBlock2::replyto_scheme_offset, dtn::BundleProtocol::PrimaryBlock2::replyto_ssp_offset, set_timestamp(), dtn::Bundle::source_, dtn::BundleProtocol::PrimaryBlock2::source_scheme_offset, dtn::BundleProtocol::PrimaryBlock2::source_ssp_offset, dtn::BundleProtocol::PrimaryBlock1::status_report_request_flags, dtn::BundleProtocol::BlockPreamble::type, and dtn::BundleProtocol::PrimaryBlock1::version.
Referenced by format_bundle(), dtn::UDPConvergenceLayer::Sender::send_bundle(), dtn::FileConvergenceLayer::send_bundle(), dtn::BluetoothConvergenceLayer::Connection::send_bundle(), and dtn::StreamConvergenceLayer::Connection::start_next_bundle().
int dtn::BundleProtocol::parse_header_blocks | ( | Bundle * | bundle, | |
u_char * | buf, | |||
size_t | len | |||
) | [static] |
Parse the received blocks, filling in the bundle with the relevant data if successful.
This succeeds iff the buffer contains a payload block header, and returns the length of all blocks up to the first byte of payload data.
Note that this implementation doesn't support sizes bigger than 4GB for the headers.
Definition at line 363 of file BundleProtocol.cc.
References oasys::__log_enabled(), oasys::StringBuffer::appendf(), ASSERT, BLOCK_FLAG_LAST_BLOCK, dtn::BundleProtocol::PrimaryBlock1::bundle_processing_flags, oasys::StringBuffer::c_str(), dtn::BundleProtocol::PrimaryBlock1::class_of_service_flags, dtn::BundleProtocol::PrimaryBlock2::creation_ts, dtn::Bundle::creation_ts_, CURRENT_VERSION, dtn::SDNV::decode(), dtn::Bundle::expiration_, EXTRACT_DICTIONARY_EID, dtn::BundleProtocol::BlockPreamble::flags, dtn::Bundle::frag_offset_, get_timestamp(), dtn::Bundle::is_fragment_, dtn::BundlePayload::length(), dtn::BundleProtocol::PrimaryBlock2::lifetime, log_crit, oasys::LOG_DEBUG, log_debug, log_err, log_warn, dtn::Bundle::orig_length_, parse_bundle_flags(), parse_cos_flags(), parse_srr_flags(), dtn::Bundle::payload_, PAYLOAD_BLOCK, dtn::BundlePayload::set_length(), dtn::BundleProtocol::PrimaryBlock1::status_report_request_flags, dtn::BundleProtocol::BlockPreamble::type, and dtn::BundleProtocol::PrimaryBlock1::version.
Referenced by dtn::StreamConvergenceLayer::Connection::handle_data_segment(), parse_bundle(), dtn::UDPConvergenceLayer::Receiver::process_data(), dtn::BluetoothConvergenceLayer::Connection::recv_bundle(), and dtn::FileConvergenceLayer::Scanner::run().
static int dtn::BundleProtocol::format_tail_blocks | ( | const Bundle * | bundle, | |
u_char * | buf, | |||
size_t | len | |||
) | [inline, static] |
Fill in the given buffer with the formatted bundle blocks that should go after the payload data.
Definition at line 90 of file BundleProtocol.h.
Referenced by format_bundle().
static int dtn::BundleProtocol::parse_tail_blocks | ( | Bundle * | bundle, | |
u_char * | buf, | |||
size_t | len | |||
) | [inline, static] |
Parse the blocks received after the payload data, filling in the bundle with the relevant data if successful.
Definition at line 107 of file BundleProtocol.h.
Referenced by parse_bundle().
size_t dtn::BundleProtocol::header_block_length | ( | const Bundle * | bundle | ) | [static] |
Return the length of the header blocks.
Definition at line 613 of file BundleProtocol.cc.
References get_payload_block_len(), and get_primary_len().
Referenced by formatted_length(), dtn::StreamConvergenceLayer::Connection::handle_send_bundle(), and dtn::StreamConvergenceLayer::Connection::start_next_bundle().
static size_t dtn::BundleProtocol::tail_block_length | ( | const Bundle * | bundle | ) | [inline, static] |
Return the length of the tail blocks.
Definition at line 124 of file BundleProtocol.h.
Referenced by formatted_length(), and dtn::StreamConvergenceLayer::Connection::handle_send_bundle().
size_t dtn::BundleProtocol::formatted_length | ( | const Bundle * | bundle | ) | [static] |
Return the length of the on-the-wire bundle protocol format for the whole bundle, i.e.
Definition at line 627 of file BundleProtocol.cc.
References header_block_length(), dtn::BundlePayload::length(), dtn::Bundle::payload_, and tail_block_length().
Referenced by dtn::BundleDaemon::handle_bundle_transmitted(), dtn::StreamConvergenceLayer::Connection::handle_end_bundle(), dtn::StreamConvergenceLayer::Connection::initiate_contact(), dtn::UDPConvergenceLayer::Sender::send_bundle(), and dtn::BundleActions::send_bundle().
int dtn::BundleProtocol::format_bundle | ( | const Bundle * | bundle, | |
u_char * | buf, | |||
size_t | len | |||
) | [static] |
Format the whole bundle, stuffing it in the supplied buffer.
Definition at line 636 of file BundleProtocol.cc.
References dtn::BundlePayload::FORCE_COPY, format_header_blocks(), format_tail_blocks(), dtn::BundlePayload::length(), dtn::Bundle::payload_, and dtn::BundlePayload::read_data().
Referenced by dtn::StreamConvergenceLayer::Connection::initiate_contact().
int dtn::BundleProtocol::parse_bundle | ( | Bundle * | bundle, | |
u_char * | buf, | |||
size_t | len | |||
) | [static] |
Parse a whole bundle.
Definition at line 670 of file BundleProtocol.cc.
References dtn::BundlePayload::length(), parse_header_blocks(), parse_tail_blocks(), dtn::Bundle::payload_, and dtn::BundlePayload::set_data().
Referenced by dtn::StreamConvergenceLayer::Connection::handle_contact_initiation().
void dtn::BundleProtocol::set_timestamp | ( | u_char * | bp, | |
const BundleTimestamp * | tv | |||
) | [static] |
Store a DTN timestamp into a 64-bit timestamp suitable for transmission over the network.
Definition at line 703 of file BundleProtocol.cc.
References dtn::BundleTimestamp::seconds_, and dtn::BundleTimestamp::seqno_.
Referenced by dtn::CustodySignal::create_custody_signal(), dtn::BundleStatusReport::create_status_report(), format_header_blocks(), and set_timestamp().
static void dtn::BundleProtocol::set_timestamp | ( | u_int64_t * | bp, | |
const BundleTimestamp * | tv | |||
) | [inline, static] |
Store a struct timeval into a 64-bit timestamp suitable for transmission over the network.
The implementation doesn't require the 64-bit destination to be word-aligned so it is safe to cast here.
Definition at line 164 of file BundleProtocol.h.
References set_timestamp().
void dtn::BundleProtocol::get_timestamp | ( | BundleTimestamp * | tv, | |
const u_char * | bp | |||
) | [static] |
Retrieve a struct timeval from a 64-bit timestamp that was transmitted over the network.
This does not require the timestamp to be word-aligned.
Definition at line 717 of file BundleProtocol.cc.
References dtn::BundleTimestamp::seconds_, and dtn::BundleTimestamp::seqno_.
Referenced by get_timestamp(), dtn::CustodySignal::parse_custody_signal(), parse_header_blocks(), and dtn::BundleStatusReport::parse_status_report().
static void dtn::BundleProtocol::get_timestamp | ( | BundleTimestamp * | tv, | |
const u_int64_t * | bp | |||
) | [inline, static] |
Retrieve a struct timeval from a 64-bit timestamp that was transmitted over the network.
This does not require the timestamp to be word-aligned.
Definition at line 180 of file BundleProtocol.h.
References get_timestamp().
bool dtn::BundleProtocol::get_admin_type | ( | const Bundle * | bundle, | |
admin_record_type_t * | type | |||
) | [static] |
Assuming the given bundle is an administrative bundle, extract the admin bundle type code from the bundle's payload.
Definition at line 853 of file BundleProtocol.cc.
References ADMIN_ANNOUNCE, ADMIN_CUSTODY_SIGNAL, ADMIN_ECHO, ADMIN_NULL, ADMIN_STATUS_REPORT, CASE, dtn::Bundle::is_admin_, NOTREACHED, dtn::Bundle::payload_, and dtn::BundlePayload::read_data().
Referenced by dtn::TclRegistration::parse_bundle_data().
size_t dtn::BundleProtocol::get_primary_len | ( | const Bundle * | bundle, | |
DictionaryVector * | dict, | |||
size_t * | dictionary_len, | |||
size_t * | primary_var_len | |||
) | [static, protected] |
Definition at line 118 of file BundleProtocol.cc.
References add_to_dictionary(), dtn::Bundle::bundleid_, dtn::Bundle::custodian_, dtn::Bundle::dest_, dtn::SDNV::encoding_len(), dtn::Bundle::frag_offset_, dtn::Bundle::is_fragment_, log_debug, dtn::Bundle::orig_length_, dtn::Bundle::replyto_, and dtn::Bundle::source_.
Referenced by format_header_blocks(), and header_block_length().
size_t dtn::BundleProtocol::get_payload_block_len | ( | const Bundle * | bundle | ) | [static, protected] |
Definition at line 184 of file BundleProtocol.cc.
References dtn::SDNV::encoding_len(), dtn::BundlePayload::length(), and dtn::Bundle::payload_.
Referenced by header_block_length().
void dtn::BundleProtocol::add_to_dictionary | ( | const EndpointID & | eid, | |
DictionaryVector * | dict, | |||
size_t * | dictlen | |||
) | [static, protected] |
Definition at line 66 of file BundleProtocol.cc.
References dtn::EndpointID::scheme_str(), and dtn::EndpointID::ssp().
Referenced by get_primary_len().
void dtn::BundleProtocol::get_dictionary_offsets | ( | DictionaryVector * | dict, | |
EndpointID | eid, | |||
u_int16_t * | scheme_offset, | |||
u_int16_t * | ssp_offset | |||
) | [static, protected] |
Definition at line 101 of file BundleProtocol.cc.
References dtn::EndpointID::scheme_str(), and dtn::EndpointID::ssp().
Referenced by format_header_blocks().
u_int8_t dtn::BundleProtocol::format_bundle_flags | ( | const Bundle * | bundle | ) | [static, protected] |
Definition at line 731 of file BundleProtocol.cc.
References BUNDLE_CUSTODY_XFER_REQUESTED, BUNDLE_DO_NOT_FRAGMENT, BUNDLE_IS_ADMIN, BUNDLE_IS_FRAGMENT, BUNDLE_SINGLETON_DESTINATION, dtn::Bundle::custody_requested_, dtn::Bundle::do_not_fragment_, dtn::Bundle::is_admin_, dtn::Bundle::is_fragment_, and dtn::Bundle::singleton_dest_.
Referenced by format_header_blocks().
void dtn::BundleProtocol::parse_bundle_flags | ( | Bundle * | bundle, | |
u_int8_t | flags | |||
) | [static, protected] |
Definition at line 760 of file BundleProtocol.cc.
References BUNDLE_CUSTODY_XFER_REQUESTED, BUNDLE_DO_NOT_FRAGMENT, BUNDLE_IS_ADMIN, BUNDLE_IS_FRAGMENT, BUNDLE_SINGLETON_DESTINATION, dtn::Bundle::custody_requested_, dtn::Bundle::do_not_fragment_, dtn::Bundle::is_admin_, dtn::Bundle::is_fragment_, and dtn::Bundle::singleton_dest_.
Referenced by parse_header_blocks().
u_int8_t dtn::BundleProtocol::format_cos_flags | ( | const Bundle * | bundle | ) | [static, protected] |
Definition at line 785 of file BundleProtocol.cc.
References dtn::Bundle::priority_.
Referenced by format_header_blocks().
void dtn::BundleProtocol::parse_cos_flags | ( | Bundle * | bundle, | |
u_int8_t | cos_flags | |||
) | [static, protected] |
Definition at line 796 of file BundleProtocol.cc.
References dtn::Bundle::priority_.
Referenced by parse_header_blocks().
u_int8_t dtn::BundleProtocol::format_srr_flags | ( | const Bundle * | bundle | ) | [static, protected] |
Definition at line 803 of file BundleProtocol.cc.
References dtn::Bundle::app_acked_rcpt_, dtn::Bundle::custody_rcpt_, dtn::Bundle::deletion_rcpt_, dtn::Bundle::delivery_rcpt_, dtn::Bundle::forward_rcpt_, dtn::Bundle::receive_rcpt_, STATUS_ACKED_BY_APP, STATUS_CUSTODY_ACCEPTED, STATUS_DELETED, STATUS_DELIVERED, STATUS_FORWARDED, and STATUS_RECEIVED.
Referenced by format_header_blocks().
void dtn::BundleProtocol::parse_srr_flags | ( | Bundle * | bundle, | |
u_int8_t | srr_flags | |||
) | [static, protected] |
Definition at line 830 of file BundleProtocol.cc.
References dtn::Bundle::app_acked_rcpt_, dtn::Bundle::custody_rcpt_, dtn::Bundle::deletion_rcpt_, dtn::Bundle::delivery_rcpt_, dtn::Bundle::forward_rcpt_, dtn::Bundle::receive_rcpt_, STATUS_ACKED_BY_APP, STATUS_CUSTODY_ACCEPTED, STATUS_DELETED, STATUS_DELIVERED, STATUS_FORWARDED, and STATUS_RECEIVED.
Referenced by parse_header_blocks().
const int dtn::BundleProtocol::CURRENT_VERSION = 0x04 [static] |
The current version of the bundling protocol.
Definition at line 187 of file BundleProtocol.h.
Referenced by format_header_blocks(), and parse_header_blocks().
The first fixed-field portion of the primary bundle block preamble structure.
The remainder of the fixed-length part of the primary bundle block that immediately follows the block length.
The basic block preamble that's common to all blocks (including the payload block but not the primary block).