+ if(!strcmp(name, myself->name))
+ {
+ syslog(LOG_ERR, _("Warning: got ADD_HOST from %s (%s) for ourself, restarting"), cl->name, cl->hostname);
+ sighup = 1;
+ free_connection(new);
+ return 0;
+ }
+
+ /* Fill in more of the new connection structure */
+
+ new->hostname = hostlookup(htonl(new->address));
+
+ /* Check if the new host already exists in the connnection list */
+
+ if((old = lookup_id(name)))
+ {
+ if((new->address == old->address) && (new->port == old->port))
+ {
+ if(debug_lvl >= DEBUG_CONNECTIONS)
+ syslog(LOG_NOTICE, _("Got duplicate ADD_HOST for %s (%s) from %s (%s)"),
+ old->name, old->hostname, name, new->hostname);
+ free_connection(new);
+ return 0;
+ }
+ else
+ {
+ if(debug_lvl >= DEBUG_CONNECTIONS)
+ syslog(LOG_NOTICE, _("Removing old entry for %s (%s) in favour of new connection"),
+ old->name, old->hostname);
+
+ terminate_connection(old);
+ }
+ }
+
+ /* Hook it up into the connection */
+
+ new->name = xstrdup(name);
+ connection_add(new);
+ id_add(new);
+
+ /* Tell the rest about the new host */
+
+ for(node = connection_tree->head; node; node = node->next)
+ {
+ p = (connection_t *)node->data;
+ if(p->status.meta && p->status.active && p!=cl)
+ send_add_host(p, new);
+ }
+
+ /* Fill in rest of connection structure */
+
+ new->nexthop = cl;
+ new->status.active = 1;
+ new->cipher_pkttype = EVP_bf_cfb();
+ new->cipher_pktkeylength = cl->cipher_pkttype->key_len + cl->cipher_pkttype->iv_len;