xrootd
XrdSecsssEnt.hh
Go to the documentation of this file.
1 #ifndef __SecsssEnt__
2 #define __SecsssEnt__
3 /******************************************************************************/
4 /* */
5 /* X r d S e c s s s E n t . h h */
6 /* */
7 /* (c) 2020 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 <set>
34 #include <string>
35 #include <stdlib.h>
36 
37 #include "XrdSys/XrdSysAtomics.hh"
38 #include "XrdSys/XrdSysPthread.hh"
39 
40 class XrdSecEntity;
41 
43 {
44 public:
45 
46 char *eData; // -> RR
47 int iLen; // Length of V1 data
48 int tLen; // Length of V1 plus V2 data (follows iLen)
49 
50 //-----------------------------------------------------------------------------
54 //-----------------------------------------------------------------------------
55 
56 void AddContact(const std::string &hostID);
57 
58 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
61 
62 void Delete();
63 
64 //-----------------------------------------------------------------------------
75 //-----------------------------------------------------------------------------
76 
77 static const int addExtra = 0x00000001;
78 static const int addCreds = 0x00000002;
79 static const int v2Client = 0x00000003;
80 
81 int RR_Data(char *&dP, const char *hostIP, int dataOpts);
82 
83 
85 
86 void UnRef()
87  {AtomicBeg(eMtx);
88  int x = AtomicDec(refCnt);
89  AtomicEnd(eMtx);
90  if (x < 1) delete this;
91  }
92 
93 static void setHostName(const char *hnP);
94 
95  XrdSecsssEnt(const XrdSecEntity *entity=0, bool defer=false)
96  : eData(0), iLen(0), tLen(0), eP(entity), refCnt(1)
97  {if (!defer) Serialize();}
98 
99 //-----------------------------------------------------------------------------
101 //-----------------------------------------------------------------------------
102 
103 private:
104  ~XrdSecsssEnt() {if (eData) free(eData);}
105 
106 bool Serialize();
107 
108 #ifndef HAVE_ATOMICS
110 #endif
111 std::set<std::string> Contacts;
112 
113 const
115 int refCnt;
116 short credLen;
117 
118 static char *myHostName;
119 static int myHostNLen;
120 };
121 #endif
short credLen
Definition: XrdSecsssEnt.hh:116
#define AtomicInc(x)
Definition: XrdSysAtomics.hh:72
std::set< std::string > Contacts
Definition: XrdSecsssEnt.hh:111
void UnRef()
Definition: XrdSecsssEnt.hh:86
int iLen
Definition: XrdSecsssEnt.hh:47
int tLen
Definition: XrdSecsssEnt.hh:48
static char * myHostName
Definition: XrdSecsssEnt.hh:118
static const int addExtra
Add v2 data.
Definition: XrdSecsssEnt.hh:77
bool Serialize()
~XrdSecsssEnt()
Destructor cannot be directly called; use Delete() instead.
Definition: XrdSecsssEnt.hh:104
void Ref()
Definition: XrdSecsssEnt.hh:84
XrdSecsssEnt(const XrdSecEntity *entity=0, bool defer=false)
Definition: XrdSecsssEnt.hh:95
#define AtomicBeg(Mtx)
Definition: XrdSysAtomics.hh:63
#define AtomicDec(x)
Definition: XrdSysAtomics.hh:68
Definition: XrdSysPthread.hh:165
#define AtomicEnd(Mtx)
Definition: XrdSysAtomics.hh:64
int RR_Data(char *&dP, const char *hostIP, int dataOpts)
static const int v2Client
Data for a v2 client wanted.
Definition: XrdSecsssEnt.hh:79
static void setHostName(const char *hnP)
void Delete()
Delete this entity object.
XrdSysMutex eMtx
Definition: XrdSecsssEnt.hh:109
char * eData
Definition: XrdSecsssEnt.hh:46
const XrdSecEntity * eP
Definition: XrdSecsssEnt.hh:114
static int myHostNLen
Definition: XrdSecsssEnt.hh:119
Definition: XrdSecEntity.hh:63
void AddContact(const std::string &hostID)
int refCnt
Definition: XrdSecsssEnt.hh:115
Definition: XrdSecsssEnt.hh:42
static const int addCreds
Add v2 data plus creds.
Definition: XrdSecsssEnt.hh:78