Browse code

Minimal Solaris/OpenIndiana support to Cmake and clean up -Werror

Change-Id: I66e3dd7b7166459526824fe5ae81a449b375b8db
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20231128111447.64445-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27581.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Arne Schwabe authored on 2023/11/28 20:14:47
Showing 4 changed files
... ...
@@ -121,11 +121,17 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
121 121
     set(TARGET_FREEBSD YES)
122 122
     set(ENABLE_DCO YES)
123 123
     link_libraries(-lnv)
124
+elseif (${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
125
+    set(TARGET_SOLARIS YES)
126
+    set(HAVE_SYS_SOCKIO_H 1)
127
+    link_libraries(-lnsl -lsocket -lresolv)
124 128
 elseif (WIN32)
125 129
     set(ENABLE_DCO YES)
126 130
 elseif (APPLE)
127 131
     set(TARGET_DARWIN YES)
128 132
     set(HAVE_NET_IF_UTUN_H YES)
133
+else()
134
+    message(FATAL_ERROR "Unknown system name: \"${CMAKE_SYSTEM_NAME}\"")
129 135
 endif ()
130 136
 
131 137
 if (UNIX)
... ...
@@ -334,7 +334,7 @@ don't. */
334 334
 #cmakedefine HAVE_SYS_SOCKET_H
335 335
 
336 336
 /* Define to 1 if you have the <sys/sockio.h> header file. */
337
-#undef HAVE_SYS_SOCKIO_H
337
+#cmakedefine HAVE_SYS_SOCKIO_H
338 338
 
339 339
 /* Define to 1 if you have the <sys/stat.h> header file. */
340 340
 #define HAVE_SYS_STAT_H 1
... ...
@@ -438,6 +438,9 @@ don't. */
438 438
 /* Are we running on Linux? */
439 439
 #cmakedefine TARGET_LINUX
440 440
 
441
+/* Are we running on Solaris/OpenIndiana? */
442
+#cmakedefine TARGET_SOLARIS
443
+
441 444
 /* Are we running WIN32? */
442 445
 #cmakedefine TARGET_WIN32
443 446
 
... ...
@@ -2342,12 +2342,11 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt,
2342 2342
         return;
2343 2343
     }
2344 2344
 
2345
-#ifndef _WIN32
2345
+#if !defined(_WIN32)
2346 2346
 #if !defined(TARGET_LINUX)
2347 2347
     const char *gateway;
2348
-#else
2349
-    int metric;
2350 2348
 #endif
2349
+#if !defined(TARGET_SOLARIS)
2351 2350
     bool gateway_needed = false;
2352 2351
     const char *device = tt->actual_name;
2353 2352
     if (r6->iface != NULL)              /* vpn server special route */
... ...
@@ -2365,6 +2364,7 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt,
2365 2365
         gateway_needed = true;
2366 2366
     }
2367 2367
 #endif
2368
+#endif
2368 2369
 
2369 2370
     struct gc_arena gc = gc_new();
2370 2371
     struct argv argv = argv_new();
... ...
@@ -2395,7 +2395,7 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt,
2395 2395
     msg( M_INFO, "delete_route_ipv6(%s/%d)", network, r6->netbits );
2396 2396
 
2397 2397
 #if defined(TARGET_LINUX)
2398
-    metric = -1;
2398
+    int metric = -1;
2399 2399
     if ((r6->flags & RT_METRIC_DEFINED) && (r6->metric > 0))
2400 2400
     {
2401 2401
         metric = r6->metric;
... ...
@@ -1900,7 +1900,7 @@ tun_dco_enabled(struct tuntap *tt)
1900 1900
 #endif
1901 1901
 
1902 1902
 
1903
-#if !(defined(_WIN32) || defined(TARGET_LINUX))
1903
+#if !(defined(_WIN32) || defined(TARGET_LINUX) || defined(TARGET_SOLARIS))
1904 1904
 static void
1905 1905
 open_tun_generic(const char *dev, const char *dev_type, const char *dev_node,
1906 1906
                  struct tuntap *tt)
... ...
@@ -2061,7 +2061,7 @@ open_tun_dco_generic(const char *dev, const char *dev_type,
2061 2061
 }
2062 2062
 #endif /* TARGET_LINUX || TARGET_FREEBSD*/
2063 2063
 
2064
-#if !defined(_WIN32)
2064
+#if !(defined(_WIN32) || defined(TARGET_SOLARIS))
2065 2065
 static void
2066 2066
 close_tun_generic(struct tuntap *tt)
2067 2067
 {
... ...
@@ -2398,13 +2398,12 @@ void
2398 2398
 open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt,
2399 2399
          openvpn_net_ctx_t *ctx)
2400 2400
 {
2401
-    int if_fd, ip_muxid, arp_muxid, arp_fd, ppa = -1;
2401
+    int if_fd = -1, ip_muxid = -1, arp_muxid = -1, arp_fd = -1, ppa = -1;
2402 2402
     struct lifreq ifr;
2403 2403
     const char *ptr;
2404
-    const char *ip_node, *arp_node;
2404
+    const char *ip_node = NULL, *arp_node = NULL;
2405 2405
     const char *dev_tuntap_type;
2406 2406
     int link_type;
2407
-    bool is_tun;
2408 2407
     struct strioctl strioc_if, strioc_ppa;
2409 2408
 
2410 2409
     /* improved generic TUN/TAP driver from
... ...
@@ -2428,7 +2427,6 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
2428 2428
         }
2429 2429
         dev_tuntap_type = "tun";
2430 2430
         link_type = I_PLINK;
2431
-        is_tun = true;
2432 2431
     }
2433 2432
     else if (tt->type == DEV_TYPE_TAP)
2434 2433
     {
... ...
@@ -2440,7 +2438,6 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
2440 2440
         arp_node = dev_node;
2441 2441
         dev_tuntap_type = "tap";
2442 2442
         link_type = I_PLINK; /* was: I_LINK */
2443
-        is_tun = false;
2444 2443
     }
2445 2444
     else
2446 2445
     {