windows-updatecell-20070619
[openafs.git] / src / WINNT / afsd / cm_conn.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_CONN_H_ENV__
11 #define __CM_CONN_H_ENV__ 1
12
13 #define CM_CONN_DEFAULTRDRTIMEOUT       45
14 #define CM_CONN_CONNDEADTIME             0
15 #define CM_CONN_HARDDEADTIME             0
16
17 extern unsigned short ConnDeadtimeout;
18 extern unsigned short HardDeadtimeout;
19 extern DWORD          RDRtimeout; 
20
21 typedef struct cm_conn {
22         struct cm_conn *nextp;          /* locked by cm_connLock */
23         struct cm_server *serverp;      /* locked by cm_serverLock */
24         struct rx_connection *callp;    /* locked by mx */
25         struct cm_user *userp;          /* locked by mx; a held reference */
26         osi_mutex_t mx;                 /* mutex for some of these fields */
27         unsigned long refCount;         /* locked by cm_connLock */
28         int ucgen;                      /* ucellp's generation number */
29         long flags;                     /* locked by mx */
30         int cryptlevel;                 /* encrytion status */
31 } cm_conn_t;
32
33 #define CM_CONN_FLAG_FORCE_NEW  1
34
35 /* structure used for tracking RPC progress */
36 typedef struct cm_req {
37         DWORD startTime;                /* Quit before RDR times us out */
38         int rpcError;                   /* RPC error code */
39         int volumeError;                /* volume error code */
40         int accessError;                /* access error code */
41         int flags;
42 } cm_req_t;
43
44 /* flags in cm_req structure */
45 #define CM_REQ_NORETRY          0x1
46 #define CM_REQ_NEW_CONN_FORCED  0x2
47
48 /*
49  * Vice2 error codes
50  * 3/20/85
51  * Note:  all of the errors listed here are currently generated by the volume
52  * package.  Other vice error codes, should they be needed, could be included
53  * here also.
54  */
55
56 #define VREADONLY       EROFS   /* Attempt to write a read-only volume */
57
58 /* Special error codes, which may require special handling (other than just
59    passing them through directly to the end user) are listed below */
60
61 #define VICE_SPECIAL_ERRORS     101     /* Lowest special error code */
62
63 #define VSALVAGE        101     /* Volume needs salvage */
64 #define VNOVNODE        102     /* Bad vnode number quoted */
65 #define VNOVOL          103     /* Volume not attached, doesn't exist, 
66                                    not created or not online */
67 #define VVOLEXISTS      104     /* Volume already exists */
68 #define VNOSERVICE      105     /* Volume is not in service (i.e. it's
69                                    is out of funds, is obsolete, or somesuch) */
70 #define VOFFLINE        106     /* Volume is off line, for the reason
71                                    given in the offline message */
72 #define VONLINE         107     /* Volume is already on line */
73 #define VDISKFULL       108     /* ENOSPC - Partition is "full",
74                                    i.e. roughly within n% of full */
75 #define VOVERQUOTA      109     /* EDQUOT - Volume max quota exceeded */
76 #define VBUSY           110     /* Volume temporarily unavailable; try again.
77                                    The volume should be available again shortly;
78                                    if it isn't something is wrong.
79                                    Not normally to be propagated to the
80                                    application level */
81 #define VMOVED          111     /* Volume has moved to another server;
82                                    do a VGetVolumeInfo to THIS server to find
83                                    out where */
84 #define VIO             112     /* Vnode temporarily unaccessible, but not known
85                                  * to be permanently bad. */
86 #define VRESTRICTED     120     /* Volume is restricted from using one or more
87                                  * of the given residencies; do a
88                                  * vos examine to find out the current
89                                  * restrictions. */
90
91 #define VRESTARTING     -100    /* server is restarting, otherwise similar to 
92                                    VBUSY above.  This is negative so that old
93                                    cache managers treat it as "server is down"*/
94
95 #include "cm_server.h"
96 #ifndef AFS_PTHREAD_ENV
97 #define AFS_PTHREAD_ENV 1
98 #endif
99 #include "rx.h"
100
101 extern void cm_InitConn(void);
102
103 extern void cm_InitReq(cm_req_t *reqp);
104
105 extern int cm_Analyze(cm_conn_t *connp, struct cm_user *up, struct cm_req *reqp,
106         struct cm_fid *fidp,
107         struct AFSVolSync *volInfop,
108         cm_serverRef_t * serversp,
109         struct cm_callbackRequest *cbrp, long code);
110
111 extern long cm_ConnByMServers(struct cm_serverRef *, struct cm_user *,
112         cm_req_t *, cm_conn_t **);
113
114 extern long cm_ConnByServer(struct cm_server *, struct cm_user *, cm_conn_t **);
115
116 extern long cm_ConnFromFID(struct cm_fid *, struct cm_user *, struct cm_req *,
117         cm_conn_t **);
118
119 extern long cm_ConnFromVolume(struct cm_volume *volp, unsigned long volid, 
120                               struct cm_user *userp, cm_req_t *reqp,
121                               cm_conn_t **connpp);
122
123 extern void cm_PutConn(cm_conn_t *connp);
124
125 extern void cm_GCConnections(cm_server_t *serverp);
126
127 extern struct rx_connection * cm_GetRxConn(cm_conn_t *connp);
128
129 extern void cm_ForceNewConnections(cm_server_t *serverp);
130
131 extern long cm_ServerAvailable(struct cm_fid *fidp, struct cm_user *userp);
132
133 #endif /*  __CM_CONN_H_ENV__ */