--- gvpe/src/conf.C 2008/08/10 02:49:27 1.48 +++ gvpe/src/conf.C 2011/02/08 23:11:35 1.52 @@ -59,7 +59,8 @@ struct configuration conf; -u8 best_protocol (u8 protset) +u8 +best_protocol (u8 protset) { if (protset & PROT_IPv4 ) return PROT_IPv4; if (protset & PROT_ICMPv4) return PROT_ICMPv4; @@ -70,7 +71,8 @@ return 0; } -const char *strprotocol (u8 protocol) +const char * +strprotocol (u8 protocol) { if (protocol & PROT_IPv4 ) return "rawip"; if (protocol & PROT_ICMPv4) return "icmp"; @@ -142,11 +144,13 @@ #endif } -void configuration::init () +void +configuration::init () { memset (this, 0, sizeof (*this)); mtu = DEFAULT_MTU; + nfmark = 0; rekey = DEFAULT_REKEY; keepalive = DEFAULT_KEEPALIVE; llevel = L_INFO; @@ -179,22 +183,27 @@ conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); } -void configuration::cleanup() +void +configuration::cleanup () { if (rsa_key) RSA_free (rsa_key); rsa_key = 0; - free (pidfilename); pidfilename = 0; - free (ifname); ifname = 0; -#if ENABLE_HTTP_PROXY - free (proxy_host); proxy_host = 0; - free (proxy_auth); proxy_auth = 0; -#endif -#if ENABLE_DNS - free (dns_forw_host); dns_forw_host = 0; -#endif + free (pidfilename); pidfilename = 0; + free (ifname); ifname = 0; +#if ENABLE_HTTP_PROXY + free (proxy_host); proxy_host = 0; + free (proxy_auth); proxy_auth = 0; +#endif +#if ENABLE_DNS + free (dns_forw_host); dns_forw_host = 0; +#endif + free (script_if_up); script_if_up = 0; + free (script_node_up); script_node_up = 0; + free (script_node_change); script_node_change = 0; + free (script_node_down); script_node_down = 0; } void @@ -332,10 +341,14 @@ conf.keepalive = atoi (val); else if (!strcmp (var, "mtu")) conf.mtu = atoi (val); + else if (!strcmp (var, "nfmark")) + conf.nfmark = atoi (val); else if (!strcmp (var, "if-up")) free (conf.script_if_up), conf.script_if_up = strdup (val); else if (!strcmp (var, "node-up")) free (conf.script_node_up), conf.script_node_up = strdup (val); + else if (!strcmp (var, "node-change")) + free (conf.script_node_change), conf.script_node_change = strdup (val); else if (!strcmp (var, "node-down")) free (conf.script_node_down), conf.script_node_down = strdup (val); else if (!strcmp (var, "pid-file")) @@ -488,7 +501,8 @@ return 0; } -void conf_node::finalise () +void +conf_node::finalise () { if (max_queue < 1) { @@ -496,14 +510,15 @@ max_queue = 1; } - if (routerprio && (connectmode != C_ALWAYS && connectmode != C_DISABLED)) + if (routerprio > 1 && (connectmode != C_ALWAYS && connectmode != C_DISABLED)) { //slog (L_WARN, _("%s: has non-zero router-priority but either 'never' or 'ondemand' as connectmode, setting it to 'always'."), nodename); connectmode = C_ALWAYS; } } -void configuration_parser::parse_argv () +void +configuration_parser::parse_argv () { for (int i = 0; i < argc; ++i) { @@ -620,7 +635,8 @@ (*i)->finalise (); } -char *configuration::config_filename (const char *name, const char *dflt) +char * +configuration::config_filename (const char *name, const char *dflt) { char *fname; @@ -671,4 +687,3 @@ cleanup (); } -