Minor fixups for neighbour handling

This commit is contained in:
Matthias Schiffer 2012-09-29 00:33:13 +02:00
parent 40cd665392
commit 1a8f3c7cef
3 changed files with 10 additions and 10 deletions

View file

@ -312,26 +312,26 @@ static void handle_tlv_hello(const ffd_tlv_hello_t *tlv_hello, size_t len, const
uint16_t seqno = ntohs(tlv_hello->seqno); uint16_t seqno = ntohs(tlv_hello->seqno);
if (neigh->last_hello.tv_sec) { if (neigh->last_hello.tv_sec) {
int16_t seqdiff = seqno - neigh->last_seqno;
if (seqdiff <= 0) {
fprintf(stderr, "debug: seqno already seen, ignorin.\n");
return;
}
int timediff = timespec_diff(&now, &neigh->last_hello)/10; int timediff = timespec_diff(&now, &neigh->last_hello)/10;
uint16_t seqexp = neigh->last_seqno + (timediff - neigh->hello_interval/2)/neigh->hello_interval; uint16_t seqexp = neigh->last_seqno + (timediff - neigh->hello_interval/2)/neigh->hello_interval;
/* cast to int16_t to ensure correct handling of seqno wrapping */ /* cast to int16_t to ensure correct handling of seqno wrapping */
if (abs((int16_t)(seqno - seqexp)) > 16) { if (abs((int16_t)(seqno - seqexp)) > 16) {
fprintf(stderr, "info: neighbor was reset.\n"); fprintf(stderr, "info: neighbour was reset.\n");
neigh->hello_log = 0; neigh->hello_log = 0;
} }
else { else {
int16_t seqdiff = seqno - neigh->last_seqno;
if (seqdiff <= 0) {
fprintf(stderr, "debug: seqno already seen, ignoring.\n");
return;
}
neigh->hello_log <<= seqdiff; neigh->hello_log <<= seqdiff;
} }
} }
else { else {
fprintf(stderr, "info: received hello from new neighbor.\n"); fprintf(stderr, "info: received hello from new neighbour.\n");
} }
neigh->hello_log |= 1; neigh->hello_log |= 1;

View file

@ -39,7 +39,7 @@
struct __attribute__((packed)) _ffd_packet_t { struct __attribute__((packed)) _ffd_packet_t {
uint16_t version_magic; uint16_t version_magic;
uint16_t len; uint16_t len;
uint8_t tlv[0]; uint8_t tlv[];
}; };

View file

@ -41,7 +41,7 @@ typedef struct __attribute__((packed)) _ffd_tlv_ihu_t {
uint8_t reserved; uint8_t reserved;
uint16_t rxcost; uint16_t rxcost;
uint16_t interval; uint16_t interval;
uint8_t address[0]; uint8_t address[];
} ffd_tlv_ihu_t; } ffd_tlv_ihu_t;
#endif /* _FFD_TLV_TYPES_H_ */ #endif /* _FFD_TLV_TYPES_H_ */