#include "system.h"
-#include <getopt.h>
-
#ifdef HAVE_READLINE
#include "readline/readline.h"
#include "readline/history.h"
}
}
-#ifdef HAVE_MINGW
+#ifdef HAVE_WINDOWS
if(filename[0] != '\\' && filename[0] != '/' && !strchr(filename, ':')) {
#else
return true;
}
-#ifdef HAVE_MINGW
+#ifdef HAVE_WINDOWS
static bool remove_service(void) {
SC_HANDLE manager = NULL;
SC_HANDLE service = NULL;
fclose(f);
-#ifndef HAVE_MINGW
+#ifndef HAVE_WINDOWS
if((pid == 0) || (kill(pid, 0) && (errno == ESRCH))) {
fprintf(stderr, "Could not find tincd running at pid %d\n", pid);
char *c;
char *slash = strrchr(program_name, '/');
-#ifdef HAVE_MINGW
+#ifdef HAVE_WINDOWS
if((c = strrchr(program_name, '\\')) > slash) {
slash = c;
char **nargv = xzalloc((optind + argc) * sizeof(*nargv));
char *arg0 = c;
-#ifdef HAVE_MINGW
+#ifdef HAVE_WINDOWS
/*
Windows has no real concept of an "argv array". A command line is just one string.
The CRT of the new process will decode the command line string to generate argv before calling main(), and (by convention)
nargv[nargc++] = argv[i];
}
-#ifdef HAVE_MINGW
+#ifdef HAVE_WINDOWS
int status = spawnvp(_P_WAIT, c, nargv);
free(nargv);
return 1;
}
-#ifdef HAVE_MINGW
+#ifdef HAVE_WINDOWS
return remove_service() ? EXIT_SUCCESS : EXIT_FAILURE;
#else
int cipher, digest, maclength, compression, distance, socket, weight;
short int pmtu, minmtu, maxmtu;
unsigned int options;
- uint32_t status_int;
node_status_t status;
long int last_state_change;
int udp_ping_rtt;
switch(req) {
case REQ_DUMP_NODES: {
- int n = sscanf(line, "%*d %*d %4095s %4095s %4095s port %4095s %d %d %d %d %x %"PRIx32" %4095s %4095s %d %hd %hd %hd %ld %d %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, node, id, host, port, &cipher, &digest, &maclength, &compression, &options, &status_int, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu, &last_state_change, &udp_ping_rtt, &in_packets, &in_bytes, &out_packets, &out_bytes);
+ int n = sscanf(line, "%*d %*d %4095s %4095s %4095s port %4095s %d %d %d %d %x %"PRIx32" %4095s %4095s %d %hd %hd %hd %ld %d %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, node, id, host, port, &cipher, &digest, &maclength, &compression, &options, &status.value, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu, &last_state_change, &udp_ping_rtt, &in_packets, &in_bytes, &out_packets, &out_bytes);
if(n != 22) {
fprintf(stderr, "Unable to parse node dump from tincd: %s\n", line);
return 1;
}
- memcpy(&status, &status_int, sizeof(status));
-
if(do_graph) {
const char *color = "black";
}
printf("%s id %s at %s port %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s distance %d pmtu %d (min %d max %d) rx %"PRIu64" %"PRIu64" tx %"PRIu64" %"PRIu64,
- node, id, host, port, cipher, digest, maclength, compression, options, status_int, nexthop, via, distance, pmtu, minmtu, maxmtu, in_packets, in_bytes, out_packets, out_bytes);
+ node, id, host, port, cipher, digest, maclength, compression, options, status.value, nexthop, via, distance, pmtu, minmtu, maxmtu, in_packets, in_bytes, out_packets, out_bytes);
if(udp_ping_rtt != -1) {
printf(" rtt %d.%03d", udp_ping_rtt / 1000, udp_ping_rtt % 1000);
break;
case REQ_DUMP_CONNECTIONS: {
- int n = sscanf(line, "%*d %*d %4095s %4095s port %4095s %x %d %x", node, host, port, &options, &socket, &status_int);
+ int n = sscanf(line, "%*d %*d %4095s %4095s port %4095s %x %d %x", node, host, port, &options, &socket, &status.value);
if(n != 6) {
fprintf(stderr, "Unable to parse connection dump from tincd.\n");
return 1;
}
- printf("%s at %s port %s options %x socket %d status %x\n", node, host, port, options, socket, status_int);
+ printf("%s at %s port %s options %x socket %d status %x\n", node, host, port, options, socket, status.value);
}
break;
char filename[PATH_MAX];
if(node) {
- snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, node);
+ if((size_t)snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, node) >= sizeof(filename)) {
+ fprintf(stderr, "Filename too long: %s" SLASH "%s\n", hosts_dir, node);
+ free(node);
+ return 1;
+ }
if(node != line) {
free(node);
}
// Replace the configuration file with the new one
-#ifdef HAVE_MINGW
+#ifdef HAVE_WINDOWS
if(remove(filename)) {
fprintf(stderr, "Error replacing file %s: %s\n", filename, strerror(errno));
check_port(name);
-#ifndef HAVE_MINGW
+#ifndef HAVE_WINDOWS
char filename[PATH_MAX];
snprintf(filename, sizeof(filename), "%s" SLASH "tinc-up", confbase);
}
char *command;
-#ifndef HAVE_MINGW
+#ifndef HAVE_WINDOWS
const char *editor = getenv("VISUAL");
if(!editor) {
return 0;
}
-#ifdef HAVE_MINGW
+#ifdef HAVE_WINDOWS
static struct WSAData wsa_state;
if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) {