import lksctp-tools-1.0.19-1.el9

This commit is contained in:
CentOS Sources 2022-01-11 13:44:05 -05:00 committed by Stepan Oksanichenko
parent f08b655b35
commit 3248be0776
15 changed files with 828 additions and 378 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/lksctp-tools-1.0.18.tar.gz
SOURCES/lksctp-tools-1.0.19.tar.gz

View File

@ -1 +1 @@
9194041a5c08cfcf34f76a4cfa40c68065e5de0a SOURCES/lksctp-tools-1.0.18.tar.gz
c22ac39995984f22471f7a2f09706f92ef811fd8 SOURCES/lksctp-tools-1.0.19.tar.gz

View File

@ -1,10 +0,0 @@
--- lksctp-tools-1.0.16/src/withsctp/withsctp.in.orig 2014-02-18 10:42:49.000000000 +0000
+++ lksctp-tools-1.0.16/src/withsctp/withsctp.in 2014-05-06 12:24:12.931873787 +0100
@@ -1,6 +1,6 @@
#!/bin/sh
# -*- sh -*-
-LIBDIR=@libdir@/@PACKAGE@
+LIBDIR=`rpm --eval "%{_libdir}"`/@PACKAGE@
BINDIR=@bindir@
export LD_PRELOAD=${LIBDIR}/libwithsctp.so.1.0.17
if ! ${BINDIR}/checksctp 2> /dev/null

View File

