#This patch was developed both in-house and from outside. We plan to submit it
#upstream, but do not yet have a target date for doing so
#
# HG changeset patch
# Parent 02c913c373b6ffeeb6e834a88be908a57449c8f7
revert back from man5 to man4
tt: Enter commit message. Lines beginning with 'HG:' are removed.
diff -r 02c913c373b6 Makefile.am
--- a/Makefile.am Mon Apr 04 12:52:48 2016 -0700
+++ b/Makefile.am Mon Apr 25 16:21:25 2016 -0700
@@ -7,9 +7,9 @@
install-data-hook:
if test -e $(DESTDIR)$(sysconfdir)/libsdp.conf; then \
- diff -q $(srcdir)/libsdp.conf $(DESTDIR)$(sysconfdir)/libsdp.conf 1> /dev/null; \
+ diff $(srcdir)/libsdp.conf $(DESTDIR)$(sysconfdir)/libsdp.conf 1> /dev/null; \
if test $$? == 1; then \
- t=$(shell date +'%Y%m%d%H%M%S'); \
+ t=$(shell date +'m%d09/20/10M%S'); \
cp -p $(srcdir)/libsdp.conf \
$(DESTDIR)$(sysconfdir)/libsdp.conf.$$t; \
echo "NOTE: existing libsdp.conf was not updated."; \
diff -r 02c913c373b6 Makefile.in
--- a/Makefile.in Mon Apr 04 12:52:48 2016 -0700
+++ b/Makefile.in Mon Apr 25 16:21:25 2016 -0700
@@ -59,6 +59,12 @@
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
+am__installdirs = "$(DESTDIR)$(man3libdir)" "$(DESTDIR)$(man4dir)"
+man3libdir = $(mandir)/man3lib
+man4dir = $(mandir)/man4
+NROFF = nroff
+man_MANS = man/libsdp.3lib man/libsdp.conf.4
+MANS = $(man_MANS)
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
@@ -114,8 +120,6 @@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
-LINUX_BUILD_FALSE = @LINUX_BUILD_FALSE@
-LINUX_BUILD_TRUE = @LINUX_BUILD_TRUE@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
@@ -131,11 +135,8 @@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
-SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
-SOLARIS_BUILD_FALSE = @SOLARIS_BUILD_FALSE@
-SOLARIS_BUILD_TRUE = @SOLARIS_BUILD_TRUE@
STRIP = @STRIP@
VERSION = @VERSION@
WANT_LIBSDP_SYS_FALSE = @WANT_LIBSDP_SYS_FALSE@
@@ -185,7 +186,7 @@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
SUBDIRS = src
-EXTRA_DIST = libsdp.spec.in libsdp.conf
+EXTRA_DIST = libsdp.spec.in libsdp.conf libsdp.3lib libsdp.conf.4
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
@@ -252,6 +253,96 @@
distclean-libtool:
-rm -f libtool
uninstall-info-am:
+install-man4: $(man4_MANS) $(man_MANS)
+ @$(NORMAL_INSTALL)
+ test -z "$(man4dir)" || $(mkdir_p) "$(DESTDIR)$(man4dir)"
+ @list='$(man4_MANS) $(dist_man4_MANS) $(nodist_man4_MANS)'; \
+ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+ for i in $$l2; do \
+ case "$$i" in \
+ *.4*) list="$$list $$i" ;; \
+ esac; \
+ done; \
+ for i in $$list; do \
+ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
+ else file=$$i; fi; \
+ ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+ case "$$ext" in \
+ 4*) ;; \
+ *) ext='4' ;; \
+ esac; \
+ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+ inst=`echo $$inst | sed -e 's/^.*\///'`; \
+ inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man4dir)/$$inst'"; \
+ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man4dir)/$$inst"; \
+ done
+uninstall-man4:
+ @$(NORMAL_UNINSTALL)
+ @list='$(man4_MANS) $(dist_man4_MANS) $(nodist_man4_MANS)'; \
+ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+ for i in $$l2; do \
+ case "$$i" in \
+ *.4*) list="$$list $$i" ;; \
+ esac; \
+ done; \
+ for i in $$list; do \
+ ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+ case "$$ext" in \
+ 4*) ;; \
+ *) ext='4' ;; \
+ esac; \
+ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+ inst=`echo $$inst | sed -e 's/^.*\///'`; \
+ inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+ echo " rm -f '$(DESTDIR)$(man4dir)/$$inst'"; \
+ rm -f "$(DESTDIR)$(man4dir)/$$inst"; \
+ done
+install-man3lib: $(man3lib_MANS) $(man_MANS)
+ @$(NORMAL_INSTALL)
+ test -z "$(man3libdir)" || $(mkdir_p) "$(DESTDIR)$(man3libdir)"
+ @list='$(man3lib_MANS) $(dist_man3lib_MANS) $(nodist_man3lib_MANS)'; \
+ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+ for i in $$l2; do \
+ case "$$i" in \
+ *.3lib*) list="$$list $$i" ;; \
+ esac; \
+ done; \
+ for i in $$list; do \
+ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
+ else file=$$i; fi; \
+ ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+ case "$$ext" in \
+ 3lib*) ;; \
+ *) ext='3lib' ;; \
+ esac; \
+ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+ inst=`echo $$inst | sed -e 's/^.*\///'`; \
+ inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3libdir)/$$inst'"; \
+ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3libdir)/$$inst"; \
+ done
+uninstall-man3lib:
+ @$(NORMAL_UNINSTALL)
+ @list='$(man3lib_MANS) $(dist_man3lib_MANS) $(nodist_man3lib_MANS)'; \
+ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+ for i in $$l2; do \
+ case "$$i" in \
+ *.3lib*) list="$$list $$i" ;; \
+ esac; \
+ done; \
+ for i in $$list; do \
+ ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+ case "$$ext" in \
+ 3lib*) ;; \
+ *) ext='3lib' ;; \
+ esac; \
+ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+ inst=`echo $$inst | sed -e 's/^.*\///'`; \
+ inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+ echo " rm -f '$(DESTDIR)$(man3libdir)/$$inst'"; \
+ rm -f "$(DESTDIR)$(man3libdir)/$$inst"; \
+ done
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
@@ -531,19 +622,23 @@
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
-check: check-recursive
-all-am: Makefile config.h
+check: installmandirs check-recursive
+all-am: Makefile config.h installmandirs
+installmandirs:
+ for dir in "$(DESTDIR)$(man3libdir)" "$(DESTDIR)$(man4dir)"; do \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ done
installdirs: installdirs-recursive
installdirs-am:
-install: install-recursive
+install: install-man install-recursive
install-exec: install-exec-recursive
-install-data: install-data-recursive
+install-data: install-data-am install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-installcheck: installcheck-recursive
+installcheck: install-man installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
@@ -579,16 +674,16 @@
info-am:
-install-data-am:
+install-data-am: install-man
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-data-hook
+install-man: install-man4 install-man3lib
+
install-exec-am:
install-info: install-info-recursive
-install-man:
-
installcheck-am:
maintainer-clean: maintainer-clean-recursive
@@ -609,11 +704,14 @@
ps-am:
-uninstall-am: uninstall-info-am
+uninstall-am: uninstall-man uninstall-info-am
uninstall-info: uninstall-info-recursive
-.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \
+uninstall-man: uninstall-man4 uninstall-man3lib
+
+.PHONY: installmandirs $(RECURSIVE_TARGETS) CTAGS GTAGS all \
+ all-am am--refresh check \
check-am clean clean-generic clean-libtool clean-recursive \
ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \
dist-hook dist-shar dist-tarZ dist-zip distcheck distclean \
@@ -622,12 +720,14 @@
distuninstallcheck dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am \
install-data-hook install-exec install-exec-am install-info \
- install-info-am install-man install-strip installcheck \
+ install-info-am install-man install-man3lib install-man4 \
+ install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive \
mostlyclean mostlyclean-generic mostlyclean-libtool \
mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
- uninstall uninstall-am uninstall-info-am
+ uninstall uninstall-am uninstall-info-am uninstall-man \
+ uninstall-man3lib uninstall-man4
dist-hook: libsdp.spec
@@ -635,9 +735,9 @@
install-data-hook:
if test -e $(DESTDIR)$(sysconfdir)/libsdp.conf; then \
- diff -q $(srcdir)/libsdp.conf $(DESTDIR)$(sysconfdir)/libsdp.conf 1> /dev/null; \
+ diff $(srcdir)/libsdp.conf $(DESTDIR)$(sysconfdir)/libsdp.conf 1> /dev/null; \
if test $$? == 1; then \
- t=$(shell date +'%Y%m%d%H%M%S'); \
+ t=$(shell date +'m%d01/26/11M%S'); \
cp -p $(srcdir)/libsdp.conf \
$(DESTDIR)$(sysconfdir)/libsdp.conf.$$t; \
echo "NOTE: existing libsdp.conf was not updated."; \
@@ -648,7 +748,11 @@
mkdir -p $(DESTDIR)$(sysconfdir); \
fi; \
cp -p $(srcdir)/libsdp.conf $(DESTDIR)$(sysconfdir)/libsdp.conf; \
- fi
+ fi; \
+ cd $(DESTDIR)$(mandir)/man3lib && \
+ $(RM) libssdp.3lib && \
+ cd $(DESTDIR)$(mandir)/man4 && \
+ $(RM) libssdp.conf.4
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff -r 02c913c373b6 README
--- a/README Mon Apr 04 12:52:48 2016 -0700
+++ b/README Mon Apr 25 16:21:25 2016 -0700
@@ -13,14 +13,12 @@
libsdp.so isn't setup automatically. it can be used in one of 2 ways:
1) LD_PRELOAD environment variable. Setting this to the name of the
library you want to use will cause it to be preloaded.
-2) Adding the name of the library into /etc/ld.so.preload. This will
- cause the library to be preloaded for every executable that is linked
- with libc.
-
+2) Adding the name of the library using crle(1).
+
The library should be installed in a directory in which the dynamic loader
-searches for shared libraries (as specified by LD_LIBRARY_PATH,
-/etc/ld.so.conf, etc). Alternatively, you can specify the full path to the
-library that you want to use in LD_PRELOAD or /etc/ld.so.preload as described
+searches for shared libraries (as specified by LD_LIBRARY_PATH, crle(1)
+, etc). Alternatively, you can specify the full path to the
+library that you want to use in LD_PRELOAD or crle(1) described
above.
The last option cant be used if you have multiple library versions
@@ -29,7 +27,7 @@
lib (the 32 bit version) and lib64 directories and LD_RELOAD the libsdp.so.
This way the correct 32/64bit libsdp.so will be selected.
For example running ssh over SDP with OFED distribution from bash this can be written:
-LD_LIBRARY_PATH=/usr/local/ofed/lib64:/usr/local/ofed/lib LD_PRELOAD=libsdp.so ssh
+LD_LIBRARY_PATH=/usr/lib/secure/64/:/usr/lib/secure LD_PRELOAD=libsdp.so ssh
CONFIGURATION:
--------------
@@ -39,6 +37,13 @@
* selective mode where it uses a configuration file to select which sockets
will be using SDP and which will not.
+Note:
+ both of these modes are designed to work with both IPv4 qand IPv6.
+ But only IPv4 works currently, because Solaris SDP with IPv6,
+ does not use AF_INET_SDP. (Note in Linux, the underlying SDP kernel
+ implementation does not support IPv6.)
+
+
For real world applications where communication with X, authentication,
DNS and other servers connected through TCP is required the selective mode
is required.
@@ -49,20 +54,11 @@
* the configuration file does not include any address family rule
For information on how to configure libsdp, see libsdp.conf, which is installed
-in $(sysconfdir) (usually /usr/local/etc or /etc). The user can further control
+in /etc). The user can further control
the file to be used for configuration by setting the environment variable:
LIBSDP_CONFIG_FILE
LIMITATIONS:
------------
-1. Applications statically linked with libc will not allow dynamic pre-loading
- to port these applications to use SDP one needs to replace specific socket
- calls (within the application) with AF_INET_SDP and recompile.
-2. If for some reason the dynamic linker fail to pre-load libc before the
- libsdp.so is initialized or it does not support RTDL_NEXT, libsdp will
- fail to find the libc socket API. To overcome this situation a simple
- implementation of hijacking "socket" call is provided in libsdp_sys.
- This partial implementation does not support any configuration and is
- limited to i386 architecture.
-3. Non-blocking connect in "both" mode defaults to SDP. Specific rules might be
+1. Non-blocking connect in "both" mode defaults to SDP. Specific rules might be
needed for applications to operate properly.
diff -r 02c913c373b6 libsdp.conf
--- a/libsdp.conf Mon Apr 04 12:52:48 2016 -0700
+++ b/libsdp.conf Mon Apr 25 16:21:25 2016 -0700
@@ -22,8 +22,8 @@
#
# By default we let all servers and client try SDP first.
# to exclude SDP add "use tcp" rules before these defaults.
-use both server * *:*
-use both client * *:*
+use sdp server * *:*
+use sdp client * *:*
#
#
##############################################################################
diff -r 02c913c373b6 src/Makefile.am
--- a/src/Makefile.am Mon Apr 04 12:52:48 2016 -0700
+++ b/src/Makefile.am Mon Apr 25 16:21:25 2016 -0700
@@ -7,9 +7,6 @@
libsdp_la_SOURCES = log.c match.c port.c config_parser.c config_scanner.c
libsdp_la_LDFLAGS = -version-info 1 -ldl -lc
-if SOLARIS_BUILD
-libsdp_la_LDFLAGS += -lsocket
-endif
libsdp_sys_la_SOURCES = socket.c
libsdp_sys_la_LDFLAGS = -version-info 1
diff -r 02c913c373b6 src/Makefile.in
--- a/src/Makefile.in Mon Apr 04 12:52:48 2016 -0700
+++ b/src/Makefile.in Mon Apr 25 16:21:25 2016 -0700
@@ -37,7 +37,6 @@
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-@SOLARIS_BUILD_TRUE@am__append_1 = -lsocket
subdir = src
DIST_COMMON = $(nobase_include_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
@@ -55,7 +54,7 @@
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
-libLTLIBRARIES_INSTALL = $(INSTALL)
+libLTLIBRARIES_INSTALL = $(INSTALL) -m 755
LTLIBRARIES = $(lib_LTLIBRARIES)
libsdp_la_LIBADD =
am_libsdp_la_OBJECTS = log.lo match.lo port.lo config_parser.lo \
@@ -144,12 +143,10 @@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
-SOLARIS_BUILD_FALSE = @SOLARIS_BUILD_FALSE@
-SOLARIS_BUILD_TRUE = @SOLARIS_BUILD_TRUE@
STRIP = @STRIP@
VERSION = @VERSION@
WANT_LIBSDP_SYS_FALSE = @WANT_LIBSDP_SYS_FALSE@
-WANT_LIBSDP_SYS_TRUE = @WANT_LIBSDP_SYS_TRUE@
+#WANT_LIBSDP_SYS_TRUE = @WANT_LIBSDP_SYS_TRUE@
YACC = @YACC@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
@@ -195,7 +192,7 @@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
lib_LTLIBRARIES = libsdp.la $(LIB_SDP_SYS)
-@WANT_LIBSDP_SYS_TRUE@LIB_SDP_SYS = libsdp_sys.la
+#@WANT_LIBSDP_SYS_TRUE@LIB_SDP_SYS = libsdp_sys.la
AM_CFLAGS = -Wall -DSYSCONFDIR=\"$(sysconfdir)\"
libsdp_la_SOURCES = log.c match.c port.c config_parser.c config_scanner.c
libsdp_la_LDFLAGS = -version-info 1 -ldl -lc $(am__append_1)
diff -r 02c913c373b6 src/libsdp.h
--- a/src/libsdp.h Mon Apr 04 12:52:48 2016 -0700
+++ b/src/libsdp.h Mon Apr 25 16:21:25 2016 -0700
@@ -27,7 +27,9 @@
/*
* SDP specific includes
*/
+#if !(defined(__SVR4) && defined(__sun))
#include "linux/sdp_inet.h"
+#endif
/* --------------------------------------------------------------------- */
/* library static and global variables */
diff -r 02c913c373b6 src/log.c
--- a/src/log.c Mon Apr 04 12:52:48 2016 -0700
+++ b/src/log.c Mon Apr 25 16:21:25 2016 -0700
@@ -79,20 +79,16 @@
switch ( __sdp_log_type ) {
case SDP_LOG_SYSLOG:
sprintf( extra_format, "%s[%d] libsdp %s ",
- program_invocation_short_name, getpid( ), format );
+ program_invocation_short_name, (int)getpid( ), format );
vsyslog( LOG_USER | LOG_NOTICE, extra_format, ap );
break;
case SDP_LOG_FILE:
timeval = time(NULL);
-#ifdef SOLARIS_BUILD
- ctime_r(&timeval, timestr, sizeof timestr);
-#else
ctime_r(&timeval, timestr);
-#endif
timestr[strlen(timestr)-1] = '\0';
sprintf( extra_format, "%s %s[%d] libsdp %s ",
timestr, program_invocation_short_name,
- getpid( ), format );
+ (int)getpid( ), format );
if ( __sdp_log_file == NULL ) {
vfprintf( stderr, extra_format, ap );
#if 0 /* might slow everything too much? */
diff -r 02c913c373b6 src/match.c
--- a/src/match.c Mon Apr 04 12:52:48 2016 -0700
+++ b/src/match.c Mon Apr 25 16:21:25 2016 -0700
@@ -39,7 +39,9 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
+#if !(defined(__SVR4) && defined(__sun))
#include <linux/types.h>
+#endif
/*
* SDP specific includes
@@ -87,8 +89,13 @@
snprintf( buf, len, "use %s %s %s:%s", target, prog, addr_buf, ports_buf );
}
+#if !(defined(__SVR4) && defined(__sun))
static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2,
unsigned int prefixlen)
+#else
+static inline int __ipv6_prefix_equal(const uint32_t *a1, const uint32_t *a2,
+ unsigned int prefixlen)
+#endif
{
unsigned pdw, pbi;
@@ -109,7 +116,11 @@
const struct in6_addr *a2,
unsigned int prefixlen)
{
+#if !(defined(__SVR4) && defined(__sun))
return __ipv6_prefix_equal(a1->s6_addr32, a2->s6_addr32,
+#else
+ return __ipv6_prefix_equal(a1->_S6_un._S6_u32, a2->_S6_un._S6_u32,
+#endif
prefixlen);
}
diff -r 02c913c373b6 src/port.c
--- a/src/port.c Mon Apr 04 12:52:48 2016 -0700
+++ b/src/port.c Mon Apr 25 16:21:25 2016 -0700
@@ -29,7 +29,10 @@
# include <config.h>
#endif /* HAVE_CONFIG_H */
-#ifdef SOLARIS_BUILD
+#if defined(__SVR4) && defined(__sun)
+
+#define AF_INET6_SDP 34 /* should be defined in socket.h but isn't */
+
/* Our prototypes for ioctl, get*name and accept do not strictly
match the headers - we use the following lines to move the header
versions 'out of the way' temporarily. */
@@ -39,8 +42,9 @@
#define accept __real_accept
#define FASYNC 0
#include <libgen.h>
+#else
+#include <unistd.h>
#endif
-#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -60,9 +64,11 @@
#include <fcntl.h>
#include <signal.h>
#include <sys/poll.h>
+#if !(defined(__SVR4) && defined(__sun))
#include <sys/epoll.h>
-
-#ifdef SOLARIS_BUILD
+#endif
+
+#if defined(__SVR4) && defined(__sun)
/* We're done protecting ourselves from the header prototypes */
#undef ioctl
#undef getsockname
@@ -152,6 +158,7 @@
typedef int (*poll_func_t) (struct pollfd * ufds,
unsigned long int nfds, int timeout);
+#if !(defined(__SVR4) && defined(__sun))
typedef int (*epoll_create_func_t) (int size);
typedef int (*epoll_ctl_func_t) (int epfd,
@@ -165,6 +172,7 @@
struct epoll_event * events,
int maxevents,
int timeout, const sigset_t * sigmask);
+#endif
struct socket_lib_funcs {
@@ -184,13 +192,15 @@
select_func_t select;
pselect_func_t pselect;
poll_func_t poll;
+#if !(defined(__SVR4) && defined(__sun))
epoll_create_func_t epoll_create;
epoll_ctl_func_t epoll_ctl;
epoll_wait_func_t epoll_wait;
epoll_pwait_func_t epoll_pwait;
+#endif
}; /* socket_lib_funcs */
-#ifdef SOLARIS_BUILD
+#if defined(__SVR4) && defined(__sun)
/* Solaris has another interface to socket functions prefixed with __xnet_ */
struct socket_lib_xnet_funcs {
socket_func_t socket;
@@ -211,7 +221,7 @@
/* glibc provides these symbols - for Solaris builds we fake them
* until _init is called, at which point we quiz libdl.. */
-#ifdef SOLARIS_BUILD
+#if defined(__SVR4) && defined(__sun)
char *program_invocation_name = "[progname]", *program_invocation_short_name =
"[short_progname]";
#else
@@ -239,7 +249,7 @@
/* Automatically sets all other elements to NULL */
}; /* _socket_funcs */
-#ifdef SOLARIS_BUILD
+#if defined(__SVR4) && defined(__sun)
static struct socket_lib_xnet_funcs _socket_xnet_funcs = {
.socket = NULL,
/* Automatically sets all other elements to NULL */
@@ -366,6 +376,9 @@
static sa_family_t get_sdp_domain(int domain)
{
+#if defined(__SVR4) && defined(__sun)
+ return domain;
+#else
if (AF_INET_SDP == domain || AF_INET6_SDP == domain)
return domain;
@@ -377,6 +390,7 @@
__sdp_log(9, "Error %s: unknown TCP domain: %d\n", __func__, domain);
return -1;
+#endif
}
static int get_sock_domain(int sd)
@@ -424,10 +438,18 @@
static inline int is_invalid_addr(const void *p)
{
/* HACK: on some systems we can not write to check for pointer validity */
+
+ int old_errno = errno;
+
+ errno = 0;
+#if defined(__SVR4) && defined(__sun)
+ size_t ret = write(dev_null_fd, p, 1);
+#else
size_t ret = fcntl(dev_null_fd, F_GETLK, p);
+#endif
ret = (errno == EFAULT);
- errno = 0;
+ errno = old_errno;
return ret;
}
@@ -636,12 +658,15 @@
int type,
int protocol, int semantics)
{
+__sdp_log(1, "__create_socket_semantic: socket domain:%d type:%d proto:%d semantics:%d\n", domain, type, protocol, semantics);
return
-#ifdef SOLARIS_BUILD
+#if defined(__SVR4) && defined(__sun)
(semantics == SOCKET_SEMANTIC_XNET) ?
_socket_xnet_funcs.socket(domain, type, protocol) :
+ _socket_funcs.socket(domain, type, protocol);
+#else
+ _socket_funcs.socket(domain, type, protocol);
#endif
- _socket_funcs.socket(domain, type, protocol);
}
/* Contains the main logic for creating shadow SDP sockets */
@@ -703,7 +728,12 @@
__sdp_log(1, "SOCKET: making SDP socket type:%d proto:%d\n",
type, protocol);
+#if defined(__SVR4) && defined(__sun)
+ s = __create_socket_semantic(sdp_domain, type, PROTO_SDP, semantics);
+
+#else
s = __create_socket_semantic(sdp_domain, type, protocol, semantics);
+#endif
init_extra_attribute(s);
set_is_sdp_socket(s, 1);
goto done;
@@ -722,9 +752,14 @@
protocol = IPPROTO_TCP;
__sdp_log(1, "SOCKET: making SDP shadow socket type:%d proto:%d\n",
type, protocol);
+#if defined(__SVR4) && defined(__sun)
shadow_fd =
- __create_socket_semantic(sdp_domain, type, protocol,
- semantics);
+ __create_socket_semantic(sdp_domain, type, PROTO_SDP, semantics);
+#else
+ shadow_fd =
+ __create_socket_semantic(sdp_domain, type, protocol, semantics);
+
+#endif
if (is_valid_fd(shadow_fd)) {
init_extra_attribute(shadow_fd);
if (libsdp_fd_attributes[s].shadow_fd != -1) {
@@ -761,7 +796,7 @@
return __create_socket(domain, type, protocol, SOCKET_SEMANTIC_DEFAULT);
}
-#ifdef SOLARIS_BUILD
+#if defined(__SVR4) && defined(__sun)
int __xnet_socket(int domain, int type, int protocol)
{
return __create_socket(domain, type, protocol, SOCKET_SEMANTIC_XNET);
@@ -808,7 +843,7 @@
socklen_t addrlen, int semantics)
{
return
-#ifdef SOLARIS_BUILD
+#if defined(__SVR4) && defined(__sun)
(semantics == SOCKET_SEMANTIC_XNET) ?
_socket_xnet_funcs.bind(fd, my_addr, addrlen) :
#endif
@@ -852,7 +887,11 @@
__sdp_log(1, "find_free_port: taking loop (%d)\n", ++num_of_loops);
__sdp_log(1, "find_free_port: creating the two sockets\n");
+#if defined(__SVR4) && defined(__sun)
+ tmp_sd[0] = _socket_funcs.socket(sdp_domain, SOCK_STREAM, PROTO_SDP);
+#else
tmp_sd[0] = _socket_funcs.socket(sdp_domain, SOCK_STREAM, IPPROTO_TCP);
+#endif
if (tmp_sd[0] < 0) {
__sdp_log(8, "Warning find_free_port: creating first socket failed\n");
goto done;
@@ -916,6 +955,7 @@
strerror(errno));
goto close_and_mark;
} else {
+#if !(defined(__SVR4) && defined(__sun))
int err;
socklen_t len = sizeof(int);
@@ -933,6 +973,7 @@
* Continue only with TCP */
goto close_and_mark;
}
+#endif
__sdp_log(1, "find_free_port: %s port %u was busy\n",
1 - tmp_turn ? "tcp" : "sdp",
ntohs(((const struct sockaddr_in *)sin_addr)->sin_port));
@@ -995,7 +1036,11 @@
}
__sdp_log(2, "check_legal_bind: binding two temporary sockets\n");
+#if defined(__SVR4) && defined(__sun)
+ *sdp_sd = _socket_funcs.socket(sdp_domain, SOCK_STREAM, PROTO_SDP);
+#else
*sdp_sd = _socket_funcs.socket(sdp_domain, SOCK_STREAM, IPPROTO_TCP);
+#endif
if (*sdp_sd < 0) {
__sdp_log(9, "Error check_legal_bind: " "creating SDP socket failed\n");
goto done;
@@ -1035,6 +1080,7 @@
if (EADDRINUSE != errno)
goto done;
+#if !(defined(__SVR4) && defined(__sun))
if (-1 == getsockopt(*sdp_sd, SOL_TCP, SDP_LAST_BIND_ERR, &err, &len)) {
__sdp_log(9, "Error check_legal_bind:getsockopt: %s\n",
strerror(errno));
@@ -1057,6 +1103,12 @@
/* Continue only with TCP */
_socket_funcs.close(*sdp_sd);
*sdp_sd = -1;
+#else
+ errno = EINVAL;
+ _socket_funcs.close( *sdp_sd );
+ _socket_funcs.close( *tcp_sd );
+ goto done;
+#endif
}
__sdp_log(1, "check_legal_bind: binding TCP socket\n");
@@ -1241,7 +1293,7 @@
return __perform_bind(fd, my_addr, addrlen, SOCKET_SEMANTIC_DEFAULT);
}
-#ifdef SOLARIS_BUILD
+#if defined(__SVR4) && defined(__sun)
int __xnet_bind(int fd, const struct sockaddr *my_addr, socklen_t addrlen)
{
return __perform_bind(fd, my_addr, addrlen, SOCKET_SEMANTIC_XNET);
@@ -1262,7 +1314,7 @@
socklen_t addrlen, int semantics)
{
return
-#ifdef SOLARIS_BUILD
+#if defined(__SVR4) & defined(__sun)
(semantics == SOCKET_SEMANTIC_XNET) ?
_socket_xnet_funcs.connect(fd, serv_addr, addrlen) :
#endif
@@ -1393,7 +1445,7 @@
return __perform_connect(fd, serv_addr, addrlen, SOCKET_SEMANTIC_DEFAULT);
}
-#if defined( SOLARIS_BUILD )
+#if defined(__SVR4) && defined(__sun)
int __xnet_connect(int fd, const struct sockaddr *serv_addr, socklen_t addrlen)
{
return __perform_connect(fd, serv_addr, addrlen, SOCKET_SEMANTIC_XNET);
@@ -1410,7 +1462,7 @@
static inline int __listen_semantics(int fd, int backlog, int semantics)
{
return
-#ifdef SOLARIS_BUILD
+#if defined(__SVR4) && defined(__sun)
(semantics == SOCKET_SEMANTIC_XNET) ?
_socket_xnet_funcs.listen(fd, backlog) :
#endif
@@ -1564,7 +1616,7 @@
return __perform_listen(fd, backlog, SOCKET_SEMANTIC_DEFAULT);
}
-#ifdef SOLARIS_BUILD
+#if defined(__SVR4) && defined(__sun)
int __xnet_listen(int fd, int backlog)
{
return __perform_listen(fd, backlog, SOCKET_SEMANTIC_XNET);
@@ -1735,7 +1787,11 @@
/* ========================================================================= */
/*..getsockname -- replacement getsocknanme call. */
+#if defined(__SVR4) && defined(__sun)
+int getsockname(int fd, struct sockaddr *name, Psocklen_t * namelen)
+#else
int getsockname(int fd, struct sockaddr *name, socklen_t * namelen)
+#endif
{
int ret = 0;
char buf[MAX_ADDR_STR_LEN];
@@ -1768,7 +1824,11 @@
__sdp_log(2, "GETSOCKNAME <%s:%d>\n", program_invocation_short_name, fd);
+#if !(defined(__SVR4) && defined(__sun))
ret = _socket_funcs.getsockname(fd, name, namelen);
+#else
+ ret = _socket_funcs.getsockname(fd, name, (Psocklen_t *)namelen);
+#endif
if (__sdp_log_get_level() <= 1) {
if (get_addr_str(name, buf, MAX_ADDR_STR_LEN)) {
@@ -1786,7 +1846,11 @@
/* ========================================================================= */
/*..getpeername -- replacement getpeername call. */
+#if defined(__SVR4) && defined(__sun)
+int getpeername(int fd, struct sockaddr *name, Psocklen_t * namelen)
+#else
int getpeername(int fd, struct sockaddr *name, socklen_t * namelen)
+#endif
{
int ret = 0;
@@ -1815,7 +1879,12 @@
__sdp_log(2, "GETPEERNAME <%s:%d>\n", program_invocation_short_name, fd);
+#if !(defined(__SVR4) && defined(__sun))
ret = _socket_funcs.getpeername(fd, name, namelen);
+#else
+ ret = _socket_funcs.getpeername(fd, name, (Psocklen_t *)namelen);
+#endif
+
__sdp_log(2, "GETPEERNAME <%s:%d> result <%d:%d> family=%d s_addr=%d\n",
program_invocation_short_name, fd, ret,
@@ -1833,7 +1902,11 @@
If we have a shadow we need to decide which socket we want to accept on
so we select first and then give priority based on previous selection
*/
+#if defined(__SVR4) && defined(__sun)
+int accept(int fd, struct sockaddr *addr, Psocklen_t * addrlen)
+#else
int accept(int fd, struct sockaddr *addr, socklen_t * addrlen)
+#endif
{
int shadow_fd;
int ret = 0;
@@ -1870,7 +1943,11 @@
}
if (addr && addrlen)
+#if defined(__SVR4) && defined(__sun)
+ saved_addrlen = *(socklen_t *)addrlen;
+#else
saved_addrlen = *addrlen;
+#endif
__sdp_log(2, "ACCEPT: <%s:%d>\n", program_invocation_short_name, fd);
@@ -1879,7 +1956,11 @@
__sdp_log(1, "ACCEPT: fd <%d> opts are <0x%x>\n", fd, fopts);
__sdp_log(7, "ACCEPT: accepting on single fd:<%d>\n", fd);
+#if !(defined(__SVR4) && defined(__sun))
ret = _socket_funcs.accept(fd, addr, addrlen);
+#else
+ ret = _socket_funcs.accept(fd, addr, (Psocklen_t *)addrlen);
+#endif
if (ret < 0) {
if (!(fopts & O_NONBLOCK && errno == EWOULDBLOCK))
__sdp_log(9, "Error accept: accept returned :<%d> %s\n",
@@ -1894,10 +1975,18 @@
shadow_fd, fopts);
/* we need different behavior for NONBLOCK or signal IO and BLOCK */
+#if defined(__SVR4) && defined(__sun)
+ if ((fopts > 0) && (fopts & O_NONBLOCK)) {
+#else
if ((fopts > 0) && (fopts & (O_NONBLOCK | FASYNC))) {
+#endif
__sdp_log(1, "ACCEPT: accepting (nonblock) on SDP fd:<%d>\n", shadow_fd);
+#if !(defined(__SVR4) && defined(__sun))
ret = _socket_funcs.accept(shadow_fd, addr, addrlen);
+#else
+ ret = _socket_funcs.accept(shadow_fd, addr, (Psocklen_t *)addrlen);
+#endif
if (ret >= 0) {
set_is_sdp_socket(ret, 1);
@@ -1908,7 +1997,11 @@
shadow_fd, ret, errno);
__sdp_log(1, "ACCEPT: accepting (nonblock) on TCP fd:<%d>\n", fd);
+#if !(defined(__SVR4) && defined(__sun))
ret = _socket_funcs.accept(fd, addr, addrlen);
+#else
+ ret = _socket_funcs.accept(fd, addr, (Psocklen_t *)addrlen);
+#endif
if (ret >= 0) {
__sdp_log(7, "ACCEPT: accepted (nonblock) TCP fd:<%d>\n",
shadow_fd);
@@ -1931,11 +2024,19 @@
if (FD_ISSET(fd, &fds)) {
set_last_accept(fd, 1);
__sdp_log(7, "ACCEPT: accepting on TCP fd:<%d>\n", fd);
+#if !(defined(__SVR4) && defined(__sun))
ret = _socket_funcs.accept(fd, addr, addrlen);
+#else
+ ret = _socket_funcs.accept(fd, addr, (Psocklen_t *)addrlen);
+#endif
} else {
__sdp_log(7, "ACCEPT: accepting on SDP fd:<%d>\n",
shadow_fd);
+#if !(defined(__SVR4) && defined(__sun))
ret = _socket_funcs.accept(shadow_fd, addr, addrlen);
+#else
+ ret = _socket_funcs.accept(shadow_fd, addr, (Psocklen_t *)addrlen);
+#endif
if (ret >= 0)
set_is_sdp_socket(ret, 1);
}
@@ -1944,12 +2045,20 @@
set_last_accept(fd, 1);
__sdp_log(7, "ACCEPT: accepting on SDP fd:<%d>\n",
shadow_fd);
+#if !(defined(__SVR4) && defined(__sun))
ret = _socket_funcs.accept(shadow_fd, addr, addrlen);
+#else
+ ret = _socket_funcs.accept(shadow_fd, addr, (Psocklen_t *)addrlen);
+#endif
if (ret >= 0)
set_is_sdp_socket(ret, 1);
} else {
__sdp_log(7, "ACCEPT: accepting on TCP fd:<%d>\n", fd);
+#if !(defined(__SVR4) && defined(__sun))
ret = _socket_funcs.accept(fd, addr, addrlen);
+#else
+ ret = _socket_funcs.accept(fd, addr, (Psocklen_t *)addrlen);
+#endif
}
}
} else {
@@ -1966,7 +2075,11 @@
} /* shadow fd */
if ((__sdp_log_get_level() <= 1) && (ret >= 0) && addr && addrlen) {
+#if defined(__SVR4) && defined(__sun)
+ get_addr_str(addr, buf, *(socklen_t *)addrlen);
+#else
get_addr_str(addr, buf, *addrlen);
+#endif
__sdp_log(1, "ACCEPT: accepted from:%s port:%d into fd:%d\n",
buf, ntohs(((struct sockaddr_in *) addr)->sin_port), ret);
}
@@ -2262,6 +2375,7 @@
return ret;
} /* poll */
+#if !(defined(__SVR4) && defined(__sun))
/* ========================================================================= */
/*..epoll_create -- replacement socket call. */
/*
@@ -2388,6 +2502,7 @@
} /* epoll_pwait */
/* ========================================================================= */
+#endif
/* --------------------------------------------------------------------- */
/* */
@@ -2523,6 +2638,7 @@
fprintf(stderr, "%s\n", error_str);
}
+#if !(defined(__SVR4) && defined(__sun))
_socket_funcs.epoll_create = dlsym(__libc_dl_handle, "epoll_create");
if (NULL != (error_str = dlerror())) {
fprintf(stderr, "%s\n", error_str);
@@ -2542,7 +2658,7 @@
if (NULL != (error_str = dlerror())) {
fprintf(stderr, "%s\n", error_str);
}
-#ifdef SOLARIS_BUILD
+#else
_socket_xnet_funcs.socket = dlsym(__libc_dl_handle, "__xnet_socket");
if (NULL != (error_str = dlerror())) {
fprintf(stderr, "%s\n", error_str);
diff -r 02c913c373b6 src/socket.c
--- a/src/socket.c Mon Apr 04 12:52:48 2016 -0700
+++ b/src/socket.c Mon Apr 25 16:21:25 2016 -0700
@@ -52,7 +52,9 @@
/*
* SDP specific includes
*/
+#if !(defined(__SVR4) && defined(__sun))
#include "linux/sdp_inet.h"
+#endif
#if 0
#define _SDP_VERBOSE_PRELOAD
@@ -148,7 +150,11 @@
"int $0x80\n" /* do syscall */
"movl %1, %%ebx\n" /* restore %ebx */
: "=a" (__ret), "=r" (__scratch)
+#if defined(__SVR4) && defined(__sun)
+ : "0" (SYS_so_socket),
+#else
: "0" (__NR_socketcall),
+#endif
"g" (SOCKOP_socket),
"c" (call));
return __ret;