services: switch to vlist
[project/unetd.git] / pex.h
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright (C) 2022 Felix Fietkau <nbd@nbd.name>
4 */
5 #ifndef __UNETD_PEX_H
6 #define __UNETD_PEX_H
7
8 #include <libubox/uloop.h>
9
10 struct network;
11
12 struct network_pex {
13 struct uloop_fd fd;
14 };
15
16 enum pex_event {
17 PEX_EV_HANDSHAKE,
18 PEX_EV_ENDPOINT_CHANGE,
19 PEX_EV_QUERY,
20 PEX_EV_PING,
21 };
22
23 void network_pex_init(struct network *net);
24 int network_pex_open(struct network *net);
25 void network_pex_close(struct network *net);
26
27 void network_pex_event(struct network *net, struct network_peer *peer,
28 enum pex_event ev);
29
30 static inline bool network_pex_active(struct network_pex *pex)
31 {
32 return pex->fd.fd >= 0;
33 }
34
35 #endif