dtn::data::NetworkFrame Class Reference

#include <NetworkFrame.h>

List of all members.

Public Member Functions

 NetworkFrame ()
 NetworkFrame (const unsigned char *data, const unsigned int size)
 ~NetworkFrame ()
 NetworkFrame (const NetworkFrame &k)
 NetworkFrame (const NetworkFrame *k)
NetworkFrameoperator= (const NetworkFrame &k)
unsigned int append (const unsigned char *data, const unsigned int size)
unsigned int append (const u_int64_t value)
unsigned int append (const int value)
unsigned int append (const unsigned int value)
unsigned int append (const char value)
unsigned int append (const unsigned char value)
unsigned int append (const string value)
unsigned int append (const double value)
map< unsigned int, unsigned int > & getFieldSizeMap ()
void setFieldSizeMap (map< unsigned int, unsigned int > mapping)
unsigned char * getData () const
unsigned int getSize () const
unsigned int getSize (const unsigned int field) const
unsigned char * get (const unsigned int field) const
u_int64_t getSDNV (const unsigned int field) const
unsigned char getChar (const unsigned int field) const
string getString (const unsigned int field) const
double getDouble (const unsigned int field) const
unsigned int getPosition (const unsigned int field) const
void set (const unsigned int field, const unsigned char *data, const unsigned int size)
void set (const unsigned int field, const u_int64_t value)
void set (const unsigned int field, const int value)
void set (const unsigned int field, const char value)
void set (const unsigned int field, const string value)
void set (const unsigned int field, const unsigned int value)
void set (const unsigned int field, const unsigned char value)
void set (const unsigned int field, double value)
void set (const unsigned int field, NetworkFrame &data)
void remove (const unsigned int field)
void insert (const unsigned int field)
size_t write (FILE *stream)
void changeSize (unsigned int field, unsigned int size)
void updateSize ()

Protected Member Functions

 NetworkFrame (unsigned char *data, unsigned int size, map< unsigned int, unsigned int > fieldsizes)

Private Member Functions

void moveData (unsigned char *data, unsigned int size, int offset)

Private Attributes

unsigned char * m_data
map< unsigned int, unsigned int > m_fieldsizes
unsigned int m_size


Constructor & Destructor Documentation

dtn::data::NetworkFrame::NetworkFrame (  ) 

Create a new empty Frame with a length of zero.

References m_data.

dtn::data::NetworkFrame::NetworkFrame ( const unsigned char *  data,
const unsigned int  size 
)

Create a new Frame with a copy of the given data.

Parameters:
[in] data The data for the new frame.
[in] size The length of the data.

References m_data.

dtn::data::NetworkFrame::~NetworkFrame (  ) 

Clean-up all the data of this object and free the data-array.

References m_data.

dtn::data::NetworkFrame::NetworkFrame ( const NetworkFrame k  ) 

Copy constructor.

Parameters:
[in] k The NetworkFrame to copy.

References m_data, m_fieldsizes, and m_size.

dtn::data::NetworkFrame::NetworkFrame ( const NetworkFrame k  ) 

Copy constructor.

Parameters:
[in] k The NetworkFrame to copy.

References m_data, m_fieldsizes, and m_size.

dtn::data::NetworkFrame::NetworkFrame ( unsigned char *  data,
unsigned int  size,
map< unsigned int, unsigned int >  fieldsizes 
) [protected]


Member Function Documentation

NetworkFrame & dtn::data::NetworkFrame::operator= ( const NetworkFrame k  ) 

Operator for assign a NetworkFrame.

Parameters:
[in] k The NetworkFrame to copy.
Returns:
The copy of the given NetworkFrame.

References m_data, m_fieldsizes, and m_size.

unsigned int dtn::data::NetworkFrame::append ( const unsigned char *  data,
const unsigned int  size 
)

unsigned int dtn::data::NetworkFrame::append ( const u_int64_t  value  ) 

Append a new field with a u_int64_t value encoded as a SDNV at the end of the NetworkFrame.

Parameters:
[in] value The u_int64_t value to be set.
Returns:
The field-index of the new field.

