mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
Fixed some sign mis-matches in overlay_abbreviations.
Added infrastructure to keep track of receiver and sender interfaces for multi-homed nodes.
This commit is contained in:
parent
1d6d744067
commit
c06b75f5c9
7
mphlr.h
7
mphlr.h
@ -661,7 +661,7 @@ extern int overlay_interface_count;
|
||||
#define OF_COMPRESS_RESERVED 0x03 /* Reserved for another compression system */
|
||||
|
||||
#define OVERLAY_ADDRESS_CACHE_SIZE 1024
|
||||
int overlay_abbreviate_address(unsigned char *in,char *out,int *ofs);
|
||||
int overlay_abbreviate_address(unsigned char *in,unsigned char *out,int *ofs);
|
||||
int overlay_abbreviate_append_address(overlay_buffer *b,unsigned char *a);
|
||||
|
||||
int overlay_abbreviate_expand_address(int interface,unsigned char *in,int *inofs,unsigned char *out,int *ofs);
|
||||
@ -720,6 +720,7 @@ typedef struct overlay_neighbour_observation {
|
||||
unsigned int s2;
|
||||
long long time_ms;
|
||||
unsigned char sender_interface;
|
||||
unsigned char receiver_interface;
|
||||
unsigned char valid;
|
||||
} overlay_neighbour_observation;
|
||||
|
||||
@ -755,9 +756,9 @@ typedef struct overlay_neighbour {
|
||||
|
||||
long long overlay_gettime_ms();
|
||||
int overlay_route_init(int mb_ram);
|
||||
int overlay_route_saw_selfannounce_ack(overlay_frame *f,long long now);
|
||||
int overlay_route_saw_selfannounce_ack(int interface,overlay_frame *f,long long now);
|
||||
int overlay_route_recalc_node_metrics(overlay_node *n);
|
||||
int overlay_route_saw_selfannounce(overlay_frame *f,long long now);
|
||||
int overlay_route_saw_selfannounce(int interface,overlay_frame *f,long long now);
|
||||
overlay_node *overlay_route_find_node(unsigned char *sid,int createP);
|
||||
unsigned int overlay_route_hash_sid(unsigned char *sid);
|
||||
int overlay_route_init(int mb_ram);
|
||||
|
@ -227,10 +227,10 @@ int overlay_frame_process(int interface,overlay_frame *f)
|
||||
switch(f->type)
|
||||
{
|
||||
case OF_TYPE_SELFANNOUNCE:
|
||||
overlay_route_saw_selfannounce(f,now);
|
||||
overlay_route_saw_selfannounce(interface,f,now);
|
||||
break;
|
||||
case OF_TYPE_SELFANNOUNCE_ACK:
|
||||
overlay_route_saw_selfannounce_ack(f,now);
|
||||
overlay_route_saw_selfannounce_ack(interface,f,now);
|
||||
break;
|
||||
default:
|
||||
return WHY("Support for that f->type not yet implemented");
|
||||
|
@ -189,7 +189,7 @@ int overlay_abbreviate_cache_address(unsigned char *sid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int overlay_abbreviate_try_byindex(unsigned char *in,char *out,int *ofs,int index)
|
||||
int overlay_abbreviate_try_byindex(unsigned char *in,unsigned char *out,int *ofs,int index)
|
||||
{
|
||||
if(!bcmp(in,abbrs->sids[index],SID_SIZE))
|
||||
{
|
||||
@ -213,11 +213,11 @@ int overlay_abbreviate_append_address(overlay_buffer *b,unsigned char *a)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int overlay_abbreviate_address(unsigned char *in,char *out,int *ofs)
|
||||
int overlay_abbreviate_address(unsigned char *in,unsigned char *out,int *ofs)
|
||||
{
|
||||
int i;
|
||||
int wasInCachedP=overlay_abbreviate_cache_address(in);
|
||||
|
||||
|
||||
if (!in) return WHY("in==NULL");
|
||||
if (in[0]<0x10) return WHY("Invalid address - 0x00-0x0f are reserved prefixes.");
|
||||
|
||||
|
@ -397,7 +397,7 @@ int overlay_route_make_neighbour(overlay_node *n)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int overlay_route_i_can_hear(unsigned char *who,int sender_interface,unsigned int s1,unsigned int s2,long long now)
|
||||
int overlay_route_i_can_hear(unsigned char *who,int sender_interface,unsigned int s1,unsigned int s2,int receiver_interface,long long now)
|
||||
{
|
||||
/* 1. Find (or create) node entry for the node.
|
||||
2. Replace oldest observation with this observation.
|
||||
@ -421,6 +421,7 @@ int overlay_route_i_can_hear(unsigned char *who,int sender_interface,unsigned in
|
||||
neh->observations[obs_index].s1=s1;
|
||||
neh->observations[obs_index].s2=s2;
|
||||
neh->observations[obs_index].sender_interface=sender_interface;
|
||||
neh->observations[obs_index].receiver_interface=receiver_interface;
|
||||
neh->observations[obs_index].valid=1;
|
||||
neh->most_recent_observation_id=obs_index;
|
||||
neh->last_observation_time_ms=now;
|
||||
@ -431,7 +432,7 @@ int overlay_route_i_can_hear(unsigned char *who,int sender_interface,unsigned in
|
||||
return WHY("Not implemented");
|
||||
}
|
||||
|
||||
int overlay_route_saw_selfannounce(overlay_frame *f,long long now)
|
||||
int overlay_route_saw_selfannounce(int interface,overlay_frame *f,long long now)
|
||||
{
|
||||
unsigned int s1,s2;
|
||||
unsigned char sender_interface;
|
||||
@ -441,7 +442,7 @@ int overlay_route_saw_selfannounce(overlay_frame *f,long long now)
|
||||
sender_interface=ntohl(*((unsigned char*)&f->payload[8]));
|
||||
fprintf(stderr,"Received self-announcement for sequence range [%08x,%08x]\n",s1,s2);
|
||||
|
||||
overlay_route_i_can_hear(f->source,sender_interface,s1,s2,now);
|
||||
overlay_route_i_can_hear(f->source,sender_interface,s1,s2,interface,now);
|
||||
|
||||
overlay_route_ack_selfannounce(f);
|
||||
|
||||
@ -492,12 +493,19 @@ int overlay_someoneelse_can_hear(unsigned char *hearer,unsigned char *who,unsign
|
||||
int overlay_route_recalc_node_metrics(overlay_node *n)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Somewhere to remember how many milliseconds we have seen */
|
||||
int ms_observed[OVERLAY_MAX_INTERFACES];
|
||||
for(i=0;i<OVERLAY_MAX_INTERFACES;i++) ms_observed[i]=0;
|
||||
|
||||
/* XXX This simple accumulation scheme does not weed out duplicates */
|
||||
|
||||
|
||||
return WHY("Not Implemented");
|
||||
|
||||
}
|
||||
|
||||
int overlay_route_saw_selfannounce_ack(overlay_frame *f,long long now)
|
||||
int overlay_route_saw_selfannounce_ack(int interface,overlay_frame *f,long long now)
|
||||
{
|
||||
if (!overlay_neighbours) return 0;
|
||||
return WHY("Not implemented");
|
||||
|
Loading…
x
Reference in New Issue
Block a user