+ if(check_id(to_name))
+ {
+ syslog(LOG_ERR, _("Got bad %s from %s (%s): %s"), "ADD_EDGE", c->name, c->hostname, _("invalid name"));
+ return -1;
+ }
+
+ /* Lookup nodes */
+
+ from = lookup_node(from_name);
+
+ if(!from)
+ {
+ syslog(LOG_ERR, _("Got bad %s from %s (%s): %s"), "ADD_EDGE", c->name, c->hostname, _("unknown node"));
+ return -1;
+ }
+
+ to = lookup_node(to_name);
+
+ if(!to)
+ {
+ syslog(LOG_ERR, _("Got bad %s from %s (%s): %s"), "ADD_EDGE", c->name, c->hostname, _("unknown node"));
+ return -1;
+ }
+
+ /* Check if edge already exists */
+
+ e = lookup_edge(from, to);
+
+ if(e)
+ {
+ if(e->weight != weight || e->options != options)
+ {
+ syslog(LOG_ERR, _("Got %s from %s (%s) which does not match existing entry"), "ADD_EDGE", c->name, c->hostname);
+ return -1;
+ }
+
+ return 0;
+ }
+ else
+ {
+ e = new_edge();
+ e->from = from;
+ e->to = to;
+ e->options = options;
+ e->weight = weight;
+ edge_add(e);
+ }
+
+ /* Tell the rest about the new edge */