/*
upnp.c -- UPnP-IGD client
- Copyright (C) 2015 Guus Sliepen <guus@tinc-vpn.org>,
+ Copyright (C) 2015-2022 Guus Sliepen <guus@tinc-vpn.org>,
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
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "upnp.h"
+#include "system.h"
#include <pthread.h>
#include "miniupnpc/upnpcommands.h"
#include "miniupnpc/upnperrors.h"
-#include "system.h"
#include "logger.h"
#include "names.h"
#include "net.h"
#include "netutl.h"
#include "utils.h"
+#include "upnp.h"
static bool upnp_tcp;
static bool upnp_udp;
#else
-#if MINIUPNPC_API_VERSION > 15
+#if MINIUPNPC_API_VERSION > 17
#warning "The version of libminiupnpc you're building against seems to be too recent. Expect trouble."
#endif
free(port);
}
-static void upnp_refresh() {
+static void upnp_refresh(void) {
logger(DEBUG_PROTOCOL, LOG_INFO, "[upnp] Discovering IGD devices");
int error;
}
static void *upnp_thread(void *data) {
+ (void)data;
+
while(true) {
time_t start = time(NULL);
upnp_refresh();
time_t now = time(NULL);
if(now < refresh_time) {
- sleep(refresh_time - now);
+ nanosleep(&(struct timespec) {
+ refresh_time - now, 0
+ }, NULL);
}
}
upnp_tcp = tcp;
upnp_udp = udp;
- get_config_int(lookup_config(config_tree, "UPnPDiscoverWait"), &upnp_discover_wait);
- get_config_int(lookup_config(config_tree, "UPnPRefreshPeriod"), &upnp_refresh_period);
+ get_config_int(lookup_config(&config_tree, "UPnPDiscoverWait"), &upnp_discover_wait);
+ get_config_int(lookup_config(&config_tree, "UPnPRefreshPeriod"), &upnp_refresh_period);
pthread_t thread;
int error = pthread_create(&thread, NULL, upnp_thread, NULL);