svn commit: r415801 - in head/net: . sock sock/files

Cy Schubert cschuber at gmail.com
Tue May 24 17:18:07 UTC 2016


Cool. I'll have to check this out... Good book.

Sent from my cellphone,
~Cy

-----Original Message-----
From: Steve Wills
Sent: 24/05/2016 10:00
To: ports-committers at freebsd.org; svn-ports-all at freebsd.org; svn-ports-head at freebsd.org
Subject: svn commit: r415801 - in head/net: . sock sock/files

Author: swills
Date: Tue May 24 16:59:54 2016
New Revision: 415801
URL: https://svnweb.freebsd.org/changeset/ports/415801

Log:
  net/sock: create port
  
  This is a standalone version of W. Richard Stevens' "sock" program,
  based on the code available for the UNIX Network Programming book.
  
  Adapted and reworked code for W. Richard Stevens' "sock" utility
  by Christian Kreibich.
  
  From the author:  In TCP/IP Illustrated Vol. 1, Richard Stevens used
  a program called "sock" to demonstrate the many properties of TCP/IP.
  Unfortunately, the book only speaks about how to use the program but
  does not point to a site for downloading its sources. While sock is
  contained in the code package accompanying UNIX Network Programming,
  this code is also getting dated.
  
  The program can be used to generate TCP or UDP packets for testing
  various network features.  It runs as either client or server.
  
  WWW: http://www.icir.org/christian/sock.html
  
  PR:		206345
  Submitted by:	Steve Jacobson <sjac998 at yahoo.com> (with slight modification)

Added:
  head/net/sock/
  head/net/sock/Makefile   (contents, props changed)
  head/net/sock/distinfo   (contents, props changed)
  head/net/sock/files/
  head/net/sock/files/patch-src__cliopen.c   (contents, props changed)
  head/net/sock/files/patch-src__loopudp.c   (contents, props changed)
  head/net/sock/files/patch-src__main.c   (contents, props changed)
  head/net/sock/files/patch-src__multicast.c   (contents, props changed)
  head/net/sock/files/patch-src__servopen.c   (contents, props changed)
  head/net/sock/files/patch-src__sock.h   (contents, props changed)
  head/net/sock/files/patch-src__sockopts.c   (contents, props changed)
  head/net/sock/files/patch-src__sourceroute.c   (contents, props changed)
  head/net/sock/files/patch-src__sourceudp.c   (contents, props changed)
  head/net/sock/pkg-descr   (contents, props changed)
Modified:
  head/net/Makefile

Modified: head/net/Makefile
==============================================================================
--- head/net/Makefile	Tue May 24 16:15:40 2016	(r415800)
+++ head/net/Makefile	Tue May 24 16:59:54 2016	(r415801)
@@ -1226,6 +1226,7 @@
     SUBDIR += sntop
     SUBDIR += sobby
     SUBDIR += socat
+    SUBDIR += sock
     SUBDIR += socketbind
     SUBDIR += socketpipe
     SUBDIR += socketw

Added: head/net/sock/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/sock/Makefile	Tue May 24 16:59:54 2016	(r415801)
@@ -0,0 +1,16 @@
+# Created by: Steve Jacobson <sjac at cs.stanford.edu>
+# $FreeBSD$
+
+PORTNAME=	sock
+PORTVERSION=	0.3.2
+CATEGORIES=	net
+MASTER_SITES=	http://www.icir.org/christian/downloads/
+
+MAINTAINER=	sjac at cs.stanford.edu
+COMMENT=	W. Richard Stevens' sock program
+
+HAS_CONFIGURE=	yes
+
+PLIST_FILES=	bin/sock
+
+.include <bsd.port.mk>

Added: head/net/sock/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/sock/distinfo	Tue May 24 16:59:54 2016	(r415801)
@@ -0,0 +1,2 @@
+SHA256 (sock-0.3.2.tar.gz) = 4ddc33767900e7cd0a4cc0f4d808638d7cfcb746c23e12274c8eba0622eee2eb
+SIZE (sock-0.3.2.tar.gz) = 113640

