IBR-DTNSuite  0.10
PrimaryBlock.h
Go to the documentation of this file.
1 /*
2  * PrimaryBlock.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef PRIMARYBLOCK_H_
23 #define PRIMARYBLOCK_H_
24 
25 #include "ibrdtn/data/Number.h"
26 #include "ibrdtn/data/EID.h"
27 #include "ibrdtn/data/Dictionary.h"
28 #include "ibrdtn/data/Serializer.h"
29 #include <ibrcommon/thread/Mutex.h>
30 #include <string>
31 #include <iostream>
32 #include <stdint.h>
33 
34 #ifdef SWIG
35 # define DEPRECATED
36 #else
37 # define DEPRECATED __attribute__ ((deprecated))
38 #endif
39 
40 namespace dtn
41 {
42  namespace data
43  {
44  static const unsigned char BUNDLE_VERSION = 0x06;
45 
47  {
48  public:
55  enum PRIORITY
56  {
57  PRIO_LOW = 0,
60  };
61 
62  enum FLAGS
63  {
64  FRAGMENT = 1 << 0x00,
65  APPDATA_IS_ADMRECORD = 1 << 0x01,
66  DONT_FRAGMENT = 1 << 0x02,
67  CUSTODY_REQUESTED = 1 << 0x03,
69  ACKOFAPP_REQUESTED = 1 << 0x05,
70  RESERVED_6 = 1 << 0x06,
71  PRIORITY_BIT1 = 1 << 0x07,
72  PRIORITY_BIT2 = 1 << 0x08,
73  CLASSOFSERVICE_9 = 1 << 0x09,
74  CLASSOFSERVICE_10 = 1 << 0x0A,
75  CLASSOFSERVICE_11 = 1 << 0x0B,
76  CLASSOFSERVICE_12 = 1 << 0x0C,
77  CLASSOFSERVICE_13 = 1 << 0x0D,
85 
86  // DTNSEC FLAGS (these are customized flags and not written down in any draft)
87  DTNSEC_REQUEST_SIGN = 1 << 0x1A,
93  };
94 
95  PrimaryBlock();
96  virtual ~PrimaryBlock();
97 
102  bool isExpired() const DEPRECATED;
103 
104  std::string toString() const;
105 
106  void set(FLAGS flag, bool value);
107  bool get(FLAGS flag) const;
108 
109  PRIORITY getPriority() const;
110  void setPriority(PRIORITY p);
111 
115  void relabel();
116 
117  bool operator==(const PrimaryBlock& other) const;
118  bool operator!=(const PrimaryBlock& other) const;
119  bool operator<(const PrimaryBlock& other) const;
120  bool operator>(const PrimaryBlock& other) const;
121 
128 
133 
134  private:
135  static ibrcommon::Mutex __sequence_lock;
136  static Number __sequencenumber;
137  static Timestamp __last_timestamp;
138  };
139  }
140 }
141 
142 #endif /* PRIMARYBLOCK_H_ */