aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Weinrank <info@weinrank.net>2019-06-28 17:05:06 +0200
committerMichael Tüxen <tuexen@fh-muenster.de>2019-06-28 17:05:06 +0200
commit37a8a0a1f9c4b1eb6c00c0043b9eb455facdcad9 (patch)
treeadad5f38ba18d81fa161b083d4f87414431827a9
parentb78601e565d257a145ac3728baa56458c94108c9 (diff)
downloadusrsctp-37a8a0a1f9c4b1eb6c00c0043b9eb455facdcad9.tar.gz
MinGW Support (32bit & 64bit) (#321)
* Added support for mingw64 (gcc 6.3.0) * Fixed mingw32/64 issue * be more verbose (#312) * Improve and of ICMP messages on Windows. When an ICMP message is received on Windows 10 for a UDP socket, WSAECONNRESET is reported as an error. In this case, just read again. Thanks to nxrighthere for reporting the issue and helping to nail it down. This fixes #309. * Fix broken links, Make URLs' protocols consistent (#315) Two Links missed leading `http(s)://` and were broken. All links to `tools.ietf.org` now consistently use https. * Backport https://svnweb.freebsd.org/base?view=revision&revision=340783 * Improve input validation for the IPPROTO_SCTP level socket options SCTP_CONNECT_X and SCTP_CONNECT_X_DELAYED. * Allow sending on demand SCTP HEARTBEATS only in the ESTABLISHED state. * Fix cross-build linux->mingw (#320) * Fix compile error due to merge mistake. * test commit * Add MinGW and MinGW64 support * MinGW support, polishing * Sanitize non C-style comments * Revert uint32_t casting for htonl * Ignore wformat errors on GCC + MinGW platforms
-rw-r--r--programs/CMakeLists.txt11
-rw-r--r--programs/client_upcall.c24
-rw-r--r--programs/ekr_loop.c6
-rw-r--r--programs/ekr_loop_offload.c4
-rw-r--r--programs/ekr_loop_upcall.c7
-rw-r--r--programs/ekr_peer.c2
-rw-r--r--programs/http_client_upcall.c2
-rw-r--r--programs/programs_helper.h2
-rw-r--r--programs/rtcweb.c10
-rw-r--r--programs/tsctp.c19
-rw-r--r--usrsctplib/CMakeLists.txt4
-rwxr-xr-xusrsctplib/netinet/sctp_cc_functions.c6
-rwxr-xr-xusrsctplib/netinet/sctp_os_userspace.h5
-rwxr-xr-xusrsctplib/netinet/sctp_pcb.c2
-rwxr-xr-xusrsctplib/netinet/sctp_pcb.h4
-rwxr-xr-xusrsctplib/netinet/sctp_userspace.c10
-rwxr-xr-xusrsctplib/user_atomic.h2
-rwxr-xr-xusrsctplib/user_environment.h2
-rwxr-xr-xusrsctplib/user_mbuf.c2
-rwxr-xr-xusrsctplib/user_recv_thread.c8
-rwxr-xr-xusrsctplib/user_socket.c18
-rwxr-xr-xusrsctplib/user_socketvar.h2
22 files changed, 89 insertions, 63 deletions
diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt
index d383c3f1..8cdff313 100644
--- a/programs/CMakeLists.txt
+++ b/programs/CMakeLists.txt
@@ -56,6 +56,17 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-D__APPLE_USE_RFC_2292)
endif ()
+if (MSYS)
+ message(STATUS "MSYS")
+ add_definitions(-D__USE_MINGW_ANSI_STDIO)
+
+ if (CMAKE_C_COMPILER_ID MATCHES "GNU")
+ message(STATUS "MYSYS + GCC")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format")
+ endif ()
+endif ()
+
#################################################
# MISC
diff --git a/programs/client_upcall.c b/programs/client_upcall.c
index d77b4af8..3de0783c 100644
--- a/programs/client_upcall.c
+++ b/programs/client_upcall.c
@@ -40,7 +40,7 @@
#if !defined(_WIN32)
#include <unistd.h>
#include <sys/time.h>
-#endif // !defined(_WIN32)
+#endif /* !defined(_WIN32) */
#include <sys/types.h>
@@ -48,7 +48,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#else // !defined(_WIN32)
+#else /* !defined(_WIN32) */
#include <io.h>
#endif
@@ -66,17 +66,17 @@ typedef char* caddr_t;
int inputAvailable(void)
{
- struct timeval tv;
- fd_set fds;
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- FD_ZERO(&fds);
-#ifndef _WIN32
- FD_SET(STDIN_FILENO, &fds);
- select(STDIN_FILENO+1, &fds, NULL, NULL, &tv);
+ struct timeval tv;
+ fd_set fds;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ FD_ZERO(&fds);
+#if defined(_WIN32) && !defined(__MINGW32__)
+ FD_SET(_fileno(stdin), &fds);
+ select(_fileno(stdin) + 1, &fds, NULL, NULL, &tv);
#else
- FD_SET(_fileno(stdin), &fds);
- select(_fileno(stdin) + 1, &fds, NULL, NULL, &tv);
+ FD_SET(STDIN_FILENO, &fds);
+ select(STDIN_FILENO+1, &fds, NULL, NULL, &tv);
#endif
return (FD_ISSET(0, &fds));
}
diff --git a/programs/ekr_loop.c b/programs/ekr_loop.c
index 2d513cb2..5988450b 100644
--- a/programs/ekr_loop.c
+++ b/programs/ekr_loop.c
@@ -82,7 +82,7 @@ handle_packets(void *arg)
length = recv(*fdp, buf, MAX_PACKET_SIZE, 0);
if (length > 0) {
if ((dump_buf = usrsctp_dumppacket(buf, (size_t)length, SCTP_DUMP_INBOUND)) != NULL) {
- //fprintf(stderr, "%s", dump_buf);
+ /* fprintf(stderr, "%s", dump_buf); */
usrsctp_freedumpbuffer(dump_buf);
}
usrsctp_conninput(fdp, buf, (size_t)length, 0);
@@ -111,7 +111,7 @@ conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df)
fdp = (int *)addr;
#endif
if ((dump_buf = usrsctp_dumppacket(buf, length, SCTP_DUMP_OUTBOUND)) != NULL) {
- //fprintf(stderr, "%s", dump_buf);
+ /* fprintf(stderr, "%s", dump_buf); */
usrsctp_freedumpbuffer(dump_buf);
}
#ifdef _WIN32
@@ -476,7 +476,7 @@ main(void)
}
memset(line, 'A', LINE_LENGTH);
sndinfo.snd_sid = 1;
- sndinfo.snd_flags = 0; //SCTP_UNORDERED;
+ sndinfo.snd_flags = 0; /* SCTP_UNORDERED */
sndinfo.snd_ppid = htonl(DISCARD_PPID);
sndinfo.snd_context = 0;
sndinfo.snd_assoc_id = 0;
diff --git a/programs/ekr_loop_offload.c b/programs/ekr_loop_offload.c
index 1d39962d..a0308c5c 100644
--- a/programs/ekr_loop_offload.c
+++ b/programs/ekr_loop_offload.c
@@ -84,7 +84,7 @@ handle_packets(void *arg)
length = recv(*fdp, buffer, MAX_PACKET_SIZE, 0);
if (length > 0) {
if ((dump_buffer = usrsctp_dumppacket(buffer, (size_t)length, SCTP_DUMP_INBOUND)) != NULL) {
- //fprintf(stderr, "%s", dump_buffer);
+ /* fprintf(stderr, "%s", dump_buffer); */
usrsctp_freedumpbuffer(dump_buffer);
}
if ((size_t)length >= sizeof(struct sctp_common_header)) {
@@ -132,7 +132,7 @@ conn_output(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df
hdr->crc32c = usrsctp_crc32c(buffer, (size_t)length);
}
if ((dump_buffer = usrsctp_dumppacket(buffer, length, SCTP_DUMP_OUTBOUND)) != NULL) {
- //fprintf(stderr, "%s", dump_buffer);
+ /* fprintf(stderr, "%s", dump_buffer); */
usrsctp_freedumpbuffer(dump_buffer);
}
#ifdef _WIN32
diff --git a/programs/ekr_loop_upcall.c b/programs/ekr_loop_upcall.c
index 7b384916..c5af5f3b 100644
--- a/programs/ekr_loop_upcall.c
+++ b/programs/ekr_loop_upcall.c
@@ -54,7 +54,7 @@
#define MAX_PACKET_SIZE (1<<16)
#define LINE_LENGTH (1<<20)
#define DISCARD_PPID 39
-//#define DUMP_PKTS_TO_FILE
+/* #define DUMP_PKTS_TO_FILE */
#ifdef _WIN32
static DWORD WINAPI
@@ -84,7 +84,7 @@ handle_packets(void *arg)
length = recv(*fdp, buf, MAX_PACKET_SIZE, 0);
if (length > 0) {
if ((dump_buf = usrsctp_dumppacket(buf, (size_t)length, SCTP_DUMP_INBOUND)) != NULL) {
- //fprintf(stderr, "%s", dump_buf);
+ /* fprintf(stderr, "%s", dump_buf); */
usrsctp_freedumpbuffer(dump_buf);
}
usrsctp_conninput(fdp, buf, (size_t)length, 0);
@@ -113,7 +113,7 @@ conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df)
fdp = (int *)addr;
#endif
if ((dump_buf = usrsctp_dumppacket(buf, length, SCTP_DUMP_OUTBOUND)) != NULL) {
- //fprintf(stderr, "%s", dump_buf);
+ /* fprintf(stderr, "%s", dump_buf); */
usrsctp_freedumpbuffer(dump_buf);
}
@@ -150,7 +150,6 @@ handle_upcall(struct socket *sock, void *data, int flgs)
while ((events = usrsctp_get_events(sock)) && (events & SCTP_EVENT_READ)) {
struct sctp_recvv_rn rn;
ssize_t n;
- //struct sockaddr_storage addr;
union sctp_sockstore addr;
int flags = 0;
socklen_t len = (socklen_t)sizeof(addr);
diff --git a/programs/ekr_peer.c b/programs/ekr_peer.c
index 26fca115..d51568c7 100644
--- a/programs/ekr_peer.c
+++ b/programs/ekr_peer.c
@@ -283,7 +283,7 @@ main(int argc, char *argv[])
perror("usrsctp_connect");
}
for (;;) {
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__MINGW32__)
if (gets_s(line, LINE_LENGTH) == NULL) {
#else
if (fgets(line, LINE_LENGTH, stdin) == NULL) {
diff --git a/programs/http_client_upcall.c b/programs/http_client_upcall.c
index cb6e60ef..0220d250 100644
--- a/programs/http_client_upcall.c
+++ b/programs/http_client_upcall.c
@@ -204,7 +204,7 @@ main(int argc, char *argv[])
goto out;
}
- //usrsctp_set_non_blocking(sock, 1);
+ /* usrsctp_set_non_blocking(sock, 1); */
rtoinfo.srto_assoc_id = 0;
rtoinfo.srto_initial = 1000;
diff --git a/programs/programs_helper.h b/programs/programs_helper.h
index 343cbaba..132685a3 100644
--- a/programs/programs_helper.h
+++ b/programs/programs_helper.h
@@ -42,4 +42,4 @@ void handle_notification(union sctp_notification *notif, size_t n);
} while (0)
#endif
-#endif // __PROGRAMS_HELPER_H__
+#endif /* __PROGRAMS_HELPER_H__ */
diff --git a/programs/rtcweb.c b/programs/rtcweb.c
index d7b67cbc..01470ad4 100644
--- a/programs/rtcweb.c
+++ b/programs/rtcweb.c
@@ -120,10 +120,10 @@ struct peer_connection {
#define SCTP_PACKED
#endif
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(__MINGW32__)
#pragma warning( push )
#pragma warning( disable : 4200 )
-#endif //defined(_WIN32)
+#endif /* defined(_WIN32) && !defined(__MINGW32__) */
struct rtcweb_datachannel_open_request {
uint8_t msg_type; /* DATA_CHANNEL_OPEN_REQUEST */
uint8_t channel_type;
@@ -132,9 +132,9 @@ struct rtcweb_datachannel_open_request {
int16_t priority;
char label[];
} SCTP_PACKED;
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(__MINGW32__)
#pragma warning( pop )
-#endif //defined(_WIN32)
+#endif /* defined(_WIN32) && !defined(__MINGW32__) */
struct rtcweb_datachannel_open_response {
uint8_t msg_type; /* DATA_CHANNEL_OPEN_RESPONSE */
@@ -1432,7 +1432,7 @@ main(int argc, char *argv[])
unlock_peer_connection(&peer_connection);
for (;;) {
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__MINGW32__)
if (gets_s(line, LINE_LENGTH) == NULL) {
#else
if (fgets(line, LINE_LENGTH, stdin) == NULL) {
diff --git a/programs/tsctp.c b/programs/tsctp.c
index 8068c1ad..d7c23e40 100644
--- a/programs/tsctp.c
+++ b/programs/tsctp.c
@@ -127,9 +127,8 @@ handle_connection(void *arg)
{
ssize_t n;
char *buf;
-#ifdef _WIN32
- HANDLE tid;
-#else
+
+#if !defined(_WIN32)
pthread_t tid;
#endif
struct socket *conn_sock;
@@ -151,9 +150,8 @@ handle_connection(void *arg)
unsigned long long sum = 0;
conn_sock = *(struct socket **)arg;
-#ifdef _WIN32
- tid = GetCurrentThread();
-#else
+
+#if !defined(_WIN32)
tid = pthread_self();
pthread_detach(tid);
#endif
@@ -349,7 +347,6 @@ int main(int argc, char **argv)
unsigned long messages = 0;
#ifdef _WIN32
unsigned long srcAddr;
- HANDLE tid;
#else
in_addr_t srcAddr;
pthread_t tid;
@@ -648,19 +645,19 @@ int main(int argc, char **argv)
continue;
}
#ifdef _WIN32
- tid = CreateThread(NULL, 0, &handle_connection, (void *)conn_sock, 0, NULL);
+ CreateThread(NULL, 0, &handle_connection, (void *)conn_sock, 0, NULL);
#else
pthread_create(&tid, NULL, &handle_connection, (void *)conn_sock);
#endif
}
if (verbose) {
- // const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
- //inet_ntoa(remote_addr.sin_addr)
+ /* const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
+ inet_ntoa(remote_addr.sin_addr) */
char addrbuf[INET_ADDRSTRLEN];
printf("Connection accepted from %s:%d\n", inet_ntop(AF_INET, &(remote_addr.sin_addr), addrbuf, INET_ADDRSTRLEN), ntohs(remote_addr.sin_port));
}
}
- //usrsctp_close(psock); // unreachable
+ /* usrsctp_close(psock); unreachable */
} else {
memset(&encaps, 0, sizeof(struct sctp_udpencaps));
encaps.sue_address.ss_family = AF_INET;
diff --git a/usrsctplib/CMakeLists.txt b/usrsctplib/CMakeLists.txt
index 595f529c..917b7506 100644
--- a/usrsctplib/CMakeLists.txt
+++ b/usrsctplib/CMakeLists.txt
@@ -173,8 +173,8 @@ add_library(usrsctp-static STATIC ${usrsctp_sources} ${usrsctp_headers})
if (WIN32)
message(STATUS "link library: ws2_32")
- target_link_libraries(usrsctp ws2_32)
- target_link_libraries(usrsctp-static ws2_32)
+ target_link_libraries(usrsctp ws2_32 Iphlpapi.lib)
+ target_link_libraries(usrsctp-static ws2_32 Iphlpapi.lib)
endif ()
set_target_properties(usrsctp-static PROPERTIES OUTPUT_NAME "usrsctp")
diff --git a/usrsctplib/netinet/sctp_cc_functions.c b/usrsctplib/netinet/sctp_cc_functions.c
index e53e4d74..41a3c80b 100755
--- a/usrsctplib/netinet/sctp_cc_functions.c
+++ b/usrsctplib/netinet/sctp_cc_functions.c
@@ -2410,7 +2410,7 @@ sctp_htcp_cwnd_update_after_ecn_echo(struct sctp_tcb *stcb,
const struct sctp_cc_functions sctp_cc_functions[] = {
{
-#if defined(__Windows__) || defined(__Userspace_os_Windows)
+#if (defined(__Windows__) || defined(__Userspace_os_Windows)) && !defined(__MINGW32__)
sctp_set_initial_cc_param,
sctp_cwnd_update_after_sack,
sctp_cwnd_update_exit_pf_common,
@@ -2431,7 +2431,7 @@ const struct sctp_cc_functions sctp_cc_functions[] = {
#endif
},
{
-#if defined(__Windows__) || defined(__Userspace_os_Windows)
+#if (defined(__Windows__) || defined(__Userspace_os_Windows)) && !defined(__MINGW32__)
sctp_set_initial_cc_param,
sctp_hs_cwnd_update_after_sack,
sctp_cwnd_update_exit_pf_common,
@@ -2452,7 +2452,7 @@ const struct sctp_cc_functions sctp_cc_functions[] = {
#endif
},
{
-#if defined(__Windows__) || defined(__Userspace_os_Windows)
+#if (defined(__Windows__) || defined(__Userspace_os_Windows)) && !defined(__MINGW32__)
sctp_htcp_set_initial_cc_param,
sctp_htcp_cwnd_update_after_sack,
sctp_cwnd_update_exit_pf_common,
diff --git a/usrsctplib/netinet/sctp_os_userspace.h b/usrsctplib/netinet/sctp_os_userspace.h
index 765deed2..5eabeac9 100755
--- a/usrsctplib/netinet/sctp_os_userspace.h
+++ b/usrsctplib/netinet/sctp_os_userspace.h
@@ -106,8 +106,9 @@ typedef DWORD userland_thread_id_t;
#define n_time unsigned __int32
#define sa_family_t unsigned __int8
#define ssize_t __int64
+#if !defined(__MINGW32__)
#define __func__ __FUNCTION__
-
+#endif
#ifndef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#endif
@@ -221,7 +222,7 @@ typedef char* caddr_t;
#define bzero(buf, len) memset(buf, 0, len)
#define bcopy(srcKey, dstKey, len) memcpy(dstKey, srcKey, len)
-#if defined(_MSC_VER) && (_MSC_VER < 1900)
+#if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(__MINGW32__)
#define snprintf(data, size, format, ...) _snprintf_s(data, size, _TRUNCATE, format, __VA_ARGS__)
#endif
#define inline __inline
diff --git a/usrsctplib/netinet/sctp_pcb.c b/usrsctplib/netinet/sctp_pcb.c
index 55390bcc..f21f7002 100755
--- a/usrsctplib/netinet/sctp_pcb.c
+++ b/usrsctplib/netinet/sctp_pcb.c
@@ -6849,7 +6849,9 @@ sctp_pcb_init()
#endif
#if defined(__Userspace__)
mbuf_initialize(NULL);
+#if !defined(__MINGW32__)
atomic_init();
+#endif
#if defined(INET) || defined(INET6)
recv_thread_init();
#endif
diff --git a/usrsctplib/netinet/sctp_pcb.h b/usrsctplib/netinet/sctp_pcb.h
index 34881863..5b8f6613 100755
--- a/usrsctplib/netinet/sctp_pcb.h
+++ b/usrsctplib/netinet/sctp_pcb.h
@@ -320,7 +320,7 @@ struct sctp_base_info {
#endif
#endif
#ifdef INET
-#if defined(__Userspace_os_Windows)
+#if defined(__Userspace_os_Windows) && !defined(__MINGW32__)
SOCKET userspace_rawsctp;
SOCKET userspace_udpsctp;
#else
@@ -331,7 +331,7 @@ struct sctp_base_info {
userland_thread_t recvthreadudp;
#endif
#ifdef INET6
-#if defined(__Userspace_os_Windows)
+#if defined(__Userspace_os_Windows) && !defined(__MINGW32__)
SOCKET userspace_rawsctp6;
SOCKET userspace_udpsctp6;
#else
diff --git a/usrsctplib/netinet/sctp_userspace.c b/usrsctplib/netinet/sctp_userspace.c
index be547836..2005b24b 100755
--- a/usrsctplib/netinet/sctp_userspace.c
+++ b/usrsctplib/netinet/sctp_userspace.c
@@ -31,8 +31,10 @@
#include <netinet/sctp_pcb.h>
#include <sys/timeb.h>
#include <iphlpapi.h>
+#if !defined(__MINGW32__)
#pragma comment(lib, "IPHLPAPI.lib")
#endif
+#endif
#include <netinet/sctp_os_userspace.h>
#if defined(__Userspace_os_FreeBSD)
#include <pthread_np.h>
@@ -46,6 +48,10 @@
/* Adapter to translate Unix thread start routines to Windows thread start
* routines.
*/
+#if defined(__MINGW32__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
static DWORD WINAPI
sctp_create_thread_adapter(void *arg) {
start_routine_t start_routine = (start_routine_t)arg;
@@ -75,6 +81,10 @@ sctp_userspace_thread_equal(userland_thread_id_t t1, userland_thread_id_t t2)
return (t1 == t2);
}
+#if defined(__MINGW32__)
+#pragma GCC diagnostic pop
+#endif
+
#else
int
sctp_userspace_thread_create(userland_thread_t *thread, start_routine_t start_routine)
diff --git a/usrsctplib/user_atomic.h b/usrsctplib/user_atomic.h
index 77ea77b6..2e6db048 100755
--- a/usrsctplib/user_atomic.h
+++ b/usrsctplib/user_atomic.h
@@ -78,7 +78,9 @@
}
#endif
#if defined(__Userspace_os_Windows)
+#if !defined(__MINGW32__)
static void atomic_init(void) {} /* empty when we are not using atomic_mtx */
+#endif
#else
static inline void atomic_init(void) {} /* empty when we are not using atomic_mtx */
#endif
diff --git a/usrsctplib/user_environment.h b/usrsctplib/user_environment.h
index 7179f1f8..2b40ceeb 100755
--- a/usrsctplib/user_environment.h
+++ b/usrsctplib/user_environment.h
@@ -62,7 +62,7 @@ extern int ipport_firstauto, ipport_lastauto;
*/
extern int nmbclusters;
-#if !defined(_MSC_VER)
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#endif
diff --git a/usrsctplib/user_mbuf.c b/usrsctplib/user_mbuf.c
index d9f5a5cb..a5037249 100755
--- a/usrsctplib/user_mbuf.c
+++ b/usrsctplib/user_mbuf.c
@@ -313,7 +313,7 @@ m_getm2(struct mbuf *m, int len, int how, short type, int flags, int allonebuf)
mb = m_gethdr(how, type);
MCLGET(mb, how);
size = MCLBYTES;
- //SCTP_BUF_LEN(mb) = MCLBYTES;
+ /* SCTP_BUF_LEN(mb) = MCLBYTES; */
} else if (flags & M_PKTHDR) {
mb = m_gethdr(how, type);
if (len < MHLEN) {
diff --git a/usrsctplib/user_recv_thread.c b/usrsctplib/user_recv_thread.c
index 4d73a312..ae5e517d 100755
--- a/usrsctplib/user_recv_thread.c
+++ b/usrsctplib/user_recv_thread.c
@@ -449,10 +449,8 @@ recv_function_raw6(void *arg)
#else
WSABUF recv_iovec[MAXLEN_MBUF_CHAIN];
int nResult, m_ErrorCode;
- DWORD flags;
DWORD ncounter = 0;
struct sockaddr_in6 from;
- int fromlen;
GUID WSARecvMsg_GUID = WSAID_WSARECVMSG;
LPFN_WSARECVMSG WSARecvMsg;
WSACMSGHDR *cmsgptr;
@@ -494,9 +492,7 @@ recv_function_raw6(void *arg)
}
to_fill = 0;
#if defined(__Userspace_os_Windows)
- flags = 0;
ncounter = 0;
- fromlen = sizeof(struct sockaddr_in6);
memset(&from, 0, sizeof(struct sockaddr_in6));
nResult = WSAIoctl(SCTP_BASE_VAR(userspace_rawsctp6), SIO_GET_EXTENSION_FUNCTION_POINTER,
&WSARecvMsg_GUID, sizeof WSARecvMsg_GUID,
@@ -849,10 +845,10 @@ recv_function_udp6(void *arg)
char cmsgbuf[CMSG_SPACE(sizeof (struct in6_pktinfo))];
int compute_crc = 1;
#if !defined(__Userspace_os_Windows)
- unsigned int ncounter;
struct iovec iov[MAXLEN_MBUF_CHAIN];
struct msghdr msg;
struct cmsghdr *cmsgptr;
+ unsigned int ncounter;
#else
GUID WSARecvMsg_GUID = WSAID_WSARECVMSG;
LPFN_WSARECVMSG WSARecvMsg;
@@ -860,8 +856,8 @@ recv_function_udp6(void *arg)
WSABUF iov[MAXLEN_MBUF_CHAIN];
WSAMSG msg;
int nResult, m_ErrorCode;
- DWORD ncounter;
WSACMSGHDR *cmsgptr;
+ DWORD ncounter;
#endif
sctp_userspace_set_threadname("SCTP/UDP/IP6 rcv");
diff --git a/usrsctplib/user_socket.c b/usrsctplib/user_socket.c
index 01815a9b..6ac0af7e 100755
--- a/usrsctplib/user_socket.c
+++ b/usrsctplib/user_socket.c
@@ -3138,14 +3138,14 @@ sctp_userspace_ip_output(int *result, struct mbuf *o_pak,
if ((!use_udp_tunneling) && (SCTP_BASE_VAR(userspace_rawsctp) != -1)) {
if (WSASendTo(SCTP_BASE_VAR(userspace_rawsctp), (LPWSABUF) send_iovec, iovcnt, &win_sent_len, win_msg_hdr.dwFlags, win_msg_hdr.name, (int) win_msg_hdr.namelen, NULL, NULL) != 0) {
*result = WSAGetLastError();
- } else if (win_sent_len != send_len) {
+ } else if ((int)win_sent_len != send_len) {
*result = WSAGetLastError();
}
}
if ((use_udp_tunneling) && (SCTP_BASE_VAR(userspace_udpsctp) != -1)) {
if (WSASendTo(SCTP_BASE_VAR(userspace_udpsctp), (LPWSABUF) send_iovec, iovcnt, &win_sent_len, win_msg_hdr.dwFlags, win_msg_hdr.name, (int) win_msg_hdr.namelen, NULL, NULL) != 0) {
*result = WSAGetLastError();
- } else if (win_sent_len != send_len) {
+ } else if ((int)win_sent_len != send_len) {
*result = WSAGetLastError();
}
}
@@ -3292,14 +3292,14 @@ void sctp_userspace_ip6_output(int *result, struct mbuf *o_pak,
if ((!use_udp_tunneling) && (SCTP_BASE_VAR(userspace_rawsctp6) != -1)) {
if (WSASendTo(SCTP_BASE_VAR(userspace_rawsctp6), (LPWSABUF) send_iovec, iovcnt, &win_sent_len, win_msg_hdr.dwFlags, win_msg_hdr.name, (int) win_msg_hdr.namelen, NULL, NULL) != 0) {
*result = WSAGetLastError();
- } else if (win_sent_len != send_len) {
+ } else if ((int)win_sent_len != send_len) {
*result = WSAGetLastError();
}
}
if ((use_udp_tunneling) && (SCTP_BASE_VAR(userspace_udpsctp6) != -1)) {
if (WSASendTo(SCTP_BASE_VAR(userspace_udpsctp6), (LPWSABUF) send_iovec, iovcnt, &win_sent_len, win_msg_hdr.dwFlags, win_msg_hdr.name, (int) win_msg_hdr.namelen, NULL, NULL) != 0) {
*result = WSAGetLastError();
- } else if (win_sent_len != send_len) {
+ } else if ((int)win_sent_len != send_len) {
*result = WSAGetLastError();
}
}
@@ -3378,9 +3378,15 @@ usrsctp_dumppacket(const void *buf, size_t len, int outbound)
#ifdef _WIN32
ftime(&tb);
localtime_s(&t, &tb.time);
+#if defined(__MINGW32__)
+ snprintf(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_FORMAT,
+ outbound ? 'O' : 'I',
+ t.tm_hour, t.tm_min, t.tm_sec, (long)(1000 * tb.millitm));
+#else
_snprintf_s(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_LENGTH, PREAMBLE_FORMAT,
outbound ? 'O' : 'I',
t.tm_hour, t.tm_min, t.tm_sec, (long)(1000 * tb.millitm));
+#endif
#else
gettimeofday(&tv, NULL);
sec = (time_t)tv.tv_sec;
@@ -3390,7 +3396,7 @@ usrsctp_dumppacket(const void *buf, size_t len, int outbound)
t.tm_hour, t.tm_min, t.tm_sec, (long)tv.tv_usec);
#endif
pos += PREAMBLE_LENGTH;
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__MINGW32__)
strncpy_s(dump_buf + pos, strlen(HEADER) + 1, HEADER, strlen(HEADER));
#else
strcpy(dump_buf + pos, HEADER);
@@ -3407,7 +3413,7 @@ usrsctp_dumppacket(const void *buf, size_t len, int outbound)
dump_buf[pos++] = low < 10 ? '0' + low : 'a' + (low - 10);
dump_buf[pos++] = ' ';
}
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__MINGW32__)
strncpy_s(dump_buf + pos, strlen(TRAILER) + 1, TRAILER, strlen(TRAILER));
#else
strcpy(dump_buf + pos, TRAILER);
diff --git a/usrsctplib/user_socketvar.h b/usrsctplib/user_socketvar.h
index e00c4c7a..470d781f 100755
--- a/usrsctplib/user_socketvar.h
+++ b/usrsctplib/user_socketvar.h
@@ -102,7 +102,9 @@ struct uio {
*/
#if defined (__Userspace_os_Windows)
#define AF_ROUTE 17
+#if !defined(__MINGW32__)
typedef __int32 pid_t;
+#endif
typedef unsigned __int32 uid_t;
enum sigType {
SIGNAL = 0,