4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #ifdef SLP
27
28 /*
29 * This file contains all the dynamic server discovery functionality
30 * for ldap_cachemgr. SLP is used to query the network for any changes
31 * in the set of deployed LDAP servers.
32 *
33 * The algorithm used is outlined here:
34 *
35 * 1. Find all naming contexts with SLPFindAttrs. (See
36 * find_all_contexts())
37 * 2. For each context, find all servers which serve that context
38 * with SLPFindSrvs. (See foreach_context())
39 * 3. For each server, retrieve that server's attributes with
40 * SLPFindAttributes. (See foreach_server())
41 * 4. Aggregate the servers' attributes into a config object. There
42 * is one config object associated with each context found in
43 * step 1. (See aggregate_attrs())
522 foreach_context, cookie);
523 if (err != SLP_OK) {
524 if (current_admin.debug_level >= DBG_CANT_FIND) {
525 (void) logit(
526 "discover: Aborting discovery: SLPFindAttrs failed: %s\n",
527 slp_strerror(err));
528 }
529 goto done;
530 }
531
532 done:
533 if (h) SLPClose(h);
534 if (fulltype) free(fulltype);
535 }
536
537 /*
538 * This is the ldap_cachemgr entry point into SLP dynamic discovery. The
539 * parameter 'r' should be a pointer to an unsigned int containing
540 * the requested interval at which the network should be queried.
541 */
542 void discover(void *r) {
543 unsigned short reqrefresh = *((unsigned int *)r);
544
545 for (;;) {
546 find_all_contexts("ldap",
547 __cache_get_cfghandle,
548 __cache_aggregate_params,
549 __cache_set_cfghandle);
550
551 if (current_admin.debug_level >= DBG_ALL) {
552 (void) logit(
553 "dynamic discovery: using refresh interval %d\n",
554 reqrefresh);
555 }
556
557 (void) sleep(reqrefresh);
558 }
559 }
560
561 #endif /* SLP */
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 *
25 * Copyright 2018 Joyent, Inc.
26 */
27
28 #ifdef SLP
29
30 /*
31 * This file contains all the dynamic server discovery functionality
32 * for ldap_cachemgr. SLP is used to query the network for any changes
33 * in the set of deployed LDAP servers.
34 *
35 * The algorithm used is outlined here:
36 *
37 * 1. Find all naming contexts with SLPFindAttrs. (See
38 * find_all_contexts())
39 * 2. For each context, find all servers which serve that context
40 * with SLPFindSrvs. (See foreach_context())
41 * 3. For each server, retrieve that server's attributes with
42 * SLPFindAttributes. (See foreach_server())
43 * 4. Aggregate the servers' attributes into a config object. There
44 * is one config object associated with each context found in
45 * step 1. (See aggregate_attrs())
524 foreach_context, cookie);
525 if (err != SLP_OK) {
526 if (current_admin.debug_level >= DBG_CANT_FIND) {
527 (void) logit(
528 "discover: Aborting discovery: SLPFindAttrs failed: %s\n",
529 slp_strerror(err));
530 }
531 goto done;
532 }
533
534 done:
535 if (h) SLPClose(h);
536 if (fulltype) free(fulltype);
537 }
538
539 /*
540 * This is the ldap_cachemgr entry point into SLP dynamic discovery. The
541 * parameter 'r' should be a pointer to an unsigned int containing
542 * the requested interval at which the network should be queried.
543 */
544 void
545 discover(void *r) {
546 unsigned short reqrefresh = *((unsigned int *)r);
547
548 (void) pthread_setname_np(pthread_self(), "discover");
549
550 for (;;) {
551 find_all_contexts("ldap",
552 __cache_get_cfghandle,
553 __cache_aggregate_params,
554 __cache_set_cfghandle);
555
556 if (current_admin.debug_level >= DBG_ALL) {
557 (void) logit(
558 "dynamic discovery: using refresh interval %d\n",
559 reqrefresh);
560 }
561
562 (void) sleep(reqrefresh);
563 }
564 }
565
566 #endif /* SLP */
|