00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _CUSTODYTIMER_H_
00018 #define _CUSTODYTIMER_H_
00019
00020 #include <oasys/thread/Timer.h>
00021 #include "bundling/BundleRef.h"
00022
00023 namespace dtn {
00024
00025 class Bundle;
00026 class Link;
00027
00045 class CustodyTimerSpec {
00046 public:
00050 static CustodyTimerSpec defaults_;
00051
00055 CustodyTimerSpec(u_int32_t min,
00056 u_int32_t lifetime_pct,
00057 u_int32_t max)
00058 : min_(min), lifetime_pct_(lifetime_pct), max_(max) {}
00059
00063 CustodyTimerSpec()
00064 : min_(defaults_.min_),
00065 lifetime_pct_(defaults_.lifetime_pct_),
00066 max_(defaults_.max_) {}
00067
00071 u_int32_t calculate_timeout(const Bundle* bundle) const;
00072
00080 int parse_options(int argc, const char* argv[],
00081 const char** invalidp = NULL);
00082
00083 u_int32_t min_;
00084 u_int32_t lifetime_pct_;
00085 u_int32_t max_;
00086 };
00087
00101 class CustodyTimer : public oasys::Timer, public oasys::Logger {
00102 public:
00104 CustodyTimer(const struct timeval& xmit_time,
00105 const CustodyTimerSpec& spec,
00106 Bundle* bundle, Link* link);
00107
00109 void timeout(const struct timeval& now);
00110
00112 BundleRef bundle_;
00113
00115 Link* link_;
00116 };
00117
00121 class CustodyTimerVec : public std::vector<CustodyTimer*> {};
00122
00123 }
00124
00125 #endif