]> git.sur5r.net Git - openldap/commitdiff
Changes for URI spport: New routines ldap_initialize and ldap_create; LDAPURLDesc...
authorMark Valence <mrv@openldap.org>
Tue, 7 Dec 1999 18:42:25 +0000 (18:42 +0000)
committerMark Valence <mrv@openldap.org>
Tue, 7 Dec 1999 18:42:25 +0000 (18:42 +0000)
include/ldap.h
libraries/libldap/init.c
libraries/libldap/ldap-int.h

index f5b733f0fb65d35202e0cc5f7d4b30551b2e0006..5af2eb99375f2e35581e43aa0dfa76b2d7d242f6 100644 (file)
@@ -114,6 +114,7 @@ LDAP_BEGIN_DECL
 #define LDAP_OPT_TIMEOUT                       0x5002  /* default timeout */
 #define LDAP_OPT_REFHOPLIMIT           0x5003  /* ref hop limit */
 #define LDAP_OPT_NETWORK_TIMEOUT        0x5005  /* socket level timeout */
+#define LDAP_OPT_URI                           0x5006
 
 /* TLS options */
 #define LDAP_OPT_X_TLS_CACERTFILE      0x6001
@@ -481,6 +482,7 @@ typedef struct ldap_friendly {
  * types for ldap URL handling
  */
 typedef struct ldap_url_desc {
+       struct ldap_url_desc *lud_next;
        int             lud_ldaps;
     char       *lud_host;
     int                lud_port;
index 805b1f18ed67a046be653bf77c515aa8a9a5f0a5..bc681d763305beeed622fc4625cee9fe176bcab3 100644 (file)
@@ -28,6 +28,7 @@ struct ldapoptions ldap_int_global_options =
 #define ATTR_KV                3
 #define ATTR_STRING    4
 #define ATTR_TLS       5
+#define ATTR_URLS      6
 
 struct ol_keyvalue {
        const char *            key;
@@ -56,10 +57,12 @@ static const struct ol_attribute {
                offsetof(struct ldapoptions, ldo_timelimit)},
        {ATTR_STRING,   "BASE",                 NULL,
                offsetof(struct ldapoptions, ldo_defbase)},
-       {ATTR_STRING,   "HOST",                 NULL,
-               offsetof(struct ldapoptions, ldo_defhost)},
        {ATTR_INT,              "PORT",                 NULL,
                offsetof(struct ldapoptions, ldo_defport)},
+       /* **** keep this around for backward compatibility */
+       {ATTR_URLS,             "HOST",                 NULL,   1},
+       /* **** */
+       {ATTR_URLS,             "URL",                  NULL,   0},
        {ATTR_BOOL,             "REFERRALS",    NULL,   LDAP_BOOL_REFERRALS},
        {ATTR_BOOL,             "RESTART",              NULL,   LDAP_BOOL_RESTART},
        {ATTR_BOOL,             "DNS",                  NULL,   LDAP_BOOL_DNS},
@@ -181,6 +184,13 @@ static void openldap_ldap_init_w_conf(const char *file)
                                ldap_pvt_tls_config( &gopts, attrs[i].offset, opt );
 #endif
                                break;
+                       case ATTR_URLS:
+                               if (attrs[i].offset == 0) {
+                                       ldap_set_option( NULL, LDAP_OPT_URI, opt );
+                               } else {
+                                       ldap_set_option( NULL, LDAP_OPT_HOST_NAME, opt );
+                               }
+                               break;
                        }
                }
        }
@@ -297,6 +307,13 @@ static void openldap_ldap_init_w_env(const char *prefix)
                        ldap_pvt_tls_config( &gopts, attrs[i].offset, value );
 #endif                         
                        break;
+               case ATTR_URLS:
+                       if (attrs[i].offset == 0) {
+                               ldap_set_option( NULL, LDAP_OPT_URI, value );
+                       } else {
+                               ldap_set_option( NULL, LDAP_OPT_HOST_NAME, value );
+                       }
+                       break;
                }
        }
 }
@@ -326,7 +343,7 @@ void ldap_int_initialize( void )
        gopts.ldo_tm_api = (struct timeval *)NULL;
        gopts.ldo_tm_net = (struct timeval *)NULL;
 
