From patchwork Wed Oct 23 08:34:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 3904 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:6bd6:b0:5b9:581e:f939 with SMTP id c22csp238926max; Wed, 23 Oct 2024 01:35:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWPA3yby1Mp0gh0Re9OpwnW9O8QPKMAKWGswOcegc+IkFnO3YfDinGmIzTzwNHFtddlEQQsL58nfdk=@openvpn.net X-Google-Smtp-Source: AGHT+IEHevJfh0S8iSyGJ0I+w4AHHzYpn4EnHy2NsNjeTgZhlEjS/y0QDPNzGba/ml62Hr6RP0YB X-Received: by 2002:a05:6602:1603:b0:835:4b2a:e52b with SMTP id ca18e2360f4ac-83af61f7668mr187580939f.10.1729672508732; Wed, 23 Oct 2024 01:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729672508; cv=none; d=google.com; s=arc-20240605; b=gDJzVF+LK5at6MMR+fHKFlDJIy/b3LReS8RF/qVJnKBW+BtRpKYaIc+Z+C2aObzJo0 QI8QRxPX80NkwaWKPUpfR5bcfrj9bh3uoQqootNTXjkquIqPnEZNhRDBG09wjEQkqoQN HYwF6iBV1qApMfqizXxfKqHg2QSGuPmB2/3TVLuFN3JKIxs22u9Qe+xNisp01Tpl1AAK IUtHHfIA6pMW4wTE79UUV65LaBcG4yaTtyRKxX24E+hPOyoHpuuEZlJzHJE/WJgYISSW A7w3UBYc+8utOF8UVPNGHMcK+/7I8uw8POBOUNmF/9i7ixu68xGKTbVyhczPRbkRcmK+ cxEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding: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; bh=GIDDp35s4uS4F2BmBN5pGpCVQVxLv+t0xfa3tf0vPS4=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=E5Je6sgnm/LI6P4ppIo5QAYMWfgO5nQdMRMMBetagnJIh+rri0WFD7NiBDGKFe3HB1 vCMiJotWAdjbMxKGbDVcFG2pF6KeyFJ8X7ARdCYKWpMdbtiCD5AEm3NrNgXP3DBLQX69 T2enyXeb8t1kn50QtWzDeTClUdQOogGGzQJqVNxMO+eV7ZpiFw7NGGiJYMlkcPYj50M2 8i25VEGNmogTdfIj2M0KNa8d/i6O98TKX+yDgwBnzdmWCTNR1Ra99qb4q658Ugbu8/Ok I/XQW4lUZeGwZIjT+qZl9CQqY9k/aw+Lu7pvQvaBCWu69jzbFhmBFjpwsjxYPmkG28Ps hehA==; 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=GI1oBmJV; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=HVLsAEwH; 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=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id ca18e2360f4ac-83ad1dbc989si340763339f.67.2024.10.23.01.35.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Oct 2024 01:35:08 -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=GI1oBmJV; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=HVLsAEwH; 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=muc.de 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 1t3WpX-0002qx-7A; Wed, 23 Oct 2024 08:34:59 +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 1t3WpW-0002qr-46 for openvpn-devel@lists.sourceforge.net; Wed, 23 Oct 2024 08:34:58 +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:To:From:Sender:Reply-To:Cc: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=VCfxyI30d4xa3hcoA44v135OYwigoEH+hkTqbrj0UwA=; b=GI1oBmJV0RMRa2DXJ+ofavWZAb nI2kQZ92sNxMrC7xzePR7kDKqZ0lykaE376RBi4CgZ1rm/AWf3F+aAJBTZySAqAYPSghAMxnR33bQ EdO1CHpfo03zV4nwT+Qiik+616dq6iYmB7zfZjHoTgepJRetlSUIfBEkXSbExUfGzZR4=; 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:To:From:Sender:Reply-To:Cc: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=VCfxyI30d4xa3hcoA44v135OYwigoEH+hkTqbrj0UwA=; b=HVLsAEwHvN9Ci0NKp0l17Sq8eZ lZWNgAqW/hqdDBImhntjPXoOPxtdXFAbsAC/xoNJysKSvMicxsH3eXwqgCi9RL+DGXrIMCzzsyB2U jTgNGMEUMLcB2CC+o0tVdBnfJvGgHbtgcD4uDnD19sZYcpBe0iNfBSxzylFqMaGa1UYE=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1t3WpU-0006Jj-Ho for openvpn-devel@lists.sourceforge.net; Wed, 23 Oct 2024 08:34:58 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 49N8Yj78028020 for ; Wed, 23 Oct 2024 10:34:45 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 49N8YiTv028019 for openvpn-devel@lists.sourceforge.net; Wed, 23 Oct 2024 10:34:44 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 23 Oct 2024 10:34:44 +0200 Message-ID: <20241023083444.27951-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: -0.0 (/) 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.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-Headers-End: 1t3WpU-0006Jj-Ho Subject: [Openvpn-devel] [PATCH v5] 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: , 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?1813693080631750999?= 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. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/758 This mail reflects revision 5 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 */