/*
 * Copyright 2000, International Business Machines Corporation and others.
 * All Rights Reserved.
 *
 * This software has been released under the terms of the IBM Public
 * License.  For details, see the LICENSE file in the top-level source
 * directory or online at http://www.openafs.org/dl/license10.html
 */

import "wtypes.idl";
cpp_quote ("#ifndef _WINNT_")
typedef WORD LANGID;
cpp_quote ("#endif // _WINNT_")

const int ENCRYPTIONKEYLENGTH = 8;


      // ASID - Admin Server ID
      // ...Type used for unique object identifiers throughout these adm
      //
typedef UINT_PTR ASID, *LPASID;


      // ASOBJTYPE - Admin Server Object Type
      // ...Enumeration used to classify a particular object within a cell.
      //    The types' values don't overlap, so they can be specified in
      //    combination during searches.
      //
typedef enum {
   TYPE_CELL       = 0x00000001,
   TYPE_SERVER     = 0x00000002,
   TYPE_SERVICE    = 0x00000004,
   TYPE_PARTITION  = 0x00000008,
   TYPE_VOLUME     = 0x00000010,
   TYPE_USER       = 0x00000020,
   TYPE_GROUP      = 0x00000040,
   TYPE_ANY        = 0x0000FFFF
} ASOBJTYPE;


      // STRING - Default String Definition
      //
cpp_quote ("#ifdef _WINDOWS_")
cpp_quote ("typedef char stringchar;")
cpp_quote ("#else // _WINDOWS_")
typedef char stringchar;
cpp_quote ("#endif // _WINDOWS_")

const int cchSTRING = 256;
typedef stringchar STRING [ cchSTRING ];


      // VOLUMEID - Volume ID
      // ...Type used to hold an AFS volume identifier.
      //
cpp_quote ("#ifndef AFSCLASS_H")
typedef unsigned int VOLUMEID, *LPVOLUMEID;
cpp_quote ("#endif // AFSCLASS_H")


      // ACCOUNTACCESS - Indicator of who is allowed to manipulate an object
      // ...An enumeration used to indicate the security level around an
      //    object. The admin server does not use this information directly,
      //    but passes it on to the AFS server processes.
      //
cpp_quote ("#ifndef AFSCLASS_H")
typedef enum {
   aaOWNER_ONLY,
   aaGROUP_ONLY,
   aaANYONE,
} ACCOUNTACCESS;
cpp_quote ("#endif // AFSCLASS_H")


      // ASACTIONTYPE - Operation Type Identifier
      // ...Enumeration used to classify a particular operation in progress
      //    by its type. Together with the ASACTION structure and ASACTLIST
      //    structure, this type is used to indicate the operations being
      //    performed on the admin server
      //
typedef enum {
   ACTION_REFRESH,	// Refreshing cache for cell or object
   ACTION_SCOUT,	// Testing for problems in cell
   ACTION_USER_CHANGE,	// Changing user's properties
   ACTION_USER_PW_CHANGE,	// Changing user's password
   ACTION_USER_UNLOCK,	// Unlocking user's account
   ACTION_USER_CREATE,	// Creating user account
   ACTION_USER_DELETE,	// Deleting user account
   ACTION_GROUP_CHANGE,	// Changing group's properties
   ACTION_GROUP_MEMBER_ADD,	// Adding a member to a group
   ACTION_GROUP_MEMBER_REMOVE,	// Removing a member from a group
   ACTION_GROUP_RENAME,	// Renaming a group
   ACTION_GROUP_CREATE,	// Creating group
   ACTION_GROUP_DELETE,	// Deleting group
   ACTION_CELL_CHANGE,	// Changing a cell's properties
} ASACTIONTYPE;


      // ASACTION - Operation Identifier
      // ...Provides a structure encapsulating all known information about an
      //    operation currently in progress.
      //
typedef struct {
   ASID  idScope;	// Scope of refresh (cell or object)
} ASACTION_REFRESH;

typedef struct {
   ASID  idScope;	// Scope of scout (cell or object)
} ASACTION_SCOUT;

