1
0
mirror of https://github.com/moparisthebest/socat synced 2024-10-31 15:25:01 -04:00

port to Dragonfly

This commit is contained in:
Gerhard Rieger 2011-11-26 14:56:19 +01:00
parent 490a01d245
commit 3ef7b3e366
5 changed files with 30 additions and 3 deletions

View File

@ -87,6 +87,9 @@ porting:
minor corrections to docu and test.sh resulting from local compilation
on Openmoko SHR
fixed sa_family_t compile error on DragonFly. Thanks to Tony Young for
reporting this issue and sending a patch.
new features:
added option max-children that limits the number of concurrent child
processes. Thanks to Sam Liddicott for providing the patch.

View File

@ -143,6 +143,9 @@
/* Define if you have the hstrerror prototype */
#undef HAVE_PROTOTYPE_HSTRERROR
/* Define if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H

View File

@ -53,6 +53,7 @@ export CFLAGS
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(inttypes.h)
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h limits.h strings.h sys/param.h sys/ioctl.h sys/time.h syslog.h unistd.h)
AC_CHECK_HEADERS(pwd.h grp.h stdint.h sys/types.h sys/poll.h sys/socket.h sys/uio.h sys/stat.h netdb.h sys/un.h)
@ -864,6 +865,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
AC_MSG_CHECKING(for sa_family_t)
AC_CACHE_VAL(sc_cv_type_sa_family_t,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>],[sa_family_t s;],
[sc_cv_type_sa_family_t=yes],
[sc_cv_type_sa_family_t=no])])

View File

@ -1,10 +1,13 @@
/* source: sysincludes.h */
/* Copyright Gerhard Rieger 2001-2009 */
/* Copyright Gerhard Rieger 2001-2011 */
/* Published under the GNU General Public License V.2, see file COPYING */
#ifndef __sysincludes_h_included
#define __sysincludes_h_included 1
#if HAVE_INTTYPES_H
#include <inttypes.h> /* uint16_t */
#endif
#if HAVE_LIMITS_H
#include <limits.h> /* USHRT_MAX */
#endif

20
test.sh
View File

