Standardize License information
[openafs.git] / src / bubasics / bubasics.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 __BUBASIC__
11 #define __BUBASIC__
12
13 /* version numbers. This version information is accessed from more than
14  * one module. Version information is kept for:
15  *      bucoord <-> butc interface
16  *      butc <-> butm interface
17  *      bu* <-> budb interface
18  *
19  * and as an interim measure, for
20  *      dumpschedule files
21  *      dump database files i.e. D*.db
22  */
23
24 /* Version of butc <-> butm interface
25  * These are not version flags as the name suggests.
26  */
27
28 #define BUTM_VERSIONFLAG_0 0            /* every size measure is in bytes */
29 #define BUTM_VERSIONFLAG_1 1            /* every size measure is in kbytes */
30 #define BUTM_VERSIONFLAG_2 2            /* afs 3.1 features */
31
32 /* current version of the interface */
33 #define BUTM_MAJORVERSION BUTM_VERSIONFLAG_2
34
35 /* versions for the bucoord <-> butc interface */
36 #define BUTC_VERSION_1          1               /* initial version, afs 3.1 */
37 #define BUTC_VERSION_2          2               /* 3.4 version - added voltype to tc_dumpDesc */
38 #define BUTC_VERSION_3          3               /* 3.4 version - labeltape change */
39 #define CUR_BUTC_VERSION        BUTC_VERSION_3
40
41 /* TAPE_VERSION Version of the current tape format used by butc
42  * Notes:
43  *
44  * version 0:   ?? - sizes in bytes
45  * version 1:   Sizes in kbytes.
46  * version 2:
47  *      1) Tape expiration information in label
48  *      2) backup systems's EOT markers at the end of a dump
49  * version 3:
50  *      1) dump id and tape use count in label
51  * version 4:
52  *      1) Got rid of large EOT markers
53  *      2) Supports appended dumps
54  */
55
56 #define TAPE_VERSION_0          0
57 #define TAPE_VERSION_1          1
58 #define TAPE_VERSION_2          2
59 #define TAPE_VERSION_3          3
60 #define TAPE_VERSION_4          4
61 #define CUR_TAPE_VERSION        TAPE_VERSION_4
62
63 #define BC_SCHEDULE_MAGIC       0x74327285      /* magic # for schedules */
64 #define BC_SCHEDULE_V3_1        1                       /* afs 3.1 */
65 #define BC_SCHEDULE_VERSION     BC_SCHEDULE_V3_1        /* current version */
66
67 #define BC_DUMPDB_MAGIC         0x10381645      /* magic # for dump db */
68 #define BC_DUMPDB_V3_1          1               /* afs 3.1 */
69 #define BC_DUMPDB_VERSION       BC_DUMPDB_V3_1  /* current version */
70
71 /* define ports that move to system configuration later */
72 #define BC_MESSAGEPORT      7020        /* for communicating with backup coordinator */
73 #define BC_TAPEPORT         7025        /* for communicating with tape controller */
74
75 #ifndef AFSCONF_BUDBPORT
76 #define AFSCONF_BUDBPORT    7021        /* for communicating with backup database */
77 #endif
78 #define BUDB_SERVICE 22314              /* service id */
79
80 #define RX_SCINDEX_NULL 0               /* No security */
81 #define RX_SCINDEX_VAB  1               /* vice tokens, with bcrypt */
82 #define RX_SCINDEX_KAD  2               /* Kerberos/DES */
83
84 /* maximums for various text strings 
85  * DON'T alter these values until all disk/tape structures can be handled
86  * correctly. In particular, volume names are 64.
87  */
88
89 /* dump states */
90 #define DUMP_FAILED     1               /* outright failed */
91 #define DUMP_PARTIAL    2               /* partial on tape */
92 #define DUMP_SUCCESS    3               /* all ok */
93 #define DUMP_RETRY      4               /* failed, but retry */
94 #define DUMP_NORETRYEOT 5               /* failed, and don't retry */
95 #define DUMP_NOTHING    6               /* Nothing was dumped */
96 #define DUMP_NODUMP     7               /* don't dump, and don't retry */
97
98
99 #define BU_MAXNAMELEN 32                /* max for misc. names: eg volumes */
100 #define BU_MAXTAPELEN 32                /* for tape names */
101 #define BU_MAXHOSTLEN 32                /* for server (machine) names */
102 #define BU_MAXTOKENLEN 16               /* identifiers */
103 #define BU_MAXUNAMELEN 256              /* length of a user name */
104 #define BU_MAXCELLLEN 256               /* length of a cell name */
105
106 /* proposed maximum name lengths  PA */
107 #define BU_MAX_NAME     64              /* misc. names */
108 #define BU_MAX_DUMP_PATH 256            /* length of schedule path name */
109
110 #define BC_MAXPORTOFFSET    58510       /* max number of port offsets in database */
111
112 #ifndef NEVERDATE
113 #define NEVERDATE 037777777777          /* a date that will never come */
114 #endif
115 #ifndef NEVERSTRING
116 #define NEVERSTRING  "NEVER                   \n"
117 #endif
118 #define cTIME(t)  ( (*(t) == NEVERDATE) ? (char *)NEVERSTRING : (char *)ctime(t) )
119
120 #ifndef Date
121 #define Date afs_uint32
122 #endif
123
124 #define DUMP_TAPE_NAME  "Ubik_db_dump"          /* base database tape name */
125
126 /* for expiration date processing */
127 #define BC_NO_EXPDATE           0       /* no expiration date */
128 #define BC_ABS_EXPDATE          1       /* absolute expiration date */
129 #define BC_REL_EXPDATE          2       /* relative expiration date */
130
131 /*macro which generates tape names from tapeSetName */
132 #define tc_MakeTapeName(name,set,seq) \
133     sprintf (name, (set)->format, (seq) + (set)->b)
134
135 /* common structure definitions */
136 struct dlqlink
137 {
138     struct dlqlink      *dlq_next;
139     struct dlqlink      *dlq_prev;
140     afs_int32           dlq_type;
141     char *              dlq_structPtr;          /* enclosing structure */
142 };
143
144 typedef struct dlqlink  dlqlinkT;
145 typedef dlqlinkT        *dlqlinkP;
146
147
148 /* invariants */
149 #define DLQ_HEAD        1001
150
151 #define DLQ_VOLENTRY    10
152 #define DLQ_FINISHTAPE  11
153 #define DLQ_USETAPE     12
154 #define DLQ_FINISHDUMP  13
155 #define DLQ_USEDUMP     14
156
157 /* simple assertion - for testing, don't halt processing */
158
159 #define DLQASSERT(condition)                                    \
160         if ( (condition) == 0 )                                 \
161         {                                                       \
162             printf("DLQASSERT: %s failed\n", #condition);       \
163         }
164
165 /* function typing */
166 extern dlqlinkP dlqFront();
167 extern dlqlinkP dlqUnlinkb();
168 extern dlqlinkP dlqUnlinkf();
169
170 /* -----------------------------
171  * Status management
172  * -----------------------------
173  */
174
175 /* status management flags
176  *
177  * Key to comments:
178  *      C - client side only
179  *      S - server side only
180  *      B - client or server
181  */
182  
183 #define STARTING        0x1     /* C; still setting up, no server task yet */
184 #define ABORT_REQUEST   0x2     /* B; user requested abort */
185 #define ABORT_SENT      0x4     /* C; abort sent to server (REQ cleared) */
186 #define ABORT_DONE      0x8     /* S; abort complete on server */
187 #define ABORT_LOCAL     0x10    /* C; abort local task if contact lost */
188 #define TASK_DONE       0x20    /* B; task complete */
189 #define SILENT          0x400   /* C; don't be verbose about termination */
190 #define NOREMOVE        0x1000  /* C; don't remove from queue */
191
192 /* comm status */
193 #define CONTACT_LOST    0x40    /* B; contact lost */
194
195 /* errror handling */
196 #define TASK_ERROR      0x80     /* S; had fatal error, will terminate */
197
198 /* general status - copied back to client for jobs status */
199 #define DRIVE_WAIT      0x100   /* S; waiting for drive to become free */
200 #define OPR_WAIT        0x200   /* S; waiting for operator action */
201 #define CALL_WAIT       0x800   /* S; waiting for callout routine completion */
202
203 struct statusS
204 {
205     dlqlinkT    link;
206
207     afs_uint32  taskId;                         /* task identifier */
208     afs_uint32      dbDumpId;                       /* dump id */
209     afs_uint32  flags;                          /* as above */
210     afs_uint32  nKBytes;                        /* bytes xferred */
211     char        volumeName[BU_MAXNAMELEN];      /* current volume (if any) */
212     afs_int32   volsFailed;                     /* # operation failures */    
213     afs_int32   lastPolled;                     /* last successful poll */
214
215     /* bucoord local */
216     char        taskName[64];                   /* type of task */
217     afs_int32   port;   
218     afs_int32   jobNumber;
219     afs_int32   volsTotal;                      /* total # vols */
220     afs_int32        scheduledDump;                  /* Time this dump was scheduled */
221     char        *cmdLine;                       /* Command to exectute for this dump */
222 };
223
224 typedef struct statusS  statusT;
225 typedef statusT         *statusP;
226
227 #endif