]> git.meshlink.io Git - meshlink/commitdiff
Move localdiscovery variables to mesh.
authorGuus Sliepen <guus@sliepen.org>
Mon, 21 Apr 2014 21:13:39 +0000 (23:13 +0200)
committerGuus Sliepen <guus@sliepen.org>
Mon, 21 Apr 2014 21:13:39 +0000 (23:13 +0200)
src/meshlink_internal.h
src/net.h
src/net_packet.c
src/net_setup.c

index 3c2b0423f7df7ec3952b6f571cdb92ba0cefe274..6426f83dcbce397df1065899a421a99ffa09b557 100644 (file)
@@ -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.
index 184dd934d050624491c2c972889ae1ac3976240e..432825fe099e58bcc10586170a04ef263dab3a06 100644 (file)
--- 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;
index c60d5a531ae87bb22d8471bd8e6c608802bf7a37..c7d6a9d8cc0d83c066f6c20c62f7585c7821ebc1 100644 (file)
@@ -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;
index 484346faaf8260c1407bfb86935986df07f473f5..bf6bab41b9e307cb05c600dd7eabbef3449b02d8 100644 (file)
@@ -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;