mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-09 12:01:15 +00:00
overlay mesh now sends basic self-announcements.
This commit is contained in:
parent
d6ec3f32c1
commit
5f1f510be5
4
mphlr.h
4
mphlr.h
@ -394,6 +394,10 @@ typedef struct overlay_interface {
|
||||
/* The time of the last tick on this interface in milli seconds */
|
||||
long long last_tick_ms;
|
||||
|
||||
/* Sequence number of last tick. Sent with announcments to help keep track of the reliability of
|
||||
getting traffic to/from us. */
|
||||
int sequence_number;
|
||||
|
||||
/* Broadcast address and netmask, if known */
|
||||
struct sockaddr_in broadcast_address;
|
||||
struct sockaddr_in netmask;
|
||||
|
@ -220,7 +220,8 @@ int overlay_tick_interface(int i, long long now)
|
||||
}
|
||||
|
||||
fprintf(stderr,"Ticking interface #%d\n",i);
|
||||
|
||||
overlay_interfaces[i].sequence_number++;
|
||||
|
||||
/* Get a buffer ready, and limit it's size appropriately.
|
||||
XXX size limit should be reduced from MTU.
|
||||
XXX we should also take account of the volume of data likely to be in the TX buffer. */
|
||||
@ -288,7 +289,8 @@ int overlay_tick_interface(int i, long long now)
|
||||
fprintf(stderr,"Sending %d bytes\n",e->length);
|
||||
if (!overlay_broadcast_ensemble(i,e->bytes,e->length))
|
||||
{
|
||||
fprintf(stderr,"Successfully transmitted tick frame on interface #%d\n",i);
|
||||
fprintf(stderr,"Successfully transmitted tick frame #%d on interface #%d\n",
|
||||
overlay_interfaces[i].sequence_number,i);
|
||||
/* De-queue the passengers who were aboard. */
|
||||
int j;
|
||||
overlay_payload **p=&overlay_tx[OVERLAY_ISOCHRONOUS_VOICE].first;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "mphlr.h"
|
||||
|
||||
int overlay_add_selfannouncement(overlay_buffer *b)
|
||||
int overlay_add_selfannouncement(int interface,overlay_buffer *b)
|
||||
{
|
||||
/* Pull the first record from the HLR database and turn it into a
|
||||
self-announcment. These are shorter than regular Subscriber Observation
|
||||
@ -22,15 +22,35 @@ int overlay_add_selfannouncement(overlay_buffer *b)
|
||||
*/
|
||||
|
||||
unsigned char c;
|
||||
int zero=0;
|
||||
|
||||
/* Make sure we can find our SID */
|
||||
if (!findHlr(hlr,&zero,NULL,NULL)) return WHY("Could not find first entry in HLR");
|
||||
|
||||
/* Header byte */
|
||||
c=OF_SELFANNOUNCE;
|
||||
if (ob_append_bytes(b,&c,1))
|
||||
return WHY("ob_append_bytes() could not add self-announcement header");
|
||||
|
||||
|
||||
|
||||
/* Add our SID to the announcement */
|
||||
if (ob_append_bytes(b,&hlr[zero+4],SID_SIZE)) return WHY("Could not append SID to self-announcement");
|
||||
|
||||
return WHY("Not implemented");
|
||||
/* A sequence number, so that others can keep track of their reception of our frames.
|
||||
These are per-interface */
|
||||
if (ob_append_int(b,overlay_interfaces[interface].sequence_number))
|
||||
return WHY("ob_append_int() could not add sequence number to self-announcement");
|
||||
|
||||
/* A TTL for this frame?
|
||||
XXX - BATMAN uses various TTLs, but I think that it may just be better to have all TTL=1,
|
||||
and have the onward nodes selectively choose which nodes to on-announce. If we prioritise
|
||||
newly arrived nodes somewhat (or at least reserve some slots for them), then we can still
|
||||
get the good news travels fast property of BATMAN, but without having to flood in the formal
|
||||
sense. */
|
||||
c=1;
|
||||
if (ob_append_bytes(b,&c,1))
|
||||
return WHY("ob_append_bytes() could not add TTL to self-announcement");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int overlay_get_nexthop(overlay_payload *p,unsigned char *nexthop,int *nexthoplen)
|
||||
|
Loading…
x
Reference in New Issue
Block a user