From 023dd46a26e1a606bc541d06d7fbf300156fd932 Mon Sep 17 00:00:00 2001 From: n07070 Date: Tue, 28 Apr 2020 17:37:51 +0200 Subject: [PATCH] Modification of the malloc's --- src/node.c | 9 +++++---- src/node.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/node.c b/src/node.c index 0aee474..ef470d7 100644 --- a/src/node.c +++ b/src/node.c @@ -802,6 +802,7 @@ int work_with_tlvs(char * data, int16_t total_packet_len, struct sockaddr_in6 *s new_neighbour.sin6_scope_id = ifindex; // Build network hash + // memset(&new_tlv,0,sizeof(struct network_hash)); build_network_hash(&new_tlv, data_list); send_single_tlv(&new_tlv, &new_neighbour, socket_num); @@ -819,13 +820,13 @@ int work_with_tlvs(char * data, int16_t total_packet_len, struct sockaddr_in6 *s if (DEBUG_LEVEL > 1) { printf("\x1b[31m[DEBUG]\x1b[0m >> Our hash : "); - for(int x = 0; x < SHA256_DIGEST_LENGTH; x++){ + for(int x = 0; x < 16; x++){ printf("%02x", hash[x]); fflush(0); } printf("\n"); printf("\x1b[31m[DEBUG]\x1b[0m >> Received : "); - for(int x = 0; x < SHA256_DIGEST_LENGTH; x++){ + for(int x = 0; x < 16; x++){ printf("%02x", cur_tlv.network_hash->network_hash[x]); fflush(0); } @@ -923,7 +924,7 @@ int work_with_tlvs(char * data, int16_t total_packet_len, struct sockaddr_in6 *s print_debug(">> Received message ! "); if (DEBUG_LEVEL > 0) { - printf("\n\t %s \n", (char *) cur_tlv.node_state->data); + printf("\nID : %li \nSeqno : %i\n ā€œ%sā€ \n", cur_tlv.node_state->node_id, cur_tlv.node_state->seqno, (char *) cur_tlv.node_state->data); } add_data(cur_tlv.node_state->length - 26, cur_tlv.node_state->node_id, cur_tlv.node_state->seqno, cur_tlv.node_state->data); @@ -1048,7 +1049,7 @@ int run_node(int sock_fd){ t_ask_for_more_peers(sock_fd); t_update_neighbours(); t_get_network_state(sock_fd); - delay = time(NULL) + 20 + (rand() % 10); + delay = time(NULL) + 20 + (rand() % 5); } // This might be cool to add, but we need to find a way to write to stdin diff --git a/src/node.h b/src/node.h index 20012f1..0f2abc4 100644 --- a/src/node.h +++ b/src/node.h @@ -62,7 +62,7 @@ typedef struct list { // The adress of the main peer #define ROOT_PEER_ADDR "2001:660:3301:9200::51c2:1b9b" - + // fonctions signatures int listen_for_packets(char * received_data_buffer, int received_data_len, struct sockaddr_in6 * sender, int sock_fd);