Make sure tinc compiles on Windows.

This commit is contained in:
Guus Sliepen 2012-07-21 12:51:53 +02:00
parent 1d4590ca5c
commit 5eeed38b8e
5 changed files with 28 additions and 18 deletions

View 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);

View 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);

View 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);
}

View 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;
}

View file

@ -31,6 +31,10 @@
#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;