INN commit: trunk (15 files)

INN Commit rra at isc.org
Thu Dec 4 20:37:30 UTC 2014


    Date: Thursday, December 4, 2014 @ 12:37:30
  Author: iulius
Revision: 9760

Rationalize the portability layer for SUN_LEN

Add new portable/socket-unix.h portability layer that includes
sys/un.h and defines SUN_LEN if the implementation does not do so.
Remove the corresponding piece of code from clibrary.h.

Added:
  trunk/include/portable/socket-unix.h
Modified:
  trunk/MANIFEST
  trunk/frontends/Makefile
  trunk/frontends/ovdb_server.c
  trunk/include/clibrary.h
  trunk/include/inn/network.h
  trunk/innd/Makefile
  trunk/innd/cc.c
  trunk/innd/lc.c
  trunk/lib/Makefile
  trunk/lib/inndcomm.c
  trunk/lib/localopen.c
  trunk/storage/Makefile
  trunk/storage/ovdb/ovdb.c
  trunk/support/getrra-c-util

--------------------------------+
 MANIFEST                       |    1 
 frontends/Makefile             |   13 ++++++------
 frontends/ovdb_server.c        |    1 
 include/clibrary.h             |   10 ---------
 include/inn/network.h          |   16 +++++++--------
 include/portable/socket-unix.h |   41 +++++++++++++++++++++++++++++++++++++++
 innd/Makefile                  |   21 ++++++++++---------
 innd/cc.c                      |    1 
 innd/lc.c                      |    1 
 lib/Makefile                   |   15 +++++++-------
 lib/inndcomm.c                 |    1 
 lib/localopen.c                |    1 
 storage/Makefile               |    3 +-
 storage/ovdb/ovdb.c            |    1 
 support/getrra-c-util          |    1 
 15 files changed, 85 insertions(+), 42 deletions(-)

Modified: MANIFEST
===================================================================
--- MANIFEST	2014-12-04 20:11:38 UTC (rev 9759)
+++ MANIFEST	2014-12-04 20:37:30 UTC (rev 9760)
@@ -421,6 +421,7 @@
 include/portable/macros.h             Set of portability macros
 include/portable/mmap.h               Wrapper for <sys/mman.h>
 include/portable/setproctitle.h       Portable setup for setproctitle
+include/portable/socket-unix.h        Wrapper for <sys/un.h> and SUN_LEN
 include/portable/socket.h             Wrapper for <sys/socket.h> and friends
 include/portable/stdbool.h            Wrapper for <stdbool.h>
 include/portable/uio.h                Wrapper for <sys/uio.h>

Modified: frontends/Makefile
===================================================================
--- frontends/Makefile	2014-12-04 20:11:38 UTC (rev 9759)
+++ frontends/Makefile	2014-12-04 20:37:30 UTC (rev 9760)
@@ -202,12 +202,13 @@
   ../include/inn/macros.h ../include/portable/mmap.h \
   ../include/portable/setproctitle.h ../include/portable/socket.h \
   ../include/portable/getaddrinfo.h ../include/portable/getnameinfo.h \
-  ../include/inn/fdflag.h ../include/inn/innconf.h \
-  ../include/inn/defines.h ../include/inn/messages.h \
-  ../include/inn/libinn.h ../include/inn/xmalloc.h ../include/inn/xwrite.h \
-  ../include/inn/paths.h ../include/inn/storage.h ../include/inn/options.h \
-  ../include/inn/ov.h ../include/inn/storage.h ../include/inn/history.h \
-  ../storage/ovdb/ovdb.h ../storage/ovdb/ovdb-private.h
+  ../include/portable/socket-unix.h ../include/inn/fdflag.h \
+  ../include/inn/innconf.h ../include/inn/defines.h \
+  ../include/inn/messages.h ../include/inn/libinn.h \
+  ../include/inn/xmalloc.h ../include/inn/xwrite.h ../include/inn/paths.h \
+  ../include/inn/storage.h ../include/inn/options.h ../include/inn/ov.h \
+  ../include/inn/storage.h ../include/inn/history.h ../storage/ovdb/ovdb.h \
+  ../storage/ovdb/ovdb-private.h
 ovdb_stat.o: ovdb_stat.c ../include/config.h ../include/inn/defines.h \
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/portable/macros.h ../include/portable/stdbool.h \

Modified: frontends/ovdb_server.c
===================================================================
--- frontends/ovdb_server.c	2014-12-04 20:11:38 UTC (rev 9759)
+++ frontends/ovdb_server.c	2014-12-04 20:37:30 UTC (rev 9760)
@@ -8,6 +8,7 @@
 #include "portable/mmap.h"
 #include "portable/setproctitle.h"
 #include "portable/socket.h"