Added: head/net/sock/files/patch-src__cliopen.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/sock/files/patch-src__cliopen.c	Tue May 24 16:59:54 2016	(r415801)
@@ -0,0 +1,264 @@
+--- src/cliopen.c.orig	2010-05-28 00:03:25 UTC
++++ src/cliopen.c
+@@ -10,42 +10,107 @@
+ 
+ #include "sock.h"
+ 
++/*
++ * Try to convert the host name as an IPv4 dotted-decimal number
++ * or an IPv6 address.
++ */
++int convert_host_address(char *host)
++{
++	struct in_addr		inaddr;
++	char			inaddr_buf[INET6_ADDRSTRLEN];
++
++	if (AF_INET == af_46) {
++		if (inet_pton(AF_INET, host, &inaddr) == 1) {
++			/* IPv4 dotted-decimal */
++			servaddr4.sin_addr = inaddr;
++
++			return (1);
++		}
++	} else {
++		if (inet_pton(AF_INET6, host, inaddr_buf) == 1) {
++			/* IPv6 address */
++			memcpy(&servaddr6.sin6_addr, inaddr_buf,
++			    sizeof(struct in6_addr));
++
++			return (1);
++		}
++	}
++
++	return (0);
++}
++
++/*
++ * Try to convert the host name as a host name string.
++ */
++int convert_host_name(char *host)
++{
++	struct hostent		*hp;
++
++	if (AF_INET == af_46) {
++		if ( (hp = gethostbyname2(host, AF_INET)) != NULL) {
++			/* IPv4 address */
++			memcpy(&servaddr4.sin_addr, hp->h_addr, hp->h_length);
++
++			return (1);
++		}
++	} else {
++		/*
++		 * Fixme:  This doesn't work on FreeBSD 8.4.
++		 * Only an IPv4 address is returned.
++		 * getaddrinfo() doesn't work either.
++		 */
++		if ( (hp = gethostbyname2(host, AF_INET6)) != NULL) {
++			/* IPv6 address */
++			memcpy(&servaddr6.sin6_addr, hp->h_addr, hp->h_length);
++
++			return (1);
++		}
++	}
++
++	return (0);
++}
++
+ int cliopen(char *host, char *port)
+ {
+ 	int			fd, i, on;
+ 	char			*protocol;
+-	struct in_addr		inaddr;
++	char			inaddr_buf[INET6_ADDRSTRLEN];
+ 	struct servent		*sp;
+-	struct hostent		*hp;
++	socklen_t		socklen;
+ 
+ 	protocol = udp ? "udp" : "tcp";
+   
+ 	/* initialize socket address structure */
+-	bzero(&servaddr, sizeof(servaddr));
+-	servaddr.sin_family = AF_INET;
++	bzero(&servaddr4, sizeof(servaddr4));
++	servaddr4.sin_family = AF_INET;
++
++	bzero(&servaddr6, sizeof(servaddr6));
++	servaddr6.sin6_family = AF_INET6;
+   
+ 	/* see if "port" is a service name or number */
+ 	if ( (i = atoi(port)) == 0) {
+ 		if ( (sp = getservbyname(port, protocol)) == NULL)
+-			err_quit("getservbyname() error for: %s/%s", port, protocol);
+-      
+-		servaddr.sin_port = sp->s_port;
+-	} else
+-		servaddr.sin_port = htons(i);
++			err_quit("getservbyname() error for: %s/%s",
++			    port, protocol);
++		servaddr4.sin_port  = sp->s_port;
++		servaddr6.sin6_port = sp->s_port;
++	} else {
++		servaddr4.sin_port  = htons(i);
++		servaddr6.sin6_port = htons(i);
++	}
+   
+ 	/*
+-	 * First try to convert the host name as a dotted-decimal number.
+-	 * Only if that fails do we call gethostbyname().
++	 * First try to convert the host name as an IPv4 dotted-decimal number
++	 * or an IPv6 address.  Only if that fails do we try to convert the
++	 * host name as a host name string.
+ 	 */
+-  
+-	if (inet_aton(host, &inaddr) == 1)
+-		servaddr.sin_addr = inaddr;	/* it's dotted-decimal */
+-	else if ( (hp = gethostbyname(host)) != NULL)
+-		bcopy(hp->h_addr, &servaddr.sin_addr, hp->h_length);
+-	else
+-		err_quit("invalid hostname: %s", host);
++	if (convert_host_address(host) != 1) {
++		if (convert_host_name(host) != 1) {
++			err_quit("invalid hostname: %s", host);
++		}
++	}
+ 
+-	if ( (fd = socket(AF_INET, udp ? SOCK_DGRAM : SOCK_STREAM, 0)) < 0)
++	if ( (fd = socket(af_46, udp ? SOCK_DGRAM : SOCK_STREAM, 0)) < 0)
+ 		err_sys("socket() error");
+ 
+ 	if (reuseaddr) {
+@@ -71,21 +136,46 @@ int cliopen(char *host, char *port)
+ 	 * (and port) using -l option.  Allow localip[] to be set but bindport
+ 	 * to be 0.
+ 	 */
+-	
+ 	if (bindport != 0 || localip[0] != 0 || udp) {
+-		bzero(&cliaddr, sizeof(cliaddr));
+-		cliaddr.sin_family      = AF_INET;
+-		cliaddr.sin_port        = htons(bindport);   /* can be 0 */
+-		if (localip[0] != 0) {
+-			if (inet_aton(localip, &cliaddr.sin_addr) == 0)
+-				err_quit("invalid IP address: %s", localip);
+-		} else
+-			cliaddr.sin_addr.s_addr = htonl(INADDR_ANY);	/* wildcard */
+-		
+-		if (bind(fd, (struct sockaddr *) &cliaddr, sizeof(cliaddr)) < 0)
+-			err_sys("bind() error");
++		if (af_46 == AF_INET) {
++			bzero(&cliaddr4, sizeof(cliaddr4));
++			cliaddr4.sin_family      = AF_INET;
++			/* can be 0 */
++			cliaddr4.sin_port        = htons(bindport);
++			if (localip[0] != 0) {
++				if (inet_aton(localip, &cliaddr4.sin_addr) == 0)
++					err_quit("invalid IP address: %s",
++					    localip);
++			} else {
++				/* wildcard */
++				cliaddr4.sin_addr.s_addr = htonl(INADDR_ANY);
++			}
++			if (bind(fd, (struct sockaddr *) &cliaddr4,
++				    sizeof(cliaddr4)) < 0) {
++				err_sys("bind() error");
++			}
++		} else {
++			bzero(&cliaddr6, sizeof(cliaddr6));
++			cliaddr6.sin6_len    = sizeof(struct sockaddr_in6);
++			cliaddr6.sin6_family = AF_INET6;
++			/* can be 0 */
++			cliaddr6.sin6_port   = htons(bindport);
++
++			/* Fixme:  localip not implemented for IPv6 */
++			cliaddr6.sin6_addr = in6addr_any;
++
++			/* Fixme:  Want to set IPV6_BINDANY? */
++
++			if (bind(fd, (struct sockaddr *) &cliaddr6,
++				    sizeof(cliaddr6)) < 0) {
++				err_sys("bind() error");
++			}
++		}
+ 	}
+-	
++
++	/* Fixme:  Does not work */
++	//join_mcast_client(fd, &cliaddr4, &cliaddr6, &servaddr4, &servaddr6);
++
+ 	/* Need to allocate buffers before connect(), since they can affect
+ 	 * TCP options (window scale, etc.).
+ 	 */
+@@ -96,13 +186,21 @@ int cliopen(char *host, char *port)
+ 	/*
+ 	 * Connect to the server.  Required for TCP, optional for UDP.
+ 	 */
+-	
+ 	if (udp == 0 || connectudp) {
+ 		for ( ; ; ) {
+-			if (connect(fd, (struct sockaddr *) &servaddr, sizeof(servaddr))
+-			    == 0)
++			if (AF_INET == af_46) {
++				if (connect(fd, (struct sockaddr *) &servaddr4,
++				    sizeof(servaddr4)) == 0)
+ 				break;		/* all OK */
+-			if (errno == EINTR)		/* can happen with SIGIO */
++			} else {
++				servaddr6.sin6_len =
++				    sizeof(struct sockaddr_in6);
++				servaddr6.sin6_family = AF_INET6;
++				if (connect(fd, (struct sockaddr *) &servaddr6,
++				    sizeof(servaddr6)) == 0)
++				break;		/* all OK */
++			}
++			if (errno == EINTR)	/* can happen with SIGIO */
+ 				continue;
+ 			if (errno == EISCONN)	/* can happen with SIGIO */
+ 				break;
+@@ -114,16 +212,38 @@ int cliopen(char *host, char *port)
+ 		/* Call getsockname() to find local address bound to socket:
+ 		   TCP ephemeral port was assigned by connect() or bind();
+ 		   UDP ephemeral port was assigned by bind(). */
+-		i = sizeof(cliaddr);
+-		if (getsockname(fd, (struct sockaddr *) &cliaddr, &i) < 0)
+-			err_sys("getsockname() error");
+-		
+-		/* Can't do one fprintf() since inet_ntoa() stores
+-		   the result in a static location. */
+-		fprintf(stderr, "connected on %s.%d ",
+-			INET_NTOA(cliaddr.sin_addr), ntohs(cliaddr.sin_port));
+-		fprintf(stderr, "to %s.%d\n",
+-			INET_NTOA(servaddr.sin_addr), ntohs(servaddr.sin_port));
++		if (AF_INET == af_46) {
++			socklen = sizeof(cliaddr4);
++			if (getsockname(fd,
++			    (struct sockaddr *) &cliaddr4, &socklen) < 0) {
++				err_sys("getsockname() error");
++			}
++			/* Can't do one fprintf() since inet_ntoa() stores
++			   the result in a static location. */
++			fprintf(stderr, "connected on %s.%d ",
++			    INET_NTOA(cliaddr4.sin_addr),
++			    ntohs(cliaddr4.sin_port));
++			fprintf(stderr, "to %s.%d\n",
++			    INET_NTOA(servaddr4.sin_addr),
++			    ntohs(servaddr4.sin_port));
++		} else {
++			socklen = sizeof(cliaddr6);
++			if (getsockname(fd,
++			    (struct sockaddr *) &cliaddr6, &socklen) < 0) {
++				err_sys("getsockname() error");
++			}
++
++			inet_ntop(AF_INET6,
++			    &cliaddr6.sin6_addr.__u6_addr.__u6_addr8,
++			    inaddr_buf, sizeof(inaddr_buf));
++			fprintf(stderr, "connected on %s.%d ",
++			    inaddr_buf, ntohs(cliaddr6.sin6_port));
++			inet_ntop(AF_INET6,
++			    &servaddr6.sin6_addr.__u6_addr.__u6_addr8,
++			    inaddr_buf, sizeof(inaddr_buf));
++			fprintf(stderr, "to %s.%d\n",
++			    inaddr_buf, ntohs(servaddr6.sin6_port));
++		}
+ 	}
+ 	
+ 	sockopts(fd, 1);	/* some options get set after connect() */

Added: head/net/sock/files/patch-src__loopudp.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/sock/files/patch-src__loopudp.c	Tue May 24 16:59:54 2016	(r415801)
@@ -0,0 +1,261 @@
+--- src/loopudp.c.orig	2010-05-28 00:03:25 UTC
++++ src/loopudp.c
+@@ -21,17 +21,28 @@
+ void
+ loop_udp(int sockfd)
+ {
+-	int maxfdp1, nread, ntowrite, stdineof, clilen, servlen, flags;
++	int maxfdp1, nread, ntowrite, stdineof, clilen, flags;
++	socklen_t		servlen;
+ 	fd_set			rset;
+-	struct sockaddr_in	cliaddr;		/* for UDP server */
+-	struct sockaddr_in	servaddr;		/* for UDP client */
++	struct sockaddr_in	cliaddr4;	/* for IPv4 UDP server */
++	struct sockaddr_in6	cliaddr6;	/* for IPv6 UDP server */
++	/*
++	 * The original local variable servaddr, and later servaddr4 and
++	 * servaddr6, were not initialized before use.  Using the initialized
++	 * global sockaddr structs allows the sendto() code, below, to work
++	 * correctly.  This was a problem with the original IPv4 code, and
++	 * later the IPv6 code.
++	 */
++	//struct sockaddr_in	servaddr4;	/* for IPv4 UDP client */
++	//struct sockaddr_in6	servaddr6;	/* for IPv6 UDP client */
++	char			inaddr_buf[INET6_ADDRSTRLEN];
+ 	
+-	struct iovec			iov[1];
+-	struct msghdr			msg;
++	struct iovec		iov[1];
++	struct msghdr		msg;
+ #ifdef	HAVE_MSGHDR_MSG_CONTROL	  	
+ #ifdef	IP_RECVDSTADDR		/* 4.3BSD Reno and later */
+ 	static struct cmsghdr  *cmptr = NULL;	/* malloc'ed */
+-	struct in_addr			dstinaddr;		/* for UDP server */
++	struct in_addr		dstinaddr;	/* for UDP server */
+ #define	CONTROLLEN	(sizeof(struct cmsghdr) + sizeof(struct in_addr))
+ #endif	/* IP_RECVDSTADDR */
+ 	
+@@ -68,8 +79,10 @@ loop_udp(int sockfd)
+ 						err_sys("shutdown() error");
+ 					
+ 					FD_CLR(STDIN_FILENO, &rset);
+-					stdineof = 1;	/* don't read stdin anymore */
+-					continue;		/* back to select() */
++					/* don't read stdin anymore */
++					stdineof = 1;
++					/* back to select() */
++					continue;
+ 				}
+ 				break;		/* default: stdin EOF -> done */
+ 			}
+@@ -77,23 +90,43 @@ loop_udp(int sockfd)
+ 			if (crlf) {
+ 				ntowrite = crlf_add(wbuf, writelen, rbuf, nread);
+ 				if (connectudp) {
+-					if (write(sockfd, wbuf, ntowrite) != ntowrite)
++					if (write(sockfd, wbuf, ntowrite) !=
++					    ntowrite) {
+ 						err_sys("write error");
++					}
+ 				} else {
+-					if (sendto(sockfd, wbuf, ntowrite, 0,
+-						   (struct sockaddr *) &servaddr, sizeof(servaddr))
+-					    != ntowrite)
+-						err_sys("sendto error");
++					if (af_46 == AF_INET) {
++						if (sendto(sockfd, wbuf, ntowrite, 0,
++						    (struct sockaddr *)&servaddr4,
++						    sizeof(servaddr4)) != ntowrite) {
++							err_sys("sendto error");
++						}
++					} else {
++						if (sendto(sockfd, wbuf, ntowrite, 0,
++						    (struct sockaddr *)&servaddr6,
++						    sizeof(servaddr6)) != ntowrite) {
++							err_sys("sendto error");
++						}
++					}
+ 				}
+ 			} else {
+ 				if (connectudp) {
+ 					if (write(sockfd, rbuf, nread) != nread)
+ 						err_sys("write error");
+ 				} else {
+-					if (sendto(sockfd, rbuf, nread, 0,
+-						   (struct sockaddr *) &servaddr, sizeof(servaddr))
+-					    != nread)
+-						err_sys("sendto error");
++					if (af_46 == AF_INET) {
++						if (sendto(sockfd, rbuf, nread, 0,
++						    (struct sockaddr *)&servaddr4,
++						    sizeof(servaddr4)) != nread) {
++							err_sys("sendto error");
++						}
++					} else {
++						if (sendto(sockfd, rbuf, nread, 0,
++						    (struct sockaddr *)&servaddr6,
++						    sizeof(servaddr6)) != nread) {
++							err_sys("sendto error");
++						}
++					}
+ 				}
+ 			}
+ 		}
+@@ -101,35 +134,54 @@ loop_udp(int sockfd)
+ 		if (FD_ISSET(sockfd, &rset)) {
+ 			/* data to read from socket */
+ 			if (server) {
+-				clilen = sizeof(cliaddr);
+-#ifndef	MSG_TRUNC	/* vanilla BSD sockets */
++				if (af_46 == AF_INET) {
++					clilen = sizeof(cliaddr4);
++				} else {
++					clilen = sizeof(cliaddr6);
++				}
++
++#ifndef	MSG_TRUNC /* vanilla BSD sockets */
++
++				/* Fixme:  Not ported for IPv6 */
++				/* Not compiled in for FreeBSD 8.4 */
+ 				nread = recvfrom(sockfd, rbuf, readlen, 0,
+-						 (struct sockaddr *) &cliaddr, &clilen);
+-	      
++				    (struct sockaddr *) &cliaddr4, &clilen);
++
+ #else	/* 4.3BSD Reno and later; use recvmsg() to get at MSG_TRUNC flag */
+-	      /* Also lets us get at control information (destination address) */
+-				
++	/* Also lets us get at control information (destination address) */
++
++				/* FreeBSD 8.4 */
+ 				iov[0].iov_base = rbuf;
+ 				iov[0].iov_len  = readlen;
+-				msg.msg_iov          = iov;
+-				msg.msg_iovlen       = 1;
+-				msg.msg_name         = (caddr_t) &cliaddr;
+-				msg.msg_namelen      = clilen;
+-				
++				msg.msg_iov     = iov;
++				msg.msg_iovlen  = 1;
++				if (af_46 == AF_INET) {
++					msg.msg_name = (caddr_t) &cliaddr4;
++				} else {
++					msg.msg_name = (caddr_t) &cliaddr6;
++				}
++				msg.msg_namelen = clilen;
++
+ #ifdef	HAVE_MSGHDR_MSG_CONTROL
+ #ifdef	IP_RECVDSTADDR
++				/* FreeBSD 8.4 */
+ 				if (cmptr == NULL && (cmptr = malloc(CONTROLLEN)) == NULL)
+ 					err_sys("malloc error for control buffer");
+ 
+-				msg.msg_control      = (caddr_t) cmptr;	/* for dest address */
++				/* for dest address */
++				msg.msg_control      = (caddr_t) cmptr;
+ 				msg.msg_controllen   = CONTROLLEN;
+ #else
+-				msg.msg_control      = (caddr_t) 0;	/* no ancillary data */
++				/* Not used for FreeBSD 8.4 */
++				/* no ancillary data */
++				msg.msg_control      = (caddr_t) 0;
+ 				msg.msg_controllen   = 0;
+ #endif	/* IP_RECVDSTADDR */
+ #endif
+ #ifdef HAVE_MSGHDR_MSG_FLAGS
+-				msg.msg_flags        = 0;			/* flags returned here */
++				/* FreeBSD 8.4 */
++				/* flags returned here */
++				msg.msg_flags        = 0;
+ #endif				
+ 				nread = recvmsg(sockfd, &msg, 0);
+ #endif	/* MSG_TRUNC */
+@@ -137,22 +189,39 @@ loop_udp(int sockfd)
+ 					err_sys("datagram receive error");
+ 				
+ 				if (verbose) {
+-					printf("from %s", INET_NTOA(cliaddr.sin_addr));
++					if (af_46 == AF_INET) {
++						printf("from %s",
++						    INET_NTOA(cliaddr4.sin_addr));
++					} else {
++			                        inet_ntop(AF_INET6,
++						    &cliaddr6.sin6_addr.
++						    __u6_addr.__u6_addr8,
++						    inaddr_buf,
++						    sizeof(inaddr_buf));
++						printf("from %s", inaddr_buf);
++					}
+ #ifdef	HAVE_MSGHDR_MSG_CONTROL
+ #ifdef	IP_RECVDSTADDR
++					/*
++					 * Fixme:  not ported for IPv6
++					 * Fixme:  recvdstaddr fails (earlier,
++					 *   in setsockopt()) for IPv6 under
++					 *   FreeBSD 8.4
++					 */
+ 					if (recvdstaddr) {
+ 						if (cmptr->cmsg_len != CONTROLLEN)
+ 							err_quit("control length (%d) != %d",
+-								 cmptr->cmsg_len, CONTROLLEN);
++							    cmptr->cmsg_len, CONTROLLEN);
+ 						if (cmptr->cmsg_level != IPPROTO_IP)
+ 							err_quit("control level != IPPROTO_IP");
+ 						if (cmptr->cmsg_type != IP_RECVDSTADDR)
+ 							err_quit("control type != IP_RECVDSTADDR");
+ 						bcopy(CMSG_DATA(cmptr), &dstinaddr,
+-						      sizeof(struct in_addr));
++						    sizeof(struct in_addr));
+ 						bzero(cmptr, CONTROLLEN);
+ 						
+-						printf(", to %s", INET_NTOA(dstinaddr));
++						printf(", to %s",
++						    INET_NTOA(dstinaddr));
+ 					}
+ #endif	/* IP_RECVDSTADDR */
+ #endif	/* HAVE_MSGHDR_MSG_CONTROL */
+@@ -178,15 +247,37 @@ loop_udp(int sockfd)
+ 				}
+ 	      
+ 			} else {
+-				/* Must use recvfrom() for unconnected UDP client */
+-				servlen = sizeof(servaddr);
+-				nread = recvfrom(sockfd, rbuf, readlen, 0,
+-						 (struct sockaddr *) &servaddr, &servlen);
+-				if (nread < 0)
++				/*
++				 * Must use recvfrom() for unconnected
++				 * UDP client
++				 */
++				/* Fixme:  not tested on FreeBSD 8.4 */
++				if (af_46 == AF_INET) {
++					servlen = sizeof(servaddr4);
++					nread = recvfrom(sockfd, rbuf, readlen,
++					    0, (struct sockaddr *)&servaddr4,
++					    &servlen);
++				} else {
++					servlen = sizeof(servaddr6);
++					nread = recvfrom(sockfd, rbuf, readlen,
++					    0, (struct sockaddr *)&servaddr6,
++					    &servlen)


[The entire original message is not included.]


More information about the svn-ports-head mailing list