… | |
… | |
17 | */ |
17 | */ |
18 | |
18 | |
19 | #ifndef VPE_CONF_H__ |
19 | #ifndef VPE_CONF_H__ |
20 | #define VPE_CONF_H__ |
20 | #define VPE_CONF_H__ |
21 | |
21 | |
22 | #include <sys/types.h> |
|
|
23 | #include <sys/socket.h> |
|
|
24 | #include <netdb.h> |
|
|
25 | |
|
|
26 | #ifdef HAVE_OPENSSL_RSA_H |
|
|
27 | # include <openssl/rsa.h> |
22 | #include <openssl/rsa.h> |
28 | #else |
|
|
29 | # include <rsa.h> |
|
|
30 | #endif |
|
|
31 | |
23 | |
32 | #include <vector> |
24 | #include <vector> |
33 | |
25 | |
34 | #include "slog.h" |
26 | #include "slog.h" |
35 | #include "global.h" |
27 | #include "global.h" |
… | |
… | |
42 | PROT_UDPv4 = 1, // udp over ipv4 |
34 | PROT_UDPv4 = 1, // udp over ipv4 |
43 | PROT_IPv4 = 2, // generic ip protocol |
35 | PROT_IPv4 = 2, // generic ip protocol |
44 | PROT_TCPv4 = 4, // tcp over ipv4 (NYI) |
36 | PROT_TCPv4 = 4, // tcp over ipv4 (NYI) |
45 | }; |
37 | }; |
46 | |
38 | |
|
|
39 | // select the "best" protocol of the available ones |
|
|
40 | u8 best_protocol (u8 protset); |
|
|
41 | const char *strprotocol (u8 protocol); |
|
|
42 | |
47 | struct conf_node { |
43 | struct conf_node { |
48 | int id; // the id of this node, a 12-bit-number |
44 | int id; // the id of this node, a 12-bit-number |
49 | |
45 | |
50 | RSA *rsa_key; // his public key |
46 | RSA *rsa_key; // his public key |
51 | char *nodename; // nodename, an internal nickname. |
47 | char *nodename; // nodename, an internal nickname. |
52 | |
48 | |
53 | char *hostname; // hostname, if known, or NULL. |
49 | char *hostname; // hostname, if known, or NULL. |
54 | |
50 | |
55 | u8 protocols; // protocols this host can send & receive |
51 | u8 protocols; // protocols this host can send & receive |
56 | u16 udp_port; // the port to bind to |
52 | u16 udp_port, tcp_port; // the port to bind to |
57 | |
53 | |
58 | enum connectmode { C_ONDEMAND, C_NEVER, C_ALWAYS, C_DISABLED } connectmode; |
54 | enum connectmode { C_ONDEMAND, C_NEVER, C_ALWAYS, C_DISABLED } connectmode; |
59 | bool compress; |
55 | bool compress; |
60 | bool inherit_tos; // inherit TOS in packets send to this destination |
56 | bool inherit_tos; // inherit TOS in packets send to this destination |
61 | |
57 | |
62 | u32 routerprio; |
58 | u32 routerprio; |
63 | |
59 | |
64 | void print (); |
60 | void print (); |
65 | |
61 | |
66 | ~conf_node () |
62 | ~conf_node (); |
67 | { |
|
|
68 | if (rsa_key) |
|
|
69 | RSA_free (rsa_key); |
|
|
70 | |
|
|
71 | free (nodename); |
|
|
72 | free (hostname); |
|
|
73 | } |
|
|
74 | }; |
63 | }; |
75 | |
64 | |
76 | struct configuration { |
65 | struct configuration { |
77 | typedef vector<conf_node *> node_vector; |
66 | typedef vector<conf_node *> node_vector; |
78 | node_vector nodes; |
67 | node_vector nodes; |
… | |
… | |
89 | u8 ip_proto; // the ip protocol to use |
78 | u8 ip_proto; // the ip protocol to use |
90 | |
79 | |
91 | char *script_if_up; |
80 | char *script_if_up; |
92 | char *script_node_up; |
81 | char *script_node_up; |
93 | char *script_node_down; |
82 | char *script_node_down; |
|
|
83 | |
|
|
84 | #if ENABLE_HTTP_PROXY |
|
|
85 | char *proxy_auth; // login:password |
|
|
86 | char *proxy_host; // the proxy hostname, e.g. proxy1.example.net |
|
|
87 | u16 proxy_port; // the proxy port, e.g. 3128 |
|
|
88 | #endif |
94 | |
89 | |
95 | void init (); |
90 | void init (); |
96 | void cleanup (); |
91 | void cleanup (); |
97 | void read_config (bool need_keys); |
92 | void read_config (bool need_keys); |
98 | void clear_config (); |
93 | void clear_config (); |