X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fprotocol_edge.c;h=d09a78779ed370fc2bd57bcf73f2086fdbed5970;hb=42e9341c12c630ebe3a550a4ce813aac4b1b047c;hp=0626cda94d66280309725766174a6cc6a6b701e9;hpb=ba799a101d57c55d4cbf602511aa24c32a5b735e;p=meshlink diff --git a/src/protocol_edge.c b/src/protocol_edge.c index 0626cda9..d09a7877 100644 --- a/src/protocol_edge.c +++ b/src/protocol_edge.c @@ -33,6 +33,8 @@ #include "utils.h" #include "xalloc.h" +extern bool node_write_dclass(meshlink_handle_t *mesh, node_t *n); + bool send_add_edge(meshlink_handle_t *mesh, connection_t *c, const edge_t *e) { bool x; char *address, *port; @@ -62,7 +64,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 +89,21 @@ 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; + node_write_dclass(mesh, from); + if(!to) { to = new_node(); to->name = xstrdup(to_name); - to->dclass = to_dclass; node_add(mesh, to); } + to->dclass = to_dclass; + node_write_dclass(mesh, to); + /* Convert addresses */ address = str2sockaddr(to_address, to_port);