mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-20 21:53:12 +00:00
Broadcast on each interface now works, at least for OSX.
This commit is contained in:
parent
b8e8a78828
commit
9108fd5c59
8
dna.c
8
dna.c
@ -262,12 +262,8 @@ int usage(char *complaint)
|
||||
fprintf(stderr," -G - Offer gateway services. Argument specifies locations of necessary files.\n");
|
||||
fprintf(stderr," Use -G [potato|android|custom:...] to set defaults for your device type.\n");
|
||||
fprintf(stderr," -N - Specify one or more interfaces for the DNA overlay mesh to operate.\n");
|
||||
fprintf(stderr," Interface specifications take the form IP[:speed[:type[:port]]], and\n");
|
||||
fprintf(stderr," multiple interfaces can be specified by comma separating them.\n");
|
||||
fprintf(stderr," Speed is the interface speed in bits per second (K,M or G suffixes allowed)\n");
|
||||
fprintf(stderr," Type is WiFi,ethernet,catear or other.\n");
|
||||
fprintf(stderr," Port specifies an alternate UDP port, otherwise %d is used.\n",PORT_DNA);
|
||||
fprintf(stderr," e.g., -N 10.1.2.3,10.1.130.45:2M:wifi\n");
|
||||
fprintf(stderr," Interface specifications take the form <+|->[interface[=type][,...]\n");
|
||||
fprintf(stderr," e.g., -N -en0,+ to use all interfaces except en0\n");
|
||||
fprintf(stderr,"\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ int overlay_interface_init(char *name,struct sockaddr_in src_addr,struct sockadd
|
||||
I(mtu)=1200;
|
||||
|
||||
I(bits_per_second)=speed_in_bits;
|
||||
I(port)=ntohs(src_addr.sin_port);
|
||||
I(port)=port;
|
||||
I(type)=type;
|
||||
I(tick_ms)=500;
|
||||
switch(type) {
|
||||
@ -235,6 +235,7 @@ int overlay_broadcast_ensemble(int interface_number,unsigned char *bytes,int len
|
||||
memset(&s, '\0', sizeof(struct sockaddr_in));
|
||||
s = overlay_interfaces[interface_number].broadcast_address;
|
||||
s.sin_family = AF_INET;
|
||||
fprintf(stderr,"Port=%d\n",overlay_interfaces[interface_number].port);
|
||||
s.sin_port = htons( overlay_interfaces[interface_number].port );
|
||||
|
||||
if(sendto(overlay_interfaces[interface_number].socket, bytes, len, 0, (struct sockaddr *)&s, sizeof(struct sockaddr_in)) < 0)
|
||||
@ -430,23 +431,29 @@ int overlay_check_ticks()
|
||||
struct timeval nowtv;
|
||||
long long now;
|
||||
|
||||
/* Check for changes to interfaces */
|
||||
overlay_interface_discover();
|
||||
|
||||
if (gettimeofday(&nowtv,NULL))
|
||||
return WHY("gettimeofday() failed");
|
||||
|
||||
|
||||
/* Get current time in milliseconds */
|
||||
now=nowtv.tv_sec*1000;
|
||||
now=now+nowtv.tv_usec/1000;
|
||||
|
||||
|
||||
/* Now check if the next tick time for the interfaces is no later than that time.
|
||||
If so, trigger a tick on the interface. */
|
||||
for(i=0;i<overlay_interface_count;i++)
|
||||
{
|
||||
if (now>=overlay_interfaces[i].last_tick_ms+overlay_interfaces[i].tick_ms)
|
||||
{
|
||||
/* This interface is due for a tick */
|
||||
overlay_tick_interface(i,now);
|
||||
overlay_interfaces[i].last_tick_ms=now;
|
||||
}
|
||||
/* Only tick live interfaces */
|
||||
if (overlay_interfaces[i].observed>0)
|
||||
if (now>=overlay_interfaces[i].last_tick_ms+overlay_interfaces[i].tick_ms)
|
||||
{
|
||||
/* This interface is due for a tick */
|
||||
overlay_tick_interface(i,now);
|
||||
overlay_interfaces[i].last_tick_ms=now;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user