typedef struct {
   ASID  idUser;	// User whose properties are changing
} ASACTION_USER_CHANGE;

typedef struct {
   ASID  idUser;	// User whose password is changing
} ASACTION_USER_PW_CHANGE;

typedef struct {
   ASID  idUser;	// User whose account is being unlocked
} ASACTION_USER_UNLOCK;

typedef struct {
   STRING szUser;	// Name of new user account
   STRING szInstance;	// Name of new user account
} ASACTION_USER_CREATE;

typedef struct {
   ASID  idUser;	// User being deleted
} ASACTION_USER_DELETE;

typedef struct {
   ASID  idGroup;	// Group whose properties are changing
} ASACTION_GROUP_CHANGE;

typedef struct {
   ASID  idGroup;	// Group which is changing
   ASID  idUser;	// User who is being added as a member
} ASACTION_GROUP_MEMBER_ADD;

typedef struct {
   ASID  idGroup;	// Group which is changing
   ASID  idUser;	// Member who is being removed
} ASACTION_GROUP_MEMBER_REMOVE;

typedef struct {
   ASID  idGroup;	// Group which is changing
   STRING szNewName;	// Member who is being removed
} ASACTION_GROUP_RENAME;

typedef struct {
   STRING szGroup;	// Name of new PTS group
} ASACTION_GROUP_CREATE;

typedef struct {
   ASID  idGroup;	// Group being deleted
} ASACTION_GROUP_DELETE;

typedef struct {
   ASACTIONTYPE Action;	// The operation in progress
   DWORD idAction;	// Unique action identifier
   UINT_PTR idClient;	// Client which initiated the operation
   ASID idCell;	// Cell in which operation is occurring
   DWORD csecActive;	// Elapsed active time for operation

   [switch_is(Action)] union {
      [case(ACTION_REFRESH)]             ASACTION_REFRESH              Refresh;
      [case(ACTION_SCOUT)]               ASACTION_SCOUT                Scout;
      [case(ACTION_USER_CHANGE)]         ASACTION_USER_CHANGE          User_Change;
      [case(ACTION_USER_PW_CHANGE)]      ASACTION_USER_PW_CHANGE       User_Pw_Change;
      [case(ACTION_USER_UNLOCK)]         ASACTION_USER_UNLOCK          User_Unlock;
      [case(ACTION_USER_CREATE)]         ASACTION_USER_CREATE          User_Create;
      [case(ACTION_USER_DELETE)]         ASACTION_USER_DELETE          User_Delete;
      [case(ACTION_GROUP_CHANGE)]        ASACTION_GROUP_CHANGE         Group_Change;
      [case(ACTION_GROUP_MEMBER_ADD)]    ASACTION_GROUP_MEMBER_ADD     Group_Member_Add;
      [case(ACTION_GROUP_MEMBER_REMOVE)] ASACTION_GROUP_MEMBER_REMOVE  Group_Member_Remove;
      [case(ACTION_GROUP_RENAME)]        ASACTION_GROUP_RENAME         Group_Rename;
      [case(ACTION_GROUP_CREATE)]        ASACTION_GROUP_CREATE         Group_Create;
      [case(ACTION_GROUP_DELETE)]        ASACTION_GROUP_DELETE         Group_Delete;
      [default]                          ;
   } u;
} ASACTION, *LPASACTION;


      // ASOBJPROP - Object Properties Structure
      // ...A union of the different object properties structures, with an
      //    ASOBJTYPE identifier to indicate which one is valid. Each such
      //    structure has an associated version; as new information is obtained
      //    on the server, the internal version number is incremented.
      //
const DWORD verPROP_NO_OBJECT = 0;     // object deleted or otherwise invalid
const DWORD verPROP_RUDIMENTARY = 1;   // only asked to obtain name etc
const DWORD verPROP_FIRST_SCAN = 2;    // first properties obtained for object

const DWORD ASOBJPROP_SERVER_MAXADDRESS = 16; // AFS uses <=16 addrs per server

typedef struct {
   DWORD idUserMax;
   DWORD idGroupMax;
} ASOBJPROP_CELL, *LPASOBJPROP_CELL;

