windows-dbg-refcount-20061016
[openafs.git] / src / WINNT / afsd / cm_user.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef __CM_USER_H_ENV__
11 #define __CM_USER_H_ENV__ 1
12
13 #include <osi.h>
14 #include <rx/rxkad.h>
15
16 /* user structure
17  * no free references outside of cm_allUsersp
18  * there are held references from cm_conn_t.
19  * 
20  * All the fields in this structure are locked by the
21  * corresponding userp's userp->mx mutex.
22  */
23 typedef struct cm_ucell {
24     struct cm_ucell *nextp;             /* next cell in the list */
25     struct cm_cell *cellp;              /* the cell this applies to */
26     char *ticketp;                      /* locked by mx */
27     int ticketLen;                      /* by mx */
28     struct ktc_encryptionKey sessionKey;/* by mx */
29     long kvno;                          /* key version in ticket */
30     time_t expirationTime;              /* when tix expire */
31     int gen;                            /* generation number */
32     int iterator;                       /* for use as ListTokens cookie */
33     long flags;                         /* flags */
34     char userName[MAXKTCNAMELEN];       /* user name */
35 #ifdef QUERY_AFSID
36     afs_uint32 uid;                     /* User's AFS ID in this cell */
37 #endif
38 } cm_ucell_t;
39
40 #define CM_UCELLFLAG_HASTIX     1       /* has Kerberos tickets */
41 #define CM_UCELLFLAG_RXKAD      2       /* an rxkad connection */
42 #define CM_UCELLFLAG_BADTIX     4       /* tickets are bad or expired */
43 #define CM_UCELLFLAG_RXGK       8       /* an rxgk connection */
44
45 typedef struct cm_user {
46     unsigned long refCount;             /* ref count - cm_userLock */
47     cm_ucell_t *cellInfop;              /* list of cell info */
48     osi_mutex_t mx;                     /* mutex */
49     int vcRefs;                         /* count of references from virtual circuits */
50     long flags;
51 } cm_user_t;
52
53 #define CM_USERFLAG_DELETE      1       /* delete on last reference */
54
55 extern void cm_InitUser(void);
56
57 extern cm_user_t *cm_NewUser(void);
58
59 extern cm_ucell_t *cm_GetUCell(cm_user_t *userp, struct cm_cell *cellp);
60
61 extern cm_ucell_t *cm_FindUCell(cm_user_t *userp, int iterator);
62
63 extern void cm_HoldUser(cm_user_t *up);
64
65 extern void cm_HoldUserVCRef(cm_user_t *up);
66
67 extern void cm_ReleaseUser(cm_user_t *up);
68
69 extern void cm_ReleaseUserVCRef(cm_user_t *up);
70
71 extern void cm_CheckTokenCache(time_t now);
72
73 extern cm_user_t *cm_rootUserp;
74
75 #endif /*  __CM_USER_H_ENV__ */