dtn::SDNV Class Reference

#include <SDNV.h>

List of all members.


Detailed Description

Class to handle parsing and formatting of self describing numeric values (SDNVs).

The basic idea is to enable a compact byte representation of numeric values that may widely vary in size. This encoding is based on the ASN.1 specification for encoding Object Identifier Arcs.

Conceptually, the integer value to be encoded is split into 7-bit segments. These are encoded into the output byte stream, such that the high order bit in each byte is set to one for all bytes except the last one.

Note that this implementation only handles values up to 64-bits in length (since the conversion is between a u_int64_t and the encoded byte sequence).

Definition at line 62 of file SDNV.h.

Static Public Member Functions

static size_t encoding_len (u_int64_t val)
 Return the number of bytes needed to encode the given value.
static int encode (u_int64_t val, u_char *bp, size_t len)
 Convert the given 64-bit integer into an SDNV.
static int decode (const u_char *bp, size_t len, u_int64_t *val)
 Convert an SDNV pointed to by bp into a unsigned 64-bit integer.
static int decode (const u_char *bp, size_t len, u_int32_t *val)
 Convert an SDNV pointed to by bp into a unsigned 32-bit integer.


Member Function Documentation

size_t dtn::SDNV::encoding_len ( u_int64_t  val  )  [static]

Return the number of bytes needed to encode the given value.

Definition at line 91 of file SDNV.cc.

References ASSERT, and encode().

Referenced by dtn::CustodySignal::create_custody_signal(), dtn::BundleStatusReport::create_status_report(), dtn::BundleProtocol::format_header_blocks(), dtn::BundleProtocol::get_payload_block_len(), dtn::BundleProtocol::get_primary_len(), dtn::StreamConvergenceLayer::Connection::initiate_contact(), dtn::BluetoothConvergenceLayer::Connection::send_bundle(), dtn::StreamConvergenceLayer::Connection::send_next_segment(), dtn::StreamConvergenceLayer::Connection::send_pending_acks(), and dtn::StreamConvergenceLayer::Connection::start_next_bundle().

int dtn::SDNV::encode ( u_int64_t  val,
u_char *  bp,
size_t  len 
) [static]

Convert the given 64-bit integer into an SDNV.

Returns:
The number of bytes used, or -1 on error.

Definition at line 47 of file SDNV.cc.

References ASSERT.

Referenced by dtn::CustodySignal::create_custody_signal(), dtn::BundleStatusReport::create_status_report(), encoding_len(), dtn::BundleProtocol::format_header_blocks(), dtn::StreamConvergenceLayer::Connection::initiate_contact(), dtn::BluetoothConvergenceLayer::Connection::send_bundle(), dtn::StreamConvergenceLayer::Connection::send_next_segment(), dtn::StreamConvergenceLayer::Connection::send_pending_acks(), and dtn::StreamConvergenceLayer::Connection::start_next_bundle().

int dtn::SDNV::decode ( const u_char *  bp,
size_t  len,
u_int64_t *  val 
) [static]

Convert an SDNV pointed to by bp into a unsigned 64-bit integer.

Returns:
The number of bytes of bp consumed, or -1 on error.

Definition at line 100 of file SDNV.cc.

References log_err.

Referenced by decode(), dtn::StreamConvergenceLayer::Connection::handle_ack_segment(), dtn::StreamConvergenceLayer::Connection::handle_contact_initiation(), dtn::StreamConvergenceLayer::Connection::handle_data_segment(), dtn::CustodySignal::parse_custody_signal(), dtn::BundleProtocol::parse_header_blocks(), dtn::BundleStatusReport::parse_status_report(), and dtn::BluetoothConvergenceLayer::Connection::recv_bundle().

static int dtn::SDNV::decode ( const u_char *  bp,
size_t  len,
u_int32_t *  val 
) [inline, static]

Convert an SDNV pointed to by bp into a unsigned 32-bit integer.

Checks for overflow in the SDNV.

Returns:
The number of bytes of bp consumed, or -1 on error.

Definition at line 90 of file SDNV.h.

References decode().


The documentation for this class was generated from the following files:
Generated on Fri Dec 22 14:48:03 2006 for DTN Reference Implementation by  doxygen 1.5.1