@ -130,7 +130,8 @@ OpenBSD)IFCONFIG=/sbin/ifconfig ;;
OSF1) IFCONFIG=/sbin/ifconfig ;;
SunOS) IFCONFIG=/sbin/ifconfig ;;
Darwin)IFCONFIG=/sbin/ifconfig ;;
#*) IFCONFIG=/sbin/ifconfig ;;
DragonFly) IFCONFIG=/sbin/ifconfig ;;
*) IFCONFIG=/sbin/ifconfig ;;
esac
# for some tests we need a second local IPv4 address
@ -161,6 +162,12 @@ SunOS)
#BCIFADDR="$SECONDADDR"
#BCADDR=$($IFCONFIG $BROADCASTIF |grep 'broadcast ' |sed 's/.*broadcast/broadcast/' |awk '{print($2);}')
;;
DragonFly)
MAINIF=$($IFCONFIG -a |grep -v ^lp |grep '^[a-z]' |grep -v '^lo0: ' |head -1 |cut -d: -f1)
BROADCASTIF="$MAINIF"
SECONDADDR=$($IFCONFIG $BROADCASTIF |grep 'inet ' |awk '{print($2);}')
BCIFADDR="$SECONDADDR"
BCADDR=$($IFCONFIG $BROADCASTIF |grep 'broadcast ' |sed 's/.*broadcast/broadcast/' |awk '{print($2);}') ;;
#AIX|FreeBSD|Solaris)
*)
SECONDADDR=$(expr "$($IFCONFIG -a |grep 'inet ' |fgrep -v ' 127.0.0.1 ' |head -n 1)" : '.*inet \([0-9.]*\) .*')
@ -1610,6 +1617,7 @@ ifprocess () {
NetBSD) l="$(ps -aj |grep "^[^ ][^ ]*[ ][ ]*$(printf %5u $1) ")" ;;
OpenBSD) l="$(ps -kaj |grep "^........ $(printf %5u $1)")" ;;
SunOS) l="$(ps -fade |grep "^........ $(printf %5u $1)")" ;;
DragonFly)l="$(ps -faje |grep "^[^ ][^ ]*[ ][ ]*$(printf %5u $1)")" ;;
*) l="$(ps -fade |grep "^[^ ][^ ]*[ ][ ]*$(printf %5u $1) ")" ;;
esac
if [ -z "$l" ]; then
@ -1633,6 +1641,7 @@ childprocess () {
NetBSD) l="$(ps -aj |grep "^[^ ][^ ]*[ ][ ]*..... $(printf %5u $1)")" ;;
OpenBSD) l="$(ps -aj |grep "^........ ..... $(printf %5u $1)")" ;;
SunOS) l="$(ps -fade |grep "^........ ..... $(printf %5u $1)")" ;;
DragonFly)l="$(ps -faje |grep "^[^ ][^ ]*[ ][ ]*..... $(printf %5u $1)")" ;;
*) l="$(ps -fade |grep "^[^ ][^ ]*[ ][ ]*[0-9][0-9]**[ ][ ]*$(printf %5u $1) ")" ;; esac
if [ -z "$l" ]; then
return 1;
@ -1652,6 +1661,7 @@ isdefunct () {
HP-UX) l="$(echo "$1" |grep ' <defunct>$')" ;;
Linux) l="$(echo "$1" |grep ' <defunct>$')" ;;
SunOS) l="$(echo "$1" |grep ' <defunct>$')" ;;
DragonFly)l="$(echo "$1" |grep ' <defunct>$')" ;;
*) l="$(echo "$1" |grep ' <defunct>$')" ;;
esac
[ -n "$l" ];
@ -1672,7 +1682,8 @@ runsip4 () {
OSF1) l=$($IFCONFIG -a |grep ' inet ') ;;
SunOS) l=$($IFCONFIG -a |grep 'inet ') ;;
Darwin)l=$($IFCONFIG lo0 |fgrep 'inet 127.0.0.1 ') ;;
# *) l=$($IFCONFIG -a |grep ' ::1[^:0-9A-Fa-f]') ;;
DragonFly)l=$($IFCONFIG -a |fgrep 'inet 127.0.0.1 ');;
*) l=$($IFCONFIG -a |grep ' ::1[^:0-9A-Fa-f]') ;;
esac
[ -z "$l" ] && return 1
# existence of interface might not suffice, check for routeability:
@ -1831,6 +1842,7 @@ checktcp4port () {
HP-UX) l=$(netstat -an |grep '^tcp 0 0 .*[0-9*]\.'$port' .* LISTEN$') ;;
OSF1) l=$(/usr/sbin/netstat -an |grep '^tcp 0 0 .*[0-9*]\.'$port' [ ]*\*\.\* [ ]*LISTEN') ;;
CYGWIN*) l=$(netstat -an -p TCP |grep '^ TCP [0-9.]*:'$port' .* LISTENING') ;;
DragonFly)l=$(netstat -ant |grep '^tcp4 .* .*[0-9*]\.'$port' [ ]* \*\.\* [ ]* LISTEN.*') ;;
*) l=$(netstat -an |grep -i 'tcp .*[0-9*][:.]'$port' .* listen') ;;
esac
[ -z "$l" ] && return 0
@ -1859,6 +1871,7 @@ waittcp4port () {
HP-UX) l=$(netstat -an |grep '^tcp 0 0 .*[0-9*]\.'$port' .* LISTEN$') ;;
OSF1) l=$(/usr/sbin/netstat -an |grep '^tcp 0 0 .*[0-9*]\.'$port' [ ]*\*\.\* [ ]*LISTEN') ;;
CYGWIN*) l=$(netstat -an -p TCP |grep '^ TCP [0-9.]*:'$port' .* LISTENING') ;;
DragonFly) l=$(netstat -ant |grep '^tcp4 .* .*[0-9*]\.'$port' [ ]* \*\.\* [ ]* LISTEN.*') ;;
*) l=$(netstat -an |grep -i 'tcp .*[0-9*][:.]'$port' .* listen') ;;
esac
[ \( \( $logic -ne 0 \) -a -n "$l" \) -o \
@ -1893,6 +1906,7 @@ waitudp4port () {
SunOS) l=$(netstat -an -f inet -P udp |grep '.*[1-9*]\.'$port' [ ]*Idle') ;;
HP-UX) l=$(netstat -an |grep '^udp 0 0 .*[0-9*]\.'$port' .* \*\.\* ') ;;
OSF1) l=$(/usr/sbin/netstat -an |grep '^udp 0 0 .*[0-9*]\.'$port' [ ]*\*\.\*') ;;
DragonFly) l=$(netstat -an |grep '^udp4 .* .*[0-9*]\.'$port' [ ]* \*\.\* [ ]*') ;;
*) l=$(netstat -an |grep -i 'udp .*[0-9*][:.]'$port' ') ;;
esac
[ \( \( $logic -ne 0 \) -a -n "$l" \) -o \
@ -1957,6 +1971,7 @@ waittcp6port () {
AIX) l=$(netstat -an |grep '^tcp[6 ] 0 0 .*[*0-9]\.'$port' .* LISTEN$') ;;
SunOS) l=$(netstat -an -f inet6 -P tcp |grep '.*[1-9*]\.'$port' .*\* [ ]* 0 .* LISTEN') ;;
#OSF1) l=$(/usr/sbin/netstat -an |grep '^tcp6 0 0 .*[0-9*]\.'$port' [ ]*\*\.\* [ ]*LISTEN') /*?*/;;
DragonFly) l=$(netstat -ant |grep '^tcp6 .* .*[0-9*]\.'$port' [ ]* \*\.\* [ ]* LISTEN.*') ;;
*) l=$(netstat -an |grep -i 'tcp6 .*:'$port' .* listen') ;;
esac
[ \( \( $logic -ne 0 \) -a -n "$l" \) -o \
@ -1988,6 +2003,7 @@ waitudp6port () {
SunOS) l=$(netstat -an -f inet6 -P udp |grep '.*[1-9*]\.'$port' [ ]*Idle') ;;
#HP-UX) l=$(netstat -an |grep '^udp 0 0 .*[0-9*]\.'$port' ') ;;
#OSF1) l=$(/usr/sbin/netstat -an |grep '^udp6 0 0 .*[0-9*]\.'$port' [ ]*\*\.\*') ;;
DragonFly) l=$(netstat -ant |grep '^udp6 .* .*[0-9*]\.'$port' [ ]* \*\.\* [ ]*') ;;
*) l=$(netstat -an |grep -i 'udp .*[0-9*][:.]'$port' ') ;;
esac
[ \( \( $logic -ne 0 \) -a -n "$l" \) -o \