References dtn::data::SDNV::encode(), dtn::data::SDNV::encoding_len(), m_data, m_fieldsizes, and m_size.

unsigned int dtn::data::NetworkFrame::append ( const int  value  ) 

Append a new field with a int value encoded as a SDNV at the end of the NetworkFrame.

Parameters:
[in] value The int value to be set.
Returns:
The field-index of the new field.

References append().

unsigned int dtn::data::NetworkFrame::append ( const unsigned int  value  ) 

Append a new field with a unsigned int value encoded as a SDNV at the end of the NetworkFrame.

Parameters:
[in] value The unsigned int value to be set.
Returns:
The field-index of the new field.

References append().

unsigned int dtn::data::NetworkFrame::append ( const char  value  ) 

Append a new field with a char value at the end of the NetworkFrame.

Parameters:
[in] value The char value to be set.
Returns:
The field-index of the new field.

References append().

unsigned int dtn::data::NetworkFrame::append ( const unsigned char  value  ) 

Append a new field with a unsigned char value at the end of the NetworkFrame.

Parameters:
[in] value The unsigned char value to be set.
Returns:
The field-index of the new field.

References m_data, m_fieldsizes, and m_size.

unsigned int dtn::data::NetworkFrame::append ( const string  value  ) 

Append a new field with a string value at the end of the NetworkFrame.

Parameters:
[in] value The string value to be set.
Returns:
The field-index of the new field.

References append().

unsigned int dtn::data::NetworkFrame::append ( const double  value  ) 

Append a new field with a double value at the end of the NetworkFrame.

Parameters:
[in] value The double value to be set.
Returns:
The field-index of the new field.

References append().

map< unsigned int, unsigned int > & dtn::data::NetworkFrame::getFieldSizeMap (  ) 

void dtn::data::NetworkFrame::setFieldSizeMap ( map< unsigned int, unsigned int >  mapping  ) 

Set the field-size-mapping to a existing mapping.

Parameters:
[in] mapping A mapping for the data.

References m_fieldsizes, and updateSize().

Referenced by dtn::data::BlockFactory::parse(), and dtn::data::BundleFactory::parsePrimaryBlock().

unsigned char * dtn::data::NetworkFrame::getData (  )  const

Get method for the pointer of the data-array.

Returns:
A pointer of the data-array.

References m_data.

Referenced by emma::Measurement::add(), dtn::data::Bundle::getData(), dtn::core::TCPMessage::getData(), dtn::core::TCPConvergenceLayer::newConnection(), set(), and write().

unsigned int dtn::data::NetworkFrame::getSize (  )  const

unsigned int dtn::data::NetworkFrame::getSize ( const unsigned int  field  )  const

Get the length of a specific field.

Parameters:
[in] field The field-index of the field.
Returns:
The length of a specific field.

References m_fieldsizes.

unsigned char * dtn::data::NetworkFrame::get ( const unsigned int  field  )  const

Get method to return a pointer to a specific field.

Parameters:
[in] field The field-index of the field.
Returns:
A pointer to the data-array at the position of the field.

References getPosition(), and m_data.

Referenced by dtn::data::Bundle::commitDictionary(), dtn::data::Bundle::getDictionary(), dtn::data::PayloadBlock::getPayload(), and emma::DiscoverBlockFactory::parse().

u_int64_t dtn::data::NetworkFrame::getSDNV ( const unsigned int  field  )  const

unsigned char dtn::data::NetworkFrame::getChar ( const unsigned int  field  )  const

Get method for a unsigned char value of a specific field.

Parameters:
[in] field The field-index of the field.
Returns:
A value decoded as unsigned char.

Referenced by dtn::data::AdministrativeBlock::getStatusFlags(), dtn::data::Block::getType(), dtn::data::CustodySignalBlock::isAccepted(), dtn::data::CustodySignalBlock::setAccepted(), dtn::core::TCPMessage::setFirst(), and dtn::core::TCPMessage::setLast().

string dtn::data::NetworkFrame::getString ( const unsigned int  field  )  const

Get method for a string value of a specific field.