+#include "portable/socket-unix.h"
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>

Modified: include/clibrary.h
===================================================================
--- include/clibrary.h	2014-12-04 20:11:38 UTC (rev 9759)
+++ include/clibrary.h	2014-12-04 20:37:30 UTC (rev 9760)
@@ -172,16 +172,6 @@
 # define STDERR_FILENO  2
 #endif
 
-/* POSIX.1g requires <sys/un.h> to define a SUN_LEN macro for determining
-   the real length of a struct sockaddr_un, but it's not available
-   everywhere yet.  If autoconf couldn't find it, define our own.  This
-   definition is from 4.4BSD by way of Stevens, Unix Network Programming
-   (2nd edition), vol. 1, pg. 917. */
-#if !HAVE_SUN_LEN
-# define SUN_LEN(sun) \
-    (sizeof(*(sun)) - sizeof((sun)->sun_path) + strlen((sun)->sun_path))
-#endif
-
 /* C99 requires va_copy.  Older versions of GCC provide __va_copy.  Per the
    Autoconf manual, memcpy is a generally portable fallback. */
 #ifndef va_copy

Modified: include/inn/network.h
===================================================================
--- include/inn/network.h	2014-12-04 20:11:38 UTC (rev 9759)
+++ include/inn/network.h	2014-12-04 20:37:30 UTC (rev 9760)
@@ -44,9 +44,9 @@
 
 /*
  * Create a socket of the given type and bind it to the specified address and
- * port (either IPv4 or IPv6), returning the resulting file descriptor or -1
- * on error.  Errors are reported using warn/syswarn.  To bind to all
- * interfaces, use "any" or "all" for address.
+ * port (either IPv4 or IPv6), returning the resulting file descriptor or
+ * INVALID_SOCKET on error.  Errors are reported using warn/syswarn.  To bind
+ * to all interfaces, use "any" or "all" for address.
  */
 socket_type network_bind_ipv4(int type, const char *addr, unsigned short port)
     __attribute__((__nonnull__));
@@ -96,10 +96,10 @@
 /*
  * Create a socket and connect it to the remote service given by the linked
  * list of addrinfo structs.  Returns the new file descriptor on success and
- * -1 on failure, with the error left in errno.  Takes an optional source
- * address and a timeout in seconds, which may be 0 for no timeout.  (Source
- * may also be "all" or "any", which mean the same thing as NULL: do not use
- * any particular source address.)
+ * INVALID_SOCKET on failure, with the error left in errno.  Takes an optional
+ * source address and a timeout in seconds, which may be 0 for no timeout.
+ * (Source may also be "all" or "any", which mean the same thing as NULL: do
+ * not use any particular source address.)
  */
 socket_type network_connect(const struct addrinfo *, const char *source,
                             time_t)
@@ -117,7 +117,7 @@
  * Creates a socket of the specified domain and type and binds it to the
  * appropriate source address, either the one supplied or all addresses if the
  * source address is NULL, "all", or "any".  Returns the newly created file
- * descriptor or -1 on error.
+ * descriptor or INVALID_SOCKET on error.
  *
  * This is a lower-level function intended primarily for the use of clients
  * that will then go on to do a non-blocking connect.

Added: include/portable/socket-unix.h
===================================================================
--- include/portable/socket-unix.h	                        (rev 0)
+++ include/portable/socket-unix.h	2014-12-04 20:37:30 UTC (rev 9760)
@@ -0,0 +1,41 @@
+/* $Id$
+ *
+ * Portability wrapper around <sys/un.h>.
+ *
+ * This wrapper exists primarily to define SUN_LEN if not defined by the
+ * implementation.  In most cases, one will want to include portable/socket.h
+ * as well for the normal socket functions.
+ *
+ * The canonical version of this file is maintained in the rra-c-util package,
+ * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ *
+ * Written by Russ Allbery <eagle at eyrie.org>
+ *
+ * The authors hereby relinquish any claim to any copyright that they may have
+ * in this work, whether granted under contract or by operation of law or
+ * international treaty, and hereby commit to the public, at large, that they
+ * shall not, at any time in the future, seek to enforce any copyright in this
+ * work against any person or entity, or prevent any person or entity from
+ * copying, publishing, distributing or creating derivative works of this
+ * work.
+ */
+
+#ifndef PORTABLE_SOCKET_UNIX_H
+#define PORTABLE_SOCKET_UNIX_H 1
+
+#include "config.h"
+#include <sys/un.h>
+
+/*
+ * POSIX.1g requires <sys/un.h> to define a SUN_LEN macro for determining
+ * the real length of a struct sockaddr_un, but it's not available
+ * everywhere yet.  If autoconf couldn't find it, define our own.  This
+ * definition is from 4.4BSD by way of Stevens, Unix Network Programming
+ * (2nd edition), vol. 1, pg. 917.
+ */
+#if !HAVE_SUN_LEN
+# define SUN_LEN(sun) \
+    (sizeof(*(sun)) - sizeof((sun)->sun_path) + strlen((sun)->sun_path))
+#endif
+
+#endif /* !PORTABLE_SOCKET_UNIX_H */


