00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __FRAGMENT_MANAGER_H__
00018 #define __FRAGMENT_MANAGER_H__
00019
00020 #include <string>
00021 #include <oasys/debug/Log.h>
00022 #include <oasys/util/StringUtils.h>
00023
00024 namespace oasys {
00025 class SpinLock;
00026 }
00027
00028 namespace dtn {
00029
00030 class Link;
00031 class Bundle;
00032 class BundleList;
00033 class BlockInfoVec;
00034 class FragmentState;
00035 class BlockInfoPointerList;
00036
00037
00038
00039
00040
00041
00049 class FragmentManager : public oasys::Logger {
00050 public:
00054 FragmentManager();
00055
00075 Bundle* create_fragment(Bundle* bundle,
00076 BlockInfoVec* blocks,
00077 size_t offset,
00078 size_t length);
00079
00083 Bundle* create_fragment(Bundle* bundle,
00084 const LinkRef& link,
00085 const BlockInfoPointerList& blocks_to_copy,
00086 size_t offset,
00087 size_t length);
00088
00095 void convert_to_fragment(Bundle* bundle, size_t length);
00096
00106 FragmentState* proactively_fragment(Bundle* bundle,
00107 const LinkRef& link,
00108 size_t max_length);
00109
00110 FragmentState* get_fragment_state(Bundle* bundle);
00111
00112 void erase_fragment_state(FragmentState* fragment);
00113
00120 bool try_to_reactively_fragment(Bundle* bundle, BlockInfoVec *blocks,
00121 size_t bytes_sent);
00122
00128 bool try_to_convert_to_fragment(Bundle* bundle);
00129
00136 void process_for_reassembly(Bundle* fragment);
00137
00141 void delete_obsoleted_fragments(Bundle* fragment);
00142
00146 void delete_fragment(Bundle* fragment);
00147
00148 protected:
00152 void get_hash_key(const Bundle*, std::string* key);
00153
00157
00158
00160 typedef oasys::StringHashMap<FragmentState*> FragmentTable;
00161 FragmentTable fragment_table_;
00162 };
00163
00164 }
00165
00166 #endif