00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
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 }
00170
00171 #endif