aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/uapi.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-01-09 19:47:29 -0800
committerJason A. Donenfeld <Jason@zx2c4.com>2017-01-10 05:36:43 +0100
commitca3f6fa1dd692fae949f090a14f81d3ef0f424d2 (patch)
tree03b68417877028135c6960bf9b7fc98cc08b1fc8 /src/uapi.h
parenttools: ipc: read from socket incrementally (diff)
downloadwireguard-monolithic-historical-ca3f6fa1dd692fae949f090a14f81d3ef0f424d2.tar.xz
wireguard-monolithic-historical-ca3f6fa1dd692fae949f090a14f81d3ef0f424d2.zip
uapi: use flag instead of C bitfield for portability
Diffstat (limited to 'src/uapi.h')
-rw-r--r--src/uapi.h31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/uapi.h b/src/uapi.h
index cd4b86b..e5d7368 100644
--- a/src/uapi.h
+++ b/src/uapi.h
@@ -48,13 +48,13 @@
* struct wgipmask
* struct wgpeer { .num_ipmasks = 0 }
*
- * If `wgdevice->replace_peer_list` is true, removes all peers of device before adding new ones.
- * If `wgpeer->remove_me` is true, the peer identified by `wgpeer->public_key` is removed.
- * If `wgpeer->replace_ipmasks` is true, removes all ipmasks before adding new ones.
+ * If `wgdevice->flags & WGDEVICE_REPLACE_PEERS` is true, removes all peers of device before adding new ones.
+ * If `wgpeer->flags & WGPEER_REMOVE_ME` is true, the peer identified by `wgpeer->public_key` is removed.
+ * If `wgpeer->flags & WGPEER_REPLACE_IPMASKS` is true, removes all ipmasks before adding new ones.
* If `wgdevice->private_key` is filled with zeros, no action is taken on the private key.
* If `wgdevice->preshared_key` is filled with zeros, no action is taken on the pre-shared key.
- * If `wgdevice->remove_private_key` is true, the private key is removed.
- * If `wgdevice->remove_preshared_key` is true, the pre-shared key is removed.
+ * If `wgdevice->flags & WGDEVICE_REMOVE_PRIVATE_KEY` is true, the private key is removed.
+ * If `wgdevice->flags & WGDEVICE_REMOVE_PRESHARED_KEY` is true, the pre-shared key is removed.
*
* Returns 0 on success, or -errno if an error occurred.
*/
@@ -97,34 +97,37 @@ struct wgipmask {
__u8 cidr;
};
+enum {
+ WGPEER_REMOVE_ME = (1 << 0),
+ WGPEER_REPLACE_IPMASKS = (1 << 1)
+};
struct wgpeer {
__u8 public_key[WG_KEY_LEN]; /* Get/Set */
+ __u32 flags; /* Set */
struct sockaddr_storage endpoint; /* Get/Set */
struct timeval last_handshake_time; /* Get */
__u64 rx_bytes, tx_bytes; /* Get */
-
- __u32 remove_me : 1; /* Set */
- __u32 replace_ipmasks : 1; /* Set */
+ __u16 persistent_keepalive_interval; /* Get/Set -- 0 = off, 0xffff = unset */
__u16 num_ipmasks; /* Get/Set */
- __u16 persistent_keepalive_interval; /* Get/Set -- 0 = off, 0xffff = unset */
};
+enum {
+ WGDEVICE_REPLACE_PEERS = (1 << 0),
+ WGDEVICE_REMOVE_PRIVATE_KEY = (1 << 1),
+ WGDEVICE_REMOVE_PRESHARED_KEY = (1 << 2)
+};
struct wgdevice {
char interface[IFNAMSIZ]; /* Get */
+ __u32 flags; /* Set */
__u8 public_key[WG_KEY_LEN]; /* Get */
__u8 private_key[WG_KEY_LEN]; /* Get/Set */
__u8 preshared_key[WG_KEY_LEN]; /* Get/Set */
-
__u16 port; /* Get/Set */
- __u32 replace_peer_list : 1; /* Set */
- __u32 remove_private_key : 1; /* Set */
- __u32 remove_preshared_key : 1; /* Set */
-
union {
__u16 num_peers; /* Get/Set */
__u64 peers_size; /* Get */