typedef struct {
   ULONG nAddresses;
   DWORD aAddresses[ ASOBJPROP_SERVER_MAXADDRESS ];
} ASOBJPROP_SERVER, *LPASOBJPROP_SERVER;

cpp_quote ("#ifndef AFSCLASS_H")
typedef enum {
   SERVICETYPE_SIMPLE,
   SERVICETYPE_FS,
   SERVICETYPE_CRON
} AFSSERVICETYPE;
cpp_quote ("#endif // AFSCLASS_H")

cpp_quote ("#ifndef AFSCLASS_H")
typedef enum {
   SERVICESTATE_RUNNING,
   SERVICESTATE_STOPPED,
   SERVICESTATE_STARTING,
   SERVICESTATE_STOPPING
} SERVICESTATE;
cpp_quote ("#endif // AFSCLASS_H")

typedef struct {
   AFSSERVICETYPE ServiceType;
   SERVICESTATE ServiceState;
   STRING szAuxStatus;
   STRING szParams;
   STRING szNotifier;
   SYSTEMTIME timeLastStart;
   SYSTEMTIME timeLastStop;
   SYSTEMTIME timeLastFail;
   ULONG nStarts;
   ULONG dwErrLast;
   ULONG dwSigLast;
} ASOBJPROP_SERVICE, *LPASOBJPROP_SERVICE;

typedef struct {
   ULONG dwID;
   UINT_PTR ckStorageTotal;
   UINT_PTR ckStorageFree;
   UINT_PTR ckStorageAllocated;
} ASOBJPROP_PARTITION, *LPASOBJPROP_PARTITION;

cpp_quote ("#ifndef AFSCLASS_H")
typedef enum {
   ftREADWRITE,
   ftREPLICA,
   ftCLONE
} FILESETTYPE;
cpp_quote ("#endif // AFSCLASS_H")

typedef struct {
   VOLUMEID id;
   VOLUMEID idReadWrite;
   VOLUMEID idReplica;
   VOLUMEID idClone;
   SYSTEMTIME timeCreation;
   SYSTEMTIME timeLastUpdate;
   SYSTEMTIME timeLastAccess;
   SYSTEMTIME timeLastBackup;
   SYSTEMTIME timeCopyCreation;
   ULONG nFiles;
   UINT_PTR ckQuota;
   UINT_PTR ckUsed;
   FILESETTYPE FilesetType;
   DWORD FilesetState;
} ASOBJPROP_VOLUME, *LPASOBJPROP_VOLUME;

const DWORD FILESETSTATE_NORMAL      = 0x00000000;
const DWORD FILESETSTATE_SALVAGE     = 0x00000001;
const DWORD FILESETSTATE_NO_VNODE    = 0x00000002;
const DWORD FILESETSTATE_NO_VOL      = 0x00000004;
const DWORD FILESETSTATE_NO_SERVICE  = 0x00000008;
const DWORD FILESETSTATE_OFFLINE     = 0x00000010;
const DWORD FILESETSTATE_DISK_FULL   = 0x00000020;
const DWORD FILESETSTATE_OVER_QUOTA  = 0x00000040;
const DWORD FILESETSTATE_BUSY        = 0x00000080;
const DWORD FILESETSTATE_MOVED       = 0x00000100;
const DWORD FILESETSTATE_LOCKED      = 0x00010000;  // see afsclass/c_set.h

typedef struct {
   BOOL fHaveKasInfo;
   BOOL fHavePtsInfo;
   STRING szInstance;

   struct
      {
      BOOL fIsAdmin;
      BOOL fCanGetTickets;
      BOOL fEncrypt;
      BOOL fCanChangePassword;
      BOOL fCanReusePasswords;
      SYSTEMTIME timeExpires;
      SYSTEMTIME timeLastPwChange;
      SYSTEMTIME timeLastMod;
      STRING szUserLastMod;
      LONG csecTicketLifetime;
      int keyVersion;
      BYTE keyData[ENCRYPTIONKEYLENGTH];
      DWORD dwKeyChecksum;
      LONG cdayPwExpire;
      LONG cFailLogin;
      LONG csecFailLoginLock;
      } KASINFO;

   struct
      {
      LONG cgroupCreationQuota;
      LONG cgroupMember;
      int uidName;
      int uidOwner;
      int uidCreator;
      STRING szOwner;
      STRING szCreator;
      ACCOUNTACCESS aaListStatus;
      ACCOUNTACCESS aaGroupsOwned;
      ACCOUNTACCESS aaMembership;
      } PTSINFO;

} ASOBJPROP_USER, *LPASOBJPROP_USER;

