return 0;
}
-static int signal_compare(const signal_t *a, const signal_t *b) {
- return a->signum - b->signum;
-}
-
static splay_tree_t io_tree = {.compare = (splay_compare_t)io_compare};
static splay_tree_t timeout_tree = {.compare = (splay_compare_t)timeout_compare};
-static splay_tree_t signal_tree = {.compare = (splay_compare_t)signal_compare};
void io_add(io_t *io, io_cb_t cb, void *data, int fd, int flags) {
if(io->cb)
}
#ifndef HAVE_MINGW
+static int signal_compare(const signal_t *a, const signal_t *b) {
+ return a->signum - b->signum;
+}
+
static io_t signalio;
static int pipefd[2] = {-1, -1};
+static splay_tree_t signal_tree = {.compare = (splay_compare_t)signal_compare};
static void signal_handler(int signum) {
unsigned char num = signum;
static DWORD WINAPI tapreader(void *bla) {
int status;
- long len;
+ DWORD len;
OVERLAPPED overlapped;
vpn_packet_t packet;
overlapped.OffsetHigh = 0;
ResetEvent(overlapped.hEvent);
- status = ReadFile(device_handle, packet.data, MTU, &len, &overlapped);
+ status = ReadFile(device_handle, (void *)packet.data, MTU, &len, &overlapped);
if(!status) {
if(GetLastError() == ERROR_IO_PENDING) {
char adapterid[1024];
char adaptername[1024];
char tapname[1024];
- long len;
+ DWORD len;
unsigned long status;
bool found = false;
continue;
len = sizeof adaptername;
- err = RegQueryValueEx(key2, "Name", 0, 0, adaptername, &len);
+ err = RegQueryValueEx(key2, "Name", 0, 0, (LPBYTE)adaptername, &len);
RegCloseKey(key2);
}
static bool write_packet(vpn_packet_t *packet) {
- long outlen;
+ DWORD outlen;
OVERLAPPED overlapped = {0};
logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s",
static bool read_packet(vpn_packet_t *packet) {
int lenin;
- if((lenin = recv(device_fd, packet->data, MTU, 0)) <= 0) {
+ if((lenin = recv(device_fd, (void *)packet->data, MTU, 0)) <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info,
device, strerror(errno));
return false;
logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s",
packet->len, device_info);
- if(sendto(device_fd, packet->data, packet->len, 0, ai->ai_addr, ai->ai_addrlen) < 0) {
+ if(sendto(device_fd, (void *)packet->data, packet->len, 0, ai->ai_addr, ai->ai_addrlen) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Can't write to %s %s: %s", device_info, device,
strerror(errno));
return false;
#ifdef HAVE_MINGW
HKEY key;
char installdir[1024] = "";
- long len = sizeof installdir;
+ DWORD len = sizeof installdir;
#endif
if(netname)
#ifdef HAVE_MINGW
if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) {
- if(!RegQueryValueEx(key, NULL, 0, 0, installdir, &len)) {
+ if(!RegQueryValueEx(key, NULL, 0, 0, (LPBYTE)installdir, &len)) {
confdir = xstrdup(installdir);
if(!logfilename)
xasprintf(&logfilename, "%s" SLASH "log" SLASH "%s.log", installdir, identname);
}
}
+#ifndef HAVE_MINGW
static void sigterm_handler(void *data) {
logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum));
event_exit();
logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum));
retry();
}
+#endif
int reload_configuration(void) {
char *fname;
int result;
socklen_t len = sizeof result;
- getsockopt(c->socket, SOL_SOCKET, SO_ERROR, &result, &len);
+ getsockopt(c->socket, SOL_SOCKET, SO_ERROR, (void *)&result, &len);
if(!result)
finish_connecting(c);
}
}
-#ifdef WEXITSTATUS
if(status != -1) {
+#ifdef WEXITSTATUS
if(WIFEXITED(status)) { /* Child exited by itself */
if(WEXITSTATUS(status)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Script %s exited with non-zero status %d",
logger(DEBUG_ALWAYS, LOG_ERR, "Script %s terminated abnormally", name);
return false;
}
+#endif
} else {
logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "system", strerror(errno));
return false;
}
-#endif
#endif
return true;
}
/* If nonzero, use null ciphers and skip all key exchanges. */
bool bypass_security = false;
+#ifdef HAVE_MLOCKALL
/* If nonzero, disable swapping for this process. */
static bool do_mlock = false;
+#endif
+#ifndef HAVE_MINGW
/* If nonzero, chroot to netdir after startup. */
static bool do_chroot = false;
/* If !NULL, do setuid to given user after startup */
static const char *switchuser = NULL;
+#endif
/* If nonzero, write log entries to a separate file. */
bool use_logfile = false;