Added path_nodes array and add_path_node() function.

This commit is contained in:
irungentoo 2014-08-08 22:07:28 -04:00
parent 545cc91662
commit bb2a6cbbe2
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 25 additions and 0 deletions

View File

@ -33,6 +33,26 @@
#define ANNOUNCE_ARRAY_SIZE 256
#define ANNOUNCE_TIMEOUT 10
/* Add a node to the path_nodes array.
*
* return -1 on failure
* return 0 on success
*/
static int add_path_node(Onion_Client *onion_c, Node_format *node)
{
unsigned int i;
for (i = 0; i < MAX_PATH_NODES; ++i) {
if (memcmp(node->client_id, onion_c->path_nodes[i].client_id, crypto_box_PUBLICKEYBYTES) == 0)
return -1;
}
onion_c->path_nodes[onion_c->path_nodes_index % MAX_PATH_NODES] = *node;
++onion_c->path_nodes_index;
return 0;
}
/*
* return -1 if nodes are suitable for creating a new path.

View File

@ -47,6 +47,8 @@
#define MAX_STORED_PINGED_NODES 9
#define MIN_NODE_PING_TIME 10
#define MAX_PATH_NODES 32
typedef struct {
uint8_t client_id[CLIENT_ID_SIZE];
IP_Port ip_port;
@ -124,6 +126,9 @@ typedef struct {
Last_Pinged last_pinged[MAX_STORED_PINGED_NODES];
Node_format path_nodes[MAX_PATH_NODES];
uint16_t path_nodes_index;
Ping_Array announce_ping_array;
uint8_t last_pinged_index;
struct {