IBR-DTNSuite  0.8
ibrdtn/ibrdtn/data/PrimaryBlock.h
Go to the documentation of this file.
00001 /*
00002  * PrimaryBlock.h
00003  *
00004  *  Created on: 26.05.2010
00005  *      Author: morgenro
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                                 // DTNSEC FLAGS (these are customized flags and not written down in any draft)
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                                 IBRDTN_REQUEST_COMPRESSION = 1 << 0x1F
00061                         };
00062 
00063                         PrimaryBlock();
00064                         virtual ~PrimaryBlock();
00065 
00070                         bool isExpired() const __attribute__ ((deprecated));
00071 
00072                         std::string toString() const;
00073 
00074                         void set(FLAGS flag, bool value);
00075                         bool get(FLAGS flag) const;
00076 
00080                         void relabel();
00081 
00082                         bool operator==(const PrimaryBlock& other) const;
00083                         bool operator!=(const PrimaryBlock& other) const;
00084                         bool operator<(const PrimaryBlock& other) const;
00085                         bool operator>(const PrimaryBlock& other) const;
00086 
00087                         size_t _procflags;
00088                         size_t _timestamp;
00089                         size_t _sequencenumber;
00090                         size_t _lifetime;
00091                         size_t _fragmentoffset;
00092                         size_t _appdatalength;
00093 
00094                         EID _source;
00095                         EID _destination;
00096                         EID _reportto;
00097                         EID _custodian;
00098 
00099                 private:
00100                         static ibrcommon::Mutex __sequence_lock;
00101                         static size_t __sequencenumber;
00102                 };
00103         }
00104 }
00105 
00106 #endif /* PRIMARYBLOCK_H_ */