summaryrefslogtreecommitdiffstats
path: root/src/wireguard.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wireguard.h')
-rw-r--r--src/wireguard.h51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/wireguard.h b/src/wireguard.h
index ede34039edd..80b35ac6df4 100644
--- a/src/wireguard.h
+++ b/src/wireguard.h
@@ -20,7 +20,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/timeout.h>
-#include <sys/rwlock.h>
+#include <sys/mutex.h>
#include <sys/fixedmap.h>
#include <sys/antireplay.h>
@@ -144,14 +144,14 @@ struct wg_timers {
};
struct wg_session {
- uint32_t s_local_id; /* Static */
- uint32_t s_remote_id; /* Static */
- struct wg_peer *s_peer; /* Static */
- struct timespec s_created; /* Static */
- struct refcnt s_refcnt; /* Atomic */
-
- /* All protected by s_lock */
- struct rwlock s_lock;
+ /* Static */
+ uint32_t s_local_id;
+ uint32_t s_remote_id;
+ struct wg_peer *s_peer;
+ struct timespec s_created;
+
+ /* All protected by s_mtx */
+ struct mutex s_mtx;
enum wg_state s_state;
struct wg_handshake {
@@ -179,14 +179,16 @@ struct wg_peer {
struct wg_pubkey p_remote;
struct refcnt p_refcnt;
- /* All protected by p_lock */
- struct rwlock p_lock;
- struct wg_cookie p_cookie;
+ /* Atomic */
struct wg_timers p_timers;
+
+ /* All protected by p_mtx */
+ struct mutex p_mtx;
+ struct wg_privkey p_shared;
+ struct wg_cookie p_cookie;
struct timespec p_last_initiation;
uint64_t p_tx_bytes;
uint64_t p_rx_bytes;
- struct wg_privkey p_shared;
uint8_t p_attempts;
struct wg_session *p_hs_session;
struct wg_session *p_ks_session;
@@ -195,15 +197,20 @@ struct wg_peer {
};
struct wg_device {
+ /* Static */
void *d_arg;
void (*d_cleanup)(struct wg_peer *);
void (*d_notify)(struct wg_peer *);
void (*d_outq)(struct wg_peer *, enum wg_pkt_type, uint32_t);
- struct fixed_map d_peers;
- struct fixed_map d_sessions;
- struct rwlock d_lock;
+
+ /* Mutex */
+ struct mutex d_mtx;
struct wg_cookie_maker d_cookie_maker;
struct wg_keypair d_keypair;
+
+ /* Atomic */
+ struct fixed_map d_peers;
+ struct fixed_map d_sessions;
};
enum wg_error {
@@ -242,12 +249,12 @@ static char *wg_error_str[] = {
/* WireGuard functions */
-void wg_device_init(struct wg_device *, int,
- void (*)(struct wg_peer *),
- void (*)(struct wg_peer *, enum wg_pkt_type, uint32_t),
- void (*)(struct wg_peer *), void *);
-void wg_device_setkey(struct wg_device *, struct wg_privkey *);
-void wg_device_destroy(struct wg_device *);
+void wg_device_init(struct wg_device *, int,
+ void (*)(struct wg_peer *),
+ void (*)(struct wg_peer *, enum wg_pkt_type, uint32_t),
+ void (*)(struct wg_peer *), void *);
+void wg_device_setkey(struct wg_device *, struct wg_privkey *);
+void wg_device_destroy(struct wg_device *);
struct wg_peer *wg_device_new_peer(struct wg_device *, struct wg_pubkey *, void *);
struct wg_peer *wg_device_ref_peerkey(struct wg_device *, struct wg_pubkey *);