diff options
author | Peter Pentchev <roam@FreeBSD.org> | 2005-07-01 17:13:34 +0000 |
---|---|---|
committer | Peter Pentchev <roam@FreeBSD.org> | 2005-07-01 17:13:34 +0000 |
commit | 43eafe775f89be73598602345adad7fb9764f33f (patch) | |
tree | b35869f74419d2c5bcae6ba2e8750db71465beb6 /net | |
parent | 39738ddbc529ca3e12db71f44c1b19e47b2ef753 (diff) | |
download | ports-43eafe775f89be73598602345adad7fb9764f33f.tar.gz ports-43eafe775f89be73598602345adad7fb9764f33f.zip |
Notes
Diffstat (limited to 'net')
-rw-r--r-- | net/datapipe/Makefile | 17 | ||||
-rw-r--r-- | net/datapipe/files/patch-datapipe.c | 53 |
2 files changed, 56 insertions, 14 deletions
diff --git a/net/datapipe/Makefile b/net/datapipe/Makefile index 16ce7fd0f162..c97bcf92b519 100644 --- a/net/datapipe/Makefile +++ b/net/datapipe/Makefile @@ -7,6 +7,7 @@ PORTNAME= datapipe PORTVERSION= 1.0 +PORTREVISION= 1 CATEGORIES= net MASTER_SITES= ftp://ftp.distributed.net/pub/dcti/unsupported/ \ http://http.distributed.net/pub/dcti/unsupported/ @@ -16,10 +17,24 @@ COMMENT= Bind a local port and connect it to a remote socket PLIST_FILES= bin/datapipe +OPTIONS= REUSEADDR "Reuse the listening socket address" on \ + NOFORK "Do not fork and background" off + +.include <bsd.port.pre.mk> + +.if defined(WITH_REUSEADDR) +CFLAGS+= -DDATAPIPE_REUSEADDR +.endif + +.if defined(WITH_NOFORK) +CFLAGS+= -DDATAPIPE_NOFORK +PKGNAMESUFFIX+=-nofork +.endif + do-build: ${CC} ${CFLAGS} -o ${WRKDIR}/${DISTNAME}/datapipe ${WRKDIR}/${DISTNAME}/datapipe.c do-install: ${INSTALL_PROGRAM} ${WRKSRC}/datapipe ${PREFIX}/bin -.include <bsd.port.mk> +.include <bsd.port.post.mk> diff --git a/net/datapipe/files/patch-datapipe.c b/net/datapipe/files/patch-datapipe.c index 04c9472983e0..2a89e28129de 100644 --- a/net/datapipe/files/patch-datapipe.c +++ b/net/datapipe/files/patch-datapipe.c @@ -1,5 +1,5 @@ ---- datapipe.c.orig Tue Jan 4 09:48:55 2000 -+++ datapipe.c Thu Jul 24 16:28:56 2003 +--- datapipe.c.orig Tue Jan 4 08:48:55 2000 ++++ datapipe.c Fri Jul 1 19:55:58 2005 @@ -59,6 +59,7 @@ #include <unistd.h> #include <netdb.h> @@ -17,7 +17,7 @@ #define IDLETIMEOUT 300 -@@ -88,7 +89,8 @@ +@@ -88,8 +89,12 @@ SOCKET lsock; char buf[4096]; struct sockaddr_in laddr, oaddr; @@ -25,18 +25,22 @@ + int i, lport, oport; + char *laddr_str, *oaddr_str; struct client_t clients[MAXCLIENTS]; ++#if defined(DATAPIPE_REUSEADDR) ++ int opt = 1; ++#endif -@@ -114,7 +116,7 @@ + #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) +@@ -114,7 +119,7 @@ /* determine the listener address and port */ bzero(&laddr, sizeof(struct sockaddr_in)); laddr.sin_family = AF_INET; - laddr.sin_port = htons((unsigned short) atol(argv[2])); -+ laddr.sin_port = htons((unsigned short) lport=atol(argv[2])); ++ laddr.sin_port = htons((unsigned short)(lport=atol(argv[2]))); laddr.sin_addr.s_addr = inet_addr(argv[1]); if (!laddr.sin_port) { fprintf(stderr, "invalid listener port\n"); -@@ -128,12 +130,13 @@ +@@ -128,12 +133,13 @@ } bcopy(n->h_addr, (char *) &laddr.sin_addr, n->h_length); } @@ -47,11 +51,11 @@ bzero(&oaddr, sizeof(struct sockaddr_in)); oaddr.sin_family = AF_INET; - oaddr.sin_port = htons((unsigned short) atol(argv[4])); -+ oaddr.sin_port = htons((unsigned short) oport=atol(argv[4])); ++ oaddr.sin_port = htons((unsigned short)(oport=atol(argv[4]))); if (!oaddr.sin_port) { fprintf(stderr, "invalid target port\n"); return 25; -@@ -147,6 +150,7 @@ +@@ -147,6 +153,7 @@ } bcopy(n->h_addr, (char *) &oaddr.sin_addr, n->h_length); } @@ -59,7 +63,7 @@ /* create the listener socket */ -@@ -154,6 +158,15 @@ +@@ -154,6 +161,21 @@ perror("socket"); return 20; } @@ -72,10 +76,33 @@ + setsockopt(lsock, SOL_SOCKET, SO_LINGER, + (const char *) &j, sizeof(j)); + } ++#if defined(DATAPIPE_REUSEADDR) ++ if (setsockopt(lsock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1) { ++ perror("setsockopt"); ++ return 20; ++ } ++#endif if (bind(lsock, (struct sockaddr *)&laddr, sizeof(laddr))) { perror("bind"); return 20; -@@ -180,7 +193,10 @@ +@@ -164,13 +186,14 @@ + } + + +- /* change the port in the listener struct to zero, since we will ++ /* change the port and address in the listener struct to zero, since we will + * use it for binding to outgoing local sockets in the future. */ + laddr.sin_port = htons(0); ++ laddr.sin_addr.s_addr = INADDR_ANY; + + + /* fork off into the background. */ +-#if !defined(__WIN32__) && !defined(WIN32) && !defined(_WIN32) ++#if !defined(__WIN32__) && !defined(WIN32) && !defined(_WIN32) && !defined(DATAPIPE_NOFORK) + if ((i = fork()) == -1) { + perror("fork"); + return 20; +@@ -180,7 +203,10 @@ setsid(); #endif @@ -87,7 +114,7 @@ /* main polling loop. */ while (1) { -@@ -203,15 +219,22 @@ +@@ -203,15 +229,22 @@ maxsock = (int) clients[i].osock; } if (select(maxsock + 1, &fdsr, NULL, NULL, &tv) < 0) { @@ -113,7 +140,7 @@ for (i = 0; i < MAXCLIENTS; i++) if (!clients[i].inuse) break; if (i < MAXCLIENTS) -@@ -219,16 +242,16 @@ +@@ -219,16 +252,16 @@ /* connect a socket to the outgoing host/port */ SOCKET osock; if ((osock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { @@ -133,7 +160,7 @@ closesocket(csock); closesocket(osock); } -@@ -239,9 +262,14 @@ +@@ -239,9 +272,14 @@ clients[i].inuse = 1; } } else { |