mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Cleaned up packet length types in toxcore.
They are now all uint16_t instead of sometimes being uint32_t. Replaced some other uint32_t with unsigned ints.
This commit is contained in:
parent
e74225039e
commit
6bbb939855
|
@ -30,7 +30,7 @@ void do_onion(Onion *onion)
|
|||
}
|
||||
|
||||
static int handled_test_1;
|
||||
static int handle_test_1(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_test_1(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion *onion = object;
|
||||
|
||||
|
@ -46,7 +46,7 @@ static int handle_test_1(void *object, IP_Port source, const uint8_t *packet, ui
|
|||
}
|
||||
|
||||
static int handled_test_2;
|
||||
static int handle_test_2(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_test_2(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
if (length != sizeof("install Gentoo"))
|
||||
return 1;
|
||||
|
@ -72,7 +72,7 @@ uint8_t sb_data[ONION_ANNOUNCE_SENDBACK_DATA_LENGTH];
|
|||
static int handled_test_3;
|
||||
uint8_t test_3_pub_key[crypto_box_PUBLICKEYBYTES];
|
||||
uint8_t test_3_ping_id[crypto_hash_sha256_BYTES];
|
||||
static int handle_test_3(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_test_3(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion *onion = object;
|
||||
|
||||
|
@ -101,7 +101,7 @@ static int handle_test_3(void *object, IP_Port source, const uint8_t *packet, ui
|
|||
|
||||
uint8_t nonce[crypto_box_NONCEBYTES];
|
||||
static int handled_test_4;
|
||||
static int handle_test_4(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_test_4(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion *onion = object;
|
||||
|
||||
|
|
|
@ -313,7 +313,7 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed
|
|||
*
|
||||
* return True(1) or False(0)
|
||||
*/
|
||||
static int client_or_ip_port_in_list(Client_data *list, uint32_t length, const uint8_t *client_id, IP_Port ip_port)
|
||||
static int client_or_ip_port_in_list(Client_data *list, uint16_t length, const uint8_t *client_id, IP_Port ip_port)
|
||||
{
|
||||
uint32_t i;
|
||||
uint64_t temp_time = unix_time();
|
||||
|
@ -392,7 +392,7 @@ static int client_or_ip_port_in_list(Client_data *list, uint32_t length, const u
|
|||
* return 1 if true.
|
||||
* return 0 if false.
|
||||
*/
|
||||
static int client_in_nodelist(const Node_format *list, uint32_t length, const uint8_t *client_id)
|
||||
static int client_in_nodelist(const Node_format *list, uint16_t length, const uint8_t *client_id)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
@ -614,7 +614,7 @@ int get_close_nodes(const DHT *dht, const uint8_t *client_id, Node_format *nodes
|
|||
*
|
||||
* returns True(1) when the item was stored, False(0) otherwise */
|
||||
static int replace_all( Client_data *list,
|
||||
uint32_t length,
|
||||
uint16_t length,
|
||||
const uint8_t *client_id,
|
||||
IP_Port ip_port,
|
||||
const uint8_t *comp_client_id )
|
||||
|
@ -938,7 +938,7 @@ static int sendnodes_ipv6(const DHT *dht, IP_Port ip_port, const uint8_t *public
|
|||
return sendpacket(dht->net, ip_port, data, 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + len);
|
||||
}
|
||||
|
||||
static int handle_getnodes(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_getnodes(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
uint32_t cmp_len = 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + CLIENT_ID_SIZE + crypto_box_MACBYTES;
|
||||
|
||||
|
@ -1003,7 +1003,7 @@ static uint8_t sent_getnode_to_node(DHT *dht, const uint8_t *client_id, IP_Port
|
|||
static int send_hardening_getnode_res(const DHT *dht, const Node_format *sendto, const uint8_t *queried_client_id,
|
||||
const uint8_t *nodes_data, uint16_t nodes_data_length);
|
||||
|
||||
static int handle_sendnodes_core(void *object, IP_Port source, const uint8_t *packet, uint32_t length,
|
||||
static int handle_sendnodes_core(void *object, IP_Port source, const uint8_t *packet, uint16_t length,
|
||||
Node_format *plain_nodes, uint16_t size_plain_nodes, uint32_t *num_nodes_out)
|
||||
{
|
||||
DHT *dht = object;
|
||||
|
@ -1065,7 +1065,7 @@ static int handle_sendnodes_core(void *object, IP_Port source, const uint8_t *pa
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handle_sendnodes_ipv6(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_sendnodes_ipv6(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
DHT *dht = object;
|
||||
Node_format plain_nodes[MAX_SENT_NODES];
|
||||
|
@ -1419,7 +1419,7 @@ int DHT_bootstrap_from_address(DHT *dht, const char *address, uint8_t ipv6enable
|
|||
*
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int route_packet(const DHT *dht, const uint8_t *client_id, const uint8_t *packet, uint32_t length)
|
||||
int route_packet(const DHT *dht, const uint8_t *client_id, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
@ -1514,7 +1514,7 @@ static int friend_iplist(const DHT *dht, IP_Port *ip_portlist, uint16_t friend_n
|
|||
* return ip for friend.
|
||||
* return number of nodes the packet was sent to. (Only works if more than (MAX_FRIEND_CLIENTS / 4).
|
||||
*/
|
||||
int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *packet, uint32_t length)
|
||||
int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
int num = friend_number(dht, friend_id);
|
||||
|
||||
|
@ -1569,7 +1569,7 @@ int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *pack
|
|||
*
|
||||
* return number of nodes the packet was sent to.
|
||||
*/
|
||||
static int routeone_tofriend(DHT *dht, const uint8_t *friend_id, const uint8_t *packet, uint32_t length)
|
||||
static int routeone_tofriend(DHT *dht, const uint8_t *friend_id, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
int num = friend_number(dht, friend_id);
|
||||
|
||||
|
@ -1667,7 +1667,7 @@ static int send_NATping(DHT *dht, const uint8_t *public_key, uint64_t ping_id, u
|
|||
|
||||
/* Handle a received ping request for. */
|
||||
static int handle_NATping(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet,
|
||||
uint32_t length)
|
||||
uint16_t length)
|
||||
{
|
||||
if (length != sizeof(uint64_t) + 1)
|
||||
return 1;
|
||||
|
@ -1947,7 +1947,7 @@ static uint32_t have_nodes_closelist(DHT *dht, Node_format *nodes, uint16_t num)
|
|||
|
||||
/* Handle a received hardening packet */
|
||||
static int handle_hardening(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet,
|
||||
uint32_t length)
|
||||
uint16_t length)
|
||||
{
|
||||
DHT *dht = object;
|
||||
|
||||
|
@ -2208,7 +2208,7 @@ void cryptopacket_registerhandler(DHT *dht, uint8_t byte, cryptopacket_handler_c
|
|||
dht->cryptopackethandlers[byte].object = object;
|
||||
}
|
||||
|
||||
static int cryptopacket_handle(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int cryptopacket_handle(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
DHT *dht = object;
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ typedef struct {
|
|||
/*----------------------------------------------------------------------------------*/
|
||||
|
||||
typedef int (*cryptopacket_handler_callback)(void *object, IP_Port ip_port, const uint8_t *source_pubkey,
|
||||
const uint8_t *data, uint32_t len);
|
||||
const uint8_t *data, uint16_t len);
|
||||
|
||||
typedef struct {
|
||||
cryptopacket_handler_callback function;
|
||||
|
@ -369,13 +369,13 @@ int DHT_connect_after_load(DHT *dht);
|
|||
*
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int route_packet(const DHT *dht, const uint8_t *client_id, const uint8_t *packet, uint32_t length);
|
||||
int route_packet(const DHT *dht, const uint8_t *client_id, const uint8_t *packet, uint16_t length);
|
||||
|
||||
/* Send the following packet to everyone who tells us they are connected to friend_id.
|
||||
*
|
||||
* return number of nodes it sent the packet to.
|
||||
*/
|
||||
int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *packet, uint32_t length);
|
||||
int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *packet, uint16_t length);
|
||||
|
||||
/* Function to handle crypto packets.
|
||||
*/
|
||||
|
|
|
@ -280,7 +280,7 @@ int LAN_ip(IP ip)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int handle_LANdiscovery(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_LANdiscovery(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
DHT *dht = object;
|
||||
|
||||
|
|
|
@ -550,7 +550,7 @@ int kill_friend_connection(Friend_Connections *fr_c, int friendcon_id)
|
|||
* This function will be called every time a friend request packet is received.
|
||||
*/
|
||||
void set_friend_request_callback(Friend_Connections *fr_c, int (*fr_request_callback)(void *, const uint8_t *,
|
||||
const uint8_t *, uint32_t), void *object)
|
||||
const uint8_t *, uint16_t), void *object)
|
||||
{
|
||||
fr_c->fr_request_callback = fr_request_callback;
|
||||
fr_c->fr_request_object = object;
|
||||
|
|
|
@ -94,7 +94,7 @@ typedef struct {
|
|||
Friend_Conn *conns;
|
||||
uint32_t num_cons;
|
||||
|
||||
int (*fr_request_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint32_t len);
|
||||
int (*fr_request_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint16_t len);
|
||||
void *fr_request_object;
|
||||
} Friend_Connections;
|
||||
|
||||
|
@ -174,7 +174,7 @@ int send_friend_request_packet(Friend_Connections *fr_c, int friendcon_id, uint3
|
|||
* This function will be called every time a friend request is received.
|
||||
*/
|
||||
void set_friend_request_callback(Friend_Connections *fr_c, int (*fr_request_callback)(void *, const uint8_t *,
|
||||
const uint8_t *, uint32_t), void *object);
|
||||
const uint8_t *, uint16_t), void *object);
|
||||
|
||||
/* Create new friend_connections instance. */
|
||||
Friend_Connections *new_friend_connections(Onion_Client *onion_c);
|
||||
|
|
|
@ -103,7 +103,7 @@ int remove_request_received(Friend_Requests *fr, const uint8_t *client_id)
|
|||
}
|
||||
|
||||
|
||||
static int friendreq_handlepacket(void *object, const uint8_t *source_pubkey, const uint8_t *packet, uint32_t length)
|
||||
static int friendreq_handlepacket(void *object, const uint8_t *source_pubkey, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Friend_Requests *fr = object;
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ static int handle_cookie_request(const Net_Crypto *c, uint8_t *request_plain, ui
|
|||
|
||||
/* Handle the cookie request packet (for raw UDP)
|
||||
*/
|
||||
static int udp_handle_cookie_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int udp_handle_cookie_request(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Net_Crypto *c = object;
|
||||
uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH];
|
||||
|
@ -207,7 +207,7 @@ static int udp_handle_cookie_request(void *object, IP_Port source, const uint8_t
|
|||
/* Handle the cookie request packet (for TCP)
|
||||
*/
|
||||
static int tcp_handle_cookie_request(const Net_Crypto *c, TCP_Client_Connection *TCP_con, uint8_t conn_id,
|
||||
const uint8_t *packet, uint32_t length)
|
||||
const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH];
|
||||
uint8_t shared_key[crypto_box_BEFORENMBYTES];
|
||||
|
@ -230,7 +230,7 @@ static int tcp_handle_cookie_request(const Net_Crypto *c, TCP_Client_Connection
|
|||
/* Handle the cookie request packet (for TCP oob packets)
|
||||
*/
|
||||
static int tcp_oob_handle_cookie_request(const Net_Crypto *c, TCP_Client_Connection *TCP_con,
|
||||
const uint8_t *dht_public_key, const uint8_t *packet, uint32_t length)
|
||||
const uint8_t *dht_public_key, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH];
|
||||
uint8_t shared_key[crypto_box_BEFORENMBYTES];
|
||||
|
@ -261,7 +261,7 @@ static int tcp_oob_handle_cookie_request(const Net_Crypto *c, TCP_Client_Connect
|
|||
* return -1 on failure.
|
||||
* return COOKIE_LENGTH on success.
|
||||
*/
|
||||
static int handle_cookie_response(uint8_t *cookie, uint64_t *number, const uint8_t *packet, uint32_t length,
|
||||
static int handle_cookie_response(uint8_t *cookie, uint64_t *number, const uint8_t *packet, uint16_t length,
|
||||
const uint8_t *shared_key)
|
||||
{
|
||||
if (length != COOKIE_RESPONSE_LENGTH)
|
||||
|
@ -335,7 +335,7 @@ static int create_crypto_handshake(const Net_Crypto *c, uint8_t *packet, const u
|
|||
* return 0 on success.
|
||||
*/
|
||||
static int 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, uint32_t length, const uint8_t *expected_real_pk)
|
||||
uint8_t *dht_public_key, uint8_t *cookie, const uint8_t *packet, uint16_t length, const uint8_t *expected_real_pk)
|
||||
{
|
||||
if (length != HANDSHAKE_PACKET_LENGTH)
|
||||
return -1;
|
||||
|
@ -764,7 +764,7 @@ static int send_data_packet(Net_Crypto *c, int crypt_connection_id, const uint8_
|
|||
* return 0 on success.
|
||||
*/
|
||||
static int send_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint32_t buffer_start, uint32_t num,
|
||||
const uint8_t *data, uint32_t length)
|
||||
const uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (length == 0 || length > MAX_CRYPTO_DATA_SIZE)
|
||||
return -1;
|
||||
|
@ -784,7 +784,7 @@ static int send_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint3
|
|||
/* return -1 if data could not be put in packet queue.
|
||||
* return positive packet number if data was put into the queue.
|
||||
*/
|
||||
static int64_t send_lossless_packet(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length,
|
||||
static int64_t send_lossless_packet(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length,
|
||||
uint8_t congestion_control)
|
||||
{
|
||||
if (length == 0 || length > MAX_CRYPTO_DATA_SIZE)
|
||||
|
@ -2305,7 +2305,7 @@ static int crypto_id_ip_port(const Net_Crypto *c, IP_Port ip_port)
|
|||
* Crypto data packets.
|
||||
*
|
||||
*/
|
||||
static int udp_handle_packet(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int udp_handle_packet(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
if (length <= CRYPTO_MIN_PACKET_SIZE || length > MAX_CRYPTO_PACKET_SIZE)
|
||||
return 1;
|
||||
|
@ -2498,7 +2498,7 @@ uint32_t crypto_num_free_sendqueue_slots(const Net_Crypto *c, int crypt_connecti
|
|||
*
|
||||
* congestion_control: should congestion control apply to this packet?
|
||||
*/
|
||||
int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length,
|
||||
int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length,
|
||||
uint8_t congestion_control)
|
||||
{
|
||||
if (length == 0)
|
||||
|
@ -2563,7 +2563,7 @@ int cryptpacket_received(Net_Crypto *c, int crypt_connection_id, uint32_t packet
|
|||
*
|
||||
* Sends a lossy cryptopacket. (first byte must in the PACKET_ID_LOSSY_RANGE_*)
|
||||
*/
|
||||
int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length)
|
||||
int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (length == 0 || length > MAX_CRYPTO_DATA_SIZE)
|
||||
return -1;
|
||||
|
|
|
@ -325,7 +325,7 @@ uint32_t crypto_num_free_sendqueue_slots(const Net_Crypto *c, int crypt_connecti
|
|||
*
|
||||
* congestion_control: should congestion control apply to this packet?
|
||||
*/
|
||||
int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length,
|
||||
int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length,
|
||||
uint8_t congestion_control);
|
||||
|
||||
/* Check if packet_number was received by the other side.
|
||||
|
@ -342,7 +342,7 @@ int cryptpacket_received(Net_Crypto *c, int crypt_connection_id, uint32_t packet
|
|||
*
|
||||
* Sends a lossy cryptopacket. (first byte must in the PACKET_ID_LOSSY_RANGE_*)
|
||||
*/
|
||||
int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length);
|
||||
int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint16_t length);
|
||||
|
||||
/* Add a tcp relay, associating it to a crypt_connection_id.
|
||||
*
|
||||
|
|
|
@ -281,7 +281,7 @@ uint64_t current_time_monotonic(void)
|
|||
/* Basic network functions:
|
||||
* Function to send packet(data) of length length to ip_port.
|
||||
*/
|
||||
int sendpacket(Networking_Core *net, IP_Port ip_port, const uint8_t *data, uint32_t length)
|
||||
int sendpacket(Networking_Core *net, IP_Port ip_port, const uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (net->family == 0) /* Socket not initialized */
|
||||
return -1;
|
||||
|
|
|
@ -277,7 +277,7 @@ int addr_resolve_or_parse_ip(const char *address, IP *to, IP *extra);
|
|||
* Packet data is put into data.
|
||||
* Packet length is put into length.
|
||||
*/
|
||||
typedef int (*packet_handler_callback)(void *object, IP_Port ip_port, const uint8_t *data, uint32_t len);
|
||||
typedef int (*packet_handler_callback)(void *object, IP_Port ip_port, const uint8_t *data, uint16_t len);
|
||||
|
||||
typedef struct {
|
||||
packet_handler_callback function;
|
||||
|
@ -338,7 +338,7 @@ uint64_t current_time_monotonic(void);
|
|||
/* Basic network functions: */
|
||||
|
||||
/* Function to send packet(data) of length length to ip_port. */
|
||||
int sendpacket(Networking_Core *net, IP_Port ip_port, const uint8_t *data, uint32_t length);
|
||||
int sendpacket(Networking_Core *net, IP_Port ip_port, const uint8_t *data, uint16_t length);
|
||||
|
||||
/* Function to call when packet beginning with byte is received. */
|
||||
void networking_registerhandler(Networking_Core *net, uint8_t byte, packet_handler_callback cb, void *object);
|
||||
|
|
|
@ -94,7 +94,7 @@ int create_onion_path(const DHT *dht, Onion_Path *new_path, const Node_format *n
|
|||
* return length of created packet on success.
|
||||
*/
|
||||
int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest,
|
||||
const uint8_t *data, uint32_t length)
|
||||
const uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (1 + length + SEND_1 > max_packet_length || length == 0)
|
||||
return -1;
|
||||
|
@ -151,7 +151,7 @@ int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion
|
|||
* return length of created packet on success.
|
||||
*/
|
||||
int create_onion_packet_tcp(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest,
|
||||
const uint8_t *data, uint32_t length)
|
||||
const uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (crypto_box_NONCEBYTES + SIZE_IPPORT + SEND_BASE * 2 + length > max_packet_length || length == 0)
|
||||
return -1;
|
||||
|
@ -197,7 +197,7 @@ int create_onion_packet_tcp(uint8_t *packet, uint16_t max_packet_length, const O
|
|||
* return -1 on failure.
|
||||
* return 0 on success.
|
||||
*/
|
||||
int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *data, uint32_t length)
|
||||
int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *data, uint16_t length)
|
||||
{
|
||||
uint8_t packet[ONION_MAX_PACKET_SIZE];
|
||||
int len = create_onion_packet(packet, sizeof(packet), path, dest, data, length);
|
||||
|
@ -217,7 +217,7 @@ int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest
|
|||
* return -1 on failure.
|
||||
* return 0 on success.
|
||||
*/
|
||||
int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, uint32_t length, const uint8_t *ret)
|
||||
int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, uint16_t length, const uint8_t *ret)
|
||||
{
|
||||
if (length > ONION_RESPONSE_MAX_DATA_SIZE || length == 0)
|
||||
return -1;
|
||||
|
@ -233,7 +233,7 @@ int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handle_send_initial(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_send_initial(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion *onion = object;
|
||||
|
||||
|
@ -257,7 +257,7 @@ static int handle_send_initial(void *object, IP_Port source, const uint8_t *pack
|
|||
return onion_send_1(onion, plain, len, source, packet + 1);
|
||||
}
|
||||
|
||||
int onion_send_1(const Onion *onion, const uint8_t *plain, uint32_t len, IP_Port source, const uint8_t *nonce)
|
||||
int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len, IP_Port source, const uint8_t *nonce)
|
||||
{
|
||||
if (len > ONION_MAX_PACKET_SIZE + SIZE_IPPORT - (1 + crypto_box_NONCEBYTES + ONION_RETURN_1))
|
||||
return 1;
|
||||
|
@ -276,7 +276,7 @@ int onion_send_1(const Onion *onion, const uint8_t *plain, uint32_t len, IP_Port
|
|||
data[0] = NET_PACKET_ONION_SEND_1;
|
||||
memcpy(data + 1, nonce, crypto_box_NONCEBYTES);
|
||||
memcpy(data + 1 + crypto_box_NONCEBYTES, plain + SIZE_IPPORT, len - SIZE_IPPORT);
|
||||
uint32_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT);
|
||||
uint16_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT);
|
||||
uint8_t *ret_part = data + data_len;
|
||||
new_nonce(ret_part);
|
||||
len = encrypt_data_symmetric(onion->secret_symmetric_key, ret_part, ip_port, SIZE_IPPORT,
|
||||
|
@ -293,7 +293,7 @@ int onion_send_1(const Onion *onion, const uint8_t *plain, uint32_t len, IP_Port
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handle_send_1(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_send_1(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion *onion = object;
|
||||
|
||||
|
@ -322,7 +322,7 @@ static int handle_send_1(void *object, IP_Port source, const uint8_t *packet, ui
|
|||
data[0] = NET_PACKET_ONION_SEND_2;
|
||||
memcpy(data + 1, packet + 1, crypto_box_NONCEBYTES);
|
||||
memcpy(data + 1 + crypto_box_NONCEBYTES, plain + SIZE_IPPORT, len - SIZE_IPPORT);
|
||||
uint32_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT);
|
||||
uint16_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT);
|
||||
uint8_t *ret_part = data + data_len;
|
||||
new_nonce(ret_part);
|
||||
uint8_t ret_data[RETURN_1 + SIZE_IPPORT];
|
||||
|
@ -342,7 +342,7 @@ static int handle_send_1(void *object, IP_Port source, const uint8_t *packet, ui
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion *onion = object;
|
||||
|
||||
|
@ -369,7 +369,7 @@ static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, ui
|
|||
|
||||
uint8_t data[ONION_MAX_PACKET_SIZE];
|
||||
memcpy(data, plain + SIZE_IPPORT, len - SIZE_IPPORT);
|
||||
uint32_t data_len = (len - SIZE_IPPORT);
|
||||
uint16_t data_len = (len - SIZE_IPPORT);
|
||||
uint8_t *ret_part = data + (len - SIZE_IPPORT);
|
||||
new_nonce(ret_part);
|
||||
uint8_t ret_data[RETURN_2 + SIZE_IPPORT];
|
||||
|
@ -390,7 +390,7 @@ static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, ui
|
|||
}
|
||||
|
||||
|
||||
static int handle_recv_3(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_recv_3(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion *onion = object;
|
||||
|
||||
|
@ -416,7 +416,7 @@ static int handle_recv_3(void *object, IP_Port source, const uint8_t *packet, ui
|
|||
data[0] = NET_PACKET_ONION_RECV_2;
|
||||
memcpy(data + 1, plain + SIZE_IPPORT, RETURN_2);
|
||||
memcpy(data + 1 + RETURN_2, packet + 1 + RETURN_3, length - (1 + RETURN_3));
|
||||
uint32_t data_len = 1 + RETURN_2 + (length - (1 + RETURN_3));
|
||||
uint16_t data_len = 1 + RETURN_2 + (length - (1 + RETURN_3));
|
||||
|
||||
if ((uint32_t)sendpacket(onion->net, send_to, data, data_len) != data_len)
|
||||
return 1;
|
||||
|
@ -424,7 +424,7 @@ static int handle_recv_3(void *object, IP_Port source, const uint8_t *packet, ui
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handle_recv_2(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_recv_2(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion *onion = object;
|
||||
|
||||
|
@ -450,7 +450,7 @@ static int handle_recv_2(void *object, IP_Port source, const uint8_t *packet, ui
|
|||
data[0] = NET_PACKET_ONION_RECV_1;
|
||||
memcpy(data + 1, plain + SIZE_IPPORT, RETURN_1);
|
||||
memcpy(data + 1 + RETURN_1, packet + 1 + RETURN_2, length - (1 + RETURN_2));
|
||||
uint32_t data_len = 1 + RETURN_1 + (length - (1 + RETURN_2));
|
||||
uint16_t data_len = 1 + RETURN_1 + (length - (1 + RETURN_2));
|
||||
|
||||
if ((uint32_t)sendpacket(onion->net, send_to, data, data_len) != data_len)
|
||||
return 1;
|
||||
|
@ -458,7 +458,7 @@ static int handle_recv_2(void *object, IP_Port source, const uint8_t *packet, ui
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handle_recv_1(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_recv_1(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion *onion = object;
|
||||
|
||||
|
@ -480,7 +480,7 @@ static int handle_recv_1(void *object, IP_Port source, const uint8_t *packet, ui
|
|||
IP_Port send_to;
|
||||
ipport_unpack(&send_to, plain);
|
||||
|
||||
uint32_t data_len = length - (1 + RETURN_1);
|
||||
uint16_t data_len = length - (1 + RETURN_1);
|
||||
|
||||
if (onion->recv_1_function && send_to.ip.family != AF_INET && send_to.ip.family != AF_INET6)
|
||||
return onion->recv_1_function(onion->callback_object, send_to, packet + (1 + RETURN_1), data_len);
|
||||
|
|
|
@ -90,7 +90,7 @@ int create_onion_path(const DHT *dht, Onion_Path *new_path, const Node_format *n
|
|||
* return length of created packet on success.
|
||||
*/
|
||||
int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest,
|
||||
const uint8_t *data, uint32_t length);
|
||||
const uint8_t *data, uint16_t length);
|
||||
|
||||
|
||||
/* Create a onion packet to be sent over tcp.
|
||||
|
@ -103,7 +103,7 @@ int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion
|
|||
* return length of created packet on success.
|
||||
*/
|
||||
int create_onion_packet_tcp(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest,
|
||||
const uint8_t *data, uint32_t length);
|
||||
const uint8_t *data, uint16_t length);
|
||||
|
||||
/* Create and send a onion packet.
|
||||
*
|
||||
|
@ -113,7 +113,7 @@ int create_onion_packet_tcp(uint8_t *packet, uint16_t max_packet_length, const O
|
|||
* return -1 on failure.
|
||||
* return 0 on success.
|
||||
*/
|
||||
int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *data, uint32_t length);
|
||||
int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *data, uint16_t length);
|
||||
|
||||
/* Create and send a onion response sent initially to dest with.
|
||||
* Maximum length of data is ONION_RESPONSE_MAX_DATA_SIZE.
|
||||
|
@ -121,7 +121,7 @@ int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest
|
|||
* return -1 on failure.
|
||||
* return 0 on success.
|
||||
*/
|
||||
int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, uint32_t length, const uint8_t *ret);
|
||||
int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, uint16_t length, const uint8_t *ret);
|
||||
|
||||
/* Function to handle/send received decrypted versions of the packet sent with send_onion_packet.
|
||||
*
|
||||
|
@ -133,11 +133,11 @@ int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data,
|
|||
* Source family must be set to something else than AF_INET6 or AF_INET so that the callback gets called
|
||||
* when the response is received.
|
||||
*/
|
||||
int onion_send_1(const Onion *onion, const uint8_t *plain, uint32_t len, IP_Port source, const uint8_t *nonce);
|
||||
int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len, IP_Port source, const uint8_t *nonce);
|
||||
|
||||
/* Set the callback to be called when the dest ip_port doesn't have AF_INET6 or AF_INET as the family.
|
||||
*
|
||||
* Format: function(void *object, IP_Port dest, uint8_t *data, uint32_t length)
|
||||
* Format: function(void *object, IP_Port dest, uint8_t *data, uint16_t length)
|
||||
*/
|
||||
void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, const uint8_t *, uint16_t),
|
||||
void *object);
|
||||
|
|
|
@ -207,7 +207,7 @@ static void generate_ping_id(const Onion_Announce *onion_a, uint64_t time, const
|
|||
*/
|
||||
static int in_entries(const Onion_Announce *onion_a, const uint8_t *public_key)
|
||||
{
|
||||
uint32_t i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ONION_ANNOUNCE_MAX_ENTRIES; ++i) {
|
||||
if (!is_timeout(onion_a->entries[i].time, ONION_ANNOUNCE_TIMEOUT)
|
||||
|
@ -258,7 +258,7 @@ static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, const ui
|
|||
|
||||
int pos = in_entries(onion_a, public_key);
|
||||
|
||||
uint32_t i;
|
||||
unsigned int i;
|
||||
|
||||
if (pos == -1) {
|
||||
for (i = 0; i < ONION_ANNOUNCE_MAX_ENTRIES; ++i) {
|
||||
|
@ -286,7 +286,7 @@ static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, const ui
|
|||
return in_entries(onion_a, public_key);
|
||||
}
|
||||
|
||||
static int handle_announce_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_announce_request(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion_Announce *onion_a = object;
|
||||
|
||||
|
@ -325,8 +325,8 @@ static int handle_announce_request(void *object, IP_Port source, const uint8_t *
|
|||
|
||||
/*Respond with a announce response packet*/
|
||||
Node_format nodes_list[MAX_SENT_NODES];
|
||||
uint32_t num_nodes = get_close_nodes(onion_a->dht, plain + ONION_PING_ID_SIZE, nodes_list, 0, LAN_ip(source.ip) == 0,
|
||||
1);
|
||||
unsigned int num_nodes = get_close_nodes(onion_a->dht, plain + ONION_PING_ID_SIZE, nodes_list, 0,
|
||||
LAN_ip(source.ip) == 0, 1);
|
||||
uint8_t nonce[crypto_box_NONCEBYTES];
|
||||
random_nonce(nonce);
|
||||
|
||||
|
@ -379,7 +379,7 @@ static int handle_announce_request(void *object, IP_Port source, const uint8_t *
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handle_data_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_data_request(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion_Announce *onion_a = object;
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ static uint16_t random_nodes_path_onion(const Onion_Client *onion_c, Node_format
|
|||
*/
|
||||
static int is_path_used(const Onion_Client_Paths *onion_paths, const Node_format *nodes)
|
||||
{
|
||||
uint32_t i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < NUMBER_ONION_PATHS; ++i) {
|
||||
if (is_timeout(onion_paths->last_path_success[i], ONION_PATH_TIMEOUT)) {
|
||||
|
@ -222,7 +222,7 @@ static uint32_t set_path_timeouts(Onion_Client *onion_c, uint32_t num, uint32_t
|
|||
* return 0 on success.
|
||||
*/
|
||||
static int send_onion_packet_tcp_udp(const Onion_Client *onion_c, const Onion_Path *path, IP_Port dest,
|
||||
const uint8_t *data, uint32_t length)
|
||||
const uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (path->ip_port1.ip.family == AF_INET || path->ip_port1.ip.family == AF_INET6) {
|
||||
uint8_t packet[ONION_MAX_PACKET_SIZE];
|
||||
|
@ -411,7 +411,7 @@ static int client_add_to_list(Onion_Client *onion_c, uint32_t num, const uint8_t
|
|||
qsort(list_nodes, MAX_ONION_CLIENTS, sizeof(Onion_Node), cmp_entry);
|
||||
|
||||
int index = -1, stored = 0;
|
||||
uint32_t i;
|
||||
unsigned int i;
|
||||
|
||||
if (is_timeout(list_nodes[0].timestamp, ONION_NODE_TIMEOUT)
|
||||
|| id_closest(reference_id, list_nodes[0].client_id, public_key) == 2) {
|
||||
|
@ -453,7 +453,7 @@ static int client_add_to_list(Onion_Client *onion_c, uint32_t num, const uint8_t
|
|||
|
||||
static int good_to_ping(Last_Pinged *last_pinged, uint8_t *last_pinged_index, const uint8_t *client_id)
|
||||
{
|
||||
uint32_t i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < MAX_STORED_PINGED_NODES; ++i) {
|
||||
if (!is_timeout(last_pinged[i].timestamp, MIN_NODE_PING_TIME))
|
||||
|
@ -494,7 +494,7 @@ static int client_ping_nodes(Onion_Client *onion_c, uint32_t num, const Node_for
|
|||
last_pinged_index = &onion_c->friends_list[num - 1].last_pinged_index;
|
||||
}
|
||||
|
||||
uint32_t i, j;
|
||||
unsigned int i, j;
|
||||
int lan_ips_accepted = (LAN_ip(source.ip) == 0);
|
||||
|
||||
for (i = 0; i < num_nodes; ++i) {
|
||||
|
@ -521,7 +521,7 @@ static int client_ping_nodes(Onion_Client *onion_c, uint32_t num, const Node_for
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handle_announce_response(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_announce_response(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion_Client *onion_c = object;
|
||||
|
||||
|
@ -579,7 +579,7 @@ static int handle_announce_response(void *object, IP_Port source, const uint8_t
|
|||
|
||||
#define DATA_IN_RESPONSE_MIN_SIZE ONION_DATA_IN_RESPONSE_MIN_SIZE
|
||||
|
||||
static int handle_data_response(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_data_response(void *object, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
Onion_Client *onion_c = object;
|
||||
|
||||
|
@ -614,7 +614,7 @@ static int handle_data_response(void *object, IP_Port source, const uint8_t *pac
|
|||
#define FAKEID_DATA_ID 156
|
||||
#define FAKEID_DATA_MIN_LENGTH (1 + sizeof(uint64_t) + crypto_box_PUBLICKEYBYTES)
|
||||
#define FAKEID_DATA_MAX_LENGTH (FAKEID_DATA_MIN_LENGTH + sizeof(Node_format)*MAX_SENT_NODES)
|
||||
static int handle_fakeid_announce(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint32_t length)
|
||||
static int handle_fakeid_announce(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint16_t length)
|
||||
{
|
||||
Onion_Client *onion_c = object;
|
||||
|
||||
|
@ -700,7 +700,7 @@ static int handle_tcp_onion(void *object, const uint8_t *data, uint16_t length)
|
|||
* return the number of packets sent on success
|
||||
* return -1 on failure.
|
||||
*/
|
||||
int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint32_t length)
|
||||
int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint16_t length)
|
||||
{
|
||||
if ((uint32_t)friend_num >= onion_c->num_friends)
|
||||
return -1;
|
||||
|
@ -722,7 +722,7 @@ int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *
|
|||
if ((uint32_t)len + crypto_box_PUBLICKEYBYTES != sizeof(packet))
|
||||
return -1;
|
||||
|
||||
uint32_t i, good_nodes[MAX_ONION_CLIENTS], num_good = 0, num_nodes = 0;
|
||||
unsigned int i, good_nodes[MAX_ONION_CLIENTS], num_good = 0, num_nodes = 0;
|
||||
Onion_Path path[MAX_ONION_CLIENTS];
|
||||
Onion_Node *list_nodes = onion_c->friends_list[friend_num].clients_list;
|
||||
|
||||
|
@ -744,7 +744,7 @@ int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *
|
|||
if (num_good < (num_nodes / 4) + 1)
|
||||
return -1;
|
||||
|
||||
uint32_t good = 0;
|
||||
unsigned int good = 0;
|
||||
|
||||
for (i = 0; i < num_good; ++i) {
|
||||
uint8_t o_packet[ONION_MAX_PACKET_SIZE];
|
||||
|
@ -768,7 +768,7 @@ int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *
|
|||
* return the number of packets sent on success
|
||||
* return -1 on failure.
|
||||
*/
|
||||
static int send_dht_fakeid(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint32_t length)
|
||||
static int send_dht_fakeid(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint16_t length)
|
||||
{
|
||||
if ((uint32_t)friend_num >= onion_c->num_friends)
|
||||
return -1;
|
||||
|
@ -799,7 +799,7 @@ static int send_dht_fakeid(const Onion_Client *onion_c, int friend_num, const ui
|
|||
}
|
||||
|
||||
static int handle_dht_fakeid(void *object, IP_Port source, const uint8_t *source_pubkey, const uint8_t *packet,
|
||||
uint32_t length)
|
||||
uint16_t length)
|
||||
{
|
||||
Onion_Client *onion_c = object;
|
||||
|
||||
|
@ -880,7 +880,7 @@ static int send_fakeid_announce(const Onion_Client *onion_c, uint16_t friend_num
|
|||
*/
|
||||
int onion_friend_num(const Onion_Client *onion_c, const uint8_t *client_id)
|
||||
{
|
||||
uint32_t i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < onion_c->num_friends; ++i) {
|
||||
if (onion_c->friends_list[i].status == 0)
|
||||
|
@ -927,7 +927,7 @@ int onion_addfriend(Onion_Client *onion_c, const uint8_t *client_id)
|
|||
if (num != -1)
|
||||
return num;
|
||||
|
||||
uint32_t i, index = ~0;
|
||||
unsigned int i, index = ~0;
|
||||
|
||||
for (i = 0; i < onion_c->num_friends; ++i) {
|
||||
if (onion_c->friends_list[i].status == 0) {
|
||||
|
@ -965,7 +965,7 @@ int onion_delfriend(Onion_Client *onion_c, int friend_num)
|
|||
// DHT_delfriend(onion_c->dht, onion_c->friends_list[friend_num].fake_client_id, 0);
|
||||
|
||||
memset(&(onion_c->friends_list[friend_num]), 0, sizeof(Onion_Friend));
|
||||
uint32_t i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = onion_c->num_friends; i != 0; --i) {
|
||||
if (onion_c->friends_list[i - 1].status != 0)
|
||||
|
@ -1121,7 +1121,7 @@ static void populate_path_nodes(Onion_Client *onion_c)
|
|||
uint32_t random_num = rand();
|
||||
memcpy(client_id, &random_num, sizeof(random_num));
|
||||
|
||||
uint32_t num_nodes = get_close_nodes(onion_c->dht, client_id, nodes_list, (rand() % 2) ? AF_INET : AF_INET6, 1, 0);
|
||||
unsigned int num_nodes = get_close_nodes(onion_c->dht, client_id, nodes_list, (rand() % 2) ? AF_INET : AF_INET6, 1, 0);
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < num_nodes; ++i) {
|
||||
|
@ -1143,12 +1143,12 @@ static void do_friend(Onion_Client *onion_c, uint16_t friendnum)
|
|||
if (onion_c->friends_list[friendnum].status == 0)
|
||||
return;
|
||||
|
||||
uint32_t interval = ANNOUNCE_FRIEND;
|
||||
unsigned int interval = ANNOUNCE_FRIEND;
|
||||
|
||||
if (onion_c->friends_list[friendnum].run_count < RUN_COUNT_FRIEND_ANNOUNCE_BEGINNING)
|
||||
interval = ANNOUNCE_FRIEND_BEGINNING;
|
||||
|
||||
uint32_t i, count = 0;
|
||||
unsigned int i, count = 0;
|
||||
Onion_Node *list_nodes = onion_c->friends_list[friendnum].clients_list;
|
||||
|
||||
if (!onion_c->friends_list[friendnum].is_online) {
|
||||
|
@ -1218,7 +1218,7 @@ void oniondata_registerhandler(Onion_Client *onion_c, uint8_t byte, oniondata_ha
|
|||
|
||||
static void do_announce(Onion_Client *onion_c)
|
||||
{
|
||||
uint32_t i, count = 0;
|
||||
unsigned int i, count = 0;
|
||||
Onion_Node *list_nodes = onion_c->clients_announce_list;
|
||||
|
||||
for (i = 0; i < MAX_ONION_CLIENTS; ++i) {
|
||||
|
@ -1233,7 +1233,7 @@ static void do_announce(Onion_Client *onion_c)
|
|||
continue;
|
||||
}
|
||||
|
||||
uint32_t interval = ANNOUNCE_INTERVAL_NOT_ANNOUNCED;
|
||||
unsigned int interval = ANNOUNCE_INTERVAL_NOT_ANNOUNCED;
|
||||
|
||||
if (list_nodes[i].is_stored) {
|
||||
interval = ANNOUNCE_INTERVAL_ANNOUNCED;
|
||||
|
@ -1264,7 +1264,7 @@ static void do_announce(Onion_Client *onion_c)
|
|||
|
||||
void do_onion_client(Onion_Client *onion_c)
|
||||
{
|
||||
uint32_t i;
|
||||
unsigned int i;
|
||||
|
||||
if (onion_c->last_run == unix_time())
|
||||
return;
|
||||
|
|
|
@ -115,7 +115,7 @@ typedef struct {
|
|||
} Onion_Friend;
|
||||
|
||||
typedef int (*oniondata_handler_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data,
|
||||
uint32_t len);
|
||||
uint16_t len);
|
||||
|
||||
typedef struct {
|
||||
DHT *dht;
|
||||
|
@ -255,7 +255,7 @@ unsigned int onion_getfriend_DHT_pubkey(const Onion_Client *onion_c, int friend_
|
|||
* return the number of packets sent on success
|
||||
* return -1 on failure.
|
||||
*/
|
||||
int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint32_t length);
|
||||
int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint16_t length);
|
||||
|
||||
/* Function to call when onion data packet with contents beginning with byte is received. */
|
||||
void oniondata_registerhandler(Onion_Client *onion_c, uint8_t byte, oniondata_handler_callback cb, void *object);
|
||||
|
|
|
@ -129,7 +129,7 @@ static int send_ping_response(PING *ping, IP_Port ipp, const uint8_t *client_id,
|
|||
return sendpacket(ping->dht->net, ipp, pk, sizeof(pk));
|
||||
}
|
||||
|
||||
static int handle_ping_request(void *_dht, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_ping_request(void *_dht, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
DHT *dht = _dht;
|
||||
int rc;
|
||||
|
@ -168,7 +168,7 @@ static int handle_ping_request(void *_dht, IP_Port source, const uint8_t *packet
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int handle_ping_response(void *_dht, IP_Port source, const uint8_t *packet, uint32_t length)
|
||||
static int handle_ping_response(void *_dht, IP_Port source, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
DHT *dht = _dht;
|
||||
int rc;
|
||||
|
@ -225,7 +225,7 @@ static int handle_ping_response(void *_dht, IP_Port source, const uint8_t *packe
|
|||
* return 1 if it is.
|
||||
* return 0 if it isn't.
|
||||
*/
|
||||
static int in_list(const Client_data *list, uint32_t length, const uint8_t *client_id, IP_Port ip_port)
|
||||
static int in_list(const Client_data *list, uint16_t length, const uint8_t *client_id, IP_Port ip_port)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user