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