aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/peer.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2015-06-05 15:58:00 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-06-25 16:48:39 +0200
commit99d303ac2739e65a02fbbc325b74ad6fcac63cc2 (patch)
tree6f4095f42d3d298cdd5ab8bc6f8ed89d9673b38b /src/peer.h
downloadwireguard-monolithic-historical-99d303ac2739e65a02fbbc325b74ad6fcac63cc2.tar.xz
wireguard-monolithic-historical-99d303ac2739e65a02fbbc325b74ad6fcac63cc2.zip
Initial commit
Diffstat (limited to 'src/peer.h')
-rw-r--r--src/peer.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/peer.h b/src/peer.h
new file mode 100644
index 0000000..05ee7bd
--- /dev/null
+++ b/src/peer.h
@@ -0,0 +1,55 @@
+/* Copyright 2015-2016 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */
+
+#ifndef PEER_H
+#define PEER_H
+
+#include "wireguard.h"
+#include "noise.h"
+#include "cookie.h"
+#include <linux/types.h>
+#include <linux/netfilter.h>
+#include <linux/spinlock.h>
+#include <linux/kref.h>
+
+struct wireguard_peer {
+ struct wireguard_device *device;
+ struct sockaddr_storage endpoint_addr;
+ struct dst_entry *endpoint_dst;
+ union {
+ struct flowi4 fl4;
+ struct flowi6 fl6;
+ } endpoint_flow;
+ rwlock_t endpoint_lock;
+ struct noise_handshake handshake;
+ struct noise_keypairs keypairs;
+ uint64_t last_sent_handshake;
+ struct work_struct transmit_handshake_work, clear_peer_work;
+ struct cookie latest_cookie;
+ struct hlist_node pubkey_hash;
+ uint64_t rx_bytes, tx_bytes;
+ struct timer_list timer_retransmit_handshake, timer_send_keepalive, timer_new_handshake, timer_kill_ephemerals;
+ unsigned int timer_handshake_attempts;
+ bool timer_need_another_keepalive;
+ struct timeval walltime_last_handshake;
+ struct sk_buff_head tx_packet_queue;
+ struct kref refcount;
+ struct rcu_head rcu;
+ struct list_head peer_list;
+ uint64_t internal_id;
+};
+
+struct wireguard_peer *peer_create(struct wireguard_device *wg, const u8 public_key[NOISE_PUBLIC_KEY_LEN]);
+
+struct wireguard_peer *peer_get(struct wireguard_peer *peer);
+void peer_put(struct wireguard_peer *peer);
+void peer_remove(struct wireguard_peer *peer);
+void peer_remove_all(struct wireguard_device *wg);
+
+struct wireguard_peer *peer_lookup_by_index(struct wireguard_device *wg, u32 index);
+
+int peer_for_each_unlocked(struct wireguard_device *wg, int (*fn)(struct wireguard_peer *peer, void *ctx), void *data);
+int peer_for_each(struct wireguard_device *wg, int (*fn)(struct wireguard_peer *peer, void *ctx), void *data);
+
+unsigned int peer_total_count(struct wireguard_device *wg);
+
+#endif