typedef struct {
   int nMembers;
   int uidName;
   int uidOwner;
   int uidCreator;
   ACCOUNTACCESS aaListStatus;
   ACCOUNTACCESS aaListGroupsOwned;
   ACCOUNTACCESS aaListMembers;
   ACCOUNTACCESS aaAddMember;
   ACCOUNTACCESS aaDeleteMember;
   STRING szOwner;
   STRING szCreator;
} ASOBJPROP_GROUP, *LPASOBJPROP_GROUP;

typedef struct {
   ASOBJTYPE Type;
   ASID idObject;
   ASID idParentCell;
   ASID idParentServer;
   ASID idParentPartition;
   STRING szName;
   DWORD verProperties;  // if > verPROP_RUDIMENTARY, union information valid
   LPARAM lParam;

   [switch_is(Type)] union {
      [case(TYPE_CELL)]      ASOBJPROP_CELL       CellProperties;
      [case(TYPE_SERVER)]    ASOBJPROP_SERVER     ServerProperties;
      [case(TYPE_SERVICE)]   ASOBJPROP_SERVICE    ServiceProperties;
      [case(TYPE_PARTITION)] ASOBJPROP_PARTITION  PartitionProperties;
      [case(TYPE_VOLUME)]    ASOBJPROP_VOLUME     VolumeProperties;
      [case(TYPE_USER)]      ASOBJPROP_USER       UserProperties;
      [case(TYPE_GROUP)]     ASOBJPROP_GROUP      GroupProperties;
      [default]              ;
   } u;
} ASOBJPROP, *LPASOBJPROP;


      // ASIDLIST - Managed type for lists of cell objects
      // ...Both the server and client libraries use TaAfsAdmSvrCommon.cpp,
      //    which contains (among other things) routines for manipulating
      //    ASIDLIST structures. This structure represents a list of ASIDs--
      //    that is, references to objects within a specific cell. Different
      //    APIs which use ASIDLIST structures may have different uses for the
      //    {ASIDLIST.aEntries[].lParam} parameter.
      //
typedef struct {
   ULONG cEntries;
   ULONG cEntriesAllocated;  // (used internally)
   [size_is(cEntriesAllocated), length_is(cEntriesAllocated)] struct {
      ASID idObject;
      LPARAM lParam;
   } aEntries[*];
} ASIDLIST, *LPASIDLIST;


      // ASOBJPROPLIST - Managed type for lists of object properties
      // ...This structure represents a list of ASOBJPROPs.
      //
typedef struct {
   ULONG cEntries;
   ULONG cEntriesAllocated;  // (used internally)
   [size_is(cEntriesAllocated), length_is(cEntriesAllocated)] struct {
      ASOBJPROP ObjectProperties;
      LPARAM lParam;
   } aEntries[*];
} ASOBJPROPLIST, *LPASOBJPROPLIST;


      // ASACTIONLIST - Managed type for lists of actions in progress
      // ...This structure represents a list of ASACTION objects.
      //
typedef struct {
   ULONG cEntries;
   ULONG cEntriesAllocated;  // (used internally)
   [size_is(cEntriesAllocated), length_is(cEntriesAllocated)] struct {
      ASACTION Action;
   } aEntries[*];
} ASACTIONLIST, *LPASACTIONLIST;


      // AFSADMSVR_SEARCH_REFRESH - Defines search parameters
      // ...This structure is used when calling AfsAdmSvr_Search.
      //
