XProtocol.hh

Go to the documentation of this file.
00001 #ifndef __XPROTOCOL_H
00002 #define __XPROTOCOL_H
00003 
00004 //#ifndef __GNUC__
00005 //#define __attribute__(x)
00006 //#ifdef SUNCC
00007 //#pragma pack(4)
00008 //#endif
00009 //#endif
00010 
00011 #ifdef __CINT__
00012 #define __attribute__(x)
00013 #endif
00014 
00015 //        $Id: XProtocol.hh 28902 2009-06-11 12:36:21Z ganis $
00016 
00017 #include "XProtocol/XPtypes.hh"
00018 
00019 // KINDS of SERVERS
00020 //
00021 //
00022 #define kXR_DataServer 1
00023 #define kXR_LBalServer 0
00024 #define kXR_maxReqRetry 10
00025 
00026 //
00027 // Kind of error inside a XTNetFile's routine (temporary)
00028 //
00029 enum XReqErrorType {
00030    kGENERICERR = 0,    // Generic error
00031    kREAD,              // Error while reading from stream
00032    kWRITE,             // Error while writing to stream
00033    kREDIRCONNECT,      // Error redirecting to a given host
00034    kOK,                // Everything seems ok
00035    kNOMORESTREAMS      // No more available stream IDs for
00036                        // async processing
00037 };
00038 
00039 //______________________________________________
00040 // PROTOCOL DEFINITION: CLIENT'S REQUESTS TYPES
00041 //______________________________________________
00042 // 
00043 enum XRequestTypes {
00044    kXR_auth    =  3000,
00045    kXR_query,   // 3001
00046    kXR_chmod,   // 3002
00047    kXR_close,   // 3003
00048    kXR_dirlist, // 3004
00049    kXR_getfile, // 3005
00050    kXR_protocol,// 3006
00051    kXR_login,   // 3007
00052    kXR_mkdir,   // 3008
00053    kXR_mv,      // 3009
00054    kXR_open,    // 3010
00055    kXR_ping,    // 3011
00056    kXR_putfile, // 3012
00057    kXR_read,    // 3013
00058    kXR_rm,      // 3014
00059    kXR_rmdir,   // 3015
00060    kXR_sync,    // 3016
00061    kXR_stat,    // 3017
00062    kXR_set,     // 3018
00063    kXR_write,   // 3019
00064    kXR_admin,   // 3020
00065    kXR_prepare, // 3021
00066    kXR_statx,   // 3022
00067    kXR_endsess, // 3023
00068    kXR_bind,    // 3024
00069    kXR_readv,   // 3025
00070    kXR_verifyw, // 3026
00071    kXR_locate,  // 3027
00072    kXR_truncate // 3028
00073 };
00074 
00075 // OPEN MODE FOR A REMOTE FILE
00076 enum XOpenRequestMode {
00077    kXR_ur = 0x100,
00078    kXR_uw = 0x080,
00079    kXR_ux = 0x040,
00080    kXR_gr = 0x020,
00081    kXR_gw = 0x010,
00082    kXR_gx = 0x008,
00083    kXR_or = 0x004,
00084    kXR_ow = 0x002,
00085    kXR_ox = 0x001
00086 };
00087 
00088 enum XMkdirOptions {
00089    kXR_mknone  = 0,
00090    kXR_mkdirpath  = 1
00091 };
00092 
00093 // this is a bitmask
00094 enum XLoginCapVer {
00095    kXR_lcvnone = 0,
00096    kXR_vermask = 63,
00097    kXR_asyncap = 128
00098 };
00099 
00100 // this is a single number that goes into capver as the version
00101 //
00102 enum XLoginVersion {
00103    kXR_ver000 = 0,  // Old clients predating history
00104    kXR_ver001 = 1,  // Generally implemented 2005 protocol
00105    kXR_ver002 = 2   // Same as 1 but adds asyncresp recognition
00106 };
00107 
00108 enum XStatRequestOption {
00109    kXR_vfs    = 1
00110 };
00111 
00112 enum XStatRespFlags {
00113    kXR_file    = 0,
00114    kXR_xset    = 1,
00115    kXR_isDir   = 2,
00116    kXR_other   = 4,
00117    kXR_offline = 8,
00118    kXR_readable=16,
00119    kXR_writable=32,
00120    kXR_poscpend=64
00121 };
00122 
00123 enum XDirlistRequestOption {
00124    kXR_online = 1
00125 };
00126 
00127 enum XOpenRequestOption {
00128    kXR_compress = 1,
00129    kXR_delete   = 2,
00130    kXR_force    = 4,
00131    kXR_new      = 8,
00132    kXR_open_read= 16,
00133    kXR_open_updt= 32,
00134    kXR_async    = 64,
00135    kXR_refresh  = 128,
00136    kXR_mkpath   = 256,
00137    kXR_open_apnd= 512,
00138    kXR_retstat  = 1024,
00139    kXR_replica  = 2048,
00140    kXR_posc     = 4096,
00141    kXR_nowait   = 8192,
00142    kXR_seqio    =16384
00143 };
00144 
00145 enum XQueryType {
00146    kXR_QStats = 1,
00147    kXR_QPrep  = 2,
00148    kXR_Qcksum = 3,
00149    kXR_Qxattr = 4,
00150    kXR_Qspace = 5,
00151    kXR_Qckscan= 6,
00152    kXR_Qconfig= 7,
00153    kXR_Qvisa  = 8,
00154    kXR_Qopaque=16,
00155    kXR_Qopaquf=32
00156 };
00157 
00158 enum XVerifyType {
00159    kXR_nocrc  = 0,
00160    kXR_crc32  = 1
00161 };
00162 
00163 enum XLogonType {
00164    kXR_useruser  = 0,
00165    kXR_useradmin = 1
00166 };
00167 
00168 // Andy's request for async/unsolicited
00169 enum XPrepRequestOption {
00170    kXR_cancel = 1,
00171    kXR_notify = 2,
00172    kXR_noerrs = 4,
00173    kXR_stage  = 8,
00174    kXR_wmode  = 16,
00175    kXR_coloc  = 32,
00176    kXR_fresh  = 64
00177 };
00178 
00179 //_______________________________________________
00180 // PROTOCOL DEFINITION: SERVER'S RESPONSES TYPES
00181 //_______________________________________________
00182 //
00183 enum XResponseType {
00184    kXR_ok      = 0,
00185    kXR_oksofar = 4000,
00186    kXR_attn,
00187    kXR_authmore,
00188    kXR_error,
00189    kXR_redirect,
00190    kXR_wait,
00191    kXR_waitresp,
00192    kXR_noResponsesYet = 10000
00193 };
00194 
00195 //_______________________________________________
00196 // PROTOCOL DEFINITION: SERVER"S ATTN CODES
00197 //_______________________________________________
00198 
00199 enum XActionCode {
00200    kXR_asyncab = 5000,
00201    kXR_asyncdi,
00202    kXR_asyncms,
00203    kXR_asyncrd,
00204    kXR_asyncwt,
00205    kXR_asyncav,
00206    kXR_asynunav,
00207    kXR_asyncgo,
00208    kXR_asynresp
00209 };
00210 
00211 //_______________________________________________
00212 // PROTOCOL DEFINITION: SERVER'S ERROR CODES
00213 //_______________________________________________
00214 //
00215 enum XErrorCode {
00216    kXR_ArgInvalid = 3000,
00217    kXR_ArgMissing,
00218    kXR_ArgTooLong,
00219    kXR_FileLocked,
00220    kXR_FileNotOpen,
00221    kXR_FSError,
00222    kXR_InvalidRequest,
00223    kXR_IOError,
00224    kXR_NoMemory,
00225    kXR_NoSpace,
00226    kXR_NotAuthorized,
00227    kXR_NotFound,
00228    kXR_ServerError,
00229    kXR_Unsupported,
00230    kXR_noserver,
00231    kXR_NotFile,
00232    kXR_isDirectory,
00233    kXR_Cancelled,
00234    kXR_ChkLenErr,
00235    kXR_ChkSumErr,
00236    kXR_inProgress,
00237    kXR_noErrorYet = 10000
00238 };
00239 
00240 
00241 //______________________________________________
00242 // PROTOCOL DEFINITION: CLIENT'S REQUESTS STRUCTS
00243 //______________________________________________
00244 // 
00245 // We need to pack structures sent all over the net!
00246 // __attribute__((packed)) assures no padding bytes.
00247 //
00248 // Nice bodies of the headers for the client requests.
00249 // Note that the protocol specifies these values to be in network
00250 //  byte order when sent
00251 //
00252 // G.Ganis: use of flat structures to avoid packing options
00253 
00254 struct ClientAdminRequest {
00255    kXR_char  streamid[2];
00256    kXR_unt16 requestid;
00257    kXR_char reserved[16];
00258    kXR_int32  dlen;
00259 };
00260 struct ClientAuthRequest {
00261    kXR_char  streamid[2];
00262    kXR_unt16 requestid;
00263    kXR_char reserved[12];
00264    kXR_char credtype[4];
00265    kXR_int32  dlen;
00266 };
00267 struct ClientBindRequest {
00268    kXR_char  streamid[2];
00269    kXR_unt16 requestid;
00270    kXR_char  sessid[16];
00271    kXR_int32  dlen;
00272 };
00273 struct ClientChmodRequest {
00274    kXR_char  streamid[2];
00275    kXR_unt16 requestid;
00276    kXR_char  reserved[14];
00277    kXR_unt16 mode;
00278    kXR_int32  dlen;
00279 };
00280 struct ClientCloseRequest {
00281    kXR_char  streamid[2];
00282    kXR_unt16 requestid;
00283    kXR_char fhandle[4];
00284    kXR_int64 fsize;
00285    kXR_char reserved[4];
00286    kXR_int32  dlen;
00287 };
00288 struct ClientDirlistRequest {
00289    kXR_char  streamid[2];
00290    kXR_unt16 requestid;
00291    kXR_char reserved[15];
00292    kXR_char options[1];
00293    kXR_int32  dlen;
00294 };
00295 struct ClientEndsessRequest {
00296    kXR_char  streamid[2];
00297    kXR_unt16 requestid;
00298    kXR_char  sessid[16];
00299    kXR_int32  dlen;
00300 };
00301 struct ClientGetfileRequest {
00302    kXR_char  streamid[2];
00303    kXR_unt16 requestid;
00304    kXR_int32 options;
00305    kXR_char reserved[8];
00306    kXR_int32 buffsz;
00307    kXR_int32  dlen;
00308 };
00309 struct ClientLocateRequest {
00310    kXR_char  streamid[2];
00311    kXR_unt16 requestid;
00312    kXR_unt16 options;
00313    kXR_char reserved[14];
00314    kXR_int32  dlen;
00315 };
00316 struct ClientLoginRequest {
00317    kXR_char  streamid[2];
00318    kXR_unt16 requestid;
00319    kXR_int32 pid;
00320    kXR_char username[8];
00321    kXR_char reserved[2];
00322    kXR_char capver[1];
00323    kXR_char role[1];
00324    kXR_int32  dlen;
00325 };
00326 struct ClientMkdirRequest {
00327    kXR_char  streamid[2];
00328    kXR_unt16 requestid;
00329    kXR_char options[1];
00330    kXR_char reserved[13];
00331    kXR_unt16 mode;
00332    kXR_int32  dlen;
00333 };
00334 struct ClientMvRequest {
00335    kXR_char  streamid[2];
00336    kXR_unt16 requestid;
00337    kXR_char reserved[16];
00338    kXR_int32  dlen;
00339 };
00340 struct ClientOpenRequest {
00341    kXR_char  streamid[2];
00342    kXR_unt16 requestid;
00343    kXR_unt16 mode;
00344    kXR_unt16 options;
00345    kXR_char  reserved[12];
00346    kXR_int32  dlen;
00347 };
00348 struct ClientPingRequest {
00349    kXR_char  streamid[2];
00350    kXR_unt16 requestid;
00351    kXR_char reserved[16];
00352    kXR_int32  dlen;
00353 };
00354 struct ClientProtocolRequest {
00355    kXR_char  streamid[2];
00356    kXR_unt16 requestid;
00357    kXR_char reserved[16];
00358    kXR_int32  dlen;
00359 };
00360 struct ClientPrepareRequest {
00361    kXR_char  streamid[2];
00362    kXR_unt16 requestid;
00363    kXR_char options;
00364    kXR_char prty;
00365    kXR_char reserved[14];
00366    kXR_int32  dlen;
00367 };
00368 struct ClientPutfileRequest {
00369    kXR_char  streamid[2];
00370    kXR_unt16 requestid;
00371    kXR_int32 options;
00372    kXR_char  reserved[8];
00373    kXR_int32 buffsz;
00374    kXR_int32  dlen;
00375 };
00376 struct ClientQueryRequest {
00377    kXR_char  streamid[2];
00378    kXR_unt16 requestid;
00379    kXR_unt16 infotype;
00380    kXR_char  reserved1[2];
00381    kXR_char  fhandle[4];
00382    kXR_char  reserved2[8];
00383    kXR_int32 dlen;
00384 };
00385 struct ClientReadRequest {
00386    kXR_char  streamid[2];
00387    kXR_unt16 requestid;
00388    kXR_char fhandle[4];
00389    kXR_int64 offset;
00390    kXR_int32 rlen;
00391    kXR_int32  dlen;
00392 };
00393 struct ClientReadVRequest {
00394    kXR_char  streamid[2];
00395    kXR_unt16 requestid;
00396    kXR_char  reserved[16];
00397    kXR_int32  dlen;
00398 };
00399 struct ClientRmRequest {
00400    kXR_char  streamid[2];
00401    kXR_unt16 requestid;
00402    kXR_char reserved[16];
00403    kXR_int32  dlen;
00404 };
00405 struct ClientRmdirRequest {
00406    kXR_char  streamid[2];
00407    kXR_unt16 requestid;
00408    kXR_char reserved[16];
00409    kXR_int32  dlen;
00410 };
00411 struct ClientSetRequest {
00412    kXR_char  streamid[2];
00413    kXR_unt16 requestid;
00414    kXR_char reserved[16];
00415    kXR_int32  dlen;
00416 };
00417 struct ClientStatRequest {
00418    kXR_char  streamid[2];
00419    kXR_unt16 requestid;
00420    kXR_char  options;
00421    kXR_char reserved[11];
00422    kXR_char fhandle[4];
00423    kXR_int32  dlen;
00424 };
00425 struct ClientSyncRequest {
00426    kXR_char  streamid[2];
00427    kXR_unt16 requestid;
00428    kXR_char fhandle[4];
00429    kXR_char reserved[12];
00430    kXR_int32  dlen;
00431 };
00432 struct ClientTruncateRequest {
00433    kXR_char  streamid[2];
00434    kXR_unt16 requestid;
00435    kXR_char fhandle[4];
00436    kXR_int64 offset;
00437    kXR_char reserved[4];
00438    kXR_int32  dlen;
00439 };
00440 struct ClientWriteRequest {
00441    kXR_char  streamid[2];
00442    kXR_unt16 requestid;
00443    kXR_char fhandle[4];
00444    kXR_int64 offset;
00445    kXR_char  pathid;
00446    kXR_char reserved[3];
00447    kXR_int32  dlen;
00448 };
00449 struct ClientVerifywRequest {
00450    kXR_char  streamid[2];
00451    kXR_unt16 requestid;
00452    kXR_char  fhandle[4];
00453    kXR_int64 offset;
00454    kXR_char  pathid;
00455    kXR_char  vertype;       // One of XVerifyType
00456    kXR_char  reserved[2];
00457    kXR_int32 dlen;          // Includes crc length
00458 };
00459 
00460 struct ClientRequestHdr {
00461    kXR_char  streamid[2];
00462    kXR_unt16 requestid;
00463    kXR_char  body[16];
00464    kXR_int32  dlen;
00465 };
00466 
00467 typedef union {
00468    struct ClientRequestHdr header;
00469    struct ClientAdminRequest admin;
00470    struct ClientAuthRequest auth;
00471    struct ClientBindRequest bind;
00472    struct ClientChmodRequest chmod;
00473    struct ClientCloseRequest close;
00474    struct ClientDirlistRequest dirlist;
00475    struct ClientEndsessRequest endsess;
00476    struct ClientGetfileRequest getfile;
00477    struct ClientLocateRequest locate;
00478    struct ClientLoginRequest login;
00479    struct ClientMkdirRequest mkdir;
00480    struct ClientMvRequest mv;
00481    struct ClientOpenRequest open;
00482    struct ClientPingRequest ping;
00483    struct ClientPrepareRequest prepare;
00484    struct ClientProtocolRequest protocol;
00485    struct ClientPutfileRequest putfile;
00486    struct ClientQueryRequest query;
00487    struct ClientReadRequest read;
00488    struct ClientReadVRequest readv;
00489    struct ClientRmRequest rm;
00490    struct ClientRmdirRequest rmdir;
00491    struct ClientSetRequest set;
00492    struct ClientStatRequest stat;
00493    struct ClientSyncRequest sync;
00494    struct ClientTruncateRequest truncate;
00495    struct ClientWriteRequest write;
00496 } ClientRequest;
00497 
00498 struct readahead_list {
00499    kXR_char fhandle[4];
00500    kXR_int32 rlen;
00501    kXR_int64 offset;
00502 };
00503 
00504 struct read_args {
00505    kXR_char       pathid;
00506    kXR_char       reserved[7];
00507    // his struct is followed by an array of readahead_list
00508 };
00509 
00510 //_____________________________________________________________________
00511 //   PROTOCOL DEFINITION: SERVER'S RESPONSE
00512 //_____________________________________________________________________
00513 //
00514 
00515 // Nice header for the server response.
00516 // Note that the protocol specifies these values to be in network
00517 // byte order when sent
00518 //
00519 // G.Ganis: The following structures never need padding bytes:
00520 //          no need of packing options
00521 
00522 struct ServerResponseHeader {
00523    kXR_char streamid[2];
00524    kXR_unt16 status;
00525    kXR_int32  dlen;
00526 };
00527 
00528 // Body for the kXR_bind response... useful
00529 struct ServerResponseBody_Bind {
00530     kXR_char substreamid;
00531 };
00532 
00533 // Body for the kXR_open response... useful
00534 struct ServerResponseBody_Open {
00535    kXR_char fhandle[4];
00536    kXR_int32 cpsize;   // cpsize & cptype returned if kXR_compress *or*
00537    kXR_char cptype[4]; // kXR_retstat is specified
00538 }; // info will follow if kXR_retstat is specified
00539 
00540 // Body for the kXR_protocol response... useful
00541 struct ServerResponseBody_Protocol {
00542    kXR_int32 pval;
00543    kXR_int32 flags;
00544 };
00545 
00546 struct ServerResponseBody_Redirect {
00547    kXR_int32 port;
00548    char host[4096]; // Should be sufficient for every use
00549 };
00550 
00551 struct ServerResponseBody_Error {
00552    kXR_int32 errnum;
00553    char errmsg[4096]; // Should be sufficient for every use
00554 };
00555 
00556 struct ServerResponseBody_Wait {
00557    kXR_int32 seconds;
00558    char infomsg[4096]; // Should be sufficient for every use
00559 };
00560 
00561 struct ServerResponseBody_Attn {
00562    kXR_int32 actnum;
00563    char parms[4096]; // Should be sufficient for every use
00564 };
00565 
00566 struct ServerResponseBody_Attn_asyncrd {
00567    kXR_int32 actnum;
00568    kXR_int32 port;
00569    char host[4092];
00570 };
00571 
00572 struct ServerResponseBody_Attn_asynresp {
00573    kXR_int32            actnum;
00574    char reserved[4];
00575    ServerResponseHeader resphdr;
00576    char respdata[4096];
00577 };
00578 
00579 struct ServerResponseBody_Attn_asyncwt {
00580    kXR_int32 actnum;
00581    kXR_int32 wsec;
00582 };
00583 
00584 struct ServerResponseBody_Attn_asyncdi {
00585    kXR_int32 actnum;
00586    kXR_int32 wsec;
00587    kXR_int32 msec;
00588 };
00589 
00590 void ServerResponseHeader2NetFmt(struct ServerResponseHeader *srh);
00591 
00592 // The fields to be sent as initial handshake
00593 struct ClientInitHandShake {
00594    kXR_int32 first;
00595    kXR_int32 second;
00596    kXR_int32 third;
00597    kXR_int32 fourth;
00598    kXR_int32 fifth;
00599 };
00600 
00601 // The body received after the first handshake's header
00602 struct ServerInitHandShake {
00603    kXR_int32 msglen;
00604    kXR_int32 protover;
00605    kXR_int32 msgval;
00606 };
00607 
00608 
00609 
00610 typedef kXR_int32 ServerResponseType;
00611 
00612 struct ALIGN_CHECK {char chkszreq[25-sizeof(ClientRequest)];
00613    char chkszrsp[ 9-sizeof(ServerResponseHeader)];
00614 };
00615 
00616 #endif

Generated on Tue Jul 5 14:46:13 2011 for ROOT_528-00b_version by  doxygen 1.5.1