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 Bundle;
00031 class BundleList;
00032
00033
00034
00035
00036
00037
00045 class FragmentManager : public oasys::Logger {
00046 public:
00050 FragmentManager();
00051
00071 Bundle* create_fragment(Bundle* bundle, size_t offset, size_t length);
00072
00079 void convert_to_fragment(Bundle* bundle, size_t length);
00080
00090 int proactively_fragment(Bundle* bundle, size_t max_length);
00091
00098 bool try_to_reactively_fragment(Bundle* bundle, size_t payload_offset,
00099 size_t bytes_sent);
00100
00106 bool try_to_convert_to_fragment(Bundle* bundle, size_t payload_offset,
00107 size_t bytes_rcvd);
00108
00115 void process_for_reassembly(Bundle* fragment);
00116
00120 void delete_fragment(Bundle* fragment);
00121
00122 protected:
00124 struct ReassemblyState {
00125 ReassemblyState()
00126 : bundle_("reassembly_state"), fragments_("reassembly_state")
00127 {}
00128
00129 BundleRef bundle_;
00130 BundleList fragments_;
00131 };
00132
00136 void get_hash_key(const Bundle*, std::string* key);
00137
00141 bool check_completed(ReassemblyState* state);
00142
00144 typedef oasys::StringHashMap<ReassemblyState*> ReassemblyTable;
00145 ReassemblyTable reassembly_table_;
00146 };
00147
00148 }
00149
00150 #endif