From patchwork Wed Feb 5 06:59:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Rozman X-Patchwork-Id: 977 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director10.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id GL/ONuACO16REwAAIUCqbw for ; Wed, 05 Feb 2020 13:01:04 -0500 Received: from proxy4.mail.iad3b.rsapps.net ([172.31.255.6]) by director10.mail.ord1d.rsapps.net with LMTP id YCriM+ACO15/EwAApN4f7A ; Wed, 05 Feb 2020 13:01:04 -0500 Received: from smtp8.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy4.mail.iad3b.rsapps.net with LMTP id cG2uLeACO15wZwAA9crAow ; Wed, 05 Feb 2020 13:01:04 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp8.gate.iad3b.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=rozman.si; dmarc=fail (p=none; dis=none) header.from=rozman.si X-Suspicious-Flag: YES X-Classification-ID: 79763c5e-4841-11ea-b959-5254005eee35-1-1 Received: from [216.105.38.7] ([216.105.38.7:40040] helo=lists.sourceforge.net) by smtp8.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id A3/32-04452-0E20B3E5; Wed, 05 Feb 2020 13:01:04 -0500 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1izOy6-0002M1-U4; Wed, 05 Feb 2020 18:00:06 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1izOy5-0002Lr-TZ for openvpn-devel@lists.sourceforge.net; Wed, 05 Feb 2020 18:00:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=OBPCm9E/Nn43VpodZ+NRcRvRJEsoK4yShQmig2FUOOQ=; b=JnbveUyEZjV+b0+FCjj2a3qZFO uGAjErnSHBQ88C6djOZTpjtuekpz6S/4Gp4guZRAw1qmmAlmUcp6ic8fLux6gMDgctsErNAYU9x88 JyBL2TK7wtZ8lfyaQdJ3G5X/E/lsCPSmTMXe9U5S3DOCYHZAlwJP4Uw237PGuphKazTc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type: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=OBPCm9E/Nn43VpodZ+NRcRvRJEsoK4yShQmig2FUOOQ=; b=A kuBExmG9fP/3oveglENIduW+PTIyeQL9yrqP5XUbMXpZm/LLntmlBtany2dOnz94cYE576DcwSbmX +LEEEgTbPyjKhdU8A5yHzbYGnijwI00qAD4QN0xzMIHo9l2U/98Q0iZTAMoYNv8c5uhuirov+ZNq5 RiOXxbh7MsO27fzQ=; Received: from pub5.amebis.si ([213.250.55.21]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1izOy2-000Qtn-PP for openvpn-devel@lists.sourceforge.net; Wed, 05 Feb 2020 18:00:05 +0000 Received: by pub5.amebis.si (Postfix, from userid 1000) id 200311002FB6; Wed, 5 Feb 2020 18:59:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rozman.si; s=default; t=1580925589; bh=OBPCm9E/Nn43VpodZ+NRcRvRJEsoK4yShQmig2FUOOQ=; h=From:To:Cc:Subject:Date:From; b=Scs+uC7FsieSSSo6XhH7jwKihTngG9Dz88eLdN4plfgJkmlIJuBSviSYULcIQddH8 1arUYiOnxJ1/AwVDNFpC+Kh1MSB42kXBpC0pRBllCub75AWY8F24vn6BZqOzFmuKk0 MyvpvpM02BOBKze74nIYjQCpF31/9sc9CIEmaeec= X-Spam-Checker-Version: SpamAssassin 3.4.3 (2019-12-06) on brana.amebis.doma X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.3 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:dc1d:9533:3ace:bf6b]) by pub5.amebis.si (Postfix) with ESMTP id 831CA1002FB5; Wed, 5 Feb 2020 18:59:46 +0100 (CET) From: Simon Rozman To: openvpn-devel@lists.sourceforge.net Date: Wed, 5 Feb 2020 18:59:44 +0100 Message-Id: <20200205175944.432-1-simon@rozman.si> X-Mailer: git-send-email 2.24.1.windows.2 MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: rozman.si] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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 X-Headers-End: 1izOy2-000Qtn-PP Subject: [Openvpn-devel] [PATCH] tun.c: uncrustify 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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Signed-off-by: Simon Rozman Acked-by: Lev Stipakov --- src/openvpn/tun.c | 117 +++++++++++++++++++++++----------------------- src/openvpn/tun.h | 8 ++-- 2 files changed, 63 insertions(+), 62 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 070b0fa0..47c3088d 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -817,7 +817,7 @@ init_tun_post(struct tuntap *tt, tt->rw_handle.read = tt->reads.overlapped.hEvent; tt->rw_handle.write = tt->writes.overlapped.hEvent; } -#endif +#endif /* ifdef _WIN32 */ } #if defined(_WIN32) \ @@ -1397,18 +1397,18 @@ do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu, { switch (tt->options.ip_win32_type) { - case IPW32_SET_MANUAL: - msg(M_INFO, - "******** NOTE: Please manually set the IP/netmask of '%s' to %s/%s (if it is not already set)", - ifname, ifconfig_local, - print_in_addr_t(tt->adapter_netmask, 0, &gc)); - break; - - case IPW32_SET_NETSH: - netsh_ifconfig(&tt->options, ifname, tt->local, - tt->adapter_netmask, NI_IP_NETMASK|NI_OPTIONS); - - break; + case IPW32_SET_MANUAL: + msg(M_INFO, + "******** NOTE: Please manually set the IP/netmask of '%s' to %s/%s (if it is not already set)", + ifname, ifconfig_local, + print_in_addr_t(tt->adapter_netmask, 0, &gc)); + break; + + case IPW32_SET_NETSH: + netsh_ifconfig(&tt->options, ifname, tt->local, + tt->adapter_netmask, NI_IP_NETMASK|NI_OPTIONS); + + break; } } } @@ -3481,7 +3481,7 @@ tun_finalize( } static const struct device_instance_id_interface * -get_device_instance_id_interface(struct gc_arena* gc) +get_device_instance_id_interface(struct gc_arena *gc) { HDEVINFO dev_info_set; DWORD err; @@ -3552,7 +3552,7 @@ get_device_instance_id_interface(struct gc_arena* gc) } cr = CM_Get_Device_Interface_List_Size(&dev_interface_list_size, - (LPGUID)& GUID_DEVINTERFACE_NET, + (LPGUID)&GUID_DEVINTERFACE_NET, device_instance_id, CM_GET_DEVICE_INTERFACE_LIST_PRESENT); @@ -3562,7 +3562,7 @@ get_device_instance_id_interface(struct gc_arena* gc) } dev_interface_list = alloc_buf_gc(dev_interface_list_size, gc); - cr = CM_Get_Device_Interface_List((LPGUID)& GUID_DEVINTERFACE_NET, device_instance_id, + cr = CM_Get_Device_Interface_List((LPGUID)&GUID_DEVINTERFACE_NET, device_instance_id, BPTR(&dev_interface_list), dev_interface_list_size, CM_GET_DEVICE_INTERFACE_LIST_PRESENT); @@ -3571,7 +3571,7 @@ get_device_instance_id_interface(struct gc_arena* gc) goto next; } - struct device_instance_id_interface* dev_if; + struct device_instance_id_interface *dev_if; ALLOC_OBJ_CLEAR_GC(dev_if, struct device_instance_id_interface, gc); dev_if->net_cfg_instance_id = string_alloc(net_cfg_instance_id, gc); dev_if->device_interface_list = string_alloc(BSTR(&dev_interface_list), gc); @@ -3587,7 +3587,7 @@ get_device_instance_id_interface(struct gc_arena* gc) } last = dev_if; - next: +next: RegCloseKey(dev_key); } @@ -3694,8 +3694,8 @@ get_tap_reg(struct gc_arena *gc) { /* Is this adapter supported? */ enum windows_driver_type windows_driver = WINDOWS_DRIVER_UNSPECIFIED; - if (strcasecmp(component_id, TAP_WIN_COMPONENT_ID) == 0 || - strcasecmp(component_id, "root\\" TAP_WIN_COMPONENT_ID) == 0) + if (strcasecmp(component_id, TAP_WIN_COMPONENT_ID) == 0 + || strcasecmp(component_id, "root\\" TAP_WIN_COMPONENT_ID) == 0) { windows_driver = WINDOWS_DRIVER_TAP_WINDOWS6; } @@ -5768,8 +5768,8 @@ tuntap_get_version_info(const struct tuntap *tt) DWORD len; CLEAR(info); if (DeviceIoControl(tt->hand, TAP_WIN_IOCTL_GET_VERSION, - &info, sizeof(info), - &info, sizeof(info), &len, NULL)) + &info, sizeof(info), + &info, sizeof(info), &len, NULL)) { msg(D_TUNTAP_INFO, "TAP-Windows Driver Version %d.%d %s", (int)info[0], @@ -5808,8 +5808,8 @@ tuntap_get_mtu(struct tuntap *tt) ULONG mtu = 0; DWORD len; if (DeviceIoControl(tt->hand, TAP_WIN_IOCTL_GET_MTU, - &mtu, sizeof(mtu), - &mtu, sizeof(mtu), &len, NULL)) + &mtu, sizeof(mtu), + &mtu, sizeof(mtu), &len, NULL)) { tt->post_open_mtu = (int)mtu; msg(D_MTU_INFO, "TAP-Windows MTU=%d", (int)mtu); @@ -5843,7 +5843,7 @@ tuntap_set_ip_addr(struct tuntap *tt, }; if (send_msg_iservice(tt->options.msg_channel, &msg, sizeof(msg), - &ack, "TUN")) + &ack, "TUN")) { status = ack.error_number; } @@ -5900,7 +5900,7 @@ tuntap_set_ip_addr(struct tuntap *tt, if (tt->did_ifconfig_setup && tt->options.ip_win32_type == IPW32_SET_IPAPI) { DWORD status; - const char* error_suffix = "I am having trouble using the Windows 'IP helper API' to automatically set the IP address -- consider using other --ip-win32 methods (not 'ipapi')"; + const char *error_suffix = "I am having trouble using the Windows 'IP helper API' to automatically set the IP address -- consider using other --ip-win32 methods (not 'ipapi')"; /* couldn't get adapter index */ if (index == TUN_ADAPTER_INDEX_INVALID) @@ -5931,7 +5931,7 @@ tuntap_set_ip_addr(struct tuntap *tt, print_in_addr_t(tt->local, 0, &gc), print_in_addr_t(tt->adapter_netmask, 0, &gc), device_guid - ); + ); } else { @@ -5978,10 +5978,10 @@ wintun_register_ring_buffer(struct tuntap *tt) msg(M_FATAL, "ERROR: Failed to impersonate as SYSTEM, make sure process is running under privileged account"); } if (!register_ring_buffers(tt->hand, - tt->wintun_send_ring, - tt->wintun_receive_ring, - tt->rw_handle.read, - tt->rw_handle.write)) + tt->wintun_send_ring, + tt->wintun_receive_ring, + tt->rw_handle.read, + tt->rw_handle.write)) { msg(M_NONFATAL, "Failed to register ring buffers: %lu", GetLastError()); ret = false; @@ -6001,8 +6001,8 @@ tuntap_set_connected(const struct tuntap *tt) ULONG status = TRUE; DWORD len; if (!DeviceIoControl(tt->hand, TAP_WIN_IOCTL_SET_MEDIA_STATUS, - &status, sizeof(status), - &status, sizeof(status), &len, NULL)) + &status, sizeof(status), + &status, sizeof(status), &len, NULL)) { msg(M_WARN, "WARNING: The TAP-Windows driver rejected a TAP_WIN_IOCTL_SET_MEDIA_STATUS DeviceIoControl call."); } @@ -6039,8 +6039,8 @@ tuntap_set_ptp(const struct tuntap *tt) ep[2] = htonl(tt->remote_netmask); status = DeviceIoControl(tt->hand, TAP_WIN_IOCTL_CONFIG_TUN, - ep, sizeof(ep), - ep, sizeof(ep), &len, NULL); + ep, sizeof(ep), + ep, sizeof(ep), &len, NULL); if (tt->did_ifconfig_setup) { @@ -6063,8 +6063,8 @@ tuntap_set_ptp(const struct tuntap *tt) ep[1] = htonl(tt->remote_netmask); if (!DeviceIoControl(tt->hand, TAP_WIN_IOCTL_CONFIG_POINT_TO_POINT, - ep, sizeof(ep), - ep, sizeof(ep), &len, NULL)) + ep, sizeof(ep), + ep, sizeof(ep), &len, NULL)) { msg(M_FATAL, "ERROR: The TAP-Windows driver rejected a DeviceIoControl call to set Point-to-Point mode, which is required for --dev tun"); } @@ -6116,8 +6116,8 @@ tuntap_dhcp_mask(const struct tuntap *tt, const char *device_guid) #ifndef SIMULATE_DHCP_FAILED /* this code is disabled to simulate bad DHCP negotiation */ if (!DeviceIoControl(tt->hand, TAP_WIN_IOCTL_CONFIG_DHCP_MASQ, - ep, sizeof(ep), - ep, sizeof(ep), &len, NULL)) + ep, sizeof(ep), + ep, sizeof(ep), &len, NULL)) { msg(M_FATAL, "ERROR: The TAP-Windows driver rejected a DeviceIoControl call to set TAP_WIN_IOCTL_CONFIG_DHCP_MASQ mode"); } @@ -6128,7 +6128,7 @@ tuntap_dhcp_mask(const struct tuntap *tt, const char *device_guid) device_guid, print_in_addr_t(ep[2], IA_NET_ORDER, &gc), ep[3] - ); + ); /* user-supplied DHCP options capability */ if (tt->options.dhcp_options) @@ -6138,8 +6138,8 @@ tuntap_dhcp_mask(const struct tuntap *tt, const char *device_guid) { msg(D_DHCP_OPT, "DHCP option string: %s", format_hex(BPTR(&buf), BLEN(&buf), 0, &gc)); if (!DeviceIoControl(tt->hand, TAP_WIN_IOCTL_CONFIG_DHCP_SET_OPT, - BPTR(&buf), BLEN(&buf), - BPTR(&buf), BLEN(&buf), &len, NULL)) + BPTR(&buf), BLEN(&buf), + BPTR(&buf), BLEN(&buf), &len, NULL)) { msg(M_FATAL, "ERROR: The TAP-Windows driver rejected a TAP_WIN_IOCTL_CONFIG_DHCP_SET_OPT DeviceIoControl call"); } @@ -6183,19 +6183,19 @@ tun_try_open_device(struct tuntap *tt, const char *device_guid, const struct dev { /* Open TAP-Windows adapter */ openvpn_snprintf(tuntap_device_path, sizeof(tuntap_device_path), "%s%s%s", - USERMODEDEVICEDIR, - device_guid, - TAP_WIN_SUFFIX); + USERMODEDEVICEDIR, + device_guid, + TAP_WIN_SUFFIX); path = tuntap_device_path; } tt->hand = CreateFile(path, - GENERIC_READ | GENERIC_WRITE, - 0, /* was: FILE_SHARE_READ */ - 0, - OPEN_EXISTING, - FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, - 0); + GENERIC_READ | GENERIC_WRITE, + 0, /* was: FILE_SHARE_READ */ + 0, + OPEN_EXISTING, + FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, + 0); if (tt->hand == INVALID_HANDLE_VALUE) { msg(D_TUNTAP_INFO, "CreateFile failed on %s device: %s", print_windows_driver(tt->windows_driver), path); @@ -6221,9 +6221,9 @@ static void tun_open_device(struct tuntap *tt, const char *dev_node, const char **device_guid) { struct gc_arena gc = gc_new(); - const struct tap_reg* tap_reg = get_tap_reg(&gc); - const struct panel_reg* panel_reg = get_panel_reg(&gc); - const struct device_instance_id_interface* device_instance_id_interface = get_device_instance_id_interface(&gc); + const struct tap_reg *tap_reg = get_tap_reg(&gc); + const struct panel_reg *panel_reg = get_panel_reg(&gc); + const struct device_instance_id_interface *device_instance_id_interface = get_device_instance_id_interface(&gc); char actual_buffer[256]; at_least_one_tap_win(tap_reg); @@ -6245,7 +6245,8 @@ tun_open_device(struct tuntap *tt, const char *dev_node, const char **device_gui if (tt->windows_driver != windows_driver) { - msg(M_FATAL, "Adapter '%s' is using %s driver, %s expected. If you want to use this device, adjust --windows-driver.", dev_node, print_windows_driver(windows_driver), print_windows_driver(tt->windows_driver)); + msg(M_FATAL, "Adapter '%s' is using %s driver, %s expected. If you want to use this device, adjust --windows-driver.", + dev_node, print_windows_driver(windows_driver), print_windows_driver(tt->windows_driver)); } if (!tun_try_open_device(tt, *device_guid, device_instance_id_interface)) @@ -6284,7 +6285,7 @@ tun_open_device(struct tuntap *tt, const char *dev_node, const char **device_gui break; } - next: +next: device_number++; } } @@ -6458,7 +6459,7 @@ netsh_delete_address_dns(const struct tuntap *tt, bool ipv6, struct gc_arena *gc * address we added (pointed out by Cedric Tabary). */ - /* netsh interface ipvX delete address \"%s\" %s */ + /* netsh interface ipvX delete address \"%s\" %s */ if (ipv6) { ifconfig_ip_local = print_in6_addr(tt->local_ipv6, 0, gc); @@ -6541,7 +6542,7 @@ close_tun(struct tuntap *tt, openvpn_net_ctx_t *ctx) strerror_win32(status, &gc)); } } -#endif +#endif /* if 1 */ dhcp_release(tt); diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 97d28f45..d6e23ea7 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -196,7 +196,7 @@ struct tuntap struct tun_ring *wintun_receive_ring; #else /* ifdef _WIN32 */ int fd; /* file descriptor for TUN/TAP dev */ -#endif +#endif /* ifdef _WIN32 */ #ifdef TARGET_SOLARIS int ip_fd; @@ -517,7 +517,7 @@ wintun_ring_wrap(ULONG value) } static inline void -read_wintun(struct tuntap *tt, struct buffer* buf) +read_wintun(struct tuntap *tt, struct buffer *buf) { struct tun_ring *ring = tt->wintun_send_ring; ULONG head = ring->head; @@ -575,7 +575,7 @@ read_wintun(struct tuntap *tt, struct buffer* buf) static inline bool is_ip_packet_valid(const struct buffer *buf) { - const struct openvpn_iphdr* ih = (const struct openvpn_iphdr *)BPTR(buf); + const struct openvpn_iphdr *ih = (const struct openvpn_iphdr *)BPTR(buf); if (OPENVPN_IPH_GET_VER(ih->version_len) == 4) { @@ -631,7 +631,7 @@ write_wintun(struct tuntap *tt, struct buffer *buf) } /* copy packet size and data into ring */ - packet = (struct TUN_PACKET* )&ring->data[tail]; + packet = (struct TUN_PACKET * )&ring->data[tail]; packet->size = BLEN(buf); memcpy(packet->data, BPTR(buf), BLEN(buf));