/*
dropin.c -- a set of drop-in replacements for libc functions
Copyright (C) 2000-2005 Ivo Timmermans,
- 2000-2016 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2018 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
return 0;
#else
+ (void)nochdir;
+ (void)noclose;
return -1;
#endif
}
#ifndef HAVE_NANOSLEEP
int nanosleep(const struct timespec *req, struct timespec *rem) {
+ (void)rem;
struct timeval tv = {req->tv_sec, req->tv_nsec / 1000};
return select(0, NULL, NULL, NULL, &tv);
}
/*
event.c -- I/O, timeout and signal event handling
- Copyright (C) 2012-2013 Guus Sliepen <guus@tinc-vpn.org>
+ Copyright (C) 2012-2018 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
while(running) {
struct timeval diff;
struct timeval *tv = get_time_remaining(&diff);
- DWORD timeout_ms = tv ? (tv->tv_sec * 1000 + tv->tv_usec / 1000 + 1) : WSA_INFINITE;
+ DWORD timeout_ms = tv ? (DWORD)(tv->tv_sec * 1000 + tv->tv_usec / 1000 + 1) : WSA_INFINITE;
if(!event_count) {
Sleep(timeout_ms);
break;
}
- if(result < WSA_WAIT_EVENT_0 || result >= WSA_WAIT_EVENT_0 + event_count - event_offset) {
+ if(result >= event_count - event_offset) {
return(false);
}
/* Look up io in the map by index. */
- event_index = result - WSA_WAIT_EVENT_0 + event_offset;
+ event_index = result - event_offset;
io_t *io = io_map[event_index];
if(io->fd == -1) {
/*
ifconfig.c -- Generate platform specific interface configuration commands
- Copyright (C) 2016-2017 Guus Sliepen <guus@tinc-vpn.org>
+ Copyright (C) 2016-2018 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
}
void ifconfig_dhcp6(FILE *out) {
+ (void)out;
fprintf(stderr, "DHCPv6 requested, but not supported by tinc on this platform\n");
}
void ifconfig_slaac(FILE *out) {
+ (void)out;
// It's the default?
}
/*
meta.c -- handle the meta communication
- Copyright (C) 2000-2014 Guus Sliepen <guus@tinc-vpn.org>,
+ Copyright (C) 2000-2018 Guus Sliepen <guus@tinc-vpn.org>,
2000-2005 Ivo Timmermans
2006 Scott Lamb <slamb@slamb.org>
#include "xalloc.h"
#ifndef MIN
-#define MIN(x, y) (((x)<(y))?(x):(y))
+static ssize_t MIN(ssize_t x, ssize_t y) {
+ return x < y ? x : y;
+}
#endif
bool send_meta_sptps(void *handle, uint8_t type, const void *buffer, size_t length) {
/*
device.c -- Interaction with Windows tap driver in a MinGW environment
Copyright (C) 2002-2005 Ivo Timmermans,
- 2002-2014 Guus Sliepen <guus@tinc-vpn.org>
+ 2002-2018 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
}
static void device_handle_read(void *data, int flags) {
+ (void)data;
+ (void)flags;
+
DWORD len;
if(!GetOverlappedResult(device_handle, &device_read_overlapped, &len, FALSE)) {
}
static bool read_packet(vpn_packet_t *packet) {
+ (void)packet;
return false;
}
/*
names.c -- generate commonly used (file)names
Copyright (C) 1998-2005 Ivo Timmermans
- 2000-2017 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2018 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
}
#ifdef HAVE_MINGW
+ (void)daemon;
if(!logfilename) {
xasprintf(&logfilename, "%s" SLASH "log", confbase);
/*
net_packet.c -- Handles in- and outgoing VPN packets
Copyright (C) 1998-2005 Ivo Timmermans,
- 2000-2017 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2018 Guus Sliepen <guus@tinc-vpn.org>
2010 Timothy Redaelli <timothy@redaelli.eu>
2010 Brandon Black <blblack@gmail.com>
return mtu;
#else
-
+ (void)n;
return MTU;
-
#endif
}
#else
vpn_packet_t pkt;
- sockaddr_t addr = {};
+ sockaddr_t addr = {0};
socklen_t addrlen = sizeof(addr);
pkt.offset = 0;
int len = recvfrom(ls->udp.fd, (void *)DATA(&pkt), MAXSIZE, 0, &addr.sa, &addrlen);
- if(len <= 0 || len > MAXSIZE) {
+ if(len <= 0 || (size_t)len > MAXSIZE) {
if(!sockwouldblock(sockerrno)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Receiving packet failed: %s", sockstrerror(sockerrno));
}
/*
net_socket.c -- Handle various kinds of sockets.
Copyright (C) 1998-2005 Ivo Timmermans,
- 2000-2017 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2018 Guus Sliepen <guus@tinc-vpn.org>
2006 Scott Lamb <slamb@slamb.org>
2009 Florian Forster <octo@verplant.org>
}
#else /* if !defined(SOL_SOCKET) || !defined(SO_BINDTODEVICE) */
+ (void)sd;
logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform", "BindToInterface");
#endif
send_id(c);
}
-static void do_outgoing_pipe(connection_t *c, char *command) {
+static void do_outgoing_pipe(connection_t *c, const char *command) {
#ifndef HAVE_MINGW
int fd[2];
exit(result);
#else
+ (void)c;
+ (void)command;
logger(DEBUG_ALWAYS, LOG_ERR, "Proxy type exec not supported on this platform!");
return;
#endif
/*
process.c -- process management functions
Copyright (C) 1999-2005 Ivo Timmermans,
- 2000-2013 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2018 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
io_t stop_io;
-DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID boe, LPVOID bah) {
+DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID data, LPVOID context) {
+ (void)type;
+ (void)data;
+ (void)context;
+
switch(request) {
case SERVICE_CONTROL_INTERROGATE:
SetServiceStatus(statushandle, &status);
/*
route.c -- routing
Copyright (C) 2000-2005 Ivo Timmermans,
- 2000-2013 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2018 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
addr.sin_family = AF_INET;
socklen_t addrlen = sizeof(addr);
- if(!getsockname(sockfd, (struct sockaddr *) &addr, &addrlen) && addrlen <= sizeof(addr)) {
+ if(!getsockname(sockfd, (struct sockaddr *) &addr, &addrlen) && (size_t)addrlen <= sizeof(addr)) {
ip_dst = addr.sin_addr;
}
}
addr.sin6_family = AF_INET6;
socklen_t addrlen = sizeof(addr);
- if(!getsockname(sockfd, (struct sockaddr *) &addr, &addrlen) && addrlen <= sizeof(addr)) {
+ if(!getsockname(sockfd, (struct sockaddr *) &addr, &addrlen) && (size_t)addrlen <= sizeof(addr)) {
pseudo.ip6_src = addr.sin6_addr;
}
}
/*
script.c -- call an external script
Copyright (C) 1999-2005 Ivo Timmermans,
- 2000-2017 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2018 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
#else
// We must keep what we putenv() around in memory.
// To do this without memory leaks, keep things in a list and reuse if possible.
- static list_t list = {};
+ static list_t list = {0};
for list_each(char, data, &list) {
if(!strcmp(data, var)) {
#ifdef HAVE_MINGW
if(!*scriptextension) {
- const char *pathext = getenv("PATHEXT") ? : ".COM;.EXE;.BAT;.CMD";
+ const char *pathext = getenv("PATHEXT");
+
+ if(!pathext) {
+ pathext = ".COM;.EXE;.BAT;.CMD";
+ }
+
size_t pathlen = strlen(pathext);
size_t scriptlen = strlen(scriptname);
char fullname[scriptlen + pathlen + 1];
# define setpriority(level) !SetPriorityClass(GetCurrentProcess(), (level))
static void stop_handler(void *data, int flags) {
+ (void)data;
+ (void)flags;
+
event_exit();
}
static BOOL WINAPI console_ctrl_handler(DWORD type) {
+ (void)type;
+
logger(DEBUG_ALWAYS, LOG_NOTICE, "Got console shutdown request");
if(WSASetEvent(stop_io.event) == FALSE) {
}
int main2(int argc, char **argv) {
+ (void)argc;
+ (void)argv;
#endif
char *priority = NULL;
/*
upnp.c -- UPnP-IGD client
- Copyright (C) 2015 Guus Sliepen <guus@tinc-vpn.org>,
+ Copyright (C) 2015-2018 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
#include "upnp.h"
+#ifndef HAVE_MINGW
#include <pthread.h>
+#endif
#include "miniupnpc/miniupnpc.h"
#include "miniupnpc/upnpcommands.h"
time_t now = time(NULL);
if(now < refresh_time) {
- sleep(refresh_time - now);
+ nanosleep(&(struct timespec) {
+ refresh_time - now, 0
+ }, NULL);
}
}
get_config_int(lookup_config(config_tree, "UPnPDiscoverWait"), &upnp_discover_wait);
get_config_int(lookup_config(config_tree, "UPnPRefreshPeriod"), &upnp_refresh_period);
+#ifdef HAVE_MINGW
+ HANDLE handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)upnp_thread, NULL, 0, NULL);
+
+ if(!handle) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Unable to start UPnP-IGD client thread");
+ }
+
+#else
pthread_t thread;
int error = pthread_create(&thread, NULL, upnp_thread, NULL);
if(error) {
logger(DEBUG_ALWAYS, LOG_ERR, "Unable to start UPnP-IGD client thread: [%d] %s", error, strerror(error));
}
+
+#endif
}