Skip to content

Commit

Permalink
embeddable-wg-library: add named wg_endpoint union
Browse files Browse the repository at this point in the history
Define wg_endpoint as a named union to allow users of the emeddable
library to use the type in function arguments, variables etc.

Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
  • Loading branch information
mikma authored and zx2c4 committed Oct 22, 2021
1 parent 1ee37b8 commit b906ecb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions contrib/embeddable-wg-library/wireguard.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ enum wg_peer_flags {
WGPEER_HAS_PERSISTENT_KEEPALIVE_INTERVAL = 1U << 4
};

typedef union wg_endpoint {
struct sockaddr addr;
struct sockaddr_in addr4;
struct sockaddr_in6 addr6;
} wg_endpoint;

typedef struct wg_peer {
enum wg_peer_flags flags;

wg_key public_key;
wg_key preshared_key;

union {
struct sockaddr addr;
struct sockaddr_in addr4;
struct sockaddr_in6 addr6;
} endpoint;
wg_endpoint endpoint;

struct timespec64 last_handshake_time;
uint64_t rx_bytes, tx_bytes;
Expand Down

0 comments on commit b906ecb

Please sign in to comment.