XRootD
Loading...
Searching...
No Matches
XrdNetPMark.hh
Go to the documentation of this file.
1#ifndef __XRDNETPMARK__
2#define __XRDNETPMARK__
3/******************************************************************************/
4/* */
5/* X r d N e t P M a r k . h h */
6/* */
7/* (c) 2021 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 <cstring>
34
35#include <stdlib.h>
36
37class XrdNetAddrInfo;
38class XrdSecEntity;
39
41{
42public:
43
44class Handle
45 {public:
46
47 bool getEA(int &ec, int &ac)
48 {if (Valid()) {ec = eCode; ac = aCode; return true;}
49 ec = ac = 0; return false;
50 }
51 // According to the specifications, ExpID and actID can be equal to 0 for HTTP-TPC.
52 bool Valid() {return (eCode == 0 && aCode == 0)
53 || (eCode >= minExpID && eCode <= maxExpID
54 && aCode >= minActID && aCode <= maxActID);}
55
56 Handle(const char *app=0, int ecode=0, int acode=0)
57 : appName(strdup(app ? app : "unknown")),
58 eCode(ecode), aCode(acode) {}
59
61 : appName(strdup(h.appName)), eCode(h.eCode),
62 aCode(h.aCode) {}
63
64 virtual ~Handle() {if(appName) free(appName);}
65
66 protected:
67 char* appName;
68 int eCode;
69 int aCode;
70 };
71
72virtual Handle *Begin(XrdSecEntity &Client, const char *path=0,
73 const char *cgi=0,
74 const char *app=0) = 0;
75
76virtual Handle *Begin(XrdNetAddrInfo &addr, Handle &handle,
77 const char *tident) = 0;
78
79static bool getEA(const char *cgi, int &ecode, int &acode);
80
82virtual ~XrdNetPMark() {} // This object cannot be deleted!
83
84// ID limits and specifications
85//
89static const int minTotID = 65;
90static const int maxTotID = 65535;
91
92protected:
93
94static const int btsActID = 6;
95static const int mskActID = 63;
96static const int minExpID = minTotID >> btsActID;
97static const int minActID = minTotID & mskActID;
98static const int maxExpID = maxTotID >> btsActID;
99static const int maxActID = maxTotID & mskActID;
100
101};
102#endif
#define tident
bool getEA(int &ec, int &ac)
Handle(const char *app=0, int ecode=0, int acode=0)
virtual Handle * Begin(XrdNetAddrInfo &addr, Handle &handle, const char *tident)=0
static const int minTotID
static bool getEA(const char *cgi, int &ecode, int &acode)
static const int btsActID
static const int maxExpID
static const int minActID
virtual ~XrdNetPMark()
static const int maxActID
static const int maxTotID
virtual Handle * Begin(XrdSecEntity &Client, const char *path=0, const char *cgi=0, const char *app=0)=0
static const int mskActID
static const int minExpID