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