diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-22 20:30:34 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-22 20:30:34 +0200 |
commit | 2d8170c259fd234c9608df2481f8f5a93f4fe387 (patch) | |
tree | e06cd29ebf63102385d6555da1c5f731eddf43f3 /src/uapi.h | |
parent | d23fe2901d9877a60cd219d0d49df01aa07f5940 (diff) |
tools: Use seqpacket instead of dgram
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/uapi.h')
-rw-r--r-- | src/uapi.h | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -129,4 +129,20 @@ struct wgdevice { }; }; +/* These are simply for convenience in iterating. It allows you to write something like: + * + * for_each_wgpeer(device, peer, i) { + * for_each_wgipmask(peer, ipmask, j) { + * do_something_with_ipmask(ipmask); + * } + * } + */ +#define for_each_wgpeer(__dev, __peer, __i) for ((__i) = 0, (__peer) = (typeof(__peer))((uint8_t *)(__dev) + sizeof(struct wgdevice)); \ + (__i) < (__dev)->num_peers; \ + ++(__i), (__peer) = (typeof(__peer))((uint8_t *)(__peer) + sizeof(struct wgpeer) + (sizeof(struct wgipmask) * (__peer)->num_ipmasks))) + +#define for_each_wgipmask(__peer, __ipmask, __i) for ((__i) = 0, (__ipmask) = (typeof(__ipmask))((uint8_t *)(__peer) + sizeof(struct wgpeer)); \ + (__i) < (__peer)->num_ipmasks; \ + ++(__i), (__ipmask) = (typeof(__ipmask))((uint8_t *)(__ipmask) + sizeof(struct wgipmask))) + #endif |