]> git.meshlink.io Git - meshlink/blobdiff - src/protocol_edge.c
dclass transfer while adding edges improved
[meshlink] / src / protocol_edge.c
index 0626cda94d66280309725766174a6cc6a6b701e9..5ab15863c5e2c0d7f9f2751fad2327cef4c11787 100644 (file)
@@ -62,7 +62,7 @@ bool add_edge_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
        int weight;
 
        if(sscanf(request, "%*d %*x "MAX_STRING" %d "MAX_STRING" "MAX_STRING" "MAX_STRING" %d %x %d",
-                         from_name, &from_dclass, to_name, to_address, to_port, &to_dclass, &options, &weight) != 6) {
+                         from_name, &from_dclass, to_name, to_address, to_port, &to_dclass, &options, &weight) != 8) {
                logger(mesh, MESHLINK_ERROR, "Got bad %s from %s (%s)", "ADD_EDGE", c->name,
                           c->hostname);
                return false;
@@ -87,17 +87,19 @@ bool add_edge_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
        if(!from) {
                from = new_node();
                from->name = xstrdup(from_name);
-               from->dclass = from_dclass;
                node_add(mesh, from);
        }
 
+       from->dclass = from_dclass;
+
        if(!to) {
                to = new_node();
                to->name = xstrdup(to_name);
-               to->dclass = to_dclass;
                node_add(mesh, to);
        }
 
+       to->dclass = to_dclass;
+
        /* Convert addresses */
 
        address = str2sockaddr(to_address, to_port);