From 34a507c9ab159a1e56715246c594b93a93d68469 Mon Sep 17 00:00:00 2001 From: james Date: Fri, 10 Feb 2006 10:01:46 +0000 Subject: Added "bytecount" command to management interface. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@887 e7ae566f-a301-0410-adde-c780ea21d3b5 --- manage.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'manage.h') diff --git a/manage.h b/manage.h index d7ed79c..1a776c3 100644 --- a/manage.h +++ b/manage.h @@ -187,6 +187,9 @@ struct man_persist { bool hold_release; const char *special_state_msg; + + counter_type bytes_in; + counter_type bytes_out; }; struct man_settings { @@ -239,6 +242,8 @@ struct man_connection { bool state_realtime; bool log_realtime; bool echo_realtime; + int bytecount_update_seconds; + time_t bytecount_last_update; const char *up_query_type; int up_query_mode; @@ -347,6 +352,35 @@ void management_echo (struct management *man, const char *string, const bool pul void management_auth_failure (struct management *man, const char *type); +/* + * These functions drive the bytecount in/out counters. + */ + +void man_bytecount_output (struct management *man); + +static inline void +man_bytecount_possible_output (struct management *man) +{ + if (man->connection.bytecount_update_seconds > 0 + && now >= man->connection.bytecount_last_update + + man->connection.bytecount_update_seconds) + man_bytecount_output (man); +} + +static inline void +management_bytes_out (struct management *man, const int size) +{ + man->persist.bytes_out += size; + man_bytecount_possible_output (man); +} + +static inline void +management_bytes_in (struct management *man, const int size) +{ + man->persist.bytes_in += size; + man_bytecount_possible_output (man); +} + #endif #endif -- cgit v1.2.3