1 /* SPDX-License-Identifier: GPL-2.0 */
13 #include <linux/types.h>
14 #include <linux/netfilter.h>
15 #include <linux/spinlock.h>
16 #include <linux/kref.h>
17 #include <net/dst_cache.h>
24 struct sockaddr_in addr4;
25 struct sockaddr_in6 addr6;
30 /* Essentially the same as addr6->scope_id */
38 struct wg_device *device;
39 struct prev_queue tx_queue, rx_queue;
40 struct sk_buff_head staged_packet_queue;
43 struct noise_keypairs keypairs;
44 struct endpoint endpoint;
45 struct dst_cache endpoint_cache;
46 rwlock_t endpoint_lock;
47 struct noise_handshake handshake;
48 atomic64_t last_sent_handshake;
49 struct work_struct transmit_handshake_work, clear_peer_work, transmit_packet_work;
50 struct cookie latest_cookie;
51 struct hlist_node pubkey_hash;
52 u64 rx_bytes, tx_bytes;
53 struct timer_list timer_retransmit_handshake, timer_send_keepalive;
54 struct timer_list timer_new_handshake, timer_zero_key_material;
55 struct timer_list timer_persistent_keepalive;
56 unsigned int timer_handshake_attempts;
57 u16 persistent_keepalive_interval;
58 bool timer_need_another_keepalive;
59 bool sent_lastminute_handshake;
60 struct timespec64 walltime_last_handshake;
63 struct list_head peer_list;
64 struct list_head allowedips_list;
65 struct napi_struct napi;
69 struct wg_peer *wg_peer_create(struct wg_device *wg,
70 const u8 public_key[NOISE_PUBLIC_KEY_LEN],
71 const u8 preshared_key[NOISE_SYMMETRIC_KEY_LEN]);
73 struct wg_peer *__must_check wg_peer_get_maybe_zero(struct wg_peer *peer);
74 static inline struct wg_peer *wg_peer_get(struct wg_peer *peer)
76 kref_get(&peer->refcount);
79 void wg_peer_put(struct wg_peer *peer);
80 void wg_peer_remove(struct wg_peer *peer);
81 void wg_peer_remove_all(struct wg_device *wg);
83 int wg_peer_init(void);
84 void wg_peer_uninit(void);
86 #endif /* _WG_PEER_H */