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