- /* Terminate any connections to this node that are not activated yet */
-
- for list_each(connection_t, other, mesh->connections) {
- if(!other->status.active && !strcmp(other->name, c->name)) {
- if(other->outgoing) {
- if(c->outgoing) {
- logger(mesh, MESHLINK_WARNING, "Two outgoing connections to the same node!");
- } else {
- c->outgoing = other->outgoing;
- }
-
- other->outgoing = NULL;
- }
-
- logger(mesh, MESHLINK_DEBUG, "Terminating pending second connection with %s", n->name);
- terminate_connection(mesh, other, false);
- }
- }
-
- /* Send him everything we know */
-
- send_everything(mesh, c);
-
- /* Create an edge_t for this connection */
-
- assert(devclass >= 0 && devclass < DEV_CLASS_COUNT);
-
- c->edge = new_edge();
- c->edge->from = mesh->self;
- c->edge->to = n;
- sockaddrcpy_setport(&c->edge->address, &c->address, atoi(hisport));
- c->edge->weight = mesh->dev_class_traits[devclass].edge_weight;
- c->edge->connection = c;
-
- node_add_recent_address(mesh, n, &c->address);
- edge_add(mesh, c->edge);
-
- /* Notify everyone of the new edge */
-
- send_add_edge(mesh, mesh->everyone, c->edge, 0);
-
- /* Run MST and SSSP algorithms */
-
- graph(mesh);
-
- /* Request a session key to jump start UDP traffic */
-
- if(c->status.initiator) {
- send_req_key(mesh, n);
- }