Fixed bug with handling of OA_CODE_SELF intepretation.

This commit is contained in:
gardners 2012-01-11 07:16:22 +10:30
parent f8eea651b5
commit 0b73df19c8
4 changed files with 15 additions and 2 deletions

View File

@ -901,4 +901,5 @@ int serval_packetvisualise(FILE *f,char *message,unsigned char *packet,int plen)
int overlay_broadcast_drop_check(unsigned char *a);
int overlay_address_is_broadcast(unsigned char *a);
int overlay_broadcast_generate_address(unsigned char *a);
int overlay_abbreviate_unset_current_sender();

View File

@ -131,6 +131,7 @@ sid overlay_abbreviate_previous_address={{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
it on most occassions.
*/
sid overlay_abbreviate_current_sender={{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
int overlay_abbreviate_current_sender_set=0;
int overlay_abbreviate_current_sender_id=-1;
int overlay_abbreviate_prepare_cache()
@ -330,7 +331,7 @@ int overlay_abbreviate_expand_address(int interface,unsigned char *in,int *inofs
used to encode the sender's address there ;) */
(*inofs)++;
if (debug&DEBUG_OVERLAYABBREVIATIONS) fprintf(stderr,"Resolving OA_CODE_SELF.\n");
if (overlay_abbreviate_current_sender_id>=0) {
if (overlay_abbreviate_current_sender_set) {
bcopy(&overlay_abbreviate_current_sender.b[0],&out[*ofs],SID_SIZE);
overlay_abbreviate_set_most_recent_address(&out[*ofs]);
(*ofs)+=SID_SIZE;
@ -523,6 +524,13 @@ int overlay_abbreviate_set_current_sender(unsigned char *in)
{
bcopy(in,&overlay_abbreviate_current_sender.b[0],SID_SIZE);
overlay_abbreviate_current_sender_id=-1;
overlay_abbreviate_current_sender_set=1;
return 0;
}
int overlay_abbreviate_unset_current_sender()
{
overlay_abbreviate_current_sender_set=0;
return 0;
}

View File

@ -95,6 +95,9 @@ int packetOkOverlay(int interface,unsigned char *packet,int len,unsigned char *t
f.payload=NULL;
f.bytes=NULL;
f.bytecount=0;
f.prev=NULL; f.next=NULL;
overlay_abbreviate_unset_current_sender();
/* Skip magic bytes and version */
for(ofs=4;ofs<len;)

View File

@ -1491,7 +1491,8 @@ int overlay_rhizome_add_advertisements(int interface_number,overlay_buffer *e)
int overlay_rhizome_saw_advertisements(int i,overlay_frame *f, long long now)
{
if (!f) return -1;
fprintf(stderr,"rhizome f->bytecount=%d\n",f->bytecount);
if (debug&DEBUG_RHIZOME) fprintf(stderr,"rhizome f->bytecount=%d\n",
f->payload->length);
return WHY("Not implemented.");
}