0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00
openvpn3/openvpn/time/asiotimer.hpp
James Yonan 7371bd8e14 First working version of cli that can be entirely driven from config
file.  Currently limited to UDP, runs only on Linux, and supports
pushed redirect-gateway but not route directives.
2011-12-18 10:50:08 +00:00

53 lines
1.1 KiB
C++

#ifndef OPENVPN_TIME_ASIOTIMER_H
#define OPENVPN_TIME_ASIOTIMER_H
#include <boost/asio.hpp>
#include <openvpn/time/time.hpp>
namespace boost {
namespace asio {
// asio time traits specialized for our Time type
template <>
struct time_traits<openvpn::Time>
{
typedef openvpn::Time time_type;
typedef openvpn::Time::Duration duration_type;
static time_type now()
{
return time_type::now();
}
static time_type add(const time_type& t, const duration_type& d)
{
return t + d;
}
static duration_type subtract(const time_type& t1, const time_type& t2)
{
return t1 - t2;
}
static bool less_than(const time_type& t1, const time_type& t2)
{
return t1 < t2;
}
/// Convert to POSIX duration type.
static boost::posix_time::time_duration to_posix_duration(const duration_type& d)
{
return boost::posix_time::microseconds(d.to_microseconds());
}
};
} // namespace asio
} // namespace boost
namespace openvpn {
typedef boost::asio::basic_deadline_timer<Time> AsioTimer;
}
#endif // OPENVPN_TIME_ASIOTIMER_H