Commit 04d713f8 authored by David Woodhouse's avatar David Woodhouse

Add openconnect_set_loglevel()

Profiling shows that in the VPN mainloop we were translating debug
messages we didn't even print. Stop that.
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent e1a2dade
......@@ -32,7 +32,6 @@ OPENCONNECT_5.0 {
openconnect_set_cancel_fd;
openconnect_set_cert_expiry_warning;
openconnect_set_client_cert;
openconnect_set_compression_mode;
openconnect_set_csd_environ;
openconnect_set_dpd;
openconnect_set_hostname;
......@@ -62,6 +61,11 @@ OPENCONNECT_5.0 {
openconnect_vpninfo_new;
};
OPENCONNECT_5_1 {
global:
openconnect_set_compression_mode;
openconnect_set_loglevel;
} OPENCONNECT_5.0;
OPENCONNECT_PRIVATE {
global: @SYMVER_TIME@ @SYMVER_GETLINE@ @SYMVER_JAVA@ @SYMVER_ASPRINTF@ @SYMVER_VASPRINTF@ @SYMVER_WIN32_STRERROR@
......
......@@ -82,6 +82,7 @@ struct openconnect_info *openconnect_vpninfo_new(const char *useragent,
vpninfo->progress = progress;
vpninfo->cbdata = privdata ? : vpninfo;
vpninfo->xmlpost = 1;
vpninfo->verbose = PRG_TRACE;
openconnect_set_reported_os(vpninfo, NULL);
if (!vpninfo->localname || !vpninfo->useragent)
......@@ -129,6 +130,12 @@ void openconnect_set_juniper(struct openconnect_info *vpninfo)
#endif
}
void openconnect_set_loglevel(struct openconnect_info *vpninfo,
int level)
{
vpninfo->verbose = level;
}
int openconnect_setup_dtls(struct openconnect_info *vpninfo,
int attempt_period)
......
......@@ -1505,6 +1505,8 @@ int main(int argc, char **argv)
}
#endif
openconnect_set_loglevel(vpninfo, verbose);
while (1) {
ret = openconnect_mainloop(vpninfo, reconnect_timeout, RECONNECT_INTERVAL_MIN);
if (ret)
......
......@@ -579,6 +579,7 @@ struct openconnect_info {
const char *quit_reason;
int verbose;
void *cbdata;
openconnect_validate_peer_cert_vfn validate_peer_cert;
openconnect_write_new_config_vfn write_new_config;
......@@ -633,7 +634,10 @@ struct openconnect_info {
#define AC_PKT_COMPRESSED 8 /* Compressed data */
#define AC_PKT_TERM_SERVER 9 /* Server kick */
#define vpn_progress(vpninfo, ...) (vpninfo)->progress((vpninfo)->cbdata, __VA_ARGS__)
#define vpn_progress(_v, lvl, ...) do { \
if ((_v)->verbose >= (lvl)) \
(_v)->progress((vpninfo)->cbdata, lvl, __VA_ARGS__); \
} while(0)
#define vpn_perror(vpninfo, msg) vpn_progress((vpninfo), PRG_ERR, "%s: %s\n", (msg), strerror(errno));
/****************************************************************************/
......
......@@ -33,7 +33,7 @@
/*
* API version 5.1:
* - Add openconnect_set_compression_mode().
* - Add openconnect_set_compression_mode(), openconnect_set_loglevel()
*
* API version 5.0:
* - Remove OPENCONNECT_X509 and openconnect_get_peer_cert().
......@@ -544,6 +544,9 @@ typedef void (*openconnect_protect_socket_vfn) (void *privdata, int fd);
void openconnect_set_protect_socket_handler(struct openconnect_info *vpninfo,
openconnect_protect_socket_vfn protect_socket);
void openconnect_set_loglevel(struct openconnect_info *vpninfo,
int level);
/* Callback for obtaining traffic stats via OC_CMD_STATS.
*/
typedef void (*openconnect_stats_vfn) (void *privdata, const struct oc_stats *stats);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment