Squashed 'external/toxcore/c-toxcore/' changes from 1701691d5..640e6cace
640e6cace fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. 6f7f51554 chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...) 5047ae5a2 chore: make the source tarball exhibit the old behavior 14804a4b8 chore: Fix sonar-scan CI action. e2db7d946 cleanup: Exclude lan_discovery test from running on macos, instead of excluding it from the project. 3accade67 chore: Fix CI, disabling some tests that no longer run on CI. ef8d767e6 cleanup: Fix comment formatting errors. 34ec822da cleanup: Fix some clang-19 format warnings. 40b3f0b46 refactor: Use clang's nullability qualifiers instead of attributes. f81e30679 refactor: Use per-parameter nullability annotations. REVERT: 1701691d5 chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...) REVERT: a87505867 fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 640e6cace81b4412c45977b94eb9c41e53c54035
This commit is contained in:
@@ -181,8 +181,7 @@ DHT *nc_get_dht(const Net_Crypto *c)
|
||||
return c->dht;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool crypt_connection_id_is_valid(const Net_Crypto *c, int crypt_connection_id)
|
||||
static bool crypt_connection_id_is_valid(const Net_Crypto *_Nonnull c, int crypt_connection_id)
|
||||
{
|
||||
if ((uint32_t)crypt_connection_id >= c->crypto_connections_length) {
|
||||
return false;
|
||||
@@ -216,9 +215,7 @@ static bool crypt_connection_id_is_valid(const Net_Crypto *c, int crypt_connecti
|
||||
* @retval -1 on failure.
|
||||
* @retval COOKIE_REQUEST_LENGTH on success.
|
||||
*/
|
||||
non_null()
|
||||
static int create_cookie_request(const Net_Crypto *c, uint8_t *packet, const uint8_t *dht_public_key,
|
||||
uint64_t number, uint8_t *shared_key)
|
||||
static int create_cookie_request(const Net_Crypto *_Nonnull c, uint8_t *_Nonnull packet, const uint8_t *_Nonnull dht_public_key, uint64_t number, uint8_t *_Nonnull shared_key)
|
||||
{
|
||||
uint8_t plain[COOKIE_REQUEST_PLAIN_LENGTH];
|
||||
|
||||
@@ -247,9 +244,8 @@ static int create_cookie_request(const Net_Crypto *c, uint8_t *packet, const uin
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int create_cookie(const Memory *mem, const Random *rng, const Mono_Time *mono_time, uint8_t *cookie, const uint8_t *bytes,
|
||||
const uint8_t *encryption_key)
|
||||
static int create_cookie(const Memory *_Nonnull mem, const Random *_Nonnull rng, const Mono_Time *_Nonnull mono_time, uint8_t *_Nonnull cookie, const uint8_t *_Nonnull bytes,
|
||||
const uint8_t *_Nonnull encryption_key)
|
||||
{
|
||||
uint8_t contents[COOKIE_CONTENTS_LENGTH];
|
||||
const uint64_t temp_time = mono_time_get(mono_time);
|
||||
@@ -270,9 +266,7 @@ static int create_cookie(const Memory *mem, const Random *rng, const Mono_Time *
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int open_cookie(const Memory *mem, const Mono_Time *mono_time, uint8_t *bytes, const uint8_t *cookie,
|
||||
const uint8_t *encryption_key)
|
||||
static int open_cookie(const Memory *_Nonnull mem, const Mono_Time *_Nonnull mono_time, uint8_t *_Nonnull bytes, const uint8_t *_Nonnull cookie, const uint8_t *_Nonnull encryption_key)
|
||||
{
|
||||
uint8_t contents[COOKIE_CONTENTS_LENGTH];
|
||||
const int len = decrypt_data_symmetric(mem, encryption_key, cookie, cookie + CRYPTO_NONCE_SIZE,
|
||||
@@ -301,9 +295,8 @@ static int open_cookie(const Memory *mem, const Mono_Time *mono_time, uint8_t *b
|
||||
* @retval -1 on failure.
|
||||
* @retval COOKIE_RESPONSE_LENGTH on success.
|
||||
*/
|
||||
non_null()
|
||||
static int create_cookie_response(const Net_Crypto *c, uint8_t *packet, const uint8_t *request_plain,
|
||||
const uint8_t *shared_key, const uint8_t *dht_public_key)
|
||||
static int create_cookie_response(const Net_Crypto *_Nonnull c, uint8_t *_Nonnull packet, const uint8_t *_Nonnull request_plain, const uint8_t *_Nonnull shared_key,
|
||||
const uint8_t *_Nonnull dht_public_key)
|
||||
{
|
||||
uint8_t cookie_plain[COOKIE_DATA_LENGTH];
|
||||
memcpy(cookie_plain, request_plain, CRYPTO_PUBLIC_KEY_SIZE);
|
||||
@@ -333,9 +326,8 @@ static int create_cookie_response(const Net_Crypto *c, uint8_t *packet, const ui
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int handle_cookie_request(const Net_Crypto *c, uint8_t *request_plain, uint8_t *shared_key,
|
||||
uint8_t *dht_public_key, const uint8_t *packet, uint16_t length)
|
||||
static int handle_cookie_request(const Net_Crypto *_Nonnull c, uint8_t *_Nonnull request_plain, uint8_t *_Nonnull shared_key, uint8_t *_Nonnull dht_public_key,
|
||||
const uint8_t *_Nonnull packet, uint16_t length)
|
||||
{
|
||||
if (length != COOKIE_REQUEST_LENGTH) {
|
||||
return -1;
|
||||
@@ -356,9 +348,8 @@ static int handle_cookie_request(const Net_Crypto *c, uint8_t *request_plain, ui
|
||||
}
|
||||
|
||||
/** Handle the cookie request packet (for raw UDP) */
|
||||
non_null(1, 2, 3) nullable(5)
|
||||
static int udp_handle_cookie_request(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length,
|
||||
void *userdata)
|
||||
static int udp_handle_cookie_request(void *_Nonnull object, const IP_Port *_Nonnull source, const uint8_t *_Nonnull packet, uint16_t length,
|
||||
void *_Nullable userdata)
|
||||
{
|
||||
const Net_Crypto *c = (const Net_Crypto *)object;
|
||||
uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH];
|
||||
@@ -383,9 +374,7 @@ static int udp_handle_cookie_request(void *object, const IP_Port *source, const
|
||||
}
|
||||
|
||||
/** Handle the cookie request packet (for TCP) */
|
||||
non_null()
|
||||
static int tcp_handle_cookie_request(const Net_Crypto *c, int connections_number, const uint8_t *packet,
|
||||
uint16_t length)
|
||||
static int tcp_handle_cookie_request(const Net_Crypto *_Nonnull c, int connections_number, const uint8_t *_Nonnull packet, uint16_t length)
|
||||
{
|
||||
uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH];
|
||||
uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE];
|
||||
@@ -406,9 +395,8 @@ static int tcp_handle_cookie_request(const Net_Crypto *c, int connections_number
|
||||
}
|
||||
|
||||
/** Handle the cookie request packet (for TCP oob packets) */
|
||||
non_null()
|
||||
static int tcp_oob_handle_cookie_request(const Net_Crypto *c, unsigned int tcp_connections_number,
|
||||
const uint8_t *dht_public_key, const uint8_t *packet, uint16_t length)
|
||||
static int tcp_oob_handle_cookie_request(const Net_Crypto *_Nonnull c, unsigned int tcp_connections_number, const uint8_t *_Nonnull dht_public_key, const uint8_t *_Nonnull packet,
|
||||
uint16_t length)
|
||||
{
|
||||
uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH];
|
||||
uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE];
|
||||
@@ -440,10 +428,8 @@ static int tcp_oob_handle_cookie_request(const Net_Crypto *c, unsigned int tcp_c
|
||||
* @retval -1 on failure.
|
||||
* @retval COOKIE_LENGTH on success.
|
||||
*/
|
||||
non_null()
|
||||
static int handle_cookie_response(const Memory *mem, uint8_t *cookie, uint64_t *number,
|
||||
const uint8_t *packet, uint16_t length,
|
||||
const uint8_t *shared_key)
|
||||
static int handle_cookie_response(const Memory *_Nonnull mem, uint8_t *_Nonnull cookie, uint64_t *_Nonnull number, const uint8_t *_Nonnull packet, uint16_t length,
|
||||
const uint8_t *_Nonnull shared_key)
|
||||
{
|
||||
if (length != COOKIE_RESPONSE_LENGTH) {
|
||||
return -1;
|
||||
@@ -471,9 +457,8 @@ static int handle_cookie_response(const Memory *mem, uint8_t *cookie, uint64_t *
|
||||
* @retval -1 on failure.
|
||||
* @retval HANDSHAKE_PACKET_LENGTH on success.
|
||||
*/
|
||||
non_null()
|
||||
static int create_crypto_handshake(const Net_Crypto *c, uint8_t *packet, const uint8_t *cookie, const uint8_t *nonce,
|
||||
const uint8_t *session_pk, const uint8_t *peer_real_pk, const uint8_t *peer_dht_pubkey)
|
||||
static int create_crypto_handshake(const Net_Crypto *_Nonnull c, uint8_t *_Nonnull packet, const uint8_t *_Nonnull cookie, const uint8_t *_Nonnull nonce, const uint8_t *_Nonnull session_pk,
|
||||
const uint8_t *_Nonnull peer_real_pk, const uint8_t *_Nonnull peer_dht_pubkey)
|
||||
{
|
||||
uint8_t plain[CRYPTO_NONCE_SIZE + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SHA512_SIZE + COOKIE_LENGTH];
|
||||
memcpy(plain, nonce, CRYPTO_NONCE_SIZE);
|
||||
@@ -520,9 +505,8 @@ static int create_crypto_handshake(const Net_Crypto *c, uint8_t *packet, const u
|
||||
* @retval false on failure.
|
||||
* @retval true on success.
|
||||
*/
|
||||
non_null(1, 2, 3, 4, 5, 6, 7) nullable(9)
|
||||
static bool handle_crypto_handshake(const Net_Crypto *c, uint8_t *nonce, uint8_t *session_pk, uint8_t *peer_real_pk,
|
||||
uint8_t *dht_public_key, uint8_t *cookie, const uint8_t *packet, uint16_t length, const uint8_t *expected_real_pk)
|
||||
static bool handle_crypto_handshake(const Net_Crypto *_Nonnull c, uint8_t *_Nonnull nonce, uint8_t *_Nonnull session_pk, uint8_t *_Nonnull peer_real_pk,
|
||||
uint8_t *_Nonnull dht_public_key, uint8_t *_Nonnull cookie, const uint8_t *_Nonnull packet, uint16_t length, const uint8_t *_Nullable expected_real_pk)
|
||||
{
|
||||
if (length != HANDSHAKE_PACKET_LENGTH) {
|
||||
return false;
|
||||
@@ -562,8 +546,7 @@ static bool handle_crypto_handshake(const Net_Crypto *c, uint8_t *nonce, uint8_t
|
||||
return true;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static Crypto_Connection *get_crypto_connection(const Net_Crypto *c, int crypt_connection_id)
|
||||
static Crypto_Connection *get_crypto_connection(const Net_Crypto *_Nonnull c, int crypt_connection_id)
|
||||
{
|
||||
if (!crypt_connection_id_is_valid(c, crypt_connection_id)) {
|
||||
return nullptr;
|
||||
@@ -577,8 +560,7 @@ static Crypto_Connection *get_crypto_connection(const Net_Crypto *c, int crypt_c
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int add_ip_port_connection(Net_Crypto *c, int crypt_connection_id, const IP_Port *ip_port)
|
||||
static int add_ip_port_connection(Net_Crypto *_Nonnull c, int crypt_connection_id, const IP_Port *_Nonnull ip_port)
|
||||
{
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -616,8 +598,7 @@ static int add_ip_port_connection(Net_Crypto *c, int crypt_connection_id, const
|
||||
* @retval IP_Port with family 0 on failure.
|
||||
* @return IP_Port on success.
|
||||
*/
|
||||
non_null()
|
||||
static IP_Port return_ip_port_connection(const Net_Crypto *c, int crypt_connection_id)
|
||||
static IP_Port return_ip_port_connection(const Net_Crypto *_Nonnull c, int crypt_connection_id)
|
||||
{
|
||||
const IP_Port empty = {{{0}}};
|
||||
|
||||
@@ -674,8 +655,7 @@ static IP_Port return_ip_port_connection(const Net_Crypto *c, int crypt_connecti
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_packet_to(const Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length)
|
||||
static int send_packet_to(const Net_Crypto *_Nonnull c, int crypt_connection_id, const uint8_t *_Nonnull data, uint16_t length)
|
||||
{
|
||||
// TODO(irungentoo): TCP, etc...
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
@@ -734,8 +714,7 @@ static int send_packet_to(const Net_Crypto *c, int crypt_connection_id, const ui
|
||||
/** @brief Return number of packets in array
|
||||
* Note that holes are counted too.
|
||||
*/
|
||||
non_null()
|
||||
static uint32_t num_packets_array(const Packets_Array *array)
|
||||
static uint32_t num_packets_array(const Packets_Array *_Nonnull array)
|
||||
{
|
||||
return array->buffer_end - array->buffer_start;
|
||||
}
|
||||
@@ -745,8 +724,7 @@ static uint32_t num_packets_array(const Packets_Array *array)
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int add_data_to_buffer(const Memory *mem, Packets_Array *array, uint32_t number, const Packet_Data *data)
|
||||
static int add_data_to_buffer(const Memory *_Nonnull mem, Packets_Array *_Nonnull array, uint32_t number, const Packet_Data *_Nonnull data)
|
||||
{
|
||||
if (number - array->buffer_start >= CRYPTO_PACKET_BUFFER_SIZE) {
|
||||
return -1;
|
||||
@@ -780,8 +758,7 @@ static int add_data_to_buffer(const Memory *mem, Packets_Array *array, uint32_t
|
||||
* @retval 0 if data at number is empty.
|
||||
* @retval 1 if data pointer was put in data.
|
||||
*/
|
||||
non_null()
|
||||
static int get_data_pointer(const Packets_Array *array, Packet_Data **data, uint32_t number)
|
||||
static int get_data_pointer(const Packets_Array *_Nonnull array, Packet_Data *_Nonnull *_Nonnull data, uint32_t number)
|
||||
{
|
||||
const uint32_t num_spots = num_packets_array(array);
|
||||
|
||||
@@ -804,8 +781,7 @@ static int get_data_pointer(const Packets_Array *array, Packet_Data **data, uint
|
||||
* @retval -1 on failure.
|
||||
* @return packet number on success.
|
||||
*/
|
||||
non_null()
|
||||
static int64_t add_data_end_of_buffer(const Logger *logger, const Memory *mem, Packets_Array *array, const Packet_Data *data)
|
||||
static int64_t add_data_end_of_buffer(const Logger *_Nonnull logger, const Memory *_Nonnull mem, Packets_Array *_Nonnull array, const Packet_Data *_Nonnull data)
|
||||
{
|
||||
const uint32_t num_spots = num_packets_array(array);
|
||||
|
||||
@@ -833,8 +809,7 @@ static int64_t add_data_end_of_buffer(const Logger *logger, const Memory *mem, P
|
||||
* @retval -1 on failure.
|
||||
* @return packet number on success.
|
||||
*/
|
||||
non_null()
|
||||
static int64_t read_data_beg_buffer(const Memory *mem, Packets_Array *array, Packet_Data *data)
|
||||
static int64_t read_data_beg_buffer(const Memory *_Nonnull mem, Packets_Array *_Nonnull array, Packet_Data *_Nonnull data)
|
||||
{
|
||||
if (array->buffer_end == array->buffer_start) {
|
||||
return -1;
|
||||
@@ -859,8 +834,7 @@ static int64_t read_data_beg_buffer(const Memory *mem, Packets_Array *array, Pac
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success
|
||||
*/
|
||||
non_null()
|
||||
static int clear_buffer_until(const Memory *mem, Packets_Array *array, uint32_t number)
|
||||
static int clear_buffer_until(const Memory *_Nonnull mem, Packets_Array *_Nonnull array, uint32_t number)
|
||||
{
|
||||
const uint32_t num_spots = num_packets_array(array);
|
||||
|
||||
@@ -883,8 +857,7 @@ static int clear_buffer_until(const Memory *mem, Packets_Array *array, uint32_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static int clear_buffer(const Memory *mem, Packets_Array *array)
|
||||
static int clear_buffer(const Memory *_Nonnull mem, Packets_Array *_Nonnull array)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
@@ -906,8 +879,7 @@ static int clear_buffer(const Memory *mem, Packets_Array *array)
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int set_buffer_end(Packets_Array *array, uint32_t number)
|
||||
static int set_buffer_end(Packets_Array *_Nonnull array, uint32_t number)
|
||||
{
|
||||
if (number - array->buffer_start > CRYPTO_PACKET_BUFFER_SIZE) {
|
||||
return -1;
|
||||
@@ -928,8 +900,7 @@ static int set_buffer_end(Packets_Array *array, uint32_t number)
|
||||
* @retval -1 on failure.
|
||||
* @return length of packet on success.
|
||||
*/
|
||||
non_null()
|
||||
static int generate_request_packet(uint8_t *data, uint16_t length, const Packets_Array *recv_array)
|
||||
static int generate_request_packet(uint8_t *_Nonnull data, uint16_t length, const Packets_Array *_Nonnull recv_array)
|
||||
{
|
||||
if (length == 0) {
|
||||
return -1;
|
||||
@@ -982,10 +953,8 @@ static int generate_request_packet(uint8_t *data, uint16_t length, const Packets
|
||||
* @retval -1 on failure.
|
||||
* @return number of requested packets on success.
|
||||
*/
|
||||
non_null()
|
||||
static int handle_request_packet(const Memory *mem, const Mono_Time *mono_time, Packets_Array *send_array,
|
||||
const uint8_t *data, uint16_t length,
|
||||
uint64_t *latest_send_time, uint64_t rtt_time)
|
||||
static int handle_request_packet(const Memory *_Nonnull mem, const Mono_Time *_Nonnull mono_time, Packets_Array *_Nonnull send_array, const uint8_t *_Nonnull data, uint16_t length,
|
||||
uint64_t *_Nonnull latest_send_time, uint64_t rtt_time)
|
||||
{
|
||||
if (length == 0) {
|
||||
return -1;
|
||||
@@ -1065,8 +1034,7 @@ static int handle_request_packet(const Memory *mem, const Mono_Time *mono_time,
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_data_packet(const Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length)
|
||||
static int send_data_packet(const Net_Crypto *_Nonnull c, int crypt_connection_id, const uint8_t *_Nonnull data, uint16_t length)
|
||||
{
|
||||
const uint16_t max_length = MAX_CRYPTO_PACKET_SIZE - (1 + sizeof(uint16_t) + CRYPTO_MAC_SIZE);
|
||||
|
||||
@@ -1103,9 +1071,7 @@ static int send_data_packet(const Net_Crypto *c, int crypt_connection_id, const
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_data_packet_helper(const Net_Crypto *c, int crypt_connection_id, uint32_t buffer_start, uint32_t num,
|
||||
const uint8_t *data, uint16_t length)
|
||||
static int send_data_packet_helper(const Net_Crypto *_Nonnull c, int crypt_connection_id, uint32_t buffer_start, uint32_t num, const uint8_t *_Nonnull data, uint16_t length)
|
||||
{
|
||||
if (length == 0 || length > MAX_CRYPTO_DATA_SIZE) {
|
||||
LOGGER_ERROR(c->log, "zero-length or too large data packet: %d (max: %d)", length, MAX_CRYPTO_PACKET_SIZE);
|
||||
@@ -1125,8 +1091,7 @@ static int send_data_packet_helper(const Net_Crypto *c, int crypt_connection_id,
|
||||
return send_data_packet(c, crypt_connection_id, packet, packet_size);
|
||||
}
|
||||
|
||||
non_null()
|
||||
static int reset_max_speed_reached(const Net_Crypto *c, int crypt_connection_id)
|
||||
static int reset_max_speed_reached(const Net_Crypto *_Nonnull c, int crypt_connection_id)
|
||||
{
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1160,9 +1125,7 @@ static int reset_max_speed_reached(const Net_Crypto *c, int crypt_connection_id)
|
||||
* @retval -1 if data could not be put in packet queue.
|
||||
* @return positive packet number if data was put into the queue.
|
||||
*/
|
||||
non_null()
|
||||
static int64_t send_lossless_packet(const Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length,
|
||||
bool congestion_control)
|
||||
static int64_t send_lossless_packet(const Net_Crypto *_Nonnull c, int crypt_connection_id, const uint8_t *_Nonnull data, uint16_t length, bool congestion_control)
|
||||
{
|
||||
if (length == 0 || length > MAX_CRYPTO_DATA_SIZE) {
|
||||
LOGGER_ERROR(c->log, "rejecting too large (or empty) packet of size %d on crypt connection %d", length,
|
||||
@@ -1217,8 +1180,7 @@ static int64_t send_lossless_packet(const Net_Crypto *c, int crypt_connection_id
|
||||
* @brief Get the lowest 2 bytes from the nonce and convert
|
||||
* them to host byte format before returning them.
|
||||
*/
|
||||
non_null()
|
||||
static uint16_t get_nonce_uint16(const uint8_t *nonce)
|
||||
static uint16_t get_nonce_uint16(const uint8_t *_Nonnull nonce)
|
||||
{
|
||||
uint16_t num;
|
||||
memcpy(&num, nonce + (CRYPTO_NONCE_SIZE - sizeof(uint16_t)), sizeof(uint16_t));
|
||||
@@ -1234,9 +1196,7 @@ static uint16_t get_nonce_uint16(const uint8_t *nonce)
|
||||
* @retval -1 on failure.
|
||||
* @return length of data on success.
|
||||
*/
|
||||
non_null()
|
||||
static int handle_data_packet(const Net_Crypto *c, int crypt_connection_id, uint8_t *data, const uint8_t *packet,
|
||||
uint16_t length)
|
||||
static int handle_data_packet(const Net_Crypto *_Nonnull c, int crypt_connection_id, uint8_t *_Nonnull data, const uint8_t *_Nonnull packet, uint16_t length)
|
||||
{
|
||||
const uint16_t crypto_packet_overhead = 1 + sizeof(uint16_t) + CRYPTO_MAC_SIZE;
|
||||
|
||||
@@ -1276,8 +1236,7 @@ static int handle_data_packet(const Net_Crypto *c, int crypt_connection_id, uint
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_request_packet(const Net_Crypto *c, int crypt_connection_id)
|
||||
static int send_request_packet(const Net_Crypto *_Nonnull c, int crypt_connection_id)
|
||||
{
|
||||
const Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1301,8 +1260,7 @@ static int send_request_packet(const Net_Crypto *c, int crypt_connection_id)
|
||||
* @retval -1 on failure.
|
||||
* @return number of packets sent on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_requested_packets(const Net_Crypto *c, int crypt_connection_id, uint32_t max_num)
|
||||
static int send_requested_packets(const Net_Crypto *_Nonnull c, int crypt_connection_id, uint32_t max_num)
|
||||
{
|
||||
if (max_num == 0) {
|
||||
return -1;
|
||||
@@ -1354,8 +1312,7 @@ static int send_requested_packets(const Net_Crypto *c, int crypt_connection_id,
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int new_temp_packet(const Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length)
|
||||
static int new_temp_packet(const Net_Crypto *_Nonnull c, int crypt_connection_id, const uint8_t *_Nonnull packet, uint16_t length)
|
||||
{
|
||||
if (length == 0 || length > MAX_CRYPTO_PACKET_SIZE) {
|
||||
return -1;
|
||||
@@ -1390,8 +1347,7 @@ static int new_temp_packet(const Net_Crypto *c, int crypt_connection_id, const u
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int clear_temp_packet(const Net_Crypto *c, int crypt_connection_id)
|
||||
static int clear_temp_packet(const Net_Crypto *_Nonnull c, int crypt_connection_id)
|
||||
{
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1415,8 +1371,7 @@ static int clear_temp_packet(const Net_Crypto *c, int crypt_connection_id)
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_temp_packet(const Net_Crypto *c, int crypt_connection_id)
|
||||
static int send_temp_packet(const Net_Crypto *_Nonnull c, int crypt_connection_id)
|
||||
{
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1443,9 +1398,7 @@ static int send_temp_packet(const Net_Crypto *c, int crypt_connection_id)
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int create_send_handshake(const Net_Crypto *c, int crypt_connection_id, const uint8_t *cookie,
|
||||
const uint8_t *dht_public_key)
|
||||
static int create_send_handshake(const Net_Crypto *_Nonnull c, int crypt_connection_id, const uint8_t *_Nonnull cookie, const uint8_t *_Nonnull dht_public_key)
|
||||
{
|
||||
const Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1473,8 +1426,7 @@ static int create_send_handshake(const Net_Crypto *c, int crypt_connection_id, c
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int send_kill_packet(const Net_Crypto *c, int crypt_connection_id)
|
||||
static int send_kill_packet(const Net_Crypto *_Nonnull c, int crypt_connection_id)
|
||||
{
|
||||
const Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1487,11 +1439,9 @@ static int send_kill_packet(const Net_Crypto *c, int crypt_connection_id)
|
||||
kill_packet, sizeof(kill_packet));
|
||||
}
|
||||
|
||||
non_null(1) nullable(3)
|
||||
static void connection_kill(Net_Crypto *c, int crypt_connection_id, void *userdata)
|
||||
static void connection_kill(Net_Crypto *_Nonnull c, int crypt_connection_id, void *_Nullable userdata)
|
||||
{
|
||||
const Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
if (conn == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -1509,9 +1459,8 @@ static void connection_kill(Net_Crypto *c, int crypt_connection_id, void *userda
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null(1, 3) nullable(6)
|
||||
static int handle_data_packet_core(Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length,
|
||||
bool udp, void *userdata)
|
||||
static int handle_data_packet_core(Net_Crypto *_Nonnull c, int crypt_connection_id, const uint8_t *_Nonnull packet, uint16_t length,
|
||||
bool udp, void *_Nullable userdata)
|
||||
{
|
||||
if (length > MAX_CRYPTO_PACKET_SIZE || length <= CRYPTO_DATA_PACKET_MIN_SIZE) {
|
||||
return -1;
|
||||
@@ -1648,8 +1597,7 @@ static int handle_data_packet_core(Net_Crypto *c, int crypt_connection_id, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static int handle_packet_cookie_response(const Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length)
|
||||
static int handle_packet_cookie_response(const Net_Crypto *_Nonnull c, int crypt_connection_id, const uint8_t *_Nonnull packet, uint16_t length)
|
||||
{
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1680,12 +1628,10 @@ static int handle_packet_cookie_response(const Net_Crypto *c, int crypt_connecti
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null(1, 3) nullable(5)
|
||||
static int handle_packet_crypto_hs(const Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length,
|
||||
void *userdata)
|
||||
static int handle_packet_crypto_hs(const Net_Crypto *_Nonnull c, int crypt_connection_id, const uint8_t *_Nonnull packet, uint16_t length,
|
||||
void *_Nullable userdata)
|
||||
{
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
if (conn == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1724,12 +1670,10 @@ static int handle_packet_crypto_hs(const Net_Crypto *c, int crypt_connection_id,
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null(1, 3) nullable(6)
|
||||
static int handle_packet_crypto_data(Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length,
|
||||
bool udp, void *userdata)
|
||||
static int handle_packet_crypto_data(Net_Crypto *_Nonnull c, int crypt_connection_id, const uint8_t *_Nonnull packet, uint16_t length,
|
||||
bool udp, void *_Nullable userdata)
|
||||
{
|
||||
const Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
if (conn == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1746,9 +1690,8 @@ static int handle_packet_crypto_data(Net_Crypto *c, int crypt_connection_id, con
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null(1, 3) nullable(6)
|
||||
static int handle_packet_connection(Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length,
|
||||
bool udp, void *userdata)
|
||||
static int handle_packet_connection(Net_Crypto *_Nonnull c, int crypt_connection_id, const uint8_t *_Nonnull packet, uint16_t length,
|
||||
bool udp, void *_Nullable userdata)
|
||||
{
|
||||
if (length == 0 || length > MAX_CRYPTO_PACKET_SIZE) {
|
||||
return -1;
|
||||
@@ -1774,8 +1717,7 @@ static int handle_packet_connection(Net_Crypto *c, int crypt_connection_id, cons
|
||||
* @retval -1 if mem_vrealloc fails.
|
||||
* @retval 0 if it succeeds.
|
||||
*/
|
||||
non_null()
|
||||
static int realloc_cryptoconnection(Net_Crypto *c, uint32_t num)
|
||||
static int realloc_cryptoconnection(Net_Crypto *_Nonnull c, uint32_t num)
|
||||
{
|
||||
if (num == 0) {
|
||||
mem_delete(c->mem, c->crypto_connections);
|
||||
@@ -1799,8 +1741,7 @@ static int realloc_cryptoconnection(Net_Crypto *c, uint32_t num)
|
||||
* @retval -1 on failure.
|
||||
* @return connection id on success.
|
||||
*/
|
||||
non_null()
|
||||
static int create_crypto_connection(Net_Crypto *c)
|
||||
static int create_crypto_connection(Net_Crypto *_Nonnull c)
|
||||
{
|
||||
int id = -1;
|
||||
|
||||
@@ -1839,8 +1780,7 @@ static int create_crypto_connection(Net_Crypto *c)
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null()
|
||||
static int wipe_crypto_connection(Net_Crypto *c, int crypt_connection_id)
|
||||
static int wipe_crypto_connection(Net_Crypto *_Nonnull c, int crypt_connection_id)
|
||||
{
|
||||
if ((uint32_t)crypt_connection_id >= c->crypto_connections_length) {
|
||||
return -1;
|
||||
@@ -1880,8 +1820,7 @@ static int wipe_crypto_connection(Net_Crypto *c, int crypt_connection_id)
|
||||
* @retval -1 if there are no connections like we are looking for.
|
||||
* @return id if it found it.
|
||||
*/
|
||||
non_null()
|
||||
static int getcryptconnection_id(const Net_Crypto *c, const uint8_t *public_key)
|
||||
static int getcryptconnection_id(const Net_Crypto *_Nonnull c, const uint8_t *_Nonnull public_key)
|
||||
{
|
||||
for (uint32_t i = 0; i < c->crypto_connections_length; ++i) {
|
||||
if (!crypt_connection_id_is_valid(c, i)) {
|
||||
@@ -1903,8 +1842,7 @@ static int getcryptconnection_id(const Net_Crypto *c, const uint8_t *public_key)
|
||||
* @retval 0 if source was a direct UDP connection.
|
||||
* @return positive number on success.
|
||||
*/
|
||||
non_null()
|
||||
static int crypto_connection_add_source(Net_Crypto *c, int crypt_connection_id, const IP_Port *source)
|
||||
static int crypto_connection_add_source(Net_Crypto *_Nonnull c, int crypt_connection_id, const IP_Port *_Nonnull source)
|
||||
{
|
||||
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
@@ -1955,12 +1893,10 @@ void new_connection_handler(Net_Crypto *c, new_connection_cb *new_connection_cal
|
||||
* @retval -1 on failure.
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
non_null(1, 2, 3) nullable(5)
|
||||
static int handle_new_connection_handshake(Net_Crypto *c, const IP_Port *source, const uint8_t *data, uint16_t length,
|
||||
void *userdata)
|
||||
static int handle_new_connection_handshake(Net_Crypto *_Nonnull c, const IP_Port *_Nonnull source, const uint8_t *_Nonnull data, uint16_t length,
|
||||
void *_Nullable userdata)
|
||||
{
|
||||
uint8_t *cookie = (uint8_t *)mem_balloc(c->mem, COOKIE_LENGTH);
|
||||
|
||||
if (cookie == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
@@ -2155,12 +2091,10 @@ int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, const IP_Port *ip
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null(1, 3) nullable(5)
|
||||
static int tcp_data_callback(void *object, int crypt_connection_id, const uint8_t *packet, uint16_t length,
|
||||
void *userdata)
|
||||
static int tcp_data_callback(void *_Nonnull object, int crypt_connection_id, const uint8_t *_Nonnull packet, uint16_t length,
|
||||
void *_Nullable userdata)
|
||||
{
|
||||
Net_Crypto *c = (Net_Crypto *)object;
|
||||
|
||||
if (length == 0 || length > MAX_CRYPTO_PACKET_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
@@ -2185,12 +2119,10 @@ static int tcp_data_callback(void *object, int crypt_connection_id, const uint8_
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null(1, 2, 4) nullable(6)
|
||||
static int tcp_oob_callback(void *object, const uint8_t *public_key, unsigned int tcp_connections_number,
|
||||
const uint8_t *packet, uint16_t length, void *userdata)
|
||||
static int tcp_oob_callback(void *_Nonnull object, const uint8_t *_Nonnull public_key, unsigned int tcp_connections_number,
|
||||
const uint8_t *_Nonnull packet, uint16_t length, void *_Nullable userdata)
|
||||
{
|
||||
Net_Crypto *c = (Net_Crypto *)object;
|
||||
|
||||
if (length == 0 || length > MAX_CRYPTO_PACKET_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
@@ -2312,8 +2244,7 @@ uint32_t copy_connected_tcp_relays_index(const Net_Crypto *c, Node_format *tcp_r
|
||||
return tcp_copy_connected_relays_index(c->tcp_c, tcp_relays, num, idx);
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void do_tcp(Net_Crypto *c, void *userdata)
|
||||
static void do_tcp(Net_Crypto *_Nonnull c, void *_Nonnull userdata)
|
||||
{
|
||||
do_tcp_connections(c->log, c->tcp_c, userdata);
|
||||
|
||||
@@ -2439,8 +2370,7 @@ int nc_dht_pk_callback(const Net_Crypto *c, int crypt_connection_id, dht_pk_cb *
|
||||
* return -1 on failure.
|
||||
* return connection id on success.
|
||||
*/
|
||||
non_null()
|
||||
static int crypto_id_ip_port(const Net_Crypto *c, const IP_Port *ip_port)
|
||||
static int crypto_id_ip_port(const Net_Crypto *_Nonnull c, const IP_Port *_Nonnull ip_port)
|
||||
{
|
||||
return bs_list_find(&c->ip_port_list, (const uint8_t *)ip_port);
|
||||
}
|
||||
@@ -2455,12 +2385,10 @@ static int crypto_id_ip_port(const Net_Crypto *c, const IP_Port *ip_port)
|
||||
* Crypto data packets.
|
||||
*
|
||||
*/
|
||||
non_null(1, 2, 3) nullable(5)
|
||||
static int udp_handle_packet(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length,
|
||||
void *userdata)
|
||||
static int udp_handle_packet(void *_Nonnull object, const IP_Port *_Nonnull source, const uint8_t *_Nonnull packet, uint16_t length,
|
||||
void *_Nullable userdata)
|
||||
{
|
||||
Net_Crypto *c = (Net_Crypto *)object;
|
||||
|
||||
if (length <= CRYPTO_MIN_PACKET_SIZE || length > MAX_CRYPTO_PACKET_SIZE) {
|
||||
return 1;
|
||||
}
|
||||
@@ -2518,8 +2446,7 @@ static int udp_handle_packet(void *object, const IP_Port *source, const uint8_t
|
||||
*/
|
||||
#define SEND_QUEUE_RATIO 2.0
|
||||
|
||||
non_null()
|
||||
static void send_crypto_packets(Net_Crypto *c)
|
||||
static void send_crypto_packets(Net_Crypto *_Nonnull c)
|
||||
{
|
||||
const uint64_t temp_time = current_time_monotonic(c->mono_time);
|
||||
double total_send_rate = 0;
|
||||
@@ -3033,12 +2960,10 @@ Net_Crypto *new_net_crypto(const Logger *log, const Memory *mem, const Random *r
|
||||
return temp;
|
||||
}
|
||||
|
||||
non_null(1) nullable(2)
|
||||
static void kill_timedout(Net_Crypto *c, void *userdata)
|
||||
static void kill_timedout(Net_Crypto *_Nonnull c, void *_Nullable userdata)
|
||||
{
|
||||
for (uint32_t i = 0; i < c->crypto_connections_length; ++i) {
|
||||
const Crypto_Connection *conn = get_crypto_connection(c, i);
|
||||
|
||||
if (conn == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user