xrootd
XrdSsiRRInfo.hh
Go to the documentation of this file.
1 #ifndef _XRDSSIRRINFO_H
2 #define _XRDSSIRRINFO_H
3 /******************************************************************************/
4 /* */
5 /* X r d S s i R R I n f o . h h */
6 /* */
7 /* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <arpa/inet.h>
34 
35 #include "XrdSsi/XrdSsiRespInfo.hh"
36 
38 {
39 public:
40 
41 static const unsigned int idMax = 16777215;
42 
43 enum Opc {Rxq = 0, Rwt = 1, Can = 2};
44 
45 inline void Cmd(Opc cmd)
46  {reqCmd = static_cast<unsigned char>(cmd);}
47 
48 inline Opc Cmd() {return static_cast<Opc>(reqCmd);}
49 
50 inline const unsigned char *Data() {return &reqCmd;}
51 
52 inline void Id(unsigned int id)
53  {unsigned char tmp = reqCmd;
54  reqId = htonl(id & idMask);
55  reqCmd = tmp;
56  }
57 
58 inline unsigned int Id() {return ntohl(reqId) & idMask;}
59 
60 inline void Size(unsigned int sz) {reqSize = htonl(sz);}
61 
62 inline unsigned int Size() {return ntohl(reqSize);}
63 
64 inline unsigned long long Info()
65  {return (static_cast<unsigned long long>(reqId & 0xffffffff) <<32LL)
66  |(static_cast<unsigned long long>(reqSize & 0xffffffff));
67 
68  }
69 
70  XrdSsiRRInfo(unsigned long long ival=0)
71  : reqId(static_cast<unsigned int>( (ival>>32) & 0xffffffff)),
72  reqSize(static_cast<unsigned int>(ival & 0xffffffff)) {}
73 
75 
76 private:
77 static const int idMask = 0x00ffffff;
78 
79 union {unsigned char reqCmd;
80  unsigned int reqId;
81  };
82  unsigned int reqSize;
83 };
84 
85 /******************************************************************************/
86 /* X r d S s i R R I n f o A t t n */
87 /******************************************************************************/
88 
90 {
91 static const int alrtResp = '!'; // In tag: response data is an alert
92 static const int fullResp = ':'; // In tag: response data is present
93 static const int pendResp = '*'; // In tag: response data is pending
94 
95  char tag;
96  char flags;
97 unsigned short pfxLen; // Length of prefix
98 unsigned int mdLen; // Length of metadata
99  int rsvd1;
100  int rsvd2;
101 };
102 #endif
void Cmd(Opc cmd)
Definition: XrdSsiRRInfo.hh:45
unsigned long long Info()
Definition: XrdSsiRRInfo.hh:64
static const int pendResp
Definition: XrdSsiRRInfo.hh:93
static const int alrtResp
Definition: XrdSsiRRInfo.hh:91
Opc
Definition: XrdSsiRRInfo.hh:43
~XrdSsiRRInfo()
Definition: XrdSsiRRInfo.hh:74
void Size(unsigned int sz)
Definition: XrdSsiRRInfo.hh:60
const unsigned char * Data()
Definition: XrdSsiRRInfo.hh:50
int rsvd2
Definition: XrdSsiRRInfo.hh:100
static const unsigned int idMax
Definition: XrdSsiRRInfo.hh:41
Definition: XrdSsiRRInfo.hh:37
XrdSsiRRInfo(unsigned long long ival=0)
Definition: XrdSsiRRInfo.hh:70
unsigned int mdLen
Definition: XrdSsiRRInfo.hh:98
unsigned int Id()
Definition: XrdSsiRRInfo.hh:58
unsigned int reqId
Definition: XrdSsiRRInfo.hh:80
Definition: XrdSsiRRInfo.hh:89
char flags
Definition: XrdSsiRRInfo.hh:96
static const int fullResp
Definition: XrdSsiRRInfo.hh:92
Definition: XrdSsiRRInfo.hh:43
Definition: XrdSsiRRInfo.hh:43
char tag
Definition: XrdSsiRRInfo.hh:95
unsigned char reqCmd
Definition: XrdSsiRRInfo.hh:79
unsigned short pfxLen
Definition: XrdSsiRRInfo.hh:97
unsigned int reqSize
Definition: XrdSsiRRInfo.hh:82
static const int idMask
Definition: XrdSsiRRInfo.hh:77
Opc Cmd()
Definition: XrdSsiRRInfo.hh:48
unsigned int Size()
Definition: XrdSsiRRInfo.hh:62
int rsvd1
Definition: XrdSsiRRInfo.hh:99
void Id(unsigned int id)
Definition: XrdSsiRRInfo.hh:52
Definition: XrdSsiRRInfo.hh:43