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.8 by pcg, Wed Apr 2 03:25:17 2003 UTC vs.
Revision 1.12 by pcg, Mon Apr 7 01:12:56 2003 UTC

53 53
54struct configuration conf; 54struct configuration conf;
55 55
56u8 best_protocol (u8 protset) 56u8 best_protocol (u8 protset)
57{ 57{
58 if (protset & PROT_IPv4) 58 if (protset & PROT_IPv4 ) return PROT_IPv4;
59 return PROT_IPv4; 59 if (protset & PROT_UDPv4) return PROT_UDPv4;
60 if (protset & PROT_TCPv4) return PROT_TCPv4;
60 61
61 return PROT_UDPv4; 62 return 0;
62} 63}
63 64
64const char *strprotocol (u8 protocol) 65const char *strprotocol (u8 protocol)
65{ 66{
66 if (protocol & PROT_IPv4 ) return "rawip"; 67 if (protocol & PROT_IPv4 ) return "rawip";
67 if (protocol & PROT_UDPv4) return "udp"; 68 if (protocol & PROT_UDPv4) return "udp";
69 if (protocol & PROT_TCPv4) return "tcp";
68 70
69 return "<unknown>"; 71 return "<unknown>";
70} 72}
71 73
72configuration::configuration () 74void
75conf_node::print ()
73{ 76{
74 init (); 77 printf ("%4d fe:fd:80:00:0%1x:%02x %c %-8.8s %-10.10s %s%s%d\n",
78 id,
79 id >> 8, id & 0xff,
80 compress ? 'Y' : 'N',
81 connectmode == C_ONDEMAND ? "ondemand" :
82 connectmode == C_NEVER ? "never" :
83 connectmode == C_ALWAYS ? "always" : "",
84 nodename,
85 hostname ? hostname : "",
86 hostname ? ":" : "",
87 hostname ? udp_port : 0
88 );
75} 89}
76 90
77configuration::~configuration () 91conf_node::~conf_node ()
78{ 92{
79 cleanup (); 93 if (rsa_key)
94 RSA_free (rsa_key);
95
96 free (nodename);
97 free (hostname);
80} 98}
81 99
82void configuration::init () 100void configuration::init ()
83{ 101{
84 memset (this, 0, sizeof (*this)); 102 memset (this, 0, sizeof (*this));
98void configuration::cleanup() 116void configuration::cleanup()
99{ 117{
100 if (rsa_key) 118 if (rsa_key)
101 RSA_free (rsa_key); 119 RSA_free (rsa_key);
102 120
103 free (ifname);
104
105 rsa_key = 0; 121 rsa_key = 0;
106 ifname = 0; 122
123 free (ifname); ifname = 0;
124#if ENABLE_HTTP_PROXY
125 free (proxy_host); proxy_host = 0;
126 free (proxy_auth); proxy_auth = 0;
127#endif
107} 128}
108 129
109void 130void
110configuration::clear_config () 131configuration::clear_config ()
111{ 132{
270 script_if_up = strdup (val); 291 script_if_up = strdup (val);
271 else if (!strcmp (var, "node-up")) 292 else if (!strcmp (var, "node-up"))
272 script_node_up = strdup (val); 293 script_node_up = strdup (val);
273 else if (!strcmp (var, "node-down")) 294 else if (!strcmp (var, "node-down"))
274 script_node_down = strdup (val); 295 script_node_down = strdup (val);
296#if ENABLE_HTTP_PROXY
297 else if (!strcmp (var, "http-proxy-host"))
298 proxy_host = strdup (val);
299 else if (!strcmp (var, "http-proxy-port"))
300 proxy_port = atoi (val);
301 else if (!strcmp (var, "http-proxy-auth"))
302 proxy_auth = (char *)base64_encode ((const u8 *)val, strlen (val));
303#endif
275 304
276 /* node-specific, non-defaultable */ 305 /* node-specific, non-defaultable */
277 else if (node != &default_node && !strcmp (var, "hostname")) 306 else if (node != &default_node && !strcmp (var, "hostname"))
278 { 307 {
279 free (node->hostname); 308 free (node->hostname);
311 parse_bool (node->compress, "compress", true, false); 340 parse_bool (node->compress, "compress", true, false);
312 } 341 }
313 // all these bool options really really cost a lot of executable size! 342 // all these bool options really really cost a lot of executable size!
314 else if (!strcmp (var, "enable-tcp")) 343 else if (!strcmp (var, "enable-tcp"))
315 { 344 {
345#if ENABLE_TCP
316 u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v; 346 u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v;
347#endif
317 } 348 }
318 else if (!strcmp (var, "enable-udp")) 349 else if (!strcmp (var, "enable-udp"))
319 { 350 {
320 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; 351 u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v;
321 } 352 }
324 u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v; 355 u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v;
325 } 356 }
326 357
327 // unknown or misplaced 358 // unknown or misplaced
328 else 359 else
329 {
330 slog (L_WARN, 360 slog (L_WARN,
331 _("unknown or misplaced variable `%s', at '%s' line %d"), 361 _("unknown or misplaced variable `%s', at '%s' line %d"),
332 var, fname, lineno); 362 var, fname, lineno);
333 }
334 } 363 }
335 364
336 fclose (f); 365 fclose (f);
337 } 366 }
338 else 367 else
409 (*i)->print (); 438 (*i)->print ();
410 439
411 printf ("\n"); 440 printf ("\n");
412} 441}
413 442
414void 443configuration::configuration ()
415conf_node::print ()
416{ 444{
417 printf ("%4d fe:fd:80:00:0%1x:%02x %c %-8.8s %-10.10s %s%s%d\n", 445 init ();
418 id,
419 id >> 8, id & 0xff,
420 compress ? 'Y' : 'N',
421 connectmode == C_ONDEMAND ? "ondemand" :
422 connectmode == C_NEVER ? "never" :
423 connectmode == C_ALWAYS ? "always" : "",
424 nodename,
425 hostname ? hostname : "",
426 hostname ? ":" : "",
427 hostname ? udp_port : 0
428 );
429} 446}
430 447
448configuration::~configuration ()
449{
450 cleanup ();
451}
452
453

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines