e2bc29911b2ae4de65edf520073965239d91b179
[openafs.git] / src / butc / butc_xbsa.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_BUTC_XBSA_H
11 #define OPENAFS_BUTC_XBSA_H
12
13 /* The following serverTypes are currently supported by this interface */
14 #define XBSA_SERVER_TYPE_NONE       0x00        /* no server, use tape drive         */
15 #define XBSA_SERVER_TYPE_UNKNOWN    0x01        /* server, don't know which type yet */
16 #define XBSA_SERVER_TYPE_ADSM       0x02        /* server type is ADSM               */
17 #define XBSA_SERVER_TYPE_MASK       0xFF        /* for (butx_transactionInfo *)->serverType (byte 1) */
18
19 #ifdef xbsa
20 #define CONF_XBSA (xbsaType != XBSA_SERVER_TYPE_NONE)   /*test if butc is XBSA */
21 #else
22 #define CONF_XBSA 0
23 #endif
24
25 #ifdef xbsa
26 #define XBSA_SET_SERVER_TYPE(server, type) ((server) = ((type) & XBSA_SERVER_TYPE_MASK))
27 #define XBSA_GET_SERVER_TYPE(server)       ((server) & XBSA_SERVER_TYPE_MASK)
28
29 /* The following serverType flags are currently supported by this interface */
30 #define XBSA_SERVER_FLAG_NONE      0x0000       /* don't allow multiple server connections */
31 #define XBSA_SERVER_FLAG_MULTIPLE  0x0100       /* allow multiple server connections */
32 #define XBSA_SERVER_FLAG_MASK      0xFF00       /* for (butx_transactionInfo *)->serverType (byte 2) */
33 #define XBSA_SET_SERVER_FLAG(server, flag)    ((server) |= ((flag) & XBSA_SERVER_FLAG_MASK))
34 #define XBSA_GET_SERVER_FLAG(server)          ((server) & XBSA_SERVER_FLAG_MASK)
35 #define XBSA_IS_SERVER_FLAG_SET(server, flag) (XBSA_GET_SERVER_FLAG(server) & flag)
36
37 #define XBSAMINBUFFER  1024     /* minimum size is 1KB */
38 #define XBSADFLTBUFFER 16384    /* default size is 16KB */
39 #define XBSAMAXBUFFER  65535    /* maximum size in 64KB-1; has to fit in 16bit integer */
40
41 #ifdef NEW_XBSA
42 #include "afsxbsa.h"
43 #else
44 #include <xbsa.h>
45 #endif
46
47 #define XBSA_NUM_ENV_STRS ADSM_ENV_STRS
48 #define XBSA_MAX_OSNAME   BSA_MAX_OSNAME
49 #define XBSA_MAX_PATHNAME BSA_MAX_PATHNAME
50
51 #define XBSA_SUCCESS 0
52
53 /* The following defines the ADSM version level prior to the addition
54  * of support for multiple servers.
55  */
56 #define XBSA_ADSM_NO_MULT_SERVER_VERSION 3
57 #define XBSA_ADSM_NO_MULT_SERVER_RELEASE 7
58 #define XBSA_ADSM_NO_MULT_SERVER_LEVEL   1
59
60 /* The following defines the XBSA Technical Standard Level */
61 #define XBSA_TS_VERSION 1
62 #define XBSA_TS_RELEASE 1
63
64 /*
65  * The butx_transactionInfo structure defines the connection to an
66  * XBSA server.  The fields in this structure should only be modified
67  * by the routines in file_xbsa.c.
68  *
69  * The values in here are specific to the transaction.
70  * Values specific to the objects should be passed separately.
71  * The spec says bsaHandle should be a long but ADSM has it as a ulong!
72  */
73 struct butx_transactionInfo {
74     ApiVersion apiVersion;
75     u_long bsaHandle;
76     afs_int32 serverType;       /* Type and flags           */
77     afs_int32 maxObjects;       /* max objects/transaction  */
78     afs_int32 numObjects;       /* objects in current trans */
79     char serverName[BSA_MAX_DESC];
80     SecurityToken secToken;
81     ObjectOwner objOwner;
82     ObjectDescriptor curObject;
83 };
84
85 extern afs_int32 xbsa_MountLibrary(struct butx_transactionInfo *info,
86                                    afs_int32 serverType);
87
88 extern afs_int32 xbsa_Initialize(struct butx_transactionInfo *info,
89                                  char *bsaObjectOwner, char *appObjectOwner,
90                                  char *secToken, char *serverName);
91
92 extern afs_int32 xbsa_Finalize(struct butx_transactionInfo *info);
93
94 extern afs_int32 xbsa_BeginTrans(struct butx_transactionInfo *info);
95
96 extern afs_int32 xbsa_EndTrans(struct butx_transactionInfo *info);
97
98 extern afs_int32 xbsa_QueryObject(struct butx_transactionInfo *info,
99                                   char *objectSpaceName, char *pathName);
100
101 extern afs_int32 xbsa_ReadObjectBegin(struct butx_transactionInfo *info,
102                                       char *dataBuffer, afs_int32 bufferSize,
103                                       afs_int32 * count,
104                                       afs_int32 * endOfData);
105
106 extern afs_int32 xbsa_ReadObjectEnd(struct butx_transactionInfo *info);
107
108 extern afs_int32 xbsa_WriteObjectBegin(struct butx_transactionInfo *info,
109                                        char *objectSpaceName, char *pathName,
110                                        char *lGName,
111                                        afs_hyper_t estimatedSize,
112                                        char *objectDescription,
113                                        char *objectInfo);
114
115 extern afs_int32 xbsa_WriteObjectEnd(struct butx_transactionInfo *info);
116
117 extern afs_int32 xbsa_WriteObjectData(struct butx_transactionInfo *info,
118                                       char *dataBuffer, afs_int32 bufferSize,
119                                       afs_int32 * count);
120
121 extern afs_int32 xbsa_ReadObjectData(struct butx_transactionInfo *info,
122                                      char *dataBuffer, afs_int32 bufferSize,
123                                      afs_int32 * count,
124                                      afs_int32 * endOfData);
125
126 extern afs_int32 xbsa_DeleteObject(struct butx_transactionInfo *info,
127                                    char *objectSpaceName, char *pathName);
128
129 #endif /*xbsa */
130
131
132 /* XBSA Global Parameters */
133
134 #ifdef XBSA_TCMAIN
135 #define XBSA_EXT
136 #else
137 #define XBSA_EXT extern
138 #endif
139
140 XBSA_EXT afs_int32 xbsaType;
141 #ifdef xbsa
142 XBSA_EXT struct butx_transactionInfo butxInfo;
143
144 #define rpc_c_protect_level_default 0
145 XBSA_EXT afs_uint32 dumpRestAuthnLevel;
146 XBSA_EXT char *xbsaObjectOwner;
147 XBSA_EXT char *appObjectOwner;
148 XBSA_EXT char *adsmServerName;
149 XBSA_EXT char *xbsaSecToken;
150 XBSA_EXT char *xbsalGName;
151 #endif /*xbsa*/
152 #endif /* OPENAFS_BUTC_XBSA_H */