A new user interface for you! Read more...

File jabbertest-ipv6.patch of Package jabbertest

diff -ur testsuite.orig/conn.c testsuite/conn.c
--- testsuite.orig/conn.c	2003-02-08 03:15:07.000000000 +0100
+++ testsuite/conn.c	2015-12-08 11:07:15.634247387 +0100
@@ -23,51 +23,48 @@
  * in addr
  */
 
-int conn_open(char *ip, char *hostname, int port)
+int conn_open(char *host, char *port)
 {
-	struct sockaddr_in addr;
-	int sockfd;
+	int sockfd = -1;
+	struct addrinfo *res;
 
-	/* specify our server */
-	addr.sin_family = AF_INET;
-	addr.sin_port = htons(port);
-
-	/* determine 32-bit IP address using either the specified IP 
-	 * string or the hostname */
-	if (ip == NULL && hostname != NULL)
-	{
-		struct hostent *entry;
-
-		entry = gethostbyname(hostname);
-		if (entry == NULL)
-		{
-			perror("gethostbyname()");
-			return -1;
+	if (host != NULL) {
+		struct addrinfo hints;
+		struct addrinfo *runp;
+
+		memset(&hints, 0, sizeof(hints));
+		hints.ai_socktype = SOCK_STREAM;
+		hints.ai_flags = AI_ADDRCONFIG;
+		
+		int e = getaddrinfo(host, port, &hints, &res);
+
+		if (e != 0) {
+			printf("failure %s\n", gai_strerror(e));
+			return 1;
 		}
-
-		addr.sin_addr.s_addr = *((unsigned long *) entry->h_addr_list[0]);
-	}
-	else if (ip != NULL && hostname == NULL)
-		addr.sin_addr.s_addr = inet_addr(ip);
-	else
-		return -1;
-
-	/* create a new socket */
-	sockfd = socket(AF_INET, SOCK_STREAM, 0);
-	if (sockfd < 0)
-	{
-		perror("socket()");
-		exit(EXIT_FAILURE);
-	}
-
-	/* connect to the server */
-	if ((connect(sockfd, (struct sockaddr *) &addr, sizeof(addr)) < 0))
-	{
-		close(sockfd);
-		return -1;
+		for (runp = res; runp != NULL; runp = runp->ai_next) {
+			/* create a new socket */
+        		sockfd = socket(runp->ai_family, runp->ai_socktype,
+					runp->ai_protocol);
+		        if (sockfd < 0) {
+                		perror("socket()");
+				continue;
+        		}
+
+		        /* connect to the server */
+		        if ((connect(sockfd, runp->ai_addr, runp->ai_addrlen) < 0)) {
+				close(sockfd);
+                		continue;
+		        }
+			break; /* connection successful  */
+		}
+		if (runp == NULL) {
+			perror("connection error");
+			sockfd = -1;
+		}
+		freeaddrinfo(res); /* free dynamically allocated memory  */
 	}
-	else
-		return sockfd;
+	return sockfd;
 }
 
 /* 
@@ -110,8 +107,9 @@
 
 	/* if sec < 0 and usec < 0 then we essentially want a blocking
 	 * read */
-	if (sec < 0 && usec < 0)
+	if (sec < 0 && usec < 0) {
 		return conn_read(sockfd, buf, len);
+	}
 
 	FD_ZERO(&fdset);
 
@@ -121,10 +119,12 @@
 	FD_SET(sockfd, &fdset);
 
 	rv = select(sockfd+1, &fdset, NULL, NULL, &timeout);
-	if (rv > 0)
+	if (rv > 0) {
 		return recv(sockfd, buf, len, 0);
-	else
+	}
+	else {
 		return -1;
+	}
 }
 
 #ifdef CONN_DRIVER
@@ -136,30 +136,29 @@
 	int sockfd, len;
 	char buf[BUFSZ+1];
 
-	if (argc != 3)
-	{
+	if (argc != 3) {
 		printf("usage: conn ip port\n");
 		exit(EXIT_FAILURE);
 	}
 
 	/* open the connection */
 	sockfd = conn_open(argv[1], atoi(argv[2]));
-	if (sockfd < 0)
-	{
+	if (sockfd < 0) {
 		perror("conn_open()");
 		exit(EXIT_FAILURE);
 	}
 
 	/* do non-blocking reads and print whatever shows up */
-	while ((len = conn_readwait(sockfd, buf, BUFSZ, 0, 0)) >= 0)
-	{
-		if (len > 0)
+	while ((len = conn_readwait(sockfd, buf, BUFSZ, 0, 0)) >= 0) {
+		if (len > 0) {
 			write(1, buf, len);
+		}
 
 		/* do non-blocking read on stdin for data to send */
 		len = conn_readwait(0, buf, BUFSZ, 0, 0);
-		if (len > 0)
+		if (len > 0) {
 			write(sockfd, buf, len);
+		}
 	}
 
 	conn_close(sockfd);
diff -ur testsuite.orig/conn.h testsuite/conn.h
--- testsuite.orig/conn.h	2001-05-14 16:50:25.000000000 +0200
+++ testsuite/conn.h	2015-11-03 16:04:15.538580011 +0100
@@ -5,7 +5,7 @@
 #ifndef _CONN_H_
 #define _CONN_H_
 
-int conn_open(char *ip, char *hostname, int port);
+int conn_open(char *host, char *port);
 int conn_close(int sockfd);
 int conn_write(int sockfd, char *buf, int len);
 int conn_read(int sockfd, char *buf, int len);
diff -ur testsuite.orig/msgloadrec.c testsuite/msgloadrec.c
--- testsuite.orig/msgloadrec.c	2003-02-17 00:10:07.000000000 +0100
+++ testsuite/msgloadrec.c	2015-11-09 13:36:15.185912550 +0100
@@ -34,7 +34,7 @@
 void print_usage(void);
 int open_session(char *servername,
 		char *hostname,
-		int   port,
+		char *port,
 		char *username, 
 		char *password, 
 		char *resource,
@@ -356,7 +356,7 @@
 				strncpy(options->password, optarg, MAX_BUFSZ);
 				break;
 			case 'p':
-				options->port = atoi(optarg);
+				options->port = optarg;
 				break;
 			case 'x':
 				options->throttle_secs = atol(optarg);
@@ -440,7 +440,7 @@
 
 int open_session(char *hostname,
 		char *servername,
-		int   port,
+		char *port,
 		char *username, 
 		char *password, 
 		char *resource,
@@ -451,8 +451,8 @@
 	user_data_t *ud;
 
 	/* open a connection with the server */
-	DPRINT("opening connection to %s on port %d\n", hostname, port);
-	sockfd = conn_open(NULL, hostname, port);
+	DPRINT("opening connection to %s on port %s\n", hostname, port);
+	sockfd = conn_open(hostname, port);
 	if (sockfd < 0)
 	{
 		perror("conn_open()");
diff -ur testsuite.orig/msgloadrec.h testsuite/msgloadrec.h
--- testsuite.orig/msgloadrec.h	2001-07-13 16:40:02.000000000 +0200
+++ testsuite/msgloadrec.h	2015-11-09 13:37:55.122140163 +0100
@@ -33,7 +33,7 @@
 	char to_user[MAX_BUFSZ+1];	/* destination user		*/
 	char password[MAX_BUFSZ+1];	/* user's jabber password	*/
 	char output[MAX_BUFSZ+1];	/* output file name		*/
-	int port;			/* jabberd port			*/
+	char *port;			/* jabberd port			*/
 	int time_data;			/* print out timing data	*/
 	int timeout;			/* timeout after x seconds	*/
 	long throttle_secs;		/* throttle time in secs	*/
Only in testsuite: msgloadrec.o
Only in testsuite: msgloadsnd
diff -ur testsuite.orig/msgloadsnd.c testsuite/msgloadsnd.c
--- testsuite.orig/msgloadsnd.c	2003-02-16 05:45:55.000000000 +0100
+++ testsuite/msgloadsnd.c	2015-11-09 13:35:39.442188982 +0100
@@ -30,7 +30,7 @@
 void print_usage(void);
 int open_session(char *servername,
 		char *hostname,
-		int   port,
+		char *port,
 		char *username, 
 		char *password, 
 		char *resource,
@@ -273,7 +273,7 @@
 				strncpy(options->from_user, optarg, MAX_BUFSZ);
 				break;
 			case 'p':
-				options->port = atoi(optarg);
+				options->port = optarg;
 				break;
 			case 'w':
 				strncpy(options->password, optarg, MAX_BUFSZ);
@@ -363,7 +363,7 @@
 
 int open_session(char *hostname,
 		char *servername,
-		int   port,
+		char *port,
 		char *username, 
 		char *password, 
 		char *resource,
@@ -374,8 +374,8 @@
 	char *streamid;
 
 	/* open a connection with the server */
-	DPRINT("opening connection to %s on port %d\n", hostname, port);
-	sockfd = conn_open(NULL, hostname, port);
+	DPRINT("opening connection to %s on port %s\n", hostname, port);
+	sockfd = conn_open(hostname, port);
 	if (sockfd < 0)
 	{
 		perror("conn_open()");
diff -ur testsuite.orig/msgloadsnd.h testsuite/msgloadsnd.h
--- testsuite.orig/msgloadsnd.h	2001-05-30 17:10:27.000000000 +0200
+++ testsuite/msgloadsnd.h	2015-11-09 13:38:05.651058829 +0100
@@ -20,7 +20,7 @@
 	char from_user[MAX_BUFSZ+1];
 	char to_user[MAX_BUFSZ+1];
 	char password[MAX_BUFSZ+1];
-	int port;
+	char *port;
 	int messages;
 	int steady_load;
 	long throttle_secs;
Only in testsuite: msgloadsnd.o
Only in testsuite: pasvlogin
diff -ur testsuite.orig/pasvlogin.c testsuite/pasvlogin.c
--- testsuite.orig/pasvlogin.c	2003-02-16 05:18:47.000000000 +0100
+++ testsuite/pasvlogin.c	2015-11-09 13:36:53.473616547 +0100
@@ -29,7 +29,7 @@
 void print_usage(void);
 int open_session(char *servername,
 		char *hostname,
-		int   port,
+		char *port,
 		char *username, 
 		char *password, 
 		char *resource,
@@ -250,7 +250,7 @@
 
 			/* server port */
 			case 'p':
-				options->port = atoi(optarg);
+				options->port = optarg;
 				break;
 
 			/* total users */
@@ -367,7 +367,7 @@
 
 int open_session(char *hostname,
 		char *servername,
-		int   port,
+		char *port,
 		char *username, 
 		char *password, 
 		char *resource,
@@ -379,8 +379,8 @@
 	user_data_t *ud;
 
 	/* open a connection with the server */
-	DPRINT("opening connection to %s on port %d\n", hostname, port);
-	sockfd = conn_open(NULL, hostname, port);
+	DPRINT("opening connection to %s on port %s\n", hostname, port);
+	sockfd = conn_open(hostname, port);
 	if (sockfd < 0)
 	{
 		perror("conn_open()");
diff -ur testsuite.orig/pasvlogin.h testsuite/pasvlogin.h
--- testsuite.orig/pasvlogin.h	2003-02-08 03:15:07.000000000 +0100
+++ testsuite/pasvlogin.h	2015-11-09 13:38:27.226892183 +0100
@@ -27,7 +27,7 @@
 	char hostname[MAX_BUFSZ+1];
 	char output[MAX_BUFSZ+1];
 	char msgfile[MAX_BUFSZ+1];
-	int port;
+	char *port;
 	int timeout;
 	int users;
 	int method;
Only in testsuite: pasvlogin.o
Only in testsuite: sha.o
diff -ur testsuite.orig/testsuite.h testsuite/testsuite.h
--- testsuite.orig/testsuite.h	2003-02-08 18:09:55.000000000 +0100
+++ testsuite/testsuite.h	2015-11-09 11:21:38.322363367 +0100
@@ -47,7 +47,7 @@
 
 #define BANNER "Jabber Test Suite - http://www.sf.net/projects/jabbertest\nThis software is governed by the GPL, read LICENSE for more information."
 
-#define JABBER_PORT 5222
+#define JABBER_PORT "5222"
 
 #endif /* _TESTSUITE_H_ */
 
Only in testsuite: userreg
diff -ur testsuite.orig/userreg.c testsuite/userreg.c
--- testsuite.orig/userreg.c	2003-02-16 05:18:47.000000000 +0100
+++ testsuite/userreg.c	2015-11-09 13:37:30.930327071 +0100
@@ -28,7 +28,7 @@
 void print_usage(void);
 int open_stream(char *servername,
 		char *hostname,
-		int   port,
+		char *port,
 		XML_Parser parser);
 int close_stream(int sockfd);
 int register_user(int sockfd,
@@ -244,7 +244,7 @@
 
 			/* server port */
 			case 'p':
-				options->port = atoi(optarg);
+				options->port = optarg;
 				break;
 
 			/* total users */
@@ -353,15 +353,15 @@
 
 int open_stream(char *servername,
 		char *hostname,
-		int   port,
+		char *port,
 		XML_Parser parser)
 {
 	int sockfd, len;
 	char buf[MAX_XML_BUFSZ+1];
 
 	/* open a connection with the server */
-	DPRINT("opening connection to %s on port %d\n", hostname, port);
-	sockfd = conn_open(NULL, hostname, port);
+	DPRINT("opening connection to %s on port %s\n", hostname, port);
+	sockfd = conn_open(hostname, port);
 	if (sockfd < 0)
 	{
 		perror("conn_open()");
diff -ur testsuite.orig/userreg.h testsuite/userreg.h
--- testsuite.orig/userreg.h	2003-02-08 03:42:19.000000000 +0100
+++ testsuite/userreg.h	2015-11-09 13:38:42.338775482 +0100
@@ -20,7 +20,7 @@
 	char output[MAX_BUFSZ+1];
 	char msgfile[MAX_BUFSZ+1];
 	int mode;
-	int port;
+	char *port;
 	int timeout;
 	int users;
 	int start_number;
Only in testsuite: userreg.o
Only in testsuite: xml_format.o