Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:27:54

0001 #ifndef __XRDNETPMARK__
0002 #define __XRDNETPMARK__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                        X r d N e t P M a r k . h h                         */
0006 /*                                                                            */
0007 /* (c) 2021 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 #include <cstring>
0034 
0035 class XrdNetAddrInfo;
0036 class XrdSecEntity;
0037 
0038 class XrdNetPMark
0039 {
0040 public:
0041 
0042 class Handle
0043      {public:
0044 
0045       bool        getEA(int &ec, int &ac)
0046                        {if (Valid()) {ec = eCode; ac = aCode; return true;}
0047                         ec = ac = 0; return false;
0048                        }
0049                   // According to the specifications, ExpID and actID can be equal to 0 for HTTP-TPC.
0050       bool        Valid() {return (eCode == 0 && aCode == 0) || (eCode >= minExpID && eCode <= maxExpID && aCode >= minActID && aCode <= maxActID);}
0051 
0052                   Handle(const char *app=0, int ecode=0, int acode=0)
0053                         : appName(app), eCode(ecode), aCode(acode) {}
0054 
0055                   Handle(Handle &h)
0056                         : appName(h.appName), eCode(h.eCode), aCode(h.aCode) {};
0057 
0058       virtual    ~Handle() {};
0059 
0060       protected:
0061       const char *appName;
0062       int         eCode;
0063       int         aCode;
0064      };
0065 
0066 virtual Handle *Begin(XrdSecEntity &Client, const char *path=0,
0067                                             const char *cgi=0,
0068                                             const char *app=0) = 0;
0069 
0070 virtual Handle *Begin(XrdNetAddrInfo &addr, Handle     &handle,
0071                                             const char *tident) = 0;
0072 
0073 static  bool    getEA(const char *cgi, int &ecode, int &acode);
0074 
0075                 XrdNetPMark() {}
0076 virtual        ~XrdNetPMark() {} // This object cannot be deleted!
0077 
0078 // ID limits and specifications
0079 //
0080 /**
0081  * From the specifications: Valid value for scitag is a single positive integer > 64 and <65536 (16bit). Any other value is considered invalid.
0082  */
0083 static const int minTotID = 65;
0084 static const int maxTotID = 65535;
0085 
0086 protected:
0087 
0088 static const int btsActID = 6;
0089 static const int mskActID = 63;
0090 static const int minExpID = minTotID >> btsActID;
0091 static const int minActID = minTotID & mskActID;
0092 static const int maxExpID = maxTotID >> btsActID;
0093 static const int maxActID = maxTotID & mskActID;
0094 
0095 };
0096 #endif