Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:56:04

0001 #ifndef __XRDXROOTDREDIRPI__
0002 #define __XRDXROOTDREDIRPI__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                   X r d X r o o t d R e d i r P I . h h                    */
0006 /*                                                                            */
0007 /* (c) 2024 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0009 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0010 /*                                                                            */
0011 /* This file is part of the XRootD software suite.                            */
0012 /*                                                                            */
0013 /* XRootD is free software: you can redistribute it and/or modify it under    */
0014 /* the terms of the GNU Lesser General Public License as published by the     */
0015 /* Free Software Foundation, either version 3 of the License, or (at your     */
0016 /* option) any later version.                                                 */
0017 /*                                                                            */
0018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0020 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0021 /* License for more details.                                                  */
0022 /*                                                                            */
0023 /* You should have received a copy of the GNU Lesser General Public License   */
0024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0025 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0026 /*                                                                            */
0027 /* The copyright holder's institutional names and contributor's names may not */
0028 /* be used to endorse or promote products derived from this software without  */
0029 /* specific prior written permission of the institution or contributor.       */
0030 /******************************************************************************/
0031 
0032 #include <cstdint>
0033 #include <string>
0034   
0035 class XrdNetAddrInfo;
0036 class XrdOucEnv;
0037 class XrdSysLogger;
0038 
0039 class XrdXrootdRedirPI
0040 {
0041 public:
0042 
0043 //-----------------------------------------------------------------------------
0044 /*! Return the actual host and port to be used for a redirection.
0045 
0046     @param  Target  -  holds the current redirect target.The target can be a
0047                        a hostname, IPv4, or bracketed IPv6 address.
0048     @param  port     - is the numeric port the client will be using to
0049                        connect to the target. It may be changed to another
0050                        upon return (see return notes).
0051     @param  TCgi    -  Optional CGI information as noted in the redirect
0052                        protocol specification (see note below). It may also 
0053                        be a null string.
0054     @param  TNetInfo - Network address information for the target.
0055     @param  CNetInfo - Network address information for the client being
0056                        redirected.
0057 
0058 
0059     @return string.size() > 0 and string.front() != '!':
0060                A new redirect target is being returned to use for the
0061                redirect. The target must also include any CGI information
0062                this is necessary (e.g. some or all from the TCgi parameter). 
0063                The port argument also holds the port number that should be
0064                used. Leave it alone if the incommin port is correct.
0065             string.size() == 0:
0066                Use the original redirect target.
0067             string.size() > 0 and string.front() == '!':
0068                A fatal error has occured and an error message should be
0069                sent to the client. The error message text are the characters
0070                after the exclamation point.
0071 
0072     @note According to the protocol specification targets are of the form
0073           host[?[fcgi][?lcgi]] and when passed are separated and the Target
0074           sargument holdse host and TCgi holds the [?[fcgi][?lcgi]] which may
0075           be a null string. When returning a new target, it must be fully
0076           specified along with any relevant cgi.
0077 */
0078 
0079 virtual std::string Redirect(const char* Target, uint16_t& port,
0080                              const char* TCgi,
0081                              XrdNetAddrInfo& TNetInfo,
0082                              XrdNetAddrInfo& CNetInfo) = 0;
0083 
0084 //-----------------------------------------------------------------------------
0085 /*! Return the actual URL to be used for a redirection.
0086 
0087     @param  urlHead -  holds the prefix to the destination spec. Typically,
0088                        this is "<protocol>://".
0089     @param  Target  -  holds the current redirect target and does not contain
0090                        the port. The target can be a hostname, IPv4, or
0091                        bracketed IPv6 address.
0092     @param  port     - is the character port the client will be using to
0093                        connect to the target. If there is no port, then
0094                        this is a null string.
0095     @param  urlTail -  Is the remaining URL (i.e. all the characters after
0096                        the target specification (i.e. host[:port]) it may
0097                        be a null string (e.g. "xroot://dest:1094" is specified.)
0098     @param  rdrOpts    Redirect options as bit flags. These may be changed.
0099                        Currently, do not touch these options.
0100     @param  TNetInfo - Network address information for the target.
0101     @param  CNetInfo - Network address information for the client being
0102                        redirected.
0103 
0104     @return string.size() > 0 and string.front() != '!':
0105                A new redirect URL has been returned to use for the redirect.
0106             string.size() == 0:
0107                Use the original redirect URL.
0108             string.size() > 0 and string.front() == '!':
0109                A fatal error has occured and an error message should be
0110                sent to the client. The error message text are the characters
0111                after the exclamation point.
0112 
0113     @note The redirect plugin should not change the original protocol.
0114 
0115     @note The URL type of redirect is esoteric and is used primarily to change
0116           protocols (e.g. xrooot to file). Hence, a default implementation
0117           is supplied.
0118 */
0119 
0120 virtual std::string RedirectURL(const char* urlHead,
0121                                 const char* Target,
0122                                 const char* port,
0123                                 const char* urlTail,
0124                                 int&        rdrOpts,
0125                                 XrdNetAddrInfo& TNetInfo,
0126                                 XrdNetAddrInfo& CNetInfo
0127                                ) {std::string x(""); return x;}       
0128 
0129 //-----------------------------------------------------------------------------
0130 //! Constructor and Destructor
0131 //-----------------------------------------------------------------------------
0132 
0133                        XrdXrootdRedirPI() {}
0134 virtual               ~XrdXrootdRedirPI() {}
0135 
0136 };
0137 
0138 /******************************************************************************/
0139 /*                   P l u g i n   I n s t a n t i a t o r                    */
0140 /******************************************************************************/
0141 
0142 //-----------------------------------------------------------------------------
0143 /*! When building a shared library plugin, the following "C" entry point must
0144     exist in the library:
0145 
0146     @param  prevPI   - pointer tp the redirect plugin that was previously
0147                        loaded, nil if none. If not nil, you may return
0148                        this pointer if you wish to cede control to it.
0149                        Alternatively you can pass control to this plugin
0150                        as needed.
0151     @param  Logger   - The message logging object to be used for messages.
0152     @param  parms    - pointer to optional parameters passed via the redirlib
0153                        directive, nil if there are no parameters.
0154     @param  configFn - pointer to the path of the configuration file. If nil
0155                        there is no configuration file.
0156     @param  envP     - Pointer to the environment containing implementation
0157                        specific information.
0158 
0159     @return Pointer to the file system object to be used or nil if an error
0160             occurred.
0161 
0162     extern "C"
0163          {XrdXrootdRedirPI *XrdXrootGetdRedirPI(XrdXrootdRedirPI *prevPI,
0164                                                 XrdSysLogger     *Logger,
0165                                                 const char       *parms,
0166                                                 const char       *configFn,
0167                                                 XrdOucEnv        *envP);
0168          }
0169 */
0170 
0171 #define XrdXrootdRedirPI_Args XrdXrootdRedirPI *prevPI,\
0172                               XrdSysLogger     *Logger,\
0173                               const char       *parms, \
0174                               const char       *configFn,\
0175                               XrdOucEnv        *envP
0176 
0177 typedef XrdXrootdRedirPI *(*XrdXrootdRedirPI_t)(XrdXrootdRedirPI_Args);
0178 
0179 
0180 //------------------------------------------------------------------------------
0181 /*! Specify the compilation version.
0182 
0183     Additionally, you *should* declare the xrootd version you used to compile
0184     your plug-in. The plugin manager automatically checks for compatibility.
0185     Declare it as follows:
0186 
0187     #include "XrdVersion.hh"
0188     XrdVERSIONINFO(XrdXrootGetdRedirPI,<name>);
0189 
0190     where <name> is a 1- to 15-character unquoted name identifying your plugin.
0191 */
0192 //------------------------------------------------------------------------------
0193 #endif