Coverage Report

Created: 2026-10-24 08:16

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