Property changes on: trunk/include/portable/socket-unix.h
___________________________________________________________________
Added: svn:eol-style
   + native
Added: svn:keywords
   + Author Date Id Revision

Modified: innd/Makefile
===================================================================
--- innd/Makefile	2014-12-04 20:11:38 UTC (rev 9759)
+++ innd/Makefile	2014-12-04 20:37:30 UTC (rev 9760)
@@ -87,9 +87,9 @@
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/portable/macros.h ../include/portable/stdbool.h \
   ../include/inn/options.h ../include/clibrary.h ../include/config.h \
-  ../include/inn/macros.h ../include/inn/innconf.h \
-  ../include/inn/defines.h ../include/inn/qio.h innd.h \
-  ../include/portable/socket.h ../include/portable/getaddrinfo.h \
+  ../include/inn/macros.h ../include/portable/socket-unix.h \
+  ../include/inn/innconf.h ../include/inn/defines.h ../include/inn/qio.h \
+  innd.h ../include/portable/socket.h ../include/portable/getaddrinfo.h \
   ../include/portable/getnameinfo.h ../include/inn/buffer.h \
   ../include/inn/history.h ../include/inn/messages.h \
   ../include/inn/timer.h ../include/inn/libinn.h ../include/inn/xmalloc.h \
@@ -149,13 +149,14 @@
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/portable/macros.h ../include/portable/stdbool.h \
   ../include/inn/options.h ../include/clibrary.h ../include/config.h \
-  ../include/inn/macros.h ../include/inn/innconf.h \
-  ../include/inn/defines.h innd.h ../include/portable/socket.h \
-  ../include/portable/getaddrinfo.h ../include/portable/getnameinfo.h \
-  ../include/inn/buffer.h ../include/inn/history.h \
-  ../include/inn/messages.h ../include/inn/timer.h ../include/inn/libinn.h \
-  ../include/inn/xmalloc.h ../include/inn/xwrite.h ../include/inn/nntp.h \
-  ../include/inn/paths.h ../include/inn/storage.h ../include/inn/options.h
+  ../include/inn/macros.h ../include/portable/socket-unix.h \
+  ../include/inn/innconf.h ../include/inn/defines.h innd.h \
+  ../include/portable/socket.h ../include/portable/getaddrinfo.h \
+  ../include/portable/getnameinfo.h ../include/inn/buffer.h \
+  ../include/inn/history.h ../include/inn/messages.h \
+  ../include/inn/timer.h ../include/inn/libinn.h ../include/inn/xmalloc.h \
+  ../include/inn/xwrite.h ../include/inn/nntp.h ../include/inn/paths.h \
+  ../include/inn/storage.h ../include/inn/options.h
 nc.o: nc.c ../include/config.h ../include/inn/defines.h \
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/portable/macros.h ../include/portable/stdbool.h \

Modified: innd/cc.c
===================================================================
--- innd/cc.c	2014-12-04 20:11:38 UTC (rev 9759)
+++ innd/cc.c	2014-12-04 20:37:30 UTC (rev 9760)
@@ -14,6 +14,7 @@
 
 #include "config.h"
 #include "clibrary.h"
+#include "portable/socket-unix.h"
 
 #ifdef HAVE_UNIX_DOMAIN_SOCKETS
 # include <sys/un.h>

Modified: innd/lc.c
===================================================================
--- innd/lc.c	2014-12-04 20:11:38 UTC (rev 9759)
+++ innd/lc.c	2014-12-04 20:37:30 UTC (rev 9760)
@@ -8,6 +8,7 @@
 
 #include "config.h"
 #include "clibrary.h"
+#include "portable/socket-unix.h"
 
 #include "inn/innconf.h"
 #include "innd.h"

Modified: lib/Makefile
===================================================================
--- lib/Makefile	2014-12-04 20:11:38 UTC (rev 9759)
+++ lib/Makefile	2014-12-04 20:37:30 UTC (rev 9760)
@@ -259,9 +259,10 @@
   ../include/inn/options.h ../include/clibrary.h ../include/config.h \
   ../include/inn/macros.h ../include/portable/socket.h \
   ../include/portable/getaddrinfo.h ../include/portable/getnameinfo.h \
