wireguard.lists.zx2c4.com archive mirror
 help / color / mirror / Atom feed
From: mikma.wg@lists.m7n.se
To: WireGuard mailing list <wireguard@lists.zx2c4.com>
Subject: [PATCH] wireguard-tools: embeddable-wg-library: add named wg_endpoint union
Date: Sun, 10 Oct 2021 23:19:22 +0200	[thread overview]
Message-ID: <b28e05e1-4209-8b82-1b00-e963b2e8fc85@m7n.se> (raw)

[-- Attachment #1: Type: text/plain, Size: 135 bytes --]

Hello,

It would be useful to have a named wg_endpoint type in the embeddable wg 
library. It's added by the attached patch.

/Mikael


[-- Attachment #2: 0001-embeddable-wg-library-add-named-wg_endpoint-union.patch --]
[-- Type: text/x-patch, Size: 1312 bytes --]

From 62b35cb221af7208399fced86660585080c688f5 Mon Sep 17 00:00:00 2001
From: Mikael Magnusson <mikma@users.sourceforge.net>
Date: Sat, 7 Nov 2020 13:32:56 +0100
Subject: [PATCH] embeddable-wg-library: add named wg_endpoint union

Define wg_endpoint as a named union to allow users of the emeddable
library to use the type in function arguments, variables etc.

Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
---
 contrib/embeddable-wg-library/wireguard.h | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/contrib/embeddable-wg-library/wireguard.h b/contrib/embeddable-wg-library/wireguard.h
index fbd8765..328fcb4 100644
--- a/contrib/embeddable-wg-library/wireguard.h
+++ b/contrib/embeddable-wg-library/wireguard.h
@@ -40,17 +40,19 @@ enum wg_peer_flags {
 	WGPEER_HAS_PERSISTENT_KEEPALIVE_INTERVAL = 1U << 4
 };
 
+typedef union wg_endpoint {
+	struct sockaddr addr;
+	struct sockaddr_in addr4;
+	struct sockaddr_in6 addr6;
+} wg_endpoint;
+
 typedef struct wg_peer {
 	enum wg_peer_flags flags;
 
 	wg_key public_key;
 	wg_key preshared_key;
 
-	union {
-		struct sockaddr addr;
-		struct sockaddr_in addr4;
-		struct sockaddr_in6 addr6;
-	} endpoint;
+	wg_endpoint endpoint;
 
 	struct timespec64 last_handshake_time;
 	uint64_t rx_bytes, tx_bytes;
-- 
2.25.1


             reply	other threads:[~2021-10-10 21:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-10 21:19 mikma.wg [this message]
2021-10-14  3:48 ` Eiji Tanioka
2021-10-22 19:26 ` Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b28e05e1-4209-8b82-1b00-e963b2e8fc85@m7n.se \
    --to=mikma.wg@lists.m7n.se \
    --cc=wireguard@lists.zx2c4.com \
    --subject='Re: [PATCH] wireguard-tools: embeddable-wg-library: add named wg_endpoint union' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).