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 /* The XRootD protocol definition, documented in this file, is distributed */ 00025 /* under a modified BSD license and may be freely used to reimplement it. */ 00026 /* Any references to "source" in this license refers to this file or any */ 00027 /* other file that specifically contains the following license. */ 00028 /* */ 00029 /* Redistribution and use in source and binary forms, with or without */ 00030 /* modification, are permitted provided that the following conditions */ 00031 /* are met: */ 00032 /* */ 00033 /* 1. Redistributions of source code must retain the above copyright notice, */ 00034 /* this list of conditions and the following disclaimer. */ 00035 /* */ 00036 /* 2. Redistributions in binary form must reproduce the above copyright */ 00037 /* notice, this list of conditions and the following disclaimer in the */ 00038 /* documentation and/or other materials provided with the distribution. */ 00039 /* */ 00040 /* 3. Neither the name of the copyright holder nor the names of its */ 00041 /* contributors may be used to endorse or promote products derived from */ 00042 /* this software without specific prior written permission. */ 00043 /* */ 00044 /* 4. Derived software may not use the name XRootD or cmsd (regardless of */ 00045 /* capitilization) in association with the derived work if the protocol */ 00046 /* documented in this file is changed in any way. */ 00047 /* */ 00048 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ 00049 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ 00050 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ 00051 /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ 00052 /* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ 00053 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ 00054 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ 00055 /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ 00056 /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ 00057 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ 00058 /******************************************************************************/ 00059 00060 #ifdef __CINT__ 00061 #define __attribute__(x) 00062 #endif 00063 00064 #include "XProtocol/XPtypes.hh" 00065 00066 // We need to pack structures sent all over the net! 00067 // __attribute__((packed)) assures no padding bytes. 00068 // 00069 // Note all binary values shall be in network byte order. 00070 // 00071 // Data is serialized as explained in XrdOucPup. 00072 00073 /******************************************************************************/ 00074 /* C o m m o n R e q u e s t S e c t i o n */ 00075 /******************************************************************************/ 00076 00077 namespace XrdCms 00078 { 00079 00080 static const unsigned char kYR_Version = 3; 00081 00082 struct CmsRRHdr 00083 { kXR_unt32 streamid; // Essentially opaque 00084 kXR_char rrCode; // Request or Response code 00085 kXR_char modifier; // RR dependent 00086 kXR_unt16 datalen; 00087 }; 00088 00089 enum CmsReqCode // Request Codes 00090 { kYR_login = 0, // Same as kYR_data 00091 kYR_chmod = 1, 00092 kYR_locate = 2, 00093 kYR_mkdir = 3, 00094 kYR_mkpath = 4, 00095 kYR_mv = 5, 00096 kYR_prepadd = 6, 00097 kYR_prepdel = 7, 00098 kYR_rm = 8, 00099 kYR_rmdir = 9, 00100 kYR_select = 10, 00101 kYR_stats = 11, 00102 kYR_avail = 12, 00103 kYR_disc = 13, 00104 kYR_gone = 14, 00105 kYR_have = 15, 00106 kYR_load = 16, 00107 kYR_ping = 17, 00108 kYR_pong = 18, 00109 kYR_space = 19, 00110 kYR_state = 20, 00111 kYR_statfs = 21, 00112 kYR_status = 22, 00113 kYR_trunc = 23, 00114 kYR_try = 24, 00115 kYR_update = 25, 00116 kYR_usage = 26, 00117 kYR_xauth = 27, 00118 kYR_MaxReq // Count of request numbers (highest + 1) 00119 }; 00120 00121 // The hopcount is used for forwarded requests. It is incremented upon each 00122 // forwarding until it wraps to zero. At this point the forward is not done. 00123 // Forwarding applies to: chmod, have, mkdir, mkpath, mv, prepdel, rm, and 00124 // rmdir. Any other modifiers must be encoded in the low order 6 bits. 00125 // 00126 enum CmsFwdModifier 00127 { kYR_hopcount = 0xc0, 00128 kYR_hopincr = 0x40 00129 }; 00130 00131 enum CmsReqModifier 00132 { kYR_raw = 0x20, // Modifier: Unmarshalled data 00133 kYR_dnf = 0x10 // Modifier: mv, rm, rmdir (do not forward) 00134 }; 00135 00136 /******************************************************************************/ 00137 /* C o m m o n R e s p o n s e S e c t i o n */ 00138 /******************************************************************************/ 00139 00140 enum CmsRspCode // Response codes 00141 { kYR_data = 0, // Same as kYR_login 00142 kYR_error = 1, 00143 kYR_redirect= 2, 00144 kYR_wait = 3, 00145 kYR_waitresp= 4, 00146 kYR_yauth = 5 00147 }; 00148 00149 enum YErrorCode 00150 { kYR_ENOENT = 1, 00151 kYR_EPERM, 00152 kYR_EACCES, 00153 kYR_EINVAL, 00154 kYR_EIO, 00155 kYR_ENOMEM, 00156 kYR_ENOSPC, 00157 kYR_ENAMETOOLONG, 00158 kYR_ENETUNREACH, 00159 kYR_ENOTBLK, 00160 kYR_EISDIR, 00161 kYR_FSError, 00162 kYR_SrvError 00163 }; 00164 00165 struct CmsResponse 00166 { CmsRRHdr Hdr; 00167 00168 enum {kYR_async = 128 // Modifier: Reply to prev waitresp 00169 }; 00170 00171 kXR_unt32 Val; // Port, Wait val, rc, asyncid 00172 // kXR_char Data[Hdr.datalen-4];// Target host, more data, or emessage 00173 }; 00174 00175 /******************************************************************************/ 00176 /* a v a i l R e q u e s t */ 00177 /******************************************************************************/ 00178 00179 // Request: avail <diskFree> <diskUtil> 00180 // Respond: n/a 00181 // 00182 struct CmsAvailRequest 00183 { CmsRRHdr Hdr; 00184 // kXR_int32 diskFree; 00185 // kXR_int32 diskUtil; 00186 }; 00187 00188 /******************************************************************************/ 00189 /* c h m o d R e q u e s t */ 00190 /******************************************************************************/ 00191 00192 // Request: chmod <ident> <mode> <path> 00193 // Respond: n/a 00194 // 00195 struct CmsChmodRequest 00196 { CmsRRHdr Hdr; 00197 // kXR_string Ident; 00198 // kXR_string Mode; 00199 // kXR_string Path; 00200 }; 00201 00202 /******************************************************************************/ 00203 /* d i s c R e q u e s t */ 00204 /******************************************************************************/ 00205 00206 // Request: disc 00207 // Respond: n/a 00208 // 00209 struct CmsDiscRequest 00210 { CmsRRHdr Hdr; 00211 }; 00212 00213 /******************************************************************************/ 00214 /* g o n e R e q u e s t */ 00215 /******************************************************************************/ 00216 00217 // Request: gone <path> 00218 // Respond: n/a 00219 // 00220 struct CmsGoneRequest 00221 { CmsRRHdr Hdr; 00222 // kXR_string Path; 00223 }; 00224 00225 /******************************************************************************/ 00226 /* h a v e R e q u e s t */ 00227 /******************************************************************************/ 00228 00229 // Request: have <path> 00230 // Respond: n/a 00231 // 00232 struct CmsHaveRequest 00233 { CmsRRHdr Hdr; 00234 enum {Online = 1, Pending = 2}; // Modifiers 00235 // kXR_string Path; 00236 }; 00237 00238 /******************************************************************************/ 00239 /* l o c a t e R e q u e s t */ 00240 /******************************************************************************/ 00241 00242 struct CmsLocateRequest 00243 { CmsRRHdr Hdr; 00244 // kXR_string Ident; 00245 // kXR_unt32 Opts; 00246 00247 enum {kYR_refresh = 0x0001, 00248 kYR_retname = 0x0002, 00249 kYR_retuniq = 0x0004, 00250 kYR_asap = 0x0080, 00251 kYR_retipv4 = 0x0000, // Client is only IPv4 00252 kYR_retipv46= 0x1000, // Client is IPv4 IPv6 00253 kYR_retipv6 = 0x2000, // Client is only IPv6 00254 kYR_retipv64= 0x3000, // Client is IPv6 IPv4 00255 kYR_retipmsk= 0x3000, // Mask to isolate retipcxx bits 00256 kYR_retipsft= 12, // Shift to convert retipcxx bits 00257 kYR_listall = 0x4000, // List everything regardless of other settings 00258 kYR_prvtnet = 0x8000 // Client is using a private address 00259 }; 00260 // kXR_string Path; 00261 00262 static const int RHLen =266; // Max length of each host response item 00263 }; 00264 00265 /******************************************************************************/ 00266 /* l o g i n R e q u e s t */ 00267 /******************************************************************************/ 00268 00269 // Request: login <login_data> 00270 // Respond: xauth <auth_data> 00271 // login <login_data> 00272 // 00273 00274 struct CmsLoginData 00275 { kXR_unt16 Size; // Temp area for packing purposes 00276 kXR_unt16 Version; 00277 kXR_unt32 Mode; // From LoginMode 00278 kXR_int32 HoldTime; // Hold time in ms(managers) 00279 kXR_unt32 tSpace; // Tot Space GB (servers) 00280 kXR_unt32 fSpace; // Free Space MB (servers) 00281 kXR_unt32 mSpace; // Minf Space MB (servers) 00282 kXR_unt16 fsNum; // File Systems (servers /supervisors) 00283 kXR_unt16 fsUtil; // FS Utilization (servers /supervisors) 00284 kXR_unt16 dPort; // Data port (servers /supervisors) 00285 kXR_unt16 sPort; // Subs port (managers/supervisors) 00286 kXR_char *SID; // Server ID (servers/ supervisors) 00287 kXR_char *Paths; // Exported paths (servers/ supervisors) 00288 kXR_char *ifList; // Exported interfaces 00289 kXR_char *envCGI; // Exported environment 00290 00291 enum LoginMode 00292 {kYR_director= 0x00000001, 00293 kYR_manager = 0x00000002, 00294 kYR_peer = 0x00000004, 00295 kYR_server = 0x00000008, 00296 kYR_proxy = 0x00000010, 00297 kYR_subman = 0x00000020, 00298 kYR_blredir = 0x00000040, // Supports or is bl redir 00299 kYR_suspend = 0x00000100, // Suspended login 00300 kYR_nostage = 0x00000200, // Staging unavailable 00301 kYR_trying = 0x00000400, // Extensive login retries 00302 kYR_debug = 0x80000000, 00303 kYR_share = 0x7f000000, // Mask to isolate share 00304 kYR_shift = 24, // Share shift position 00305 kYR_tzone = 0x00f80000, // Mask to isolate time zone 00306 kYR_shifttz = 19 // TZone shift position 00307 }; 00308 }; 00309 00310 struct CmsLoginRequest 00311 { CmsRRHdr Hdr; 00312 CmsLoginData Data; 00313 }; 00314 00315 struct CmsLoginResponse 00316 { CmsRRHdr Hdr; 00317 CmsLoginData Data; 00318 }; 00319 00320 /******************************************************************************/ 00321 /* l o a d R e q u e s t */ 00322 /******************************************************************************/ 00323 00324 // Request: load <cpu> <io> <load> <mem> <pag> <util> <dskfree> 00325 // Respond: n/a 00326 // 00327 struct CmsLoadRequest 00328 { CmsRRHdr Hdr; 00329 enum {cpuLoad=0, netLoad, xeqLoad, memLoad, pagLoad, dskLoad, 00330 numLoad}; 00331 // kXR_char theLoad[numload]; 00332 // kXR_int dskFree; 00333 }; 00334 00335 /******************************************************************************/ 00336 /* m k d i r R e q u e s t */ 00337 /******************************************************************************/ 00338 00339 // Request: mkdir <ident> <mode> <path> 00340 // Respond: n/a 00341 // 00342 struct CmsMkdirRequest 00343 { CmsRRHdr Hdr; 00344 // kXR_string Ident; 00345 // kXR_string Mode; 00346 // kXR_string Path; 00347 }; 00348 00349 /******************************************************************************/ 00350 /* m k p a t h R e q u e s t */ 00351 /******************************************************************************/ 00352 00353 // Request: <id> mkpath <mode> <path> 00354 // Respond: n/a 00355 // 00356 struct CmsMkpathRequest 00357 { CmsRRHdr Hdr; 00358 // kXR_string Ident; 00359 // kXR_string Mode; 00360 // kXR_string Path; 00361 }; 00362 00363 /******************************************************************************/ 00364 /* m v R e q u e s t */ 00365 /******************************************************************************/ 00366 00367 // Request: <id> mv <old_name> <new_name> 00368 // Respond: n/a 00369 // 00370 struct CmsMvRequest { 00371 CmsRRHdr Hdr; // Subject to kYR_dnf modifier! 00372 // kXR_string Ident; 00373 // kXR_string Old_Path; 00374 // kXR_string New_Path; 00375 }; 00376 00377 /******************************************************************************/ 00378 /* p i n g R e q u e s t */ 00379 /******************************************************************************/ 00380 00381 // Request: ping 00382 // Respond: n/a 00383 // 00384 struct CmsPingRequest { 00385 CmsRRHdr Hdr; 00386 }; 00387 00388 /******************************************************************************/ 00389 /* p o n g R e q u e s t */ 00390 /******************************************************************************/ 00391 00392 // Request: pong 00393 // Respond: n/a 00394 // 00395 struct CmsPongRequest { 00396 CmsRRHdr Hdr; 00397 }; 00398 00399 /******************************************************************************/ 00400 /* p r e p a d d R e q u e s t */ 00401 /******************************************************************************/ 00402 00403 // Request: <id> prepadd <reqid> <usr> <prty> <mode> <path>\n 00404 // Respond: No response. 00405 // 00406 struct CmsPrepAddRequest 00407 { CmsRRHdr Hdr; // Modifier used with following options 00408 00409 enum {kYR_stage = 0x0001, // Stage the data 00410 kYR_write = 0x0002, // Prepare for writing 00411 kYR_coloc = 0x0004, // Prepare for co-location 00412 kYR_fresh = 0x0008, // Prepare by time refresh 00413 kYR_metaman = 0x0010 // Prepare via meta-manager 00414 }; 00415 // kXR_string Ident; 00416 // kXR_string reqid; 00417 // kXR_string user; 00418 // kXR_string prty; 00419 // kXR_string mode; 00420 // kXR_string Path; 00421 // kXR_string Opaque; // Optional 00422 }; 00423 00424 /******************************************************************************/ 00425 /* p r e p d e l R e q u e s t */ 00426 /******************************************************************************/ 00427 00428 // Request: <id> prepdel <reqid> 00429 // Respond: No response. 00430 // 00431 struct CmsPrepDelRequest 00432 { CmsRRHdr Hdr; 00433 // kXR_string Ident; 00434 // kXR_string reqid; 00435 }; 00436 00437 /******************************************************************************/ 00438 /* r m R e q u e s t */ 00439 /******************************************************************************/ 00440 00441 // Request: <id> rm <path> 00442 // Respond: n/a 00443 // 00444 struct CmsRmRequest 00445 { CmsRRHdr Hdr; // Subject to kYR_dnf modifier! 00446 // kXR_string Ident; 00447 // kXR_string Path; 00448 }; 00449 00450 /******************************************************************************/ 00451 /* r m d i r R e q u e s t */ 00452 /******************************************************************************/ 00453 00454 // Request: <id> rmdir <path> 00455 // Respond: n/a 00456 // 00457 struct CmsRmdirRequest 00458 { CmsRRHdr Hdr; // Subject to kYR_dnf modifier! 00459 // kXR_string Ident; 00460 // kXR_string Path; 00461 }; 00462 00463 /******************************************************************************/ 00464 /* s e l e c t R e q u e s t */ 00465 /******************************************************************************/ 00466 00467 // Request: <id> select[s] {c | d | m | r | w | s | t | x} <path> [-host] 00468 00469 // Note: selects - requests a cache refresh for <path> 00470 // kYR_refresh - refresh file location cache 00471 // kYR_create c - file will be created 00472 // kYR_delete d - file will be created or truncated 00473 // kYR_metaop m - inod will only be modified 00474 // kYR_read r - file will only be read 00475 // kYR_replica - file will replicated 00476 // kYR_write w - file will be read and writen 00477 // kYR_stats s - only stat information will be obtained 00478 // kYR_online x - consider only online files 00479 // may be combined with kYR_stats (file must be resident) 00480 // - - the host failed to deliver the file. 00481 00482 00483 struct CmsSelectRequest 00484 { CmsRRHdr Hdr; 00485 // kXR_string Ident; 00486 // kXR_unt32 Opts; 00487 00488 enum {kYR_refresh = 0x00000001, 00489 kYR_create = 0x00000002, // May combine with trunc -> delete 00490 kYR_online = 0x00000004, 00491 kYR_read = 0x00000008, // Default 00492 kYR_trunc = 0x00000010, // -> write 00493 kYR_write = 0x00000020, 00494 kYR_stat = 0x00000040, // Exclsuive 00495 kYR_metaop = 0x00000080, 00496 kYR_replica = 0x00000100, // Only in combination with create 00497 kYR_mwfiles = 0x00000200, // Multiple writables files are OK 00498 kYR_retipv4 = 0x00000000, // Client is only IPv4 00499 kYR_retipv46= 0x00001000, // Client is IPv4 IPv6 00500 kYR_retipv6 = 0x00002000, // Client is only IPv6 00501 kYR_retipv64= 0x00003000, // Client is IPv6 IPv4 00502 kYR_retipmsk= 0x00003000, // Mask to isolate retipcxx bits 00503 kYR_retipsft= 12, // Shift to convert retipcxx bits 00504 kYR_prvtnet = 0x00008000, // Client is using a private address 00505 00506 kYR_tryMISS = 0x00000000, // Retry due to missing file (triedrc=enoent) 00507 kYR_tryIOER = 0x00010000, // Retry due to I/O error (triedrc=ioerr) 00508 kYR_tryFSER = 0x00020000, // Retry due to FS error (triedrc=fserr) 00509 kYR_trySVER = 0x00030000, // Retry due to server error (triedrc=srverr) 00510 kYR_tryMASK = 0x00030000, // Mask to isolate retry reason 00511 kYR_trySHFT = 16, // Amount to shift right 00512 kYR_tryRSEL = 0x00040000, // Retry for reselection (triedrc=resel) 00513 kYR_aWeak = 0x00100000, // Affinity: weak 00514 kYR_aStrong = 0x00200000, // Affinity: strong 00515 kYR_aStrict = 0x00300000, // Affinity: strict 00516 kYR_aNone = 0x00400000, // Affinity: none 00517 kYR_aSpec = 0x00700000, // Mask to test if any affinity specified 00518 kYR_aPack = 0x00300000, // Mask to test if the affinity packs choice 00519 kYR_aWait = 0x00200000 // Mask to test if the affinity must wait 00520 }; 00521 // kXR_string Path; 00522 // kXR_string Opaque; // Optional 00523 // kXR_string Host; // Optional 00524 }; 00525 00526 /******************************************************************************/ 00527 /* s p a c e R e q u e s t */ 00528 /******************************************************************************/ 00529 00530 // Request: space 00531 // 00532 00533 struct CmsSpaceRequest 00534 { CmsRRHdr Hdr; 00535 }; 00536 00537 /******************************************************************************/ 00538 /* s t a t e R e q u e s t */ 00539 /******************************************************************************/ 00540 00541 // Request: state <path> 00542 // 00543 00544 struct CmsStateRequest 00545 { CmsRRHdr Hdr; 00546 // kXR_string Path; 00547 00548 enum {kYR_refresh = 0x01, // Modifier 00549 kYR_noresp = 0x02, 00550 kYR_metaman = 0x08 00551 }; 00552 }; 00553 00554 /******************************************************************************/ 00555 /* s t a t f s R e q u e s t */ 00556 /******************************************************************************/ 00557 00558 // Request: statfs <path> 00559 // 00560 00561 struct CmsStatfsRequest 00562 { CmsRRHdr Hdr; // Modifier used with following options 00563 // kXR_string Path; 00564 00565 enum {kYR_qvfs = 0x0001 // Virtual file system query 00566 }; 00567 }; 00568 00569 /******************************************************************************/ 00570 /* s t a t s R e q u e s t */ 00571 /******************************************************************************/ 00572 00573 // Request: stats or statsz (determined by modifier) 00574 // 00575 00576 struct CmsStatsRequest 00577 { CmsRRHdr Hdr; 00578 00579 enum {kYR_size = 1 // Modifier 00580 }; 00581 }; 00582 00583 /******************************************************************************/ 00584 /* s t a t u s R e q u e s t */ 00585 /******************************************************************************/ 00586 00587 // Request: status 00588 // 00589 struct CmsStatusRequest 00590 { CmsRRHdr Hdr; 00591 00592 enum {kYR_Stage = 0x01, kYR_noStage = 0x02, // Modifier 00593 kYR_Resume = 0x04, kYR_Suspend = 0x08, 00594 kYR_Reset = 0x10 // Exclusive 00595 }; 00596 }; 00597 00598 /******************************************************************************/ 00599 /* t r u n c R e q u e s t */ 00600 /******************************************************************************/ 00601 00602 // Request: <id> trunc <path> 00603 // Respond: n/a 00604 // 00605 struct CmsTruncRequest 00606 { CmsRRHdr Hdr; 00607 // kXR_string Ident; 00608 // kXR_string Size; 00609 // kXR_string Path; 00610 }; 00611 00612 /******************************************************************************/ 00613 /* t r y R e q u e s t */ 00614 /******************************************************************************/ 00615 00616 // Request: try 00617 // 00618 struct CmsTryRequest 00619 { CmsRRHdr Hdr; 00620 kXR_unt16 sLen; // This is the string length in PUP format 00621 00622 // kYR_string {ipaddr:port}[up to STMax]; 00623 00624 enum {kYR_permtop = 0x01 // Modifier Permanent redirect to top level 00625 }; 00626 }; 00627 00628 /******************************************************************************/ 00629 /* u p d a t e R e q u e s t */ 00630 /******************************************************************************/ 00631 00632 // Request: update 00633 // 00634 struct CmsUpdateRequest 00635 { CmsRRHdr Hdr; 00636 }; 00637 00638 /******************************************************************************/ 00639 /* u s a g e R e q u e s t */ 00640 /******************************************************************************/ 00641 00642 // Request: usage 00643 // 00644 struct CmsUsageRequest 00645 { CmsRRHdr Hdr; 00646 }; 00647 00648 }; // namespace XrdCms 00649 #endif