00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _FORWARDINGINFO_H_
00018 #define _FORWARDINGINFO_H_
00019
00020 #include <string>
00021 #include <sys/time.h>
00022 #include <oasys/serialize/Serialize.h>
00023 #include <oasys/util/Time.h>
00024 #include "CustodyTimer.h"
00025
00026 namespace dtn {
00027
00038 class ForwardingInfo : public oasys::SerializableObject {
00039 public:
00043 typedef enum {
00044 INVALID_ACTION = 0,
00045 FORWARD_ACTION = 1 << 0,
00046 COPY_ACTION = 1 << 1,
00047 } action_t;
00048
00053 static const unsigned int ANY_ACTION = 0xffffffff;
00054
00055 static inline const char* action_to_str(action_t action)
00056 {
00057 switch(action) {
00058 case INVALID_ACTION: return "INVALID";
00059 case FORWARD_ACTION: return "FORWARD";
00060 case COPY_ACTION: return "COPY";
00061 default:
00062 NOTREACHED;
00063 }
00064 }
00065
00069 typedef enum {
00070 NONE = 0,
00071 QUEUED = 1 << 0,
00072 TRANSMITTED = 1 << 1,
00073 TRANSMIT_FAILED = 1 << 2,
00074 CANCELLED = 1 << 3,
00075 CUSTODY_TIMEOUT = 1 << 4,
00076 DELIVERED = 1 << 5,
00077 SUPPRESSED = 1 << 6,
00078 RECEIVED = 1 << 10,
00079 } state_t;
00080
00085 static const unsigned int ANY_STATE = 0xffffffff;
00086
00087 static const char* state_to_str(state_t state)
00088 {
00089 switch(state) {
00090 case NONE: return "NONE";
00091 case QUEUED: return "QUEUED";
00092 case TRANSMITTED: return "TRANSMITTED";
00093 case TRANSMIT_FAILED: return "TRANSMIT_FAILED";
00094 case CANCELLED: return "CANCELLED";
00095 case CUSTODY_TIMEOUT: return "CUSTODY_TIMEOUT";
00096 case DELIVERED: return "DELIVERED";
00097 case SUPPRESSED: return "SUPPRESSED";
00098 case RECEIVED: return "RECEIVED";
00099
00100 default:
00101 NOTREACHED;
00102 }
00103 }
00104
00108 ForwardingInfo()
00109 : state_(NONE),
00110 action_(INVALID_ACTION),
00111 link_name_(""),
00112 regid_(0xffffffff),
00113 remote_eid_(),
00114 custody_spec_() {}
00115
00116
00117
00118
00119 ForwardingInfo(const oasys::Builder& builder)
00120 : state_(NONE),
00121 action_(INVALID_ACTION),
00122 link_name_(""),
00123 regid_(0xffffffff),
00124 remote_eid_(builder),
00125 custody_spec_() {}
00126
00130 ForwardingInfo(state_t state,
00131 action_t action,
00132 const std::string& link_name,
00133 u_int32_t regid,
00134 const EndpointID& remote_eid,
00135 const CustodyTimerSpec& custody_spec)
00136 : state_(NONE),
00137 action_(action),
00138 link_name_(link_name),
00139 regid_(regid),
00140 remote_eid_(remote_eid),
00141 custody_spec_(custody_spec)
00142 {
00143 set_state(state);
00144 }
00145
00149 void set_state(state_t new_state)
00150 {
00151 state_ = new_state;
00152 timestamp_.get_time();
00153 }
00154
00155 virtual void serialize(oasys::SerializeAction *a);
00156
00158 const state_t state() const { return static_cast<state_t>(state_); }
00159 const action_t action() const { return static_cast<action_t>(action_); }
00160 const std::string& link_name() const { return link_name_; }
00161 const u_int32_t regid() const { return regid_; }
00162 const EndpointID& remote_eid() const { return remote_eid_; }
00163 const oasys::Time& timestamp() const { return timestamp_; }
00164 const CustodyTimerSpec& custody_spec() const { return custody_spec_; }
00166
00167 private:
00168 u_int32_t state_;
00169 u_int32_t action_;
00170 std::string link_name_;
00171 u_int32_t regid_;
00172 EndpointID remote_eid_;
00173 oasys::Time timestamp_;
00174 CustodyTimerSpec custody_spec_;
00175 };
00176
00177 }
00178
00179 #endif