forked from Green-Sky/tomato
Squashed 'external/toxcore/c-toxcore/' changes from 55752a2e2ef..11ab1d2a723
11ab1d2a723 fix: reduce memory usage in group chats by 75% Significantly reduced the memory usage of groups since all message slots are preallocated for every peer for send and receive buffers of buffer size (hundreds of MiB peak when save contained alot of peers to try to connect to) 4f09f4e147c chore: Fix tsan build by moving it to GitHub CI. 6460c25c9e0 refactor: Use `merge_sort` instead of `qsort` for sorting. c660bbe8c95 test: Fix crypto_test to initialise its plain text buffer. 0204db6184b cleanup: Fix layering check warnings. df2211e1548 refactor: Use tox memory allocator for temporary buffers in crypto. ac812871a2e feat: implement the last 2 missing network struct functions and make use of them 29d1043be0b test: friend request test now tests min/max message sizes 93aafd78c1f fix: friend requests with very long messages are no longer dropped 819aa2b2618 feat: Add option to disable DNS lookups in toxcore. 0ac23cee035 fix: windows use of REUSEADDR 7d2811d302d chore(ci): make bazel server shutdown faster 1dc399ba20d chore: Use vcpkg instead of conan in the MSVC build. 14d823165d9 chore: Migrate to conan 2. bdd17c16787 cleanup: Allocate logger using tox memory allocator. b396c061515 chore(deps): bump third_party/cmp from `2ac6bca` to `52bfcfa` 2e94da60d09 feat(net): add missing connect to network struct 41fb1839c7b chore: Add check to ensure version numbers agree. 934a8301113 chore: Release 0.2.20 3acef4bf044 fix: Add missing free in dht_get_nodes_response event. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 11ab1d2a7232eee19b51ce126ccce267d6578903
This commit is contained in:
@ -39,6 +39,7 @@ typedef int net_close_cb(void *obj, Socket sock);
|
||||
typedef Socket net_accept_cb(void *obj, Socket sock);
|
||||
typedef int net_bind_cb(void *obj, Socket sock, const Network_Addr *addr);
|
||||
typedef int net_listen_cb(void *obj, Socket sock, int backlog);
|
||||
typedef int net_connect_cb(void *obj, Socket sock, const Network_Addr *addr);
|
||||
typedef int net_recvbuf_cb(void *obj, Socket sock);
|
||||
typedef int net_recv_cb(void *obj, Socket sock, uint8_t *buf, size_t len);
|
||||
typedef int net_recvfrom_cb(void *obj, Socket sock, uint8_t *buf, size_t len, Network_Addr *addr);
|
||||
@ -48,8 +49,8 @@ typedef Socket net_socket_cb(void *obj, int domain, int type, int proto);
|
||||
typedef int net_socket_nonblock_cb(void *obj, Socket sock, bool nonblock);
|
||||
typedef int net_getsockopt_cb(void *obj, Socket sock, int level, int optname, void *optval, size_t *optlen);
|
||||
typedef int net_setsockopt_cb(void *obj, Socket sock, int level, int optname, const void *optval, size_t optlen);
|
||||
typedef int net_getaddrinfo_cb(void *obj, int family, Network_Addr **addrs);
|
||||
typedef int net_freeaddrinfo_cb(void *obj, Network_Addr *addrs);
|
||||
typedef int net_getaddrinfo_cb(void *obj, const Memory *mem, const char *address, int family, int protocol, Network_Addr **addrs);
|
||||
typedef int net_freeaddrinfo_cb(void *obj, const Memory *mem, Network_Addr *addrs);
|
||||
|
||||
/** @brief Functions wrapping POSIX network functions.
|
||||
*
|
||||
@ -61,6 +62,7 @@ typedef struct Network_Funcs {
|
||||
net_accept_cb *accept;
|
||||
net_bind_cb *bind;
|
||||
net_listen_cb *listen;
|
||||
net_connect_cb *connect;
|
||||
net_recvbuf_cb *recvbuf;
|
||||
net_recv_cb *recv;
|
||||
net_recvfrom_cb *recvfrom;
|
||||
@ -396,21 +398,23 @@ non_null()
|
||||
void ipport_copy(IP_Port *target, const IP_Port *source);
|
||||
|
||||
/**
|
||||
* Resolves string into an IP address
|
||||
* @brief Resolves string into an IP address.
|
||||
*
|
||||
* @param address a hostname (or something parseable to an IP address)
|
||||
* @param to to.family MUST be initialized, either set to a specific IP version
|
||||
* @param[in,out] ns Network object.
|
||||
* @param[in] address a hostname (or something parseable to an IP address).
|
||||
* @param[in,out] to to.family MUST be initialized, either set to a specific IP version
|
||||
* (TOX_AF_INET/TOX_AF_INET6) or to the unspecified TOX_AF_UNSPEC (0), if both
|
||||
* IP versions are acceptable
|
||||
* @param extra can be NULL and is only set in special circumstances, see returns
|
||||
* IP versions are acceptable.
|
||||
* @param[out] extra can be NULL and is only set in special circumstances, see returns.
|
||||
* @param[in] dns_enabled if false, DNS resolution is skipped.
|
||||
*
|
||||
* Returns in `*to` a matching address (IPv6 or IPv4)
|
||||
* Returns in `*extra`, if not NULL, an IPv4 address, if `to->family` was TOX_AF_UNSPEC
|
||||
* Returns in `*to` a matching address (IPv6 or IPv4).
|
||||
* Returns in `*extra`, if not NULL, an IPv4 address, if `to->family` was `TOX_AF_UNSPEC`.
|
||||
*
|
||||
* @return true on success, false on failure
|
||||
*/
|
||||
non_null(1, 2, 3) nullable(4)
|
||||
bool addr_resolve_or_parse_ip(const Network *ns, const char *address, IP *to, IP *extra);
|
||||
non_null(1, 2, 3, 4) nullable(5)
|
||||
bool addr_resolve_or_parse_ip(const Network *ns, const Memory *mem, const char *address, IP *to, IP *extra, bool dns_enabled);
|
||||
|
||||
/** @brief Function to receive data, ip and port of sender is put into ip_port.
|
||||
* Packet data is put into data.
|
||||
@ -501,7 +505,7 @@ void networking_poll(const Networking_Core *net, void *userdata);
|
||||
* Return false on failure.
|
||||
*/
|
||||
non_null()
|
||||
bool net_connect(const Memory *mem, const Logger *log, Socket sock, const IP_Port *ip_port);
|
||||
bool net_connect(const Network *ns, const Memory *mem, const Logger *log, Socket sock, const IP_Port *ip_port);
|
||||
|
||||
/** @brief High-level getaddrinfo implementation.
|
||||
*
|
||||
@ -510,14 +514,21 @@ bool net_connect(const Memory *mem, const Logger *log, Socket sock, const IP_Por
|
||||
* address that can be specified by calling `net_connect()`, the port is ignored.
|
||||
*
|
||||
* Skip all addresses with socktype != type (use type = -1 to get all addresses)
|
||||
* To correctly deallocate array memory use `net_freeipport()`
|
||||
* To correctly deallocate array memory use `net_freeipport()`.
|
||||
*
|
||||
* @param ns Network object.
|
||||
* @param mem Memory allocator.
|
||||
* @param node The node parameter identifies the host or service on which to connect.
|
||||
* @param[out] res An array of IP_Port structures will be allocated into this pointer.
|
||||
* @param tox_type The type of socket to use (stream or datagram), only relevant for DNS lookups.
|
||||
* @param dns_enabled If false, DNS resolution is skipped, when passed a hostname, this function will return an error.
|
||||
*
|
||||
* @return number of elements in res array.
|
||||
* @retval 0 if res array empty.
|
||||
* @retval -1 on error.
|
||||
*/
|
||||
non_null()
|
||||
int32_t net_getipport(const Memory *mem, const char *node, IP_Port **res, int tox_type);
|
||||
int32_t net_getipport(const Network *ns, const Memory *mem, const char *node, IP_Port **res, int tox_type, bool dns_enabled);
|
||||
|
||||
/** Deallocates memory allocated by net_getipport */
|
||||
non_null(1) nullable(2)
|
||||
|
Reference in New Issue
Block a user