along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: protocol.c,v 1.28.4.4 2000/06/25 16:01:12 guus Exp $
+ $Id: protocol.c,v 1.28.4.12 2000/06/27 20:55:12 guus Exp $
*/
#include "config.h"
return -1;
}
- syslog(LOG_NOTICE, _("Connection with " IP_ADDR_S " (%s) activated"),
+ if(debug_lvl > 0)
+ syslog(LOG_NOTICE, _("Connection with " IP_ADDR_S " (%s) activated"),
IP_ADDR_V(cl->vpn_ip), cl->hostname);
cp
return 0;
syslog(LOG_DEBUG, _("Sending ADD_HOST for " IP_ADDR_S " (%s) to " IP_ADDR_S " (%s)"),
IP_ADDR_V(new_host->vpn_ip), hostname, IP_ADDR_V(cl->vpn_ip), cl->hostname);
- buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx/%lx:%x %d\n", ADD_HOST, new_host->real_ip, new_host->vpn_ip, new_host->vpn_mask, new_host->port, flags);
+ buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx/%lx:%x %d\n", ADD_HOST, real_ip, new_host->vpn_ip, new_host->vpn_mask, new_host->port, flags);
if((write(cl->meta_socket, buffer, buflen)) < 0)
{
{
cp
if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Sending BASIC_INFO to " IP_ADDR_S),
+ syslog(LOG_DEBUG, _("Sending BASIC_INFO to %s"),
cl->hostname);
buflen = snprintf(buffer, MAXBUFSIZE, "%d %d %lx/%lx:%x %d\n", BASIC_INFO, PROT_CURRENT, myself->vpn_ip, myself->vpn_mask, myself->port, myself->flags);
{
cp
if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Got BASIC_INFO from " IP_ADDR_S), cl->hostname);
+ syslog(LOG_DEBUG, _("Got BASIC_INFO from %s"), cl->hostname);
if(sscanf(cl->buffer, "%*d %d %lx/%lx:%hx %d", &cl->protocol_version, &cl->vpn_ip, &cl->vpn_mask, &cl->port, &cl->flags) != 5)
{
- syslog(LOG_ERR, _("Got bad BASIC_INFO from " IP_ADDR_S),
+ syslog(LOG_ERR, _("Got bad BASIC_INFO from %s"),
cl->hostname);
return -1;
}
old connection that has timed out but we don't know it yet. Because our
conn_list entry is not active, lookup_conn will skip ourself. */
- while(old=lookup_conn(cl->vpn_ip))
+ while(old = lookup_conn(cl->vpn_ip))
terminate_connection(old);
cl->status.active = 1;
cl->status.active = 1;
syslog(LOG_NOTICE, _("Connection with " IP_ADDR_S " (%s) activated"),
IP_ADDR_V(cl->vpn_ip), cl->hostname);
+ upstreamindex = 0;
cp
return 0;
}
IP_ADDR_V(cl->vpn_ip), cl->hostname);
cl->status.termreq = 1;
- cl->status.active = 0;
if(cl->status.active)
notify_others(cl, NULL, send_del_host);
+ cl->status.active = 0;
+
terminate_connection(cl);
cp
return 0;
return 0;
}
- notify_others(cl, fw, send_del_host);
+ notify_others(fw, cl, send_del_host);
fw->status.termreq = 1;
+ fw->status.active = 0;
+
terminate_connection(fw);
cp
return 0;
ip_t vpn_mask;
unsigned short port;
int flags;
- conn_list_t *ncn, *fw;
+ conn_list_t *ncn, *old;
cp
if(!cl->status.active)
{
return -1;
}
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Got ADD_HOST from " IP_ADDR_S " (%s)"),
- IP_ADDR_V(cl->vpn_ip), cl->hostname);
-
- /*
- Suggestion of Hans Bayle
- */
- if((fw = lookup_conn(vpn_ip)))
- {
- if(fw->nexthop == cl)
- notify_others(fw, cl, send_add_host);
- else
- syslog(LOG_DEBUG, _("Invalid ADD_HOST from " IP_ADDR_S " (%s)"),
- IP_ADDR_V(cl->vpn_ip), cl->hostname);
- return 0;
- }
-
+ while(old = lookup_conn(vpn_ip))
+ terminate_connection(old);
+
ncn = new_conn_list();
ncn->real_ip = real_ip;
- ncn->hostname = hostlookup(real_ip);
+ ncn->hostname = hostlookup(htonl(real_ip));
ncn->vpn_ip = vpn_ip;
ncn->vpn_mask = vpn_mask;
ncn->port = port;
ncn->next = conn_list;
conn_list = ncn;
ncn->status.active = 1;
+
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got ADD_HOST for " IP_ADDR_S " (%s) from " IP_ADDR_S " (%s)"),
+ IP_ADDR_V(ncn->vpn_ip), ncn->hostname, IP_ADDR_V(cl->vpn_ip), cl->hostname);
+
notify_others(ncn, cl, send_add_host);
cp
return 0;
ik->status.validkey = 0;
ik->status.waitingforkey = 0;
- notify_others(cl, ik, send_key_changed);
+ notify_others(ik, cl, send_key_changed);
cp
return 0;
}