mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-18 02:39:44 +00:00
More debugging output fixes and bug fixes for overlay operation.
Added proper check to suppress frames claiming to come from ourselves ( necessary for squelching multi-hop broadcasts, although we need an extra step there of having transaction ids on broadcast frames so that we can flood smartly).
This commit is contained in:
parent
cb174a71f6
commit
2a3721506b
@ -231,6 +231,12 @@ int overlay_frame_process(int interface,overlay_frame *f)
|
||||
if (debug&DEBUG_OVERLAYFRAMES) WHY("Source address could not be resolved, so dropping frame.");
|
||||
return -1;
|
||||
}
|
||||
if (overlay_address_is_local(f->source))
|
||||
{
|
||||
if (debug&DEBUG_OVERLAYROUTING)
|
||||
WHY("Dropping frame claiming to come from myself.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (f->destination_address_status==OA_RESOLVED) {
|
||||
for(i=0;i<SID_SIZE;i++) if (f->destination[i]!=0xff) break;
|
||||
|
@ -74,7 +74,10 @@ int ob_unlimitsize(overlay_buffer *b)
|
||||
int ob_makespace(overlay_buffer *b,int bytes)
|
||||
{
|
||||
if (b->sizeLimit!=-1) {
|
||||
if (b->length+bytes>b->sizeLimit) return WHY("Asked to make space beyond size limit");
|
||||
if (b->length+bytes>b->sizeLimit) {
|
||||
if (debug&DEBUG_PACKETFORMATS) WHY("Asked to make space beyond size limit");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (b->length+bytes>=b->allocSize)
|
||||
{
|
||||
|
@ -140,7 +140,9 @@ int overlay_frame_package_fmt1(overlay_frame *p,overlay_buffer *b)
|
||||
if (ob_makespace(b,2+headers->length+p->payload->length)) {
|
||||
/* Not enough space free in output buffer */
|
||||
ob_free(headers);
|
||||
return WHY("Could not make enough space free in output buffer");
|
||||
if (debug&DEBUG_PACKETFORMATS)
|
||||
WHY("Could not make enough space free in output buffer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Package up headers and payload */
|
||||
|
@ -972,6 +972,18 @@ int overlay_route_saw_selfannounce_ack(int interface,overlay_frame *f,long long
|
||||
|
||||
int overlay_route_record_link(long long now,unsigned char *to,unsigned char *via,unsigned int timestamp,int score,int gateways_en_route)
|
||||
{
|
||||
int i,slot=-1;
|
||||
|
||||
/* Don't record routes to ourselves */
|
||||
if (overlay_address_is_local(to)) return 0;
|
||||
|
||||
for(i=0;i<SID_SIZE;i++) if (to[i]!=via[i]) break;
|
||||
if (i==SID_SIZE) {
|
||||
/* TO and VIA are the same, which makes no sense.
|
||||
So ignore */
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr,"route_record_link(0x%llx,%s*,",
|
||||
now,overlay_render_sid_prefix(to,7));
|
||||
fprintf(stderr,"%s*,0x%08x,%d)\n",
|
||||
@ -980,7 +992,6 @@ int overlay_route_record_link(long long now,unsigned char *to,unsigned char *via
|
||||
overlay_node *n=overlay_route_find_node(to,1 /* create node if missing */);
|
||||
if (!n) return WHY("Could not find or create entry for node");
|
||||
|
||||
int i,slot=-1;
|
||||
for(i=0;i<OVERLAY_MAX_OBSERVATIONS;i++)
|
||||
{
|
||||
/* Take note of where we can find space for a fresh observation */
|
||||
@ -1020,8 +1031,8 @@ int overlay_route_record_link(long long now,unsigned char *to,unsigned char *via
|
||||
|
||||
overlay_route_recalc_node_metrics(n,now);
|
||||
|
||||
overlay_route_dump();
|
||||
|
||||
if (1||debug&DEBUG_OVERLAYROUTEMONITOR) overlay_route_dump();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user