diff options
author | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2008-10-24 09:21:40 +0000 |
---|---|---|
committer | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2008-10-24 09:21:40 +0000 |
commit | 5f435d64d7c0694a56a64dc7a79d4828fcf8154c (patch) | |
tree | 73f96b3705c2134d9cea87305f83e3571c81da4a /manage.h | |
parent | Added optional files SAMPCONF_CONF2 (second sample configuration (diff) | |
download | openvpn-5f435d64d7c0694a56a64dc7a79d4828fcf8154c.tar.xz |
Extended Management Interface "bytecount" command
to work when OpenVPN is running as a server.
Documented Management Interface "bytecount" command in
management/management-notes.txt.
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3452 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'manage.h')
-rw-r--r-- | manage.h | 56 |
1 files changed, 48 insertions, 8 deletions
@@ -51,6 +51,8 @@ struct man_def_auth_context { unsigned int flags; unsigned int mda_key_id_counter; + + time_t bytecount_last_update; }; #endif @@ -143,6 +145,10 @@ log_history_capacity (const struct log_history *h) struct management_callback { void *arg; + +# define MCF_SERVER (1<<0) /* is OpenVPN being run as a server? */ + unsigned int flags; + void (*status) (void *arg, const int version, struct status_output *so); void (*show_net) (void *arg, const int msglevel); int (*kill_by_cn) (void *arg, const char *common_name); @@ -432,31 +438,65 @@ 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); +void man_bytecount_output_client (struct management *man); static inline void -man_bytecount_possible_output (struct management *man) +man_bytecount_possible_output_client (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); + man_bytecount_output_client (man); } static inline void -management_bytes_out (struct management *man, const int size) +management_bytes_out_client (struct management *man, const int size) { man->persist.bytes_out += size; - man_bytecount_possible_output (man); + man_bytecount_possible_output_client (man); } static inline void -management_bytes_in (struct management *man, const int size) +management_bytes_in_client (struct management *man, const int size) { man->persist.bytes_in += size; - man_bytecount_possible_output (man); + man_bytecount_possible_output_client (man); } -#endif +static inline void +management_bytes_out (struct management *man, const int size) +{ + if (!(man->persist.callback.flags & MCF_SERVER)) + management_bytes_out_client (man, size); +} +static inline void +management_bytes_in (struct management *man, const int size) +{ + if (!(man->persist.callback.flags & MCF_SERVER)) + management_bytes_in_client (man, size); +} + +#ifdef MANAGEMENT_DEF_AUTH + +static inline void +management_bytes_server (struct management *man, + const counter_type *bytes_in_total, + const counter_type *bytes_out_total, + struct man_def_auth_context *mdac) +{ + void man_bytecount_output_server (struct management *man, + const counter_type *bytes_in_total, + const counter_type *bytes_out_total, + struct man_def_auth_context *mdac); + + if (man->connection.bytecount_update_seconds > 0 + && now >= mdac->bytecount_last_update + man->connection.bytecount_update_seconds + && (mdac->flags & (DAF_CONNECTION_ESTABLISHED|DAF_CONNECTION_CLOSED)) == DAF_CONNECTION_ESTABLISHED) + man_bytecount_output_server (man, bytes_in_total, bytes_out_total, mdac); +} + +#endif /* MANAGEMENT_DEF_AUTH */ + +#endif #endif |