From patchwork Tue Nov 26 14:26:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander von Gluck X-Patchwork-Id: 3962 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:8712:b0:5db:5963:ef83 with SMTP id bv18csp91836mab; Tue, 26 Nov 2024 06:27:26 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXwxlz2djnQ/UWXw6bdKgTl5gJjLFlP4pcU0wXQSAYNb6iqyqyYclzIOXJOFZejxE31YWu6FwyCpe4=@openvpn.net X-Google-Smtp-Source: AGHT+IFYPFW9AlIKh8InE67tHlb2xspRD86wvA4CsDvhL43u1A1W2/z4Ly1lVUSnVmyz9HKCGCz6 X-Received: by 2002:a05:6602:150e:b0:843:ea73:134a with SMTP id ca18e2360f4ac-843ea731849mr58056839f.15.1732631246077; Tue, 26 Nov 2024 06:27:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732631246; cv=none; d=google.com; s=arc-20240605; b=ZsK4+0zvcqJKp5O4KCMhysMmD6qFE++FMVunUIgkgp3Bq8m6Aj/sY5WikaoNUEVLwQ hwEkvXMaitu5EWdCdbSDiFiw/8MOXLA8V9bu5AVQJ/OdZQA8MUwnMpAuXhbXpe5jvRgb PkWwpN0cEQge2FCzeyEsbZMnTB9XuSi8f9cEEbH+kHlHD2qCprgO7CyGLeuZnKsOtu2f tkeJ84hy0uGjpOuf+1byh4s1UD5YJ4fY+KD2ce44SfxuBTMqd0Ucp80t3jspIAFMvnLZ J4I8CejdO46nxfZFC9MH7tRDy18e2BZdN7HQOZ5fjlNfjCu0HqEuQlgV0hjDvpeDRoop IWbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:cc:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:feedback-id:message-id:to:date:dkim-signature :dkim-signature:dkim-signature; bh=FofDWftHkePi3LtKQTHdzGXiAS4UBYDeEHRysFFhiZA=; fh=Lax8FLCU6g10Y/m0qvv2Y0VsQFNWipWiwwrtnzp74qE=; b=TZyXdi+nRMobp45PxpLU1K7IUHKSFHhqMvSRigG4ZfwB0updF3W0wvMBEYRWJ31gSN Pu40UMjeCjWOQ0caT5PVssBvqRCIwtK4Ugb47F3+j8E2ez+9iPwcf8DVBBDAjMvmmIjQ hCD1h2huy46MW89eKdVqpe6Ud0w1HSwutccj6dlKNdbXS2OaBGGQbrxcargrtQydbIsX MFI/Eo1AL1Qa2ckDEe7btz7NneRr9Sg+gJTyIrN7+lKsVdXe61fHvdHVWTtxfLPyF9z1 kzIoAKc4dDiJvJnfCQWBM0k2u+gakia5QQB1PD1EcXQ/BNR2wCdiXJc6fn+Ka6Vl5HGK BHLw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=O+C8A5Js; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=AZTukemO; dkim=neutral (body hash did not verify) header.i=@terarocket.io header.s=protonmail2 header.b=EgBFNMW6; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id ca18e2360f4ac-8419f4709e8si246538539f.94.2024.11.26.06.27.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Nov 2024 06:27:26 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=O+C8A5Js; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=AZTukemO; dkim=neutral (body hash did not verify) header.i=@terarocket.io header.s=protonmail2 header.b=EgBFNMW6; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tFwX2-0001UZ-Ea; Tue, 26 Nov 2024 14:27:11 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tFwX0-0001UR-Nz for openvpn-devel@lists.sourceforge.net; Tue, 26 Nov 2024 14:27:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:MIME-Version:Message-ID:Subject:Cc: From:To:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1gyvbDsQoiT8r8wDpuaWXj2mariBTUrfcwfB9LEzKNs=; b=O+C8A5JszCCrIV1Q/zJ0gzxwP7 yytIk3UHO/N2GUWs11yf6Yg8Z2rp+WiHeurrvrARAPvA2+311J5nQGKf0LCo9DME8NT3y2BMn9d8y PCs48iEktt3LlKAz8mTMfeg65xOWn7NEYmFMaquTqr481PDyr8cXRFOdv17DqaqLUSq8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:MIME-Version:Message-ID:Subject:Cc:From:To:Date:Sender: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=1gyvbDsQoiT8r8wDpuaWXj2mariBTUrfcwfB9LEzKNs=; b=A ZTukemOXsHXuqfNJRh/9leAWpi6k3DD0ucc78y+lclPg3jhdncNHiws2PzfE309lhnrx/XKeQbq/c Oz/CKyyfJK2WCfXlvoNQCppUuS+Pp6ne0qg9mEPdPpq7HoelZt6OPjdAxQ+05B40vOgw6dqCDNw+v AKJFtI3y50PVHBDg=; Received: from mail-4323.proton.ch ([185.70.43.23]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1tFwWy-0008Go-ES for openvpn-devel@lists.sourceforge.net; Tue, 26 Nov 2024 14:27:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=terarocket.io; s=protonmail2; t=1732631220; x=1732890420; bh=1gyvbDsQoiT8r8wDpuaWXj2mariBTUrfcwfB9LEzKNs=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector: List-Unsubscribe:List-Unsubscribe-Post; b=EgBFNMW6Rv4lyetK8iyzhE0dzId1XGCC8DsRLXRASByFC7u9mdSYOAmDtyQ4Wt1A8 1rWc9y/WJePa4TzBj8+7aM/IIZPuW7LcaaA05rHhMnnRWVVb3Brd3boNNew1P4As69 uzjWRpoAapFHpTPF609pi9YU2oe3pRjk25KE1/oW6Ii3gGiP+mPqK3al48bO2b/US2 MD+LiL1qgX4k/2Yg1vkS4xoId/Kwz/LJHCPZvsZBGPh1PcsiSYfUP2X7QcKpDx2qpE nbs5oP1UMle+FksZ8DVMfh7Laab6oXUHCgWQ5preUa11O7v4zCvUeWXDIwOgqRgV5D Zs8QsZHXR8ORg== Date: Tue, 26 Nov 2024 14:26:52 +0000 To: openvpn-devel@lists.sourceforge.net Message-ID: <20241126142639.67446-1-alex@terarocket.io> Feedback-ID: 105812837:user:proton X-Pm-Message-ID: 6acd46ecb3f976fec9917bc3b3ed114e8194db1a MIME-Version: 1.0 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Alexander von Gluck IV --- configure.ac | 5 +++++ src/openvpn/route.c | 15 +++++++++++++++ src/openvpn/tun.c | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/configure.ac b/configure.ac index 0876a6a5..7f6e43dd 100644 --- a/configure.ac +++ b/configure.ac @@ -368, 6 +368, 11 @@ case "$host" in have_tap_header="yes" ac_cv_header_net_if_h="no" # e [...] Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [185.70.43.23 listed in sa-trusted.bondedsender.org] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [185.70.43.23 listed in bl.score.senderscore.com] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [185.70.43.23 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Headers-End: 1tFwWy-0008Go-ES Subject: [Openvpn-devel] [PATCH 1/2] Haiku: Introduce basic platform support X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alexander von Gluck via Openvpn-devel From: Alexander von Gluck Reply-To: Alexander von Gluck Cc: Alexander von Gluck IV Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1816795541620684149?= X-GMAIL-MSGID: =?utf-8?q?1816795541620684149?= From: Alexander von Gluck IV --- configure.ac | 5 +++++ src/openvpn/route.c | 15 +++++++++++++++ src/openvpn/tun.c | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) #endif /* if defined(TARGET_LINUX) */ @@ -1909,10 +1919,17 @@ open_tun_generic(const char *dev, const char *dev_type, const char *dev_node, { for (int i = 0; i < 256; ++i) { +#if defined(TARGET_H AIKU) + snprintf(tunname, sizeof(tunname), + "/dev/%s/%d", dev, i); + snprintf(dynamic_name, sizeof(dynamic_name), + "%s/%d", dev, i); +#else snprintf(tunname, sizeof(tunname), "/dev/%s%d", dev, i); snprintf(dynamic_name, sizeof(dynamic_name), "%s%d", dev, i); +#endif if ((tt->fd = open(tunname, O_RDWR)) > 0) { dynamic_opened = true; diff --git a/configure.ac b/configure.ac index 0876a6a5..7f6e43dd 100644 --- a/configure.ac +++ b/configure.ac @@ -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" diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 2e584c71..fa20d08f 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -1853,6 +1853,21 @@ add_route(struct route_ipv4 *r, status = ret ? RTA_SUCCESS : RTA_ERROR; } +#el if defined(TARGET_HAIKU) + + { + /* ex: route add /dev/net/ipro1000/0 default gw 192.168.1.1 netmask 255.255.255.0 */ + argv_printf(&argv, "route add %s inet default gw %s netmask %s", + rgi->iface, + gateway, + netmask); + + argv_msg(D_ROUTE, &argv); + bool ret = openvpn_execve_check(&argv, es, 0, + "ERROR: Haiku route add command failed"); + status = ret ? RTA_SUCCESS : RTA_ERROR; + } + #else /* if defined(TARGET_LINUX) */ 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"); #endif /* if defined(TARGET_LINUX) */ diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 85fe01af..65e3b5ba 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1631,6 +1631,16 @@ 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 */ + // Need to add ifconfig_remote_netmask since right now it is just NULL + 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."); From patchwork Tue Nov 26 14:26:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander von Gluck X-Patchwork-Id: 3963 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:8712:b0:5db:5963:ef83 with SMTP id bv18csp92050mab; Tue, 26 Nov 2024 06:27:44 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVfMt03Y7O3kecivua6miCZ0WMadD+RavEbxldCEx0hYv8h9Nm+NqMD/j5MC5qBjfBX8JhdaqhdrY4=@openvpn.net X-Google-Smtp-Source: AGHT+IFOIhXLdSu0mqfiMLelA+V8vvM7KoObgn3+6G4pdBHjHpqSp1LhvSVfzZdFQ4vocNYRS7Zi X-Received: by 2002:a05:6808:10c6:b0:3e7:ac6a:2137 with SMTP id 5614622812f47-3ea592e7160mr2029194b6e.16.1732631264123; Tue, 26 Nov 2024 06:27:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732631264; cv=none; d=google.com; s=arc-20240605; b=CTWwA1/zQHKelnV76ivB/jWnUL9Muu7LpZGcvik2T7Dh/yS6pO87aARrx6x+6UVaSC D26EUbEbAJg6JzyX7RLM6P5zNs7IPiBAg2KtUXueR0PmQphIMg0QPCldWSy1/Cun56IV Mw+jOPoOUW+mwD2MFsNc2JdheiZWY4+dnk8XubZupnRmhRcBEYbEV6qx2jzN6LAZx4Mf QD7RiK9amhNK62HHcx83rU+Lkmttv997TVIEAQ0bu0KqiY0AOPywsjkbPGDvvGBLl6qt rp2BGdia9kSNUI/BJZuNiJ+HLHSAZT/RNBAT7D3CWVER+0mF7YmEXKRgO44jJKJA91ye r1ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:feedback-id:references:in-reply-to:message-id:to:date :dkim-signature:dkim-signature:dkim-signature; bh=APEDSRVJXOb3KeUpZnwpvwWsDvh3HST+zVv15vO4TC8=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=jtx++n/Y7AdHvl0uptdct0AndWxohOgKuy6jUzFgSTtJM64/8Bz+3qQn4L1GCPwBW1 TNl+hTrQqs0nZWkfyqAWuamc9rbgnDPaaWMzyHjIEguWrYuhKe/qz3/j1vcRTD97R5sO 9LzoxYphfQY3yTSA/JlGMlDN7ThuOdcGrBKxWioQh6bMAvbK4DNbMuxurZzL7cxwdyzt Z7UUoLGBE05/qoY4lYyXQjuwJ5U8tv/GcffwETrdc9HLKEoU0Z+tM+2FAhwTrDxuk8Ci YrhIs3u4D8HiOmwcyWgI9sFjjTYPoN3xNt+1/HbuQm1ZGovYm6h6u2ouWajcHueh3F6a FZjQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="c442wzt/"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Vst60yR0; dkim=neutral (body hash did not verify) header.i=@terarocket.io header.s=protonmail2 header.b=CN+9c+n2; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5614622812f47-3ea4af5a9cesi1814301b6e.320.2024.11.26.06.27.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Nov 2024 06:27:44 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="c442wzt/"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Vst60yR0; dkim=neutral (body hash did not verify) header.i=@terarocket.io header.s=protonmail2 header.b=CN+9c+n2; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tFwXQ-0007MV-L3; Tue, 26 Nov 2024 14:27:36 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tFwXP-0007M6-0M for openvpn-devel@lists.sourceforge.net; Tue, 26 Nov 2024 14:27:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:From:To:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=f3Fu7z3AKIeSgozi8r5ckNFu0veECjzOHBEG+VxMFZQ=; b=c442wzt/tausBJBfBB9cLLsZIK H7ACP5+e3XzXu3lIpX1F2hZonQ58Yjsc28W6RHZCbMr0flgPjwJwaX2le9+O/sXt8pUF2G122PlMM 8MinLEXJdvUlznr8OHxadBDFypass0+r8yqBX0maAuQjcBa9LEuszdVdxeBg8fpb5Y9E=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc: From:To:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=f3Fu7z3AKIeSgozi8r5ckNFu0veECjzOHBEG+VxMFZQ=; b=Vst60yR03Vi+Uu/ri016WyHPg1 Z1Wo+gerAB8rr8neWunW2OL2cUvUSOQ0fTkBK9LVgr2KOjyfT4HCMwjtTlkBYLQrSfVz9P3FHZ8kf 2ePUN8T89HDmROqdYqifUA7DrcjMtp3JVuxrC+mL8h9RZ1AgJaEidQU6RXg1iE2Ewcfk=; Received: from mail-10626.protonmail.ch ([79.135.106.26]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1tFwX3-0008H9-SG for openvpn-devel@lists.sourceforge.net; Tue, 26 Nov 2024 14:27:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=terarocket.io; s=protonmail2; t=1732631222; x=1732890422; bh=f3Fu7z3AKIeSgozi8r5ckNFu0veECjzOHBEG+VxMFZQ=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=CN+9c+n2Gs+6RJrnPDZU6N4mdeA4XUKt5+sYXDrG05xV0rY62BcOcgVM+0E7XoKii 1WbjKy90K3DTWYFroqjFExZc/ODR7ljVncP2VJKTkcgeaj82xGZoScOro0BPdomJIM ZjzlOS5HKp2TshN1GUr1uSK+z2tcPjEABFtSgjILYa+nphh2Fxor99xWyyVKpu2gP1 dAVmFxF5zmTKfTkyk6tlpMTFjjtFFmgyqmZ2W7A3ZDblUr1HyFxxNw+dpyoJ47Ba5/ CX7nLvkAYAbMNOGWzapSXhR8yhXQd9YKyKudo0A7tybaTaJM/bM+tAWsZGFxuKs5SW EMvNxfpPQHDFA== Date: Tue, 26 Nov 2024 14:26:59 +0000 To: openvpn-devel@lists.sourceforge.net Message-ID: <20241126142639.67446-2-alex@terarocket.io> In-Reply-To: <20241126142639.67446-1-alex@terarocket.io> References: <20241126142639.67446-1-alex@terarocket.io> Feedback-ID: 105812837:user:proton X-Pm-Message-ID: 2d87c6161d44708be25787b3ff95fd4b5ef127ee MIME-Version: 1.0 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: --- src/openvpn/route.c | 109 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 2 deletions(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index fa20d08f..8d319123 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -54, 6 +54, 12 @@ #include /* RT_ROUNDUP(), RT [...] Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [79.135.106.26 listed in sa-trusted.bondedsender.org] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [79.135.106.26 listed in bl.score.senderscore.com] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Headers-End: 1tFwX3-0008H9-SG Subject: [Openvpn-devel] [PATCH 2/2] Haiku: Pull in routing table to get default route X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alexander von Gluck via Openvpn-devel From: Alexander von Gluck Reply-To: Alexander von Gluck Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1816795560517654971?= X-GMAIL-MSGID: =?utf-8?q?1816795560517654971?= --- src/openvpn/route.c | 109 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 2 deletions(-) @@ -2344,6 +2352,21 @@ delete_route(struct route_ipv4 *r, openvpn_execve_check(&argv, es, 0, "ERROR: AIX route delete command failed"); } +#elif defined(TARGET_HAIKU) + + { + // route del /dev/net/ipro1000/0 inet 192.168.0.0 gw 192.168.1.1 netmask 255.255.0.0 + argv_printf(&argv, "%s del %s inet %s gw %s netmask %s", + ROUTE_PATH, + rgi->iface, + network, + gateway, + netmask); + + argv_msg(D_ROUTE, &argv); + openvpn_execve_check(&argv, es, 0, "ERROR: Haiku inet route delete command failed"); + } + #else /* if defined(TARGET_LINUX) */ 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"); #endif /* if defined(TARGET_LINUX) */ @@ -2523,6 +2546,19 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt, msg(D_ROUTE_DEBUG, "Deleting routes on Android is not possible/not " "needed. The VpnService API allows routes to be set " "on connect only and will clean up automatically."); +#elif defined(TARGET_HAIKU) + { + argv_printf(&argv, "%s del %s inet6 %s gw %s prefixlen %d", + ROUTE_PATH, + r6->iface, + network, + gateway, + r6->netbits); + + argv_msg(D_ROUTE, &argv); + openvpn_execve_check(&argv, es, 0, "ERROR: Haiku inet 6 route delete command failed"); + + } #else /* if defined(TARGET_LINUX) */ msg(M_FATAL, "Sorry, but I don't know how to do 'route ipv6' commands on this operating system. Try putting your routes in a --route-down script"); #endif /* if defined(TARGET_LINUX) */ @@ -3460,6 +3496,75 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6, } } +#elif defined(TARGET_HAIKU) + +void +get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx) +{ + CLEAR(*rgi); + + int sockfd = -1; + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd < 0) { + msg(M_INFO, "%s: Error opening socket for AF_INET", __func__); + return; + } + + struct ifconf config; + config.ifc_len = sizeof(config.ifc_value); + if (ioctl(sockfd, SIOCGRTSIZE, &config, sizeof(struct ifconf)) < 0) { + msg(M_INFO, "%s: Error getting routing table size", __func__); + return; + } + + uint32 size = (uin t32)config.ifc_value; + if (size == 0) + return; + + void *buffer = malloc(size); + if (buffer == NULL) { + fprintf(stderr, "%s: Out of memory.\n", __func__); + return; + } + + config.ifc_len = size; + config.ifc_buf = buffer; + if (ioctl(sockfd, SIOCGRTTABLE, &config, sizeof(struct ifconf)) < 0) + return; + + struct ifreq *interface = (struct ifreq*)buffer; + struct ifreq *end = (struct ifreq*)((uint8*)buffer + size); + + while (interface < end) { + struct route_entry route = interface->ifr_route; + if ((route.flags & RTF_GATEWAY) != 0 && (route.flags & RTF_DEFAULT) != 0) { + //msg(M_INFO, "%s: FOUND DEFAULT GATEWAY ON %s", __func__, interface->ifr_name); + rgi->gateway.addr = ntohl(((struct sockaddr_in *)route.gateway)->sin_addr.s_addr); + rgi->flags = RGI_ADDR_DEFINED | RGI_IFACE_DEFINED; + strcpy(rgi->iface, interface->ifr_name); + } + + int32 addressSize = 0; + if (route.destination != NULL) + addressSize += route.destination->sa_len; + if (route.mask != NULL) + addressSize += route.mask->sa_len; + if (route.gateway != NULL) + addressSize += route.gateway->sa_len; + + interface = (struct ifreq*)((addr_t)interface + IF_NAMESIZE + + sizeof(struct route_entry) + addressSize); + } +} + +void +get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6, + const struct in6_addr *dest, openvpn_net_ctx_t *ctx) +{ + /* TODO: Same for ipv6 with AF_INET6 */ + CLEAR(*rgi6); +} + #elif defined(TARGET_DARWIN) || defined(TARGET_SOLARIS) \ || defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) \ || defined(TARGET_OPENBSD) || defined(TARGET_NETBSD) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index fa20d08f..8d319123 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -54,6 +54,12 @@ #include /* RT_ROUNDUP(), RT_ADVANCE() */ #endif +#if defined(TARGET_HAIKU) +#include /* uint32, etc */ +#include /* ifconf etc */ +#include /* SIOCGRTTABLE, etc */ +#endif /* TARGET_HAIKU */ + #ifdef _WIN32 #include "openvpn-msg.h" @@ -1857,14 +1863,16 @@ add_route(struct route_ipv4 *r, { /* ex: route add /dev/net/ipro1000/0 default gw 192.168.1.1 netmask 255.255.255.0 */ - argv_printf(&argv, "route add %s inet default gw %s netmask %s", + argv_printf(&argv, "%s add %s inet %s gw %s netmask %s", + ROUTE_PATH, rgi- >iface, + network, gateway, netmask); argv_msg(D_ROUTE, &argv); bool ret = openvpn_execve_check(&argv, es, 0, - "ERROR: Haiku route add command failed"); + "ERROR: Haiku inet route add command failed"); status = ret ? RTA_SUCCESS : RTA_ERROR; }