* [PATCH] contrib: handles peer version in embed-wireguard
@ 2018-12-03 23:15 Gawen ARAB
2018-12-05 15:59 ` Gawen ARAB
2018-12-07 4:36 ` Jason A. Donenfeld
0 siblings, 2 replies; 3+ messages in thread
From: Gawen ARAB @ 2018-12-03 23:15 UTC (permalink / raw)
To: wireguard
Commit bc84ba3a inserted a peer version placeholder. Embeddable
wireguard did not handle the flag WGPEER_A_PROTOCOL_VERSION and printed
the following warning:
Warning: one or more unrecognized netlink attributes
This commit adds the field 'protocol_version' to the structure
'wg_peer'. It is equal to 0 if no protocol version were defined.
---
contrib/examples/embeddable-wg-library/wireguard.c | 5 +++++
contrib/examples/embeddable-wg-library/wireguard.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/contrib/examples/embeddable-wg-library/wireguard.c
b/contrib/examples/embeddable-wg-library/wireguard.c
index f0bdb5f..9610c50 100644
--- a/contrib/examples/embeddable-wg-library/wireguard.c
+++ b/contrib/examples/embeddable-wg-library/wireguard.c
@@ -66,6 +66,7 @@ enum wgpeer_attribute {
WGPEER_A_RX_BYTES,
WGPEER_A_TX_BYTES,
WGPEER_A_ALLOWEDIPS,
+ WGPEER_A_PROTOCOL_VERSION,
__WGPEER_A_LAST
};
@@ -1326,6 +1327,10 @@ static int parse_peer(const struct nlattr
*attr, void *data)
break;
case WGPEER_A_ALLOWEDIPS:
return mnl_attr_parse_nested(attr, parse_allowedips, peer);
+ case WGPEER_A_PROTOCOL_VERSION:
+ if (!mnl_attr_validate(attr, MNL_TYPE_U32))
+ peer->protocol_version = mnl_attr_get_u32(attr);
+ break;
default:
warn_unrecognized("netlink");
}
diff --git a/contrib/examples/embeddable-wg-library/wireguard.h
b/contrib/examples/embeddable-wg-library/wireguard.h
index e9210a4..2cee9ac 100644
--- a/contrib/examples/embeddable-wg-library/wireguard.h
+++ b/contrib/examples/embeddable-wg-library/wireguard.h
@@ -49,6 +49,7 @@ typedef struct wg_peer {
struct timespec last_handshake_time;
uint64_t rx_bytes, tx_bytes;
uint16_t persistent_keepalive_interval;
+ uint32_t protocol_version;
struct wg_allowedip *first_allowedip, *last_allowedip;
struct wg_peer *next_peer;
--
2.19.2
_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] contrib: handles peer version in embed-wireguard
2018-12-03 23:15 [PATCH] contrib: handles peer version in embed-wireguard Gawen ARAB
@ 2018-12-05 15:59 ` Gawen ARAB
2018-12-07 4:36 ` Jason A. Donenfeld
1 sibling, 0 replies; 3+ messages in thread
From: Gawen ARAB @ 2018-12-05 15:59 UTC (permalink / raw)
To: wireguard
[-- Attachment #1.1: Type: text/plain, Size: 2019 bytes --]
Commit bc84ba3a inserted a peer version placeholder. Embeddable
wireguard did not handle the flag WGPEER_A_PROTOCOL_VERSION and printed
the following warning:
Warning: one or more unrecognized netlink attributes
This commit adds the field 'protocol_version' to the structure
'wg_peer'. It is equal to 0 if no protocol version were defined.
---
contrib/examples/embeddable-wg-library/wireguard.c | 5 +++++
contrib/examples/embeddable-wg-library/wireguard.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/contrib/examples/embeddable-wg-library/wireguard.c
b/contrib/examples/embeddable-wg-library/wireguard.c
index f0bdb5f..9610c50 100644
--- a/contrib/examples/embeddable-wg-library/wireguard.c
+++ b/contrib/examples/embeddable-wg-library/wireguard.c
@@ -66,6 +66,7 @@ enum wgpeer_attribute {
WGPEER_A_RX_BYTES,
WGPEER_A_TX_BYTES,
WGPEER_A_ALLOWEDIPS,
+ WGPEER_A_PROTOCOL_VERSION,
__WGPEER_A_LAST
};
@@ -1326,6 +1327,10 @@ static int parse_peer(const struct nlattr
*attr, void *data)
break;
case WGPEER_A_ALLOWEDIPS:
return mnl_attr_parse_nested(attr, parse_allowedips, peer);
+ case WGPEER_A_PROTOCOL_VERSION:
+ if (!mnl_attr_validate(attr, MNL_TYPE_U32))
+ peer->protocol_version = mnl_attr_get_u32(attr);
+ break;
default:
warn_unrecognized("netlink");
}
diff --git a/contrib/examples/embeddable-wg-library/wireguard.h
b/contrib/examples/embeddable-wg-library/wireguard.h
index e9210a4..2cee9ac 100644
--- a/contrib/examples/embeddable-wg-library/wireguard.h
+++ b/contrib/examples/embeddable-wg-library/wireguard.h
@@ -49,6 +49,7 @@ typedef struct wg_peer {
struct timespec last_handshake_time;
uint64_t rx_bytes, tx_bytes;
uint16_t persistent_keepalive_interval;
+ uint32_t protocol_version;
struct wg_allowedip *first_allowedip, *last_allowedip;
struct wg_peer *next_peer;
--
2.19.2
[-- Attachment #1.2: Type: text/html, Size: 2518 bytes --]
[-- Attachment #2: Type: text/plain, Size: 148 bytes --]
_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] contrib: handles peer version in embed-wireguard
2018-12-03 23:15 [PATCH] contrib: handles peer version in embed-wireguard Gawen ARAB
2018-12-05 15:59 ` Gawen ARAB
@ 2018-12-07 4:36 ` Jason A. Donenfeld
1 sibling, 0 replies; 3+ messages in thread
From: Jason A. Donenfeld @ 2018-12-07 4:36 UTC (permalink / raw)
To: g; +Cc: WireGuard mailing list
Thanks. Fixed there in the same way it was earlier in src/tools/.
_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-12-07 4:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-03 23:15 [PATCH] contrib: handles peer version in embed-wireguard Gawen ARAB
2018-12-05 15:59 ` Gawen ARAB
2018-12-07 4:36 ` Jason A. Donenfeld
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).