Adding support for marking payloads as broadcast so that they can

be directed to all interfaces if they are broadcast (previously
overlay mesh would "broadcast" to one semi-random interface only).
This commit is contained in:
gardners 2012-04-14 04:06:08 +09:30
parent 0cb3e6e60b
commit f972c988b9
2 changed files with 18 additions and 1 deletions

View File

@ -220,6 +220,16 @@ int overlay_payload_enqueue(int q,overlay_frame *p)
if (0) dump_queue("before",q);
/* If the frame is broadcast, then mark it correctly so that it can be sent
via all interfaces. */
if (overlay_address_is_broadcast(p->destination))
{
p->isBroadcast=1;
int i;
for(i=0;i<OVERLAY_MAX_INTERFACES;i++) p->broadcast_sent_via[i]=0;
}
else p->isBroadcast=0;
overlay_frame *l=overlay_tx[q].last;
if (l) l->next=p;
p->prev=l;

View File

@ -474,6 +474,7 @@ int packetSendRequest(int method,unsigned char *packet,int packet_len,int batchP
struct response_set *responses);
int readArpTable(struct in_addr peers[],int *peer_count,int peer_max);
#define OVERLAY_MAX_INTERFACES 16
typedef struct overlay_address_table {
unsigned char epoch;
@ -515,6 +516,12 @@ typedef struct overlay_frame {
unsigned char ttl;
/* Mark which interfaces the frame has been sent on,
so that we can ensure that broadcast frames get sent
exactly once on each interface */
int isBroadcast;
unsigned char broadcast_sent_via[OVERLAY_MAX_INTERFACES];
unsigned char nexthop[32];
int nexthop_address_status;
int nexthop_interface; /* which interface the next hop should be attempted on */
@ -554,6 +561,7 @@ extern int overlayMode;
#define OVERLAY_INTERFACE_ETHERNET 1
#define OVERLAY_INTERFACE_WIFI 2
#define OVERLAY_INTERFACE_PACKETRADIO 3
typedef struct overlay_interface {
char name[80];
int fd;
@ -603,7 +611,6 @@ typedef struct overlay_interface {
/* Maximum interface count is rather arbitrary.
Memory consumption is O(n) with respect to this parameter, so let's not make it too big for now.
*/
#define OVERLAY_MAX_INTERFACES 16
extern overlay_interface overlay_interfaces[OVERLAY_MAX_INTERFACES];
extern int overlay_last_interface_number; // used to remember where a packet came from
extern unsigned int overlay_sequence_number;