diff --git a/mphlr.h b/mphlr.h index 26acc199..9e6caed1 100644 --- a/mphlr.h +++ b/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(); diff --git a/overlay.c b/overlay.c index d7709a41..f300c796 100644 --- a/overlay.c +++ b/overlay.c @@ -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 @@ -198,9 +200,11 @@ int overlay_frame_process(int interface,overlay_frame *f) if (i==SID_SIZE) ultimatelyForMe=1; } } - - 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; diff --git a/overlay_interface.c b/overlay_interface.c index ff99327c..f750eaee 100644 --- a/overlay_interface.c +++ b/overlay_interface.c @@ -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--; } } } diff --git a/overlay_route.c b/overlay_route.c index 1a03ebd2..a643f28b 100644 --- a/overlay_route.c +++ b/overlay_route.c @@ -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;binscore,ob->gateways_en_route, + overlay_render_sid_prefix(ob->sender_prefix,7),ob->interface); + } + } + fprintf(stderr,"\n"); + } + return 0; +}