Ticket #18673: 0001-Haiku-Introduce-basic-platform-support.patch

File 0001-Haiku-Introduce-basic-platform-support.patch, 3.9 KB (added by kallisti5, 12 months ago)

openvpn patches

  • configure.ac

    From 83a0ae3c39c9117dd59bb6f4fee117612b893577 Mon Sep 17 00:00:00 2001
    From: Alexander von Gluck IV <kallisti5@unixzen.com>
    Date: Fri, 17 Nov 2023 14:39:01 -0600
    Subject: [PATCH] Haiku: Introduce basic platform support
    
    * Based on the original work of GSOC student Swangeon
    ---
     configure.ac        |  4 ++++
     src/openvpn/route.c | 15 +++++++++++++++
     src/openvpn/tun.c   | 19 ++++++++++++++++++-
     3 files changed, 37 insertions(+), 1 deletion(-)
    
    diff --git a/configure.ac b/configure.ac
    index 84eaad60..4ca8f4f0 100644
    a b case "$host" in  
    373373        have_tap_header="yes"
    374374        ac_cv_header_net_if_h="no"  # exists, but breaks things
    375375        ;;
     376    *-*-haiku*)
     377        AC_DEFINE([TARGET_HAIKU], [1], [Are we running Haiku?])
     378        AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["H"], [Target prefix])
     379        ;;
    376380    *)
    377381        AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["X"], [Target prefix])
    378382        have_tap_header="yes"
  • src/openvpn/route.c

    diff --git a/src/openvpn/route.c b/src/openvpn/route.c
    index ff64938a..fa6dc1d5 100644
    a b add_route(struct route_ipv4 *r,  
    18421842        status = ret ? RTA_SUCCESS : RTA_ERROR;
    18431843    }
    18441844
     1845#elif defined(TARGET_HAIKU)
     1846
     1847    {
     1848        /* ex: route add /dev/net/ipro1000/0 default gw 192.168.1.1 netmask 255.255.255.0 */
     1849        argv_printf(&argv, "route add %s default gw %s netmask %s",
     1850                    rgi->iface,
     1851                    gateway,
     1852                    netmask);
     1853
     1854        argv_msg(D_ROUTE, &argv);
     1855        bool ret = openvpn_execve_check(&argv, es, 0,
     1856                                        "ERROR: Haiku route add command failed");
     1857        status = ret ? RTA_SUCCESS : RTA_ERROR;
     1858    }
     1859
    18451860#else  /* if defined(TARGET_LINUX) */
    18461861    msg(M_FATAL, "Sorry, but I don't know how to do 'route' commands on this operating system.  Try putting your routes in a --route-up script");
    18471862#endif /* if defined(TARGET_LINUX) */
  • src/openvpn/tun.c

    diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
    index 82ab6c05..28a78881 100644
    a b do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu,  
    16431643    {
    16441644        windows_set_mtu(tt->adapter_index, AF_INET, tun_mtu);
    16451645    }
     1646#elif defined(TARGET_HAIKU)
     1647    {
     1648        /* example: ifconfig tap0 inet 1.1.1.1 255.255.255.0 mtu 1450 up */
     1649        // Need to add ifconfig_remote_netmask since right now it is just NULL
     1650        argv_printf(&argv, "%s %s inet %s 255.255.255.0 mtu %d up", IFCONFIG_PATH,
     1651            ifname, ifconfig_local, tun_mtu);
     1652
     1653        argv_msg(M_INFO, &argv);
     1654        openvpn_execve_check(&argv, es, S_FATAL, "Haiku ifconfig failed");
     1655    }
    16461656#else  /* if defined(TARGET_LINUX) */
    16471657    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.");
    16481658#endif /* if defined(TARGET_LINUX) */
    tun_dco_enabled(struct tuntap *tt)  
    18991909}
    19001910#endif
    19011911
    1902 
    19031912#if !(defined(_WIN32) || defined(TARGET_LINUX))
    19041913static void
    19051914open_tun_generic(const char *dev, const char *dev_type, const char *dev_node,
    open_tun_generic(const char *dev, const char *dev_type, const char *dev_node,  
    19341943            {
    19351944                for (int i = 0; i < 256; ++i)
    19361945                {
     1946#if defined(TARGET_HAIKU)
     1947                    // Haiku just uses literal names
     1948                    openvpn_snprintf(tunname, sizeof(tunname),
     1949                                     "/dev/net/%s/%d", dev, i);
     1950                    openvpn_snprintf(dynamic_name, sizeof(dynamic_name),
     1951                                     "/dev/net/%s/%d", dev, i);
     1952#else
    19371953                    openvpn_snprintf(tunname, sizeof(tunname),
    19381954                                     "/dev/%s%d", dev, i);
    19391955                    openvpn_snprintf(dynamic_name, sizeof(dynamic_name),
    19401956                                     "%s%d", dev, i);
     1957#endif
    19411958                    if ((tt->fd = open(tunname, O_RDWR)) > 0)
    19421959                    {
    19431960                        dynamic_opened = true;