From patchwork Wed Nov 15 13:45:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3443 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:3c06:b0:f2:62eb:61c1 with SMTP id e6csp2926286dys; Wed, 15 Nov 2023 05:46:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqKZ5ggnccYCttaa49gei4tJhX1PA5vscc62msOZs5d6wLDJnil35UfSJLmRh1KVXmRBny X-Received: by 2002:a05:6a21:339c:b0:185:a0eb:8574 with SMTP id yy28-20020a056a21339c00b00185a0eb8574mr2294871pzb.5.1700055975902; Wed, 15 Nov 2023 05:46:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700055975; cv=none; d=google.com; s=arc-20160816; b=D7rbOB/kEvw2BWMhIAiMwJiAlpOXUx7Lu3/sIsvXfnTXvDhTqrmRSZIspUuLkSY8cW NAmWsoc8hdMETbeEfnlP+oD8+hAjGK45X3b1o/sKwXbO7Mjp29zTmW0s8GitMnY1bzWb 6VvGUf7Ei8G1ZvHq3SPID2NAfKMG5HrspBKEU7RLL0u+LInmL1H28DfD1QDTv6Ir6vK9 egI9tDPxaZrtV+e1rFGEua7QgivbMA6z9rK75BXxAYxHPNkp+7eV7OtjpqTQaI4yzIVA bl+u47tExrZdF8IHYYsEBXHIrHRKXZGZt2h0qsb7hTbyA0txtX74np/mGUA6u85D+EG3 gJDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=Qhc/VpXz/QXQc88jsxoObJ/Knlsi5aXFaGZfUc9hRHA=; fh=U7wEyxtwz2o5+UdevFSA47vNeG9knhWH0KV//QhD5a0=; b=mE1n/9vWym6FBzXURGw3MByffT5sDxVXnn34A0evba23a25W/DyjLgllQB/z4boTKJ KWuP4jOf5nIJXDktyHUeV4Lzm8+FcCM8RaaD3TuFPmnfGdqCheSNjcgBHAZNW6M51EHH TuF17P4wKh0o+CfVkUHZ5Gbqx/0sVvWEwysDjVL1giKX/6sRYr+X/LJcnalydw/0K7UK vELM2LF1eFTCJatfFWOZKtWHikYN/EAyRRyvvvrKjzT8MrDhEYlm5guQe/BWeOuN8u9w mfSDaF8KTTIKjdR7xpnICgx2X0Pus+tU3SotBrrHbcypZFzYUQu3894JIqdRfCCEryNT VK3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=LmGQdHIG; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="fu1h9+/2"; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=HFq69ap6; 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=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id v20-20020a056a00149400b006be26c1be4bsi10391424pfu.73.2023.11.15.05.46.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2023 05:46:15 -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=LmGQdHIG; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="fu1h9+/2"; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=HFq69ap6; 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=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.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 1r3GCq-0001Ql-15; Wed, 15 Nov 2023 13:45:24 +0000 Received: from [172.30.20.202] (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 1r3GCm-0001QZ-Ef for openvpn-devel@lists.sourceforge.net; Wed, 15 Nov 2023 13:45:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=QiMleLzcIzmBcwTzCxk6OVAGj7Rp7W0izBOzscxYWTA=; b=LmGQdHIG+TFwsjj1/clgG9CQp9 wDB7Gpw88e7H5oy+wgkY49i4LE3qyEyVhma1ik4DxBiT3yCWYyhdzSaX4eDT0drBmLO2GB94VN1jt AHV6xrz6kgVc5AxKrzXIkqJ018oSHuu7sSK/0zzI+jBO/NkylAQ/1cZlMcr2NZYQ2OZY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=QiMleLzcIzmBcwTzCxk6OVAGj7Rp7W0izBOzscxYWTA=; b=f u1h9+/2c+JW9F+vPGRTsVAyF6XOVPf/F3H+6iX8ZzH5bSciK6DhtAluwHmB+0xV7leuXu0nr7zi6d 7TdIh+4FXQw2cVn+sFcirHOo/mYvZmUrjGL8s3ZWlMUqR5AnGQCUV4Vwq6EVXukderRAABGWG+iFn 5pxKVUFr71NdJ+ic=; Received: from mail-wr1-f45.google.com ([209.85.221.45]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1r3GCh-0000Ne-MG for openvpn-devel@lists.sourceforge.net; Wed, 15 Nov 2023 13:45:20 +0000 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-32fb190bf9bso519460f8f.1 for ; Wed, 15 Nov 2023 05:45:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1700055909; x=1700660709; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=QiMleLzcIzmBcwTzCxk6OVAGj7Rp7W0izBOzscxYWTA=; b=HFq69ap6BO96LtakFSl6j3RGRkENeZqR9Ie5uC8Fatdm0XOsBp00LNz4mtU9/daH33 Y4HXFqdActn7kA4ZKG+Rytk8NMDl65TFgMlHlJCv68mXM4rziPLJ+tMWXZkC5cdagAIK uAOZWa+3sNxfFZnPorPWYsxFP1YesrNKOsCOYUpstpx8UHRKJ5kqfmKkmRNPmn7crw5E 6VxBO/Wn5C4e68ZqiHXAqhzL6SF4LXkT31eRXk1E7cV/TL0R3l0tFE/ccVZtOXhH7Lv5 t/RoS9FuZ+tUK6/ViRUVw+/uUvpZM3TuQ8eKntmU4OAYPeB8xHPvGr5wuGLrgKRa9gnd T6Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700055909; x=1700660709; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QiMleLzcIzmBcwTzCxk6OVAGj7Rp7W0izBOzscxYWTA=; b=bfvCaoX3qJDFO79RbkKak+TBg3ux0Xl9j5TIHBO810iYTcALbvz2ubHU60DNeVMhEz KzsVQWlzqAHMjQdWItml5oSAB4jbsSWuQEdjC79Atg90TLkrMf4eE13MduKW/v4JeVRd ZrSD+ji3a6DwVQ5xtc3IgiL5YvZOybwu15v3Ff1qz+za0EiNVDsVr1jEisl1IPGYNOBx 5Nz1+fEzI80nEXDKfpxqmUgO7sGxyXLpvzhkFjgNLakm2dQ9CWb4SJjUhTAATIh7JOqt tAbRCa/vTUCm/lDz2TZKtnS5qPbDAIh+Ex3W6Rw/ALno1KgCzj+dKC7rsT/PGIlh69WP uOcA== X-Gm-Message-State: AOJu0YyTEKNc4Wc6rVwvnwB+DfmtznYPoVVEUa6E3fuuwmCjgkP5xmcz 2Cq+Yw+bdrsEKoMv8MUVs7p7M0nM/tFeh6KG8J4= X-Received: by 2002:a05:6000:1447:b0:331:5975:a867 with SMTP id v7-20020a056000144700b003315975a867mr1686479wrx.19.1700055908997; Wed, 15 Nov 2023 05:45:08 -0800 (PST) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id u25-20020adfa199000000b0032fb46812c2sm10710738wru.12.2023.11.15.05.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 05:45:08 -0800 (PST) From: "ordex (Code Review)" X-Google-Original-From: "ordex (Code Review)" X-Gerrit-PatchSet: 1 Date: Wed, 15 Nov 2023 13:45:07 +0000 To: plaisthos , flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: Id5c50dc754837ddb9a9414d8f38982f75e99bace X-Gerrit-Change-Number: 432 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 5a19be5433dd8b7f3a143fc23e92f64526e1a163 References: Message-ID: <48fd065a8239ec40d1f2eec759fab20038a0dafe-HTML@gerrit.openvpn.net> MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: 0.6 (/) 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: Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit Content analysis details: (0.6 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.45 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.221.45 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 T_SCC_BODY_TEXT_LINE No description available. 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML 0.8 UPPERCASE_50_75 message body is 50-75% uppercase X-Headers-End: 1r3GCh-0000Ne-MG Subject: [Openvpn-devel] [L] Change in openvpn[master]: io_work: convert shift argument to uintptr_t 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: , Reply-To: a@unstable.cc, arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1782637894742897192?= X-GMAIL-MSGID: =?utf-8?q?1782637894742897192?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/432?usp=email to review the following change. Change subject: io_work: convert shift argument to uintptr_t ...................................................................... io_work: convert shift argument to uintptr_t Instead of passing the shift argument as pointer, pass directly its integer value. This will allow the code to distinguish a shift value from a real object pointer, like we already do in multi_tcp_process_io(). This change will allow us later to pass an event_arg object as event handler argument instead of a simple integer value. Change-Id: Id5c50dc754837ddb9a9414d8f38982f75e99bace Signed-off-by: Antonio Quartulli --- M src/openvpn/forward.c M src/openvpn/mtcp.c M src/openvpn/ovpn_dco_linux.h M src/openvpn/ovpn_dco_win.h 4 files changed, 212 insertions(+), 213 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/32/432/1 diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 88d3fea..9cc5c6b 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -2046,14 +2046,12 @@ unsigned int tuntap = 0; struct event_set_return esr[4]; - /* These shifts all depend on EVENT_READ (=1) and EVENT_WRITE (=2) - * and are added to the shift. Check openvpn.h for more details. - */ - static int socket_shift = SOCKET_SHIFT; - static int tun_shift = TUN_SHIFT; - static int err_shift = ERR_SHIFT; + /* These shifts all depend on EVENT_READ and EVENT_WRITE */ + static uintptr_t socket_shift = 0; /* depends on SOCKET_READ and SOCKET_WRITE */ + static uintptr_t tun_shift = 2; /* depends on TUN_READ and TUN_WRITE */ + static uintptr_t err_shift = 4; /* depends on ES_ERROR */ #ifdef ENABLE_MANAGEMENT - static int management_shift = MANAGEMENT_SHIFT; + static uintptr_t management_shift = 6; /* depends on MANAGEMENT_READ and MANAGEMENT_WRITE */ #endif #ifdef ENABLE_ASYNC_PUSH static int file_shift = FILE_SHIFT; @@ -2073,7 +2071,7 @@ */ if (flags & IOW_WAIT_SIGNAL) { - wait_signal(c->c2.event_set, (void *)&err_shift); + wait_signal(c->c2.event_set, (void *)err_shift); } /* @@ -2167,7 +2165,7 @@ * Configure event wait based on socket, tuntap flags. */ socket_set(c->c2.link_socket, c->c2.event_set, socket, (void *)&socket_shift, NULL); - tun_set(c->c1.tuntap, c->c2.event_set, tuntap, (void *)&tun_shift, NULL); + tun_set(c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift, NULL); #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) if (socket & EVENT_READ && c->c2.did_open_tun) { @@ -2178,7 +2176,7 @@ #ifdef ENABLE_MANAGEMENT if (management) { - management_socket_set(management, c->c2.event_set, (void *)&management_shift, NULL); + management_socket_set(management, c->c2.event_set, (void *)management_shift, NULL); } #endif @@ -2229,7 +2227,7 @@ for (i = 0; i < status; ++i) { const struct event_set_return *e = &esr[i]; - c->c2.event_set_status |= ((e->rwflags & 3) << *((int *)e->arg)); + c->c2.event_set_status |= ((e->rwflags & 3) << (uintptr_t)e->arg); } } else if (status == 0) diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c index b83bdca..de1d24f 100644 --- a/src/openvpn/mtcp.c +++ b/src/openvpn/mtcp.c @@ -720,6 +720,7 @@ multi_tcp_action(m, mi, TA_SOCKET_READ, false); } break; + /* new incoming TCP client attempting to connect? */ case EVENT_ARG_LINK_SOCKET: ASSERT(m->top.c2.link_socket); diff --git a/src/openvpn/ovpn_dco_linux.h b/src/openvpn/ovpn_dco_linux.h index 73e19b5..e62d2b4 100644 --- a/src/openvpn/ovpn_dco_linux.h +++ b/src/openvpn/ovpn_dco_linux.h @@ -4,8 +4,8 @@ * * Copyright (C) 2019-2023 OpenVPN, Inc. * - * Author: James Yonan - * Antonio Quartulli + * Author: James Yonan + * Antonio Quartulli */ #ifndef _UAPI_LINUX_OVPN_DCO_H_ @@ -19,238 +19,238 @@ * enum ovpn_nl_commands - supported netlink commands */ enum ovpn_nl_commands { - /** - * @OVPN_CMD_UNSPEC: unspecified command to catch errors - */ - OVPN_CMD_UNSPEC = 0, + /** + * @OVPN_CMD_UNSPEC: unspecified command to catch errors + */ + OVPN_CMD_UNSPEC = 0, - /** - * @OVPN_CMD_NEW_PEER: Configure peer with its crypto keys - */ - OVPN_CMD_NEW_PEER, + /** + * @OVPN_CMD_NEW_PEER: Configure peer with its crypto keys + */ + OVPN_CMD_NEW_PEER, - /** - * @OVPN_CMD_SET_PEER: Tweak parameters for an existing peer - */ - OVPN_CMD_SET_PEER, + /** + * @OVPN_CMD_SET_PEER: Tweak parameters for an existing peer + */ + OVPN_CMD_SET_PEER, - /** - * @OVPN_CMD_DEL_PEER: Remove peer from internal table - */ - OVPN_CMD_DEL_PEER, + /** + * @OVPN_CMD_DEL_PEER: Remove peer from internal table + */ + OVPN_CMD_DEL_PEER, - OVPN_CMD_NEW_KEY, + OVPN_CMD_NEW_KEY, - OVPN_CMD_SWAP_KEYS, + OVPN_CMD_SWAP_KEYS, - OVPN_CMD_DEL_KEY, + OVPN_CMD_DEL_KEY, - /** - * @OVPN_CMD_GET_PEER: Retrieve the status of a peer or all peers - */ - OVPN_CMD_GET_PEER, + /** + * @OVPN_CMD_GET_PEER: Retrieve the status of a peer or all peers + */ + OVPN_CMD_GET_PEER, }; enum ovpn_cipher_alg { - /** - * @OVPN_CIPHER_ALG_NONE: No encryption - reserved for debugging only - */ - OVPN_CIPHER_ALG_NONE = 0, - /** - * @OVPN_CIPHER_ALG_AES_GCM: AES-GCM AEAD cipher with any allowed key size - */ - OVPN_CIPHER_ALG_AES_GCM, - /** - * @OVPN_CIPHER_ALG_CHACHA20_POLY1305: ChaCha20Poly1305 AEAD cipher - */ - OVPN_CIPHER_ALG_CHACHA20_POLY1305, + /** + * @OVPN_CIPHER_ALG_NONE: No encryption - reserved for debugging only + */ + OVPN_CIPHER_ALG_NONE = 0, + /** + * @OVPN_CIPHER_ALG_AES_GCM: AES-GCM AEAD cipher with any allowed key size + */ + OVPN_CIPHER_ALG_AES_GCM, + /** + * @OVPN_CIPHER_ALG_CHACHA20_POLY1305: ChaCha20Poly1305 AEAD cipher + */ + OVPN_CIPHER_ALG_CHACHA20_POLY1305, }; enum ovpn_del_peer_reason { - __OVPN_DEL_PEER_REASON_FIRST, - OVPN_DEL_PEER_REASON_TEARDOWN = __OVPN_DEL_PEER_REASON_FIRST, - OVPN_DEL_PEER_REASON_USERSPACE, - OVPN_DEL_PEER_REASON_EXPIRED, - OVPN_DEL_PEER_REASON_TRANSPORT_ERROR, - OVPN_DEL_PEER_REASON_TRANSPORT_DISCONNECT, - __OVPN_DEL_PEER_REASON_AFTER_LAST + __OVPN_DEL_PEER_REASON_FIRST, + OVPN_DEL_PEER_REASON_TEARDOWN = __OVPN_DEL_PEER_REASON_FIRST, + OVPN_DEL_PEER_REASON_USERSPACE, + OVPN_DEL_PEER_REASON_EXPIRED, + OVPN_DEL_PEER_REASON_TRANSPORT_ERROR, + OVPN_DEL_PEER_REASON_TRANSPORT_DISCONNECT, + __OVPN_DEL_PEER_REASON_AFTER_LAST }; enum ovpn_key_slot { - __OVPN_KEY_SLOT_FIRST, - OVPN_KEY_SLOT_PRIMARY = __OVPN_KEY_SLOT_FIRST, - OVPN_KEY_SLOT_SECONDARY, - __OVPN_KEY_SLOT_AFTER_LAST, + __OVPN_KEY_SLOT_FIRST, + OVPN_KEY_SLOT_PRIMARY = __OVPN_KEY_SLOT_FIRST, + OVPN_KEY_SLOT_SECONDARY, + __OVPN_KEY_SLOT_AFTER_LAST, }; enum ovpn_netlink_attrs { - OVPN_ATTR_UNSPEC = 0, - OVPN_ATTR_IFINDEX, - OVPN_ATTR_NEW_PEER, - OVPN_ATTR_SET_PEER, - OVPN_ATTR_DEL_PEER, - OVPN_ATTR_NEW_KEY, - OVPN_ATTR_SWAP_KEYS, - OVPN_ATTR_DEL_KEY, - OVPN_ATTR_GET_PEER, + OVPN_ATTR_UNSPEC = 0, + OVPN_ATTR_IFINDEX, + OVPN_ATTR_NEW_PEER, + OVPN_ATTR_SET_PEER, + OVPN_ATTR_DEL_PEER, + OVPN_ATTR_NEW_KEY, + OVPN_ATTR_SWAP_KEYS, + OVPN_ATTR_DEL_KEY, + OVPN_ATTR_GET_PEER, - __OVPN_ATTR_AFTER_LAST, - OVPN_ATTR_MAX = __OVPN_ATTR_AFTER_LAST - 1, + __OVPN_ATTR_AFTER_LAST, + OVPN_ATTR_MAX = __OVPN_ATTR_AFTER_LAST - 1, }; enum ovpn_netlink_key_dir_attrs { - OVPN_KEY_DIR_ATTR_UNSPEC = 0, - OVPN_KEY_DIR_ATTR_CIPHER_KEY, - OVPN_KEY_DIR_ATTR_NONCE_TAIL, + OVPN_KEY_DIR_ATTR_UNSPEC = 0, + OVPN_KEY_DIR_ATTR_CIPHER_KEY, + OVPN_KEY_DIR_ATTR_NONCE_TAIL, - __OVPN_KEY_DIR_ATTR_AFTER_LAST, - OVPN_KEY_DIR_ATTR_MAX = __OVPN_KEY_DIR_ATTR_AFTER_LAST - 1, + __OVPN_KEY_DIR_ATTR_AFTER_LAST, + OVPN_KEY_DIR_ATTR_MAX = __OVPN_KEY_DIR_ATTR_AFTER_LAST - 1, }; enum ovpn_netlink_new_key_attrs { - OVPN_NEW_KEY_ATTR_UNSPEC = 0, - OVPN_NEW_KEY_ATTR_PEER_ID, - OVPN_NEW_KEY_ATTR_KEY_SLOT, - OVPN_NEW_KEY_ATTR_KEY_ID, - OVPN_NEW_KEY_ATTR_CIPHER_ALG, - OVPN_NEW_KEY_ATTR_ENCRYPT_KEY, - OVPN_NEW_KEY_ATTR_DECRYPT_KEY, + OVPN_NEW_KEY_ATTR_UNSPEC = 0, + OVPN_NEW_KEY_ATTR_PEER_ID, + OVPN_NEW_KEY_ATTR_KEY_SLOT, + OVPN_NEW_KEY_ATTR_KEY_ID, + OVPN_NEW_KEY_ATTR_CIPHER_ALG, + OVPN_NEW_KEY_ATTR_ENCRYPT_KEY, + OVPN_NEW_KEY_ATTR_DECRYPT_KEY, - __OVPN_NEW_KEY_ATTR_AFTER_LAST, - OVPN_NEW_KEY_ATTR_MAX = __OVPN_NEW_KEY_ATTR_AFTER_LAST - 1, + __OVPN_NEW_KEY_ATTR_AFTER_LAST, + OVPN_NEW_KEY_ATTR_MAX = __OVPN_NEW_KEY_ATTR_AFTER_LAST - 1, }; enum ovpn_netlink_del_key_attrs { - OVPN_DEL_KEY_ATTR_UNSPEC = 0, - OVPN_DEL_KEY_ATTR_PEER_ID, - OVPN_DEL_KEY_ATTR_KEY_SLOT, + OVPN_DEL_KEY_ATTR_UNSPEC = 0, + OVPN_DEL_KEY_ATTR_PEER_ID, + OVPN_DEL_KEY_ATTR_KEY_SLOT, - __OVPN_DEL_KEY_ATTR_AFTER_LAST, - OVPN_DEL_KEY_ATTR_MAX = __OVPN_DEL_KEY_ATTR_AFTER_LAST - 1, + __OVPN_DEL_KEY_ATTR_AFTER_LAST, + OVPN_DEL_KEY_ATTR_MAX = __OVPN_DEL_KEY_ATTR_AFTER_LAST - 1, }; enum ovpn_netlink_swap_keys_attrs { - OVPN_SWAP_KEYS_ATTR_UNSPEC = 0, - OVPN_SWAP_KEYS_ATTR_PEER_ID, + OVPN_SWAP_KEYS_ATTR_UNSPEC = 0, + OVPN_SWAP_KEYS_ATTR_PEER_ID, - __OVPN_SWAP_KEYS_ATTR_AFTER_LAST, - OVPN_SWAP_KEYS_ATTR_MAX = __OVPN_SWAP_KEYS_ATTR_AFTER_LAST - 1, + __OVPN_SWAP_KEYS_ATTR_AFTER_LAST, + OVPN_SWAP_KEYS_ATTR_MAX = __OVPN_SWAP_KEYS_ATTR_AFTER_LAST - 1, }; enum ovpn_netlink_new_peer_attrs { - OVPN_NEW_PEER_ATTR_UNSPEC = 0, - OVPN_NEW_PEER_ATTR_PEER_ID, - OVPN_NEW_PEER_ATTR_SOCKADDR_REMOTE, - OVPN_NEW_PEER_ATTR_SOCKET, - OVPN_NEW_PEER_ATTR_IPV4, - OVPN_NEW_PEER_ATTR_IPV6, - OVPN_NEW_PEER_ATTR_LOCAL_IP, + OVPN_NEW_PEER_ATTR_UNSPEC = 0, + OVPN_NEW_PEER_ATTR_PEER_ID, + OVPN_NEW_PEER_ATTR_SOCKADDR_REMOTE, + OVPN_NEW_PEER_ATTR_SOCKET, + OVPN_NEW_PEER_ATTR_IPV4, + OVPN_NEW_PEER_ATTR_IPV6, + OVPN_NEW_PEER_ATTR_LOCAL_IP, - __OVPN_NEW_PEER_ATTR_AFTER_LAST, - OVPN_NEW_PEER_ATTR_MAX = __OVPN_NEW_PEER_ATTR_AFTER_LAST - 1, + __OVPN_NEW_PEER_ATTR_AFTER_LAST, + OVPN_NEW_PEER_ATTR_MAX = __OVPN_NEW_PEER_ATTR_AFTER_LAST - 1, }; enum ovpn_netlink_set_peer_attrs { - OVPN_SET_PEER_ATTR_UNSPEC = 0, - OVPN_SET_PEER_ATTR_PEER_ID, - OVPN_SET_PEER_ATTR_KEEPALIVE_INTERVAL, - OVPN_SET_PEER_ATTR_KEEPALIVE_TIMEOUT, + OVPN_SET_PEER_ATTR_UNSPEC = 0, + OVPN_SET_PEER_ATTR_PEER_ID, + OVPN_SET_PEER_ATTR_KEEPALIVE_INTERVAL, + OVPN_SET_PEER_ATTR_KEEPALIVE_TIMEOUT, - __OVPN_SET_PEER_ATTR_AFTER_LAST, - OVPN_SET_PEER_ATTR_MAX = __OVPN_SET_PEER_ATTR_AFTER_LAST - 1, + __OVPN_SET_PEER_ATTR_AFTER_LAST, + OVPN_SET_PEER_ATTR_MAX = __OVPN_SET_PEER_ATTR_AFTER_LAST - 1, }; enum ovpn_netlink_del_peer_attrs { - OVPN_DEL_PEER_ATTR_UNSPEC = 0, - OVPN_DEL_PEER_ATTR_REASON, - OVPN_DEL_PEER_ATTR_PEER_ID, + OVPN_DEL_PEER_ATTR_UNSPEC = 0, + OVPN_DEL_PEER_ATTR_REASON, + OVPN_DEL_PEER_ATTR_PEER_ID, - __OVPN_DEL_PEER_ATTR_AFTER_LAST, - OVPN_DEL_PEER_ATTR_MAX = __OVPN_DEL_PEER_ATTR_AFTER_LAST - 1, + __OVPN_DEL_PEER_ATTR_AFTER_LAST, + OVPN_DEL_PEER_ATTR_MAX = __OVPN_DEL_PEER_ATTR_AFTER_LAST - 1, }; enum ovpn_netlink_get_peer_attrs { - OVPN_GET_PEER_ATTR_UNSPEC = 0, - OVPN_GET_PEER_ATTR_PEER_ID, + OVPN_GET_PEER_ATTR_UNSPEC = 0, + OVPN_GET_PEER_ATTR_PEER_ID, - __OVPN_GET_PEER_ATTR_AFTER_LAST, - OVPN_GET_PEER_ATTR_MAX = __OVPN_GET_PEER_ATTR_AFTER_LAST - 1, + __OVPN_GET_PEER_ATTR_AFTER_LAST, + OVPN_GET_PEER_ATTR_MAX = __OVPN_GET_PEER_ATTR_AFTER_LAST - 1, }; enum ovpn_netlink_get_peer_response_attrs { - OVPN_GET_PEER_RESP_ATTR_UNSPEC = 0, - OVPN_GET_PEER_RESP_ATTR_PEER_ID, - OVPN_GET_PEER_RESP_ATTR_SOCKADDR_REMOTE, - OVPN_GET_PEER_RESP_ATTR_IPV4, - OVPN_GET_PEER_RESP_ATTR_IPV6, - OVPN_GET_PEER_RESP_ATTR_LOCAL_IP, - OVPN_GET_PEER_RESP_ATTR_LOCAL_PORT, - OVPN_GET_PEER_RESP_ATTR_KEEPALIVE_INTERVAL, - OVPN_GET_PEER_RESP_ATTR_KEEPALIVE_TIMEOUT, - OVPN_GET_PEER_RESP_ATTR_VPN_RX_BYTES, - OVPN_GET_PEER_RESP_ATTR_VPN_TX_BYTES, - OVPN_GET_PEER_RESP_ATTR_VPN_RX_PACKETS, - OVPN_GET_PEER_RESP_ATTR_VPN_TX_PACKETS, - OVPN_GET_PEER_RESP_ATTR_LINK_RX_BYTES, - OVPN_GET_PEER_RESP_ATTR_LINK_TX_BYTES, - OVPN_GET_PEER_RESP_ATTR_LINK_RX_PACKETS, - OVPN_GET_PEER_RESP_ATTR_LINK_TX_PACKETS, + OVPN_GET_PEER_RESP_ATTR_UNSPEC = 0, + OVPN_GET_PEER_RESP_ATTR_PEER_ID, + OVPN_GET_PEER_RESP_ATTR_SOCKADDR_REMOTE, + OVPN_GET_PEER_RESP_ATTR_IPV4, + OVPN_GET_PEER_RESP_ATTR_IPV6, + OVPN_GET_PEER_RESP_ATTR_LOCAL_IP, + OVPN_GET_PEER_RESP_ATTR_LOCAL_PORT, + OVPN_GET_PEER_RESP_ATTR_KEEPALIVE_INTERVAL, + OVPN_GET_PEER_RESP_ATTR_KEEPALIVE_TIMEOUT, + OVPN_GET_PEER_RESP_ATTR_VPN_RX_BYTES, + OVPN_GET_PEER_RESP_ATTR_VPN_TX_BYTES, + OVPN_GET_PEER_RESP_ATTR_VPN_RX_PACKETS, + OVPN_GET_PEER_RESP_ATTR_VPN_TX_PACKETS, + OVPN_GET_PEER_RESP_ATTR_LINK_RX_BYTES, + OVPN_GET_PEER_RESP_ATTR_LINK_TX_BYTES, + OVPN_GET_PEER_RESP_ATTR_LINK_RX_PACKETS, + OVPN_GET_PEER_RESP_ATTR_LINK_TX_PACKETS, - __OVPN_GET_PEER_RESP_ATTR_AFTER_LAST, - OVPN_GET_PEER_RESP_ATTR_MAX = __OVPN_GET_PEER_RESP_ATTR_AFTER_LAST - 1, + __OVPN_GET_PEER_RESP_ATTR_AFTER_LAST, + OVPN_GET_PEER_RESP_ATTR_MAX = __OVPN_GET_PEER_RESP_ATTR_AFTER_LAST - 1, }; enum ovpn_netlink_peer_stats_attrs { - OVPN_PEER_STATS_ATTR_UNSPEC = 0, - OVPN_PEER_STATS_BYTES, - OVPN_PEER_STATS_PACKETS, + OVPN_PEER_STATS_ATTR_UNSPEC = 0, + OVPN_PEER_STATS_BYTES, + OVPN_PEER_STATS_PACKETS, - __OVPN_PEER_STATS_ATTR_AFTER_LAST, - OVPN_PEER_STATS_ATTR_MAX = __OVPN_PEER_STATS_ATTR_AFTER_LAST - 1, + __OVPN_PEER_STATS_ATTR_AFTER_LAST, + OVPN_PEER_STATS_ATTR_MAX = __OVPN_PEER_STATS_ATTR_AFTER_LAST - 1, }; enum ovpn_netlink_peer_attrs { - OVPN_PEER_ATTR_UNSPEC = 0, - OVPN_PEER_ATTR_PEER_ID, - OVPN_PEER_ATTR_SOCKADDR_REMOTE, - OVPN_PEER_ATTR_IPV4, - OVPN_PEER_ATTR_IPV6, - OVPN_PEER_ATTR_LOCAL_IP, - OVPN_PEER_ATTR_KEEPALIVE_INTERVAL, - OVPN_PEER_ATTR_KEEPALIVE_TIMEOUT, - OVPN_PEER_ATTR_ENCRYPT_KEY, - OVPN_PEER_ATTR_DECRYPT_KEY, - OVPN_PEER_ATTR_RX_STATS, - OVPN_PEER_ATTR_TX_STATS, + OVPN_PEER_ATTR_UNSPEC = 0, + OVPN_PEER_ATTR_PEER_ID, + OVPN_PEER_ATTR_SOCKADDR_REMOTE, + OVPN_PEER_ATTR_IPV4, + OVPN_PEER_ATTR_IPV6, + OVPN_PEER_ATTR_LOCAL_IP, + OVPN_PEER_ATTR_KEEPALIVE_INTERVAL, + OVPN_PEER_ATTR_KEEPALIVE_TIMEOUT, + OVPN_PEER_ATTR_ENCRYPT_KEY, + OVPN_PEER_ATTR_DECRYPT_KEY, + OVPN_PEER_ATTR_RX_STATS, + OVPN_PEER_ATTR_TX_STATS, - __OVPN_PEER_ATTR_AFTER_LAST, - OVPN_PEER_ATTR_MAX = __OVPN_PEER_ATTR_AFTER_LAST - 1, + __OVPN_PEER_ATTR_AFTER_LAST, + OVPN_PEER_ATTR_MAX = __OVPN_PEER_ATTR_AFTER_LAST - 1, }; enum ovpn_netlink_packet_attrs { - OVPN_PACKET_ATTR_UNSPEC = 0, - OVPN_PACKET_ATTR_PACKET, - OVPN_PACKET_ATTR_PEER_ID, + OVPN_PACKET_ATTR_UNSPEC = 0, + OVPN_PACKET_ATTR_PACKET, + OVPN_PACKET_ATTR_PEER_ID, - __OVPN_PACKET_ATTR_AFTER_LAST, - OVPN_PACKET_ATTR_MAX = __OVPN_PACKET_ATTR_AFTER_LAST - 1, + __OVPN_PACKET_ATTR_AFTER_LAST, + OVPN_PACKET_ATTR_MAX = __OVPN_PACKET_ATTR_AFTER_LAST - 1, }; enum ovpn_ifla_attrs { - IFLA_OVPN_UNSPEC = 0, - IFLA_OVPN_MODE, + IFLA_OVPN_UNSPEC = 0, + IFLA_OVPN_MODE, - __IFLA_OVPN_AFTER_LAST, - IFLA_OVPN_MAX = __IFLA_OVPN_AFTER_LAST - 1, + __IFLA_OVPN_AFTER_LAST, + IFLA_OVPN_MAX = __IFLA_OVPN_AFTER_LAST - 1, }; enum ovpn_mode { - __OVPN_MODE_FIRST = 0, - OVPN_MODE_P2P = __OVPN_MODE_FIRST, - OVPN_MODE_MP, + __OVPN_MODE_FIRST = 0, + OVPN_MODE_P2P = __OVPN_MODE_FIRST, + OVPN_MODE_MP, - __OVPN_MODE_AFTER_LAST, + __OVPN_MODE_AFTER_LAST, }; #endif /* _UAPI_LINUX_OVPN_DCO_H_ */ diff --git a/src/openvpn/ovpn_dco_win.h b/src/openvpn/ovpn_dco_win.h index ea2a733..e8bd074 100644 --- a/src/openvpn/ovpn_dco_win.h +++ b/src/openvpn/ovpn_dco_win.h @@ -3,7 +3,7 @@ * * Copyright (C) 2020-2021 OpenVPN Inc * - * Author: Lev Stipakov + * Author: Lev Stipakov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 @@ -29,76 +29,76 @@ #include typedef enum { - OVPN_PROTO_UDP, - OVPN_PROTO_TCP + OVPN_PROTO_UDP, + OVPN_PROTO_TCP } OVPN_PROTO; typedef struct _OVPN_NEW_PEER { - union { - SOCKADDR_IN Addr4; - SOCKADDR_IN6 Addr6; - } Local; + union { + SOCKADDR_IN Addr4; + SOCKADDR_IN6 Addr6; + } Local; - union { - SOCKADDR_IN Addr4; - SOCKADDR_IN6 Addr6; - } Remote; + union { + SOCKADDR_IN Addr4; + SOCKADDR_IN6 Addr6; + } Remote; - OVPN_PROTO Proto; -} OVPN_NEW_PEER, * POVPN_NEW_PEER; + OVPN_PROTO Proto; +} OVPN_NEW_PEER, *POVPN_NEW_PEER; typedef struct _OVPN_STATS { - LONG LostInControlPackets; - LONG LostOutControlPackets; + LONG LostInControlPackets; + LONG LostOutControlPackets; - LONG LostInDataPackets; - LONG LostOutDataPackets; + LONG LostInDataPackets; + LONG LostOutDataPackets; - LONG ReceivedDataPackets; - LONG ReceivedControlPackets; + LONG ReceivedDataPackets; + LONG ReceivedControlPackets; - LONG SentControlPackets; - LONG SentDataPackets; + LONG SentControlPackets; + LONG SentDataPackets; - LONG64 TransportBytesSent; - LONG64 TransportBytesReceived; + LONG64 TransportBytesSent; + LONG64 TransportBytesReceived; - LONG64 TunBytesSent; - LONG64 TunBytesReceived; -} OVPN_STATS, * POVPN_STATS; + LONG64 TunBytesSent; + LONG64 TunBytesReceived; +} OVPN_STATS, *POVPN_STATS; typedef enum _OVPN_KEY_SLOT { - OVPN_KEY_SLOT_PRIMARY, - OVPN_KEY_SLOT_SECONDARY + OVPN_KEY_SLOT_PRIMARY, + OVPN_KEY_SLOT_SECONDARY } OVPN_KEY_SLOT; typedef enum _OVPN_CIPHER_ALG { - OVPN_CIPHER_ALG_NONE, - OVPN_CIPHER_ALG_AES_GCM, - OVPN_CIPHER_ALG_CHACHA20_POLY1305 + OVPN_CIPHER_ALG_NONE, + OVPN_CIPHER_ALG_AES_GCM, + OVPN_CIPHER_ALG_CHACHA20_POLY1305 } OVPN_CIPHER_ALG; typedef struct _OVPN_KEY_DIRECTION { - unsigned char Key[32]; - unsigned char KeyLen; // 16/24/32 -> AES-128-GCM/AES-192-GCM/AES-256-GCM - unsigned char NonceTail[8]; + unsigned char Key[32]; + unsigned char KeyLen; /* 16/24/32 -> AES-128-GCM/AES-192-GCM/AES-256-GCM */ + unsigned char NonceTail[8]; } OVPN_KEY_DIRECTION; typedef struct _OVPN_CRYPTO_DATA { - OVPN_KEY_DIRECTION Encrypt; - OVPN_KEY_DIRECTION Decrypt; - OVPN_KEY_SLOT KeySlot; - OVPN_CIPHER_ALG CipherAlg; - unsigned char KeyId; - int PeerId; -} OVPN_CRYPTO_DATA, * POVPN_CRYPTO_DATA; + OVPN_KEY_DIRECTION Encrypt; + OVPN_KEY_DIRECTION Decrypt; + OVPN_KEY_SLOT KeySlot; + OVPN_CIPHER_ALG CipherAlg; + unsigned char KeyId; + int PeerId; +} OVPN_CRYPTO_DATA, *POVPN_CRYPTO_DATA; typedef struct _OVPN_SET_PEER { - LONG KeepaliveInterval; - LONG KeepaliveTimeout; - LONG MSS; -} OVPN_SET_PEER, * POVPN_SET_PEER; + LONG KeepaliveInterval; + LONG KeepaliveTimeout; + LONG MSS; +} OVPN_SET_PEER, *POVPN_SET_PEER; typedef struct _OVPN_VERSION { LONG Major;