mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-19 05:07:56 +00:00
added code to display overlay mesh route table (incomplete)
fixed bug with recording routes from packets with unresolvable addresses.
This commit is contained in:
parent
d7aa6bcc01
commit
a91c5d29c3
1
mphlr.h
1
mphlr.h
@ -794,3 +794,4 @@ int ob_dump(overlay_buffer *b,char *desc);
|
||||
unsigned int ob_get_int(overlay_buffer *b,int offset);
|
||||
char *overlay_render_sid(unsigned char *sid);
|
||||
int overlay_route_record_link(long long now,unsigned char *to,unsigned char *via,unsigned int timestamp,int score,int interface,int gateways_en_route);
|
||||
int overlay_route_dump();
|
||||
|
@ -133,6 +133,8 @@ int overlay_frame_process(int interface,overlay_frame *f)
|
||||
|
||||
long long now=overlay_gettime_ms();
|
||||
|
||||
if (debug>1) fprintf(stderr,">>> Received frame\n");
|
||||
|
||||
/* First order of business is whether the nexthop address has been resolved.
|
||||
If not, we need to think about asking for it to be resolved.
|
||||
The trouble is that we do not want to trigger a Hanson Event (a storm of
|
||||
@ -199,8 +201,10 @@ int overlay_frame_process(int interface,overlay_frame *f)
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,"This frame does%s have me listed as next hop.\n",forMe?"":" not");
|
||||
fprintf(stderr,"This frame is%s for me.\n",ultimatelyForMe?"":" not");
|
||||
if (debug>3) {
|
||||
fprintf(stderr,"This frame does%s have me listed as next hop.\n",forMe?"":" not");
|
||||
fprintf(stderr,"This frame is%s for me.\n",ultimatelyForMe?"":" not");
|
||||
}
|
||||
|
||||
/* Not for us? Then just ignore it */
|
||||
if (!forMe) return 0;
|
||||
|
@ -485,8 +485,7 @@ int overlay_stuff_packet_from_queue(int i,overlay_buffer *e,int q,long long now,
|
||||
|
||||
/* XXX Uses hardcoded freshness threshold, when it should get it from the queue */
|
||||
if (now>((*p)->enqueued_at+overlay_tx[q].latencyTarget)) {
|
||||
/* Stale, so remove from queue.
|
||||
(NOT the cause of the 20110905 segfault) */
|
||||
/* Stale, so remove from queue. */
|
||||
|
||||
/* Get pointer to stale entry */
|
||||
overlay_frame *stale=*p;
|
||||
@ -587,9 +586,11 @@ int overlay_tick_interface(int i, long long now)
|
||||
while ((*p)&&(*p!=pax[j])) p=&(*p)->next;
|
||||
/* Now get rid of this frame once we have found it */
|
||||
if (*p) {
|
||||
fprintf(stderr,"** dequeueing pax @ %p\n",*p);
|
||||
*p=pax[j]->next;
|
||||
if (pax[j]->next) pax[j]->next->prev=pax[j]->prev;
|
||||
if (op_free(pax[j])) WHY("op_free() failed");
|
||||
overlay_tx[q].length--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -775,6 +775,19 @@ char *overlay_render_sid(unsigned char *sid)
|
||||
return ors_out;
|
||||
}
|
||||
|
||||
char *overlay_render_sid_prefix(unsigned char *sid,int l)
|
||||
{
|
||||
int zero=0;
|
||||
|
||||
if (l<0) l=0;
|
||||
if (l>(SID_SIZE*2)) l=SID_SIZE*2;
|
||||
|
||||
extractSid(sid,&zero,ors_out);
|
||||
ors_out[l]=0;
|
||||
return ors_out;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Self-announcement acks bounce back to the self-announcer from immediate neighbours
|
||||
who report the link score they have calculated based on listening to self-announces
|
||||
@ -814,7 +827,8 @@ int overlay_route_saw_selfannounce_ack(int interface,overlay_frame *f,long long
|
||||
iface=f->payload->bytes[i++];
|
||||
|
||||
// Call something like the following for each link
|
||||
overlay_route_record_link(now,f->source,f->source,timestamp,score,interface,0 /* no gateways in between */);
|
||||
if (f->source_address_status==OA_RESOLVED)
|
||||
overlay_route_record_link(now,f->source,f->source,timestamp,score,interface,0 /* no gateways in between */);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -872,5 +886,34 @@ int overlay_route_record_link(long long now,unsigned char *to,unsigned char *via
|
||||
|
||||
WHY("Need to update best known route");
|
||||
|
||||
overlay_route_dump();
|
||||
|
||||
return WHY("Not complete");
|
||||
}
|
||||
|
||||
int overlay_route_dump()
|
||||
{
|
||||
int bin,slot,o;
|
||||
|
||||
fprintf(stderr,"\nOverlay Mesh Route Table\n------------------------\n");
|
||||
|
||||
for(bin=0;bin<overlay_bin_count;bin++)
|
||||
for(slot=0;slot<overlay_bin_size;slot++)
|
||||
{
|
||||
if (!overlay_nodes[bin][slot].sid[0]) continue;
|
||||
|
||||
fprintf(stderr,"%s* :",overlay_render_sid_prefix(overlay_nodes[bin][slot].sid,7));
|
||||
for(o=0;o<OVERLAY_MAX_OBSERVATIONS;o++)
|
||||
{
|
||||
if (overlay_nodes[bin][slot].observations[o].valid)
|
||||
{
|
||||
overlay_node_observation *ob=&overlay_nodes[bin][slot].observations[o];
|
||||
fprintf(stderr," %d/%d via %s*:%d",
|
||||
ob->score,ob->gateways_en_route,
|
||||
overlay_render_sid_prefix(ob->sender_prefix,7),ob->interface);
|
||||
}
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user