diff options
author | Gerrit Pape <pape@smarden.org> | 2008-03-30 23:06:24 +0000 |
---|---|---|
committer | Dmitry Bogatov <KAction@debian.org> | 2018-11-29 05:18:32 +0000 |
commit | a2670d6b2b9050b7d110ab7d732a65a96c9a03e3 (patch) | |
tree | b76afb0f16d00d4d3a778d37518a8d52830baec4 | |
parent | ea0237e72a0305379fa489dc18e93369e65ec5bd (diff) |
Import Debian changes 1:0.88-1~bpo40+1
ucspi-tcp (1:0.88-1~bpo40+1) etch-backports; urgency=low
* build for etch.
ucspi-tcp (1:0.88-1) unstable; urgency=low
* debian/changelog: add epoch 1 to supersede unofficial package.
* debian/rules: remove target configure:; use glibc by default instead
of dietlibc.
* debian/control: no longer Build-Depends: dietlibc.
* debian/gcc/: remove; obsolete.
* debian/rules: install programs into /usr/bin/.
* debian/rules: new target patch: apply diffs from debian/diff/, reverse
apply in target clean:.
* debian/diff/0001-error.h-include-errno.h-instead-of-extern-int.diff:
new; error.h: '#include <errno.h>' instead of 'extern int errno;'.
* debian/ucspi-tcp-man/: new; add manpages downloaded from
http://smarden.org/pape/djb/manpages/ucspi-tcp-0.88-man-20020317.tar.gz.
* debian/rules: install manpages from debian/ucspi-tcp-man/ into
/usr/share/man/man1/.
* debian/control: no longer Recommends: ucspi-tcp-doc; Replaces:
ucspi-tcp-doc.
* debian/implicit: add proper dependencies to support 'parallel build'
through make -j (thx Daniel Schepler for the patch).
* debian/rules: run dpkg-shlibdeps; remove debian/substvars in target
clean:.
* debian/control: Depends: ${shlibs:Depends}.
* debian/control: Standards-Version: 3.7.2.2.
* debian/copyright: rewrite copyright.
* debian/ucspi-tcp.README.Debian: remove reference to unofficial packages.
* debian/control: minor updates to descriptions.
* debian/diff/0002-rblsmtpd.c-don-t-use-a-the-default-rbl.maps.vix.com.diff:
new; rblsmtpd.c: don't use a the default rbl.maps.vix.com if run without
-r switch.
* first upload to Debian/main (closes: #459318).
* debian/ucspi-tcp.NEWS.Debian: new; package introduced to Debian/main,
mention how to put on hold if upgrade from non-free is not desired.
ucspi-tcp (0.88-zarge2) sarge; urgency=low
* build against sarge's dietlibc-dev (0.28-3).
ucspi-tcp (0.88-zarge1) sarge; urgency=low
* debian/rules: minor cleanup.
* debian/implicit: update to revision 1.10.
ucspi-tcp (0.88-zarge0.3) sarge; urgency=low
* debian/rules: stop using debhelper, use implicit rules.
* debian/implicit: new; implicit Makefile rules.
* debian/README.Debian, debian/docs: rename to debian/ucspi-tcp.*.
* debian/dirs: remove; obsolete.
* debian/copyright: minor.
* debian/control: no longer Build-Depends: dephelper; remove
Standards-Version.
ucspi-tcp (0.88-zarge0.2) sarge; urgency=low
* use diet libc.
* debian/rules: set up diet program as c compiler wrapper; conditionally
overwrite PATH to have diet program used as c compiler wrapper; minor
cleanup.
* debian/gcc/gcc*: new; diet program as c compiler wrapper.
* debian/control: Build-Depends: dietlibc-dev; no longer Depends:
${shlibs:Depends}.
ucspi-tcp (0.88-woody0.1) woody; urgency=low
* woody package; new Standards-Version: 3.5.2.
* just _recommend_ ucspi-tcp-doc.
135 files changed, 1917 insertions, 8621 deletions
@@ -216,40 +216,3 @@ wait_pid.c warn-auto.sh warn-shsgr x86cpuid.c -dns_ip6.c -dns_ipq6.c -dns_nd6.c -dns_sortip6.c -fmt_xlong.c -ip6_fmt.c -ip6_scan.c -scan_0x.c -socket_accept6.c -socket_bind6.c -socket_conn6.c -socket_local6.c -socket_recv6.c -socket_remote6.c -socket_send6.c -socket_tcp6.c -timeoutconn6.c -tryip6.c -haveip6.h2 -haveip6.h1 -remoteinfo6.c -addcr.1 -argv0.1 -date@.1 -delcr.1 -finger@.1 -fixcr.1 -http@.1 -mconnect.1 -recordio.1 -tcp-environ.5 -tcpcat.1 -tcpclient.1 -tcprules.1 -tcprulescheck.1 -tcpserver.1 -who@.1 @@ -76,14 +76,12 @@ byte.a: \ makelib byte_chr.o byte_copy.o byte_cr.o byte_diff.o byte_rchr.o \ byte_zero.o case_diffb.o case_diffs.o fmt_ulong.o ip4_fmt.o \ ip4_scan.o scan_ulong.o str_chr.o str_diff.o str_len.o str_start.o \ -uint16_pack.o uint16_unpack.o uint32_pack.o uint32_unpack.o \ -ip6_fmt.o scan_ip6.o scan_xlong.o fmt_xlong.o +uint16_pack.o uint16_unpack.o uint32_pack.o uint32_unpack.o ./makelib byte.a byte_chr.o byte_copy.o byte_cr.o \ byte_diff.o byte_rchr.o byte_zero.o case_diffb.o \ case_diffs.o fmt_ulong.o ip4_fmt.o ip4_scan.o scan_ulong.o \ str_chr.o str_diff.o str_len.o str_start.o uint16_pack.o \ - uint16_unpack.o uint32_pack.o uint32_unpack.o ip6_fmt.o \ - scan_ip6.o scan_xlong.o fmt_xlong.o + uint16_unpack.o uint32_pack.o uint32_unpack.o byte_chr.o: \ compile byte_chr.c byte.h @@ -183,13 +181,11 @@ compile delcr.c buffer.h exit.h dns.a: \ makelib dns_dfd.o dns_domain.o dns_dtda.o dns_ip.o dns_ipq.o \ dns_name.o dns_nd.o dns_packet.o dns_random.o dns_rcip.o dns_rcrw.o \ -dns_resolve.o dns_sortip.o dns_transmit.o dns_txt.o dns_ip6.o \ -dns_sortip6.o dns_nd6.o dns_ipq6.o +dns_resolve.o dns_sortip.o dns_transmit.o dns_txt.o ./makelib dns.a dns_dfd.o dns_domain.o dns_dtda.o dns_ip.o \ dns_ipq.o dns_name.o dns_nd.o dns_packet.o dns_random.o \ dns_rcip.o dns_rcrw.o dns_resolve.o dns_sortip.o \ - dns_transmit.o dns_txt.o dns_ip6.o dns_sortip6.o dns_nd6.o \ - dns_ipq6.o + dns_transmit.o dns_txt.o dns_dfd.o: \ compile dns_dfd.c error.h alloc.h byte.h dns.h stralloc.h gen_alloc.h \ @@ -261,7 +257,7 @@ taia.h tai.h uint64.h taia.h dns_transmit.o: \ compile dns_transmit.c socket.h uint16.h alloc.h error.h byte.h \ readwrite.h uint16.h dns.h stralloc.h gen_alloc.h iopause.h taia.h \ -tai.h uint64.h taia.h uint32.h +tai.h uint64.h taia.h ./compile dns_transmit.c dns_txt.o: \ @@ -502,15 +498,9 @@ exit.h fmt.h iopause.h taia.h tai.h uint64.h pathexec.h remoteinfo.o: \ compile remoteinfo.c fmt.h buffer.h socket.h uint16.h error.h \ iopause.h taia.h tai.h uint64.h timeoutconn.h uint16.h remoteinfo.h \ -stralloc.h gen_alloc.h uint16.h uint32.h +stralloc.h gen_alloc.h uint16.h ./compile remoteinfo.c -remoteinfo6.o: \ -compile remoteinfo6.c fmt.h buffer.h socket.h uint16.h error.h \ -iopause.h taia.h tai.h uint64.h timeoutconn.h uint16.h remoteinfo.h \ -stralloc.h gen_alloc.h uint16.h uint32.h - ./compile remoteinfo6.c - rts: \ warn-auto.sh rts.sh conf-home cat warn-auto.sh rts.sh \ @@ -567,43 +557,43 @@ trylsock.c compile load rm -f trylsock.o trylsock socket_accept.o: \ -compile socket_accept.c byte.h socket.h uint16.h uint32.h +compile socket_accept.c byte.h socket.h uint16.h ./compile socket_accept.c socket_bind.o: \ -compile socket_bind.c byte.h socket.h uint16.h uint32.h +compile socket_bind.c byte.h socket.h uint16.h ./compile socket_bind.c socket_conn.o: \ -compile socket_conn.c readwrite.h byte.h socket.h uint16.h uint32.h +compile socket_conn.c readwrite.h byte.h socket.h uint16.h ./compile socket_conn.c socket_delay.o: \ -compile socket_delay.c socket.h uint16.h uint32.h +compile socket_delay.c socket.h uint16.h ./compile socket_delay.c socket_listen.o: \ -compile socket_listen.c socket.h uint16.h uint32.h +compile socket_listen.c socket.h uint16.h ./compile socket_listen.c socket_local.o: \ -compile socket_local.c byte.h socket.h uint16.h uint32.h +compile socket_local.c byte.h socket.h uint16.h ./compile socket_local.c socket_opts.o: \ -compile socket_opts.c socket.h uint16.h uint32.h +compile socket_opts.c socket.h uint16.h ./compile socket_opts.c socket_remote.o: \ -compile socket_remote.c byte.h socket.h uint16.h uint32.h +compile socket_remote.c byte.h socket.h uint16.h ./compile socket_remote.c socket_tcp.o: \ -compile socket_tcp.c ndelay.h socket.h uint16.h uint32.h +compile socket_tcp.c ndelay.h socket.h uint16.h ./compile socket_tcp.c socket_udp.o: \ -compile socket_udp.c ndelay.h socket.h uint16.h uint32.h +compile socket_udp.c ndelay.h socket.h uint16.h ./compile socket_udp.c str_chr.o: \ @@ -720,9 +710,9 @@ warn-auto.sh tcpcat.sh conf-home chmod 755 tcpcat tcpclient: \ -load tcpclient.o remoteinfo6.o dns.a time.a unix.a \ -byte.a socket.lib byte.h timeoutconn6.o - ./load tcpclient remoteinfo6.o timeoutconn6.o dns.a time.a \ +load tcpclient.o remoteinfo.o timeoutconn.o dns.a time.a unix.a \ +byte.a socket.lib + ./load tcpclient remoteinfo.o timeoutconn.o dns.a time.a \ unix.a byte.a `cat socket.lib` tcpclient.o: \ @@ -730,7 +720,7 @@ compile tcpclient.c sig.h exit.h sgetopt.h subgetopt.h uint16.h fmt.h \ scan.h str.h ip4.h uint16.h socket.h uint16.h fd.h stralloc.h \ gen_alloc.h buffer.h error.h strerr.h pathexec.h timeoutconn.h \ uint16.h remoteinfo.h stralloc.h uint16.h dns.h stralloc.h iopause.h \ -taia.h tai.h uint64.h taia.h uint32.h +taia.h tai.h uint64.h taia.h ./compile tcpclient.c tcprules: \ @@ -752,9 +742,9 @@ stralloc.h gen_alloc.h ./compile tcprulescheck.c tcpserver: \ -load tcpserver.o rules.o remoteinfo6.o timeoutconn6.o cdb.a dns.a \ +load tcpserver.o rules.o remoteinfo.o timeoutconn.o cdb.a dns.a \ time.a unix.a byte.a socket.lib - ./load tcpserver rules.o remoteinfo6.o timeoutconn6.o cdb.a \ + ./load tcpserver rules.o remoteinfo.o timeoutconn.o cdb.a \ dns.a time.a unix.a byte.a `cat socket.lib` tcpserver.o: \ @@ -763,7 +753,7 @@ exit.h env.h prot.h open.h wait.h readwrite.h stralloc.h gen_alloc.h \ alloc.h buffer.h error.h strerr.h sgetopt.h subgetopt.h pathexec.h \ socket.h uint16.h ndelay.h remoteinfo.h stralloc.h uint16.h rules.h \ stralloc.h sig.h dns.h stralloc.h iopause.h taia.h tai.h uint64.h \ -taia.h uint32.h +taia.h ./compile tcpserver.c time.a: \ @@ -775,14 +765,9 @@ taia_less.o taia_now.o taia_pack.o taia_sub.o taia_uint.o timeoutconn.o: \ compile timeoutconn.c ndelay.h socket.h uint16.h iopause.h taia.h \ -tai.h uint64.h error.h timeoutconn.h uint16.h uint32.h +tai.h uint64.h error.h timeoutconn.h uint16.h ./compile timeoutconn.c -timeoutconn6.o: \ -compile timeoutconn6.c ndelay.h socket.h uint16.h iopause.h taia.h \ -tai.h uint64.h error.h timeoutconn.h uint16.h uint32.h - ./compile timeoutconn6.c - uint16_pack.o: \ compile uint16_pack.c uint16.h ./compile uint16_pack.c @@ -821,12 +806,7 @@ socket_conn.o socket_delay.o socket_listen.o socket_local.o \ socket_opts.o socket_remote.o socket_tcp.o socket_udp.o \ stralloc_cat.o stralloc_catb.o stralloc_cats.o stralloc_copy.o \ stralloc_eady.o stralloc_opyb.o stralloc_opys.o stralloc_pend.o \ -strerr_die.o strerr_sys.o subgetopt.o wait_nohang.o wait_pid.o \ -socket_conn6.o socket_bind6.o socket_accept6.o socket_recv6.o \ -socket_send6.o socket_local6.o socket_remote6.o socket_tcp6.o \ -socket_getifname.o socket_getifidx.o socket_v4mappedprefix.o \ -socket_ip4loopback.o socket_v6any.o socket_v6loopback.o \ -socket_udp6.o +strerr_die.o strerr_sys.o subgetopt.o wait_nohang.o wait_pid.o ./makelib unix.a alloc.o alloc_re.o buffer.o buffer_0.o \ buffer_1.o buffer_2.o buffer_copy.o buffer_get.o \ buffer_put.o env.o error.o error_str.o fd_copy.o fd_move.o \ @@ -839,12 +819,7 @@ socket_udp6.o socket_udp.o stralloc_cat.o stralloc_catb.o stralloc_cats.o \ stralloc_copy.o stralloc_eady.o stralloc_opyb.o \ stralloc_opys.o stralloc_pend.o strerr_die.o strerr_sys.o \ - subgetopt.o wait_nohang.o wait_pid.o socket_conn6.o \ - socket_bind6.o socket_accept6.o socket_recv6.o socket_send6.o \ - socket_local6.o socket_remote6.o socket_tcp6.o \ - socket_getifname.o socket_getifidx.o socket_v4mappedprefix.o \ - socket_ip4loopback.o socket_v6any.o socket_v6loopback.o \ - socket_udp6.o + subgetopt.o wait_nohang.o wait_pid.o wait_nohang.o: \ compile wait_nohang.c haswaitp.h @@ -860,110 +835,3 @@ warn-auto.sh who@.sh conf-home | sed s}HOME}"`head -1 conf-home`"}g \ > who@ chmod 755 who@ - -socket_conn6.o: \ -compile socket_conn6.c socket.h uint16.h haveip6.h error.h ip6.h \ -uint32.h - ./compile socket_conn6.c - -socket_bind6.o: \ -compile socket_bind6.c socket.h uint16.h haveip6.h error.h ip6.h \ -uint32.h - ./compile socket_bind6.c - -socket_accept6.o: \ -compile socket_accept6.c socket.h uint16.h haveip6.h error.h ip6.h \ -uint32.h - ./compile socket_accept6.c - -socket_recv6.o: \ -compile socket_recv6.c socket.h uint16.h haveip6.h error.h ip6.h \ -uint32.h - ./compile socket_recv6.c - -socket_send6.o: \ -compile socket_send6.c socket.h uint16.h haveip6.h error.h uint32.h - ./compile socket_send6.c - -socket_local6.o: \ -compile socket_local6.c socket.h uint16.h haveip6.h error.h uint32.h - ./compile socket_local6.c - -socket_remote6.o: \ -compile socket_remote6.c socket.h uint16.h haveip6.h error.h uint32.h - ./compile socket_remote6.c - -dns_sortip6.o: \ -compile dns_sortip6.c byte.h dns.h stralloc.h gen_alloc.h iopause.h \ -taia.h tai.h uint64.h taia.h - ./compile dns_sortip6.c - -dns_nd6.o: \ -compile dns_nd6.c byte.h fmt.h dns.h stralloc.h gen_alloc.h iopause.h \ -taia.h tai.h uint64.h taia.h - ./compile dns_nd6.c - -dns_ipq6.o: \ -compile dns_ipq6.c stralloc.h gen_alloc.h case.h byte.h str.h dns.h \ -stralloc.h iopause.h taia.h tai.h uint64.h taia.h ip6.h - ./compile dns_ipq6.c - -dns_ip6.o: \ -compile dns_ip6.c stralloc.h gen_alloc.h uint16.h byte.h dns.h \ -stralloc.h iopause.h taia.h tai.h uint64.h taia.h - ./compile dns_ip6.c - -fmt_xlong.o: \ -compile fmt_xlong.c scan.h - ./compile fmt_xlong.c - -scan_xlong.o: \ -compile scan_xlong.c scan.h - ./compile scan_xlong.c - -ip6_fmt.o: \ -compile ip6_fmt.c fmt.h ip6.h - ./compile ip6_fmt.c - -scan_ip6.o: \ -compile scan_ip6.c scan.h ip6.h - ./compile scan_ip6.c - -socket_tcp6.o: \ -compile socket_tcp6.c ndelay.h socket.h uint16.h uint32.h - ./compile socket_tcp6.c - -socket_udp6.o: \ -compile socket_udp6.c ndelay.h socket.h uint16.h uint32.h - ./compile socket_udp6.c - -haveip6.h: \ -tryip6.c choose compile haveip6.h1 haveip6.h2 - ./choose c tryip6 haveip6.h1 haveip6.h2 > haveip6.h - -socket_getifname.o: \ -compile socket_getifname.c socket.h uint16.h uint32.h - ./compile socket_getifname.c - -socket_getifidx.o: \ -compile socket_getifidx.c socket.h uint16.h uint32.h - ./compile socket_getifidx.c - -socket_ip4loopback.o: \ -compile socket_ip4loopback.c - ./compile socket_ip4loopback.c - -socket_v4mappedprefix.o: \ -compile socket_v4mappedprefix.c - ./compile socket_v4mappedprefix.c - -socket_v6any.o: \ -compile socket_v6any.c - ./compile socket_v6any.c - -socket_v6loopback.o: \ -compile socket_v6loopback.c - ./compile socket_v6loopback.c - -clean: - rm -f `cat TARGETS` @@ -1,33 +0,0 @@ -<</Contents [/c << /local_003a_002f_002fOfflineDocuments_002erss [/c << /ModDate [/t (D:20060130173814)] - /RSS [/c << /Description [/t (These are documents that I have taken offline)] - /Extension [/c << /http_003a_002f_002fns_002eadobe_002ecom_002fAcrobat_002fRSS_002fInbox_002f_003afeedUI [/t (local://OfflineTracker.js)] - /http_003a_002f_002fns_002eadobe_002ecom_002fAcrobat_002fRSS_002fInbox_002f_003amarkUnread [/t (false)] ->>] - /Items [/c <<>>] - /Title [/t (Offline Documents)] - /URL [/t (local://OfflineDocuments.rss)] ->>] - /State [/i 200] - /TTL [/i 10000] - /Type [/a /Internal] - /Verified [/b true] ->>] - /local_003a_002f_002fParticipantReviews_002erss [/c << /ModDate [/t (D:20060130173814)] - /RSS [/c << /Description [/t (These are document reviews that I am participating in)] - /Extension [/c << /http_003a_002f_002fns_002eadobe_002ecom_002fAcrobat_002fRSS_002fInbox_002f_003afeedUI [/t (local://ReviewTracker.js)] - /http_003a_002f_002fns_002eadobe_002ecom_002fAcrobat_002fRSS_002fInbox_002f_003amarkUnread [/t (false)] ->>] - /Items [/c <<>>] - /Title [/t (Participant Reviews)] - /URL [/t (local://ParticipantReviews.rss)] ->>] - /State [/i 200] - /TTL [/i 10000] - /Type [/a /Internal] - /Verified [/b true] ->>] ->>] -/Feeds [/c << /0 [/t (local://ParticipantReviews.rss)] - /1 [/t (local://OfflineDocuments.rss)] ->>] ->>
\ No newline at end of file @@ -169,31 +169,3 @@ instcheck it setup check -dns_ip6.o -dns_ipq6.o -dns_nd6.o -dns_sortip6.o -fmt_xlong.o -ip6_fmt.o -ip6_scan.o -scan_0x.o -socket_accept6.o -socket_bind6.o -socket_conn6.o -socket_local6.o -socket_recv6.o -socket_remote6.o -socket_send6.o -socket_tcp6.o -timeoutconn6.o -haveip6.h -remoteinfo6.o -socket_getifidx.o -socket_getifname.o -scan_ip6.o -scan_xlong.o -socket_ip4loopback.o -socket_udp6.o -socket_v4mappedprefix.o -socket_v6any.o -socket_v6loopback.o diff --git a/addcr.1 b/addcr.1 deleted file mode 100644 index 3bae1f7..0000000 --- a/addcr.1 +++ /dev/null @@ -1,22 +0,0 @@ -.TH addcr 1 -.SH NAME -addcr \- add a CR before each LF -.SH SYNOPSIS -.B addcr -.SH DESCRIPTION -.B addcr -inserts CR at the end of each line of input. -It does not insert CR at the end of a partial final line. -.SH COMPATIBILITY -Some vendors ship -.B unix2dos -or -.B bsd2dos -tools similar to -.BR addcr . -Those tools often blow up on long lines and nulls. -.B addcr -has no trouble with long lines and nulls. -.SH "SEE ALSO" -delcr(1), -fixcr(1) diff --git a/argv0.1 b/argv0.1 deleted file mode 100644 index ad9634d..0000000 --- a/argv0.1 +++ /dev/null @@ -1,47 +0,0 @@ -.TH argv0 1 -.SH NAME -argv0 \- run a program with a specified 0th argument -.SH SYNOPSIS -.B argv0 -.I realname -.I zero -[ -.I arg ... -] -.SH DESCRIPTION -.B argv0 -runs -the program stored as -.I realname -on disk, -with the given -arguments. -It sets the 0th argument of -the program to -.IR zero . - -For example, - -.EX - argv0 /bin/csh -bin/csh -.EE - -runs -.B /bin/csh -with a 0th argument of -.BR -bin/csh . -.B csh -will think it is a login shell -and behave accordingly. - -.B argv0 -can be used to run some -.B inetd -wrappers under -.BR tcpserver . -.SH "SEE ALSO" -csh(1), -tcpserver(1), -execve(2), -execvp(3), -inetd(8) @@ -1,4 +1,4 @@ -/usr +/usr/local This is the ucspi-tcp home directory. Programs will be installed in .../bin. diff --git a/date@.1 b/date@.1 deleted file mode 100644 index fa0ba98..0000000 --- a/date@.1 +++ /dev/null @@ -1,32 +0,0 @@ -.TH date@ 1 -.SH NAME -date@ \- print the date on a host -.SH SYNTAX -.B date@ -[ -.I host -] -.SH DESCRIPTION -.B date@ -connects to TCP port 13 (Daytime) on -.I host -and prints any data it receives. -It removes CR and converts unprintable characters to a visible format. - -If -.I host -is not supplied, -.B date@ -connects to the local host. - -Some computers respond to port 13 with a human-readable date. -For example, they may be running - -.EX - tcpserver 0 13 date & -.EE -.SH "SEE ALSO" -cat(1), -delcr(1), -tcpclient(1), -tcpserver(1) diff --git a/debian/README-src b/debian/README-src deleted file mode 100644 index 09dc364..0000000 --- a/debian/README-src +++ /dev/null @@ -1,13 +0,0 @@ -This is a feeble little package that just contains a script to unpack -and build #PACKAGE# from source, so that we don't violate Dan Bernstein's -`no binary distribution, without approval' restriction. - -Hopefully this will help allow a binary package to be approved, but -even if it doesn't it means that Debian users can use #PACKAGE# without -too much effort. - -To generate the real binary package, just run: - - build-#PACKAGE# - -Jon Marler <jmarler@debian.org> diff --git a/debian/addcr.1 b/debian/addcr.1 deleted file mode 100644 index 51e52ea..0000000 --- a/debian/addcr.1 +++ /dev/null @@ -1,21 +0,0 @@ -.TH addcr 1 -.SH NAME -addcr \- copy stdin to stdout adding \\r chars after all \\n -.SH SYNOPSIS -.B addcr -.SH DESCRIPTION -.B addcr -reads stdin, adds \\r chars after any \\n and copies all to stdout. - -.SH DIAGNOSTICS -.PP -Returns zero on success, or 111 if an error occurred. - -.SH "SEE ALSO" -.BR delcr (1) - -.SH AUTHOR -Written by D. J. Bernstein <djb@pobox.com>. - -Manual page added by Roberto Lumbreras <rover@debian.org>. - diff --git a/debian/build-PACKAGE b/debian/build-PACKAGE deleted file mode 100644 index 94fa949..0000000 --- a/debian/build-PACKAGE +++ /dev/null @@ -1,195 +0,0 @@ -#!/bin/bash -e -# -# build-<package> -# -# $Id: build-PACKAGE,v 1.5 1998/05/01 08:35:36 phil Exp $ -# -# Written by Philip Hands <phil@hands.com> -# Copyright (C) 1998 Free Software Foundation, Inc. -# Copying: GPL - -# ask_user --- function prompts the user with y/n style prompt -# -# It's behaviour is controlled via the parameters: -# 1 - the initial prompt -# 2 - default return value (set to 0, 1 or "none") -# 3 - the patern match for acceptable Yes responses -# 4 - the patern match for acceptable No responses -# 5 - the error prompt, displayed when the user fails to provide valid input -# -# e.g. ask_user "Foo, or Bar [fb] " none '[fF]*' '[bB]*' "try again" - -ask_user() { - P=${1:-'Should I do this ? [yN] '} - D=${2:-1} - Y=${3:-'[yY]*'} - N=${4:-'[nN]*'} - E=${5:-'\nPlease enter either y)es or n)o, followed by <RETURN>\n'} - - while true ; do - echo -ne "$P" - read response - case "$response" in - ${Y} ) return 0 ;; - ${N} ) return 1 ;; - "" ) [ "$D" = 0 -o "$D" = 1 ] && return $D ;; - esac - echo -e $E - done -} - -package=${0##*build-} -NEWDIR=/tmp/$package - -cat <<!END! - -This script unpacks the ${package} source into a directory, and -compiles it to produce a binary ${package}*.deb file. - -The directory where this is done will end up containing the source -and package files for the $package binary package, along with a -directory containing the unpacked source. - -!END! - -line=kjfdsh -read -e -p "Enter a directory where you would like to do this [$NEWDIR] " line -NEWDIR="${line:-$NEWDIR}" - -if test -d $NEWDIR -then - ask_user "$NEWDIR already exists, should I use it anyway ? [yN] " || { - echo -e "\nPlease fix it and run $0 again\n" - exit 1 - } -else - mkdir $NEWDIR -fi - -cd $NEWDIR -dpkg-source -x /usr/src/${package}-src/${package}_*.dsc -cd ${package}-* - -CANBEROOT=no -SU="" -if [ 0 = `id -u` ] -then - BUILDROOT="" - CANBEROOT=yes -else - hash fakeroot 2>/dev/null && HAVE_FAKEROOT=fakeroot || HAVE_FAKEROOT="" - hash sudo 2>/dev/null && HAVE_SUDO=sudo || HAVE_SUDO="" - if [ -n "$HAVE_FAKEROOT" -a -n "$HAVE_SUDO" ] - then - echo "" - if ask_user "Should I use sudo or fakeroot to build the package ? [sF] " 1 '[sS]*' '[fF]*' "\nPlease enter either s)udo or f)akeroot, followed by <RETURN>\n" - then - BUILDROOT=sudo - else - BUILDROOT=fakeroot - fi - elif [ -n "$HAVE_FAKEROOT" -o -n "$HAVE_SUDO" ] - then - BUILDROOT="${HAVE_FAKEROOT:-$HAVE_SUDO}" - else - # sanity check, dependencies should provide one of them - echo "" - echo 'oops! you have not installed fakeroot or sudo!' - echo "" - exit 1 - fi - - if [ -n "$HAVE_SUDO" ] - then - cat<<!END! - -In addition to building the package, there are certain other actions that -you may want me to do (i.e. installing the new package) that need real root -access. If you want, I can a achieve this by use of sudo. - -In each case, you will be prompted before I attempt one of these actions - -!END! - if ask_user "Should I use sudo to gain real root access when required ? [Yn] " 0 - then - SU=sudo - CANBEROOT=yes - fi - fi -fi - -echo "" -cd $NEWDIR -dpkg-source -x /usr/src/${package}-src/${package}*.dsc -cd ${package}-* - -echo "" -echo "Binary package $package will be compiled now" -echo "This can take long time, depending on your machine" -echo "" -echo -n "Press ENTER to continue..." -read blah - -$BUILDROOT debian/rules binary-arch - -cd .. - -if [ -f ${package}*.deb ] -then - echo "" - echo "It seems that all went ok" - echo "" -else - echo "" - echo "Some error happened, stopping here." - echo "" - exit 1 -fi - -if ask_user "Do you want to remove all files in $NEWDIR,\nexcept `echo ${package}*.deb` now? [Yn] " 0 -then - [ "$BUILDROOT" = sudo ] && ROOT4RM=sudo - echo -n "Removing files... " - $ROOT4RM rm -rf ./${package}-*/ - $ROOT4RM rm -f ./${package}*{.dsc,.diff.gz,.orig.tar.gz} - echo "done" -fi - -echo "" - -if [ "$CANBEROOT" = yes ] -then - if ask_user "Do you want to install `echo ${package}*.deb` now? [Yn] " 0 - then - $SU dpkg --install ${package}*.deb || true - fi -else - echo "`echo ${package}*.deb` is in $NEWDIR" - echo "You have to execute the following to install it, being root:" - echo "" - echo " dpkg --install `echo ${package}*.deb`" -fi - -echo "" - -if [ "$CANBEROOT" = yes ] -then - if ask_user "Do you want to purge ${package}-src now? [yN] " 1 - then - $SU dpkg --purge ${package}-src || true - fi -else - echo "" - echo "You can now remove package ${package}-src running as root" - echo "" - echo " dpkg --remove ${package}-src" -fi - -echo "" -echo "Remember that you can install `echo ${package}*.deb`" -echo "on other computers so you don't need to compile it again." -echo "" -echo 'Good luck!' -echo "" - -exit 0 diff --git a/debian/changelog b/debian/changelog index 6565fa1..344e324 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,126 +1,128 @@ -ucspi-tcp (0.88-13) unstable; urgency=high +ucspi-tcp (1:0.88-1~bpo40+1) etch-backports; urgency=low - * Added patch to fix VERY dead default RBL (Closes: #410125) - * Updated control file - * Cleaned up rules script to allow autobuilding - * Removed old usr/doc symlink code + * build for etch. - -- Jon Marler <jmarler@debian.org> Wed, 7 Feb 2007 16:50:27 -0600 + -- Gerrit Pape <pape@smarden.org> Sun, 30 Mar 2008 23:06:24 +0000 -ucspi-tcp (0.88-12) unstable; urgency=low +ucspi-tcp (1:0.88-1) unstable; urgency=low - * Fix to allow building -src package without building binary package + * debian/changelog: add epoch 1 to supersede unofficial package. + * debian/rules: remove target configure:; use glibc by default instead + of dietlibc. + * debian/control: no longer Build-Depends: dietlibc. + * debian/gcc/: remove; obsolete. + * debian/rules: install programs into /usr/bin/. + * debian/rules: new target patch: apply diffs from debian/diff/, reverse + apply in target clean:. + * debian/diff/0001-error.h-include-errno.h-instead-of-extern-int.diff: + new; error.h: '#include <errno.h>' instead of 'extern int errno;'. + * debian/ucspi-tcp-man/: new; add manpages downloaded from + http://smarden.org/pape/djb/manpages/ucspi-tcp-0.88-man-20020317.tar.gz. + * debian/rules: install manpages from debian/ucspi-tcp-man/ into + /usr/share/man/man1/. + * debian/control: no longer Recommends: ucspi-tcp-doc; Replaces: + ucspi-tcp-doc. + * debian/implicit: add proper dependencies to support 'parallel build' + through make -j (thx Daniel Schepler for the patch). + * debian/rules: run dpkg-shlibdeps; remove debian/substvars in target + clean:. + * debian/control: Depends: ${shlibs:Depends}. + * debian/control: Standards-Version: 3.7.2.2. + * debian/copyright: rewrite copyright. + * debian/ucspi-tcp.README.Debian: remove reference to unofficial packages. + * debian/control: minor updates to descriptions. + * debian/diff/0002-rblsmtpd.c-don-t-use-a-the-default-rbl.maps.vix.com.diff: + new; rblsmtpd.c: don't use a the default rbl.maps.vix.com if run without + -r switch. + * first upload to Debian/main (closes: #459318). + * debian/ucspi-tcp.NEWS.Debian: new; package introduced to Debian/main, + mention how to put on hold if upgrade from non-free is not desired. - -- Jon Marler <jmarler@debian.org> Thu, 21 Dec 2006 17:13:33 -0600 + -- Gerrit Pape <pape@smarden.org> Wed, 09 Jan 2008 21:26:17 +0000 -ucspi-tcp (0.88-11) unstable; urgency=low +ucspi-tcp (0.88-zarge2) sarge; urgency=low - * Removed information about building to comply with policy 3.9 (Closes: - #402339) + * build against sarge's dietlibc-dev (0.28-3). - -- Jon Marler <jmarler@debian.org> Tue, 12 Dec 2006 19:34:54 -0600 + -- Gerrit Pape <pape@smarden.org> Thu, 26 May 2005 19:01:37 +0000 -ucspi-tcp (0.88-10) unstable; urgency=low +ucspi-tcp (0.88-zarge1) sarge; urgency=low - * Added IPV6 Patch (Closes: #151550) - * New man pages included with IPV6 patch (Closes: #142736) - * Added man pages back into build script (Closes: #105610) - * Moved ucspi-tcp-misc programs into ucspi-tcp package (Closes: #255707) + * debian/rules: minor cleanup. + * debian/implicit: update to revision 1.10. - -- Jon Marler <jmarler@debian.org> Mon, 30 Jan 2006 16:43:31 -0600 + -- Gerrit Pape <pape@smarden.org> Sun, 15 Aug 2004 18:18:36 +0000 -ucspi-tcp (0.88-9) unstable; urgency=low +ucspi-tcp (0.88-zarge0.3) sarge; urgency=low - * Added patch to increase logging for rblsmtpd from dean-debian@arctic.org + * debian/rules: stop using debhelper, use implicit rules. + * debian/implicit: new; implicit Makefile rules. + * debian/README.Debian, debian/docs: rename to debian/ucspi-tcp.*. + * debian/dirs: remove; obsolete. + * debian/copyright: minor. + * debian/control: no longer Build-Depends: dephelper; remove + Standards-Version. - -- Jon Marler <jmarler@debian.org> Mon, 29 Dec 2003 14:28:04 -0600 + -- Gerrit Pape <pape@smarden.org> Mon, 22 Mar 2004 14:25:30 +0000 -ucspi-tcp (0.88-8) unstable; urgency=low +ucspi-tcp (0.88-zarge0.2) sarge; urgency=low - * Added -isp to dpkg-gencontrol + * use diet libc. + * debian/rules: set up diet program as c compiler wrapper; conditionally + overwrite PATH to have diet program used as c compiler wrapper; minor + cleanup. + * debian/gcc/gcc*: new; diet program as c compiler wrapper. + * debian/control: Build-Depends: dietlibc-dev; no longer Depends: + ${shlibs:Depends}. - -- Jon Marler <jmarler@debian.org> Mon, 3 Feb 2003 09:57:27 -0600 + -- Gerrit Pape <pape@smarden.org> Wed, 12 Nov 2003 12:58:36 +0000 -ucspi-tcp (0.88-7) unstable; urgency=low +ucspi-tcp (0.88-woody0.1) woody; urgency=low - * Applied patch from Jurriaan <thunder7@xs4all.nl> (Closes: #174529) + * woody package; new Standards-Version: 3.5.2. + * just _recommend_ ucspi-tcp-doc. - -- Jon Marler <jmarler@debian.org> Thu, 2 Jan 2003 03:02:05 -0600 + -- Gerrit Pape <pape@smarden.org> Mon, 15 Oct 2001 14:01:04 +0200 -ucspi-tcp (0.88-6) testing unstable; urgency=low +ucspi-tcp (0.88-1) stable; urgency=low - * Added libc6-dev to depends (closes #105598) + * 1st debian version, no other changes. - -- Jon Marler <jmarler@debian.org> Mon, 28 Oct 2002 15:57:31 -0600 + -- Gerrit Pape <pape@innominate.com> Thu, 1 Feb 2001 10:03:07 +0100 -ucspi-tcp (0.88-5) testing unstable; urgency=low +ucspi-tcp (0.88-0.7) unstable; urgency=low - * Fixed symlink from /usr/share/doc to /usr/doc (closes #102454) + * binaries are now installed in /usr/local/bin. - -- Jon Marler <jmarler@debian.org> Wed, 27 Jun 2001 17:50:48 -0500 + -- Gerrit Pape <pape@innominate.com> Mon, 18 Dec 2000 11:13:26 +0100 -ucspi-tcp (0.88-4) unstable; urgency=low +ucspi-tcp (0.88-0.6) unstable; urgency=low - * Applied rss patch to allow rblsmtpd to use A records - * Removed "-R" advertisement from rblsmtpd + * home of binaries is /usr. - -- Jon Marler <jmarler@debian.org> Tue, 26 Jun 2001 13:32:42 -0500 + -- Gerrit Pape <pape@innominate.de> Tue, 22 Aug 2000 12:56:23 +0200 -ucspi-tcp (0.88-3) unstable; urgency=low +ucspi-tcp (0.88-0.5) unstable; urgency=low - * Moved docs to /usr/share/doc + * removed all documentation -> will be in ucspi-tcp-doc. - -- Jon Marler <jmarler@debian.org> Mon, 26 Mar 2001 11:32:41 -0600 + -- Gerrit Pape <pape@innominate.de> Mon, 14 Aug 2000 15:48:46 +0200 -ucspi-tcp (0.88-2) unstable; urgency=low +ucspi-tcp (0.88-0.4) unstable; urgency=low - * Fixed dependancy (closes #71949) + * forgotten man-pages for rblsmtpd, addcr, delcr added. - -- Jon Marler <jmarler@debian.org> Mon, 18 Dec 2000 15:03:16 -0600 + -- Gerrit Pape <pape@innominate.de> Tue, 4 Jul 2000 18:58:12 +0200 -ucspi-tcp (0.88-1) unstable; urgency=low +ucspi-tcp (0.88-0.3) unstable; urgency=low - * New upstream release. - * Many changes. See http://cr.yp.to/ucspi-tcp/upgrade.html - * Now conflicts with rblsmtpd. rblsmtpd is included with ucspi-tcp + * man-pages added. - -- Jon Marler <jmarler@debian.org> Mon, 18 Dec 2000 12:34:10 -0600 + -- Gerrit Pape <pape@innominate.de> Tue, 25 Apr 2000 09:23:02 +0200 -ucspi-tcp (0.84-1) unstable; urgency=low +ucspi-tcp (0.88-0.2) unstable; urgency=low - * New upstream release (closes: #34076) - * New maintainer + * Initial Release. - -- Jon Marler <jmarler@debian.org> Tue, 6 Jul 1999 11:58:37 +0100 + -- Gerrit Pape <pape@innominate.de> Fri, 24 Mar 2000 13:05:58 +0100 -ucspi-tcp (0.80-4) unstable; urgency=low - - * get rid of RBL patch, at Dan Bernstein's request - - -- Philip Hands <phil@hands.com> Mon, 22 Jun 1998 20:04:44 +0100 - -ucspi-tcp (0.80-3) unstable; urgency=low - - * fix the distribution, from non-free, to unstable - - -- Philip Hands <phil@hands.com> Fri, 1 May 1998 09:24:49 +0100 - -ucspi-tcp (0.80-2) non-free; urgency=low - - * tidy up rules file, so no hand editing of .changes is needed to exclude - the non-distributable binary file - * get rid of dependancy on debmake - - -- Philip Hands <phil@hands.com> Fri, 20 Mar 1998 12:01:47 +0000 - -ucspi-tcp (0.80-1) non-free; urgency=low - - * new package - * includes tcpserver with RBL support (see: http://www.qmail.org/rbl/) - - -- Philip Hands <phil@hands.com> Sat, 14 Mar 1998 11:43:56 +0000 - -Local variables: -mode: debian-changelog -add-log-mailing-address: "jmarler@debian.org" -End: diff --git a/debian/control b/debian/control index fc98ba2..73734d7 100644 --- a/debian/control +++ b/debian/control @@ -1,34 +1,36 @@ Source: ucspi-tcp -Section: non-free/net +Section: net Priority: optional -Maintainer: Jon Marler <jmarler@debian.org> -Build-Depends: dpkg-dev (>= 1.4.0.20), patch (>= 2.5-0bo1), gcc, make, fakeroot | sudo, groff-base, adduser -Standards-Version: 3.7.2 +Maintainer: Gerrit Pape <pape@smarden.org> +Standards-Version: 3.7.2.2 -Package: ucspi-tcp-src -Architecture: all -Priority: optional -Depends: dpkg-dev (>= 1.4.0.20), patch (>= 2.5-0bo1), fakeroot | sudo, gcc, make, libc6-dev -Section: non-free/net -Description: Source only package for building ucspi-tcp binary package - Written by Dan J. Bernstein, tcpclient and tcpserver are - powerful easy-to-use command-line tools for building TCP - client-server applications. tcpserver provides TCP access control - features, similar to tcp-wrappers/tcpd's hosts.allow but much - faster; it can run high-availability services much better than - inetd. +Package: ucspi-tcp +Architecture: any +Depends: ${shlibs:Depends} +Replaces: ucspi-tcp-doc +Description: command-line tools for building TCP client-server applications + tcpserver waits for incoming connections and, for each connection, runs a + program of your choice. Your program receives environment variables showing + the local and remote host names, IP addresses, and port numbers. + . + tcpserver offers a concurrency limit to protect you from running out of + processes and memory. When you are handling 40 (by default) simultaneous + connections, tcpserver smoothly defers acceptance of new connections. + . + tcpserver also provides TCP access control features, similar to + tcp-wrappers/tcpd's hosts.allow but much faster. Its access control rules + are compiled into a hashed format with cdb, so it can easily deal with + thousands of different hosts. . - Real-time Blocking List support is also included in tcpserver, so - you can run qmail-smtpd with it and avoid a lot of SPAM. + This package includes a recordio tool that monitors all the input and output + of a server. . - tcpclient and tcpserver conform to UCSPI, the UNIX Client-Server - Program Interface, using the TCP protocol. + tcpclient makes a TCP connection and runs a program of your choice. It sets + up the same environment variables as tcpserver. . - Dan Bernstein (ucspi-tcp's author) only gives permission for his code - to be distributed in source form, or binary by approval. This package - has been put together to allow people to easily build a binary - package for themselves, from source. + This package includes several sample clients built on top of tcpclient: + who@, date@, finger@, http@, tcpcat, and mconnect. . - If there is a package called ucspi-tcp available, then Dan has approved the - binary version of the package for distribution, so you might as well install - that and save yourself some effort. + tcpserver and tcpclient conform to UCSPI, the UNIX Client-Server Program + Interface, using the TCP protocol. UCSPI tools are + available for several different networks. diff --git a/debian/control.real b/debian/control.real deleted file mode 100644 index 1fed3ab..0000000 --- a/debian/control.real +++ /dev/null @@ -1,58 +0,0 @@ -Source: ucspi-tcp -Section: non-free/net -Priority: optional -Maintainer: Jon Marler <jmarler@debian.org> -Build-Depends: dpkg-dev (>= 1.4.0.20), patch (>= 2.5-0bo1), gcc, make, fakeroot | sudo, groff-base, adduser -Standards-Version: 3.7.2 - -Package: ucspi-tcp -Architecture: any -Depends: ${shlibs:Depends} -Section: non-free/net -Priority: optional -Provides: rblsmtpd -Conflicts: rblsmtpd -Description: tools for building TCP client-server applications. - Written by Dan J. Bernstein, tcpclient and tcpserver are - powerful easy-to-use command-line tools for building TCP - client-server applications. tcpserver provides TCP access control - features, similar to tcp-wrappers/tcpd's hosts.allow but much - faster; it can run high-availability services much better than - inetd. - . - Real-time Blocking List support is also included in tcpserver, so - you can run qmail-smtpd with it and avoid a lot of SPAM. - . - tcpclient and tcpserver conform to UCSPI, the UNIX Client-Server - Program Interface, using the TCP protocol. - . - Note that this package cannot be distributed it in - binary form without Dan Bernstein's permission. - -Package: ucspi-tcp-src -Architecture: all -Priority: optional -Depends: dpkg-dev (>= 1.4.0.20), patch (>= 2.5-0bo1), fakeroot | sudo, gcc, make, libc6-dev -Section: non-free/net -Description: Source only package for building ucspi-tcp binary package - Written by Dan J. Bernstein, tcpclient and tcpserver are - powerful easy-to-use command-line tools for building TCP - client-server applications. tcpserver provides TCP access control - features, similar to tcp-wrappers/tcpd's hosts.allow but much - faster; it can run high-availability services much better than - inetd. - . - Real-time Blocking List support is also included in tcpserver, so - you can run qmail-smtpd with it and avoid a lot of SPAM. - . - tcpclient and tcpserver conform to UCSPI, the UNIX Client-Server - Program Interface, using the TCP protocol. - . - Dan Bernstein (ucspi-tcp's author) only gives permission for his code - to be distributed in source form, or binary by approval. This package - has been put together to allow people to easily build a binary - package for themselves, from source. - . - If there is a package called ucspi-tcp available, then Dan has approved the - binary version of the package for distribution, so you might as well install - that and save yourself some effort. diff --git a/debian/copyright b/debian/copyright index 80bbc26..d75466e 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,47 +1,21 @@ -This is the Debian GNU/Linux version of ucspi-tcp, a set of -command-line tools for building TCP client-server applications, -packaged by Philip Hands <phil@hands.com> with help from -Roberto Lumbreras <rover@debian.org>. +This package was debianized by Gerrit Pape <pape@smarden.org> on +Fri, 24 Mar 2000 13:05:58 +0100. -This package provides "tcpserver-rbl", which includes RBL support. -See http://maps.vix.com/rbl/ and http://www.qmail.org/rbl/ for -more information about RBL. +It was downloaded from + http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz -This package was put together from sources obtained from: - ftp://koobera.math.uic.edu/www/software/ucspi-tcp-0.84.tar.gz +Upstream Author: D. J. Bernstein <djb@cr.yp.to> -Changes for Debian: - * added Debian GNU/Linux package maintenance system files - * added manual pages for addcr/delcr +The man-pages in debian/ucspi-tcp-man/ were downloaded from + http://smarden.org/pape/djb/manpages/ucspi-tcp-0.88-man-20020317.tar.gz -Copyrights ----------- +Copyright: -* ucspi-tcp: -Copyright (C) 1998 D. J. Bernstein <djb@pobox.com> +D. J. Bernstein placed the ucspi-tcp package into the public domain. +From http://cr.yp.to/distributors.html + What are the distribution terms for ucspi-tcp? + 2007.12.28: I hereby place the ucspi-tcp package (in particular, + ucspi-tcp-0.88.tar.gz, with MD5 checksum 39b619147db54687c4a583a7a94c9163) + into the public domain. The package is no longer copyrighted. -* modifications for Debian: - Copyright (C) 1998 Software in the Public Interest <http://www.debian.org> - - -License -------- - -* ucspi-tcp: - -Like any other piece of software (and information generally), ucspi-tcp -comes with NO WARRANTY. - -Dan Bernstein grants any use of ucspi-tcp, including patching and -distributing diffs; but he doesn't allow binary distributions -without his approval. See http://pobox.com/~djb/softwarelaw.html - -* Modifications for Debian: - -GPL. - -A copy of the GNU General Public License is available as -`/usr/share/doc/copyright/GPL' in the Debian GNU/Linux distribution or on -the World Wide Web at `http://www.gnu.org/copyleft/gpl.html'. You can -also obtain it by writing to the Free Software Foundation, Inc., 59 -Temple Place - Suite 330, Boston, MA 02111-1307, USA +The Debian diff is in the public domain. diff --git a/debian/delcr.1 b/debian/delcr.1 deleted file mode 100644 index 29f3cf2..0000000 --- a/debian/delcr.1 +++ /dev/null @@ -1,21 +0,0 @@ -.TH delcr 1 -.SH NAME -delcr \- copy stdin to stdout deleting a \\r char before \\n from input -.SH SYNOPSIS -.B delcr -.SH DESCRIPTION -.B delcr -reads stdin, deletes \\r char before a \\n and copies the remaining to stdout. - -.SH DIAGNOSTICS -.PP -return status is zero on success, or 111 if an error occurred. - -.SH "SEE ALSO" -.BR addcr (1) - -.SH AUTHOR -Written by D. J. Bernstein <djb@pobox.com>. - -Manual page added by Roberto Lumbreras <rover@debian.org>. - diff --git a/debian/diff/0001-error.h-include-errno.h-instead-of-extern-int.diff b/debian/diff/0001-error.h-include-errno.h-instead-of-extern-int.diff new file mode 100644 index 0000000..f154e66 --- /dev/null +++ b/debian/diff/0001-error.h-include-errno.h-instead-of-extern-int.diff @@ -0,0 +1,25 @@ +From f40f579bf6a031034ab1d4998fc60b768dfb3a6a Mon Sep 17 00:00:00 2001 +From: Gerrit Pape <pape@smarden.org> +Date: Wed, 12 Dec 2007 16:28:18 +0000 +Subject: [PATCH] error.h: '#include <errno.h>' instead of 'extern int errno;' + +--- + error.h | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/error.h b/error.h +index d5f3c7e..f660d93 100644 +--- a/error.h ++++ b/error.h +@@ -1,7 +1,7 @@ + #ifndef ERROR_H + #define ERROR_H + +-extern int errno; ++#include <errno.h> + + extern int error_intr; + extern int error_nomem; +-- +1.5.3.4 + diff --git a/debian/diff/0002-rblsmtpd.c-don-t-use-a-the-default-rbl.maps.vix.com.diff b/debian/diff/0002-rblsmtpd.c-don-t-use-a-the-default-rbl.maps.vix.com.diff new file mode 100644 index 0000000..dbeb307 --- /dev/null +++ b/debian/diff/0002-rblsmtpd.c-don-t-use-a-the-default-rbl.maps.vix.com.diff @@ -0,0 +1,43 @@ +From 99d57999a03b7378d8a17c6463007ca19d3d5521 Mon Sep 17 00:00:00 2001 +From: Gerrit Pape <pape@smarden.org> +Date: Wed, 9 Jan 2008 07:16:42 +0000 +Subject: [PATCH] rblsmtpd.c: don't use a the default rbl.maps.vix.com if run without -r switch. + +rbl.maps.vix.com is obsolete, so don't use it as default rbl if run +without the -r switch; default to no rbl instead. +--- + rblsmtpd.c | 4 +--- + 1 files changed, 1 insertions(+), 3 deletions(-) + +diff --git a/rblsmtpd.c b/rblsmtpd.c +index cc8ba2e..9695d9e 100644 +--- a/rblsmtpd.c ++++ b/rblsmtpd.c +@@ -155,7 +155,6 @@ void rblsmtpd(void) + + main(int argc,char **argv,char **envp) + { +- int flagwantdefaultrbl = 1; + char *x; + int opt; + +@@ -182,7 +181,7 @@ main(int argc,char **argv,char **envp) + case 'c': flagfailclosed = 1; break; + case 'C': flagfailclosed = 0; break; + case 't': scan_ulong(optarg,&timeout); break; +- case 'r': rbl(optarg); flagwantdefaultrbl = 0; break; ++ case 'r': rbl(optarg); break; + case 'a': antirbl(optarg); break; + default: usage(); + } +@@ -190,7 +189,6 @@ main(int argc,char **argv,char **envp) + argv += optind; + if (!*argv) usage(); + +- if (flagwantdefaultrbl) rbl("rbl.maps.vix.com"); + if (decision >= 2) rblsmtpd(); + + pathexec_run(*argv,argv,envp); +-- +1.5.3.8 + diff --git a/debian/implicit b/debian/implicit new file mode 100644 index 0000000..2b074cd --- /dev/null +++ b/debian/implicit @@ -0,0 +1,93 @@ +# $Id: 60d9070435b8d5608f20f60bc44e081960b6e39d $ + +.PHONY: deb-checkdir deb-checkuid + +deb-checkdir: + @test -e debian/control || sh -cx '! : wrong directory' +deb-checkuid: + @test "`id -u`" -eq 0 || sh -cx '! : need root privileges' + +%.deb: %.deb-docs %.deb-DEBIAN + @rm -f $*.deb $*.deb-checkdir $*.deb-docs $*.deb-docs-base \ + $*.deb-docs-docs $*.deb-docs-examples $*.deb-DEBIAN \ + $*.deb-DEBIAN-dir $*.deb-DEBIAN-scripts $*.deb-DEBIAN-md5sums + +%.udeb: %.deb-DEBIAN + @rm -f $*.deb $*.deb-checkdir $*.deb-DEBIAN $*.deb-DEBIAN-dir \ + $*.deb-DEBIAN-scripts $*.deb-DEBIAN-md5sums + +%.deb-checkdir: install + @test -d debian/$* || sh -cx '! : directory debian/$* missing' + @test "`id -u`" -eq 0 || sh -cx '! : need root privileges' + +%.deb-docs-base: install + : implicit + @rm -f debian/$*/usr/share/doc/$*/* || : + @install -d -m0755 debian/$*/usr/share/doc/$* + : debian/$*/usr/share/doc/$*/ + @sh -cx 'install -m0644 debian/copyright debian/$*/usr/share/doc/$*/' + @sh -cx 'install -m0644 debian/changelog \ + debian/$*/usr/share/doc/$*/changelog.Debian' + @test ! -r changelog || \ + sh -cx 'install -m0644 changelog debian/$*/usr/share/doc/$*/' + @test -r debian/$*/usr/share/doc/$*/changelog || \ + sh -cx 'mv debian/$*/usr/share/doc/$*/changelog.Debian \ + debian/$*/usr/share/doc/$*/changelog' + @test -s debian/$*/usr/share/doc/$*/changelog || \ + sh -cx 'rm -f debian/$*/usr/share/doc/$*/changelog' + @gzip -9 debian/$*/usr/share/doc/$*/changelog* +%.deb-docs-docs: %.deb-docs-base + @for i in `cat debian/$*.docs 2>/dev/null || :`; do \ + if test -d $$i; then \ + sh -cx "install -d -m0755 debian/$*/usr/share/doc/$*/$${i##*/}" && \ + for j in $$i/*; do \ + sh -cx "install -m0644 $$j \ + debian/$*/usr/share/doc/$*/$${i##*/}/" || exit 1; \ + done || exit 1; \ + continue; \ + fi; \ + sh -cx "install -m0644 $$i debian/$*/usr/share/doc/$*/" || exit 1; \ + done + @test ! -r debian/$*.README.Debian || \ + sh -cx 'install -m0644 debian/$*.README.Debian \ + debian/$*/usr/share/doc/$*/README.Debian' + @if test -r debian/$*.NEWS.Debian; then \ + sh -cx 'install -m0644 debian/$*.NEWS.Debian \ + debian/$*/usr/share/doc/$*/NEWS.Debian && \ + gzip -9 debian/$*/usr/share/doc/$*/NEWS.Debian'; \ + fi +%.deb-docs-examples: %.deb-docs-docs + @rm -rf debian/$*/usr/share/doc/$*/examples + : debian/$*/usr/share/doc/$*/examples/ + @test ! -r debian/$*.examples || \ + install -d -m0755 debian/$*/usr/share/doc/$*/examples + @for i in `cat debian/$*.examples 2>/dev/null || :`; do \ + sh -cx "install -m0644 $$i debian/$*/usr/share/doc/$*/examples/" \ + || exit 1; \ + done +%.deb-docs: %.deb-checkdir %.deb-docs-base %.deb-docs-docs %.deb-docs-examples + : debian/$*/usr/share/doc/$*/ ok + +%.deb-DEBIAN-base: install + @rm -rf debian/$*/DEBIAN + : debian/$*/DEBIAN/ + @install -d -m0755 debian/$*/DEBIAN + @for i in conffiles shlibs templates; do \ + test ! -r debian/$*.$$i || \ + sh -cx "install -m0644 debian/$*.$$i debian/$*/DEBIAN/$$i" \ + || exit 1; \ + done +%.deb-DEBIAN-scripts: %.deb-DEBIAN-base + @for i in preinst prerm postinst postrm config; do \ + test ! -r debian/$*.$$i || \ + sh -cx "install -m0755 debian/$*.$$i debian/$*/DEBIAN/$$i" \ + || exit 1; \ + done +%.deb-DEBIAN-md5sums: %.deb-DEBIAN-base %.deb-docs + : debian/$*/DEBIAN/md5sums + @rm -f debian/$*/DEBIAN/md5sums + @cd debian/$* && find * -path 'DEBIAN' -prune -o \ + -type f -exec md5sum {} >>DEBIAN/md5sums \; +%.deb-DEBIAN: %.deb-checkdir %.deb-DEBIAN-base %.deb-DEBIAN-scripts \ + %.deb-DEBIAN-md5sums + : debian/$*/DEBIAN/ ok diff --git a/debian/postinst b/debian/postinst deleted file mode 100644 index 48012b7..0000000 --- a/debian/postinst +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -e -#if [ "$1" = "configure" ]; then -# if [ -d /usr/doc -a ! -e /usr/doc/ucspi-tcp -a -d /usr/share/doc/ucspi-tcp ]; then -# ln -sf ../share/doc/ucspi-tcp /usr/doc/ucspi-tcp -# fi -#fi - diff --git a/debian/postrm b/debian/postrm deleted file mode 100644 index f5f9b19..0000000 --- a/debian/postrm +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -if [ remove = "$1" ]; then - dpkg-divert --package ucspi-tcp --remove --rename \ - --divert /usr/man/man5/tcp-environ.5q.gz /usr/man/man5/tcp-environ.5.gz -fi diff --git a/debian/preinst b/debian/preinst deleted file mode 100644 index fc74082..0000000 --- a/debian/preinst +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -if [ install = "$1" ]; then - dpkg-divert --package ucspi-tcp --add --rename \ - --divert /usr/man/man5/tcp-environ.5q.gz /usr/man/man5/tcp-environ.5.gz -fi diff --git a/debian/prerm b/debian/prerm deleted file mode 100644 index e1dba46..0000000 --- a/debian/prerm +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -e -if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/ucspi-tcp ]; then - rm -f /usr/doc/ucspi-tcp -fi - diff --git a/debian/rules b/debian/rules index 47a3b37..17716e9 100755 --- a/debian/rules +++ b/debian/rules @@ -1,121 +1,71 @@ -#!/usr/bin/make -f -# -# Copyright (C) 1998 Software in the Public Interest <www.debian.org> - -SHELL = /bin/bash - -BINS = tcpserver tcpclient tcprules tcprulescheck rblsmtpd mconnect-io addcr delcr fixcrio argv0 recordio - -SHBINS = who@ date@ finger@ tcpcat mconnect http@ - -MAN1 = tcpclient.1 tcpserver.1 tcprules.1 debian/addcr.1 debian/delcr.1 tcprulescheck.1 tcpcat.1 date@.1 finger@.1 http@.1 who@.1 - -MAN5 = tcp-environ.5 - -DOCS = README TODO VERSION SYSDEPS CHANGES FILES TARGETS - -PACKAGE = $(shell perl -e 'print <> =~ /(\S*)\s/' debian/changelog) -PKG_VER = $(shell perl -e 'print <> =~ /\((.*)\)/' debian/changelog) -PKG_UPVER = $(shell perl -e 'print <> =~ /\((.*)-[^-]*\)/' debian/changelog) - -TMPSRC = debian/tmp-src - -build: binary-src - touch build - -buildbinary: - echo "$$PWD/debian/tmp/usr" > conf-home-debian +#!/usr/bin/make -f + +STRIP =strip +ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + STRIP =: nostrip +endif + +DIR=$(shell pwd)/debian/ucspi-tcp + +patch: deb-checkdir patch-stamp +patch-stamp: + for i in `ls -1 debian/diff/*.diff || :`; do \ + patch -p1 <$$i || exit 1; \ + done + touch patch-stamp + +build: deb-checkdir build-stamp +build-stamp: patch-stamp + test -r conf-home'{orig}' || cp -f conf-home conf-home'{orig}' + echo /usr >conf-home $(MAKE) - touch buildbinary - -clean: checkdir debian/control - rm -f build debian/files debian/substvars - rm -f $(BINS) $(SHBINS) - rm -f *.o *.a *.0 - rm -rf debian/tmp debian/misc $(TMPSRC) - rm -f auto-ccld.sh make-load find-systype systype load \ - make-compile compile select.h make-makelib makelib \ - hassgprm.h hassgact.h dns.lib uint32.h haswaitp.h \ - install instcheck test.cdb auto-str rts auto_home.c \ - chkshsgr choose conf-home-debian fork.h hasshsgr.h \ - iopause.h socket.lib uint64.h - find . \( -name '#*#' -o -name '*~' -o -name DEADJOE -o \ - -name '*.orig' -o -name '*.rej' -o -name '*.bak' -o \ - -name '.*.orig' -o -name '.*.rej' -o -name .SUMS -o \ - -name TAGS -o -name core \) -exec rm -f {} \; - -binary-indep: checkroot build - -binary-arch: checkroot buildbinary - rm -rf debian/tmp - install -d -m 0755 debian/tmp/{DEBIAN,usr/{bin,man/man{1,5},share/doc/ucspi-tcp}} - install -s -m 0755 $(BINS) debian/tmp/usr/bin/ - install -m 0755 $(SHBINS) debian/tmp/usr/bin/ - - install -m 0644 $(MAN1) debian/tmp/usr/man/man1/ - install -m 0644 $(MAN5) debian/tmp/usr/man/man5/ - - install -m 0644 CHANGES debian/tmp/usr/share/doc/ucspi-tcp/changelog - install -m 0644 debian/changelog debian/tmp/usr/share/doc/ucspi-tcp/changelog.Debian - install -m 0644 $(DOCS) debian/tmp/usr/share/doc/ucspi-tcp/ - gzip -fr debian/tmp/usr/share/doc/ debian/tmp/usr/man/ - install -m 0644 debian/copyright debian/tmp/usr/share/doc/ucspi-tcp/copyright - install -p -m 0755 debian/prerm debian/postrm debian/preinst debian/tmp/DEBIAN - - dpkg-shlibdeps $(BINS) - dpkg-gencontrol -pucspi-tcp -cdebian/control.real - chown -R root.root debian/tmp - dpkg --build debian/tmp .. - -binary-src: checkroot checkdir debian/control ../$(PACKAGE)_$(PKG_UPVER).orig.tar.gz \ -../$(PACKAGE)_$(PKG_VER).dsc ../$(PACKAGE)_$(PKG_VER).diff.gz - -rm -rf $(TMPSRC) debian/files - - install -d $(TMPSRC)/DEBIAN \ - $(TMPSRC)/usr/bin \ - $(TMPSRC)/usr/src/$(PACKAGE)-src \ - $(TMPSRC)/usr/share/doc/$(PACKAGE)-src - install -m 755 debian/build-PACKAGE $(TMPSRC)/usr/bin/build-$(PACKAGE) - install -m 0644 ../$(PACKAGE)_$(PKG_UPVER).orig.tar.gz \ - ../$(PACKAGE)_$(PKG_VER).dsc \ - ../$(PACKAGE)_$(PKG_VER).diff.gz \ - $(TMPSRC)/usr/src/$(PACKAGE)-src/ - sed -e "s/#PACKAGE#/$(PACKAGE)/" debian/src.postinst > $(TMPSRC)/DEBIAN/postinst - chmod 755 $(TMPSRC)/DEBIAN/postinst - - sed -e "s/#PACKAGE#/$(PACKAGE)/" debian/src.prerm > $(TMPSRC)/DEBIAN/prerm - chmod 755 $(TMPSRC)/DEBIAN/prerm - - sed -e "s/#PACKAGE#/$(PACKAGE)/" debian/README-src > $(TMPSRC)/usr/share/doc/$(PACKAGE)-src/README.Debian - install -m 0644 debian/changelog $(TMPSRC)/usr/share/doc/$(PACKAGE)-src/changelog.Debian - chmod 644 $(TMPSRC)/usr/share/doc/$(PACKAGE)-src/changelog.Debian - gzip -fr $(TMPSRC)/usr/share/doc/ - install -m 0644 debian/copyright $(TMPSRC)/usr/share/doc/$(PACKAGE)-src/ - - dpkg-gencontrol -p$(PACKAGE)-src -P$(TMPSRC) - chown -R root.root $(TMPSRC) - dpkg --build $(TMPSRC) .. - -debian/control: debian/control.real - test -f debian/control.real && sed -e "/^Package: $(PACKAGE)-src$$/b" -e "/^Package: /,/^$$/d" debian/control.real > debian/control - -../$(PACKAGE)_$(PKG_UPVER).orig.tar.gz: - @{ echo "Error: $@ missing"; exit 1; } - -../$(PACKAGE)_$(PKG_VER).dsc ../$(PACKAGE)_$(PKG_VER).diff.gz: debian/rules - debian/rules clean - cd ..; dpkg-source -b $(PACKAGE)-$(PKG_UPVER) - -binary: binary-src - -source diff: - @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false - -checkdir: - @test -f tcpserver.c -a -f debian/rules - -checkroot: checkdir - @test 0 = `id -u` || { echo "Error: not super-user"; exit 1; } - -.PHONY: binary binary-arch binary-indep clean checkroot checkdir - + touch build-stamp + +clean: deb-checkdir deb-checkuid + rm -f `cat TARGETS` + test ! -e patch-stamp || \ + for i in `ls -1r debian/diff/*.diff || :`; do patch -p1 -R <$$i; done + rm -f patch-stamp build-stamp + rm -rf '$(DIR)' + rm -f debian/files debian/substvars changelog + test ! -r conf-home'{orig}' || mv -f conf-home'{orig}' conf-home + +install: deb-checkdir deb-checkuid build-stamp + rm -rf '$(DIR)' + # programs + install -d -m0755 '$(DIR)'/usr/bin + test -r conf-home'{orig}' || cp conf-home conf-home'{orig}' + echo '$(DIR)'/usr >conf-home + rm -f install instcheck install.o instcheck.o hier.o auto_home.o + $(MAKE) install instcheck + mv -f conf-home'{orig}' conf-home + ./install + ./instcheck + # fix up permissions + chmod 0755 '$(DIR)'/usr '$(DIR)'/usr/bin + # strip + for i in addcr argv0 delcr fixcrio mconnect-io rblsmtpd recordio \ + tcpclient tcprules tcprulescheck tcpserver; do \ + $(STRIP) -R .comment -R .note '$(DIR)'/usr/bin/$$i || exit 1; \ + done + # manpages + install -d -m0755 '$(DIR)'/usr/share/man/man1 + for i in debian/ucspi-tcp-man/*.1; do \ + install -m0644 $$i '$(DIR)'/usr/share/man/man1/ && \ + gzip -9 '$(DIR)'/usr/share/man/man1/$${i##*/} || exit 1; \ + done + # changelog + test -r changelog || ln -s CHANGES changelog + +binary-indep: + +binary-arch: install ucspi-tcp.deb + dpkg-shlibdeps '$(DIR)'/usr/bin/* + dpkg-gencontrol -isp -pucspi-tcp -P'$(DIR)' + dpkg -b '$(DIR)' .. + +binary: binary-indep binary-arch + +.PHONY: patch build clean install binary-indep binary-arch binary + +include debian/implicit diff --git a/debian/src.postinst b/debian/src.postinst deleted file mode 100644 index d7181d8..0000000 --- a/debian/src.postinst +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -e - -# This code is old, and no longer needed -#if [ "$1" = "configure" ]; then -# if [ -d /usr/doc -a ! -e /usr/doc/ucspi-tcp-src -a -d /usr/share/doc/ucspi-tcp-src ]; then -# ln -sf ../share/doc/ucspi-tcp-src /usr/doc/ucspi-tcp-src -# fi -#fi - -# Below removed at the request of Thomas Huriaux BUG#402339 -#echo "" -#echo "To build #PACKAGE# binary package, you have to run" -#echo "" -#echo " build-#PACKAGE#" -#echo "" - -#echo -n "Press ENTER to continue..." -#read blah - -exit 0 diff --git a/debian/src.prerm b/debian/src.prerm deleted file mode 100644 index 0189a6a..0000000 --- a/debian/src.prerm +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -e -# More old code no longer needed -#if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/ucspi-tcp ]; then -# rm -f /usr/doc/ucspi-tcp -#fi - diff --git a/debian/ucspi-tcp-man/README b/debian/ucspi-tcp-man/README new file mode 100644 index 0000000..8a84568 --- /dev/null +++ b/debian/ucspi-tcp-man/README @@ -0,0 +1,21 @@ +Mon, 24 Apr 2000 18:46:53 +0200 + +These man-pages were created from djb's documentation found at +http://cr.yp.to/ucspi-tcp.html . + +Gzip the man-pages and copy them to a subdirectory man1/ of any directory +found in Your $MANPATH: + + # gzip *.1 ; cp *.1.gz /usr/share/man/man1/ + +G. Pape <pape@smarden.org> + +Tue, 4 Jul 2000 18:53:38 +0200 + * man-pages for rblsmtpd, addcr, delcr added. + +Wed, 2 May 2001 13:56:46 +0200 + * two typos in tcpserver.1. + +Sun, 17 Mar 2002 15:32:59 +0100 + * merged changes from http://cr.yp.to/ucspi-tcp/tcpclient.html into + tcpclient.1. diff --git a/debian/ucspi-tcp-man/addcr.1 b/debian/ucspi-tcp-man/addcr.1 new file mode 100644 index 0000000..d4ffeee --- /dev/null +++ b/debian/ucspi-tcp-man/addcr.1 @@ -0,0 +1,28 @@ +.TH addcr 1 +.SH NAME +addcr \- inserts a CR (\\015) before each LF (\\012) +.SH SYNOPSIS +.B addcr +.SH DESCRIPTION +.B addcr +inserts a CR (\\015) before each LF (\\012), i.e., at the end of each line of input. It does not insert a CR at the end of a partial final line. + +.B addcr +reads input from stdin and writes to stdout. +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +argv0(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +finger@(1), +http@(1), +tcpcat(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/argv0.1 b/debian/ucspi-tcp-man/argv0.1 new file mode 100644 index 0000000..fb6d533 --- /dev/null +++ b/debian/ucspi-tcp-man/argv0.1 @@ -0,0 +1,70 @@ +.TH argv0 1 +.SH NAME +argv0 \- runs a program with a specified 0th argument. +.SH SYNOPSIS +.B argv0 +.I realname +.I zero +.I args +.SH DESCRIPTION +.I realname +is one argument. +.I zero +is one argument. +.I args +is any number of arguments. + +.B argv0 +runs the program stored as +.I realname +on disk, with +.I zero +as the 0th argument (rather than +.IR realname ) +and +.I args +as the remaining arguments. +.SH APPLICATIONS +Some programs pay special attention to the 0th argument. +.B argv0 +makes these programs usable from shell scripts. + +For example, +.IP +argv0 /bin/csh -csh +.P +runs /bin/csh with a 0th argument of -csh. /bin/csh will think it is a login +shell and behave accordingly. + +As another example, the command +.IP +tcpserver 0 ftp argv0 tcpd ftpd -l -A +.P +has a similar effect to the line +.IP +ftp stream tcp nowait root tcpd ftpd -l -A +.P +in /etc/inetd.conf. The tcpd program is run with 0th argument ftpd and +remaining arguments -l -A. Note that tcpd can and should be replaced by the +.B -x +option of +.BR tcpserver (1): +.IP +tcpserver -x ftp.tcp 0 ftp ftpd -l -A +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +finger@(1), +http@(1), +tcpcat(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/date@.1 b/debian/ucspi-tcp-man/date@.1 new file mode 100644 index 0000000..bbbacaa --- /dev/null +++ b/debian/ucspi-tcp-man/date@.1 @@ -0,0 +1,44 @@ +.TH date@ 1 +.SH NAME +date@ \- prints the date on a remote host. +.SH SYNOPSIS +.B date@ +[ +.I host +] +.SH DESCRIPTION +.B date@ +connects to TCP port 13 (Daytime) on +.I host +and prints any data it receives. It removes CR (\\015) and converts unprintable +characters to a visible format. + +If +.I host +is not supplied, +.B date@ +connects to the local host. + +Some computers respond to port 13 with a human-readable date. For example, +they may be running +.IP +tcpserver -RHl0 0 13 date +.P +using tcpserver. +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +argv0(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +finger@(1), +http@(1), +tcpcat(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/delcr.1 b/debian/ucspi-tcp-man/delcr.1 new file mode 100644 index 0000000..7372e03 --- /dev/null +++ b/debian/ucspi-tcp-man/delcr.1 @@ -0,0 +1,28 @@ +.TH delcr 1 +.SH NAME +delcr \- removes a CR (\\015) at the end of each line of input, if a CR is present. +.SH SYNOPSIS +.B delcr +.SH DESCRIPTION +.B delcr +removes a CR (\\015) at the end of each line of input, if a CR is present. It does not remove a CR at the end of a partial final line. + +.B delcr +reads input from stdin and writes to stdout. +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +argv0(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +finger@(1), +http@(1), +tcpcat(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/finger@.1 b/debian/ucspi-tcp-man/finger@.1 new file mode 100644 index 0000000..d1679e0 --- /dev/null +++ b/debian/ucspi-tcp-man/finger@.1 @@ -0,0 +1,53 @@ +.TH finger@ 1 +.SH NAME +finger@ \- gets user information from a remote host. +.SH SYNOPSIS +.B finger@ +[ +.I host +[ +.I user +] ] +.SH DESCRIPTION +.B finger@ +connects to TCP port 79 (Finger) on +.IR host , +sends +.I user +(with an extra CR) to +.IR host , +and prints any data it receives. It removes CR and converts unprintable +characters to a visible format. + +Some computers respond to port 79 with information about +.IR user . + +If +.I user +is not supplied, +.B finger@ +sends a blank line to host. Some computers respond with information about all +the users who are logged in. + +If +.I host +is not supplied, +.B finger@ +connects to the local host. +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +argv0(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +http@(1), +tcpcat(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/fixcrio.1 b/debian/ucspi-tcp-man/fixcrio.1 new file mode 100644 index 0000000..656153e --- /dev/null +++ b/debian/ucspi-tcp-man/fixcrio.1 @@ -0,0 +1,37 @@ +.TH fixcrio 1 +.SH NAME +fixcrio \- inserts missing CRs at the ends of lines. +.SH SYNOPSIS +.B fixcrio +.I prog +.SH DESCRIPTION +.B fixcrio +runs +.IR prog . +It inserts CR at the end of each line of input or output to +.I prog +that does not have a CR. + +.B fixcrio +runs as a child process of +.IR prog . +It exits when it sees the end of +.IR prog 's +output. +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +argv0(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +finger@(1), +http@(1), +tcpcat(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/http@.1 b/debian/ucspi-tcp-man/http@.1 new file mode 100644 index 0000000..89cbdff --- /dev/null +++ b/debian/ucspi-tcp-man/http@.1 @@ -0,0 +1,68 @@ +.TH http@ 1 +.SH NAME +http@ \- gets a web page from a remote host. +.SH SYNOPSIS +.B http@ +[ +.I host +[ +.I page +[ +.I port +] +] +] +.SH DESCRIPTION +.B http@ +connects to +.I port +on +.IR host , +sends +.IP +GET +.I /page +HTTP/1.0 + +Host: host +.P +to +.IR host , +and prints the contents of the response, removing CR from the end of each +line. + +If +.I port +is not supplied, +.B http@ +uses TCP port 80 (HTTP). + +If +.I page +is not supplied, +.B http@ +asks for / from +.IR host . + +If +.I host +is not supplied, +.B http@ +connects to the local host. +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +argv0(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +finger@(1), +tcpcat(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/mconnect.1 b/debian/ucspi-tcp-man/mconnect.1 new file mode 100644 index 0000000..3c29ea3 --- /dev/null +++ b/debian/ucspi-tcp-man/mconnect.1 @@ -0,0 +1,46 @@ +.TH mconnect 1 +.SH NAME +mconnect \- connects to a remote SMTP server. +.SH SYNOPSIS +.B mconnect +[ +.I host +[ +.I port +] +] +.SH DESCRIPTION +.B mconnect +connects to +.I port +on +.IR host . +It sends its input to +.IR host , +adding a CR to each line. Meanwhile it prints anything it receives from +.IR host . + +If +.I port +is not supplied, mconnect uses port 25 (SMTP). + +If +.I host +is not supplied, mconnect connects to the local host. +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +argv0(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +finger@(1), +http@(1), +tcpcat(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/rblsmtpd.1 b/debian/ucspi-tcp-man/rblsmtpd.1 new file mode 100644 index 0000000..9d9ca08 --- /dev/null +++ b/debian/ucspi-tcp-man/rblsmtpd.1 @@ -0,0 +1,136 @@ +.TH rblsmtpd 1 +.SH NAME +rblsmtpd \- blocks mail from RBL-listed sites. It works with any SMTP server that can run under +.BR tcpserver (1) +.SH SYNOPSIS +.B rblsmtpd +.I opts +.I prog +.SH DESCRIPTION +.I opts +is a series of getopt-style options. +.I prog +consists of one or more arguments. + +Normally +.B rblsmtpd +runs +.IR prog . +.I prog +is expected to carry out an SMTP conversation to receive incoming mail messages. + +However, +.B rblsmtpd +does not invoke +.I prog +if it is told to block mail from this client. Instead it carries out its own limited SMTP conversation, temporarily rejecting all attempts to send a message. Meanwhile it prints one line on descriptor 2 to log its activity. + +.B rblsmtpd +drops the limited SMTP conversation after 60 seconds, even if the client has not quit by then. +.SH OPTIONS +.TP +.B \-t \fIn +Change the timeout to +.I n +seconds. +.P +.B Blocked clients +.P +If the $RBLSMTPD environment variable is set and is nonempty, +.B rblsmtpd +blocks mail. It uses $RBLSMTPD as an error message for the client. Normally +.B rblsmtpd +runs under +.BR tcpserver (1); +you can use +.BR tcprules (1) +to set $RBLSMTPD for selected clients. + +If $RBLSMTPD is set and is empty, +.B rblsmtpd +does not block mail. + +If $RBLSMTPD is not set, +.B rblsmtpd +looks up $TCPREMOTEIP in the RBL, and blocks mail if $TCPREMOTEIP is listed. +.B tcpserver +sets up $TCPREMOTEIP as the IP address of the remote host. +.TP +.B \-r \fIbase +Use +.I base +as an RBL source. An IP address +.I a.b.c.d +is listed by that source if +.I d.c.b.a.base +has a TXT record. +.B rblsmtpd +uses the contents of the TXT record as an error message for the client. +.TP +.B \-a \fIbase +Use +.I base +as an anti-RBL source. An IP address +.I a.b.c.d +is anti-listed by that source if +.I d.c.b.a.base +has an A record. In this case +.B rblsmtpd +does not block mail. +.P +You may supply any number of +.B \-r +and +.B \-a +options. +.B rblsmtpd +tries each source in turn until it finds one that lists or anti-lists $TCPREMOTEIP. It also tries an RBL source of rbl.maps.vix.com if you do not supply any +.B -r +options. See http://maps.vix.com/rbl/ for more information about rbl.maps.vix.com. + +If you want to run your own RBL source or anti-RBL source for +.BR rblsmtpd , +you can use +.B rbldns +from the DNScache (djbdns) package. +.P +.B Temporary errors +.P +Normally, if $RBLSMTPD is set, +.B rblsmtpd +uses a 451 error code in its limited SMTP conversation. This tells legitimate clients to try again later. It gives innocent relay operators a chance to see the problem, prohibit relaying, get off the RBL, and get the mail delivered. + +However, if $RBLSMTPD begins with a hyphen, +.B rblsmtpd +removes the hyphen and uses a 553 error code. This tells legitimate clients to bounce the message immediately. + +There are several error-handling options for RBL lookups: +.TP +.B \-B +(Default.) Use a 451 error code for IP addresses listed in the RBL. +.TP +.B \-b +Use a 553 error code for IP addresses listed in the RBL. +.TP +.B \-C +(Default.) Handle RBL lookups in a ``fail-open'' mode. If an RBL lookup fails temporarily, assume that the address is not listed; if an anti-RBL lookup fails temporarily, assume that the address is anti-listed. Unfortunately, a knowledgeable attacker can force an RBL lookup or an anti-RBL lookup to fail temporarily, so that his mail is not blocked. +.TP +.B \-c +Handle RBL lookups in a ``fail-closed'' mode. If an RBL lookup fails temporarily, assume that the address is listed (but use a 451 error code even with -b). If an anti-RBL lookup fails temporarily, assume that the address is not anti-listed (but use a 451 error code even if a subsequent RBL lookup succeeds with -b). Unfortunately, this sometimes delays legitimate mail. +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +finger@(1), +http@(1), +tcpcat(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/recordio.1 b/debian/ucspi-tcp-man/recordio.1 new file mode 100644 index 0000000..6a7a586 --- /dev/null +++ b/debian/ucspi-tcp-man/recordio.1 @@ -0,0 +1,69 @@ +.TH recordio 1 +.SH NAME +recordio \- records the input and output of a program. +.SH SYNOPSIS +.B recordio +.I prog +.SH DESCRIPTION +.B recordio +runs +.IR prog . +It prints lines to descriptor 2 showing the input and output of +.IR prog . + +At the beginning of each line on descriptor 2, +.B recordio +inserts the +.I prog +process ID, along with < for input or > for output. At the end of each line +it inserts +, a space, or [EOF]; a space indicates that there was a new line +in the input or output, and [EOF] indicates the end of input or output. + +.B recordio +prints every packet of input and output immediately. It does not attempt to +combine packets into coherent lines. For example, +.IP +recordio sh -c 'cat /dev/fd/8 2>&1' > /dev/null +.P +could produce + + 5135 > cat: /dev/fd/8: Bad file descriptor + 5135 > [EOF] + +or + + 5135 > cat: + + 5135 > /dev/fd/8+ + 5135 > : + + 5135 > Bad file descriptor + 5135 > [EOF] + +if the cat program prints several packets. + +.B recordio +uses several lines for long packets to guarantee that each line is printed +atomically. + +.B recordio +runs as a child process of +.IR prog . +It exits when it sees the end of +.IR prog 's +output. +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +argv0(1), +fixcrio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +finger@(1), +http@(1), +tcpcat(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/tcpcat.1 b/debian/ucspi-tcp-man/tcpcat.1 new file mode 100644 index 0000000..2216c63 --- /dev/null +++ b/debian/ucspi-tcp-man/tcpcat.1 @@ -0,0 +1,34 @@ +.TH tcpcat 1 +.SH NAME +tcpcat \- prints data from a remote host. +.SH SYNOPSIS +.B tcpcat +.I host +.I port +.SH DESCRIPTION +.B tcpcat +connects to +.I port +on +.IR host . +It prints any data it receives. + +.B tcpcat +can be used to transfer binary data. It does no conversions. +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +argv0(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +finger@(1), +http@(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/tcpclient.1 b/debian/ucspi-tcp-man/tcpclient.1 new file mode 100644 index 0000000..60c4d21 --- /dev/null +++ b/debian/ucspi-tcp-man/tcpclient.1 @@ -0,0 +1,144 @@ +.TH tcpclient 1 +.SH NAME +tcpclient \- creates an outgoing TCP connection. +.SH SYNOPSIS +.B tcpclient +[ +.I opts +] +.I host +.I port +.I prog +.SH DESCRIPTION +.I opts +is a series of getopt-style options. +.I host +is one argument. +.I port +is one argument. +.I prog +consists of one or more arguments. + +.B tcpclient +attempts to connect to a TCP server. If it is successful, it runs +.IR prog , +with descriptor 6 reading from the network and descriptor 7 writing to the +network. It also sets up several environment variables (see +.BR tcp-environ (5) +). + +The server's address is given by +.I host +and +.IR port . +.I port +may be a name from /etc/services or a number. +.I host +may be 0, referring to the local machine, or a dotted-decimal IP address, or +a host name; it is fed through qualification using dns_ip4_qualify. + +If the server has several IP addresses, +.B tcpclient +tries each address in turn. +.SH OPTIONS +.B General options: +.TP +.B \-q +Quiet. Do not print error messages. +.TP +.B \-Q +(Default.) Print error messages. +.TP +.B \-v +Verbose. Print error messages and status messages. +.P +.B Connection options: +.TP +.B \-T \fIx\fR+\fIy +Give up on the connection attempt after +.I x\fR+\fIy +seconds. Default: 2+58. When a host has several IP addresses, +.B tcpclient +tries to connect to the first IP address, waits +.I x +seconds, tries to connect to the second IP address, waits +.I x +seconds, etc.; then it retries each address that timed out, waiting +.I y +seconds per address. You may omit +.RI + y +to skip the second try. Before version 0.88, +.BR tcpclient (1) +will use only +.I x +(default: 60). +.TP +.B \-i \fIlocalip +Use +.I localip +as the IP address for the local side of the connection; quit if +.I localip +is not available. Normally +.B tcpclient +lets the operating system choose an address. +.TP +.B \-p \fIlocalport +Use +.I localport +as the TCP port for the local side of the connection; quit if +.I localport +is not available. Normally +.B tcpclient +lets the operating system choose a port. +.TP +.B \-d +Delay sending data for a fraction of a second whenever the remote host is +responding slowly. This is currently the default, but it may not be in the +future; if you want it, set it explicitly. +.TP +.B \-D +Never delay sending data; enable TCP_NODELAY. +.P +.B Data-gathering options: +.TP +.B \-h +(Default.) Look up the remote host name in DNS to set the environment variable +$TCPREMOTEHOST. +.TP +.B \-H +Do not look up the remote host name in DNS; remove the environment variable +$TCPREMOTEHOST. +.TP +.B \-l \fIlocalname +Do not look up the local host name in DNS; use +.I localname +for the environment variable $TCPLOCALHOST. A common choice for localname is +0. +.TP +.B \-r +(Default.) Attempt to obtain $TCPREMOTEINFO from the remote host. +.TP +.B \-R +Do not attempt to obtain $TCPREMOTEINFO from the remote host. +.TP +.B \-t \fIn +Give up on the $TCPREMOTEINFO connection attempt after +.I n +seconds. Default: 26. +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +argv0(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +who@(1), +date@(1), +finger@(1), +http@(1), +tcpcat(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/tcprules.1 b/debian/ucspi-tcp-man/tcprules.1 new file mode 100644 index 0000000..6a838d6 --- /dev/null +++ b/debian/ucspi-tcp-man/tcprules.1 @@ -0,0 +1,166 @@ +.TH tcprules 1 +.SH NAME +tcprules \- compiles rules for +.BR tcpserver (1). +.SH SYNOPSIS +.B tcprules +.I cdb +.I tmp +.SH DESCRIPTION +.BR tcpserver (1) +optionally follows rules to decide whether a TCP connection is acceptable. For +example, the rule +.IP +18.23.0.32:deny +.P +prohibits connections from IP address 18.23.0.32. + +.B tcprules +reads rules from its standard input and writes them into +.I cdb +in a binary format suited for quick access by +.BR tcpserver (1). + +.B tcprules +can be used while +.BR tcpserver (1) +is running. It ensures that +.I cdb +is updated atomically. It does this by first writing the rules to +.I tmp +and then moving +.I tmp +on top of +.IR cdb . +If +.I tmp +already exists, it is destroyed. The directories containing +.I cdb +and +.I tmp +must be writable to +.BR tcprules ; +they must also be on the same filesystem. + +If there is a problem with the input or with +.IR tmp , +.B tcprules +complains and leaves +.I cdb +alone. + +The binary +.I cdb +format is portable across machines. +.SH RULE FORMAT +A rule is one line. A file containing rules may also contain comments: lines +beginning with # are ignored. + +Each rule contains an address, a colon, and a list of instructions, with no +extra spaces. When +.BR tcpserver (1) +receives a connection from that address, it follows the instructions. +.SH ADDRESSES +.BR tcpserver (1) +looks for rules with various addresses: +.IP 1. +$TCPREMOTEINFO@$TCPREMOTEIP, if $TCPREMOTEINFO is set; +.IP 2. +$TCPREMOTEINFO@=$TCPREMOTEHOST, if $TCPREMOTEINFO is set and $TCPREMOTEHOST is +set; +.IP 3. +$TCPREMOTEIP; +.IP 4. +=$TCPREMOTEHOST, if $TCPREMOTEHOST is set; +.IP 5. +shorter and shorter prefixes of $TCPREMOTEIP ending with a dot; +.IP 6. +shorter and shorter suffixes of $TCPREMOTEHOST starting with a dot, preceded +by =, if $TCPREMOTEHOST is set; +.IP 7. +=, if $TCPREMOTEHOST is set; and finally +.IP 8. +the empty string. +.P +.BR tcpserver (1) +uses the first rule it finds. You should use the +.B -p +option to +.BR tcpserver (1) +if you rely on $TCPREMOTEHOST here. + +For example, here are some rules: + + joe@127.0.0.1:first + 18.23.0.32:second + :third + 127.:fourth + +If $TCPREMOTEIP is 10.119.75.38, +.BR tcpserver (1) +will follow the third instructions. + +If $TCPREMOTEIP is 18.23.0.32, +.BR tcpserver (1) +will follow the second instructions. + +If $TCPREMOTEIP is 127.0.0.1 and $TCPREMOTEINFO is bill, +.BR tcpserver (1) +will follow the fourth instructions. + +If $TCPREMOTEIP is 127.0.0.1 and $TCPREMOTEINFO is joe, +.BR tcpserver (1) +will follow the first instructions. + +You can use +.BR tcprulescheck (1) +to see how tcpserver will interpret rules in +.IR cdb . +.SH ADDRESS RANGES +.B tcprules +treats 1.2.3.37-53:ins as an abbreviation for the rules 1.2.3.37:ins, +1.2.3.38:ins, and so on up through 1.2.3.53:ins. Similarly, 10.2-3.:ins is an +abbreviation for 10.2.:ins and 10.3.:ins. +.SH INSTRUCTIONS +The instructions in a rule must begin with either allow or deny. deny tells +.BR tcpserver (1) +to drop the connection without running anything. For example, the rule +.IP +:deny +.P +tells +.BR tcpserver (1) +to drop all connections that aren't handled by more specific rules. + +The instructions may continue with some environment variables, in the form +var="x". +.BR tcpserver (1) +adds an environment variable $var with value x. For example, +.IP +10.0.:allow,RELAYCLIENT="@fix.me" +.P +adds an environment variable $RELAYCLIENT with value @fix.me. The quotes may +be replaced by any repeated character: +.IP +10.0.:allow,RELAYCLIENT=/@fix.me/ +.P +Any number of variables may be listed: +.IP +127.0.0.1:allow,RELAYCLIENT="",TCPLOCALHOST="movie.edu" +.SH SEE ALSO +tcpserver(1), +tcprulescheck(1), +argv0(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +finger@(1), +http@(1), +tcpcat(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/tcprulescheck.1 b/debian/ucspi-tcp-man/tcprulescheck.1 new file mode 100644 index 0000000..3635165 --- /dev/null +++ b/debian/ucspi-tcp-man/tcprulescheck.1 @@ -0,0 +1,33 @@ +.TH tcprulescheck 1 +.SH NAME +tcprulescheck \- checks tcprules +.SH SYNOPSIS +.B tcprulescheck +.I cdb +.SH DESCRIPTION +.B tcprulescheck +says what +.BR tcpserver (1) +will do with a connection from IP address $TCPREMOTEIP with host name +$TCPREMOTEHOST and remote connection information $TCPREMOTEINFO, following +the rules compiled into +.I cdb +by +.BR tcprules (1). +.SH SEE ALSO +tcpserver(1), +tcprules(1), +argv0(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +finger@(1), +http@(1), +tcpcat(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/tcpserver.1 b/debian/ucspi-tcp-man/tcpserver.1 new file mode 100644 index 0000000..f78ec0a --- /dev/null +++ b/debian/ucspi-tcp-man/tcpserver.1 @@ -0,0 +1,207 @@ +.TH tcpserver 1 +.SH NAME +tcpserver \- accepts incoming TCP connections. +.SH SYNOPSIS +.B tcpserver +[ +.I opts +] +.I host +.I port +.I prog +.SH DESCRIPTION +.I opts +is a series of getopt-style options. +.I host +is one argument. +.I port +is one argument. +.I prog +consists of one or more arguments. + +.B tcpserver +waits for connections from TCP clients. For each connection, it runs +.IR prog , +with descriptor 0 reading from the network and descriptor 1 writing to the +network. It also sets up several environment variables. + +The server's address is given by +.I host +and +.IR port . +.I port +may be a name from /etc/services or a number; if it is 0, +.B tcpserver +will choose a free TCP port. +.I host +may be 0, allowing connections to any local IP address; or a dotted-decimal IP +address, allowing connections only to that address; or a host name, allowing +connections to the first IP address for that host. Host names are fed through +qualification using dns_ip4_qualify. + +.B tcpserver +exits when it receives SIGTERM. +.SH OPTIONS +.B General options: +.TP +.B \-q +Quiet. Do not print error messages. +.TP +.B \-Q +(Default.) Print error messages. +.TP +.B \-v +Verbose. Print error messages and status messages. +.P +.B Connection options: +.TP +.B \-c \fIn +Do not handle more than +.I n +simultaneous connections. If there are +.I n +simultaneous copies of prog running, defer acceptance of a new connection +until one copy finishes. +.I n +must be a positive integer. Default: 40. +.TP +.B \-x \fIcdb +Follow the rules compiled into +.I cdb +by +.BR tcprules (1). +These rules may specify setting environment variables or rejecting connections +from bad sources. You can rerun +.BR tcprules (1) +to change the rules while +.B tcpserver +is running. +.TP +.B \-X +With +.B -x \fIcdb, +allow connections even if +.I cdb +does not exist. Normally +.B tcpserver +will drop the connection if +.I cdb +does not exist. +.TP +.B \-B \fIbanner +Write +.I banner +to the network immediately after each connection is made. +.B tcpserver +writes +.I banner +before looking up $TCPREMOTEHOST, before looking up $TCPREMOTEINFO, and before +checking +.IR cdb . +This feature can be used to reduce latency in protocols where the client waits +for a greeting from the server. +.TP +.B \-g \fIgid +Switch group ID to +.I gid +after preparing to receive connections. +.I gid +must be a positive integer. +.TP +.B \-u \fIuid +Switch user ID to +.I uid +after preparing to receive connections. +.I uid +must be a positive integer. +.TP +.B \-U +Same as +.B \-g +$GID +.B \-u +$UID. Typically $GID and $UID are set by +.BR envuidgid (8). +.TP +.B \-1 +After preparing to receive connections, print the local port number to +standard output. +.TP +.B \-b \fIn +Allow a backlog of approximately +.I n +TCP SYNs. On some systems, +.I n +is silently limited to 5. On systems supporting SYN cookies, the backlog is +irrelevant. +.TP +.B \-o +Leave IP options alone. If the client is sending packets along an IP source +route, send packets back along the same route. +.TP +.B \-O +(Default.) Kill IP options. A client can still use source routing to connect +and to send data, but packets will be sent back along the default route. +.TP +.B \-d +Delay sending data for a fraction of a second whenever the remote host is +responding slowly. This is currently the default, but it may not be in the +future; if you want it, set it explicitly. +.TP +.B \-D +Never delay sending data; enable TCP_NODELAY. +.P +.B Data-gathering options: +.TP +.B \-h +(Default.) Look up the remote host name in DNS to set the environment variable +$TCPREMOTEHOST. +.TP +.B \-H +Do not look up the remote host name in DNS; remove the environment variable +$TCPREMOTEHOST. To avoid loops, you must use this option for servers on TCP +port 53. +.TP +.B \-p +Paranoid. After looking up the remote host name in DNS, look up the IP +addresses in DNS for that host name, and remove the environment variable +$TCPREMOTEHOST if none of the addresses match the client's IP address. +.TP +.B \-P +(Default.) Not paranoid. +.TP +.B \-l \fIlocalname +Do not look up the local host name in DNS; use +.I localname +for the environment variable $TCPLOCALHOST. A common choice for +.I localname +is 0. To avoid loops, you must use this option for servers on TCP port 53. +.TP +.B \-r +(Default.) Attempt to obtain $TCPREMOTEINFO from the remote host. +.TP +.B \-R +Do not attempt to obtain $TCPREMOTEINFO from the remote host. To avoid loops, +you must use this option for servers on TCP ports 53 and 113. +.TP +.B \-t \fIn +Give up on the $TCPREMOTEINFO connection attempt after +.I n +seconds. Default: 26. +.SH SEE ALSO +tcprules(1), +tcprulescheck(1), +argv0(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +who@(1), +date@(1), +finger@(1), +http@(1), +tcpcat(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp-man/who@.1 b/debian/ucspi-tcp-man/who@.1 new file mode 100644 index 0000000..622ad94 --- /dev/null +++ b/debian/ucspi-tcp-man/who@.1 @@ -0,0 +1,44 @@ +.TH who@ 1 +.SH NAME +who@ \- prints the list of active users on a remote host. +.SH SYNOPSIS +.B who@ +[ +.I host +] +.SH DESCRIPTION +.B who@ +connects to TCP port 11 (Systat) on +.I host +and prints any data it receives. It removes CR (\\015) and converts unprintable +characters to a visible format. + +If +.I host +is not supplied, +.B who@ +connects to the local host. + +Some computers respond to port 11 with a list of active users. For example, +they may be running +.IP +tcpserver -RHl0 0 11 who +.P +using tcpserver. +.SH SEE ALSO +tcpserver(1), +tcprules(1), +tcprulescheck(1), +argv0(1), +fixcrio(1), +recordio(1), +rblsmtpd(1), +tcpclient(1), +date@(1), +finger@(1), +http@(1), +tcpcat(1), +mconnect(1), +tcp-environ(5) + +http://cr.yp.to/ucspi-tcp.html diff --git a/debian/ucspi-tcp.NEWS.Debian b/debian/ucspi-tcp.NEWS.Debian new file mode 100644 index 0000000..9003527 --- /dev/null +++ b/debian/ucspi-tcp.NEWS.Debian @@ -0,0 +1,17 @@ +ucspi-tcp (1:0.88-1) unstable; urgency=low + + With the ucspi-tcp package being put into the public domain by the + upstream author, ucspi-tcp is now available as binary package in + Debian/main. + + Please note that this new binary package does not include as many + patches as the package created through the ucspi-tcp-src package + available in Debian/non-free. ucspi-tcp-src is still available, if + you don't want to upgrade to this new binary package, you should stop + the installation, make sure the ucspi-tcp-src package is installed, + and put ucspi-tcp on hold, as described in + + http://www.debian.org/doc/FAQ/ch-pkg_basics.en.html#s-puttingonhold + + -- Gerrit Pape <pape@smarden.org> Wed, 09 Jan 2008 07:16:22 +0000 + diff --git a/debian/ucspi-tcp.README.Debian b/debian/ucspi-tcp.README.Debian new file mode 100644 index 0000000..d508141 --- /dev/null +++ b/debian/ucspi-tcp.README.Debian @@ -0,0 +1,61 @@ +ucspi-tcp for Debian +-------------------- + +From http://cr.yp.to/ucspi-tcp.html: + +tcpserver and tcpclient are easy-to-use command-line tools for building TCP +client-server applications. + +tcpserver waits for incoming connections and, for each connection, runs a +program of your choice. Your program receives environment +variables showing the local and remote host names, IP addresses, and port +numbers. + +tcpserver offers a concurrency limit to protect you from running out of +processes and memory. When you are handling 40 (by default) +simultaneous connections, tcpserver smoothly defers acceptance of new +connections. + +tcpserver also provides TCP access control features, similar to +tcp-wrappers/tcpd's hosts.allow but much faster. Its access control rules +are compiled into a hashed format with cdb, so it can easily deal with +thousands of different hosts. + +This package includes a recordio tool that monitors all the input and output +of a server. + +tcpclient makes a TCP connection and runs a program of your choice. It sets +up the same environment variables as tcpserver. + +This package includes several sample clients built on top of tcpclient: +who@, date@, finger@, http@, tcpcat, and mconnect. + +tcpserver and tcpclient conform to UCSPI, the UNIX Client-Server Program +Interface, using the TCP protocol. UCSPI tools are +available for several different networks. + +Other command-line TCP tools + +The current ucspi-tcp interface is a refinement of the tcpserver/tcpclient +interface in my 1991 clientserver package, which replaced the +attachport/authtcp interface in my 1989 auth package. + +ucspi-tcp now competes with several other programs: + + inetd, a root-only TCP server supplied by all UNIX vendors; + xinetd, a replacement for inetd; + the mconnect client supplied as part of SunOS; + the socket program; + faucet and hose, part of the netpipes package; and + the netcat program, which also supports UDP. + +Many sites are replacing inetd with tcpserver, for several reasons: + + inetd is unreliable under high loads. It cuts off service for 10 + minutes if it receives `too many'' connections in 1 minute. + inetd does not provide effective resource management. It will happily + use up all your memory if you are running a popular service. + inetd has trouble with sudden bursts of activity. Its listen() backlog + is typically only 5 or 10 and cannot be raised. + + -- Gerrit Pape <pape@smarden.org>, Mon, 15 Oct 2001 13:25:22 +0200 diff --git a/debian/ucspi-tcp.docs b/debian/ucspi-tcp.docs new file mode 100644 index 0000000..e048c57 --- /dev/null +++ b/debian/ucspi-tcp.docs @@ -0,0 +1,3 @@ +README +TODO +VERSION diff --git a/delcr.1 b/delcr.1 deleted file mode 100644 index 18ea736..0000000 --- a/delcr.1 +++ /dev/null @@ -1,30 +0,0 @@ -.TH delcr 1 -.SH NAME -delcr \- remove a CR before each LF -.SH SYNOPSIS -.B delcr -.SH DESCRIPTION -.B delcr -removes a CR at the end of each line of input, -if a CR is present. -It also removes a CR at the end of a partial final line. - -The pipeline - -.EX - addcr | delcr -.EE - -prints an exact copy of its input. -.SH COMPATIBILITY -Some vendors ship -.B dos2unix -or -.B dos2bsd -tools similar to -.BR delcr . -Those tools often blow up on long lines and nulls. -.B delcr -has no trouble with long lines and nulls. -.SH "SEE ALSO" -addcr(1) @@ -34,60 +34,51 @@ struct dns_transmit { unsigned int curserver; struct taia deadline; unsigned int pos; - const char *servers; - char localip[16]; - unsigned int scope_id; + char *servers; + char localip[4]; char qtype[2]; } ; -extern void dns_random_init(const char *); +extern void dns_random_init(char *); extern unsigned int dns_random(unsigned int); extern void dns_sortip(char *,unsigned int); -extern void dns_sortip6(char *,unsigned int); extern void dns_domain_free(char **); -extern int dns_domain_copy(char **,const char *); -extern unsigned int dns_domain_length(const char *); -extern int dns_domain_equal(const char *,const char *); -extern int dns_domain_suffix(const char *,const char *); -extern unsigned int dns_domain_suffixpos(const char *,const char *); -extern int dns_domain_fromdot(char **,const char *,unsigned int); -extern int dns_domain_todot_cat(stralloc *,const char *); +extern int dns_domain_copy(char **,char *); +extern unsigned int dns_domain_length(char *); +extern int dns_domain_equal(char *,char *); +extern char *dns_domain_suffix(char *,char *); +extern int dns_domain_fromdot(char **,char *,unsigned int); +extern int dns_domain_todot_cat(stralloc *,char *); -extern unsigned int dns_packet_copy(const char *,unsigned int,unsigned int,char *,unsigned int); -extern unsigned int dns_packet_getname(const char *,unsigned int,unsigned int,char **); -extern unsigned int dns_packet_skipname(const char *,unsigned int,unsigned int); +extern unsigned int dns_packet_copy(char *,unsigned int,unsigned int,char *,unsigned int); +extern unsigned int dns_packet_getname(char *,unsigned int,unsigned int,char **); +extern unsigned int dns_packet_skipname(char *,unsigned int,unsigned int); +extern int dns_packet_nameequal(char *,unsigned int,unsigned int,char *,unsigned int,unsigned int); -extern int dns_transmit_start(struct dns_transmit *,const char *,int,const char *,const char *,const char *); +extern int dns_transmit_start(struct dns_transmit *,char *,int,char *,char *,char *); extern void dns_transmit_free(struct dns_transmit *); extern void dns_transmit_io(struct dns_transmit *,iopause_fd *,struct taia *); -extern int dns_transmit_get(struct dns_transmit *,const iopause_fd *,const struct taia *); +extern int dns_transmit_get(struct dns_transmit *,iopause_fd *,struct taia *); extern int dns_resolvconfip(char *); -extern int dns_resolve(const char *,const char *); +extern int dns_resolve(char *,char *); extern struct dns_transmit dns_resolve_tx; -extern int dns_ip4_packet(stralloc *,const char *,unsigned int); -extern int dns_ip4(stralloc *,const stralloc *); -extern int dns_ip6_packet(stralloc *,const char *,unsigned int); -extern int dns_ip6(stralloc *,stralloc *); -extern int dns_name_packet(stralloc *,const char *,unsigned int); -extern void dns_name4_domain(char *,const char *); +extern int dns_ip4_packet(stralloc *,char *,unsigned int); +extern int dns_ip4(stralloc *,stralloc *); +extern int dns_name_packet(stralloc *,char *,unsigned int); +extern void dns_name4_domain(char *,char *); #define DNS_NAME4_DOMAIN 31 -extern int dns_name4(stralloc *,const char *); -extern int dns_txt_packet(stralloc *,const char *,unsigned int); -extern int dns_txt(stralloc *,const stralloc *); -extern int dns_mx_packet(stralloc *,const char *,unsigned int); -extern int dns_mx(stralloc *,const stralloc *); +extern int dns_name4(stralloc *,char *); +extern int dns_txt_packet(stralloc *,char *,unsigned int); +extern int dns_txt(stralloc *,stralloc *); +extern int dns_mx_packet(stralloc *,char *,unsigned int); +extern int dns_mx(stralloc *,stralloc *); extern int dns_resolvconfrewrite(stralloc *); -extern int dns_ip4_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *); -extern int dns_ip4_qualify(stralloc *,stralloc *,const stralloc *); -extern int dns_ip6_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *); -extern int dns_ip6_qualify(stralloc *,stralloc *,const stralloc *); - -extern int dns_name6_domain(char *,char *); -#define DNS_NAME6_DOMAIN (4*16+11) +extern int dns_ip4_qualify_rules(stralloc *,stralloc *,stralloc *,stralloc *); +extern int dns_ip4_qualify(stralloc *,stralloc *,stralloc *); #endif @@ -1,10 +1,9 @@ -#include <stdlib.h> -#include <errno.h> +#include "error.h" +#include "alloc.h" #include "byte.h" #include "dns.h" -#include "error.h" -int dns_domain_fromdot(char **out,const char *buf,unsigned int n) +int dns_domain_fromdot(char **out,char *buf,unsigned int n) { char label[63]; unsigned int labellen = 0; /* <= sizeof label */ @@ -60,11 +59,11 @@ int dns_domain_fromdot(char **out,const char *buf,unsigned int n) if (namelen + 1 > sizeof name) return 0; name[namelen++] = 0; - x = malloc(namelen); + x = alloc(namelen); if (!x) return 0; byte_copy(x,namelen,name); - if (*out) free(*out); + if (*out) alloc_free(*out); *out = x; return 1; } diff --git a/dns_domain.c b/dns_domain.c index 80ac5ea..f898485 100644 --- a/dns_domain.c +++ b/dns_domain.c @@ -1,15 +1,16 @@ -#include <stdlib.h> +#include "error.h" +#include "alloc.h" #include "case.h" #include "byte.h" #include "dns.h" -unsigned int dns_domain_length(const char *dn) +unsigned int dns_domain_length(char *dn) { - const char *x; + char *x; unsigned char c; x = dn; - while ((c = *x++)) + while (c = *x++) x += (unsigned int) c; return x - dn; } @@ -17,26 +18,26 @@ unsigned int dns_domain_length(const char *dn) void dns_domain_free(char **out) { if (*out) { - free(*out); + alloc_free(*out); *out = 0; } } -int dns_domain_copy(char **out,const char *in) +int dns_domain_copy(char **out,char *in) { unsigned int len; char *x; len = dns_domain_length(in); - x = malloc(len); + x = alloc(len); if (!x) return 0; byte_copy(x,len,in); - if (*out) free(*out); + if (*out) alloc_free(*out); *out = x; return 1; } -int dns_domain_equal(const char *dn1,const char *dn2) +int dns_domain_equal(char *dn1,char *dn2) { unsigned int len; @@ -47,25 +48,12 @@ int dns_domain_equal(const char *dn1,const char *dn2) return 1; } -int dns_domain_suffix(const char *big,const char *little) -{ - unsigned char c; - - for (;;) { - if (dns_domain_equal(big,little)) return 1; - c = *big++; - if (!c) return 0; - big += c; - } -} - -unsigned int dns_domain_suffixpos(const char *big,const char *little) +char *dns_domain_suffix(char *big,char *little) { - const char *orig = big; unsigned char c; for (;;) { - if (dns_domain_equal(big,little)) return big - orig; + if (dns_domain_equal(big,little)) return big; c = *big++; if (!c) return 0; big += c; @@ -1,7 +1,7 @@ #include "stralloc.h" #include "dns.h" -int dns_domain_todot_cat(stralloc *out,const char *d) +int dns_domain_todot_cat(stralloc *out,char *d) { char ch; char ch2; @@ -3,7 +3,7 @@ #include "byte.h" #include "dns.h" -int dns_ip4_packet(stralloc *out,const char *buf,unsigned int len) +int dns_ip4_packet(stralloc *out,char *buf,unsigned int len) { unsigned int pos; char header[12]; @@ -36,7 +36,7 @@ int dns_ip4_packet(stralloc *out,const char *buf,unsigned int len) static char *q = 0; -int dns_ip4(stralloc *out,const stralloc *fqdn) +int dns_ip4(stralloc *out,stralloc *fqdn) { unsigned int i; char code; diff --git a/dns_ip6.c b/dns_ip6.c deleted file mode 100644 index 1a2ce08..0000000 --- a/dns_ip6.c +++ /dev/null @@ -1,103 +0,0 @@ -#include "stralloc.h" -#include "uint16.h" -#include "byte.h" -#include "dns.h" -#include "ip4.h" -#include "ip6.h" - -static int dns_ip6_packet_add(stralloc *out,const char *buf,unsigned int len) -{ - unsigned int pos; - char header[16]; - uint16 numanswers; - uint16 datalen; - - pos = dns_packet_copy(buf,len,0,header,12); if (!pos) return -1; - uint16_unpack_big(header + 6,&numanswers); - pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; - pos += 4; - - while (numanswers--) { - pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; - pos = dns_packet_copy(buf,len,pos,header,10); if (!pos) return -1; - uint16_unpack_big(header + 8,&datalen); - if (byte_equal(header,2,DNS_T_AAAA)) { - if (byte_equal(header + 2,2,DNS_C_IN)) - if (datalen == 16) { - if (!dns_packet_copy(buf,len,pos,header,16)) return -1; - if (!stralloc_catb(out,header,16)) return -1; - } - } else if (byte_equal(header,2,DNS_T_A)) - if (byte_equal(header + 2,2,DNS_C_IN)) - if (datalen == 4) { - byte_copy(header,12,V4mappedprefix); - if (!dns_packet_copy(buf,len,pos,header+12,4)) return -1; - if (!stralloc_catb(out,header,16)) return -1; - } - pos += datalen; - } - - dns_sortip6(out->s,out->len); - return 0; -} - -int dns_ip6_packet(stralloc *out,const char *buf,unsigned int len) { - if (!stralloc_copys(out,"")) return -1; - return dns_ip6_packet_add(out,buf,len); -} - -static char *q = 0; - -int dns_ip6(stralloc *out,stralloc *fqdn) -{ - unsigned int i; - char code; - char ch; - char ip[16]; - - if (!stralloc_copys(out,"")) return -1; - if (!stralloc_readyplus(fqdn,1)) return -1; - fqdn->s[fqdn->len]=0; - if ((i=scan_ip6(fqdn->s,ip))) { - if (fqdn->s[i]) return -1; - stralloc_copyb(out,ip,16); - return 0; - } - code = 0; - for (i = 0;i <= fqdn->len;++i) { - if (i < fqdn->len) - ch = fqdn->s[i]; - else - ch = '.'; - - if ((ch == '[') || (ch == ']')) continue; - if (ch == '.') { - if (!stralloc_append(out,&code)) return -1; - code = 0; - continue; - } - if ((ch >= '0') && (ch <= '9')) { - code *= 10; - code += ch - '0'; - continue; - } - - if (!dns_domain_fromdot(&q,fqdn->s,fqdn->len)) return -1; - if (!stralloc_copys(out,"")) return -1; - if (dns_resolve(q,DNS_T_AAAA) != -1) - if (dns_ip6_packet_add(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) != -1) { - dns_transmit_free(&dns_resolve_tx); - dns_domain_free(&q); - } - if (!dns_domain_fromdot(&q,fqdn->s,fqdn->len)) return -1; - if (dns_resolve(q,DNS_T_A) != -1) - if (dns_ip6_packet_add(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) != -1) { - dns_transmit_free(&dns_resolve_tx); - dns_domain_free(&q); - } - return out->a>0?0:-1; - } - - out->len &= ~3; - return 0; -} @@ -4,7 +4,7 @@ #include "str.h" #include "dns.h" -static int doit(stralloc *work,const char *rule) +static int doit(stralloc *work,char *rule) { char ch; unsigned int colon; @@ -30,7 +30,7 @@ static int doit(stralloc *work,const char *rule) return stralloc_cats(work,rule + colon + 1); } -int dns_ip4_qualify_rules(stralloc *out,stralloc *fqdn,const stralloc *in,const stralloc *rules) +int dns_ip4_qualify_rules(stralloc *out,stralloc *fqdn,stralloc *in,stralloc *rules) { unsigned int i; unsigned int j; @@ -63,7 +63,7 @@ int dns_ip4_qualify_rules(stralloc *out,stralloc *fqdn,const stralloc *in,const } } -int dns_ip4_qualify(stralloc *out,stralloc *fqdn,const stralloc *in) +int dns_ip4_qualify(stralloc *out,stralloc *fqdn,stralloc *in) { static stralloc rules; if (dns_resolvconfrewrite(&rules) == -1) return -1; diff --git a/dns_ipq6.c b/dns_ipq6.c deleted file mode 100644 index d5cea12..0000000 --- a/dns_ipq6.c +++ /dev/null @@ -1,72 +0,0 @@ -#include "stralloc.h" -#include "case.h" -#include "byte.h" -#include "str.h" -#include "dns.h" - -static int doit(stralloc *work,const char *rule) -{ - char ch; - unsigned int colon; - unsigned int prefixlen; - - ch = *rule++; - if ((ch != '?') && (ch != '=') && (ch != '*') && (ch != '-')) return 1; - colon = str_chr(rule,':'); - if (!rule[colon]) return 1; - - if (work->len < colon) return 1; - prefixlen = work->len - colon; - if ((ch == '=') && prefixlen) return 1; - if (case_diffb(rule,colon,work->s + prefixlen)) return 1; - if (ch == '?') { - if (byte_chr(work->s,prefixlen,'.') < prefixlen) return 1; - if (byte_chr(work->s,prefixlen,':') < prefixlen) return 1; - if (byte_chr(work->s,prefixlen,'[') < prefixlen) return 1; - if (byte_chr(work->s,prefixlen,']') < prefixlen) return 1; - } - - work->len = prefixlen; - if (ch == '-') work->len = 0; - return stralloc_cats(work,rule + colon + 1); -} - -int dns_ip6_qualify_rules(stralloc *out,stralloc *fqdn,const stralloc *in,const stralloc *rules) -{ - unsigned int i; - unsigned int j; - unsigned int plus; - unsigned int fqdnlen; - - if (!stralloc_copy(fqdn,in)) return -1; - - for (j = i = 0;j < rules->len;++j) - if (!rules->s[j]) { - if (!doit(fqdn,rules->s + i)) return -1; - i = j + 1; - } - - fqdnlen = fqdn->len; - plus = byte_chr(fqdn->s,fqdnlen,'+'); - if (plus >= fqdnlen) - return dns_ip6(out,fqdn); - - i = plus + 1; - for (;;) { - j = byte_chr(fqdn->s + i,fqdnlen - i,'+'); - byte_copy(fqdn->s + plus,j,fqdn->s + i); - fqdn->len = plus + j; - if (dns_ip6(out,fqdn) == -1) return -1; - if (out->len) return 0; - i += j; - if (i >= fqdnlen) return 0; - ++i; - } -} - -int dns_ip6_qualify(stralloc *out,stralloc *fqdn,const stralloc *in) -{ - static stralloc rules; - if (dns_resolvconfrewrite(&rules) == -1) return -1; - return dns_ip6_qualify_rules(out,fqdn,in,&rules); -} @@ -2,11 +2,10 @@ #include "uint16.h" #include "byte.h" #include "dns.h" -#include "ip6.h" static char *q = 0; -int dns_name_packet(stralloc *out,const char *buf,unsigned int len) +int dns_name_packet(stralloc *out,char *buf,unsigned int len) { unsigned int pos; char header[12]; @@ -36,7 +35,7 @@ int dns_name_packet(stralloc *out,const char *buf,unsigned int len) return 0; } -int dns_name4(stralloc *out,const char ip[4]) +int dns_name4(stralloc *out,char ip[4]) { char name[DNS_NAME4_DOMAIN]; @@ -47,17 +46,3 @@ int dns_name4(stralloc *out,const char ip[4]) dns_domain_free(&q); return 0; } - -int dns_name6(stralloc *out,char ip[16]) -{ - char name[DNS_NAME6_DOMAIN]; - - if (ip6_isv4mapped(ip)) - return dns_name4(out,ip+12); - dns_name6_domain(name,ip); - if (dns_resolve(name,DNS_T_PTR) == -1) return -1; - if (dns_name_packet(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) == -1) return -1; - dns_transmit_free(&dns_resolve_tx); - dns_domain_free(&q); - return 0; -} @@ -2,7 +2,7 @@ #include "fmt.h" #include "dns.h" -void dns_name4_domain(char name[DNS_NAME4_DOMAIN],const char ip[4]) +void dns_name4_domain(char name[DNS_NAME4_DOMAIN],char ip[4]) { unsigned int namelen; unsigned int i; diff --git a/dns_nd6.c b/dns_nd6.c deleted file mode 100644 index fb1da88..0000000 --- a/dns_nd6.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "byte.h" -#include "fmt.h" -#include "dns.h" - -/* RFC1886: - * 4321:0:1:2:3:4:567:89ab - * -> - * b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.IP6.INT. - */ - -static inline char tohex(char c) { - return c>=10?c-10+'a':c+'0'; -} - -int dns_name6_domain(char name[DNS_NAME6_DOMAIN],char ip[16]) -{ - unsigned int j; - - for (j=0; j<16; j++) { - name[j*4]=1; - name[j*4+1]=tohex(ip[15-j] & 15); - name[j*4+2]=1; - name[j*4+3]=tohex((unsigned char)ip[15-j] >> 4); - } - byte_copy(name + 4*16,10,"\3ip6\4arpa\0"); - return 4*16+10; -} - diff --git a/dns_packet.c b/dns_packet.c index 72cfb35..04a2cc8 100644 --- a/dns_packet.c +++ b/dns_packet.c @@ -2,11 +2,10 @@ DNS should have used LZ77 instead of its own sophomoric compression algorithm. */ -#include <errno.h> -#include "dns.h" #include "error.h" +#include "dns.h" -unsigned int dns_packet_copy(const char *buf,unsigned int len,unsigned int pos,char *out,unsigned int outlen) +unsigned int dns_packet_copy(char *buf,unsigned int len,unsigned int pos,char *out,unsigned int outlen) { while (outlen) { if (pos >= len) { errno = error_proto; return 0; } @@ -16,7 +15,7 @@ unsigned int dns_packet_copy(const char *buf,unsigned int len,unsigned int pos,c return pos; } -unsigned int dns_packet_skipname(const char *buf,unsigned int len,unsigned int pos) +unsigned int dns_packet_skipname(char *buf,unsigned int len,unsigned int pos) { unsigned char ch; @@ -33,7 +32,7 @@ unsigned int dns_packet_skipname(const char *buf,unsigned int len,unsigned int p return 0; } -unsigned int dns_packet_getname(const char *buf,unsigned int len,unsigned int pos,char **d) +unsigned int dns_packet_getname(char *buf,unsigned int len,unsigned int pos,char **d) { unsigned int loop = 0; unsigned int state = 0; diff --git a/dns_random.c b/dns_random.c index 2158ed4..b9892b4 100644 --- a/dns_random.c +++ b/dns_random.c @@ -1,4 +1,3 @@ -#include <unistd.h> #include "dns.h" #include "taia.h" #include "uint32.h" @@ -30,7 +29,7 @@ static void surf(void) } } -void dns_random_init(const char data[128]) +void dns_random_init(char data[128]) { int i; struct taia t; @@ -2,13 +2,12 @@ #include "openreadclose.h" #include "byte.h" #include "ip4.h" -#include "ip6.h" -#include "dns.h" #include "env.h" +#include "dns.h" static stralloc data = {0}; -static int init(char ip[256]) +static int init(char ip[64]) { int i; int j; @@ -17,16 +16,15 @@ static int init(char ip[256]) x = env_get("DNSCACHEIP"); if (x) - while (iplen <= 60) { + while (iplen <= 60) if (*x == '.') ++x; else { - i = scan_ip6(x,ip + iplen); + i = ip4_scan(x,ip + iplen); if (!i) break; x += i; - iplen += 16; + iplen += 4; } - } if (!iplen) { i = openreadclose("/etc/resolv.conf",&data,64); @@ -41,9 +39,8 @@ static int init(char ip[256]) while ((data.s[i] == ' ') || (data.s[i] == '\t')) ++i; if (iplen <= 60) - if (scan_ip6(data.s + i,ip + iplen)) { - iplen += 16; - } + if (ip4_scan(data.s + i,ip + iplen)) + iplen += 4; } i = j + 1; } @@ -51,19 +48,19 @@ static int init(char ip[256]) } if (!iplen) { - byte_copy(ip,16,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1"); - iplen = 16; + byte_copy(ip,4,"\177\0\0\1"); + iplen = 4; } - byte_zero(ip + iplen,256 - iplen); + byte_zero(ip + iplen,64 - iplen); return 0; } static int ok = 0; static unsigned int uses; static struct taia deadline; -static char ip[256]; /* defined if ok */ +static char ip[64]; /* defined if ok */ -int dns_resolvconfip(char s[256]) +int dns_resolvconfip(char s[64]) { struct taia now; @@ -80,6 +77,6 @@ int dns_resolvconfip(char s[256]) } --uses; - byte_copy(s,256,ip); + byte_copy(s,64,ip); return 0; } @@ -1,17 +1,16 @@ -#include <unistd.h> #include "taia.h" +#include "env.h" #include "byte.h" #include "str.h" #include "openreadclose.h" #include "dns.h" -#include "env.h" static stralloc data = {0}; static int init(stralloc *rules) { char host[256]; - const char *x; + char *x; int i; int j; int k; diff --git a/dns_resolve.c b/dns_resolve.c index 82b5bbb..3365c00 100644 --- a/dns_resolve.c +++ b/dns_resolve.c @@ -2,20 +2,19 @@ #include "taia.h" #include "byte.h" #include "dns.h" -#include "ip6.h" struct dns_transmit dns_resolve_tx = {0}; -int dns_resolve(const char *q,const char qtype[2]) +int dns_resolve(char *q,char qtype[2]) { struct taia stamp; struct taia deadline; - char servers[256]; + char servers[64]; iopause_fd x[1]; int r; if (dns_resolvconfip(servers) == -1) return -1; - if (dns_transmit_start(&dns_resolve_tx,servers,1,q,qtype,V6any) == -1) return -1; + if (dns_transmit_start(&dns_resolve_tx,servers,1,q,qtype,"\0\0\0\0") == -1) return -1; for (;;) { taia_now(&stamp); diff --git a/dns_sortip6.c b/dns_sortip6.c deleted file mode 100644 index 7e752e9..0000000 --- a/dns_sortip6.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "byte.h" -#include "dns.h" - -/* XXX: sort servers by configurable notion of closeness? */ -/* XXX: pay attention to competence of each server? */ - -void dns_sortip6(char *s,unsigned int n) -{ - unsigned int i; - char tmp[16]; - - n >>= 4; - while (n > 1) { - i = dns_random(n); - --n; - byte_copy(tmp,16,s + (i << 4)); - byte_copy(s + (i << 4),16,s + (n << 4)); - byte_copy(s + (n << 4),16,tmp); - } -} diff --git a/dns_transmit.c b/dns_transmit.c index 9511511..df12826 100644 --- a/dns_transmit.c +++ b/dns_transmit.c @@ -1,15 +1,12 @@ -#include <sys/types.h> -#include <sys/socket.h> -#include <unistd.h> -#include <stdlib.h> #include "socket.h" -#include <errno.h> +#include "alloc.h" +#include "error.h" #include "byte.h" +#include "readwrite.h" #include "uint16.h" #include "dns.h" -#include "ip6.h" -static int serverwantstcp(const char *buf,unsigned int len) +static int serverwantstcp(char *buf,unsigned int len) { char out[12]; @@ -18,7 +15,7 @@ static int serverwantstcp(const char *buf,unsigned int len) return 0; } -static int serverfailed(const char *buf,unsigned int len) +static int serverfailed(char *buf,unsigned int len) { char out[12]; unsigned int rcode; @@ -26,11 +23,11 @@ static int serverfailed(const char *buf,unsigned int len) if (!dns_packet_copy(buf,len,0,out,12)) return 1; rcode = out[3]; rcode &= 15; - if (rcode && (rcode != 3)) { errno = EAGAIN; return 1; } + if (rcode && (rcode != 3)) { errno = error_again; return 1; } return 0; } -static int irrelevant(const struct dns_transmit *d,const char *buf,unsigned int len) +static int irrelevant(struct dns_transmit *d,char *buf,unsigned int len) { char out[12]; char *dn; @@ -43,8 +40,8 @@ static int irrelevant(const struct dns_transmit *d,const char *buf,unsigned int dn = 0; pos = dns_packet_getname(buf,len,pos,&dn); if (!pos) return 1; - if (!dns_domain_equal(dn,d->query + 14)) { free(dn); return 1; } - free(dn); + if (!dns_domain_equal(dn,d->query + 14)) { alloc_free(dn); return 1; } + alloc_free(dn); pos = dns_packet_copy(buf,len,pos,out,4); if (!pos) return 1; if (byte_diff(out,2,d->qtype)) return 1; @@ -56,14 +53,14 @@ static int irrelevant(const struct dns_transmit *d,const char *buf,unsigned int static void packetfree(struct dns_transmit *d) { if (!d->packet) return; - free(d->packet); + alloc_free(d->packet); d->packet = 0; } static void queryfree(struct dns_transmit *d) { if (!d->query) return; - free(d->query); + alloc_free(d->query); d->query = 0; } @@ -86,9 +83,9 @@ static int randombind(struct dns_transmit *d) int j; for (j = 0;j < 10;++j) - if (socket_bind6(d->s1 - 1,d->localip,1025 + dns_random(64510),d->scope_id) == 0) + if (socket_bind4(d->s1 - 1,d->localip,1025 + dns_random(64510)) == 0) return 0; - if (socket_bind6(d->s1 - 1,d->localip,0,d->scope_id) == 0) + if (socket_bind4(d->s1 - 1,d->localip,0) == 0) return 0; return -1; } @@ -97,22 +94,22 @@ static const int timeouts[4] = { 1, 3, 11, 45 }; static int thisudp(struct dns_transmit *d) { - const char *ip; + char *ip; socketfree(d); while (d->udploop < 4) { for (;d->curserver < 16;++d->curserver) { - ip = d->servers + 16 * d->curserver; - if (byte_diff(ip,16,V6any)) { + ip = d->servers + 4 * d->curserver; + if (byte_diff(ip,4,"\0\0\0\0")) { d->query[2] = dns_random(256); d->query[3] = dns_random(256); - d->s1 = 1 + socket_udp6(); + d->s1 = 1 + socket_udp(); if (!d->s1) { dns_transmit_free(d); return -1; } if (randombind(d) == -1) { dns_transmit_free(d); return -1; } - if (socket_connect6(d->s1 - 1,ip,53,d->scope_id) == 0) + if (socket_connect4(d->s1 - 1,ip,53) == 0) if (send(d->s1 - 1,d->query + 2,d->querylen - 2,0) == d->querylen - 2) { struct taia now; taia_now(&now); @@ -148,29 +145,29 @@ static int nextudp(struct dns_transmit *d) static int thistcp(struct dns_transmit *d) { struct taia now; - const char *ip; + char *ip; socketfree(d); packetfree(d); for (;d->curserver < 16;++d->curserver) { - ip = d->servers + 16 * d->curserver; - if (byte_diff(ip,16,V6any)) { + ip = d->servers + 4 * d->curserver; + if (byte_diff(ip,4,"\0\0\0\0")) { d->query[2] = dns_random(256); d->query[3] = dns_random(256); - d->s1 = 1 + socket_tcp6(); + d->s1 = 1 + socket_tcp(); if (!d->s1) { dns_transmit_free(d); return -1; } if (randombind(d) == -1) { dns_transmit_free(d); return -1; } taia_now(&now); taia_uint(&d->deadline,10); taia_add(&d->deadline,&d->deadline,&now); - if (socket_connect6(d->s1 - 1,ip,53,d->scope_id) == 0) { + if (socket_connect4(d->s1 - 1,ip,53) == 0) { d->tcpstate = 2; return 0; } - if ((errno == EINPROGRESS) || (errno == EWOULDBLOCK)) { + if ((errno == error_inprogress) || (errno == error_wouldblock)) { d->tcpstate = 1; return 0; } @@ -194,16 +191,16 @@ static int nexttcp(struct dns_transmit *d) return thistcp(d); } -int dns_transmit_start(struct dns_transmit *d,const char servers[256],int flagrecursive,const char *q,const char qtype[2],const char localip[16]) +int dns_transmit_start(struct dns_transmit *d,char servers[64],int flagrecursive,char *q,char qtype[2],char localip[4]) { unsigned int len; dns_transmit_free(d); - errno = EIO; + errno = error_io; len = dns_domain_length(q); d->querylen = len + 18; - d->query = malloc(d->querylen); + d->query = alloc(d->querylen); if (!d->query) return -1; uint16_pack_big(d->query,len + 16); @@ -214,7 +211,7 @@ int dns_transmit_start(struct dns_transmit *d,const char servers[256],int flagre byte_copy(d->qtype,2,qtype); d->servers = servers; - byte_copy(d->localip,16,localip); + byte_copy(d->localip,4,localip); d->udploop = flagrecursive ? 1 : 0; @@ -239,19 +236,19 @@ void dns_transmit_io(struct dns_transmit *d,iopause_fd *x,struct taia *deadline) *deadline = d->deadline; } -int dns_transmit_get(struct dns_transmit *d,const iopause_fd *x,const struct taia *when) +int dns_transmit_get(struct dns_transmit *d,iopause_fd *x,struct taia *when) { char udpbuf[513]; unsigned char ch; int r; int fd; - errno = EIO; + errno = error_io; fd = d->s1 - 1; if (!x->revents) { if (taia_less(when,&d->deadline)) return 0; - errno = ETIMEDOUT; + errno = error_timeout; if (d->tcpstate == 0) return nextudp(d); return nexttcp(d); } @@ -263,7 +260,7 @@ have sent query to curserver on UDP socket s */ r = recv(fd,udpbuf,sizeof udpbuf,0); if (r <= 0) { - if (errno == ECONNREFUSED) if (d->udploop == 2) return 0; + if (d->udploop == 2) return 0; return nextudp(d); } if (r + 1 > sizeof udpbuf) return 0; @@ -277,7 +274,7 @@ have sent query to curserver on UDP socket s socketfree(d); d->packetlen = r; - d->packet = malloc(d->packetlen); + d->packet = alloc(d->packetlen); if (!d->packet) { dns_transmit_free(d); return -1; } byte_copy(d->packet,d->packetlen,udpbuf); queryfree(d); @@ -337,7 +334,7 @@ have received one byte of packet length into packetlen d->packetlen += ch; d->tcpstate = 5; d->pos = 0; - d->packet = malloc(d->packetlen); + d->packet = alloc(d->packetlen); if (!d->packet) { dns_transmit_free(d); return -1; } return 0; } @@ -3,7 +3,7 @@ #include "byte.h" #include "dns.h" -int dns_txt_packet(stralloc *out,const char *buf,unsigned int len) +int dns_txt_packet(stralloc *out,char *buf,unsigned int len) { unsigned int pos; char header[12]; @@ -48,7 +48,7 @@ int dns_txt_packet(stralloc *out,const char *buf,unsigned int len) static char *q = 0; -int dns_txt(stralloc *out,const stralloc *fqdn) +int dns_txt(stralloc *out,stralloc *fqdn) { if (!dns_domain_fromdot(&q,fqdn->s,fqdn->len)) return -1; if (dns_resolve(q,DNS_T_TXT) == -1) return -1; @@ -1,7 +1,7 @@ #ifndef ERROR_H #define ERROR_H -#include <errno.h> +extern int errno; extern int error_intr; extern int error_nomem; diff --git a/finger@.1 b/finger@.1 deleted file mode 100644 index 93b6288..0000000 --- a/finger@.1 +++ /dev/null @@ -1,45 +0,0 @@ -.TH finger@ 1 -.SH NAME -finger@ \- get user information from a host -.SH SYNTAX -.B finger@ -[ -.I host -[ -.I user -] -] -.SH DESCRIPTION -.B finger@ -connects to TCP port 79 (Finger) on -.IR host , -sends -.I user -(with an extra CR) -to -.IR host , -and prints any data it receives. -It removes CR and converts unprintable characters to a visible format. -Some computers respond to port 79 with information about -.IR user . - -If -.I user -is not supplied, -.B finger@ -sends a blank line to -.IR host . -Some computers respond with information about -all the users who are logged in. - -If -.I host -is not supplied, -.B finger@ -connects to the local host. -.SH "SEE ALSO" -addcr(1), -cat(1), -delcr(1), -finger(1), -tcpclient(1) diff --git a/fixcr.1 b/fixcr.1 deleted file mode 100644 index ebb8b53..0000000 --- a/fixcr.1 +++ /dev/null @@ -1,11 +0,0 @@ -.TH fixcr 1 -.SH NAME -fixcr \- make sure that there is a CR before each LF -.SH SYNOPSIS -.B fixcr -.SH DESCRIPTION -.B fixcr -inserts CR at the end of each line of input where a CR is not already present. -It does not insert CR at the end of a partial final line. -.SH "SEE ALSO" -addcr(1) diff --git a/fmt_xlong.c b/fmt_xlong.c deleted file mode 100644 index 332fc9a..0000000 --- a/fmt_xlong.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "fmt.h" - -char tohex(char num) { - if (num<10) - return num+'0'; - else if (num<16) - return num-10+'a'; - else - return -1; -} - -unsigned int fmt_xlong(register char *s,register unsigned long u) -{ - register unsigned int len; register unsigned long q; - len = 1; q = u; - while (q > 15) { ++len; q /= 16; } - if (s) { - s += len; - do { *--s = tohex(u % 16); u /= 16; } while(u); /* handles u == 0 */ - } - return len; -} diff --git a/haveip6.h b/haveip6.h deleted file mode 100644 index 5564de9..0000000 --- a/haveip6.h +++ /dev/null @@ -1 +0,0 @@ -#define LIBC_HAS_IP6 1 diff --git a/haveip6.h1 b/haveip6.h1 deleted file mode 100644 index 8b13789..0000000 --- a/haveip6.h1 +++ /dev/null @@ -1 +0,0 @@ - diff --git a/haveip6.h2 b/haveip6.h2 deleted file mode 100644 index 5564de9..0000000 --- a/haveip6.h2 +++ /dev/null @@ -1 +0,0 @@ -#define LIBC_HAS_IP6 1 @@ -4,9 +4,6 @@ void hier() { h(auto_home,-1,-1,02755); d(auto_home,"bin",-1,-1,02755); - d(auto_home,"man",-1,-1,02755); - d(auto_home,"man/man1",-1,-1,02755); - d(auto_home,"man/man5",-1,-1,02755); c(auto_home,"bin","tcpserver",-1,-1,0755); c(auto_home,"bin","tcprules",-1,-1,0755); @@ -25,20 +22,4 @@ void hier() c(auto_home,"bin","delcr",-1,-1,0755); c(auto_home,"bin","fixcrio",-1,-1,0755); c(auto_home,"bin","rblsmtpd",-1,-1,0755); - - c(auto_home,"man/man1","tcpclient.1",-1,-1,0644); - c(auto_home,"man/man1","tcpserver.1",-1,-1,0644); - c(auto_home,"man/man1","tcprules.1",-1,-1,0644); - c(auto_home,"man/man1","tcprulescheck.1",-1,-1,0644); - c(auto_home,"man/man1","fixcr.1",-1,-1,0644); - c(auto_home,"man/man1","addcr.1",-1,-1,0644); - c(auto_home,"man/man1","delcr.1",-1,-1,0644); - c(auto_home,"man/man1","who@.1",-1,-1,0644); - c(auto_home,"man/man1","date@.1",-1,-1,0644); - c(auto_home,"man/man1","finger@.1",-1,-1,0644); - c(auto_home,"man/man1","http@.1",-1,-1,0644); - c(auto_home,"man/man1","mconnect.1",-1,-1,0644); - c(auto_home,"man/man1","argv0.1",-1,-1,0644); - c(auto_home,"man/man1","recordio.1",-1,-1,0644); - c(auto_home,"man/man5","tcp-environ.5",-1,-1,0644); } diff --git a/http@.1 b/http@.1 deleted file mode 100644 index 4861b34..0000000 --- a/http@.1 +++ /dev/null @@ -1,52 +0,0 @@ -.TH http@ 1 -.SH NAME -http@ \- get a web page from a host through HTTP -.SH SYNTAX -.B http@ -[ -.I host -[ -.I page -[ -.I port -] -] -] -.SH DESCRIPTION -.B http@ -connects to -.I port -on -.IR host , -sends -.B GET /\fIpage -(with an extra CR) -to -.IR host , -and prints any data it receives, -removing CR from the end of each line. - -If -.I port -is not supplied, -.B http@ -uses port 80 (HTTP). - -If -.I page -is not supplied, -.B http@ -sends -.B GET / -to -.IR host . - -If -.I host -is not supplied, -.B http@ -connects to the local host. -.SH "SEE ALSO" -addcr(1), -delcr(1), -tcpclient(1) @@ -6,6 +6,4 @@ extern unsigned int ip4_fmt(char *,char *); #define IP4_FMT 20 -extern const char ip4loopback[4]; /* = {127,0,0,1}; */ - #endif @@ -1,28 +0,0 @@ -#ifndef IP6_H -#define IP6_H - -#include "byte.h" - -extern unsigned int scan_ip6(const char *src,char *ip); -extern unsigned int fmt_ip6(char *dest,const char *ip); - -extern unsigned int scan_ip6_flat(const char *src,char *); -extern unsigned int fmt_ip6_flat(char *dest,const char *); - -/* - ip6 address syntax: (h = hex digit), no leading '0' required - 1. hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh - 2. any number of 0000 may be abbreviated as "::", but only once - flat ip6 address syntax: - hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh - */ - -#define IP6_FMT 40 - -extern const unsigned char V4mappedprefix[12]; /*={0,0,0,0,0,0,0,0,0,0,0xff,0xff}; */ -extern const unsigned char V6loopback[16]; /*={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; */ -extern const unsigned char V6any[16]; /*={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; */ - -#define ip6_isv4mapped(ip) (byte_equal(ip,12,V4mappedprefix)) - -#endif diff --git a/ip6_fmt.c b/ip6_fmt.c deleted file mode 100644 index eb56d36..0000000 --- a/ip6_fmt.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "fmt.h" -#include "byte.h" -#include "ip4.h" -#include "ip6.h" - -unsigned int ip6_fmt(char *s,char ip[16]) -{ - unsigned int len; - unsigned int i; - unsigned int temp; - unsigned int compressing; - int j; - - len = 0; compressing = 0; - for (j=0; j<16; j+=2) { - if (j==12 && ip6_isv4mapped(ip)) { - temp=ip4_fmt(s,ip+12); - len+=temp; - s+=temp; - break; - } - temp = ((unsigned long) (unsigned char) ip[j] << 8) + - (unsigned long) (unsigned char) ip[j+1]; - if (temp == 0) { - if (!compressing) { - compressing=1; - if (j==0) { - *s=':'; s+=1; ++len; - } - } - } else { - if (compressing) { - compressing=0; - *s=':'; s+=1; ++len; - } - i = fmt_xlong(s,temp); len += i; if (s) s += i; - if (s && j<14) *s++ = ':'; ++len; - } - } - - if (s) *s=0; - return len; -} - -static char tohex(char num) { - if (num<10) - return num+'0'; - else if (num<16) - return num-10+'a'; - else - return -1; -} - -unsigned int ip6_fmt_flat(char *s,char ip[16]) -{ - int i; - for (i=0; i<16; i++) { - *s++=tohex((unsigned char)ip[i] >> 4); - *s++=tohex((unsigned char)ip[i] & 15); - } - return 32; -} diff --git a/mconnect.1 b/mconnect.1 deleted file mode 100644 index 6648367..0000000 --- a/mconnect.1 +++ /dev/null @@ -1,36 +0,0 @@ -.TH mconnect 1 -.SH NAME -mconnect \- connect to the SMTP server on a host -.SH SYNTAX -.B mconnect -[ -.I host -[ -.I port -] -] -.SH DESCRIPTION -.B mconnect -connects to -.I port -on -.IR host . -It sends its input to -.IR host , -adding a CR to each line. -Meanwhile it prints anything it receives from -.IR host . - -If -.I port -is not supplied, -.B mconnect -uses port 25 (SMTP). - -If -.I host -is not supplied, -.B mconnect -connects to the local host. -.SH "SEE ALSO" -tcpclient(1) diff --git a/old-rules.c b/old-rules.c deleted file mode 100644 index 7225115..0000000 --- a/old-rules.c +++ /dev/null @@ -1,101 +0,0 @@ -#include "alloc.h" -#include "stralloc.h" -#include "open.h" -#include "cdb.h" -#include "rules.h" - -stralloc rules_name = {0}; - -static struct cdb c; - -static int dorule(void (*callback)(char *,unsigned int)) -{ - char *data; - unsigned int datalen; - - switch(cdb_find(&c,rules_name.s,rules_name.len)) { - case -1: return -1; - case 0: return 0; - } - - datalen = cdb_datalen(&c); - data = alloc(datalen); - if (!data) return -1; - if (cdb_read(&c,data,datalen,cdb_datapos(&c)) == -1) { - alloc_free(data); - return -1; - } - - callback(data,datalen); - alloc_free(data); - return 1; -} - -static int doit(void (*callback)(char *,unsigned int),char *ip,char *host,char *info) -{ - int r; - - if (info) { - if (!stralloc_copys(&rules_name,info)) return -1; - if (!stralloc_cats(&rules_name,"@")) return -1; - if (!stralloc_cats(&rules_name,ip)) return -1; - r = dorule(callback); - if (r) return r; - - if (host) { - if (!stralloc_copys(&rules_name,info)) return -1; - if (!stralloc_cats(&rules_name,"@=")) return -1; - if (!stralloc_cats(&rules_name,host)) return -1; - r = dorule(callback); - if (r) return r; - } - } - - if (!stralloc_copys(&rules_name,ip)) return -1; - r = dorule(callback); - if (r) return r; - - if (host) { - if (!stralloc_copys(&rules_name,"=")) return -1; - if (!stralloc_cats(&rules_name,host)) return -1; - r = dorule(callback); - if (r) return r; - } - - if (!stralloc_copys(&rules_name,ip)) return -1; - while (rules_name.len > 0) { - if (ip[rules_name.len - 1] == '.' || - (ip[rules_name.len-1]==':' && rules_name.len>1)) { - r = dorule(callback); - if (r) return r; - } - --rules_name.len; - } - - if (host) { - while (*host) { - if (*host == '.') { - if (!stralloc_copys(&rules_name,"=")) return -1; - if (!stralloc_cats(&rules_name,host)) return -1; - r = dorule(callback); - if (r) return r; - } - ++host; - } - if (!stralloc_copys(&rules_name,"=")) return -1; - r = dorule(callback); - if (r) return r; - } - - rules_name.len = 0; - return dorule(callback); -} - -int rules(void (*callback)(char *,unsigned int),int fd,char *ip,char *host,char *info) -{ - int r; - cdb_init(&c,fd); - r = doit(callback,ip,host,info); - cdb_free(&c); - return r; -} diff --git a/patches/rblsmtpd-logging.patch b/patches/rblsmtpd-logging.patch deleted file mode 100644 index 975a22e..0000000 --- a/patches/rblsmtpd-logging.patch +++ /dev/null @@ -1,49 +0,0 @@ ---- ucspi-tcp-0.88/rblsmtpd.c.orig 2003-11-16 23:52:05.000000000 -0800 -+++ ucspi-tcp-0.88/rblsmtpd.c 2003-12-28 14:48:26.000000000 -0800 -@@ -55,6 +55,7 @@ - - int decision = 0; /* 0 undecided, 1 accept, 2 reject, 3 bounce */ - static stralloc text; /* defined if decision is 2 or 3 */ -+static char *decision_base; - - static stralloc tmp; - -@@ -76,6 +77,7 @@ - if (flagfailclosed) { - if (!stralloc_copys(&text,"temporary RBL lookup error")) nomem(); - decision = 2; -+ decision_base = base; - } - return; - } -@@ -105,15 +107,18 @@ - if (flagfailclosed) { - if (!stralloc_copys(&text,"temporary RBL lookup error")) nomem(); - decision = 2; -+ decision_base = base; - } - return; - } - } -- if (text.len) -+ if (text.len) { - if (flagrblbounce) - decision = 3; - else - decision = 2; -+ decision_base = base; -+ } - } - - void antirbl(char *base) -@@ -173,6 +178,10 @@ - buffer_puts(buffer_2,ip_env); - buffer_puts(buffer_2," pid "); - buffer_put(buffer_2,strnum,fmt_ulong(strnum,getpid())); -+ if (decision_base) { -+ buffer_puts(buffer_2, " "); -+ buffer_puts(buffer_2,decision_base); -+ } - buffer_puts(buffer_2,": "); - buffer_put(buffer_2,message.s,message.len); - buffer_puts(buffer_2,"\n"); diff --git a/patches/rblsmtpd-nodefaultrbl.patch b/patches/rblsmtpd-nodefaultrbl.patch deleted file mode 100644 index fd9e90e..0000000 --- a/patches/rblsmtpd-nodefaultrbl.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff -ur ucspi-tcp-0.88.orig/rblsmtpd.c ucspi-tcp-0.88/rblsmtpd.c ---- ucspi-tcp-0.88.orig/rblsmtpd.c Thu Jan 16 14:33:56 2003 -+++ ucspi-tcp-0.88/rblsmtpd.c Thu Jan 16 14:38:17 2003 -@@ -155,7 +155,6 @@ - - main(int argc,char **argv,char **envp) - { -- int flagwantdefaultrbl = 1; - char *x; - int opt; - -@@ -182,7 +181,7 @@ - case 'c': flagfailclosed = 1; break; - case 'C': flagfailclosed = 0; break; - case 't': scan_ulong(optarg,&timeout); break; -- case 'r': rbl(optarg); flagwantdefaultrbl = 0; break; -+ case 'r': rbl(optarg); break; - case 'a': antirbl(optarg); break; - default: usage(); - } -@@ -190,7 +189,6 @@ - argv += optind; - if (!*argv) usage(); - -- if (flagwantdefaultrbl) rbl("rbl.maps.vix.com"); - if (decision >= 2) rblsmtpd(); - - pathexec_run(*argv,argv,envp); diff --git a/patches/ucspi-tcp-0.88-ipv6.diff17 b/patches/ucspi-tcp-0.88-ipv6.diff17 deleted file mode 100644 index 52769a9..0000000 --- a/patches/ucspi-tcp-0.88-ipv6.diff17 +++ /dev/null @@ -1,4900 +0,0 @@ -diff -uNr ucspi-tcp-0.88-stock/FILES ucspi-tcp-0.88/FILES ---- ucspi-tcp-0.88-stock/FILES Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/FILES Fri Sep 9 12:07:53 2005 -@@ -216,3 +216,40 @@ - warn-auto.sh - warn-shsgr - x86cpuid.c -+dns_ip6.c -+dns_ipq6.c -+dns_nd6.c -+dns_sortip6.c -+fmt_xlong.c -+ip6_fmt.c -+ip6_scan.c -+scan_0x.c -+socket_accept6.c -+socket_bind6.c -+socket_conn6.c -+socket_local6.c -+socket_recv6.c -+socket_remote6.c -+socket_send6.c -+socket_tcp6.c -+timeoutconn6.c -+tryip6.c -+haveip6.h2 -+haveip6.h1 -+remoteinfo6.c -+addcr.1 -+argv0.1 -+date@.1 -+delcr.1 -+finger@.1 -+fixcr.1 -+http@.1 -+mconnect.1 -+recordio.1 -+tcp-environ.5 -+tcpcat.1 -+tcpclient.1 -+tcprules.1 -+tcprulescheck.1 -+tcpserver.1 -+who@.1 -diff -uNr ucspi-tcp-0.88-stock/Makefile ucspi-tcp-0.88/Makefile ---- ucspi-tcp-0.88-stock/Makefile Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/Makefile Fri Sep 9 12:07:53 2005 -@@ -76,12 +76,14 @@ - makelib byte_chr.o byte_copy.o byte_cr.o byte_diff.o byte_rchr.o \ - byte_zero.o case_diffb.o case_diffs.o fmt_ulong.o ip4_fmt.o \ - ip4_scan.o scan_ulong.o str_chr.o str_diff.o str_len.o str_start.o \ --uint16_pack.o uint16_unpack.o uint32_pack.o uint32_unpack.o -+uint16_pack.o uint16_unpack.o uint32_pack.o uint32_unpack.o \ -+ip6_fmt.o scan_ip6.o scan_xlong.o fmt_xlong.o - ./makelib byte.a byte_chr.o byte_copy.o byte_cr.o \ - byte_diff.o byte_rchr.o byte_zero.o case_diffb.o \ - case_diffs.o fmt_ulong.o ip4_fmt.o ip4_scan.o scan_ulong.o \ - str_chr.o str_diff.o str_len.o str_start.o uint16_pack.o \ -- uint16_unpack.o uint32_pack.o uint32_unpack.o -+ uint16_unpack.o uint32_pack.o uint32_unpack.o ip6_fmt.o \ -+ scan_ip6.o scan_xlong.o fmt_xlong.o - - byte_chr.o: \ - compile byte_chr.c byte.h -@@ -181,11 +183,13 @@ - dns.a: \ - makelib dns_dfd.o dns_domain.o dns_dtda.o dns_ip.o dns_ipq.o \ - dns_name.o dns_nd.o dns_packet.o dns_random.o dns_rcip.o dns_rcrw.o \ --dns_resolve.o dns_sortip.o dns_transmit.o dns_txt.o -+dns_resolve.o dns_sortip.o dns_transmit.o dns_txt.o dns_ip6.o \ -+dns_sortip6.o dns_nd6.o dns_ipq6.o - ./makelib dns.a dns_dfd.o dns_domain.o dns_dtda.o dns_ip.o \ - dns_ipq.o dns_name.o dns_nd.o dns_packet.o dns_random.o \ - dns_rcip.o dns_rcrw.o dns_resolve.o dns_sortip.o \ -- dns_transmit.o dns_txt.o -+ dns_transmit.o dns_txt.o dns_ip6.o dns_sortip6.o dns_nd6.o \ -+ dns_ipq6.o - - dns_dfd.o: \ - compile dns_dfd.c error.h alloc.h byte.h dns.h stralloc.h gen_alloc.h \ -@@ -257,7 +261,7 @@ - dns_transmit.o: \ - compile dns_transmit.c socket.h uint16.h alloc.h error.h byte.h \ - readwrite.h uint16.h dns.h stralloc.h gen_alloc.h iopause.h taia.h \ --tai.h uint64.h taia.h -+tai.h uint64.h taia.h uint32.h - ./compile dns_transmit.c - - dns_txt.o: \ -@@ -498,9 +502,15 @@ - remoteinfo.o: \ - compile remoteinfo.c fmt.h buffer.h socket.h uint16.h error.h \ - iopause.h taia.h tai.h uint64.h timeoutconn.h uint16.h remoteinfo.h \ --stralloc.h gen_alloc.h uint16.h -+stralloc.h gen_alloc.h uint16.h uint32.h - ./compile remoteinfo.c - -+remoteinfo6.o: \ -+compile remoteinfo6.c fmt.h buffer.h socket.h uint16.h error.h \ -+iopause.h taia.h tai.h uint64.h timeoutconn.h uint16.h remoteinfo.h \ -+stralloc.h gen_alloc.h uint16.h uint32.h -+ ./compile remoteinfo6.c -+ - rts: \ - warn-auto.sh rts.sh conf-home - cat warn-auto.sh rts.sh \ -@@ -557,43 +567,43 @@ - rm -f trylsock.o trylsock - - socket_accept.o: \ --compile socket_accept.c byte.h socket.h uint16.h -+compile socket_accept.c byte.h socket.h uint16.h uint32.h - ./compile socket_accept.c - - socket_bind.o: \ --compile socket_bind.c byte.h socket.h uint16.h -+compile socket_bind.c byte.h socket.h uint16.h uint32.h - ./compile socket_bind.c - - socket_conn.o: \ --compile socket_conn.c readwrite.h byte.h socket.h uint16.h -+compile socket_conn.c readwrite.h byte.h socket.h uint16.h uint32.h - ./compile socket_conn.c - - socket_delay.o: \ --compile socket_delay.c socket.h uint16.h -+compile socket_delay.c socket.h uint16.h uint32.h - ./compile socket_delay.c - - socket_listen.o: \ --compile socket_listen.c socket.h uint16.h -+compile socket_listen.c socket.h uint16.h uint32.h - ./compile socket_listen.c - - socket_local.o: \ --compile socket_local.c byte.h socket.h uint16.h -+compile socket_local.c byte.h socket.h uint16.h uint32.h - ./compile socket_local.c - - socket_opts.o: \ --compile socket_opts.c socket.h uint16.h -+compile socket_opts.c socket.h uint16.h uint32.h - ./compile socket_opts.c - - socket_remote.o: \ --compile socket_remote.c byte.h socket.h uint16.h -+compile socket_remote.c byte.h socket.h uint16.h uint32.h - ./compile socket_remote.c - - socket_tcp.o: \ --compile socket_tcp.c ndelay.h socket.h uint16.h -+compile socket_tcp.c ndelay.h socket.h uint16.h uint32.h - ./compile socket_tcp.c - - socket_udp.o: \ --compile socket_udp.c ndelay.h socket.h uint16.h -+compile socket_udp.c ndelay.h socket.h uint16.h uint32.h - ./compile socket_udp.c - - str_chr.o: \ -@@ -710,9 +720,9 @@ - chmod 755 tcpcat - - tcpclient: \ --load tcpclient.o remoteinfo.o timeoutconn.o dns.a time.a unix.a \ --byte.a socket.lib -- ./load tcpclient remoteinfo.o timeoutconn.o dns.a time.a \ -+load tcpclient.o remoteinfo6.o dns.a time.a unix.a \ -+byte.a socket.lib byte.h timeoutconn6.o -+ ./load tcpclient remoteinfo6.o timeoutconn6.o dns.a time.a \ - unix.a byte.a `cat socket.lib` - - tcpclient.o: \ -@@ -720,7 +730,7 @@ - scan.h str.h ip4.h uint16.h socket.h uint16.h fd.h stralloc.h \ - gen_alloc.h buffer.h error.h strerr.h pathexec.h timeoutconn.h \ - uint16.h remoteinfo.h stralloc.h uint16.h dns.h stralloc.h iopause.h \ --taia.h tai.h uint64.h taia.h -+taia.h tai.h uint64.h taia.h uint32.h - ./compile tcpclient.c - - tcprules: \ -@@ -742,9 +752,9 @@ - ./compile tcprulescheck.c - - tcpserver: \ --load tcpserver.o rules.o remoteinfo.o timeoutconn.o cdb.a dns.a \ -+load tcpserver.o rules.o remoteinfo6.o timeoutconn6.o cdb.a dns.a \ - time.a unix.a byte.a socket.lib -- ./load tcpserver rules.o remoteinfo.o timeoutconn.o cdb.a \ -+ ./load tcpserver rules.o remoteinfo6.o timeoutconn6.o cdb.a \ - dns.a time.a unix.a byte.a `cat socket.lib` - - tcpserver.o: \ -@@ -753,7 +763,7 @@ - alloc.h buffer.h error.h strerr.h sgetopt.h subgetopt.h pathexec.h \ - socket.h uint16.h ndelay.h remoteinfo.h stralloc.h uint16.h rules.h \ - stralloc.h sig.h dns.h stralloc.h iopause.h taia.h tai.h uint64.h \ --taia.h -+taia.h uint32.h - ./compile tcpserver.c - - time.a: \ -@@ -765,9 +775,14 @@ - - timeoutconn.o: \ - compile timeoutconn.c ndelay.h socket.h uint16.h iopause.h taia.h \ --tai.h uint64.h error.h timeoutconn.h uint16.h -+tai.h uint64.h error.h timeoutconn.h uint16.h uint32.h - ./compile timeoutconn.c - -+timeoutconn6.o: \ -+compile timeoutconn6.c ndelay.h socket.h uint16.h iopause.h taia.h \ -+tai.h uint64.h error.h timeoutconn.h uint16.h uint32.h -+ ./compile timeoutconn6.c -+ - uint16_pack.o: \ - compile uint16_pack.c uint16.h - ./compile uint16_pack.c -@@ -806,7 +821,12 @@ - socket_opts.o socket_remote.o socket_tcp.o socket_udp.o \ - stralloc_cat.o stralloc_catb.o stralloc_cats.o stralloc_copy.o \ - stralloc_eady.o stralloc_opyb.o stralloc_opys.o stralloc_pend.o \ --strerr_die.o strerr_sys.o subgetopt.o wait_nohang.o wait_pid.o -+strerr_die.o strerr_sys.o subgetopt.o wait_nohang.o wait_pid.o \ -+socket_conn6.o socket_bind6.o socket_accept6.o socket_recv6.o \ -+socket_send6.o socket_local6.o socket_remote6.o socket_tcp6.o \ -+socket_getifname.o socket_getifidx.o socket_v4mappedprefix.o \ -+socket_ip4loopback.o socket_v6any.o socket_v6loopback.o \ -+socket_udp6.o - ./makelib unix.a alloc.o alloc_re.o buffer.o buffer_0.o \ - buffer_1.o buffer_2.o buffer_copy.o buffer_get.o \ - buffer_put.o env.o error.o error_str.o fd_copy.o fd_move.o \ -@@ -819,7 +839,12 @@ - socket_udp.o stralloc_cat.o stralloc_catb.o stralloc_cats.o \ - stralloc_copy.o stralloc_eady.o stralloc_opyb.o \ - stralloc_opys.o stralloc_pend.o strerr_die.o strerr_sys.o \ -- subgetopt.o wait_nohang.o wait_pid.o -+ subgetopt.o wait_nohang.o wait_pid.o socket_conn6.o \ -+ socket_bind6.o socket_accept6.o socket_recv6.o socket_send6.o \ -+ socket_local6.o socket_remote6.o socket_tcp6.o \ -+ socket_getifname.o socket_getifidx.o socket_v4mappedprefix.o \ -+ socket_ip4loopback.o socket_v6any.o socket_v6loopback.o \ -+ socket_udp6.o - - wait_nohang.o: \ - compile wait_nohang.c haswaitp.h -@@ -835,3 +860,110 @@ - | sed s}HOME}"`head -1 conf-home`"}g \ - > who@ - chmod 755 who@ -+ -+socket_conn6.o: \ -+compile socket_conn6.c socket.h uint16.h haveip6.h error.h ip6.h \ -+uint32.h -+ ./compile socket_conn6.c -+ -+socket_bind6.o: \ -+compile socket_bind6.c socket.h uint16.h haveip6.h error.h ip6.h \ -+uint32.h -+ ./compile socket_bind6.c -+ -+socket_accept6.o: \ -+compile socket_accept6.c socket.h uint16.h haveip6.h error.h ip6.h \ -+uint32.h -+ ./compile socket_accept6.c -+ -+socket_recv6.o: \ -+compile socket_recv6.c socket.h uint16.h haveip6.h error.h ip6.h \ -+uint32.h -+ ./compile socket_recv6.c -+ -+socket_send6.o: \ -+compile socket_send6.c socket.h uint16.h haveip6.h error.h uint32.h -+ ./compile socket_send6.c -+ -+socket_local6.o: \ -+compile socket_local6.c socket.h uint16.h haveip6.h error.h uint32.h -+ ./compile socket_local6.c -+ -+socket_remote6.o: \ -+compile socket_remote6.c socket.h uint16.h haveip6.h error.h uint32.h -+ ./compile socket_remote6.c -+ -+dns_sortip6.o: \ -+compile dns_sortip6.c byte.h dns.h stralloc.h gen_alloc.h iopause.h \ -+taia.h tai.h uint64.h taia.h -+ ./compile dns_sortip6.c -+ -+dns_nd6.o: \ -+compile dns_nd6.c byte.h fmt.h dns.h stralloc.h gen_alloc.h iopause.h \ -+taia.h tai.h uint64.h taia.h -+ ./compile dns_nd6.c -+ -+dns_ipq6.o: \ -+compile dns_ipq6.c stralloc.h gen_alloc.h case.h byte.h str.h dns.h \ -+stralloc.h iopause.h taia.h tai.h uint64.h taia.h ip6.h -+ ./compile dns_ipq6.c -+ -+dns_ip6.o: \ -+compile dns_ip6.c stralloc.h gen_alloc.h uint16.h byte.h dns.h \ -+stralloc.h iopause.h taia.h tai.h uint64.h taia.h -+ ./compile dns_ip6.c -+ -+fmt_xlong.o: \ -+compile fmt_xlong.c scan.h -+ ./compile fmt_xlong.c -+ -+scan_xlong.o: \ -+compile scan_xlong.c scan.h -+ ./compile scan_xlong.c -+ -+ip6_fmt.o: \ -+compile ip6_fmt.c fmt.h ip6.h -+ ./compile ip6_fmt.c -+ -+scan_ip6.o: \ -+compile scan_ip6.c scan.h ip6.h -+ ./compile scan_ip6.c -+ -+socket_tcp6.o: \ -+compile socket_tcp6.c ndelay.h socket.h uint16.h uint32.h -+ ./compile socket_tcp6.c -+ -+socket_udp6.o: \ -+compile socket_udp6.c ndelay.h socket.h uint16.h uint32.h -+ ./compile socket_udp6.c -+ -+haveip6.h: \ -+tryip6.c choose compile haveip6.h1 haveip6.h2 -+ ./choose c tryip6 haveip6.h1 haveip6.h2 > haveip6.h -+ -+socket_getifname.o: \ -+compile socket_getifname.c socket.h uint16.h uint32.h -+ ./compile socket_getifname.c -+ -+socket_getifidx.o: \ -+compile socket_getifidx.c socket.h uint16.h uint32.h -+ ./compile socket_getifidx.c -+ -+socket_ip4loopback.o: \ -+compile socket_ip4loopback.c -+ ./compile socket_ip4loopback.c -+ -+socket_v4mappedprefix.o: \ -+compile socket_v4mappedprefix.c -+ ./compile socket_v4mappedprefix.c -+ -+socket_v6any.o: \ -+compile socket_v6any.c -+ ./compile socket_v6any.c -+ -+socket_v6loopback.o: \ -+compile socket_v6loopback.c -+ ./compile socket_v6loopback.c -+ -+clean: -+ rm -f `cat TARGETS` -diff -uNr ucspi-tcp-0.88-stock/TARGETS ucspi-tcp-0.88/TARGETS ---- ucspi-tcp-0.88-stock/TARGETS Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/TARGETS Fri Sep 9 12:07:53 2005 -@@ -169,3 +169,31 @@ - it - setup - check -+dns_ip6.o -+dns_ipq6.o -+dns_nd6.o -+dns_sortip6.o -+fmt_xlong.o -+ip6_fmt.o -+ip6_scan.o -+scan_0x.o -+socket_accept6.o -+socket_bind6.o -+socket_conn6.o -+socket_local6.o -+socket_recv6.o -+socket_remote6.o -+socket_send6.o -+socket_tcp6.o -+timeoutconn6.o -+haveip6.h -+remoteinfo6.o -+socket_getifidx.o -+socket_getifname.o -+scan_ip6.o -+scan_xlong.o -+socket_ip4loopback.o -+socket_udp6.o -+socket_v4mappedprefix.o -+socket_v6any.o -+socket_v6loopback.o -diff -uNr ucspi-tcp-0.88-stock/addcr.1 ucspi-tcp-0.88/addcr.1 ---- ucspi-tcp-0.88-stock/addcr.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/addcr.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,22 @@ -+.TH addcr 1 -+.SH NAME -+addcr \- add a CR before each LF -+.SH SYNOPSIS -+.B addcr -+.SH DESCRIPTION -+.B addcr -+inserts CR at the end of each line of input. -+It does not insert CR at the end of a partial final line. -+.SH COMPATIBILITY -+Some vendors ship -+.B unix2dos -+or -+.B bsd2dos -+tools similar to -+.BR addcr . -+Those tools often blow up on long lines and nulls. -+.B addcr -+has no trouble with long lines and nulls. -+.SH "SEE ALSO" -+delcr(1), -+fixcr(1) -diff -uNr ucspi-tcp-0.88-stock/argv0.1 ucspi-tcp-0.88/argv0.1 ---- ucspi-tcp-0.88-stock/argv0.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/argv0.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,47 @@ -+.TH argv0 1 -+.SH NAME -+argv0 \- run a program with a specified 0th argument -+.SH SYNOPSIS -+.B argv0 -+.I realname -+.I zero -+[ -+.I arg ... -+] -+.SH DESCRIPTION -+.B argv0 -+runs -+the program stored as -+.I realname -+on disk, -+with the given -+arguments. -+It sets the 0th argument of -+the program to -+.IR zero . -+ -+For example, -+ -+.EX -+ argv0 /bin/csh -bin/csh -+.EE -+ -+runs -+.B /bin/csh -+with a 0th argument of -+.BR -bin/csh . -+.B csh -+will think it is a login shell -+and behave accordingly. -+ -+.B argv0 -+can be used to run some -+.B inetd -+wrappers under -+.BR tcpserver . -+.SH "SEE ALSO" -+csh(1), -+tcpserver(1), -+execve(2), -+execvp(3), -+inetd(8) -diff -uNr ucspi-tcp-0.88-stock/date@.1 ucspi-tcp-0.88/date@.1 ---- ucspi-tcp-0.88-stock/date@.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/date@.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,32 @@ -+.TH date@ 1 -+.SH NAME -+date@ \- print the date on a host -+.SH SYNTAX -+.B date@ -+[ -+.I host -+] -+.SH DESCRIPTION -+.B date@ -+connects to TCP port 13 (Daytime) on -+.I host -+and prints any data it receives. -+It removes CR and converts unprintable characters to a visible format. -+ -+If -+.I host -+is not supplied, -+.B date@ -+connects to the local host. -+ -+Some computers respond to port 13 with a human-readable date. -+For example, they may be running -+ -+.EX -+ tcpserver 0 13 date & -+.EE -+.SH "SEE ALSO" -+cat(1), -+delcr(1), -+tcpclient(1), -+tcpserver(1) -diff -uNr ucspi-tcp-0.88-stock/delcr.1 ucspi-tcp-0.88/delcr.1 ---- ucspi-tcp-0.88-stock/delcr.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/delcr.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,30 @@ -+.TH delcr 1 -+.SH NAME -+delcr \- remove a CR before each LF -+.SH SYNOPSIS -+.B delcr -+.SH DESCRIPTION -+.B delcr -+removes a CR at the end of each line of input, -+if a CR is present. -+It also removes a CR at the end of a partial final line. -+ -+The pipeline -+ -+.EX -+ addcr | delcr -+.EE -+ -+prints an exact copy of its input. -+.SH COMPATIBILITY -+Some vendors ship -+.B dos2unix -+or -+.B dos2bsd -+tools similar to -+.BR delcr . -+Those tools often blow up on long lines and nulls. -+.B delcr -+has no trouble with long lines and nulls. -+.SH "SEE ALSO" -+addcr(1) -diff -uNr ucspi-tcp-0.88-stock/dns.h ucspi-tcp-0.88/dns.h ---- ucspi-tcp-0.88-stock/dns.h Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns.h Fri Sep 9 12:07:53 2005 -@@ -34,51 +34,60 @@ - unsigned int curserver; - struct taia deadline; - unsigned int pos; -- char *servers; -- char localip[4]; -+ const char *servers; -+ char localip[16]; -+ unsigned int scope_id; - char qtype[2]; - } ; - --extern void dns_random_init(char *); -+extern void dns_random_init(const char *); - extern unsigned int dns_random(unsigned int); - - extern void dns_sortip(char *,unsigned int); -+extern void dns_sortip6(char *,unsigned int); - - extern void dns_domain_free(char **); --extern int dns_domain_copy(char **,char *); --extern unsigned int dns_domain_length(char *); --extern int dns_domain_equal(char *,char *); --extern char *dns_domain_suffix(char *,char *); --extern int dns_domain_fromdot(char **,char *,unsigned int); --extern int dns_domain_todot_cat(stralloc *,char *); -- --extern unsigned int dns_packet_copy(char *,unsigned int,unsigned int,char *,unsigned int); --extern unsigned int dns_packet_getname(char *,unsigned int,unsigned int,char **); --extern unsigned int dns_packet_skipname(char *,unsigned int,unsigned int); --extern int dns_packet_nameequal(char *,unsigned int,unsigned int,char *,unsigned int,unsigned int); -+extern int dns_domain_copy(char **,const char *); -+extern unsigned int dns_domain_length(const char *); -+extern int dns_domain_equal(const char *,const char *); -+extern int dns_domain_suffix(const char *,const char *); -+extern unsigned int dns_domain_suffixpos(const char *,const char *); -+extern int dns_domain_fromdot(char **,const char *,unsigned int); -+extern int dns_domain_todot_cat(stralloc *,const char *); -+ -+extern unsigned int dns_packet_copy(const char *,unsigned int,unsigned int,char *,unsigned int); -+extern unsigned int dns_packet_getname(const char *,unsigned int,unsigned int,char **); -+extern unsigned int dns_packet_skipname(const char *,unsigned int,unsigned int); - --extern int dns_transmit_start(struct dns_transmit *,char *,int,char *,char *,char *); -+extern int dns_transmit_start(struct dns_transmit *,const char *,int,const char *,const char *,const char *); - extern void dns_transmit_free(struct dns_transmit *); - extern void dns_transmit_io(struct dns_transmit *,iopause_fd *,struct taia *); --extern int dns_transmit_get(struct dns_transmit *,iopause_fd *,struct taia *); -+extern int dns_transmit_get(struct dns_transmit *,const iopause_fd *,const struct taia *); - - extern int dns_resolvconfip(char *); --extern int dns_resolve(char *,char *); -+extern int dns_resolve(const char *,const char *); - extern struct dns_transmit dns_resolve_tx; - --extern int dns_ip4_packet(stralloc *,char *,unsigned int); --extern int dns_ip4(stralloc *,stralloc *); --extern int dns_name_packet(stralloc *,char *,unsigned int); --extern void dns_name4_domain(char *,char *); -+extern int dns_ip4_packet(stralloc *,const char *,unsigned int); -+extern int dns_ip4(stralloc *,const stralloc *); -+extern int dns_ip6_packet(stralloc *,const char *,unsigned int); -+extern int dns_ip6(stralloc *,stralloc *); -+extern int dns_name_packet(stralloc *,const char *,unsigned int); -+extern void dns_name4_domain(char *,const char *); - #define DNS_NAME4_DOMAIN 31 --extern int dns_name4(stralloc *,char *); --extern int dns_txt_packet(stralloc *,char *,unsigned int); --extern int dns_txt(stralloc *,stralloc *); --extern int dns_mx_packet(stralloc *,char *,unsigned int); --extern int dns_mx(stralloc *,stralloc *); -+extern int dns_name4(stralloc *,const char *); -+extern int dns_txt_packet(stralloc *,const char *,unsigned int); -+extern int dns_txt(stralloc *,const stralloc *); -+extern int dns_mx_packet(stralloc *,const char *,unsigned int); -+extern int dns_mx(stralloc *,const stralloc *); - - extern int dns_resolvconfrewrite(stralloc *); --extern int dns_ip4_qualify_rules(stralloc *,stralloc *,stralloc *,stralloc *); --extern int dns_ip4_qualify(stralloc *,stralloc *,stralloc *); -+extern int dns_ip4_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *); -+extern int dns_ip4_qualify(stralloc *,stralloc *,const stralloc *); -+extern int dns_ip6_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *); -+extern int dns_ip6_qualify(stralloc *,stralloc *,const stralloc *); -+ -+extern int dns_name6_domain(char *,char *); -+#define DNS_NAME6_DOMAIN (4*16+11) - - #endif -diff -uNr ucspi-tcp-0.88-stock/dns_dfd.c ucspi-tcp-0.88/dns_dfd.c ---- ucspi-tcp-0.88-stock/dns_dfd.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_dfd.c Fri Sep 9 12:07:53 2005 -@@ -1,9 +1,10 @@ --#include "error.h" --#include "alloc.h" -+#include <stdlib.h> -+#include <errno.h> - #include "byte.h" - #include "dns.h" -+#include "error.h" - --int dns_domain_fromdot(char **out,char *buf,unsigned int n) -+int dns_domain_fromdot(char **out,const char *buf,unsigned int n) - { - char label[63]; - unsigned int labellen = 0; /* <= sizeof label */ -@@ -59,11 +60,11 @@ - if (namelen + 1 > sizeof name) return 0; - name[namelen++] = 0; - -- x = alloc(namelen); -+ x = malloc(namelen); - if (!x) return 0; - byte_copy(x,namelen,name); - -- if (*out) alloc_free(*out); -+ if (*out) free(*out); - *out = x; - return 1; - } -diff -uNr ucspi-tcp-0.88-stock/dns_domain.c ucspi-tcp-0.88/dns_domain.c ---- ucspi-tcp-0.88-stock/dns_domain.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_domain.c Fri Sep 9 12:07:53 2005 -@@ -1,16 +1,15 @@ --#include "error.h" --#include "alloc.h" -+#include <stdlib.h> - #include "case.h" - #include "byte.h" - #include "dns.h" - --unsigned int dns_domain_length(char *dn) -+unsigned int dns_domain_length(const char *dn) - { -- char *x; -+ const char *x; - unsigned char c; - - x = dn; -- while (c = *x++) -+ while ((c = *x++)) - x += (unsigned int) c; - return x - dn; - } -@@ -18,26 +17,26 @@ - void dns_domain_free(char **out) - { - if (*out) { -- alloc_free(*out); -+ free(*out); - *out = 0; - } - } - --int dns_domain_copy(char **out,char *in) -+int dns_domain_copy(char **out,const char *in) - { - unsigned int len; - char *x; - - len = dns_domain_length(in); -- x = alloc(len); -+ x = malloc(len); - if (!x) return 0; - byte_copy(x,len,in); -- if (*out) alloc_free(*out); -+ if (*out) free(*out); - *out = x; - return 1; - } - --int dns_domain_equal(char *dn1,char *dn2) -+int dns_domain_equal(const char *dn1,const char *dn2) - { - unsigned int len; - -@@ -48,12 +47,25 @@ - return 1; - } - --char *dns_domain_suffix(char *big,char *little) -+int dns_domain_suffix(const char *big,const char *little) -+{ -+ unsigned char c; -+ -+ for (;;) { -+ if (dns_domain_equal(big,little)) return 1; -+ c = *big++; -+ if (!c) return 0; -+ big += c; -+ } -+} -+ -+unsigned int dns_domain_suffixpos(const char *big,const char *little) - { -+ const char *orig = big; - unsigned char c; - - for (;;) { -- if (dns_domain_equal(big,little)) return big; -+ if (dns_domain_equal(big,little)) return big - orig; - c = *big++; - if (!c) return 0; - big += c; -diff -uNr ucspi-tcp-0.88-stock/dns_dtda.c ucspi-tcp-0.88/dns_dtda.c ---- ucspi-tcp-0.88-stock/dns_dtda.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_dtda.c Fri Sep 9 12:07:53 2005 -@@ -1,7 +1,7 @@ - #include "stralloc.h" - #include "dns.h" - --int dns_domain_todot_cat(stralloc *out,char *d) -+int dns_domain_todot_cat(stralloc *out,const char *d) - { - char ch; - char ch2; -diff -uNr ucspi-tcp-0.88-stock/dns_ip.c ucspi-tcp-0.88/dns_ip.c ---- ucspi-tcp-0.88-stock/dns_ip.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_ip.c Fri Sep 9 12:07:53 2005 -@@ -3,7 +3,7 @@ - #include "byte.h" - #include "dns.h" - --int dns_ip4_packet(stralloc *out,char *buf,unsigned int len) -+int dns_ip4_packet(stralloc *out,const char *buf,unsigned int len) - { - unsigned int pos; - char header[12]; -@@ -36,7 +36,7 @@ - - static char *q = 0; - --int dns_ip4(stralloc *out,stralloc *fqdn) -+int dns_ip4(stralloc *out,const stralloc *fqdn) - { - unsigned int i; - char code; -diff -uNr ucspi-tcp-0.88-stock/dns_ip6.c ucspi-tcp-0.88/dns_ip6.c ---- ucspi-tcp-0.88-stock/dns_ip6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/dns_ip6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,103 @@ -+#include "stralloc.h" -+#include "uint16.h" -+#include "byte.h" -+#include "dns.h" -+#include "ip4.h" -+#include "ip6.h" -+ -+static int dns_ip6_packet_add(stralloc *out,const char *buf,unsigned int len) -+{ -+ unsigned int pos; -+ char header[16]; -+ uint16 numanswers; -+ uint16 datalen; -+ -+ pos = dns_packet_copy(buf,len,0,header,12); if (!pos) return -1; -+ uint16_unpack_big(header + 6,&numanswers); -+ pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; -+ pos += 4; -+ -+ while (numanswers--) { -+ pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; -+ pos = dns_packet_copy(buf,len,pos,header,10); if (!pos) return -1; -+ uint16_unpack_big(header + 8,&datalen); -+ if (byte_equal(header,2,DNS_T_AAAA)) { -+ if (byte_equal(header + 2,2,DNS_C_IN)) -+ if (datalen == 16) { -+ if (!dns_packet_copy(buf,len,pos,header,16)) return -1; -+ if (!stralloc_catb(out,header,16)) return -1; -+ } -+ } else if (byte_equal(header,2,DNS_T_A)) -+ if (byte_equal(header + 2,2,DNS_C_IN)) -+ if (datalen == 4) { -+ byte_copy(header,12,V4mappedprefix); -+ if (!dns_packet_copy(buf,len,pos,header+12,4)) return -1; -+ if (!stralloc_catb(out,header,16)) return -1; -+ } -+ pos += datalen; -+ } -+ -+ dns_sortip6(out->s,out->len); -+ return 0; -+} -+ -+int dns_ip6_packet(stralloc *out,const char *buf,unsigned int len) { -+ if (!stralloc_copys(out,"")) return -1; -+ return dns_ip6_packet_add(out,buf,len); -+} -+ -+static char *q = 0; -+ -+int dns_ip6(stralloc *out,stralloc *fqdn) -+{ -+ unsigned int i; -+ char code; -+ char ch; -+ char ip[16]; -+ -+ if (!stralloc_copys(out,"")) return -1; -+ if (!stralloc_readyplus(fqdn,1)) return -1; -+ fqdn->s[fqdn->len]=0; -+ if ((i=scan_ip6(fqdn->s,ip))) { -+ if (fqdn->s[i]) return -1; -+ stralloc_copyb(out,ip,16); -+ return 0; -+ } -+ code = 0; -+ for (i = 0;i <= fqdn->len;++i) { -+ if (i < fqdn->len) -+ ch = fqdn->s[i]; -+ else -+ ch = '.'; -+ -+ if ((ch == '[') || (ch == ']')) continue; -+ if (ch == '.') { -+ if (!stralloc_append(out,&code)) return -1; -+ code = 0; -+ continue; -+ } -+ if ((ch >= '0') && (ch <= '9')) { -+ code *= 10; -+ code += ch - '0'; -+ continue; -+ } -+ -+ if (!dns_domain_fromdot(&q,fqdn->s,fqdn->len)) return -1; -+ if (!stralloc_copys(out,"")) return -1; -+ if (dns_resolve(q,DNS_T_AAAA) != -1) -+ if (dns_ip6_packet_add(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) != -1) { -+ dns_transmit_free(&dns_resolve_tx); -+ dns_domain_free(&q); -+ } -+ if (!dns_domain_fromdot(&q,fqdn->s,fqdn->len)) return -1; -+ if (dns_resolve(q,DNS_T_A) != -1) -+ if (dns_ip6_packet_add(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) != -1) { -+ dns_transmit_free(&dns_resolve_tx); -+ dns_domain_free(&q); -+ } -+ return out->a>0?0:-1; -+ } -+ -+ out->len &= ~3; -+ return 0; -+} -diff -uNr ucspi-tcp-0.88-stock/dns_ipq.c ucspi-tcp-0.88/dns_ipq.c ---- ucspi-tcp-0.88-stock/dns_ipq.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_ipq.c Fri Sep 9 12:07:53 2005 -@@ -4,7 +4,7 @@ - #include "str.h" - #include "dns.h" - --static int doit(stralloc *work,char *rule) -+static int doit(stralloc *work,const char *rule) - { - char ch; - unsigned int colon; -@@ -30,7 +30,7 @@ - return stralloc_cats(work,rule + colon + 1); - } - --int dns_ip4_qualify_rules(stralloc *out,stralloc *fqdn,stralloc *in,stralloc *rules) -+int dns_ip4_qualify_rules(stralloc *out,stralloc *fqdn,const stralloc *in,const stralloc *rules) - { - unsigned int i; - unsigned int j; -@@ -63,7 +63,7 @@ - } - } - --int dns_ip4_qualify(stralloc *out,stralloc *fqdn,stralloc *in) -+int dns_ip4_qualify(stralloc *out,stralloc *fqdn,const stralloc *in) - { - static stralloc rules; - if (dns_resolvconfrewrite(&rules) == -1) return -1; -diff -uNr ucspi-tcp-0.88-stock/dns_ipq6.c ucspi-tcp-0.88/dns_ipq6.c ---- ucspi-tcp-0.88-stock/dns_ipq6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/dns_ipq6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,72 @@ -+#include "stralloc.h" -+#include "case.h" -+#include "byte.h" -+#include "str.h" -+#include "dns.h" -+ -+static int doit(stralloc *work,const char *rule) -+{ -+ char ch; -+ unsigned int colon; -+ unsigned int prefixlen; -+ -+ ch = *rule++; -+ if ((ch != '?') && (ch != '=') && (ch != '*') && (ch != '-')) return 1; -+ colon = str_chr(rule,':'); -+ if (!rule[colon]) return 1; -+ -+ if (work->len < colon) return 1; -+ prefixlen = work->len - colon; -+ if ((ch == '=') && prefixlen) return 1; -+ if (case_diffb(rule,colon,work->s + prefixlen)) return 1; -+ if (ch == '?') { -+ if (byte_chr(work->s,prefixlen,'.') < prefixlen) return 1; -+ if (byte_chr(work->s,prefixlen,':') < prefixlen) return 1; -+ if (byte_chr(work->s,prefixlen,'[') < prefixlen) return 1; -+ if (byte_chr(work->s,prefixlen,']') < prefixlen) return 1; -+ } -+ -+ work->len = prefixlen; -+ if (ch == '-') work->len = 0; -+ return stralloc_cats(work,rule + colon + 1); -+} -+ -+int dns_ip6_qualify_rules(stralloc *out,stralloc *fqdn,const stralloc *in,const stralloc *rules) -+{ -+ unsigned int i; -+ unsigned int j; -+ unsigned int plus; -+ unsigned int fqdnlen; -+ -+ if (!stralloc_copy(fqdn,in)) return -1; -+ -+ for (j = i = 0;j < rules->len;++j) -+ if (!rules->s[j]) { -+ if (!doit(fqdn,rules->s + i)) return -1; -+ i = j + 1; -+ } -+ -+ fqdnlen = fqdn->len; -+ plus = byte_chr(fqdn->s,fqdnlen,'+'); -+ if (plus >= fqdnlen) -+ return dns_ip6(out,fqdn); -+ -+ i = plus + 1; -+ for (;;) { -+ j = byte_chr(fqdn->s + i,fqdnlen - i,'+'); -+ byte_copy(fqdn->s + plus,j,fqdn->s + i); -+ fqdn->len = plus + j; -+ if (dns_ip6(out,fqdn) == -1) return -1; -+ if (out->len) return 0; -+ i += j; -+ if (i >= fqdnlen) return 0; -+ ++i; -+ } -+} -+ -+int dns_ip6_qualify(stralloc *out,stralloc *fqdn,const stralloc *in) -+{ -+ static stralloc rules; -+ if (dns_resolvconfrewrite(&rules) == -1) return -1; -+ return dns_ip6_qualify_rules(out,fqdn,in,&rules); -+} -diff -uNr ucspi-tcp-0.88-stock/dns_name.c ucspi-tcp-0.88/dns_name.c ---- ucspi-tcp-0.88-stock/dns_name.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_name.c Fri Sep 9 12:07:53 2005 -@@ -2,10 +2,11 @@ - #include "uint16.h" - #include "byte.h" - #include "dns.h" -+#include "ip6.h" - - static char *q = 0; - --int dns_name_packet(stralloc *out,char *buf,unsigned int len) -+int dns_name_packet(stralloc *out,const char *buf,unsigned int len) - { - unsigned int pos; - char header[12]; -@@ -35,7 +36,7 @@ - return 0; - } - --int dns_name4(stralloc *out,char ip[4]) -+int dns_name4(stralloc *out,const char ip[4]) - { - char name[DNS_NAME4_DOMAIN]; - -@@ -43,6 +44,20 @@ - if (dns_resolve(name,DNS_T_PTR) == -1) return -1; - if (dns_name_packet(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) == -1) return -1; - dns_transmit_free(&dns_resolve_tx); -+ dns_domain_free(&q); -+ return 0; -+} -+ -+int dns_name6(stralloc *out,char ip[16]) -+{ -+ char name[DNS_NAME6_DOMAIN]; -+ -+ if (ip6_isv4mapped(ip)) -+ return dns_name4(out,ip+12); -+ dns_name6_domain(name,ip); -+ if (dns_resolve(name,DNS_T_PTR) == -1) return -1; -+ if (dns_name_packet(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) == -1) return -1; -+ dns_transmit_free(&dns_resolve_tx); - dns_domain_free(&q); - return 0; - } -diff -uNr ucspi-tcp-0.88-stock/dns_nd.c ucspi-tcp-0.88/dns_nd.c ---- ucspi-tcp-0.88-stock/dns_nd.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_nd.c Fri Sep 9 12:07:53 2005 -@@ -2,7 +2,7 @@ - #include "fmt.h" - #include "dns.h" - --void dns_name4_domain(char name[DNS_NAME4_DOMAIN],char ip[4]) -+void dns_name4_domain(char name[DNS_NAME4_DOMAIN],const char ip[4]) - { - unsigned int namelen; - unsigned int i; -diff -uNr ucspi-tcp-0.88-stock/dns_nd6.c ucspi-tcp-0.88/dns_nd6.c ---- ucspi-tcp-0.88-stock/dns_nd6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/dns_nd6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,28 @@ -+#include "byte.h" -+#include "fmt.h" -+#include "dns.h" -+ -+/* RFC1886: -+ * 4321:0:1:2:3:4:567:89ab -+ * -> -+ * b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.IP6.INT. -+ */ -+ -+static inline char tohex(char c) { -+ return c>=10?c-10+'a':c+'0'; -+} -+ -+int dns_name6_domain(char name[DNS_NAME6_DOMAIN],char ip[16]) -+{ -+ unsigned int j; -+ -+ for (j=0; j<16; j++) { -+ name[j*4]=1; -+ name[j*4+1]=tohex(ip[15-j] & 15); -+ name[j*4+2]=1; -+ name[j*4+3]=tohex((unsigned char)ip[15-j] >> 4); -+ } -+ byte_copy(name + 4*16,10,"\3ip6\4arpa\0"); -+ return 4*16+10; -+} -+ -diff -uNr ucspi-tcp-0.88-stock/dns_packet.c ucspi-tcp-0.88/dns_packet.c ---- ucspi-tcp-0.88-stock/dns_packet.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_packet.c Fri Sep 9 12:07:53 2005 -@@ -2,10 +2,11 @@ - DNS should have used LZ77 instead of its own sophomoric compression algorithm. - */ - --#include "error.h" -+#include <errno.h> - #include "dns.h" -+#include "error.h" - --unsigned int dns_packet_copy(char *buf,unsigned int len,unsigned int pos,char *out,unsigned int outlen) -+unsigned int dns_packet_copy(const char *buf,unsigned int len,unsigned int pos,char *out,unsigned int outlen) - { - while (outlen) { - if (pos >= len) { errno = error_proto; return 0; } -@@ -15,7 +16,7 @@ - return pos; - } - --unsigned int dns_packet_skipname(char *buf,unsigned int len,unsigned int pos) -+unsigned int dns_packet_skipname(const char *buf,unsigned int len,unsigned int pos) - { - unsigned char ch; - -@@ -32,7 +33,7 @@ - return 0; - } - --unsigned int dns_packet_getname(char *buf,unsigned int len,unsigned int pos,char **d) -+unsigned int dns_packet_getname(const char *buf,unsigned int len,unsigned int pos,char **d) - { - unsigned int loop = 0; - unsigned int state = 0; -diff -uNr ucspi-tcp-0.88-stock/dns_random.c ucspi-tcp-0.88/dns_random.c ---- ucspi-tcp-0.88-stock/dns_random.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_random.c Fri Sep 9 12:07:53 2005 -@@ -1,3 +1,4 @@ -+#include <unistd.h> - #include "dns.h" - #include "taia.h" - #include "uint32.h" -@@ -29,7 +30,7 @@ - } - } - --void dns_random_init(char data[128]) -+void dns_random_init(const char data[128]) - { - int i; - struct taia t; -diff -uNr ucspi-tcp-0.88-stock/dns_rcip.c ucspi-tcp-0.88/dns_rcip.c ---- ucspi-tcp-0.88-stock/dns_rcip.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_rcip.c Fri Sep 9 12:07:53 2005 -@@ -2,12 +2,13 @@ - #include "openreadclose.h" - #include "byte.h" - #include "ip4.h" --#include "env.h" -+#include "ip6.h" - #include "dns.h" -+#include "env.h" - - static stralloc data = {0}; - --static int init(char ip[64]) -+static int init(char ip[256]) - { - int i; - int j; -@@ -16,15 +17,16 @@ - - x = env_get("DNSCACHEIP"); - if (x) -- while (iplen <= 60) -+ while (iplen <= 60) { - if (*x == '.') - ++x; - else { -- i = ip4_scan(x,ip + iplen); -+ i = scan_ip6(x,ip + iplen); - if (!i) break; - x += i; -- iplen += 4; -+ iplen += 16; - } -+ } - - if (!iplen) { - i = openreadclose("/etc/resolv.conf",&data,64); -@@ -39,8 +41,9 @@ - while ((data.s[i] == ' ') || (data.s[i] == '\t')) - ++i; - if (iplen <= 60) -- if (ip4_scan(data.s + i,ip + iplen)) -- iplen += 4; -+ if (scan_ip6(data.s + i,ip + iplen)) { -+ iplen += 16; -+ } - } - i = j + 1; - } -@@ -48,19 +51,19 @@ - } - - if (!iplen) { -- byte_copy(ip,4,"\177\0\0\1"); -- iplen = 4; -+ byte_copy(ip,16,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1"); -+ iplen = 16; - } -- byte_zero(ip + iplen,64 - iplen); -+ byte_zero(ip + iplen,256 - iplen); - return 0; - } - - static int ok = 0; - static unsigned int uses; - static struct taia deadline; --static char ip[64]; /* defined if ok */ -+static char ip[256]; /* defined if ok */ - --int dns_resolvconfip(char s[64]) -+int dns_resolvconfip(char s[256]) - { - struct taia now; - -@@ -77,6 +80,6 @@ - } - - --uses; -- byte_copy(s,64,ip); -+ byte_copy(s,256,ip); - return 0; - } -diff -uNr ucspi-tcp-0.88-stock/dns_rcrw.c ucspi-tcp-0.88/dns_rcrw.c ---- ucspi-tcp-0.88-stock/dns_rcrw.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_rcrw.c Fri Sep 9 12:07:53 2005 -@@ -1,16 +1,17 @@ -+#include <unistd.h> - #include "taia.h" --#include "env.h" - #include "byte.h" - #include "str.h" - #include "openreadclose.h" - #include "dns.h" -+#include "env.h" - - static stralloc data = {0}; - - static int init(stralloc *rules) - { - char host[256]; -- char *x; -+ const char *x; - int i; - int j; - int k; -diff -uNr ucspi-tcp-0.88-stock/dns_resolve.c ucspi-tcp-0.88/dns_resolve.c ---- ucspi-tcp-0.88-stock/dns_resolve.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_resolve.c Fri Sep 9 12:07:53 2005 -@@ -2,19 +2,20 @@ - #include "taia.h" - #include "byte.h" - #include "dns.h" -+#include "ip6.h" - - struct dns_transmit dns_resolve_tx = {0}; - --int dns_resolve(char *q,char qtype[2]) -+int dns_resolve(const char *q,const char qtype[2]) - { - struct taia stamp; - struct taia deadline; -- char servers[64]; -+ char servers[256]; - iopause_fd x[1]; - int r; - - if (dns_resolvconfip(servers) == -1) return -1; -- if (dns_transmit_start(&dns_resolve_tx,servers,1,q,qtype,"\0\0\0\0") == -1) return -1; -+ if (dns_transmit_start(&dns_resolve_tx,servers,1,q,qtype,V6any) == -1) return -1; - - for (;;) { - taia_now(&stamp); -diff -uNr ucspi-tcp-0.88-stock/dns_sortip6.c ucspi-tcp-0.88/dns_sortip6.c ---- ucspi-tcp-0.88-stock/dns_sortip6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/dns_sortip6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,20 @@ -+#include "byte.h" -+#include "dns.h" -+ -+/* XXX: sort servers by configurable notion of closeness? */ -+/* XXX: pay attention to competence of each server? */ -+ -+void dns_sortip6(char *s,unsigned int n) -+{ -+ unsigned int i; -+ char tmp[16]; -+ -+ n >>= 4; -+ while (n > 1) { -+ i = dns_random(n); -+ --n; -+ byte_copy(tmp,16,s + (i << 4)); -+ byte_copy(s + (i << 4),16,s + (n << 4)); -+ byte_copy(s + (n << 4),16,tmp); -+ } -+} -diff -uNr ucspi-tcp-0.88-stock/dns_transmit.c ucspi-tcp-0.88/dns_transmit.c ---- ucspi-tcp-0.88-stock/dns_transmit.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_transmit.c Fri Sep 9 12:07:53 2005 -@@ -1,12 +1,15 @@ -+#include <sys/types.h> -+#include <sys/socket.h> -+#include <unistd.h> -+#include <stdlib.h> - #include "socket.h" --#include "alloc.h" --#include "error.h" -+#include <errno.h> - #include "byte.h" --#include "readwrite.h" - #include "uint16.h" - #include "dns.h" -+#include "ip6.h" - --static int serverwantstcp(char *buf,unsigned int len) -+static int serverwantstcp(const char *buf,unsigned int len) - { - char out[12]; - -@@ -15,7 +18,7 @@ - return 0; - } - --static int serverfailed(char *buf,unsigned int len) -+static int serverfailed(const char *buf,unsigned int len) - { - char out[12]; - unsigned int rcode; -@@ -23,11 +26,11 @@ - if (!dns_packet_copy(buf,len,0,out,12)) return 1; - rcode = out[3]; - rcode &= 15; -- if (rcode && (rcode != 3)) { errno = error_again; return 1; } -+ if (rcode && (rcode != 3)) { errno = EAGAIN; return 1; } - return 0; - } - --static int irrelevant(struct dns_transmit *d,char *buf,unsigned int len) -+static int irrelevant(const struct dns_transmit *d,const char *buf,unsigned int len) - { - char out[12]; - char *dn; -@@ -40,8 +43,8 @@ - - dn = 0; - pos = dns_packet_getname(buf,len,pos,&dn); if (!pos) return 1; -- if (!dns_domain_equal(dn,d->query + 14)) { alloc_free(dn); return 1; } -- alloc_free(dn); -+ if (!dns_domain_equal(dn,d->query + 14)) { free(dn); return 1; } -+ free(dn); - - pos = dns_packet_copy(buf,len,pos,out,4); if (!pos) return 1; - if (byte_diff(out,2,d->qtype)) return 1; -@@ -53,14 +56,14 @@ - static void packetfree(struct dns_transmit *d) - { - if (!d->packet) return; -- alloc_free(d->packet); -+ free(d->packet); - d->packet = 0; - } - - static void queryfree(struct dns_transmit *d) - { - if (!d->query) return; -- alloc_free(d->query); -+ free(d->query); - d->query = 0; - } - -@@ -83,9 +86,9 @@ - int j; - - for (j = 0;j < 10;++j) -- if (socket_bind4(d->s1 - 1,d->localip,1025 + dns_random(64510)) == 0) -+ if (socket_bind6(d->s1 - 1,d->localip,1025 + dns_random(64510),d->scope_id) == 0) - return 0; -- if (socket_bind4(d->s1 - 1,d->localip,0) == 0) -+ if (socket_bind6(d->s1 - 1,d->localip,0,d->scope_id) == 0) - return 0; - return -1; - } -@@ -94,22 +97,22 @@ - - static int thisudp(struct dns_transmit *d) - { -- char *ip; -+ const char *ip; - - socketfree(d); - - while (d->udploop < 4) { - for (;d->curserver < 16;++d->curserver) { -- ip = d->servers + 4 * d->curserver; -- if (byte_diff(ip,4,"\0\0\0\0")) { -+ ip = d->servers + 16 * d->curserver; -+ if (byte_diff(ip,16,V6any)) { - d->query[2] = dns_random(256); - d->query[3] = dns_random(256); - -- d->s1 = 1 + socket_udp(); -+ d->s1 = 1 + socket_udp6(); - if (!d->s1) { dns_transmit_free(d); return -1; } - if (randombind(d) == -1) { dns_transmit_free(d); return -1; } - -- if (socket_connect4(d->s1 - 1,ip,53) == 0) -+ if (socket_connect6(d->s1 - 1,ip,53,d->scope_id) == 0) - if (send(d->s1 - 1,d->query + 2,d->querylen - 2,0) == d->querylen - 2) { - struct taia now; - taia_now(&now); -@@ -145,29 +148,29 @@ - static int thistcp(struct dns_transmit *d) - { - struct taia now; -- char *ip; -+ const char *ip; - - socketfree(d); - packetfree(d); - - for (;d->curserver < 16;++d->curserver) { -- ip = d->servers + 4 * d->curserver; -- if (byte_diff(ip,4,"\0\0\0\0")) { -+ ip = d->servers + 16 * d->curserver; -+ if (byte_diff(ip,16,V6any)) { - d->query[2] = dns_random(256); - d->query[3] = dns_random(256); - -- d->s1 = 1 + socket_tcp(); -+ d->s1 = 1 + socket_tcp6(); - if (!d->s1) { dns_transmit_free(d); return -1; } - if (randombind(d) == -1) { dns_transmit_free(d); return -1; } - - taia_now(&now); - taia_uint(&d->deadline,10); - taia_add(&d->deadline,&d->deadline,&now); -- if (socket_connect4(d->s1 - 1,ip,53) == 0) { -+ if (socket_connect6(d->s1 - 1,ip,53,d->scope_id) == 0) { - d->tcpstate = 2; - return 0; - } -- if ((errno == error_inprogress) || (errno == error_wouldblock)) { -+ if ((errno == EINPROGRESS) || (errno == EWOULDBLOCK)) { - d->tcpstate = 1; - return 0; - } -@@ -191,16 +194,16 @@ - return thistcp(d); - } - --int dns_transmit_start(struct dns_transmit *d,char servers[64],int flagrecursive,char *q,char qtype[2],char localip[4]) -+int dns_transmit_start(struct dns_transmit *d,const char servers[256],int flagrecursive,const char *q,const char qtype[2],const char localip[16]) - { - unsigned int len; - - dns_transmit_free(d); -- errno = error_io; -+ errno = EIO; - - len = dns_domain_length(q); - d->querylen = len + 18; -- d->query = alloc(d->querylen); -+ d->query = malloc(d->querylen); - if (!d->query) return -1; - - uint16_pack_big(d->query,len + 16); -@@ -211,7 +214,7 @@ - - byte_copy(d->qtype,2,qtype); - d->servers = servers; -- byte_copy(d->localip,4,localip); -+ byte_copy(d->localip,16,localip); - - d->udploop = flagrecursive ? 1 : 0; - -@@ -236,19 +239,19 @@ - *deadline = d->deadline; - } - --int dns_transmit_get(struct dns_transmit *d,iopause_fd *x,struct taia *when) -+int dns_transmit_get(struct dns_transmit *d,const iopause_fd *x,const struct taia *when) - { - char udpbuf[513]; - unsigned char ch; - int r; - int fd; - -- errno = error_io; -+ errno = EIO; - fd = d->s1 - 1; - - if (!x->revents) { - if (taia_less(when,&d->deadline)) return 0; -- errno = error_timeout; -+ errno = ETIMEDOUT; - if (d->tcpstate == 0) return nextudp(d); - return nexttcp(d); - } -@@ -260,7 +263,7 @@ - */ - r = recv(fd,udpbuf,sizeof udpbuf,0); - if (r <= 0) { -- if (d->udploop == 2) return 0; -+ if (errno == ECONNREFUSED) if (d->udploop == 2) return 0; - return nextudp(d); - } - if (r + 1 > sizeof udpbuf) return 0; -@@ -274,7 +277,7 @@ - socketfree(d); - - d->packetlen = r; -- d->packet = alloc(d->packetlen); -+ d->packet = malloc(d->packetlen); - if (!d->packet) { dns_transmit_free(d); return -1; } - byte_copy(d->packet,d->packetlen,udpbuf); - queryfree(d); -@@ -334,7 +337,7 @@ - d->packetlen += ch; - d->tcpstate = 5; - d->pos = 0; -- d->packet = alloc(d->packetlen); -+ d->packet = malloc(d->packetlen); - if (!d->packet) { dns_transmit_free(d); return -1; } - return 0; - } -diff -uNr ucspi-tcp-0.88-stock/dns_txt.c ucspi-tcp-0.88/dns_txt.c ---- ucspi-tcp-0.88-stock/dns_txt.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/dns_txt.c Fri Sep 9 12:07:53 2005 -@@ -3,7 +3,7 @@ - #include "byte.h" - #include "dns.h" - --int dns_txt_packet(stralloc *out,char *buf,unsigned int len) -+int dns_txt_packet(stralloc *out,const char *buf,unsigned int len) - { - unsigned int pos; - char header[12]; -@@ -48,7 +48,7 @@ - - static char *q = 0; - --int dns_txt(stralloc *out,stralloc *fqdn) -+int dns_txt(stralloc *out,const stralloc *fqdn) - { - if (!dns_domain_fromdot(&q,fqdn->s,fqdn->len)) return -1; - if (dns_resolve(q,DNS_T_TXT) == -1) return -1; -diff -uNr ucspi-tcp-0.88-stock/error.h ucspi-tcp-0.88/error.h ---- ucspi-tcp-0.88-stock/error.h Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/error.h Fri Sep 9 12:09:13 2005 -@@ -1,7 +1,7 @@ - #ifndef ERROR_H - #define ERROR_H - --extern int errno; -+#include <errno.h> - - extern int error_intr; - extern int error_nomem; -diff -uNr ucspi-tcp-0.88-stock/finger@.1 ucspi-tcp-0.88/finger@.1 ---- ucspi-tcp-0.88-stock/finger@.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/finger@.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,45 @@ -+.TH finger@ 1 -+.SH NAME -+finger@ \- get user information from a host -+.SH SYNTAX -+.B finger@ -+[ -+.I host -+[ -+.I user -+] -+] -+.SH DESCRIPTION -+.B finger@ -+connects to TCP port 79 (Finger) on -+.IR host , -+sends -+.I user -+(with an extra CR) -+to -+.IR host , -+and prints any data it receives. -+It removes CR and converts unprintable characters to a visible format. -+Some computers respond to port 79 with information about -+.IR user . -+ -+If -+.I user -+is not supplied, -+.B finger@ -+sends a blank line to -+.IR host . -+Some computers respond with information about -+all the users who are logged in. -+ -+If -+.I host -+is not supplied, -+.B finger@ -+connects to the local host. -+.SH "SEE ALSO" -+addcr(1), -+cat(1), -+delcr(1), -+finger(1), -+tcpclient(1) -diff -uNr ucspi-tcp-0.88-stock/fixcr.1 ucspi-tcp-0.88/fixcr.1 ---- ucspi-tcp-0.88-stock/fixcr.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/fixcr.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,11 @@ -+.TH fixcr 1 -+.SH NAME -+fixcr \- make sure that there is a CR before each LF -+.SH SYNOPSIS -+.B fixcr -+.SH DESCRIPTION -+.B fixcr -+inserts CR at the end of each line of input where a CR is not already present. -+It does not insert CR at the end of a partial final line. -+.SH "SEE ALSO" -+addcr(1) -diff -uNr ucspi-tcp-0.88-stock/fmt_xlong.c ucspi-tcp-0.88/fmt_xlong.c ---- ucspi-tcp-0.88-stock/fmt_xlong.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/fmt_xlong.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,22 @@ -+#include "fmt.h" -+ -+char tohex(char num) { -+ if (num<10) -+ return num+'0'; -+ else if (num<16) -+ return num-10+'a'; -+ else -+ return -1; -+} -+ -+unsigned int fmt_xlong(register char *s,register unsigned long u) -+{ -+ register unsigned int len; register unsigned long q; -+ len = 1; q = u; -+ while (q > 15) { ++len; q /= 16; } -+ if (s) { -+ s += len; -+ do { *--s = tohex(u % 16); u /= 16; } while(u); /* handles u == 0 */ -+ } -+ return len; -+} -diff -uNr ucspi-tcp-0.88-stock/haveip6.h1 ucspi-tcp-0.88/haveip6.h1 ---- ucspi-tcp-0.88-stock/haveip6.h1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/haveip6.h1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1 @@ -+ -diff -uNr ucspi-tcp-0.88-stock/haveip6.h2 ucspi-tcp-0.88/haveip6.h2 ---- ucspi-tcp-0.88-stock/haveip6.h2 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/haveip6.h2 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1 @@ -+#define LIBC_HAS_IP6 1 -diff -uNr ucspi-tcp-0.88-stock/hier.c ucspi-tcp-0.88/hier.c ---- ucspi-tcp-0.88-stock/hier.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/hier.c Fri Sep 9 12:07:53 2005 -@@ -4,6 +4,9 @@ - { - h(auto_home,-1,-1,02755); - d(auto_home,"bin",-1,-1,02755); -+ d(auto_home,"man",-1,-1,02755); -+ d(auto_home,"man/man1",-1,-1,02755); -+ d(auto_home,"man/man5",-1,-1,02755); - - c(auto_home,"bin","tcpserver",-1,-1,0755); - c(auto_home,"bin","tcprules",-1,-1,0755); -@@ -22,4 +25,20 @@ - c(auto_home,"bin","delcr",-1,-1,0755); - c(auto_home,"bin","fixcrio",-1,-1,0755); - c(auto_home,"bin","rblsmtpd",-1,-1,0755); -+ -+ c(auto_home,"man/man1","tcpclient.1",-1,-1,0644); -+ c(auto_home,"man/man1","tcpserver.1",-1,-1,0644); -+ c(auto_home,"man/man1","tcprules.1",-1,-1,0644); -+ c(auto_home,"man/man1","tcprulescheck.1",-1,-1,0644); -+ c(auto_home,"man/man1","fixcr.1",-1,-1,0644); -+ c(auto_home,"man/man1","addcr.1",-1,-1,0644); -+ c(auto_home,"man/man1","delcr.1",-1,-1,0644); -+ c(auto_home,"man/man1","who@.1",-1,-1,0644); -+ c(auto_home,"man/man1","date@.1",-1,-1,0644); -+ c(auto_home,"man/man1","finger@.1",-1,-1,0644); -+ c(auto_home,"man/man1","http@.1",-1,-1,0644); -+ c(auto_home,"man/man1","mconnect.1",-1,-1,0644); -+ c(auto_home,"man/man1","argv0.1",-1,-1,0644); -+ c(auto_home,"man/man1","recordio.1",-1,-1,0644); -+ c(auto_home,"man/man5","tcp-environ.5",-1,-1,0644); - } -diff -uNr ucspi-tcp-0.88-stock/http@.1 ucspi-tcp-0.88/http@.1 ---- ucspi-tcp-0.88-stock/http@.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/http@.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,52 @@ -+.TH http@ 1 -+.SH NAME -+http@ \- get a web page from a host through HTTP -+.SH SYNTAX -+.B http@ -+[ -+.I host -+[ -+.I page -+[ -+.I port -+] -+] -+] -+.SH DESCRIPTION -+.B http@ -+connects to -+.I port -+on -+.IR host , -+sends -+.B GET /\fIpage -+(with an extra CR) -+to -+.IR host , -+and prints any data it receives, -+removing CR from the end of each line. -+ -+If -+.I port -+is not supplied, -+.B http@ -+uses port 80 (HTTP). -+ -+If -+.I page -+is not supplied, -+.B http@ -+sends -+.B GET / -+to -+.IR host . -+ -+If -+.I host -+is not supplied, -+.B http@ -+connects to the local host. -+.SH "SEE ALSO" -+addcr(1), -+delcr(1), -+tcpclient(1) -diff -uNr ucspi-tcp-0.88-stock/ip4.h ucspi-tcp-0.88/ip4.h ---- ucspi-tcp-0.88-stock/ip4.h Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/ip4.h Fri Sep 9 12:07:53 2005 -@@ -6,4 +6,6 @@ - - #define IP4_FMT 20 - -+extern const char ip4loopback[4]; /* = {127,0,0,1}; */ -+ - #endif -diff -uNr ucspi-tcp-0.88-stock/ip6.h ucspi-tcp-0.88/ip6.h ---- ucspi-tcp-0.88-stock/ip6.h Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/ip6.h Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,28 @@ -+#ifndef IP6_H -+#define IP6_H -+ -+#include "byte.h" -+ -+extern unsigned int scan_ip6(const char *src,char *ip); -+extern unsigned int fmt_ip6(char *dest,const char *ip); -+ -+extern unsigned int scan_ip6_flat(const char *src,char *); -+extern unsigned int fmt_ip6_flat(char *dest,const char *); -+ -+/* -+ ip6 address syntax: (h = hex digit), no leading '0' required -+ 1. hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh -+ 2. any number of 0000 may be abbreviated as "::", but only once -+ flat ip6 address syntax: -+ hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh -+ */ -+ -+#define IP6_FMT 40 -+ -+extern const unsigned char V4mappedprefix[12]; /*={0,0,0,0,0,0,0,0,0,0,0xff,0xff}; */ -+extern const unsigned char V6loopback[16]; /*={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; */ -+extern const unsigned char V6any[16]; /*={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; */ -+ -+#define ip6_isv4mapped(ip) (byte_equal(ip,12,V4mappedprefix)) -+ -+#endif -diff -uNr ucspi-tcp-0.88-stock/ip6_fmt.c ucspi-tcp-0.88/ip6_fmt.c ---- ucspi-tcp-0.88-stock/ip6_fmt.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/ip6_fmt.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,62 @@ -+#include "fmt.h" -+#include "byte.h" -+#include "ip4.h" -+#include "ip6.h" -+ -+unsigned int ip6_fmt(char *s,char ip[16]) -+{ -+ unsigned int len; -+ unsigned int i; -+ unsigned int temp; -+ unsigned int compressing; -+ int j; -+ -+ len = 0; compressing = 0; -+ for (j=0; j<16; j+=2) { -+ if (j==12 && ip6_isv4mapped(ip)) { -+ temp=ip4_fmt(s,ip+12); -+ len+=temp; -+ s+=temp; -+ break; -+ } -+ temp = ((unsigned long) (unsigned char) ip[j] << 8) + -+ (unsigned long) (unsigned char) ip[j+1]; -+ if (temp == 0) { -+ if (!compressing) { -+ compressing=1; -+ if (j==0) { -+ *s=':'; s+=1; ++len; -+ } -+ } -+ } else { -+ if (compressing) { -+ compressing=0; -+ *s=':'; s+=1; ++len; -+ } -+ i = fmt_xlong(s,temp); len += i; if (s) s += i; -+ if (s && j<14) *s++ = ':'; ++len; -+ } -+ } -+ -+ if (s) *s=0; -+ return len; -+} -+ -+static char tohex(char num) { -+ if (num<10) -+ return num+'0'; -+ else if (num<16) -+ return num-10+'a'; -+ else -+ return -1; -+} -+ -+unsigned int ip6_fmt_flat(char *s,char ip[16]) -+{ -+ int i; -+ for (i=0; i<16; i++) { -+ *s++=tohex((unsigned char)ip[i] >> 4); -+ *s++=tohex((unsigned char)ip[i] & 15); -+ } -+ return 32; -+} -diff -uNr ucspi-tcp-0.88-stock/mconnect.1 ucspi-tcp-0.88/mconnect.1 ---- ucspi-tcp-0.88-stock/mconnect.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/mconnect.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,36 @@ -+.TH mconnect 1 -+.SH NAME -+mconnect \- connect to the SMTP server on a host -+.SH SYNTAX -+.B mconnect -+[ -+.I host -+[ -+.I port -+] -+] -+.SH DESCRIPTION -+.B mconnect -+connects to -+.I port -+on -+.IR host . -+It sends its input to -+.IR host , -+adding a CR to each line. -+Meanwhile it prints anything it receives from -+.IR host . -+ -+If -+.I port -+is not supplied, -+.B mconnect -+uses port 25 (SMTP). -+ -+If -+.I host -+is not supplied, -+.B mconnect -+connects to the local host. -+.SH "SEE ALSO" -+tcpclient(1) -diff -uNr ucspi-tcp-0.88-stock/old-rules.c ucspi-tcp-0.88/old-rules.c ---- ucspi-tcp-0.88-stock/old-rules.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/old-rules.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,101 @@ -+#include "alloc.h" -+#include "stralloc.h" -+#include "open.h" -+#include "cdb.h" -+#include "rules.h" -+ -+stralloc rules_name = {0}; -+ -+static struct cdb c; -+ -+static int dorule(void (*callback)(char *,unsigned int)) -+{ -+ char *data; -+ unsigned int datalen; -+ -+ switch(cdb_find(&c,rules_name.s,rules_name.len)) { -+ case -1: return -1; -+ case 0: return 0; -+ } -+ -+ datalen = cdb_datalen(&c); -+ data = alloc(datalen); -+ if (!data) return -1; -+ if (cdb_read(&c,data,datalen,cdb_datapos(&c)) == -1) { -+ alloc_free(data); -+ return -1; -+ } -+ -+ callback(data,datalen); -+ alloc_free(data); -+ return 1; -+} -+ -+static int doit(void (*callback)(char *,unsigned int),char *ip,char *host,char *info) -+{ -+ int r; -+ -+ if (info) { -+ if (!stralloc_copys(&rules_name,info)) return -1; -+ if (!stralloc_cats(&rules_name,"@")) return -1; -+ if (!stralloc_cats(&rules_name,ip)) return -1; -+ r = dorule(callback); -+ if (r) return r; -+ -+ if (host) { -+ if (!stralloc_copys(&rules_name,info)) return -1; -+ if (!stralloc_cats(&rules_name,"@=")) return -1; -+ if (!stralloc_cats(&rules_name,host)) return -1; -+ r = dorule(callback); -+ if (r) return r; -+ } -+ } -+ -+ if (!stralloc_copys(&rules_name,ip)) return -1; -+ r = dorule(callback); -+ if (r) return r; -+ -+ if (host) { -+ if (!stralloc_copys(&rules_name,"=")) return -1; -+ if (!stralloc_cats(&rules_name,host)) return -1; -+ r = dorule(callback); -+ if (r) return r; -+ } -+ -+ if (!stralloc_copys(&rules_name,ip)) return -1; -+ while (rules_name.len > 0) { -+ if (ip[rules_name.len - 1] == '.' || -+ (ip[rules_name.len-1]==':' && rules_name.len>1)) { -+ r = dorule(callback); -+ if (r) return r; -+ } -+ --rules_name.len; -+ } -+ -+ if (host) { -+ while (*host) { -+ if (*host == '.') { -+ if (!stralloc_copys(&rules_name,"=")) return -1; -+ if (!stralloc_cats(&rules_name,host)) return -1; -+ r = dorule(callback); -+ if (r) return r; -+ } -+ ++host; -+ } -+ if (!stralloc_copys(&rules_name,"=")) return -1; -+ r = dorule(callback); -+ if (r) return r; -+ } -+ -+ rules_name.len = 0; -+ return dorule(callback); -+} -+ -+int rules(void (*callback)(char *,unsigned int),int fd,char *ip,char *host,char *info) -+{ -+ int r; -+ cdb_init(&c,fd); -+ r = doit(callback,ip,host,info); -+ cdb_free(&c); -+ return r; -+} -diff -uNr ucspi-tcp-0.88-stock/pathexec.h ucspi-tcp-0.88/pathexec.h ---- ucspi-tcp-0.88-stock/pathexec.h Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/pathexec.h Fri Sep 9 12:07:53 2005 -@@ -2,7 +2,7 @@ - #define PATHEXEC_H - - extern void pathexec_run(char *,char **,char **); --extern int pathexec_env(char *,char *); -+extern int pathexec_env(const char *,const char *); - extern void pathexec(char **); - - #endif -diff -uNr ucspi-tcp-0.88-stock/pathexec_env.c ucspi-tcp-0.88/pathexec_env.c ---- ucspi-tcp-0.88-stock/pathexec_env.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/pathexec_env.c Fri Sep 9 12:07:53 2005 -@@ -8,7 +8,7 @@ - static stralloc plus; - static stralloc tmp; - --int pathexec_env(char *s,char *t) -+int pathexec_env(const char *s,const char *t) - { - if (!s) return 1; - if (!stralloc_copys(&tmp,s)) return 0; -@@ -22,7 +22,6 @@ - - void pathexec(char **argv) - { -- char *path; - char **e; - unsigned int elen; - unsigned int i; -diff -uNr ucspi-tcp-0.88-stock/recordio.1 ucspi-tcp-0.88/recordio.1 ---- ucspi-tcp-0.88-stock/recordio.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/recordio.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,75 @@ -+.TH recordio 1 -+.SH NAME -+recordio \- record the input and output of a program -+.SH SYNTAX -+.B recordio -+.I program -+[ -+.I arg ... -+] -+.SH DESCRIPTION -+.B recordio -+runs -+.I program -+with the given arguments. -+It prints lines to stderr -+showing the input and output of -+.IR program . -+ -+At the beginning of each line on stderr, -+.B recordio -+inserts the -+.I program -+process ID, -+along with -+.B < -+for input or -+.B > -+for output. -+At the end of each line it inserts a space, a plus sign, or [EOF]; -+a space indicates that there was a newline in the input or output, -+and [EOF] indicates the end of input or output. -+ -+.B recordio -+prints every packet of input and output immediately. -+It does not attempt to combine packets into coherent stderr lines. -+For example, -+ -+.EX -+ recordio sh -c 'cat /dev/fd/8 2>&1' > /dev/null -+.EE -+ -+could produce -+ -+.EX -+ 5135 > cat: /dev/fd/8: Bad file descriptor -+.br -+ 5135 > [EOF] -+.EE -+ -+or -+ -+.EX -+ 5135 > cat: + -+.br -+ 5135 > /dev/fd/8+ -+.br -+ 5135 > : + -+.br -+ 5135 > Bad file descriptor -+.br -+ 5135 > [EOF] -+.EE -+ -+.B recordio -+uses several lines for long packets -+to guarantee that each line is printed atomically to stderr. -+ -+.B recordio -+runs as a child of -+.IR program . -+It exits when it sees the end of -+.IR program 's -+output. -+.SH "SEE ALSO" -+tcpserver(1) -diff -uNr ucspi-tcp-0.88-stock/remoteinfo.h ucspi-tcp-0.88/remoteinfo.h ---- ucspi-tcp-0.88-stock/remoteinfo.h Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/remoteinfo.h Fri Sep 9 12:07:53 2005 -@@ -5,5 +5,6 @@ - #include "uint16.h" - - extern int remoteinfo(stralloc *,char *,uint16,char *,uint16,unsigned int); -+extern int remoteinfo6(stralloc *,char *,uint16,char *,uint16,unsigned int,uint32); - - #endif -diff -uNr ucspi-tcp-0.88-stock/remoteinfo6.c ucspi-tcp-0.88/remoteinfo6.c ---- ucspi-tcp-0.88-stock/remoteinfo6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/remoteinfo6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,98 @@ -+#include "fmt.h" -+#include "buffer.h" -+#include "socket.h" -+#include "error.h" -+#include "iopause.h" -+#include "timeoutconn.h" -+#include "remoteinfo.h" -+ -+static struct taia now; -+static struct taia deadline; -+ -+static int mywrite(int fd,char *buf,int len) -+{ -+ iopause_fd x; -+ -+ x.fd = fd; -+ x.events = IOPAUSE_WRITE; -+ for (;;) { -+ taia_now(&now); -+ iopause(&x,1,&deadline,&now); -+ if (x.revents) break; -+ if (taia_less(&deadline,&now)) { -+ errno = error_timeout; -+ return -1; -+ } -+ } -+ return write(fd,buf,len); -+} -+ -+static int myread(int fd,char *buf,int len) -+{ -+ iopause_fd x; -+ -+ x.fd = fd; -+ x.events = IOPAUSE_READ; -+ for (;;) { -+ taia_now(&now); -+ iopause(&x,1,&deadline,&now); -+ if (x.revents) break; -+ if (taia_less(&deadline,&now)) { -+ errno = error_timeout; -+ return -1; -+ } -+ } -+ return read(fd,buf,len); -+} -+ -+static int doit(stralloc *out,int s,char ipremote[16],uint16 portremote,char iplocal[16],uint16 portlocal,unsigned int timeout,uint32 netif) -+{ -+ buffer b; -+ char bspace[128]; -+ char strnum[FMT_ULONG]; -+ int numcolons; -+ char ch; -+ -+ if (socket_bind6(s,iplocal,0,netif) == -1) return -1; -+ if (timeoutconn6(s,ipremote,113,timeout,netif) == -1) return -1; -+ -+ buffer_init(&b,mywrite,s,bspace,sizeof bspace); -+ buffer_put(&b,strnum,fmt_ulong(strnum,portremote)); -+ buffer_put(&b," , ",3); -+ buffer_put(&b,strnum,fmt_ulong(strnum,portlocal)); -+ buffer_put(&b,"\r\n",2); -+ if (buffer_flush(&b) == -1) return -1; -+ -+ buffer_init(&b,myread,s,bspace,sizeof bspace); -+ numcolons = 0; -+ for (;;) { -+ if (buffer_get(&b,&ch,1) != 1) return -1; -+ if ((ch == ' ') || (ch == '\t') || (ch == '\r')) continue; -+ if (ch == '\n') return 0; -+ if (numcolons < 3) { -+ if (ch == ':') ++numcolons; -+ } -+ else { -+ if (!stralloc_append(out,&ch)) return -1; -+ if (out->len > 256) return 0; -+ } -+ } -+} -+ -+int remoteinfo6(stralloc *out,char ipremote[16],uint16 portremote,char iplocal[16],uint16 portlocal,unsigned int timeout,uint32 netif) -+{ -+ int s; -+ int r; -+ -+ if (!stralloc_copys(out,"")) return -1; -+ -+ taia_now(&now); -+ taia_uint(&deadline,timeout); -+ taia_add(&deadline,&now,&deadline); -+ -+ s = socket_tcp6(); -+ if (s == -1) return -1; -+ r = doit(out,s,ipremote,portremote,iplocal,portlocal,timeout,netif); -+ close(s); -+ return r; -+} -diff -uNr ucspi-tcp-0.88-stock/rules.c ucspi-tcp-0.88/rules.c ---- ucspi-tcp-0.88-stock/rules.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/rules.c Fri Sep 9 12:07:53 2005 -@@ -64,7 +64,7 @@ - - if (!stralloc_copys(&rules_name,ip)) return -1; - while (rules_name.len > 0) { -- if (ip[rules_name.len - 1] == '.') { -+ if (ip[rules_name.len - 1] == '.' || ip[rules_name.len - 1] == ':') { - r = dorule(callback); - if (r) return r; - } -diff -uNr ucspi-tcp-0.88-stock/scan_ip6.c ucspi-tcp-0.88/scan_ip6.c ---- ucspi-tcp-0.88-stock/scan_ip6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/scan_ip6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,87 @@ -+#include "scan.h" -+#include "ip4.h" -+#include "ip6.h" -+ -+/* -+ * IPv6 addresses are really ugly to parse. -+ * Syntax: (h = hex digit) -+ * 1. hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh -+ * 2. any number of 0000 may be abbreviated as "::", but only once -+ * 3. The last two words may be written as IPv4 address -+ */ -+ -+unsigned int scan_ip6(const char *s,char ip[16]) -+{ -+ unsigned int i; -+ unsigned int len=0; -+ unsigned long u; -+ -+ char suffix[16]; -+ int prefixlen=0; -+ int suffixlen=0; -+ -+ if ((i=ip4_scan((char*)s,ip+12))) { -+ for (len=0; len<12; ++len) ip[len]=V4mappedprefix[len]; -+ return i; -+ } -+ for (i=0; i<16; i++) ip[i]=0; -+ for (;;) { -+ if (*s == ':') { -+ len++; -+ if (s[1] == ':') { /* Found "::", skip to part 2 */ -+ s+=2; -+ len++; -+ break; -+ } -+ s++; -+ } -+ i = scan_xlong((char*)s,&u); -+ if (!i) return 0; -+ if (prefixlen==12 && s[i]=='.') { -+ /* the last 4 bytes may be written as IPv4 address */ -+ i=ip4_scan((char*)s,ip+12); -+ if (i) -+ return i+len; -+ else -+ return 0; -+ } -+ ip[prefixlen++] = (u >> 8); -+ ip[prefixlen++] = (u & 255); -+ s += i; len += i; -+ if (prefixlen==16) -+ return len; -+ } -+ -+/* part 2, after "::" */ -+ for (;;) { -+ if (*s == ':') { -+ if (suffixlen==0) -+ break; -+ s++; -+ len++; -+ } else if (suffixlen!=0) -+ break; -+ i = scan_xlong((char*)s,&u); -+ if (!i) { -+ len--; -+ break; -+ } -+ if (suffixlen+prefixlen<=12 && s[i]=='.') { -+ int j=ip4_scan((char*)s,suffix+suffixlen); -+ if (j) { -+ suffixlen+=4; -+ len+=j; -+ break; -+ } else -+ prefixlen=12-suffixlen; /* make end-of-loop test true */ -+ } -+ suffix[suffixlen++] = (u >> 8); -+ suffix[suffixlen++] = (u & 255); -+ s += i; len += i; -+ if (prefixlen+suffixlen==16) -+ break; -+ } -+ for (i=0; i<suffixlen; i++) -+ ip[16-suffixlen+i] = suffix[i]; -+ return len; -+} -diff -uNr ucspi-tcp-0.88-stock/scan_xlong.c ucspi-tcp-0.88/scan_xlong.c ---- ucspi-tcp-0.88-stock/scan_xlong.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/scan_xlong.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,23 @@ -+#include "scan.h" -+ -+static int fromhex(unsigned char c) { -+ if (c>='0' && c<='9') -+ return c-'0'; -+ else if (c>='A' && c<='F') -+ return c-'A'+10; -+ else if (c>='a' && c<='f') -+ return c-'a'+10; -+ return -1; -+} -+ -+unsigned int scan_xlong(char *src,unsigned long *dest) { -+ register const char *tmp=src; -+ register int l=0; -+ register unsigned char c; -+ while ((c=fromhex(*tmp))<16) { -+ l=(l<<4)+c; -+ ++tmp; -+ } -+ *dest=l; -+ return tmp-src; -+} -diff -uNr ucspi-tcp-0.88-stock/socket.h ucspi-tcp-0.88/socket.h ---- ucspi-tcp-0.88-stock/socket.h Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/socket.h Fri Sep 9 12:07:53 2005 -@@ -2,21 +2,52 @@ - #define SOCKET_H - - #include "uint16.h" -+#include "uint32.h" - - extern int socket_tcp(void); - extern int socket_udp(void); -+extern int socket_tcp6(void); -+extern int socket_udp6(void); - --extern int socket_connect4(int,char *,uint16); -+extern int socket_connect4(int,const char *,uint16); -+extern int socket_connect6(int s,const char *ip,uint16 port,uint32 scope_id); - extern int socket_connected(int); --extern int socket_bind4(int,char *,uint16); --extern int socket_bind4_reuse(int,char *,uint16); -+extern int socket_bind4(int,const char *,uint16); -+extern int socket_bind4_reuse(int,const char *,uint16); -+extern int socket_bind6(int s,const char *ip,uint16 port,uint32 scope_id); -+extern int socket_bind6_reuse(int s,const char *ip,uint16 port,uint32 scope_id); - extern int socket_listen(int,int); - extern int socket_accept4(int,char *,uint16 *); -+extern int socket_accept6(int s,char *ip,uint16 *port,uint32 *scope_id); - extern int socket_recv4(int,char *,int,char *,uint16 *); --extern int socket_send4(int,char *,int,char *,uint16); -+extern int socket_send4(int,const char *,int,const char *,uint16); -+extern int socket_recv6(int s,char *buf,unsigned int len,char *ip,uint16 *port,uint32 *scope_id); -+extern int socket_send6(int s,const char *buf,unsigned int len,const char *ip,uint16 port,uint32 scope_id); - extern int socket_local4(int,char *,uint16 *); - extern int socket_remote4(int,char *,uint16 *); -+extern int socket_local6(int s,char *ip,uint16 *port,uint32 *scope_id); -+extern int socket_remote6(int s,char *ip,uint16 *port,uint32 *scope_id); -+ -+/* enable sending udp packets to the broadcast address */ -+extern int socket_broadcast(int); -+/* join a multicast group on the given interface */ -+extern int socket_mcjoin4(int,char *,char *); -+extern int socket_mcjoin6(int,char *,int); -+/* leave a multicast group on the given interface */ -+extern int socket_mcleave4(int,char *); -+extern int socket_mcleave6(int,char *); -+/* set multicast TTL/hop count for outgoing packets */ -+extern int socket_mcttl4(int,char); -+extern int socket_mcttl6(int,char); -+/* enable multicast loopback */ -+extern int socket_mcloop4(int,char); -+extern int socket_mcloop6(int,char); -+ -+extern const char* socket_getifname(uint32 interface); -+extern uint32 socket_getifidx(const char *ifname); - - extern void socket_tryreservein(int,int); - -+extern int noipv6; -+ - #endif -diff -uNr ucspi-tcp-0.88-stock/socket_accept6.c ucspi-tcp-0.88/socket_accept6.c ---- ucspi-tcp-0.88-stock/socket_accept6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_accept6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,44 @@ -+#include <sys/types.h> -+#include <sys/param.h> -+#include <sys/socket.h> -+#include <netinet/in.h> -+#include "byte.h" -+#include "socket.h" -+#include "ip6.h" -+#include "haveip6.h" -+#include "error.h" -+ -+int socket_accept6(int s,char ip[16],uint16 *port,uint32 *scope_id) -+{ -+#ifdef LIBC_HAS_IP6 -+ struct sockaddr_in6 sa; -+#else -+ struct sockaddr_in sa; -+#endif -+ unsigned int dummy = sizeof sa; -+ int fd; -+ -+ fd = accept(s,(struct sockaddr *) &sa,&dummy); -+ if (fd == -1) return -1; -+ -+#ifdef LIBC_HAS_IP6 -+ if (sa.sin6_family==AF_INET) { -+ struct sockaddr_in *sa4=(struct sockaddr_in*)&sa; -+ byte_copy(ip,12,V4mappedprefix); -+ byte_copy(ip+12,4,(char *) &sa4->sin_addr); -+ uint16_unpack_big((char *) &sa4->sin_port,port); -+ return fd; -+ } -+ byte_copy(ip,16,(char *) &sa.sin6_addr); -+ uint16_unpack_big((char *) &sa.sin6_port,port); -+ if (scope_id) *scope_id=sa.sin6_scope_id; -+ -+ return fd; -+#else -+ byte_copy(ip,12,V4mappedprefix); -+ byte_copy(ip+12,4,(char *) &sa.sin_addr); -+ uint16_unpack_big((char *) &sa.sin_port,port); -+ if (scope_id) *scope_id=0; -+ return fd; -+#endif -+} -diff -uNr ucspi-tcp-0.88-stock/socket_bind.c ucspi-tcp-0.88/socket_bind.c ---- ucspi-tcp-0.88-stock/socket_bind.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/socket_bind.c Fri Sep 9 12:07:53 2005 -@@ -5,7 +5,7 @@ - #include "byte.h" - #include "socket.h" - --int socket_bind4(int s,char ip[4],uint16 port) -+int socket_bind4(int s,const char ip[4],uint16 port) - { - struct sockaddr_in sa; - -@@ -17,7 +17,7 @@ - return bind(s,(struct sockaddr *) &sa,sizeof sa); - } - --int socket_bind4_reuse(int s,char ip[4],uint16 port) -+int socket_bind4_reuse(int s,const char ip[4],uint16 port) - { - int opt = 1; - setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof opt); -diff -uNr ucspi-tcp-0.88-stock/socket_bind6.c ucspi-tcp-0.88/socket_bind6.c ---- ucspi-tcp-0.88-stock/socket_bind6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_bind6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,45 @@ -+#include <sys/types.h> -+#include <sys/param.h> -+#include <sys/socket.h> -+#include <netinet/in.h> -+#include "byte.h" -+#include "socket.h" -+#include "ip6.h" -+#include "haveip6.h" -+#include "error.h" -+ -+int socket_bind6(int s,const char ip[16],uint16 port,uint32 scope_id) -+{ -+#ifdef LIBC_HAS_IP6 -+ struct sockaddr_in6 sa; -+ -+ if (noipv6) { -+#endif -+ int i; -+ for (i=0; i<16; i++) -+ if (ip[i]!=0) break; -+ if (i==16 || ip6_isv4mapped(ip)) -+ return socket_bind4(s,ip+12,port); -+#ifdef LIBC_HAS_IP6 -+ } -+ byte_zero(&sa,sizeof sa); -+ sa.sin6_family = AF_INET6; -+ uint16_pack_big((char *) &sa.sin6_port,port); -+/* implicit: sa.sin6_flowinfo = 0; */ -+ byte_copy((char *) &sa.sin6_addr,16,ip); -+ sa.sin6_scope_id=scope_id; -+ -+ return bind(s,(struct sockaddr *) &sa,sizeof sa); -+#else -+ errno=error_proto; -+ return -1; -+#endif -+} -+ -+int socket_bind6_reuse(int s,const char ip[16],uint16 port,uint32 scope_id) -+{ -+ int opt = 1; -+ setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof opt); -+ return socket_bind6(s,ip,port,scope_id); -+} -+ -diff -uNr ucspi-tcp-0.88-stock/socket_conn.c ucspi-tcp-0.88/socket_conn.c ---- ucspi-tcp-0.88-stock/socket_conn.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/socket_conn.c Fri Sep 9 12:07:53 2005 -@@ -6,7 +6,7 @@ - #include "byte.h" - #include "socket.h" - --int socket_connect4(int s,char ip[4],uint16 port) -+int socket_connect4(int s,const char ip[4],uint16 port) - { - struct sockaddr_in sa; - -diff -uNr ucspi-tcp-0.88-stock/socket_conn6.c ucspi-tcp-0.88/socket_conn6.c ---- ucspi-tcp-0.88-stock/socket_conn6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_conn6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,38 @@ -+#include <sys/param.h> -+#include <sys/types.h> -+#include <sys/socket.h> -+#include <netinet/in.h> -+#include <errno.h> -+#include "byte.h" -+#include "socket.h" -+#include "ip6.h" -+#include "haveip6.h" -+#include "uint32.h" -+#include "ip4.h" -+ -+int socket_connect6(int s,const char ip[16],uint16 port,uint32 scope_id) -+{ -+#ifdef LIBC_HAS_IP6 -+ struct sockaddr_in6 sa; -+ -+ if (noipv6) { -+#endif -+ if (ip6_isv4mapped(ip)) -+ return socket_connect4(s,ip+12,port); -+ if (byte_equal(ip,16,V6loopback)) -+ return socket_connect4(s,ip4loopback,port); -+#ifdef LIBC_HAS_IP6 -+ } -+ byte_zero(&sa,sizeof sa); -+ sa.sin6_family = PF_INET6; -+ uint16_pack_big((char *) &sa.sin6_port,port); -+ sa.sin6_flowinfo = 0; -+ sa.sin6_scope_id = scope_id; -+ byte_copy((char *) &sa.sin6_addr,16,ip); -+ -+ return connect(s,(struct sockaddr *) &sa,sizeof sa); -+#else -+ errno=EPROTONOSUPPORT; -+ return -1; -+#endif -+} -diff -uNr ucspi-tcp-0.88-stock/socket_getifidx.c ucspi-tcp-0.88/socket_getifidx.c ---- ucspi-tcp-0.88-stock/socket_getifidx.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_getifidx.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,8 @@ -+#include <sys/types.h> -+#include <sys/socket.h> -+#include <net/if.h> -+#include "socket.h" -+ -+uint32 socket_getifidx(const char* ifname) { -+ return if_nametoindex(ifname); -+} -diff -uNr ucspi-tcp-0.88-stock/socket_getifname.c ucspi-tcp-0.88/socket_getifname.c ---- ucspi-tcp-0.88-stock/socket_getifname.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_getifname.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,14 @@ -+#include <sys/types.h> -+#include <sys/socket.h> -+#include <net/if.h> -+#include "socket.h" -+ -+static char ifname[IFNAMSIZ]; -+ -+const char* socket_getifname(uint32 interface) { -+ char *tmp=if_indextoname(interface,ifname); -+ if (tmp) -+ return tmp; -+ else -+ return "[unknown]"; -+} -diff -uNr ucspi-tcp-0.88-stock/socket_ip4loopback.c ucspi-tcp-0.88/socket_ip4loopback.c ---- ucspi-tcp-0.88-stock/socket_ip4loopback.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_ip4loopback.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,2 @@ -+ -+const char ip4loopback[4] = {127,0,0,1}; -diff -uNr ucspi-tcp-0.88-stock/socket_local6.c ucspi-tcp-0.88/socket_local6.c ---- ucspi-tcp-0.88-stock/socket_local6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_local6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,39 @@ -+#include <sys/types.h> -+#include <sys/param.h> -+#include <sys/socket.h> -+#include <netinet/in.h> -+#include "byte.h" -+#include "socket.h" -+#include "ip6.h" -+#include "haveip6.h" -+#include "error.h" -+ -+int socket_local6(int s,char ip[16],uint16 *port,uint32 *scope_id) -+{ -+#ifdef LIBC_HAS_IP6 -+ struct sockaddr_in6 sa; -+#else -+ struct sockaddr_in sa; -+#endif -+ unsigned int dummy = sizeof sa; -+ -+ if (getsockname(s,(struct sockaddr *) &sa,&dummy) == -1) return -1; -+#ifdef LIBC_HAS_IP6 -+ if (sa.sin6_family==AF_INET) { -+ struct sockaddr_in *sa4=(struct sockaddr_in*)&sa; -+ byte_copy(ip,12,V4mappedprefix); -+ byte_copy(ip+12,4,(char *) &sa4->sin_addr); -+ uint16_unpack_big((char *) &sa4->sin_port,port); -+ return 0; -+ } -+ byte_copy(ip,16,(char *) &sa.sin6_addr); -+ uint16_unpack_big((char *) &sa.sin6_port,port); -+ if (scope_id) *scope_id=sa.sin6_scope_id; -+#else -+ byte_copy(ip,12,V4mappedprefix); -+ byte_copy(ip+12,4,(char *) &sa.sin_addr); -+ uint16_unpack_big((char *) &sa.sin_port,port); -+ if (scope_id) *scope_id=0; -+#endif -+ return 0; -+} -diff -uNr ucspi-tcp-0.88-stock/socket_recv6.c ucspi-tcp-0.88/socket_recv6.c ---- ucspi-tcp-0.88-stock/socket_recv6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_recv6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,44 @@ -+#include <sys/types.h> -+#include <sys/param.h> -+#include <sys/socket.h> -+#include <netinet/in.h> -+#include "byte.h" -+#include "socket.h" -+#include "ip6.h" -+#include "haveip6.h" -+#include "error.h" -+ -+int socket_recv6(int s,char *buf,unsigned int len,char ip[16],uint16 *port,uint32 *scope_id) -+{ -+#ifdef LIBC_HAS_IP6 -+ struct sockaddr_in6 sa; -+#else -+ struct sockaddr_in sa; -+#endif -+ unsigned int dummy = sizeof sa; -+ int r; -+ -+ byte_zero(&sa,dummy); -+ r = recvfrom(s,buf,len,0,(struct sockaddr *) &sa,&dummy); -+ if (r == -1) return -1; -+ -+#ifdef LIBC_HAS_IP6 -+ if (noipv6) { -+ struct sockaddr_in *sa4=(struct sockaddr_in *)&sa; -+ byte_copy(ip,12,V4mappedprefix); -+ byte_copy(ip+12,4,(char *) &sa4->sin_addr); -+ uint16_unpack_big((char *) &sa4->sin_port,port); -+ return r; -+ } -+ byte_copy(ip,16,(char *) &sa.sin6_addr); -+ uint16_unpack_big((char *) &sa.sin6_port,port); -+ if (scope_id) *scope_id=sa.sin6_scope_id; -+#else -+ byte_copy(ip,12,(char *)V4mappedprefix); -+ byte_copy(ip+12,4,(char *) &sa.sin_addr); -+ uint16_unpack_big((char *) &sa.sin_port,port); -+ if (scope_id) *scope_id=0; -+#endif -+ -+ return r; -+} -diff -uNr ucspi-tcp-0.88-stock/socket_remote6.c ucspi-tcp-0.88/socket_remote6.c ---- ucspi-tcp-0.88-stock/socket_remote6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_remote6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,39 @@ -+#include <sys/types.h> -+#include <sys/param.h> -+#include <sys/socket.h> -+#include <netinet/in.h> -+#include "byte.h" -+#include "socket.h" -+#include "ip6.h" -+#include "haveip6.h" -+#include "error.h" -+ -+int socket_remote6(int s,char ip[16],uint16 *port,uint32 *scope_id) -+{ -+#ifdef LIBC_HAS_IP6 -+ struct sockaddr_in6 sa; -+#else -+ struct sockaddr_in sa; -+#endif -+ unsigned int dummy = sizeof sa; -+ -+ if (getpeername(s,(struct sockaddr *) &sa,&dummy) == -1) return -1; -+#ifdef LIBC_HAS_IP6 -+ if (sa.sin6_family==AF_INET) { -+ struct sockaddr_in *sa4=(struct sockaddr_in*)&sa; -+ byte_copy(ip,12,V4mappedprefix); -+ byte_copy(ip+12,4,(char *) &sa4->sin_addr); -+ uint16_unpack_big((char *) &sa4->sin_port,port); -+ return 0; -+ } -+ byte_copy(ip,16,(char *) &sa.sin6_addr); -+ uint16_unpack_big((char *) &sa.sin6_port,port); -+ if (scope_id) *scope_id=sa.sin6_scope_id; -+#else -+ byte_copy(ip,12,V4mappedprefix); -+ byte_copy(ip+12,4,(char *) &sa.sin_addr); -+ uint16_unpack_big((char *) &sa.sin_port,port); -+ if (scope_id) *scope_id=0; -+#endif -+ return 0; -+} -diff -uNr ucspi-tcp-0.88-stock/socket_send6.c ucspi-tcp-0.88/socket_send6.c ---- ucspi-tcp-0.88-stock/socket_send6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_send6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,40 @@ -+#include <sys/types.h> -+#include <sys/param.h> -+#include <sys/socket.h> -+#include <netinet/in.h> -+#include "byte.h" -+#include "socket.h" -+#include "ip4.h" -+#include "ip6.h" -+#include "haveip6.h" -+#include "error.h" -+ -+int socket_send6(int s,const char *buf,unsigned int len,const char ip[16],uint16 port,uint32 scope_id) -+{ -+#ifdef LIBC_HAS_IP6 -+ struct sockaddr_in6 sa; -+#else -+ struct sockaddr_in sa; -+#endif -+ -+ byte_zero(&sa,sizeof sa); -+#ifdef LIBC_HAS_IP6 -+ if (noipv6) { -+#endif -+ if (ip6_isv4mapped(ip)) -+ return socket_send4(s,buf,len,ip+12,port); -+ if (byte_equal(ip,16,V6loopback)) -+ return socket_send4(s,buf,len,ip4loopback,port); -+#ifdef LIBC_HAS_IP6 -+ errno=error_proto; -+ return -1; -+ } -+ sa.sin6_family = AF_INET6; -+ uint16_pack_big((char *) &sa.sin6_port,port); -+ byte_copy((char *) &sa.sin6_addr,16,ip); -+ return sendto(s,buf,len,0,(struct sockaddr *) &sa,sizeof sa); -+#else -+ errno=error_proto; -+ return -1; -+#endif -+} -diff -uNr ucspi-tcp-0.88-stock/socket_tcp6.c ucspi-tcp-0.88/socket_tcp6.c ---- ucspi-tcp-0.88-stock/socket_tcp6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_tcp6.c Fri Sep 9 12:09:31 2005 -@@ -0,0 +1,44 @@ -+#include <sys/types.h> -+#include <sys/param.h> -+#include <sys/socket.h> -+#include <netinet/in.h> -+#include <errno.h> -+#include "ndelay.h" -+#include "socket.h" -+#include "haveip6.h" -+#include "error.h" -+ -+#ifdef LIBC_HAS_IP6 -+int noipv6=0; -+#else -+int noipv6=1; -+#endif -+ -+int socket_tcp6(void) -+{ -+#ifdef LIBC_HAS_IP6 -+ int s; -+ -+ if (noipv6) goto compat; -+ s = socket(PF_INET6,SOCK_STREAM,0); -+ if (s == -1) { -+ if (errno == EINVAL || errno == EAFNOSUPPORT) { -+compat: -+ s=socket(AF_INET,SOCK_STREAM,0); -+ noipv6=1; -+ if (s==-1) return -1; -+ } else -+ return -1; -+ } -+ if (ndelay_on(s) == -1) { close(s); return -1; } -+#ifdef IPV6_V6ONLY -+ { -+ int zero=0; -+ setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero)); -+ } -+#endif -+ return s; -+#else -+ return socket_tcp(); -+#endif -+} -diff -uNr ucspi-tcp-0.88-stock/socket_udp6.c ucspi-tcp-0.88/socket_udp6.c ---- ucspi-tcp-0.88-stock/socket_udp6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_udp6.c Fri Sep 9 12:09:42 2005 -@@ -0,0 +1,38 @@ -+#include <sys/types.h> -+#include <sys/socket.h> -+#include <netinet/in.h> -+#include <errno.h> -+#include "haveip6.h" -+#include "socket.h" -+ -+#ifndef EAFNOSUPPORT -+#define EAFNOSUPPORT EINVAL -+#endif -+ -+int socket_udp6(void) -+{ -+#ifdef LIBC_HAS_IP6 -+ int s; -+ -+ if (noipv6) goto compat; -+ s = socket(PF_INET6,SOCK_DGRAM,0); -+ if (s == -1) { -+ if (errno == EINVAL || errno == EAFNOSUPPORT) { -+compat: -+ s=socket(AF_INET,SOCK_DGRAM,0); -+ noipv6=1; -+ if (s==-1) return -1; -+ } else -+ return -1; -+ } -+#ifdef IPV6_V6ONLY -+ { -+ int zero=0; -+ setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero)); -+ } -+#endif -+ return s; -+#else -+ return socket_udp(); -+#endif -+} -diff -uNr ucspi-tcp-0.88-stock/socket_v4mappedprefix.c ucspi-tcp-0.88/socket_v4mappedprefix.c ---- ucspi-tcp-0.88-stock/socket_v4mappedprefix.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_v4mappedprefix.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,2 @@ -+ -+const unsigned char V4mappedprefix[12]={0,0,0,0,0,0,0,0,0,0,0xff,0xff}; -diff -uNr ucspi-tcp-0.88-stock/socket_v6any.c ucspi-tcp-0.88/socket_v6any.c ---- ucspi-tcp-0.88-stock/socket_v6any.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_v6any.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,2 @@ -+ -+const unsigned char V6any[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; -diff -uNr ucspi-tcp-0.88-stock/socket_v6loopback.c ucspi-tcp-0.88/socket_v6loopback.c ---- ucspi-tcp-0.88-stock/socket_v6loopback.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/socket_v6loopback.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,2 @@ -+ -+const unsigned char V6loopback[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; -diff -uNr ucspi-tcp-0.88-stock/str.h ucspi-tcp-0.88/str.h ---- ucspi-tcp-0.88-stock/str.h Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/str.h Fri Sep 9 12:07:53 2005 -@@ -1,13 +1,13 @@ - #ifndef STR_H - #define STR_H - --extern unsigned int str_copy(char *,char *); --extern int str_diff(char *,char *); --extern int str_diffn(char *,char *,unsigned int); --extern unsigned int str_len(char *); --extern unsigned int str_chr(char *,int); --extern unsigned int str_rchr(char *,int); --extern int str_start(char *,char *); -+extern unsigned int str_copy(char *,const char *); -+extern int str_diff(const char *,const char *); -+extern int str_diffn(const char *,const char *,unsigned int); -+extern unsigned int str_len(const char *); -+extern unsigned int str_chr(const char *,int); -+extern unsigned int str_rchr(const char *,int); -+extern int str_start(const char *,const char *); - - #define str_equal(s,t) (!str_diff((s),(t))) - -diff -uNr ucspi-tcp-0.88-stock/str_chr.c ucspi-tcp-0.88/str_chr.c ---- ucspi-tcp-0.88-stock/str_chr.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/str_chr.c Fri Sep 9 12:07:53 2005 -@@ -1,9 +1,9 @@ - #include "str.h" - --unsigned int str_chr(register char *s,int c) -+unsigned int str_chr(register const char *s,int c) - { - register char ch; -- register char *t; -+ register const char *t; - - ch = c; - t = s; -diff -uNr ucspi-tcp-0.88-stock/str_diff.c ucspi-tcp-0.88/str_diff.c ---- ucspi-tcp-0.88-stock/str_diff.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/str_diff.c Fri Sep 9 12:07:53 2005 -@@ -1,6 +1,6 @@ - #include "str.h" - --int str_diff(register char *s,register char *t) -+int str_diff(register const char *s,register const char *t) - { - register char x; - -diff -uNr ucspi-tcp-0.88-stock/str_len.c ucspi-tcp-0.88/str_len.c ---- ucspi-tcp-0.88-stock/str_len.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/str_len.c Fri Sep 9 12:07:53 2005 -@@ -1,8 +1,8 @@ - #include "str.h" - --unsigned int str_len(char *s) -+unsigned int str_len(const char *s) - { -- register char *t; -+ register const char *t; - - t = s; - for (;;) { -diff -uNr ucspi-tcp-0.88-stock/str_start.c ucspi-tcp-0.88/str_start.c ---- ucspi-tcp-0.88-stock/str_start.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/str_start.c Fri Sep 9 12:07:53 2005 -@@ -1,6 +1,6 @@ - #include "str.h" - --int str_start(register char *s,register char *t) -+int str_start(register const char *s,register const char *t) - { - register char x; - -diff -uNr ucspi-tcp-0.88-stock/stralloc.h ucspi-tcp-0.88/stralloc.h ---- ucspi-tcp-0.88-stock/stralloc.h Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/stralloc.h Fri Sep 9 12:07:53 2005 -@@ -9,18 +9,20 @@ - extern int stralloc_readyplus(stralloc *,unsigned int); - extern int stralloc_copy(stralloc *,stralloc *); - extern int stralloc_cat(stralloc *,stralloc *); --extern int stralloc_copys(stralloc *,char *); --extern int stralloc_cats(stralloc *,char *); --extern int stralloc_copyb(stralloc *,char *,unsigned int); --extern int stralloc_catb(stralloc *,char *,unsigned int); -+extern int stralloc_copys(stralloc *,const char *); -+extern int stralloc_cats(stralloc *,const char *); -+extern int stralloc_copyb(stralloc *,const char *,unsigned int); -+extern int stralloc_catb(stralloc *,const char *,unsigned int); - extern int stralloc_append(stralloc *,char *); /* beware: this takes a pointer to 1 char */ --extern int stralloc_starts(stralloc *,char *); -+extern int stralloc_starts(stralloc *,const char *); - - #define stralloc_0(sa) stralloc_append(sa,"") - - extern int stralloc_catulong0(stralloc *,unsigned long,unsigned int); - extern int stralloc_catlong0(stralloc *,long,unsigned int); - -+extern void stralloc_free(stralloc *); -+ - #define stralloc_catlong(sa,l) (stralloc_catlong0((sa),(l),0)) - #define stralloc_catuint0(sa,i,n) (stralloc_catulong0((sa),(i),(n))) - #define stralloc_catint0(sa,i,n) (stralloc_catlong0((sa),(i),(n))) -diff -uNr ucspi-tcp-0.88-stock/stralloc_catb.c ucspi-tcp-0.88/stralloc_catb.c ---- ucspi-tcp-0.88-stock/stralloc_catb.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/stralloc_catb.c Fri Sep 9 12:07:53 2005 -@@ -1,7 +1,7 @@ - #include "stralloc.h" - #include "byte.h" - --int stralloc_catb(stralloc *sa,char *s,unsigned int n) -+int stralloc_catb(stralloc *sa,const char *s,unsigned int n) - { - if (!sa->s) return stralloc_copyb(sa,s,n); - if (!stralloc_readyplus(sa,n + 1)) return 0; -diff -uNr ucspi-tcp-0.88-stock/stralloc_cats.c ucspi-tcp-0.88/stralloc_cats.c ---- ucspi-tcp-0.88-stock/stralloc_cats.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/stralloc_cats.c Fri Sep 9 12:07:53 2005 -@@ -2,7 +2,7 @@ - #include "str.h" - #include "stralloc.h" - --int stralloc_cats(stralloc *sa,char *s) -+int stralloc_cats(stralloc *sa,const char *s) - { - return stralloc_catb(sa,s,str_len(s)); - } -diff -uNr ucspi-tcp-0.88-stock/stralloc_opyb.c ucspi-tcp-0.88/stralloc_opyb.c ---- ucspi-tcp-0.88-stock/stralloc_opyb.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/stralloc_opyb.c Fri Sep 9 12:07:53 2005 -@@ -1,7 +1,7 @@ - #include "stralloc.h" - #include "byte.h" - --int stralloc_copyb(stralloc *sa,char *s,unsigned int n) -+int stralloc_copyb(stralloc *sa,const char *s,unsigned int n) - { - if (!stralloc_ready(sa,n + 1)) return 0; - byte_copy(sa->s,n,s); -diff -uNr ucspi-tcp-0.88-stock/stralloc_opys.c ucspi-tcp-0.88/stralloc_opys.c ---- ucspi-tcp-0.88-stock/stralloc_opys.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/stralloc_opys.c Fri Sep 9 12:07:53 2005 -@@ -2,7 +2,7 @@ - #include "str.h" - #include "stralloc.h" - --int stralloc_copys(stralloc *sa,char *s) -+int stralloc_copys(stralloc *sa,const char *s) - { - return stralloc_copyb(sa,s,str_len(s)); - } -diff -uNr ucspi-tcp-0.88-stock/tcp-environ.5 ucspi-tcp-0.88/tcp-environ.5 ---- ucspi-tcp-0.88-stock/tcp-environ.5 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/tcp-environ.5 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,66 @@ -+.TH tcp-environ 5 -+.SH NAME -+tcp-environ \- TCP-related environment variables -+.SH DESCRIPTION -+The following environment variables -+describe a TCP connection. -+They are set up by -+.BR tcp-env , -+.BR tcpclient , -+and -+.BR tcpserver . -+Note that -+.BR TCPLOCALHOST , -+.BR TCPREMOTEHOST , -+and -+.B TCPREMOTEINFO -+can contain arbitrary characters. -+.TP 5 -+PROTO -+The string -+.BR TCP . -+.TP 5 -+TCPLOCALHOST -+The domain name of the local host, -+with uppercase letters converted to lowercase. -+If there is no currently available domain name -+for the local IP address, -+.B TCPLOCALHOST -+is not set. -+.TP 5 -+TCPLOCALIP -+The IP address of the local host, in dotted-decimal form. -+.TP 5 -+TCPLOCALPORT -+The local TCP port number, in decimal. -+.TP 5 -+TCPREMOTEHOST -+The domain name of the remote host, -+with uppercase letters converted to lowercase. -+If there is no currently available domain name -+for the remote IP address, -+.B TCPREMOTEHOST -+is not set. -+.TP 5 -+TCPREMOTEINFO -+A connection-specific string, perhaps a username, -+supplied by the remote host -+via 931/1413/IDENT/TAP. -+If the remote host did not supply connection information, -+.B TCPREMOTEINFO -+is not set. -+.TP 5 -+TCPREMOTEIP -+The IP address of the remote host. -+.TP 5 -+TCPREMOTEPORT -+The remote TCP port number. -+.TP 5 -+TCPINTERFACE -+The interface name ("eth0") for IPv6 connections using link-local -+addresses. -+.SH "SEE ALSO" -+tcpclient(1), -+tcpserver(1), -+tcp-env(1), -+tcp(4) -diff -uNr ucspi-tcp-0.88-stock/tcpcat.1 ucspi-tcp-0.88/tcpcat.1 ---- ucspi-tcp-0.88-stock/tcpcat.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/tcpcat.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,20 @@ -+.TH tcpcat 1 -+.SH NAME -+tcpcat \- print data from a TCP port -+.SH SYNTAX -+.B tcpcat -+.I host -+.I port -+.SH DESCRIPTION -+.B tcpcat -+connects to -+.I port -+on -+.I host -+and prints any data it receives. -+ -+.B tcpcat -+can be used to transfer binary data. -+It does no conversions. -+.SH "SEE ALSO" -+tcpclient(1) -diff -uNr ucspi-tcp-0.88-stock/tcpclient.1 ucspi-tcp-0.88/tcpclient.1 ---- ucspi-tcp-0.88-stock/tcpclient.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/tcpclient.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,173 @@ -+.TH tcpclient 1 -+.SH NAME -+tcpclient \- create an outgoing TCP connection -+.SH SYNOPSIS -+.B tcpclient -+[ -+.B \-46hHrRdDqQv -+] -+[ -+.B \-i\fIlocalip -+] -+[ -+.B \-p\fIlocalport -+] -+[ -+.B \-T\fItimeoutconn -+] -+[ -+.B \-l\fIlocalname -+] -+[ -+.B \-t\fItimeoutinfo -+] -+[ -+.B \-I\fIinterface -+] -+.I host -+.I port -+.I program -+[ -+.I arg ... -+] -+.SH DESCRIPTION -+.B tcpclient -+attempts to connect to a TCP server. -+If it is successful, it runs -+.I program -+with the given arguments, -+with descriptor 6 reading from the network -+and descriptor 7 writing to the network. -+ -+The server's address is given by -+.I host -+and -+.IR port . -+.I host -+may be 0, referring to the local machine, -+or a dotted-decimal IP address, -+or a host name; -+if a host has several IP addresses, -+.B tcpclient -+tries each in turn. -+.I port -+may be a numeric port number -+or a port name. -+ -+.B tcpclient -+sets up several environment variables, -+as described in -+.B tcp-environ(5). -+.SH OPTIONS -+.TP -+.B \-i\fIlocalip -+Use -+.I localip -+as the IP address for the local side of the connection; -+quit if -+.I localip -+is not available. -+.TP -+.B \-p\fIlocalport -+Use -+.I localport -+as the port number for the local side of the connection; -+quit if -+.I localport -+is not available. -+.TP -+.B \-I\fIinterface -+Use -+.I interface -+as the local network interface. This is only defined for IPv6 sockets -+and needed if you use link-local IPv6 addresses. -+.TP -+.B \-T\fItimeoutconn -+Give up on the -+connection attempt -+after -+.I timeoutconn -+seconds. Default: 60. -+This timeout applies to each IP address tried. -+.TP -+.B \-d -+(Default.) -+Delay sending data for a fraction of a second whenever the -+remote host is responding slowly, -+to make better use of the network. -+.TP -+.B \-D -+Never delay sending data; -+enable TCP_NODELAY. -+This is appropriate for interactive connections. -+.TP -+.B \-q -+Quiet. -+Do not print any messages. -+.TP -+.B \-Q -+(Default.) -+Print error messages. -+.TP -+.B \-v -+Verbose. -+Print all available messages. -+.SH "DATA-GATHERING OPTIONS" -+.TP -+.B \-h -+(Default.) -+Look up the remote host name for -+.BR TCPREMOTEHOST . -+.TP -+.B \-H -+Do not look up the remote host name; -+unset -+.BR TCPREMOTEHOST . -+.TP -+.B \-l\fIlocalname -+Do not look up the local host name; -+use -+.I localname -+for -+.BR TCPLOCALHOST . -+.TP -+.B \-r -+(Default.) -+Attempt to obtain -+.B TCPREMOTEINFO -+from the remote host. -+.TP -+.B \-R -+Do not attempt to obtain -+.B TCPREMOTEINFO -+from the remote host. -+.TP -+.B \-t\fItimeoutinfo -+Give up on the -+.B TCPREMOTEINFO -+connection attempt -+after -+.I timeoutinfo -+seconds. Default: 26. -+.TP -+.B \-4 -+Fall back to IPv4 sockets. This is necessary for terminally broken -+systems like OpenBSD which will not let IPv6 sockets connect to -+V4-mapped IPv6 addresses. Please note that this also applies to DNS -+lookups, so you will have to use an DNS resolver with an IPv6 address to -+connect to IPv6 systems. Use \fBDNSCACHEIP\fR to set the DNS resolver -+IP dynamically. -+.TP -+.B \-6 -+Force IPv6 mode in UCSPI environment variables, even for -+IPv4 connections. This will set \fB$PROTO\fR to \fBTCP6\fR and put -+IPv4-mapped IPv6 addresses in \fBTCPLOCALIP\fR and \fBTCPREMOTEIP\fR. -+.SH "SEE ALSO" -+date@(1), -+finger@(1), -+http@(1), -+mconnect(1), -+tcpcat(1), -+tcpserver(1), -+who@(1), -+tcp-environ(5) -diff -uNr ucspi-tcp-0.88-stock/tcpclient.c ucspi-tcp-0.88/tcpclient.c ---- ucspi-tcp-0.88-stock/tcpclient.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/tcpclient.c Fri Sep 9 12:07:53 2005 -@@ -9,6 +9,7 @@ - #include "scan.h" - #include "str.h" - #include "ip4.h" -+#include "ip6.h" - #include "uint16.h" - #include "socket.h" - #include "fd.h" -@@ -20,6 +21,7 @@ - #include "timeoutconn.h" - #include "remoteinfo.h" - #include "dns.h" -+#include "byte.h" - - #define FATAL "tcpclient: fatal: " - #define CONNECT "tcpclient: unable to connect to " -@@ -31,27 +33,30 @@ - void usage(void) - { - strerr_die1x(100,"tcpclient: usage: tcpclient \ --[ -hHrRdDqQv ] \ -+[ -46hHrRdDqQv ] \ - [ -i localip ] \ - [ -p localport ] \ - [ -T timeoutconn ] \ - [ -l localname ] \ - [ -t timeoutinfo ] \ -+[ -I interface ] \ - host port program"); - } - -+int forcev6 = 0; - int verbosity = 1; - int flagdelay = 1; - int flagremoteinfo = 1; - int flagremotehost = 1; - unsigned long itimeout = 26; - unsigned long ctimeout[2] = { 2, 58 }; -+uint32 netif = 0; - --char iplocal[4] = { 0,0,0,0 }; -+char iplocal[16] = { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 }; - uint16 portlocal = 0; - char *forcelocal = 0; - --char ipremote[4]; -+char ipremote[16]; - uint16 portremote; - - char *hostname; -@@ -61,12 +66,13 @@ - static stralloc tmp; - static stralloc fqdn; - char strnum[FMT_ULONG]; --char ipstr[IP4_FMT]; -+char ipstr[IP6_FMT]; - - char seed[128]; - - main(int argc,char **argv) - { -+ int fakev4=0; - unsigned long u; - int opt; - char *x; -@@ -80,8 +86,10 @@ - close(7); - sig_ignore(sig_pipe); - -- while ((opt = getopt(argc,argv,"dDvqQhHrRi:p:t:T:l:")) != opteof) -+ while ((opt = getopt(argc,argv,"46dDvqQhHrRi:p:t:T:l:I:")) != opteof) - switch(opt) { -+ case '4': noipv6 = 1; break; -+ case '6': forcev6 = 1; break; - case 'd': flagdelay = 1; break; - case 'D': flagdelay = 0; break; - case 'v': verbosity = 2; break; -@@ -97,7 +105,8 @@ - if (optarg[j] == '+') ++j; - scan_ulong(optarg + j,&ctimeout[1]); - break; -- case 'i': if (!ip4_scan(optarg,iplocal)) usage(); break; -+ case 'i': if (!scan_ip6(optarg,iplocal)) usage(); break; -+ case 'I': netif=socket_getifidx(optarg); break; - case 'p': scan_ulong(optarg,&u); portlocal = u; break; - default: usage(); - } -@@ -108,8 +117,8 @@ - - hostname = *argv; - if (!hostname) usage(); -- if (str_equal(hostname,"")) hostname = "127.0.0.1"; -- if (str_equal(hostname,"0")) hostname = "127.0.0.1"; -+ if (!hostname[0] || str_equal(hostname,"0")) -+ hostname = (noipv6?"127.0.0.1":"::1"); - - x = *++argv; - if (!x) usage(); -@@ -127,33 +136,36 @@ - if (!*++argv) usage(); - - if (!stralloc_copys(&tmp,hostname)) nomem(); -- if (dns_ip4_qualify(&addresses,&fqdn,&tmp) == -1) -+ if (dns_ip6_qualify(&addresses,&fqdn,&tmp) == -1) - strerr_die4sys(111,FATAL,"temporarily unable to figure out IP address for ",hostname,": "); -- if (addresses.len < 4) -+ if (addresses.len < 16) - strerr_die3x(111,FATAL,"no IP address for ",hostname); - -- if (addresses.len == 4) { -+ if (addresses.len == 16) { - ctimeout[0] += ctimeout[1]; - ctimeout[1] = 0; - } - - for (cloop = 0;cloop < 2;++cloop) { - if (!stralloc_copys(&moreaddresses,"")) nomem(); -- for (j = 0;j + 4 <= addresses.len;j += 4) { -- s = socket_tcp(); -+ for (j = 0;j + 16 <= addresses.len;j += 4) { -+ s = socket_tcp6(); - if (s == -1) - strerr_die2sys(111,FATAL,"unable to create socket: "); -- if (socket_bind4(s,iplocal,portlocal) == -1) -+ if (socket_bind6(s,iplocal,portlocal,netif) == -1) - strerr_die2sys(111,FATAL,"unable to bind socket: "); -- if (timeoutconn(s,addresses.s + j,portremote,ctimeout[cloop]) == 0) -+ if (timeoutconn6(s,addresses.s + j,portremote,ctimeout[cloop],netif) == 0) - goto CONNECTED; - close(s); - if (!cloop && ctimeout[1] && (errno == error_timeout)) { -- if (!stralloc_catb(&moreaddresses,addresses.s + j,4)) nomem(); -+ if (!stralloc_catb(&moreaddresses,addresses.s + j,16)) nomem(); - } - else { - strnum[fmt_ulong(strnum,portremote)] = 0; -- ipstr[ip4_fmt(ipstr,addresses.s + j)] = 0; -+ if (ip6_isv4mapped(addresses.s+j)) -+ ipstr[ip4_fmt(ipstr,addresses.s + j + 12)] = 0; -+ else -+ ipstr[ip6_fmt(ipstr,addresses.s + j)] = 0; - strerr_warn5(CONNECT,ipstr," port ",strnum,": ",&strerr_sys); - } - } -@@ -169,37 +181,46 @@ - if (!flagdelay) - socket_tcpnodelay(s); /* if it fails, bummer */ - -- if (!pathexec_env("PROTO","TCP")) nomem(); -- -- if (socket_local4(s,iplocal,&portlocal) == -1) -+ if (socket_local6(s,iplocal,&portlocal,&netif) == -1) - strerr_die2sys(111,FATAL,"unable to get local address: "); - -+ if (!forcev6 && (ip6_isv4mapped(iplocal) || byte_equal(iplocal,16,V6any))) -+ fakev4=1; -+ -+ if (!pathexec_env("PROTO",fakev4?"TCP":"TCP6")) nomem(); -+ - strnum[fmt_ulong(strnum,portlocal)] = 0; - if (!pathexec_env("TCPLOCALPORT",strnum)) nomem(); -- ipstr[ip4_fmt(ipstr,iplocal)] = 0; -+ if (fakev4) -+ ipstr[ip4_fmt(ipstr,iplocal+12)] = 0; -+ else -+ ipstr[ip6_fmt(ipstr,iplocal)] = 0; - if (!pathexec_env("TCPLOCALIP",ipstr)) nomem(); - - x = forcelocal; - if (!x) -- if (dns_name4(&tmp,iplocal) == 0) { -+ if (dns_name6(&tmp,iplocal) == 0) { - if (!stralloc_0(&tmp)) nomem(); - x = tmp.s; - } - if (!pathexec_env("TCPLOCALHOST",x)) nomem(); - -- if (socket_remote4(s,ipremote,&portremote) == -1) -+ if (socket_remote6(s,ipremote,&portremote,&netif) == -1) - strerr_die2sys(111,FATAL,"unable to get remote address: "); - - strnum[fmt_ulong(strnum,portremote)] = 0; - if (!pathexec_env("TCPREMOTEPORT",strnum)) nomem(); -- ipstr[ip4_fmt(ipstr,ipremote)] = 0; -+ if (fakev4) -+ ipstr[ip4_fmt(ipstr,ipremote+12)] = 0; -+ else -+ ipstr[ip6_fmt(ipstr,ipremote)] = 0; - if (!pathexec_env("TCPREMOTEIP",ipstr)) nomem(); - if (verbosity >= 2) - strerr_warn4("tcpclient: connected to ",ipstr," port ",strnum,0); - - x = 0; - if (flagremotehost) -- if (dns_name4(&tmp,ipremote) == 0) { -+ if (dns_name6(&tmp,ipremote) == 0) { - if (!stralloc_0(&tmp)) nomem(); - x = tmp.s; - } -@@ -207,7 +228,7 @@ - - x = 0; - if (flagremoteinfo) -- if (remoteinfo(&tmp,ipremote,portremote,iplocal,portlocal,itimeout) == 0) { -+ if (remoteinfo6(&tmp,ipremote,portremote,iplocal,portlocal,itimeout,netif) == 0) { - if (!stralloc_0(&tmp)) nomem(); - x = tmp.s; - } -diff -uNr ucspi-tcp-0.88-stock/tcprules.1 ucspi-tcp-0.88/tcprules.1 ---- ucspi-tcp-0.88-stock/tcprules.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/tcprules.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,221 @@ -+.TH tcprules 1 -+.SH NAME -+tcprules \- compile rules for tcpserver -+.SH SYNOPSIS -+.B tcprules -+.I rules.cdb -+.I rules.tmp -+.SH OVERVIEW -+.B tcpserver -+optionally follows rules to decide whether a TCP connection is acceptable. -+For example, a rule of -+ -+.EX -+ 18.23.0.32:deny -+.EE -+ -+prohibits connections from IP address 18.23.0.32. -+ -+.B tcprules -+reads rules from its standard input -+and writes them into -+.I rules.cdb -+in a binary format suited -+for quick access by -+.BR tcpserver . -+ -+.B tcprules -+can be used while -+.B tcpserver -+is running: -+it ensures that -+.I rules.cdb -+is updated atomically. -+It does this by first writing the rules to -+.I rules.tmp -+and then moving -+.I rules.tmp -+on top of -+.IR rules.cdb . -+If -+.I rules.tmp -+already exists, it is destroyed. -+The directories containing -+.I rules.cdb -+and -+.I rules.tmp -+must be writable to -+.BR tcprules ; -+they must also be on the same filesystem. -+ -+If there is a problem with the input, -+.B tcprules -+complains and leaves -+.I rules.cdb -+alone. -+ -+The binary -+.I rules.cdb -+format is portable across machines. -+.SH "RULE FORMAT" -+A rule takes up one line. -+A file containing rules -+may also contain comments: lines beginning with # are ignored. -+ -+Each rule contains an -+.BR address , -+a colon, -+and a list of -+.BR instructions , -+with no extra spaces. -+When -+.B tcpserver -+receives a connection from that address, -+it follows the instructions. -+.SH "ADDRESSES" -+.B tcpserver -+starts by looking for a rule with address -+.IR TCPREMOTEINFO\fB@\fITCPREMOTEIP . -+If it doesn't find one, or if -+.I TCPREMOTEINFO -+is not set, it tries the address -+.IR TCPREMOTEIP . -+If that doesn't work, it tries shorter and shorter prefixes of -+.I TCPREMOTEIP -+ending with a dot. -+If none of them work, it tries the empty string. -+ -+For example, here are some rules: -+ -+.EX -+ joe@127.0.0.1:first -+.br -+ 18.23.0.32:second -+.br -+ 127.:third -+.br -+ :fourth -+.br -+ ::1:fifth -+.EE -+ -+If -+.I TCPREMOTEIP -+is -+.BR 10.119.75.38 , -+.B tcpserver -+will follow the -+.B fourth -+instructions. -+ -+If -+.I TCPREMOTEIP -+is -+.BR ::1 , -+.B tcpserver -+will follow the -+.B fifth -+instructions. Note that you cannot detect IPv4 mapped addresses by -+matching "::ffff", as those addresses will be converted to IPv4 before -+looking at the rules. -+ -+If -+.I TCPREMOTEIP -+is -+.BR 18.23.0.32 , -+.B tcpserver -+will follow the -+.B second -+instructions. -+ -+If -+.I TCPREMOTEINFO -+is -+.B bill -+and -+.I TCPREMOTEIP -+is -+.BR 127.0.0.1 , -+.B tcpserver -+will follow the -+.B third -+instructions. -+ -+If -+.I TCPREMOTEINFO -+is -+.B joe -+and -+.I TCPREMOTEIP -+is -+.BR 127.0.0.1 , -+.B tcpserver -+will follow the -+.B first -+instructions. -+.SH "ADDRESS RANGES" -+.B tcprules -+treats -+.B 1.2.3.37-53:ins -+as an abbreviation -+for the rules -+.BR 1.2.3.37:ins , -+.BR 1.2.3.38:ins , -+and so on up through -+.BR 1.2.3.53:ins . -+Similarly, -+.BR 10.2-3.:ins -+is an abbreviation for -+.B 10.2.:ins -+and -+.BR 10.3.:ins . -+.SH "INSTRUCTIONS" -+The instructions in a rule must begin with either -+.B allow -+or -+.BR deny . -+.B deny -+tells -+.B tcpserver -+to drop the connection without running anything. -+For example, the rule -+ -+.EX -+ :deny -+.EE -+ -+tells -+.B tcpserver -+to drop all connections that aren't handled by more specific rules. -+ -+The instructions may continue with some environment variables, -+in the format -+.IR ,VAR="VALUE" . -+.B tcpserver -+adds -+.I VAR=VALUE -+to the current environment. -+For example, -+ -+.EX -+ 10.0.:allow,RELAYCLIENT="@fix.me" -+.EE -+ -+adds -+.B RELAYCLIENT=@fix.me -+to the environment. -+The quotes here may be replaced by any repeated character: -+ -+.EX -+ 10.0.:allow,RELAYCLIENT=/@fix.me/ -+.EE -+ -+Any number of variables may be listed: -+ -+.EX -+ 127.0.0.1:allow,RELAYCLIENT="",TCPLOCALHOST="movie.edu" -+.EE -+.SH "SEE ALSO" -+tcprulescheck(1), -+tcpserver(1), -+tcp-environ(5) -diff -uNr ucspi-tcp-0.88-stock/tcprules.c ucspi-tcp-0.88/tcprules.c ---- ucspi-tcp-0.88-stock/tcprules.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/tcprules.c Fri Sep 9 12:07:53 2005 -@@ -123,8 +123,15 @@ - } - line.len = len; /* for die_bad() */ - -- colon = byte_chr(x,len,':'); -- if (colon == len) continue; -+ colon = 0; -+ for (;;) { -+ int tmp; -+ tmp = byte_chr(x + colon,len - colon,':'); -+ colon += tmp; -+ if (colon == len) continue; -+ if (byte_equal(x+colon+1,4,"deny") || byte_equal(x+colon+1,5,"allow")) break; -+ ++colon; -+ } - - if (!stralloc_copyb(&address,x,colon)) nomem(); - if (!stralloc_copys(&data,"")) nomem(); -diff -uNr ucspi-tcp-0.88-stock/tcprulescheck.1 ucspi-tcp-0.88/tcprulescheck.1 ---- ucspi-tcp-0.88-stock/tcprulescheck.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/tcprulescheck.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,25 @@ -+.TH tcprulescheck 1 -+.SH NAME -+tcprulescheck \- try out rules for tcpserver -+.SH SYNTAX -+.B tcprulescheck -+.I rules.cdb -+.I tcpremoteip -+[ -+.I tcpremoteinfo -+] -+.SH DESCRIPTION -+.B tcprulescheck -+says what -+.B tcpserver -+will do with a connection from -+IP address -+.IR tcpremoteip , -+following the rules compiled into -+.I rules.cdb -+by -+.BR tcprules . -+.SH "SEE ALSO" -+tcprules(1), -+tcpserver(1), -+tcp-environ(5) -diff -uNr ucspi-tcp-0.88-stock/tcpserver.1 ucspi-tcp-0.88/tcpserver.1 ---- ucspi-tcp-0.88-stock/tcpserver.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/tcpserver.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,266 @@ -+.TH tcpserver 1 -+.SH NAME -+tcpserver \- accept incoming TCP connections -+.SH SYNOPSIS -+.B tcpserver -+[ -+.B \-146jpPhHrRoOdDqQv -+] -+[ -+.B \-c\fIlimit -+] -+[ -+.B \-x\fIrules.cdb -+] -+[ -+.B \-B\fIbanner -+] -+[ -+.B \-g\fIgid -+] -+[ -+.B \-u\fIuid -+] -+[ -+.B \-b\fIbacklog -+] -+[ -+.B \-l\fIlocalname -+] -+[ -+.B \-t\fItimeout -+] -+[ -+.B \-I\fIinterface -+] -+.I host -+.I port -+.I program -+[ -+.I arg ... -+] -+.SH DESCRIPTION -+.B tcpserver -+waits for connections from TCP clients. -+For each connection, it runs -+.I program -+with the given arguments, -+with descriptor 0 reading from the network -+and descriptor 1 writing to the network. -+ -+The server's address is given by -+.I host -+and -+.IR port . -+.I host -+can be 0, allowing connections from any host; -+or a particular IP address, -+allowing connections only to that address; -+or a host name, allowing connections to the first IP address -+for that host. -+.I port -+may be a numeric port number -+or a port name. -+If -+.I port -+is 0, -+.B tcpserver -+will choose a free port. -+ -+.B tcpserver -+sets up several environment variables, -+as described in -+.B tcp-environ(5). -+ -+.B tcpserver -+exits when it receives SIGTERM. -+.SH "OPTIONS" -+.TP -+.B \-c\fIlimit -+Do not handle more than -+.I limit -+simultaneous connections. -+If there are -+.I limit -+simultaneous copies of -+.I program -+running, defer acceptance of a new connection -+until one copy finishes. -+.I limit -+must be a positive integer. -+Default: 40. -+.TP -+.B \-x\fIrules.cdb -+Follow the rules compiled into -+.I rules.cdb -+by -+.BR tcprules . -+These rules may specify setting environment variables -+or rejecting connections from bad sources. -+ -+.B tcpserver -+does not read -+.I rules.cdb -+into memory; -+you can rerun -+.B tcprules -+to change -+.BR tcpserver 's -+behavior on the fly. -+.TP -+.B \-B\fIbanner -+Write -+.I banner -+to the network immediately after each connection is made. -+.B tcpserver -+writes -+.I banner -+before looking up -+.BR TCPREMOTEHOST , -+before looking up -+.BR TCPREMOTEINFO , -+and before checking -+.IR rules.cdb . -+ -+This feature can be used to reduce latency in protocols -+where the client waits for a greeting from the server. -+.TP -+.B \-g\fIgid -+Switch group ID to -+.I gid -+after preparing to receive connections. -+.I gid -+must be a positive integer. -+.TP -+.B \-u\fIuid -+Switch user ID to -+.I uid -+after preparing to receive connections. -+.I uid -+must be a positive integer. -+.TP -+.B \-1 -+After preparing to receive connections, -+print the local port number to standard output. -+.TP -+.B \-4 -+Fall back to IPv4 sockets. This is necessary for terminally broken -+systems like OpenBSD which will not let IPv6 sockets connect to -+V4-mapped IPv6 addresses. Please note that this also applies to DNS -+lookups, so you will have to use an DNS resolver with an IPv6 address to -+accept IPv6 connections. Use \fBDNSCACHEIP\fR to set the DNS resolver -+IP dynamically. -+.TP -+.B \-6 -+Force IPv6 mode in UCSPI environment variables, even for -+IPv4 connections. This will set \fB$PROTO\fR to \fBTCP6\fR and put -+IPv4-mapped IPv6 addresses in \fBTCPLOCALIP\fR and \fBTCPREMOTEIP\fR. -+.TP -+.B \-I\fIinterface -+Bind to the network interface -+.I interface -+("eth0" on Linux, for example). This is only defined and needed for -+IPv6 link-local addresses. -+.TP -+.B \-b\fIbacklog -+Allow up to -+.I backlog -+simultaneous SYN_RECEIVEDs. -+Default: 20. -+On some systems, -+.I backlog -+is silently limited to 5. -+See -+.BR listen (2) -+for more details. -+.TP -+.B \-o -+Leave IP options alone. -+If the client is sending packets along an IP source route, -+send packets back along the same route. -+.TP -+.B \-O -+(Default.) -+Kill IP options. -+A client can still use source routing to connect and to send data, -+but packets will be sent back along the default route. -+.TP -+.B \-d -+(Default.) -+Delay sending data for a fraction of a second whenever the -+remote host is responding slowly, -+to make better use of the network. -+.TP -+.B \-D -+Never delay sending data; -+enable TCP_NODELAY. -+This is appropriate for interactive connections. -+.TP -+.B \-q -+Quiet. -+Do not print any messages. -+.TP -+.B \-Q -+(Default.) -+Print error messages. -+.TP -+.B \-v -+Verbose. -+Print all available messages. -+.SH "DATA-GATHERING OPTIONS" -+.TP -+.B \-p -+Paranoid. -+After looking up the remote host name, -+look up the IP addresses for that name, -+and make sure one of them matches -+.BR TCPREMOTEIP . -+If none of them do, -+unset -+.BR TCPREMOTEHOST . -+.TP -+.B \-P -+(Default.) -+Not paranoid. -+.TP -+.B \-h -+(Default.) -+Look up the remote host name and set -+.BR TCPREMOTEHOST . -+.TP -+.B \-H -+Do not look up the remote host name. -+.TP -+.B \-l\fIlocalname -+Do not look up the local host name; -+use -+.I localname -+for -+.BR TCPLOCALHOST . -+.TP -+.B \-r -+(Default.) -+Attempt to obtain -+.B TCPREMOTEINFO -+from the remote host. -+.TP -+.B \-R -+Do not attempt to obtain -+.B TCPREMOTEINFO -+from the remote host. -+.TP -+.B \-t\fItimeout -+Give up on the -+.B TCPREMOTEINFO -+connection attempt -+after -+.I timeout -+seconds. Default: 26. -+.SH "SEE ALSO" -+argv0(1), -+fixcr(1), -+recordio(1), -+tcpclient(1), -+tcprules(1), -+listen(2), -+tcp-environ(5) -diff -uNr ucspi-tcp-0.88-stock/tcpserver.c ucspi-tcp-0.88/tcpserver.c ---- ucspi-tcp-0.88-stock/tcpserver.c Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/tcpserver.c Fri Sep 9 12:07:53 2005 -@@ -7,6 +7,7 @@ - #include "fmt.h" - #include "scan.h" - #include "ip4.h" -+#include "ip6.h" - #include "fd.h" - #include "exit.h" - #include "env.h" -@@ -28,6 +29,7 @@ - #include "sig.h" - #include "dns.h" - -+int forcev6 = 0; - int verbosity = 1; - int flagkillopts = 1; - int flagdelay = 1; -@@ -36,20 +38,21 @@ - int flagremotehost = 1; - int flagparanoid = 0; - unsigned long timeout = 26; -+uint32 netif = 0; - - static stralloc tcpremoteinfo; - - uint16 localport; - char localportstr[FMT_ULONG]; --char localip[4]; --char localipstr[IP4_FMT]; -+char localip[16]; -+char localipstr[IP6_FMT]; - static stralloc localhostsa; - char *localhost = 0; - - uint16 remoteport; - char remoteportstr[FMT_ULONG]; --char remoteip[4]; --char remoteipstr[IP4_FMT]; -+char remoteip[16]; -+char remoteipstr[IP6_FMT]; - static stralloc remotehostsa; - char *remotehost = 0; - -@@ -96,12 +99,12 @@ - if (ch < 33) ch = '?'; - if (ch > 126) ch = '?'; - if (ch == '%') ch = '?'; /* logger stupidity */ -- if (ch == ':') ch = '?'; -+/* if (ch == ':') ch = '?'; */ - append(&ch); - } - cats("..."); - } --void env(char *s,char *t) -+void env(const char *s,const char *t) - { - if (!pathexec_env(s,t)) drop_nomem(); - } -@@ -135,9 +138,16 @@ - - void doit(int t) - { -+ int fakev4=0; - int j; -+ uint32 scope_id; - -- remoteipstr[ip4_fmt(remoteipstr,remoteip)] = 0; -+ if (!forcev6 && ip6_isv4mapped(remoteip)) -+ fakev4=1; -+ if (fakev4) -+ remoteipstr[ip4_fmt(remoteipstr,remoteip+12)] = 0; -+ else -+ remoteipstr[ip6_fmt(remoteipstr,remoteip)] = 0; - - if (verbosity >= 2) { - strnum[fmt_ulong(strnum,getpid())] = 0; -@@ -155,30 +165,40 @@ - strerr_die2sys(111,DROP,"unable to print banner: "); - } - -- if (socket_local4(t,localip,&localport) == -1) -+ if (socket_local6(t,localip,&localport,&scope_id) == -1) - strerr_die2sys(111,DROP,"unable to get local address: "); - -- localipstr[ip4_fmt(localipstr,localip)] = 0; -+ if (fakev4) -+ localipstr[ip4_fmt(localipstr,localip+12)] = 0; -+ else -+ localipstr[ip6_fmt(localipstr,localip)] = 0; - remoteportstr[fmt_ulong(remoteportstr,remoteport)] = 0; - - if (!localhost) -- if (dns_name4(&localhostsa,localip) == 0) -+ if (dns_name6(&localhostsa,localip) == 0) - if (localhostsa.len) { - if (!stralloc_0(&localhostsa)) drop_nomem(); - localhost = localhostsa.s; - } -- env("PROTO","TCP"); -+ env("PROTO",fakev4?"TCP":"TCP6"); - env("TCPLOCALIP",localipstr); -+ localipstr[ip6_fmt(localipstr,localip)]=0; -+ env("TCP6LOCALIP",localipstr); -+ - env("TCPLOCALPORT",localportstr); -+ env("TCP6LOCALPORT",localportstr); - env("TCPLOCALHOST",localhost); -+ env("TCP6LOCALHOST",localhost); -+ if (!fakev4 && scope_id) -+ env("TCP6INTERFACE",socket_getifname(scope_id)); - - if (flagremotehost) -- if (dns_name4(&remotehostsa,remoteip) == 0) -+ if (dns_name6(&remotehostsa,remoteip) == 0) - if (remotehostsa.len) { - if (flagparanoid) -- if (dns_ip4(&tmp,&remotehostsa) == 0) -- for (j = 0;j + 4 <= tmp.len;j += 4) -- if (byte_equal(remoteip,4,tmp.s + j)) { -+ if (dns_ip6(&tmp,&remotehostsa) == 0) -+ for (j = 0;j + 16 <= tmp.len;j += 16) -+ if (byte_equal(remoteip,16,tmp.s + j)) { - flagparanoid = 0; - break; - } -@@ -188,15 +208,20 @@ - } - } - env("TCPREMOTEIP",remoteipstr); -+ remoteipstr[ip6_fmt(remoteipstr,remoteip)]=0; -+ env("TCP6REMOTEIP",remoteipstr); - env("TCPREMOTEPORT",remoteportstr); -+ env("TCP6REMOTEPORT",remoteportstr); - env("TCPREMOTEHOST",remotehost); -+ env("TCP6REMOTEHOST",remotehost); - - if (flagremoteinfo) { -- if (remoteinfo(&tcpremoteinfo,remoteip,remoteport,localip,localport,timeout) == -1) -+ if (remoteinfo6(&tcpremoteinfo,remoteip,remoteport,localip,localport,timeout,netif) == -1) - flagremoteinfo = 0; - if (!stralloc_0(&tcpremoteinfo)) drop_nomem(); - } - env("TCPREMOTEINFO",flagremoteinfo ? tcpremoteinfo.s : 0); -+ env("TCP6REMOTEINFO",flagremoteinfo ? tcpremoteinfo.s : 0); - - if (fnrules) { - int fdrules; -@@ -206,7 +231,15 @@ - if (!flagallownorules) drop_rules(); - } - else { -- if (rules(found,fdrules,remoteipstr,remotehost,flagremoteinfo ? tcpremoteinfo.s : 0) == -1) drop_rules(); -+ int fakev4=0; -+ char* temp; -+ if (!forcev6 && ip6_isv4mapped(remoteip)) -+ fakev4=1; -+ if (fakev4) -+ temp=remoteipstr+7; -+ else -+ temp=remoteipstr; -+ if (rules(found,fdrules,temp,remotehost,flagremoteinfo ? tcpremoteinfo.s : 0) == -1) drop_rules(); - close(fdrules); - } - } -@@ -240,7 +273,7 @@ - { - strerr_warn1("\ - tcpserver: usage: tcpserver \ --[ -1UXpPhHrRoOdDqQv ] \ -+[ -461UXpPhHrRoOdDqQv ] \ - [ -c limit ] \ - [ -x rules.cdb ] \ - [ -B banner ] \ -@@ -249,6 +282,7 @@ - [ -b backlog ] \ - [ -l localname ] \ - [ -t timeout ] \ -+[ -I interface ] \ - host port program",0); - _exit(100); - } -@@ -299,8 +333,8 @@ - unsigned long u; - int s; - int t; -- -- while ((opt = getopt(argc,argv,"dDvqQhHrR1UXx:t:u:g:l:b:B:c:pPoO")) != opteof) -+ -+ while ((opt = getopt(argc,argv,"46dDvqQhHrR1UXx:t:u:g:l:b:B:c:I:pPoO")) != opteof) - switch(opt) { - case 'b': scan_ulong(optarg,&backlog); break; - case 'c': scan_ulong(optarg,&limit); break; -@@ -325,7 +359,10 @@ - x = env_get("GID"); if (x) scan_ulong(x,&gid); break; - case 'u': scan_ulong(optarg,&uid); break; - case 'g': scan_ulong(optarg,&gid); break; -+ case 'I': netif=socket_getifidx(optarg); break; - case '1': flag1 = 1; break; -+ case '4': noipv6 = 1; break; -+ case '6': forcev6 = 1; break; - case 'l': localhost = optarg; break; - default: usage(); - } -@@ -337,8 +374,7 @@ - - hostname = *argv++; - if (!hostname) usage(); -- if (str_equal(hostname,"")) hostname = "0.0.0.0"; -- if (str_equal(hostname,"0")) hostname = "0.0.0.0"; -+ if (str_equal(hostname,"")) hostname = "0"; - - x = *argv++; - if (!x) usage(); -@@ -348,7 +384,7 @@ - se = getservbyname(x,"tcp"); - if (!se) - strerr_die3x(111,FATAL,"unable to figure out port number for ",x); -- localport = ntohs(se->s_port); -+ uint16_unpack_big((char*)&se->s_port,&localport); - } - - if (!*argv) usage(); -@@ -358,20 +394,26 @@ - sig_catch(sig_term,sigterm); - sig_ignore(sig_pipe); - -- if (!stralloc_copys(&tmp,hostname)) -- strerr_die2x(111,FATAL,"out of memory"); -- if (dns_ip4_qualify(&addresses,&fqdn,&tmp) == -1) -- strerr_die4sys(111,FATAL,"temporarily unable to figure out IP address for ",hostname,": "); -- if (addresses.len < 4) -- strerr_die3x(111,FATAL,"no IP address for ",hostname); -- byte_copy(localip,4,addresses.s); -+ if (str_equal(hostname,"0")) { -+ byte_zero(localip,sizeof localip); -+ } else { -+ if (!stralloc_copys(&tmp,hostname)) -+ strerr_die2x(111,FATAL,"out of memory"); -+ if (dns_ip6_qualify(&addresses,&fqdn,&tmp) == -1) -+ strerr_die4sys(111,FATAL,"temporarily unable to figure out IP address for ",hostname,": "); -+ if (addresses.len < 16) -+ strerr_die3x(111,FATAL,"no IP address for ",hostname); -+ byte_copy(localip,16,addresses.s); -+ if (ip6_isv4mapped(localip)) -+ noipv6=1; -+ } - -- s = socket_tcp(); -+ s = socket_tcp6(); - if (s == -1) - strerr_die2sys(111,FATAL,"unable to create socket: "); -- if (socket_bind4_reuse(s,localip,localport) == -1) -+ if (socket_bind6_reuse(s,localip,localport,netif) == -1) - strerr_die2sys(111,FATAL,"unable to bind: "); -- if (socket_local4(s,localip,&localport) == -1) -+ if (socket_local6(s,localip,&localport,&netif) == -1) - strerr_die2sys(111,FATAL,"unable to get local address: "); - if (socket_listen(s,backlog) == -1) - strerr_die2sys(111,FATAL,"unable to listen: "); -@@ -399,7 +441,7 @@ - while (numchildren >= limit) sig_pause(); - - sig_unblock(sig_child); -- t = socket_accept4(s,remoteip,&remoteport); -+ t = socket_accept6(s,remoteip,&remoteport,&netif); - sig_block(sig_child); - - if (t == -1) continue; -diff -uNr ucspi-tcp-0.88-stock/timeoutconn.h ucspi-tcp-0.88/timeoutconn.h ---- ucspi-tcp-0.88-stock/timeoutconn.h Sat Mar 18 16:18:42 2000 -+++ ucspi-tcp-0.88/timeoutconn.h Fri Sep 9 12:07:53 2005 -@@ -2,7 +2,9 @@ - #define TIMEOUTCONN_H - - #include "uint16.h" -+#include "uint32.h" - - extern int timeoutconn(int,char *,uint16,unsigned int); -+extern int timeoutconn6(int,char *,uint16,unsigned int,uint32); - - #endif -diff -uNr ucspi-tcp-0.88-stock/timeoutconn6.c ucspi-tcp-0.88/timeoutconn6.c ---- ucspi-tcp-0.88-stock/timeoutconn6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/timeoutconn6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,34 @@ -+#include "ndelay.h" -+#include "socket.h" -+#include "iopause.h" -+#include "error.h" -+#include "timeoutconn.h" -+ -+int timeoutconn6(int s,char ip[16],uint16 port,unsigned int timeout,uint32 netif) -+{ -+ struct taia now; -+ struct taia deadline; -+ iopause_fd x; -+ -+ if (socket_connect6(s,ip,port,netif) == -1) { -+ if ((errno != error_wouldblock) && (errno != error_inprogress)) return -1; -+ x.fd = s; -+ x.events = IOPAUSE_WRITE; -+ taia_now(&now); -+ taia_uint(&deadline,timeout); -+ taia_add(&deadline,&now,&deadline); -+ for (;;) { -+ taia_now(&now); -+ iopause(&x,1,&deadline,&now); -+ if (x.revents) break; -+ if (taia_less(&deadline,&now)) { -+ errno = error_timeout; /* note that connect attempt is continuing */ -+ return -1; -+ } -+ } -+ if (!socket_connected(s)) return -1; -+ } -+ -+ if (ndelay_off(s) == -1) return -1; -+ return 0; -+} -diff -uNr ucspi-tcp-0.88-stock/tryip6.c ucspi-tcp-0.88/tryip6.c ---- ucspi-tcp-0.88-stock/tryip6.c Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/tryip6.c Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,8 @@ -+#include <sys/types.h> -+#include <sys/socket.h> -+#include <netinet/in.h> -+ -+main() { -+ struct sockaddr_in6 sa; -+ sa.sin6_family = PF_INET6; -+} -diff -uNr ucspi-tcp-0.88-stock/usr/local/man/man1/tcpclient.1 ucspi-tcp-0.88/usr/local/man/man1/tcpclient.1 ---- ucspi-tcp-0.88-stock/usr/local/man/man1/tcpclient.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/usr/local/man/man1/tcpclient.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,173 @@ -+.TH tcpclient 1 -+.SH NAME -+tcpclient \- create an outgoing TCP connection -+.SH SYNOPSIS -+.B tcpclient -+[ -+.B \-46hHrRdDqQv -+] -+[ -+.B \-i\fIlocalip -+] -+[ -+.B \-p\fIlocalport -+] -+[ -+.B \-T\fItimeoutconn -+] -+[ -+.B \-l\fIlocalname -+] -+[ -+.B \-t\fItimeoutinfo -+] -+[ -+.B \-I\fIinterface -+] -+.I host -+.I port -+.I program -+[ -+.I arg ... -+] -+.SH DESCRIPTION -+.B tcpclient -+attempts to connect to a TCP server. -+If it is successful, it runs -+.I program -+with the given arguments, -+with descriptor 6 reading from the network -+and descriptor 7 writing to the network. -+ -+The server's address is given by -+.I host -+and -+.IR port . -+.I host -+may be 0, referring to the local machine, -+or a dotted-decimal IP address, -+or a host name; -+if a host has several IP addresses, -+.B tcpclient -+tries each in turn. -+.I port -+may be a numeric port number -+or a port name. -+ -+.B tcpclient -+sets up several environment variables, -+as described in -+.B tcp-environ(5). -+.SH OPTIONS -+.TP -+.B \-i\fIlocalip -+Use -+.I localip -+as the IP address for the local side of the connection; -+quit if -+.I localip -+is not available. -+.TP -+.B \-p\fIlocalport -+Use -+.I localport -+as the port number for the local side of the connection; -+quit if -+.I localport -+is not available. -+.TP -+.B \-I\fIinterface -+Use -+.I interface -+as the local network interface. This is only defined for IPv6 sockets -+and needed if you use link-local IPv6 addresses. -+.TP -+.B \-T\fItimeoutconn -+Give up on the -+connection attempt -+after -+.I timeoutconn -+seconds. Default: 60. -+This timeout applies to each IP address tried. -+.TP -+.B \-d -+(Default.) -+Delay sending data for a fraction of a second whenever the -+remote host is responding slowly, -+to make better use of the network. -+.TP -+.B \-D -+Never delay sending data; -+enable TCP_NODELAY. -+This is appropriate for interactive connections. -+.TP -+.B \-q -+Quiet. -+Do not print any messages. -+.TP -+.B \-Q -+(Default.) -+Print error messages. -+.TP -+.B \-v -+Verbose. -+Print all available messages. -+.SH "DATA-GATHERING OPTIONS" -+.TP -+.B \-h -+(Default.) -+Look up the remote host name for -+.BR TCPREMOTEHOST . -+.TP -+.B \-H -+Do not look up the remote host name; -+unset -+.BR TCPREMOTEHOST . -+.TP -+.B \-l\fIlocalname -+Do not look up the local host name; -+use -+.I localname -+for -+.BR TCPLOCALHOST . -+.TP -+.B \-r -+(Default.) -+Attempt to obtain -+.B TCPREMOTEINFO -+from the remote host. -+.TP -+.B \-R -+Do not attempt to obtain -+.B TCPREMOTEINFO -+from the remote host. -+.TP -+.B \-t\fItimeoutinfo -+Give up on the -+.B TCPREMOTEINFO -+connection attempt -+after -+.I timeoutinfo -+seconds. Default: 26. -+.TP -+.B \-4 -+Fall back to IPv4 sockets. This is necessary for terminally broken -+systems like OpenBSD which will not let IPv6 sockets connect to -+V4-mapped IPv6 addresses. Please note that this also applies to DNS -+lookups, so you will have to use an DNS resolver with an IPv6 address to -+connect to IPv6 systems. Use \fBDNSCACHEIP\fR to set the DNS resolver -+IP dynamically. -+.TP -+.B \-6 -+Force IPv6 mode in UCSPI environment variables, even for -+IPv4 connections. This will set \fB$PROTO\fR to \fBTCP6\fR and put -+IPv4-mapped IPv6 addresses in \fBTCPLOCALIP\fR and \fBTCPREMOTEIP\fR. -+.SH "SEE ALSO" -+date@(1), -+finger@(1), -+http@(1), -+mconnect(1), -+tcpcat(1), -+tcpserver(1), -+who@(1), -+tcp-environ(5) -diff -uNr ucspi-tcp-0.88-stock/usr/local/man/man1/tcpserver.1 ucspi-tcp-0.88/usr/local/man/man1/tcpserver.1 ---- ucspi-tcp-0.88-stock/usr/local/man/man1/tcpserver.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/usr/local/man/man1/tcpserver.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,266 @@ -+.TH tcpserver 1 -+.SH NAME -+tcpserver \- accept incoming TCP connections -+.SH SYNOPSIS -+.B tcpserver -+[ -+.B \-146jpPhHrRoOdDqQv -+] -+[ -+.B \-c\fIlimit -+] -+[ -+.B \-x\fIrules.cdb -+] -+[ -+.B \-B\fIbanner -+] -+[ -+.B \-g\fIgid -+] -+[ -+.B \-u\fIuid -+] -+[ -+.B \-b\fIbacklog -+] -+[ -+.B \-l\fIlocalname -+] -+[ -+.B \-t\fItimeout -+] -+[ -+.B \-I\fIinterface -+] -+.I host -+.I port -+.I program -+[ -+.I arg ... -+] -+.SH DESCRIPTION -+.B tcpserver -+waits for connections from TCP clients. -+For each connection, it runs -+.I program -+with the given arguments, -+with descriptor 0 reading from the network -+and descriptor 1 writing to the network. -+ -+The server's address is given by -+.I host -+and -+.IR port . -+.I host -+can be 0, allowing connections from any host; -+or a particular IP address, -+allowing connections only to that address; -+or a host name, allowing connections to the first IP address -+for that host. -+.I port -+may be a numeric port number -+or a port name. -+If -+.I port -+is 0, -+.B tcpserver -+will choose a free port. -+ -+.B tcpserver -+sets up several environment variables, -+as described in -+.B tcp-environ(5). -+ -+.B tcpserver -+exits when it receives SIGTERM. -+.SH "OPTIONS" -+.TP -+.B \-c\fIlimit -+Do not handle more than -+.I limit -+simultaneous connections. -+If there are -+.I limit -+simultaneous copies of -+.I program -+running, defer acceptance of a new connection -+until one copy finishes. -+.I limit -+must be a positive integer. -+Default: 40. -+.TP -+.B \-x\fIrules.cdb -+Follow the rules compiled into -+.I rules.cdb -+by -+.BR tcprules . -+These rules may specify setting environment variables -+or rejecting connections from bad sources. -+ -+.B tcpserver -+does not read -+.I rules.cdb -+into memory; -+you can rerun -+.B tcprules -+to change -+.BR tcpserver 's -+behavior on the fly. -+.TP -+.B \-B\fIbanner -+Write -+.I banner -+to the network immediately after each connection is made. -+.B tcpserver -+writes -+.I banner -+before looking up -+.BR TCPREMOTEHOST , -+before looking up -+.BR TCPREMOTEINFO , -+and before checking -+.IR rules.cdb . -+ -+This feature can be used to reduce latency in protocols -+where the client waits for a greeting from the server. -+.TP -+.B \-g\fIgid -+Switch group ID to -+.I gid -+after preparing to receive connections. -+.I gid -+must be a positive integer. -+.TP -+.B \-u\fIuid -+Switch user ID to -+.I uid -+after preparing to receive connections. -+.I uid -+must be a positive integer. -+.TP -+.B \-1 -+After preparing to receive connections, -+print the local port number to standard output. -+.TP -+.B \-4 -+Fall back to IPv4 sockets. This is necessary for terminally broken -+systems like OpenBSD which will not let IPv6 sockets connect to -+V4-mapped IPv6 addresses. Please note that this also applies to DNS -+lookups, so you will have to use an DNS resolver with an IPv6 address to -+accept IPv6 connections. Use \fBDNSCACHEIP\fR to set the DNS resolver -+IP dynamically. -+.TP -+.B \-6 -+Force IPv6 mode in UCSPI environment variables, even for -+IPv4 connections. This will set \fB$PROTO\fR to \fBTCP6\fR and put -+IPv4-mapped IPv6 addresses in \fBTCPLOCALIP\fR and \fBTCPREMOTEIP\fR. -+.TP -+.B \-I\fIinterface -+Bind to the network interface -+.I interface -+("eth0" on Linux, for example). This is only defined and needed for -+IPv6 link-local addresses. -+.TP -+.B \-b\fIbacklog -+Allow up to -+.I backlog -+simultaneous SYN_RECEIVEDs. -+Default: 20. -+On some systems, -+.I backlog -+is silently limited to 5. -+See -+.BR listen (2) -+for more details. -+.TP -+.B \-o -+Leave IP options alone. -+If the client is sending packets along an IP source route, -+send packets back along the same route. -+.TP -+.B \-O -+(Default.) -+Kill IP options. -+A client can still use source routing to connect and to send data, -+but packets will be sent back along the default route. -+.TP -+.B \-d -+(Default.) -+Delay sending data for a fraction of a second whenever the -+remote host is responding slowly, -+to make better use of the network. -+.TP -+.B \-D -+Never delay sending data; -+enable TCP_NODELAY. -+This is appropriate for interactive connections. -+.TP -+.B \-q -+Quiet. -+Do not print any messages. -+.TP -+.B \-Q -+(Default.) -+Print error messages. -+.TP -+.B \-v -+Verbose. -+Print all available messages. -+.SH "DATA-GATHERING OPTIONS" -+.TP -+.B \-p -+Paranoid. -+After looking up the remote host name, -+look up the IP addresses for that name, -+and make sure one of them matches -+.BR TCPREMOTEIP . -+If none of them do, -+unset -+.BR TCPREMOTEHOST . -+.TP -+.B \-P -+(Default.) -+Not paranoid. -+.TP -+.B \-h -+(Default.) -+Look up the remote host name and set -+.BR TCPREMOTEHOST . -+.TP -+.B \-H -+Do not look up the remote host name. -+.TP -+.B \-l\fIlocalname -+Do not look up the local host name; -+use -+.I localname -+for -+.BR TCPLOCALHOST . -+.TP -+.B \-r -+(Default.) -+Attempt to obtain -+.B TCPREMOTEINFO -+from the remote host. -+.TP -+.B \-R -+Do not attempt to obtain -+.B TCPREMOTEINFO -+from the remote host. -+.TP -+.B \-t\fItimeout -+Give up on the -+.B TCPREMOTEINFO -+connection attempt -+after -+.I timeout -+seconds. Default: 26. -+.SH "SEE ALSO" -+argv0(1), -+fixcr(1), -+recordio(1), -+tcpclient(1), -+tcprules(1), -+listen(2), -+tcp-environ(5) -diff -uNr ucspi-tcp-0.88-stock/who@.1 ucspi-tcp-0.88/who@.1 ---- ucspi-tcp-0.88-stock/who@.1 Thu Jan 1 01:00:00 1970 -+++ ucspi-tcp-0.88/who@.1 Fri Sep 9 12:07:53 2005 -@@ -0,0 +1,32 @@ -+.TH who@ 1 -+.SH NAME -+who@ \- print list of active users on a host -+.SH SYNTAX -+.B who@ -+[ -+.I host -+] -+.SH DESCRIPTION -+.B who@ -+connects to TCP port 11 (Systat) on -+.I host -+and prints any data it receives. -+It removes CR and converts unprintable characters to a visible format. -+ -+If -+.I host -+is not supplied, -+.B who@ -+connects to the local host. -+ -+Some computers respond to port 11 with a list of active users. -+For example, they may be running -+ -+.EX -+ tcpserver 0 11 who & -+.EE -+.SH "SEE ALSO" -+cat(1), -+delcr(1), -+tcpclient(1), -+tcpserver(1) diff --git a/patches/ucspi-tcp-0.88.errno.patch b/patches/ucspi-tcp-0.88.errno.patch deleted file mode 100644 index fd93909..0000000 --- a/patches/ucspi-tcp-0.88.errno.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -u ucspi-tcp-0.88.old/error.h ucspi-tcp-0.88/error.h ---- ucspi-tcp-0.88.old/error.h 2000-03-18 09:18:20.000000000 -0600 -+++ ucspi-tcp-0.88/error.h 2003-01-08 13:39:12.000000000 -0600 -@@ -1,7 +1,7 @@ - #ifndef ERROR_H - #define ERROR_H - --extern int errno; -+#include <errno.h> - - extern int error_intr; - extern int error_nomem; @@ -2,7 +2,7 @@ #define PATHEXEC_H extern void pathexec_run(char *,char **,char **); -extern int pathexec_env(const char *,const char *); +extern int pathexec_env(char *,char *); extern void pathexec(char **); #endif diff --git a/pathexec_env.c b/pathexec_env.c index 157e71b..48bba7e 100644 --- a/pathexec_env.c +++ b/pathexec_env.c @@ -8,7 +8,7 @@ static stralloc plus; static stralloc tmp; -int pathexec_env(const char *s,const char *t) +int pathexec_env(char *s,char *t) { if (!s) return 1; if (!stralloc_copys(&tmp,s)) return 0; @@ -22,6 +22,7 @@ int pathexec_env(const char *s,const char *t) void pathexec(char **argv) { + char *path; char **e; unsigned int elen; unsigned int i; @@ -22,7 +22,7 @@ void nomem(void) } void usage(void) { - strerr_die1x(100,"rblsmtpd: usage: rblsmtpd [ -b ] [ -t timeout ] [ -r base ] [ -a base ] smtpd [ arg ... ]"); + strerr_die1x(100,"rblsmtpd: usage: rblsmtpd [ -b ] [ -R ] [ -t timeout ] [ -r base ] [ -a base ] smtpd [ arg ... ]"); } char *ip_env; @@ -55,70 +55,27 @@ int flagmustnotbounce = 0; int decision = 0; /* 0 undecided, 1 accept, 2 reject, 3 bounce */ static stralloc text; /* defined if decision is 2 or 3 */ -static char *decision_base; static stralloc tmp; void rbl(char *base) { - int i; - char *altreply = 0; if (decision) return; if (!stralloc_copy(&tmp,&ip_reverse)) nomem(); - i = str_chr(base, ':'); - if (base[i]) { - base[i] = 0; - altreply = base+i+1; - } if (!stralloc_cats(&tmp,base)) nomem(); - if (altreply) { - if (dns_ip4(&text,&tmp) == -1) { - flagmustnotbounce = 1; - if (flagfailclosed) { - if (!stralloc_copys(&text,"temporary RBL lookup error")) nomem(); - decision = 2; - decision_base = base; - } - return; - } - if (text.len) { - if(!stralloc_copys(&text, "")) nomem(); - while(*altreply) { - char *x; - i = str_chr(altreply, '%'); - if(!stralloc_catb(&text, altreply, i)) nomem(); - if(altreply[i] && - altreply[i+1]=='I' && - altreply[i+2]=='P' && - altreply[i+3]=='%') { - if(!stralloc_catb(&text, ip_env, str_len(ip_env))) nomem(); - altreply+=i+4; - } else if(altreply[i]) { - if(!stralloc_cats(&text, "%")) nomem(); - altreply+=i+1; - } else { - altreply+=i; - } - } - } - } else { - if (dns_txt(&text,&tmp) == -1) { - flagmustnotbounce = 1; - if (flagfailclosed) { - if (!stralloc_copys(&text,"temporary RBL lookup error")) nomem(); - decision = 2; - decision_base = base; - } - return; + if (dns_txt(&text,&tmp) == -1) { + flagmustnotbounce = 1; + if (flagfailclosed) { + if (!stralloc_copys(&text,"temporary RBL lookup error")) nomem(); + decision = 2; } + return; } - if (text.len) { + if (text.len) if (flagrblbounce) decision = 3; else decision = 2; - decision_base = base; - } } void antirbl(char *base) @@ -178,10 +135,6 @@ void rblsmtpd(void) buffer_puts(buffer_2,ip_env); buffer_puts(buffer_2," pid "); buffer_put(buffer_2,strnum,fmt_ulong(strnum,getpid())); - if (decision_base) { - buffer_puts(buffer_2, " "); - buffer_puts(buffer_2,decision_base); - } buffer_puts(buffer_2,": "); buffer_put(buffer_2,message.s,message.len); buffer_puts(buffer_2,"\n"); @@ -202,6 +155,7 @@ void rblsmtpd(void) main(int argc,char **argv,char **envp) { + int flagwantdefaultrbl = 1; char *x; int opt; @@ -228,7 +182,7 @@ main(int argc,char **argv,char **envp) case 'c': flagfailclosed = 1; break; case 'C': flagfailclosed = 0; break; case 't': scan_ulong(optarg,&timeout); break; - case 'r': rbl(optarg); break; + case 'r': rbl(optarg); flagwantdefaultrbl = 0; break; case 'a': antirbl(optarg); break; default: usage(); } @@ -236,6 +190,7 @@ main(int argc,char **argv,char **envp) argv += optind; if (!*argv) usage(); + if (flagwantdefaultrbl) rbl("rbl.maps.vix.com"); if (decision >= 2) rblsmtpd(); pathexec_run(*argv,argv,envp); diff --git a/recordio.1 b/recordio.1 deleted file mode 100644 index e056776..0000000 --- a/recordio.1 +++ /dev/null @@ -1,75 +0,0 @@ -.TH recordio 1 -.SH NAME -recordio \- record the input and output of a program -.SH SYNTAX -.B recordio -.I program -[ -.I arg ... -] -.SH DESCRIPTION -.B recordio -runs -.I program -with the given arguments. -It prints lines to stderr -showing the input and output of -.IR program . - -At the beginning of each line on stderr, -.B recordio -inserts the -.I program -process ID, -along with -.B < -for input or -.B > -for output. -At the end of each line it inserts a space, a plus sign, or [EOF]; -a space indicates that there was a newline in the input or output, -and [EOF] indicates the end of input or output. - -.B recordio -prints every packet of input and output immediately. -It does not attempt to combine packets into coherent stderr lines. -For example, - -.EX - recordio sh -c 'cat /dev/fd/8 2>&1' > /dev/null -.EE - -could produce - -.EX - 5135 > cat: /dev/fd/8: Bad file descriptor -.br - 5135 > [EOF] -.EE - -or - -.EX - 5135 > cat: + -.br - 5135 > /dev/fd/8+ -.br - 5135 > : + -.br - 5135 > Bad file descriptor -.br - 5135 > [EOF] -.EE - -.B recordio -uses several lines for long packets -to guarantee that each line is printed atomically to stderr. - -.B recordio -runs as a child of -.IR program . -It exits when it sees the end of -.IR program 's -output. -.SH "SEE ALSO" -tcpserver(1) diff --git a/remoteinfo.h b/remoteinfo.h index 0884cc1..2ca779d 100644 --- a/remoteinfo.h +++ b/remoteinfo.h @@ -5,6 +5,5 @@ #include "uint16.h" extern int remoteinfo(stralloc *,char *,uint16,char *,uint16,unsigned int); -extern int remoteinfo6(stralloc *,char *,uint16,char *,uint16,unsigned int,uint32); #endif diff --git a/remoteinfo6.c b/remoteinfo6.c deleted file mode 100644 index cf3b7c1..0000000 --- a/remoteinfo6.c +++ /dev/null @@ -1,98 +0,0 @@ -#include "fmt.h" -#include "buffer.h" -#include "socket.h" -#include "error.h" -#include "iopause.h" -#include "timeoutconn.h" -#include "remoteinfo.h" - -static struct taia now; -static struct taia deadline; - -static int mywrite(int fd,char *buf,int len) -{ - iopause_fd x; - - x.fd = fd; - x.events = IOPAUSE_WRITE; - for (;;) { - taia_now(&now); - iopause(&x,1,&deadline,&now); - if (x.revents) break; - if (taia_less(&deadline,&now)) { - errno = error_timeout; - return -1; - } - } - return write(fd,buf,len); -} - -static int myread(int fd,char *buf,int len) -{ - iopause_fd x; - - x.fd = fd; - x.events = IOPAUSE_READ; - for (;;) { - taia_now(&now); - iopause(&x,1,&deadline,&now); - if (x.revents) break; - if (taia_less(&deadline,&now)) { - errno = error_timeout; - return -1; - } - } - return read(fd,buf,len); -} - -static int doit(stralloc *out,int s,char ipremote[16],uint16 portremote,char iplocal[16],uint16 portlocal,unsigned int timeout,uint32 netif) -{ - buffer b; - char bspace[128]; - char strnum[FMT_ULONG]; - int numcolons; - char ch; - - if (socket_bind6(s,iplocal,0,netif) == -1) return -1; - if (timeoutconn6(s,ipremote,113,timeout,netif) == -1) return -1; - - buffer_init(&b,mywrite,s,bspace,sizeof bspace); - buffer_put(&b,strnum,fmt_ulong(strnum,portremote)); - buffer_put(&b," , ",3); - buffer_put(&b,strnum,fmt_ulong(strnum,portlocal)); - buffer_put(&b,"\r\n",2); - if (buffer_flush(&b) == -1) return -1; - - buffer_init(&b,myread,s,bspace,sizeof bspace); - numcolons = 0; - for (;;) { - if (buffer_get(&b,&ch,1) != 1) return -1; - if ((ch == ' ') || (ch == '\t') || (ch == '\r')) continue; - if (ch == '\n') return 0; - if (numcolons < 3) { - if (ch == ':') ++numcolons; - } - else { - if (!stralloc_append(out,&ch)) return -1; - if (out->len > 256) return 0; - } - } -} - -int remoteinfo6(stralloc *out,char ipremote[16],uint16 portremote,char iplocal[16],uint16 portlocal,unsigned int timeout,uint32 netif) -{ - int s; - int r; - - if (!stralloc_copys(out,"")) return -1; - - taia_now(&now); - taia_uint(&deadline,timeout); - taia_add(&deadline,&now,&deadline); - - s = socket_tcp6(); - if (s == -1) return -1; - r = doit(out,s,ipremote,portremote,iplocal,portlocal,timeout,netif); - close(s); - return r; -} @@ -64,7 +64,7 @@ static int doit(void (*callback)(char *,unsigned int),char *ip,char *host,char * if (!stralloc_copys(&rules_name,ip)) return -1; while (rules_name.len > 0) { - if (ip[rules_name.len - 1] == '.' || ip[rules_name.len - 1] == ':') { + if (ip[rules_name.len - 1] == '.') { r = dorule(callback); if (r) return r; } diff --git a/scan_ip6.c b/scan_ip6.c deleted file mode 100644 index ee239fd..0000000 --- a/scan_ip6.c +++ /dev/null @@ -1,87 +0,0 @@ -#include "scan.h" -#include "ip4.h" -#include "ip6.h" - -/* - * IPv6 addresses are really ugly to parse. - * Syntax: (h = hex digit) - * 1. hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh - * 2. any number of 0000 may be abbreviated as "::", but only once - * 3. The last two words may be written as IPv4 address - */ - -unsigned int scan_ip6(const char *s,char ip[16]) -{ - unsigned int i; - unsigned int len=0; - unsigned long u; - - char suffix[16]; - int prefixlen=0; - int suffixlen=0; - - if ((i=ip4_scan((char*)s,ip+12))) { - for (len=0; len<12; ++len) ip[len]=V4mappedprefix[len]; - return i; - } - for (i=0; i<16; i++) ip[i]=0; - for (;;) { - if (*s == ':') { - len++; - if (s[1] == ':') { /* Found "::", skip to part 2 */ - s+=2; - len++; - break; - } - s++; - } - i = scan_xlong((char*)s,&u); - if (!i) return 0; - if (prefixlen==12 && s[i]=='.') { - /* the last 4 bytes may be written as IPv4 address */ - i=ip4_scan((char*)s,ip+12); - if (i) - return i+len; - else - return 0; - } - ip[prefixlen++] = (u >> 8); - ip[prefixlen++] = (u & 255); - s += i; len += i; - if (prefixlen==16) - return len; - } - -/* part 2, after "::" */ - for (;;) { - if (*s == ':') { - if (suffixlen==0) - break; - s++; - len++; - } else if (suffixlen!=0) - break; - i = scan_xlong((char*)s,&u); - if (!i) { - len--; - break; - } - if (suffixlen+prefixlen<=12 && s[i]=='.') { - int j=ip4_scan((char*)s,suffix+suffixlen); - if (j) { - suffixlen+=4; - len+=j; - break; - } else - prefixlen=12-suffixlen; /* make end-of-loop test true */ - } - suffix[suffixlen++] = (u >> 8); - suffix[suffixlen++] = (u & 255); - s += i; len += i; - if (prefixlen+suffixlen==16) - break; - } - for (i=0; i<suffixlen; i++) - ip[16-suffixlen+i] = suffix[i]; - return len; -} diff --git a/scan_xlong.c b/scan_xlong.c deleted file mode 100644 index 6e46d74..0000000 --- a/scan_xlong.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "scan.h" - -static int fromhex(unsigned char c) { - if (c>='0' && c<='9') - return c-'0'; - else if (c>='A' && c<='F') - return c-'A'+10; - else if (c>='a' && c<='f') - return c-'a'+10; - return -1; -} - -unsigned int scan_xlong(char *src,unsigned long *dest) { - register const char *tmp=src; - register int l=0; - register unsigned char c; - while ((c=fromhex(*tmp))<16) { - l=(l<<4)+c; - ++tmp; - } - *dest=l; - return tmp-src; -} @@ -2,52 +2,21 @@ #define SOCKET_H #include "uint16.h" -#include "uint32.h" extern int socket_tcp(void); extern int socket_udp(void); -extern int socket_tcp6(void); -extern int socket_udp6(void); -extern int socket_connect4(int,const char *,uint16); -extern int socket_connect6(int s,const char *ip,uint16 port,uint32 scope_id); +extern int socket_connect4(int,char *,uint16); extern int socket_connected(int); -extern int socket_bind4(int,const char *,uint16); -extern int socket_bind4_reuse(int,const char *,uint16); -extern int socket_bind6(int s,const char *ip,uint16 port,uint32 scope_id); -extern int socket_bind6_reuse(int s,const char *ip,uint16 port,uint32 scope_id); +extern int socket_bind4(int,char *,uint16); +extern int socket_bind4_reuse(int,char *,uint16); extern int socket_listen(int,int); extern int socket_accept4(int,char *,uint16 *); -extern int socket_accept6(int s,char *ip,uint16 *port,uint32 *scope_id); extern int socket_recv4(int,char *,int,char *,uint16 *); -extern int socket_send4(int,const char *,int,const char *,uint16); -extern int socket_recv6(int s,char *buf,unsigned int len,char *ip,uint16 *port,uint32 *scope_id); -extern int socket_send6(int s,const char *buf,unsigned int len,const char *ip,uint16 port,uint32 scope_id); +extern int socket_send4(int,char *,int,char *,uint16); extern int socket_local4(int,char *,uint16 *); extern int socket_remote4(int,char *,uint16 *); -extern int socket_local6(int s,char *ip,uint16 *port,uint32 *scope_id); -extern int socket_remote6(int s,char *ip,uint16 *port,uint32 *scope_id); - -/* enable sending udp packets to the broadcast address */ -extern int socket_broadcast(int); -/* join a multicast group on the given interface */ -extern int socket_mcjoin4(int,char *,char *); -extern int socket_mcjoin6(int,char *,int); -/* leave a multicast group on the given interface */ -extern int socket_mcleave4(int,char *); -extern int socket_mcleave6(int,char *); -/* set multicast TTL/hop count for outgoing packets */ -extern int socket_mcttl4(int,char); -extern int socket_mcttl6(int,char); -/* enable multicast loopback */ -extern int socket_mcloop4(int,char); -extern int socket_mcloop6(int,char); - -extern const char* socket_getifname(uint32 interface); -extern uint32 socket_getifidx(const char *ifname); extern void socket_tryreservein(int,int); -extern int noipv6; - #endif diff --git a/socket_accept6.c b/socket_accept6.c deleted file mode 100644 index a8a9a07..0000000 --- a/socket_accept6.c +++ /dev/null @@ -1,44 +0,0 @@ -#include <sys/types.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include "byte.h" -#include "socket.h" -#include "ip6.h" -#include "haveip6.h" -#include "error.h" - -int socket_accept6(int s,char ip[16],uint16 *port,uint32 *scope_id) -{ -#ifdef LIBC_HAS_IP6 - struct sockaddr_in6 sa; -#else - struct sockaddr_in sa; -#endif - unsigned int dummy = sizeof sa; - int fd; - - fd = accept(s,(struct sockaddr *) &sa,&dummy); - if (fd == -1) return -1; - -#ifdef LIBC_HAS_IP6 - if (sa.sin6_family==AF_INET) { - struct sockaddr_in *sa4=(struct sockaddr_in*)&sa; - byte_copy(ip,12,V4mappedprefix); - byte_copy(ip+12,4,(char *) &sa4->sin_addr); - uint16_unpack_big((char *) &sa4->sin_port,port); - return fd; - } - byte_copy(ip,16,(char *) &sa.sin6_addr); - uint16_unpack_big((char *) &sa.sin6_port,port); - if (scope_id) *scope_id=sa.sin6_scope_id; - - return fd; -#else - byte_copy(ip,12,V4mappedprefix); - byte_copy(ip+12,4,(char *) &sa.sin_addr); - uint16_unpack_big((char *) &sa.sin_port,port); - if (scope_id) *scope_id=0; - return fd; -#endif -} diff --git a/socket_bind.c b/socket_bind.c index 067b4a8..20830a4 100644 --- a/socket_bind.c +++ b/socket_bind.c @@ -5,7 +5,7 @@ #include "byte.h" #include "socket.h" -int socket_bind4(int s,const char ip[4],uint16 port) +int socket_bind4(int s,char ip[4],uint16 port) { struct sockaddr_in sa; @@ -17,7 +17,7 @@ int socket_bind4(int s,const char ip[4],uint16 port) return bind(s,(struct sockaddr *) &sa,sizeof sa); } -int socket_bind4_reuse(int s,const char ip[4],uint16 port) +int socket_bind4_reuse(int s,char ip[4],uint16 port) { int opt = 1; setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof opt); diff --git a/socket_bind6.c b/socket_bind6.c deleted file mode 100644 index 8a5a7cd..0000000 --- a/socket_bind6.c +++ /dev/null @@ -1,45 +0,0 @@ -#include <sys/types.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include "byte.h" -#include "socket.h" -#include "ip6.h" -#include "haveip6.h" -#include "error.h" - -int socket_bind6(int s,const char ip[16],uint16 port,uint32 scope_id) -{ -#ifdef LIBC_HAS_IP6 - struct sockaddr_in6 sa; - - if (noipv6) { -#endif - int i; - for (i=0; i<16; i++) - if (ip[i]!=0) break; - if (i==16 || ip6_isv4mapped(ip)) - return socket_bind4(s,ip+12,port); -#ifdef LIBC_HAS_IP6 - } - byte_zero(&sa,sizeof sa); - sa.sin6_family = AF_INET6; - uint16_pack_big((char *) &sa.sin6_port,port); -/* implicit: sa.sin6_flowinfo = 0; */ - byte_copy((char *) &sa.sin6_addr,16,ip); - sa.sin6_scope_id=scope_id; - - return bind(s,(struct sockaddr *) &sa,sizeof sa); -#else - errno=error_proto; - return -1; -#endif -} - -int socket_bind6_reuse(int s,const char ip[16],uint16 port,uint32 scope_id) -{ - int opt = 1; - setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof opt); - return socket_bind6(s,ip,port,scope_id); -} - diff --git a/socket_conn.c b/socket_conn.c index dcc93ac..35adac4 100644 --- a/socket_conn.c +++ b/socket_conn.c @@ -6,7 +6,7 @@ #include "byte.h" #include "socket.h" -int socket_connect4(int s,const char ip[4],uint16 port) +int socket_connect4(int s,char ip[4],uint16 port) { struct sockaddr_in sa; diff --git a/socket_conn6.c b/socket_conn6.c deleted file mode 100644 index 0ad886d..0000000 --- a/socket_conn6.c +++ /dev/null @@ -1,38 +0,0 @@ -#include <sys/param.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <errno.h> -#include "byte.h" -#include "socket.h" -#include "ip6.h" -#include "haveip6.h" -#include "uint32.h" -#include "ip4.h" - -int socket_connect6(int s,const char ip[16],uint16 port,uint32 scope_id) -{ -#ifdef LIBC_HAS_IP6 - struct sockaddr_in6 sa; - - if (noipv6) { -#endif - if (ip6_isv4mapped(ip)) - return socket_connect4(s,ip+12,port); - if (byte_equal(ip,16,V6loopback)) - return socket_connect4(s,ip4loopback,port); -#ifdef LIBC_HAS_IP6 - } - byte_zero(&sa,sizeof sa); - sa.sin6_family = PF_INET6; - uint16_pack_big((char *) &sa.sin6_port,port); - sa.sin6_flowinfo = 0; - sa.sin6_scope_id = scope_id; - byte_copy((char *) &sa.sin6_addr,16,ip); - - return connect(s,(struct sockaddr *) &sa,sizeof sa); -#else - errno=EPROTONOSUPPORT; - return -1; -#endif -} diff --git a/socket_getifidx.c b/socket_getifidx.c deleted file mode 100644 index 452d6d7..0000000 --- a/socket_getifidx.c +++ /dev/null @@ -1,8 +0,0 @@ -#include <sys/types.h> -#include <sys/socket.h> -#include <net/if.h> -#include "socket.h" - -uint32 socket_getifidx(const char* ifname) { - return if_nametoindex(ifname); -} diff --git a/socket_getifname.c b/socket_getifname.c deleted file mode 100644 index 77edff9..0000000 --- a/socket_getifname.c +++ /dev/null @@ -1,14 +0,0 @@ -#include <sys/types.h> -#include <sys/socket.h> -#include <net/if.h> -#include "socket.h" - -static char ifname[IFNAMSIZ]; - -const char* socket_getifname(uint32 interface) { - char *tmp=if_indextoname(interface,ifname); - if (tmp) - return tmp; - else - return "[unknown]"; -} diff --git a/socket_ip4loopback.c b/socket_ip4loopback.c deleted file mode 100644 index 1bbbe95..0000000 --- a/socket_ip4loopback.c +++ /dev/null @@ -1,2 +0,0 @@ - -const char ip4loopback[4] = {127,0,0,1}; diff --git a/socket_local6.c b/socket_local6.c deleted file mode 100644 index 23427c3..0000000 --- a/socket_local6.c +++ /dev/null @@ -1,39 +0,0 @@ -#include <sys/types.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include "byte.h" -#include "socket.h" -#include "ip6.h" -#include "haveip6.h" -#include "error.h" - -int socket_local6(int s,char ip[16],uint16 *port,uint32 *scope_id) -{ -#ifdef LIBC_HAS_IP6 - struct sockaddr_in6 sa; -#else - struct sockaddr_in sa; -#endif - unsigned int dummy = sizeof sa; - - if (getsockname(s,(struct sockaddr *) &sa,&dummy) == -1) return -1; -#ifdef LIBC_HAS_IP6 - if (sa.sin6_family==AF_INET) { - struct sockaddr_in *sa4=(struct sockaddr_in*)&sa; - byte_copy(ip,12,V4mappedprefix); - byte_copy(ip+12,4,(char *) &sa4->sin_addr); - uint16_unpack_big((char *) &sa4->sin_port,port); - return 0; - } - byte_copy(ip,16,(char *) &sa.sin6_addr); - uint16_unpack_big((char *) &sa.sin6_port,port); - if (scope_id) *scope_id=sa.sin6_scope_id; -#else - byte_copy(ip,12,V4mappedprefix); - byte_copy(ip+12,4,(char *) &sa.sin_addr); - uint16_unpack_big((char *) &sa.sin_port,port); - if (scope_id) *scope_id=0; -#endif - return 0; -} diff --git a/socket_recv6.c b/socket_recv6.c deleted file mode 100644 index a86ca96..0000000 --- a/socket_recv6.c +++ /dev/null @@ -1,44 +0,0 @@ -#include <sys/types.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include "byte.h" -#include "socket.h" -#include "ip6.h" -#include "haveip6.h" -#include "error.h" - -int socket_recv6(int s,char *buf,unsigned int len,char ip[16],uint16 *port,uint32 *scope_id) -{ -#ifdef LIBC_HAS_IP6 - struct sockaddr_in6 sa; -#else - struct sockaddr_in sa; -#endif - unsigned int dummy = sizeof sa; - int r; - - byte_zero(&sa,dummy); - r = recvfrom(s,buf,len,0,(struct sockaddr *) &sa,&dummy); - if (r == -1) return -1; - -#ifdef LIBC_HAS_IP6 - if (noipv6) { - struct sockaddr_in *sa4=(struct sockaddr_in *)&sa; - byte_copy(ip,12,V4mappedprefix); - byte_copy(ip+12,4,(char *) &sa4->sin_addr); - uint16_unpack_big((char *) &sa4->sin_port,port); - return r; - } - byte_copy(ip,16,(char *) &sa.sin6_addr); - uint16_unpack_big((char *) &sa.sin6_port,port); - if (scope_id) *scope_id=sa.sin6_scope_id; -#else - byte_copy(ip,12,(char *)V4mappedprefix); - byte_copy(ip+12,4,(char *) &sa.sin_addr); - uint16_unpack_big((char *) &sa.sin_port,port); - if (scope_id) *scope_id=0; -#endif - - return r; -} diff --git a/socket_remote6.c b/socket_remote6.c deleted file mode 100644 index e60a539..0000000 --- a/socket_remote6.c +++ /dev/null @@ -1,39 +0,0 @@ -#include <sys/types.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include "byte.h" -#include "socket.h" -#include "ip6.h" -#include "haveip6.h" -#include "error.h" - -int socket_remote6(int s,char ip[16],uint16 *port,uint32 *scope_id) -{ -#ifdef LIBC_HAS_IP6 - struct sockaddr_in6 sa; -#else - struct sockaddr_in sa; -#endif - unsigned int dummy = sizeof sa; - - if (getpeername(s,(struct sockaddr *) &sa,&dummy) == -1) return -1; -#ifdef LIBC_HAS_IP6 - if (sa.sin6_family==AF_INET) { - struct sockaddr_in *sa4=(struct sockaddr_in*)&sa; - byte_copy(ip,12,V4mappedprefix); - byte_copy(ip+12,4,(char *) &sa4->sin_addr); - uint16_unpack_big((char *) &sa4->sin_port,port); - return 0; - } - byte_copy(ip,16,(char *) &sa.sin6_addr); - uint16_unpack_big((char *) &sa.sin6_port,port); - if (scope_id) *scope_id=sa.sin6_scope_id; -#else - byte_copy(ip,12,V4mappedprefix); - byte_copy(ip+12,4,(char *) &sa.sin_addr); - uint16_unpack_big((char *) &sa.sin_port,port); - if (scope_id) *scope_id=0; -#endif - return 0; -} diff --git a/socket_send6.c b/socket_send6.c deleted file mode 100644 index 4b2d1e8..0000000 --- a/socket_send6.c +++ /dev/null @@ -1,40 +0,0 @@ -#include <sys/types.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include "byte.h" -#include "socket.h" -#include "ip4.h" -#include "ip6.h" -#include "haveip6.h" -#include "error.h" - -int socket_send6(int s,const char *buf,unsigned int len,const char ip[16],uint16 port,uint32 scope_id) -{ -#ifdef LIBC_HAS_IP6 - struct sockaddr_in6 sa; -#else - struct sockaddr_in sa; -#endif - - byte_zero(&sa,sizeof sa); -#ifdef LIBC_HAS_IP6 - if (noipv6) { -#endif - if (ip6_isv4mapped(ip)) - return socket_send4(s,buf,len,ip+12,port); - if (byte_equal(ip,16,V6loopback)) - return socket_send4(s,buf,len,ip4loopback,port); -#ifdef LIBC_HAS_IP6 - errno=error_proto; - return -1; - } - sa.sin6_family = AF_INET6; - uint16_pack_big((char *) &sa.sin6_port,port); - byte_copy((char *) &sa.sin6_addr,16,ip); - return sendto(s,buf,len,0,(struct sockaddr *) &sa,sizeof sa); -#else - errno=error_proto; - return -1; -#endif -} diff --git a/socket_tcp6.c b/socket_tcp6.c deleted file mode 100644 index 74099e2..0000000 --- a/socket_tcp6.c +++ /dev/null @@ -1,44 +0,0 @@ -#include <sys/types.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <errno.h> -#include "ndelay.h" -#include "socket.h" -#include "haveip6.h" -#include "error.h" - -#ifdef LIBC_HAS_IP6 -int noipv6=0; -#else -int noipv6=1; -#endif - -int socket_tcp6(void) -{ -#ifdef LIBC_HAS_IP6 - int s; - - if (noipv6) goto compat; - s = socket(PF_INET6,SOCK_STREAM,0); - if (s == -1) { - if (errno == EINVAL || errno == EAFNOSUPPORT) { -compat: - s=socket(AF_INET,SOCK_STREAM,0); - noipv6=1; - if (s==-1) return -1; - } else - return -1; - } - if (ndelay_on(s) == -1) { close(s); return -1; } -#ifdef IPV6_V6ONLY - { - int zero=0; - setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero)); - } -#endif - return s; -#else - return socket_tcp(); -#endif -} diff --git a/socket_udp6.c b/socket_udp6.c deleted file mode 100644 index 3769b1d..0000000 --- a/socket_udp6.c +++ /dev/null @@ -1,38 +0,0 @@ -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <errno.h> -#include "haveip6.h" -#include "socket.h" - -#ifndef EAFNOSUPPORT -#define EAFNOSUPPORT EINVAL -#endif - -int socket_udp6(void) -{ -#ifdef LIBC_HAS_IP6 - int s; - - if (noipv6) goto compat; - s = socket(PF_INET6,SOCK_DGRAM,0); - if (s == -1) { - if (errno == EINVAL || errno == EAFNOSUPPORT) { -compat: - s=socket(AF_INET,SOCK_DGRAM,0); - noipv6=1; - if (s==-1) return -1; - } else - return -1; - } -#ifdef IPV6_V6ONLY - { - int zero=0; - setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero)); - } -#endif - return s; -#else - return socket_udp(); -#endif -} diff --git a/socket_v4mappedprefix.c b/socket_v4mappedprefix.c deleted file mode 100644 index dbed824..0000000 --- a/socket_v4mappedprefix.c +++ /dev/null @@ -1,2 +0,0 @@ - -const unsigned char V4mappedprefix[12]={0,0,0,0,0,0,0,0,0,0,0xff,0xff}; diff --git a/socket_v6any.c b/socket_v6any.c deleted file mode 100644 index c6d0cbb..0000000 --- a/socket_v6any.c +++ /dev/null @@ -1,2 +0,0 @@ - -const unsigned char V6any[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; diff --git a/socket_v6loopback.c b/socket_v6loopback.c deleted file mode 100644 index b81ee65..0000000 --- a/socket_v6loopback.c +++ /dev/null @@ -1,2 +0,0 @@ - -const unsigned char V6loopback[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; @@ -1,13 +1,13 @@ #ifndef STR_H #define STR_H -extern unsigned int str_copy(char *,const char *); -extern int str_diff(const char *,const char *); -extern int str_diffn(const char *,const char *,unsigned int); -extern unsigned int str_len(const char *); -extern unsigned int str_chr(const char *,int); -extern unsigned int str_rchr(const char *,int); -extern int str_start(const char *,const char *); +extern unsigned int str_copy(char *,char *); +extern int str_diff(char *,char *); +extern int str_diffn(char *,char *,unsigned int); +extern unsigned int str_len(char *); +extern unsigned int str_chr(char *,int); +extern unsigned int str_rchr(char *,int); +extern int str_start(char *,char *); #define str_equal(s,t) (!str_diff((s),(t))) @@ -1,9 +1,9 @@ #include "str.h" -unsigned int str_chr(register const char *s,int c) +unsigned int str_chr(register char *s,int c) { register char ch; - register const char *t; + register char *t; ch = c; t = s; @@ -1,6 +1,6 @@ #include "str.h" -int str_diff(register const char *s,register const char *t) +int str_diff(register char *s,register char *t) { register char x; @@ -1,8 +1,8 @@ #include "str.h" -unsigned int str_len(const char *s) +unsigned int str_len(char *s) { - register const char *t; + register char *t; t = s; for (;;) { diff --git a/str_start.c b/str_start.c index 757189d..43430bb 100644 --- a/str_start.c +++ b/str_start.c @@ -1,6 +1,6 @@ #include "str.h" -int str_start(register const char *s,register const char *t) +int str_start(register char *s,register char *t) { register char x; @@ -9,20 +9,18 @@ extern int stralloc_ready(stralloc *,unsigned int); extern int stralloc_readyplus(stralloc *,unsigned int); extern int stralloc_copy(stralloc *,stralloc *); extern int stralloc_cat(stralloc *,stralloc *); -extern int stralloc_copys(stralloc *,const char *); -extern int stralloc_cats(stralloc *,const char *); -extern int stralloc_copyb(stralloc *,const char *,unsigned int); -extern int stralloc_catb(stralloc *,const char *,unsigned int); +extern int stralloc_copys(stralloc *,char *); +extern int stralloc_cats(stralloc *,char *); +extern int stralloc_copyb(stralloc *,char *,unsigned int); +extern int stralloc_catb(stralloc *,char *,unsigned int); extern int stralloc_append(stralloc *,char *); /* beware: this takes a pointer to 1 char */ -extern int stralloc_starts(stralloc *,const char *); +extern int stralloc_starts(stralloc *,char *); #define stralloc_0(sa) stralloc_append(sa,"") extern int stralloc_catulong0(stralloc *,unsigned long,unsigned int); extern int stralloc_catlong0(stralloc *,long,unsigned int); -extern void stralloc_free(stralloc *); - #define stralloc_catlong(sa,l) (stralloc_catlong0((sa),(l),0)) #define stralloc_catuint0(sa,i,n) (stralloc_catulong0((sa),(i),(n))) #define stralloc_catint0(sa,i,n) (stralloc_catlong0((sa),(i),(n))) diff --git a/stralloc_catb.c b/stralloc_catb.c index b606e32..b739bed 100644 --- a/stralloc_catb.c +++ b/stralloc_catb.c @@ -1,7 +1,7 @@ #include "stralloc.h" #include "byte.h" -int stralloc_catb(stralloc *sa,const char *s,unsigned int n) +int stralloc_catb(stralloc *sa,char *s,unsigned int n) { if (!sa->s) return stralloc_copyb(sa,s,n); if (!stralloc_readyplus(sa,n + 1)) return 0; diff --git a/stralloc_cats.c b/stralloc_cats.c index 92cb66e..8b11e94 100644 --- a/stralloc_cats.c +++ b/stralloc_cats.c @@ -2,7 +2,7 @@ #include "str.h" #include "stralloc.h" -int stralloc_cats(stralloc *sa,const char *s) +int stralloc_cats(stralloc *sa,char *s) { return stralloc_catb(sa,s,str_len(s)); } diff --git a/stralloc_opyb.c b/stralloc_opyb.c index 593029d..46b99fc 100644 --- a/stralloc_opyb.c +++ b/stralloc_opyb.c @@ -1,7 +1,7 @@ #include "stralloc.h" #include "byte.h" -int stralloc_copyb(stralloc *sa,const char *s,unsigned int n) +int stralloc_copyb(stralloc *sa,char *s,unsigned int n) { if (!stralloc_ready(sa,n + 1)) return 0; byte_copy(sa->s,n,s); diff --git a/stralloc_opys.c b/stralloc_opys.c index 860c7e0..78594b0 100644 --- a/stralloc_opys.c +++ b/stralloc_opys.c @@ -2,7 +2,7 @@ #include "str.h" #include "stralloc.h" -int stralloc_copys(stralloc *sa,const char *s) +int stralloc_copys(stralloc *sa,char *s) { return stralloc_copyb(sa,s,str_len(s)); } diff --git a/tcp-environ.5 b/tcp-environ.5 deleted file mode 100644 index fecad70..0000000 --- a/tcp-environ.5 +++ /dev/null @@ -1,66 +0,0 @@ -.TH tcp-environ 5 -.SH NAME -tcp-environ \- TCP-related environment variables -.SH DESCRIPTION -The following environment variables -describe a TCP connection. -They are set up by -.BR tcp-env , -.BR tcpclient , -and -.BR tcpserver . -Note that -.BR TCPLOCALHOST , -.BR TCPREMOTEHOST , -and -.B TCPREMOTEINFO -can contain arbitrary characters. -.TP 5 -PROTO -The string -.BR TCP . -.TP 5 -TCPLOCALHOST -The domain name of the local host, -with uppercase letters converted to lowercase. -If there is no currently available domain name -for the local IP address, -.B TCPLOCALHOST -is not set. -.TP 5 -TCPLOCALIP -The IP address of the local host, in dotted-decimal form. -.TP 5 -TCPLOCALPORT -The local TCP port number, in decimal. -.TP 5 -TCPREMOTEHOST -The domain name of the remote host, -with uppercase letters converted to lowercase. -If there is no currently available domain name -for the remote IP address, -.B TCPREMOTEHOST -is not set. -.TP 5 -TCPREMOTEINFO -A connection-specific string, perhaps a username, -supplied by the remote host -via 931/1413/IDENT/TAP. -If the remote host did not supply connection information, -.B TCPREMOTEINFO -is not set. -.TP 5 -TCPREMOTEIP -The IP address of the remote host. -.TP 5 -TCPREMOTEPORT -The remote TCP port number. -.TP 5 -TCPINTERFACE -The interface name ("eth0") for IPv6 connections using link-local -addresses. -.SH "SEE ALSO" -tcpclient(1), -tcpserver(1), -tcp-env(1), -tcp(4) diff --git a/tcpcat.1 b/tcpcat.1 deleted file mode 100644 index 4c51ed5..0000000 --- a/tcpcat.1 +++ /dev/null @@ -1,20 +0,0 @@ -.TH tcpcat 1 -.SH NAME -tcpcat \- print data from a TCP port -.SH SYNTAX -.B tcpcat -.I host -.I port -.SH DESCRIPTION -.B tcpcat -connects to -.I port -on -.I host -and prints any data it receives. - -.B tcpcat -can be used to transfer binary data. -It does no conversions. -.SH "SEE ALSO" -tcpclient(1) diff --git a/tcpclient.1 b/tcpclient.1 deleted file mode 100644 index f82f6b3..0000000 --- a/tcpclient.1 +++ /dev/null @@ -1,173 +0,0 @@ -.TH tcpclient 1 -.SH NAME -tcpclient \- create an outgoing TCP connection -.SH SYNOPSIS -.B tcpclient -[ -.B \-46hHrRdDqQv -] -[ -.B \-i\fIlocalip -] -[ -.B \-p\fIlocalport -] -[ -.B \-T\fItimeoutconn -] -[ -.B \-l\fIlocalname -] -[ -.B \-t\fItimeoutinfo -] -[ -.B \-I\fIinterface -] -.I host -.I port -.I program -[ -.I arg ... -] -.SH DESCRIPTION -.B tcpclient -attempts to connect to a TCP server. -If it is successful, it runs -.I program -with the given arguments, -with descriptor 6 reading from the network -and descriptor 7 writing to the network. - -The server's address is given by -.I host -and -.IR port . -.I host -may be 0, referring to the local machine, -or a dotted-decimal IP address, -or a host name; -if a host has several IP addresses, -.B tcpclient -tries each in turn. -.I port -may be a numeric port number -or a port name. - -.B tcpclient -sets up several environment variables, -as described in -.B tcp-environ(5). -.SH OPTIONS -.TP -.B \-i\fIlocalip -Use -.I localip -as the IP address for the local side of the connection; -quit if -.I localip -is not available. -.TP -.B \-p\fIlocalport -Use -.I localport -as the port number for the local side of the connection; -quit if -.I localport -is not available. -.TP -.B \-I\fIinterface -Use -.I interface -as the local network interface. This is only defined for IPv6 sockets -and needed if you use link-local IPv6 addresses. -.TP -.B \-T\fItimeoutconn -Give up on the -connection attempt -after -.I timeoutconn -seconds. Default: 60. -This timeout applies to each IP address tried. -.TP -.B \-d -(Default.) -Delay sending data for a fraction of a second whenever the -remote host is responding slowly, -to make better use of the network. -.TP -.B \-D -Never delay sending data; -enable TCP_NODELAY. -This is appropriate for interactive connections. -.TP -.B \-q -Quiet. -Do not print any messages. -.TP -.B \-Q -(Default.) -Print error messages. -.TP -.B \-v -Verbose. -Print all available messages. -.SH "DATA-GATHERING OPTIONS" -.TP -.B \-h -(Default.) -Look up the remote host name for -.BR TCPREMOTEHOST . -.TP -.B \-H -Do not look up the remote host name; -unset -.BR TCPREMOTEHOST . -.TP -.B \-l\fIlocalname -Do not look up the local host name; -use -.I localname -for -.BR TCPLOCALHOST . -.TP -.B \-r -(Default.) -Attempt to obtain -.B TCPREMOTEINFO -from the remote host. -.TP -.B \-R -Do not attempt to obtain -.B TCPREMOTEINFO -from the remote host. -.TP -.B \-t\fItimeoutinfo -Give up on the -.B TCPREMOTEINFO -connection attempt -after -.I timeoutinfo -seconds. Default: 26. -.TP -.B \-4 -Fall back to IPv4 sockets. This is necessary for terminally broken -systems like OpenBSD which will not let IPv6 sockets connect to -V4-mapped IPv6 addresses. Please note that this also applies to DNS -lookups, so you will have to use an DNS resolver with an IPv6 address to -connect to IPv6 systems. Use \fBDNSCACHEIP\fR to set the DNS resolver -IP dynamically. -.TP -.B \-6 -Force IPv6 mode in UCSPI environment variables, even for -IPv4 connections. This will set \fB$PROTO\fR to \fBTCP6\fR and put -IPv4-mapped IPv6 addresses in \fBTCPLOCALIP\fR and \fBTCPREMOTEIP\fR. -.SH "SEE ALSO" -date@(1), -finger@(1), -http@(1), -mconnect(1), -tcpcat(1), -tcpserver(1), -who@(1), -tcp-environ(5) diff --git a/tcpclient.c b/tcpclient.c index 77b1ad5..9f6d7f2 100644 --- a/tcpclient.c +++ b/tcpclient.c @@ -9,7 +9,6 @@ #include "scan.h" #include "str.h" #include "ip4.h" -#include "ip6.h" #include "uint16.h" #include "socket.h" #include "fd.h" @@ -21,7 +20,6 @@ #include "timeoutconn.h" #include "remoteinfo.h" #include "dns.h" -#include "byte.h" #define FATAL "tcpclient: fatal: " #define CONNECT "tcpclient: unable to connect to " @@ -33,30 +31,27 @@ void nomem(void) void usage(void) { strerr_die1x(100,"tcpclient: usage: tcpclient \ -[ -46hHrRdDqQv ] \ +[ -hHrRdDqQv ] \ [ -i localip ] \ [ -p localport ] \ [ -T timeoutconn ] \ [ -l localname ] \ [ -t timeoutinfo ] \ -[ -I interface ] \ host port program"); } -int forcev6 = 0; int verbosity = 1; int flagdelay = 1; int flagremoteinfo = 1; int flagremotehost = 1; unsigned long itimeout = 26; unsigned long ctimeout[2] = { 2, 58 }; -uint32 netif = 0; -char iplocal[16] = { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 }; +char iplocal[4] = { 0,0,0,0 }; uint16 portlocal = 0; char *forcelocal = 0; -char ipremote[16]; +char ipremote[4]; uint16 portremote; char *hostname; @@ -66,13 +61,12 @@ static stralloc moreaddresses; static stralloc tmp; static stralloc fqdn; char strnum[FMT_ULONG]; -char ipstr[IP6_FMT]; +char ipstr[IP4_FMT]; char seed[128]; main(int argc,char **argv) { - int fakev4=0; unsigned long u; int opt; char *x; @@ -86,10 +80,8 @@ main(int argc,char **argv) close(7); sig_ignore(sig_pipe); - while ((opt = getopt(argc,argv,"46dDvqQhHrRi:p:t:T:l:I:")) != opteof) + while ((opt = getopt(argc,argv,"dDvqQhHrRi:p:t:T:l:")) != opteof) switch(opt) { - case '4': noipv6 = 1; break; - case '6': forcev6 = 1; break; case 'd': flagdelay = 1; break; case 'D': flagdelay = 0; break; case 'v': verbosity = 2; break; @@ -105,8 +97,7 @@ main(int argc,char **argv) if (optarg[j] == '+') ++j; scan_ulong(optarg + j,&ctimeout[1]); break; - case 'i': if (!scan_ip6(optarg,iplocal)) usage(); break; - case 'I': netif=socket_getifidx(optarg); break; + case 'i': if (!ip4_scan(optarg,iplocal)) usage(); break; case 'p': scan_ulong(optarg,&u); portlocal = u; break; default: usage(); } @@ -117,8 +108,8 @@ main(int argc,char **argv) hostname = *argv; if (!hostname) usage(); - if (!hostname[0] || str_equal(hostname,"0")) - hostname = (noipv6?"127.0.0.1":"::1"); + if (str_equal(hostname,"")) hostname = "127.0.0.1"; + if (str_equal(hostname,"0")) hostname = "127.0.0.1"; x = *++argv; if (!x) usage(); @@ -136,36 +127,33 @@ main(int argc,char **argv) if (!*++argv) usage(); if (!stralloc_copys(&tmp,hostname)) nomem(); - if (dns_ip6_qualify(&addresses,&fqdn,&tmp) == -1) + if (dns_ip4_qualify(&addresses,&fqdn,&tmp) == -1) strerr_die4sys(111,FATAL,"temporarily unable to figure out IP address for ",hostname,": "); - if (addresses.len < 16) + if (addresses.len < 4) strerr_die3x(111,FATAL,"no IP address for ",hostname); - if (addresses.len == 16) { + if (addresses.len == 4) { ctimeout[0] += ctimeout[1]; ctimeout[1] = 0; } for (cloop = 0;cloop < 2;++cloop) { if (!stralloc_copys(&moreaddresses,"")) nomem(); - for (j = 0;j + 16 <= addresses.len;j += 4) { - s = socket_tcp6(); + for (j = 0;j + 4 <= addresses.len;j += 4) { + s = socket_tcp(); if (s == -1) strerr_die2sys(111,FATAL,"unable to create socket: "); - if (socket_bind6(s,iplocal,portlocal,netif) == -1) + if (socket_bind4(s,iplocal,portlocal) == -1) strerr_die2sys(111,FATAL,"unable to bind socket: "); - if (timeoutconn6(s,addresses.s + j,portremote,ctimeout[cloop],netif) == 0) + if (timeoutconn(s,addresses.s + j,portremote,ctimeout[cloop]) == 0) goto CONNECTED; close(s); if (!cloop && ctimeout[1] && (errno == error_timeout)) { - if (!stralloc_catb(&moreaddresses,addresses.s + j,16)) nomem(); + if (!stralloc_catb(&moreaddresses,addresses.s + j,4)) nomem(); } else { strnum[fmt_ulong(strnum,portremote)] = 0; - if (ip6_isv4mapped(addresses.s+j)) - ipstr[ip4_fmt(ipstr,addresses.s + j + 12)] = 0; - else - ipstr[ip6_fmt(ipstr,addresses.s + j)] = 0; + ipstr[ip4_fmt(ipstr,addresses.s + j)] = 0; strerr_warn5(CONNECT,ipstr," port ",strnum,": ",&strerr_sys); } } @@ -181,46 +169,37 @@ main(int argc,char **argv) if (!flagdelay) socket_tcpnodelay(s); /* if it fails, bummer */ - if (socket_local6(s,iplocal,&portlocal,&netif) == -1) - strerr_die2sys(111,FATAL,"unable to get local address: "); - - if (!forcev6 && (ip6_isv4mapped(iplocal) || byte_equal(iplocal,16,V6any))) - fakev4=1; + if (!pathexec_env("PROTO","TCP")) nomem(); - if (!pathexec_env("PROTO",fakev4?"TCP":"TCP6")) nomem(); + if (socket_local4(s,iplocal,&portlocal) == -1) + strerr_die2sys(111,FATAL,"unable to get local address: "); strnum[fmt_ulong(strnum,portlocal)] = 0; if (!pathexec_env("TCPLOCALPORT",strnum)) nomem(); - if (fakev4) - ipstr[ip4_fmt(ipstr,iplocal+12)] = 0; - else - ipstr[ip6_fmt(ipstr,iplocal)] = 0; + ipstr[ip4_fmt(ipstr,iplocal)] = 0; if (!pathexec_env("TCPLOCALIP",ipstr)) nomem(); x = forcelocal; if (!x) - if (dns_name6(&tmp,iplocal) == 0) { + if (dns_name4(&tmp,iplocal) == 0) { if (!stralloc_0(&tmp)) nomem(); x = tmp.s; } if (!pathexec_env("TCPLOCALHOST",x)) nomem(); - if (socket_remote6(s,ipremote,&portremote,&netif) == -1) + if (socket_remote4(s,ipremote,&portremote) == -1) strerr_die2sys(111,FATAL,"unable to get remote address: "); strnum[fmt_ulong(strnum,portremote)] = 0; if (!pathexec_env("TCPREMOTEPORT",strnum)) nomem(); - if (fakev4) - ipstr[ip4_fmt(ipstr,ipremote+12)] = 0; - else - ipstr[ip6_fmt(ipstr,ipremote)] = 0; + ipstr[ip4_fmt(ipstr,ipremote)] = 0; if (!pathexec_env("TCPREMOTEIP",ipstr)) nomem(); if (verbosity >= 2) strerr_warn4("tcpclient: connected to ",ipstr," port ",strnum,0); x = 0; if (flagremotehost) - if (dns_name6(&tmp,ipremote) == 0) { + if (dns_name4(&tmp,ipremote) == 0) { if (!stralloc_0(&tmp)) nomem(); x = tmp.s; } @@ -228,7 +207,7 @@ main(int argc,char **argv) x = 0; if (flagremoteinfo) - if (remoteinfo6(&tmp,ipremote,portremote,iplocal,portlocal,itimeout,netif) == 0) { + if (remoteinfo(&tmp,ipremote,portremote,iplocal,portlocal,itimeout) == 0) { if (!stralloc_0(&tmp)) nomem(); x = tmp.s; } diff --git a/tcprules.1 b/tcprules.1 deleted file mode 100644 index 084165b..0000000 --- a/tcprules.1 +++ /dev/null @@ -1,221 +0,0 @@ -.TH tcprules 1 -.SH NAME -tcprules \- compile rules for tcpserver -.SH SYNOPSIS -.B tcprules -.I rules.cdb -.I rules.tmp -.SH OVERVIEW -.B tcpserver -optionally follows rules to decide whether a TCP connection is acceptable. -For example, a rule of - -.EX - 18.23.0.32:deny -.EE - -prohibits connections from IP address 18.23.0.32. - -.B tcprules -reads rules from its standard input -and writes them into -.I rules.cdb -in a binary format suited -for quick access by -.BR tcpserver . - -.B tcprules -can be used while -.B tcpserver -is running: -it ensures that -.I rules.cdb -is updated atomically. -It does this by first writing the rules to -.I rules.tmp -and then moving -.I rules.tmp -on top of -.IR rules.cdb . -If -.I rules.tmp -already exists, it is destroyed. -The directories containing -.I rules.cdb -and -.I rules.tmp -must be writable to -.BR tcprules ; -they must also be on the same filesystem. - -If there is a problem with the input, -.B tcprules -complains and leaves -.I rules.cdb -alone. - -The binary -.I rules.cdb -format is portable across machines. -.SH "RULE FORMAT" -A rule takes up one line. -A file containing rules -may also contain comments: lines beginning with # are ignored. - -Each rule contains an -.BR address , -a colon, -and a list of -.BR instructions , -with no extra spaces. -When -.B tcpserver -receives a connection from that address, -it follows the instructions. -.SH "ADDRESSES" -.B tcpserver -starts by looking for a rule with address -.IR TCPREMOTEINFO\fB@\fITCPREMOTEIP . -If it doesn't find one, or if -.I TCPREMOTEINFO -is not set, it tries the address -.IR TCPREMOTEIP . -If that doesn't work, it tries shorter and shorter prefixes of -.I TCPREMOTEIP -ending with a dot. -If none of them work, it tries the empty string. - -For example, here are some rules: - -.EX - joe@127.0.0.1:first -.br - 18.23.0.32:second -.br - 127.:third -.br - :fourth -.br - ::1:fifth -.EE - -If -.I TCPREMOTEIP -is -.BR 10.119.75.38 , -.B tcpserver -will follow the -.B fourth -instructions. - -If -.I TCPREMOTEIP -is -.BR ::1 , -.B tcpserver -will follow the -.B fifth -instructions. Note that you cannot detect IPv4 mapped addresses by -matching "::ffff", as those addresses will be converted to IPv4 before -looking at the rules. - -If -.I TCPREMOTEIP -is -.BR 18.23.0.32 , -.B tcpserver -will follow the -.B second -instructions. - -If -.I TCPREMOTEINFO -is -.B bill -and -.I TCPREMOTEIP -is -.BR 127.0.0.1 , -.B tcpserver -will follow the -.B third -instructions. - -If -.I TCPREMOTEINFO -is -.B joe -and -.I TCPREMOTEIP -is -.BR 127.0.0.1 , -.B tcpserver -will follow the -.B first -instructions. -.SH "ADDRESS RANGES" -.B tcprules -treats -.B 1.2.3.37-53:ins -as an abbreviation -for the rules -.BR 1.2.3.37:ins , -.BR 1.2.3.38:ins , -and so on up through -.BR 1.2.3.53:ins . -Similarly, -.BR 10.2-3.:ins -is an abbreviation for -.B 10.2.:ins -and -.BR 10.3.:ins . -.SH "INSTRUCTIONS" -The instructions in a rule must begin with either -.B allow -or -.BR deny . -.B deny -tells -.B tcpserver -to drop the connection without running anything. -For example, the rule - -.EX - :deny -.EE - -tells -.B tcpserver -to drop all connections that aren't handled by more specific rules. - -The instructions may continue with some environment variables, -in the format -.IR ,VAR="VALUE" . -.B tcpserver -adds -.I VAR=VALUE -to the current environment. -For example, - -.EX - 10.0.:allow,RELAYCLIENT="@fix.me" -.EE - -adds -.B RELAYCLIENT=@fix.me -to the environment. -The quotes here may be replaced by any repeated character: - -.EX - 10.0.:allow,RELAYCLIENT=/@fix.me/ -.EE - -Any number of variables may be listed: - -.EX - 127.0.0.1:allow,RELAYCLIENT="",TCPLOCALHOST="movie.edu" -.EE -.SH "SEE ALSO" -tcprulescheck(1), -tcpserver(1), -tcp-environ(5) @@ -123,15 +123,8 @@ main(int argc,char **argv) } line.len = len; /* for die_bad() */ - colon = 0; - for (;;) { - int tmp; - tmp = byte_chr(x + colon,len - colon,':'); - colon += tmp; - if (colon == len) continue; - if (byte_equal(x+colon+1,4,"deny") || byte_equal(x+colon+1,5,"allow")) break; - ++colon; - } + colon = byte_chr(x,len,':'); + if (colon == len) continue; if (!stralloc_copyb(&address,x,colon)) nomem(); if (!stralloc_copys(&data,"")) nomem(); diff --git a/tcprulescheck.1 b/tcprulescheck.1 deleted file mode 100644 index 3f0de24..0000000 --- a/tcprulescheck.1 +++ /dev/null @@ -1,25 +0,0 @@ -.TH tcprulescheck 1 -.SH NAME -tcprulescheck \- try out rules for tcpserver -.SH SYNTAX -.B tcprulescheck -.I rules.cdb -.I tcpremoteip -[ -.I tcpremoteinfo -] -.SH DESCRIPTION -.B tcprulescheck -says what -.B tcpserver -will do with a connection from -IP address -.IR tcpremoteip , -following the rules compiled into -.I rules.cdb -by -.BR tcprules . -.SH "SEE ALSO" -tcprules(1), -tcpserver(1), -tcp-environ(5) diff --git a/tcpserver.1 b/tcpserver.1 deleted file mode 100644 index 72c5ca0..0000000 --- a/tcpserver.1 +++ /dev/null @@ -1,266 +0,0 @@ -.TH tcpserver 1 -.SH NAME -tcpserver \- accept incoming TCP connections -.SH SYNOPSIS -.B tcpserver -[ -.B \-146jpPhHrRoOdDqQv -] -[ -.B \-c\fIlimit -] -[ -.B \-x\fIrules.cdb -] -[ -.B \-B\fIbanner -] -[ -.B \-g\fIgid -] -[ -.B \-u\fIuid -] -[ -.B \-b\fIbacklog -] -[ -.B \-l\fIlocalname -] -[ -.B \-t\fItimeout -] -[ -.B \-I\fIinterface -] -.I host -.I port -.I program -[ -.I arg ... -] -.SH DESCRIPTION -.B tcpserver -waits for connections from TCP clients. -For each connection, it runs -.I program -with the given arguments, -with descriptor 0 reading from the network -and descriptor 1 writing to the network. - -The server's address is given by -.I host -and -.IR port . -.I host -can be 0, allowing connections from any host; -or a particular IP address, -allowing connections only to that address; -or a host name, allowing connections to the first IP address -for that host. -.I port -may be a numeric port number -or a port name. -If -.I port -is 0, -.B tcpserver -will choose a free port. - -.B tcpserver -sets up several environment variables, -as described in -.B tcp-environ(5). - -.B tcpserver -exits when it receives SIGTERM. -.SH "OPTIONS" -.TP -.B \-c\fIlimit -Do not handle more than -.I limit -simultaneous connections. -If there are -.I limit -simultaneous copies of -.I program -running, defer acceptance of a new connection -until one copy finishes. -.I limit -must be a positive integer. -Default: 40. -.TP -.B \-x\fIrules.cdb -Follow the rules compiled into -.I rules.cdb -by -.BR tcprules . -These rules may specify setting environment variables -or rejecting connections from bad sources. - -.B tcpserver -does not read -.I rules.cdb -into memory; -you can rerun -.B tcprules -to change -.BR tcpserver 's -behavior on the fly. -.TP -.B \-B\fIbanner -Write -.I banner -to the network immediately after each connection is made. -.B tcpserver -writes -.I banner -before looking up -.BR TCPREMOTEHOST , -before looking up -.BR TCPREMOTEINFO , -and before checking -.IR rules.cdb . - -This feature can be used to reduce latency in protocols -where the client waits for a greeting from the server. -.TP -.B \-g\fIgid -Switch group ID to -.I gid -after preparing to receive connections. -.I gid -must be a positive integer. -.TP -.B \-u\fIuid -Switch user ID to -.I uid -after preparing to receive connections. -.I uid -must be a positive integer. -.TP -.B \-1 -After preparing to receive connections, -print the local port number to standard output. -.TP -.B \-4 -Fall back to IPv4 sockets. This is necessary for terminally broken -systems like OpenBSD which will not let IPv6 sockets connect to -V4-mapped IPv6 addresses. Please note that this also applies to DNS -lookups, so you will have to use an DNS resolver with an IPv6 address to -accept IPv6 connections. Use \fBDNSCACHEIP\fR to set the DNS resolver -IP dynamically. -.TP -.B \-6 -Force IPv6 mode in UCSPI environment variables, even for -IPv4 connections. This will set \fB$PROTO\fR to \fBTCP6\fR and put -IPv4-mapped IPv6 addresses in \fBTCPLOCALIP\fR and \fBTCPREMOTEIP\fR. -.TP -.B \-I\fIinterface -Bind to the network interface -.I interface -("eth0" on Linux, for example). This is only defined and needed for -IPv6 link-local addresses. -.TP -.B \-b\fIbacklog -Allow up to -.I backlog -simultaneous SYN_RECEIVEDs. -Default: 20. -On some systems, -.I backlog -is silently limited to 5. -See -.BR listen (2) -for more details. -.TP -.B \-o -Leave IP options alone. -If the client is sending packets along an IP source route, -send packets back along the same route. -.TP -.B \-O -(Default.) -Kill IP options. -A client can still use source routing to connect and to send data, -but packets will be sent back along the default route. -.TP -.B \-d -(Default.) -Delay sending data for a fraction of a second whenever the -remote host is responding slowly, -to make better use of the network. -.TP -.B \-D -Never delay sending data; -enable TCP_NODELAY. -This is appropriate for interactive connections. -.TP -.B \-q -Quiet. -Do not print any messages. -.TP -.B \-Q -(Default.) -Print error messages. -.TP -.B \-v -Verbose. -Print all available messages. -.SH "DATA-GATHERING OPTIONS" -.TP -.B \-p -Paranoid. -After looking up the remote host name, -look up the IP addresses for that name, -and make sure one of them matches -.BR TCPREMOTEIP . -If none of them do, -unset -.BR TCPREMOTEHOST . -.TP -.B \-P -(Default.) -Not paranoid. -.TP -.B \-h -(Default.) -Look up the remote host name and set -.BR TCPREMOTEHOST . -.TP -.B \-H -Do not look up the remote host name. -.TP -.B \-l\fIlocalname -Do not look up the local host name; -use -.I localname -for -.BR TCPLOCALHOST . -.TP -.B \-r -(Default.) -Attempt to obtain -.B TCPREMOTEINFO -from the remote host. -.TP -.B \-R -Do not attempt to obtain -.B TCPREMOTEINFO -from the remote host. -.TP -.B \-t\fItimeout -Give up on the -.B TCPREMOTEINFO -connection attempt -after -.I timeout -seconds. Default: 26. -.SH "SEE ALSO" -argv0(1), -fixcr(1), -recordio(1), -tcpclient(1), -tcprules(1), -listen(2), -tcp-environ(5) diff --git a/tcpserver.c b/tcpserver.c index aab637f..979a0be 100644 --- a/tcpserver.c +++ b/tcpserver.c @@ -7,7 +7,6 @@ #include "fmt.h" #include "scan.h" #include "ip4.h" -#include "ip6.h" #include "fd.h" #include "exit.h" #include "env.h" @@ -29,7 +28,6 @@ #include "sig.h" #include "dns.h" -int forcev6 = 0; int verbosity = 1; int flagkillopts = 1; int flagdelay = 1; @@ -38,21 +36,20 @@ int flagremoteinfo = 1; int flagremotehost = 1; int flagparanoid = 0; unsigned long timeout = 26; -uint32 netif = 0; static stralloc tcpremoteinfo; uint16 localport; char localportstr[FMT_ULONG]; -char localip[16]; -char localipstr[IP6_FMT]; +char localip[4]; +char localipstr[IP4_FMT]; static stralloc localhostsa; char *localhost = 0; uint16 remoteport; char remoteportstr[FMT_ULONG]; -char remoteip[16]; -char remoteipstr[IP6_FMT]; +char remoteip[4]; +char remoteipstr[IP4_FMT]; static stralloc remotehostsa; char *remotehost = 0; @@ -99,12 +96,12 @@ void safecats(char *s) if (ch < 33) ch = '?'; if (ch > 126) ch = '?'; if (ch == '%') ch = '?'; /* logger stupidity */ -/* if (ch == ':') ch = '?'; */ + if (ch == ':') ch = '?'; append(&ch); } cats("..."); } -void env(const char *s,const char *t) +void env(char *s,char *t) { if (!pathexec_env(s,t)) drop_nomem(); } @@ -138,16 +135,9 @@ void found(char *data,unsigned int datalen) void doit(int t) { - int fakev4=0; int j; - uint32 scope_id; - if (!forcev6 && ip6_isv4mapped(remoteip)) - fakev4=1; - if (fakev4) - remoteipstr[ip4_fmt(remoteipstr,remoteip+12)] = 0; - else - remoteipstr[ip6_fmt(remoteipstr,remoteip)] = 0; + remoteipstr[ip4_fmt(remoteipstr,remoteip)] = 0; if (verbosity >= 2) { strnum[fmt_ulong(strnum,getpid())] = 0; @@ -165,40 +155,30 @@ void doit(int t) strerr_die2sys(111,DROP,"unable to print banner: "); } - if (socket_local6(t,localip,&localport,&scope_id) == -1) + if (socket_local4(t,localip,&localport) == -1) strerr_die2sys(111,DROP,"unable to get local address: "); - if (fakev4) - localipstr[ip4_fmt(localipstr,localip+12)] = 0; - else - localipstr[ip6_fmt(localipstr,localip)] = 0; + localipstr[ip4_fmt(localipstr,localip)] = 0; remoteportstr[fmt_ulong(remoteportstr,remoteport)] = 0; if (!localhost) - if (dns_name6(&localhostsa,localip) == 0) + if (dns_name4(&localhostsa,localip) == 0) if (localhostsa.len) { if (!stralloc_0(&localhostsa)) drop_nomem(); localhost = localhostsa.s; } - env("PROTO",fakev4?"TCP":"TCP6"); + env("PROTO","TCP"); env("TCPLOCALIP",localipstr); - localipstr[ip6_fmt(localipstr,localip)]=0; - env("TCP6LOCALIP",localipstr); - env("TCPLOCALPORT",localportstr); - env("TCP6LOCALPORT",localportstr); env("TCPLOCALHOST",localhost); - env("TCP6LOCALHOST",localhost); - if (!fakev4 && scope_id) - env("TCP6INTERFACE",socket_getifname(scope_id)); if (flagremotehost) - if (dns_name6(&remotehostsa,remoteip) == 0) + if (dns_name4(&remotehostsa,remoteip) == 0) if (remotehostsa.len) { if (flagparanoid) - if (dns_ip6(&tmp,&remotehostsa) == 0) - for (j = 0;j + 16 <= tmp.len;j += 16) - if (byte_equal(remoteip,16,tmp.s + j)) { + if (dns_ip4(&tmp,&remotehostsa) == 0) + for (j = 0;j + 4 <= tmp.len;j += 4) + if (byte_equal(remoteip,4,tmp.s + j)) { flagparanoid = 0; break; } @@ -208,20 +188,15 @@ void doit(int t) } } env("TCPREMOTEIP",remoteipstr); - remoteipstr[ip6_fmt(remoteipstr,remoteip)]=0; - env("TCP6REMOTEIP",remoteipstr); env("TCPREMOTEPORT",remoteportstr); - env("TCP6REMOTEPORT",remoteportstr); env("TCPREMOTEHOST",remotehost); - env("TCP6REMOTEHOST",remotehost); if (flagremoteinfo) { - if (remoteinfo6(&tcpremoteinfo,remoteip,remoteport,localip,localport,timeout,netif) == -1) + if (remoteinfo(&tcpremoteinfo,remoteip,remoteport,localip,localport,timeout) == -1) flagremoteinfo = 0; if (!stralloc_0(&tcpremoteinfo)) drop_nomem(); } env("TCPREMOTEINFO",flagremoteinfo ? tcpremoteinfo.s : 0); - env("TCP6REMOTEINFO",flagremoteinfo ? tcpremoteinfo.s : 0); if (fnrules) { int fdrules; @@ -231,15 +206,7 @@ void doit(int t) if (!flagallownorules) drop_rules(); } else { - int fakev4=0; - char* temp; - if (!forcev6 && ip6_isv4mapped(remoteip)) - fakev4=1; - if (fakev4) - temp=remoteipstr+7; - else - temp=remoteipstr; - if (rules(found,fdrules,temp,remotehost,flagremoteinfo ? tcpremoteinfo.s : 0) == -1) drop_rules(); + if (rules(found,fdrules,remoteipstr,remotehost,flagremoteinfo ? tcpremoteinfo.s : 0) == -1) drop_rules(); close(fdrules); } } @@ -273,7 +240,7 @@ void usage(void) { strerr_warn1("\ tcpserver: usage: tcpserver \ -[ -461UXpPhHrRoOdDqQv ] \ +[ -1UXpPhHrRoOdDqQv ] \ [ -c limit ] \ [ -x rules.cdb ] \ [ -B banner ] \ @@ -282,7 +249,6 @@ tcpserver: usage: tcpserver \ [ -b backlog ] \ [ -l localname ] \ [ -t timeout ] \ -[ -I interface ] \ host port program",0); _exit(100); } @@ -333,8 +299,8 @@ main(int argc,char **argv) unsigned long u; int s; int t; - - while ((opt = getopt(argc,argv,"46dDvqQhHrR1UXx:t:u:g:l:b:B:c:I:pPoO")) != opteof) + + while ((opt = getopt(argc,argv,"dDvqQhHrR1UXx:t:u:g:l:b:B:c:pPoO")) != opteof) switch(opt) { case 'b': scan_ulong(optarg,&backlog); break; case 'c': scan_ulong(optarg,&limit); break; @@ -359,10 +325,7 @@ main(int argc,char **argv) x = env_get("GID"); if (x) scan_ulong(x,&gid); break; case 'u': scan_ulong(optarg,&uid); break; case 'g': scan_ulong(optarg,&gid); break; - case 'I': netif=socket_getifidx(optarg); break; case '1': flag1 = 1; break; - case '4': noipv6 = 1; break; - case '6': forcev6 = 1; break; case 'l': localhost = optarg; break; default: usage(); } @@ -374,7 +337,8 @@ main(int argc,char **argv) hostname = *argv++; if (!hostname) usage(); - if (str_equal(hostname,"")) hostname = "0"; + if (str_equal(hostname,"")) hostname = "0.0.0.0"; + if (str_equal(hostname,"0")) hostname = "0.0.0.0"; x = *argv++; if (!x) usage(); @@ -384,7 +348,7 @@ main(int argc,char **argv) se = getservbyname(x,"tcp"); if (!se) strerr_die3x(111,FATAL,"unable to figure out port number for ",x); - uint16_unpack_big((char*)&se->s_port,&localport); + localport = ntohs(se->s_port); } if (!*argv) usage(); @@ -394,26 +358,20 @@ main(int argc,char **argv) sig_catch(sig_term,sigterm); sig_ignore(sig_pipe); - if (str_equal(hostname,"0")) { - byte_zero(localip,sizeof localip); - } else { - if (!stralloc_copys(&tmp,hostname)) - strerr_die2x(111,FATAL,"out of memory"); - if (dns_ip6_qualify(&addresses,&fqdn,&tmp) == -1) - strerr_die4sys(111,FATAL,"temporarily unable to figure out IP address for ",hostname,": "); - if (addresses.len < 16) - strerr_die3x(111,FATAL,"no IP address for ",hostname); - byte_copy(localip,16,addresses.s); - if (ip6_isv4mapped(localip)) - noipv6=1; - } - - s = socket_tcp6(); + if (!stralloc_copys(&tmp,hostname)) + strerr_die2x(111,FATAL,"out of memory"); + if (dns_ip4_qualify(&addresses,&fqdn,&tmp) == -1) + strerr_die4sys(111,FATAL,"temporarily unable to figure out IP address for ",hostname,": "); + if (addresses.len < 4) + strerr_die3x(111,FATAL,"no IP address for ",hostname); + byte_copy(localip,4,addresses.s); + + s = socket_tcp(); if (s == -1) strerr_die2sys(111,FATAL,"unable to create socket: "); - if (socket_bind6_reuse(s,localip,localport,netif) == -1) + if (socket_bind4_reuse(s,localip,localport) == -1) strerr_die2sys(111,FATAL,"unable to bind: "); - if (socket_local6(s,localip,&localport,&netif) == -1) + if (socket_local4(s,localip,&localport) == -1) strerr_die2sys(111,FATAL,"unable to get local address: "); if (socket_listen(s,backlog) == -1) strerr_die2sys(111,FATAL,"unable to listen: "); @@ -441,7 +399,7 @@ main(int argc,char **argv) while (numchildren >= limit) sig_pause(); sig_unblock(sig_child); - t = socket_accept6(s,remoteip,&remoteport,&netif); + t = socket_accept4(s,remoteip,&remoteport); sig_block(sig_child); if (t == -1) continue; diff --git a/timeoutconn.h b/timeoutconn.h index 01e6a75..7f9dcc9 100644 --- a/timeoutconn.h +++ b/timeoutconn.h @@ -2,9 +2,7 @@ #define TIMEOUTCONN_H #include "uint16.h" -#include "uint32.h" extern int timeoutconn(int,char *,uint16,unsigned int); -extern int timeoutconn6(int,char *,uint16,unsigned int,uint32); #endif diff --git a/timeoutconn6.c b/timeoutconn6.c deleted file mode 100644 index 75e9f5a..0000000 --- a/timeoutconn6.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "ndelay.h" -#include "socket.h" -#include "iopause.h" -#include "error.h" -#include "timeoutconn.h" - -int timeoutconn6(int s,char ip[16],uint16 port,unsigned int timeout,uint32 netif) -{ - struct taia now; - struct taia deadline; - iopause_fd x; - - if (socket_connect6(s,ip,port,netif) == -1) { - if ((errno != error_wouldblock) && (errno != error_inprogress)) return -1; - x.fd = s; - x.events = IOPAUSE_WRITE; - taia_now(&now); - taia_uint(&deadline,timeout); - taia_add(&deadline,&now,&deadline); - for (;;) { - taia_now(&now); - iopause(&x,1,&deadline,&now); - if (x.revents) break; - if (taia_less(&deadline,&now)) { - errno = error_timeout; /* note that connect attempt is continuing */ - return -1; - } - } - if (!socket_connected(s)) return -1; - } - - if (ndelay_off(s) == -1) return -1; - return 0; -} diff --git a/tryip6.c b/tryip6.c deleted file mode 100644 index e0d7cfb..0000000 --- a/tryip6.c +++ /dev/null @@ -1,8 +0,0 @@ -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> - -main() { - struct sockaddr_in6 sa; - sa.sin6_family = PF_INET6; -} diff --git a/ucspi-rss.diff b/ucspi-rss.diff deleted file mode 100644 index 903125e..0000000 --- a/ucspi-rss.diff +++ /dev/null @@ -1,64 +0,0 @@ -diff -ruN --exclude conf-* ucspi-tcp-0.88/rblsmtpd.c ucspi-tcp-0.88.fix/rblsmtpd.c ---- ucspi-tcp-0.88/rblsmtpd.c Sat Mar 18 10:18:42 2000 -+++ ucspi-tcp-0.88.fix/rblsmtpd.c Wed Aug 9 16:42:33 2000 -@@ -60,16 +60,54 @@ - - void rbl(char *base) - { -+ int i; -+ char *altreply = 0; - if (decision) return; - if (!stralloc_copy(&tmp,&ip_reverse)) nomem(); -+ i = str_chr(base, ':'); -+ if (base[i]) { -+ base[i] = 0; -+ altreply = base+i+1; -+ } - if (!stralloc_cats(&tmp,base)) nomem(); -- if (dns_txt(&text,&tmp) == -1) { -- flagmustnotbounce = 1; -- if (flagfailclosed) { -- if (!stralloc_copys(&text,"temporary RBL lookup error")) nomem(); -- decision = 2; -+ if (altreply) { -+ if (dns_ip4(&text,&tmp) == -1) { -+ flagmustnotbounce = 1; -+ if (flagfailclosed) { -+ if (!stralloc_copys(&text,"temporary RBL lookup error")) nomem(); -+ decision = 2; -+ } -+ return; -+ } -+ if (text.len) { -+ if(!stralloc_copys(&text, "")) nomem(); -+ while(*altreply) { -+ char *x; -+ i = str_chr(altreply, '%'); -+ if(!stralloc_catb(&text, altreply, i)) nomem(); -+ if(altreply[i] && -+ altreply[i+1]=='I' && -+ altreply[i+2]=='P' && -+ altreply[i+3]=='%') { -+ if(!stralloc_catb(&text, ip_env, str_len(ip_env))) nomem(); -+ altreply+=i+4; -+ } else if(altreply[i]) { -+ if(!stralloc_cats(&text, "%")) nomem(); -+ altreply+=i+1; -+ } else { -+ altreply+=i; -+ } -+ } -+ } -+ } else { -+ if (dns_txt(&text,&tmp) == -1) { -+ flagmustnotbounce = 1; -+ if (flagfailclosed) { -+ if (!stralloc_copys(&text,"temporary RBL lookup error")) nomem(); -+ decision = 2; -+ } -+ return; - } -- return; - } - if (text.len) - if (flagrblbounce) @@ -1,32 +0,0 @@ -.TH who@ 1 -.SH NAME -who@ \- print list of active users on a host -.SH SYNTAX -.B who@ -[ -.I host -] -.SH DESCRIPTION -.B who@ -connects to TCP port 11 (Systat) on -.I host -and prints any data it receives. -It removes CR and converts unprintable characters to a visible format. - -If -.I host -is not supplied, -.B who@ -connects to the local host. - -Some computers respond to port 11 with a list of active users. -For example, they may be running - -.EX - tcpserver 0 11 who & -.EE -.SH "SEE ALSO" -cat(1), -delcr(1), -tcpclient(1), -tcpserver(1) |