Parameters:
[in] field The field-index of the field.
Returns:
A value decoded as string.

References getSize().

Referenced by emma::DiscoverBlock::getConnectionAddress(), dtn::data::StatusReportBlock::getSource(), and dtn::data::CustodySignalBlock::getSource().

double dtn::data::NetworkFrame::getDouble ( const unsigned int  field  )  const

Get method for a double value of a specific field.

Parameters:
[in] field The field-index of the field.
Returns:
A value decoded as double.

unsigned int dtn::data::NetworkFrame::getPosition ( const unsigned int  field  )  const

Get method to find the position of a specific field in a data-array.

Parameters:
[in] field The field-index of the field.
Returns:
The begin of a field in the data-array.

References getSize(), and m_fieldsizes.

Referenced by changeSize(), get(), dtn::data::Bundle::getPosition(), and set().

void dtn::data::NetworkFrame::set ( const unsigned int  field,
const unsigned char *  data,
const unsigned int  size 
)

Copy a existing data-array to a field of this NetworkFrame.

Parameters:
[in] field The field-index of the field.
[in] data The data-array to be set.
[in] size The size of the data-array.

References changeSize(), getPosition(), and m_data.

Referenced by dtn::data::Bundle::commitDictionary(), dtn::data::PayloadBlockFactory::newCustodySignalBlock(), emma::DiscoverBlockFactory::newDiscoverBlock(), dtn::data::PayloadBlockFactory::newPayloadBlock(), dtn::data::PayloadBlockFactory::newStatusReportBlock(), dtn::data::CustodySignalBlock::setAccepted(), dtn::data::Block::setBlockFlags(), emma::DiscoverBlock::setConnectionAddress(), emma::DiscoverBlock::setConnectionPort(), dtn::data::StatusReportBlock::setCreationTimestamp(), dtn::data::CustodySignalBlock::setCreationTimestamp(), dtn::data::StatusReportBlock::setCreationTimestampSequence(), dtn::data::CustodySignalBlock::setCreationTimestampSequence(), dtn::data::Bundle::setCustodian(), dtn::data::Bundle::setDestination(), dtn::core::TCPMessage::setFirst(), dtn::data::StatusReportBlock::setFragmentLength(), dtn::data::CustodySignalBlock::setFragmentLength(), dtn::data::StatusReportBlock::setFragmentOffset(), dtn::data::CustodySignalBlock::setFragmentOffset(), dtn::data::Bundle::setInteger(), dtn::core::TCPMessage::setLast(), emma::DiscoverBlock::setLatitude(), emma::DiscoverBlock::setLongitude(), dtn::data::PayloadBlock::setPayload(), dtn::data::StatusReportBlock::setReasonCode(), dtn::data::Bundle::setReportTo(), dtn::data::StatusReportBlock::setSource(), dtn::data::CustodySignalBlock::setSource(), dtn::data::Bundle::setSource(), dtn::data::AdministrativeBlock::setStatusFlags(), dtn::data::StatusReportBlock::setTimeOfCustodyAcceptance(), dtn::data::StatusReportBlock::setTimeOfDeletion(), dtn::data::StatusReportBlock::setTimeOfDelivery(), dtn::data::StatusReportBlock::setTimeOfForwarding(), dtn::data::StatusReportBlock::setTimeOfReceipt(), dtn::data::CustodySignalBlock::setTimeOfSignal(), dtn::data::Bundle::updateBlockLength(), and dtn::data::Block::updateBlockSize().

void dtn::data::NetworkFrame::set ( const unsigned int  field,
const u_int64_t  value 
)

Set a u_int64_t value into a specific field, encoded as SDNV.

Parameters:
[in] field The field-index of the field.
[in] value The u_int64_t value to be set.

References changeSize(), dtn::data::SDNV::encode(), dtn::data::SDNV::encoding_len(), getPosition(), and m_data.

void dtn::data::NetworkFrame::set ( const unsigned int  field,
const int  value 
)

Set a int value into a specific field, encoded as SDNV.

Parameters:
[in] field The field-index of the field.
[in] value The int value to be set.

