mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Const-correctness for onion.c
This commit is contained in:
parent
0aa0cbda42
commit
1494992a9f
|
@ -54,7 +54,7 @@ static void change_symmetric_key(Onion *onion)
|
||||||
* return -1 on failure.
|
* return -1 on failure.
|
||||||
* return 0 on success.
|
* return 0 on success.
|
||||||
*/
|
*/
|
||||||
int create_onion_path(DHT *dht, Onion_Path *new_path, Node_format *nodes)
|
int create_onion_path(const DHT *dht, Onion_Path *new_path, const Node_format *nodes)
|
||||||
{
|
{
|
||||||
if (!new_path || !nodes)
|
if (!new_path || !nodes)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -149,7 +149,7 @@ int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion
|
||||||
* return -1 on failure.
|
* return -1 on failure.
|
||||||
* return 0 on success.
|
* return 0 on success.
|
||||||
*/
|
*/
|
||||||
int send_onion_packet(Networking_Core *net, Onion_Path *path, IP_Port dest, uint8_t *data, uint32_t length)
|
int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *data, uint32_t length)
|
||||||
{
|
{
|
||||||
uint8_t packet[ONION_MAX_PACKET_SIZE];
|
uint8_t packet[ONION_MAX_PACKET_SIZE];
|
||||||
int len = create_onion_packet(packet, sizeof(packet), path, dest, data, length);
|
int len = create_onion_packet(packet, sizeof(packet), path, dest, data, length);
|
||||||
|
@ -209,7 +209,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);
|
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, const uint8_t *nonce)
|
int onion_send_1(const Onion *onion, const uint8_t *plain, uint32_t len, IP_Port source, const uint8_t *nonce)
|
||||||
{
|
{
|
||||||
IP_Port send_to;
|
IP_Port send_to;
|
||||||
ipport_unpack(&send_to, plain);
|
ipport_unpack(&send_to, plain);
|
||||||
|
|
|
@ -76,7 +76,7 @@ typedef struct {
|
||||||
* return -1 on failure.
|
* return -1 on failure.
|
||||||
* return 0 on success.
|
* return 0 on success.
|
||||||
*/
|
*/
|
||||||
int create_onion_path(DHT *dht, Onion_Path *new_path, Node_format *nodes);
|
int create_onion_path(const DHT *dht, Onion_Path *new_path, const Node_format *nodes);
|
||||||
|
|
||||||
/* Create a onion packet.
|
/* Create a onion packet.
|
||||||
*
|
*
|
||||||
|
@ -98,7 +98,7 @@ int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion
|
||||||
* return -1 on failure.
|
* return -1 on failure.
|
||||||
* return 0 on success.
|
* return 0 on success.
|
||||||
*/
|
*/
|
||||||
int send_onion_packet(Networking_Core *net, Onion_Path *path, IP_Port dest, uint8_t *data, uint32_t length);
|
int send_onion_packet(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *data, uint32_t length);
|
||||||
|
|
||||||
/* Create and send a onion response sent initially to dest with.
|
/* Create and send a onion response sent initially to dest with.
|
||||||
* Maximum length of data is ONION_RESPONSE_MAX_DATA_SIZE.
|
* Maximum length of data is ONION_RESPONSE_MAX_DATA_SIZE.
|
||||||
|
@ -118,7 +118,7 @@ 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
|
* 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.
|
* when the response is received.
|
||||||
*/
|
*/
|
||||||
int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, const uint8_t *nonce);
|
int onion_send_1(const Onion *onion, const 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.
|
/* Set the callback to be called when the dest ip_port doesn't have AF_INET6 or AF_INET as the family.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user