FragmentManager.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2004-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
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 // XXX/demmer should change the overall flow of the reassembly so all
00034 // arriving bundle fragments are enqueued onto the appropriate
00035 // reassembly state list immediately -- in fact all the fragmentation
00036 // and reassembly stuff needs rework
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 } // namespace dtn
00149 
00150 #endif /* __FRAGMENT_MANAGER_H__ */

Generated on Sat Sep 8 08:36:16 2007 for DTN Reference Implementation by  doxygen 1.5.3