+#include <sys/types.h>
+
#ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: conf.c,v 1.9.4.11 2000/10/11 13:42:52 guus Exp $
+ $Id: conf.c,v 1.9.4.12 2000/10/11 22:00:57 guus Exp $
*/
-#include "config.h"
-
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <syslog.h>
#include <xalloc.h>
#include "netutl.h" /* for strtoip */
#include <utils.h> /* for cp */
+#include "config.h"
+
#include "system.h"
config_t *config;
*/
int read_config_file(config_t **base, const char *fname)
{
- int err;
+ int err = -1;
FILE *fp;
char line[MAXBUFSIZE]; /* There really should not be any line longer than this... */
char *p, *q;
- int i, err = -1, lineno = 0;
+ int i, lineno = 0;
config_t *cfg;
cp
if((fp = fopen (fname, "r")) == NULL)
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: conf.h,v 1.6.4.10 2000/10/11 13:42:52 guus Exp $
+ $Id: conf.h,v 1.6.4.11 2000/10/11 22:00:58 guus Exp $
*/
#ifndef __TINC_CONF_H__
unsigned long mask;
} ip_mask_t;
-typedef union data_t {
- unsigned long val;
- void *ptr;
- ip_mask_t *ip;
-} data_t;
-
typedef enum which_t {
tincname = 1,
connectto,
resolve_dns,
interface,
interfaceip,
- configuration
address,
port,
publickey,
struct config_t *next;
which_t which;
int argtype;
- data_t data;
+ union data {
+ unsigned long val;
+ void *ptr;
+ ip_mask_t *ip;
+ struct config_t *next; /* For nested configs! */
+ } data;
} config_t;
typedef struct internal_config_t {
extern char *configfilename;
extern config_t *add_config_val(config_t **, int, char *);
-extern int read_config_file(const char *);
-extern const config_t *get_config_val(which_t type);
-extern const config_t *get_next_config_val(which_t type, int);
+extern int read_config_file(config_t **, const char *);
+extern const config_t *get_config_val(config_t *, which_t type);
+extern const config_t *get_next_config_val(config_t *, which_t type, int);
extern void clear_config();
#endif /* __TINC_CONF_H__ */
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: connlist.c,v 1.1.2.1 2000/10/11 10:35:15 guus Exp $
+ $Id: connlist.c,v 1.1.2.2 2000/10/11 22:00:58 guus Exp $
*/
+#include <syslog.h>
+
#include "config.h"
#include <utils.h>
-#include "connlist.h"
+#include "net.h" /* Don't ask. */
/* Root of the connection list */
conn_list_t *new_conn_list(void)
{
- conn_list_t *p = xmalloc(sizeof(*p));
+ conn_list_t *p = (conn_list_t *)xmalloc(sizeof(*p));
cp
/* initialise all those stupid pointers at once */
memset(p, '\0', sizeof(*p));
void conn_list_add(conn_list_t *cl)
{
cp
- cl->next = connlist;
+ cl->next = conn_list;
cl->prev = NULL;
cl->next->prev = cl;
- connlist = cl;
+ conn_list = cl;
cp
}
if(cl->prev)
cl->prev->next = cl->next;
else
- connlist = cl->next;
+ conn_list = cl->next;
cl->next->prev = cl->prev;
free_conn_list(cl);
/* Lookup functions */
+conn_list_t *lookup_id(char *name)
+{
+ conn_list_t *p;
+cp
+ for(p = conn_list; p != NULL; p = p->next)
+ if(strcmp(name, p->name) == 0)
+ break;
+cp
+ return p;
+}
+
conn_list_t *lookup_conn_list_mac(mac_t address)
{
conn_list_t *p;
cp
for(p = conn_list; p != NULL; p = p->next)
- if(lookup_subnet_mac(p, address))
+ if(lookup_subnet_mac(p->subnets, address))
break;
cp
return p;
conn_list_t *p;
cp
for(p = conn_list; p != NULL; p = p->next)
- if(lookup_subnet_ipv4(p, address))
+ if(lookup_subnet_ipv4(p->subnets, address))
break;
cp
return p;
conn_list_t *p;
cp
for(p = conn_list; p != NULL; p = p->next)
- if(lookup_subnet_ipv6(p, address))
+ if(lookup_subnet_ipv6(p->subnets, address))
break;
cp
return p;
void dump_conn_list(void)
{
conn_list_t *p;
+ subnet_t *s;
+ char *netstr;
cp
syslog(LOG_DEBUG, _("Connection list:"));
for(p = conn_list; p != NULL; p = p->next)
{
- syslog(LOG_DEBUG, _("%s netmask %d.%d.%d.%d at %s port %hd flags %d sockets %d, %d status %04x"),
- p->name, IP_ADDR_V(p->vpn_mask), p->hostname, p->port, p->flags,
+ syslog(LOG_DEBUG, _("%s at %s port %hd flags %d sockets %d, %d status %04x"),
+ p->name, p->hostname, p->port, p->flags,
p->socket, p->meta_socket, p->status);
+ for(s = p->subnets; s != NULL; s = s->next)
+ {
+ netstr = net2str(s);
+ syslog(LOG_DEBUG, ": %s", netstr);
+ free(netstr);
+ }
}
+
+ syslog(LOG_DEBUG, _("End of connection list."));
cp
}
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: connlist.h,v 1.1.2.1 2000/10/11 10:35:15 guus Exp $
+ $Id: connlist.h,v 1.1.2.2 2000/10/11 22:00:58 guus Exp $
*/
#ifndef __TINC_CONNLIST_H__
#include <openssl/evp.h>
#include "net.h"
-#include "subnet.h"
+#include "conf.h"
typedef struct conn_list_t {
char *name; /* name of this connection */
- ip_t real_ip; /* his real (internet) ip */
+ ipv4_t address; /* his real (internet) ip */
char *hostname; /* the hostname of its real ip */
short unsigned int port; /* his portnumber */
int protocol_version; /* used protocol */
struct subnet_t *subnets; /* Pointer to a list of subnets belonging to this connection */
+ struct config_t *config; /* Pointer to configuration tree belonging to this host */
+
struct conn_list_t *next; /* after all, it's a list of connections */
+ struct conn_list_t *prev; /* doubly linked for O(1) deletions */
} conn_list_t;
+#include "subnet.h"
+
extern conn_list_t *conn_list;
extern conn_list_t *myself;
extern void free_conn_list(conn_list_t *);
extern void add_conn_list(conn_list_t *);
extern void del_conn_list(conn_list_t *);
+extern conn_list_t *lookup_id(char *);
extern conn_list_t *lookup_conn_list_mac(mac_t);
extern conn_list_t *lookup_conn_list_ipv4(ipv4_t);
extern conn_list_t *lookup_conn_list_ipv6(ipv6_t);
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: meta.c,v 1.1.2.2 2000/10/11 10:35:15 guus Exp $
+ $Id: meta.c,v 1.1.2.3 2000/10/11 22:00:58 guus Exp $
*/
#include "config.h"
return 0;
}
-int broadcast_meta(conn_list_t *cl, const char *buffer, int length)
+int broadcast_meta(conn_list_t *cl, char *buffer, int length)
{
conn_list_t *p;
cp
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.33 2000/10/11 10:35:16 guus Exp $
+ $Id: net.c,v 1.35.4.34 2000/10/11 22:00:58 guus Exp $
*/
#include "config.h"
p->data[0] = p->data[6] = 0xfe;
p->data[1] = p->data[7] = 0xfd;
/* Really evil pointer stuff just below! */
- *((ip_t*)(&p->data[2])) = (ip_t)(htonl(myself->real_ip));
+ *((ip_t*)(&p->data[2])) = (ip_t)(htonl(myself->address));
*((ip_t*)(&p->data[8])) = *((ip_t*)(&p->data[26]));
cp
}
{
conn_list_t *cl;
cp
- if((cl = lookup_conn(to)) == NULL)
+ if((cl = lookup_conn_list_ipv4(to)) == NULL)
{
if(debug_lvl > 3)
{
}
/* If we ourselves have indirectdata flag set, we should send only to our uplink! */
-
- /* The next few lines will be obsoleted, if we are going indirect, matching subnet_t
- should point to only our uplink as the recepient
- */
-
- if(myself->flags & EXPORTINDIRECTDATA)
- {
- for(cl = conn_list; cl != NULL && !cl->status.outgoing; cl = cl->next);
- if(!cl)
- { /* No open outgoing connection has been found. */
- if(debug_lvl > 3)
- syslog(LOG_NOTICE, _("There is no remote host I can send this packet to!"));
- return -1;
- }
- }
- else
-
- /* If indirectdata flag is set for the destination we just looked up,
- * then real_ip is actually the vpn_ip of the gateway tincd
- * it is behind.
- */
-
- if(cl->flags & INDIRECTDATA)
- {
- if(debug_lvl > 3)
- syslog(LOG_NOTICE, _("Indirect packet to %s via %s"),
- cl->name, cl->hostname);
- if((cl = lookup_conn(cl->real_ip)) == NULL)
- {
- if(debug_lvl > 3)
- syslog(LOG_NOTICE, _("Indirect look up %d.%d.%d.%d in connection list failed!"), IP_ADDR_V(to));
-
- /* Gateway tincd dead? Should we kill it? (GS) */
-
- return -1;
- }
- if(cl->flags & INDIRECTDATA) /* This should not happen */
- {
- if(debug_lvl > 3)
- syslog(LOG_NOTICE, _("Double indirection for %d.%d.%d.%d"), IP_ADDR_V(to));
- return -1;
- }
- }
+ /* FIXME - check for indirection and reprogram it The Right Way(tm) this time. */
+
if(my_key_expiry <= time(NULL))
regenerate_keys();
const char *tapfname;
config_t const *cfg;
cp
- if((cfg = get_config_val(tapdevice)) == NULL)
+ if((cfg = get_config_val(config, tapdevice)) == NULL)
tapfname = "/dev/tap0";
else
tapfname = cfg->data.ptr;
return -1;
}
- if((cfg = get_config_val(interface)))
+ if((cfg = get_config_val(config, interface)))
{
if(setsockopt(nfd, SOL_SOCKET, SO_KEEPALIVE, cfg->data.ptr, strlen(cfg->data.ptr)))
{
a.sin_family = AF_INET;
a.sin_port = htons(port);
- if((cfg = get_config_val(interfaceip)))
+ if((cfg = get_config_val(config, interfaceip)))
a.sin_addr.s_addr = htonl(cfg->data.ip->ip);
else
a.sin_addr.s_addr = htonl(INADDR_ANY);
if(debug_lvl > 0)
syslog(LOG_INFO, _("Trying to connect to %s"), cl->hostname);
- if((cfg = get_config_val(upstreamport)) == NULL)
+ if((cfg = get_config_val(cl->config, port)) == NULL)
cl->port = 655;
else
cl->port = cfg->data.val;
a.sin_family = AF_INET;
a.sin_port = htons(cl->port);
- a.sin_addr.s_addr = htonl(cl->real_ip);
+ a.sin_addr.s_addr = htonl(cl->address);
if(connect(cl->meta_socket, (struct sockaddr *)&a, sizeof(a)) == -1)
{
}
ncn = new_conn_list();
- ncn->real_ip = ntohl(*((ip_t*)(h->h_addr_list[0])));
- ncn->hostname = hostlookup(htonl(ncn->real_ip));
+ ncn->address = ntohl(*((ip_t*)(h->h_addr_list[0])));
+ ncn->hostname = hostlookup(htonl(ncn->address));
if(setup_outgoing_meta_socket(ncn) < 0)
{
myself->hostname = "MYSELF"; /* FIXME? */
myself->flags = 0;
- if(!(cfg = get_config_val(tincname))) /* Not acceptable */
+ if(!(cfg = get_config_val(config, tincname))) /* Not acceptable */
{
syslog(LOG_ERR, _("Name for tinc daemon required!"));
return -1;
else
myself->name = (char*)cfg->data.val;
- if(!(cfg = get_config_val(listenport)))
+ if(!(cfg = get_config_val(myself, port)))
myself->port = 655;
else
myself->port = cfg->data.val;
- if((cfg = get_config_val(indirectdata)))
+ if((cfg = get_config_val(config, indirectdata)))
if(cfg->data.val == stupid_true)
myself->flags |= EXPORTINDIRECTDATA;
- if((cfg = get_config_val(tcponly)))
+ if((cfg = get_config_val(config, tcponly)))
if(cfg->data.val == stupid_true)
myself->flags |= TCPONLY;
{
config_t const *cfg;
cp
- cfg = get_next_config_val(upstreamip, upstreamindex++);
-
+/* FIXME! Use name instead of upstreamip.
+ cfg = get_next_config_val(config, upstreamip, upstreamindex++);
+*/
while(cfg)
{
if(!setup_outgoing_connection(cfg->data.ptr)) /* function returns 0 when there are no problems */
signal(SIGALRM, SIG_IGN);
return;
}
- cfg = get_next_config_val(upstreamip, upstreamindex++); /* Or else we try the next ConnectTo line */
+// cfg = get_next_config_val(config, upstreamip, upstreamindex++); /* Or else we try the next ConnectTo line */
}
signal(SIGALRM, sigalrm_handler);
{
config_t const *cfg;
cp
- if((cfg = get_config_val(pingtimeout)) == NULL)
+ if((cfg = get_config_val(config, pingtimeout)) == NULL)
timeout = 5;
else
timeout = cfg->data.val;
if(setup_myself() < 0)
return -1;
- if((cfg = get_next_config_val(upstreamip, upstreamindex++)) == NULL)
+// if((cfg = get_next_config_val(config, upstreamip, upstreamindex++)) == NULL)
/* No upstream IP given, we're listen only. */
return 0;
{
if(!setup_outgoing_connection(cfg->data.ptr)) /* function returns 0 when there are no problems */
return 0;
- cfg = get_next_config_val(upstreamip, upstreamindex++); /* Or else we try the next ConnectTo line */
+// cfg = get_next_config_val(config, upstreamip, upstreamindex++); /* Or else we try the next ConnectTo line */
}
signal(SIGALRM, sigalrm_handler);
a.sin_family = AF_INET;
a.sin_port = htons(cl->port);
- a.sin_addr.s_addr = htonl(cl->real_ip);
+ a.sin_addr.s_addr = htonl(cl->address);
if(connect(nfd, (struct sockaddr *)&a, sizeof(a)) == -1)
{
return NULL;
}
- p->real_ip = ntohl(ci.sin_addr.s_addr);
+ p->address = ntohl(ci.sin_addr.s_addr);
p->hostname = hostlookup(ci.sin_addr.s_addr);
p->meta_socket = sfd;
p->status.meta = 1;
syslog(LOG_INFO, _("Rereading configuration file"));
close_network_connections();
clear_config();
- if(read_config_file(configfilename))
+ if(read_config_file(&config, configfilename))
{
syslog(LOG_ERR, _("Unable to reread configuration file, exiting"));
exit(0);
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: net.h,v 1.9.4.14 2000/10/11 10:35:16 guus Exp $
+ $Id: net.h,v 1.9.4.15 2000/10/11 22:01:00 guus Exp $
*/
#ifndef __TINC_NET_H__
#include "config.h"
#include "conf.h"
-#include "connlist.h"
#define MAXSIZE 1700 /* should be a bit more than the MTU for the tapdevice */
#define MTU 1600
extern char *request_name[256];
extern char *status_text[10];
+#include "connlist.h" /* Yes, very strange placement indeed, but otherwise the typedefs get all tangled up */
+
extern int str2opt(const char *);
extern char *opt2str(int);
extern int send_packet(ip_t, vpn_packet_t *);
extern void main_loop(void);
extern int setup_vpn_connection(conn_list_t *);
extern void terminate_connection(conn_list_t *);
-extern void flush_queues(conn_list_t*);
+extern void flush_queues(conn_list_t *);
extern int xrecv(vpn_packet_t *);
extern void add_queue(packet_queue_t **, void *, size_t);
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: netutl.c,v 1.12.4.11 2000/10/11 10:35:17 guus Exp $
+ $Id: netutl.c,v 1.12.4.12 2000/10/11 22:01:00 guus Exp $
*/
#include "config.h"
in.s_addr = addr;
lookup_hostname = 0;
- if((cfg = get_config_val(resolve_dns)) != NULL)
+ if((cfg = get_config_val(config, resolve_dns)) != NULL)
if(cfg->data.val == stupid_true)
lookup_hostname = 1;
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: netutl.h,v 1.2.4.2 2000/10/11 10:35:17 guus Exp $
+ $Id: netutl.h,v 1.2.4.3 2000/10/11 22:01:00 guus Exp $
*/
#ifndef __TINC_NETUTL_H__
#define __TINC_NETUTL_H__
#include "net.h"
+#include "conf.h"
extern char *hostlookup(unsigned long);
extern ip_mask_t *strtoip(char*);
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.37 2000/10/11 13:42:52 guus Exp $
+ $Id: protocol.c,v 1.28.4.38 2000/10/11 22:01:00 guus Exp $
*/
#include "config.h"
if(debug_lvl >= DEBUG_PROTOCOL)
syslog(LOG_DEBUG, _("Sending %s to %s (%s)"), request_name[request], cl->name, cl->hostname);
cp
- return send_meta(cl, buffer, length);
+ return send_meta(cl, buffer, len);
}
int receive_request(conn_list_t *cl)
/* Convert the random data to a hexadecimal formatted string */
bin2hex(cl->hischallenge,buffer,CHAL_LENGTH);
- buffer[keylength*2] = '\0';
+ buffer[CHAL_LENGTH*2] = '\0';
/* Send the challenge */
/* Check if subnet string is valid */
- if((subnet = str2net(subnetstr)) == -1)
+ if(!(subnet = str2net(subnetstr)))
{
syslog(LOG_ERR, _("Got bad ADD_SUBNET from %s (%s): invalid subnet string"), cl->name, cl->hostname);
free(name); free(subnetstr);
/* Check if the owner of the new subnet is in the connection list */
- if(!(owner = lookup_id(name))
+ if(!(owner = lookup_id(name)))
{
syslog(LOG_ERR, _("Got ADD_SUBNET for %s from %s (%s) which is not in our connection list"),
name, cl->name, cl->hostname);
}
/* If everything is correct, add the subnet to the list of the owner */
+
+ subnet_add(owner, subnet);
cp
- return subnet_add(owner, subnet);
+ return 0;
}
int send_del_subnet(conn_list_t *cl, conn_list_t *other, subnet_t *subnet)
/* Check if subnet string is valid */
- if((subnet = str2net(subnetstr)) == -1)
+ if(!(subnet = str2net(subnetstr)))
{
syslog(LOG_ERR, _("Got bad DEL_SUBNET from %s (%s): invalid subnet string"), cl->name, cl->hostname);
free(name); free(subnetstr);
/* Check if the owner of the new subnet is in the connection list */
- if(!(owner = lookup_id(name))
+ if(!(owner = lookup_id(name)))
{
syslog(LOG_ERR, _("Got DEL_SUBNET for %s from %s (%s) which is not in our connection list"),
name, cl->name, cl->hostname);
return -1;
}
- /* If everything is correct, add the subnet to the list of the owner */
+ /* If everything is correct, delete the subnet from the list of the owner */
+
+ subnet_del(subnet);
cp
- return subnet_del(owner, subnet);
+ return 0;
}
/* New and closed connections notification */
{
cp
return send_request(cl, "%d %s %s %lx:%d %lx", ADD_HOST,
- myself->name, other->name, other->real_ip, other->port, other->options);
+ myself->name, other->name, other->address, other->port, other->options);
}
int add_host_h(conn_list_t *cl)
/* Lookup his uplink */
- if(!(new->hisuplink = lookup_id(sender))
+ if(!(new->hisuplink = lookup_id(sender)))
{
syslog(LOG_ERR, _("Got ADD_HOST from %s (%s) with origin %s which is not in our connection list"),
sender, cl->name, cl->hostname);
/* Fill in more of the new conn_list structure */
- new->hostname = hostlookup(htonl(new->real_ip));
+ 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->real_ip == old->real_ip) && (new->port == old->port))
+ 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)"),
{
cp
return send_request(cl, "%d %s %s %lx:%d %lx", DEL_HOST,
- myself->name, other->name, other->real_ip, other->port, other->options);
+ myself->name, other->name, other->address, other->port, other->options);
}
int del_host_h(conn_list_t *cl)
/* Lookup his uplink */
- if(!(hisuplink = lookup_id(sender))
+ if(!(hisuplink = lookup_id(sender)))
{
syslog(LOG_ERR, _("Got DEL_HOST from %s (%s) with origin %s which is not in our connection list"),
cl->name, cl->hostname, sender);
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: protocol.h,v 1.5.4.9 2000/10/11 10:35:17 guus Exp $
+ $Id: protocol.h,v 1.5.4.10 2000/10/11 22:01:02 guus Exp $
*/
#ifndef __TINC_PROTOCOL_H__
extern int send_id(conn_list_t*);
extern int send_challenge(conn_list_t*);
-extern int send_chal_reply(conn_list_t*, char*);
+extern int send_chal_reply(conn_list_t*);
extern int send_ack(conn_list_t*);
extern int send_status(conn_list_t*, int, char*);
extern int send_error(conn_list_t*, int, char*);
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: subnet.c,v 1.1.2.2 2000/10/11 10:35:17 guus Exp $
+ $Id: subnet.c,v 1.1.2.3 2000/10/11 22:01:02 guus Exp $
*/
#include "config.h"
cp
}
-void subnet_del(conn_list_t *cl, subnet_t *subnet)
+void subnet_del(subnet_t *subnet)
{
cp
if(subnet->prev)
switch(type)
{
case SUBNET_MAC:
- if(sscanf(netstr, "%d,%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &subnet->type,
- &subnet->net.mac.x[0],
- &subnet->net.mac.x[1],
- &subnet->net.mac.x[2],
- &subnet->net.mac.x[3],
- &subnet->net.mac.x[4],
- &subnet->net.mac.x[5]) != 7)
+ if(sscanf(subnetstr, "%d,%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &subnet->type,
+ &subnet->net.mac.address.x[0],
+ &subnet->net.mac.address.x[1],
+ &subnet->net.mac.address.x[2],
+ &subnet->net.mac.address.x[3],
+ &subnet->net.mac.address.x[4],
+ &subnet->net.mac.address.x[5]) != 7)
{
free_subnet(subnet);
return NULL;
}
break;
- case SUBNET_IPv4:
+ case SUBNET_IPV4:
if(sscanf(subnetstr, "%d,%lx:%lx", &subnet->type, &subnet->net.ipv4.address, &subnet->net.ipv4.mask) != 3)
{
free_subnet(subnet);
return NULL;
}
break;
- case SUBNET_IPv6:
- if(sscanf(netstr, "%d,%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx/%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", &subnet->type,
+ case SUBNET_IPV6:
+ if(sscanf(subnetstr, "%d,%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx/%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", &subnet->type,
&subnet->net.ipv6.address.x[0],
&subnet->net.ipv6.address.x[1],
&subnet->net.ipv6.address.x[2],
default:
free_subnet(subnet);
return NULL;
+ }
cp
return subnet;
}
{
case SUBNET_MAC:
asprintf(netstr, "%d,%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", subnet->type,
- subnet->net.mac.x[0],
- subnet->net.mac.x[1],
- subnet->net.mac.x[2],
- subnet->net.mac.x[3],
- subnet->net.mac.x[4],
- subnet->net.mac.x[5]);
- case SUBNET_IPv4:
+ subnet->net.mac.address.x[0],
+ subnet->net.mac.address.x[1],
+ subnet->net.mac.address.x[2],
+ subnet->net.mac.address.x[3],
+ subnet->net.mac.address.x[4],
+ subnet->net.mac.address.x[5]);
+ case SUBNET_IPV4:
asprintf(netstr, "%d,%lx:%lx", subnet->type, subnet->net.ipv4.address, subnet->net.ipv4.mask);
- case SUBNET_IPv6:
+ case SUBNET_IPV6:
asprintf(netstr, "%d,%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx/%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx",
subnet->net.ipv6.address.x[0],
subnet->net.ipv6.address.x[1],
subnet_t *lookup_subnet_ipv6(subnet_t *subnets, ipv6_t address)
{
subnet_t *subnet;
+ int i;
cp
for(subnet = subnets; subnet != NULL; subnet = subnet->next)
{
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: subnet.h,v 1.1.2.2 2000/10/11 10:35:17 guus Exp $
+ $Id: subnet.h,v 1.1.2.3 2000/10/11 22:01:02 guus Exp $
*/
#ifndef __TINC_SUBNET_H__
#define __TINC_SUBNET_H__
#include "net.h"
-#include "connlist.h"
enum
{
/* And now for the actual subnet: */
- union
+ union net
{
subnet_mac_t mac;
subnet_ipv4_t ipv4;
} subnet_t;
+#include "connlist.h"
+
extern subnet_t *new_subnet(void);
extern void free_subnet(subnet_t *);
-extern void subnet_add(conn_list_t *, subnet_t *);
+extern void subnet_add(struct conn_list_t *, subnet_t *);
extern void subnet_del(subnet_t *);
extern char *net2str(subnet_t *);
extern subnet_t *str2net(char *);
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: tincd.c,v 1.10.4.9 2000/09/06 11:49:05 guus Exp $
+ $Id: tincd.c,v 1.10.4.10 2000/10/11 22:01:02 guus Exp $
*/
#include "config.h"
if(kill_tincd)
exit(kill_other());
- if(read_config_file(configfilename))
+ if(read_config_file(&config, configfilename))
return 1;
setup_signals();