Merge branch 'const_correctness' of https://github.com/schuetzm/ProjectTox-Core into schuetzm-const_correctness

This commit is contained in:
irungentoo 2014-06-15 10:29:13 -04:00
commit a38d962b04
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
18 changed files with 124 additions and 123 deletions

View File

@ -1067,7 +1067,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, uint8_t *packet, uint32_t length)
static int handle_getnodes(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
uint32_t cmp_len = 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + CLIENT_ID_SIZE + crypto_box_MACBYTES;
@ -1194,7 +1194,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, uint8_t *packet, uint32_t length)
static int handle_sendnodes_ipv6(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
DHT *dht = object;
Node_format plain_nodes[MAX_SENT_NODES];
@ -2296,7 +2296,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, uint8_t *packet, uint32_t length)
static int cryptopacket_handle(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
DHT *dht = object;

View File

@ -98,7 +98,7 @@ static void fetch_broadcast_info(uint16_t port)
* return 1 if sent to at least one broadcast target.
* return 0 on failure to find any valid broadcast target.
*/
static uint32_t send_broadcasts(Networking_Core *net, uint16_t port, uint8_t *data, uint16_t length)
static uint32_t send_broadcasts(Networking_Core *net, uint16_t port, const uint8_t *data, uint16_t length)
{
/* fetch only once? on every packet? every X seconds?
* old: every packet, new: once */
@ -207,7 +207,7 @@ int LAN_ip(IP ip)
return -1;
}
static int handle_LANdiscovery(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_LANdiscovery(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
DHT *dht = object;

View File

@ -959,7 +959,7 @@ static int get_chat_num(Messenger *m, Group_Chat *chat)
return -1;
}
static void group_message_function(Group_Chat *chat, int peer_number, uint8_t *message, uint16_t length, void *userdata)
static void group_message_function(Group_Chat *chat, int peer_number, const uint8_t *message, uint16_t length, void *userdata)
{
Messenger *m = userdata;
int i = get_chat_num(m, chat);
@ -975,7 +975,7 @@ static void group_message_function(Group_Chat *chat, int peer_number, uint8_t *m
(*m->group_message)(m, i, peer_number, message_terminated, length, m->group_message_userdata);
}
static void group_action_function(Group_Chat *chat, int peer_number, uint8_t *action, uint16_t length, void *userdata)
static void group_action_function(Group_Chat *chat, int peer_number, const uint8_t *action, uint16_t length, void *userdata)
{
Messenger *m = userdata;
int i = get_chat_num(m, chat);
@ -1261,7 +1261,7 @@ int group_names(Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES],
return group_client_names(m->chats[groupnumber], names, lengths, length);
}
static int handle_group(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_group(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
Messenger *m = object;

View File

@ -619,7 +619,7 @@ static int rm_connection_index(TCP_Server *TCP_server, TCP_Secure_Connection *co
}
}
static int handle_onion_recv_1(void *object, IP_Port dest, uint8_t *data, uint16_t length)
static int handle_onion_recv_1(void *object, IP_Port dest, const uint8_t *data, uint16_t length)
{
TCP_Server *TCP_server = object;
uint32_t index = dest.ip.ip6.uint32[0];

View File

@ -103,7 +103,7 @@ struct Assoc {
/* the complete distance would be CLIENT_ID_SIZE long...
* returns DISTANCE_INDEX_DISTANCE_BITS valid bits */
static uint64_t id_distance(Assoc *assoc, void *callback_data, uint8_t *id_ref, uint8_t *id_test)
static uint64_t id_distance(const Assoc *assoc, void *callback_data, const uint8_t *id_ref, const uint8_t *id_test)
{
/* with BIG_ENDIAN, this would be a one-liner... */
uint64_t retval = 0;
@ -196,7 +196,7 @@ static void dist_index_bubble(Assoc *assoc, uint64_t *dist_list, size_t first, s
*
* Result is NOT MAPPED to CANDIDATES_TO_KEEP range, i.e. map before using
* it for list access. */
static hash_t id_hash(Assoc *assoc, uint8_t *id)
static hash_t id_hash(const Assoc *assoc, const uint8_t *id)
{
uint32_t i, res = 0x19a64e82;
@ -213,7 +213,7 @@ static hash_t id_hash(Assoc *assoc, uint8_t *id)
/* up to HASH_COLLIDE_COUNT calls to different spots,
* result IS mapped to CANDIDATES_TO_KEEP range */
static hash_t hash_collide(Assoc *assoc, hash_t hash)
static hash_t hash_collide(const Assoc *assoc, hash_t hash)
{
uint64_t hash64 = hash % assoc->candidates_bucket_size;
hash64 = (hash64 * HASH_COLLIDE_PRIME) % assoc->candidates_bucket_size;
@ -241,7 +241,7 @@ static hash_t hash_collide(Assoc *assoc, hash_t hash)
}
/* returns the "seen" assoc related to the ipp */
static IPPTsPng *entry_assoc(Client_entry *cl_entry, IP_Port *ipp)
static IPPTsPng *entry_assoc(Client_entry *cl_entry, const IP_Port *ipp)
{
if (!cl_entry)
return NULL;
@ -256,7 +256,7 @@ static IPPTsPng *entry_assoc(Client_entry *cl_entry, IP_Port *ipp)
}
/* returns the "heard" assoc related to the ipp */
static IP_Port *entry_heard_get(Client_entry *entry, IP_Port *ipp)
static IP_Port *entry_heard_get(Client_entry *entry, const IP_Port *ipp)
{
if (ipp->ip.family == AF_INET)
return &entry->assoc_heard4;
@ -271,7 +271,7 @@ static IP_Port *entry_heard_get(Client_entry *entry, IP_Port *ipp)
* LAN ip
*
* returns 1 if the entry did change */
static int entry_heard_store(Client_entry *entry, IPPTs *ippts)
static int entry_heard_store(Client_entry *entry, const IPPTs *ippts)
{
if (!entry || !ippts)
return 0;
@ -279,7 +279,8 @@ static int entry_heard_store(Client_entry *entry, IPPTs *ippts)
if (!ipport_isset(&ippts->ip_port))
return 0;
IP_Port *heard, *ipp = &ippts->ip_port;
IP_Port *heard;
const IP_Port *ipp = &ippts->ip_port;
if (ipp->ip.family == AF_INET)
heard = &entry->assoc_heard4;
@ -314,13 +315,13 @@ static int entry_heard_store(Client_entry *entry, IPPTs *ippts)
}
/* maps Assoc callback signature to id_closest() */
static int assoc_id_closest(Assoc *assoc, void *callback_data, uint8_t *client_id, uint8_t *client_id1,
uint8_t *client_id2)
static int assoc_id_closest(const Assoc *assoc, void *callback_data, const uint8_t *client_id, const uint8_t *client_id1,
const uint8_t *client_id2)
{
return id_closest(client_id, client_id1, client_id2);
}
static bucket_t id_bucket(uint8_t *id, uint8_t bits)
static bucket_t id_bucket(const uint8_t *id, uint8_t bits)
{
/* return the first "bits" bits of id */
bucket_t retval = 0;
@ -340,12 +341,12 @@ static bucket_t id_bucket(uint8_t *id, uint8_t bits)
/*****************************************************************************/
static bucket_t candidates_id_bucket(Assoc *assoc, uint8_t *id)
static bucket_t candidates_id_bucket(const Assoc *assoc, const uint8_t *id)
{
return id_bucket(id, assoc->candidates_bucket_bits);
}
static uint8_t candidates_search(Assoc *assoc, uint8_t *id, hash_t hash, Client_entry **entryptr)
static uint8_t candidates_search(const Assoc *assoc, const uint8_t *id, hash_t hash, Client_entry **entryptr)
{
bucket_t bucket = candidates_id_bucket(assoc, id);
candidates_bucket *cnd_bckt = &assoc->candidates[bucket];
@ -365,8 +366,8 @@ static uint8_t candidates_search(Assoc *assoc, uint8_t *id, hash_t hash, Client_
return 0;
}
static void candidates_update_assoc(Assoc *assoc, Client_entry *entry, uint8_t used, IPPTs *ippts_send,
IP_Port *ipp_recv)
static void candidates_update_assoc(const Assoc *assoc, Client_entry *entry, uint8_t used, const IPPTs *ippts_send,
const IP_Port *ipp_recv)
{
if (!assoc || !entry || !ippts_send)
return;
@ -397,7 +398,7 @@ static void candidates_update_assoc(Assoc *assoc, Client_entry *entry, uint8_t u
entry_heard_store(entry, ippts_send);
}
static uint8_t candidates_create_internal(Assoc *assoc, hash_t hash, uint8_t *id, uint8_t seen,
static uint8_t candidates_create_internal(const Assoc *assoc, hash_t const hash, const uint8_t *id, uint8_t seen,
uint8_t used, bucket_t *bucketptr, size_t *posptr)
{
if (!assoc || !id || !bucketptr || !posptr)
@ -454,8 +455,8 @@ static uint8_t candidates_create_internal(Assoc *assoc, hash_t hash, uint8_t *id
return 0;
}
static uint8_t candidates_create_new(Assoc *assoc, hash_t hash, uint8_t *id, uint8_t used,
IPPTs *ippts_send, IP_Port *ipp_recv)
static uint8_t candidates_create_new(const Assoc *assoc, hash_t hash, const uint8_t *id, uint8_t used,
const IPPTs *ippts_send, const IP_Port *ipp_recv)
{
if (!assoc || !id || !ippts_send)
return 0;
@ -550,7 +551,7 @@ static void client_id_self_update(Assoc *assoc)
* seen should be 0 (zero), if the candidate was announced by someone else,
* seen should be 1 (one), if there is confirmed connectivity (a definite response)
*/
uint8_t Assoc_add_entry(Assoc *assoc, uint8_t *id, IPPTs *ippts_send, IP_Port *ipp_recv, uint8_t used)
uint8_t Assoc_add_entry(Assoc *assoc, const uint8_t *id, const IPPTs *ippts_send, const IP_Port *ipp_recv, uint8_t used)
{
if (!assoc || !id || !ippts_send)
return 0;
@ -777,7 +778,7 @@ static size_t prime_upto_min9(size_t limit)
}
/* create */
Assoc *new_Assoc(size_t bits, size_t entries, uint8_t *public_id)
Assoc *new_Assoc(size_t bits, size_t entries, const uint8_t *public_id)
{
if (!public_id)
return NULL;
@ -850,7 +851,7 @@ Assoc *new_Assoc(size_t bits, size_t entries, uint8_t *public_id)
return assoc;
}
Assoc *new_Assoc_default(uint8_t *public_id)
Assoc *new_Assoc_default(const uint8_t *public_id)
{
/* original 8, 251 averages to ~32k entries... probably the whole DHT :D
* 320 entries is fine, hopefully */
@ -858,7 +859,7 @@ Assoc *new_Assoc_default(uint8_t *public_id)
}
/* own client_id, assocs for this have to be ignored */
void Assoc_self_client_id_changed(Assoc *assoc, uint8_t *id)
void Assoc_self_client_id_changed(Assoc *assoc, const uint8_t *id)
{
if (assoc && id) {
assoc->self_hash = 0;

View File

@ -21,21 +21,21 @@ typedef struct Assoc Assoc;
/* custom distance handler, if it's not ID-distance based
* return values exactly like id_closest() */
typedef int (*Assoc_distance_relative_callback)(Assoc *assoc, void *callback_data, uint8_t *client_id,
uint8_t *client_id1, uint8_t *client_id2);
typedef int (*Assoc_distance_relative_callback)(const Assoc *assoc, void *callback_data, const uint8_t *client_id,
const uint8_t *client_id1, const uint8_t *client_id2);
#define DISTANCE_INDEX_DISTANCE_BITS 44
/* absolute distance: can be same for different client_id_check values
* return value should have DISTANCE_INDEX_DISTANCE_BITS valid bits */
typedef uint64_t (*Assoc_distance_absolute_callback)(Assoc *assoc, void *callback_data,
uint8_t *client_id_ref, uint8_t *client_id_check);
typedef uint64_t (*Assoc_distance_absolute_callback)(const Assoc *assoc, void *callback_data,
const uint8_t *client_id_ref, const uint8_t *client_id_check);
/*****************************************************************************/
/* Central entry point for new associations: add a new candidate to the cache
* returns 1 if entry is stored, 2 if existing entry was updated, 0 else */
uint8_t Assoc_add_entry(Assoc *assoc, uint8_t *id, IPPTs *ippts_send, IP_Port *ipp_recv, uint8_t used);
uint8_t Assoc_add_entry(Assoc *assoc, const uint8_t *id, const IPPTs *ippts_send, const IP_Port *ipp_recv, uint8_t used);
/*****************************************************************************/
@ -72,7 +72,7 @@ uint8_t Assoc_get_close_entries(Assoc *assoc, Assoc_close_entries *close_entries
/*****************************************************************************/
/* create: default sizes (6, 5 => 320 entries) */
Assoc *new_Assoc_default(uint8_t *public_id);
Assoc *new_Assoc_default(const uint8_t *public_id);
/* create: customized sizes
* total is (2^bits) * entries
@ -81,10 +81,10 @@ Assoc *new_Assoc_default(uint8_t *public_id);
*
* preferably bits should be large and entries small to ensure spread
* in the search space (e. g. 5, 5 is preferable to 2, 41) */
Assoc *new_Assoc(size_t bits, size_t entries, uint8_t *public_id);
Assoc *new_Assoc(size_t bits, size_t entries, const uint8_t *public_id);
/* public_id changed (loaded), update which entry isn't stored */
void Assoc_self_client_id_changed(Assoc *assoc, uint8_t *public_id);
void Assoc_self_client_id_changed(Assoc *assoc, const uint8_t *public_id);
/* every 45s send out a getnodes() for a "random" bucket */
#define ASSOC_BUCKET_REFRESH 45
@ -97,7 +97,7 @@ void do_Assoc(Assoc *assoc, DHT *dht);
void kill_Assoc(Assoc *assoc);
#ifdef LOGGING
void Assoc_status(Assoc *assoc);
void Assoc_status(const Assoc *assoc);
#endif /* LOGGING */
#endif /* !__ASSOC_H__ */

View File

@ -35,7 +35,7 @@
* return 0 if it sent the friend request directly to the friend.
* return the number of peers it was routed through if it did not send it directly.
*/
int send_friendrequest(Onion_Client *onion_c, uint8_t *public_key, uint32_t nospam_num, uint8_t *data, uint32_t length)
int send_friendrequest(const Onion_Client *onion_c, const uint8_t *public_key, uint32_t nospam_num, const uint8_t *data, uint32_t length)
{
if (1 + sizeof(nospam_num) + length > ONION_CLIENT_MAX_DATA_SIZE || length == 0)
return -1;
@ -65,7 +65,7 @@ void set_nospam(Friend_Requests *fr, uint32_t num)
fr->nospam = num;
}
uint32_t get_nospam(Friend_Requests *fr)
uint32_t get_nospam(const Friend_Requests *fr)
{
return fr->nospam;
}
@ -118,7 +118,7 @@ static int request_received(Friend_Requests *fr, const uint8_t *client_id)
* return 0 if it removed it successfully.
* return -1 if it didn't find it.
*/
int remove_request_received(Friend_Requests *fr, uint8_t *client_id)
int remove_request_received(Friend_Requests *fr, const uint8_t *client_id)
{
uint32_t i;

View File

@ -51,17 +51,17 @@ typedef struct {
* data is the data in the request and length is the length.
* Maximum length of data is MAX_FRIEND_REQUEST_DATA_SIZE.
*/
int send_friendrequest(Onion_Client *onion_c, uint8_t *public_key, uint32_t nospam_num, uint8_t *data, uint32_t length);
int send_friendrequest(const Onion_Client *onion_c, const uint8_t *public_key, uint32_t nospam_num, const uint8_t *data, uint32_t length);
/* Set and get the nospam variable used to prevent one type of friend request spam. */
void set_nospam(Friend_Requests *fr, uint32_t num);
uint32_t get_nospam(Friend_Requests *fr);
uint32_t get_nospam(const Friend_Requests *fr);
/* Remove client id from received_requests list.
*
* return 0 if it removed it successfully.
* return -1 if it didn't find it.
*/
int remove_request_received(Friend_Requests *fr, uint8_t *client_id);
int remove_request_received(Friend_Requests *fr, const uint8_t *client_id);
/* Set the function that will be executed when a friend request for us is received.
* Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length, void * userdata)

View File

@ -65,7 +65,7 @@ typedef struct {
* TODO: make this more efficient.
*/
static int peer_in_chat(Group_Chat *chat, uint8_t *client_id)
static int peer_in_chat(const Group_Chat *chat, const uint8_t *client_id)
{
uint32_t i;
@ -82,7 +82,7 @@ static int peer_in_chat(Group_Chat *chat, uint8_t *client_id)
* return 1 if client_id1 is closer.
* return 2 if client_id2 is closer.
*/
static int id_closest_groupchats(uint8_t *id, uint8_t *id1, uint8_t *id2)
static int id_closest_groupchats(const uint8_t *id, const uint8_t *id1, const uint8_t *id2)
{
size_t i;
uint8_t distance1, distance2;
@ -110,7 +110,7 @@ static int id_closest_groupchats(uint8_t *id, uint8_t *id1, uint8_t *id2)
* Return -1 if the peer is in the closelist.
*/
static int peer_okping(Group_Chat *chat, uint8_t *client_id)
static int peer_okping(const Group_Chat *chat, const uint8_t *client_id)
{
uint32_t i, j = 0;
@ -143,7 +143,7 @@ static int peer_okping(Group_Chat *chat, uint8_t *client_id)
* Return 0 if success.
* Return -1 if peer was not put in list/updated.
*/
static int add_closepeer(Group_Chat *chat, uint8_t *client_id, IP_Port ip_port)
static int add_closepeer(Group_Chat *chat, const uint8_t *client_id, IP_Port ip_port)
{
uint32_t i;
@ -175,7 +175,7 @@ static int add_closepeer(Group_Chat *chat, uint8_t *client_id, IP_Port ip_port)
return -1;
}
static int send_groupchatpacket(Group_Chat *chat, IP_Port ip_port, uint8_t *public_key, uint8_t *data, uint32_t length,
static int send_groupchatpacket(const Group_Chat *chat, IP_Port ip_port, const uint8_t *public_key, const uint8_t *data, uint32_t length,
uint8_t request_id)
{
if (id_equal(chat->self_public_key, public_key))
@ -200,7 +200,7 @@ static int send_groupchatpacket(Group_Chat *chat, IP_Port ip_port, uint8_t *publ
*
* return the number of peers the packet was sent to.
*/
static uint8_t sendto_allpeers(Group_Chat *chat, uint8_t *data, uint16_t length, uint8_t request_id)
static uint8_t sendto_allpeers(const Group_Chat *chat, const uint8_t *data, uint16_t length, uint8_t request_id)
{
uint16_t sent = 0;
uint32_t i;
@ -224,7 +224,7 @@ static uint8_t sendto_allpeers(Group_Chat *chat, uint8_t *data, uint16_t length,
* return peernum if success or peer already in chat.
* return -1 if error.
*/
static int addpeer(Group_Chat *chat, uint8_t *client_id)
static int addpeer(Group_Chat *chat, const uint8_t *client_id)
{
int peernum = peer_in_chat(chat, client_id);
@ -319,7 +319,7 @@ static int delpeer(Group_Chat *chat, int peernum)
* return length of name if success
* return -1 if failure
*/
int group_peername(Group_Chat *chat, int peernum, uint8_t *name)
int group_peername(const Group_Chat *chat, int peernum, uint8_t *name)
{
if ((uint32_t)peernum >= chat->numpeers)
return -1;
@ -334,7 +334,7 @@ int group_peername(Group_Chat *chat, int peernum, uint8_t *name)
return chat->group[peernum].nick_len;
}
static void setnick(Group_Chat *chat, int peernum, uint8_t *contents, uint16_t contents_len)
static void setnick(Group_Chat *chat, int peernum, const uint8_t *contents, uint16_t contents_len)
{
if (contents_len > MAX_NICK_BYTES || contents_len == 0)
return;
@ -355,7 +355,7 @@ static void setnick(Group_Chat *chat, int peernum, uint8_t *contents, uint16_t c
/* TODO: move this to global section */
#define GROUP_PING_TIMEOUT 5
static int send_getnodes(Group_Chat *chat, IP_Port ip_port, int peernum)
static int send_getnodes(const Group_Chat *chat, IP_Port ip_port, int peernum)
{
if ((uint32_t)peernum >= chat->numpeers)
return -1;
@ -382,7 +382,7 @@ static int send_getnodes(Group_Chat *chat, IP_Port ip_port, int peernum)
CRYPTO_PACKET_GROUP_CHAT_GET_NODES);
}
static int send_sendnodes(Group_Chat *chat, IP_Port ip_port, int peernum, uint64_t pingid)
static int send_sendnodes(const Group_Chat *chat, IP_Port ip_port, int peernum, uint64_t pingid)
{
if ((uint32_t)peernum >= chat->numpeers)
return -1;
@ -404,7 +404,7 @@ static int send_sendnodes(Group_Chat *chat, IP_Port ip_port, int peernum, uint64
sizeof(contents.pingid) + sizeof(groupchat_nodes) * j, CRYPTO_PACKET_GROUP_CHAT_SEND_NODES);
}
static int handle_getnodes(Group_Chat *chat, IP_Port source, int peernum, uint8_t *data, uint32_t len)
static int handle_getnodes(const Group_Chat *chat, IP_Port source, int peernum, const uint8_t *data, uint32_t len)
{
if (len != sizeof(getnodes_data))
return 1;
@ -422,7 +422,7 @@ static int handle_getnodes(Group_Chat *chat, IP_Port source, int peernum, uint8_
return 0;
}
static int handle_sendnodes(Group_Chat *chat, IP_Port source, int peernum, uint8_t *data, uint32_t len)
static int handle_sendnodes(Group_Chat *chat, IP_Port source, int peernum, const uint8_t *data, uint32_t len)
{
if ((uint32_t)peernum >= chat->numpeers)
return 1;
@ -487,7 +487,7 @@ static int handle_sendnodes(Group_Chat *chat, IP_Port source, int peernum, uint8
#define GROUP_DATA_MIN_SIZE (crypto_box_PUBLICKEYBYTES + sizeof(uint32_t) + 1)
static void send_names_new_peer(Group_Chat *chat);
static int handle_data(Group_Chat *chat, uint8_t *data, uint32_t len)
static int handle_data(Group_Chat *chat, const uint8_t *data, uint32_t len)
{
if (len < GROUP_DATA_MIN_SIZE)
return 1;
@ -526,7 +526,7 @@ static int handle_data(Group_Chat *chat, uint8_t *data, uint32_t len)
chat->group[peernum].last_message_number = message_num;
int handled = 1;
uint8_t *contents = data + GROUP_DATA_MIN_SIZE;
const uint8_t *contents = data + GROUP_DATA_MIN_SIZE;
uint16_t contents_len = len - GROUP_DATA_MIN_SIZE;
switch (data[crypto_box_PUBLICKEYBYTES + sizeof(message_num)]) {
@ -585,7 +585,7 @@ static int handle_data(Group_Chat *chat, uint8_t *data, uint32_t len)
return 1;
}
static uint8_t send_data(Group_Chat *chat, uint8_t *data, uint32_t len, uint8_t message_id)
static uint8_t send_data(Group_Chat *chat, const uint8_t *data, uint32_t len, uint8_t message_id)
{
if (len + GROUP_DATA_MIN_SIZE > MAX_CRYPTO_REQUEST_SIZE) /*NOTE: not the real maximum len.*/
return 1;
@ -614,7 +614,7 @@ static uint8_t send_data(Group_Chat *chat, uint8_t *data, uint32_t len, uint8_t
* return 1 if error.
*/
int handle_groupchatpacket(Group_Chat *chat, IP_Port source, uint8_t *packet, uint32_t length)
int handle_groupchatpacket(Group_Chat *chat, IP_Port source, const uint8_t *packet, uint32_t length)
{
if (length > MAX_CRYPTO_REQUEST_SIZE)
return 1;
@ -652,12 +652,12 @@ int handle_groupchatpacket(Group_Chat *chat, IP_Port source, uint8_t *packet, ui
return 1;
}
uint32_t group_sendmessage(Group_Chat *chat, uint8_t *message, uint32_t length)
uint32_t group_sendmessage(Group_Chat *chat, const uint8_t *message, uint32_t length)
{
return send_data(chat, message, length, GROUP_CHAT_CHAT_MESSAGE); //TODO: better return values?
}
uint32_t group_sendaction(Group_Chat *chat, uint8_t *action, uint32_t length)
uint32_t group_sendaction(Group_Chat *chat, const uint8_t *action, uint32_t length)
{
return send_data(chat, action, length, GROUP_CHAT_ACTION);
}
@ -686,20 +686,20 @@ int set_nick(Group_Chat *chat, const uint8_t *nick, uint16_t nick_len)
return 0;
}
uint32_t group_newpeer(Group_Chat *chat, uint8_t *client_id)
uint32_t group_newpeer(Group_Chat *chat, const uint8_t *client_id)
{
addpeer(chat, client_id);
return send_data(chat, client_id, crypto_box_PUBLICKEYBYTES, GROUP_CHAT_NEW_PEER); //TODO: better return values?
}
void callback_groupmessage(Group_Chat *chat, void (*function)(Group_Chat *chat, int, uint8_t *, uint16_t, void *),
void callback_groupmessage(Group_Chat *chat, void (*function)(Group_Chat *chat, int, const uint8_t *, uint16_t, void *),
void *userdata)
{
chat->group_message = function;
chat->group_message_userdata = userdata;
}
void callback_groupaction(Group_Chat *chat, void (*function)(Group_Chat *chat, int, uint8_t *, uint16_t, void *),
void callback_groupaction(Group_Chat *chat, void (*function)(Group_Chat *chat, int, const uint8_t *, uint16_t, void *),
void *userdata)
{
chat->group_action = function;
@ -713,12 +713,12 @@ void callback_namelistchange(Group_Chat *chat, void (*function)(Group_Chat *chat
chat->group_namelistchange_userdata = userdata;
}
uint32_t group_numpeers(Group_Chat *chat)
uint32_t group_numpeers(const Group_Chat *chat)
{
return chat->numpeers;
}
uint32_t group_client_names(Group_Chat *chat, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[], uint16_t length)
uint32_t group_client_names(const Group_Chat *chat, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[], uint16_t length)
{
uint32_t i;
@ -833,12 +833,12 @@ void kill_groupchat(Group_Chat *chat)
free(chat);
}
void chat_bootstrap(Group_Chat *chat, IP_Port ip_port, uint8_t *client_id)
void chat_bootstrap(Group_Chat *chat, IP_Port ip_port, const uint8_t *client_id)
{
send_getnodes(chat, ip_port, addpeer(chat, client_id));
}
void chat_bootstrap_nonlazy(Group_Chat *chat, IP_Port ip_port, uint8_t *client_id)
void chat_bootstrap_nonlazy(Group_Chat *chat, IP_Port ip_port, const uint8_t *client_id)
{
send_getnodes(chat, ip_port, addpeer(chat, client_id));
add_closepeer(chat, client_id, ip_port);

View File

@ -62,9 +62,9 @@ typedef struct Group_Chat {
uint32_t numpeers;
uint32_t message_number;
void (*group_message)(struct Group_Chat *m, int, uint8_t *, uint16_t, void *);
void (*group_message)(struct Group_Chat *m, int, const uint8_t *, uint16_t, void *);
void *group_message_userdata;
void (*group_action)(struct Group_Chat *m, int, uint8_t *, uint16_t, void *);
void (*group_action)(struct Group_Chat *m, int, const uint8_t *, uint16_t, void *);
void *group_action_userdata;
void (*peer_namelistchange)(struct Group_Chat *m, int peer, uint8_t change, void *);
void *group_namelistchange_userdata;
@ -91,14 +91,14 @@ typedef struct Group_Chat {
* return length of name if success
* return -1 if failure
*/
int group_peername(Group_Chat *chat, int peernum, uint8_t *name);
int group_peername(const Group_Chat *chat, int peernum, uint8_t *name);
/*
* Set callback function for chat messages.
*
* format of function is: function(Group_Chat *chat, peer number, message, message length, userdata)
*/
void callback_groupmessage(Group_Chat *chat, void (*function)(Group_Chat *chat, int, uint8_t *, uint16_t, void *),
void callback_groupmessage(Group_Chat *chat, void (*function)(Group_Chat *chat, int, const uint8_t *, uint16_t, void *),
void *userdata);
/*
@ -106,7 +106,7 @@ void callback_groupmessage(Group_Chat *chat, void (*function)(Group_Chat *chat,
*
* format of function is: function(Group_Chat *chat, peer number, action, action length, userdata)
*/
void callback_groupaction(Group_Chat *chat, void (*function)(Group_Chat *chat, int, uint8_t *, uint16_t, void *),
void callback_groupaction(Group_Chat *chat, void (*function)(Group_Chat *chat, int, const uint8_t *, uint16_t, void *),
void *userdata);
/*
@ -130,14 +130,14 @@ void callback_namelistchange(Group_Chat *chat, void (*function)(Group_Chat *chat
*
* returns the number of peers it has sent it to.
*/
uint32_t group_sendmessage(Group_Chat *chat, uint8_t *message, uint32_t length);
uint32_t group_sendmessage(Group_Chat *chat, const uint8_t *message, uint32_t length);
/*
* Send an action to the group.
*
* returns the number of peers it has sent it to.
*/
uint32_t group_sendaction(Group_Chat *chat, uint8_t *action, uint32_t length);
uint32_t group_sendaction(Group_Chat *chat, const uint8_t *action, uint32_t length);
/*
* Set our nick for this group.
@ -150,7 +150,7 @@ int set_nick(Group_Chat *chat, const uint8_t *nick, uint16_t nick_len);
* Tell everyone about a new peer (a person we are inviting for example.)
*
*/
uint32_t group_newpeer(Group_Chat *chat, uint8_t *client_id);
uint32_t group_newpeer(Group_Chat *chat, const uint8_t *client_id);
/* Create a new group chat.
@ -164,7 +164,7 @@ Group_Chat *new_groupchat(Networking_Core *net);
/* Return the number of peers in the group chat.
*/
uint32_t group_numpeers(Group_Chat *chat);
uint32_t group_numpeers(const Group_Chat *chat);
/* List all the peers in the group chat.
*
@ -172,7 +172,7 @@ uint32_t group_numpeers(Group_Chat *chat);
*
* returns the number of peers.
*/
uint32_t group_client_names(Group_Chat *chat, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[], uint16_t length);
uint32_t group_client_names(const Group_Chat *chat, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[], uint16_t length);
/* Kill a group chat
*
@ -188,11 +188,11 @@ void do_groupchat(Group_Chat *chat);
/* if we receive a group chat packet we call this function so it can be handled.
return 0 if packet is handled correctly.
return 1 if it didn't handle the packet or if the packet was shit. */
int handle_groupchatpacket(Group_Chat *chat, IP_Port source, uint8_t *packet, uint32_t length);
int handle_groupchatpacket(Group_Chat *chat, IP_Port source, const uint8_t *packet, uint32_t length);
void chat_bootstrap(Group_Chat *chat, IP_Port ip_port, uint8_t *client_id);
void chat_bootstrap_nonlazy(Group_Chat *chat, IP_Port ip_port, uint8_t *client_id);
void chat_bootstrap(Group_Chat *chat, IP_Port ip_port, const uint8_t *client_id);
void chat_bootstrap_nonlazy(Group_Chat *chat, IP_Port ip_port, const uint8_t *client_id);
#endif

View File

@ -120,7 +120,7 @@ static int create_cookie(uint8_t *cookie, uint8_t *bytes, uint8_t *encryption_ke
* return -1 on failure.
* return 0 on success.
*/
static int open_cookie(uint8_t *bytes, uint8_t *cookie, uint8_t *encryption_key)
static int open_cookie(uint8_t *bytes, const uint8_t *cookie, const uint8_t *encryption_key)
{
uint8_t contents[COOKIE_CONTENTS_LENGTH];
int len = decrypt_data_symmetric(encryption_key, cookie, cookie + crypto_box_NONCEBYTES,
@ -178,7 +178,7 @@ static int create_cookie_response(Net_Crypto *c, uint8_t *packet, uint8_t *reque
* return 0 on success.
*/
static int handle_cookie_request(Net_Crypto *c, uint8_t *request_plain, uint8_t *shared_key, uint8_t *dht_public_key,
uint8_t *packet, uint16_t length)
const uint8_t *packet, uint16_t length)
{
if (length != COOKIE_REQUEST_LENGTH)
return -1;
@ -197,7 +197,7 @@ static int handle_cookie_request(Net_Crypto *c, uint8_t *request_plain, uint8_t
/* Handle the cookie request packet (for raw UDP)
*/
static int udp_handle_cookie_request(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int udp_handle_cookie_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
Net_Crypto *c = object;
uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH];
@ -275,8 +275,8 @@ static int tcp_oob_handle_cookie_request(Net_Crypto *c, TCP_Client_Connection *T
* return -1 on failure.
* return COOKIE_LENGTH on success.
*/
static int handle_cookie_response(uint8_t *cookie, uint64_t *number, uint8_t *packet, uint32_t length,
uint8_t *shared_key)
static int handle_cookie_response(uint8_t *cookie, uint64_t *number, const uint8_t *packet, uint32_t length,
const uint8_t *shared_key)
{
if (length != COOKIE_RESPONSE_LENGTH)
return -1;
@ -349,7 +349,7 @@ static int create_crypto_handshake(Net_Crypto *c, uint8_t *packet, uint8_t *cook
* return 0 on success.
*/
static int handle_crypto_handshake(Net_Crypto *c, uint8_t *nonce, uint8_t *session_pk, uint8_t *peer_real_pk,
uint8_t *dht_public_key, uint8_t *cookie, uint8_t *packet, uint32_t length, uint8_t *expected_real_pk)
uint8_t *dht_public_key, uint8_t *cookie, const uint8_t *packet, uint32_t length, uint8_t *expected_real_pk)
{
if (length != HANDSHAKE_PACKET_LENGTH)
return -1;
@ -815,7 +815,7 @@ static uint16_t get_nonce_uint16(uint8_t *nonce)
* return -1 on failure.
* return length of data on success.
*/
static int handle_data_packet(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uint8_t *packet, uint16_t length)
static int handle_data_packet(Net_Crypto *c, int crypt_connection_id, uint8_t *data, const uint8_t *packet, uint16_t length)
{
if (length <= (1 + sizeof(uint16_t) + crypto_box_MACBYTES) || length > MAX_CRYPTO_PACKET_SIZE)
return -1;
@ -1039,7 +1039,7 @@ static int send_kill_packet(Net_Crypto *c, int crypt_connection_id)
* return -1 on failure.
* return 0 on success.
*/
static int handle_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint8_t *packet, uint16_t length)
static int handle_data_packet_helper(Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length)
{
if (length > MAX_CRYPTO_PACKET_SIZE || length <= CRYPTO_DATA_PACKET_MIN_SIZE)
return -1;
@ -1133,7 +1133,7 @@ static int handle_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uin
* return -1 on failure.
* return 0 on success.
*/
static int handle_packet_connection(Net_Crypto *c, int crypt_connection_id, uint8_t *packet, uint16_t length)
static int handle_packet_connection(Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length)
{
if (length == 0 || length > MAX_CRYPTO_PACKET_SIZE)
return -1;
@ -1370,7 +1370,7 @@ void new_connection_handler(Net_Crypto *c, int (*new_connection_callback)(void *
* return -1 on failure.
* return 0 on success.
*/
static int handle_new_connection_handshake(Net_Crypto *c, IP_Port source, uint8_t *data, uint16_t length)
static int handle_new_connection_handshake(Net_Crypto *c, IP_Port source, const uint8_t *data, uint16_t length)
{
New_Connection n_c;
n_c.cookie = malloc(COOKIE_LENGTH);
@ -2123,7 +2123,7 @@ static int crypto_id_ip_port(Net_Crypto *c, IP_Port ip_port)
* Crypto data packets.
*
*/
static int udp_handle_packet(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int udp_handle_packet(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
if (length <= CRYPTO_MIN_PACKET_SIZE || length > MAX_CRYPTO_PACKET_SIZE)
return 1;

View File

@ -270,7 +270,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, uint8_t *data, uint32_t len);
typedef int (*packet_handler_callback)(void *object, IP_Port ip_port, const uint8_t *data, uint32_t len);
typedef struct {
packet_handler_callback function;

View File

@ -149,7 +149,7 @@ int send_onion_packet(Networking_Core *net, Onion_Path *path, IP_Port dest, uint
* return -1 on failure.
* return 0 on success.
*/
int send_onion_response(Networking_Core *net, IP_Port dest, uint8_t *data, uint32_t length, uint8_t *ret)
int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, uint32_t length, const uint8_t *ret)
{
if (length > ONION_RESPONSE_MAX_DATA_SIZE || length == 0)
return -1;
@ -165,7 +165,7 @@ int send_onion_response(Networking_Core *net, IP_Port dest, uint8_t *data, uint3
return 0;
}
static int handle_send_initial(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_send_initial(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
Onion *onion = object;
@ -189,7 +189,7 @@ static int handle_send_initial(void *object, IP_Port source, uint8_t *packet, ui
return onion_send_1(onion, plain, len, source, packet + 1);
}
int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, uint8_t *nonce)
int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, const uint8_t *nonce)
{
IP_Port send_to;
ipport_unpack(&send_to, plain);
@ -219,7 +219,7 @@ int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, uin
return 0;
}
static int handle_send_1(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_send_1(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
Onion *onion = object;
@ -268,7 +268,7 @@ static int handle_send_1(void *object, IP_Port source, uint8_t *packet, uint32_t
return 0;
}
static int handle_send_2(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
Onion *onion = object;
@ -316,7 +316,7 @@ static int handle_send_2(void *object, IP_Port source, uint8_t *packet, uint32_t
}
static int handle_recv_3(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_recv_3(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
Onion *onion = object;
@ -350,7 +350,7 @@ static int handle_recv_3(void *object, IP_Port source, uint8_t *packet, uint32_t
return 0;
}
static int handle_recv_2(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_recv_2(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
Onion *onion = object;
@ -384,7 +384,7 @@ static int handle_recv_2(void *object, IP_Port source, uint8_t *packet, uint32_t
return 0;
}
static int handle_recv_1(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_recv_1(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
Onion *onion = object;
@ -417,7 +417,7 @@ static int handle_recv_1(void *object, IP_Port source, uint8_t *packet, uint32_t
return 0;
}
void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, uint8_t *, uint16_t), void *object)
void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, const uint8_t *, uint16_t), void *object)
{
onion->recv_1_function = function;
onion->callback_object = object;

View File

@ -35,7 +35,7 @@ typedef struct {
Shared_Keys shared_keys_2;
Shared_Keys shared_keys_3;
int (*recv_1_function)(void *, IP_Port, uint8_t *, uint16_t);
int (*recv_1_function)(void *, IP_Port, const uint8_t *, uint16_t);
void *callback_object;
} Onion;
@ -94,7 +94,7 @@ int send_onion_packet(Networking_Core *net, Onion_Path *path, IP_Port dest, uint
* return -1 on failure.
* return 0 on success.
*/
int send_onion_response(Networking_Core *net, IP_Port dest, uint8_t *data, uint32_t length, uint8_t *ret);
int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, uint32_t length, const uint8_t *ret);
/* Function to handle/send received decrypted versions of the packet sent with send_onion_packet.
*
@ -106,13 +106,13 @@ int send_onion_response(Networking_Core *net, IP_Port dest, uint8_t *data, uint3
* 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(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, uint8_t *nonce);
int onion_send_1(Onion *onion, uint8_t *plain, uint32_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)
*/
void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, uint8_t *, uint16_t), void *object);
void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, const uint8_t *, uint16_t), void *object);
Onion *new_onion(DHT *dht);

View File

@ -115,7 +115,7 @@ int send_data_request(Networking_Core *net, Onion_Path *path, IP_Port dest, uint
}
/* Generate a ping_id and put it in ping_id */
static void generate_ping_id(Onion_Announce *onion_a, uint64_t time, uint8_t *public_key, IP_Port ret_ip_port,
static void generate_ping_id(Onion_Announce *onion_a, uint64_t time, const uint8_t *public_key, IP_Port ret_ip_port,
uint8_t *ping_id)
{
time /= PING_ID_TIMEOUT;
@ -132,7 +132,7 @@ static void generate_ping_id(Onion_Announce *onion_a, uint64_t time, uint8_t *pu
* return -1 if no
* return position in list if yes
*/
static int in_entries(Onion_Announce *onion_a, uint8_t *public_key)
static int in_entries(const Onion_Announce *onion_a, const uint8_t *public_key)
{
uint32_t i;
@ -179,8 +179,8 @@ static int cmp_entry(const void *a, const void *b)
* return -1 if failure
* return position if added
*/
static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, uint8_t *public_key, uint8_t *data_public_key,
uint8_t *ret)
static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, const uint8_t *public_key, const uint8_t *data_public_key,
const uint8_t *ret)
{
int pos = in_entries(onion_a, public_key);
@ -213,14 +213,14 @@ static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, uint8_t
return in_entries(onion_a, public_key);
}
static int handle_announce_request(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_announce_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
Onion_Announce *onion_a = object;
if (length != ANNOUNCE_REQUEST_SIZE_RECV)
return 1;
uint8_t *packet_public_key = packet + 1 + crypto_box_NONCEBYTES;
const uint8_t *packet_public_key = packet + 1 + crypto_box_NONCEBYTES;
uint8_t shared_key[crypto_box_BEFORENMBYTES];
get_shared_key(&onion_a->shared_keys_recv, shared_key, onion_a->dht->self_secret_key, packet_public_key);
@ -302,7 +302,7 @@ static int handle_announce_request(void *object, IP_Port source, uint8_t *packet
return 0;
}
static int handle_data_request(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_data_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
Onion_Announce *onion_a = object;

View File

@ -164,7 +164,7 @@ static int new_sendback(Onion_Client *onion_c, uint32_t num, uint8_t *public_key
* return ~0 on failure
* return num (see new_sendback(...)) on success
*/
static uint32_t check_sendback(Onion_Client *onion_c, uint8_t *sendback, uint8_t *ret_pubkey, IP_Port *ret_ip_port)
static uint32_t check_sendback(Onion_Client *onion_c, const uint8_t *sendback, uint8_t *ret_pubkey, IP_Port *ret_ip_port)
{
uint64_t sback;
memcpy(&sback, sendback, sizeof(uint64_t));
@ -377,7 +377,7 @@ static int client_ping_nodes(Onion_Client *onion_c, uint32_t num, Node_format *n
return 0;
}
static int handle_announce_response(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_announce_response(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
Onion_Client *onion_c = object;
@ -432,7 +432,7 @@ static int handle_announce_response(void *object, IP_Port source, uint8_t *packe
#define DATA_IN_RESPONSE_MIN_SIZE ONION_DATA_IN_RESPONSE_MIN_SIZE
static int handle_data_response(void *object, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_data_response(void *object, IP_Port source, const uint8_t *packet, uint32_t length)
{
Onion_Client *onion_c = object;
@ -530,7 +530,7 @@ static int handle_fakeid_announce(void *object, const uint8_t *source_pubkey, co
* return the number of packets sent on success
* return -1 on failure.
*/
int send_onion_data(Onion_Client *onion_c, int friend_num, uint8_t *data, uint32_t length)
int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint32_t length)
{
if ((uint32_t)friend_num >= onion_c->num_friends)
return -1;

View File

@ -212,7 +212,7 @@ uint64_t onion_getfriend_DHT_pubkey(Onion_Client *onion_c, int friend_num, uint8
* return the number of packets sent on success
* return -1 on failure.
*/
int send_onion_data(Onion_Client *onion_c, int friend_num, uint8_t *data, uint32_t length);
int send_onion_data(const Onion_Client *onion_c, int friend_num, const uint8_t *data, uint32_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);

View File

@ -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, uint8_t *packet, uint32_t length)
static int handle_ping_request(void *_dht, IP_Port source, const uint8_t *packet, uint32_t length)
{
DHT *dht = _dht;
int rc;
@ -168,7 +168,7 @@ static int handle_ping_request(void *_dht, IP_Port source, uint8_t *packet, uint
return 0;
}
static int handle_ping_response(void *_dht, IP_Port source, uint8_t *packet, uint32_t length)
static int handle_ping_response(void *_dht, IP_Port source, const uint8_t *packet, uint32_t length)
{
DHT *dht = _dht;
int rc;