-       gopts.ldo_defhost = LDAP_STRDUP("localhost");
+       ldap_url_parselist(&gopts.ldo_defludp, "ldap://localhost/");
        gopts.ldo_defport = LDAP_PORT;
 
        gopts.ldo_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT;
index 2ab4ee7d61323f1207dbb4e43d2265c8728457ab..396ba3ef7e6876f2423155c466db789a1bb46bc7 100644 (file)
@@ -100,9 +100,9 @@ struct ldapoptions {
        ber_int_t               ldo_timelimit;
        ber_int_t               ldo_sizelimit;
 
+       LDAPURLDesc *ldo_defludp;
        int             ldo_defport;
        char*   ldo_defbase;
-       char*   ldo_defhost;
 
 #ifdef LDAP_CONNECTIONLESS
        int             ldo_cldaptries; /* connectionless search retry count */
@@ -146,7 +146,7 @@ typedef struct ldap_conn {
 #define LDAP_CONNST_NEEDSOCKET         1
 #define LDAP_CONNST_CONNECTING         2
 #define LDAP_CONNST_CONNECTED          3
-       LDAPServer              *lconn_server;
+       LDAPURLDesc             *lconn_server;
        char                    *lconn_krbinstance;
        struct ldap_conn        *lconn_next;
        BerElement              *lconn_ber;/* ber receiving on this conn. */
@@ -351,7 +351,7 @@ LIBLDAP_F (char *) ldap_get_kerberosv4_credentials LDAP_P((
  * in open.c
  */
 LIBLDAP_F (int) ldap_open_defconn( LDAP *ld );
-LIBLDAP_F (int) open_ldap_connection( LDAP *ld, Sockbuf *sb, const char *host, int defport, char **krbinstancep, int async );
+LIBLDAP_F (int) open_ldap_connection( LDAP *ld, Sockbuf *sb, LDAPURLDesc *srvlist, char **krbinstancep, int async );
 
 
 /*
@@ -386,8 +386,8 @@ LIBLDAP_F (ber_int_t) ldap_send_initial_request( LDAP *ld, ber_tag_t msgtype,
 LIBLDAP_F (BerElement *) ldap_alloc_ber_with_options( LDAP *ld );
 LIBLDAP_F (void) ldap_set_ber_options( LDAP *ld, BerElement *ber );
 
-LIBLDAP_F (int) ldap_send_server_request( LDAP *ld, BerElement *ber, ber_int_t msgid, LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc, int bind );
-LIBLDAP_F (LDAPConn *) ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, int connect, int bind );
+LIBLDAP_F (int) ldap_send_server_request( LDAP *ld, BerElement *ber, ber_int_t msgid, LDAPRequest *parentreq, LDAPURLDesc *srvlist, LDAPConn *lc, int bind );
+LIBLDAP_F (LDAPConn *) ldap_new_connection( LDAP *ld, LDAPURLDesc *srvlist, int use_ldsb, int connect, int bind );
 LIBLDAP_F (LDAPRequest *) ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid );
 LIBLDAP_F (void) ldap_free_request( LDAP *ld, LDAPRequest *lr );
 LIBLDAP_F (void) ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
@@ -439,6 +439,33 @@ LIBLDAP_F (int) ldap_send_unbind LDAP_P((
        LDAPControl **sctrls,
        LDAPControl **cctrls ));
 
+/*
+ * in url.c
+ */
+LIBLDAP_F (LDAPURLDesc *) ldap_url_dup LDAP_P((
+       LDAPURLDesc *ludp ));
+
+LIBLDAP_F (LDAPURLDesc *) ldap_url_duplist LDAP_P((
+       LDAPURLDesc *ludlist ));
+
+LIBLDAP_F (int) ldap_url_parselist LDAP_P((
+       LDAPURLDesc **ludlist,
+       const char *url ));
+
+LIBLDAP_F (int) ldap_url_parsehosts LDAP_P((
+       LDAPURLDesc **ludlist,
+       const char *hosts ));
+
+LIBLDAP_F (char *) ldap_url_list2hosts LDAP_P((
+       LDAPURLDesc *ludlist ));
+
+LIBLDAP_F (char *) ldap_url_list2urls LDAP_P((
+       LDAPURLDesc *ludlist ));
+
+LIBLDAP_F (void) ldap_free_urllist LDAP_P((
+       LDAPURLDesc *ludlist ));
+
+
 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
 /*
  * in getdxbyname.c