Internationalization of tinc.

This commit is contained in:
Ivo Timmermans 2000-05-29 21:01:26 +00:00
parent 61e71ab74a
commit 9fd02ffcb0
34 changed files with 5517 additions and 192 deletions

View file

@ -35,6 +35,8 @@
#include "conf.h"
#include "netutl.h" /* for strtoip */
#include "system.h"
config_t *config;
int debug_lvl = 0;
int timeout = 0; /* seconds before timeout */
@ -150,14 +152,14 @@ readconfig(const char *fname, FILE *fp)
if(!hazahaza[i].name)
{
fprintf(stderr, "%s: %d: Invalid variable name `%s'.\n",
fprintf(stderr, _("%s: %d: Invalid variable name `%s'.\n"),
fname, lineno, p);
return -1;
}
if(((q = strtok(NULL, "\t\n\r =")) == NULL) || q[0] == '#')
{
fprintf(stderr, "%s: %d: No value given for `%s'.\n",
fprintf(stderr, _("%s: %d: No value given for `%s'.\n"),
fname, lineno, hazahaza[i].name);
return -1;
}
@ -165,7 +167,7 @@ readconfig(const char *fname, FILE *fp)
cfg = add_config_val(&config, hazahaza[i].argtype, q);
if(cfg == NULL)
{
fprintf(stderr, "%s: %d: Invalid value `%s' for variable `%s'.\n",
fprintf(stderr, _("%s: %d: Invalid value `%s' for variable `%s'.\n"),
fname, lineno, q, hazahaza[i].name);
return -1;
}
@ -186,7 +188,7 @@ read_config_file(const char *fname)
if((fp = fopen (fname, "r")) == NULL)
{
fprintf(stderr, "Could not open %s: %s\n", fname, sys_errlist[errno]);
fprintf(stderr, _("Could not open %s: %s\n"), fname, sys_errlist[errno]);
return 1;
}

View file

@ -47,6 +47,8 @@
#include "net.h"
#include "protocol.h"
#include "system.h"
#define ENCR_GENERATOR "0xd"
#define ENCR_PRIME "0x7fffffffffffffffffffffffffffffff" /* Mersenne :) */
@ -104,14 +106,14 @@ cp
if((f = fopen(filename, "rb")) == NULL)
{
syslog(LOG_ERR, "Could not open %s: %m", filename);
syslog(LOG_ERR, _("Could not open %s: %m"), filename);
return -1;
}
fscanf(f, "%d ", &size);
if(size < 1 || size > (1<<15))
{
syslog(LOG_ERR, "Illegal passphrase in %s; size would be %d", filename, size);
syslog(LOG_ERR, _("Illegal passphrase in %s; size would be %d"), filename, size);
return -1;
}
size >>= 2; /* bits->nibbles */
@ -145,11 +147,11 @@ cp
else
my_key_expiry = (time_t)(time(NULL) + cfg->data.val);
syslog(LOG_NOTICE, "Generating %d bits keys.", PRIVATE_KEY_BITS);
syslog(LOG_NOTICE, _("Generating %d bits keys."), PRIVATE_KEY_BITS);
if((f = fopen("/dev/urandom", "r")) == NULL)
{
syslog(LOG_ERR, "Opening /dev/urandom failed: %m");
syslog(LOG_ERR, _("Opening /dev/urandom failed: %m"));
return -1;
}
@ -214,7 +216,7 @@ cp
encryption_keylen = len;
if(debug_lvl > 2)
syslog(LOG_INFO, "Encryption key set to %s", tmp);
syslog(LOG_INFO, _("Encryption key set to %s"), tmp);
free(tmp);
mpz_clear(ak);

View file

@ -27,6 +27,8 @@
#include "encr.h"
#include "system.h"
unsigned char initvec[] = { 0x22, 0x7b, 0xad, 0x55, 0x41, 0xf4, 0x3e, 0xf3 };
int main(int argc, char **argv)
@ -37,7 +39,7 @@ int main(int argc, char **argv)
if(argc > 2 || (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))))
{
fprintf(stderr, "Usage: %s bits\n", argv[0]);
fprintf(stderr, _("Usage: %s bits\n"), argv[0]);
return 1;
}
@ -46,17 +48,17 @@ int main(int argc, char **argv)
if(!(bits = atol(argv[1])))
{
fprintf(stderr, "Illegal number: %s\n", argv[1]);
fprintf(stderr, _("Illegal number: %s\n"), argv[1]);
return 1;
}
bits = ((bits - 1) | 63) + 1;
fprintf(stderr, "Generating %d bits number", bits);
fprintf(stderr, _("Generating %d bits number"), bits);
bytes = bits >> 3;
if((fp = fopen("/dev/urandom", "r")) == NULL)
{
perror("Opening /dev/urandom");
perror(_("Opening /dev/urandom"));
return 1;
}
@ -69,7 +71,7 @@ int main(int argc, char **argv)
if(feof(fp))
{
puts("");
fprintf(stderr, "File was empty!\n");
fprintf(stderr, _("File was empty!\n"));
}
p[i] = c;
}
@ -77,7 +79,7 @@ int main(int argc, char **argv)
if(isatty(1))
{
fprintf(stderr, ": done.\nThe following line should be ENTIRELY copied into a passphrase file:\n");
fprintf(stderr, _(": done.\nThe following line should be ENTIRELY copied into a passphrase file:\n"));
printf("%d ", bits);
for(i = 0; i < bytes; i++)
printf("%02x", p[i]);
@ -89,7 +91,7 @@ int main(int argc, char **argv)
for(i = 0; i < bytes; i++)
printf("%02x", p[i]);
puts("");
fprintf(stderr, ": done.\n");
fprintf(stderr, _(": done.\n"));
}
return 0;

