#ifndef __CSearchPlugin_h__
#define __CSearchPlugin_h__ 1
#include <stdio.h>
#include "DirServicesTypes.h"
#include "PrivateTypes.h"
#include "PluginData.h"
#include "CConfigs.h"
#include "CBuff.h"
#include "CServerPlugin.h"
#include "CInternalDispatchThread.h"
#include <CoreFoundation/CoreFoundation.h>
#include "DSEventSemaphore.h"
#define kXMLSwitchComputersKey "Switch Computers"
#define kXMLSwitchAllKey "Switch All"
#define kXMLServerConfigKey "LDAP Server Config"
class CDataBuff;
typedef enum {
keUnknownState = 0,
keGetRecordList = 1,
keAddDataToBuff = 2,
keGetNextNodeRef = 5,
keSetContinueData = 6,
keDone = 7,
keError = 8,
keBufferTooSmall = 9,
keSearchNodeListEnd =10
} eSearchState;
typedef struct sSearchConfig {
sSearchList *fSearchNodeList;
UInt32 fSearchNodePolicy;
CConfigs *pConfigFromXML;
char *fSearchNodeName;
char *fSearchConfigFilePrefix;
eDirNodeType fDirNodeType;
UInt32 fSearchConfigKey; sSearchConfig *fNext;
} sSearchConfig;
typedef struct {
UInt32 fID;
tDirReference fDirRef;
tDirNodeReference fNodeRef;
bool fAttrOnly;
UInt32 fRecCount;
UInt32 fRecIndex;
UInt32 fLimitRecSearch;
UInt32 fTotalRecCount;
eSearchState fState;
tDataBuffer *fDataBuff;
void *fContextData;
bool bNodeBuffTooSmall;
bool bIsAugmented;
tDataListPtr fAugmentReqAttribs;
} sSearchContinueData;
typedef struct {
sSearchList *fSearchNodeList;
int32_t bListChanged; DSMutexSemaphore *pSearchListMutex;
UInt32 offset;
UInt32 fSearchConfigKey;
void *fSearchNode;
bool bAutoSearchList;
bool bCheckForNIParentNow;
uid_t fUID;
uid_t fEffectiveUID;
#if AUGMENT_RECORDS
CConfigs *pConfigFromXML;
#endif
} sSearchContextData;
class CSearchPluginHandlerThread : public CInternalDispatchThread
{
public:
CSearchPluginHandlerThread ( void );
CSearchPluginHandlerThread ( const FourCharCode inThreadSignature, int inWhichFunction, void *inNeededClass );
virtual ~CSearchPluginHandlerThread ( void );
virtual long ThreadMain ( void ); virtual void StartThread ( void );
virtual void StopThread ( void );
protected:
virtual void LastChance ( void );
private:
int fWhichFunction;
void *fNeededClass;
};
__BEGIN_DECLS
int ShouldRegisterWorkstation(void);
__END_DECLS
class CSearchPlugin : public CServerPlugin
{
public:
static DSEventSemaphore fAuthPolicyChangeEvent;
static DSEventSemaphore fContactPolicyChangeEvent;
static int32_t fAuthCheckNodeThreadActive;
static int32_t fContactCheckNodeThreadActive;
CSearchPlugin ( FourCharCode inSig, const char *inName );
virtual ~CSearchPlugin ( void );
virtual SInt32 Validate ( const char *inVersionStr, const UInt32 inSignature );
virtual SInt32 Initialize ( void );
virtual SInt32 SetPluginState ( const UInt32 inState );
virtual SInt32 PeriodicTask ( void );
virtual SInt32 ProcessRequest ( void *inData );
static void WakeUpRequests ( void );
static void ContinueDeallocProc ( void *inContinueData );
static void ContextDeallocProc ( void* inContextData );
static void ContextSetListChangedProc
( void* inContextData );
static void ContextSetCheckForNIParentNowProc
( void* inContextData );
SInt32 CleanSearchConfigData ( sSearchConfig *inList );
SInt32 CleanSearchListData ( sSearchList *inList );
void EnsureCheckNodesThreadIsRunning ( tDirPatternMatch policyToCheck );
void CheckNodes ( tDirPatternMatch policyToCheck, int32_t *threadFlag, DSEventSemaphore *eventSemaphore );
bool fRegisterWorkstation;
protected:
bool SwitchSearchPolicy ( UInt32 inSearchPolicy,
sSearchConfig *inSearchConfig );
SInt32 HandleRequest ( void *inData );
void WaitForInit ( void );
SInt32 AddLocalNodesAsFirstPaths ( sSearchList **inSearchNodeList );
SInt32 AddDefaultLDAPNodesLast ( sSearchList **inSearchNodeList );
sSearchConfig *MakeSearchConfigData ( sSearchList *inSearchNodeList,
UInt32 inSearchPolicy,
CConfigs *inConfigFromXML,
char *inSearchNodeName,
char *inSearchConfigFilePrefix,
eDirNodeType inDirNodeType,
UInt32 inSearchConfigType );
sSearchConfig *FindSearchConfigWithKey ( UInt32 inSearchConfigKey );
SInt32 AddSearchConfigToList ( sSearchConfig *inSearchConfig );
static SInt32 CleanContextData ( sSearchContextData *inContext );
void SetSearchPolicyIndicatorFile( UInt32 inSearchNodeIndex,
UInt32 inSearchPolicyIndex );
void RemoveSearchPolicyIndicatorFile ( void );
void HandleMultipleNetworkTransitions ( void );
private:
SInt32 OpenDirNode ( sOpenDirNode *inData );
SInt32 CloseDirNode ( sCloseDirNode *inData );
SInt32 GetDirNodeInfo ( sGetDirNodeInfo *inData );
SInt32 GetRecordList ( sGetRecordList *inData );
SInt32 GetRecordEntry ( sGetRecordEntry *inData );
SInt32 GetAttributeEntry ( sGetAttributeEntry *inData );
SInt32 GetAttributeValue ( sGetAttributeValue *inData );
sSearchList *GetDefaultLocalPath ( void );
sSearchList *GetBSDLocalPath ( void );
sSearchList *GetDefaultLDAPPaths ( void );
SInt32 AttributeValueSearch ( sDoAttrValueSearchWithData *inData );
SInt32 MultipleAttributeValueSearch
( sDoMultiAttrValueSearchWithData *inData );
SInt32 CloseAttributeList ( sCloseAttributeList *inData );
SInt32 CloseAttributeValueList ( sCloseAttributeValueList *inData );
SInt32 ReleaseContinueData ( sReleaseContinueData *inData );
SInt32 DoPlugInCustomCall ( sDoPlugInCustomCall *inData );
void SystemGoingToSleep ( void );
void SystemWillPowerOn ( void );
SInt32 GetNextNodeRef ( tDirNodeReference inNodeRef,
tDirNodeReference *outNodeRef,
sSearchContextData *inContext );
tDataList *GetNodePath ( tDirNodeReference inNodeRef,
sSearchContextData *inContext );
SInt32 AddDataToOutBuff ( sSearchContinueData *inContinue,
CBuff *inOutBuff,
sSearchContextData *inContext,
tDataListPtr inRequestedAttrList );
SInt32 CheckSearchPolicyChange ( sSearchContextData *pContext,
tDirNodeReference inNodeRef,
tContextData inContinueData );
bool IsAugmented ( sSearchContextData *inContext,
tDirNodeReference inNodeRef );
void UpdateContinueForAugmented ( sSearchContextData *inContext,
sSearchContinueData *inContinue,
tDataListPtr inAttrTypeRequestList );
sSearchContextData* MakeContextData ( void );
sSearchList* DupSearchListWithNewRefs( sSearchList *inSearchList );
sSearchList* BuildNetworkNodeList ( void );
#if AUGMENT_RECORDS
SInt32 CheckForAugmentConfig ( tDirPatternMatch policyToCheck );
CFDictionaryRef FindAugmentConfigRecord ( tDirPatternMatch nodeType );
#endif
sSearchConfig *pSearchConfigList; DSMutexSemaphore fMutex;
tDirReference fDirRef;
UInt32 fState;
CFStringRef fLZMACAddress;
CFStringRef fNLZMACAddress;
char *fAuthSearchPathCheck;
bool fSomeNodeFailedToOpen;
#if AUGMENT_RECORDS
tDirNodeReference fAugmentNodeRef;
#endif
};
#endif // __CSearchPlugin_H__