mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
Always update unicast addresses
This commit is contained in:
parent
839de7557c
commit
3ab474be16
@ -81,20 +81,17 @@ struct subscriber{
|
||||
|
||||
// result of routing calculations;
|
||||
int reachable;
|
||||
union{
|
||||
// if indirect, who is the next hop?
|
||||
struct subscriber *next_hop;
|
||||
|
||||
struct{
|
||||
// if direct, where do we send packets?
|
||||
struct overlay_interface *interface;
|
||||
|
||||
// if reachable==REACHABLE_UNICAST use this address & sequence number, else use the interface broadcast address
|
||||
struct sockaddr_in address;
|
||||
};
|
||||
};
|
||||
|
||||
// public signing key details
|
||||
// if indirect, who is the next hop?
|
||||
struct subscriber *next_hop;
|
||||
|
||||
// if direct, or unicast, where do we send packets?
|
||||
struct overlay_interface *interface;
|
||||
|
||||
// if reachable==REACHABLE_UNICAST send packets to this address, else use the interface broadcast address
|
||||
struct sockaddr_in address;
|
||||
|
||||
// public signing key details for remote peers
|
||||
unsigned char sas_public[SAS_SIZE];
|
||||
time_ms_t sas_last_request;
|
||||
unsigned char sas_valid;
|
||||
|
@ -823,10 +823,9 @@ overlay_interface_register(char *name,
|
||||
int broadcast_match = 0;
|
||||
int name_match =0;
|
||||
|
||||
if ((overlay_interfaces[i].broadcast_address.sin_addr.s_addr & 0xffffffff)
|
||||
== (broadcast.s_addr & 0xffffffff)){
|
||||
if (overlay_interfaces[i].broadcast_address.sin_addr.s_addr
|
||||
== broadcast.s_addr)
|
||||
broadcast_match = 1;
|
||||
}
|
||||
|
||||
name_match = !strcasecmp(overlay_interfaces[i].name, name);
|
||||
|
||||
|
@ -151,11 +151,16 @@ static void parse_frame(struct overlay_buffer *buff){
|
||||
|
||||
overlay_address_set_sender(sender);
|
||||
|
||||
if (sender->reachable==REACHABLE_NONE){
|
||||
// locate the interface we should send outgoing unicast packets to
|
||||
overlay_interface *interface = overlay_interface_find(*addr);
|
||||
if (interface){
|
||||
// assume the port number of the other servald matches our local port number configuration
|
||||
// locate the interface we should send outgoing unicast packets to
|
||||
overlay_interface *interface = overlay_interface_find(*addr);
|
||||
if (interface){
|
||||
// always update the IP address we heard them from, even if we don't need to use it right now
|
||||
sender->address.sin_family = AF_INET;
|
||||
sender->address.sin_addr = *addr;
|
||||
// assume the port number of the other servald matches our local port number configuration
|
||||
sender->address.sin_port = htons(interface->port);
|
||||
|
||||
if (sender->reachable==REACHABLE_NONE){
|
||||
reachable_unicast(sender, interface, *addr, interface->port);
|
||||
}
|
||||
}
|
||||
|
@ -278,12 +278,16 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
|
||||
|
||||
overlay_address_set_sender(f.source);
|
||||
|
||||
struct sockaddr_in *addr=(struct sockaddr_in *)recvaddr;
|
||||
|
||||
// always update the IP address we heard them from, even if we don't need to use it right now
|
||||
f.source->address = *addr;
|
||||
|
||||
// if this is a dummy announcement for a node that isn't in our routing table
|
||||
if (f.destination &&
|
||||
(f.source->reachable == REACHABLE_NONE || f.source->reachable == REACHABLE_UNICAST) &&
|
||||
(!f.source->node) &&
|
||||
(interface->fileP || recvaddr->sa_family==AF_INET)){
|
||||
struct sockaddr_in *addr=(struct sockaddr_in *)recvaddr;
|
||||
|
||||
// mark this subscriber as reachable directly via unicast.
|
||||
reachable_unicast(f.source, interface, addr->sin_addr, ntohs(addr->sin_port));
|
||||
|
Loading…
Reference in New Issue
Block a user