fixed the neighbour update problem
This commit is contained in:
parent
00ed727da0
commit
9b2a3f1ea8
15
src/node.c
15
src/node.c
@ -612,17 +612,19 @@ int validate_tlv(char *data, int pos, int16_t packet_len){
|
|||||||
printf(">> Reading out of packet length. \n");
|
printf(">> Reading out of packet length. \n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
// 0 1 2 3 = Packet
|
||||||
|
// 4 = type 5 = tlv_len
|
||||||
unsigned char tlv_len = data[pos+1];
|
unsigned char tlv_len = data[pos+1];
|
||||||
|
|
||||||
// Check that the tlv does not exceed the packet length
|
// Check that the tlv does not exceed the packet length
|
||||||
|
printf("%i ; %i ; %i\n", pos, tlv_len, packet_len );
|
||||||
if(pos + tlv_len > packet_len){
|
if(pos + tlv_len > packet_len){
|
||||||
printf(">> The TLV Length exceed the packet length\n");
|
printf(">> The TLV Length exceed the packet length\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(">> TLV has type %i\n", type );
|
printf(">> TLV has type %i\n", type );
|
||||||
|
|
||||||
// Returns the type of the tlv or -1 if something went wrong
|
// Returns the type of the tlv or -1 if something went wrong
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -691,7 +693,7 @@ int add_message(char * message, int message_len){
|
|||||||
}
|
}
|
||||||
// We then look at the differents TLVs in the packet.
|
// We then look at the differents TLVs in the packet.
|
||||||
int work_with_tlvs(char * data, int16_t total_packet_len, struct sockaddr_in6 *sender, int socket_num){
|
int work_with_tlvs(char * data, int16_t total_packet_len, struct sockaddr_in6 *sender, int socket_num){
|
||||||
int16_t packet_len = ntohs(((packet*) data)->length);
|
int16_t packet_len = ((packet*) data)->length;
|
||||||
|
|
||||||
if(packet_len != total_packet_len - 4) {
|
if(packet_len != total_packet_len - 4) {
|
||||||
fprintf(stderr, ">> Length indicated in packet differs from real length of packet received.\n");
|
fprintf(stderr, ">> Length indicated in packet differs from real length of packet received.\n");
|
||||||
@ -725,8 +727,8 @@ int work_with_tlvs(char * data, int16_t total_packet_len, struct sockaddr_in6 *s
|
|||||||
int ifindex = 0;
|
int ifindex = 0;
|
||||||
|
|
||||||
ifindex = 0;
|
ifindex = 0;
|
||||||
while(pos < packet_len) {
|
while(pos < total_packet_len) {
|
||||||
switch(validate_tlv(data, pos, packet_len)) {
|
switch(validate_tlv(data, pos, total_packet_len)) {
|
||||||
case 0:
|
case 0:
|
||||||
// We received a padding tlv so it is ignored
|
// We received a padding tlv so it is ignored
|
||||||
pos += 1;
|
pos += 1;
|
||||||
@ -779,7 +781,8 @@ int work_with_tlvs(char * data, int16_t total_packet_len, struct sockaddr_in6 *s
|
|||||||
|
|
||||||
if(memcmp(hash, cur_tlv.network_hash->network_hash, 16) == 0) {
|
if(memcmp(hash, cur_tlv.network_hash->network_hash, 16) == 0) {
|
||||||
build_network_state_req(&new_tlv);
|
build_network_state_req(&new_tlv);
|
||||||
add_tlv(&pack, &new_tlv, sender, socket_num);
|
send_single_tlv(&new_tlv, sender, socket_num);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The position is updated
|
// The position is updated
|
||||||
|
Loading…
Reference in New Issue
Block a user