Announce all links on connection to monitor interface

This commit is contained in:
Jeremy Lakeman 2013-05-08 13:42:11 +09:30
parent a59b306173
commit dcdb8fcdd4
3 changed files with 32 additions and 6 deletions

View File

@ -382,6 +382,13 @@ void monitor_get_all_supported_codecs(unsigned char *codecs){
}
}
static int monitor_announce_all_peers(struct subscriber *subscriber, void *context)
{
if (subscriber->reachable&REACHABLE)
monitor_announce_peer(subscriber->sid);
return 0;
}
static int monitor_set(const struct cli_parsed *parsed, void *context)
{
struct monitor_context *c=context;
@ -397,13 +404,15 @@ static int monitor_set(const struct cli_parsed *parsed, void *context)
}
}else if (strcase_startswith(parsed->args[1],"rhizome", NULL))
c->flags|=MONITOR_RHIZOME;
else if (strcase_startswith(parsed->args[1],"peers", NULL))
else if (strcase_startswith(parsed->args[1],"peers", NULL)){
c->flags|=MONITOR_PEERS;
else if (strcase_startswith(parsed->args[1],"dnahelper", NULL))
enum_subscribers(NULL, monitor_announce_all_peers, NULL);
}else if (strcase_startswith(parsed->args[1],"dnahelper", NULL))
c->flags|=MONITOR_DNAHELPER;
else if (strcase_startswith(parsed->args[1],"links", NULL))
else if (strcase_startswith(parsed->args[1],"links", NULL)){
c->flags|=MONITOR_LINKS;
else
link_state_announce_links();
}else
return monitor_write_error(c,"Unknown monitor type");
char msg[1024];

View File

@ -353,6 +353,19 @@ next:
return 0;
}
static int monitor_announce(struct subscriber *subscriber, void *context){
if (subscriber->reachable & REACHABLE){
struct link_state *state = get_link_state(subscriber);
monitor_announce_link(state->hop_count, state->transmitter, subscriber);
}
return 0;
}
int link_state_announce_links(){
enum_subscribers(NULL, monitor_announce, NULL);
return 0;
}
static int append_link_state(struct overlay_buffer *payload, char flags,
struct subscriber *transmitter, struct subscriber *receiver,
int interface, int version, int ack_sequence, uint32_t ack_mask,
@ -635,7 +648,7 @@ int link_received_packet(struct subscriber *subscriber, struct overlay_interface
if (offset < 32){
if (config.debug.verbose && config.debug.linkstate)
DEBUGF("LINK STATE; late seq %d from %s on %s",
link->ack_sequence, alloca_tohex_sid(subscriber->sid), interface->name);
sender_seq, alloca_tohex_sid(subscriber->sid), interface->name);
link->ack_mask |= (1<<offset);
}else{
link->ack_mask = (link->ack_mask << 1) | 1;
@ -724,6 +737,9 @@ int link_receive(overlay_mdp_frame *mdp)
ack_mask = ob_get_ui32(payload);
drop_rate = 15 - NumberOfSetBits((ack_mask & 0x7FFF));
// we can deal with low packet loss, it's not interesting if it changes, ignore it.
if (drop_rate <=2)
drop_rate = 0;
}
if (flags & FLAG_HAS_DROP_RATE){
@ -772,7 +788,7 @@ int link_receive(overlay_mdp_frame *mdp)
if (link && transmitter == my_subscriber){
// TODO combine our link stats with theirs
version = link->link_version;
if (abs(drop_rate - link->drop_rate)>1)
if (drop_rate != link->drop_rate)
version++;
}

View File

@ -833,6 +833,7 @@ int link_received_packet(struct subscriber *subscriber, struct overlay_interface
int link_receive(overlay_mdp_frame *mdp);
void link_explained(struct subscriber *subscriber);
void link_interface_down(struct overlay_interface *interface);
int link_state_announce_links();
int generate_nonce(unsigned char *nonce,int bytes);