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 <string>
00015 #include <iostream>
00016
00017 namespace dtn
00018 {
00019 namespace data
00020 {
00021 static const unsigned char BUNDLE_VERSION = 0x06;
00022
00023 class PrimaryBlock
00024 {
00025 friend class DefaultSerializer;
00026 friend class DefaultDeserializer;
00027
00028 public:
00029 enum FLAGS
00030 {
00031 FRAGMENT = 1 << 0x00,
00032 APPDATA_IS_ADMRECORD = 1 << 0x01,
00033 DONT_FRAGMENT = 1 << 0x02,
00034 CUSTODY_REQUESTED = 1 << 0x03,
00035 DESTINATION_IS_SINGLETON = 1 << 0x04,
00036 ACKOFAPP_REQUESTED = 1 << 0x05,
00037 RESERVED_6 = 1 << 0x06,
00038 PRIORITY_BIT1 = 1 << 0x07,
00039 PRIORITY_BIT2 = 1 << 0x08,
00040 CLASSOFSERVICE_9 = 1 << 0x09,
00041 CLASSOFSERVICE_10 = 1 << 0x0A,
00042 CLASSOFSERVICE_11 = 1 << 0x0B,
00043 CLASSOFSERVICE_12 = 1 << 0x0C,
00044 CLASSOFSERVICE_13 = 1 << 0x0D,
00045 REQUEST_REPORT_OF_BUNDLE_RECEPTION = 1 << 0x0E,
00046 REQUEST_REPORT_OF_CUSTODY_ACCEPTANCE = 1 << 0x0F,
00047 REQUEST_REPORT_OF_BUNDLE_FORWARDING = 1 << 0x10,
00048 REQUEST_REPORT_OF_BUNDLE_DELIVERY = 1 << 0x11,
00049 REQUEST_REPORT_OF_BUNDLE_DELETION = 1 << 0x12,
00050 STATUS_REPORT_REQUEST_19 = 1 << 0x13,
00051 STATUS_REPORT_REQUEST_20 = 1 << 0x14
00052 };
00053
00054 PrimaryBlock();
00055 virtual ~PrimaryBlock();
00056
00057 bool isExpired() const;
00058 std::string toString() const;
00059
00060 void set(FLAGS flag, bool value);
00061 bool get(FLAGS flag) const;
00062
00066 void relabel();
00067
00068 bool operator==(const PrimaryBlock& other) const;
00069 bool operator!=(const PrimaryBlock& other) const;
00070 bool operator<(const PrimaryBlock& other) const;
00071 bool operator>(const PrimaryBlock& other) const;
00072
00073 size_t _procflags;
00074 size_t _timestamp;
00075 size_t _sequencenumber;
00076 size_t _lifetime;
00077 size_t _fragmentoffset;
00078 size_t _appdatalength;
00079
00080 EID _source;
00081 EID _destination;
00082 EID _reportto;
00083 EID _custodian;
00084
00085 private:
00086 static size_t __sequencenumber;
00087 };
00088 }
00089 }
00090
00091 #endif