diff options
author | Felix Weinrank <info@weinrank.net> | 2019-06-28 17:05:06 +0200 |
---|---|---|
committer | Michael Tüxen <tuexen@fh-muenster.de> | 2019-06-28 17:05:06 +0200 |
commit | 37a8a0a1f9c4b1eb6c00c0043b9eb455facdcad9 (patch) | |
tree | adad5f38ba18d81fa161b083d4f87414431827a9 /programs | |
parent | b78601e565d257a145ac3728baa56458c94108c9 (diff) | |
download | usrsctp-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
Diffstat (limited to 'programs')
-rw-r--r-- | programs/CMakeLists.txt | 11 | ||||
-rw-r--r-- | programs/client_upcall.c | 24 | ||||
-rw-r--r-- | programs/ekr_loop.c | 6 | ||||
-rw-r--r-- | programs/ekr_loop_offload.c | 4 | ||||
-rw-r--r-- | programs/ekr_loop_upcall.c | 7 | ||||
-rw-r--r-- | programs/ekr_peer.c | 2 | ||||
-rw-r--r-- | programs/http_client_upcall.c | 2 | ||||
-rw-r--r-- | programs/programs_helper.h | 2 | ||||
-rw-r--r-- | programs/rtcweb.c | 10 | ||||
-rw-r--r-- | programs/tsctp.c | 19 |
10 files changed, 47 insertions, 40 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; |