… | |
… | |
32 | #include <sys/stat.h> |
32 | #include <sys/stat.h> |
33 | #include <sys/types.h> |
33 | #include <sys/types.h> |
34 | #include <unistd.h> |
34 | #include <unistd.h> |
35 | |
35 | |
36 | #include <netinet/in.h> |
36 | #include <netinet/in.h> |
|
|
37 | #include <netinet/icmp.h> |
37 | |
38 | |
38 | #include <openssl/err.h> |
39 | #include <openssl/err.h> |
39 | #include <openssl/pem.h> |
40 | #include <openssl/pem.h> |
40 | #include <openssl/rsa.h> |
41 | #include <openssl/rsa.h> |
41 | #include <openssl/rand.h> |
42 | #include <openssl/rand.h> |
… | |
… | |
53 | |
54 | |
54 | struct configuration conf; |
55 | struct configuration conf; |
55 | |
56 | |
56 | u8 best_protocol (u8 protset) |
57 | u8 best_protocol (u8 protset) |
57 | { |
58 | { |
58 | if (protset & PROT_IPv4 ) return PROT_IPv4; |
59 | if (protset & PROT_IPv4 ) return PROT_IPv4; |
|
|
60 | if (protset & PROT_ICMPv4) return PROT_ICMPv4; |
59 | if (protset & PROT_UDPv4) return PROT_UDPv4; |
61 | if (protset & PROT_UDPv4 ) return PROT_UDPv4; |
60 | if (protset & PROT_TCPv4) return PROT_TCPv4; |
62 | if (protset & PROT_TCPv4 ) return PROT_TCPv4; |
61 | |
63 | |
62 | return 0; |
64 | return 0; |
63 | } |
65 | } |
64 | |
66 | |
65 | const char *strprotocol (u8 protocol) |
67 | const char *strprotocol (u8 protocol) |
66 | { |
68 | { |
67 | if (protocol & PROT_IPv4 ) return "rawip"; |
69 | if (protocol & PROT_IPv4 ) return "rawip"; |
|
|
70 | if (protocol & PROT_ICMPv4) return "icmp"; |
68 | if (protocol & PROT_UDPv4) return "udp"; |
71 | if (protocol & PROT_UDPv4 ) return "udp"; |
69 | if (protocol & PROT_TCPv4) return "tcp"; |
72 | if (protocol & PROT_TCPv4 ) return "tcp"; |
70 | |
73 | |
71 | return "<unknown>"; |
74 | return "<unknown>"; |
72 | } |
75 | } |
73 | |
76 | |
74 | void |
77 | void |
… | |
… | |
103 | |
106 | |
104 | rekey = DEFAULT_REKEY; |
107 | rekey = DEFAULT_REKEY; |
105 | keepalive = DEFAULT_KEEPALIVE; |
108 | keepalive = DEFAULT_KEEPALIVE; |
106 | llevel = L_INFO; |
109 | llevel = L_INFO; |
107 | ip_proto = IPPROTO_GRE; |
110 | ip_proto = IPPROTO_GRE; |
|
|
111 | icmp_type = ICMP_ECHOREPLY; |
108 | |
112 | |
109 | default_node.udp_port = DEFAULT_UDPPORT; |
113 | default_node.udp_port = DEFAULT_UDPPORT; |
110 | default_node.tcp_port = DEFAULT_UDPPORT; |
114 | default_node.tcp_port = DEFAULT_UDPPORT; |
111 | default_node.connectmode = conf_node::C_ALWAYS; |
115 | default_node.connectmode = conf_node::C_ALWAYS; |
112 | default_node.compress = true; |
116 | default_node.compress = true; |
… | |
… | |
223 | else |
227 | else |
224 | slog (L_WARN, "'%s': %s, at '%s' line %d", val, UNKNOWN_LOGLEVEL, fname, line); |
228 | slog (L_WARN, "'%s': %s, at '%s' line %d", val, UNKNOWN_LOGLEVEL, fname, line); |
225 | } |
229 | } |
226 | else if (!strcmp (var, "ip-proto")) |
230 | else if (!strcmp (var, "ip-proto")) |
227 | ip_proto = atoi (val); |
231 | ip_proto = atoi (val); |
|
|
232 | else if (!strcmp (var, "icmp-type")) |
|
|
233 | icmp_type = atoi (val); |
228 | |
234 | |
229 | // per config |
235 | // per config |
230 | else if (!strcmp (var, "node")) |
236 | else if (!strcmp (var, "node")) |
231 | { |
237 | { |
232 | default_node.id++; |
238 | default_node.id++; |
… | |
… | |
344 | { |
350 | { |
345 | #if ENABLE_TCP |
351 | #if ENABLE_TCP |
346 | u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v; |
352 | u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v; |
347 | #endif |
353 | #endif |
348 | } |
354 | } |
|
|
355 | else if (!strcmp (var, "enable-icmp")) |
|
|
356 | { |
|
|
357 | #if ENABLE_ICMP |
|
|
358 | u8 v; parse_bool (v, "enable-icmp" , PROT_ICMPv4, 0); node->protocols = (node->protocols & ~PROT_ICMPv4) | v; |
|
|
359 | #endif |
|
|
360 | } |
349 | else if (!strcmp (var, "enable-udp")) |
361 | else if (!strcmp (var, "enable-udp")) |
350 | { |
362 | { |
351 | u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; |
363 | u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; |
352 | } |
364 | } |
353 | else if (!strcmp (var, "enable-rawip")) |
365 | else if (!strcmp (var, "enable-rawip")) |