17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57ddae043Siz202018 * Common Development and Distribution License (the "License"). 67ddae043Siz202018 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*b57459abSJulian Pullen * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _CACHEMGR_H 277c478bd9Sstevel@tonic-gate #define _CACHEMGR_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 307c478bd9Sstevel@tonic-gate extern "C" { 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 33e1dd0a2fSth160488 #include <thread.h> 34e1dd0a2fSth160488 #include <synch.h> 35e1dd0a2fSth160488 #include <unistd.h> 36e1dd0a2fSth160488 #include <procfs.h> 377c478bd9Sstevel@tonic-gate #include "ns_sldap.h" 387c478bd9Sstevel@tonic-gate #include "ns_internal.h" 397c478bd9Sstevel@tonic-gate #include "ns_cache_door.h" 407c478bd9Sstevel@tonic-gate #include "cachemgr_door.h" 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #define LOGFILE "/var/ldap/cachemgr.log" 437c478bd9Sstevel@tonic-gate #define KILLCACHEMGR "/var/lib/ldap/ldap_cachemgr -K" 447c478bd9Sstevel@tonic-gate #define MAXBITSIZE 30 457c478bd9Sstevel@tonic-gate #define MAXDEBUG DBG_ALL 467c478bd9Sstevel@tonic-gate #define DEFAULTTTL 3600 /* 1 hour */ 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate typedef union { 497c478bd9Sstevel@tonic-gate ldap_data_t data; 507c478bd9Sstevel@tonic-gate char space[BUFFERSIZE]; 517c478bd9Sstevel@tonic-gate } dataunion; 527c478bd9Sstevel@tonic-gate 53e1dd0a2fSth160488 /* 54e1dd0a2fSth160488 * In ldap_cachemgr, it return -99 for some case, start with -100 here 55e1dd0a2fSth160488 */ 56e1dd0a2fSth160488 typedef enum chg_error { 57e1dd0a2fSth160488 CHG_SUCCESS = 0, 58e1dd0a2fSth160488 CHG_NO_MEMORY = -100, 59e1dd0a2fSth160488 CHG_INVALID_PARAM = -101, 60e1dd0a2fSth160488 CHG_NOT_FOUND_IN_WAITING_LIST = -102, 61e1dd0a2fSth160488 CHG_EXCEED_MAX_THREADS = -103, 62e1dd0a2fSth160488 CHG_NSCD_REPEATED_CALL = -104 63e1dd0a2fSth160488 } chg_error_t; 64e1dd0a2fSth160488 65e1dd0a2fSth160488 typedef struct waiting_list { 66e1dd0a2fSth160488 pid_t pid; /* pid of the door client */ 67e1dd0a2fSth160488 thread_t tid; /* thread id of the server */ 68e1dd0a2fSth160488 /* thread */ 69e1dd0a2fSth160488 int cleanup; /* 1: the thread will be */ 70e1dd0a2fSth160488 /* cleaned up */ 71e1dd0a2fSth160488 struct waiting_list *prev; /* previous node in the */ 72e1dd0a2fSth160488 /* linked list */ 73e1dd0a2fSth160488 struct waiting_list *next; /* next node in the linked */ 74e1dd0a2fSth160488 /* list */ 75e1dd0a2fSth160488 } waiting_list_t; 76e1dd0a2fSth160488 77e1dd0a2fSth160488 /* 78e1dd0a2fSth160488 * This structure contains the buffer for the chang data and a wating list to 79e1dd0a2fSth160488 * regester all the threads that handle GETSTATUSCHANGE START call and are 80e1dd0a2fSth160488 * waiting for the change notification. 81e1dd0a2fSth160488 * The notification threads save the data in the buffer then send broadcast 82e1dd0a2fSth160488 * to wake up the GETSTATUSCHANGE START threads to copy data to the stack and 83e1dd0a2fSth160488 * door_return(). 84e1dd0a2fSth160488 */ 85e1dd0a2fSth160488 typedef struct chg_info { 86e1dd0a2fSth160488 mutex_t chg_lock; /* mutex for this data structure */ 87e1dd0a2fSth160488 cond_t chg_cv; /* cond var for synchronization */ 88e1dd0a2fSth160488 int chg_wakeup; /* flag used with chg_cv for */ 89e1dd0a2fSth160488 /* synchronization */ 90e1dd0a2fSth160488 waiting_list_t *chg_w_first; /* the head of the linked list */ 91e1dd0a2fSth160488 waiting_list_t *chg_w_last; /* the tail of the linked list */ 92e1dd0a2fSth160488 char *chg_data; /* the buffer for the change data */ 93e1dd0a2fSth160488 int chg_data_size; /* the size of the change data */ 94e1dd0a2fSth160488 } chg_info_t; 95e1dd0a2fSth160488 967c478bd9Sstevel@tonic-gate extern char *getcacheopt(char *s); 977c478bd9Sstevel@tonic-gate extern void logit(char *format, ...); 987c478bd9Sstevel@tonic-gate extern int load_admin_defaults(admin_t *ptr, int will_become_server); 997c478bd9Sstevel@tonic-gate extern int getldap_init(void); 1007c478bd9Sstevel@tonic-gate extern void getldap_revalidate(void); 1017c478bd9Sstevel@tonic-gate extern int getldap_uidkeepalive(int keep, int interval); 1027c478bd9Sstevel@tonic-gate extern int getldap_invalidate(void); 1037ddae043Siz202018 extern void getldap_lookup(LineBuf *config_info, ldap_call_t *in); 104*b57459abSJulian Pullen extern void getldap_admincred(LineBuf *config_info, ldap_call_t *in); 1057c478bd9Sstevel@tonic-gate extern void getldap_refresh(void); 1067c478bd9Sstevel@tonic-gate extern int cachemgr_set_dl(admin_t *ptr, int value); 1077c478bd9Sstevel@tonic-gate extern int cachemgr_set_ttl(ldap_stat_t *cache, char *name, int value); 1087c478bd9Sstevel@tonic-gate extern int get_clearance(int callnumber); 1097c478bd9Sstevel@tonic-gate extern int release_clearance(int callnumber); 1107c478bd9Sstevel@tonic-gate #ifdef SLP 1117c478bd9Sstevel@tonic-gate extern void discover(); 112a506a34cSth160488 #endif /* SLP */ 1137c478bd9Sstevel@tonic-gate extern void getldap_serverInfo_refresh(void); 1147ddae043Siz202018 extern void getldap_getserver(LineBuf *config_info, ldap_call_t *in); 1157ddae043Siz202018 extern void getldap_get_cacheData(LineBuf *config_info, ldap_call_t *in); 1167ddae043Siz202018 extern int getldap_set_cacheData(ldap_call_t *in); 1177ddae043Siz202018 extern void getldap_get_cacheStat(LineBuf *stat_info); 118e1dd0a2fSth160488 extern int is_called_from_nscd(pid_t pid); /* in cachemgr.c */ 119e1dd0a2fSth160488 extern int chg_is_called_from_nscd_or_peruser_nscd(char *dc_str, pid_t *pidp); 120e1dd0a2fSth160488 extern void *chg_cleanup_waiting_threads(void *arg); 121e1dd0a2fSth160488 extern int chg_get_statusChange(LineBuf *config_info, ldap_call_t *in, 122e1dd0a2fSth160488 pid_t nscd_pid); 123e1dd0a2fSth160488 extern int chg_notify_statusChange(char *str); 124e1dd0a2fSth160488 extern void chg_test_config_change(ns_config_t *new, int *change_status); 125e1dd0a2fSth160488 extern void chg_config_cookie_set(ldap_get_chg_cookie_t *cookie); 126e1dd0a2fSth160488 extern ldap_get_chg_cookie_t chg_config_cookie_get(void); 1277c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1287c478bd9Sstevel@tonic-gate } 1297c478bd9Sstevel@tonic-gate #endif 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate #endif /* _CACHEMGR_H */ 132