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/serialize/Serialize.h>
00021 #include <oasys/thread/Timer.h>
00022 #include <oasys/util/Time.h>
00023 #include "bundling/BundleRef.h"
00024 #include "contacts/Link.h"
00025
00026 namespace dtn {
00027
00028 class Bundle;
00029
00047 class CustodyTimerSpec : public oasys::SerializableObject {
00048 public:
00052 static CustodyTimerSpec defaults_;
00053
00057 CustodyTimerSpec(u_int32_t min,
00058 u_int32_t lifetime_pct,
00059 u_int32_t max)
00060 : min_(min), lifetime_pct_(lifetime_pct), max_(max) {}
00061
00065 CustodyTimerSpec()
00066 : min_(defaults_.min_),
00067 lifetime_pct_(defaults_.lifetime_pct_),
00068 max_(defaults_.max_) {}
00069
00073 u_int32_t calculate_timeout(const Bundle* bundle) const;
00074
00082 int parse_options(int argc, const char* argv[],
00083 const char** invalidp = NULL);
00084
00085 void serialize(oasys::SerializeAction* a);
00086
00087 u_int32_t min_;
00088 u_int32_t lifetime_pct_;
00089 u_int32_t max_;
00090 };
00091
00105 class CustodyTimer : public oasys::Timer, public oasys::Logger {
00106 public:
00108 CustodyTimer(const oasys::Time& xmit_time,
00109 const CustodyTimerSpec& spec,
00110 Bundle* bundle, const LinkRef& link);
00111
00113 void timeout(const struct timeval& now);
00114
00116 BundleRef bundle_;
00117
00119 LinkRef link_;
00120 };
00121
00125 class CustodyTimerVec : public std::vector<CustodyTimer*> {};
00126
00127 }
00128
00129 #endif