]> git.sur5r.net Git - openldap/commitdiff
Add -4/-6 flags to slapd to force use of IPv4 or IPv6
authorKurt Zeilenga <kurt@openldap.org>
Sat, 15 Jun 2002 22:01:39 +0000 (22:01 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 15 Jun 2002 22:01:39 +0000 (22:01 +0000)
doc/man/man8/slapd.8
servers/slapd/daemon.c
servers/slapd/main.c
servers/slapd/slap.h

index afb12e712f6aee6fa89bbdd0220e64086f695f1b..f30dcc0a9f00a2855f45b28481c70e030624d2a5 100644 (file)
@@ -6,6 +6,7 @@
 slapd \- Stand-alone LDAP Daemon
 .SH SYNOPSIS
 .B LIBEXECDIR/slapd 
+.B [\-[4|6]]
 .B [\-d debug\-level]
 .B [\-f slapd\-config\-file]
 .B [\-h URLs]
@@ -57,6 +58,12 @@ See the "OpenLDAP Administrator's Guide" for more details on
 .BR slapd .
 .SH OPTIONS
 .TP
+.B \-4
+Listen on IPv4 addresses only.
+.TP
+.B \-6
+Listen on IPv6 addresses only.
+.TP
 .BI \-d " debug\-level"
 Turn on debugging as defined by
 .I debug\-level.
index 80de649bea208adccf645b2ac580e0e00bb2ee10..c34077e2244ef3013edcccaefe026d1240bf3c7b 100644 (file)
@@ -33,6 +33,8 @@ int deny_severity = LOG_NOTICE;
 #define LDAPI_MOD_URLEXT               "x-mod"
 #endif /* LDAP_PF_LOCAL */
 
+int slap_inet4or6 = AF_UNSPEC;
+
 /* globals */
 time_t starttime;
 ber_socket_t dtblsize;
@@ -414,7 +416,7 @@ static int slap_get_listener_addresses(
                memset( &hints, '\0', sizeof(hints) );
                hints.ai_flags = AI_PASSIVE;
                hints.ai_socktype = SOCK_STREAM;
-               hints.ai_family = AF_UNSPEC;
+               hints.ai_family = slap_inet4or6;
                snprintf(serv, sizeof serv, "%d", port);
 
                if ( (err = getaddrinfo(host, serv, &hints, &res)) ) {
index b48f222450b9b3552c8c1d58719294718ff3196b..cea889cf7adfc9c38a657b481e40f431b4929b54 100644 (file)
@@ -96,6 +96,8 @@ usage( char *name )
        fprintf( stderr,
                "usage: %s options\n", name );
        fprintf( stderr,
+               "\t-4\t\tIPv4 only\n"
+               "\t-6\t\tIPv6 only\n"
                "\t-d level\tDebug level" "\n"
                "\t-f filename\tConfiguration file\n"
 #if defined(HAVE_SETUID) && defined(HAVE_SETGID)
@@ -216,6 +218,9 @@ int main( int argc, char **argv )
 
        while ( (i = getopt( argc, argv,
                             "d:f:h:s:n:t"
+#if LDAP_PF_INET6
+                               "46"
+#endif
 #ifdef HAVE_CHROOT
                                "r:"
 #endif
@@ -227,6 +232,15 @@ int main( int argc, char **argv )
 #endif
                             )) != EOF ) {
                switch ( i ) {
+#ifdef LDAP_PF_INET6
+               case '4':
+                       slap_inet4or6 = AF_INET;
+                       break;
+               case '6':
+                       slap_inet4or6 = AF_INET6;
+                       break;
+#endif
+
                case 'h':       /* listen URLs */
                        if ( urls != NULL ) free( urls );
                        urls = ch_strdup( optarg );
index b4c0d795ddc04413288ca7c756755e214d0deee7..b3b129ba105ee4229256dcc4acae898e2454ac6e 100644 (file)
@@ -250,6 +250,10 @@ typedef union slap_sockaddr {
 #endif
 } Sockaddr;
 
+#ifdef LDAP_PF_INET6
+extern int slap_inet4or6;
+#endif
+
 typedef struct slap_oid_macro {
        struct berval som_oid;
        char **som_names;