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.23 by pcg, Thu Jan 29 19:30:08 2004 UTC vs.
Revision 1.25 by pcg, Mon May 10 20:13:09 2004 UTC

44#include "util.h" 44#include "util.h"
45 45
46char *confbase; 46char *confbase;
47char *thisnode; 47char *thisnode;
48char *identname; 48char *identname;
49char *pidfilename;
50 49
51struct configuration conf; 50struct configuration conf;
52 51
53u8 best_protocol (u8 protset) 52u8 best_protocol (u8 protset)
54{ 53{
55 if (protset & PROT_IPv4 ) return PROT_IPv4; 54 if (protset & PROT_IPv4 ) return PROT_IPv4;
56 if (protset & PROT_ICMPv4) return PROT_ICMPv4; 55 if (protset & PROT_ICMPv4) return PROT_ICMPv4;
57 if (protset & PROT_UDPv4 ) return PROT_UDPv4; 56 if (protset & PROT_UDPv4 ) return PROT_UDPv4;
58 if (protset & PROT_TCPv4 ) return PROT_TCPv4; 57 if (protset & PROT_TCPv4 ) return PROT_TCPv4;
58 if (protset & PROT_DNSv4 ) return PROT_DNSv4;
59 59
60 return 0; 60 return 0;
61} 61}
62 62
63const char *strprotocol (u8 protocol) 63const char *strprotocol (u8 protocol)
64{ 64{
65 if (protocol & PROT_IPv4 ) return "rawip"; 65 if (protocol & PROT_IPv4 ) return "rawip";
66 if (protocol & PROT_ICMPv4) return "icmp"; 66 if (protocol & PROT_ICMPv4) return "icmp";
67 if (protocol & PROT_UDPv4 ) return "udp"; 67 if (protocol & PROT_UDPv4 ) return "udp";
68 if (protocol & PROT_TCPv4 ) return "tcp"; 68 if (protocol & PROT_TCPv4 ) return "tcp";
69 if (protocol & PROT_DNSv4 ) return "dns";
69 70
70 return "<unknown>"; 71 return "<unknown>";
71} 72}
72 73
73void 74void
96 free (hostname); 97 free (hostname);
97} 98}
98 99
99void configuration::init () 100void configuration::init ()
100{ 101{
102 asprintf (&confbase, "%s/vpe", CONFDIR);
103
101 memset (this, 0, sizeof (*this)); 104 memset (this, 0, sizeof (*this));
102 105
103 mtu = DEFAULT_MTU; 106 mtu = DEFAULT_MTU;
104 rekey = DEFAULT_REKEY; 107 rekey = DEFAULT_REKEY;
105 keepalive = DEFAULT_KEEPALIVE; 108 keepalive = DEFAULT_KEEPALIVE;
108#if ENABLE_ICMP 111#if ENABLE_ICMP
109 icmp_type = ICMP_ECHOREPLY; 112 icmp_type = ICMP_ECHOREPLY;
110#endif 113#endif
111 114
112 default_node.udp_port = DEFAULT_UDPPORT; 115 default_node.udp_port = DEFAULT_UDPPORT;
113 default_node.tcp_port = DEFAULT_UDPPORT; 116 default_node.tcp_port = DEFAULT_UDPPORT; // ehrm
114 default_node.connectmode = conf_node::C_ALWAYS; 117 default_node.connectmode = conf_node::C_ALWAYS;
115 default_node.compress = true; 118 default_node.compress = true;
116 default_node.protocols = PROT_UDPv4; 119 default_node.protocols = PROT_UDPv4;
120
121 conf.pidfilename = strdup (LOCALSTATEDIR "/run/vped.pid");
117} 122}
118 123
119void configuration::cleanup() 124void configuration::cleanup()
120{ 125{
121 if (rsa_key) 126 if (rsa_key)
122 RSA_free (rsa_key); 127 RSA_free (rsa_key);
123 128
124 rsa_key = 0; 129 rsa_key = 0;
125 130
131 free (pidfilename); pidfilename = 0;
126 free (ifname); ifname = 0; 132 free (ifname); ifname = 0;
127#if ENABLE_HTTP_PROXY 133#if ENABLE_HTTP_PROXY
128 free (proxy_host); proxy_host = 0; 134 free (proxy_host); proxy_host = 0;
129 free (proxy_auth); proxy_auth = 0; 135 free (proxy_auth); proxy_auth = 0;
130#endif 136#endif
131} 137}
132 138
133void 139void
134configuration::clear_config () 140configuration::clear_config ()
281 287
282 if (::thisnode && !strcmp (node->nodename, ::thisnode)) 288 if (::thisnode && !strcmp (node->nodename, ::thisnode))
283 thisnode = node; 289 thisnode = node;
284 } 290 }
285 else if (!strcmp (var, "private-key")) 291 else if (!strcmp (var, "private-key"))
286 prikeyfile = strdup (val); 292 free (prikeyfile), prikeyfile = strdup (val);
287 else if (!strcmp (var, "ifpersist")) 293 else if (!strcmp (var, "ifpersist"))
288 { 294 {
289 parse_bool (ifpersist, "ifpersist", true, false); 295 parse_bool (ifpersist, "ifpersist", true, false);
290 } 296 }
291 else if (!strcmp (var, "ifname")) 297 else if (!strcmp (var, "ifname"))
292 ifname = strdup (val); 298 free (ifname), ifname = strdup (val);
293 else if (!strcmp (var, "rekey")) 299 else if (!strcmp (var, "rekey"))
294 rekey = atoi (val); 300 rekey = atoi (val);
295 else if (!strcmp (var, "keepalive")) 301 else if (!strcmp (var, "keepalive"))
296 keepalive = atoi (val); 302 keepalive = atoi (val);
297 else if (!strcmp (var, "mtu")) 303 else if (!strcmp (var, "mtu"))
298 mtu = atoi (val); 304 mtu = atoi (val);
299 else if (!strcmp (var, "if-up")) 305 else if (!strcmp (var, "if-up"))
300 script_if_up = strdup (val); 306 free (script_if_up), script_if_up = strdup (val);
301 else if (!strcmp (var, "node-up")) 307 else if (!strcmp (var, "node-up"))
302 script_node_up = strdup (val); 308 free (script_node_up), script_node_up = strdup (val);
303 else if (!strcmp (var, "node-down")) 309 else if (!strcmp (var, "node-down"))
304 script_node_down = strdup (val); 310 free (script_node_down), script_node_down = strdup (val);
311 else if (!strcmp (var, "pid-file"))
312 free (pidfilename), pidfilename = strdup (val);
305 else if (!strcmp (var, "http-proxy-host")) 313 else if (!strcmp (var, "http-proxy-host"))
306 { 314 {
307#if ENABLE_HTTP_PROXY 315#if ENABLE_HTTP_PROXY
308 proxy_host = strdup (val); 316 free (proxy_host), proxy_host = strdup (val);
309#endif 317#endif
310 } 318 }
311 else if (!strcmp (var, "http-proxy-port")) 319 else if (!strcmp (var, "http-proxy-port"))
312 { 320 {
313#if ENABLE_HTTP_PROXY 321#if ENABLE_HTTP_PROXY
321#endif 329#endif
322 } 330 }
323 331
324 /* node-specific, non-defaultable */ 332 /* node-specific, non-defaultable */
325 else if (node != &default_node && !strcmp (var, "hostname")) 333 else if (node != &default_node && !strcmp (var, "hostname"))
326 {
327 free (node->hostname);
328 node->hostname = strdup (val); 334 free (node->hostname), node->hostname = strdup (val);
329 }
330 335
331 /* node-specific, defaultable */ 336 /* node-specific, defaultable */
332 else if (!strcmp (var, "udp-port")) 337 else if (!strcmp (var, "udp-port"))
333 node->udp_port = atoi (val); 338 node->udp_port = atoi (val);
334 else if (!strcmp (var, "tcp-port")) 339 else if (!strcmp (var, "tcp-port"))
335 node->tcp_port = atoi (val); 340 node->tcp_port = atoi (val);
341 else if (!strcmp (var, "dns-port"))
342 node->dns_port = atoi (val);
336 else if (!strcmp (var, "router-priority")) 343 else if (!strcmp (var, "router-priority"))
337 node->routerprio = atoi (val); 344 node->routerprio = atoi (val);
338 else if (!strcmp (var, "connect")) 345 else if (!strcmp (var, "connect"))
339 { 346 {
340 if (!strcmp (val, "ondemand")) 347 if (!strcmp (val, "ondemand"))
369 { 376 {
370#if ENABLE_ICMP 377#if ENABLE_ICMP
371 u8 v; parse_bool (v, "enable-icmp" , PROT_ICMPv4, 0); node->protocols = (node->protocols & ~PROT_ICMPv4) | v; 378 u8 v; parse_bool (v, "enable-icmp" , PROT_ICMPv4, 0); node->protocols = (node->protocols & ~PROT_ICMPv4) | v;
372#endif 379#endif
373 } 380 }
381 else if (!strcmp (var, "enable-dns"))
382 {
383#if ENABLE_DNS
384 u8 v; parse_bool (v, "enable-dns" , PROT_DNSv4, 0); node->protocols = (node->protocols & ~PROT_DNSv4) | v;
385#endif
386 }
374 else if (!strcmp (var, "enable-udp")) 387 else if (!strcmp (var, "enable-udp"))
375 { 388 {
376 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; 389 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v;
377 } 390 }
378 else if (!strcmp (var, "enable-rawip")) 391 else if (!strcmp (var, "enable-rawip"))
379 { 392 {;
380 u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v; 393 u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v;
381 } 394 }
382 395
383 // unknown or misplaced 396 // unknown or misplaced
384 else 397 else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines