mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-30 08:03:49 +00:00
Ignore duplicate link layer packets, eg bluetooth names
This commit is contained in:
parent
298849b25b
commit
deb1027024
@ -458,15 +458,14 @@ int send_please_explain(struct decode_context *context, struct subscriber *sourc
|
||||
if (!context->sender)
|
||||
frame->source_full=1;
|
||||
|
||||
frame->destination = destination;
|
||||
if (destination){
|
||||
frame->ttl = PAYLOAD_TTL_DEFAULT; // MAX?
|
||||
frame->destination = destination;
|
||||
frame->source_full=1;
|
||||
}else{
|
||||
// send both a broadcast & unicast response out the same interface this packet arrived on.
|
||||
frame->ttl=1;// how will this work with olsr??
|
||||
if (context->interface){
|
||||
frame->destination = destination;
|
||||
frame_add_destination(frame, NULL, context->interface->destination);
|
||||
|
||||
struct network_destination *dest = create_unicast_destination(&context->addr, context->interface);
|
||||
|
@ -238,7 +238,7 @@ int parseMdpPacketHeader(struct decode_context *context, struct overlay_frame *f
|
||||
int seq = ob_get(buffer);
|
||||
if (seq == -1)
|
||||
RETURN(WHY("Unable to read packet seq"));
|
||||
if (link_received_duplicate(context->sender, seq)){
|
||||
if (link_received_duplicate(context, seq)){
|
||||
if (IF_DEBUG(verbose))
|
||||
DEBUG(overlayframes, "Don't process or forward duplicate payloads");
|
||||
forward=process=0;
|
||||
@ -313,9 +313,7 @@ int parseEnvelopeHeader(struct decode_context *context, struct overlay_interface
|
||||
interface->name, alloca_socket_address(addr));
|
||||
}
|
||||
|
||||
link_received_packet(context, sender_seq, packet_flags & PACKET_UNICAST);
|
||||
|
||||
RETURN(0);
|
||||
RETURN(link_received_packet(context, sender_seq, packet_flags & PACKET_UNICAST));
|
||||
OUT();
|
||||
}
|
||||
|
||||
|
@ -288,8 +288,9 @@ void frame_remove_destination(struct overlay_frame *frame, int i){
|
||||
}
|
||||
|
||||
void frame_add_destination(struct overlay_frame *frame, struct subscriber *next_hop, struct network_destination *dest){
|
||||
if (frame->destination_count >= MAX_PACKET_DESTINATIONS)
|
||||
if ((!dest->ifconfig.send)||frame->destination_count >= MAX_PACKET_DESTINATIONS)
|
||||
return;
|
||||
|
||||
unsigned i = frame->destination_count++;
|
||||
frame->destinations[i].destination=add_destination_ref(dest);
|
||||
frame->destinations[i].next_hop = next_hop;
|
||||
|
16
route_link.c
16
route_link.c
@ -1146,9 +1146,9 @@ int link_state_ack_soon(struct subscriber *subscriber)
|
||||
}
|
||||
|
||||
// our neighbour is sending a duplicate frame, did we see the original?
|
||||
int link_received_duplicate(struct subscriber *subscriber, int payload_seq)
|
||||
int link_received_duplicate(struct decode_context *context, int payload_seq)
|
||||
{
|
||||
struct neighbour *neighbour = get_neighbour(subscriber, 0);
|
||||
struct neighbour *neighbour = get_neighbour(context->sender, 0);
|
||||
if (!neighbour)
|
||||
return 0;
|
||||
|
||||
@ -1244,13 +1244,20 @@ int link_received_packet(struct decode_context *context, int sender_seq, char un
|
||||
|
||||
create_out_links(neighbour, context->interface, &context->addr);
|
||||
|
||||
link->ack_counter --;
|
||||
|
||||
// for now we'll use a simple time based link up/down flag + dropped packet count
|
||||
if (sender_seq >=0){
|
||||
if (link->ack_sequence != -1){
|
||||
int offset = (link->ack_sequence - 1 - sender_seq)&0xFF;
|
||||
if (offset < 64){
|
||||
if (link->ack_mask & (1ull<<offset)){
|
||||
// received duplicate frame?
|
||||
if (IF_DEBUG(verbose))
|
||||
DEBUGF(linkstate, "LINK STATE; duplicate seq %d from %s on %s",
|
||||
sender_seq, alloca_tohex_sid_t(context->sender->sid), context->interface->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// packets were re-ordered?
|
||||
if (IF_DEBUG(verbose))
|
||||
DEBUGF(linkstate, "LINK STATE; late seq %d from %s on %s",
|
||||
sender_seq, alloca_tohex_sid_t(context->sender->sid), context->interface->name);
|
||||
@ -1285,6 +1292,7 @@ int link_received_packet(struct decode_context *context, int sender_seq, char un
|
||||
}
|
||||
link->link_timeout = now + context->interface->destination->ifconfig.reachable_timeout_ms;
|
||||
|
||||
link->ack_counter --;
|
||||
// force an update soon when we need to promptly ack packets
|
||||
if (neighbour->using_us && link->ack_counter <=0){
|
||||
neighbour_find_best_link(neighbour);
|
||||
|
2
serval.h
2
serval.h
@ -302,7 +302,7 @@ int unpack_uint(unsigned char *buffer, int buff_size, uint64_t *v);
|
||||
void rhizome_fetch_log_short_status();
|
||||
extern char crash_handler_clue[1024];
|
||||
|
||||
int link_received_duplicate(struct subscriber *subscriber, int previous_seq);
|
||||
int link_received_duplicate(struct decode_context *context, int payload_seq);
|
||||
int link_received_packet(struct decode_context *context, int sender_seq, char unicast);
|
||||
int link_receive(struct internal_mdp_header *header, struct overlay_buffer *payload);
|
||||
void link_explained(struct subscriber *subscriber);
|
||||
|
Loading…
x
Reference in New Issue
Block a user