BlockProcessor.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 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 _BLOCKPROCESSOR_H_
00018 #define _BLOCKPROCESSOR_H_
00019 
00020 #include <oasys/compat/inttypes.h>
00021 
00022 #include "BundleProtocol.h"
00023 
00024 namespace dtn {
00025 
00026 class BlockInfo;
00027 class BlockInfoVec;
00028 class Bundle;
00029 class Link;
00030 
00036 class BlockProcessor {
00037 public:
00044     BlockProcessor(int block_type);
00045                    
00049     virtual ~BlockProcessor();
00050     
00052     int block_type() { return block_type_; }
00054     
00071     virtual int consume(Bundle* bundle, BlockInfo* block,
00072                         u_char* buf, size_t len);
00073 
00080     virtual bool validate(const Bundle* bundle, BlockInfo* block,
00081                      BundleProtocol::status_report_reason_t* reception_reason,
00082                      BundleProtocol::status_report_reason_t* deletion_reason);
00083 
00092     virtual void prepare(const Bundle*    bundle,
00093                          Link*            link,
00094                          BlockInfoVec*    blocks,
00095                          const BlockInfo* source);
00096     
00102     virtual void generate(const Bundle* bundle,
00103                           Link*         link,
00104                           BlockInfo*    block,
00105                           bool          last) = 0;
00106     
00114     virtual void finalize(const Bundle* bundle, Link* link, BlockInfo* block);
00115 
00128     virtual void produce(const Bundle* bundle, const BlockInfo* block,
00129                          u_char* buf, size_t offset, size_t len);
00130 
00135     void init_block(BlockInfo* block, u_int8_t type, u_int8_t flags,
00136                     u_char* bp, size_t len);
00137     
00138 protected:
00139     // XXX/demmer temporary until we get rid of the old interface
00140     friend class BundleProtocol;
00141     friend class BlockInfo;
00142     
00150     int consume_preamble(BlockInfo* block,
00151                          u_char* buf,
00152                          size_t len,
00153                          size_t preamble_size = 0);
00154     
00159     void generate_preamble(BlockInfo* block,
00160                            u_int8_t type,
00161                            u_int8_t flags,
00162                            size_t data_length);
00163     
00164 private:
00166     int block_type_;
00167 };
00168 
00169 } // namespace dtn
00170 
00171 #endif /* _BLOCKPROCESSOR_H_ */

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