128
src/net.c
View file

@ -44,6 +44,8 @@
#include "netutl.h"
#include "protocol.h"
#include "system.h"
int tap_fd = -1;
int total_tap_in = 0;
@ -98,11 +100,11 @@ cp
rp.len = htons(rp.len);
if(debug_lvl > 3)
syslog(LOG_ERR, "Sent %d bytes to %lx", ntohs(rp.len), cl->vpn_ip);
syslog(LOG_ERR, _("Sent %d bytes to %lx"), ntohs(rp.len), cl->vpn_ip);
if((r = send(cl->socket, (char*)&rp, ntohs(rp.len), 0)) < 0)
{
syslog(LOG_ERR, "Error sending data: %m");
syslog(LOG_ERR, _("Error sending data: %m"));
return -1;
}
@ -122,7 +124,7 @@ cp
add_mac_addresses(&vp);
if((lenin = write(tap_fd, &vp, vp.len + sizeof(vp.len))) < 0)
syslog(LOG_ERR, "Can't write to tap device: %m");
syslog(LOG_ERR, _("Can't write to tap device: %m"));
else
total_tap_out += lenin;
@ -141,7 +143,7 @@ void add_queue(packet_queue_t **q, void *packet, size_t s)
queue_element_t *e;
cp
if(debug_lvl > 3)
syslog(LOG_DEBUG, "packet to queue: %d", s);
syslog(LOG_DEBUG, _("packet to queue: %d"), s);
e = xmalloc(sizeof(*e));
e->packet = xmalloc(s);
@ -228,7 +230,7 @@ cp
}
if(debug_lvl > 3)
syslog(LOG_DEBUG, "queue flushed");
syslog(LOG_DEBUG, _("queue flushed"));
cp
}
@ -243,7 +245,7 @@ cp
if(cl->sq)
{
if(debug_lvl > 1)
syslog(LOG_DEBUG, "Flushing send queue for " IP_ADDR_S,
syslog(LOG_DEBUG, _("Flushing send queue for " IP_ADDR_S),
IP_ADDR_V(cl->vpn_ip));
flush_queue(cl, &(cl->sq), xsend);
}
@ -251,7 +253,7 @@ cp
if(cl->rq)
{
if(debug_lvl > 1)
syslog(LOG_DEBUG, "Flushing receive queue for " IP_ADDR_S,
syslog(LOG_DEBUG, _("Flushing receive queue for " IP_ADDR_S),
IP_ADDR_V(cl->vpn_ip));
flush_queue(cl, &(cl->rq), xrecv);
}
@ -269,14 +271,14 @@ cp
{
if(debug_lvl > 2)
{
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.");
syslog(LOG_NOTICE, _("There is no remote host I can send this packet to."));
return -1;
}
}
@ -300,7 +302,7 @@ cp
{
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));
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? */
}
@ -325,7 +327,7 @@ cp
if((nfd = open(tapfname, O_RDWR | O_NONBLOCK)) < 0)
{
syslog(LOG_ERR, "Could not open %s: %m", tapfname);
syslog(LOG_ERR, _("Could not open %s: %m"), tapfname);
return -1;
}
@ -346,20 +348,20 @@ int setup_listen_meta_socket(int port)
cp
if((nfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
{
syslog(LOG_ERR, "Creating metasocket failed: %m");
syslog(LOG_ERR, _("Creating metasocket failed: %m"));
return -1;
}
if(setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)))
{
syslog(LOG_ERR, "setsockopt: %m");
syslog(LOG_ERR, _("setsockopt: %m"));
return -1;
}
flags = fcntl(nfd, F_GETFL);
if(fcntl(nfd, F_SETFL, flags | O_NONBLOCK) < 0)
{
syslog(LOG_ERR, "fcntl: %m");
syslog(LOG_ERR, _("fcntl: %m"));
return -1;
}
@ -370,13 +372,13 @@ cp
if(bind(nfd, (struct sockaddr *)&a, sizeof(struct sockaddr)))
{
syslog(LOG_ERR, "Can't bind to port %hd/tcp: %m", port);
syslog(LOG_ERR, _("Can't bind to port %hd/tcp: %m"), port);
return -1;
}
if(listen(nfd, 3))
{
syslog(LOG_ERR, "listen: %m");
syslog(LOG_ERR, _("listen: %m"));
return -1;
}
cp
@ -395,20 +397,20 @@ int setup_vpn_in_socket(int port)
cp
if((nfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
{
syslog(LOG_ERR, "Creating socket failed: %m");
syslog(LOG_ERR, _("Creating socket failed: %m"));
return -1;
}
if(setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)))
{
syslog(LOG_ERR, "setsockopt: %m");
syslog(LOG_ERR, _("setsockopt: %m"));
return -1;
}
flags = fcntl(nfd, F_GETFL);
if(fcntl(nfd, F_SETFL, flags | O_NONBLOCK) < 0)
{
syslog(LOG_ERR, "fcntl: %m");
syslog(LOG_ERR, _("fcntl: %m"));
return -1;
}
@ -419,7 +421,7 @@ cp
if(bind(nfd, (struct sockaddr *)&a, sizeof(struct sockaddr)))
{
syslog(LOG_ERR, "Can't bind to port %hd/udp: %m", port);
syslog(LOG_ERR, _("Can't bind to port %hd/udp: %m"), port);
return -1;
}
cp
@ -443,7 +445,7 @@ cp
cl->meta_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(cl->meta_socket == -1)
{
syslog(LOG_ERR, "Creating socket failed: %m");
syslog(LOG_ERR, _("Creating socket failed: %m"));
return -1;
}
@ -453,20 +455,20 @@ cp
if(connect(cl->meta_socket, (struct sockaddr *)&a, sizeof(a)) == -1)
{
syslog(LOG_ERR, IP_ADDR_S ":%d: %m", IP_ADDR_V(cl->real_ip), cl->port);
syslog(LOG_ERR, _(IP_ADDR_S ":%d: %m"), IP_ADDR_V(cl->real_ip), cl->port);
return -1;
}
flags = fcntl(cl->meta_socket, F_GETFL);
if(fcntl(cl->meta_socket, F_SETFL, flags | O_NONBLOCK) < 0)
{
syslog(LOG_ERR, "fcntl: %m");
syslog(LOG_ERR, _("fcntl: %m"));
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 %s:%hd"), cl->hostname, cl->port);
cp
return 0;
}
@ -487,7 +489,7 @@ cp
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;
}
@ -511,7 +513,7 @@ cp
if(!(cfg = get_config_val(myvpnip)))
{
syslog(LOG_ERR, "No value for my VPN IP given");
syslog(LOG_ERR, _("No value for my VPN IP given"));
return -1;
}
@ -525,20 +527,20 @@ cp
if((myself->meta_socket = setup_listen_meta_socket(myself->port)) < 0)
{
syslog(LOG_ERR, "Unable to set up a listening socket");
syslog(LOG_ERR, _("Unable to set up a listening socket"));
return -1;
}
if((myself->socket = setup_vpn_in_socket(myself->port)) < 0)
{
syslog(LOG_ERR, "Unable to set up an incoming vpn data socket");
syslog(LOG_ERR, _("Unable to set up an incoming vpn data socket"));
close(myself->meta_socket);
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;
}
@ -561,7 +563,7 @@ cp
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
@ -594,7 +596,7 @@ 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, _("Try to re-establish outgoing connection in 5 minutes."));
}
cp
return 0;
@ -632,7 +634,7 @@ cp
close(tap_fd);
destroy_conn_list();
syslog(LOG_NOTICE, "Terminating.");
syslog(LOG_NOTICE, _("Terminating."));
cp
return;
}
@ -646,12 +648,12 @@ int setup_vpn_connection(conn_list_t *cl)
struct sockaddr_in a;
cp
if(debug_lvl > 1)
syslog(LOG_DEBUG, "Opening UDP socket to " IP_ADDR_S, IP_ADDR_V(cl->real_ip));
syslog(LOG_DEBUG, _("Opening UDP socket to " IP_ADDR_S), IP_ADDR_V(cl->real_ip));
nfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(nfd == -1)
{
syslog(LOG_ERR, "Creating data socket failed: %m");
syslog(LOG_ERR, _("Creating data socket failed: %m"));
return -1;
}
@ -661,7 +663,7 @@ cp
if(connect(nfd, (struct sockaddr *)&a, sizeof(a)) == -1)
{
syslog(LOG_ERR, "Connecting to " IP_ADDR_S ":%d failed: %m",
syslog(LOG_ERR, _("Connecting to " IP_ADDR_S ":%d failed: %m"),
IP_ADDR_V(cl->real_ip), cl->port);
return -1;
}
@ -669,7 +671,7 @@ cp
flags = fcntl(nfd, F_GETFL);
if(fcntl(nfd, F_SETFL, flags | O_NONBLOCK) < 0)
{
syslog(LOG_ERR, "This is a bug: %s:%d: %d:%m", __FILE__, __LINE__, nfd);
syslog(LOG_ERR, _("This is a bug: %s:%d: %d:%m"), __FILE__, __LINE__, nfd);
return -1;
}
@ -693,7 +695,7 @@ cp
if(getpeername(sfd, &ci, &len) < 0)
{
syslog(LOG_ERR, "Error: getpeername: %m");
syslog(LOG_ERR, _("Error: getpeername: %m"));
return NULL;
}
@ -705,7 +707,7 @@ cp
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 %s:%d"), p->hostname, htons(ci.sin_port));
if(send_basic_info(p) < 0)
{
@ -753,12 +755,12 @@ int handle_incoming_vpn_data(conn_list_t *cl)
cp
if(getsockopt(cl->socket, SOL_SOCKET, SO_ERROR, &x, &l) < 0)
{
syslog(LOG_ERR, "This is a bug: %s:%d: %d:%m", __FILE__, __LINE__, cl->socket);
syslog(LOG_ERR, _("This is a bug: %s:%d: %d:%m"), __FILE__, __LINE__, cl->socket);
return -1;
}
if(x)
{
syslog(LOG_ERR, "Incoming data socket error: %s", sys_errlist[x]);
syslog(LOG_ERR, _("Incoming data socket error: %s"), sys_errlist[x]);
return -1;
}
@ -766,7 +768,7 @@ cp
lenin = recvfrom(cl->socket, &rp, MTU, 0, NULL, NULL);
if(lenin <= 0)
{
syslog(LOG_ERR, "Receiving data failed: %m");
syslog(LOG_ERR, _("Receiving data failed: %m"));
return -1;
}
total_socket_in += lenin;
@ -779,11 +781,11 @@ cp
{
f = lookup_conn(rp.from);
if(debug_lvl > 3)
syslog(LOG_DEBUG, "packet from " IP_ADDR_S " (len %d)",
syslog(LOG_DEBUG, _("packet from " IP_ADDR_S " (len %d)"),
IP_ADDR_V(rp.from), rp.len);
if(!f)
{
syslog(LOG_ERR, "Got packet from unknown source " IP_ADDR_S,
syslog(LOG_ERR, _("Got packet from unknown source " IP_ADDR_S),
IP_ADDR_V(rp.from));
return -1;
}
@ -815,7 +817,7 @@ cp
return;
if(debug_lvl > 0)
syslog(LOG_NOTICE, "Closing connection with %s.", cl->hostname);
syslog(LOG_NOTICE, _("Closing connection with %s."), cl->hostname);
if(cl->status.timeout)
send_timeout(cl);
@ -831,7 +833,7 @@ cp
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, _("Try to re-establish outgoing connection in 5 seconds."));
}
cl->status.active = 0;
@ -863,7 +865,7 @@ cp
{
if(p->status.pinged && !p->status.got_pong)
{
syslog(LOG_INFO, "%s (" IP_ADDR_S ") didn't respond to ping",
syslog(LOG_INFO, _("%s (" IP_ADDR_S ") didn't respond to ping"),
p->hostname, IP_ADDR_V(p->vpn_ip));
p->status.timeout = 1;
terminate_connection(p);
@ -894,7 +896,7 @@ int handle_new_meta_connection(conn_list_t *cl)
cp
if((nfd = accept(cl->meta_socket, &client, &len)) < 0)
{
syslog(LOG_ERR, "Accepting a new connection failed: %m");
syslog(LOG_ERR, _("Accepting a new connection failed: %m"));
return -1;
}
@ -902,7 +904,7 @@ cp
{
shutdown(nfd, 2);
close(nfd);
syslog(LOG_NOTICE, "Closed attempted connection.");
syslog(LOG_NOTICE, _("Closed attempted connection."));
return 0;
}
@ -924,18 +926,18 @@ int handle_incoming_meta_data(conn_list_t *cl)
cp
if(getsockopt(cl->meta_socket, SOL_SOCKET, SO_ERROR, &x, &l) < 0)
{
syslog(LOG_ERR, "This is a bug: %s:%d: %d:%m", __FILE__, __LINE__, cl->meta_socket);
syslog(LOG_ERR, _("This is a bug: %s:%d: %d:%m"), __FILE__, __LINE__, cl->meta_socket);
return -1;
}
if(x)
{
syslog(LOG_ERR, "Metadata socket error: %s", sys_errlist[x]);
syslog(LOG_ERR, _("Metadata socket error: %s"), sys_errlist[x]);
return -1;
}
if(cl->buflen >= MAXBUFSIZE)
{
syslog(LOG_ERR, "Metadata read buffer overflow.");
syslog(LOG_ERR, _("Metadata read buffer overflow."));
return -1;
}
@ -943,7 +945,7 @@ cp
if(lenin<=0)
{
syslog(LOG_ERR, "Metadata socket read error: %m");
syslog(LOG_ERR, _("Metadata socket read error: %m"));
return -1;
}
@ -970,22 +972,22 @@ cp
{
if(request_handlers[request] == NULL)
{
syslog(LOG_ERR, "Unknown request: %s", cl->buffer);
syslog(LOG_ERR, _("Unknown request: %s"), cl->buffer);
return -1;
}
if(debug_lvl > 3)
syslog(LOG_DEBUG, "Got request: %s", cl->buffer);
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_V(cl->real_ip));
return -1;
}
}
else
{
syslog(LOG_ERR, "Bogus data received.");
syslog(LOG_ERR, _("Bogus data received."));
return -1;
}
@ -1029,7 +1031,7 @@ cp
I've once got here when it said `No route to host'.
*/
getsockopt(p->socket, SOL_SOCKET, SO_ERROR, &x, &l);
syslog(LOG_ERR, "Outgoing data socket error: %s", sys_errlist[x]);
syslog(LOG_ERR, _("Outgoing data socket error: %s"), sys_errlist[x]);
terminate_connection(p);
return;
}
@ -1064,7 +1066,7 @@ cp
memset(&vp, 0, sizeof(vp));
if((lenin = read(tap_fd, &vp, MTU)) <= 0)
{
syslog(LOG_ERR, "Error while reading from tapdevice: %m");
syslog(LOG_ERR, _("Error while reading from tapdevice: %m"));
return;
}
@ -1074,7 +1076,7 @@ cp
if(ether_type != 0x0800)
{
if(debug_lvl > 0)
syslog(LOG_INFO, "Non-IP ethernet frame %04x from " MAC_ADDR_S,
syslog(LOG_INFO, _("Non-IP ethernet frame %04x from " MAC_ADDR_S),
ether_type, MAC_ADDR_V(vp.data[6]));
return;
}
@ -1082,7 +1084,7 @@ cp
if(lenin < 32)
{
if(debug_lvl > 0)
syslog(LOG_INFO, "Dropping short packet");
syslog(LOG_INFO, _("Dropping short packet"));
return;
}
@ -1090,10 +1092,10 @@ cp
to = ntohl(*((unsigned long*)(&vp.data[30])));
if(debug_lvl > 3)
syslog(LOG_DEBUG, "An IP packet (%04x) for " IP_ADDR_S " from " IP_ADDR_S,
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)
syslog(LOG_DEBUG, MAC_ADDR_S " to " MAC_ADDR_S,
syslog(LOG_DEBUG, _(MAC_ADDR_S " to " MAC_ADDR_S),
MAC_ADDR_V(vp.data[0]), MAC_ADDR_V(vp.data[6]));
vp.len = (length_t)lenin - 2;
@ -1128,7 +1130,7 @@ cp
{
if(errno == EINTR) /* because of alarm */
continue;
syslog(LOG_ERR, "Error while waiting for input: %m");
syslog(LOG_ERR, _("Error while waiting for input: %m"));
return;
}

View file

@ -35,6 +35,8 @@
#include "net.h"
#include "netutl.h"
#include "system.h"
/*
look for a connection associated with the given vpn ip,
return its connection structure.
@ -203,7 +205,7 @@ cp
if(!(h = gethostbyname(p)))
{
fprintf(stderr, "Error looking up `%s': %s\n", p, sys_errlist[h_errno]);
fprintf(stderr, _("Error looking up `%s': %s\n"), p, sys_errlist[h_errno]);
return NULL;
}
@ -227,7 +229,7 @@ void dump_conn_list(void)
{
conn_list_t *p;
cp
syslog(LOG_DEBUG, "Connection list:");
syslog(LOG_DEBUG, _("Connection list:"));
for(p = conn_list; p != NULL; p = p->next)
{

View file

@ -1,6 +1,7 @@
/*
protocol.c -- handle the meta-protocol
Copyright (C) 1999,2000 Ivo Timmermans <zarq@iname.com>
Copyright (C) 1999,2000 Ivo Timmermans <itimmermans@bigfoot.com>,
2000 Guus Sliepen <guus@sliepen.warande.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -15,6 +16,8 @@
You should have received a copy of the GNU General Public License
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.26 2000/05/29 21:01:25 zarq Exp $
*/
#include "config.h"
@ -37,6 +40,8 @@
#include "netutl.h"
#include "protocol.h"
#include "system.h"
char buffer[MAXBUFSIZE+1];
int buflen;
@ -46,17 +51,17 @@ int send_ack(conn_list_t *cl)
{
cp
if(debug_lvl > 2)
syslog(LOG_DEBUG, "Send ACK to %s", cl->hostname);
syslog(LOG_DEBUG, _("Send ACK to %s"), cl->hostname);
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 %s activated."), cl->hostname);
cp
return 0;
}
@ -65,7 +70,7 @@ int send_termreq(conn_list_t *cl)
{
cp
if(debug_lvl > 2)
syslog(LOG_DEBUG, "Send TERMREQ to " IP_ADDR_S,
syslog(LOG_DEBUG, _("Send TERMREQ to " IP_ADDR_S),
IP_ADDR_V(cl->vpn_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", TERMREQ, myself->vpn_ip);
@ -73,7 +78,7 @@ cp
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
@ -84,14 +89,14 @@ int send_timeout(conn_list_t *cl)
{
cp
if(debug_lvl > 2)
syslog(LOG_DEBUG, "Send TIMEOUT to " IP_ADDR_S,
syslog(LOG_DEBUG, _("Send TIMEOUT to " IP_ADDR_S),
IP_ADDR_V(cl->vpn_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
@ -102,14 +107,14 @@ 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,
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));
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
@ -120,13 +125,13 @@ 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));
syslog(LOG_DEBUG, _("pinging " IP_ADDR_S), IP_ADDR_V(cl->vpn_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
@ -140,7 +145,7 @@ 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
@ -151,14 +156,14 @@ int send_add_host(conn_list_t *cl, conn_list_t *new_host)
{
cp
if(debug_lvl > 2)
syslog(LOG_DEBUG, "Sending add host to " IP_ADDR_S,
syslog(LOG_DEBUG, _("Sending add host to " IP_ADDR_S),
IP_ADDR_V(cl->vpn_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx/%lx:%x\n", ADD_HOST, new_host->real_ip, new_host->vpn_ip, new_host->vpn_mask, new_host->port);
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
@ -169,14 +174,14 @@ 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,
syslog(LOG_DEBUG, _("Sending KEY_CHANGED to " IP_ADDR_S),
IP_ADDR_V(cl->vpn_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
@ -197,14 +202,14 @@ int send_basic_info(conn_list_t *cl)
{
cp
if(debug_lvl > 2)
syslog(LOG_DEBUG, "Send BASIC_INFO to " IP_ADDR_S,
syslog(LOG_DEBUG, _("Send BASIC_INFO to " IP_ADDR_S),
IP_ADDR_V(cl->real_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d %d %lx/%lx:%x\n", BASIC_INFO, PROT_CURRENT, myself->vpn_ip, myself->vpn_mask, myself->port);
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
@ -218,14 +223,14 @@ cp
encrypt_passphrase(&tmp);
if(debug_lvl > 2)
syslog(LOG_DEBUG, "Send PASSPHRASE %s to " IP_ADDR_S,
syslog(LOG_DEBUG, _("Send PASSPHRASE %s to " IP_ADDR_S),
tmp.phrase, IP_ADDR_V(cl->vpn_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
@ -236,14 +241,14 @@ int send_public_key(conn_list_t *cl)
{
cp
if(debug_lvl > 2)
syslog(LOG_DEBUG, "Send PUBLIC_KEY %s to " IP_ADDR_S,
syslog(LOG_DEBUG, _("Send PUBLIC_KEY %s to " IP_ADDR_S),
my_public_key_base36, IP_ADDR_V(cl->vpn_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
@ -257,7 +262,7 @@ 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
@ -271,20 +276,20 @@ cp
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 key request 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,
syslog(LOG_DEBUG, _("Sending out request for public key to " IP_ADDR_S),
IP_ADDR_V(fw->nexthop->vpn_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;
@ -301,20 +306,20 @@ cp
if(!fw)
{
syslog(LOG_ERR, "Attempting to send key answer to " IP_ADDR_S ", which does not exist?",
syslog(LOG_ERR, _("Attempting to send key answer 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,
syslog(LOG_DEBUG, _("Sending public key to " IP_ADDR_S),
IP_ADDR_V(fw->nexthop->vpn_ip));
buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx %d %s\n", ANS_KEY, to, myself->vpn_ip, my_key_expiry, my_public_key_base36);
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;
}
cp
@ -362,22 +367,22 @@ int basic_info_h(conn_list_t *cl)
cp
if(sscanf(cl->buffer, "%*d %d %lx/%lx:%hx", &cl->protocol_version, &cl->vpn_ip, &cl->vpn_mask, &cl->port) != 4)
{
syslog(LOG_ERR, "got bad BASIC_INFO request: %s", cl->buffer);
syslog(LOG_ERR, _("got bad BASIC_INFO request: %s"), cl->buffer);
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,
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",
syslog(LOG_DEBUG, _("Peer uses protocol version %d"),
cl->protocol_version);
if(cl->status.outgoing)
@ -403,13 +408,13 @@ cp
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 request: %s"), cl->buffer);
return -1;
}
cl->pp->len = strlen(cl->pp->phrase);
if(debug_lvl > 2)
syslog(LOG_DEBUG, "got PASSPHRASE");
syslog(LOG_DEBUG, _("got PASSPHRASE"));
if(cl->status.outgoing)
send_passphrase(cl);
@ -426,22 +431,22 @@ int public_key_h(conn_list_t *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 request: %s"), cl->buffer);
return -1;
}
if(debug_lvl > 2)
syslog(LOG_DEBUG, "got PUBLIC_KEY %s", g_n);
syslog(LOG_DEBUG, _("got PUBLIC_KEY %s"), g_n);
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");
syslog(LOG_INFO, _("Passphrase OK"));
if(cl->status.outgoing)
send_public_key(cl);
@ -467,10 +472,10 @@ int ack_h(conn_list_t *cl)
{
cp
if(debug_lvl > 2)
syslog(LOG_DEBUG, "got ACK");
syslog(LOG_DEBUG, _("got ACK"));
cl->status.active = 1;
syslog(LOG_NOTICE, "Connection with %s activated.", cl->hostname);
syslog(LOG_NOTICE, _("Connection with %s activated."), cl->hostname);
cp
return 0;
}
@ -478,7 +483,7 @@ cp
int termreq_h(conn_list_t *cl)
{
cp
syslog(LOG_NOTICE, IP_ADDR_S " wants to quit", IP_ADDR_V(cl->vpn_ip));
syslog(LOG_NOTICE, _(IP_ADDR_S " wants to quit"), IP_ADDR_V(cl->vpn_ip));
cl->status.termreq = 1;
terminate_connection(cl);
@ -491,7 +496,7 @@ 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));
syslog(LOG_NOTICE, _(IP_ADDR_S " says it's gotten a timeout from us"), IP_ADDR_V(cl->vpn_ip));
cl->status.termreq = 1;
terminate_connection(cl);
cp
@ -507,17 +512,17 @@ 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 request: %s"), cl->buffer);
return -1;
}
if(debug_lvl > 2)
syslog(LOG_DEBUG, "got DEL_HOST for " IP_ADDR_S,
syslog(LOG_DEBUG, _("got DEL_HOST for " IP_ADDR_S),
IP_ADDR_V(vpn_ip));
if(!(fw = lookup_conn(vpn_ip)))
{
syslog(LOG_ERR, "Somebody wanted to delete " IP_ADDR_S " which does not exist?",
syslog(LOG_ERR, _("Somebody wanted to delete " IP_ADDR_S " which does not exist?"),
IP_ADDR_V(vpn_ip));
return 0;
}
@ -535,7 +540,7 @@ 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));
syslog(LOG_DEBUG, _("responding to ping from " IP_ADDR_S), IP_ADDR_V(cl->vpn_ip));
cl->status.pinged = 0;
cl->status.got_pong = 1;
@ -549,7 +554,7 @@ 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));
syslog(LOG_DEBUG, _("ok, got pong from " IP_ADDR_S), IP_ADDR_V(cl->vpn_ip));
cl->status.got_pong = 1;
cp
return 0;
@ -566,14 +571,14 @@ cp
if(!cl->status.active) return -1;
if(sscanf(cl->buffer, "%*d %lx %lx/%lx:%hx", &real_ip, &vpn_ip, &vpn_mask, &port) != 4)
{
syslog(LOG_ERR, "got bad ADD_HOST request: %s", cl->buffer);
syslog(LOG_ERR, _("got bad ADD_HOST request: %s"), cl->buffer);
return -1;
}
if(debug_lvl > 2)
syslog(LOG_DEBUG, "Add host request from " IP_ADDR_S, IP_ADDR_V(cl->vpn_ip));
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)",
syslog(LOG_DEBUG, _("got ADD_HOST(" IP_ADDR_S "," IP_ADDR_S ",%hd)"),
IP_ADDR_V(vpn_ip), IP_ADDR_V(vpn_mask), port);
/*
@ -609,12 +614,12 @@ cp
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 request: %s"), cl->buffer);
return -1;
}
if(debug_lvl > 2)
syslog(LOG_DEBUG, "got REQ_KEY from " IP_ADDR_S " for " IP_ADDR_S,
syslog(LOG_DEBUG, _("got REQ_KEY from " IP_ADDR_S " for " IP_ADDR_S),
IP_ADDR_V(from), IP_ADDR_V(to));
if((to & myself->vpn_mask) == (myself->vpn_ip & myself->vpn_mask))
@ -627,20 +632,20 @@ cp
if(!fw)
{
syslog(LOG_ERR, "Attempting to forward key request to " IP_ADDR_S ", which does not exist?",
syslog(LOG_ERR, _("Attempting to forward key request 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,
syslog(LOG_DEBUG, _("Forwarding request for public key to " IP_ADDR_S),
IP_ADDR_V(fw->nexthop->vpn_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
@ -693,23 +698,23 @@ 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 request: %s"), cl->buffer);
return -1;
}
if(debug_lvl > 3)
syslog(LOG_DEBUG, "got ANS_KEY from " IP_ADDR_S " for " IP_ADDR_S,
syslog(LOG_DEBUG, _("got ANS_KEY from " IP_ADDR_S " for " IP_ADDR_S),
IP_ADDR_V(from), IP_ADDR_V(to));
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.");
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 key from " IP_ADDR_S ", which does not exist?"),
IP_ADDR_V(from));
return -1;
}
@ -725,20 +730,20 @@ cp
if(!fw)
{
syslog(LOG_ERR, "Attempting to forward key to " IP_ADDR_S ", which does not exist?",
syslog(LOG_ERR, _("Attempting to forward 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,
syslog(LOG_DEBUG, _("Forwarding public key to " IP_ADDR_S),
IP_ADDR_V(fw->nexthop->vpn_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
@ -753,19 +758,19 @@ 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 ANS_KEY request: %s"), cl->buffer);
return -1;
}
if(debug_lvl > 2)
syslog(LOG_DEBUG, "got KEY_CHANGED from " IP_ADDR_S,
syslog(LOG_DEBUG, _("got KEY_CHANGED from " IP_ADDR_S),
IP_ADDR_V(from));
ik = lookup_conn(from);
if(!ik)
{
syslog(LOG_ERR, "Got changed key from " IP_ADDR_S ", which does not exist?",
syslog(LOG_ERR, _("Got changed key from " IP_ADDR_S ", which does not exist?"),
IP_ADDR_V(from));
return -1;
}
@ -774,7 +779,7 @@ cp
ik->status.waitingforkey = 0;
if(debug_lvl > 3)
syslog(LOG_DEBUG, "Forwarding key invalidation request");
syslog(LOG_DEBUG, _("Forwarding key invalidation request"));
notify_others(cl, ik, send_key_changed);
cp

View file

@ -19,6 +19,9 @@
/*
* $Log: tincd.c,v $
* Revision 1.9 2000/05/29 21:01:26 zarq
* Internationalization of tinc.
*
* Revision 1.8 2000/05/14 12:22:42 guus
* Cleanups.
*
@ -60,6 +63,8 @@
#include "net.h"
#include "netutl.h"
#include "system.h"
/* The name this program was run with. */
char *program_name;
@ -106,19 +111,19 @@ static void
usage(int status)
{
if(status != 0)
fprintf(stderr, "Try `%s --help\' for more information.\n", program_name);
fprintf(stderr, _("Try `%s --help\' for more information.\n"), program_name);
else
{
printf("Usage: %s [option]...\n\n", program_name);
printf(" -c, --config=FILE Read configuration options from FILE.\n"
" -D, --no-detach Don't fork and detach.\n"
" -d Increase debug level.\n"
" -k, --kill Attempt to kill a running tincd and exit.\n"
" -n, --net=NETNAME Connect to net NETNAME.\n"
" -t, --timeout=TIMEOUT Seconds to wait before giving a timeout.\n");
printf(" --help Display this help and exit.\n"
" --version Output version information and exit.\n\n");
printf("Report bugs to tinc@nl.linux.org.\n");
printf(_("Usage: %s [option]...\n\n"), program_name);
printf(_(" -c, --config=FILE Read configuration options from FILE.\n"
" -D, --no-detach Don't fork and detach.\n"
" -d Increase debug level.\n"
" -k, --kill Attempt to kill a running tincd and exit.\n"
" -n, --net=NETNAME Connect to net NETNAME.\n"
" -t, --timeout=TIMEOUT Seconds to wait before giving a timeout.\n"));
printf(_(" --help Display this help and exit.\n"
" --version Output version information and exit.\n\n"));
printf(_("Report bugs to tinc@nl.linux.org.\n"));
}
exit(status);
}
@ -156,7 +161,7 @@ parse_options(int argc, char **argv, char **envp)
case 't': /* timeout */
if(!(p = add_config_val(&config, TYPE_INT, optarg)))
{
printf("Invalid timeout value `%s'.\n", optarg);
printf(_("Invalid timeout value `%s'.\n"), optarg);
usage(1);
}
break;
@ -170,7 +175,7 @@ parse_options(int argc, char **argv, char **envp)
void memory_full(int size)
{
syslog(LOG_ERR, "Memory exhausted (last is %s:%d) (couldn't allocate %d bytes); exiting.", cp_file, cp_line, size);
syslog(LOG_ERR, _("Memory exhausted (last is %s:%d) (couldn't allocate %d bytes); exiting."), cp_file, cp_line, size);
exit(1);
}
@ -225,10 +230,10 @@ int detach(void)
openlog(identname, LOG_CONS | LOG_PID, LOG_DAEMON);
if(debug_lvl > 1)
syslog(LOG_NOTICE, "tincd %s (%s %s) starting, debug level %d.",
syslog(LOG_NOTICE, _("tincd %s (%s %s) starting, debug level %d."),
VERSION, __DATE__, __TIME__, debug_lvl);
else
syslog(LOG_NOTICE, "tincd %s starting, debug level %d.", VERSION, debug_lvl);
syslog(LOG_NOTICE, _("tincd %s starting, debug level %d."), VERSION, debug_lvl);
xalloc_fail_func = memory_full;
@ -243,7 +248,7 @@ void cleanup_and_exit(int c)
close_network_connections();
if(debug_lvl > 0)
syslog(LOG_INFO, "Total bytes written: tap %d, socket %d; bytes read: tap %d, socket %d.",
syslog(LOG_INFO, _("Total bytes written: tap %d, socket %d; bytes read: tap %d, socket %d."),
total_tap_out, total_socket_out, total_tap_in, total_socket_in);
closelog();
@ -261,10 +266,10 @@ int write_pidfile(void)
if((pid = check_pid(pidfilename)))
{
if(netname)
fprintf(stderr, "A tincd is already running for net `%s' with pid %d.\n",
fprintf(stderr, _("A tincd is already running for net `%s' with pid %d.\n"),
netname, pid);
else
fprintf(stderr, "A tincd is already running with pid %d.\n", pid);
fprintf(stderr, _("A tincd is already running with pid %d.\n"), pid);
return 1;
}
@ -285,16 +290,16 @@ int kill_other(void)
if(!(pid = read_pid(pidfilename)))
{
if(netname)
fprintf(stderr, "No other tincd is running for net `%s'.\n", netname);
fprintf(stderr, _("No other tincd is running for net `%s'.\n"), netname);
else
fprintf(stderr, "No other tincd is running.\n");
fprintf(stderr, _("No other tincd is running.\n"));
return 1;
}
errno = 0; /* No error, sometimes errno is only changed on error */
/* ESRCH is returned when no process with that pid is found */
if(kill(pid, SIGTERM) && errno == ESRCH)
fprintf(stderr, "Removing stale lock file.\n");
fprintf(stderr, _("Removing stale lock file.\n"));
remove_pid(pidfilename);
return 0;
@ -342,16 +347,21 @@ main(int argc, char **argv, char **envp)
{
program_name = argv[0];
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
parse_options(argc, argv, envp);
if(show_version)
{
printf("%s version %s\nCopyright (C) 1998,1999,2000 Ivo Timmermans and others,\n"
"see the AUTHORS file for a complete list.\n\n"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
"and you are welcome to redistribute it under certain conditions;\n"
"see the file COPYING for details.\n\n", PACKAGE, VERSION);
printf("This product includes software developed by Eric Young (eay@mincom.oz.au)\n");
printf(_("%s version %s\n"), PACKAGE, VERSION);
printf(_("Copyright (C) 1998,1999,2000 Ivo Timmermans and others,\n"
"see the AUTHORS file for a complete list.\n\n"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
"and you are welcome to redistribute it under certain conditions;\n"
"see the file COPYING for details.\n\n"));
printf(_("This product includes software developed by Eric Young (eay@mincom.oz.au)\n"));
return 0;
}
@ -361,7 +371,7 @@ main(int argc, char **argv, char **envp)
if(geteuid())
{
fprintf(stderr, "You must be root to run this program. sorry.\n");
fprintf(stderr, _("You must be root to run this program. sorry.\n"));
return 1;
}
@ -396,7 +406,7 @@ RETSIGTYPE
sigterm_handler(int a)
{
if(debug_lvl > 0)
syslog(LOG_NOTICE, "Got TERM signal");
syslog(LOG_NOTICE, _("Got TERM signal"));
cleanup_and_exit(0);
}
@ -404,14 +414,14 @@ RETSIGTYPE
sigquit_handler(int a)
{
if(debug_lvl > 0)
syslog(LOG_NOTICE, "Got QUIT signal");
syslog(LOG_NOTICE, _("Got QUIT signal"));
cleanup_and_exit(0);
}
RETSIGTYPE
sigsegv_square(int a)
{
syslog(LOG_NOTICE, "Got another SEGV signal: not restarting");
syslog(LOG_NOTICE, _("Got another SEGV signal: not restarting"));
exit(0);
}
@ -419,10 +429,10 @@ RETSIGTYPE
sigsegv_handler(int a)
{
if(cp_file)
syslog(LOG_NOTICE, "Got SEGV signal after %s line %d. Trying to re-execute.",
syslog(LOG_NOTICE, _("Got SEGV signal after %s line %d. Trying to re-execute."),
cp_file, cp_line);
else
syslog(LOG_NOTICE, "Got SEGV signal; trying to re-execute.");
syslog(LOG_NOTICE, _("Got SEGV signal; trying to re-execute."));
signal(SIGSEGV, sigsegv_square);
@ -435,7 +445,7 @@ RETSIGTYPE
sighup_handler(int a)
{
if(debug_lvl > 0)
syslog(LOG_NOTICE, "Got HUP signal");
syslog(LOG_NOTICE, _("Got HUP signal"));
close_network_connections();
setup_network_connections();
/* FIXME: read config-file and re-establish network connections */
@ -445,7 +455,7 @@ RETSIGTYPE
sigint_handler(int a)
{
if(debug_lvl > 0)
syslog(LOG_NOTICE, "Got INT signal");
syslog(LOG_NOTICE, _("Got INT signal"));
cleanup_and_exit(0);
}
@ -459,7 +469,7 @@ RETSIGTYPE
sigusr2_handler(int a)
{
if(debug_lvl > 1)
syslog(LOG_NOTICE, "Forcing new keys");
syslog(LOG_NOTICE, _("Forcing new key generation"));
regenerate_keys();
}
@ -467,10 +477,10 @@ RETSIGTYPE
sighuh(int a)
{
if(cp_file)
syslog(LOG_NOTICE, "Got unexpected signal (%d) after %s line %d.",
syslog(LOG_NOTICE, _("Got unexpected signal (%d) after %s line %d."),
a, cp_file, cp_line);
else
syslog(LOG_NOTICE, "Got unexpected signal (%d).", a);
syslog(LOG_NOTICE, _("Got unexpected signal (%d)."), a);
}
void