… | |
… | |
57 | char *thisnode; |
57 | char *thisnode; |
58 | char *identname; |
58 | char *identname; |
59 | |
59 | |
60 | struct configuration conf; |
60 | struct configuration conf; |
61 | |
61 | |
|
|
62 | u8 |
62 | u8 best_protocol (u8 protset) |
63 | best_protocol (u8 protset) |
63 | { |
64 | { |
64 | if (protset & PROT_IPv4 ) return PROT_IPv4; |
65 | if (protset & PROT_IPv4 ) return PROT_IPv4; |
65 | if (protset & PROT_ICMPv4) return PROT_ICMPv4; |
66 | if (protset & PROT_ICMPv4) return PROT_ICMPv4; |
66 | if (protset & PROT_UDPv4 ) return PROT_UDPv4; |
67 | if (protset & PROT_UDPv4 ) return PROT_UDPv4; |
67 | if (protset & PROT_TCPv4 ) return PROT_TCPv4; |
68 | if (protset & PROT_TCPv4 ) return PROT_TCPv4; |
68 | if (protset & PROT_DNSv4 ) return PROT_DNSv4; |
69 | if (protset & PROT_DNSv4 ) return PROT_DNSv4; |
69 | |
70 | |
70 | return 0; |
71 | return 0; |
71 | } |
72 | } |
72 | |
73 | |
|
|
74 | const char * |
73 | const char *strprotocol (u8 protocol) |
75 | strprotocol (u8 protocol) |
74 | { |
76 | { |
75 | if (protocol & PROT_IPv4 ) return "rawip"; |
77 | if (protocol & PROT_IPv4 ) return "rawip"; |
76 | if (protocol & PROT_ICMPv4) return "icmp"; |
78 | if (protocol & PROT_ICMPv4) return "icmp"; |
77 | if (protocol & PROT_UDPv4 ) return "udp"; |
79 | if (protocol & PROT_UDPv4 ) return "udp"; |
78 | if (protocol & PROT_TCPv4 ) return "tcp"; |
80 | if (protocol & PROT_TCPv4 ) return "tcp"; |
… | |
… | |
140 | free (dns_hostname); |
142 | free (dns_hostname); |
141 | #endif |
143 | #endif |
142 | #endif |
144 | #endif |
143 | } |
145 | } |
144 | |
146 | |
|
|
147 | void |
145 | void configuration::init () |
148 | configuration::init () |
146 | { |
149 | { |
147 | memset (this, 0, sizeof (*this)); |
150 | memset (this, 0, sizeof (*this)); |
148 | |
151 | |
149 | mtu = DEFAULT_MTU; |
152 | mtu = DEFAULT_MTU; |
150 | nfmark = 0; |
153 | nfmark = 0; |
… | |
… | |
178 | #endif |
181 | #endif |
179 | |
182 | |
180 | conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); |
183 | conf.pidfilename = strdup (LOCALSTATEDIR "/run/gvpe.pid"); |
181 | } |
184 | } |
182 | |
185 | |
|
|
186 | void |
183 | void configuration::cleanup() |
187 | configuration::cleanup () |
184 | { |
188 | { |
185 | if (rsa_key) |
189 | if (rsa_key) |
186 | RSA_free (rsa_key); |
190 | RSA_free (rsa_key); |
187 | |
191 | |
188 | rsa_key = 0; |
192 | rsa_key = 0; |
… | |
… | |
495 | return _("unknown configuration directive. (ignored)"); |
499 | return _("unknown configuration directive. (ignored)"); |
496 | |
500 | |
497 | return 0; |
501 | return 0; |
498 | } |
502 | } |
499 | |
503 | |
|
|
504 | void |
500 | void conf_node::finalise () |
505 | conf_node::finalise () |
501 | { |
506 | { |
502 | if (max_queue < 1) |
507 | if (max_queue < 1) |
503 | { |
508 | { |
504 | slog (L_WARN, _("%s: max-queue value invalid, setting it to 1."), nodename); |
509 | slog (L_WARN, _("%s: max-queue value invalid, setting it to 1."), nodename); |
505 | max_queue = 1; |
510 | max_queue = 1; |
… | |
… | |
510 | //slog (L_WARN, _("%s: has non-zero router-priority but either 'never' or 'ondemand' as connectmode, setting it to 'always'."), nodename); |
515 | //slog (L_WARN, _("%s: has non-zero router-priority but either 'never' or 'ondemand' as connectmode, setting it to 'always'."), nodename); |
511 | connectmode = C_ALWAYS; |
516 | connectmode = C_ALWAYS; |
512 | } |
517 | } |
513 | } |
518 | } |
514 | |
519 | |
|
|
520 | void |
515 | void configuration_parser::parse_argv () |
521 | configuration_parser::parse_argv () |
516 | { |
522 | { |
517 | for (int i = 0; i < argc; ++i) |
523 | for (int i = 0; i < argc; ++i) |
518 | { |
524 | { |
519 | char *v = argv [i]; |
525 | char *v = argv [i]; |
520 | |
526 | |
… | |
… | |
627 | |
633 | |
628 | for (configuration::node_vector::iterator i = conf.nodes.begin(); i != conf.nodes.end(); ++i) |
634 | for (configuration::node_vector::iterator i = conf.nodes.begin(); i != conf.nodes.end(); ++i) |
629 | (*i)->finalise (); |
635 | (*i)->finalise (); |
630 | } |
636 | } |
631 | |
637 | |
|
|
638 | char * |
632 | char *configuration::config_filename (const char *name, const char *dflt) |
639 | configuration::config_filename (const char *name, const char *dflt) |
633 | { |
640 | { |
634 | char *fname; |
641 | char *fname; |
635 | |
642 | |
636 | asprintf (&fname, name ? name : dflt, ::thisnode); |
643 | asprintf (&fname, name ? name : dflt, ::thisnode); |
637 | |
644 | |
… | |
… | |
678 | configuration::~configuration () |
685 | configuration::~configuration () |
679 | { |
686 | { |
680 | cleanup (); |
687 | cleanup (); |
681 | } |
688 | } |
682 | |
689 | |
683 | |
|
|