Coverage Report

Created: 2025-10-08 19:34

/work/toxcore/TCP_server.h
Line
Count
Source
1
/* SPDX-License-Identifier: GPL-3.0-or-later
2
 * Copyright © 2016-2025 The TokTok team.
3
 * Copyright © 2014 Tox project.
4
 */
5
6
/**
7
 * Implementation of the TCP relay server part of Tox.
8
 */
9
#ifndef C_TOXCORE_TOXCORE_TCP_SERVER_H
10
#define C_TOXCORE_TOXCORE_TCP_SERVER_H
11
12
#include "attributes.h"
13
#include "crypto_core.h"
14
#include "forwarding.h"
15
#include "logger.h"
16
#include "mem.h"
17
#include "mono_time.h"
18
#include "net_profile.h"
19
#include "network.h"
20
#include "onion.h"
21
22
1.09M
#define MAX_INCOMING_CONNECTIONS 256
23
24
19
#define TCP_MAX_BACKLOG MAX_INCOMING_CONNECTIONS
25
26
#define ARRAY_ENTRY_SIZE 6
27
28
typedef enum TCP_Status {
29
    TCP_STATUS_NO_STATUS,
30
    TCP_STATUS_CONNECTED,
31
    TCP_STATUS_UNCONFIRMED,
32
    TCP_STATUS_CONFIRMED,
33
} TCP_Status;
34
35
typedef struct TCP_Server TCP_Server;
36
37
const uint8_t *_Nonnull tcp_server_public_key(const TCP_Server *_Nonnull tcp_server);
38
size_t tcp_server_listen_count(const TCP_Server *_Nonnull tcp_server);
39
40
/** Create new TCP server instance. */
41
TCP_Server *_Nullable new_tcp_server(const Logger *_Nonnull logger, const Memory *_Nonnull mem, const Random *_Nonnull rng, const Network *_Nonnull ns,
42
                                     bool ipv6_enabled, uint16_t num_sockets, const uint16_t *_Nonnull ports,
43
                                     const uint8_t *_Nonnull secret_key, Onion *_Nullable onion, Forwarding *_Nullable forwarding);
44
/** Run the TCP_server */
45
void do_tcp_server(TCP_Server *_Nonnull tcp_server, const Mono_Time *_Nonnull mono_time);
46
47
/** Kill the TCP server */
48
void kill_tcp_server(TCP_Server *_Nullable tcp_server);
49
/** @brief Returns a pointer to the net profile associated with `tcp_server`.
50
 *
51
 * Returns null if `tcp_server` is null.
52
 */
53
const Net_Profile *_Nullable tcp_server_get_net_profile(const TCP_Server *_Nullable tcp_server);
54
#endif /* C_TOXCORE_TOXCORE_TCP_SERVER_H */