diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2018-12-16 00:03:59 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2019-04-02 00:27:38 +0200 |
commit | 21f7709a81622ff0e1c0242386b08d011a6a63b5 (patch) | |
tree | f3763226822cbbb2eeb069f83ce407dcc4172d1d | |
parent | 7f955015c45c8193ca11ffca021bfbe5ae7877fe (diff) |
wireguard-lib: Update library
-rw-r--r-- | sysdep/linux/wireguard.c | 66 |
1 files changed, 26 insertions, 40 deletions
diff --git a/sysdep/linux/wireguard.c b/sysdep/linux/wireguard.c index b8368e9f..370b3dae 100644 --- a/sysdep/linux/wireguard.c +++ b/sysdep/linux/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 }; @@ -87,39 +88,39 @@ enum wgallowedip_attribute { #define MNL_ATTR_HDRLEN MNL_ALIGN(sizeof(struct nlattr)) enum mnl_attr_data_type { - MNL_TYPE_UNSPEC, - MNL_TYPE_U8, - MNL_TYPE_U16, - MNL_TYPE_U32, - MNL_TYPE_U64, - MNL_TYPE_STRING, - MNL_TYPE_FLAG, - MNL_TYPE_MSECS, - MNL_TYPE_NESTED, - MNL_TYPE_NESTED_COMPAT, - MNL_TYPE_NUL_STRING, - MNL_TYPE_BINARY, - MNL_TYPE_MAX, + MNL_TYPE_UNSPEC, + MNL_TYPE_U8, + MNL_TYPE_U16, + MNL_TYPE_U32, + MNL_TYPE_U64, + MNL_TYPE_STRING, + MNL_TYPE_FLAG, + MNL_TYPE_MSECS, + MNL_TYPE_NESTED, + MNL_TYPE_NESTED_COMPAT, + MNL_TYPE_NUL_STRING, + MNL_TYPE_BINARY, + MNL_TYPE_MAX, }; #define mnl_attr_for_each(attr, nlh, offset) \ - for ((attr) = mnl_nlmsg_get_payload_offset((nlh), (offset)); \ - mnl_attr_ok((attr), (char *)mnl_nlmsg_get_payload_tail(nlh) - (char *)(attr)); \ - (attr) = mnl_attr_next(attr)) + for ((attr) = mnl_nlmsg_get_payload_offset((nlh), (offset)); \ + mnl_attr_ok((attr), (char *)mnl_nlmsg_get_payload_tail(nlh) - (char *)(attr)); \ + (attr) = mnl_attr_next(attr)) #define mnl_attr_for_each_nested(attr, nest) \ - for ((attr) = mnl_attr_get_payload(nest); \ - mnl_attr_ok((attr), (char *)mnl_attr_get_payload(nest) + mnl_attr_get_payload_len(nest) - (char *)(attr)); \ - (attr) = mnl_attr_next(attr)) + for ((attr) = mnl_attr_get_payload(nest); \ + mnl_attr_ok((attr), (char *)mnl_attr_get_payload(nest) + mnl_attr_get_payload_len(nest) - (char *)(attr)); \ + (attr) = mnl_attr_next(attr)) #define mnl_attr_for_each_payload(payload, payload_size) \ - for ((attr) = (payload); \ - mnl_attr_ok((attr), (char *)(payload) + payload_size - (char *)(attr)); \ - (attr) = mnl_attr_next(attr)) + for ((attr) = (payload); \ + mnl_attr_ok((attr), (char *)(payload) + payload_size - (char *)(attr)); \ + (attr) = mnl_attr_next(attr)) -#define MNL_CB_ERROR -1 -#define MNL_CB_STOP 0 -#define MNL_CB_OK 1 +#define MNL_CB_ERROR -1 +#define MNL_CB_STOP 0 +#define MNL_CB_OK 1 typedef int (*mnl_attr_cb_t)(const struct nlattr *attr, void *data); typedef int (*mnl_cb_t)(const struct nlmsghdr *nlh, void *data); @@ -903,15 +904,6 @@ static int add_next_to_inflatable_buffer(struct inflatable_buffer *buffer) return 0; } -static void warn_unrecognized(const char *which) -{ - static bool once = false; - if (once) - return; - once = true; - fprintf(stderr, "Warning: one or more unrecognized %s attributes\n", which); -} - static int parse_linkinfo(const struct nlattr *attr, void *data) { struct inflatable_buffer *buffer = data; @@ -1233,8 +1225,6 @@ static int parse_allowedip(const struct nlattr *attr, void *data) if (!mnl_attr_validate(attr, MNL_TYPE_U8)) allowedip->cidr = mnl_attr_get_u8(attr); break; - default: - warn_unrecognized("netlink"); } return MNL_CB_OK; @@ -1326,8 +1316,6 @@ static int parse_peer(const struct nlattr *attr, void *data) break; case WGPEER_A_ALLOWEDIPS: return mnl_attr_parse_nested(attr, parse_allowedips, peer); - default: - warn_unrecognized("netlink"); } return MNL_CB_OK; @@ -1396,8 +1384,6 @@ static int parse_device(const struct nlattr *attr, void *data) break; case WGDEVICE_A_PEERS: return mnl_attr_parse_nested(attr, parse_peers, device); - default: - warn_unrecognized("netlink"); } return MNL_CB_OK; |