Skip to contentSkip to conversation

Mac OS X support

Openvpn-devel Christoph Pfisterer 2 participants 2 messages May 6, 2002

lore
Share & tools
lore
#0 lore raw

Hi all!

With some tweaking, I was able to get OpenVPN running on Mac OS X and use it happily with a Linux peer. Discussion and patches follow.

First of all, current versions of Mac OS X don't include a tun driver, although it is present in the source tree (publicly available via CVS). An independent port of the FreeBSD driver as a loadable module exists, but OpenVPN uncovered some bugs in it. I was able to fix those bugs and effectively took over maintenance of the driver. It is available from <http://chrisp.de/en/projects/tunnel.html>; OpenVPN requires at least version 1.1.0.

OpenVPN itself also needed some small patches, mostly due to Mac OS X's customized GCC and its outdated BSD headers. There are three main problems:

1. There is no in_addr_t and uint32_t is not automatically defined. Some research revealed that uint32_t is defined in <stdint.h>, which is not included explicitly. On Linux, it is included implicitly by <netinet/in.h>, but not so on Mac OS X. This is easily fixed in syshead.h.

2. Apple's precompiling version of cpp doesn't know about macros with variable arguments. Passing the "--no-cpp-precomp" command line option gets rid of this. I added a small check to configure to add it automatically.

3. There is no socklen_t. Coming up with a quick workaround was easy, but fixing it properly wasn't. I found a quite complete configure test for this in OpenSSH, it actually originated from curl. Unfortunately it only works with autoconf 2.50 or newer.

The attached patch is against the current CVS version (which identifies itself as 1.1.1.6). It compiles and runs fine on my Mac OS X box, although I haven't tested the new features yet.

Please let me know what you think.

Greetings,
chrisp

Signature · 3 lines
chrisp a.k.a. Christoph Pfisterer   "Any sufficiently advanced
[email protected]... - http://chrisp.de      bug is indistinguishable
PGP key & geek code available        from a feature."

> R rdarwin-support.patchi�i�Km iX�

Index: acconfig.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/acconfig.h,v
retrieving revision 1.2

acconfig.h +6 -0
diff -u -r1.2 acconfig.h
@@ -48,6 +48,9 @@
 /* early versions of glibc don't define in_addr_t */
 #undef in_addr_t
 
+/* some outdated systems don't have socklen_t */
+#undef socklen_t
+
 /* what system are we running on? */
 #undef TARGET_ALIAS
 
@@ -59,3 +62,6 @@
 
 /* are we running on BSD? */
 #undef TARGET_BSD
+
+/* are we running on Mac OS X / Darwin? */
+#undef TARGET_DARWIN

Index: configure.in
===================================================================
RCS file: /cvsroot/openvpn/openvpn/configure.in,v
retrieving revision 1.8

configure.in +51 -0

69 lines not on this page · raw message

Index: syshead.h
===================================================================
RCS file: /cvsroot/openvpn/openvpn/syshead.h,v
retrieving revision 1.2

syshead.h +1 -0
diff -u -r1.2 syshead.h
@@ -34,6 +34,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <stdarg.h>
 #include <unistd.h>
 #include <signal.h>
#1 lore raw

Hello Christoph,

Hey, that's great news. It looks like you were able to make it work with a very small patch.

A couple comments:

(1) The TYPE_SOCKLEN_T macro is cool, but we can't rely on people having autoconf 2.5 or newer (unless we start distributing configure in addition to configure.in). Is there a way the macro could be coded to eliminate this dependency? What is it in the macro that requires 2.5?

(2) You might want to take a look at 1.1.1.9 which is on the CVS now. In particular, tun.c has seen a lot of work over the weekend to add support for solaris, freebsd, and openbsd. You will want to add an #ifdef TARGET_DARWIN to the mix. You might also want to add a TARGET_DARWIN case to do_ifconfig(), so OpenVPN's --ifconfig option works correctly on Mac OS X.

Can you edit INSTALL with the appropriate Mac OS X info, including a URL where they can get your tun driver, and initial steps to create and configure the tun device?

I will merge everything in your patch now except the TYPE_SOCKLEN_T macro pending more thought.

Great Work!

James

----- Original Message -----
From: "Christoph Pfisterer" <[email protected]...>
To: <[email protected]>
Sent: Monday, May 06, 2002 7:08 AM
Subject: [Openvpn-devel] Mac OS X support

Quoted 46 lines

Hi all!

With some tweaking, I was able to get OpenVPN running on Mac OS X and use it happily with a Linux peer. Discussion and patches follow.

First of all, current versions of Mac OS X don't include a tun driver, although it is present in the source tree (publicly available via CVS). An independent port of the FreeBSD driver as a loadable module exists, but OpenVPN uncovered some bugs in it. I was able to fix those bugs and effectively took over maintenance of the driver. It is available from <http://chrisp.de/en/projects/tunnel.html>;
OpenVPN requires at least version 1.1.0.

OpenVPN itself also needed some small patches, mostly due to Mac OS X's customized GCC and its outdated BSD headers. There are three main problems:

1. There is no in_addr_t and uint32_t is not automatically defined. Some research revealed that uint32_t is defined in <stdint.h>, which is not included explicitly. On Linux, it is included implicitly by <netinet/in.h>, but not so on Mac OS X. This is easily fixed in syshead.h.

2. Apple's precompiling version of cpp doesn't know about macros with variable arguments. Passing the "--no-cpp-precomp" command line option gets rid of this. I added a small check to configure to add it automatically.

3. There is no socklen_t. Coming up with a quick workaround was easy, but fixing it properly wasn't. I found a quite complete configure test for this in OpenSSH, it actually originated from curl. Unfortunately it only works with autoconf 2.50 or newer.

The attached patch is against the current CVS version (which identifies itself as 1.1.1.6). It compiles and runs fine on my Mac OS X box, although I haven't tested the new features yet.

Please let me know what you think.

Greetings,
chrisp

--
chrisp a.k.a. Christoph Pfisterer "Any sufficiently advanced
[email protected]... - http://chrisp.de bug is indistinguishable
PGP key & geek code available from a feature."