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,
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_noErrorYet = 10000
00298 };
00299 
00300 
00301 //______________________________________________
00302 // PROTOCOL DEFINITION: CLIENT'S REQUESTS STRUCTS
00303 //______________________________________________
00304 // 
00305 // We need to pack structures sent all over the net!
00306 // __attribute__((packed)) assures no padding bytes.
00307 //
00308 // Nice bodies of the headers for the client requests.
00309 // Note that the protocol specifies these values to be in network
00310 //  byte order when sent
00311 //
00312 // G.Ganis: use of flat structures to avoid packing options
00313 
00314 struct ClientAdminRequest {
00315    kXR_char  streamid[2];
00316    kXR_unt16 requestid;
00317    kXR_char reserved[16];
00318    kXR_int32  dlen;
00319 };
00320 struct ClientAuthRequest {
00321    kXR_char  streamid[2];
00322    kXR_unt16 requestid;
00323    kXR_char reserved[12];
00324    kXR_char credtype[4];
00325    kXR_int32  dlen;
00326 };
00327 struct ClientBindRequest {
00328    kXR_char  streamid[2];
00329    kXR_unt16 requestid;
00330    kXR_char  sessid[16];
00331    kXR_int32  dlen;
00332 };
00333 struct ClientChmodRequest {
00334    kXR_char  streamid[2];
00335    kXR_unt16 requestid;
00336    kXR_char  reserved[14];
00337    kXR_unt16 mode;
00338    kXR_int32  dlen;
00339 };
00340 struct ClientCloseRequest {
00341    kXR_char  streamid[2];
00342    kXR_unt16 requestid;
00343    kXR_char fhandle[4];
00344    kXR_int64 fsize;
00345    kXR_char reserved[4];
00346    kXR_int32  dlen;
00347 };
00348 struct ClientDirlistRequest {
00349    kXR_char  streamid[2];
00350    kXR_unt16 requestid;
00351    kXR_char reserved[15];
00352    kXR_char options[1];
00353    kXR_int32  dlen;
00354 };
00355 struct ClientEndsessRequest {
00356    kXR_char  streamid[2];
00357    kXR_unt16 requestid;
00358    kXR_char  sessid[16];
00359    kXR_int32  dlen;
00360 };
00361 struct ClientGetfileRequest {
00362    kXR_char  streamid[2];
00363    kXR_unt16 requestid;
00364    kXR_int32 options;
00365    kXR_char reserved[8];
00366    kXR_int32 buffsz;
00367    kXR_int32  dlen;
00368 };
00369 struct ClientLocateRequest {
00370    kXR_char  streamid[2];
00371    kXR_unt16 requestid;
00372    kXR_unt16 options;
00373    kXR_char reserved[14];
00374    kXR_int32  dlen;
00375 };
00376 struct ClientLoginRequest {
00377    kXR_char  streamid[2];
00378    kXR_unt16 requestid;
00379    kXR_int32 pid;
00380    kXR_char username[8];
00381    kXR_char reserved;
00382    kXR_char ability;       // See XLoginAbility enum flags
00383    kXR_char capver[1];     // See XLoginCapVer  enum flags
00384    kXR_char role[1];
00385    kXR_int32  dlen;
00386 };
00387 struct ClientMkdirRequest {
00388    kXR_char  streamid[2];
00389    kXR_unt16 requestid;
00390    kXR_char options[1];
00391    kXR_char reserved[13];
00392    kXR_unt16 mode;
00393    kXR_int32  dlen;
00394 };
00395 struct ClientMvRequest {
00396    kXR_char  streamid[2];
00397    kXR_unt16 requestid;
00398    kXR_char reserved[16];
00399    kXR_int32  dlen;
00400 };
00401 struct ClientOpenRequest {
00402    kXR_char  streamid[2];
00403    kXR_unt16 requestid;
00404    kXR_unt16 mode;
00405    kXR_unt16 options;
00406    kXR_char  reserved[12];
00407    kXR_int32  dlen;
00408 };
00409 
00410 struct ClientPingRequest {
00411    kXR_char  streamid[2];
00412    kXR_unt16 requestid;
00413    kXR_char reserved[16];
00414    kXR_int32  dlen;
00415 };
00416 struct ClientProtocolRequest {
00417    kXR_char  streamid[2];
00418    kXR_unt16 requestid;
00419    kXR_int32 clientpv;      // 2.9.7 or higher
00420    kXR_char  reserved[12];
00421    kXR_int32 dlen;
00422 };
00423 struct ClientPrepareRequest {
00424    kXR_char  streamid[2];
00425    kXR_unt16 requestid;
00426    kXR_char  options;
00427    kXR_char  prty;
00428    kXR_unt16 port;          // 2.9.9 or higher
00429    kXR_char  reserved[12];
00430    kXR_int32 dlen;
00431 };
00432 struct ClientPutfileRequest {
00433    kXR_char  streamid[2];
00434    kXR_unt16 requestid;
00435    kXR_int32 options;
00436    kXR_char  reserved[8];
00437    kXR_int32 buffsz;
00438    kXR_int32  dlen;
00439 };
00440 struct ClientQueryRequest {
00441    kXR_char  streamid[2];
00442    kXR_unt16 requestid;
00443    kXR_unt16 infotype;
00444    kXR_char  reserved1[2];
00445    kXR_char  fhandle[4];
00446    kXR_char  reserved2[8];
00447    kXR_int32 dlen;
00448 };
00449 struct ClientReadRequest {
00450    kXR_char  streamid[2];
00451    kXR_unt16 requestid;
00452    kXR_char fhandle[4];
00453    kXR_int64 offset;
00454    kXR_int32 rlen;
00455    kXR_int32  dlen;
00456 };
00457 struct ClientReadVRequest {
00458    kXR_char  streamid[2];
00459    kXR_unt16 requestid;
00460    kXR_char  reserved[15];
00461    kXR_char  pathid;
00462    kXR_int32 dlen;
00463 };
00464 struct ClientRmRequest {
00465    kXR_char  streamid[2];
00466    kXR_unt16 requestid;
00467    kXR_char reserved[16];
00468    kXR_int32  dlen;
00469 };
00470 struct ClientRmdirRequest {
00471    kXR_char  streamid[2];
00472    kXR_unt16 requestid;
00473    kXR_char reserved[16];
00474    kXR_int32  dlen;
00475 };
00476 struct ClientSetRequest {
00477    kXR_char  streamid[2];
00478    kXR_unt16 requestid;
00479    kXR_char reserved[16];
00480    kXR_int32  dlen;
00481 };
00482 struct ClientStatRequest {
00483    kXR_char  streamid[2];
00484    kXR_unt16 requestid;
00485    kXR_char  options;
00486    kXR_char reserved[11];
00487    kXR_char fhandle[4];
00488    kXR_int32  dlen;
00489 };
00490 struct ClientSyncRequest {
00491    kXR_char  streamid[2];
00492    kXR_unt16 requestid;
00493    kXR_char fhandle[4];
00494    kXR_char reserved[12];
00495    kXR_int32  dlen;
00496 };
00497 struct ClientTruncateRequest {
00498    kXR_char  streamid[2];
00499    kXR_unt16 requestid;
00500    kXR_char fhandle[4];
00501    kXR_int64 offset;
00502    kXR_char reserved[4];
00503    kXR_int32  dlen;
00504 };
00505 struct ClientWriteRequest {
00506    kXR_char  streamid[2];
00507    kXR_unt16 requestid;
00508    kXR_char fhandle[4];
00509    kXR_int64 offset;
00510    kXR_char  pathid;
00511    kXR_char reserved[3];
00512    kXR_int32  dlen;
00513 };
00514 struct ClientVerifywRequest {
00515    kXR_char  streamid[2];
00516    kXR_unt16 requestid;
00517    kXR_char  fhandle[4];
00518    kXR_int64 offset;
00519    kXR_char  pathid;
00520    kXR_char  vertype;       // One of XVerifyType
00521    kXR_char  reserved[2];
00522    kXR_int32 dlen;          // Includes crc length
00523 };
00524 
00525 struct ClientRequestHdr {
00526    kXR_char  streamid[2];
00527    kXR_unt16 requestid;
00528    kXR_char  body[16];
00529    kXR_int32  dlen;
00530 };
00531 
00532 typedef union {
00533    struct ClientRequestHdr header;
00534    struct ClientAdminRequest admin;
00535    struct ClientAuthRequest auth;
00536    struct ClientBindRequest bind;
00537    struct ClientChmodRequest chmod;
00538    struct ClientCloseRequest close;
00539    struct ClientDirlistRequest dirlist;
00540    struct ClientEndsessRequest endsess;
00541    struct ClientGetfileRequest getfile;
00542    struct ClientLocateRequest locate;
00543    struct ClientLoginRequest login;
00544    struct ClientMkdirRequest mkdir;
00545    struct ClientMvRequest mv;
00546    struct ClientOpenRequest open;
00547    struct ClientPingRequest ping;
00548    struct ClientPrepareRequest prepare;
00549    struct ClientProtocolRequest protocol;
00550    struct ClientPutfileRequest putfile;
00551    struct ClientQueryRequest query;
00552    struct ClientReadRequest read;
00553    struct ClientReadVRequest readv;
00554    struct ClientRmRequest rm;
00555    struct ClientRmdirRequest rmdir;
00556    struct ClientSetRequest set;
00557    struct ClientStatRequest stat;
00558    struct ClientSyncRequest sync;
00559    struct ClientTruncateRequest truncate;
00560    struct ClientWriteRequest write;
00561 } ClientRequest;
00562 
00563 struct readahead_list {
00564    kXR_char fhandle[4];
00565    kXR_int32 rlen;
00566    kXR_int64 offset;
00567 };
00568 
00569 struct read_args {
00570    kXR_char       pathid;
00571    kXR_char       reserved[7];
00572    // his struct is followed by an array of readahead_list
00573 };
00574 
00575 //_____________________________________________________________________
00576 //   PROTOCOL DEFINITION: SERVER'S RESPONSE
00577 //_____________________________________________________________________
00578 //
00579 
00580 // Nice header for the server response.
00581 // Note that the protocol specifies these values to be in network
00582 // byte order when sent
00583 //
00584 // G.Ganis: The following structures never need padding bytes:
00585 //          no need of packing options
00586 
00587 struct ServerResponseHeader {
00588    kXR_char streamid[2];
00589    kXR_unt16 status;
00590    kXR_int32  dlen;
00591 };
00592 
00593 // Body for the kXR_bind response... useful
00594 struct ServerResponseBody_Bind {
00595     kXR_char substreamid;
00596 };
00597 
00598 // Body for the kXR_open response... useful
00599 struct ServerResponseBody_Open {
00600    kXR_char fhandle[4];
00601    kXR_int32 cpsize;   // cpsize & cptype returned if kXR_compress *or*
00602    kXR_char cptype[4]; // kXR_retstat is specified
00603 }; // info will follow if kXR_retstat is specified
00604 
00605 // Body for the kXR_protocol response... useful
00606 struct ServerResponseBody_Protocol {
00607    kXR_int32 pval;
00608    kXR_int32 flags;
00609 };
00610 
00611 struct ServerResponseBody_Login {
00612    kXR_char  sessid[16];
00613    kXR_char  sec[4096]; // Should be sufficient for every use
00614 };
00615 
00616 struct ServerResponseBody_Redirect {
00617    kXR_int32 port;
00618    char host[4096]; // Should be sufficient for every use
00619 };
00620 
00621 struct ServerResponseBody_Error {
00622    kXR_int32 errnum;
00623    char errmsg[4096]; // Should be sufficient for every use
00624 };
00625 
00626 struct ServerResponseBody_Wait {
00627    kXR_int32 seconds;
00628    char infomsg[4096]; // Should be sufficient for every use
00629 };
00630 
00631 struct ServerResponseBody_Waitresp {
00632    kXR_int32 seconds;
00633 };
00634 
00635 struct ServerResponseBody_Attn {
00636    kXR_int32 actnum;
00637    char parms[4096]; // Should be sufficient for every use
00638 };
00639 
00640 struct ServerResponseBody_Attn_asyncrd {
00641    kXR_int32 actnum;
00642    kXR_int32 port;
00643    char host[4092];
00644 };
00645 
00646 struct ServerResponseBody_Attn_asynresp {
00647    kXR_int32            actnum;
00648    char reserved[4];
00649    ServerResponseHeader resphdr;
00650    char respdata[4096];
00651 };
00652 
00653 struct ServerResponseBody_Attn_asyncwt {
00654    kXR_int32 actnum;
00655    kXR_int32 wsec;
00656 };
00657 
00658 struct ServerResponseBody_Attn_asyncdi {
00659    kXR_int32 actnum;
00660    kXR_int32 wsec;
00661    kXR_int32 msec;
00662 };
00663 
00664 struct ServerResponseBody_Authmore {
00665    char data[4096];
00666 };
00667 
00668 struct ServerResponseBody_Buffer {
00669    char data[4096];
00670 };
00671 
00672 struct ServerResponse
00673 {
00674   ServerResponseHeader hdr;
00675   union
00676   {
00677     ServerResponseBody_Error    error;
00678     ServerResponseBody_Authmore authmore;
00679     ServerResponseBody_Wait     wait;
00680     ServerResponseBody_Waitresp waitresp;
00681     ServerResponseBody_Redirect redirect;
00682     ServerResponseBody_Attn     attn;
00683     ServerResponseBody_Protocol protocol;
00684     ServerResponseBody_Login    login;
00685     ServerResponseBody_Buffer   buffer;
00686     ServerResponseBody_Bind     bind;
00687   } body;
00688 };
00689 
00690 void ServerResponseHeader2NetFmt(struct ServerResponseHeader *srh);
00691 
00692 // The fields to be sent as initial handshake
00693 struct ClientInitHandShake {
00694    kXR_int32 first;
00695    kXR_int32 second;
00696    kXR_int32 third;
00697    kXR_int32 fourth;
00698    kXR_int32 fifth;
00699 };
00700 
00701 // The body received after the first handshake's header
00702 struct ServerInitHandShake {
00703    kXR_int32 msglen;
00704    kXR_int32 protover;
00705    kXR_int32 msgval;
00706 };
00707 
00708 
00709 
00710 typedef kXR_int32 ServerResponseType;
00711 
00712 struct ALIGN_CHECK {char chkszreq[25-sizeof(ClientRequest)];
00713    char chkszrsp[ 9-sizeof(ServerResponseHeader)];
00714 };
00715 
00716 /******************************************************************************/
00717 /*                   X P r o t o c o l   U t i l i t i e s                    */
00718 /******************************************************************************/
00719 
00720 #include <errno.h>
00721 #if defined(WIN32)
00722 #if !defined(ENOTBLK)
00723 #  define ENOTBLK 15
00724 #endif
00725 #if !defined(ETXTBSY)
00726 #define ETXTBSY 26
00727 #endif
00728 #if !defined(ENOBUFS)
00729 #define ENOBUFS 105
00730 #endif
00731 #if !defined(ENETUNREACH)
00732 #define ENETUNREACH 114
00733 #endif
00734 #endif
00735   
00736 class XProtocol
00737 {
00738 public:
00739 
00740 // mapError() is the occicial mapping from errno to xrootd protocol error.
00741 //
00742 static int mapError(int rc)
00743       {if (rc < 0) rc = -rc;
00744        switch(rc)
00745           {case ENOENT:       return kXR_NotFound;
00746            case EPERM:        return kXR_NotAuthorized;
00747            case EACCES:       return kXR_NotAuthorized;
00748            case EIO:          return kXR_IOError;
00749            case ENOMEM:       return kXR_NoMemory;
00750            case ENOBUFS:      return kXR_NoMemory;
00751            case ENOSPC:       return kXR_NoSpace;
00752            case ENAMETOOLONG: return kXR_ArgTooLong;
00753            case ENETUNREACH:  return kXR_noserver;
00754            case ENOTBLK:      return kXR_NotFile;
00755            case EISDIR:       return kXR_isDirectory;
00756            case EEXIST:       return kXR_InvalidRequest;
00757            case ETXTBSY:      return kXR_inProgress;
00758            default:           return kXR_FSError;
00759           }
00760       }
00761 };
00762 #endif

Generated on 12 Dec 2014 for xrootd by  doxygen 1.4.7