From f7bacce5e9fb1363a503970b00d601c3d1d7bd12 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 21 Apr 2014 23:13:39 +0200 Subject: [PATCH] Move localdiscovery variables to mesh. --- src/meshlink_internal.h | 4 ++++ src/net.h | 3 --- src/net_packet.c | 16 +++++++--------- src/net_setup.c | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/meshlink_internal.h b/src/meshlink_internal.h index 3c2b0423..6426f83d 100644 --- a/src/meshlink_internal.h +++ b/src/meshlink_internal.h @@ -24,6 +24,7 @@ #include "event.h" #include "meshlink.h" +#include "sockaddr.h" typedef enum proxytype_t { PROXY_NONE = 0, @@ -70,6 +71,9 @@ struct meshlink_handle { char *proxyuser; char *proxypass; proxytype_t proxytype; + + bool localdiscovery; + sockaddr_t localdiscovery_address; }; /// A handle for a MeshLink node. diff --git a/src/net.h b/src/net.h index 184dd934..432825fe 100644 --- a/src/net.h +++ b/src/net.h @@ -80,11 +80,8 @@ typedef struct outgoing_t { } outgoing_t; extern int maxoutbufsize; -extern int seconds_till_retry; extern int addressfamily; extern unsigned replaywin; -extern bool localdiscovery; -extern sockaddr_t localdiscovery_address; extern listen_socket_t listen_socket[MAXSOCKETS]; extern int listen_sockets; diff --git a/src/net_packet.c b/src/net_packet.c index c60d5a53..c7d6a9d8 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -43,8 +43,6 @@ int keylifetime = 0; static void send_udppacket(node_t *, vpn_packet_t *); unsigned replaywin = 16; -bool localdiscovery = false; -sockaddr_t localdiscovery_address; #define MAX_SEQNO 1073741824 @@ -112,7 +110,7 @@ static void send_mtu_probe_handler(void *data) { timeout = pingtimeout; } - for(int i = 0; i < 4 + localdiscovery; i++) { + for(int i = 0; i < 4 + mesh->localdiscovery; i++) { int len; if(i == 0) { @@ -422,18 +420,18 @@ static void choose_broadcast_address(const node_t *n, const sockaddr_t **sa, int *sock = rand() % listen_sockets; if(listen_socket[*sock].sa.sa.sa_family == AF_INET6) { - if(localdiscovery_address.sa.sa_family == AF_INET6) { - localdiscovery_address.in6.sin6_port = n->prevedge->address.in.sin_port; - *sa = &localdiscovery_address; + if(mesh->localdiscovery_address.sa.sa_family == AF_INET6) { + mesh->localdiscovery_address.in6.sin6_port = n->prevedge->address.in.sin_port; + *sa = &mesh->localdiscovery_address; } else { broadcast_ipv6.in6.sin6_port = n->prevedge->address.in.sin_port; broadcast_ipv6.in6.sin6_scope_id = listen_socket[*sock].sa.in6.sin6_scope_id; *sa = &broadcast_ipv6; } } else { - if(localdiscovery_address.sa.sa_family == AF_INET) { - localdiscovery_address.in.sin_port = n->prevedge->address.in.sin_port; - *sa = &localdiscovery_address; + if(mesh->localdiscovery_address.sa.sa_family == AF_INET) { + mesh->localdiscovery_address.in.sin_port = n->prevedge->address.in.sin_port; + *sa = &mesh->localdiscovery_address; } else { broadcast_ipv4.in.sin_port = n->prevedge->address.in.sin_port; *sa = &broadcast_ipv4; diff --git a/src/net_setup.c b/src/net_setup.c index 484346fa..bf6bab41 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -176,7 +176,7 @@ char *get_name(void) { } bool setup_myself_reloadable(void) { - localdiscovery = true; + mesh->localdiscovery = true; keylifetime = 3600; // TODO: check if this can be removed as well maxtimeout = 900; autoconnect = 3; -- 2.39.5