typedef enum {
   SEARCH_KNOWN_OBJECTS,    // test only already-found objects
   SEARCH_ALL_OBJECTS       // ensure cell scanned for all such objects first
} AFSADMSVR_SEARCH_REFRESH;


      // AFSADMSVR_GET_TYPE - Defines data retrieval parameters
      // AFSADMSVR_GET_LEVEL - Defines data retrieval parameters
      // ...These structures are used when calling AfsAdmSvr_GetObject
      //
typedef enum {
   RETURN_DATA_ALWAYS,         // only need to return name etc
   RETURN_IF_OUT_OF_DATE,      // always returns information for all objects
} AFSADMSVR_GET_TYPE;

typedef enum {
   GET_RUDIMENTARY_DATA,       // only need to return name etc
   GET_ALL_DATA                // always returns information for all objects
} AFSADMSVR_GET_LEVEL;


      // AFSADMSVR_CHANGECELL_PARAMS - Parameters for changing a cell
      //
typedef struct {
   DWORD idUserMax;
   DWORD idGroupMax;
} AFSADMSVR_CHANGECELL_PARAMS, *LPAFSADMSVR_CHANGECELL_PARAMS;


      // AFSADMSVR_CHANGEUSER_PARAMS - Parameters for changing users' properties
      //
typedef struct {
   BOOL fIsAdmin;
   BOOL fCanGetTickets;
   BOOL fEncrypt;
   BOOL fCanChangePassword;
   BOOL fCanReusePasswords;
   SYSTEMTIME timeExpires;
   LONG cdayPwExpire;
   LONG csecTicketLifetime;
   LONG cFailLogin;
   LONG csecFailLoginLock;
   LONG cgroupCreationQuota;
   ACCOUNTACCESS aaListStatus;
   ACCOUNTACCESS aaGroupsOwned;
   ACCOUNTACCESS aaMembership;
} AFSADMSVR_CHANGEUSER_PARAMS, *LPAFSADMSVR_CHANGEUSER_PARAMS;


      // AFSADMSVR_CHANGEGROUP_PARAMS - Parameters for changing groups
      //
typedef struct {
   STRING szOwner;
   ACCOUNTACCESS aaListStatus;
   ACCOUNTACCESS aaListGroupsOwned;
   ACCOUNTACCESS aaListMembers;
   ACCOUNTACCESS aaAddMember;
   ACCOUNTACCESS aaDeleteMember;
} AFSADMSVR_CHANGEGROUP_PARAMS, *LPAFSADMSVR_CHANGEGROUP_PARAMS;


      // AFSADMSVR_CREATEUSER_PARAMS - Parameters for creating user accounts
      //
typedef struct
   {
   STRING szName;
   STRING szInstance;
   STRING szPassword;
   UINT_PTR idUser;
   BOOL fCreateKAS;
   BOOL fCreatePTS;
   } AFSADMSVR_CREATEUSER_PARAMS, *LPAFSADMSVR_CREATEUSER_PARAMS;


      // AFSADMSVR_CREATEGROUP_PARAMS - Parameters for creating PTS groups
      //
typedef struct
   {
   STRING szName;
   STRING szOwner;
   int idGroup;
   } AFSADMSVR_CREATEGROUP_PARAMS, *LPAFSADMSVR_CREATEGROUP_PARAMS;


      // AFSADMSVR_DELETEUSER_PARAMS - Parameters for deleting user accounts
      //
typedef struct
   {
   BOOL fDeleteKAS;
   BOOL fDeletePTS;
   } AFSADMSVR_DELETEUSER_PARAMS, *LPAFSADMSVR_DELETEUSER_PARAMS;


      // AFSADMSVR_SEARCH_TYPE - Advanced search types
      //
typedef enum
   {
   SEARCH_NO_LIMITATIONS,
   SEARCH_EXPIRES_BEFORE,
   SEARCH_PASSWORD_EXPIRES_BEFORE
   } AFSADMSVR_SEARCH_TYPE;

      // AFSADMSVR_SEARCH_PARAMS - Advanced search parameters
      //
typedef struct
   {
   AFSADMSVR_SEARCH_TYPE SearchType;
   SYSTEMTIME SearchTime;
   } AFSADMSVR_SEARCH_PARAMS, *LPAFSADMSVR_SEARCH_PARAMS;

