… | |
… | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
15 | GNU General Public License for more details. |
16 | |
16 | |
17 | 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 |
18 | along with gvpe; if not, write to the Free Software |
18 | along with gvpe; if not, write to the Free Software |
19 | Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | */ |
20 | */ |
21 | |
21 | |
22 | #ifndef GVPE_CONF_H__ |
22 | #ifndef GVPE_CONF_H__ |
23 | #define GVPE_CONF_H__ |
23 | #define GVPE_CONF_H__ |
24 | |
24 | |
… | |
… | |
32 | #define DEFAULT_REKEY 3600 |
32 | #define DEFAULT_REKEY 3600 |
33 | #define DEFAULT_KEEPALIVE 60 // one keepalive/minute (it's just 8 bytes...) |
33 | #define DEFAULT_KEEPALIVE 60 // one keepalive/minute (it's just 8 bytes...) |
34 | #define DEFAULT_UDPPORT 655 // same as tinc, conflicts would be rare |
34 | #define DEFAULT_UDPPORT 655 // same as tinc, conflicts would be rare |
35 | #define DEFAULT_MTU 1500 // let's ether-net |
35 | #define DEFAULT_MTU 1500 // let's ether-net |
36 | #define DEFAULT_MAX_RETRY 3600 // retry at least this often |
36 | #define DEFAULT_MAX_RETRY 3600 // retry at least this often |
|
|
37 | #define DEFAULT_MAX_TTL 60 // packets expire after this many seconds |
|
|
38 | #define DEFAULT_MAX_QUEUE 512 // never queue more than this many packets |
37 | |
39 | |
38 | #define DEFAULT_DNS_TIMEOUT_FACTOR 8.F // initial retry timeout multiple |
40 | #define DEFAULT_DNS_TIMEOUT_FACTOR 8.F // initial retry timeout multiple |
39 | #define DEFAULT_DNS_SEND_INTERVAL .01F // minimum send interval |
41 | #define DEFAULT_DNS_SEND_INTERVAL .01F // minimum send interval |
40 | #define DEFAULT_DNS_OVERLAP_FACTOR .5F // RTT * LATENCY_FACTOR == sending rate |
42 | #define DEFAULT_DNS_OVERLAP_FACTOR .5F // RTT * LATENCY_FACTOR == sending rate |
41 | #define DEFAULT_DNS_MAX_OUTSTANDING 100 // max. number of outstanding requests |
43 | #define DEFAULT_DNS_MAX_OUTSTANDING 100 // max. number of outstanding requests |
42 | |
44 | |
43 | enum { |
45 | enum |
|
|
46 | { |
44 | PROT_UDPv4 = 0x01, // udp over ipv4 |
47 | PROT_UDPv4 = 0x01, // udp over ipv4 |
45 | PROT_IPv4 = 0x02, // generic ip protocol |
48 | PROT_IPv4 = 0x02, // generic ip protocol |
46 | PROT_TCPv4 = 0x04, // tcp over ipv4 (server) |
49 | PROT_TCPv4 = 0x04, // tcp over ipv4 (server) |
47 | PROT_ICMPv4 = 0x08, // icmp over ipv4 |
50 | PROT_ICMPv4 = 0x08, // icmp over ipv4 |
48 | PROT_DNSv4 = 0x10, // dns tunnel ipv4 (server) |
51 | PROT_DNSv4 = 0x10, // dns tunnel ipv4 (server) |
… | |
… | |
53 | |
56 | |
54 | // select the "best" protocol of the available ones |
57 | // select the "best" protocol of the available ones |
55 | u8 best_protocol (u8 protset); |
58 | u8 best_protocol (u8 protset); |
56 | const char *strprotocol (u8 protocol); |
59 | const char *strprotocol (u8 protocol); |
57 | |
60 | |
58 | struct conf_node { |
61 | struct conf_node |
|
|
62 | { |
59 | int id; // the id of this node, a 12-bit-number |
63 | int id; // the id of this node, a 12-bit-number |
60 | |
64 | |
61 | RSA *rsa_key; // his public key |
65 | RSA *rsa_key; // his public key |
62 | char *nodename; // nodename, an internal nickname. |
66 | char *nodename; // nodename, an internal nickname. |
63 | char *hostname; // hostname, if known, or NULL. |
67 | char *hostname; // hostname, if known, or NULL. |
… | |
… | |
69 | u16 dns_port; |
73 | u16 dns_port; |
70 | |
74 | |
71 | u8 protocols; // protocols this host can send & receive |
75 | u8 protocols; // protocols this host can send & receive |
72 | u16 udp_port, tcp_port; // the port to bind to |
76 | u16 udp_port, tcp_port; // the port to bind to |
73 | int max_retry; |
77 | int max_retry; |
|
|
78 | double max_ttl; // packets expire after this many seconds |
|
|
79 | int max_queue; // maixmum send queue length |
74 | |
80 | |
75 | enum connectmode { C_ONDEMAND, C_NEVER, C_ALWAYS, C_DISABLED } connectmode; |
81 | enum connectmode { C_ONDEMAND, C_NEVER, C_ALWAYS, C_DISABLED } connectmode; |
76 | bool compress; |
82 | bool compress; |
77 | bool inherit_tos; // inherit TOS in packets send to this destination |
83 | bool inherit_tos; // inherit TOS in packets send to this destination |
78 | |
84 | |
|
|
85 | vector<const char *> allow_direct; |
|
|
86 | vector<const char *> deny_direct; |
|
|
87 | |
79 | u32 routerprio; |
88 | u32 routerprio; |
|
|
89 | |
|
|
90 | bool can_direct (struct conf_node *other); |
80 | |
91 | |
81 | void print (); |
92 | void print (); |
82 | |
93 | |
83 | ~conf_node (); |
94 | ~conf_node (); |
84 | }; |
95 | }; |
85 | |
96 | |
86 | struct configuration { |
97 | struct configuration |
|
|
98 | { |
87 | typedef vector<conf_node *> node_vector; |
99 | typedef vector<conf_node *> node_vector; |
88 | node_vector nodes; |
100 | node_vector nodes; |
89 | conf_node default_node; |
101 | conf_node default_node; |
90 | conf_node *thisnode; |
102 | conf_node *thisnode; |
91 | int mtu; // the mtu used for outgoing tunnel packets |
103 | int mtu; // the mtu used for outgoing tunnel packets |
… | |
… | |
121 | int dns_max_outstanding; |
133 | int dns_max_outstanding; |
122 | #endif |
134 | #endif |
123 | |
135 | |
124 | void init (); |
136 | void init (); |
125 | void cleanup (); |
137 | void cleanup (); |
126 | void read_config (bool need_keys); |
|
|
127 | void clear_config (); |
138 | void clear (); |
128 | |
139 | |
129 | // create a filename from string, replacing %s by the nodename |
140 | // create a filename from string, replacing %s by the nodename |
130 | // and using relative paths under confbase. |
141 | // and using relative paths under confbase. |
131 | char *config_filename (const char *name, const char *dflt); |
142 | char *config_filename (const char *name, const char *dflt); |
132 | |
143 | |
… | |
… | |
134 | |
145 | |
135 | configuration (); |
146 | configuration (); |
136 | ~configuration (); |
147 | ~configuration (); |
137 | }; |
148 | }; |
138 | |
149 | |
|
|
150 | struct configuration_parser |
|
|
151 | { |
|
|
152 | configuration &conf; |
|
|
153 | |
|
|
154 | bool need_keys; |
|
|
155 | conf_node *node; |
|
|
156 | |
|
|
157 | int argc; |
|
|
158 | char **argv; |
|
|
159 | |
|
|
160 | configuration_parser (configuration &conf, bool need_keys, int argc, char **argv); |
|
|
161 | |
|
|
162 | const char *parse_line (char *line); |
|
|
163 | void parse_argv (); |
|
|
164 | }; |
|
|
165 | |
139 | extern struct configuration conf; |
166 | extern struct configuration conf; |
140 | |
167 | |
141 | #define THISNODE ::conf.thisnode |
168 | #define THISNODE ::conf.thisnode |
142 | |
169 | |
143 | #endif |
170 | #endif |