/*
net_setup.c -- Setup.
Copyright (C) 1998-2005 Ivo Timmermans,
- 2000-2014 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2016 Guus Sliepen <guus@tinc-vpn.org>
2006 Scott Lamb <slamb@slamb.org>
2010 Brandon Black <blblack@gmail.com>
#include "utils.h"
#include "xalloc.h"
+#ifdef HAVE_MINIUPNPC
+#include "upnp.h"
+#endif
+
char *myport;
static char *myname;
static io_t device_io;
static bool read_invitation_key(void) {
FILE *fp;
- char *fname;
+ char fname[PATH_MAX];
if(invitation_key) {
ecdsa_free(invitation_key);
invitation_key = NULL;
}
- xasprintf(&fname, "%s" SLASH "invitations" SLASH "ed25519_key.priv", confbase);
+ snprintf(fname, sizeof fname, "%s" SLASH "invitations" SLASH "ed25519_key.priv", confbase);
fp = fopen(fname, "r");
logger(DEBUG_ALWAYS, LOG_ERR, "Reading Ed25519 private key file `%s' failed", fname);
}
- free(fname);
return invitation_key;
}
void load_all_subnets(void) {
DIR *dir;
struct dirent *ent;
- char *dname;
+ char dname[PATH_MAX];
- xasprintf(&dname, "%s" SLASH "hosts", confbase);
+ snprintf(dname, sizeof dname, "%s" SLASH "hosts", confbase);
dir = opendir(dname);
if(!dir) {
logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s", dname, strerror(errno));
- free(dname);
return;
}
if((s2 = lookup_subnet(n, s))) {
s2->expires = -1;
+ free(s);
} else {
subnet_add(n, s);
}
void load_all_nodes(void) {
DIR *dir;
struct dirent *ent;
- char *dname;
+ char dname[PATH_MAX];
- xasprintf(&dname, "%s" SLASH "hosts", confbase);
+ snprintf(dname, sizeof dname, "%s" SLASH "hosts", confbase);
dir = opendir(dname);
if(!dir) {
logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s", dname, strerror(errno));
- free(dname);
return;
}
#if !defined(SOL_IP) || !defined(IP_TOS)
if(priorityinheritance)
- logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform", "PriorityInheritance");
+ logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform for IPv4 connections", "PriorityInheritance");
+#endif
+
+#if !defined(IPPROTO_IPV6) || !defined(IPV6_TCLASS)
+ if(priorityinheritance)
+ logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform for IPv6 connections", "PriorityInheritance");
#endif
if(!get_config_int(lookup_config(config_tree, "MACExpire"), &macexpire))
else if(!strcasecmp(type, "vde"))
devops = vde_devops;
#endif
+ free(type);
}
get_config_bool(lookup_config(config_tree, "DeviceStandby"), &device_standby);
xasprintf(&myself->hostname, "MYSELF port %s", myport);
myself->connection->hostname = xstrdup(myself->hostname);
+ char *upnp = NULL;
+ get_config_string(lookup_config(config_tree, "UPnP"), &upnp);
+ bool upnp_tcp = false;
+ bool upnp_udp = false;
+ if (upnp) {
+ if (!strcasecmp(upnp, "yes"))
+ upnp_tcp = upnp_udp = true;
+ else if (!strcasecmp(upnp, "udponly"))
+ upnp_udp = true;
+ free(upnp);
+ }
+ if (upnp_tcp || upnp_udp) {
+#ifdef HAVE_MINIUPNPC
+ upnp_init(upnp_tcp, upnp_udp);
+#else
+ logger(DEBUG_ALWAYS, LOG_WARNING, "UPnP was requested, but tinc isn't built with miniupnpc support!");
+#endif
+ }
+
/* Done. */
last_config_check = now.tv_sec;