X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fupnp.c;h=8223b2df24c9ada26bdae2aa1544600a8a300ff5;hb=c44b08613508c993e7fd9f625e0b1b4775efffed;hp=5e41d1b653996d16dbf0e81016341fa17a2e95ab;hpb=1c475ecb575367a6b3f9328b0f643ad636155341;p=tinc diff --git a/src/upnp.c b/src/upnp.c index 5e41d1b6..8223b2df 100644 --- a/src/upnp.c +++ b/src/upnp.c @@ -1,6 +1,6 @@ /* upnp.c -- UPnP-IGD client - Copyright (C) 2015 Guus Sliepen , + Copyright (C) 2015-2022 Guus Sliepen , 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 @@ -17,7 +17,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "upnp.h" +#include "system.h" #include @@ -25,12 +25,12 @@ #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; @@ -105,7 +105,7 @@ static void upnp_add_mapping(struct UPNPUrls *urls, struct IGDdatas *data, const free(port); } -static void upnp_refresh() { +static void upnp_refresh(void) { logger(DEBUG_PROTOCOL, LOG_INFO, "[upnp] Discovering IGD devices"); int error; @@ -159,7 +159,7 @@ static void *upnp_thread(void *data) { time_t now = time(NULL); if(now < refresh_time) { - sleep(refresh_time - now); + sleep_millis((refresh_time - now) * 1000); } } @@ -173,8 +173,8 @@ void upnp_init(bool tcp, bool udp) { 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);