From 6251106d6429de76d99c9521bfc1af22e4470076 Mon Sep 17 00:00:00 2001 From: Felix Weinrank Date: Wed, 31 Jul 2019 10:33:11 +0200 Subject: [PATCH] Allow ekr_loop* ports to be set via command line argument (#332) * 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) * ekr_loop* allowed to specify ports * Buildbot trigger * Update ekr_loop.c * Update ekr_loop.c * Update ekr_loop.c * Update ekr_loop.c * revert changes * test * Revert changes --- programs/ekr_loop.c | 13 ++++++++++--- programs/ekr_loop_offload.c | 13 ++++++++++--- programs/ekr_loop_upcall.c | 13 ++++++++++--- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/programs/ekr_loop.c b/programs/ekr_loop.c index 21e323bf1..df2308864 100644 --- a/programs/ekr_loop.c +++ b/programs/ekr_loop.c @@ -258,7 +258,7 @@ print_addresses(struct socket *sock) #endif int -main(void) +main(int argc, char *argv[]) { struct sockaddr_in sin_s, sin_c; struct sockaddr_conn sconn; @@ -280,6 +280,13 @@ main(void) #ifdef _WIN32 WSADATA wsaData; #endif + uint16_t client_port = 9900; + uint16_t server_port = 9901; + + if (argc == 3) { + client_port = atoi(argv[1]); + server_port = atoi(argv[2]); + } #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { @@ -313,14 +320,14 @@ main(void) #ifdef HAVE_SIN_LEN sin_c.sin_len = sizeof(struct sockaddr_in); #endif - sin_c.sin_port = htons(9900); + sin_c.sin_port = htons(client_port); sin_c.sin_addr.s_addr = htonl(INADDR_LOOPBACK); memset(&sin_s, 0, sizeof(struct sockaddr_in)); sin_s.sin_family = AF_INET; #ifdef HAVE_SIN_LEN sin_s.sin_len = sizeof(struct sockaddr_in); #endif - sin_s.sin_port = htons(9901); + sin_s.sin_port = htons(server_port); sin_s.sin_addr.s_addr = htonl(INADDR_LOOPBACK); #ifdef _WIN32 if (bind(fd_c, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { diff --git a/programs/ekr_loop_offload.c b/programs/ekr_loop_offload.c index a0308c5c9..deb8f1fb9 100644 --- a/programs/ekr_loop_offload.c +++ b/programs/ekr_loop_offload.c @@ -278,7 +278,7 @@ print_addresses(struct socket *sock) #endif int -main(void) +main(int argc, char *argv[]) { struct sockaddr_in sin_s, sin_c; struct sockaddr_conn sconn; @@ -300,6 +300,13 @@ main(void) #ifdef _WIN32 WSADATA wsaData; #endif + uint16_t client_port = 9900; + uint16_t server_port = 9901; + + if (argc == 3) { + client_port = atoi(argv[1]); + server_port = atoi(argv[2]); + } #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { @@ -334,14 +341,14 @@ main(void) #ifdef HAVE_SIN_LEN sin_c.sin_len = sizeof(struct sockaddr_in); #endif - sin_c.sin_port = htons(9899); + sin_c.sin_port = htons(client_port); sin_c.sin_addr.s_addr = htonl(INADDR_LOOPBACK); memset(&sin_s, 0, sizeof(struct sockaddr_in)); sin_s.sin_family = AF_INET; #ifdef HAVE_SIN_LEN sin_s.sin_len = sizeof(struct sockaddr_in); #endif - sin_s.sin_port = htons(9901); + sin_s.sin_port = htons(server_port); sin_s.sin_addr.s_addr = htonl(INADDR_LOOPBACK); #ifdef _WIN32 if (bind(fd_c, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { diff --git a/programs/ekr_loop_upcall.c b/programs/ekr_loop_upcall.c index c5af5f3b9..aab236b4e 100644 --- a/programs/ekr_loop_upcall.c +++ b/programs/ekr_loop_upcall.c @@ -291,7 +291,7 @@ print_addresses(struct socket *sock) #endif int -main(void) +main(int argc, char *argv[]) { struct sockaddr_in sin_s, sin_c; struct sockaddr_conn sconn; @@ -313,6 +313,13 @@ main(void) #ifdef _WIN32 WSADATA wsaData; #endif + uint16_t client_port = 9900; + uint16_t server_port = 9901; + + if (argc == 3) { + client_port = atoi(argv[1]); + server_port = atoi(argv[2]); + } #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { @@ -346,14 +353,14 @@ main(void) #ifdef HAVE_SIN_LEN sin_c.sin_len = sizeof(struct sockaddr_in); #endif - sin_c.sin_port = htons(9900); + sin_c.sin_port = htons(client_port); sin_c.sin_addr.s_addr = htonl(INADDR_LOOPBACK); memset(&sin_s, 0, sizeof(struct sockaddr_in)); sin_s.sin_family = AF_INET; #ifdef HAVE_SIN_LEN sin_s.sin_len = sizeof(struct sockaddr_in); #endif - sin_s.sin_port = htons(9901); + sin_s.sin_port = htons(server_port); sin_s.sin_addr.s_addr = htonl(INADDR_LOOPBACK); #ifdef _WIN32 if (bind(fd_c, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {