xrootd

YProtocol.hh

Go to the documentation of this file.
00001 #ifndef __YPROTOCOL_H
00002 #define __YPROTOCOL_H
00003 
00004 #ifdef __CINT__
00005 #define __attribute__(x)
00006 #endif
00007 
00008 //        $Id$
00009 
00010 #include "XProtocol/XPtypes.hh"
00011 
00012 // We need to pack structures sent all over the net!
00013 // __attribute__((packed)) assures no padding bytes.
00014 //
00015 // Note all binary values shall be in network byte order.
00016 //
00017 // Data is serialized as explained in XrdOucPup.
00018   
00019 /******************************************************************************/
00020 /*                C o m m o n   R e q u e s t   S e c t i o n                 */
00021 /******************************************************************************/
00022 
00023 namespace XrdCms
00024 {
00025 
00026 static const char kYR_Version = 2;
00027 
00028 struct CmsRRHdr
00029 {  kXR_unt32  streamid;    // Essentially opaque
00030    kXR_char   rrCode;      // Request or Response code
00031    kXR_char   modifier;    // RR dependent
00032    kXR_unt16  datalen;
00033 };
00034   
00035 enum CmsReqCode            // Request Codes
00036 {    kYR_login   =  0,     // Same as kYR_data
00037      kYR_chmod   =  1,
00038      kYR_locate  =  2,
00039      kYR_mkdir   =  3,
00040      kYR_mkpath  =  4,
00041      kYR_mv      =  5,
00042      kYR_prepadd =  6,
00043      kYR_prepdel =  7,
00044      kYR_rm      =  8,
00045      kYR_rmdir   =  9,
00046      kYR_select  = 10,
00047      kYR_stats   = 11,
00048      kYR_avail   = 12,
00049      kYR_disc    = 13,
00050      kYR_gone    = 14,
00051      kYR_have    = 15,
00052      kYR_load    = 16,
00053      kYR_ping    = 17,
00054      kYR_pong    = 18,
00055      kYR_space   = 19,
00056      kYR_state   = 20,
00057      kYR_statfs  = 21,
00058      kYR_status  = 22,
00059      kYR_trunc   = 23,
00060      kYR_try     = 24,
00061      kYR_update  = 25,
00062      kYR_usage   = 26,
00063      kYR_xauth   = 27,
00064      kYR_MaxReq            // Count of request numbers (highest + 1)
00065 };
00066 
00067 // The hopcount is used for forwarded requests. It is incremented upon each
00068 // forwarding until it wraps to zero. At this point the forward is not done.
00069 // Forwarding applies to: chmod, have, mkdir, mkpath, mv, prepdel, rm, and 
00070 // rmdir. Any other modifiers must be encoded in the low order 6 bits.
00071 //
00072 enum CmsFwdModifier
00073 {    kYR_hopcount = 0xc0,
00074      kYR_hopincr  = 0x40
00075 };
00076 
00077 enum CmsReqModifier
00078 {    kYR_raw = 0x20,     // Modifier: Unmarshalled data
00079      kYR_dnf = 0x10      // Modifier: mv, rm, rmdir (do not forward)
00080 };
00081 
00082 /******************************************************************************/
00083 /*               C o m m o n   R e s p o n s e   S e c t i o n                */
00084 /******************************************************************************/
00085   
00086 enum CmsRspCode            // Response codes
00087 {    kYR_data    = 0,      // Same as kYR_login
00088      kYR_error   = 1,
00089      kYR_redirect= 2,
00090      kYR_wait    = 3,
00091      kYR_waitresp= 4,
00092      kYR_yauth   = 5
00093 };
00094 
00095 enum YErrorCode
00096 {  kYR_ENOENT = 1,
00097    kYR_EPERM,
00098    kYR_EACCES,
00099    kYR_EINVAL,
00100    kYR_EIO,
00101    kYR_ENOMEM,
00102    kYR_ENOSPC,
00103    kYR_ENAMETOOLONG,
00104    kYR_ENETUNREACH,
00105    kYR_ENOTBLK,
00106    kYR_EISDIR
00107 };
00108 
00109 struct CmsResponse
00110 {      CmsRRHdr      Hdr;
00111 
00112 enum  {kYR_async   = 128                 // Modifier: Reply to prev waitresp
00113       };
00114 
00115        kXR_unt32     Val;                // Port, Wait val, rc, asyncid
00116 //     kXR_char      Data[Hdr.datalen-4];// Target host, more data, or emessage
00117 };
00118 
00119 /******************************************************************************/
00120 /*                         a v a i l   R e q u e s t                          */
00121 /******************************************************************************/
00122   
00123 // Request: avail <diskFree> <diskUtil>
00124 // Respond: n/a
00125 //
00126 struct CmsAvailRequest
00127 {      CmsRRHdr      Hdr;
00128 //     kXR_int32     diskFree;
00129 //     kXR_int32     diskUtil;
00130 };
00131 
00132 /******************************************************************************/
00133 /*                         c h m o d   R e q u e s t                          */
00134 /******************************************************************************/
00135   
00136 // Request: chmod <ident> <mode> <path>
00137 // Respond: n/a
00138 //
00139 struct CmsChmodRequest
00140 {      CmsRRHdr      Hdr;
00141 //     kXR_string    Ident;
00142 //     kXR_string    Mode;
00143 //     kXR_string    Path;
00144 };
00145 
00146 /******************************************************************************/
00147 /*                          d i s c   R e q u e s t                           */
00148 /******************************************************************************/
00149   
00150 // Request: disc
00151 // Respond: n/a
00152 //
00153 struct CmsDiscRequest
00154 {      CmsRRHdr      Hdr;
00155 };
00156 
00157 /******************************************************************************/
00158 /*                          g o n e   R e q u e s t                           */
00159 /******************************************************************************/
00160   
00161 // Request: gone <path>
00162 // Respond: n/a
00163 //
00164 struct CmsGoneRequest
00165 {      CmsRRHdr      Hdr;
00166 //     kXR_string    Path;
00167 };
00168 
00169 /******************************************************************************/
00170 /*                          h a v e   R e q u e s t                           */
00171 /******************************************************************************/
00172   
00173 // Request: have <path>
00174 // Respond: n/a
00175 //
00176 struct CmsHaveRequest
00177 {      CmsRRHdr      Hdr;
00178        enum          {Online = 1, Pending = 2};  // Modifiers
00179 //     kXR_string    Path;
00180 };
00181 
00182 /******************************************************************************/
00183 /*                        l o c a t e   R e q u e s t                         */
00184 /******************************************************************************/
00185 
00186 struct CmsLocateRequest
00187 {      CmsRRHdr      Hdr;
00188 //     kXR_string    Ident;
00189 //     kXR_unt32     Opts;
00190 
00191 enum  {kYR_refresh = 0x01,
00192        kYR_asap    = 0x80
00193       };
00194 //     kXR_string    Path;
00195 
00196 static const int     RILen = 32;  // Max length of each response item
00197 };
00198 
00199 /******************************************************************************/
00200 /*                         l o g i n   R e q u e s t                          */
00201 /******************************************************************************/
00202   
00203 // Request: login  <login_data>
00204 // Respond: xauth  <auth_data>
00205 //          login  <login_data>
00206 //
00207 
00208 struct CmsLoginData
00209 {      kXR_unt16  Size;              // Temp area for packing purposes
00210        kXR_unt16  Version;
00211        kXR_unt32  Mode;              // From LoginMode
00212        kXR_int32  HoldTime;          // Hold time in ms(managers)
00213        kXR_unt32  tSpace;            // Tot  Space  GB (servers)
00214        kXR_unt32  fSpace;            // Free Space  MB (servers)
00215        kXR_unt32  mSpace;            // Minf Space  MB (servers)
00216        kXR_unt16  fsNum;             // File Systems   (servers /supervisors)
00217        kXR_unt16  fsUtil;            // FS Utilization (servers /supervisors)
00218        kXR_unt16  dPort;             // Data port      (servers /supervisors)
00219        kXR_unt16  sPort;             // Subs port      (managers/supervisors)
00220        kXR_char  *SID;               // Server ID      (servers/ supervisors)
00221        kXR_char  *Paths;             // Exported paths (servers/ supervisors)
00222 
00223        enum       LoginMode
00224                  {kYR_director=   0x00000001,
00225                   kYR_manager =   0x00000002,
00226                   kYR_peer    =   0x00000004,
00227                   kYR_server  =   0x00000008,
00228                   kYR_proxy   =   0x00000010,
00229                   kYR_suspend =   0x00000100,   // Suspended login
00230                   kYR_nostage =   0x00000200,   // Staging unavailable
00231                   kYR_trying  =   0x00000400,   // Extensive login retries
00232                   kYR_debug   =   0x80000000
00233                  };
00234 };
00235 
00236 struct CmsLoginRequest
00237 {  CmsRRHdr     Hdr;
00238    CmsLoginData Data;
00239 };
00240 
00241 struct CmsLoginResponse
00242 {  CmsRRHdr     Hdr;
00243    CmsLoginData Data;
00244 };
00245 
00246 /******************************************************************************/
00247 /*                          l o a d   R e q u e s t                           */
00248 /******************************************************************************/
00249   
00250 // Request: load <cpu> <io> <load> <mem> <pag> <util> <dskfree>
00251 // Respond: n/a
00252 //
00253 struct CmsLoadRequest
00254 {      CmsRRHdr      Hdr;
00255        enum         {cpuLoad=0, netLoad, xeqLoad, memLoad, pagLoad, dskLoad,
00256                      numLoad};
00257 //     kXR_char      theLoad[numload];
00258 //     kXR_int       dskFree;
00259 };
00260 
00261 /******************************************************************************/
00262 /*                         m k d i r   R e q u e s t                          */
00263 /******************************************************************************/
00264   
00265 // Request: mkdir <ident> <mode> <path>
00266 // Respond: n/a
00267 //
00268 struct CmsMkdirRequest
00269 {      CmsRRHdr      Hdr;
00270 //     kXR_string    Ident;
00271 //     kXR_string    Mode;
00272 //     kXR_string    Path;
00273 };
00274 
00275 /******************************************************************************/
00276 /*                        m k p a t h   R e q u e s t                         */
00277 /******************************************************************************/
00278   
00279 // Request: <id> mkpath <mode> <path>
00280 // Respond: n/a
00281 //
00282 struct CmsMkpathRequest
00283 {      CmsRRHdr      Hdr;
00284 //     kXR_string    Ident;
00285 //     kXR_string    Mode;
00286 //     kXR_string    Path;
00287 };
00288 
00289 /******************************************************************************/
00290 /*                            m v   R e q u e s t                             */
00291 /******************************************************************************/
00292   
00293 // Request: <id> mv <old_name> <new_name>
00294 // Respond: n/a
00295 //
00296 struct CmsMvRequest {
00297        CmsRRHdr      Hdr;      // Subject to kYR_dnf modifier!
00298 //     kXR_string    Ident;
00299 //     kXR_string    Old_Path;
00300 //     kXR_string    New_Path;
00301 };
00302 
00303 /******************************************************************************/
00304 /*                          p i n g   R e q u e s t                           */
00305 /******************************************************************************/
00306   
00307 // Request: ping
00308 // Respond: n/a
00309 //
00310 struct CmsPingRequest {
00311        CmsRRHdr      Hdr;
00312 };
00313 
00314 /******************************************************************************/
00315 /*                          p o n g   R e q u e s t                           */
00316 /******************************************************************************/
00317   
00318 // Request: pong
00319 // Respond: n/a
00320 //
00321 struct CmsPongRequest {
00322        CmsRRHdr      Hdr;
00323 };
00324 
00325 /******************************************************************************/
00326 /*                       p r e p a d d   R e q u e s t                        */
00327 /******************************************************************************/
00328   
00329 // Request: <id> prepadd <reqid> <usr> <prty> <mode> <path>\n
00330 // Respond: No response.
00331 //
00332 struct CmsPrepAddRequest
00333 {      CmsRRHdr      Hdr;    // Modifier used with following options
00334 
00335 enum  {kYR_stage   = 0x0001, // Stage   the data
00336        kYR_write   = 0x0002, // Prepare for writing
00337        kYR_coloc   = 0x0004, // Prepare for co-location
00338        kYR_fresh   = 0x0008, // Prepare by  time refresh
00339        kYR_metaman = 0x0010  // Prepare via meta-manager
00340       };
00341 //     kXR_string    Ident;
00342 //     kXR_string    reqid;
00343 //     kXR_string    user;
00344 //     kXR_string    prty;
00345 //     kXR_string    mode;
00346 //     kXR_string    Path;
00347 //     kXR_string    Opaque; // Optional
00348 };
00349 
00350 /******************************************************************************/
00351 /*                       p r e p d e l   R e q u e s t                        */
00352 /******************************************************************************/
00353   
00354 // Request: <id> prepdel <reqid>
00355 // Respond: No response.
00356 //
00357 struct CmsPrepDelRequest
00358 {      CmsRRHdr      Hdr;
00359 //     kXR_string    Ident;
00360 //     kXR_string    reqid;
00361 };
00362 
00363 /******************************************************************************/
00364 /*                            r m   R e q u e s t                             */
00365 /******************************************************************************/
00366   
00367 // Request: <id> rm <path>
00368 // Respond: n/a
00369 //
00370 struct CmsRmRequest
00371 {      CmsRRHdr      Hdr;    // Subject to kYR_dnf modifier!
00372 //     kXR_string    Ident;
00373 //     kXR_string    Path;
00374 };
00375 
00376 /******************************************************************************/
00377 /*                         r m d i r   R e q u e s t                          */
00378 /******************************************************************************/
00379   
00380 // Request: <id> rmdir <path>
00381 // Respond: n/a
00382 //
00383 struct CmsRmdirRequest
00384 {      CmsRRHdr      Hdr;    // Subject to kYR_dnf modifier!
00385 //     kXR_string    Ident;
00386 //     kXR_string    Path;
00387 };
00388 
00389 /******************************************************************************/
00390 /*                        s e l e c t   R e q u e s t                         */
00391 /******************************************************************************/
00392   
00393 // Request: <id> select[s] {c | d | m | r | w | s | t | x} <path> [-host]
00394 
00395 // Note: selects - requests a cache refresh for <path>
00396 // kYR_refresh   - refresh file location cache
00397 // kYR_create  c - file will be created
00398 // kYR_delete  d - file will be created or truncated
00399 // kYR_metaop  m - inod will only be modified
00400 // kYR_read    r - file will only be read
00401 // kYR_replica   - file will replicated
00402 // kYR_write   w - file will be read and writen
00403 // kYR_stats   s - only stat information will be obtained
00404 // kYR_online  x - consider only online files
00405 //                 may be combined with kYR_stats (file must be resident)
00406 //             - - the host failed to deliver the file.
00407 
00408 
00409 struct CmsSelectRequest
00410 {      CmsRRHdr      Hdr;
00411 //     kXR_string    Ident;
00412 //     kXR_unt32     Opts;
00413 
00414 enum  {kYR_refresh = 0x0001,
00415        kYR_create  = 0x0002, // May combine with trunc -> delete
00416        kYR_online  = 0x0004,
00417        kYR_read    = 0x0008, // Default
00418        kYR_trunc   = 0x0010, // -> write
00419        kYR_write   = 0x0020,
00420        kYR_stat    = 0x0040, // Exclsuive
00421        kYR_metaop  = 0x0080,
00422        kYR_replica = 0x0100  // Only in combination with create
00423       };
00424 //     kXR_string    Path;
00425 //     kXR_string    Opaque; // Optional
00426 //     kXR_string    Host;   // Optional
00427 };
00428 
00429 /******************************************************************************/
00430 /*                         s p a c e   R e q u e s t                          */
00431 /******************************************************************************/
00432   
00433 // Request: space
00434 //
00435 
00436 struct CmsSpaceRequest
00437 {      CmsRRHdr      Hdr;
00438 };
00439   
00440 /******************************************************************************/
00441 /*                         s t a t e   R e q u e s t                          */
00442 /******************************************************************************/
00443   
00444 // Request: state <path>
00445 //
00446 
00447 struct CmsStateRequest
00448 {      CmsRRHdr      Hdr;
00449 //     kXR_string    Path;
00450 
00451 enum  {kYR_refresh = 0x01,   // Modifier
00452        kYR_noresp  = 0x02,
00453        kYR_metaman = 0x08
00454       };
00455 };
00456   
00457 /******************************************************************************/
00458 /*                        s t a t f s   R e q u e s t                         */
00459 /******************************************************************************/
00460   
00461 // Request: statfs <path>
00462 //
00463 
00464 struct CmsStatfsRequest
00465 {      CmsRRHdr      Hdr;
00466 //     kXR_string    Path;
00467 };
00468 
00469 /******************************************************************************/
00470 /*                         s t a t s   R e q u e s t                          */
00471 /******************************************************************************/
00472   
00473 // Request: stats or statsz (determined by modifier)
00474 //
00475 
00476 struct CmsStatsRequest
00477 {      CmsRRHdr      Hdr;
00478 
00479 enum  {kYR_size = 1  // Modifier
00480       };
00481 };
00482 
00483 /******************************************************************************/
00484 /*                        s t a t u s   R e q u e s t                         */
00485 /******************************************************************************/
00486   
00487 // Request: status
00488 //
00489 struct CmsStatusRequest
00490 {      CmsRRHdr      Hdr;
00491 
00492 enum  {kYR_Stage  = 0x01, kYR_noStage = 0x02,  // Modifier
00493        kYR_Resume = 0x04, kYR_Suspend = 0x08,
00494        kYR_Reset  = 0x10                       // Exclusive
00495       };
00496 };
00497 
00498 /******************************************************************************/
00499 /*                         t r u n c   R e q u e s t                          */
00500 /******************************************************************************/
00501   
00502 // Request: <id> trunc <path>
00503 // Respond: n/a
00504 //
00505 struct CmsTruncRequest
00506 {      CmsRRHdr      Hdr;
00507 //     kXR_string    Ident;
00508 //     kXR_string    Size;
00509 //     kXR_string    Path;
00510 };
00511 
00512 /******************************************************************************/
00513 /*                           t r y   R e q u e s t                            */
00514 /******************************************************************************/
00515   
00516 // Request: try
00517 //
00518 struct CmsTryRequest
00519 {      CmsRRHdr      Hdr;
00520        kXR_unt16     sLen;   // This is the string length in PUP format
00521 
00522 //     kYR_string    {ipaddr:port}[up to STMax];
00523 };
00524 
00525 /******************************************************************************/
00526 /*                        u p d a t e   R e q u e s t                         */
00527 /******************************************************************************/
00528   
00529 // Request: update
00530 //
00531 struct CmsUpdateRequest
00532 {      CmsRRHdr      Hdr;
00533 };
00534 
00535 /******************************************************************************/
00536 /*                         u s a g e   R e q u e s t                          */
00537 /******************************************************************************/
00538   
00539 // Request: usage
00540 //
00541 struct CmsUsageRequest
00542 {      CmsRRHdr      Hdr;
00543 };
00544 
00545 }; // namespace XrdCms
00546 #endif