-  ../include/inn/innconf.h ../include/inn/defines.h \
-  ../include/inn/inndcomm.h ../include/inn/libinn.h \
-  ../include/inn/xmalloc.h ../include/inn/xwrite.h ../include/inn/paths.h
+  ../include/portable/socket-unix.h ../include/inn/innconf.h \
+  ../include/inn/defines.h ../include/inn/inndcomm.h \
+  ../include/inn/libinn.h ../include/inn/xmalloc.h ../include/inn/xwrite.h \
+  ../include/inn/paths.h
 list.o: list.c ../include/config.h ../include/inn/defines.h \
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/portable/macros.h ../include/portable/stdbool.h \
@@ -271,10 +272,10 @@
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/portable/macros.h ../include/portable/stdbool.h \
   ../include/inn/options.h ../include/clibrary.h ../include/config.h \
-  ../include/inn/macros.h ../include/inn/innconf.h \
-  ../include/inn/defines.h ../include/inn/libinn.h \
-  ../include/inn/xmalloc.h ../include/inn/xwrite.h ../include/inn/nntp.h \
-  ../include/inn/paths.h
+  ../include/inn/macros.h ../include/portable/socket-unix.h \
+  ../include/inn/innconf.h ../include/inn/defines.h \
+  ../include/inn/libinn.h ../include/inn/xmalloc.h ../include/inn/xwrite.h \
+  ../include/inn/nntp.h ../include/inn/paths.h
 lockfile.o: lockfile.c ../include/config.h ../include/inn/defines.h \
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/portable/macros.h ../include/portable/stdbool.h \

Modified: lib/inndcomm.c
===================================================================
--- lib/inndcomm.c	2014-12-04 20:11:38 UTC (rev 9759)
+++ lib/inndcomm.c	2014-12-04 20:37:30 UTC (rev 9760)
@@ -6,6 +6,7 @@
 #include "config.h"
 #include "clibrary.h"
 #include "portable/socket.h"
+#include "portable/socket-unix.h"
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>

Modified: lib/localopen.c
===================================================================
--- lib/localopen.c	2014-12-04 20:11:38 UTC (rev 9759)
+++ lib/localopen.c	2014-12-04 20:37:30 UTC (rev 9760)
@@ -4,6 +4,7 @@
 
 #include "config.h"
 #include "clibrary.h"
+#include "portable/socket-unix.h"
 #include <errno.h>
 #include <sys/socket.h>
 

Modified: storage/Makefile
===================================================================
--- storage/Makefile	2014-12-04 20:11:38 UTC (rev 9759)
+++ storage/Makefile	2014-12-04 20:37:30 UTC (rev 9760)
@@ -208,7 +208,8 @@
   ../include/inn/options.h ../include/clibrary.h ../include/config.h \
   ../include/inn/macros.h ../include/portable/socket.h \
   ../include/portable/getaddrinfo.h ../include/portable/getnameinfo.h \
-  ../include/conffile.h ../include/inn/fdflag.h ../include/inn/innconf.h \
+  ../include/portable/socket-unix.h ../include/conffile.h \
+  ../include/inn/fdflag.h ../include/inn/innconf.h \
   ../include/inn/defines.h ../include/inn/libinn.h \
   ../include/inn/xmalloc.h ../include/inn/xwrite.h \
   ../include/inn/messages.h ../include/inn/newsuser.h \

Modified: storage/ovdb/ovdb.c
===================================================================
--- storage/ovdb/ovdb.c	2014-12-04 20:11:38 UTC (rev 9759)
+++ storage/ovdb/ovdb.c	2014-12-04 20:37:30 UTC (rev 9760)
@@ -73,6 +73,7 @@
 #include "config.h"
 #include "clibrary.h"
 #include "portable/socket.h"
+#include "portable/socket-unix.h"
 #include <errno.h>
 #include <fcntl.h>
 #ifdef HAVE_LIMITS_H

Modified: support/getrra-c-util
===================================================================
--- support/getrra-c-util	2014-12-04 20:11:38 UTC (rev 9759)
+++ support/getrra-c-util	2014-12-04 20:37:30 UTC (rev 9760)
@@ -167,6 +167,7 @@
 download portable/seteuid.c lib seteuid.c
 download portable/snprintf.c lib snprintf.c
 download portable/socket.h include/portable socket.h
+download portable/socket-unix.h include/portable socket-unix.h
 download portable/stdbool.h include/portable stdbool.h
 download portable/strlcat.c lib strlcat.c
 download portable/strlcpy.c lib strlcpy.c



More information about the inn-committers mailing list