Development discussion of WireGuard
 help / color / mirror / Atom feed
From: SMTP: namiltd@poczta.onet.pl;
To: wireguard@lists.zx2c4.com
Subject: [PATCH] centos 6 compatibility
Date: Sun, 3 Mar 2019 14:30:17 +0100	[thread overview]
Message-ID: <dd1d1bde-dd6b-6f36-e08f-3552ee0686a2@poczta.onet.pl> (raw)

---
 src/crypto/zinc/blake2s/blake2s.c | 17 +++++++++++++++++
 src/socket.c                      |  7 +++++++
 2 files changed, 24 insertions(+)

diff --git a/src/crypto/zinc/blake2s/blake2s.c b/src/crypto/zinc/blake2s/blake2s.c
index b881db0..60b7763 100644
--- a/src/crypto/zinc/blake2s/blake2s.c
+++ b/src/crypto/zinc/blake2s/blake2s.c
@@ -19,9 +19,16 @@
 #include <linux/init.h>
 #include <linux/bug.h>
 #include <asm/unaligned.h>
+#define GCC_VERSION (__GNUC__ * 10000 \
+		    + __GNUC_MINOR__ * 100 \
+		    + __GNUC_PATCHLEVEL__)
 
+#if GCC_VERSION > 40407
 typedef union {
 	struct {
+#else
+typedef struct {
+#endif
 		u8 digest_length;
 		u8 key_length;
 		u8 fanout;
@@ -33,8 +40,10 @@ typedef union {
 		u8 inner_length;
 		u8 salt[8];
 		u8 personal[8];
+#if GCC_VERSION > 40407
 	};
 	__le32 words[8];
+#endif
 } __packed blake2s_param;
 
 static const u32 blake2s_iv[8] = {
@@ -74,9 +83,17 @@ static inline void blake2s_init_param(struct blake2s_state *state,
 {
 	int i;
 
+#if GCC_VERSION <= 40407
+	const __le32 *words;
+	words = (const __le32 *)param;
+#endif
 	memset(state, 0, sizeof(*state));
 	for (i = 0; i < 8; ++i)
+#if GCC_VERSION > 40407
 		state->h[i] = blake2s_iv[i] ^ le32_to_cpu(param->words[i]);
+#else
+		state->h[i] = blake2s_iv[i] ^ le32_to_cpu(words[i]);
+#endif
 }
 
 void blake2s_init(struct blake2s_state *state, const size_t outlen)
diff --git a/src/socket.c b/src/socket.c
index 652d798..dfc98d3 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -16,6 +16,9 @@
 #include <linux/inetdevice.h>
 #include <net/udp_tunnel.h>
 #include <net/ipv6.h>
+#define GCC_VERSION (__GNUC__ * 10000 \
+		    + __GNUC_MINOR__ * 100 \
+		    + __GNUC_PATCHLEVEL__)
 
 static int send4(struct wg_device *wg, struct sk_buff *skb,
 		 struct endpoint *endpoint, u8 ds, struct dst_cache *cache)
@@ -363,7 +366,9 @@ int wg_socket_init(struct wg_device *wg, u16 port)
 	struct socket *new4 = NULL, *new6 = NULL;
 	struct udp_port_cfg port4 = {
 		.family = AF_INET,
+#if GCC_VERSION > 40407
 		.local_ip.s_addr = htonl(INADDR_ANY),
+#endif
 		.local_udp_port = htons(port),
 		.use_udp_checksums = true
 	};
@@ -371,7 +376,9 @@ int wg_socket_init(struct wg_device *wg, u16 port)
 	int retries = 0;
 	struct udp_port_cfg port6 = {
 		.family = AF_INET6,
+#if GCC_VERSION > 40407
 		.local_ip6 = IN6ADDR_ANY_INIT,
+#endif
 		.use_udp6_tx_checksums = true,
 		.use_udp6_rx_checksums = true,
 		.ipv6_v6only = true
-- 
2.18.0.windows.1

_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

             reply	other threads:[~2019-03-20 22:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-03 13:30 namiltd [this message]
2019-03-27 14:48 ` Mieczysław Nalewaj
2019-03-29 14:36   ` Mieczysław Nalewaj

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=dd1d1bde-dd6b-6f36-e08f-3552ee0686a2@poczta.onet.pl \
    --to=namiltd@poczta.onet.pl \
    --cc=wireguard@lists.zx2c4.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).