/work/toxcore/LAN_discovery.h
Line | Count | Source |
1 | | /* SPDX-License-Identifier: GPL-3.0-or-later |
2 | | * Copyright © 2016-2025 The TokTok team. |
3 | | * Copyright © 2013 Tox project. |
4 | | */ |
5 | | |
6 | | /** |
7 | | * LAN discovery implementation. |
8 | | */ |
9 | | #ifndef C_TOXCORE_TOXCORE_LAN_DISCOVERY_H |
10 | | #define C_TOXCORE_TOXCORE_LAN_DISCOVERY_H |
11 | | |
12 | | #include "attributes.h" |
13 | | #include "mem.h" |
14 | | #include "network.h" |
15 | | |
16 | | /** |
17 | | * Interval in seconds between LAN discovery packet sending. |
18 | | */ |
19 | 1.45k | #define LAN_DISCOVERY_INTERVAL 10 |
20 | | |
21 | | typedef struct Broadcast_Info Broadcast_Info; |
22 | | |
23 | | /** |
24 | | * Send a LAN discovery pcaket to the broadcast address with port port. |
25 | | * |
26 | | * @return true on success, false on failure. |
27 | | */ |
28 | | bool lan_discovery_send(const Networking_Core *_Nonnull net, const Broadcast_Info *_Nonnull broadcast, const uint8_t *_Nonnull dht_pk, uint16_t port); |
29 | | |
30 | | /** |
31 | | * Discovers broadcast devices and IP addresses. |
32 | | */ |
33 | | Broadcast_Info *_Nullable lan_discovery_init(const Memory *_Nonnull mem, const Network *_Nonnull ns); |
34 | | |
35 | | /** |
36 | | * Free all resources associated with the broadcast info. |
37 | | */ |
38 | | void lan_discovery_kill(Broadcast_Info *_Nullable broadcast); |
39 | | /** |
40 | | * Is IP a local ip or not. |
41 | | */ |
42 | | bool ip_is_local(const IP *_Nonnull ip); |
43 | | |
44 | | /** |
45 | | * Checks if a given IP isn't routable. |
46 | | * |
47 | | * @return true if ip is a LAN ip, false if it is not. |
48 | | */ |
49 | | bool ip_is_lan(const IP *_Nonnull ip); |
50 | | |
51 | | #endif /* C_TOXCORE_TOXCORE_LAN_DISCOVERY_H */ |