Fix sparse warnings and add an extra sprinkling of const.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 28 May 2011 21:36:52 +0000 (23:36 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 28 May 2011 21:36:52 +0000 (23:36 +0200)
This is more or less the equivalent of Sven-Haegar Koch's fixes in the 1.1
branch.

35 files changed:
lib/pidfile.c
lib/pidfile.h
lib/utils.c
lib/utils.h
lib/xalloc.h
lib/xmalloc.c
src/bsd/device.c
src/conf.c
src/conf.h
src/connection.h
src/cygwin/device.c
src/dummy/device.c
src/event.c
src/graph.c
src/graph.h
src/linux/device.c
src/mingw/device.c
src/net.c
src/net.h
src/net_packet.c
src/net_setup.c
src/net_socket.c
src/node.c
src/node.h
src/process.c
src/protocol.c
src/protocol.h
src/protocol_key.c
src/protocol_misc.c
src/protocol_subnet.c
src/raw_socket/device.c
src/solaris/device.c
src/subnet.c
src/uml_socket/device.c
src/vde/device.c

index 425b304..6e24d5f 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "system.h"
 
 
 #include "system.h"
 
+#include "pidfile.h"
+
 #ifndef HAVE_MINGW
 /* read_pid
  *
 #ifndef HAVE_MINGW
 /* read_pid
  *
@@ -34,7 +36,7 @@
  * 0 is returned if either there's no pidfile, it's empty
  * or no pid can be read.
  */
  * 0 is returned if either there's no pidfile, it's empty
  * or no pid can be read.
  */
-pid_t read_pid (char *pidfile)
+pid_t read_pid (const char *pidfile)
 {
   FILE *f;
   long pid;
 {
   FILE *f;
   long pid;
@@ -53,7 +55,7 @@ pid_t read_pid (char *pidfile)
  * table (using /proc) to determine if the process already exists. If
  * so the pid is returned, otherwise 0.
  */
  * table (using /proc) to determine if the process already exists. If
  * so the pid is returned, otherwise 0.
  */
-pid_t check_pid (char *pidfile)
+pid_t check_pid (const char *pidfile)
 {
   pid_t pid = read_pid(pidfile);
 
 {
   pid_t pid = read_pid(pidfile);
 
@@ -79,7 +81,7 @@ pid_t check_pid (char *pidfile)
  * Writes the pid to the specified file. If that fails 0 is
  * returned, otherwise the pid.
  */
  * Writes the pid to the specified file. If that fails 0 is
  * returned, otherwise the pid.
  */
-pid_t write_pid (char *pidfile)
+pid_t write_pid (const char *pidfile)
 {
   FILE *f;
   int fd;
 {
   FILE *f;
   int fd;
@@ -124,7 +126,7 @@ pid_t write_pid (char *pidfile)
  * Remove the the specified file. The result from unlink(2)
  * is returned
  */
  * Remove the the specified file. The result from unlink(2)
  * is returned
  */
-int remove_pid (char *pidfile)
+int remove_pid (const char *pidfile)
 {
   return unlink (pidfile);
 }
 {
   return unlink (pidfile);
 }
index d7b970c..590a7bc 100644 (file)
@@ -26,7 +26,7 @@
  * 0 is returned if either there's no pidfile, it's empty
  * or no pid can be read.
  */
  * 0 is returned if either there's no pidfile, it's empty
  * or no pid can be read.
  */
-pid_t read_pid (char *pidfile);
+extern pid_t read_pid (const char *pidfile);
 
 /* check_pid
  *
 
 /* check_pid
  *
@@ -34,19 +34,19 @@ pid_t read_pid (char *pidfile);
  * table (using /proc) to determine if the process already exists. If
  * so 1 is returned, otherwise 0.
  */
  * table (using /proc) to determine if the process already exists. If
  * so 1 is returned, otherwise 0.
  */
-pid_t check_pid (char *pidfile);
+extern pid_t check_pid (const char *pidfile);
 
 /* write_pid
  *
  * Writes the pid to the specified file. If that fails 0 is
  * returned, otherwise the pid.
  */
 
 /* write_pid
  *
  * Writes the pid to the specified file. If that fails 0 is
  * returned, otherwise the pid.
  */
-pid_t write_pid (char *pidfile);
+extern pid_t write_pid (const char *pidfile);
 
 /* remove_pid
  *
  * Remove the the specified file. The result from unlink(2)
  * is returned
  */
 
 /* remove_pid
  *
  * Remove the the specified file. The result from unlink(2)
  * is returned
  */
-int remove_pid (char *pidfile);
+extern int remove_pid (const char *pidfile);
 #endif
 #endif
index dd7e4de..6ea904a 100644 (file)
@@ -23,9 +23,9 @@
 #include "../src/logger.h"
 #include "utils.h"
 
 #include "../src/logger.h"
 #include "utils.h"
 
-const char hexadecimals[] = "0123456789ABCDEF";
+static const char hexadecimals[] = "0123456789ABCDEF";
 
 
-int charhex2bin(char c) {
+static int charhex2bin(char c) {
        if(isdigit(c))
                return c - '0';
        else
        if(isdigit(c))
                return c - '0';
        else
@@ -67,7 +67,7 @@ const char *winerror(int err) {
 }
 #endif
 
 }
 #endif
 
-unsigned int bitfield_to_int(void *bitfield, size_t size) {
+unsigned int bitfield_to_int(const void *bitfield, size_t size) {
        unsigned int value = 0;
        if(size > sizeof value)
                size = sizeof value;
        unsigned int value = 0;
        if(size > sizeof value)
                size = sizeof value;
index 4456616..f6ff705 100644 (file)
@@ -40,6 +40,6 @@ extern const char *winerror(int);
 #define sockinprogress(x) ((x) == EINPROGRESS)
 #endif
 
 #define sockinprogress(x) ((x) == EINPROGRESS)
 #endif
 
-extern unsigned int bitfield_to_int(void *bitfield, size_t size);
+extern unsigned int bitfield_to_int(const void *bitfield, size_t size);
 
 #endif                                                 /* __TINC_UTILS_H__ */
 
 #endif                                                 /* __TINC_UTILS_H__ */
index 51f99bd..952f921 100644 (file)
@@ -16,7 +16,7 @@ extern int xalloc_exit_failure;
 extern char *const xalloc_msg_memory_exhausted;
 
 /* FIXME: describe */
 extern char *const xalloc_msg_memory_exhausted;
 
 /* FIXME: describe */
-extern void (*xalloc_fail_func) ();
+extern void (*xalloc_fail_func) (int);
 
 void *xmalloc PARAMS ((size_t n)) __attribute__ ((__malloc__));
 void *xmalloc_and_zero PARAMS ((size_t n)) __attribute__ ((__malloc__));
 
 void *xmalloc PARAMS ((size_t n)) __attribute__ ((__malloc__));
 void *xmalloc_and_zero PARAMS ((size_t n)) __attribute__ ((__malloc__));
index 4e79aff..e4079ce 100644 (file)
@@ -56,7 +56,7 @@ int xalloc_exit_failure = EXIT_FAILURE;
 char *const xalloc_msg_memory_exhausted = "Memory exhausted";
 
 /* FIXME: describe */
 char *const xalloc_msg_memory_exhausted = "Memory exhausted";
 
 /* FIXME: describe */
-void (*xalloc_fail_func) (int) = 0;
+void (*xalloc_fail_func) (int) = NULL;
 
 static void
 xalloc_fail (int size)
 
 static void
 xalloc_fail (int size)
@@ -70,13 +70,12 @@ xalloc_fail (int size)
 /* Allocate N bytes of memory dynamically, with error checking.  */
 
 void *
 /* Allocate N bytes of memory dynamically, with error checking.  */
 
 void *
-xmalloc (n)
-     size_t n;
+xmalloc (size_t n)
 {
   void *p;
 
   p = malloc (n);
 {
   void *p;
 
   p = malloc (n);
-  if (p == 0)
+  if (p == NULL)
     xalloc_fail ((int)n);
   return p;
 }
     xalloc_fail ((int)n);
   return p;
 }
@@ -84,13 +83,12 @@ xmalloc (n)
 /* Allocate N bytes of memory dynamically, and set it all to zero. */
 
 void *
 /* Allocate N bytes of memory dynamically, and set it all to zero. */
 
 void *
-xmalloc_and_zero (n)
-     size_t n;
+xmalloc_and_zero (size_t n)
 {
   void *p;
 
   p = malloc (n);
 {
   void *p;
 
   p = malloc (n);
-  if (p == 0)
+  if (p == NULL)
     xalloc_fail ((int)n);
   memset (p, '\0', n);
   return p;
     xalloc_fail ((int)n);
   memset (p, '\0', n);
   return p;
@@ -101,12 +99,10 @@ xmalloc_and_zero (n)
    If P is NULL, run xmalloc.  */
 
 void *
    If P is NULL, run xmalloc.  */
 
 void *
-xrealloc (p, n)
-     void *p;
-     size_t n;
+xrealloc (void *p, size_t n)
 {
   p = realloc (p, n);
 {
   p = realloc (p, n);
-  if (p == 0)
+  if (p == NULL)
     xalloc_fail (n);
   return p;
 }
     xalloc_fail (n);
   return p;
 }
@@ -134,7 +130,7 @@ xcalloc (n, s)
   void *p;
 
   p = calloc (n, s);
   void *p;
 
   p = calloc (n, s);
-  if (p == 0)
+  if (p == NULL)
     xalloc_fail ();
   return p;
 }
     xalloc_fail ();
   return p;
 }
index d6ef0e8..a41827f 100644 (file)
@@ -22,6 +22,7 @@
 #include "system.h"
 
 #include "conf.h"
 #include "system.h"
 
 #include "conf.h"
+#include "device.h"
 #include "logger.h"
 #include "net.h"
 #include "route.h"
 #include "logger.h"
 #include "net.h"
 #include "route.h"
index 5f8fdb1..b895b7f 100644 (file)
@@ -92,7 +92,7 @@ void config_add(avl_tree_t *config_tree, config_t *cfg) {
        avl_insert(config_tree, cfg);
 }
 
        avl_insert(config_tree, cfg);
 }
 
-config_t *lookup_config(avl_tree_t *config_tree, char *variable) {
+config_t *lookup_config(const avl_tree_t *config_tree, char *variable) {
        config_t cfg, *found;
 
        cfg.variable = variable;
        config_t cfg, *found;
 
        cfg.variable = variable;
@@ -110,7 +110,7 @@ config_t *lookup_config(avl_tree_t *config_tree, char *variable) {
        return found;
 }
 
        return found;
 }
 
-config_t *lookup_config_next(avl_tree_t *config_tree, const config_t *cfg) {
+config_t *lookup_config_next(const avl_tree_t *config_tree, const config_t *cfg) {
        avl_node_t *node;
        config_t *found;
 
        avl_node_t *node;
        config_t *found;
 
@@ -188,7 +188,7 @@ bool get_config_address(const config_t *cfg, struct addrinfo **result) {
 }
 
 bool get_config_subnet(const config_t *cfg, subnet_t ** result) {
 }
 
 bool get_config_subnet(const config_t *cfg, subnet_t ** result) {
-       subnet_t subnet = {0};
+       subnet_t subnet = {NULL};
 
        if(!cfg)
                return false;
 
        if(!cfg)
                return false;
@@ -368,7 +368,7 @@ void read_config_options(avl_tree_t *config_tree, const char *prefix) {
        }
 }
 
        }
 }
 
-bool read_server_config() {
+bool read_server_config(void) {
        char *fname;
        bool x;
 
        char *fname;
        bool x;
 
index 3eae4ad..5b0796e 100644 (file)
@@ -48,8 +48,8 @@ extern void exit_configuration(avl_tree_t **);
 extern config_t *new_config(void) __attribute__ ((__malloc__));
 extern void free_config(config_t *);
 extern void config_add(avl_tree_t *, config_t *);
 extern config_t *new_config(void) __attribute__ ((__malloc__));
 extern void free_config(config_t *);
 extern void config_add(avl_tree_t *, config_t *);
-extern config_t *lookup_config(avl_tree_t *, char *);
-extern config_t *lookup_config_next(avl_tree_t *, const config_t *);
+extern config_t *lookup_config(const avl_tree_t *, char *);
+extern config_t *lookup_config_next(const avl_tree_t *, const config_t *);
 extern bool get_config_bool(const config_t *, bool *);
 extern bool get_config_int(const config_t *, int *);
 extern bool get_config_string(const config_t *, char **);
 extern bool get_config_bool(const config_t *, bool *);
 extern bool get_config_int(const config_t *, int *);
 extern bool get_config_string(const config_t *, char **);
index 05e8b4b..eb13413 100644 (file)
 #define OPTION_CLAMP_MSS       0x0008
 
 typedef struct connection_status_t {
 #define OPTION_CLAMP_MSS       0x0008
 
 typedef struct connection_status_t {
-       int pinged:1;                           /* sent ping */
-       int active:1;                           /* 1 if active.. */
-       int connecting:1;                       /* 1 if we are waiting for a non-blocking connect() to finish */
-       int termreq:1;                          /* the termination of this connection was requested */
-       int remove:1;                           /* Set to 1 if you want this connection removed */
-       int timeout:1;                          /* 1 if gotten timeout */
-       int encryptout:1;                       /* 1 if we can encrypt outgoing traffic */
-       int decryptin:1;                        /* 1 if we have to decrypt incoming traffic */
-       int mst:1;                              /* 1 if this connection is part of a minimum spanning tree */
-       int unused:23;
+       unsigned int pinged:1;                          /* sent ping */
+       unsigned int active:1;                          /* 1 if active.. */
+       unsigned int connecting:1;                      /* 1 if we are waiting for a non-blocking connect() to finish */
+       unsigned int termreq:1;                         /* the termination of this connection was requested */
+       unsigned int remove:1;                          /* Set to 1 if you want this connection removed */
+       unsigned int timeout:1;                         /* 1 if gotten timeout */
+       unsigned int encryptout:1;                      /* 1 if we can encrypt outgoing traffic */
+       unsigned int decryptin:1;                       /* 1 if we have to decrypt incoming traffic */
+       unsigned int mst:1;                             /* 1 if this connection is part of a minimum spanning tree */
+       unsigned int unused:23;
 } connection_status_t;
 
 #include "edge.h"
 } connection_status_t;
 
 #include "edge.h"
index 90966cd..42016cb 100644 (file)
@@ -24,6 +24,7 @@
 #include <w32api/winioctl.h>
 
 #include "conf.h"
 #include <w32api/winioctl.h>
 
 #include "conf.h"
+#include "device.h"
 #include "logger.h"
 #include "net.h"
 #include "route.h"
 #include "logger.h"
 #include "net.h"
 #include "route.h"
index c84e899..25a38f2 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "system.h"
 
 
 #include "system.h"
 
+#include "device.h"
 #include "logger.h"
 #include "net.h"
 
 #include "logger.h"
 #include "net.h"
 
index 99e6a23..e03b04d 100644 (file)
@@ -28,7 +28,7 @@
 avl_tree_t *event_tree;
 extern time_t now;
 
 avl_tree_t *event_tree;
 extern time_t now;
 
-int id;
+static int id;
 
 static int event_compare(const event_t *a, const event_t *b) {
        if(a->time > b->time)
 
 static int event_compare(const event_t *a, const event_t *b) {
        if(a->time > b->time)
index 3495f23..9aadcd8 100644 (file)
@@ -49,6 +49,7 @@
 #include "connection.h"
 #include "device.h"
 #include "edge.h"
 #include "connection.h"
 #include "device.h"
 #include "edge.h"
+#include "graph.h"
 #include "logger.h"
 #include "netutl.h"
 #include "node.h"
 #include "logger.h"
 #include "netutl.h"
 #include "node.h"
@@ -65,7 +66,7 @@ static bool graph_changed = true;
    Please note that sorting on weight is already done by add_edge().
 */
 
    Please note that sorting on weight is already done by add_edge().
 */
 
-void mst_kruskal(void) {
+static void mst_kruskal(void) {
        avl_node_t *node, *next;
        edge_t *e;
        node_t *n;
        avl_node_t *node, *next;
        edge_t *e;
        node_t *n;
@@ -146,7 +147,7 @@ void mst_kruskal(void) {
    Running time: O(E)
 */
 
    Running time: O(E)
 */
 
-void sssp_bfs(void) {
+static void sssp_bfs(void) {
        avl_node_t *node, *next, *to;
        edge_t *e;
        node_t *n;
        avl_node_t *node, *next, *to;
        edge_t *e;
        node_t *n;
index 2600601..fb41096 100644 (file)
@@ -22,8 +22,6 @@
 #define __TINC_GRAPH_H__
 
 extern void graph(void);
 #define __TINC_GRAPH_H__
 
 extern void graph(void);
-extern void mst_kruskal(void);
-extern void sssp_bfs(void);
 extern void dump_graph(void);
 
 #endif /* __TINC_GRAPH_H__ */
 extern void dump_graph(void);
 
 #endif /* __TINC_GRAPH_H__ */
index 0632d51..c7c1b65 100644 (file)
@@ -28,6 +28,7 @@
 #endif
 
 #include "conf.h"
 #endif
 
 #include "conf.h"
+#include "device.h"
 #include "logger.h"
 #include "net.h"
 #include "route.h"
 #include "logger.h"
 #include "net.h"
 #include "route.h"
index fec53cf..1dac3bf 100644 (file)
@@ -24,6 +24,7 @@
 #include <winioctl.h>
 
 #include "conf.h"
 #include <winioctl.h>
 
 #include "conf.h"
+#include "device.h"
 #include "logger.h"
 #include "net.h"
 #include "route.h"
 #include "logger.h"
 #include "net.h"
 #include "route.h"
index e6a1166..3508dd7 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -423,7 +423,7 @@ int main_loop(void) {
                                        }
                                }
 
                                        }
                                }
 
-                               send_key_changed(broadcast, myself);
+                               send_key_changed();
                                keyexpires = now + keylifetime;
                        }
 
                                keyexpires = now + keylifetime;
                        }
 
index 55856e2..b831cdd 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -121,6 +121,8 @@ extern time_t now;
 extern int contradicting_add_edge;
 extern int contradicting_del_edge;
 
 extern int contradicting_add_edge;
 extern int contradicting_del_edge;
 
+extern volatile bool running;
+
 /* Yes, very strange placement indeed, but otherwise the typedefs get all tangled up */
 #include "connection.h"
 #include "node.h"
 /* Yes, very strange placement indeed, but otherwise the typedefs get all tangled up */
 #include "connection.h"
 #include "node.h"
@@ -133,7 +135,7 @@ extern bool handle_new_meta_connection(int);
 extern int setup_listen_socket(const sockaddr_t *);
 extern int setup_vpn_in_socket(const sockaddr_t *);
 extern void send_packet(const struct node_t *, vpn_packet_t *);
 extern int setup_listen_socket(const sockaddr_t *);
 extern int setup_vpn_in_socket(const sockaddr_t *);
 extern void send_packet(const struct node_t *, vpn_packet_t *);
-extern void receive_tcppacket(struct connection_t *, char *, int);
+extern void receive_tcppacket(struct connection_t *, const char *, int);
 extern void broadcast_packet(const struct node_t *, vpn_packet_t *);
 extern bool setup_network(void);
 extern void setup_outgoing_connection(struct outgoing_t *);
 extern void broadcast_packet(const struct node_t *, vpn_packet_t *);
 extern bool setup_network(void);
 extern void setup_outgoing_connection(struct outgoing_t *);
@@ -144,7 +146,7 @@ extern void terminate_connection(struct connection_t *, bool);
 extern void flush_queue(struct node_t *);
 extern bool read_rsa_public_key(struct connection_t *);
 extern void send_mtu_probe(struct node_t *);
 extern void flush_queue(struct node_t *);
 extern bool read_rsa_public_key(struct connection_t *);
 extern void send_mtu_probe(struct node_t *);
-extern void load_all_subnets();
+extern void load_all_subnets(void);
 
 #ifndef HAVE_MINGW
 #define closesocket(s) close(s)
 
 #ifndef HAVE_MINGW
 #define closesocket(s) close(s)
index c7efa88..062523e 100644 (file)
@@ -365,7 +365,7 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt) {
                receive_packet(n, inpkt);
 }
 
                receive_packet(n, inpkt);
 }
 
-void receive_tcppacket(connection_t *c, char *buffer, int len) {
+void receive_tcppacket(connection_t *c, const char *buffer, int len) {
        vpn_packet_t outpkt;
 
        outpkt.len = len;
        vpn_packet_t outpkt;
 
        outpkt.len = len;
index cc6ef68..f18e3bf 100644 (file)
@@ -144,7 +144,7 @@ bool read_rsa_public_key(connection_t *c) {
        return false;
 }
 
        return false;
 }
 
-bool read_rsa_private_key(void) {
+static bool read_rsa_private_key(void) {
        FILE *fp;
        char *fname, *key, *pubkey;
        struct stat s;
        FILE *fp;
        char *fname, *key, *pubkey;
        struct stat s;
@@ -267,7 +267,7 @@ void load_all_subnets(void) {
 /*
   Configure node_t myself and set up the local sockets (listen only)
 */
 /*
   Configure node_t myself and set up the local sockets (listen only)
 */
-bool setup_myself(void) {
+static bool setup_myself(void) {
        config_t *cfg;
        subnet_t *subnet;
        char *name, *hostname, *mode, *afname, *cipher, *digest;
        config_t *cfg;
        subnet_t *subnet;
        char *name, *hostname, *mode, *afname, *cipher, *digest;
index 2e6b068..a45bc20 100644 (file)
@@ -535,7 +535,7 @@ bool handle_new_meta_connection(int sock) {
        return true;
 }
 
        return true;
 }
 
-void free_outgoing(outgoing_t *outgoing) {
+static void free_outgoing(outgoing_t *outgoing) {
        if(outgoing->ai)
                freeaddrinfo(outgoing->ai);
 
        if(outgoing->ai)
                freeaddrinfo(outgoing->ai);
 
index 36979ef..d6156b6 100644 (file)
@@ -124,7 +124,7 @@ void node_del(node_t *n) {
 }
 
 node_t *lookup_node(char *name) {
 }
 
 node_t *lookup_node(char *name) {
-       node_t n = {0};
+       node_t n = {NULL};
 
        n.name = name;
 
 
        n.name = name;
 
@@ -132,7 +132,7 @@ node_t *lookup_node(char *name) {
 }
 
 node_t *lookup_node_udp(const sockaddr_t *sa) {
 }
 
 node_t *lookup_node_udp(const sockaddr_t *sa) {
-       node_t n = {0};
+       node_t n = {NULL};
 
        n.address = *sa;
        n.name = NULL;
 
        n.address = *sa;
        n.name = NULL;
@@ -158,7 +158,7 @@ void update_node_udp(node_t *n, const sockaddr_t *sa) {
                ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s set to %s", n->name, n->hostname);
        } else {
                memset(&n->address, 0, sizeof n->address);
                ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s set to %s", n->name, n->hostname);
        } else {
                memset(&n->address, 0, sizeof n->address);
-               n->hostname = 0;
+               n->hostname = NULL;
                ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s cleared", n->name);
        }
 }
                ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s cleared", n->name);
        }
 }
index 7bac28e..107a59b 100644 (file)
 #include "subnet.h"
 
 typedef struct node_status_t {
 #include "subnet.h"
 
 typedef struct node_status_t {
-       int unused_active:1;                    /* 1 if active (not used for nodes) */
-       int validkey:1;                         /* 1 if we currently have a valid key for him */
-       int unused_waitingforkey:1;             /* 1 if we already sent out a request */
-       int visited:1;                          /* 1 if this node has been visited by one of the graph algorithms */
-       int reachable:1;                        /* 1 if this node is reachable in the graph */
-       int indirect:1;                         /* 1 if this node is not directly reachable by us */
-       int unused:26;
+       unsigned int unused_active:1;                   /* 1 if active (not used for nodes) */
+       unsigned int validkey:1;                                /* 1 if we currently have a valid key for him */
+       unsigned int unused_waitingforkey:1;            /* 1 if we already sent out a request */
+       unsigned int visited:1;                         /* 1 if this node has been visited by one of the graph algorithms */
+       unsigned int reachable:1;                       /* 1 if this node is reachable in the graph */
+       unsigned int indirect:1;                                /* 1 if this node is not directly reachable by us */
+       unsigned int unused:26;
 } node_status_t;
 
 typedef struct node_t {
 } node_status_t;
 
 typedef struct node_t {
index e74c1d9..c659237 100644 (file)
@@ -25,6 +25,7 @@
 #include "device.h"
 #include "edge.h"
 #include "logger.h"
 #include "device.h"
 #include "edge.h"
 #include "logger.h"
+#include "net.h"
 #include "node.h"
 #include "pidfile.h"
 #include "process.h"
 #include "node.h"
 #include "pidfile.h"
 #include "process.h"
@@ -41,10 +42,9 @@ extern char *identname;
 extern char *pidfilename;
 extern char **g_argv;
 extern bool use_logfile;
 extern char *pidfilename;
 extern char **g_argv;
 extern bool use_logfile;
-extern volatile bool running;
 
 #ifndef HAVE_MINGW
 
 #ifndef HAVE_MINGW
-sigset_t emptysigset;
+static sigset_t emptysigset;
 #endif
 
 static int saved_debug_level = -1;
 #endif
 
 static int saved_debug_level = -1;
index 9d7c349..5de30d7 100644 (file)
@@ -189,7 +189,7 @@ void exit_requests(void) {
 }
 
 bool seen_request(char *request) {
 }
 
 bool seen_request(char *request) {
-       past_request_t *new, p = {0};
+       past_request_t *new, p = {NULL};
 
        p.request = request;
 
 
        p.request = request;
 
index 2aed26d..6c46c72 100644 (file)
@@ -96,10 +96,10 @@ extern bool send_add_subnet(struct connection_t *, const struct subnet_t *);
 extern bool send_del_subnet(struct connection_t *, const struct subnet_t *);
 extern bool send_add_edge(struct connection_t *, const struct edge_t *);
 extern bool send_del_edge(struct connection_t *, const struct edge_t *);
 extern bool send_del_subnet(struct connection_t *, const struct subnet_t *);
 extern bool send_add_edge(struct connection_t *, const struct edge_t *);
 extern bool send_del_edge(struct connection_t *, const struct edge_t *);
-extern void send_key_changed();
+extern void send_key_changed(void);
 extern bool send_req_key(struct node_t *);
 extern bool send_ans_key(struct node_t *);
 extern bool send_req_key(struct node_t *);
 extern bool send_ans_key(struct node_t *);
-extern bool send_tcppacket(struct connection_t *, struct vpn_packet_t *);
+extern bool send_tcppacket(struct connection_t *, const struct vpn_packet_t *);
 
 /* Request handlers  */
 
 
 /* Request handlers  */
 
index 6ff68d2..f34ebaa 100644 (file)
@@ -34,9 +34,9 @@
 #include "utils.h"
 #include "xalloc.h"
 
 #include "utils.h"
 #include "xalloc.h"
 
-bool mykeyused = false;
+static bool mykeyused = false;
 
 
-void send_key_changed() {
+void send_key_changed(void) {
        avl_node_t *node;
        connection_t *c;
 
        avl_node_t *node;
        connection_t *c;
 
index 28571ef..6f7ab03 100644 (file)
@@ -119,7 +119,7 @@ bool pong_h(connection_t *c) {
 
 /* Sending and receiving packets via TCP */
 
 
 /* Sending and receiving packets via TCP */
 
-bool send_tcppacket(connection_t *c, vpn_packet_t *packet) {
+bool send_tcppacket(connection_t *c, const vpn_packet_t *packet) {
        /* If there already is a lot of data in the outbuf buffer, discard this packet.
            We use a very simple Random Early Drop algorithm. */
 
        /* If there already is a lot of data in the outbuf buffer, discard this packet.
            We use a very simple Random Early Drop algorithm. */
 
index 9ae491d..62656c3 100644 (file)
@@ -45,7 +45,7 @@ bool add_subnet_h(connection_t *c) {
        char subnetstr[MAX_STRING_SIZE];
        char name[MAX_STRING_SIZE];
        node_t *owner;
        char subnetstr[MAX_STRING_SIZE];
        char name[MAX_STRING_SIZE];
        node_t *owner;
-       subnet_t s = {0}, *new, *old;
+       subnet_t s = {NULL}, *new, *old;
 
        if(sscanf(c->buffer, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) {
                logger(LOG_ERR, "Got bad %s from %s (%s)", "ADD_SUBNET", c->name,
 
        if(sscanf(c->buffer, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) {
                logger(LOG_ERR, "Got bad %s from %s (%s)", "ADD_SUBNET", c->name,
@@ -154,7 +154,7 @@ bool del_subnet_h(connection_t *c) {
        char subnetstr[MAX_STRING_SIZE];
        char name[MAX_STRING_SIZE];
        node_t *owner;
        char subnetstr[MAX_STRING_SIZE];
        char name[MAX_STRING_SIZE];
        node_t *owner;
-       subnet_t s = {0}, *find;
+       subnet_t s = {NULL}, *find;
 
        if(sscanf(c->buffer, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) {
                logger(LOG_ERR, "Got bad %s from %s (%s)", "DEL_SUBNET", c->name,
 
        if(sscanf(c->buffer, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) {
                logger(LOG_ERR, "Got bad %s from %s (%s)", "DEL_SUBNET", c->name,
index f68e461..abe368a 100644 (file)
@@ -23,6 +23,7 @@
 #include <netpacket/packet.h>
 
 #include "conf.h"
 #include <netpacket/packet.h>
 
 #include "conf.h"
+#include "device.h"
 #include "net.h"
 #include "logger.h"
 #include "utils.h"
 #include "net.h"
 #include "logger.h"
 #include "utils.h"
index 3a50b16..0dfffb1 100644 (file)
@@ -26,6 +26,7 @@
 #include <net/if_tun.h>
 
 #include "conf.h"
 #include <net/if_tun.h>
 
 #include "conf.h"
+#include "device.h"
 #include "logger.h"
 #include "net.h"
 #include "utils.h"
 #include "logger.h"
 #include "net.h"
 #include "utils.h"
index 67be001..f010e4e 100644 (file)
@@ -52,7 +52,7 @@ static subnet_t *cache_mac_subnet[2];
 static bool cache_mac_valid[2];
 static int cache_mac_slot;
 
 static bool cache_mac_valid[2];
 static int cache_mac_slot;
 
-void subnet_cache_flush() {
+void subnet_cache_flush(void) {
        cache_ipv4_valid[0] = cache_ipv4_valid[1] = false;
        cache_ipv6_valid[0] = cache_ipv6_valid[1] = false;
        cache_mac_valid[0] = cache_mac_valid[1] = false;
        cache_ipv4_valid[0] = cache_ipv4_valid[1] = false;
        cache_ipv6_valid[0] = cache_ipv6_valid[1] = false;
        cache_mac_valid[0] = cache_mac_valid[1] = false;
@@ -451,7 +451,7 @@ subnet_t *lookup_subnet_ipv6(const ipv6_t *address) {
 void subnet_update(node_t *owner, subnet_t *subnet, bool up) {
        avl_node_t *node;
        int i;
 void subnet_update(node_t *owner, subnet_t *subnet, bool up) {
        avl_node_t *node;
        int i;
-       char *envp[9] = {0};
+       char *envp[9] = {NULL};
        char netstr[MAXNETSTR];
        char *name, *address, *port;
        char empty[] = "";
        char netstr[MAXNETSTR];
        char *name, *address, *port;
        char empty[] = "";
index 59551b4..a2da757 100644 (file)
@@ -23,6 +23,7 @@
 #include <sys/un.h>
 
 #include "conf.h"
 #include <sys/un.h>
 
 #include "conf.h"
+#include "device.h"
 #include "net.h"
 #include "logger.h"
 #include "utils.h"
 #include "net.h"
 #include "logger.h"
 #include "utils.h"
index 6148ccb..63171f9 100644 (file)
@@ -22,6 +22,7 @@
 #include <libvdeplug_dyn.h>
 
 #include "conf.h"
 #include <libvdeplug_dyn.h>
 
 #include "conf.h"
+#include "device.h"
 #include "net.h"
 #include "logger.h"
 #include "utils.h"
 #include "net.h"
 #include "logger.h"
 #include "utils.h"