along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: net.c,v 1.35.4.2 2000/06/24 12:35:42 guus Exp $
+ $Id: net.c,v 1.35.4.3 2000/06/25 15:16:11 guus Exp $
*/
#include "config.h"
cp
if(cl->sq)
{
- if(debug_lvl > 1)
+ if(debug_lvl > 3)
syslog(LOG_DEBUG, _("Flushing send queue for " IP_ADDR_S),
IP_ADDR_V(cl->vpn_ip));
flush_queue(cl, &(cl->sq), xsend);
if(cl->rq)
{
- if(debug_lvl > 1)
+ if(debug_lvl > 3)
syslog(LOG_DEBUG, _("Flushing receive queue for " IP_ADDR_S),
IP_ADDR_V(cl->vpn_ip));
flush_queue(cl, &(cl->rq), xrecv);
cp
if((cl = lookup_conn(to)) == NULL)
{
- if(debug_lvl > 2)
+ if(debug_lvl > 3)
{
- syslog(LOG_NOTICE, _("trying to look up " IP_ADDR_S " in connection list failed."),
+ syslog(LOG_NOTICE, _("Trying to look up " IP_ADDR_S " in connection list failed!"),
IP_ADDR_V(to));
}
for(cl = conn_list; cl != NULL && !cl->status.outgoing; cl = cl->next);
if(!cl)
{ /* No open outgoing connection has been found. */
- if(debug_lvl > 2)
- syslog(LOG_NOTICE, _("There is no remote host I can send this packet to."));
+ if(debug_lvl > 3)
+ syslog(LOG_NOTICE, _("There is no remote host I can send this packet to!"));
return -1;
}
}
for(cl = conn_list; cl != NULL && !cl->status.outgoing; cl = cl->next);
if(!cl)
{ /* No open outgoing connection has been found. */
- if(debug_lvl > 2)
- syslog(LOG_NOTICE, _("There is no remote host I can send this packet to."));
+ if(debug_lvl > 3)
+ syslog(LOG_NOTICE, _("There is no remote host I can send this packet to!"));
return -1;
}
}
{
if((cl = lookup_conn(cl->vpn_ip)) == NULL)
{
- if(debug_lvl > 2)
+ if(debug_lvl > 3)
{
- syslog(LOG_NOTICE, _("indirect look up " IP_ADDR_S " in connection list failed."),
+ syslog(LOG_NOTICE, _("Indirect look up " IP_ADDR_S " in connection list failed!"),
IP_ADDR_V(to));
}
return -1;
}
if(cl->flags & INDIRECTDATA) /* This should not happen */
- if(debug_lvl > 1)
+ if(debug_lvl > 3)
{
syslog(LOG_NOTICE, _("double indirection for " IP_ADDR_S),
IP_ADDR_V(to));
if(!cl->status.active)
{
add_queue(&(cl->sq), packet, packet->len + 2);
- if(debug_lvl > 1)
- syslog(LOG_INFO, _(IP_ADDR_S " is not ready, queueing packet."), IP_ADDR_V(cl->vpn_ip));
+ if(debug_lvl > 3)
+ syslog(LOG_INFO, _(IP_ADDR_S " is not ready, queueing packet"), IP_ADDR_V(cl->vpn_ip));
return 0; /* We don't want to mess up, do we? */
}
return -1;
}
- cl->hostname = hostlookup(htonl(cl->real_ip));
-
- syslog(LOG_INFO, _("Connected to %s:%hd"), cl->hostname, cl->port);
+ syslog(LOG_INFO, _("Connected to " IP_ADDR_S ":%hd"),
+ IP_ADDR_V(cl->real_ip), cl->port);
cp
return 0;
}
if(setup_outgoing_meta_socket(ncn) < 0)
{
- syslog(LOG_ERR, _("Could not set up a meta connection."));
+ syslog(LOG_ERR, _("Could not set up a meta connection!"));
free_conn_element(ncn);
return -1;
}
myself->status.active = 1;
- syslog(LOG_NOTICE, _("Ready: listening on port %d."), myself->port);
+ syslog(LOG_NOTICE, _("Ready: listening on port %d"), myself->port);
cp
return 0;
}
if(seconds_till_retry>300) /* Don't wait more than 5 minutes. */
seconds_till_retry = 300;
alarm(seconds_till_retry);
- syslog(LOG_ERR, _("Still failed to connect to other. Will retry in %d seconds."),
+ syslog(LOG_ERR, _("Still failed to connect to other, will retry in %d seconds"),
seconds_till_retry);
}
cp
signal(SIGALRM, sigalrm_handler);
seconds_till_retry = 300;
alarm(seconds_till_retry);
- syslog(LOG_NOTICE, _("Try to re-establish outgoing connection in 5 minutes."));
+ syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in 5 minutes"));
}
cp
return 0;
close(tap_fd);
destroy_conn_list();
- syslog(LOG_NOTICE, _("Terminating."));
+ syslog(LOG_NOTICE, _("Terminating"));
cp
return;
}
int nfd, flags;
struct sockaddr_in a;
cp
- if(debug_lvl > 1)
+ if(debug_lvl > 0)
syslog(LOG_DEBUG, _("Opening UDP socket to " IP_ADDR_S), IP_ADDR_V(cl->real_ip));
nfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
return NULL;
}
- p->hostname = hostlookup(ci.sin_addr.s_addr);
p->real_ip = ntohl(ci.sin_addr.s_addr);
p->meta_socket = sfd;
p->status.meta = 1;
p->last_ping_time = time(NULL);
p->want_ping = 0;
- syslog(LOG_NOTICE, _("Connection from %s:%d"), p->hostname, htons(ci.sin_port));
+ syslog(LOG_NOTICE, _("Connection from " IP_ADDR_S ":%d"),
+ IP_ADDR_V(p->real_ip), htons(ci.sin_port));
if(send_basic_info(p) < 0)
{
return;
if(debug_lvl > 0)
- syslog(LOG_NOTICE, _("Closing connection with %s."), cl->hostname);
+ syslog(LOG_NOTICE, _("Closing connection with " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
if(cl->status.timeout)
send_timeout(cl);
signal(SIGALRM, sigalrm_handler);
seconds_till_retry = 5;
alarm(seconds_till_retry);
- syslog(LOG_NOTICE, _("Try to re-establish outgoing connection in 5 seconds."));
+ syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in 5 seconds"));
}
cl->status.active = 0;
{
if(p->status.pinged && !p->status.got_pong)
{
- syslog(LOG_INFO, _("%s (" IP_ADDR_S ") didn't respond to ping"),
- p->hostname, IP_ADDR_V(p->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_INFO, _(IP_ADDR_S " (" IP_ADDR_S ") didn't respond to ping"),
+ IP_ADDR_V(p->vpn_ip), IP_ADDR_V(p->real_ip));
p->status.timeout = 1;
terminate_connection(p);
}
{
shutdown(nfd, 2);
close(nfd);
- syslog(LOG_NOTICE, _("Closed attempted connection."));
+ syslog(LOG_NOTICE, _("Closed attempted connection"));
return 0;
}
if(cl->buflen >= MAXBUFSIZE)
{
- syslog(LOG_ERR, _("Metadata read buffer overflow."));
+ syslog(LOG_ERR, _("Metadata read buffer overflow!"));
return -1;
}
if(cl->reqlen)
{
+ if(debug_lvl > 2)
+ syslog(LOG_DEBUG, _("Got request from " IP_ADDR_S " (" IP_ADDR_S "): %s"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip), cl->buffer);
if(sscanf(cl->buffer, "%d", &request) == 1)
{
if((request < 0) || (request > 255) || (request_handlers[request] == NULL))
{
- syslog(LOG_ERR, _("Unknown request: %s"), cl->buffer);
+ syslog(LOG_ERR, _("Unknown request from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
return -1;
}
- if(debug_lvl > 3)
- syslog(LOG_DEBUG, _("Got request: %s"), cl->buffer);
-
if(request_handlers[request](cl)) /* Something went wrong. Probably scriptkiddies. Terminate. */
{
- syslog(LOG_ERR, _("Error while processing request from " IP_ADDR_S), IP_ADDR_V(cl->real_ip));
+ syslog(LOG_ERR, _("Error while processing request from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
return -1;
}
}
else
{
- syslog(LOG_ERR, _("Bogus data received."));
+ syslog(LOG_ERR, _("Bogus data received from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
return -1;
}
ether_type = ntohs(*((unsigned short*)(&vp.data[12])));
if(ether_type != 0x0800)
{
- if(debug_lvl > 0)
+ if(debug_lvl > 3)
syslog(LOG_INFO, _("Non-IP ethernet frame %04x from " MAC_ADDR_S),
ether_type, MAC_ADDR_V(vp.data[6]));
return;
if(lenin < 32)
{
- if(debug_lvl > 0)
+ if(debug_lvl > 3)
syslog(LOG_INFO, _("Dropping short packet"));
return;
}
if(debug_lvl > 3)
syslog(LOG_DEBUG, _("An IP packet (%04x) for " IP_ADDR_S " from " IP_ADDR_S),
ether_type, IP_ADDR_V(to), IP_ADDR_V(from));
- if(debug_lvl > 4)
+ if(debug_lvl > 3)
syslog(LOG_DEBUG, _(MAC_ADDR_S " to " MAC_ADDR_S),
MAC_ADDR_V(vp.data[0]), MAC_ADDR_V(vp.data[6]));
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.1 2000/06/23 19:27:03 guus Exp $
+ $Id: protocol.c,v 1.28.4.2 2000/06/25 15:16:12 guus Exp $
*/
#include "config.h"
int send_ack(conn_list_t *cl)
{
cp
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Send ACK to %s"), cl->hostname);
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending ACK to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d\n", ACK);
if((write(cl->meta_socket, buffer, buflen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %d:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %d:%d: %m"), __FILE__, __LINE__);
return -1;
}
- syslog(LOG_NOTICE, _("Connection with %s activated."), cl->hostname);
+ syslog(LOG_NOTICE, _("Connection with " IP_ADDR_S " (" IP_ADDR_S ") activated"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
cp
return 0;
}
int send_termreq(conn_list_t *cl)
{
cp
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Send TERMREQ to " IP_ADDR_S),
- IP_ADDR_V(cl->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending TERMREQ to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", TERMREQ, myself->vpn_ip);
if(write(cl->meta_socket, buffer, buflen) < 0)
{
if(debug_lvl > 1)
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
int send_timeout(conn_list_t *cl)
{
cp
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Send TIMEOUT to " IP_ADDR_S),
- IP_ADDR_V(cl->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending TIMEOUT to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", PINGTIMEOUT, myself->vpn_ip);
if((write(cl->meta_socket, buffer, buflen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
int send_del_host(conn_list_t *cl, conn_list_t *new_host)
{
cp
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Sending delete host " IP_ADDR_S " to " IP_ADDR_S),
- IP_ADDR_V(new_host->vpn_ip), IP_ADDR_V(cl->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending DEL_HOST for " IP_ADDR_S " to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(new_host->vpn_ip), IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", DEL_HOST, new_host->vpn_ip);
if((write(cl->meta_socket, buffer, buflen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
int send_ping(conn_list_t *cl)
{
cp
- if(debug_lvl > 3)
- syslog(LOG_DEBUG, _("pinging " IP_ADDR_S), IP_ADDR_V(cl->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending PING to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d\n", PING);
if((write(cl->meta_socket, buffer, buflen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
int send_pong(conn_list_t *cl)
{
cp
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending PONG to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
+
buflen = snprintf(buffer, MAXBUFSIZE, "%d\n", PONG);
if((write(cl->meta_socket, buffer, buflen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
ip_t real_ip;
int flags;
cp
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Sending add host to " IP_ADDR_S),
- IP_ADDR_V(cl->vpn_ip));
-
real_ip = new_host->real_ip;
flags = new_host->flags;
real_ip = myself->vpn_ip;
}
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending ADD_HOST for " IP_ADDR_S " (" IP_ADDR_S ") to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(new_host->vpn_ip), IP_ADDR_V(real_ip), IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
+
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);
if((write(cl->meta_socket, buffer, buflen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
int send_key_changed(conn_list_t *cl, conn_list_t *src)
{
cp
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Sending KEY_CHANGED to " IP_ADDR_S),
- IP_ADDR_V(cl->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending KEY_CHANGED origin " IP_ADDR_S " to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(src->vpn_ip), IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", KEY_CHANGED, src->vpn_ip);
if((write(cl->meta_socket, buffer, buflen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
int send_basic_info(conn_list_t *cl)
{
cp
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Send BASIC_INFO to " IP_ADDR_S),
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending BASIC_INFO to " IP_ADDR_S),
IP_ADDR_V(cl->real_ip));
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);
if((write(cl->meta_socket, buffer, buflen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
cp
encrypt_passphrase(&tmp);
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Send PASSPHRASE %s to " IP_ADDR_S),
- tmp.phrase, IP_ADDR_V(cl->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending PASSPHRASE to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d %s\n", PASSPHRASE, tmp.phrase);
if((write(cl->meta_socket, buffer, buflen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
int send_public_key(conn_list_t *cl)
{
cp
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Send PUBLIC_KEY %s to " IP_ADDR_S),
- my_public_key_base36, IP_ADDR_V(cl->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending PUBLIC_KEY to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d %s\n", PUBLIC_KEY, my_public_key_base36);
if((write(cl->meta_socket, buffer, buflen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
return 0;
}
+/* WDN doet deze functie? (GS)
int send_calculate(conn_list_t *cl, char *k)
{
cp
if((write(cl->meta_socket, buffer, buflen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
return 0;
}
+*/
int send_key_request(ip_t to)
{
fw = lookup_conn(to);
if(!fw)
{
- syslog(LOG_ERR, _("Attempting to send key request to " IP_ADDR_S ", which does not exist?"),
+ syslog(LOG_ERR, _("Attempting to send REQ_KEY to " IP_ADDR_S ", which does not exist?"),
IP_ADDR_V(to));
return -1;
}
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Sending out request for public key to " IP_ADDR_S),
- IP_ADDR_V(fw->nexthop->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending REQ_KEY to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(fw->nexthop->vpn_ip), IP_ADDR_V(fw->nexthop->real_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx\n", REQ_KEY, to, myself->vpn_ip);
if((write(fw->nexthop->meta_socket, buffer, buflen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
fw->status.waitingforkey = 1;
if(!fw)
{
- syslog(LOG_ERR, _("Attempting to send key answer to " IP_ADDR_S ", which does not exist?"),
+ syslog(LOG_ERR, _("Attempting to send ANS_KEY to " IP_ADDR_S ", which does not exist?"),
IP_ADDR_V(to));
return -1;
}
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Sending public key to " IP_ADDR_S),
- IP_ADDR_V(fw->nexthop->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Sending ANS_KEY to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(fw->nexthop->vpn_ip), IP_ADDR_V(fw->nexthop->real_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx %d %s\n", ANS_KEY, to, myself->vpn_ip, my_key_expiry, my_public_key_base36);
int basic_info_h(conn_list_t *cl)
{
cp
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got BASIC_INFO from " IP_ADDR_S), IP_ADDR_V(cl->real_ip));
+
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 request: %s"), cl->buffer);
+ syslog(LOG_ERR, _("Got bad BASIC_INFO from " IP_ADDR_S),
+ IP_ADDR_V(cl->real_ip));
return -1;
}
if(cl->protocol_version != PROT_CURRENT)
{
- syslog(LOG_ERR, _("Peer uses incompatible protocol version %d."),
+ syslog(LOG_ERR, _("Peer uses incompatible protocol version %d"),
cl->protocol_version);
return -1;
}
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("got BASIC_INFO(%hd," IP_ADDR_S "," IP_ADDR_S ")"), cl->port,
- IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->vpn_mask));
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Peer uses protocol version %d"),
- cl->protocol_version);
-
if(cl->status.outgoing)
{
if(setup_vpn_connection(cl) < 0)
if(sscanf(cl->buffer, "%*d %as", &(cl->pp->phrase)) != 1)
{
- syslog(LOG_ERR, _("got bad PASSPHRASE request: %s"), cl->buffer);
+ syslog(LOG_ERR, _("Got bad PASSPHRASE from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
return -1;
}
cl->pp->len = strlen(cl->pp->phrase);
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("got PASSPHRASE"));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got PASSPHRASE from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
if(cl->status.outgoing)
send_passphrase(cl);
cp
if(sscanf(cl->buffer, "%*d %as", &g_n) != 1)
{
- syslog(LOG_ERR, _("got bad PUBLIC_KEY request: %s"), cl->buffer);
+ syslog(LOG_ERR, _("Got bad PUBLIC_KEY from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
return -1;
}
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("got PUBLIC_KEY %s"), g_n);
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got PUBLIC_KEY from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
if(verify_passphrase(cl, g_n))
{
/* intruder! */
- syslog(LOG_ERR, _("Intruder: passphrase does not match."));
+ syslog(LOG_ERR, _("Intruder: passphrase does not match!"));
return -1;
}
- if(debug_lvl > 2)
- syslog(LOG_INFO, _("Passphrase OK"));
-
if(cl->status.outgoing)
send_public_key(cl);
else
int ack_h(conn_list_t *cl)
{
cp
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("got ACK"));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got ACK from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
cl->status.active = 1;
- syslog(LOG_NOTICE, _("Connection with %s activated."), cl->hostname);
+ syslog(LOG_NOTICE, _("Connection with " IP_ADDR_S " (" IP_ADDR_S ") activated"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
cp
return 0;
}
int termreq_h(conn_list_t *cl)
{
cp
- syslog(LOG_NOTICE, _(IP_ADDR_S " wants to quit"), IP_ADDR_V(cl->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got TERMREQ from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
+
cl->status.termreq = 1;
terminate_connection(cl);
int timeout_h(conn_list_t *cl)
{
cp
- if(!cl->status.active) return -1;
- syslog(LOG_NOTICE, _(IP_ADDR_S " says it's gotten a timeout from us"), IP_ADDR_V(cl->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got TIMEOUT from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
+
cl->status.termreq = 1;
terminate_connection(cl);
cp
if(sscanf(cl->buffer, "%*d %lx", &vpn_ip) != 1)
{
- syslog(LOG_ERR, _("got bad DEL_HOST request: %s"), cl->buffer);
+ syslog(LOG_ERR, _("Got bad DEL_HOST from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
return -1;
}
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("got DEL_HOST for " IP_ADDR_S),
- IP_ADDR_V(vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got DEL_HOST for " IP_ADDR_S " from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(vpn_ip), IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
if(!(fw = lookup_conn(vpn_ip)))
{
- syslog(LOG_ERR, _("Somebody wanted to delete " IP_ADDR_S " which does not exist?"),
- IP_ADDR_V(vpn_ip));
+ syslog(LOG_ERR, _("Got DEL_HOST for " IP_ADDR_S " from " IP_ADDR_S " (" IP_ADDR_S ") which does not exist?"),
+ IP_ADDR_V(vpn_ip), IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
return 0;
}
int ping_h(conn_list_t *cl)
{
cp
- if(!cl->status.active) return -1;
- if(debug_lvl > 3)
- syslog(LOG_DEBUG, _("responding to ping from " IP_ADDR_S), IP_ADDR_V(cl->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got PING from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
+
cl->status.pinged = 0;
cl->status.got_pong = 1;
int pong_h(conn_list_t *cl)
{
cp
- if(!cl->status.active) return -1;
- if(debug_lvl > 3)
- syslog(LOG_DEBUG, _("ok, got pong from " IP_ADDR_S), IP_ADDR_V(cl->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got PONG from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
+
cl->status.got_pong = 1;
cp
return 0;
return -1;
if(sscanf(cl->buffer, "%*d %lx %lx/%lx:%hx %d", &real_ip, &vpn_ip, &vpn_mask, &port, &flags) != 5)
{
- syslog(LOG_ERR, _("got bad ADD_HOST request: %s"), cl->buffer);
+ syslog(LOG_ERR, _("Got bad ADD_HOST from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
return -1;
}
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Add host request from " IP_ADDR_S), IP_ADDR_V(cl->vpn_ip));
- if(debug_lvl > 3)
- syslog(LOG_DEBUG, _("got ADD_HOST(" IP_ADDR_S "," IP_ADDR_S ",%hd)"),
- IP_ADDR_V(vpn_ip), IP_ADDR_V(vpn_mask), port);
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got ADD_HOST from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
/*
Suggestion of Hans Bayle
if(fw->nexthop == cl)
notify_others(fw, cl, send_add_host);
else
- if(debug_lvl > 1)
- syslog(LOG_DEBUG, _("Invalid add_host request from " IP_ADDR_S),
- IP_ADDR_V(cl->vpn_ip));
+ syslog(LOG_DEBUG, _("Invalid ADD_HOST from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
return 0;
}
ncn->vpn_mask = vpn_mask;
ncn->port = port;
ncn->flags = flags;
- ncn->hostname = hostlookup(real_ip);
ncn->nexthop = cl;
ncn->next = conn_list;
conn_list = ncn;
if(!cl->status.active) return -1;
if(sscanf(cl->buffer, "%*d %lx %lx", &to, &from) != 2)
{
- syslog(LOG_ERR, _("got bad request: %s"), cl->buffer);
+ syslog(LOG_ERR, _("Got bad REQ_KEY from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
return -1;
}
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("got REQ_KEY from " IP_ADDR_S " for " IP_ADDR_S),
- IP_ADDR_V(from), IP_ADDR_V(to));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got REQ_KEY origin " IP_ADDR_S " destination " IP_ADDR_S " from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(from), IP_ADDR_V(to), IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
if((to & myself->vpn_mask) == (myself->vpn_ip & myself->vpn_mask))
{ /* hey! they want something from ME! :) */
if(!fw)
{
- syslog(LOG_ERR, _("Attempting to forward key request to " IP_ADDR_S ", which does not exist?"),
+ syslog(LOG_ERR, _("Attempting to forward REQ_KEY to " IP_ADDR_S ", which does not exist?"),
IP_ADDR_V(to));
return -1;
}
- if(debug_lvl > 3)
- syslog(LOG_DEBUG, _("Forwarding request for public key to " IP_ADDR_S),
- IP_ADDR_V(fw->nexthop->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Forwarding REQ_KEY to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(fw->nexthop->vpn_ip), IP_ADDR_V(fw->nexthop->real_ip));
cl->buffer[cl->reqlen-1] = '\n';
if(write(fw->nexthop->meta_socket, cl->buffer, cl->reqlen) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
if(!cl->status.active) return -1;
if(sscanf(cl->buffer, "%*d %lx %lx %d %as", &to, &from, &expiry, &key) != 4)
{
- syslog(LOG_ERR, _("got bad ANS_KEY request: %s"), cl->buffer);
+ syslog(LOG_ERR, _("Got bad ANS_KEY from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
return -1;
}
- if(debug_lvl > 3)
- syslog(LOG_DEBUG, _("got ANS_KEY from " IP_ADDR_S " for " IP_ADDR_S),
- IP_ADDR_V(from), IP_ADDR_V(to));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got ANS_KEY origin " IP_ADDR_S " destination " IP_ADDR_S " from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(from), IP_ADDR_V(to), IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
if(to == myself->vpn_ip)
{ /* hey! that key's for ME! :) */
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Yeah! key arrived. Now do something with it."));
gk = lookup_conn(from);
if(!gk)
{
- syslog(LOG_ERR, _("Receiving key from " IP_ADDR_S ", which does not exist?"),
+ syslog(LOG_ERR, _("Receiving ANS_KEY from " IP_ADDR_S ", which does not exist?"),
IP_ADDR_V(from));
return -1;
}
if(!fw)
{
- syslog(LOG_ERR, _("Attempting to forward key to " IP_ADDR_S ", which does not exist?"),
+ syslog(LOG_ERR, _("Attempting to forward ANS_KEY to " IP_ADDR_S ", which does not exist?"),
IP_ADDR_V(to));
return -1;
}
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("Forwarding public key to " IP_ADDR_S),
- IP_ADDR_V(fw->nexthop->vpn_ip));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Forwarding ANS_KEY to " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(fw->nexthop->vpn_ip), IP_ADDR_V(fw->nexthop->real_ip));
cl->buffer[cl->reqlen-1] = '\n';
if((write(fw->nexthop->meta_socket, cl->buffer, cl->reqlen)) < 0)
{
- syslog(LOG_ERR, _("send failed: %s:%d: %m"), __FILE__, __LINE__);
+ syslog(LOG_ERR, _("Send failed: %s:%d: %m"), __FILE__, __LINE__);
return -1;
}
cp
if(!cl->status.active) return -1;
if(sscanf(cl->buffer, "%*d %lx", &from) != 1)
{
- syslog(LOG_ERR, _("got bad ANS_KEY request: %s"), cl->buffer);
+ syslog(LOG_ERR, _("Got bad KEY_CHANGED from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
return -1;
}
- if(debug_lvl > 2)
- syslog(LOG_DEBUG, _("got KEY_CHANGED from " IP_ADDR_S),
- IP_ADDR_V(from));
+ if(debug_lvl > 1)
+ syslog(LOG_DEBUG, _("Got KEY_CHANGED origin " IP_ADDR_S " from " IP_ADDR_S " (" IP_ADDR_S ")"),
+ IP_ADDR_V(from), IP_ADDR_V(cl->vpn_ip), IP_ADDR_V(cl->real_ip));
ik = lookup_conn(from);
if(!ik)
{
- syslog(LOG_ERR, _("Got changed key from " IP_ADDR_S ", which does not exist?"),
+ syslog(LOG_ERR, _("Got KEY_CHANGED from " IP_ADDR_S ", which does not exist?"),
IP_ADDR_V(from));
return -1;
}
ik->status.validkey = 0;
ik->status.waitingforkey = 0;
- if(debug_lvl > 3)
- syslog(LOG_DEBUG, _("Forwarding key invalidation request"));
-
notify_others(cl, ik, send_key_changed);
cp
return 0;