Make sure tinc compiles on Windows.
This commit is contained in:
parent
1d4590ca5c
commit
5eeed38b8e
5 changed files with 28 additions and 18 deletions
|
@ -39,7 +39,7 @@ bool send_meta_sptps(void *handle, const char *buffer, size_t length) {
|
||||||
abort();
|
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);
|
buffer_add(&c->outbuf, buffer, length);
|
||||||
event_add(&c->outevent, NULL);
|
event_add(&c->outevent, NULL);
|
||||||
|
|
|
@ -390,8 +390,8 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) {
|
||||||
size_t outlen;
|
size_t outlen;
|
||||||
#if defined(SOL_IP) && defined(IP_TOS)
|
#if defined(SOL_IP) && defined(IP_TOS)
|
||||||
static int priority = 0;
|
static int priority = 0;
|
||||||
int origpriority = origpkt->priority;
|
|
||||||
#endif
|
#endif
|
||||||
|
int origpriority = origpkt->priority;
|
||||||
|
|
||||||
if(!n->status.reachable) {
|
if(!n->status.reachable) {
|
||||||
logger(DEBUG_TRAFFIC, LOG_INFO, "Trying to send UDP packet to unreachable node %s (%s)", n->name, n->hostname);
|
logger(DEBUG_TRAFFIC, LOG_INFO, "Trying to send UDP packet to unreachable node %s (%s)", n->name, n->hostname);
|
||||||
|
|
|
@ -193,11 +193,11 @@ bool send_ans_key_ecdh(node_t *to) {
|
||||||
|
|
||||||
b64encode(key, key, ECDH_SIZE + siglen);
|
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,
|
myself->name, to->name, key,
|
||||||
cipher_get_nid(&myself->incipher),
|
cipher_get_nid(&myself->incipher),
|
||||||
digest_get_nid(&myself->indigest),
|
digest_get_nid(&myself->indigest),
|
||||||
digest_length(&myself->indigest),
|
(int)digest_length(&myself->indigest),
|
||||||
myself->incompression);
|
myself->incompression);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -225,11 +225,11 @@ bool send_ans_key(node_t *to) {
|
||||||
to->received_seqno = 0;
|
to->received_seqno = 0;
|
||||||
if(replaywin) memset(to->late, 0, replaywin);
|
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,
|
myself->name, to->name, key,
|
||||||
cipher_get_nid(&to->incipher),
|
cipher_get_nid(&to->incipher),
|
||||||
digest_get_nid(&to->indigest),
|
digest_get_nid(&to->indigest),
|
||||||
digest_length(&to->indigest),
|
(int)digest_length(&to->indigest),
|
||||||
to->incompression);
|
to->incompression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "poll.h"
|
|
||||||
|
|
||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
#include "ecdsa.h"
|
#include "ecdsa.h"
|
||||||
|
@ -36,7 +35,7 @@ ecdsa_t mykey, hiskey;
|
||||||
static bool send_data(void *handle, const char *data, size_t len) {
|
static bool send_data(void *handle, const char *data, size_t len) {
|
||||||
char hex[len * 2 + 1];
|
char hex[len * 2 + 1];
|
||||||
bin2hex(data, hex, len);
|
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;
|
const int *sock = handle;
|
||||||
if(send(*sock, data, len, 0) != len)
|
if(send(*sock, data, len, 0) != len)
|
||||||
return false;
|
return false;
|
||||||
|
@ -67,6 +66,12 @@ int main(int argc, char *argv[]) {
|
||||||
if(argc > 4)
|
if(argc > 4)
|
||||||
initiator = true;
|
initiator = true;
|
||||||
|
|
||||||
|
#ifdef HAVE_MINGW
|
||||||
|
static struct WSAData wsa_state;
|
||||||
|
if(WSAStartup(MAKEWORD(2, 2), &wsa_state))
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct addrinfo *ai, hint;
|
struct addrinfo *ai, hint;
|
||||||
memset(&hint, 0, sizeof hint);
|
memset(&hint, 0, sizeof hint);
|
||||||
|
|
||||||
|
@ -136,15 +141,16 @@ int main(int argc, char *argv[]) {
|
||||||
while(true) {
|
while(true) {
|
||||||
char buf[65535] = "";
|
char buf[65535] = "";
|
||||||
|
|
||||||
struct pollfd fds[2];
|
fd_set fds;
|
||||||
fds[0].fd = 0;
|
FD_ZERO(&fds);
|
||||||
fds[0].events = POLLIN;
|
#ifndef HAVE_MINGW
|
||||||
fds[1].fd = sock;
|
FD_SET(0, &fds);
|
||||||
fds[1].events = POLLIN;
|
#endif
|
||||||
if(poll(fds, 2, -1) < 0)
|
FD_SET(sock, &fds);
|
||||||
|
if(select(sock + 1, &fds, NULL, NULL, NULL) <= 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if(fds[0].revents) {
|
if(FD_ISSET(0, &fds)) {
|
||||||
ssize_t len = read(0, buf, sizeof buf);
|
ssize_t len = read(0, buf, sizeof buf);
|
||||||
if(len < 0) {
|
if(len < 0) {
|
||||||
fprintf(stderr, "Could not read from stdin: %s\n", strerror(errno));
|
fprintf(stderr, "Could not read from stdin: %s\n", strerror(errno));
|
||||||
|
@ -163,7 +169,7 @@ int main(int argc, char *argv[]) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fds[1].revents) {
|
if(FD_ISSET(sock, &fds)) {
|
||||||
ssize_t len = recv(sock, buf, sizeof buf, 0);
|
ssize_t len = recv(sock, buf, sizeof buf, 0);
|
||||||
if(len < 0) {
|
if(len < 0) {
|
||||||
fprintf(stderr, "Could not read from socket: %s\n", strerror(errno));
|
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];
|
char hex[len * 2 + 1];
|
||||||
bin2hex(buf, hex, len);
|
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))
|
if(!sptps_receive_data(&s, buf, len))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
#include "tincctl.h"
|
#include "tincctl.h"
|
||||||
#include "top.h"
|
#include "top.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_MINGW
|
||||||
|
#define mkdir(a, b) mkdir(a)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The name this program was run with. */
|
/* The name this program was run with. */
|
||||||
static char *program_name = NULL;
|
static char *program_name = NULL;
|
||||||
|
|
||||||
|
@ -1354,7 +1358,7 @@ static int cmd_edit(int argc, char *argv[]) {
|
||||||
#ifndef HAVE_MINGW
|
#ifndef HAVE_MINGW
|
||||||
char *editor = getenv("VISUAL") ?: getenv("EDITOR") ?: "vi";
|
char *editor = getenv("VISUAL") ?: getenv("EDITOR") ?: "vi";
|
||||||
#else
|
#else
|
||||||
char *editor = "edit"
|
char *editor = "edit";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *command;
|
char *command;
|
||||||
|
|
Loading…
Reference in a new issue