xrootd
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
XrdNetAddr Class Reference

#include <XrdNetAddr.hh>

Inheritance diagram for XrdNetAddr:
Inheritance graph
[legend]
Collaboration diagram for XrdNetAddr:
Collaboration graph
[legend]

Public Member Functions

int Port (int pNum=-1)
 
bool Register (const char *hName)
 
const char * Set (const char *hSpec, int pNum=PortInSpec)
 
const char * Set (const char *hSpec, int &numIP, int maxIP, int pNum=PortInSpec, bool forUDP=false)
 
const char * Set (const struct sockaddr *sockP, int sockFD=-1)
 
const char * Set (int sockFD, bool peer=true)
 
const char * Set (struct addrinfo *rP, int port, bool mapit=false)
 
void SetDialect (const char *dP)
 
void SetLocation (XrdNetAddrInfo::LocInfo &loc)
 
void SetTLS (bool val)
 
 XrdNetAddr ()
 Assignment operator and copy constructor are inherited, no need to define.
 
 XrdNetAddr (const XrdNetAddr *addr)
 
 XrdNetAddr (const sockaddr *addr)
 
 XrdNetAddr (const sockaddr_in *addr)
 
 XrdNetAddr (const sockaddr_in6 *addr)
 
 XrdNetAddr (int port)
 
 ~XrdNetAddr ()
 Destructor.
 
- Public Member Functions inherited from XrdNetAddrInfo
const char * Dialect ()
 
int Family () const
 
int Format (char *bAddr, int bLen, fmtUse fmtType=fmtAuto, int fmtOpts=0)
 
bool isLoopback ()
 
bool isIPType (IPType ipType) const
 
bool isMapped () const
 
bool isPrivate ()
 
bool isRegistered ()
 
bool isUsingTLS ()
 
const struct LocInfoLocation ()
 
const char * Name (const char *eName=0, const char **eText=0)
 
const XrdNetSockAddrNetAddr ()
 
int Port ()
 
int Protocol ()
 
int Same (const XrdNetAddrInfo *ipAddr, bool plusPort=false)
 
const sockaddr * SockAddr ()
 
SOCKLEN_t SockSize ()
 
int SockFD ()
 
XrdNetAddrInfooperator= (XrdNetAddrInfo const &rhs)
 Assignment operator.
 
 XrdNetAddrInfo (XrdNetAddrInfo const &oP)
 Copy constructor.
 
 XrdNetAddrInfo ()
 Constructor.
 
 XrdNetAddrInfo (const XrdNetAddrInfo *addr)
 
 ~XrdNetAddrInfo ()
 Destructor.
 

Static Public Member Functions

static bool DynDNS ()
 
static bool IPV4Set ()
 
static void SetCache (int keeptime)
 
static void SetDynDNS (bool onoff)
 
static void SetIPV4 ()
 
static void SetIPV6 ()
 
- Static Public Member Functions inherited from XrdNetAddrInfo
static bool isHostName (const char *name)
 

Static Public Attributes

static const int PortInSpec = (int)0x80000000
 
- Static Public Attributes inherited from XrdNetAddrInfo
static const int noPort = 0x0000001
 Do not add port number.
 
static const int noPortRaw = 0x0000002
 Use raw address format (no port)
 
static const int old6Map4 = 0x0000004
 Use deprecated IPV6 mapped format.
 
static const int prefipv4 = 0x0000008
 Use if mapped IPV4 actual format.
 

Private Member Functions

bool Map64 ()
 

Static Private Member Functions

static struct addrinfo * Hints (int htype, int stype)
 

Static Private Attributes

static struct addrinfo * hostHints
 
static struct addrinfo * huntHintsTCP
 
static struct addrinfo * huntHintsUDP
 
static bool useIPV4
 
static bool dynDNS
 

Additional Inherited Members

- Public Types inherited from XrdNetAddrInfo
enum  fmtUse { fmtAuto =0 , fmtName , fmtAddr , fmtAdv6 }
 
enum  IPType { IPv4 = AF_INET , IPv6 = AF_INET6 , IPuX = AF_UNIX }
 
- Protected Member Functions inherited from XrdNetAddrInfo
char * LowCase (char *str)
 
int QFill (char *bAddr, int bLen)
 
int Resolve ()
 
- Protected Attributes inherited from XrdNetAddrInfo
XrdNetSockAddr IP
 
union { 
 
   struct sockaddr *   sockAddr 
 
   struct sockaddr_un *   unixPipe 
 
};  
 
char * hostName
 
LocInfo addrLoc
 
unsigned short addrSize
 
unsigned char protType
 
