File indexing completed on 2025-01-30 10:27:52
0001 #ifndef __XPROTOCOL_H
0002 #define __XPROTOCOL_H
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 #ifdef __CINT__
0056 #define __attribute__(x)
0057 #endif
0058
0059 #include "XProtocol/XPtypes.hh"
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 #define kXR_PROTOCOLVERSION 0x00000511
0071 #define kXR_PROTXATTVERSION 0x00000500
0072 #define kXR_PROTTLSVERSION 0x00000500
0073 #define kXR_PROTPGRWVERSION 0x00000511
0074 #define kXR_PROTSIGNVERSION 0x00000310
0075 #define kXR_PROTOCOLVSTRING "5.1.0"
0076
0077
0078
0079
0080
0081
0082
0083 struct ClientInitHandShake {
0084 kXR_int32 first;
0085 kXR_int32 second;
0086 kXR_int32 third;
0087 kXR_int32 fourth;
0088 kXR_int32 fifth;
0089 };
0090
0091
0092
0093 struct ServerInitHandShake {
0094 kXR_int32 msglen;
0095 kXR_int32 protover;
0096 kXR_int32 msgval;
0097 };
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 enum XRequestTypes {
0111 kXR_1stRequest= 3000,
0112 kXR_auth = 3000,
0113 kXR_query,
0114 kXR_chmod,
0115 kXR_close,
0116 kXR_dirlist,
0117 kXR_gpfile,
0118 kXR_protocol,
0119 kXR_login,
0120 kXR_mkdir,
0121 kXR_mv,
0122 kXR_open,
0123 kXR_ping,
0124 kXR_chkpoint,
0125 kXR_read,
0126 kXR_rm,
0127 kXR_rmdir,
0128 kXR_sync,
0129 kXR_stat,
0130 kXR_set,
0131 kXR_write,
0132 kXR_fattr,
0133 kXR_prepare,
0134 kXR_statx,
0135 kXR_endsess,
0136 kXR_bind,
0137 kXR_readv,
0138 kXR_pgwrite,
0139 kXR_locate,
0140 kXR_truncate,
0141 kXR_sigver,
0142 kXR_pgread,
0143 kXR_writev,
0144 kXR_REQFENCE
0145 };
0146
0147
0148
0149 enum XVirtRequestTypes {
0150 kXR_virtReadv = 2000
0151 };
0152
0153
0154
0155 struct ClientRequestHdr {
0156 kXR_char streamid[2];
0157 kXR_unt16 requestid;
0158 kXR_char body[16];
0159 kXR_int32 dlen;
0160 };
0161
0162
0163
0164
0165
0166 struct ClientAuthRequest {
0167 kXR_char streamid[2];
0168 kXR_unt16 requestid;
0169 kXR_char reserved[12];
0170 kXR_char credtype[4];
0171 kXR_int32 dlen;
0172 };
0173
0174
0175
0176
0177
0178 struct ClientBindRequest {
0179 kXR_char streamid[2];
0180 kXR_unt16 requestid;
0181 kXR_char sessid[16];
0182 kXR_int32 dlen;
0183 };
0184
0185
0186
0187
0188
0189 struct ClientChmodRequest {
0190 kXR_char streamid[2];
0191 kXR_unt16 requestid;
0192 kXR_char reserved[14];
0193 kXR_unt16 mode;
0194 kXR_int32 dlen;
0195 };
0196
0197
0198
0199
0200
0201 struct ClientChkPointRequest {
0202 kXR_char streamid[2];
0203 kXR_unt16 requestid;
0204 kXR_char fhandle[4];
0205 kXR_char reserved[11];
0206 kXR_char opcode;
0207 kXR_int32 dlen;
0208 };
0209
0210
0211
0212 static const int kXR_ckpBegin = 0;
0213 static const int kXR_ckpCommit = 1;
0214 static const int kXR_ckpQuery = 2;
0215 static const int kXR_ckpRollback= 3;
0216 static const int kXR_ckpXeq = 4;
0217
0218
0219
0220 static const int kXR_ckpMinMax = 104857604;
0221
0222
0223
0224
0225
0226 struct ClientCloseRequest {
0227 kXR_char streamid[2];
0228 kXR_unt16 requestid;
0229 kXR_char fhandle[4];
0230 kXR_char reserved[12];
0231 kXR_int32 dlen;
0232 };
0233
0234
0235
0236
0237
0238 enum XDirlistRequestOption {
0239 kXR_online = 1,
0240 kXR_dstat = 2,
0241 kXR_dcksm = 4
0242 };
0243
0244 struct ClientDirlistRequest {
0245 kXR_char streamid[2];
0246 kXR_unt16 requestid;
0247 kXR_char reserved[15];
0248 kXR_char options[1];
0249 kXR_int32 dlen;
0250 };
0251
0252
0253
0254
0255
0256 struct ClientEndsessRequest {
0257 kXR_char streamid[2];
0258 kXR_unt16 requestid;
0259 kXR_char sessid[16];
0260 kXR_int32 dlen;
0261 };
0262
0263
0264
0265
0266
0267
0268
0269 enum xfaSubCode {
0270 kXR_fattrDel = 0,
0271 kXR_fattrGet = 1,
0272 kXR_fattrList = 2,
0273 kXR_fattrSet = 3,
0274 kXR_fatrrMaxSC = 3
0275 };
0276
0277
0278
0279 enum xfaLimits {
0280 kXR_faMaxVars = 16,
0281 kXR_faMaxNlen = 248,
0282 kXR_faMaxVlen = 65536
0283 };
0284
0285 struct ClientFattrRequest {
0286 kXR_char streamid[2];
0287 kXR_unt16 requestid;
0288 kXR_char fhandle[4];
0289 kXR_char subcode;
0290 kXR_char numattr;
0291 kXR_char options;
0292 kXR_char reserved[9];
0293 kXR_int32 dlen;
0294
0295
0296
0297 static const int isNew = 0x01;
0298 static const int aData = 0x10;
0299
0300
0301
0302 static char* NVecInsert( const char *name, char *buffer );
0303
0304
0305
0306 static char* VVecInsert( const char *value, char *buffer );
0307
0308
0309
0310 static char* NVecRead( char* buffer, kXR_unt16 &rc );
0311
0312
0313
0314 static char* NVecRead( char* buffer, char *&name );
0315
0316
0317
0318 static char* VVecRead( char* buffer, kXR_int32 &len );
0319
0320
0321
0322 static char* VVecRead( char* buffer, kXR_int32 len, char *&value );
0323
0324 };
0325
0326
0327
0328
0329
0330 struct ClientGPfileRequest {
0331 kXR_char streamid[2];
0332 kXR_unt16 requestid;
0333 kXR_int32 options;
0334 kXR_char reserved[8];
0335 kXR_int32 buffsz;
0336 kXR_int32 dlen;
0337 };
0338
0339
0340
0341
0342
0343 struct ClientLocateRequest {
0344 kXR_char streamid[2];
0345 kXR_unt16 requestid;
0346 kXR_unt16 options;
0347 kXR_char reserved[14];
0348 kXR_int32 dlen;
0349 };
0350
0351
0352
0353
0354
0355
0356 enum XLoginAbility {
0357 kXR_nothing = 0,
0358 kXR_fullurl = 1,
0359 kXR_multipr = 3,
0360 kXR_readrdok = 4,
0361 kXR_hasipv64 = 8,
0362 kXR_onlyprv4 = 16,
0363 kXR_onlyprv6 = 32,
0364 kXR_lclfile = 64,
0365 kXR_redirflags = 128
0366 };
0367
0368
0369 enum XLoginAbility2 {
0370 kXR_empty = 0,
0371 kXR_ecredir = 1
0372 };
0373
0374
0375 enum XLoginCapVer {
0376 kXR_lcvnone = 0,
0377 kXR_vermask = 63,
0378 kXR_asyncap = 128
0379 };
0380
0381
0382
0383 enum XLoginVersion {
0384 kXR_ver000 = 0,
0385 kXR_ver001 = 1,
0386 kXR_ver002 = 2,
0387 kXR_ver003 = 3,
0388 kXR_ver004 = 4,
0389 kXR_ver005 = 5
0390 };
0391
0392 struct ClientLoginRequest {
0393 kXR_char streamid[2];
0394 kXR_unt16 requestid;
0395 kXR_int32 pid;
0396 kXR_char username[8];
0397 kXR_char ability2;
0398 kXR_char ability;
0399 kXR_char capver[1];
0400 kXR_char reserved2;
0401 kXR_int32 dlen;
0402 };
0403
0404
0405
0406
0407
0408 enum XMkdirOptions {
0409 kXR_mknone = 0,
0410 kXR_mkdirpath = 1
0411 };
0412
0413 struct ClientMkdirRequest {
0414 kXR_char streamid[2];
0415 kXR_unt16 requestid;
0416 kXR_char options[1];
0417 kXR_char reserved[13];
0418 kXR_unt16 mode;
0419 kXR_int32 dlen;
0420 };
0421
0422
0423
0424
0425
0426 struct ClientMvRequest {
0427 kXR_char streamid[2];
0428 kXR_unt16 requestid;
0429 kXR_char reserved[14];
0430 kXR_int16 arg1len;
0431 kXR_int32 dlen;
0432 };
0433
0434
0435
0436
0437
0438
0439 enum XOpenRequestMode {
0440 kXR_ur = 0x100,
0441 kXR_uw = 0x080,
0442 kXR_ux = 0x040,
0443 kXR_gr = 0x020,
0444 kXR_gw = 0x010,
0445 kXR_gx = 0x008,
0446 kXR_or = 0x004,
0447 kXR_ow = 0x002,
0448 kXR_ox = 0x001
0449 };
0450
0451 enum XOpenRequestOption {
0452 kXR_compress = 0x0001,
0453 kXR_delete = 0x0002,
0454 kXR_force = 0x0004,
0455 kXR_new = 0x0008,
0456 kXR_open_read= 0x0010,
0457 kXR_open_updt= 0x0020,
0458 kXR_async = 0x0040,
0459 kXR_refresh = 0x0080,
0460 kXR_mkpath = 0x0100,
0461 kXR_prefname = 0x0100,
0462 kXR_open_apnd= 0x0200,
0463 kXR_retstat = 0x0400,
0464 kXR_4dirlist = 0x0400,
0465 kXR_replica = 0x0800,
0466 kXR_posc = 0x1000,
0467 kXR_nowait = 0x2000,
0468 kXR_seqio = 0x4000,
0469 kXR_open_wrto= 0x8000
0470 };
0471
0472 enum XOpenRequestOption2 {
0473 kXR_dup = 0x0001,
0474 kXR_samefs = 0x0002
0475 };
0476
0477 struct ClientOpenRequest {
0478 kXR_char streamid[2];
0479 kXR_unt16 requestid;
0480 kXR_unt16 mode;
0481 kXR_unt16 options;
0482 kXR_char reserved[12];
0483 kXR_int32 dlen;
0484 };
0485
0486
0487
0488
0489
0490
0491
0492 namespace XrdProto
0493 {
0494 static const int kXR_pgPageSZ = 4096;
0495 static const int kXR_pgPageBL = 12;
0496 static const int kXR_pgUnitSZ = kXR_pgPageSZ + sizeof(kXR_unt32);
0497 static const int kXR_pgMaxEpr = 128;
0498 static const int kXR_pgMaxEos = 256;
0499
0500
0501
0502 static const kXR_char kXR_AnyPath = 0xff;
0503 static const int kXR_pgRetry = 0x01;
0504 }
0505
0506 struct ClientPgReadRequest {
0507 kXR_char streamid[2];
0508 kXR_unt16 requestid;
0509 kXR_char fhandle[4];
0510 kXR_int64 offset;
0511 kXR_int32 rlen;
0512 kXR_int32 dlen;
0513 };
0514
0515 struct ClientPgReadReqArgs {
0516 kXR_char pathid;
0517 kXR_char reqflags;
0518 };
0519
0520 namespace
0521 {
0522 }
0523
0524
0525
0526
0527
0528 struct ClientPgWriteRequest {
0529 kXR_char streamid[2];
0530 kXR_unt16 requestid;
0531 kXR_char fhandle[4];
0532 kXR_int64 offset;
0533 kXR_char pathid;
0534 kXR_char reqflags;
0535 kXR_char reserved[2];
0536 kXR_int32 dlen;
0537
0538 };
0539
0540
0541
0542
0543
0544 struct ClientPingRequest {
0545 kXR_char streamid[2];
0546 kXR_unt16 requestid;
0547 kXR_char reserved[16];
0548 kXR_int32 dlen;
0549 };
0550
0551
0552
0553
0554
0555 struct ClientProtocolRequest {
0556 kXR_char streamid[2];
0557 kXR_unt16 requestid;
0558 kXR_int32 clientpv;
0559 kXR_char flags;
0560 kXR_char expect;
0561 kXR_char reserved[10];
0562 kXR_int32 dlen;
0563
0564 enum RequestFlags {
0565 kXR_secreqs = 0x01,
0566 kXR_ableTLS = 0x02,
0567 kXR_wantTLS = 0x04,
0568 kXR_bifreqs = 0x08
0569 };
0570
0571 enum ExpectFlags {
0572 kXR_ExpMask = 0x0f,
0573 kXR_ExpNone = 0x00,
0574 kXR_ExpBind = 0x01,
0575 kXR_ExpGPF = 0x02,
0576 kXR_ExpLogin = 0x03,
0577 kXR_ExpTPC = 0x04,
0578 kXR_ExpGPFA = 0x08
0579 };
0580 };
0581
0582
0583
0584
0585
0586 enum XPrepRequestOption {
0587 kXR_cancel = 1,
0588 kXR_notify = 2,
0589 kXR_noerrs = 4,
0590 kXR_stage = 8,
0591 kXR_wmode = 16,
0592 kXR_coloc = 32,
0593 kXR_fresh = 64,
0594 kXR_usetcp = 128,
0595
0596 kXR_evict = 0x0001
0597 };
0598
0599 struct ClientPrepareRequest {
0600 kXR_char streamid[2];
0601 kXR_unt16 requestid;
0602 kXR_char options;
0603 kXR_char prty;
0604 kXR_unt16 port;
0605 kXR_unt16 optionX;
0606 kXR_char reserved[10];
0607 kXR_int32 dlen;
0608 };
0609
0610
0611
0612
0613
0614 enum XQueryType {
0615 kXR_QStats = 1,
0616 kXR_QPrep = 2,
0617 kXR_Qcksum = 3,
0618 kXR_Qxattr = 4,
0619 kXR_Qspace = 5,
0620 kXR_Qckscan= 6,
0621 kXR_Qconfig= 7,
0622 kXR_Qvisa = 8,
0623 kXR_Qopaque=16,
0624 kXR_Qopaquf=32,
0625 kXR_Qopaqug=64
0626 };
0627
0628 struct ClientQueryRequest {
0629 kXR_char streamid[2];
0630 kXR_unt16 requestid;
0631 kXR_unt16 infotype;
0632 kXR_char reserved1[2];
0633 kXR_char fhandle[4];
0634 kXR_char reserved2[8];
0635 kXR_int32 dlen;
0636 };
0637
0638
0639
0640
0641
0642 struct ClientReadRequest {
0643 kXR_char streamid[2];
0644 kXR_unt16 requestid;
0645 kXR_char fhandle[4];
0646 kXR_int64 offset;
0647 kXR_int32 rlen;
0648 kXR_int32 dlen;
0649
0650 };
0651
0652 struct read_args {
0653 kXR_char pathid;
0654 kXR_char reserved[7];
0655
0656 };
0657
0658 struct readahead_list {
0659 kXR_char fhandle[4];
0660 kXR_int32 rlen;
0661 kXR_int64 offset;
0662 };
0663
0664
0665
0666
0667
0668 struct ClientReadVRequest {
0669 kXR_char streamid[2];
0670 kXR_unt16 requestid;
0671 kXR_char reserved[15];
0672 kXR_char pathid;
0673 kXR_int32 dlen;
0674
0675 };
0676
0677 namespace XrdProto
0678 {
0679 struct read_list {
0680 kXR_char fhandle[4];
0681 kXR_int32 rlen;
0682 kXR_int64 offset;
0683 };
0684 static const int rlItemLen = sizeof(read_list);
0685 static const int maxRvecln = 16384;
0686 static const int maxRvecsz = maxRvecln/rlItemLen;
0687 }
0688
0689
0690
0691
0692
0693 struct ClientRmRequest {
0694 kXR_char streamid[2];
0695 kXR_unt16 requestid;
0696 kXR_char reserved[16];
0697 kXR_int32 dlen;
0698 };
0699
0700
0701
0702
0703
0704 struct ClientRmdirRequest {
0705 kXR_char streamid[2];
0706 kXR_unt16 requestid;
0707 kXR_char reserved[16];
0708 kXR_int32 dlen;
0709 };
0710
0711
0712
0713
0714
0715 struct ClientSetRequest {
0716 kXR_char streamid[2];
0717 kXR_unt16 requestid;
0718 kXR_char reserved[15];
0719 kXR_char modifier;
0720 kXR_int32 dlen;
0721 };
0722
0723
0724
0725
0726
0727
0728 enum XSecCrypto {
0729 kXR_SHA256 = 0x01,
0730 kXR_HashMask = 0x0f,
0731 kXR_rsaKey = 0x80
0732 };
0733
0734
0735 enum XSecFlags {
0736 kXR_nodata = 1
0737 };
0738
0739
0740 enum XSecVersion {
0741 kXR_Ver_00 = 0
0742 };
0743
0744 struct ClientSigverRequest {
0745 kXR_char streamid[2];
0746 kXR_unt16 requestid;
0747 kXR_unt16 expectrid;
0748 kXR_char version;
0749 kXR_char flags;
0750 kXR_unt64 seqno;
0751 kXR_char crypto;
0752 kXR_char rsvd2[3];
0753 kXR_int32 dlen;
0754 };
0755
0756
0757
0758
0759
0760 enum XStatRequestOption {
0761 kXR_vfs = 1
0762 };
0763
0764 struct ClientStatRequest {
0765 kXR_char streamid[2];
0766 kXR_unt16 requestid;
0767 kXR_char options;
0768 kXR_char reserved[11];
0769 kXR_char fhandle[4];
0770 kXR_int32 dlen;
0771 };
0772
0773
0774
0775
0776
0777 struct ClientSyncRequest {
0778 kXR_char streamid[2];
0779 kXR_unt16 requestid;
0780 kXR_char fhandle[4];
0781 kXR_char reserved[12];
0782 kXR_int32 dlen;
0783 };
0784
0785
0786
0787
0788
0789 struct ClientTruncateRequest {
0790 kXR_char streamid[2];
0791 kXR_unt16 requestid;
0792 kXR_char fhandle[4];
0793 kXR_int64 offset;
0794 kXR_char reserved[4];
0795 kXR_int32 dlen;
0796 };
0797
0798
0799
0800
0801
0802 struct ClientWriteRequest {
0803 kXR_char streamid[2];
0804 kXR_unt16 requestid;
0805 kXR_char fhandle[4];
0806 kXR_int64 offset;
0807 kXR_char pathid;
0808 kXR_char reserved[3];
0809 kXR_int32 dlen;
0810 };
0811
0812
0813
0814
0815
0816 struct ClientWriteVRequest {
0817 kXR_char streamid[2];
0818 kXR_unt16 requestid;
0819 kXR_char options;
0820 kXR_char reserved[15];
0821 kXR_int32 dlen;
0822
0823
0824 static const kXR_int32 doSync = 0x01;
0825 };
0826
0827 namespace XrdProto
0828 {
0829 struct write_list {
0830 kXR_char fhandle[4];
0831 kXR_int32 wlen;
0832 kXR_int64 offset;
0833 };
0834 static const int wlItemLen = sizeof(write_list);
0835 static const int maxWvecln = 16384;
0836 static const int maxWvecsz = maxWvecln/wlItemLen;
0837 }
0838
0839
0840
0841
0842
0843 typedef union {
0844 struct ClientRequestHdr header;
0845 struct ClientAuthRequest auth;
0846 struct ClientBindRequest bind;
0847 struct ClientChkPointRequest chkpoint;
0848 struct ClientChmodRequest chmod;
0849 struct ClientCloseRequest close;
0850 struct ClientDirlistRequest dirlist;
0851 struct ClientEndsessRequest endsess;
0852 struct ClientFattrRequest fattr;
0853 struct ClientGPfileRequest gpfile;
0854 struct ClientLocateRequest locate;
0855 struct ClientLoginRequest login;
0856 struct ClientMkdirRequest mkdir;
0857 struct ClientMvRequest mv;
0858 struct ClientOpenRequest open;
0859 struct ClientPgReadRequest pgread;
0860 struct ClientPgWriteRequest pgwrite;
0861 struct ClientPingRequest ping;
0862 struct ClientPrepareRequest prepare;
0863 struct ClientProtocolRequest protocol;
0864 struct ClientQueryRequest query;
0865 struct ClientReadRequest read;
0866 struct ClientReadVRequest readv;
0867 struct ClientRmRequest rm;
0868 struct ClientRmdirRequest rmdir;
0869 struct ClientSetRequest set;
0870 struct ClientSigverRequest sigver;
0871 struct ClientStatRequest stat;
0872 struct ClientSyncRequest sync;
0873 struct ClientTruncateRequest truncate;
0874 struct ClientWriteRequest write;
0875 struct ClientWriteVRequest writev;
0876 } ClientRequest;
0877
0878 typedef union {
0879 struct ClientRequestHdr header;
0880 struct ClientSigverRequest sigver;
0881 } SecurityRequest;
0882
0883
0884
0885
0886
0887
0888
0889
0890
0891
0892
0893
0894
0895
0896 enum XResponseType {
0897 kXR_ok = 0,
0898 kXR_oksofar = 4000,
0899 kXR_attn,
0900 kXR_authmore,
0901 kXR_error,
0902 kXR_redirect,
0903 kXR_wait,
0904 kXR_waitresp,
0905 kXR_status,
0906 kXR_noResponsesYet = 10000
0907 };
0908
0909
0910
0911 struct ServerResponseHeader {
0912 kXR_char streamid[2];
0913 kXR_unt16 status;
0914 kXR_int32 dlen;
0915 };
0916
0917
0918
0919 struct ServerResponseBody_Buffer {
0920 char data[4096];
0921 };
0922
0923
0924
0925
0926
0927 enum XActionCode {
0928 kXR_asyncab = 5000,
0929 kXR_asyncdi,
0930 kXR_asyncms = 5002,
0931 kXR_asyncrd,
0932 kXR_asyncwt,
0933 kXR_asyncav,
0934 kXR_asynunav,
0935 kXR_asyncgo,
0936 kXR_asynresp= 5008
0937 };
0938
0939 struct ServerResponseBody_Attn {
0940 kXR_int32 actnum;
0941 char parms[4096];
0942 };
0943
0944 struct ServerResponseBody_Attn_asyncms {
0945 kXR_int32 actnum;
0946 char reserved[4];
0947 ServerResponseHeader resphdr;
0948 char respdata[4096];
0949 };
0950
0951 struct ServerResponseBody_Attn_asynresp {
0952 kXR_int32 actnum;
0953 char reserved[4];
0954 ServerResponseHeader resphdr;
0955 char respdata[4096];
0956 };
0957
0958
0959
0960
0961
0962 struct ServerResponseBody_Authmore {
0963 char data[4096];
0964 };
0965
0966
0967
0968
0969
0970 struct ServerResponseBody_Bind {
0971 kXR_char substreamid;
0972 };
0973
0974
0975
0976
0977
0978 struct ServerResponseBody_ChkPoint {
0979 kXR_unt32 maxCkpSize;
0980 kXR_unt32 useCkpSize;
0981 };
0982
0983
0984
0985
0986
0987 enum XErrorCode {
0988 kXR_ArgInvalid = 3000,
0989 kXR_ArgMissing,
0990 kXR_ArgTooLong,
0991 kXR_FileLocked,
0992 kXR_FileNotOpen,
0993 kXR_FSError,
0994 kXR_InvalidRequest,
0995 kXR_IOError,
0996 kXR_NoMemory,
0997 kXR_NoSpace,
0998 kXR_NotAuthorized,
0999 kXR_NotFound,
1000 kXR_ServerError,
1001 kXR_Unsupported,
1002 kXR_noserver,
1003 kXR_NotFile,
1004 kXR_isDirectory,
1005 kXR_Cancelled,
1006 kXR_ItExists,
1007 kXR_ChkSumErr,
1008 kXR_inProgress,
1009 kXR_overQuota,
1010 kXR_SigVerErr,
1011 kXR_DecryptErr,
1012 kXR_Overloaded,
1013 kXR_fsReadOnly,
1014 kXR_BadPayload,
1015 kXR_AttrNotFound,
1016 kXR_TLSRequired,
1017 kXR_noReplicas,
1018 kXR_AuthFailed,
1019 kXR_Impossible,
1020 kXR_Conflict,
1021 kXR_TooManyErrs,
1022 kXR_ReqTimedOut,
1023 kXR_TimerExpired,
1024 kXR_ERRFENCE,
1025 kXR_noErrorYet = 10000
1026 };
1027
1028 struct ServerResponseBody_Error {
1029 kXR_int32 errnum;
1030 char errmsg[4096];
1031 };
1032
1033
1034
1035
1036
1037 struct ServerResponseBody_Login {
1038 kXR_char sessid[16];
1039 kXR_char sec[4096];
1040 };
1041
1042
1043
1044
1045
1046 struct ServerResponseBody_Open {
1047 kXR_char fhandle[4];
1048 kXR_int32 cpsize;
1049 kXR_char cptype[4];
1050 };
1051
1052
1053
1054
1055
1056 struct ServerResponseBody_pgRead {
1057 kXR_int64 offset;
1058
1059 };
1060
1061
1062
1063
1064
1065 struct ServerResponseBody_pgWrite {
1066 kXR_int64 offset;
1067 };
1068
1069
1070
1071
1072
1073 struct ServerResponseBody_pgWrCSE {
1074 kXR_unt32 cseCRC;
1075 kXR_int16 dlFirst;
1076 kXR_int16 dlLast;
1077
1078 };
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089 struct ServerResponseBifs_Protocol {
1090 kXR_char theTag;
1091 kXR_char rsvd;
1092 kXR_unt16 bifILen;
1093
1094 };
1095
1096
1097
1098
1099
1100 struct ServerResponseSVec_Protocol {
1101 kXR_char reqindx;
1102 kXR_char reqsreq;
1103 };
1104
1105 struct ServerResponseReqs_Protocol {
1106 kXR_char theTag;
1107 kXR_char rsvd;
1108 kXR_char secver;
1109 kXR_char secopt;
1110 kXR_char seclvl;
1111 kXR_char secvsz;
1112 ServerResponseSVec_Protocol secvec;
1113 };
1114
1115
1116 namespace XrdProto
1117 {
1118 typedef struct ServerResponseBifs_Protocol bifReqs;
1119 typedef struct ServerResponseReqs_Protocol secReqs;
1120 }
1121
1122
1123
1124 #define kXR_secOData 0x01
1125 #define kXR_secOFrce 0x02
1126
1127
1128
1129 #define kXR_secNone 0
1130 #define kXR_secCompatible 1
1131 #define kXR_secStandard 2
1132 #define kXR_secIntense 3
1133 #define kXR_secPedantic 4
1134
1135
1136
1137 #define kXR_signIgnore 0
1138 #define kXR_signLikely 1
1139 #define kXR_signNeeded 2
1140
1141
1142
1143
1144 #define kXR_secver_0 0
1145
1146
1147
1148 #define kXR_DataServer 1
1149 #define kXR_LBalServer 0
1150
1151
1152
1153
1154 #define kXR_isManager 0x00000002
1155 #define kXR_isServer 0x00000001
1156 #define kXR_attrMeta 0x00000100
1157 #define kXR_attrProxy 0x00000200
1158 #define kXR_attrSuper 0x00000400
1159 #define kXR_attrVirtRdr 0x00000800
1160
1161
1162
1163 #define kXR_recoverWrts 0x00001000
1164 #define kXR_collapseRedir 0x00002000
1165 #define kXR_ecRedir 0x00004000
1166
1167
1168
1169 #define kXR_anongpf 0x00800000
1170 #define kXR_supgpf 0x00400000
1171 #define kXR_suppgrw 0x00200000
1172 #define kXR_supposc 0x00100000
1173
1174
1175
1176 #define kXR_haveTLS 0x80000000
1177 #define kXR_gotoTLS 0x40000000
1178 #define kXR_tlsAny 0x1f000000
1179 #define kXR_tlsData 0x01000000
1180 #define kXR_tlsGPF 0x02000000
1181 #define kXR_tlsLogin 0x04000000
1182 #define kXR_tlsSess 0x08000000
1183 #define kXR_tlsTPC 0x10000000
1184 #define kXR_tlsGPFA 0x20000000
1185
1186
1187
1188 struct ServerResponseBody_Protocol {
1189 kXR_int32 pval;
1190 kXR_int32 flags;
1191 ServerResponseReqs_Protocol secreq;
1192 };
1193
1194
1195
1196
1197 #define kXR_ShortProtRespLen sizeof(ServerResponseBody_Protocol)-\
1198 sizeof(ServerResponseReqs_Protocol)
1199
1200
1201
1202
1203
1204 struct ServerResponseBody_Redirect {
1205 kXR_int32 port;
1206 char host[4096];
1207 };
1208
1209
1210
1211
1212
1213
1214
1215 enum XStatRespFlags {
1216 kXR_file = 0,
1217 kXR_xset = 1,
1218 kXR_isDir = 2,
1219 kXR_other = 4,
1220 kXR_offline = 8,
1221 kXR_readable=16,
1222 kXR_writable=32,
1223 kXR_poscpend=64,
1224 kXR_bkpexist=128
1225 };
1226
1227
1228
1229
1230
1231 struct ServerResponseBody_Status {
1232 kXR_unt32 crc32c;
1233 kXR_char streamID[2];
1234 kXR_char requestid;
1235 kXR_char resptype;
1236 kXR_char reserved[4];
1237 kXR_int32 dlen;
1238
1239
1240 };
1241
1242 namespace XrdProto
1243 {
1244 enum RespType {
1245
1246 kXR_FinalResult = 0x00,
1247 kXR_PartialResult = 0x01,
1248 kXR_ProgressInfo = 0x02
1249 };
1250
1251
1252
1253 static const int kXR_statusBodyLen = sizeof(ServerResponseBody_Status);
1254 }
1255
1256 struct ServerResponseStatus {
1257 struct ServerResponseHeader hdr;
1258 struct ServerResponseBody_Status bdy;
1259 };
1260
1261
1262
1263
1264
1265 struct ServerResponseBody_Wait {
1266 kXR_int32 seconds;
1267 char infomsg[4096];
1268 };
1269
1270
1271
1272
1273
1274 struct ServerResponseBody_Waitresp {
1275 kXR_int32 seconds;
1276 };
1277
1278
1279
1280
1281
1282 struct ServerResponse
1283 {
1284 ServerResponseHeader hdr;
1285 union
1286 {
1287 ServerResponseBody_Attn attn;
1288 ServerResponseBody_Authmore authmore;
1289 ServerResponseBody_Bind bind;
1290 ServerResponseBody_Buffer buffer;
1291 ServerResponseBody_Error error;
1292 ServerResponseBody_Login login;
1293 ServerResponseBody_Protocol protocol;
1294 ServerResponseBody_Redirect redirect;
1295 ServerResponseBody_Status status;
1296 ServerResponseBody_Wait wait;
1297 ServerResponseBody_Waitresp waitresp;
1298 } body;
1299 };
1300
1301
1302
1303
1304 struct ServerResponseV2
1305 {
1306 ServerResponseStatus status;
1307 union
1308 {
1309 ServerResponseBody_pgRead pgread;
1310 ServerResponseBody_pgWrite pgwrite;
1311 } info;
1312 };
1313
1314 struct ALIGN_CHECK {char chkszreq[25-sizeof(ClientRequest)];
1315 char chkszrsp[ 9-sizeof(ServerResponseHeader)];
1316 };
1317
1318
1319
1320
1321
1322 #include <cerrno>
1323 #if defined(WIN32)
1324 #if !defined(ENOTBLK)
1325 # define ENOTBLK 15
1326 #endif
1327 #if !defined(ETXTBSY)
1328 #define ETXTBSY 26
1329 #endif
1330 #if !defined(ENOBUFS)
1331 #define ENOBUFS 105
1332 #endif
1333 #if !defined(ENETUNREACH)
1334 #define ENETUNREACH 114
1335 #endif
1336 #endif
1337
1338 #ifndef ENOATTR
1339 #define ENOATTR ENODATA
1340 #endif
1341
1342 #ifndef EBADRQC
1343 #define EBADRQC EBADRPC
1344 #endif
1345
1346 #ifndef EAUTH
1347 #define EAUTH EBADE
1348 #endif
1349
1350 struct stat;
1351
1352 class XProtocol
1353 {
1354 public:
1355
1356
1357
1358 static int mapError(int rc)
1359 {if (rc < 0) rc = -rc;
1360 switch(rc)
1361 {case ENOENT: return kXR_NotFound;
1362 case EINVAL: return kXR_ArgInvalid;
1363 case EPERM: return kXR_NotAuthorized;
1364 case EACCES: return kXR_NotAuthorized;
1365 case EIO: return kXR_IOError;
1366 case ENOMEM: return kXR_NoMemory;
1367 case ENOBUFS: return kXR_NoMemory;
1368 case ENOSPC: return kXR_NoSpace;
1369 case ENAMETOOLONG: return kXR_ArgTooLong;
1370 case ENETUNREACH: return kXR_noserver;
1371 case ENOTBLK: return kXR_NotFile;
1372 case ENOTSUP: return kXR_Unsupported;
1373 case EISDIR: return kXR_isDirectory;
1374 case ENOTEMPTY: [[fallthrough]];
1375
1376
1377
1378 case EEXIST:
1379 return kXR_ItExists;
1380 case EBADRQC: return kXR_InvalidRequest;
1381 case ETXTBSY: return kXR_inProgress;
1382 case ENODEV: return kXR_FSError;
1383 case EFAULT: return kXR_ServerError;
1384 case EDOM: return kXR_ChkSumErr;
1385 case EDQUOT: return kXR_overQuota;
1386 case EILSEQ: return kXR_SigVerErr;
1387 case ERANGE: return kXR_DecryptErr;
1388 case EUSERS: return kXR_Overloaded;
1389 case EROFS: return kXR_fsReadOnly;
1390 case ENOATTR: return kXR_AttrNotFound;
1391 case EPROTOTYPE: return kXR_TLSRequired;
1392 case EADDRNOTAVAIL: return kXR_noReplicas;
1393 case EAUTH: return kXR_AuthFailed;
1394 case EIDRM: return kXR_Impossible;
1395 case ENOTTY: return kXR_Conflict;
1396 case ETOOMANYREFS: return kXR_TooManyErrs;
1397 case ETIMEDOUT: return kXR_ReqTimedOut;
1398 case EBADF: return kXR_FileNotOpen;
1399 case ECANCELED: return kXR_Cancelled;
1400 case ETIME: return kXR_TimerExpired;
1401 default: return kXR_FSError;
1402 }
1403 }
1404
1405 static int toErrno( int xerr )
1406 {
1407 switch(xerr)
1408 {case kXR_ArgInvalid: return EINVAL;
1409 case kXR_ArgMissing: return EINVAL;
1410 case kXR_ArgTooLong: return ENAMETOOLONG;
1411 case kXR_FileLocked: return EDEADLK;
1412 case kXR_FileNotOpen: return EBADF;
1413 case kXR_FSError: return ENODEV;
1414 case kXR_InvalidRequest:return EBADRQC;
1415 case kXR_IOError: return EIO;
1416 case kXR_NoMemory: return ENOMEM;
1417 case kXR_NoSpace: return ENOSPC;
1418 case kXR_NotAuthorized: return EACCES;
1419 case kXR_NotFound: return ENOENT;
1420 case kXR_ServerError: return EFAULT;
1421 case kXR_Unsupported: return ENOTSUP;
1422 case kXR_noserver: return EHOSTUNREACH;
1423 case kXR_NotFile: return ENOTBLK;
1424 case kXR_isDirectory: return EISDIR;
1425 case kXR_Cancelled: return ECANCELED;
1426 case kXR_ItExists: return EEXIST;
1427 case kXR_ChkSumErr: return EDOM;
1428 case kXR_inProgress: return EINPROGRESS;
1429 case kXR_overQuota: return EDQUOT;
1430 case kXR_SigVerErr: return EILSEQ;
1431 case kXR_DecryptErr: return ERANGE;
1432 case kXR_Overloaded: return EUSERS;
1433 case kXR_fsReadOnly: return EROFS;
1434 case kXR_BadPayload: return EINVAL;
1435 case kXR_AttrNotFound: return ENOATTR;
1436 case kXR_TLSRequired: return EPROTOTYPE;
1437 case kXR_noReplicas: return EADDRNOTAVAIL;
1438 case kXR_AuthFailed: return EAUTH;
1439 case kXR_Impossible: return EIDRM;
1440 case kXR_Conflict: return ENOTTY;
1441 case kXR_TooManyErrs: return ETOOMANYREFS;
1442 case kXR_ReqTimedOut: return ETIMEDOUT;
1443 case kXR_TimerExpired: return ETIME;
1444 default: return ENOMSG;
1445 }
1446 }
1447
1448 static const char *errName(kXR_int32 errCode);
1449
1450 static const char *reqName(kXR_unt16 reqCode);
1451
1452
1453
1454
1455
1456 struct ServerResponseBody_Attn_asyncdi {
1457 kXR_int32 actnum;
1458 kXR_int32 wsec;
1459 kXR_int32 msec;
1460 };
1461
1462 struct ServerResponseBody_Attn_asyncrd {
1463 kXR_int32 actnum;
1464 kXR_int32 port;
1465 char host[4092];
1466 };
1467
1468 struct ServerResponseBody_Attn_asyncwt {
1469 kXR_int32 actnum;
1470 kXR_int32 wsec;
1471 };
1472
1473
1474
1475 enum XReqErrorType {
1476 kGENERICERR = 0,
1477 kREAD,
1478 kWRITE,
1479 kREDIRCONNECT,
1480 kOK,
1481 kNOMORESTREAMS
1482
1483 };
1484
1485 typedef kXR_int32 ServerResponseType;
1486
1487 #define kXR_maxReqRetry 10
1488
1489 };
1490 #endif