void dtn::data::NetworkFrame::set ( const unsigned int  field,
const char  value 
)

Set a char value into a specific field.

Parameters:
[in] field The field-index of the field.
[in] value The char value to be set.

void dtn::data::NetworkFrame::set ( const unsigned int  field,
const string  value 
)

Set a string into a specific field.

Parameters:
[in] field The field-index of the field.
[in] value The string value to be set.

void dtn::data::NetworkFrame::set ( const unsigned int  field,
const unsigned int  value 
)

Set a unsigned int value into a specific field, encoded as SDNV.

Parameters:
[in] field The field-index of the field.
[in] value The unsigned int value to be set.

void dtn::data::NetworkFrame::set ( const unsigned int  field,
const unsigned char  value 
)

Set a unsigned char value into a specific field.

Parameters:
[in] field The field-index of the field.
[in] value The unsigned char value to be set.

References changeSize(), getPosition(), and m_data.

void dtn::data::NetworkFrame::set ( const unsigned int  field,
double  value 
)

Set a double value into a specific field.

Parameters:
[in] field The field-index of the field.
[in] value The double value to be set.

void dtn::data::NetworkFrame::set ( const unsigned int  field,
NetworkFrame data 
)

Copy a existing NetworkFrame into the data-array of this NetworkFrame.

Parameters:
[in] field The field-index of the field.
[in] data A reference to the NetworkFrame with data to copy.

References getData(), getFieldSizeMap(), getSize(), and m_fieldsizes.

void dtn::data::NetworkFrame::remove ( const unsigned int  field  ) 

Remove a specific field from the NetworkFrame.

Parameters:
[in] field The field-index of the field.

References changeSize(), and m_fieldsizes.

Referenced by dtn::data::Bundle::setFragment().

void dtn::data::NetworkFrame::insert ( const unsigned int  field  ) 

Insert a new field into the NetworkFrame with the given field-index. All existing field are renumbered.

Parameters:
[in] field The number of the new field.

References m_fieldsizes.

Referenced by dtn::data::StatusReportBlock::setFragmentLength(), dtn::data::CustodySignalBlock::setFragmentLength(), dtn::data::StatusReportBlock::setFragmentOffset(), and dtn::data::CustodySignalBlock::setFragmentOffset().

size_t dtn::data::NetworkFrame::write ( FILE *  stream  ) 

Write a NetworkFrame to a FILE stream.

Parameters:
[in] stream A opened filestream.
Returns:
The size of written bytes.

References getData(), and getSize().

void dtn::data::NetworkFrame::changeSize ( unsigned int  field,
unsigned int  size 
)

Change the size of a field to a specific value.

Parameters:
[in] field The field-index of the field.
[in] size The new size of the field.

References getPosition(), m_data, m_fieldsizes, m_size, and moveData().

Referenced by dtn::data::Bundle::commitDictionary(), remove(), and set().

void dtn::data::NetworkFrame::updateSize (  ) 

void dtn::data::NetworkFrame::moveData ( unsigned char *  data,
unsigned int  size,
int  offset 
) [private]

Method to move data to front or back of a data-array.

Parameters:
[in,out] data Data-array to be changed.
[in] size The length of the data-array.
[in] offset The begin of the data to move.

Referenced by changeSize().


Member Data Documentation

unsigned char* dtn::data::NetworkFrame::m_data [private]

map<unsigned int, unsigned int> dtn::data::NetworkFrame::m_fieldsizes [private]

Mapping between field-index and length of the field.

Referenced by append(), changeSize(), getFieldSizeMap(), getPosition(), getSize(), insert(), NetworkFrame(), operator=(), remove(), set(), setFieldSizeMap(), and updateSize().

unsigned int dtn::data::NetworkFrame::m_size [private]

Full length of the NetworkFrame.

Referenced by append(), changeSize(), getSize(), NetworkFrame(), operator=(), and updateSize().


The documentation for this class was generated from the following files:

Generated on Wed Mar 25 12:41:43 2009 for IBR-DTN by  doxygen 1.5.6