@ -1,31 +0,0 @@
From e5952a0cdfa8b1b56a5823574835f1f771f14ae0 Mon Sep 17 00:00:00 2001
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Date: Fri, 24 Aug 2018 09:53:00 -0300
Subject: [PATCH 3/3] build: 0b0dce7a36fb actually belongs to v4.19
Typo or not, this commit actually belongs to v4.19 and made me wonder why
on v4.18 it didn't find this feature.
Fixes: 817f0bfa248f ("build: add two defines for Peer Address Parameters extensions on sctp_paddrparams")
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index f55775a..5de5c76 100644
--- a/configure.ac
+++ b/configure.ac
@@ -101,7 +101,7 @@ LKSCTP_CHECK_TYPE([struct sctp_prinfo], [HAVE_SCTP_SENDV])
# added on v4.16, 30f6ebf65bc4
LKSCTP_CHECK_DECL([SCTP_AUTH_NO_AUTH], [HAVE_SCTP_AUTH_NO_AUTH])
-# New members to sctp_paddrparams, added on v4.18, 0b0dce7a36fb
+# New members to sctp_paddrparams, added on v4.19, 0b0dce7a36fb
LKSCTP_CHECK_MEMBER([struct sctp_paddrparams.spp_ipv6_flowlabel],
[HAVE_SCTP_SPP_IPV6_FLOWLABEL])
LKSCTP_CHECK_MEMBER([struct sctp_paddrparams.spp_dscp],
--
1.8.3.1

View File

@ -1,35 +0,0 @@
From 378560050a8f93786c590cc99a55461666205b61 Mon Sep 17 00:00:00 2001
From: Xin Long <lucien.xin@gmail.com>
Date: Fri, 24 Aug 2018 01:13:32 +0800
Subject: [PATCH] build: fix netinet/sctp.h not to be installed
After libcnetinet_HEADERS was set to sctp.h.in, netinet/sctp.h can
no longer be installed into ${includedir}.
Since "AC_CONFIG_HEADERS([src/include/netinet/sctp.h])" is already
added into configure.ac, there's no need to generate sctp.h by
automake.
So we simply set libcnetinet_HEADERS back to sctp.h.
Fixes: 9607dd85e70a ("netinet/sctp.h: dynamically build based on system setup")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
src/include/netinet/Makefile.am | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/include/netinet/Makefile.am b/src/include/netinet/Makefile.am
index ca0aac2..965db8c 100644
--- a/src/include/netinet/Makefile.am
+++ b/src/include/netinet/Makefile.am
@@ -11,5 +11,4 @@ libcnetinetdir = $(includedir)/netinet
# API.
include_HEADERS =
-libcnetinet_HEADERS = sctp.h.in
-BUILT_SOURCES = sctp.h
+libcnetinet_HEADERS = sctp.h
--
1.8.3.1

View File

@ -1,35 +0,0 @@
From 596efd6631b83069d41782fb0ee2d6cf76a50dfa Mon Sep 17 00:00:00 2001
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Date: Fri, 24 Aug 2018 09:52:59 -0300
Subject: [PATCH 2/3] build: fix probing for HAVE_SCTP_SENDV
Somehow it was using a type that is non-existent. The right one is
sctp_prinfo, introduced on ed63afb8a318 ("sctp: add support for PR-SCTP
Information for sendmsg"), present on v4.17.
Fixes: 1b798f1ca3b5 ("build: add define HAVE_SCTP_AUTH_NO_AUTH")
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
---
configure.ac | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index dad658c..f55775a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,9 +94,8 @@ LKSCTP_CHECK_MEMBER([struct sctp_pdapi_event.pdapi_stream],
LKSCTP_CHECK_MEMBER([struct sctp_pdapi_event.pdapi_seq],
[HAVE_SCTP_PDAPI_EVENT_PDAPI_SEQ])
-# PR-SCTP field used to probe for sendv/recvv support, added on v4.17
-LKSCTP_CHECK_MEMBER([struct sendv_prinfo.sctp_prinfo],
- [HAVE_SCTP_SENDV])
+# PR-SCTP struct used to probe for sendv/recvv support, added on v4.17
+LKSCTP_CHECK_TYPE([struct sctp_prinfo], [HAVE_SCTP_SENDV])
# This event indicates that the peer does not support SCTP authentication,
# added on v4.16, 30f6ebf65bc4
--
1.8.3.1

View File

@ -1,52 +0,0 @@
From db6d15bf12a0123e4320e5fd7cb688331dea1bdc Mon Sep 17 00:00:00 2001
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Date: Fri, 24 Aug 2018 09:52:58 -0300
Subject: [PATCH 1/3] build: remove v4.12 secondary defines in favor of
HAVE_SCTP_STREAM_RECONFIG
These were backups, commented out since beginning.
HAVE_SCTP_STREAM_RECONFIG is enough to identify that these are there, so
lets use only one.
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
---
configure.ac | 8 --------
src/include/netinet/sctp.h.in | 2 --
2 files changed, 10 deletions(-)
diff --git a/configure.ac b/configure.ac
index 2ae36ec..dad658c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,14 +82,6 @@ AC_CHECK_FUNCS([bzero gethostbyname gettimeofday memmove memset select socket \
LKSCTP_CHECK_MEMBER([struct sctp_event_subscribe.sctp_stream_reset_event],
[HAVE_SCTP_STREAM_RESET_EVENT])
-# Support for assoc reset event, added on v4.12, c95129d127c6
-#LKSCTP_CHECK_MEMBER([struct sctp_event_subscribe.sctp_assoc_reset_event], \
-# [HAVE_SCTP_ASSOC_RESET_EVENT])
-
-# Support for stream change event, added on v4.12, b444153fb5a6
-#LKSCTP_CHECK_MEMBER([struct sctp_event_subscribe.sctp_stream_change_event], \
-# [HAVE_SCTP_STREAM_CHANGE_EVENT])
-
# RFC 6525 (Stream Reconf), finished on v4.12, c0d8bab6ae51
LKSCTP_CHECK_DECL([SCTP_RECONFIG_SUPPORTED], [HAVE_SCTP_STREAM_RECONFIG])
diff --git a/src/include/netinet/sctp.h.in b/src/include/netinet/sctp.h.in
index c049077..2009f1c 100644
--- a/src/include/netinet/sctp.h.in
+++ b/src/include/netinet/sctp.h.in
@@ -61,8 +61,6 @@ extern "C" {
#define HAVE_SCTP_CANSET_PRIMARY
#undef HAVE_SCTP_STREAM_RESET_EVENT
-#undef HAVE_SCTP_ASSOC_RESET_EVENT
-#undef HAVE_SCTP_STREAM_CHANGE_EVENT
#undef HAVE_SCTP_STREAM_RECONFIG
#undef HAVE_SCTP_PEELOFF_FLAGS
#undef HAVE_SCTP_PDAPI_EVENT_PDAPI_STREAM
--
1.8.3.1

View File

@ -1,71 +0,0 @@
From 7de2bd7e769f10521e3d0c2cb42c6f6b9b505dd0 Mon Sep 17 00:00:00 2001
From: Xin Long <lucien.xin@gmail.com>
Date: Thu, 16 Aug 2018 14:12:30 +0800
Subject: [PATCH] configure.ac: add CURRENT REVISION and AGE for libsctp and
libwithsctp
Add CURRENT REVISION and AGE for libsctp and libwithsctp in
configure.ac to update these 2 library version information.
Compatible with before, they will start from 1:18:0. But each
will get updated according to their definitions in the future.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
configure.ac | 7 +++++++
src/lib/Makefile.am | 7 +++++--
src/withsctp/Makefile.am | 3 ++-
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 275ef4e..2ae36ec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,6 +14,13 @@ dnl reduce clutter in the root; if we put it below AM_INIT_AUTOMAKE,
dnl configure will fail ...)
AC_INIT([lksctp-tools], [1.0.18], [], [], [http://www.lksctp.org/])
+AC_SUBST(LIBSCTP_CURRENT, 1)
+AC_SUBST(LIBSCTP_REVISION, 18)
+AC_SUBST(LIBSCTP_AGE, 0)
+AC_SUBST(LIBWITHSCTP_CURRENT, 1)
+AC_SUBST(LIBWITHSCTP_REVISION, 18)
+AC_SUBST(LIBWITHSCTP_AGE, 0)
+
AC_CONFIG_AUX_DIR(bin)
AC_CONFIG_SRCDIR([src/apps/sctp_darn.c])
AC_CONFIG_HEADERS([config.h])
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 6100c56..1d62175 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -8,5 +8,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include
lib_LTLIBRARIES = libsctp.la
-libsctp_la_SOURCES = bindx.c connectx.c peeloff.c opt_info.c addrs.c sendmsg.c recvmsg.c Versions.map
-libsctp_la_LDFLAGS = -version-info 1:17:0 -Wl,--version-script=$(srcdir)/Versions.map
+libsctp_la_SOURCES = bindx.c connectx.c peeloff.c opt_info.c \
+ addrs.c sendmsg.c recvmsg.c Versions.map
+libsctp_la_LDFLAGS = -version-info \
+ @LIBSCTP_CURRENT@:@LIBSCTP_REVISION@:@LIBSCTP_AGE@ \
+ -Wl,--version-script=$(srcdir)/Versions.map
diff --git a/src/withsctp/Makefile.am b/src/withsctp/Makefile.am
index 70b1cca..1f6ca37 100644
--- a/src/withsctp/Makefile.am
+++ b/src/withsctp/Makefile.am
@@ -14,7 +14,8 @@ AM_CPPFLAGS=-I$(top_srcdir)/src/include
pkglib_LTLIBRARIES = libwithsctp.la
libwithsctp_la_SOURCES = sctp_load_libs.c sctp_socket.c sctp_bind.c \
sctp_sockopt.c sctp_socket.h
-libwithsctp_la_LDFLAGS = -version-info 1:17:0 -ldl
+libwithsctp_la_LDFLAGS = -version-info \
+ @LIBWITHSCTP_CURRENT@:@LIBWITHSCTP_REVISION@:@LIBWITHSCTP_AGE@ -ldl
pkgdoc_DATA = sctp_load_libs.c sctp_socket.c sctp_bind.c \
sctp_sockopt.c sctp_socket.h checksctp.c
--
1.8.3.1

View File

@ -1,43 +0,0 @@
From 7c0ef4d441b3833e721df58f56e2cb8c81b34df4 Mon Sep 17 00:00:00 2001
From: Xin Long <lucien.xin@gmail.com>
Date: Thu, 16 Aug 2018 14:12:01 +0800
Subject: [PATCH] withsctp: use @PACKAGE_VERSION@ in withsctp.h
use @PACKAGE_VERSION@ to replace the hardcode version.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
Makefile.rules | 3 ++-
src/withsctp/withsctp.in | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/Makefile.rules b/Makefile.rules
index 83f5f0c..d3693fa 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -15,4 +15,5 @@
edit = @sed \
-e "s|\@bindir\@|$(bindir)|" \
-e "s|\@libdir\@|$(libdir)|" \
- -e "s|\@PACKAGE\@|$(PACKAGE)|"
+ -e "s|\@PACKAGE\@|$(PACKAGE)|" \
+ -e "s|\@PACKAGE_VERSION\@|$(PACKAGE_VERSION)|"
diff --git a/src/withsctp/withsctp.in b/src/withsctp/withsctp.in
index 7f182ba..fda5ebc 100644
--- a/src/withsctp/withsctp.in
+++ b/src/withsctp/withsctp.in
@@ -2,7 +2,8 @@
# -*- sh -*-
LIBDIR=`rpm --eval "%{_libdir}"`/@PACKAGE@
BINDIR=@bindir@
-export LD_PRELOAD=${LIBDIR}/libwithsctp.so.1.0.17
+LIBVER=@PACKAGE_VERSION@
+export LD_PRELOAD=${LIBDIR}/libwithsctp.so.${LIBVER}
if ! ${BINDIR}/checksctp 2> /dev/null
then
${BINDIR}/checksctp;
--
1.8.3.1

View File

@ -1,85 +0,0 @@
diff --git a/configure.ac b/configure.ac
index 5de5c76..d3e31c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,4 +130,12 @@ AC_ARG_ENABLE(tests,
[enable_tests=yes])
AM_CONDITIONAL(BUILD_TESTS, [test $enable_tests != no])
+# GCC tries to be "helpful" and only issue a warning for unrecognized
+# attributes. So we compile the test with Werror, so that if the
+# attribute is not recognized the compilation fails
+AC_LANG(C)
+AC_LANG_WERROR
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[__attribute__ ((symver ("foo@foo_1"))) void frob (void) { }]])],
+ [AC_DEFINE([HAVE_ATTRIBUTE_SYMVER], [1], [Checking for symver attribute])], [])
+
AC_OUTPUT
diff --git a/src/lib/connectx.c b/src/lib/connectx.c
index 5f4552b..2a21e3a 100644
--- a/src/lib/connectx.c
+++ b/src/lib/connectx.c
@@ -26,6 +26,18 @@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
+#include "config.h"
+
+#define __SYMPFX(pfx, sym) #pfx sym
+#define _SYMPFX(pfx, sym) __SYMPFX(pfx, sym)
+#define SYMPFX(sym) _SYMPFX(__USER_LABEL_PREFIX__, #sym)
+
+#if HAVE_ATTRIBUTE_SYMVER
+#define SYMVER(name, name2) __attribute__ ((symver (SYMPFX(name2))))
+#else
+#define SYMVER(name, name2) __asm__(".symver " SYMPFX(name) "," SYMPFX(name2));
+#endif
+
/* Support the sctp_connectx() interface.
*
@@ -64,6 +76,7 @@ static int __connectx_addrsize(const struct sockaddr *addrs,
}
+SYMVER(__sctp_connectx, sctp_connectx@)
int __sctp_connectx(int fd, struct sockaddr *addrs, int addrcnt)
{
int addrs_size = __connectx_addrsize(addrs, addrcnt);
@@ -75,6 +88,7 @@ int __sctp_connectx(int fd, struct sockaddr *addrs, int addrcnt)
addrs_size);
}
+SYMVER(sctp_connectx_orig, sctp_connectx@VERS_1)
extern int sctp_connectx_orig (int)
__attribute ((alias ("__sctp_connectx")));
@@ -114,6 +128,7 @@ static int __connectx(int fd, struct sockaddr *addrs, socklen_t addrs_size,
addrs, addrs_size);
}
+SYMVER(sctp_connectx2, sctp_connectx@VERS_2)
int sctp_connectx2(int fd, struct sockaddr *addrs, int addrcnt,
sctp_assoc_t *id)
{
@@ -125,6 +140,7 @@ int sctp_connectx2(int fd, struct sockaddr *addrs, int addrcnt,
return __connectx(fd, addrs, addrs_size, id);
}
+SYMVER(sctp_connectx3, sctp_connectx@@VERS_3)
int sctp_connectx3(int fd, struct sockaddr *addrs, int addrcnt,
sctp_assoc_t *id)
{
@@ -179,12 +195,3 @@ int sctp_connectx3(int fd, struct sockaddr *addrs, int addrcnt,
return __connectx(fd, addrs, addrs_size, id);
}
-#define __SYMPFX(pfx, sym) #pfx sym
-#define _SYMPFX(pfx, sym) __SYMPFX(pfx, sym)
-#define SYMPFX(sym) _SYMPFX(__USER_LABEL_PREFIX__, #sym)
-#define SYMVER(name, name2) __asm__(".symver " SYMPFX(name) "," SYMPFX(name2))
-
-SYMVER(__sctp_connectx, sctp_connectx@);
-SYMVER(sctp_connectx_orig, sctp_connectx@VERS_1);
-SYMVER(sctp_connectx2, sctp_connectx@VERS_2);
-SYMVER(sctp_connectx3, sctp_connectx@@VERS_3);

View File

@ -0,0 +1,143 @@
From 166c26dca2a5004f83c5dbc1cb9870667fa8e301 Mon Sep 17 00:00:00 2001
From: Xin Long <lucien.xin@gmail.com>
Date: Wed, 4 Aug 2021 07:29:13 -0400
Subject: [PATCH 1/4] myftp: replace use of deprecated gethostbyname with
getaddrinfo
This patch is to replace use of deprecated gethostbyname with
getaddrinfo in the file src/apps/myftp.c.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
configure.ac | 2 +-
src/apps/myftp.c | 40 ++++++++++++++++++----------------------
2 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/configure.ac b/configure.ac
index 4e2f7b4..8345dab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,7 +75,7 @@ AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_SETVBUF_REVERSED
AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([bzero gethostbyname gettimeofday memmove memset select socket \
+AC_CHECK_FUNCS([bzero getaddrinfo gethostbyname gettimeofday memmove memset select socket \
strchr strerror strtol strtoul])
# Support for stream reset even, added on v4.11, 35ea82d611da
diff --git a/src/apps/myftp.c b/src/apps/myftp.c
index 64fa3f2..473fa03 100644
--- a/src/apps/myftp.c
+++ b/src/apps/myftp.c
@@ -64,11 +64,11 @@ typedef enum { COMMAND_NONE, COMMAND_RECV, COMMAND_SEND } command_t;
#define MAX_NUM_HOST 5
static char *local_host[MAX_NUM_HOST];
static int num_local_host = 0;
-static int local_port = 4444;
+static char *local_port = "4444";
static int buffer_size = BUFSIZE;
static char *remote_host = NULL;
-static int remote_port = 4444;
+static char *remote_port = "4444";
static command_t command = COMMAND_NONE;
static char *filename = NULL;
static int interactive = 0;
@@ -133,7 +133,7 @@ static int parse_arguments(int argc, char *argv[])
break;
case 2: /* local port */
case 'P':
- local_port = atoi(optarg);
+ local_port = optarg;
break;
case 3: /* remote host */
case 'h':
@@ -141,7 +141,7 @@ static int parse_arguments(int argc, char *argv[])
break;
case 4: /* remote port */
case 'p':
- remote_port = atoi(optarg);
+ remote_port = optarg;
break;
case 5:
case 'f':
@@ -236,6 +236,7 @@ emsg(char *prog,char *s)
static int build_endpoint(char *argv0)
{
+ struct addrinfo hints, *rp;
int retval,i;
/* Create the local endpoint. */
@@ -245,22 +246,19 @@ static int build_endpoint(char *argv0)
}
for ( i = 0;i < num_local_host;i++ ) {
- struct hostent *hst;
- struct sockaddr_in laddr;
-
- memset(&laddr, 0, sizeof(laddr));
/* Get the transport address for the local host name. */
fprintf(stderr,"Hostname %d is %s\n",i+1,local_host[i]);
- if ( (hst = gethostbyname(local_host[i])) == NULL ) {
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_INET;
+ hints.ai_protocol = IPPROTO_SCTP;
+ if (getaddrinfo(local_host[i], local_port, &hints, &rp) != 0) {
fprintf(stderr, "%s: bad hostname: %s\n", argv0, local_host[i]);
exit(1);
}
- memcpy(&laddr.sin_addr, hst->h_addr_list[0],sizeof(laddr.sin_addr));
- laddr.sin_port = htons(local_port);
- laddr.sin_family = AF_INET;
/* Bind this socket to the test port. */
- if ( bind(retval, (struct sockaddr *)&laddr, sizeof(laddr)) ) {
+ if (bind(retval, rp->ai_addr, rp->ai_addrlen)) {
emsg(argv0,"bind");
exit(-1);
}
@@ -339,21 +337,19 @@ command_send(char *argv0, int sk)
{
struct msghdr outmsg;
struct iovec iov;
- struct hostent *hst;
- struct sockaddr_in remote_addr;
+ struct addrinfo hints, *rp;
int fd;
int msglen;
int ct;
/* Set up the destination. */
- hst = gethostbyname(remote_host);
- if (hst == NULL || hst->h_length < 1) {
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_INET;
+ hints.ai_protocol = IPPROTO_SCTP;
+ if (getaddrinfo(remote_host, remote_port, &hints, &rp) != 0) {
fprintf(stderr, "%s: bad hostname: %s\n", argv0, remote_host);
exit(1);
}
- memcpy(&remote_addr.sin_addr, hst->h_addr_list[0], sizeof(remote_addr.sin_addr));
- remote_addr.sin_port = htons(remote_port);
- remote_addr.sin_family = AF_INET;
/* Initialize the message struct we use to pass messages to
* the remote socket.
@@ -364,8 +360,8 @@ command_send(char *argv0, int sk)
outmsg.msg_iovlen = 1;
outmsg.msg_control = NULL;
outmsg.msg_controllen = 0;
- outmsg.msg_name = &remote_addr;
- outmsg.msg_namelen = sizeof(remote_addr);
+ outmsg.msg_name = rp->ai_addr;
+ outmsg.msg_namelen = rp->ai_addrlen;
/* open the file */
if ( filename == NULL ) fd = 0;
--
2.27.0

View File

@ -0,0 +1,401 @@
From e44ac51d213c193c894747fef6d61f521d0a7804 Mon Sep 17 00:00:00 2001
From: Xin Long <lucien.xin@gmail.com>
Date: Wed, 4 Aug 2021 07:29:16 -0400
Subject: [PATCH 4/4] sctp_darn: replace use of deprecated gethostbyname with
getaddrinfo
This patch is to replace use of deprecated gethostbyname with
getaddrinfo in the file src/apps/sctp_darn.c.
Note that different from sctp_test, sctp_darn prefers v4 address
to v6 address when getting addrinfo from hostname. To keep the
compatibility, we don't change it.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
configure.ac | 2 +-
src/apps/sctp_darn.c | 246 +++++++++++++------------------------------
2 files changed, 72 insertions(+), 176 deletions(-)
diff --git a/configure.ac b/configure.ac
index 8345dab..28132bf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,7 +75,7 @@ AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_SETVBUF_REVERSED
AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([bzero getaddrinfo gethostbyname gettimeofday memmove memset select socket \
+AC_CHECK_FUNCS([bzero getaddrinfo gettimeofday memmove memset select socket \
strchr strerror strtol strtoul])
# Support for stream reset even, added on v4.11, 35ea82d611da
diff --git a/src/apps/sctp_darn.c b/src/apps/sctp_darn.c
index bcfb822..133c1c6 100644
--- a/src/apps/sctp_darn.c
+++ b/src/apps/sctp_darn.c
@@ -126,7 +126,6 @@ int if_index = 0;
sockaddr_storage_t remote_addr;
sa_family_t ra_family; /* What family is remote_addr? */
int ra_len = 0; /* How long is remote_addr? */
-void *ra_raw; /* This is the addr part of remote_addr. */
int new_connection = 1;
enum inter_cmd_num {
@@ -491,49 +490,29 @@ int
build_endpoint(char *argv0, int portnum)
{
int retval;
- struct hostent *hst;
+ struct addrinfo hints, *rp;
sockaddr_storage_t local_addr;
- sa_family_t la_family; /* What family is local_addr? */
- int la_len; /* How long is local_addr? */
- void *la_raw; /* This is the addr part of local_addr. */
int error;
struct sctp_event_subscribe subscribe;
/* Get the transport address for the local host name. */
- hst = gethostbyname(local_host);
- if (hst == NULL) {
- hst = gethostbyname2(local_host, AF_INET6);
- }
-
- if (hst == NULL || hst->h_length < 1) {
- fprintf(stderr, "%s: bad hostname: %s\n", argv0, local_host);
- exit(1);
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_INET;
+ hints.ai_protocol = IPPROTO_SCTP;
+ if (getaddrinfo(local_host, NULL, &hints, &rp) != 0) {
+ hints.ai_family = AF_INET6;
+ if (getaddrinfo(local_host, NULL, &hints, &rp) != 0) {
+ fprintf(stderr, "%s: bad hostname: %s\n", argv0, local_host);
+ exit(1);
+ }
}
-
- la_family = hst->h_addrtype;
- switch (la_family) {
- case AF_INET:
- la_len = sizeof(local_addr.v4);
- la_raw = &local_addr.v4.sin_addr;
- local_addr.v4.sin_port = htons(portnum);
- local_addr.v4.sin_family = AF_INET;
- break;
- case AF_INET6:
- la_len = sizeof(local_addr.v6);
- la_raw = &local_addr.v6.sin6_addr;
- local_addr.v6.sin6_port = htons(portnum);
- local_addr.v6.sin6_family = AF_INET6;
+ memcpy(&local_addr, rp->ai_addr, rp->ai_addrlen);
+ local_addr.v4.sin_port = htons(portnum); /* equal to v6.sin6_port */
+ if (rp->ai_family == AF_INET6)
local_addr.v6.sin6_scope_id = if_index;
- break;
- default:
- fprintf(stderr, "Invalid address type.\n");
- exit(1);
- break;
- }
- memcpy(la_raw, hst->h_addr_list[0], hst->h_length);
/* Create the local endpoint. */
- retval = socket(la_family, socket_type, IPPROTO_SCTP);
+ retval = socket(rp->ai_family, socket_type, IPPROTO_SCTP);
if (retval < 0) {
fprintf(stderr, "%s: failed to create socket: %s.\n",
argv0, strerror(errno));
@@ -553,7 +532,7 @@ build_endpoint(char *argv0, int portnum)
}
/* Bind this socket to the test port. */
- error = bind(retval, &local_addr.sa, la_len);
+ error = bind(retval, &local_addr.sa, rp->ai_addrlen);
if (error != 0) {
fprintf(stderr, "%s: can not bind to %s:%d: %s.\n",
argv0, local_host, portnum,
@@ -778,7 +757,7 @@ command_send(char *argv0, int *skp)
struct iovec iov;
int done = 0;
char message[REALLY_BIG];
- struct hostent *hst;
+ struct addrinfo hints, *rp;
int c;
struct sockaddr *addrs;
int msglen;
@@ -787,38 +766,21 @@ command_send(char *argv0, int *skp)
/* Set up the destination. */
if (remote_host != NULL) {
- hst = gethostbyname(remote_host);
- if (hst == NULL) {
- hst = gethostbyname2(remote_host, AF_INET6);
- }
-
- if (hst == NULL || hst->h_length < 1) {
- fprintf(stderr, "%s: bad hostname: %s\n",
- argv0, remote_host);
- exit(1);
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_INET;
+ hints.ai_protocol = IPPROTO_SCTP;
+ if (getaddrinfo(remote_host, NULL, &hints, &rp) != 0) {
+ hints.ai_family = AF_INET6;
+ if (getaddrinfo(remote_host, NULL, &hints, &rp) != 0) {
+ fprintf(stderr, "%s: bad hostname: %s\n", argv0, remote_host);
+ exit(1);
+ }
}
-
- ra_family = hst->h_addrtype;
- switch (ra_family) {
- case AF_INET:
- ra_len = sizeof(remote_addr.v4);
- ra_raw = &remote_addr.v4.sin_addr;
- remote_addr.v4.sin_port = htons(remote_port);
- remote_addr.v4.sin_family = AF_INET;
- break;
- case AF_INET6:
- ra_len = sizeof(remote_addr.v6);
- ra_raw = &remote_addr.v6.sin6_addr;
- remote_addr.v6.sin6_port = htons(remote_port);
- remote_addr.v6.sin6_family = AF_INET6;
+ memcpy(&remote_addr, rp->ai_addr, rp->ai_addrlen);
+ remote_addr.v4.sin_port = htons(remote_port); /* equal to v6.sin6_port */
+ if (rp->ai_family == AF_INET6)
remote_addr.v6.sin6_scope_id = if_index;
- break;
- default:
- fprintf(stderr, "Invalid address type.\n");
- exit(1);
- break;
- }
- memcpy(ra_raw, hst->h_addr_list[0], hst->h_length);
+ ra_len = rp->ai_addrlen;
}
/* Initialize the global value for interactive mode functions. */
@@ -1041,7 +1003,7 @@ command_poll(char *argv0)
fd_set *xbitsp = NULL;
struct msghdr outmsg;
- struct hostent *hst;
+ struct addrinfo hints, *rp;
int msglen;
int temp_fd, temp_set;
@@ -1050,38 +1012,20 @@ command_poll(char *argv0)
/* If a remote host is specified, initialize the destination. */
if (remote_host) {
/* Set up the destination. */
- hst = gethostbyname(remote_host);
- if (hst == NULL) {
- hst = gethostbyname2(remote_host, AF_INET6);
- }
-
- if (hst == NULL || hst->h_length < 1) {
- fprintf(stderr, "%s: bad hostname: %s\n",
- argv0, remote_host);
- exit(1);
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_INET;
+ hints.ai_protocol = IPPROTO_SCTP;
+ if (getaddrinfo(remote_host, NULL, &hints, &rp) != 0) {
+ hints.ai_family = AF_INET6;
+ if (getaddrinfo(remote_host, NULL, &hints, &rp) != 0) {
+ fprintf(stderr, "%s: bad hostname: %s\n", argv0, remote_host);
+ exit(1);
+ }
}
-
- ra_family = hst->h_addrtype;
- switch (ra_family) {
- case AF_INET:
- ra_len = sizeof(remote_addr.v4);
- ra_raw = &remote_addr.v4.sin_addr;
- remote_addr.v4.sin_port = htons(remote_port);
- remote_addr.v4.sin_family = AF_INET;
- break;
- case AF_INET6:
- ra_len = sizeof(remote_addr.v6);
- ra_raw = &remote_addr.v6.sin6_addr;
- remote_addr.v6.sin6_port = htons(remote_port);
- remote_addr.v6.sin6_family = AF_INET6;
+ memcpy(&remote_addr, rp->ai_addr, rp->ai_addrlen);
+ remote_addr.v4.sin_port = htons(remote_port); /* equal to v6.sin6_port */
+ if (rp->ai_family == AF_INET6)
remote_addr.v6.sin6_scope_id = if_index;
- break;
- default:
- fprintf(stderr, "Invalid address type.\n");
- exit(1);
- break;
- }
- memcpy(ra_raw, hst->h_addr_list[0], hst->h_length);
/* Initialize the message struct we use to pass messages to
* the remote socket.
@@ -1091,7 +1035,7 @@ command_poll(char *argv0)
outmsg.msg_control = NULL;
outmsg.msg_controllen = 0;
outmsg.msg_name = &remote_addr;
- outmsg.msg_namelen = ra_len;
+ outmsg.msg_namelen = rp->ai_addrlen;
outmsg.msg_flags = 0;
}
@@ -1406,14 +1350,11 @@ struct sockaddr *
append_addr(const char *parm, struct sockaddr *addrs, int *ret_count)
{
struct sockaddr *new_addrs = NULL;
+ struct addrinfo hints, *res, *rp;
void *aptr;
struct sockaddr *sa_addr;
struct sockaddr_in *b4ap;
struct sockaddr_in6 *b6ap;
- struct hostent *hst4 = NULL;
- struct hostent *hst6 = NULL;
- int i4 = 0;
- int i6 = 0;
int j;
int orig_count = *ret_count;
int count = orig_count;
@@ -1421,28 +1362,17 @@ append_addr(const char *parm, struct sockaddr *addrs, int *ret_count)
if (!parm)
return NULL;
- /* Get the entries for this host. */
- hst4 = gethostbyname(parm);
- hst6 = gethostbyname2(parm, AF_INET6);
- if ((NULL == hst4 || hst4->h_length < 1)
- && (NULL == hst6 || hst6->h_length < 1)) {
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_protocol = IPPROTO_SCTP;
+ if (getaddrinfo(parm, NULL, &hints, &res) != 0) {
fprintf(stderr, "bad hostname: %s\n", parm);
goto finally;
}
-
- /* Figure out the number of addresses. */
- if (NULL != hst4) {
- for (i4 = 0; NULL != hst4->h_addr_list[i4]; ++i4) {
- count++;
- }
- }
- if (NULL != hst6) {
- for (i6 = 0; NULL != hst6->h_addr_list[i6]; ++i6) {
- count++;
- }
- }
+ for (rp = res; rp != NULL; rp = rp->ai_next)
+ count++;
/* Expand memory for the new addresses. Assume all the addresses
* are v6 addresses.
@@ -1473,31 +1403,14 @@ append_addr(const char *parm, struct sockaddr *addrs, int *ret_count)
}
/* Put the new addresses away. */
- if (NULL != hst4) {
- for (j = 0; j < i4; ++j) {
- b4ap = (struct sockaddr_in *)aptr;
- memset(b4ap, 0x00, sizeof(*b4ap));
- b4ap->sin_family = AF_INET;
- b4ap->sin_port = htons(local_port);
- bcopy(hst4->h_addr_list[j], &b4ap->sin_addr,
- hst4->h_length);
-
- aptr += sizeof(struct sockaddr_in);
- } /* for (loop through the new v4 addresses) */
- }
-
- if (NULL != hst6) {
- for (j = 0; j < i6; ++j) {
- b6ap = (struct sockaddr_in6 *)aptr;
- memset(b6ap, 0x00, sizeof(*b6ap));
- b6ap->sin6_family = AF_INET6;
- b6ap->sin6_port = htons(local_port);
+ for (rp = res; rp != NULL; rp = rp->ai_next) {
+ b4ap = (struct sockaddr_in *)aptr;
+ b6ap = (struct sockaddr_in6 *)aptr;
+ bcopy(rp->ai_addr, aptr, rp->ai_addrlen);
+ b4ap->sin_port = htons(local_port); /* equal to b6ap.v6.sin6_port */
+ if (rp->ai_family == AF_INET6)
b6ap->sin6_scope_id = if_index;
- bcopy(hst6->h_addr_list[j], &b6ap->sin6_addr,
- hst6->h_length);
-
- aptr += sizeof(struct sockaddr_in6);
- } /* for (loop through the new v6 addresses) */
+ aptr += rp->ai_addrlen;
}
finally:
@@ -2123,7 +2036,7 @@ shutdown_func(char *argv0, int *skp, int shutdown_type)
struct cmsghdr *cmsg;
int error=0, bytes_sent;
struct sctp_sndrcvinfo *sinfo;
- struct hostent *hst;
+ struct addrinfo hints, *rp;
char *sd_type;
int sk = *skp;
@@ -2142,37 +2055,20 @@ shutdown_func(char *argv0, int *skp, int shutdown_type)
if (socket_type == SOCK_SEQPACKET) {
/* Set up the destination. */
if (remote_host) {
- hst = gethostbyname(remote_host);
- if (hst == NULL) {
- hst = gethostbyname2(remote_host, AF_INET6);
- }
-
- if (hst == NULL || hst->h_length < 1) {
- fprintf(stderr, "%s: bad hostname: %s\n",
- argv0, remote_host);
- exit(1);
- }
-
- ra_family = hst->h_addrtype;
- switch (ra_family) {
- case AF_INET:
- ra_len = sizeof(remote_addr.v4);
- ra_raw = &remote_addr.v4.sin_addr;
- remote_addr.v4.sin_port = htons(remote_port);
- remote_addr.v4.sin_family = AF_INET;
- break;
- case AF_INET6:
- ra_len = sizeof(remote_addr.v6);
- ra_raw = &remote_addr.v6.sin6_addr;
- remote_addr.v6.sin6_port = htons(remote_port);
- remote_addr.v6.sin6_family = AF_INET6;
- break;
- default:
- fprintf(stderr, "Invalid address type.\n");
- exit(1);
- break;
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_INET;
+ hints.ai_protocol = IPPROTO_SCTP;
+ if (getaddrinfo(remote_host, NULL, &hints, &rp) != 0) {
+ hints.ai_family = AF_INET6;
+ if (getaddrinfo(remote_host, NULL, &hints, &rp) != 0) {
+ fprintf(stderr, "%s: bad hostname: %s\n",
+ argv0, remote_host);
+ exit(1);
+ }
}
- memcpy(ra_raw, hst->h_addr_list[0], hst->h_length);
+ memcpy(&remote_addr, rp->ai_addr, rp->ai_addrlen);
+ remote_addr.v4.sin_port = htons(remote_port); /* equal to v6.sin6_port */
+ ra_len = rp->ai_addrlen;
}
/* Initialize the message struct we use to pass messages to
--
2.27.0

View File

@ -0,0 +1,116 @@
From ecdb9294c5dce938ef7c488404be65d23552fb18 Mon Sep 17 00:00:00 2001
From: Xin Long <lucien.xin@gmail.com>
Date: Wed, 4 Aug 2021 07:29:15 -0400
Subject: [PATCH 3/4] sctp_test: replace use of deprecated gethostbyname with
getaddrinfo
This patch is to replace use of deprecated gethostbyname with
getaddrinfo in the file src/apps/sctp_test.c.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
src/apps/sctp_test.c | 63 +++++++++++---------------------------------
1 file changed, 16 insertions(+), 47 deletions(-)
diff --git a/src/apps/sctp_test.c b/src/apps/sctp_test.c
index cd7654b..e382804 100644
--- a/src/apps/sctp_test.c
+++ b/src/apps/sctp_test.c
@@ -487,14 +487,11 @@ struct sockaddr *
append_addr(const char *parm, struct sockaddr *addrs, int *ret_count)
{
struct sockaddr *new_addrs = NULL;
+ struct addrinfo hints, *res, *rp;
void *aptr;
struct sockaddr *sa_addr;
struct sockaddr_in *b4ap;
struct sockaddr_in6 *b6ap;
- struct hostent *hst4 = NULL;
- struct hostent *hst6 = NULL;
- int i4 = 0;
- int i6 = 0;
int j;
int orig_count = *ret_count;
int count = orig_count;
@@ -514,27 +511,16 @@ append_addr(const char *parm, struct sockaddr *addrs, int *ret_count)
}
}
- /* Get the entries for this host. */
- hst4 = gethostbyname(ipaddr);
- hst6 = gethostbyname2(ipaddr, AF_INET6);
-
- if ((NULL == hst4 || hst4->h_length < 1)
- && (NULL == hst6 || hst6->h_length < 1)) {
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_protocol = IPPROTO_SCTP;
+ if (getaddrinfo(ipaddr, NULL, &hints, &res) != 0) {
fprintf(stderr, "bad hostname: %s\n", ipaddr);
goto finally;
}
- /* Figure out the number of addresses. */
- if (NULL != hst4) {
- for (i4 = 0; NULL != hst4->h_addr_list[i4]; ++i4) {
- count++;
- }
- }
- if (NULL != hst6) {
- for (i6 = 0; NULL != hst6->h_addr_list[i6]; ++i6) {
- count++;
- }
- }
+ for (rp = res; rp != NULL; rp = rp->ai_next)
+ count++;
/* Expand memory for the new addresses. Assume all the addresses
* are v6 addresses.
@@ -565,34 +551,17 @@ append_addr(const char *parm, struct sockaddr *addrs, int *ret_count)
}
/* Put the new addresses away. */
- if (NULL != hst4) {
- for (j = 0; j < i4; ++j) {
- b4ap = (struct sockaddr_in *)aptr;
- memset(b4ap, 0x00, sizeof(*b4ap));
- b4ap->sin_family = AF_INET;
- b4ap->sin_port = htons(local_port);
- bcopy(hst4->h_addr_list[j], &b4ap->sin_addr,
- hst4->h_length);
-
- aptr += sizeof(struct sockaddr_in);
- } /* for (loop through the new v4 addresses) */
- }
-
- if (NULL != hst6) {
- for (j = 0; j < i6; ++j) {
- b6ap = (struct sockaddr_in6 *)aptr;
- memset(b6ap, 0x00, sizeof(*b6ap));
- b6ap->sin6_family = AF_INET6;
- b6ap->sin6_port = htons(local_port);
+ for (rp = res; rp != NULL; rp = rp->ai_next) {
+ b4ap = (struct sockaddr_in *)aptr;
+ b6ap = (struct sockaddr_in6 *)aptr;
+ bcopy(rp->ai_addr, aptr, rp->ai_addrlen);
+ b4ap->sin_port = htons(local_port); /* equal to b6ap.v6.sin6_port */
+ if (rp->ai_family == AF_INET6) {
b6ap->sin6_scope_id = if_index;
- bcopy(hst6->h_addr_list[j], &b6ap->sin6_addr,
- hst6->h_length);
- if (!ifindex) {
+ if (!ifindex)
b6ap->sin6_scope_id = ifindex;
- }
-
- aptr += sizeof(struct sockaddr_in6);
- } /* for (loop through the new v6 addresses) */
+ }
+ aptr += rp->ai_addrlen;
}
finally:
--
2.27.0

View File

@ -0,0 +1,156 @@
From 469cf426bc292b6d23770ce930577c1997654229 Mon Sep 17 00:00:00 2001
From: Xin Long <lucien.xin@gmail.com>
Date: Wed, 4 Aug 2021 07:29:14 -0400
Subject: [PATCH 2/4] sctp_xconnect: replace use of deprecated gethostbyname
with getaddrinfo
This patch is to replace use of deprecated gethostbyname with
getaddrinfo in the file src/apps/sctp_xconnect.c.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
src/apps/sctp_xconnect.c | 72 +++++++++++++++++-----------------------
1 file changed, 31 insertions(+), 41 deletions(-)
diff --git a/src/apps/sctp_xconnect.c b/src/apps/sctp_xconnect.c
index 6759c0e..5cd1049 100644
--- a/src/apps/sctp_xconnect.c
+++ b/src/apps/sctp_xconnect.c
@@ -63,13 +63,13 @@ int TST_CNT = 0;
int mode = NOT_DEFINED;
-int assoc_num,
- remote_port,
- local_port;
+int assoc_num;
int active = 0;
-char *local_host = NULL;
-char *remote_host = NULL;
+char *local_host;
+char *remote_host;
+char *local_port;
+char *remote_port;
sockaddr_storage_t client_loop,
server_loop;
struct hostent *hst;
@@ -102,6 +102,7 @@ void usage(char *argv0)
/* Parse command line options */
void parse_arguments(int argc, char*argv[]) {
+ struct addrinfo hints, *rp;
int c;
while ((c = getopt(argc, argv, ":H:P:ach:ln:p:")) >= 0) {
@@ -110,7 +111,7 @@ void parse_arguments(int argc, char*argv[]) {
local_host = optarg;
break;
case 'P':
- local_port = atoi(optarg);
+ local_port = optarg;
break;
case 'c':
if (mode == NOT_DEFINED)
@@ -138,7 +139,7 @@ void parse_arguments(int argc, char*argv[]) {
assoc_num = atoi(optarg);
break;
case 'p':
- remote_port = atoi(optarg);
+ remote_port = optarg;
break;
default:
usage(argv[0]);
@@ -146,6 +147,9 @@ void parse_arguments(int argc, char*argv[]) {
}
} /* while() */
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_INET;
+ hints.ai_protocol = IPPROTO_SCTP;
if (mode == CLIENT) {
if (assoc_num) {
if (assoc_num > MAXCLIENTNUM) {
@@ -160,13 +164,13 @@ void parse_arguments(int argc, char*argv[]) {
assoc_num = 1;
if (remote_host && remote_port) {
- hst = gethostbyname(remote_host);
-
- memcpy(&server_loop.v4.sin_addr, hst->h_addr_list[0],
- sizeof(server_loop.v4.sin_addr));
-
- server_loop.v4.sin_family = AF_INET;
-server_loop.v4.sin_port = htons(remote_port);
+ if (getaddrinfo(remote_host, remote_port, &hints, &rp) != 0) {
+ printf("%s: bad remote hostname or port: %s, %s\n",
+ argv[0], remote_host, remote_port);
+ usage(argv[0]);
+ exit(0);
+ }
+ memcpy(&server_loop, rp->ai_addr, rp->ai_addrlen);
} else {
printf("Remote host and remote port must be defined "
"in client mode\n");
@@ -174,20 +178,12 @@ server_loop.v4.sin_port = htons(remote_port);
exit(0);
}
- if (local_host) {
- hst = gethostbyname(local_host);
-
- memcpy(&client_loop.v4.sin_addr, hst->h_addr_list[0],
- sizeof(client_loop.v4.sin_addr));
- } else
- client_loop.v4.sin_addr.s_addr = INADDR_ANY;
-
- if (local_port)
- client_loop.v4.sin_port = htons(local_port);
- else
- client_loop.v4.sin_port = 0;
-
- client_loop.v4.sin_family = AF_INET;
+ if (getaddrinfo(local_host, local_port, &hints, &rp) != 0) {
+ printf("%s: bad local hostname or port: %s, %s\n",
+ argv[0], local_host, local_port);
+ exit(0);
+ }
+ memcpy(&client_loop, rp->ai_addr, rp->ai_addrlen);
} else if (mode == SERVER) {
if (active) {
printf("This option if for client use only");
@@ -201,23 +197,17 @@ server_loop.v4.sin_port = htons(remote_port);
exit(0);
}
- if (local_host) {
- hst = gethostbyname(local_host);
-
- memcpy(&server_loop.v4.sin_addr, hst->h_addr_list[0],
- sizeof(server_loop.v4.sin_addr));
- } else
- server_loop.v4.sin_addr.s_addr = INADDR_ANY;
-
- if (local_port)
- server_loop.v4.sin_port = htons(local_port);
- else {
+ if (!local_port) {
printf("Specify a local port in server mode.\n");
usage(argv[0]);
exit(0);
}
-
- server_loop.v4.sin_family = AF_INET;
+ if (getaddrinfo(local_host, local_port, &hints, &rp) != 0) {
+ printf("%s: bad local hostname or port: %s, %s\n",
+ argv[0], local_host, local_port);
+ exit(0);
+ }
+ memcpy(&server_loop, rp->ai_addr, rp->ai_addrlen);
} else {
printf("Must assisgn a client or server mode.\n");
usage(argv[0]);
--
2.27.0

View File

@ -1,21 +1,17 @@
Name: lksctp-tools
Summary: User-space access to Linux Kernel SCTP
Version: 1.0.18
Release: 11%{?dist}
Version: 1.0.19
Release: 1%{?dist}
# src/apps/bindx_test.C is GPLv2, I've asked upstream for clarification
License: GPLv2 and GPLv2+ and LGPLv2 and MIT
Group: System Environment/Libraries
URL: http://lksctp.sourceforge.net
Source0: https://github.com/sctp/lksctp-tools/archive/%{name}-%{version}.tar.gz
Patch0: lksctp-tools-1.0.16-libdir.patch
Patch1: lksctp-tools-1.0.18-withsctp-use-PACKAGE_VERSION-in-withsctp.h.patch
Patch2: lksctp-tools-1.0.18-configure.ac-add-CURRENT-REVISION-and-AGE-for-libsct.patch
Patch3: lksctp-tools-1.0.18-build-fix-netinet-sctp.h-not-to-be-installed.patch
Patch4: lksctp-tools-1.0.18-build-remove-v4.12-secondary-defines-in-favor-of-HAV.patch
Patch5: lksctp-tools-1.0.18-build-fix-probing-for-HAVE_SCTP_SENDV.patch
Patch6: lksctp-tools-1.0.18-build-0b0dce7a36fb-actually-belongs-to-v4.19.patch
Patch7: lksctp-tools-symver.patch
Patch0: myftp-replace-use-of-deprecated-gethostbyname-with-g.patch
Patch1: sctp_xconnect-replace-use-of-deprecated-gethostbynam.patch
Patch2: sctp_test-replace-use-of-deprecated-gethostbyname-wi.patch
Patch3: sctp_darn-replace-use-of-deprecated-gethostbyname-wi.patch
BuildRequires: libtool, automake, autoconf, make
%description
@ -54,10 +50,6 @@ Drafts).
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%build
[ ! -x ./configure ] && sh bootstrap
@ -94,6 +86,10 @@ find $RPM_BUILD_ROOT -type f -name "*.la" -delete
%doc doc/*.txt
%changelog
* Wed Nov 17 2021 Xin Long <lxin@redhat.com> - 1.0.19-1
- Rebase to 1.0.19 and append the fixes for gethostbyname.
Related: rhbz#1982820
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.0.18-11
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688