From patchwork Mon Oct 14 12:21:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Lichtenheld X-Patchwork-Id: 3890 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:1757:b0:5b9:581e:f939 with SMTP id c23csp1875310maw; Mon, 14 Oct 2024 05:22:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWxDrQ5JFeDSC5ZWpCOaI0oIZ1zbbBljtwbso10ddGUnbVCMtg1mrimKmOCFTJ3wGPDy5QDbBNn5F0=@openvpn.net X-Google-Smtp-Source: AGHT+IEr2zYc5hSNG1CdcQ2Xup+aCginElrTN0+Aof8ywWGtfSA3JJkVBu26ijlzc55+WaK67PAR X-Received: by 2002:a05:6808:23d0:b0:3e0:4db9:8c44 with SMTP id 5614622812f47-3e5d222e336mr3068488b6e.27.1728908539731; Mon, 14 Oct 2024 05:22:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728908539; cv=none; d=google.com; s=arc-20240605; b=WFEGOgXCXNivg6CStRWQkDPQu01aNred9B3sMtYUXgTjssmISBnEogSgNSZ7x9Wzui 0nvHuMS05U3nQ9CSghdF7vAElWY45kSfISMAWjwBsgKF9LZrccHluPkzLZcNczIFVjBq 005rWp3l9llSpfBDr91HvcYsg06kejQ9/irAvRGCAvsd8dEkWLd8BbpDwxqUv4ceOw1h bes+wJ4CGizQSVUq7Io9pfzo52D1I0xY3GtPKgfFgwSFkM9bxZNkWCnIa4llp+86AeQE 1QHjjTBBgoGa3PTxkVbde1fIyfdXsE2dEZhfV2SD46Uw1OcjtN+aWFvlK4DQXNYXKmDr sWkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:cc:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=KjG+V8KN03PthCfedGk2P0PFfBHUb24Eu0y/YCX7N1s=; fh=yXAbqwSLX4AZy2IfjuXV6xw9sEGAlDO35mmlrsbkSnM=; b=djviRuB9BOUquPSF1Jnnh0qjOIyWDlYhEvFg5qseYFcppLG1WSPtddUsMmNrRGK9FZ gE1l0yIcdOXpF8HU0P39QxyoC+I7PpJLPfuxGGHphKhHCxAPBGQFA+uRejgHBZFosCAl n/rYCxbk2pPh+Do2ms4s6qJZBzA7QJNgRWcGYz1WwacUiAmM6w2JiOKTdbinqvwfURwB cb8Xl9CCRF7P1xD+QweB4NU27N4h/pU1CbS5p86c/E1w3MSOI7N06VB4y2TVGNs7JEo+ RvxZJNSsgszbN7IpJscXTX7G3IhhgbXn2bncSFtFTu/WWwtR5vACyOz1wKqZEopOfoB8 Lfyg==; 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=P08Py4VK; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=SEHUCKDa; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=DBonfRNs; 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 Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5614622812f47-3e50a2c48ddsi4806080b6e.127.2024.10.14.05.22.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2024 05:22:19 -0700 (PDT) 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=P08Py4VK; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=SEHUCKDa; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=DBonfRNs; 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 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.95) (envelope-from ) id 1t0K5R-0000vl-PP; Mon, 14 Oct 2024 12:22:09 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1t0K5Q-0000vT-4x for openvpn-devel@lists.sourceforge.net; Mon, 14 Oct 2024 12:22:08 +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:References: In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Gp1YaDrnU2PNAkT59WZoTDN+pKLUkqC3rzbLSdS2qdA=; b=P08Py4VK3rwRDFbt8wAA18lM9R fciPo6omXjZGnLbxFmHwWpJBSAIhYRJfhv3Hv5yjXuxpg44qchymRwPs+SyX/491Z33rj2zug/Yu9 86bGq8/UreUe2qwDCNBhYFaTLWRQ1RHmRto58nqc3ELPDR8qWIMFfxECxforQSBlY03Y=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Gp1YaDrnU2PNAkT59WZoTDN+pKLUkqC3rzbLSdS2qdA=; b=SEHUCKDaBblEOwOWuESltEVfiA u6m6ITVBVRoh+2miOw6kMBBDgZgk2vGVtQ8t68HAwCLWgInI/z6o7jz2A8tFe1cvUiHUuTkOVI15Y ZIpe21Vdhl97O2/dtL+0oqZ3QCzh8GuIQ+QmCOweRI07JoY6dEiKOTnYDdmp+DJsPhdU=; Received: from mout-p-101.mailbox.org ([80.241.56.151]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1t0K5N-0005Eq-Oz for openvpn-devel@lists.sourceforge.net; Mon, 14 Oct 2024 12:22:08 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4XRxDj2nvVz9sqf; Mon, 14 Oct 2024 14:21:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lichtenheld.com; s=MBO0001; t=1728908517; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gp1YaDrnU2PNAkT59WZoTDN+pKLUkqC3rzbLSdS2qdA=; b=DBonfRNslGYPodKXeZncyRMTwqgPnoFuPXnB/rKLzTt7ElcLEFepIQn/L3GD1eGLakRcAx l9HvQgja9T/jzZid2H7OoOVhoq5SNK8yCbA149uuDq9wtkVxXQYes4niYFn9loOTA0c2bH sFIk9YM8bZRrQ9bPjzrjwgFUKdSHarYGc7KcPkXOL7FWpc+tLgH+XtcfCTeKsssZmUR1+a Lru3zTeTVvWzOV+duEzICjx6po2tsKs80UzF7BqSNKm+GLBP/HHrFScxD10Zz5IkOzwIcu +JFbz163yRATWrjIRpn70vL7T7eb6p6cn9LGQgfxt20BNUBAHThbNTyHaIK56Q== From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Mon, 14 Oct 2024 14:21:55 +0200 Message-Id: <20241014122155.37199-1-frank@lichtenheld.com> In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4XRxDj2nvVz9sqf X-Spam-Score: -0.9 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.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: Antonio Quartulli In order to prepare the code to work with distinct sockets, it is essential that i/o functions do not operate on any hard-coded socket object (i.e. c->c2.link_socket). Content analysis details: (-0.9 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [80.241.56.151 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.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-Headers-End: 1t0K5N-0005Eq-Oz Subject: [Openvpn-devel] [PATCH v4] pass link_socket object to i/o functions 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: , Cc: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1812892001081850040?= X-GMAIL-MSGID: =?utf-8?q?1812892001081850040?= From: Antonio Quartulli In order to prepare the code to work with distinct sockets, it is essential that i/o functions do not operate on any hard-coded socket object (i.e. c->c2.link_socket). This patch changes all the low-level i/o functionis to work with a socket specified as argument rather than a fixed one. Change-Id: I8eae2d3356bbcc5d632eeb4fbe80de8009d9b40d Signed-off-by: Antonio Quartulli Signed-off-by: Gianmarco De Gregori Acked-by: Frank Lichtenheld --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. I manually added Signed-off-by for Giaan since he submitted this change, so he clearly did vouch for it. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/758 This mail reflects revision 4 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld diff --git a/src/openvpn/event.h b/src/openvpn/event.h index 844ea7b..b3ba183 100644 --- a/src/openvpn/event.h +++ b/src/openvpn/event.h @@ -137,6 +137,7 @@ event_arg_t type; union { struct multi_instance *mi; /* if type = EVENT_ARG_MULTI_INSTANCE */ + struct link_socket *sock; /* if type = EVENT_ARG_LINK_SOCKET */ } u; }; diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 6df01d1..6f279ec 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -884,9 +884,9 @@ */ static inline void -socks_postprocess_incoming_link(struct context *c) +socks_postprocess_incoming_link(struct context *c, struct link_socket *sock) { - if (c->c2.link_socket->socks_proxy && c->c2.link_socket->info.proto == PROTO_UDP) + if (sock->socks_proxy && sock->info.proto == PROTO_UDP) { socks_process_incoming_udp(&c->c2.buf, &c->c2.from); } @@ -894,13 +894,14 @@ static inline void socks_preprocess_outgoing_link(struct context *c, + struct link_socket *sock, struct link_socket_actual **to_addr, int *size_delta) { - if (c->c2.link_socket->socks_proxy && c->c2.link_socket->info.proto == PROTO_UDP) + if (sock->socks_proxy && sock->info.proto == PROTO_UDP) { *size_delta += socks_process_outgoing_udp(&c->c2.to_link, c->c2.to_link_addr); - *to_addr = &c->c2.link_socket->socks_relay; + *to_addr = &sock->socks_relay; } } @@ -925,7 +926,7 @@ */ void -read_incoming_link(struct context *c) +read_incoming_link(struct context *c, struct link_socket *sock) { /* * Set up for recvfrom call to read datagram @@ -940,17 +941,17 @@ c->c2.buf = c->c2.buffers->read_link_buf; ASSERT(buf_init(&c->c2.buf, c->c2.frame.buf.headroom)); - status = link_socket_read(c->c2.link_socket, + status = link_socket_read(sock, &c->c2.buf, &c->c2.from); - if (socket_connection_reset(c->c2.link_socket, status)) + if (socket_connection_reset(sock, status)) { #if PORT_SHARE - if (port_share && socket_foreign_protocol_detected(c->c2.link_socket)) + if (port_share && socket_foreign_protocol_detected(sock)) { - const struct buffer *fbuf = socket_foreign_protocol_head(c->c2.link_socket); - const int sd = socket_foreign_protocol_sd(c->c2.link_socket); + const struct buffer *fbuf = socket_foreign_protocol_head(sock); + const int sd = socket_foreign_protocol_sd(sock); port_share_redirect(port_share, fbuf, sd); register_signal(c->sig, SIGTERM, "port-share-redirect"); } @@ -977,7 +978,7 @@ bool dco_win_timeout = tuntap_is_dco_win_timeout(c->c1.tuntap, status); /* check recvfrom status */ - check_status(status, "read", c->c2.link_socket, NULL); + check_status(status, "read", sock, NULL); if (dco_win_timeout) { @@ -985,7 +986,7 @@ } /* Remove socks header if applicable */ - socks_postprocess_incoming_link(c); + socks_postprocess_incoming_link(c, sock); perf_pop(); } @@ -1222,11 +1223,11 @@ } static void -process_incoming_link(struct context *c) +process_incoming_link(struct context *c, struct link_socket *sock) { perf_push(PERF_PROC_IN_LINK); - struct link_socket_info *lsi = get_link_socket_info(c); + struct link_socket_info *lsi = &sock->info; const uint8_t *orig_buf = c->c2.buf.data; process_incoming_link_part1(c, lsi, false); @@ -1732,7 +1733,7 @@ */ void -process_outgoing_link(struct context *c) +process_outgoing_link(struct context *c, struct link_socket *sock) { struct gc_arena gc = gc_new(); int error_code = 0; @@ -1775,7 +1776,7 @@ #if PASSTOS_CAPABILITY /* Set TOS */ - link_socket_set_tos(c->c2.link_socket); + link_socket_set_tos(sock); #endif /* Log packet send */ @@ -1786,7 +1787,7 @@ } #endif msg(D_LINK_RW, "%s WRITE [%d] to %s: %s", - proto2ascii(c->c2.link_socket->info.proto, c->c2.link_socket->info.af, true), + proto2ascii(sock->info.proto, sock->info.af, true), BLEN(&c->c2.to_link), print_link_socket_actual(c->c2.to_link_addr, &gc), PROTO_DUMP(&c->c2.to_link, &gc)); @@ -1797,10 +1798,12 @@ int size_delta = 0; /* If Socks5 over UDP, prepend header */ - socks_preprocess_outgoing_link(c, &to_addr, &size_delta); + socks_preprocess_outgoing_link(c, sock, &to_addr, &size_delta); /* Send packet */ - size = (int)link_socket_write(c->c2.link_socket, &c->c2.to_link, to_addr); + size = (int)link_socket_write(sock, + &c->c2.to_link, + to_addr); /* Undo effect of prepend */ link_socket_write_post_size_adjust(&size, size_delta, &c->c2.to_link); @@ -1829,7 +1832,7 @@ /* Check return status */ error_code = openvpn_errno(); - check_status(size, "write", c->c2.link_socket, NULL); + check_status(size, "write", sock, NULL); if (size > 0) { @@ -2272,7 +2275,7 @@ } void -process_io(struct context *c) +process_io(struct context *c, struct link_socket *sock) { const unsigned int status = c->c2.event_set_status; @@ -2287,7 +2290,7 @@ /* TCP/UDP port ready to accept write */ if (status & SOCKET_WRITE) { - process_outgoing_link(c); + process_outgoing_link(c, sock); } /* TUN device ready to accept write */ else if (status & TUN_WRITE) @@ -2297,10 +2300,10 @@ /* Incoming data on TCP/UDP port */ else if (status & SOCKET_READ) { - read_incoming_link(c); + read_incoming_link(c, sock); if (!IS_SIG(c)) { - process_incoming_link(c); + process_incoming_link(c, sock); } } /* Incoming data on TUN device */ diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index 422c591..8ef19b4 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -72,7 +72,8 @@ void pre_select(struct context *c); -void process_io(struct context *c); +void process_io(struct context *c, struct link_socket *sock); + /**********************************************************************/ /** @@ -128,10 +129,11 @@ * context associated with the appropriate VPN tunnel for which data is * available to be read. * - * @param c - The context structure which contains the external - * network socket from which to read incoming packets. + * @param c The context structure which contains the external + * network socket from which to read incoming packets. + * @param sock The socket where the packet can be read from. */ -void read_incoming_link(struct context *c); +void read_incoming_link(struct context *c, struct link_socket *sock); /** * Starts processing a packet read from the external network interface. @@ -197,10 +199,11 @@ * * If an error occurs, it is logged and the packet is dropped. * - * @param c - The context structure of the VPN tunnel associated with the - * packet. + * @param c The context structure of the VPN tunnel associated with the + * packet. + * @param sock The socket to be used to send the packet. */ -void process_outgoing_link(struct context *c); +void process_outgoing_link(struct context *c, struct link_socket *sock); /**************************************************************************/ diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c index c002a38..1b956f4 100644 --- a/src/openvpn/mtcp.c +++ b/src/openvpn/mtcp.c @@ -483,7 +483,7 @@ ASSERT(mi); ASSERT(mi->context.c2.link_socket); set_prefix(mi); - read_incoming_link(&mi->context); + read_incoming_link(&mi->context, mi->context.c2.link_socket); clear_prefix(); if (!IS_SIG(&mi->context)) { diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 268b430..5fbd7b0 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -317,7 +317,7 @@ msg_set_prefix("Connection Attempt"); m->top.c2.to_link = m->hmac_reply; m->top.c2.to_link_addr = m->hmac_reply_dest; - process_outgoing_link(&m->top); + process_outgoing_link(&m->top, m->top.c2.link_socket); m->hmac_reply_dest = NULL; } } @@ -380,7 +380,7 @@ /* Incoming data on UDP port */ else if (status & SOCKET_READ) { - read_incoming_link(&m->top); + read_incoming_link(&m->top, m->top.c2.link_socket); if (!IS_SIG(&m->top)) { multi_process_incoming_link(m, NULL, mpp_flags); diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h index 1b99ef7..f386a3b 100644 --- a/src/openvpn/multi.h +++ b/src/openvpn/multi.h @@ -683,7 +683,7 @@ { bool ret = true; set_prefix(mi); - process_outgoing_link(&mi->context); + process_outgoing_link(&mi->context, mi->context.c2.link_socket); ret = multi_process_post(m, mi, mpp_flags); clear_prefix(); return ret; diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index 16147b7..1db5422 100644 --- a/src/openvpn/openvpn.c +++ b/src/openvpn/openvpn.c @@ -91,7 +91,7 @@ } /* process the I/O which triggered select */ - process_io(c); + process_io(c, c->c2.link_socket); P2P_CHECK_SIG(); perf_pop(); diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index cf04090..efd742c 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -969,12 +969,12 @@ } bool -link_socket_update_flags(struct link_socket *ls, unsigned int sockflags) +link_socket_update_flags(struct link_socket *sock, unsigned int sockflags) { - if (ls && socket_defined(ls->sd)) + if (sock && socket_defined(sock->sd)) { - ls->sockflags |= sockflags; - return socket_set_flags(ls->sd, ls->sockflags); + sock->sockflags |= sockflags; + return socket_set_flags(sock->sd, sock->sockflags); } else { @@ -983,13 +983,13 @@ } void -link_socket_update_buffer_sizes(struct link_socket *ls, int rcvbuf, int sndbuf) +link_socket_update_buffer_sizes(struct link_socket *sock, int rcvbuf, int sndbuf) { - if (ls && socket_defined(ls->sd)) + if (sock && socket_defined(sock->sd)) { - ls->socket_buffer_sizes.sndbuf = sndbuf; - ls->socket_buffer_sizes.rcvbuf = rcvbuf; - socket_set_buffers(ls->sd, &ls->socket_buffer_sizes, true); + sock->socket_buffer_sizes.sndbuf = sndbuf; + sock->socket_buffer_sizes.rcvbuf = rcvbuf; + socket_set_buffers(sock->sd, &sock->socket_buffer_sizes, true); } } @@ -1831,6 +1831,7 @@ sock->sd = SOCKET_UNDEFINED; sock->ctrl_sd = SOCKET_UNDEFINED; sock->ev_arg.type = EVENT_ARG_LINK_SOCKET; + sock->ev_arg.u.sock = sock; return sock; } diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h index c152ab0..566efee 100644 --- a/src/openvpn/socket.h +++ b/src/openvpn/socket.h @@ -461,9 +461,9 @@ void setenv_trusted(struct env_set *es, const struct link_socket_info *info); -bool link_socket_update_flags(struct link_socket *ls, unsigned int sockflags); +bool link_socket_update_flags(struct link_socket *sock, unsigned int sockflags); -void link_socket_update_buffer_sizes(struct link_socket *ls, int rcvbuf, int sndbuf); +void link_socket_update_buffer_sizes(struct link_socket *sock, int rcvbuf, int sndbuf); /* * Low-level functions @@ -1225,13 +1225,13 @@ * Extract TOS bits. Assumes that ipbuf is a valid IPv4 packet. */ static inline void -link_socket_extract_tos(struct link_socket *ls, const struct buffer *ipbuf) +link_socket_extract_tos(struct link_socket *sock, const struct buffer *ipbuf) { - if (ls && ipbuf) + if (sock && ipbuf) { struct openvpn_iphdr *iph = (struct openvpn_iphdr *) BPTR(ipbuf); - ls->ptos = iph->tos; - ls->ptos_defined = true; + sock->ptos = iph->tos; + sock->ptos_defined = true; } } @@ -1240,11 +1240,11 @@ * from tunnel packet. */ static inline void -link_socket_set_tos(struct link_socket *ls) +link_socket_set_tos(struct link_socket *sock) { - if (ls && ls->ptos_defined) + if (sock && sock->ptos_defined) { - setsockopt(ls->sd, IPPROTO_IP, IP_TOS, (const void *)&ls->ptos, sizeof(ls->ptos)); + setsockopt(sock->sd, IPPROTO_IP, IP_TOS, (const void *)&sock->ptos, sizeof(sock->ptos)); } } @@ -1255,50 +1255,50 @@ */ static inline bool -socket_read_residual(const struct link_socket *s) +socket_read_residual(const struct link_socket *sock) { - return s && s->stream_buf.residual_fully_formed; + return sock && sock->stream_buf.residual_fully_formed; } static inline event_t -socket_event_handle(const struct link_socket *s) +socket_event_handle(const struct link_socket *sock) { #ifdef _WIN32 - return &s->rw_handle; + return &sock->rw_handle; #else - return s->sd; + return sock->sd; #endif } -event_t socket_listen_event_handle(struct link_socket *s); +event_t socket_listen_event_handle(struct link_socket *sock); unsigned int -socket_set(struct link_socket *s, +socket_set(struct link_socket *sock, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent); static inline void -socket_set_listen_persistent(struct link_socket *s, +socket_set_listen_persistent(struct link_socket *sock, struct event_set *es, void *arg) { - if (s && !s->listen_persistent_queued) + if (sock && !sock->listen_persistent_queued) { - event_ctl(es, socket_listen_event_handle(s), EVENT_READ, arg); - s->listen_persistent_queued = true; + event_ctl(es, socket_listen_event_handle(sock), EVENT_READ, arg); + sock->listen_persistent_queued = true; } } static inline void -socket_reset_listen_persistent(struct link_socket *s) +socket_reset_listen_persistent(struct link_socket *sock) { #ifdef _WIN32 - reset_net_event_win32(&s->listen_handle, s->sd); + reset_net_event_win32(&sock->listen_handle, sock->sd); #endif } -const char *socket_stat(const struct link_socket *s, unsigned int rwflags, struct gc_arena *gc); +const char *socket_stat(const struct link_socket *sock, unsigned int rwflags, struct gc_arena *gc); #endif /* SOCKET_H */