Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef PRIMARYBLOCK_H_
00009 #define PRIMARYBLOCK_H_
00010
00011 #include "ibrdtn/data/EID.h"
00012 #include "ibrdtn/data/Dictionary.h"
00013 #include "ibrdtn/data/Serializer.h"
00014 #include <ibrcommon/thread/Mutex.h>
00015 #include <string>
00016 #include <iostream>
00017
00018 namespace dtn
00019 {
00020 namespace data
00021 {
00022 static const unsigned char BUNDLE_VERSION = 0x06;
00023
00024 class PrimaryBlock
00025 {
00026 friend class DefaultSerializer;
00027 friend class DefaultDeserializer;
00028
00029 public:
00030 enum FLAGS
00031 {
00032 FRAGMENT = 1 << 0x00,
00033 APPDATA_IS_ADMRECORD = 1 << 0x01,
00034 DONT_FRAGMENT = 1 << 0x02,
00035 CUSTODY_REQUESTED = 1 << 0x03,
00036 DESTINATION_IS_SINGLETON = 1 << 0x04,
00037 ACKOFAPP_REQUESTED = 1 << 0x05,
00038 RESERVED_6 = 1 << 0x06,
00039 PRIORITY_BIT1 = 1 << 0x07,
00040 PRIORITY_BIT2 = 1 << 0x08,
00041 CLASSOFSERVICE_9 = 1 << 0x09,
00042 CLASSOFSERVICE_10 = 1 << 0x0A,
00043 CLASSOFSERVICE_11 = 1 << 0x0B,
00044 CLASSOFSERVICE_12 = 1 << 0x0C,
00045 CLASSOFSERVICE_13 = 1 << 0x0D,
00046 REQUEST_REPORT_OF_BUNDLE_RECEPTION = 1 << 0x0E,
00047 REQUEST_REPORT_OF_CUSTODY_ACCEPTANCE = 1 << 0x0F,
00048 REQUEST_REPORT_OF_BUNDLE_FORWARDING = 1 << 0x10,
00049 REQUEST_REPORT_OF_BUNDLE_DELIVERY = 1 << 0x11,
00050 REQUEST_REPORT_OF_BUNDLE_DELETION = 1 << 0x12,
00051 STATUS_REPORT_REQUEST_19 = 1 << 0x13,
00052 STATUS_REPORT_REQUEST_20 = 1 << 0x14,
00053
00054
00055 DTNSEC_REQUEST_SIGN = 1 << 0x1A,
00056 DTNSEC_REQUEST_ENCRYPT = 1 << 0x1B,
00057 DTNSEC_STATUS_VERIFIED = 1 << 0x1C,
00058 DTNSEC_STATUS_CONFIDENTIAL = 1 << 0x1D,
00059 DTNSEC_STATUS_AUTHENTICATED = 1 << 0x1E
00060 };
00061
00062 PrimaryBlock();
00063 virtual ~PrimaryBlock();
00064
00069 bool isExpired() const __attribute__ ((deprecated));
00070
00071 std::string toString() const;
00072
00073 void set(FLAGS flag, bool value);
00074 bool get(FLAGS flag) const;
00075
00079 void relabel();
00080
00081 bool operator==(const PrimaryBlock& other) const;
00082 bool operator!=(const PrimaryBlock& other) const;
00083 bool operator<(const PrimaryBlock& other) const;
00084 bool operator>(const PrimaryBlock& other) const;
00085
00086 size_t _procflags;
00087 size_t _timestamp;
00088 size_t _sequencenumber;
00089 size_t _lifetime;
00090 size_t _fragmentoffset;
00091 size_t _appdatalength;
00092
00093 EID _source;
00094 EID _destination;
00095 EID _reportto;
00096 EID _custodian;
00097
00098 private:
00099 static ibrcommon::Mutex __sequence_lock;
00100 static size_t __sequencenumber;
00101 };
00102 }
00103 }
00104
00105 #endif