Ticket #15: openvpn_accounting.patch
File openvpn_accounting.patch, 22.9 KB (added by , 13 years ago) |
---|
-
configure.ac
From c985b48175071006a077c377cd23170f516c2036 Mon Sep 17 00:00:00 2001 From: chantra <chantra@debuntu.org> Date: Sat, 5 Jun 2010 13:21:53 +0200 Subject: Attempt to handle accounting in OpenVPN This might help setting Accounting info for Radius plugins. ref: http://comments.gmane.org/gmane.network.openvpn.devel/990 Signed-off-by: chantra <chantra@debuntu.org> --- configure.ac | 11 ++++++++ init.c | 5 ++++ multi.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++----- openvpn-plugin.h | 3 +- openvpn.h | 5 ++++ options.c | 25 +++++++++++++++++++ options.h | 4 +++ plugin.c | 2 + 8 files changed, 115 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 4626e46..8c76e24 100644
a b AC_ARG_ENABLE(profiling, 199 199 [PROFILE="no"] 200 200 ) 201 201 202 AC_ARG_ENABLE(accounting, 203 [ --enable-accounting Enable client accounting support], 204 [ACCOUNTING="$enableval"], 205 [ACCOUNTING="no"] 206 ) 207 202 208 AC_ARG_ENABLE(strict-options, 203 209 [ --enable-strict-options Enable strict options check between peers (debugging option)], 204 210 [STRICT_OPTIONS="$enableval"], … … if test "$PROFILE" = "yes"; then 858 864 CFLAGS="$CFLAGS -pg -DENABLE_PROFILING" 859 865 fi 860 866 867 dnl enable accounting 868 if test "$ACCOUNTING" = "yes"; then 869 AC_DEFINE(ENABLE_ACCOUNTING, 1, [Enable client accounting]) 870 fi 871 861 872 dnl enable strict options check between peers 862 873 if test "$STRICT_OPTIONS" = "yes"; then 863 874 AC_DEFINE(STRICT_OPTIONS_CHECK, 1, [Enable strict options check between peers]) -
init.c
diff --git a/init.c b/init.c index 8ec6ca6..5bb11ca 100644
a b do_init_timers (struct context *c, bool deferred) 870 870 event_timeout_init (&c->c2.occ_mtu_load_test_interval, OCC_MTU_LOAD_INTERVAL_SECONDS, now); 871 871 #endif 872 872 873 #ifdef ENABLE_ACCOUNTING 874 if (c->options.accounting_freq) 875 event_timeout_init (&c->c2.accounting_interval, c->options.accounting_freq, now); 876 #endif 877 873 878 /* initialize packet_id persistence timer */ 874 879 #ifdef USE_CRYPTO 875 880 if (c->options.packet_id_file) -
multi.c
diff --git a/multi.c b/multi.c index 7a06bd0..9d4c58d 100644
a b multi_client_connect_post (struct multi_context *m, 1301 1301 option_permissions_mask, 1302 1302 option_types_found, 1303 1303 mi->context.c2.es); 1304 1305 1304 if (!delete_file (dc_file)) 1306 1305 msg (D_MULTI_ERRORS, "MULTI: problem deleting temporary file: %s", 1307 1306 dc_file); … … multi_client_connect_post (struct multi_context *m, 1314 1313 */ 1315 1314 multi_select_virtual_addr (m, mi); 1316 1315 multi_set_virtual_addr_env (m, mi); 1316 #ifdef ENABLE_ACCOUNTING 1317 event_timeout_modify_wakeup (&mi->context.c2.accounting_interval, mi->context.options.accounting_freq); 1318 #endif 1319 1317 1320 } 1318 1321 } 1319 1322 … … multi_client_connect_post_plugin (struct multi_context *m, 1341 1344 { 1342 1345 if (config.list[i] && config.list[i]->value) 1343 1346 options_string_import (&mi->context.options, 1344 config.list[i]->value,1345 D_IMPORT_ERRORS|M_OPTERR,1346 option_permissions_mask,1347 option_types_found,1348 mi->context.c2.es);1347 config.list[i]->value, 1348 D_IMPORT_ERRORS|M_OPTERR, 1349 option_permissions_mask, 1350 option_types_found, 1351 mi->context.c2.es); 1349 1352 } 1350 1353 1351 1354 /* … … multi_client_connect_post_plugin (struct multi_context *m, 1356 1359 */ 1357 1360 multi_select_virtual_addr (m, mi); 1358 1361 multi_set_virtual_addr_env (m, mi); 1362 #ifdef ENABLE_ACCOUNTING 1363 event_timeout_modify_wakeup (&mi->context.c2.accounting_interval, mi->context.options.accounting_freq); 1364 #endif 1365 1359 1366 } 1360 1367 } 1361 1368 … … multi_connection_established (struct multi_context *m, struct multi_instance *mi 1520 1527 1521 1528 /* do --client-connect setenvs */ 1522 1529 multi_client_connect_setenv (m, mi); 1530 #ifdef ENABLE_ACCOUNTING 1531 event_timeout_modify_wakeup (&mi->context.c2.accounting_interval, mi->context.options.accounting_freq); 1532 #endif 1533 1523 1534 1524 1535 #ifdef ENABLE_PLUGIN 1525 1536 /* … … multi_process_per_second_timers_dowork (struct multi_context *m) 2379 2390 if (status_trigger (m->top.c1.status_output)) 2380 2391 multi_print_status (m, m->top.c1.status_output, m->status_file_version); 2381 2392 } 2382 2393 #ifdef ENABLE_PLUGIN 2394 #ifdef ENABLE_ACCOUNTING 2395 /* for each client context if register to PLUGIN_STATS 2396 * and event should be triggered, send status to plugin 2397 */ 2398 if (plugin_defined (m->top.plugins, OPENVPN_PLUGIN_STATS)) 2399 { 2400 struct argv argv = argv_new (); 2401 if (m->hash) 2402 { 2403 struct gc_arena gc_top = gc_new (); 2404 struct hash_iterator hi; 2405 const struct hash_element *he; 2406 2407 hash_iterator_init (m->hash, &hi, true); 2408 while ((he = hash_iterator_next (&hi))) 2409 { 2410 struct gc_arena gc = gc_new (); 2411 struct multi_instance *mi = (struct multi_instance *) he->value; 2412 if (!mi->halt) 2413 { 2414 struct context *client_context = &(mi->context); 2415 struct timeval null; 2416 CLEAR (null); 2417 if (event_timeout_trigger (&(client_context->c2.accounting_interval), &null, ETT_DEFAULT)) 2418 { 2419 msg (M_DEBUG, "DEBUG: ACCOUNTING triggerred after %ds (%d) for %s", 2420 client_context->options.accounting_freq, client_context->c2.accounting_interval.n, 2421 tls_common_name (client_context->c2.tls_multi, false)); 2422 setenv_stats (client_context); 2423 if (plugin_call (client_context->plugins, OPENVPN_PLUGIN_STATS, &argv, NULL, client_context->c2.es) != OPENVPN_PLUGIN_FUNC_SUCCESS) 2424 { 2425 msg (M_WARN, "WARNING: stats plugin call failed"); 2426 } 2427 } 2428 } 2429 gc_free (&gc); 2430 } 2431 hash_iterator_free (&hi); 2432 } 2433 argv_reset (&argv); 2434 } 2435 #endif /* ENABLE_ACCOUNTING */ 2436 #endif /* ENABLE_PLUGIN */ 2383 2437 /* possibly flush ifconfig-pool file */ 2384 2438 multi_ifconfig_pool_persist (m, false); 2385 2439 -
openvpn-plugin.h
diff --git a/openvpn-plugin.h b/openvpn-plugin.h index 56b0a70..bb5fd39 100644
a b 97 97 #define OPENVPN_PLUGIN_CLIENT_CONNECT_V2 9 98 98 #define OPENVPN_PLUGIN_TLS_FINAL 10 99 99 #define OPENVPN_PLUGIN_ENABLE_PF 11 100 #define OPENVPN_PLUGIN_N 12 100 #define OPENVPN_PLUGIN_STATS 12 101 #define OPENVPN_PLUGIN_N 13 101 102 102 103 /* 103 104 * Build a mask out of a set of plug-in types. -
openvpn.h
diff --git a/openvpn.h b/openvpn.h index 0757eb1..08f1b3d 100644
a b struct context_2 305 305 int occ_mtu_load_n_tries; 306 306 #endif 307 307 308 #ifdef ENABLE_ACCOUNTING 309 struct event_timeout accounting_interval; 310 #endif 311 308 312 #ifdef USE_CRYPTO 309 313 310 314 /* … … struct context_2 447 451 #ifdef MANAGEMENT_DEF_AUTH 448 452 struct man_def_auth_context mda_context; 449 453 #endif 454 450 455 }; 451 456 452 457 /* -
options.c
diff --git a/options.c b/options.c index 3a2a6c5..bc04aa3 100644
a b static const char usage_message[] = 307 307 "--status file n : Write operational status to file every n seconds.\n" 308 308 "--status-version [n] : Choose the status file format version number.\n" 309 309 " Currently, n can be 1, 2, or 3 (default=1).\n" 310 #ifdef ENABLE_ACCOUNTING 311 "--accounting-freq s : Send client accounting information every s seconds.\n" 312 #endif 310 313 #ifdef ENABLE_OCC 311 314 "--disable-occ : Disable options consistency check between peers.\n" 312 315 #endif … … init_options (struct options *o, const bool init_gc) 691 694 #ifdef ENABLE_OCC 692 695 o->occ = true; 693 696 #endif 697 #ifdef ENABLE_ACCOUNTING 698 o->accounting_freq = 60; 699 #endif 694 700 #ifdef ENABLE_MANAGEMENT 695 701 o->management_log_history_cache = 250; 696 702 o->management_echo_buffer_size = 100; … … show_settings (const struct options *o) 1382 1388 show_p2mp_parms (o); 1383 1389 #endif 1384 1390 1391 #ifdef ENABLE_ACCOUNTING 1392 SHOW_INT (accounting_freq); 1393 #endif 1394 1385 1395 #ifdef WIN32 1386 1396 SHOW_BOOL (show_net_up); 1387 1397 SHOW_INT (route_method); … … add_option (struct options *options, 5741 5751 options->persist_mode = 1; 5742 5752 } 5743 5753 #endif 5754 #ifdef ENABLE_ACCOUNTING 5755 else if (streq (p[0], "accounting-freq") && p[1]) 5756 { 5757 int freq; 5758 5759 VERIFY_PERMISSION (OPT_P_INSTANCE | OPT_P_GENERAL); 5760 freq = atoi (p[1]); 5761 if (freq < 0) 5762 { 5763 msg (msglevel, "--accounting-freq must be >= 0"); 5764 goto err; 5765 } 5766 options->accounting_freq = freq; 5767 } 5768 #endif 5744 5769 else 5745 5770 { 5746 5771 if (file) -
options.h
diff --git a/options.h b/options.h index ebff532..0f66f7a 100644
a b struct options 405 405 406 406 #endif 407 407 408 #ifdef ENABLE_ACCOUNTING 409 int accounting_freq; 410 #endif 411 408 412 #ifdef USE_CRYPTO 409 413 /* Cipher parms */ 410 414 const char *shared_secret_file; -
plugin.c
diff --git a/plugin.c b/plugin.c index 769de8d..9d0563d 100644
a b plugin_type_name (const int type) 88 88 return "PLUGIN_TLS_FINAL"; 89 89 case OPENVPN_PLUGIN_ENABLE_PF: 90 90 return "OPENVPN_PLUGIN_ENABLE_PF"; 91 case OPENVPN_PLUGIN_STATS: 92 return "OPENVPN_PLUGIN_STATS"; 91 93 default: 92 94 return "PLUGIN_???"; 93 95 } -
init.c
-- 1.7.0.4 From 213738abce4f30aa183c2bee59ac8c852e11ff3a Mon Sep 17 00:00:00 2001 From: chantra <chantra@debuntu.org> Date: Sun, 6 Jun 2010 07:25:30 +0200 Subject: OPENVPN_PLUGIN_ACCOUNTING can now update acct freq OPENVPN_PLUGIN_ACCOUNTING can make use of openvpn_plugin_func_v2 to update accounting_freq value Fixed issues: - handle option update with do_deferred_options - properly handle timeout modification/init/clear - check if timeout defined before checking if timeout can be triggered Signed-off-by: chantra <chantra@debuntu.org> --- init.c | 18 ++++++++ multi.c | 125 ++++++++++++++++++++++++++++++++++++++---------------- openvpn-plugin.h | 2 +- openvpn.h | 2 +- options.c | 2 +- options.h | 3 +- plugin.c | 4 +- 7 files changed, 113 insertions(+), 43 deletions(-) diff --git a/init.c b/init.c index 5bb11ca..c60617d 100644
a b do_deferred_options (struct context *c, const unsigned int found) 1431 1431 } 1432 1432 #endif 1433 1433 1434 #if defined(ENABLE_PLUGIN) && defined(ENABLE_ACCOUNTING) 1435 if (found & OPT_P_ACCOUNTING) 1436 { 1437 msg (D_PUSH, "OPTIONS IMPORT: accounting interval modified"); 1438 if (c->options.accounting_freq == 0) 1439 { 1440 if (event_timeout_defined (&c->c2.accounting_interval)) 1441 event_timeout_clear (&c->c2.accounting_interval); 1442 } 1443 else 1444 { 1445 if (event_timeout_defined (&c->c2.accounting_interval)) 1446 event_timeout_modify_wakeup( &c->c2.accounting_interval, c->options.accounting_freq); 1447 else 1448 event_timeout_init (&c->c2.accounting_interval, c->options.accounting_freq, now); 1449 } 1450 } 1451 #endif 1434 1452 if (found & OPT_P_SHAPER) 1435 1453 { 1436 1454 msg (D_PUSH, "OPTIONS IMPORT: traffic shaper enabled"); -
multi.c
diff --git a/multi.c b/multi.c index 9d4c58d..f6c70d9 100644
a b multi_client_connect_post (struct multi_context *m, 1313 1313 */ 1314 1314 multi_select_virtual_addr (m, mi); 1315 1315 multi_set_virtual_addr_env (m, mi); 1316 #ifdef ENABLE_ACCOUNTING1317 event_timeout_modify_wakeup (&mi->context.c2.accounting_interval, mi->context.options.accounting_freq);1318 #endif1319 1316 1320 1317 } 1321 1318 } … … multi_client_connect_post_plugin (struct multi_context *m, 1359 1356 */ 1360 1357 multi_select_virtual_addr (m, mi); 1361 1358 multi_set_virtual_addr_env (m, mi); 1359 } 1360 } 1361 1362 1362 #ifdef ENABLE_ACCOUNTING 1363 event_timeout_modify_wakeup (&mi->context.c2.accounting_interval, mi->context.options.accounting_freq); 1364 #endif 1363 /* 1364 * Called after stats plug-in is called 1365 */ 1366 static void 1367 multi_accounting_post_plugin (struct multi_context *m, 1368 struct multi_instance *mi, 1369 const struct plugin_return *pr, 1370 unsigned int option_permissions_mask, 1371 unsigned int *option_types_found) 1372 { 1373 struct plugin_return config; 1365 1374 1375 plugin_return_get_column (pr, &config, "config"); 1376 1377 /* Did script generate a dynamic config file? */ 1378 if (plugin_return_defined (&config)) 1379 { 1380 int i; 1381 for (i = 0; i < config.n; ++i) 1382 { 1383 if (config.list[i] && config.list[i]->value) 1384 options_string_import (&mi->context.options, 1385 config.list[i]->value, 1386 D_IMPORT_ERRORS|M_OPTERR, 1387 option_permissions_mask, 1388 option_types_found, 1389 mi->context.c2.es); 1390 } 1366 1391 } 1367 1392 } 1368 1369 #endif 1393 #endif /* ENABLE_ACCOUNTING */ 1394 #endif /* ENABLE_PLUGIN */ 1370 1395 1371 1396 #ifdef MANAGEMENT_DEF_AUTH 1372 1397 … … multi_connection_established (struct multi_context *m, struct multi_instance *mi 1458 1483 | OPT_P_CONFIG 1459 1484 | OPT_P_ECHO 1460 1485 | OPT_P_COMP 1461 | OPT_P_SOCKFLAGS; 1486 | OPT_P_SOCKFLAGS 1487 | OPT_P_ACCOUNTING; 1462 1488 1463 1489 int cc_succeeded = true; /* client connect script status */ 1464 1490 int cc_succeeded_count = 0; … … multi_connection_established (struct multi_context *m, struct multi_instance *mi 1527 1553 1528 1554 /* do --client-connect setenvs */ 1529 1555 multi_client_connect_setenv (m, mi); 1530 #ifdef ENABLE_ACCOUNTING1531 event_timeout_modify_wakeup (&mi->context.c2.accounting_interval, mi->context.options.accounting_freq);1532 #endif1533 1556 1534 1557 1535 1558 #ifdef ENABLE_PLUGIN … … gremlin_flood_clients (struct multi_context *m) 2375 2398 } 2376 2399 #endif 2377 2400 2378 /* 2379 * Process timers in the top-level context 2401 #ifdef ENABLE_ACCOUNTING 2402 /** 2403 * Process client instances accounting by invoking 2404 * OPENVPN_PLUGIN_ACCOUNTING 2380 2405 */ 2381 void 2382 multi_process_per_second_timers_dowork (struct multi_context *m) 2406 void multi_client_accounting (struct multi_context *m) 2383 2407 { 2384 /* possibly reap instances/routes in vhash */2385 multi_reap_process (m);2386 2408 2387 /* possibly print to status log */ 2388 if (m->top.c1.status_output) 2389 { 2390 if (status_trigger (m->top.c1.status_output)) 2391 multi_print_status (m, m->top.c1.status_output, m->status_file_version); 2392 } 2393 #ifdef ENABLE_PLUGIN 2394 #ifdef ENABLE_ACCOUNTING 2395 /* for each client context if register to PLUGIN_STATS 2409 const unsigned int option_permissions_mask = OPT_P_ACCOUNTING; 2410 unsigned int option_types_found; 2411 /* for each client context if register to PLUGIN_ACCOUNTING 2396 2412 * and event should be triggered, send status to plugin 2397 */ 2398 if (plugin_defined (m->top.plugins, OPENVPN_PLUGIN_ STATS))2413 */ 2414 if (plugin_defined (m->top.plugins, OPENVPN_PLUGIN_ACCOUNTING)) 2399 2415 { 2400 2416 struct argv argv = argv_new (); 2401 2417 if (m->hash) … … multi_process_per_second_timers_dowork (struct multi_context *m) 2405 2421 const struct hash_element *he; 2406 2422 2407 2423 hash_iterator_init (m->hash, &hi, true); 2424 2408 2425 while ((he = hash_iterator_next (&hi))) 2409 2426 { 2410 2427 struct gc_arena gc = gc_new (); 2411 2428 struct multi_instance *mi = (struct multi_instance *) he->value; 2412 2429 if (!mi->halt) 2413 2430 { 2414 struct context *c lient_context = &(mi->context);2431 struct context *c = &mi->context; 2415 2432 struct timeval null; 2416 2433 CLEAR (null); 2417 if (event_timeout_trigger (&(client_context->c2.accounting_interval), &null, ETT_DEFAULT)) 2434 if (event_timeout_defined (&c->c2.accounting_interval) && 2435 event_timeout_trigger (&c->c2.accounting_interval, &null, ETT_DEFAULT)) 2418 2436 { 2419 msg (M_DEBUG, "DEBUG: ACCOUNTING triggerred after %ds (%d) for %s", 2420 client_context->options.accounting_freq, client_context->c2.accounting_interval.n, 2421 tls_common_name (client_context->c2.tls_multi, false)); 2422 setenv_stats (client_context); 2423 if (plugin_call (client_context->plugins, OPENVPN_PLUGIN_STATS, &argv, NULL, client_context->c2.es) != OPENVPN_PLUGIN_FUNC_SUCCESS) 2437 #ifdef ENABLE_DEBUG 2438 msg (M_DEBUG, "DEBUG: ACCOUNTING triggerred after %ds for %s", 2439 c->c2.accounting_interval.n, 2440 tls_common_name (c->c2.tls_multi, false)); 2441 #endif 2442 struct plugin_return pr; 2443 plugin_return_init (&pr); 2444 2445 option_types_found = 0; 2446 setenv_stats (c); 2447 if (plugin_call (c->plugins, OPENVPN_PLUGIN_ACCOUNTING, &argv, &pr, c->c2.es) != OPENVPN_PLUGIN_FUNC_SUCCESS) 2424 2448 { 2425 2449 msg (M_WARN, "WARNING: stats plugin call failed"); 2426 2450 } 2451 else 2452 { 2453 multi_accounting_post_plugin (m, mi, &pr, option_permissions_mask, &option_types_found); 2454 do_deferred_options (c, option_types_found); 2455 } 2456 plugin_return_free (&pr); 2427 2457 } 2428 2458 } 2429 2459 gc_free (&gc); … … multi_process_per_second_timers_dowork (struct multi_context *m) 2432 2462 } 2433 2463 argv_reset (&argv); 2434 2464 } 2435 #endif /* ENABLE_ACCOUNTING */ 2436 #endif /* ENABLE_PLUGIN */ 2465 } 2466 #endif 2467 2468 /* 2469 * Process timers in the top-level context 2470 */ 2471 void 2472 multi_process_per_second_timers_dowork (struct multi_context *m) 2473 { 2474 /* possibly reap instances/routes in vhash */ 2475 multi_reap_process (m); 2476 2477 /* possibly print to status log */ 2478 if (m->top.c1.status_output) 2479 { 2480 if (status_trigger (m->top.c1.status_output)) 2481 multi_print_status (m, m->top.c1.status_output, m->status_file_version); 2482 } 2483 2484 #if defined(ENABLE_PLUGIN) && defined(ENABLE_ACCOUNTING) 2485 multi_client_accounting (m); 2486 #endif 2487 2437 2488 /* possibly flush ifconfig-pool file */ 2438 2489 multi_ifconfig_pool_persist (m, false); 2439 2490 -
openvpn-plugin.h
diff --git a/openvpn-plugin.h b/openvpn-plugin.h index bb5fd39..44e62a6 100644
a b 97 97 #define OPENVPN_PLUGIN_CLIENT_CONNECT_V2 9 98 98 #define OPENVPN_PLUGIN_TLS_FINAL 10 99 99 #define OPENVPN_PLUGIN_ENABLE_PF 11 100 #define OPENVPN_PLUGIN_ STATS12100 #define OPENVPN_PLUGIN_ACCOUNTING 12 101 101 #define OPENVPN_PLUGIN_N 13 102 102 103 103 /* -
openvpn.h
diff --git a/openvpn.h b/openvpn.h index 08f1b3d..a4711c6 100644
a b struct context_2 305 305 int occ_mtu_load_n_tries; 306 306 #endif 307 307 308 #if def ENABLE_ACCOUNTING308 #if defined(ENABLE_PLUGIN) && defined(ENABLE_ACCOUNTING) 309 309 struct event_timeout accounting_interval; 310 310 #endif 311 311 -
options.c
diff --git a/options.c b/options.c index bc04aa3..05bf37c 100644
a b add_option (struct options *options, 5756 5756 { 5757 5757 int freq; 5758 5758 5759 VERIFY_PERMISSION (OPT_P_ INSTANCE | OPT_P_GENERAL);5759 VERIFY_PERMISSION (OPT_P_ACCOUNTING); 5760 5760 freq = atoi (p[1]); 5761 5761 if (freq < 0) 5762 5762 { -
options.h
diff --git a/options.h b/options.h index 0f66f7a..ebfb621 100644
a b struct options 406 406 #endif 407 407 408 408 #ifdef ENABLE_ACCOUNTING 409 int accounting_freq; 409 int accounting_freq; 410 410 #endif 411 411 412 412 #ifdef USE_CRYPTO … … struct options 548 548 #define OPT_P_SOCKBUF (1<<25) 549 549 #define OPT_P_SOCKFLAGS (1<<26) 550 550 #define OPT_P_CONNECTION (1<<27) 551 #define OPT_P_ACCOUNTING (1<<28) 551 552 552 553 #define OPT_P_DEFAULT (~(OPT_P_INSTANCE|OPT_P_PULL_MODE)) 553 554 -
plugin.c
diff --git a/plugin.c b/plugin.c index 9d0563d..a0ee535 100644
a b plugin_type_name (const int type) 88 88 return "PLUGIN_TLS_FINAL"; 89 89 case OPENVPN_PLUGIN_ENABLE_PF: 90 90 return "OPENVPN_PLUGIN_ENABLE_PF"; 91 case OPENVPN_PLUGIN_ STATS:92 return "OPENVPN_PLUGIN_ STATS";91 case OPENVPN_PLUGIN_ACCOUNTING: 92 return "OPENVPN_PLUGIN_ACCOUNTING"; 93 93 default: 94 94 return "PLUGIN_???"; 95 95 } -
init.c
-- 1.7.0.4 From 1728b04986a31fb587553a41a991b402fb0fb9e4 Mon Sep 17 00:00:00 2001 From: chantra <chantra@debuntu.org> Date: Sun, 6 Jun 2010 07:46:16 +0200 Subject: Double checking that ENABLE_PLUGIN is defined There is no reason to enable the feature if ENABLE_PLUGIN is not defined in the first place Signed-off-by: chantra <chantra@debuntu.org> --- init.c | 2 +- multi.c | 3 +-- options.c | 8 ++++---- options.h | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/init.c b/init.c index c60617d..4d4a7c2 100644
a b do_init_timers (struct context *c, bool deferred) 870 870 event_timeout_init (&c->c2.occ_mtu_load_test_interval, OCC_MTU_LOAD_INTERVAL_SECONDS, now); 871 871 #endif 872 872 873 #if def ENABLE_ACCOUNTING873 #if defined(ENABLE_PLUGIN) && defined(ENABLE_ACCOUNTING) 874 874 if (c->options.accounting_freq) 875 875 event_timeout_init (&c->c2.accounting_interval, c->options.accounting_freq, now); 876 876 #endif -
multi.c
diff --git a/multi.c b/multi.c index f6c70d9..a467580 100644
a b void multi_client_accounting (struct multi_context *m) 2431 2431 struct context *c = &mi->context; 2432 2432 struct timeval null; 2433 2433 CLEAR (null); 2434 if (event_timeout_defined (&c->c2.accounting_interval) && 2435 event_timeout_trigger (&c->c2.accounting_interval, &null, ETT_DEFAULT)) 2434 if (event_timeout_trigger (&c->c2.accounting_interval, &null, ETT_DEFAULT)) 2436 2435 { 2437 2436 #ifdef ENABLE_DEBUG 2438 2437 msg (M_DEBUG, "DEBUG: ACCOUNTING triggerred after %ds for %s", -
options.c
diff --git a/options.c b/options.c index 05bf37c..8d33490 100644
a b static const char usage_message[] = 307 307 "--status file n : Write operational status to file every n seconds.\n" 308 308 "--status-version [n] : Choose the status file format version number.\n" 309 309 " Currently, n can be 1, 2, or 3 (default=1).\n" 310 #if def ENABLE_ACCOUNTING310 #if defined(ENABLE_PLUGIN) && defined(ENABLE_ACCOUNTING) 311 311 "--accounting-freq s : Send client accounting information every s seconds.\n" 312 312 #endif 313 313 #ifdef ENABLE_OCC … … init_options (struct options *o, const bool init_gc) 694 694 #ifdef ENABLE_OCC 695 695 o->occ = true; 696 696 #endif 697 #if def ENABLE_ACCOUNTING697 #if defined(ENABLE_PLUGIN) && defined(ENABLE_ACCOUNTING) 698 698 o->accounting_freq = 60; 699 699 #endif 700 700 #ifdef ENABLE_MANAGEMENT … … show_settings (const struct options *o) 1388 1388 show_p2mp_parms (o); 1389 1389 #endif 1390 1390 1391 #if def ENABLE_ACCOUNTING1391 #if defined(ENABLE_PLUGIN) && defined(ENABLE_ACCOUNTING) 1392 1392 SHOW_INT (accounting_freq); 1393 1393 #endif 1394 1394 … … add_option (struct options *options, 5751 5751 options->persist_mode = 1; 5752 5752 } 5753 5753 #endif 5754 #if def ENABLE_ACCOUNTING5754 #if defined(ENABLE_PLUGIN) && defined(ENABLE_ACCOUNTING) 5755 5755 else if (streq (p[0], "accounting-freq") && p[1]) 5756 5756 { 5757 5757 int freq; -
options.h
diff --git a/options.h b/options.h index ebfb621..19dfd4c 100644
a b struct options 405 405 406 406 #endif 407 407 408 #if def ENABLE_ACCOUNTING408 #if defined(ENABLE_PLUGIN) && defined(ENABLE_ACCOUNTING) 409 409 int accounting_freq; 410 410 #endif 411 411