XProtocol.hh

Go to the documentation of this file.
00001 #ifndef __XPROTOCOL_H
00002 #define __XPROTOCOL_H
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                          X P r o t o c o l . h h                           */
00006 /*                                                                            */
00007 /* (c) 2012 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /*                                                                            */
00012 /* This file is part of the XRootD software suite.                            */
00013 /*                                                                            */
00014 /* XRootD is free software: you can redistribute it and/or modify it under    */
00015 /* the terms of the GNU Lesser General Public License as published by the     */
00016 /* Free Software Foundation, either version 3 of the License, or (at your     */
00017 /* option) any later version.                                                 */
00018 /*                                                                            */
00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00022 /* License for more details.                                                  */
00023 /*                                                                            */
00024 /* You should have received a copy of the GNU Lesser General Public License   */
00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00027 /*                                                                            */
00028 /* The copyright holder's institutional names and contributor's names may not */
00029 /* be used to endorse or promote products derived from this software without  */
00030 /* specific prior written permission of the institution or contributor.       */
00031 /******************************************************************************/
00032 
00033 //#ifndef __GNUC__
00034 //#define __attribute__(x)
00035 //#ifdef SUNCC
00036 //#pragma pack(4)
00037 //#endif
00038 //#endif
00039 
00040 #ifdef __CINT__
00041 #define __attribute__(x)
00042 #endif
00043 
00044 // The following is the binary representation of the protocol version here.
00045 // Protocol version is repesented as three base10 digits x.y.z with x having no
00046 // upper limit (i.e. n.9.9 + 1 -> n+1.0.0).
00047 //
00048 #define kXR_PROTOCOLVERSION  0x00000300
00049 #define kXR_PROTOCOLVSTRING "3.0.0"
00050 
00051 #include "XProtocol/XPtypes.hh"
00052 
00053 // KINDS of SERVERS
00054 //
00055 //
00056 #define kXR_DataServer 1
00057 #define kXR_LBalServer 0
00058 
00059 // The below are defined for protocol version 2.9.7 or higher
00060 //
00061 #define kXR_isManager 0x00000002
00062 #define kXR_isServer  0x00000001
00063 #define kXR_attrMeta  0x00000100
00064 #define kXR_attrProxy 0x00000200
00065 #define kXR_attrSuper 0x00000400
00066 
00067 #define kXR_maxReqRetry 10
00068 
00069 //
00070 // Kind of error inside a XTNetFile's routine (temporary)
00071 //
00072 enum XReqErrorType {
00073    kGENERICERR = 0,    // Generic error
00074    kREAD,              // Error while reading from stream
00075    kWRITE,             // Error while writing to stream
00076    kREDIRCONNECT,      // Error redirecting to a given host
00077    kOK,                // Everything seems ok
00078    kNOMORESTREAMS      // No more available stream IDs for
00079                        // async processing
00080 };
00081 
00082 //______________________________________________
00083 // PROTOCOL DEFINITION: CLIENT'S REQUESTS TYPES
00084 //______________________________________________
00085 // 
00086 enum XRequestTypes {
00087    kXR_auth    =  3000,
00088    kXR_query,   // 3001
00089    kXR_chmod,   // 3002
00090    kXR_close,   // 3003
00091    kXR_dirlist, // 3004
00092    kXR_getfile, // 3005
00093    kXR_protocol,// 3006
00094    kXR_login,   // 3007
00095    kXR_mkdir,   // 3008
00096    kXR_mv,      // 3009
00097    kXR_open,    // 3010
00098    kXR_ping,    // 3011
00099    kXR_putfile, // 3012
00100    kXR_read,    // 3013
00101    kXR_rm,      // 3014
00102    kXR_rmdir,   // 3015
00103    kXR_sync,    // 3016
00104    kXR_stat,    // 3017
00105    kXR_set,     // 3018
00106    kXR_write,   // 3019
00107    kXR_admin,   // 3020
00108    kXR_prepare, // 3021
00109    kXR_statx,   // 3022
00110    kXR_endsess, // 3023
00111    kXR_bind,    // 3024
00112    kXR_readv,   // 3025
00113    kXR_verifyw, // 3026
00114    kXR_locate,  // 3027
00115    kXR_truncate // 3028
00116 };
00117 
00118 // OPEN MODE FOR A REMOTE FILE
00119 enum XOpenRequestMode {
00120    kXR_ur = 0x100,
00121    kXR_uw = 0x080,
00122    kXR_ux = 0x040,
00123    kXR_gr = 0x020,
00124    kXR_gw = 0x010,
00125    kXR_gx = 0x008,
00126    kXR_or = 0x004,
00127    kXR_ow = 0x002,
00128    kXR_ox = 0x001
00129 };
00130 
00131 enum XMkdirOptions {
00132    kXR_mknone  = 0,
00133    kXR_mkdirpath  = 1
00134 };
00135 
00136 // this is a bitmask
00137 enum XLoginAbility {
00138    kXR_nothing =   0,
00139    kXR_fullurl =   1,
00140    kXR_multipr =   3,
00141    kXR_readrdok=   4,
00142    kXR_hasipv64=   8,
00143    kXR_onlyprv4=  16,
00144    kXR_onlyprv6=  32
00145 };
00146 
00147 // this is a bitmask
00148 enum XLoginCapVer {
00149    kXR_lcvnone = 0,
00150    kXR_vermask = 63,
00151    kXR_asyncap = 128
00152 };
00153 
00154 // this is a single number that goes into capver as the version
00155 //
00156 enum XLoginVersion {
00157    kXR_ver000 = 0,  // Old clients predating history
00158    kXR_ver001 = 1,  // Generally implemented 2005 protocol
00159    kXR_ver002 = 2,  // Same as 1 but adds asyncresp recognition
00160    kXR_ver003 = 3   // The 2011-2012 rewritten client
00161 };
00162 
00163 enum XStatRequestOption {
00164    kXR_vfs    = 1
00165 };
00166 
00167 enum XStatRespFlags {
00168    kXR_file    = 0,
00169    kXR_xset    = 1,
00170    kXR_isDir   = 2,
00171    kXR_other   = 4,
00172    kXR_offline = 8,
00173    kXR_readable=16,
00174    kXR_writable=32,
00175    kXR_poscpend=64,
00176    kXR_bkpexist=128
00177 };
00178 
00179 enum XDirlistRequestOption {
00180    kXR_online = 1,
00181    kXR_dstat  = 2
00182 };
00183 
00184 enum XOpenRequestOption {
00185    kXR_compress = 1,      // also locate (return unique hosts)
00186    kXR_delete   = 2,
00187    kXR_force    = 4,
00188    kXR_new      = 8,
00189    kXR_open_read= 16,
00190    kXR_open_updt= 32,
00191    kXR_async    = 64,
00192    kXR_refresh  = 128,   // also locate
00193    kXR_mkpath   = 256,
00194    kXR_prefname = 256,   // only locate
00195    kXR_open_apnd= 512,
00196    kXR_retstat  = 1024,
00197    kXR_replica  = 2048,
00198    kXR_posc     = 4096,
00199    kXR_nowait   = 8192,  // also locate
00200    kXR_seqio    =16384,
00201    kXR_open_wrto=32768
00202 };
00203 
00204 enum XQueryType {
00205    kXR_QStats = 1,
00206    kXR_QPrep  = 2,
00207    kXR_Qcksum = 3,
00208    kXR_Qxattr = 4,
00209    kXR_Qspace = 5,
00210    kXR_Qckscan= 6,
00211    kXR_Qconfig= 7,
00212    kXR_Qvisa  = 8,
00213    kXR_Qopaque=16,
00214    kXR_Qopaquf=32,
00215    kXR_Qopaqug=64
00216 };
00217 
00218 enum XVerifyType {
00219    kXR_nocrc  = 0,
00220    kXR_crc32  = 1
00221 };
00222 
00223 enum XLogonType {
00224    kXR_useruser  = 0,
00225    kXR_useradmin = 1
00226 };
00227 
00228 // Andy's request for async/unsolicited
00229 enum XPrepRequestOption {
00230    kXR_cancel = 1,
00231    kXR_notify = 2,
00232    kXR_noerrs = 4,
00233    kXR_stage  = 8,
00234    kXR_wmode  = 16,
00235    kXR_coloc  = 32,
00236    kXR_fresh  = 64
00237 };
00238 
00239 //_______________________________________________
00240 // PROTOCOL DEFINITION: SERVER'S RESPONSES TYPES
00241 //_______________________________________________
00242 //
00243 enum XResponseType {
00244    kXR_ok      = 0,
00245    kXR_oksofar = 4000,
00246    kXR_attn,
00247    kXR_authmore,
00248    kXR_error,
00249    kXR_redirect,
00250    kXR_wait,
00251    kXR_waitresp,
00252    kXR_noResponsesYet = 10000
00253 };
00254 
00255 //_______________________________________________
00256 // PROTOCOL DEFINITION: SERVER"S ATTN CODES
00257 //_______________________________________________
00258 
00259 enum XActionCode {
00260    kXR_asyncab = 5000,
00261    kXR_asyncdi,
00262    kXR_asyncms,
00263    kXR_asyncrd,
00264    kXR_asyncwt,
00265    kXR_asyncav,
00266    kXR_asynunav,
00267    kXR_asyncgo,
00268    kXR_asynresp
00269 };
00270 
00271 //_______________________________________________
00272 // PROTOCOL DEFINITION: SERVER'S ERROR CODES
00273 //_______________________________________________
00274 //
00275 enum XErrorCode {
00276    kXR_ArgInvalid = 3000,
00277    kXR_ArgMissing,
00278    kXR_ArgTooLong,
00279    kXR_FileLocked,
00280    kXR_FileNotOpen,
00281    kXR_FSError,
00282    kXR_InvalidRequest,
00283    kXR_IOError,
00284    kXR_NoMemory,
00285    kXR_NoSpace,
00286    kXR_NotAuthorized,
00287    kXR_NotFound,
00288    kXR_ServerError,
00289    kXR_Unsupported,
00290    kXR_noserver,
00291    kXR_NotFile,
00292    kXR_isDirectory,
00293    kXR_Cancelled,
00294    kXR_ChkLenErr,
00295    kXR_ChkSumErr,
00296    kXR_inProgress,
00297    kXR_overQuota,
00298    kXR_noErrorYet = 10000
00299 };
00300 
00301 
00302 //______________________________________________
00303 // PROTOCOL DEFINITION: CLIENT'S REQUESTS STRUCTS
00304 //______________________________________________
00305 // 
00306 // We need to pack structures sent all over the net!
00307 // __attribute__((packed)) assures no padding bytes.
00308 //
00309 // Nice bodies of the headers for the client requests.
00310 // Note that the protocol specifies these values to be in network
00311 //  byte order when sent
00312 //
00313 // G.Ganis: use of flat structures to avoid packing options
00314 
00315 struct ClientAdminRequest {
00316    kXR_char  streamid[2];
00317    kXR_unt16 requestid;
00318    kXR_char reserved[16];
00319    kXR_int32  dlen;
00320 };
00321 struct ClientAuthRequest {
00322    kXR_char  streamid[2];
00323    kXR_unt16 requestid;
00324    kXR_char reserved[12];
00325    kXR_char credtype[4];
00326    kXR_int32  dlen;
00327 };
00328 struct ClientBindRequest {
00329    kXR_char  streamid[2];
00330    kXR_unt16 requestid;
00331    kXR_char  sessid[16];
00332    kXR_int32  dlen;
00333 };
00334 struct ClientChmodRequest {
00335    kXR_char  streamid[2];
00336    kXR_unt16 requestid;
00337    kXR_char  reserved[14];
00338    kXR_unt16 mode;
00339    kXR_int32  dlen;
00340 };
00341 struct ClientCloseRequest {
00342    kXR_char  streamid[2];
00343    kXR_unt16 requestid;
00344    kXR_char fhandle[4];
00345    kXR_int64 fsize;
00346    kXR_char reserved[4];
00347    kXR_int32  dlen;
00348 };
00349 struct ClientDirlistRequest {
00350    kXR_char  streamid[2];
00351    kXR_unt16 requestid;
00352    kXR_char reserved[15];
00353    kXR_char options[1];
00354    kXR_int32  dlen;
00355 };
00356 struct ClientEndsessRequest {
00357    kXR_char  streamid[2];
00358    kXR_unt16 requestid;
00359    kXR_char  sessid[16];
00360    kXR_int32  dlen;
00361 };
00362 struct ClientGetfileRequest {
00363    kXR_char  streamid[2];
00364    kXR_unt16 requestid;
00365    kXR_int32 options;
00366    kXR_char reserved[8];
00367    kXR_int32 buffsz;
00368    kXR_int32  dlen;
00369 };
00370 struct ClientLocateRequest {
00371    kXR_char  streamid[2];
00372    kXR_unt16 requestid;
00373    kXR_unt16 options;
00374    kXR_char reserved[14];
00375    kXR_int32  dlen;
00376 };
00377 struct ClientLoginRequest {
00378    kXR_char  streamid[2];
00379    kXR_unt16 requestid;
00380    kXR_int32 pid;
00381    kXR_char username[8];
00382    kXR_char reserved;
00383    kXR_char ability;       // See XLoginAbility enum flags
00384    kXR_char capver[1];     // See XLoginCapVer  enum flags
00385    kXR_char role[1];
00386    kXR_int32  dlen;
00387 };
00388 struct ClientMkdirRequest {
00389    kXR_char  streamid[2];
00390    kXR_unt16 requestid;
00391    kXR_char options[1];
00392    kXR_char reserved[13];
00393    kXR_unt16 mode;
00394    kXR_int32  dlen;
00395 };
00396 struct ClientMvRequest {
00397    kXR_char  streamid[2];
00398    kXR_unt16 requestid;
00399    kXR_char reserved[16];
00400    kXR_int32  dlen;
00401 };
00402 struct ClientOpenRequest {
00403    kXR_char  streamid[2];
00404    kXR_unt16 requestid;
00405    kXR_unt16 mode;
00406    kXR_unt16 options;
00407    kXR_char  reserved[12];
00408    kXR_int32  dlen;
00409 };
00410 
00411 struct ClientPingRequest {
00412    kXR_char  streamid[2];
00413    kXR_unt16 requestid;
00414    kXR_char reserved[16];
00415    kXR_int32  dlen;
00416 };
00417 struct ClientProtocolRequest {
00418    kXR_char  streamid[2];
00419    kXR_unt16 requestid;
00420    kXR_int32 clientpv;      // 2.9.7 or higher
00421    kXR_char  reserved[12];
00422    kXR_int32 dlen;
00423 };
00424 struct ClientPrepareRequest {
00425    kXR_char  streamid[2];
00426    kXR_unt16 requestid;
00427    kXR_char  options;
00428    kXR_char  prty;
00429    kXR_unt16 port;          // 2.9.9 or higher
00430    kXR_char  reserved[12];
00431    kXR_int32 dlen;
00432 };
00433 struct ClientPutfileRequest {
00434    kXR_char  streamid[2];
00435    kXR_unt16 requestid;
00436    kXR_int32 options;
00437    kXR_char  reserved[8];
00438    kXR_int32 buffsz;
00439    kXR_int32  dlen;
00440 };
00441 struct ClientQueryRequest {
00442    kXR_char  streamid[2];
00443    kXR_unt16 requestid;
00444    kXR_unt16 infotype;
00445    kXR_char  reserved1[2];
00446    kXR_char  fhandle[4];
00447    kXR_char  reserved2[8];
00448    kXR_int32 dlen;
00449 };
00450 struct ClientReadRequest {
00451    kXR_char  streamid[2];
00452    kXR_unt16 requestid;
00453    kXR_char fhandle[4];
00454    kXR_int64 offset;
00455    kXR_int32 rlen;
00456    kXR_int32  dlen;
00457 };
00458 struct ClientReadVRequest {
00459    kXR_char  streamid[2];
00460    kXR_unt16 requestid;
00461    kXR_char  reserved[15];
00462    kXR_char  pathid;
00463    kXR_int32 dlen;
00464 };
00465 struct ClientRmRequest {
00466    kXR_char  streamid[2];
00467    kXR_unt16 requestid;
00468    kXR_char reserved[16];
00469    kXR_int32  dlen;
00470 };
00471 struct ClientRmdirRequest {
00472    kXR_char  streamid[2];
00473    kXR_unt16 requestid;
00474    kXR_char reserved[16];
00475    kXR_int32  dlen;
00476 };
00477 struct ClientSetRequest {
00478    kXR_char  streamid[2];
00479    kXR_unt16 requestid;
00480    kXR_char reserved[16];
00481    kXR_int32  dlen;
00482 };
00483 struct ClientStatRequest {
00484    kXR_char  streamid[2];
00485    kXR_unt16 requestid;
00486    kXR_char  options;
00487    kXR_char reserved[11];
00488    kXR_char fhandle[4];
00489    kXR_int32  dlen;
00490 };
00491 struct ClientSyncRequest {
00492    kXR_char  streamid[2];
00493    kXR_unt16 requestid;
00494    kXR_char fhandle[4];
00495    kXR_char reserved[12];
00496    kXR_int32  dlen;
00497 };
00498 struct ClientTruncateRequest {
00499    kXR_char  streamid[2];
00500    kXR_unt16 requestid;
00501    kXR_char fhandle[4];
00502    kXR_int64 offset;
00503    kXR_char reserved[4];
00504    kXR_int32  dlen;
00505 };
00506 struct ClientWriteRequest {
00507    kXR_char  streamid[2];
00508    kXR_unt16 requestid;
00509    kXR_char fhandle[4];
00510    kXR_int64 offset;
00511    kXR_char  pathid;
00512    kXR_char reserved[3];
00513    kXR_int32  dlen;
00514 };
00515 struct ClientVerifywRequest {
00516    kXR_char  streamid[2];
00517    kXR_unt16 requestid;
00518    kXR_char  fhandle[4];
00519    kXR_int64 offset;
00520    kXR_char  pathid;
00521    kXR_char  vertype;       // One of XVerifyType
00522    kXR_char  reserved[2];
00523    kXR_int32 dlen;          // Includes crc length
00524 };
00525 
00526 struct ClientRequestHdr {
00527    kXR_char  streamid[2];
00528    kXR_unt16 requestid;
00529    kXR_char  body[16];
00530    kXR_int32  dlen;
00531 };
00532 
00533 typedef union {
00534    struct ClientRequestHdr header;
00535    struct ClientAdminRequest admin;
00536    struct ClientAuthRequest auth;
00537    struct ClientBindRequest bind;
00538    struct ClientChmodRequest chmod;
00539    struct ClientCloseRequest close;
00540    struct ClientDirlistRequest dirlist;
00541    struct ClientEndsessRequest endsess;
00542    struct ClientGetfileRequest getfile;
00543    struct ClientLocateRequest locate;
00544    struct ClientLoginRequest login;
00545    struct ClientMkdirRequest mkdir;
00546    struct ClientMvRequest mv;
00547    struct ClientOpenRequest open;
00548    struct ClientPingRequest ping;
00549    struct ClientPrepareRequest prepare;
00550    struct ClientProtocolRequest protocol;
00551    struct ClientPutfileRequest putfile;
00552    struct ClientQueryRequest query;
00553    struct ClientReadRequest read;
00554    struct ClientReadVRequest readv;
00555    struct ClientRmRequest rm;
00556    struct ClientRmdirRequest rmdir;
00557    struct ClientSetRequest set;
00558    struct ClientStatRequest stat;
00559    struct ClientSyncRequest sync;
00560    struct ClientTruncateRequest truncate;
00561    struct ClientWriteRequest write;
00562 } ClientRequest;
00563 
00564 struct readahead_list {
00565    kXR_char fhandle[4];
00566    kXR_int32 rlen;
00567    kXR_int64 offset;
00568 };
00569 
00570 struct read_args {
00571    kXR_char       pathid;
00572    kXR_char       reserved[7];
00573    // his struct is followed by an array of readahead_list
00574 };
00575 
00576 //_____________________________________________________________________
00577 //   PROTOCOL DEFINITION: SERVER'S RESPONSE
00578 //_____________________________________________________________________
00579 //
00580 
00581 // Nice header for the server response.
00582 // Note that the protocol specifies these values to be in network
00583 // byte order when sent
00584 //
00585 // G.Ganis: The following structures never need padding bytes:
00586 //          no need of packing options
00587 
00588 struct ServerResponseHeader {
00589    kXR_char streamid[2];
00590    kXR_unt16 status;
00591    kXR_int32  dlen;
00592 };
00593 
00594 // Body for the kXR_bind response... useful
00595 struct ServerResponseBody_Bind {
00596     kXR_char substreamid;
00597 };
00598 
00599 // Body for the kXR_open response... useful
00600 struct ServerResponseBody_Open {
00601    kXR_char fhandle[4];
00602    kXR_int32 cpsize;   // cpsize & cptype returned if kXR_compress *or*
00603    kXR_char cptype[4]; // kXR_retstat is specified
00604 }; // info will follow if kXR_retstat is specified
00605 
00606 // Body for the kXR_protocol response... useful
00607 struct ServerResponseBody_Protocol {
00608    kXR_int32 pval;
00609    kXR_int32 flags;
00610 };
00611 
00612 struct ServerResponseBody_Login {
00613    kXR_char  sessid[16];
00614    kXR_char  sec[4096]; // Should be sufficient for every use
00615 };
00616 
00617 struct ServerResponseBody_Redirect {
00618    kXR_int32 port;
00619    char host[4096]; // Should be sufficient for every use
00620 };
00621 
00622 struct ServerResponseBody_Error {
00623    kXR_int32 errnum;
00624    char errmsg[4096]; // Should be sufficient for every use
00625 };
00626 
00627 struct ServerResponseBody_Wait {
00628    kXR_int32 seconds;
00629    char infomsg[4096]; // Should be sufficient for every use
00630 };
00631 
00632 struct ServerResponseBody_Waitresp {
00633    kXR_int32 seconds;
00634 };
00635 
00636 struct ServerResponseBody_Attn {
00637    kXR_int32 actnum;
00638    char parms[4096]; // Should be sufficient for every use
00639 };
00640 
00641 struct ServerResponseBody_Attn_asyncrd {
00642    kXR_int32 actnum;
00643    kXR_int32 port;
00644    char host[4092];
00645 };
00646 
00647 struct ServerResponseBody_Attn_asynresp {
00648    kXR_int32            actnum;
00649    char reserved[4];
00650    ServerResponseHeader resphdr;
00651    char respdata[4096];
00652 };
00653 
00654 struct ServerResponseBody_Attn_asyncwt {
00655    kXR_int32 actnum;
00656    kXR_int32 wsec;
00657 };
00658 
00659 struct ServerResponseBody_Attn_asyncdi {
00660    kXR_int32 actnum;
00661    kXR_int32 wsec;
00662    kXR_int32 msec;
00663 };
00664 
00665 struct ServerResponseBody_Authmore {
00666    char data[4096];
00667 };
00668 
00669 struct ServerResponseBody_Buffer {
00670    char data[4096];
00671 };
00672 
00673 struct ServerResponse
00674 {
00675   ServerResponseHeader hdr;
00676   union
00677   {
00678     ServerResponseBody_Error    error;
00679     ServerResponseBody_Authmore authmore;
00680     ServerResponseBody_Wait     wait;
00681     ServerResponseBody_Waitresp waitresp;
00682     ServerResponseBody_Redirect redirect;
00683     ServerResponseBody_Attn     attn;
00684     ServerResponseBody_Protocol protocol;
00685     ServerResponseBody_Login    login;
00686     ServerResponseBody_Buffer   buffer;
00687     ServerResponseBody_Bind     bind;
00688   } body;
00689 };
00690 
00691 void ServerResponseHeader2NetFmt(struct ServerResponseHeader *srh);
00692 
00693 // The fields to be sent as initial handshake
00694 struct ClientInitHandShake {
00695    kXR_int32 first;
00696    kXR_int32 second;
00697    kXR_int32 third;
00698    kXR_int32 fourth;
00699    kXR_int32 fifth;
00700 };
00701 
00702 // The body received after the first handshake's header
00703 struct ServerInitHandShake {
00704    kXR_int32 msglen;
00705    kXR_int32 protover;
00706    kXR_int32 msgval;
00707 };
00708 
00709 
00710 
00711 typedef kXR_int32 ServerResponseType;
00712 
00713 struct ALIGN_CHECK {char chkszreq[25-sizeof(ClientRequest)];
00714    char chkszrsp[ 9-sizeof(ServerResponseHeader)];
00715 };
00716 
00717 /******************************************************************************/
00718 /*                   X P r o t o c o l   U t i l i t i e s                    */
00719 /******************************************************************************/
00720 
00721 #include <errno.h>
00722 #if defined(WIN32)
00723 #if !defined(ENOTBLK)
00724 #  define ENOTBLK 15
00725 #endif
00726 #if !defined(ETXTBSY)
00727 #define ETXTBSY 26
00728 #endif
00729 #if !defined(ENOBUFS)
00730 #define ENOBUFS 105
00731 #endif
00732 #if !defined(ENETUNREACH)
00733 #define ENETUNREACH 114
00734 #endif
00735 #endif
00736   
00737 class XProtocol
00738 {
00739 public:
00740 
00741 // mapError() is the occicial mapping from errno to xrootd protocol error.
00742 //
00743 static int mapError(int rc)
00744       {if (rc < 0) rc = -rc;
00745        switch(rc)
00746           {case ENOENT:       return kXR_NotFound;
00747            case EPERM:        return kXR_NotAuthorized;
00748            case EACCES:       return kXR_NotAuthorized;
00749            case EIO:          return kXR_IOError;
00750            case ENOMEM:       return kXR_NoMemory;
00751            case ENOBUFS:      return kXR_NoMemory;
00752            case ENOSPC:       return kXR_NoSpace;
00753            case ENAMETOOLONG: return kXR_ArgTooLong;
00754            case ENETUNREACH:  return kXR_noserver;
00755            case ENOTBLK:      return kXR_NotFile;
00756            case EISDIR:       return kXR_isDirectory;
00757            case EEXIST:       return kXR_InvalidRequest;
00758            case ETXTBSY:      return kXR_inProgress;
00759            case ENODEV:       return kXR_FSError;
00760            case EFAULT:       return kXR_ServerError;
00761            case EDQUOT:       return kXR_overQuota;
00762            default:           return kXR_FSError;
00763           }
00764       }
00765 
00766 static int toErrno( int xerr )
00767 {
00768     switch(xerr)
00769        {case kXR_ArgInvalid:    return EINVAL;
00770         case kXR_ArgMissing:    return EINVAL;
00771         case kXR_ArgTooLong:    return ENAMETOOLONG;
00772         case kXR_FileLocked:    return EDEADLK;
00773         case kXR_FileNotOpen:   return EBADF;
00774         case kXR_FSError:       return EIO;
00775         case kXR_InvalidRequest:return EEXIST;
00776         case kXR_IOError:       return EIO;
00777         case kXR_NoMemory:      return ENOMEM;
00778         case kXR_NoSpace:       return ENOSPC;
00779         case kXR_NotAuthorized: return EACCES;
00780         case kXR_NotFound:      return ENOENT;
00781         case kXR_ServerError:   return ENOMSG;
00782         case kXR_Unsupported:   return ENOSYS;
00783         case kXR_noserver:      return EHOSTUNREACH;
00784         case kXR_NotFile:       return ENOTBLK;
00785         case kXR_isDirectory:   return EISDIR;
00786         case kXR_Cancelled:     return ECANCELED;
00787         case kXR_ChkLenErr:     return EDOM;
00788         case kXR_ChkSumErr:     return EDOM;
00789         case kXR_inProgress:    return EINPROGRESS;
00790         case kXR_overQuota:     return EDQUOT;
00791         default:                return ENOMSG;
00792        }
00793 }
00794 
00795 };
00796 
00797 
00798 #endif

Generated on 5 Oct 2016 for xrootd by  doxygen 1.4.7