+ /* Notify others of this connection */
+
+ for(node = connection_tree->head; node; node = node->next)
+ {
+ other = (connection_t *)node->data;
+
+ if(other == c)
+ continue;
+
+ send_add_node(other, c->node);
+ send_add_edge(other, c->edge);
+ }
+
+ /* Run MST and SSSP algorithms */
+
+ mst_kruskal();
+ sssp_bfs();
+cp
+ return 0;
+}
+
+
+
+/* Address and subnet information exchange */
+
+int send_add_subnet(connection_t *c, subnet_t *subnet)
+{
+ int x;
+ char *netstr;
+cp
+ x = send_request(c, "%d %s %s", ADD_SUBNET,
+ subnet->owner->name, netstr = net2str(subnet));
+ free(netstr);
+cp
+ return x;
+}
+
+int add_subnet_h(connection_t *c)
+{
+ char subnetstr[MAX_STRING_SIZE];
+ char name[MAX_STRING_SIZE];
+ node_t *owner;
+ connection_t *other;
+ subnet_t *s;
+ avl_node_t *node;
+cp
+ if(sscanf(c->buffer, "%*d "MAX_STRING" "MAX_STRING, name, subnetstr) != 2)
+ {
+ syslog(LOG_ERR, _("Got bad %s from %s (%s)"), "ADD_SUBNET", c->name, c->hostname);
+ return -1;
+ }
+
+ /* Check if owner name is a valid */
+
+ if(check_id(name))
+ {
+ syslog(LOG_ERR, _("Got bad %s from %s (%s): %s"), "ADD_SUBNET", c->name, c->hostname, _("invalid name"));
+ return -1;
+ }
+
+ /* Check if subnet string is valid */
+
+ if(!(s = str2net(subnetstr)))
+ {
+ syslog(LOG_ERR, _("Got bad %s from %s (%s): %s"), "ADD_SUBNET", c->name, c->hostname, _("invalid subnet string"));
+ return -1;
+ }
+
+ /* Check if the owner of the new subnet is in the connection list */
+
+ if(!(owner = lookup_node(name)))
+ {
+ syslog(LOG_ERR, _("Got ADD_SUBNET from %s (%s) for %s which is not in our connection list"),
+ name, c->name, c->hostname);
+ return -1;
+ }
+
+ /* If everything is correct, add the subnet to the list of the owner */
+
+ subnet_add(owner, s);
+
+ /* Tell the rest */