ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/conf.C
(Generate patch)

Comparing gvpe/src/conf.C (file contents):
Revision 1.27 by pcg, Fri Jun 11 15:56:31 2004 UTC vs.
Revision 1.32 by pcg, Sat Mar 5 15:48:54 2005 UTC

1/* 1/*
2 conf.c -- configuration code 2 conf.c -- configuration code
3 Copyright (C) 2003-2004 Marc Lehmann <pcg@goof.com> 3 Copyright (C) 2003-2005 Marc Lehmann <gvpe@schmorp.de>
4 4
5 This file is part of GVPE.
6
5 This program is free software; you can redistribute it and/or modify 7 GVPE is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 10 (at your option) any later version.
9 11
10 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 15 GNU General Public License for more details.
14 16
15 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 18 along with gvpe; if not, write to the Free Software
17 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/ 20*/
19 21
20#include "config.h" 22#include "config.h"
21 23
93 if (rsa_key) 95 if (rsa_key)
94 RSA_free (rsa_key); 96 RSA_free (rsa_key);
95 97
96 free (nodename); 98 free (nodename);
97 free (hostname); 99 free (hostname);
100#if ENABLE_DNS
101 free (domain);
102 free (dns_hostname);
103#endif
98} 104}
99 105
100void configuration::init () 106void configuration::init ()
101{ 107{
102 memset (this, 0, sizeof (*this)); 108 memset (this, 0, sizeof (*this));
112 118
113 default_node.udp_port = DEFAULT_UDPPORT; 119 default_node.udp_port = DEFAULT_UDPPORT;
114 default_node.tcp_port = DEFAULT_UDPPORT; // ehrm 120 default_node.tcp_port = DEFAULT_UDPPORT; // ehrm
115 default_node.connectmode = conf_node::C_ALWAYS; 121 default_node.connectmode = conf_node::C_ALWAYS;
116 default_node.compress = true; 122 default_node.compress = true;
117 default_node.protocols = PROT_UDPv4; 123 default_node.protocols = 0;
118 default_node.max_retry = DEFAULT_MAX_RETRY; 124 default_node.max_retry = DEFAULT_MAX_RETRY;
125
126#if ENABLE_DNS
127 default_node.dns_port = 0; // default is 0 == client
128 dns_forw_port = 53;
129#endif
119 130
120 conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); 131 conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid");
121} 132}
122 133
123void configuration::cleanup() 134void configuration::cleanup()
125 if (rsa_key) 136 if (rsa_key)
126 RSA_free (rsa_key); 137 RSA_free (rsa_key);
127 138
128 rsa_key = 0; 139 rsa_key = 0;
129 140
130 free (pidfilename); pidfilename = 0; 141 free (pidfilename); pidfilename = 0;
131 free (ifname); ifname = 0; 142 free (ifname); ifname = 0;
132#if ENABLE_HTTP_PROXY 143#if ENABLE_HTTP_PROXY
133 free (proxy_host); proxy_host = 0; 144 free (proxy_host); proxy_host = 0;
134 free (proxy_auth); proxy_auth = 0; 145 free (proxy_auth); proxy_auth = 0;
146#endif
147#if ENABLE_DNS
148 free (dns_forw_host); dns_forw_host = 0;
135#endif 149#endif
136} 150}
137 151
138void 152void
139configuration::clear_config () 153configuration::clear_config ()
307 free (script_node_up), script_node_up = strdup (val); 321 free (script_node_up), script_node_up = strdup (val);
308 else if (!strcmp (var, "node-down")) 322 else if (!strcmp (var, "node-down"))
309 free (script_node_down), script_node_down = strdup (val); 323 free (script_node_down), script_node_down = strdup (val);
310 else if (!strcmp (var, "pid-file")) 324 else if (!strcmp (var, "pid-file"))
311 free (pidfilename), pidfilename = strdup (val); 325 free (pidfilename), pidfilename = strdup (val);
326#if ENABLE_DNS
327 else if (!strcmp (var, "dns-forw-host"))
328 free (dns_forw_host), dns_forw_host = strdup (val);
329 else if (!strcmp (var, "dns-forw-port"))
330 dns_forw_port = atoi (val);
331#endif
312 else if (!strcmp (var, "http-proxy-host")) 332 else if (!strcmp (var, "http-proxy-host"))
313 { 333 {
314#if ENABLE_HTTP_PROXY 334#if ENABLE_HTTP_PROXY
315 free (proxy_host), proxy_host = strdup (val); 335 free (proxy_host), proxy_host = strdup (val);
316#endif 336#endif
335 /* node-specific, defaultable */ 355 /* node-specific, defaultable */
336 else if (!strcmp (var, "udp-port")) 356 else if (!strcmp (var, "udp-port"))
337 node->udp_port = atoi (val); 357 node->udp_port = atoi (val);
338 else if (!strcmp (var, "tcp-port")) 358 else if (!strcmp (var, "tcp-port"))
339 node->tcp_port = atoi (val); 359 node->tcp_port = atoi (val);
360#if ENABLE_DNS
361 else if (!strcmp (var, "dns-hostname"))
362 free (node->dns_hostname), node->dns_hostname = strdup (val);
340 else if (!strcmp (var, "dns-port")) 363 else if (!strcmp (var, "dns-port"))
341 node->dns_port = atoi (val); 364 node->dns_port = atoi (val);
365#endif
366 else if (!strcmp (var, "dns-domain"))
367 {
368#if ENABLE_DNS
369 free (node->domain), node->domain = strdup (val);
370#endif
371 }
342 else if (!strcmp (var, "router-priority")) 372 else if (!strcmp (var, "router-priority"))
343 node->routerprio = atoi (val); 373 node->routerprio = atoi (val);
344 else if (!strcmp (var, "max-retry")) 374 else if (!strcmp (var, "max-retry"))
345 node->max_retry = atoi (val); 375 node->max_retry = atoi (val);
346 else if (!strcmp (var, "connect")) 376 else if (!strcmp (var, "connect"))
388 else if (!strcmp (var, "enable-udp")) 418 else if (!strcmp (var, "enable-udp"))
389 { 419 {
390 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; 420 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v;
391 } 421 }
392 else if (!strcmp (var, "enable-rawip")) 422 else if (!strcmp (var, "enable-rawip"))
393 {; 423 {
394 u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v; 424 u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v;
395 } 425 }
396 426
397 // unknown or misplaced 427 // unknown or misplaced
398 else 428 else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines