00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _PRIMARY_BLOCK_PROCESSOR_H_
00018 #define _PRIMARY_BLOCK_PROCESSOR_H_
00019
00020 #include "BlockProcessor.h"
00021
00022 namespace dtn {
00023
00024 class DictionaryVector;
00025 class EndpointID;
00026
00030 class PrimaryBlockProcessor : public BlockProcessor {
00031 public:
00033 PrimaryBlockProcessor();
00034
00036 int consume(Bundle* bundle,
00037 BlockInfo* block,
00038 u_char* buf,
00039 size_t len);
00040
00041 bool validate(const Bundle* bundle,
00042 BlockInfoVec* block_list,
00043 BlockInfo* block,
00044 status_report_reason_t* reception_reason,
00045 status_report_reason_t* deletion_reason);
00046
00047 int prepare(const Bundle* bundle,
00048 BlockInfoVec* xmit_blocks,
00049 const BlockInfo* source,
00050 const LinkRef& link,
00051 list_owner_t list);
00052
00053 int generate(const Bundle* bundle,
00054 BlockInfoVec* xmit_blocks,
00055 BlockInfo* block,
00056 const LinkRef& link,
00057 bool last);
00058
00059 void generate_primary(const Bundle* bundle,
00060 BlockInfoVec* xmit_blocks,
00061 BlockInfo* block);
00063
00064 protected:
00069 typedef enum {
00070 BUNDLE_IS_FRAGMENT = 1 << 0,
00071 BUNDLE_IS_ADMIN = 1 << 1,
00072 BUNDLE_DO_NOT_FRAGMENT = 1 << 2,
00073 BUNDLE_CUSTODY_XFER_REQUESTED = 1 << 3,
00074 BUNDLE_SINGLETON_DESTINATION = 1 << 4,
00075 BUNDLE_ACK_BY_APP = 1 << 5,
00076 BUNDLE_UNUSED = 1 << 6
00077 } bundle_processing_flag_t;
00078
00083 struct PrimaryBlock {
00084 u_int8_t version;
00085 u_int64_t processing_flags;
00086 u_int64_t block_length;
00087 u_int64_t dest_scheme_offset;
00088 u_int64_t dest_ssp_offset;
00089 u_int64_t source_scheme_offset;
00090 u_int64_t source_ssp_offset;
00091 u_int64_t replyto_scheme_offset;
00092 u_int64_t replyto_ssp_offset;
00093 u_int64_t custodian_scheme_offset;
00094 u_int64_t custodian_ssp_offset;
00095 u_int64_t creation_time;
00096 u_int64_t creation_sequence;
00097 u_int64_t lifetime;
00098 u_int64_t dictionary_length;
00099 };
00100
00101
00104 friend class BundleProtocol;
00105
00106 static size_t get_primary_len(const Bundle* bundle,
00107 Dictionary* dict,
00108 PrimaryBlock* primary);
00109
00110 static u_int64_t format_bundle_flags(const Bundle* bundle);
00111 static void parse_bundle_flags(Bundle* bundle, u_int64_t flags);
00112
00113 static u_int64_t format_cos_flags(const Bundle* bundle);
00114 static void parse_cos_flags(Bundle* bundle, u_int64_t cos_flags);
00115
00116 static u_int64_t format_srr_flags(const Bundle* bundle);
00117 static void parse_srr_flags(Bundle* bundle, u_int64_t srr_flags);
00119 };
00120
00121 }
00122
00123 #endif