Squashed 'external/toxcore/c-toxcore/' changes from 03e9fbf3703..e740b4e3b2e

e740b4e3b2e feat: Implement Tox network profiler

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: e740b4e3b2e3aa594ab259e2a80153f5eed8fd16
This commit is contained in:
2024-09-22 12:50:20 +02:00
parent fe6c5391a2
commit 0ce5c0a0ad
34 changed files with 943 additions and 46 deletions

View File

@@ -17,6 +17,7 @@
#include "bin_pack.h"
#include "logger.h"
#include "mem.h"
#include "net_profile.h"
#ifdef __cplusplus
extern "C" {
@@ -234,8 +235,9 @@ Socket net_invalid_socket(void);
/**
* Calls send(sockfd, buf, len, MSG_NOSIGNAL).
*/
non_null()
int net_send(const Network *ns, const Logger *log, Socket sock, const uint8_t *buf, size_t len, const IP_Port *ip_port);
non_null(1, 2, 4, 6) nullable(7)
int net_send(const Network *ns, const Logger *log, Socket sock, const uint8_t *buf, size_t len, const IP_Port *ip_port,
Net_Profile *net_profile);
/**
* Calls recv(sockfd, buf, len, MSG_NOSIGNAL).
*/
@@ -477,7 +479,7 @@ typedef struct Packet {
* Function to send a network packet to a given IP/port.
*/
non_null()
int send_packet(const Networking_Core *net, const IP_Port *ip_port, Packet packet);
int send_packet(Networking_Core *net, const IP_Port *ip_port, Packet packet);
/**
* Function to send packet(data) of length length to ip_port.
@@ -485,7 +487,7 @@ int send_packet(const Networking_Core *net, const IP_Port *ip_port, Packet packe
* @deprecated Use send_packet instead.
*/
non_null()
int sendpacket(const Networking_Core *net, const IP_Port *ip_port, const uint8_t *data, uint16_t length);
int sendpacket(Networking_Core *net, const IP_Port *ip_port, const uint8_t *data, uint16_t length);
/** Function to call when packet beginning with byte is received. */
non_null(1) nullable(3, 4)
@@ -493,7 +495,7 @@ void networking_registerhandler(Networking_Core *net, uint8_t byte, packet_handl
/** Call this several times a second. */
non_null(1) nullable(2)
void networking_poll(const Networking_Core *net, void *userdata);
void networking_poll(Networking_Core *net, void *userdata);
/** @brief Connect a socket to the address specified by the ip_port.
*
@@ -603,6 +605,13 @@ Networking_Core *new_networking_no_udp(const Logger *log, const Memory *mem, con
nullable(1)
void kill_networking(Networking_Core *net);
/** @brief Returns a pointer to the network net_profile object associated with `net`.
*
* Returns null if `net` is null.
*/
non_null()
const Net_Profile *net_get_net_profile(const Networking_Core *net);
#ifdef __cplusplus
} /* extern "C" */
#endif