#include <BundleFactory.h>
Public Member Functions | |
| void | registerExtensionBlock (BlockFactory *f) |
| void | unregisterExtensionBlock (BlockFactory *f) |
| Bundle * | parse (const unsigned char *data, unsigned int size) const |
| Bundle * | newBundle () |
| Block * | copyBlock (const Block &block) const |
| unsigned int | getSequenceNumber () |
Static Public Member Functions | |
| static BundleFactory & | getInstance () |
| static unsigned int | getDTNTime () |
| static list< Bundle > | split (const Bundle &bundle, unsigned int maxsize) |
| static Bundle * | slice (const Bundle &bundle, unsigned int size, unsigned int &offset) |
| static Bundle * | cut (const Bundle &bundle, unsigned int size, unsigned int &offset) |
| static pair< Bundle *, Bundle * > | cutAt (const Bundle &bundle, unsigned int position) |
| static Bundle * | merge (list< Bundle > &bundles) |
| static Bundle * | merge (const Bundle &fragment1, const Bundle &fragment2) |
Private Member Functions | |
| BundleFactory () | |
| virtual | ~BundleFactory () |
| BlockFactory & | getExtension (unsigned char type) |
| map< char, BlockFactory * > & | getExtensions () |
| Bundle * | createBundle (bool fragmented=false) |
| NetworkFrame * | parsePrimaryBlock (const unsigned char *data, unsigned int size) const |
Static Private Member Functions | |
| static bool | compareFragments (const Bundle &first, const Bundle &second) |
| static Block * | getBlock (const unsigned char *data, unsigned int size) |
Private Attributes | |
| BlockFactory | m_blockfactory |
| map< char, BlockFactory * > | m_extensions |
Static Private Attributes | |
| static unsigned int | SECONDS_TILL_2000 = 946681200 |
| dtn::data::BundleFactory::BundleFactory | ( | ) | [private] |
References registerExtensionBlock().
| dtn::data::BundleFactory::~BundleFactory | ( | ) | [private, virtual] |
References dtn::data::PayloadBlock::BLOCK_TYPE, m_extensions, and unregisterExtensionBlock().
| BundleFactory & dtn::data::BundleFactory::getInstance | ( | ) | [static] |
Returns a static instance of the BundleFactory.
Referenced by dtn::data::Bundle::Bundle(), copyBlock(), and getBlock().
| void dtn::data::BundleFactory::registerExtensionBlock | ( | BlockFactory * | f | ) |
Register a BlockFactory for parsing extension blocks of a bundle.
| [in] | f | Pointer to a instance of the BlockFactory. |
References dtn::data::BlockFactory::getBlockType(), and m_extensions.
Referenced by BundleFactory().
| void dtn::data::BundleFactory::unregisterExtensionBlock | ( | BlockFactory * | f | ) |
Removes a BlockFactory for parsing extension blocks of a bundle.
| [in] | f | Pointer to a instance of the BlockFactory. |
References dtn::data::BlockFactory::getBlockType(), and m_extensions.
Referenced by ~BundleFactory().
| Bundle * dtn::data::BundleFactory::parse | ( | const unsigned char * | data, | |
| unsigned int | size | |||
| ) | const |
Parse some given data and create a bundle object out of the data.
| [in] | data | A pointer to a data array of bundle data. |
| [in] | size | The size of the data array. |
References dtn::data::PayloadBlockFactory::castAdministrativeBlock(), getBlock(), dtn::data::Block::getFrame(), dtn::data::NetworkFrame::getSDNV(), dtn::data::NetworkFrame::getSize(), parsePrimaryBlock(), and dtn::data::PROCFLAGS.
Referenced by dtn::core::TCPConnection::receive(), and dtn::core::UDPConvergenceLayer::receiveBundle().
| Bundle * dtn::data::BundleFactory::newBundle | ( | ) |
Create a new empty bundle object.
References dtn::data::Dictionary::add(), dtn::data::NetworkFrame::append(), dtn::data::CREATION_TIMESTAMP, dtn::data::CREATION_TIMESTAMP_SEQUENCE, dtn::data::DICTIONARY_BYTEARRAY, dtn::data::DICTIONARY_LENGTH, getDTNTime(), dtn::data::Dictionary::getLength(), getSequenceNumber(), dtn::data::ProcessingFlags::getValue(), dtn::data::LIFETIME, dtn::data::PrimaryFlags::setEIDSingleton(), dtn::data::Bundle::updateBlockLength(), and dtn::data::Dictionary::write().
Referenced by dtn::daemon::EchoWorker::callbackBundleReceived(), dtn::core::BundleCore::createCustodySignal(), dtn::core::BundleCore::createStatusReport(), dtn::daemon::TestApplication::reportIt(), emma::MeasurementWorker::tick(), and emma::EmmaConvergenceLayer::yell().
Makes a copy of a block.
| block | The block to copy. |
References dtn::data::BlockFactory::copy(), getExtension(), getInstance(), and dtn::data::Block::getType().
Referenced by dtn::data::Bundle::Bundle().
| unsigned int dtn::data::BundleFactory::getDTNTime | ( | ) | [static] |
Get the current dtn time which is the seconds since the year 2000.
References SECONDS_TILL_2000.
Referenced by dtn::data::Bundle::isExpired(), newBundle(), and dtn::data::PayloadBlockFactory::newCustodySignalBlock().
| unsigned int dtn::data::BundleFactory::getSequenceNumber | ( | ) |
Get a new sequence number and count up the internal counter.
Referenced by newBundle().
| list< Bundle > dtn::data::BundleFactory::split | ( | const Bundle & | bundle, | |
| unsigned int | maxsize | |||
| ) | [static] |
Split a bundle into a list of bundle fragments.
| [in] | bundle | The bundle to split. |
| [in] | maxsize | The maximum size of a fragment. |
References slice().
| Bundle * dtn::data::BundleFactory::slice | ( | const Bundle & | bundle, | |
| unsigned int | size, | |||
| unsigned int & | offset | |||
| ) | [static] |
Slices a bundle into a fragment bundles with a specific size and returns it.
| [in] | bundle | The bundle to slice. |
| [in] | size | The size of the fragment. |
| [in,out] | offset | A offset which tells the method to start from. The offset is moved forward to the end of the fragment. |
References dtn::data::Bundle::appendBlock(), dtn::data::APPLICATION_DATA_LENGTH, dtn::data::SDNV::encoding_len(), dtn::data::FRAGMENTATION_OFFSET, dtn::data::Bundle::getFrame(), dtn::data::Bundle::getInteger(), dtn::data::Bundle::getLength(), dtn::data::PayloadBlock::getLength(), dtn::data::PayloadBlock::getPayload(), dtn::data::Bundle::getPayloadBlock(), dtn::data::Bundle::getPrimaryFlags(), dtn::data::PrimaryFlags::isFragment(), dtn::data::PrimaryFlags::isFragmentationForbidden(), dtn::data::PayloadBlockFactory::newPayloadBlock(), dtn::data::Bundle::setFragment(), and dtn::data::Bundle::setInteger().
Referenced by split().
| Bundle * dtn::data::BundleFactory::cut | ( | const Bundle & | bundle, | |
| unsigned int | size, | |||
| unsigned int & | offset | |||
| ) | [static] |
Cut the payload of the bundle after a specific size and returns a fragment bundle.
| [in] | bundle | The bundle to slice. |
| [in] | size | The payload size of the fragment. |
| [in,out] | offset | A offset which tells the method to start from. The offset is moved forward to the end of the fragment. |
References dtn::data::Bundle::appendBlock(), dtn::data::APPLICATION_DATA_LENGTH, dtn::data::FRAGMENTATION_OFFSET, dtn::data::Bundle::getFrame(), dtn::data::Bundle::getInteger(), dtn::data::PayloadBlock::getLength(), dtn::data::PayloadBlock::getPayload(), dtn::data::Bundle::getPayloadBlock(), dtn::data::Bundle::getPrimaryFlags(), dtn::data::PrimaryFlags::isFragment(), dtn::data::PrimaryFlags::isFragmentationForbidden(), dtn::data::PayloadBlockFactory::newPayloadBlock(), dtn::data::Bundle::setFragment(), and dtn::data::Bundle::setInteger().
Referenced by cutAt().
| pair< Bundle *, Bundle * > dtn::data::BundleFactory::cutAt | ( | const Bundle & | bundle, | |
| unsigned int | position | |||
| ) | [static] |
Cut a bundle at a given position into two fragments. The position is absolutely, so you have to use a position between the borders of the payload. Otherwise a FragmentationException is thrown.
| [in] | bundle | The bundle which needs to be cut at a given position. |
| [in] | position | The position for the cut in the payload of the bundle. |
References cut(), dtn::data::Bundle::getPayloadBlock(), and dtn::data::PayloadBlock::getPayloadRange().
Merge a list of fragments to one bundle. If not all fragments are in the given list, the algorithm try to partly merge the bundles and put the resulting fragment into the given list. Bundle-Objects which were merged are removed out of the list and deleted by this method.
| [in,out] | bundles | A list of bundle objects. These bundles have to be fragments. If not, a FragmentationException is thrown. |
References compareFragments(), dtn::data::Bundle::getPrimaryFlags(), and dtn::data::PrimaryFlags::isFragment().
| Bundle * dtn::data::BundleFactory::merge | ( | const Bundle & | fragment1, | |
| const Bundle & | fragment2 | |||
| ) | [static] |
Merge two fragments to one bundle or a new fragment. If the fragments aren't bordering or overlapping a FragmentationException is thrown.
| [in] | fragment1 | The first fragment. The offset of this bundle has to be smaller than the offset of the second fragment. |
| [in] | fragment2 | The second fragment. The offset of this bundle has to be bigger than the offset of the first fragment. |
References dtn::data::Bundle::appendBlock(), dtn::data::APPLICATION_DATA_LENGTH, dtn::data::CREATION_TIMESTAMP, dtn::data::CREATION_TIMESTAMP_SEQUENCE, dtn::data::FRAGMENTATION_OFFSET, dtn::data::Bundle::getFrame(), dtn::data::Bundle::getInteger(), dtn::data::PayloadBlock::getLength(), dtn::data::Bundle::getPayloadBlock(), dtn::data::Bundle::getPrimaryFlags(), dtn::data::Bundle::getSource(), dtn::data::PrimaryFlags::isFragment(), dtn::data::LIFETIME, dtn::data::PayloadBlockFactory::merge(), and dtn::data::Bundle::setFragment().
| BlockFactory & dtn::data::BundleFactory::getExtension | ( | unsigned char | type | ) | [private] |
| map< char, BlockFactory * > & dtn::data::BundleFactory::getExtensions | ( | ) | [private] |
References m_extensions.
| Bundle* dtn::data::BundleFactory::createBundle | ( | bool | fragmented = false |
) | [private] |
| NetworkFrame * dtn::data::BundleFactory::parsePrimaryBlock | ( | const unsigned char * | data, | |
| unsigned int | size | |||
| ) | const [private] |
References dtn::data::APPLICATION_DATA_LENGTH, dtn::data::BLOCKLENGTH, dtn::data::SDNV::decode(), dtn::data::DICTIONARY_BYTEARRAY, dtn::data::DICTIONARY_LENGTH, dtn::data::FRAGMENTATION_OFFSET, dtn::data::PrimaryFlags::isFragment(), dtn::data::SDNV::len(), dtn::data::PROCFLAGS, and dtn::data::NetworkFrame::setFieldSizeMap().
Referenced by parse().
| bool dtn::data::BundleFactory::compareFragments | ( | const Bundle & | first, | |
| const Bundle & | second | |||
| ) | [static, private] |
compare method for sorting fragments
References dtn::data::FRAGMENTATION_OFFSET, and dtn::data::Bundle::getInteger().
Referenced by merge().
| Block * dtn::data::BundleFactory::getBlock | ( | const unsigned char * | data, | |
| unsigned int | size | |||
| ) | [static, private] |
References getExtension(), getInstance(), and dtn::data::BlockFactory::parse().
Referenced by parse().
unsigned int dtn::data::BundleFactory::SECONDS_TILL_2000 = 946681200 [static, private] |
Referenced by getDTNTime().
Referenced by getExtension().
map<char, BlockFactory*> dtn::data::BundleFactory::m_extensions [private] |
Referenced by getExtension(), getExtensions(), registerExtensionBlock(), unregisterExtensionBlock(), and ~BundleFactory().
1.5.6