unsigned char protFlgs
 
int sockNum
 
const char * protName
 
- Static Protected Attributes inherited from XrdNetAddrInfo
static XrdNetCachednsCache
 
static const char isTLS = 0x01
 Location using TLS.
 

Constructor & Destructor Documentation

◆ XrdNetAddr() [1/6]

XrdNetAddr::XrdNetAddr ( )
inline

Assignment operator and copy constructor are inherited, no need to define.

Constructor

Parameters
addrA pointer to an initialized and valid sockaddr or sockaddr compatible structure used to initialize the address.
portUses the address of the current host and the speoified port number to initilize the address.

◆ XrdNetAddr() [2/6]

XrdNetAddr::XrdNetAddr ( const XrdNetAddr addr)
inline

◆ XrdNetAddr() [3/6]

XrdNetAddr::XrdNetAddr ( const sockaddr *  addr)
inline

References Set().

◆ XrdNetAddr() [4/6]

XrdNetAddr::XrdNetAddr ( const sockaddr_in *  addr)
inline

References Set().

◆ XrdNetAddr() [5/6]

XrdNetAddr::XrdNetAddr ( const sockaddr_in6 *  addr)
inline

References Set().

◆ XrdNetAddr() [6/6]

XrdNetAddr::XrdNetAddr ( int  port)

◆ ~XrdNetAddr()

XrdNetAddr::~XrdNetAddr ( )
inline

Destructor.

Member Function Documentation

◆ DynDNS()

static bool XrdNetAddr::DynDNS ( )
inlinestatic

Determine if dynamic DNS has been set.

Returns
True Dynamic DNS has been set. False Dynamic DNS has not been set.

References dynDNS.

◆ Hints()

static struct addrinfo * XrdNetAddr::Hints ( int  htype,
int  stype 
)
staticprivate

◆ IPV4Set()

static bool XrdNetAddr::IPV4Set ( )
inlinestatic

Determine if IPV4 mode has been set.

Returns
True IPV4 mode has been set. False IPV4 mode has not been set.

References useIPV4.

◆ Map64()

bool XrdNetAddr::Map64 ( )
private

◆ Port()

int XrdNetAddr::Port ( int  pNum = -1)

Optionally set and also returns the port number for our address.

Parameters
pNumwhen negative it only returns the current port. Otherwise, it is taken as the value to be set.
Returns
Success: The port number, which may be 0 if not set. Failure: -1 address is not an internet address or port is invalid.

◆ Register()

bool XrdNetAddr::Register ( const char *  hName)

Register a host name with this IP address. This is not MT-safe!

Parameters
hName-> to a true host name which should be fully qualified. One of the IP addresses registered to this name must match the IP address associated with this object.
Returns
True: Specified name is now associated with this address. False: Nothing changed, registration could not be verified.

◆ Set() [1/5]

const char * XrdNetAddr::Set ( const char *  hSpec,
int &  numIP,
int  maxIP,
int  pNum = PortInSpec,
bool  forUDP = false 
)

Return multiple addresses. This form can only be used on the first element of this object that has been allocated as an array. This method is useful for getting all of the aliases assigned to a dns entry. The file descriptor association is set to a negative value.

Parameters
hSpec0 -> address is set to in6addr_any for binding via bind() !0 -> convert specification to an address. Valid formats: IP.v4: nnn.nnn.nnn.nnn[:<port>] IP.v6: [ipv6_addr][:<port>] IP.xx: name[:port] xx is determined by getaddrinfo()
maxIPnumber of elements in the array.
numIPthe number of IP addresses actually set (returned value).
pNum>= 0 uses the value as the port number regardless of what is in hSpec, should it be supplied. However, if is present, it must be a valid port number or name. < 0 uses the positive value as the port number if the port number has not been specified in hSpec. **** When set to PortInSpec(the default, see below) the port number/name must be specified in hSpec. If it is not, an error is returned.
forUDPwhen true addresses are usable for UDP connections. Otherwise, they are for TCP connections.
Returns
Success: 0 with numIP set to the number of elements set. Failure: the error message text describing the error and numIP is set to zero. The message is in persistent storage and cannot be modified.

◆ Set() [2/5]

const char * XrdNetAddr::Set ( const char *  hSpec,
int  pNum = PortInSpec 
)

Referenced by XrdNetAddr(), XrdNetAddr(), and XrdNetAddr().

◆ Set() [3/5]

const char * XrdNetAddr::Set ( const struct sockaddr *  sockP,
int  sockFD = -1 
)

Set our address via a sockaddr structure.

