- if(!errorstring)
- errorstring = error_text[errno];
- return send_request(cl, "%d %d %s", ERROR, errno, errstring);
-}
+ /* Okay, before we active the connection, we check if there is another entry
+ in the connection list with the same name. If so, it presumably is an
+ old connection that has timed out but we don't know it yet.
+ */
+
+ while((old = lookup_id(cl->name)))
+ {
+ if(debug_lvl >= DEBUG_CONNECTIONS)
+ syslog(LOG_NOTICE, _("Removing old entry for %s at %s in favour of new connection from %s"),
+ cl->name, old->hostname, cl->hostname);
+
+ terminate_connection(old);
+ }
+
+ /* Activate this connection */
+
+ cl->allow_request = ALL;
+ cl->status.active = 1;
+ cl->nexthop = cl;
+ cl->cipher_pkttype = EVP_bf_cbc();
+ cl->cipher_pktkeylength = cl->cipher_pkttype->key_len + cl->cipher_pkttype->iv_len;
+
+ if(debug_lvl >= DEBUG_CONNECTIONS)
+ syslog(LOG_NOTICE, _("Connection with %s (%s) activated"), cl->name, cl->hostname);