1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
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 crypt_queue tx_queue
, rx_queue
;
40 struct sk_buff_head staged_packet_queue
;
42 struct noise_keypairs keypairs
;
43 struct endpoint endpoint
;
44 struct dst_cache endpoint_cache
;
45 rwlock_t endpoint_lock
;
46 struct noise_handshake handshake
;
47 atomic64_t last_sent_handshake
;
48 struct work_struct transmit_handshake_work
, clear_peer_work
;
49 struct cookie latest_cookie
;
50 struct hlist_node pubkey_hash
;
51 u64 rx_bytes
, tx_bytes
;
52 struct timer_list timer_retransmit_handshake
, timer_send_keepalive
;
53 struct timer_list timer_new_handshake
, timer_zero_key_material
;
54 struct timer_list timer_persistent_keepalive
;
55 unsigned int timer_handshake_attempts
;
56 u16 persistent_keepalive_interval
;
57 bool timer_need_another_keepalive
;
58 bool sent_lastminute_handshake
;
59 struct timespec64 walltime_last_handshake
;
62 struct list_head peer_list
;
63 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 #endif /* _WG_PEER_H */