Skip to content

Commit

Permalink
Haiku: Introduce basic platform / tun support
Browse files Browse the repository at this point in the history
* Special thanks to Sean Brady's hard work in GSoC 2023 towards creating
  a TUN/TAP driver for Haiku!
* More kudos to Augustin Cavalier for making it functional :-)

Signed-off-by: Alexander von Gluck <[email protected]>
Acked-by: Gert Doering <[email protected]>
Change-Id: I9a278374f492a538f0c174ced1746c3b1f82b8c9
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg29947.html
Signed-off-by: Gert Doering <[email protected]>
  • Loading branch information
kallisti5 authored and cron2 committed Nov 28, 2024
1 parent 6c636f5 commit f808037
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
10 changes: 10 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ TUN/TAP Driver References:

http://www.whiteboard.ne.jp/~admin2/tuntap/

* Haiku:

Haiku can't yet dynamically create TUN/TAP devices, so you need to manually
create one before running openvpn:

# ifconfig tun/0 up

A standard reference the dev as "tun" in your config is all that's needed
to use the tunnel device.

* Windows

OpenVPN on Windows needs a TUN/TAP kernel driver to work. OpenVPN installers
Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ case "$host" in
have_tap_header="yes"
ac_cv_header_net_if_h="no" # exists, but breaks things
;;
*-*-haiku*)
AC_DEFINE([TARGET_HAIKU], [1], [Are we running Haiku?])
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["H"], [Target prefix])
LIBS="${LIBS} -lnetwork"
;;
*)
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["X"], [Target prefix])
have_tap_header="yes"
Expand Down
16 changes: 14 additions & 2 deletions src/openvpn/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,13 @@ do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu,
{
windows_set_mtu(tt->adapter_index, AF_INET, tun_mtu);
}
#elif defined(TARGET_HAIKU)
/* example: ifconfig tun/0 inet 1.1.1.1 255.255.255.0 mtu 1450 up */
argv_printf(&argv, "%s %s inet %s %s mtu %d up", IFCONFIG_PATH,
ifname, ifconfig_local, ifconfig_remote_netmask, tun_mtu);

argv_msg(M_INFO, &argv);
openvpn_execve_check(&argv, es, S_FATAL, "Haiku ifconfig failed");
#else /* if defined(TARGET_LINUX) */
msg(M_FATAL, "Sorry, but I don't know how to do 'ifconfig' commands on this operating system. You should ifconfig your TUN/TAP device manually or use an --up script.");
#endif /* if defined(TARGET_LINUX) */
Expand Down Expand Up @@ -1909,10 +1916,15 @@ open_tun_generic(const char *dev, const char *dev_type, const char *dev_node,
{
for (int i = 0; i < 256; ++i)
{
/* some platforms have a dedicated directory per driver */
char *sep = "";
#if defined(TARGET_HAIKU)
sep = "/";
#endif
snprintf(tunname, sizeof(tunname),
"/dev/%s%d", dev, i);
"/dev/%s%s%d", dev, sep, i);
snprintf(dynamic_name, sizeof(dynamic_name),
"%s%d", dev, i);
"%s%s%d", dev, sep, i);
if ((tt->fd = open(tunname, O_RDWR)) > 0)
{
dynamic_opened = true;
Expand Down

0 comments on commit f808037

Please sign in to comment.