wireguard.lists.zx2c4.com archive mirror
 help / color / mirror / Atom feed
From: Gawen ARAB <g@wenarab.com>
To: wireguard@lists.zx2c4.com
Subject: [PATCH] contrib: handles peer version in embed-wireguard
Date: Tue, 4 Dec 2018 00:15:46 +0100	[thread overview]
Message-ID: <CADjxVNr0PnZm8ckYtSToOrgkn5DkJUAEqMKZyKULN8avNRcfQQ@mail.gmail.com> (raw)

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

             reply	other threads:[~2018-12-06 23:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-03 23:15 Gawen ARAB [this message]
2018-12-05 15:59 ` [PATCH] contrib: handles peer version in embed-wireguard Gawen ARAB
2018-12-07  4:36 ` 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=CADjxVNr0PnZm8ckYtSToOrgkn5DkJUAEqMKZyKULN8avNRcfQQ@mail.gmail.com \
    --to=g@wenarab.com \
    --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).