mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-18 10:46:23 +00:00
Log when a peer becomes reachable or unreachable, edit tests to wait for this message
This commit is contained in:
parent
6f12edd7a8
commit
fdc70d7512
@ -539,6 +539,14 @@ int monitor_announce_peer(const unsigned char *sid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int monitor_announce_unreachable_peer(const unsigned char *sid)
|
||||
{
|
||||
char msg[1024];
|
||||
int n = snprintf(msg, sizeof msg, "\nOLDPEER:%s\n", alloca_tohex_sid(sid));
|
||||
monitor_tell_clients(msg, n, MONITOR_PEERS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int monitor_send_audio(vomp_call_state *call, int audio_codec, unsigned int start_time, unsigned int end_time, const unsigned char *audio, int audio_length)
|
||||
{
|
||||
if (0) DEBUGF("Tell call monitor about audio for call %06x:%06x",
|
||||
|
@ -523,10 +523,6 @@ overlay_node *overlay_route_find_node(const unsigned char *sid, int prefixLen, i
|
||||
|
||||
bcopy(sid, overlay_nodes[bin_number][free_slot].sid, SID_SIZE);
|
||||
|
||||
/* Ask for newly discovered node to be advertised */
|
||||
overlay_route_please_advertise(&overlay_nodes[bin_number][free_slot]);
|
||||
monitor_announce_peer(sid);
|
||||
|
||||
// This info message is used by tests; don't alter or remove it.
|
||||
INFOF("ADD OVERLAY NODE sid=%s slot=%d", alloca_tohex_sid(sid), free_slot);
|
||||
|
||||
@ -872,6 +868,16 @@ int overlay_route_recalc_node_metrics(overlay_node *n,long long now)
|
||||
if (debug&DEBUG_OVERLAYROUTEMONITOR) overlay_route_dump();
|
||||
}
|
||||
|
||||
if (n->best_link_score && !best_score){
|
||||
INFOF("PEER UNREACHABLE, sid=%s", alloca_tohex_sid(n->sid));
|
||||
monitor_announce_unreachable_peer(n->sid);
|
||||
}else if(best_score && !n->best_link_score){
|
||||
INFOF("PEER REACHABLE, sid=%s", alloca_tohex_sid(n->sid));
|
||||
/* Make sure node is advertised soon */
|
||||
overlay_route_please_advertise(n);
|
||||
monitor_announce_peer(n->sid);
|
||||
}
|
||||
|
||||
/* Remember new reachability information */
|
||||
n->best_link_score=best_score;
|
||||
n->best_observation=best_observation;
|
||||
@ -980,6 +986,9 @@ int overlay_route_recalc_neighbour_metrics(overlay_neighbour *n,long long now)
|
||||
/* From the sum of observations calculate the metrics.
|
||||
We want the score to climb quickly and then plateu.
|
||||
*/
|
||||
|
||||
int scoreChanged=0;
|
||||
|
||||
for(i=0;i<OVERLAY_MAX_INTERFACES;i++) {
|
||||
int score;
|
||||
if (ms_observed_200sec[i]>200000) ms_observed_200sec[i]=200000;
|
||||
@ -1001,10 +1010,15 @@ int overlay_route_recalc_neighbour_metrics(overlay_neighbour *n,long long now)
|
||||
if (score>255) score=255;
|
||||
}
|
||||
|
||||
if (n->scores[i]!=score){
|
||||
scoreChanged=1;
|
||||
n->scores[i]=score;
|
||||
}
|
||||
if ((debug&DEBUG_OVERLAYROUTING)&&score)
|
||||
DEBUGF("Neighbour score on interface #%d = %d (observations for %dms)",i,score,ms_observed_200sec[i]);
|
||||
}
|
||||
if (scoreChanged)
|
||||
overlay_route_recalc_node_metrics(n->node, now);
|
||||
|
||||
return 0;
|
||||
|
||||
|
1
serval.h
1
serval.h
@ -1518,6 +1518,7 @@ int monitor_get_fds(struct pollfd *fds,int *fdcount,int fdmax);
|
||||
int monitor_call_status(vomp_call_state *call);
|
||||
int monitor_send_audio(vomp_call_state *call, int audio_codec, unsigned int start_time, unsigned int end_time, const unsigned char *audio, int audio_length);
|
||||
int monitor_announce_peer(const unsigned char *sid);
|
||||
int monitor_announce_unreachable_peer(const unsigned char *sid);
|
||||
int monitor_tell_clients(char *msg, int msglen, int mask);
|
||||
extern int monitor_socket_count;
|
||||
|
||||
|
@ -487,7 +487,7 @@ instances_see_each_other() {
|
||||
[ $I = $J ] && continue
|
||||
local logvar=LOG${I#+}
|
||||
local sidvar=SID${J#+}
|
||||
if ! grep "ADD OVERLAY NODE sid=${!sidvar}" "${!logvar}"; then
|
||||
if ! grep "PEER REACHABLE, sid=${!sidvar}" "${!logvar}"; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user