Index: head/sysutils/socket/Makefile =================================================================== --- head/sysutils/socket/Makefile +++ head/sysutils/socket/Makefile @@ -2,18 +2,16 @@ # $FreeBSD$ PORTNAME= socket -PORTVERSION= 1.1 -PORTREVISION= 2 +PORTVERSION= 1.2 +#PORTREVISION= 1 CATEGORIES= sysutils net ipv6 -MASTER_SITES= http://wolfram.schneider.org/src/\ - http://people.freebsd.org/~wosch/src/ +MASTER_SITES= https://wolfram.schneider.org/src/ LOCAL/wosch MAINTAINER= wosch@FreeBSD.org COMMENT= Create TCP socket and connect to stdin/out LICENSE= GPLv1 -MAKE_ENV+= SWITCHES="-DUSE_INET6 -DHAVE_SYS_PARAM_H -Wall" PLIST_FILES= bin/socket man/man1/socket.1.gz OPTIONS_DEFINE= DOCS Index: head/sysutils/socket/distinfo =================================================================== --- head/sysutils/socket/distinfo +++ head/sysutils/socket/distinfo @@ -1,2 +1,3 @@ -SHA256 (socket-1.1.tar.gz) = 628dbfac1cb76943b74a19f34ab69bdb496a94a403cfdd489deac4de23ea46f8 -SIZE (socket-1.1.tar.gz) = 14426 +TIMESTAMP = 1517137172 +SHA256 (socket-1.2.tar.gz) = 4a2dc2ebd1c60fa644e96382bce17e878409e585319960326a0b7c6750661c8f +SIZE (socket-1.2.tar.gz) = 16989 Index: head/sysutils/socket/files/patch-Headerfix =================================================================== --- head/sysutils/socket/files/patch-Headerfix +++ head/sysutils/socket/files/patch-Headerfix @@ -1,218 +0,0 @@ ---- Makefile.orig Thu Sep 10 16:59:31 1992 -+++ Makefile Wed Aug 14 16:57:57 1996 -@@ -43,7 +43,8 @@ - ### CDC 4680 EP/IX: (I know it *has* setsid(2), but not with bsd43) - # SWITCHES = -systype bsd43 -DNOSETSID - -- -+# FreeBSD 2.x (4.4BSD) -+SWITCHES=-DHAVE_SYS_PARAM_H -Wall - - ### It should not be necessary to change anything below this line. - ################################################################## ---- README.orig Wed Sep 9 16:45:16 1992 -+++ README Wed Aug 14 16:57:58 1996 -@@ -166,4 +166,4 @@ - 1000 Berlin 10 - Germany - -- -+Juergen Nickelsen ---- globals.h.orig Sun Aug 30 21:04:27 1992 -+++ globals.h Wed Aug 14 16:57:58 1996 -@@ -8,6 +8,11 @@ - */ - - #include "patchlevel.h" -+ -+#if HAVE_SYS_PARAM_H -+# include -+#endif -+ - - /* globals for socket */ - -@@ -49,4 +54,7 @@ - extern int crlfflag ; - extern int active_socket ; - extern char *progname ; --extern char *sys_errlist[], *sys_siglist[] ; -+ -+#if !(defined(BSD) && (BSD >=199306)) -+ extern char *sys_errlist[], *sys_siglist[] ; -+#endif ---- io.c.orig Sun Aug 30 19:15:26 1992 -+++ io.c Wed Aug 14 16:57:58 1996 -@@ -16,6 +16,8 @@ - #endif - #include - #include -+#include -+#include - #include "globals.h" - - /* read from from, write to to. select(2) has returned, so input -@@ -90,7 +92,7 @@ - - /* all IO to and from the socket is handled here. The main part is - * a loop around select(2). */ --do_io() -+void do_io() - { - fd_set readfds ; - int fdset_width ; ---- siglist.c.orig Sun Aug 30 15:50:48 1992 -+++ siglist.c Wed Aug 14 16:57:58 1996 -@@ -32,12 +32,18 @@ - # endif /* !_NSIG */ - #endif /* !NSIG */ - --char *sys_siglist[NSIG]; -+#if HAVE_SYS_PARAM_H -+# include -+#endif - -+#if !(defined(BSD) && (BSD >=199306)) -+char *sys_siglist[NSIG]; -+#endif - extern *malloc (); - --initialize_siglist () -+void initialize_siglist () - { -+#if !(defined(BSD) && (BSD >=199306)) - register int i; - - for (i = 0; i < NSIG; i++) -@@ -219,4 +225,5 @@ - sprintf (sys_siglist[i], "Unknown Signal #%d", i); - } - } -+#endif /* !(defined(BSD) && (BSD >=199306)) */ - } ---- socket.1.orig Wed Sep 9 16:38:19 1992 -+++ socket.1 Wed Aug 14 16:57:58 1996 -@@ -158,4 +158,4 @@ - .SH VERSION - This manual page describes Socket\-1.1. - .SH AUTHOR --Juergen Nickelsen -+Juergen Nickelsen ---- socket.c.orig Wed Sep 9 16:14:34 1992 -+++ socket.c Wed Aug 14 16:57:59 1996 -@@ -18,6 +18,8 @@ - #else - #include - #endif -+#include -+#include - #include "globals.h" - - /* global variables */ -@@ -37,6 +39,8 @@ - void server A((int port, char *service_name)) ; - void handle_server_connection A((void)) ; - void client A((char *host, int port, char *service_name)) ; -+extern void init_signals A((void)) ; -+extern void do_io A((void)) ; - - int main(argc, argv) - int argc ; -@@ -46,7 +50,7 @@ - int opt ; /* option character */ - int error = 0 ; /* usage error occurred */ - extern int optind ; /* from getopt() */ -- char *host ; /* name of remote host */ -+ /* char *host ; */ /* name of remote host */ - int port ; /* port number for socket */ - char *service_name ; /* name of service for port */ - -@@ -58,7 +62,7 @@ - - /* set up progname for later use */ - progname = argv[0] ; -- if (cp = strrchr(progname, '/')) progname = cp + 1 ; -+ if ((cp = strrchr(progname, '/'))) progname = cp + 1 ; - - /* parse options */ - while ((opt = getopt(argc, argv, "bcflp:qrsvw?")) != -1) { -@@ -185,15 +189,15 @@ - long norder ; - char dotted[20] ; - -- he = gethostbyaddr(&sa.sin_addr.s_addr, -+ he = gethostbyaddr((char *)&sa.sin_addr.s_addr, - sizeof(sa.sin_addr.s_addr), AF_INET) ; - if (!he) { - norder = htonl(sa.sin_addr.s_addr) ; - sprintf(dotted, "%d.%d.%d.%d", -- (norder >> 24) & 0xff, -- (norder >> 16) & 0xff, -- (norder >> 8) & 0xff, -- norder & 0xff) ; -+ (int)((norder >> 24) & 0xff), -+ (int)((norder >> 16) & 0xff), -+ (int)((norder >> 8) & 0xff), -+ (int)(norder & 0xff)) ; - } - fprintf(stderr, "connection from %s\n", - (he ? he->h_name : dotted)) ; ---- socketp.c.orig Sun Aug 9 03:41:42 1992 -+++ socketp.c Wed Aug 14 16:57:59 1996 -@@ -11,10 +11,16 @@ - #include - #include - #include -+#include - #include - #include -+#include -+#include -+#include - #include "globals.h" - -+extern int is_number A((char *)); -+ - /* - * create a server socket on PORT accepting QUEUE_LENGTH connections - */ -@@ -52,7 +58,7 @@ - { - struct sockaddr_in sa ; - struct hostent *hp ; -- int a, s ; -+ int s ; - long addr ; - - -@@ -76,7 +82,7 @@ - if ((s = socket(sa.sin_family, SOCK_STREAM, 0)) < 0) { /* get socket */ - return -1 ; - } -- if (connect(s, &sa, sizeof(sa)) < 0) { /* connect */ -+ if (connect(s, (struct sockaddr *)&sa, sizeof(sa)) < 0) { /* connect */ - close(s) ; - return -1 ; - } ---- utils.c.orig Wed Sep 9 16:31:16 1992 -+++ utils.c Wed Aug 14 16:57:59 1996 -@@ -25,8 +25,10 @@ - #else - #include - #endif -+#include - #include "globals.h" - -+extern void initialize_siglist A((void)) ; - - /* Signal handler, print message and exit */ - SIG_HANDLER_RET exitsig(sig) -@@ -70,7 +72,7 @@ - - /* set up signal handling. All except TSTP, CONT, CLD, and QUIT - * are caught with exitsig(). */ --init_signals() -+void init_signals() - { - int i ; - #ifdef SIG_SETMASK /* only with BSD signals */ Index: head/sysutils/socket/files/patch-Makefile_1 =================================================================== --- head/sysutils/socket/files/patch-Makefile_1 +++ head/sysutils/socket/files/patch-Makefile_1 @@ -1,11 +0,0 @@ ---- Makefile.orig 1992-09-10 23:59:31.000000000 +0900 -+++ Makefile 2013-12-02 12:47:26.000000000 +0900 -@@ -13,7 +13,7 @@ - INSTALLBINMODE = 755 - INSTALLMANPATH = $(INSTALLBASE)/man - INSTALLMANMODE = 444 --CC = cc -+#CC = ${CC} - CFLAGS = $(SWITCHES) -O - LDFLAGS = $(SWITCHES) -s - Index: head/sysutils/socket/files/patch-Makefile_2 =================================================================== --- head/sysutils/socket/files/patch-Makefile_2 +++ head/sysutils/socket/files/patch-Makefile_2 @@ -1,37 +0,0 @@ -*** Makefile.orig Fri Mar 22 11:42:23 2002 ---- Makefile Fri Mar 22 11:56:04 2002 -*************** -*** 8,14 **** - ### socket.1 in /usr/local/man/man1/socket.1 - ### Make sure the target directories exist before doing a "make install". - -! INSTALLBASE = /usr/local - INSTALLBINPATH = $(INSTALLBASE)/bin - INSTALLBINMODE = 755 - INSTALLMANPATH = $(INSTALLBASE)/man ---- 8,14 ---- - ### socket.1 in /usr/local/man/man1/socket.1 - ### Make sure the target directories exist before doing a "make install". - -! INSTALLBASE = ${DESTDIR}${PREFIX} - INSTALLBINPATH = $(INSTALLBASE)/bin - INSTALLBINMODE = 755 - INSTALLMANPATH = $(INSTALLBASE)/man -*************** -*** 43,50 **** - ### CDC 4680 EP/IX: (I know it *has* setsid(2), but not with bsd43) - # SWITCHES = -systype bsd43 -DNOSETSID - -! # FreeBSD 2.x (4.4BSD) -! SWITCHES=-DHAVE_SYS_PARAM_H -Wall - - ### It should not be necessary to change anything below this line. - ################################################################## ---- 43,49 ---- - ### CDC 4680 EP/IX: (I know it *has* setsid(2), but not with bsd43) - # SWITCHES = -systype bsd43 -DNOSETSID - -! - - ### It should not be necessary to change anything below this line. - ################################################################## Index: head/sysutils/socket/files/patch-globals.h =================================================================== --- head/sysutils/socket/files/patch-globals.h +++ head/sysutils/socket/files/patch-globals.h @@ -1,31 +0,0 @@ -*** globals.h.orig Fri Mar 22 11:42:23 2002 ---- globals.h Fri Mar 22 12:05:22 2002 -*************** -*** 13,19 **** - # include - #endif - -- - /* globals for socket */ - - #define IN 0 /* standard input */ ---- 13,18 ---- -*************** -*** 27,35 **** ---- 26,41 ---- - #define A(args) () - #endif - -+ #ifndef USE_INET6 - int create_server_socket A((int port, int queue_length)) ; - int create_client_socket A((char **hostname, int port)) ; - int resolve_service A((char *name_or_number, char *protocol, char **name)) ; -+ #else /* USE_INET6 */ -+ int *create_server_sockets A((char **port, int queue_length)) ; -+ int create_client_socket A((char **hostname, char **port)) ; -+ int socket_local_name A((int socket, char **name, char **ipname, char **port)); -+ int socket_remote_name A((int socket, char **name, char **ipname, char **port)); -+ #endif /* USE_INET6 */ - void catchsig A((int sig)) ; - void usage A((void)) ; - int do_read_write A((int from, int to)) ; Index: head/sysutils/socket/files/patch-socket.c =================================================================== --- head/sysutils/socket/files/patch-socket.c +++ head/sysutils/socket/files/patch-socket.c @@ -1,327 +0,0 @@ -*** socket.c.orig Fri Mar 22 11:42:23 2002 ---- socket.c Fri Mar 22 12:06:16 2002 -*************** -*** 9,14 **** ---- 9,17 ---- - - #include - #include -+ #ifdef USE_INET6 -+ #include -+ #endif /* USE_INET6 */ - #include - #include - #include -*************** -*** 36,44 **** - char *progname ; /* name of the game */ - char *pipe_program = NULL ; /* program to execute in two-way pipe */ - - void server A((int port, char *service_name)) ; -- void handle_server_connection A((void)) ; - void client A((char *host, int port, char *service_name)) ; - extern void init_signals A((void)) ; - extern void do_io A((void)) ; - ---- 39,53 ---- - char *progname ; /* name of the game */ - char *pipe_program = NULL ; /* program to execute in two-way pipe */ - -+ #ifndef USE_INET6 - void server A((int port, char *service_name)) ; - void client A((char *host, int port, char *service_name)) ; -+ #else /* USE_INET6 */ -+ void server A((char *port)) ; -+ void client A((char *host, char *port)) ; -+ #endif /* USE_INET6 */ -+ -+ void handle_server_connection A((void)) ; - extern void init_signals A((void)) ; - extern void do_io A((void)) ; - -*************** -*** 51,58 **** ---- 60,69 ---- - int error = 0 ; /* usage error occurred */ - extern int optind ; /* from getopt() */ - /* char *host ; */ /* name of remote host */ -+ #ifndef USE_INET6 - int port ; /* port number for socket */ - char *service_name ; /* name of service for port */ -+ #endif /* USE_INET6 */ - - /* print version ID if requested */ - if (argv[1] && !strcmp(argv[1], "-version")) { -*************** -*** 62,68 **** - - /* set up progname for later use */ - progname = argv[0] ; -! if ((cp = strrchr(progname, '/'))) progname = cp + 1 ; - - /* parse options */ - while ((opt = getopt(argc, argv, "bcflp:qrsvw?")) != -1) { ---- 73,80 ---- - - /* set up progname for later use */ - progname = argv[0] ; -! cp = strrchr(progname, '/'); -! if (cp) progname = cp + 1 ; - - /* parse options */ - while ((opt = getopt(argc, argv, "bcflp:qrsvw?")) != -1) { -*************** -*** 130,135 **** ---- 142,148 ---- - /* set up signal handling */ - init_signals() ; - -+ #ifndef USE_INET6 - /* get port number */ - port = resolve_service(argv[optind + 1 - serverflag], - "tcp", &service_name) ; -*************** -*** 138,178 **** ---- 151,231 ---- - exit(5) ; - } - -+ #endif /* not USE_INET6 */ - /* and go */ - if (serverflag) { - if (backgflag) { - background() ; - } -+ #ifndef USE_INET6 - server(port, service_name) ; -+ #else /* USE_INET6 */ -+ server(argv[optind]) ; -+ #endif /* USE_INET6 */ - } else { -+ #ifndef USE_INET6 - client(argv[optind], port, service_name) ; -+ #else /* USE_INET6 */ -+ client(argv[optind], argv[optind + 1]) ; -+ #endif /* USE_INET6 */ - } - exit(0) ; - } - - -+ #ifndef USE_INET6 - void server(port, service_name) - int port ; - char *service_name ; -+ #else /* USE_INET6 */ -+ void server(port) -+ char *port ; -+ #endif /* USE_INET6 */ - { -+ #ifndef USE_INET6 - int socket_handle, alen ; -+ #else /* USE_INET6 */ -+ int *socket_handle_list ; -+ #endif /* USE_INET6 */ - - /* allocate server socket */ -+ #ifndef USE_INET6 - socket_handle = create_server_socket(port, 1) ; - if (socket_handle < 0) { -+ #else /* USE_INET6 */ -+ socket_handle_list = create_server_sockets(&port, 1) ; -+ if (!socket_handle_list) { -+ #endif /* USE_INET6 */ - perror2("server socket") ; - exit(1) ; - } -+ #ifdef USE_INET6 -+ -+ #endif /* USE_INET6 */ - if (verboseflag) { -+ #ifndef USE_INET6 - fprintf(stderr, "listening on port %d", port) ; - if (service_name) { - fprintf(stderr, " (%s)", service_name) ; - } - fprintf(stderr, "\n") ; -+ #else /* USE_INET6 */ -+ char *ip, *port; -+ int fd, i; -+ -+ fd = socket_handle_list[1]; -+ for (i = 1; i <= socket_handle_list[0]; i++) { -+ if (!fd || fd < socket_handle_list[i]) -+ fd = socket_handle_list[i]; -+ socket_local_name (fd, NULL, &ip, &port); -+ fprintf(stderr, "listening at address %s on port %s\n", ip, port) ; -+ } -+ #endif /* USE_INET6 */ - } - - /* server loop */ - do { -+ #ifndef USE_INET6 - struct sockaddr_in sa ; - - alen = sizeof(sa) ; -*************** -*** 189,204 **** - long norder ; - char dotted[20] ; - -! he = gethostbyaddr((char *)&sa.sin_addr.s_addr, - sizeof(sa.sin_addr.s_addr), AF_INET) ; - if (!he) { - norder = htonl(sa.sin_addr.s_addr) ; - sprintf(dotted, "%d.%d.%d.%d", -! (int)((norder >> 24) & 0xff), -! (int)((norder >> 16) & 0xff), -! (int)((norder >> 8) & 0xff), -! (int)(norder & 0xff)) ; - } - fprintf(stderr, "connection from %s\n", - (he ? he->h_name : dotted)) ; - } ---- 242,317 ---- - long norder ; - char dotted[20] ; - -! he = gethostbyaddr((const char *)&sa.sin_addr.s_addr, - sizeof(sa.sin_addr.s_addr), AF_INET) ; - if (!he) { - norder = htonl(sa.sin_addr.s_addr) ; - sprintf(dotted, "%d.%d.%d.%d", -! (int)((norder >> 24) & 0xff), -! (int)((norder >> 16) & 0xff), -! (int)((norder >> 8) & 0xff), -! (int)(norder & 0xff)) ; -! #else /* USE_INET6 */ -! struct timeval tv; -! fd_set readfd; -! int fd, i, nfds, retval; -! -! fd = socket_handle_list[1]; -! for (i = 1; i <= socket_handle_list[0]; i++) { -! if (!fd || fd < socket_handle_list[i]) -! fd = socket_handle_list[i]; -! } -! nfds=fd+1; -! -! FD_ZERO(&readfd); -! for (i = 1; i <= socket_handle_list[0]; i++) -! FD_SET(socket_handle_list[i],&readfd); -! -! tv.tv_sec = 10; -! tv.tv_usec = 0; -! -! retval = select(nfds, &readfd, NULL, NULL, &tv); -! -! if(retval!=-1) { -! for (i = 1; i <= socket_handle_list[0]; i++) { -! fd = socket_handle_list[i]; -! if (FD_ISSET(fd, &readfd)) { -! -! /* accept a connection */ -! active_socket = accept(fd, (struct sockaddr *) 0, (int *)0); -! if (active_socket == -1) { -! perror2("accept") ; -! } else { -! /* if verbose, get name of peer and give message */ -! if (verboseflag) { -! char *host, *ip, *port; -! -! if(!socket_remote_name(active_socket,&host, &ip, &port)) { -! fprintf(stderr, "connection from %s at %s to %s\n", host, ip, port); -! } -! else -! fprintf(stderr, "cannot get name or address of peer") ; -! } -! -! if (forkflag) { -! switch (fork()) { -! case 0: -! handle_server_connection() ; -! exit(0) ; -! case -1: -! perror2("fork") ; -! break ; -! default: -! close(active_socket) ; -! wait_for_children() ; -! } -! } else { -! handle_server_connection() ; -! } -! } -! #endif /* USE_INET6 */ - } -+ #ifndef USE_INET6 - fprintf(stderr, "connection from %s\n", - (he ? he->h_name : dotted)) ; - } -*************** -*** 216,224 **** ---- 329,342 ---- - } - } else { - handle_server_connection() ; -+ #endif /* not USE_INET6 */ - } - } - } while (loopflag) ; -+ #ifdef USE_INET6 -+ -+ free (socket_handle_list); -+ #endif /* USE_INET6 */ - } - - -*************** -*** 239,251 **** ---- 357,381 ---- - } - - -+ #ifndef USE_INET6 - void client(host, port, service_name) -+ #else /* USE_INET6 */ -+ void client(host, port) -+ #endif /* USE_INET6 */ - char *host ; -+ #ifndef USE_INET6 - int port ; - char *service_name ; -+ #else /* USE_INET6 */ -+ char *port ; -+ #endif /* USE_INET6 */ - { - /* get connection */ -+ #ifndef USE_INET6 - active_socket = create_client_socket(&host, port) ; -+ #else /* USE_INET6 */ -+ active_socket = create_client_socket(&host, &port) ; -+ #endif /* USE_INET6 */ - if (active_socket == -1) { - perror2("client socket") ; - exit(errno) ; -*************** -*** 254,264 **** ---- 384,401 ---- - exit(13) ; - } - if (verboseflag) { -+ #ifndef USE_INET6 - fprintf(stderr, "connected to %s port %d", host, port) ; - if (service_name) { - fprintf(stderr, " (%s)", service_name) ; - } - fprintf(stderr, "\n") ; -+ #else /* USE_INET6 */ -+ char *host, *ip, *port; -+ -+ socket_local_name (active_socket, &host, &ip, &port); -+ fprintf(stderr, "connected to %s with address %s at port %s\n", host, ip, port) ; -+ #endif /* USE_INET6 */ - } - - /* open pipes to program if requested */ Index: head/sysutils/socket/files/patch-socketp.c =================================================================== --- head/sysutils/socket/files/patch-socketp.c +++ head/sysutils/socket/files/patch-socketp.c @@ -1,358 +0,0 @@ -*** socketp.c.orig Fri Mar 22 11:42:23 2002 ---- socketp.c Fri Mar 22 12:07:59 2002 -*************** -*** 21,26 **** ---- 21,27 ---- - - extern int is_number A((char *)); - -+ #ifndef USE_INET6 - /* - * create a server socket on PORT accepting QUEUE_LENGTH connections - */ -*************** -*** 31,39 **** - struct sockaddr_in sa ; - int s; - -! if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - return -1 ; -- } - - bzero((char *) &sa, sizeof(sa)) ; - sa.sin_family = AF_INET ; ---- 32,40 ---- - struct sockaddr_in sa ; - int s; - -! s = socket(AF_INET, SOCK_STREAM, 0); -! if (s < 0) - return -1 ; - - bzero((char *) &sa, sizeof(sa)) ; - sa.sin_family = AF_INET ; -*************** -*** 41,56 **** - sa.sin_port = htons(port) ; - - if (bind(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) { -! return -1 ; - } - if (listen(s, 1) < 0) { -! return -1 ; - } - - return s ; - } - - - /* create a client socket connected to PORT on HOSTNAME */ - int create_client_socket(hostname, port) - char **hostname ; ---- 42,126 ---- - sa.sin_port = htons(port) ; - - if (bind(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) { -! return -1 ; - } - if (listen(s, 1) < 0) { -! return -1 ; - } - - return s ; - } -+ #else /* USE_INET6 */ -+ /* -+ * create a server socket(s) on PORT accepting QUEUE_LENGTH connections -+ * -+ * FWD (ifdef USE_INET6): -+ * there can be more than one socket; one for each supported address -+ * family. This is for portability as not all IPv6 stacks implement -+ * the wildcard bind as a bind to *ll IPv4 *and* IPv6 addresses. -+ * so we'll just open a socket for each address getaddrinfo() gives -+ * back to us. The price of portability... -+ */ -+ int *create_server_sockets(port, queue_length) -+ char **port ; -+ int queue_length ; -+ { -+ struct addrinfo hints, *r, *res; -+ int *s, *slist, error, maxs; -+ int reuse_addr = 1; -+ -+ memset(&hints, 0, sizeof(hints)); -+ hints.ai_flags = AI_PASSIVE; -+ hints.ai_family = AF_UNSPEC; -+ hints.ai_socktype = SOCK_STREAM; -+ hints.ai_protocol = 0; -+ error = getaddrinfo(NULL, *port, &hints, &res); -+ -+ if (!error) { -+ for (maxs = 0, r = res; r; r = r->ai_next, maxs++); -+ slist = malloc ((maxs+1) * sizeof(int)); -+ if (slist) { -+ slist[0] = maxs; /* max. num of sockets */ -+ -+ s = slist+1; -+ for (r = res; r; r = r->ai_next) { -+ *s = socket(r->ai_family, r->ai_socktype, r->ai_protocol); -+ if (*s < 0) -+ continue; -+ -+ setsockopt(*s,SOL_SOCKET,SO_REUSEADDR,&reuse_addr,sizeof(reuse_addr)); -+ -+ if (bind(*s, r->ai_addr, r->ai_addrlen) < 0) { -+ close (*s); -+ continue; -+ } -+ -+ if (listen(*s, 1) < 0) { -+ close (*s); -+ continue; -+ } -+ s++; -+ } -+ } -+ } -+ else -+ slist = NULL; - -+ if (res) -+ freeaddrinfo(res); - -+ if (slist && !slist[0]) { -+ free (slist); -+ slist = NULL; -+ } -+ -+ return (slist); -+ } -+ #endif /* USE_INET6 */ -+ -+ -+ /* create a client socket connected to PORT on HOSTNAME */ -+ #ifndef USE_INET6 - /* create a client socket connected to PORT on HOSTNAME */ - int create_client_socket(hostname, port) - char **hostname ; -*************** -*** 64,94 **** - - bzero(&sa, sizeof(sa)) ; - if ((addr = inet_addr(*hostname)) != -1) { -! /* is Internet addr in octet notation */ -! bcopy(&addr, (char *) &sa.sin_addr, sizeof(addr)) ; /* set address */ -! sa.sin_family = AF_INET ; - } else { -! /* do we know the host's address? */ -! if ((hp = gethostbyname(*hostname)) == NULL) { -! return -2 ; -! } -! *hostname = hp->h_name ; -! bcopy(hp->h_addr, (char *) &sa.sin_addr, hp->h_length) ; -! sa.sin_family = hp->h_addrtype ; - } - - sa.sin_port = htons((u_short) port) ; - - if ((s = socket(sa.sin_family, SOCK_STREAM, 0)) < 0) { /* get socket */ -! return -1 ; - } - if (connect(s, (struct sockaddr *)&sa, sizeof(sa)) < 0) { /* connect */ -! close(s) ; -! return -1 ; - } - return s ; - } - - /* return the port number for service NAME_OR_NUMBER. If NAME is non-null, - * the name is the service is written there. - */ ---- 134,311 ---- - - bzero(&sa, sizeof(sa)) ; - if ((addr = inet_addr(*hostname)) != -1) { -! /* is Internet addr in octet notation */ -! bcopy(&addr, (char *) &sa.sin_addr, sizeof(addr)) ; /* set address */ -! sa.sin_family = AF_INET ; - } else { -! /* do we know the host's address? */ -! if ((hp = gethostbyname(*hostname)) == NULL) { -! return -2 ; -! } -! *hostname = hp->h_name ; -! bcopy(hp->h_addr, (char *) &sa.sin_addr, hp->h_length) ; -! sa.sin_family = hp->h_addrtype ; - } - - sa.sin_port = htons((u_short) port) ; - - if ((s = socket(sa.sin_family, SOCK_STREAM, 0)) < 0) { /* get socket */ -! return -1 ; - } - if (connect(s, (struct sockaddr *)&sa, sizeof(sa)) < 0) { /* connect */ -! close(s) ; -! return -1 ; - } - return s ; - } - -+ #else /* USE_INET6 */ -+ int create_client_socket(hostname, port) -+ char **hostname ; -+ char **port ; -+ { -+ int s, connected, err ; -+ struct addrinfo hints, *r, *res; -+ -+ memset(&hints, 0, sizeof(hints)); -+ hints.ai_flags = AI_NUMERICHOST; -+ hints.ai_family = AF_UNSPEC; -+ hints.ai_socktype= SOCK_STREAM; -+ err = getaddrinfo(*hostname, *port, &hints, &res); -+ if (res) freeaddrinfo(res); -+ -+ if (!err) { -+ /* numeric */ -+ memset(&hints, 0, sizeof(hints)); -+ hints.ai_flags = AI_CANONNAME; -+ hints.ai_family = AF_UNSPEC; -+ hints.ai_socktype = SOCK_STREAM; -+ hints.ai_protocol = 0; -+ err = getaddrinfo(*hostname, *port, &hints, &res); -+ if (err) s = -2; -+ } else { -+ /* non-numeric */ -+ memset(&hints, 0, sizeof(hints)); -+ hints.ai_family = AF_UNSPEC; -+ hints.ai_socktype = SOCK_STREAM; -+ hints.ai_protocol = 0; -+ err = getaddrinfo(*hostname, *port, &hints, &res); -+ if (err) s = -2; -+ } -+ -+ -+ if (!err) { -+ err = 0; s = -1; -+ connected = 0; -+ for (r = res; r && !connected; r = r->ai_next) { -+ s = socket(r->ai_family, r->ai_socktype, r->ai_protocol); -+ if (s < 0) -+ continue; -+ -+ if (connect(s, r->ai_addr, r->ai_addrlen) < 0) { -+ err = errno; -+ close(s); -+ s = -1; -+ continue; -+ } -+ connected++; -+ break; -+ } -+ if (!connected) s = -1; -+ } -+ -+ if (res) -+ freeaddrinfo(res); -+ -+ return (s); -+ } -+ #endif /* USE_INET6 */ -+ -+ #ifdef USE_INET6 -+ /* Determines hostname, address and port number used for the peer of socket */ -+ int socket_remote_name(socket, name, ipname, port) -+ int socket; -+ char **name; -+ char **ipname; -+ char **port; -+ { -+ struct sockaddr_storage server; -+ int length=sizeof(server), retval, error; -+ static char host[NI_MAXHOST],ip[NI_MAXHOST],portstr[NI_MAXSERV]; -+ -+ error = getpeername(socket,(struct sockaddr*)&server,&length); -+ if(!error) { -+ error = getnameinfo((struct sockaddr*)&server, length, host, -+ NI_MAXHOST, NULL, 0, 0); -+ error = getnameinfo((struct sockaddr*)&server, length, ip, -+ NI_MAXHOST, NULL, NI_MAXSERV, -+ NI_NUMERICHOST); -+ retval = error; -+ -+ error = getnameinfo((struct sockaddr*)&server, length, NULL, 0, -+ portstr, NI_MAXSERV, 0); -+ -+ if (error) -+ retval = getnameinfo((struct sockaddr*)&server, length, ip, -+ NI_MAXHOST, portstr, NI_MAXSERV, -+ NI_NUMERICSERV); -+ } -+ else -+ retval = error; -+ -+ if(name) -+ *name=host; -+ if(ipname) -+ *ipname=ip; -+ if(port) -+ *port=portstr; -+ -+ return(retval); -+ } -+ -+ /* Determines the hostname, address and port number used for our socket */ -+ int socket_local_name(socket, name, ipname, port) -+ int socket; -+ char **name; -+ char **ipname; -+ char **port; -+ { -+ struct sockaddr_storage server; -+ int length=sizeof(server), retval, error; -+ static char host[NI_MAXHOST],ip[NI_MAXHOST],portstr[NI_MAXSERV]; -+ -+ error = getsockname(socket,(struct sockaddr*)&server,&length); -+ if(!error) { -+ error = getnameinfo((struct sockaddr*)&server, length, host, -+ NI_MAXHOST, NULL, 0, 0); -+ error = getnameinfo((struct sockaddr*)&server, length, ip, -+ NI_MAXHOST, NULL, NI_MAXSERV, -+ NI_NUMERICHOST); -+ retval = error; -+ -+ error = getnameinfo((struct sockaddr*)&server, length, NULL, 0, -+ portstr, NI_MAXSERV, 0); -+ -+ if (error) -+ retval = getnameinfo((struct sockaddr*)&server, length, ip, -+ NI_MAXHOST, portstr, NI_MAXSERV, -+ NI_NUMERICSERV); -+ } -+ else -+ retval = error; -+ -+ if(name) -+ *name=host; -+ if(ipname) -+ *ipname=ip; -+ if(port) -+ *port=portstr; -+ -+ return(retval); -+ } -+ #endif /* USE_INET6 */ -+ -+ #ifndef USE_INET6 - /* return the port number for service NAME_OR_NUMBER. If NAME is non-null, - * the name is the service is written there. - */ -*************** -*** 122,126 **** ---- 339,344 ---- - return ntohs(servent->s_port) ; - } - } -+ #endif /* !USE_INET6 */ - - /*EOF*/ Index: head/sysutils/socket/files/patch-utils.c =================================================================== --- head/sysutils/socket/files/patch-utils.c +++ head/sysutils/socket/files/patch-utils.c @@ -1,21 +0,0 @@ -*** utils.c.orig Fri Feb 29 15:21:52 2008 ---- utils.c Fri Feb 29 15:23:26 2008 -*************** -*** 89,98 **** ---- 89,102 ---- - case SIGTTIN: - case SIGSTOP: - case SIGCONT: - continue ; - #endif -+ #ifdef SIGINFO -+ case SIGINFO: -+ continue ; -+ #endif - #if !defined (SIGCHLD) && defined (SIGCLD) - #define SIGCHLD SIGCLD - #endif - #ifdef SIGCHLD - case SIGCHLD: - -