[PATCH] contrib: handles peer version in embed-wireguard
Gawen ARAB
g at wenarab.com
Wed Dec 5 16:59:06 CET 2018
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/wireguard/attachments/20181205/5f050592/attachment.html>
More information about the WireGuard
mailing list