]> git.meshlink.io Git - meshlink/commitdiff
Make sure tinc compiles on Windows.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 21 Jul 2012 10:51:53 +0000 (12:51 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 21 Jul 2012 10:51:53 +0000 (12:51 +0200)
src/meta.c
src/net_packet.c
src/protocol_key.c
src/sptps_test.c
src/tincctl.c

index a272baf57e10da72687fed8c7aa91223e626bccc..84094d46f56a7db859c02782ca36c67e79aa1056 100644 (file)
@@ -39,7 +39,7 @@ bool send_meta_sptps(void *handle, const char *buffer, size_t length) {
                abort();
        }
 
-       logger(DEBUG_META, LOG_DEBUG, "send_meta_sptps(%s, %p, %zu)", c->name, buffer, length);
+       logger(DEBUG_META, LOG_DEBUG, "send_meta_sptps(%s, %p, %d)", c->name, buffer, (int)length);
 
        buffer_add(&c->outbuf, buffer, length);
        event_add(&c->outevent, NULL);
index cbdc15cfebc98ea77156017b65db2c4beb3d472a..e9fd10ce53c9a8856452cc5d5debf6f63a59264b 100644 (file)
@@ -390,8 +390,8 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) {
        size_t outlen;
 #if defined(SOL_IP) && defined(IP_TOS)
        static int priority = 0;
-       int origpriority = origpkt->priority;
 #endif
+       int origpriority = origpkt->priority;
 
        if(!n->status.reachable) {
                logger(DEBUG_TRAFFIC, LOG_INFO, "Trying to send UDP packet to unreachable node %s (%s)", n->name, n->hostname);
index 0e02c6ed33576ae9dee14c8bdd180a5174ed4134..39643cc34a589eca738ba005e1b0aa7ffa45d568 100644 (file)
@@ -193,11 +193,11 @@ bool send_ans_key_ecdh(node_t *to) {
 
        b64encode(key, key, ECDH_SIZE + siglen);
 
-       int result = send_request(to->nexthop->connection, "%d %s %s %s %d %d %zu %d", ANS_KEY,
+       int result = send_request(to->nexthop->connection, "%d %s %s %s %d %d %d %d", ANS_KEY,
                                                myself->name, to->name, key,
                                                cipher_get_nid(&myself->incipher),
                                                digest_get_nid(&myself->indigest),
-                                               digest_length(&myself->indigest),
+                                               (int)digest_length(&myself->indigest),
                                                myself->incompression);
 
        return result;
@@ -225,11 +225,11 @@ bool send_ans_key(node_t *to) {
        to->received_seqno = 0;
        if(replaywin) memset(to->late, 0, replaywin);
 
-       return send_request(to->nexthop->connection, "%d %s %s %s %d %d %zu %d", ANS_KEY,
+       return send_request(to->nexthop->connection, "%d %s %s %s %d %d %d %d", ANS_KEY,
                                                myself->name, to->name, key,
                                                cipher_get_nid(&to->incipher),
                                                digest_get_nid(&to->indigest),
-                                               digest_length(&to->indigest),
+                                               (int)digest_length(&to->indigest),
                                                to->incompression);
 }
 
index 79a1a85d13317f2fb2e310d372252881a3990216..30cc33c087157e6ae1cf559fb43ebef6a5d7ccaa 100644 (file)
@@ -18,7 +18,6 @@
 */
 
 #include "system.h"
-#include "poll.h"
 
 #include "crypto.h"
 #include "ecdsa.h"
@@ -36,7 +35,7 @@ ecdsa_t mykey, hiskey;
 static bool send_data(void *handle, const char *data, size_t len) {
        char hex[len * 2 + 1];
        bin2hex(data, hex, len);
-       fprintf(stderr, "Sending %zu bytes of data:\n%s\n", len, hex);
+       fprintf(stderr, "Sending %d bytes of data:\n%s\n", (int)len, hex);
        const int *sock = handle;
        if(send(*sock, data, len, 0) != len)
                return false;
@@ -67,6 +66,12 @@ int main(int argc, char *argv[]) {
        if(argc > 4)
                initiator = true;
 
+#ifdef HAVE_MINGW
+       static struct WSAData wsa_state;
+       if(WSAStartup(MAKEWORD(2, 2), &wsa_state))
+               return 1;
+#endif
+
        struct addrinfo *ai, hint;
        memset(&hint, 0, sizeof hint);
 
@@ -136,15 +141,16 @@ int main(int argc, char *argv[]) {
        while(true) {
                char buf[65535] = "";
 
-               struct pollfd fds[2];
-               fds[0].fd = 0;
-               fds[0].events = POLLIN;
-               fds[1].fd = sock;
-               fds[1].events = POLLIN;
-               if(poll(fds, 2, -1) < 0)
+               fd_set fds;
+               FD_ZERO(&fds);
+#ifndef HAVE_MINGW
+               FD_SET(0, &fds);
+#endif
+               FD_SET(sock, &fds);
+               if(select(sock + 1, &fds, NULL, NULL, NULL) <= 0)
                        return 1;
 
-               if(fds[0].revents) {
+               if(FD_ISSET(0, &fds)) {
                        ssize_t len = read(0, buf, sizeof buf);
                        if(len < 0) {
                                fprintf(stderr, "Could not read from stdin: %s\n", strerror(errno));
@@ -163,7 +169,7 @@ int main(int argc, char *argv[]) {
                                return 1;
                }
 
-               if(fds[1].revents) {
+               if(FD_ISSET(sock, &fds)) {
                        ssize_t len = recv(sock, buf, sizeof buf, 0);
                        if(len < 0) {
                                fprintf(stderr, "Could not read from socket: %s\n", strerror(errno));
@@ -175,7 +181,7 @@ int main(int argc, char *argv[]) {
                        }
                        char hex[len * 2 + 1];
                        bin2hex(buf, hex, len);
-                       fprintf(stderr, "Received %zd bytes of data:\n%s\n", len, hex);
+                       fprintf(stderr, "Received %d bytes of data:\n%s\n", (int)len, hex);
                        if(!sptps_receive_data(&s, buf, len))
                                return 1;
                }
index b977d13765cc9d33a632118c2feae55c2207f9a3..c25ad2c5c83552181b9640f85e5f49b2ac7938f5 100644 (file)
 #include "tincctl.h"
 #include "top.h"
 
+#ifdef HAVE_MINGW
+#define mkdir(a, b) mkdir(a)
+#endif
+
 /* The name this program was run with. */
 static char *program_name = NULL;
 
@@ -1354,7 +1358,7 @@ static int cmd_edit(int argc, char *argv[]) {
 #ifndef HAVE_MINGW
        char *editor = getenv("VISUAL") ?: getenv("EDITOR") ?: "vi";
 #else
-       char *editor = "edit"
+       char *editor = "edit";
 #endif
 
        char *command;