+
+ /* 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(new->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, new->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 */
+
+ connection_add(new);