… | |
… | |
31 | #include <errno.h> |
31 | #include <errno.h> |
32 | #include <time.h> |
32 | #include <time.h> |
33 | #include <unistd.h> |
33 | #include <unistd.h> |
34 | #include <fcntl.h> |
34 | #include <fcntl.h> |
35 | #include <sys/socket.h> |
35 | #include <sys/socket.h> |
36 | #include <netinet/in.h> |
36 | |
37 | #include <arpa/inet.h> |
37 | #include "netcompat.h" |
38 | #include <net/if.h> |
|
|
39 | #ifdef HAVE_NETINET_IN_SYSTM_H |
|
|
40 | # include <netinet/in_systm.h> |
|
|
41 | #endif |
|
|
42 | #ifdef HAVE_NETINET_IP_H |
|
|
43 | # include <netinet/ip.h> |
|
|
44 | #endif |
|
|
45 | #ifdef HAVE_NETINET_TCP_H |
|
|
46 | # include <netinet/tcp.h> |
|
|
47 | #endif |
|
|
48 | #if ENABLE_ICMP |
|
|
49 | # include <netinet/ip_icmp.h> |
|
|
50 | #endif |
|
|
51 | |
38 | |
52 | #include "pidfile.h" |
39 | #include "pidfile.h" |
53 | |
40 | |
54 | #include "connection.h" |
41 | #include "connection.h" |
55 | #include "util.h" |
42 | #include "util.h" |
56 | #include "vpn.h" |
43 | #include "vpn.h" |
57 | |
|
|
58 | #if !defined(SOL_IP) && defined(IPPROTO_IP) |
|
|
59 | # define SOL_IP IPPROTO_IP |
|
|
60 | #endif |
|
|
61 | |
44 | |
62 | ///////////////////////////////////////////////////////////////////////////// |
45 | ///////////////////////////////////////////////////////////////////////////// |
63 | |
46 | |
64 | const char *vpn::script_if_up () |
47 | const char *vpn::script_if_up () |
65 | { |
48 | { |
… | |
… | |
320 | |
303 | |
321 | return ~sum; |
304 | return ~sum; |
322 | } |
305 | } |
323 | |
306 | |
324 | #if ENABLE_ICMP |
307 | #if ENABLE_ICMP |
325 | struct icmp_header { |
|
|
326 | u8 type; |
|
|
327 | u8 code; |
|
|
328 | u16 checksum; |
|
|
329 | union { |
|
|
330 | struct { |
|
|
331 | u16 id; |
|
|
332 | u16 sequence; |
|
|
333 | } echo; |
|
|
334 | u32 gateway; |
|
|
335 | struct { |
|
|
336 | u16 unused; |
|
|
337 | u16 mtu; |
|
|
338 | } frag; |
|
|
339 | } un; |
|
|
340 | }; |
|
|
341 | |
|
|
342 | bool |
308 | bool |
343 | vpn::send_icmpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos) |
309 | vpn::send_icmpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos) |
344 | { |
310 | { |
345 | #if defined(SOL_IP) && defined(IP_TOS) |
311 | #if defined(SOL_IP) && defined(IP_TOS) |
346 | setsockopt (icmpv4_fd, SOL_IP, IP_TOS, &tos, sizeof tos); |
312 | setsockopt (icmpv4_fd, SOL_IP, IP_TOS, &tos, sizeof tos); |