Parameters
sockPa pointer to an initialized and valid sockaddr structure.
sockFDthe associated file descriptor and can be used to record the file descriptor returned by accept().
Returns
Success: Returns 0. Failure: Returns the error message text describing the error. The message is in persistent storage and cannot be modified.

◆ Set() [4/5]

const char * XrdNetAddr::Set ( int  sockFD,
bool  peer = true 
)

Set our address from the supplied socket file descriptor.

Parameters
sockFDa connected socket file descriptor. The value is also recorded as the associated file descriptor.
peerWhen true the address is set from getpeername() When false the address is set from getsockname()
Returns
Success: Returns 0. Failure: Returns the error message text describing the error. The message is in persistent storage and cannot be modified.

◆ Set() [5/5]

const char * XrdNetAddr::Set ( struct addrinfo *  rP,
int  port,
bool  mapit = false 
)

Set our address via and addrinfo structure and initialize the port.

Parameters
rPpointer to an addrinfo structure.
portthe port number to set.
mapitwhen true maps IPv4 addresses to IPv6. Otherwise, does not.
Returns
Success: Returns 0. Failure: Returns the error message text describing the error. The message is in persistent storage and cannot be modified.

◆ SetCache()

static void XrdNetAddr::SetCache ( int  keeptime)
static

Set the cache time for address to name resolutions. This method should only be called during initialization time. The default is to not use the cache.

◆ SetDialect()

void XrdNetAddr::SetDialect ( const char *  dP)
inline

Set the dialect being spoken on this network link.

Parameters
dPPointer to the dialect name. It must be permanently stable.

References XrdNetAddrInfo::protName.

◆ SetDynDNS()

static void XrdNetAddr::SetDynDNS ( bool  onoff)
static

Indicate whether or not dynamic DNS is being used. This method should only be called during initialization time. The default is fixed DNS.

Parameters
onoffTrue if dynamic DNS is being used, false otherwise.

◆ SetIPV4()

static void XrdNetAddr::SetIPV4 ( )
static

Force this object to work in IPV4 mode only. This method permanently sets IPV4 mode which cannot be undone without a restart. It is meant to bypass broken IPV6 stacks on those unfortunate hosts that have one. It should be called before any other calls to this object (e.g. initialization time).

◆ SetIPV6()

static void XrdNetAddr::SetIPV6 ( )
static

Force this object to work in IPV6 mode using IPV6 or mapped IPV4 addresses. This method permanently sets IPV6 mode which cannot be undone without a restart. It is meant to disable the default mode which determines which address to use based on which address types are configured on the host (i.e. getaddrinfo() with hints AI_ADDRCONFIG|AI_V4MAPPED).

◆ SetLocation()

void XrdNetAddr::SetLocation ( XrdNetAddrInfo::LocInfo loc)

Set the location for this address

Parameters
locpointer to the structure that describes the location. See XrdnetAddrInfo for the definition of the stucture.

Referenced by XrdLinkXeq::setLocation().

◆ SetTLS()

void XrdNetAddr::SetTLS ( bool  val)

Set the location's TLS state.

Parameters
valTrue if TLS is being used, false otherwise.

Member Data Documentation

◆ dynDNS

bool XrdNetAddr::dynDNS
staticprivate

Referenced by DynDNS().

◆ hostHints

struct addrinfo* XrdNetAddr::hostHints
staticprivate

◆ huntHintsTCP

struct addrinfo* XrdNetAddr::huntHintsTCP
staticprivate

◆ huntHintsUDP

struct addrinfo* XrdNetAddr::huntHintsUDP
staticprivate

◆ PortInSpec

const int XrdNetAddr::PortInSpec = (int)0x80000000
static

Set the IP address and possibly the port number.

Parameters
hSpec0 -> address is set to in6addr_any for binding via bind() (INADDR_ANY in IPV4 mode). !0 -> convert specification to an address. Valid formats: IPv4: nnn.nnn.nnn.nnn[:<port>] IPv6: [ipv6_addr][:<port>] addr brackets required IPvx: name[:port] x is determined by getaddrinfo() Unix: /<path>
pNum>= 0 uses the value as the port number regardless of what is in hSpec, should it be supplied. However, if is present, it must be a valid port number or name. < 0 uses the positive value as the port number if the port number has not been specified in hSpec. **** When set to PortInSpec(the default, see below) the port number/name must be specified in hSpec. If it is not, an error is returned.
Returns
Success: 0. Failure: Error message text describing the error. The message is in persistent storage and cannot be modified.

◆ useIPV4

bool XrdNetAddr::useIPV4
staticprivate

Referenced by IPV4Set().


The documentation for this class was generated from the following file: