Ticket #662: patch_openvpn_configure

File patch_openvpn_configure, 4.6 KB (added by pruy, 6 years ago)

patch to configure files needed for NetBSD

Line 
1diff --git a/configure.ac b/configure.ac
2index b75d51f..8867587 100644
3--- a/configure.ac
4+++ b/configure.ac
5@@ -441,6 +441,7 @@ AC_CHECK_HEADERS([ \
6        sys/mman.h sys/file.h sys/wait.h \
7        unistd.h signal.h libgen.h stropts.h \
8        syslog.h pwd.h grp.h \
9+       net/if_tap.h \
10        sys/sockio.h sys/uio.h linux/sockios.h \
11        linux/types.h sys/poll.h sys/epoll.h err.h \
12 ])
13@@ -455,6 +456,9 @@ SOCKET_INCLUDES="
14 #ifdef HAVE_SYS_SOCKET_H
15 #include <sys/socket.h>
16 #endif
17+#ifdef HAVE_NET_IF_H
18+#include <net/if.h>
19+#endif
20 #ifdef HAVE_NETINET_IN_H
21 #include <netinet/in.h>
22 #endif
23@@ -518,6 +522,12 @@ AC_CHECK_TYPE(
24        ,
25        [[${SOCKET_INCLUDES}]]
26 )
27+AC_CHECK_MEMBER(
28+       [struct in_pktinfo.ipi_spec_dst],
29+       [AC_DEFINE([HAVE_IPI_SPEC_DST], [1], [struct in_pktinfo.ipi_spec_dst needed for IP_PKTINFO support])],
30+       ,
31+       [[${SOCKET_INCLUDES}]]
32+)
33 AC_CHECK_TYPE(
34         [sa_family_t],
35         [AC_DEFINE([HAVE_SA_FAMILY_T], [1], [sa_family_t, needed to hold AF_* info])],
36diff --git a/src/compat/compat-basename.c b/src/compat/compat-basename.c
37index a057691..0ca0f5f 100644
38--- a/src/compat/compat-basename.c
39+++ b/src/compat/compat-basename.c
40@@ -28,6 +28,10 @@
41 #include "config-msvc.h"
42 #endif
43 
44+#ifdef __sun
45+int need_at_least_one_symbol = 0;
46+#endif
47+
48 #ifndef HAVE_BASENAME
49 
50 #include "compat.h"
51diff --git a/src/openvpn/init.c b/src/openvpn/init.c
52index cb73a3d..7f4ff4a 100644
53--- a/src/openvpn/init.c
54+++ b/src/openvpn/init.c
55@@ -1293,7 +1293,7 @@ initialization_sequence_completed (struct context *c, const unsigned int flags)
56           switch (local.addr.sa.sa_family)
57             {
58             case AF_INET:
59-#ifdef IP_PKTINFO
60+#if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
61               local.addr.in4.sin_addr = actual->pi.in4.ipi_spec_dst;
62 #else
63               local.addr.in4.sin_addr = actual->pi.in4;
64diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
65index 714a847..a165428 100644
66--- a/src/openvpn/socket.c
67+++ b/src/openvpn/socket.c
68@@ -2457,7 +2457,7 @@ print_link_socket_actual_ex (const struct link_socket_actual *act,
69                  struct openvpn_sockaddr sa;
70                  CLEAR (sa);
71                  sa.addr.in4.sin_family = AF_INET;
72-#ifdef IP_PKTINFO
73+#if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
74                  sa.addr.in4.sin_addr = act->pi.in4.ipi_spec_dst;
75                  if_indextoname(act->pi.in4.ipi_ifindex, ifname);
76 #elif defined(IP_RECVDSTADDR)
77@@ -2859,7 +2859,7 @@ link_socket_read_tcp (struct link_socket *sock,
78 struct openvpn_in4_pktinfo
79 {
80   struct cmsghdr cmsghdr;
81-#ifdef HAVE_IN_PKTINFO
82+#if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
83   struct in_pktinfo pi4;
84 #elif defined(IP_RECVDSTADDR)
85   struct in_addr pi4;
86@@ -2904,7 +2904,7 @@ link_socket_read_udp_posix_recvmsg (struct link_socket *sock,
87       cmsg = CMSG_FIRSTHDR (&mesg);
88       if (cmsg != NULL
89          && CMSG_NXTHDR (&mesg, cmsg) == NULL
90-#ifdef IP_PKTINFO
91+#if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
92          && cmsg->cmsg_level == SOL_IP
93          && cmsg->cmsg_type == IP_PKTINFO
94 #elif defined(IP_RECVDSTADDR)
95@@ -2915,7 +2915,7 @@ link_socket_read_udp_posix_recvmsg (struct link_socket *sock,
96 #endif
97          && cmsg->cmsg_len >= sizeof (struct openvpn_in4_pktinfo))
98        {
99-#ifdef IP_PKTINFO
100+#if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
101          struct in_pktinfo *pkti = (struct in_pktinfo *) CMSG_DATA (cmsg);
102          from->pi.in4.ipi_ifindex = pkti->ipi_ifindex;
103          from->pi.in4.ipi_spec_dst = pkti->ipi_spec_dst;
104@@ -3016,7 +3016,7 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,
105         mesg.msg_namelen = sizeof (struct sockaddr_in);
106         mesg.msg_control = &opi;
107         mesg.msg_flags = 0;
108-#ifdef HAVE_IN_PKTINFO
109+#if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
110         mesg.msg_controllen = sizeof (struct openvpn_in4_pktinfo);
111         cmsg = CMSG_FIRSTHDR (&mesg);
112         cmsg->cmsg_len = sizeof (struct openvpn_in4_pktinfo);
113diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h
114index b154bc0..312ef55 100644
115--- a/src/openvpn/socket.h
116+++ b/src/openvpn/socket.h
117@@ -90,7 +90,7 @@ struct link_socket_actual
118   struct openvpn_sockaddr dest;
119 #if ENABLE_IP_PKTINFO
120   union {
121-#ifdef HAVE_IN_PKTINFO
122+#if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
123     struct in_pktinfo in4;
124 #elif defined(IP_RECVDSTADDR)
125     struct in_addr in4;
126@@ -623,7 +623,7 @@ addr_defined_ipi (const struct link_socket_actual *lsa)
127 #if ENABLE_IP_PKTINFO
128   if (!lsa) return 0;
129   switch (lsa->dest.addr.sa.sa_family) {
130-#ifdef HAVE_IN_PKTINFO
131+#if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
132     case AF_INET: return lsa->pi.in4.ipi_spec_dst.s_addr != 0;
133 #elif defined(IP_RECVDSTADDR)
134     case AF_INET: return lsa->pi.in4.s_addr != 0;