Reformat the code using astyle.
[tinc] / src / tincctl.c
index a09ac98..87bbfe0 100644 (file)
@@ -40,6 +40,7 @@
 #include "tincctl.h"
 #include "top.h"
 #include "version.h"
+#include "subnet.h"
 
 #ifndef MSG_NOSIGNAL
 #define MSG_NOSIGNAL 0
@@ -1352,7 +1353,7 @@ static int cmd_dump(int argc, char *argv[]) {
                                        color = "green";
                                }
 
-                               printf(" %s [label = \"%s\", color = \"%s\"%s];\n", node, node, color, strcmp(host, "MYSELF") ? "" : ", style = \"filled\"");
+                               printf(" \"%s\" [label = \"%s\", color = \"%s\"%s];\n", node, node, color, strcmp(host, "MYSELF") ? "" : ", style = \"filled\"");
                        } else {
                                if(only_reachable && !status.reachable) {
                                        continue;
@@ -1382,9 +1383,9 @@ static int cmd_dump(int argc, char *argv[]) {
                                float w = 1 + 65536.0 / weight;
 
                                if(do_graph == 1 && strcmp(node1, node2) > 0) {
-                                       printf(" %s -- %s [w = %f, weight = %f];\n", node1, node2, w, w);
+                                       printf(" \"%s\" -- \"%s\" [w = %f, weight = %f];\n", node1, node2, w, w);
                                } else if(do_graph == 2) {
-                                       printf(" %s -> %s [w = %f, weight = %f];\n", node1, node2, w, w);
+                                       printf(" \"%s\" -> \"%s\" [w = %f, weight = %f];\n", node1, node2, w, w);
                                }
                        } else {
                                printf("%s to %s at %s port %s local %s port %s options %x weight %d\n", from, to, host, port, local_host, local_port, options, weight);
@@ -1886,6 +1887,19 @@ static int cmd_config(int argc, char *argv[]) {
                found = true;
                variable = (char *)variables[i].name;
 
+               if(!strcasecmp(variable, "Subnet")) {
+                       subnet_t s = {0};
+
+                       if(!str2net(&s, value)) {
+                               fprintf(stderr, "Malformed subnet definition %s\n", value);
+                       }
+
+                       if(!subnetcheck(s)) {
+                               fprintf(stderr, "Network address and prefix length do not match: %s\n", value);
+                               return 1;
+                       }
+               }
+
                /* Discourage use of obsolete variables. */
 
                if(variables[i].type & VAR_OBSOLETE && action >= 0) {