Loading...
Searching...
No Matches
XrdNetUtils Class Reference

`#include <XrdNetUtils.hh>`

Collaboration diagram for XrdNetUtils:

## Public Types

enum | AddrOpts { allIPMap = 0 , allIPv64 = 1 , allV4Map = 2 , onlyIPv6 = 3 , onlyIPv4 = 4 , prefIPv6 = 8 , prefAuto = 16 , order46 = 32 , order64 = 64 , onlyUDP =128 }
enum | IPComp { IPSame = 0 , IPDFam , IPDiff , IPNSup }
enum | NetProt { hasNone = 0 , hasIPv4 = 1 , hasIPv6 = 2 , hasIP64 = 3 , hasPub4 = 4 , hasPub6 = 8 }
enum | NetType { qryINET = 0 , qryINIF = 1 }

## Public Member Functions

| XrdNetUtils ()
| Constructor.
| ~XrdNetUtils ()
| Destructor.

## Static Public Member Functions

static IPComp | Compare (XrdNetSockAddr &ip1, XrdNetSockAddr &ip2, bool *psame=0)
static bool | ConnectWithTimeout (int sockfd, const struct sockaddr *clientAddr, size_t clientAddrLen, uint32_t timeout_sec, std::stringstream &errMsg)
static int | Decode (XrdNetSockAddr *sadr, const char *buff, int blen)
static int | Encode (const XrdNetSockAddr *sadr, char *buff, int blen, int port=-1)
static const char * | GetAddrs (const char *hSpec, XrdNetAddr *aListP[], int &aListN, AddrOpts opts=allIPMap, int pNum=PortInSpec)
static const char * | GetAddrs (const std::string &hSpec, std::vector< XrdNetAddr > &aVec, int *ordn=0, AddrOpts opts=allIPMap, int pNum=PortInSpec)
static const char * | GetAddrs (std::vector< std::string > &hSVec, std::vector< XrdNetAddr > &aVec, int *ordn=0, AddrOpts opts=allIPMap, unsigned int rotNum=0, bool force=false)
static int | GetSokInfo (int fd, char *theAddr, int theALen, char &theType)
static XrdOucTList * | Hosts (const char *hSpec, int hPort=-1, int hWant=8, int *sPort=0, const char **eText=0)
static int | IPFormat (const struct sockaddr *sAddr, char *bP, int bL, int opts=0)
static int | IPFormat (int fd, char *bP, int bL, int opts=0)
static bool | Match (const char *hName, const char *pattern)
static char * | MyHostName (const char *eName="*unknown*", const char **eText=0)
static NetProt | NetConfig (NetType netquery=qryINET, const char **eText=0)
static bool | Parse (const char *hSpec, const char **hName, const char **hNend, const char **hPort, const char **hPend)
static int | Port (int fd, const char **eText=0)
static int | ProtoID (const char *pName)
static int | ServPort (const char *sName, bool isUDP=false, const char **eText=0)
static int | SetAuto (AddrOpts aOpts=allIPMap)
static bool | Singleton (const char *hSpec, const char **eText=0)

## Static Public Attributes

static const int | noPort = 1
static const int | NoPortRaw = (int)0xC0000000
static const int | oldFmt = 2
static const int | PortInSpec = (int)0x80000000

## Detailed Description

Definition at line 46 of file XrdNetUtils.hh.

## Member Enumeration Documentation

## AddrOpts

enum XrdNetUtils::AddrOpts

Version 1: Return multiple addresses associated with a host or IP address.

Parameters

  hSpec | -> convert specification to addresses. Valid formats: IP.v4: nnn.nnn.nnn.nnn[:<port>] IP.v6: [ipv6_addr][:<port>] IP.xx: name[:port] xx is determined by getaddrinfo()
  aListP | place where the pointer to the returned array of XrdNetAddr objects is to be placed. Set to zero if none returned. The caller must delete this array when no longer needed.
  aListN | place where the number of elements in aListP are to be returned.

  opts

  Options on what to return. Choose one of: allIPMap - all IPv6 and mapped IPv4 addrs (default) allIPv64 - all IPv6 and unmapped IPv4 addrs allV4Map - all mapped IPV4 addrs. onlyIPv6 - only IPv6 addrs onlyIPv4 - only unmapped IPv4 addrs prefIPv6 - only IPv6 addrs; if none, mapped IPv4 addrs prefAuto - Returns addresses based on configured non-local interfaces. The returned addresses will be normally useable on this host and may be IPv4, IPv6, mapped IPv4, or a mixture. The above may be or'd with one or more of the following: onlyUDP - only addrs valid for UDP connections else TCP order46 - List IPv4 addresses (mapped or native) first. order64 - List IPv6 addresses first.

  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. < 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. **** When set to NoPortRaw then hSpec does not contain a port number and is a host name, IPv4 address, or an IPv6 address without surrounding brackets.

Returns
  Success: 0 with aListN set to the number of elements in aListP. Failure: the error message text describing the error and aListP and aListN is set to zero.

Enumerator
allIPMap |
allIPv64 |
allV4Map |
onlyIPv6 |
onlyIPv4 |
prefIPv6 |
prefAuto |
order46 |
order64 |
onlyUDP |

Definition at line 143 of file XrdNetUtils.hh.

{allIPMap= 0, allIPv64= 1, allV4Map= 2,
onlyIPv6= 3, onlyIPv4= 4, prefIPv6= 8,
prefAuto= 16, order46 = 32, order64 = 64,
onlyUDP =128
};
XrdNetUtils::prefAuto
@ prefAuto
Definition XrdNetUtils.hh:145
XrdNetUtils::allIPv64
@ allIPv64
Definition XrdNetUtils.hh:143
XrdNetUtils::prefIPv6
@ prefIPv6
Definition XrdNetUtils.hh:144
XrdNetUtils::allV4Map
@ allV4Map
Definition XrdNetUtils.hh:143
XrdNetUtils::onlyUDP
@ onlyUDP
Definition XrdNetUtils.hh:146
XrdNetUtils::order46
@ order46
Definition XrdNetUtils.hh:145
XrdNetUtils::allIPMap
@ allIPMap
Definition XrdNetUtils.hh:143
XrdNetUtils::order64
@ order64
Definition XrdNetUtils.hh:145
XrdNetUtils::onlyIPv4
@ onlyIPv4
Definition XrdNetUtils.hh:144
XrdNetUtils::onlyIPv6
@ onlyIPv6
Definition XrdNetUtils.hh:144

## IPComp

enum XrdNetUtils::IPComp

Compare two IP addresses and indicate differe\nces, if any.

Parameters

  ip1 | The first address.
  ip2 | The second addres.
  psame | If not zero set to true if ports are the same, o/w false.

Returns
  IPSame The addresses are the same. IPDFam The addresses differ in address family. IPDiff The addresses have different destination, same family. IPNSuf The address family of one or both addresses not supported.

Enumerator
IPSame |
IPDFam |
IPDiff |
IPNSup |

Definition at line 63 of file XrdNetUtils.hh.

{IPSame = 0, IPDFam, IPDiff, IPNSup};
XrdNetUtils::IPNSup
@ IPNSup
Definition XrdNetUtils.hh:63
XrdNetUtils::IPSame
@ IPSame
Definition XrdNetUtils.hh:63
XrdNetUtils::IPDiff
@ IPDiff
Definition XrdNetUtils.hh:63
XrdNetUtils::IPDFam
@ IPDFam
Definition XrdNetUtils.hh:63

## NetProt

enum XrdNetUtils::NetProt

Get the supported network protocols.

Parameters

  netqry | An NetType enum specifying the protocol to inspect.
  eText | When not nil, is where to place error message text.

Returns
  One the the NetProt enums (see below). When hasNone is returned and eText is not nill it will point to a static string that gives the reason. If the reason is a null string, the query was successful but returned no matching protocols.

Enumerator
hasNone | Unable to determine available protocols.
hasIPv4 |
hasIPv6 |
hasIP64 |
hasPub4 |
hasPub6 |

Definition at line 351 of file XrdNetUtils.hh.

{hasNone = 0,
hasIPv4 = 1, //<! Has only IPv4 capability
hasIPv6 = 2, //<! Has only IPv6 capability
hasIP64 = 3, //<! Has IPv4 IPv6 capability (dual stack)
hasPub4 = 4, //<! Has IPv4 public address (or'd with above)
hasPub6 = 8 //<! Has IPv6 public address (or'd with above)
};
XrdNetUtils::hasPub4
@ hasPub4
Definition XrdNetUtils.hh:355
XrdNetUtils::hasIP64
@ hasIP64
Definition XrdNetUtils.hh:354
XrdNetUtils::hasPub6
@ hasPub6
Definition XrdNetUtils.hh:356
XrdNetUtils::hasIPv6
@ hasIPv6
Definition XrdNetUtils.hh:353
XrdNetUtils::hasNone
@ hasNone
Unable to determine available protocols.
Definition XrdNetUtils.hh:351
XrdNetUtils::hasIPv4
@ hasIPv4
Definition XrdNetUtils.hh:352

## NetType

enum XrdNetUtils::NetType

Enumerator
qryINET | Only consider internet protocols via DNS.
qryINIF | Only consider internet protocols via ifconfig.

Definition at line 359 of file XrdNetUtils.hh.

{qryINET = 0,
qryINIF = 1
};
XrdNetUtils::qryINET
@ qryINET
Only consider internet protocols via DNS.
Definition XrdNetUtils.hh:359
XrdNetUtils::qryINIF
@ qryINIF
Only consider internet protocols via ifconfig.
Definition XrdNetUtils.hh:360

## Constructor & Destructor Documentation

## XrdNetUtils()

XrdNetUtils::XrdNetUtils | ( |  | ) |

inline

Constructor.

Definition at line 454 of file XrdNetUtils.hh.

{}

## ~XrdNetUtils()

XrdNetUtils::~XrdNetUtils | ( |  | ) |

inline

Destructor.

Definition at line 460 of file XrdNetUtils.hh.

{}

## Member Function Documentation

## Compare()

XrdNetUtils::IPComp XrdNetUtils::Compare | ( | XrdNetSockAddr & | ip1,
|  | XrdNetSockAddr & | ip2,
|  | bool * | psame = 0 )

static

Definition at line 70 of file XrdNetUtils.cc.

{
// The family code is always in the same place so trivially check equivalence
//
if (ip1.Addr.sa_family != ip2.Addr.sa_family) return IPDFam;
// Since the mailies are te same we need to check if he actual ip addess is
// same, What we check depends on the address family. Start with IPv6.
//
if (ip1.Addr.sa_family == AF_INET6)
{if (memcmp(&ip1.v6.sin6_addr,&ip2.v6.sin6_addr,sizeof(struct in6_addr)))
return IPDiff;
if (psame) *psame = (ip1.v6.sin6_port == ip2.v6.sin6_port);
return IPSame;
}
// Try IPv4
//
if (ip1.Addr.sa_family == AF_INET)
{if (memcmp(&ip1.v4.sin_addr,&ip2.v4.sin_addr, sizeof(struct in_addr)))
return IPDiff;
if (psame) *psame = (ip1.v4.sin_port == ip2.v4.sin_port);
return IPSame;
}
// We don't support the address family
//
return IPNSup;
}
XrdNetSockAddr::v6
struct sockaddr_in6 v6
Definition XrdNetSockAddr.hh:43
XrdNetSockAddr::Addr
struct sockaddr Addr
Definition XrdNetSockAddr.hh:45
XrdNetSockAddr::v4
struct sockaddr_in v4
Definition XrdNetSockAddr.hh:44

References XrdNetSockAddr::Addr, IPDFam, IPDiff, IPNSup, IPSame, XrdNetSockAddr::v4, and XrdNetSockAddr::v6.

## ConnectWithTimeout()

bool XrdNetUtils::ConnectWithTimeout | ( | int | sockfd,
|  | const struct sockaddr * | clientAddr,
|  | size_t | clientAddrLen,
|  | uint32_t | timeout_sec,
|  | std::stringstream & | errMsg )

static

Definition at line 981 of file XrdNetUtils.cc.

{
if (!SetSockBlocking(sockfd, false, errMsg)) { // Set to non-blocking
close(sockfd);
return false;
}
int result = connect(sockfd, clientAddr, clientAddrLen);
if (result == 0) {
//We've managed to connect immediately
// Set the socket back to blocking
if(!SetSockBlocking(sockfd, true, errMsg)) {
::close(sockfd);
return false;
}
return true;
} else if (errno != EINPROGRESS) {
errMsg << "Connection failed: " << strerror(errno);
::close(sockfd);
return false;
}
struct pollfd fds;
fds.fd = sockfd;
fds.events = POLLOUT; // Wait for the socket to be ready to write
result = poll(&fds, 1, timeout_sec * 1000); //Timeout in milliseconds
if (result < 0) {
errMsg << "Poll error: " << strerror(errno);
::close(sockfd);
return false;
} else if (result == 0) {
errMsg << "Connection timed out";
::close(sockfd);
return false;
}
// Polling succeeded
if (!(fds.revents & POLLOUT)) {
// We should normally not reach this code
errMsg << "Poll returned without error but the corresponding socket (" << sockfd << ") is not ready to write";
::close(sockfd);
return false;
}
// Check for potential errors on the socket after polling
int so_error;
socklen_t len = sizeof(so_error);
getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &so_error, &len);
if (so_error != 0) {
errMsg << "Connection failed after poll: " << strerror(so_error);
::close(sockfd);
return false;
}
// Everything succeeded, set the socket back to blocking
if(!SetSockBlocking(sockfd, true, errMsg)) {
::close(sockfd);
return false;
}
return true;
}
close
#define close(a)
Definition XrdPosix.hh:48

References close.

Referenced by XrdHttpTpc::PMarkManager::connect().

Here is the caller graph for this function:

## Decode()

int XrdNetUtils::Decode | ( | XrdNetSockAddr * | sadr,
|  | const char * | buff,
|  | int | blen )

static

Decode an "encoded" ipv6/4 address and place it "sockaddr" type structure.

Parameters

  sadr | address of the union that will hold the results.
  buff | address of buffer that holds the encoding.
  blen | length of the string (it need not be null terminated).

Returns
  > 0 the port number in host byte order. = 0 the port number was not set. < 0 the encoding was not correct.

Definition at line 105 of file XrdNetUtils.cc.

{
static const int ipv4Sz = sizeof(struct in_addr)*2+4;
static const int ipv6Sz = sizeof(struct in6_addr)*2+4;
char bval[sizeof(struct in6_addr)+2];
int isv6, n, i = 0, Odd = 0;
// Determine if this will be IPV4 or IPV6 (only ones allowed)
//
if (blen == ipv6Sz) isv6 = 1;
else if (blen == ipv4Sz) isv6 = 0;
else return -1;
// Convert the whole string to a temporary
//
while(blen--)
{ if (*buff >= '0' && *buff <= '9') n = *buff-48;
else if (*buff >= 'a' && *buff <= 'f') n = *buff-87;
else if (*buff >= 'A' && *buff <= 'F') n = *buff-55;
else return -1;
if (Odd) bval[i++] |= n;
else bval[i ] = n << 4;
buff++; Odd = ~Odd;
}
// Clear the address
//
memset(sadr, 0, sizeof(XrdNetSockAddr));
// Copy out the data, as needed
//
if (isv6)
{sadr->v6.sin6_family = AF_INET6;
memcpy(&(sadr->v6.sin6_port), bval, 2);
memcpy(&(sadr->v6.sin6_addr), &bval[2], sizeof(struct in6_addr));
} else {
sadr->v4.sin_family = AF_INET;
memcpy(&(sadr->v4.sin_port), bval, 2);
memcpy(&(sadr->v4.sin_addr), &bval[2], sizeof(struct in_addr));
}
// Return the converted port (it's the same for v4/v6)
//
return static_cast<int>(ntohs(sadr->v6.sin6_port));
}

References XrdNetSockAddr::v4, and XrdNetSockAddr::v6.

Referenced by XrdOucReqID::isMine().

Here is the caller graph for this function:

## Encode()

int XrdNetUtils::Encode | ( | const XrdNetSockAddr * | sadr,
|  | char * | buff,
|  | int | blen,
|  | int | port = -1 )

static

Encode the address and return it in a supplied buffer.

Parameters

  sadr | address of the union that holds the IPV4/6 address.
  buff | address of buffer to hold the null terminated encoding.
  blen | length of the buffer. It6 should be at least 40 bytes.
  port | optional port value to use as opposed to the one present in sockaddr sadr. The port must be in host order.

Returns
  > 0 the length of the encoding less the null byte. = 0 current address format not supported for encoding. < 0 buffer is too small; abs(retval) bytes needed.

Definition at line 155 of file XrdNetUtils.cc.

{
static const char *hv = "0123456789abcdef";
char *src, bval[sizeof(struct in6_addr)+2];
int asz, i, j = 0;
// Compute the size we need for the buffer (note we only support IP4/6)
//
if (sadr->Addr.sa_family == AF_INET6)
{src = (char *)&(sadr->v6.sin6_addr); asz = sizeof(struct in6_addr);}
else if (sadr->Addr.sa_family == AF_INET)
{src = (char *)&(sadr->v4.sin_addr); asz = sizeof(struct in_addr); }
else return 0;
if (blen < (asz*2)+5) return -((asz*2)+5);
// Get the port value in the first two bytes followed by the address.
//
if (port < 0) memcpy(bval, &(sadr->v6.sin6_port), 2);
else {short sPort = htons(static_cast<short>(port));
memcpy(bval, &sPort, 2);
}
memcpy(&bval[2], src, asz);
asz += 2;
// Now convert to hex
//
for (i = 0; i < asz; i++)
{buff[j++] = hv[(bval[i] >> 4) & 0x0f];
buff[j++] = hv[ bval[i] & 0x0f];
}
buff[j] = '\0';
// All done
//
return asz*2;
}

References XrdNetSockAddr::Addr, XrdNetSockAddr::v4, and XrdNetSockAddr::v6.

Referenced by XrdOucReqID::XrdOucReqID(), and XrdOssPath::InitPrefix().

Here is the caller graph for this function:

## GetAddrs() [1/3]

const char * XrdNetUtils::GetAddrs | ( | const char * | hSpec,
|  | XrdNetAddr * | aListP[],
|  | int & | aListN,
|  | XrdNetUtils::AddrOpts | opts = allIPMap,
|  | int | pNum = PortInSpec )

static

Definition at line 274 of file XrdNetUtils.cc.

{
const char *eText;
hpSpec aInfo(opts);
// Prep the returned fields
//
*aVec = 0;
aVsz = 0;
// Parse the options
//
GetHints(aInfo, opts);
// Parse the host specification and get addresses
//
if ((eText = GetHostPort(aInfo, hSpec, pNum))
|| (eText = GetAInfo(aInfo))) return eText;
// If we have any addresses, resize the vector with that many netaddr objects
// and then initialze each one of them.
//
if (aInfo.aNum4 || aInfo.aNum6)
{aVsz = aInfo.aNum4 + aInfo.aNum6;
*aVec = new XrdNetAddr[(unsigned int)aVsz];
FillAddr(aInfo, *aVec);
}
// All done
//
return 0;
}
opts
struct myOpts opts

References XrdNetSpace::hpSpec::aNum4, XrdNetSpace::hpSpec::aNum6, and opts.

Referenced by XrdNetRegistry::GetAddrs(), XrdCl::Utils::GetHostAddresses(), NetConfig(), XrdNetAddr::Register(), and XrdNetIF::SetIF().

Here is the caller graph for this function:

## GetAddrs() [2/3]

const char * XrdNetUtils::GetAddrs | ( | const std::string & | hSpec,
|  | std::vector< XrdNetAddr > & | aVec,
|  | int * | ordn = 0,
|  | AddrOpts | opts = allIPMap,
|  | int | pNum = PortInSpec )

static

Version 2: Return multiple addresses associated with a host or IP address.

Parameters

  hSpec | Reference to address specification (see version 1).
  aVec | Reference to the vector to contain addresses.
  ordn | Pointer to where the partition ordinal is to be stored.
  opts | Options on what to return (see version 1).
  pNum | Port number argument (see version 1).

Returns
  Success: 0 is returned. When ordn is not nil, the number of IPv4 entries (for order46) or IPv6 (for order64) entries that appear in the front of the vector. If ordering is not specified, the value is set to the size of the vector. Failure: the error message text describing the error and aVec is cleared (i.e. has no elements).

Definition at line 311 of file XrdNetUtils.cc.

{
// If this references a registered name, process it as such.
//
if (*(hSpec.c_str()) == XrdNetRegistry::pfx)
return XrdNetRegistry::GetAddrs(hSpec, aVec, ordn, opts, pNum);
// Start up!
//
const char *eText;
hpSpec aInfo(opts);
// Clear the result vector
//
aVec.clear();
if (ordn) *ordn = 0;
// Parse the options
//
GetHints(aInfo, opts);
// Parse the host specification and get address info
//
if ((eText = GetHostPort(aInfo, hSpec.c_str(), pNum))
|| (eText = GetAInfo(aInfo))) return eText;
// If we have any addresses, resize the vector with that many netaddr objects
// and then initialze each one of them.
//
if (aInfo.aNum4 || aInfo.aNum6)
{aVec.resize(aInfo.aNum4 + aInfo.aNum6);
FillAddr(aInfo, aVec.data(), ordn);
}
// All done
//
return 0;
}
XrdNetRegistry::GetAddrs
static const char * GetAddrs(const std::string &hSpec, std::vector< XrdNetAddr > &aVec, int *ordn=0, XrdNetUtils::AddrOpts opts=XrdNetUtils::allIPMap, int pNum=XrdNetUtils::PortInSpec)
Definition XrdNetRegistry.cc:110
XrdNetRegistry::pfx
static const char pfx
Registry names must start with this character.
Definition XrdNetRegistry.hh:43

References XrdNetSpace::hpSpec::aNum4, XrdNetSpace::hpSpec::aNum6, XrdNetRegistry::GetAddrs(), opts, and XrdNetRegistry::pfx.

Here is the call graph for this function:

## GetAddrs() [3/3]

const char * XrdNetUtils::GetAddrs | ( | std::vector< std::string > & | hSVec,
|  | std::vector< XrdNetAddr > & | aVec,
|  | int * | ordn = 0,
|  | AddrOpts | opts = allIPMap,
|  | unsigned int | rotNum = 0,
|  | bool | force = false )

static

Version 3: Return multiple addresses associated with a list of host or IP addresses.

Parameters

  hSVec | vector of address specification (see version 1). Note that this version requires hSVec entries to have a port number.
  aVec | Reference to the vector to contain addresses.
  ordn | Pointer to where the partition ordinal is to be stored.
  opts | Options on what to return (see version 1).
  rotNum | The rotation factor to order addresses in the result.
  force | When true resolution errors are ignored.

Returns
  Success: 0 is returned. When ordn is not nil, the number of IPv4 entries (for order46) or IPv6 (for order64) entries that appear in the front of the vector. If ordering is not specified, the value is set to the size of the vector. Failure: the error message text describing the error and aVec is cleared (i.e. has no elements).

Definition at line 354 of file XrdNetUtils.cc.

{
const char *eText;
hpSpec aInfo(opts);
// Clear the result vector and make sure we have something to do
//
aVec.clear();
if (ordn) *ordn = 0;
if (!hSVec.size()) return 0;
// Parse the options
//
GetHints(aInfo, opts);
// Process each specification
//
for (int i = 0; i < (int)hSVec.size(); i++)
{if (((eText = GetHostPort(aInfo, hSVec[i].c_str(), PortInSpec))
|| (eText = GetAInfo(aInfo))) && !force) return eText;
}
// Size the vector and fill it in
//
if (aInfo.aNum4 || aInfo.aNum6)
{aVec.resize(aInfo.aNum4 + aInfo.aNum6);
FillAddr(aInfo, aVec.data(), ordn, rotNum);
}
// All done
//
return 0;
}
XrdNetUtils::PortInSpec
static const int PortInSpec
Definition XrdNetUtils.hh:149

References XrdNetSpace::hpSpec::aNum4, XrdNetSpace::hpSpec::aNum6, opts, and PortInSpec.

## GetSokInfo()

int XrdNetUtils::GetSokInfo | ( | int | fd,
|  | char * | theAddr,
|  | int | theALen,
|  | char & | theType )

static

Obtain connection information from a socket.

Parameters

  fd | The file descriptor of the socket whose address is to be converted. The sign of the fd indicates which address: fd > 0 the peer address is used (i.e. getpeername) fd < 0 the local address is used (i.e. getsockname)
  theAddr | pointer to a buffer of theAlen bytes where the text version of the IP address is to be returned. The text uses the actual native address format. If theAddr is nil or theAlen is not positive, only the port and address type are returned.
  theALen | length of the theAddr buffer.
  theType | either the character 4 (IPv4) or 6 (IPv6) is returned. corrresponding to the address family. Note that should be AF_INET6 but the address is mapped, '4' is returned.

Returns
  Success: >= 0 corresponding to the port number.
  Failure: < 0 corresponding to -errno.

Definition at line 533 of file XrdNetUtils.cc.

{
XrdNetSockAddr theIP;
XrdNetAddr ipAddr;
static const int fmtopts = XrdNetAddrInfo::noPortRaw
| XrdNetAddrInfo::prefipv4;
SOCKLEN_t addrSize = sizeof(theIP);
int rc;
unsigned short thePort;
// The the address wanted
//
rc = (fd > 0 ? getpeername( fd, &theIP.Addr, &addrSize)
: getsockname(-fd, &theIP.Addr, &addrSize));
if (rc) return -errno;
// Set the address
//
if (ipAddr.Set(&theIP.Addr)) return -EAFNOSUPPORT;
// Establis the type of address we have
//
if (ipAddr.isIPType(XrdNetAddrInfo::IPv4) || ipAddr.isMapped()) theType='4';
else theType = '6';
// Now format the address
//
if (theAddr && theALen > 0
&& !ipAddr.Format(theAddr, theALen, XrdNetAddrInfo::fmtAddr, fmtopts))
return -EINVAL;
// Get the port number and return it.
//
thePort = htons((theIP.Addr.sa_family == AF_INET
? theIP.v4.sin_port : theIP.v6.sin6_port));
return static_cast<int>(thePort);
}
if
if(ec< 0) ec
SOCKLEN_t
#define SOCKLEN_t
Definition XrdSysPlatform.hh:269
XrdNetAddrInfo::isMapped
bool isMapped() const
Definition XrdNetAddrInfo.hh:155
XrdNetAddrInfo::IPv4
@ IPv4
Definition XrdNetAddrInfo.hh:144
XrdNetAddrInfo::noPortRaw
static const int noPortRaw
Use raw address format (no port).
Definition XrdNetAddrInfo.hh:105
XrdNetAddrInfo::prefipv4
static const int prefipv4
Use if mapped IPV4 actual format.
Definition XrdNetAddrInfo.hh:107
XrdNetAddrInfo::isIPType
bool isIPType(IPType ipType) const
Definition XrdNetAddrInfo.hh:146
XrdNetAddrInfo::Format
int Format(char *bAddr, int bLen, fmtUse fmtType=fmtAuto, int fmtOpts=0)
Definition XrdNetAddrInfo.cc:81
XrdNetAddrInfo::fmtAddr
@ fmtAddr
Address using suitable ipv4 or ipv6 format.
Definition XrdNetAddrInfo.hh:101
XrdNetAddr::Set
const char * Set(const char *hSpec, int pNum=PortInSpec)
Definition XrdNetAddr.cc:216

References XrdNetSockAddr::Addr, XrdNetAddrInfo::fmtAddr, XrdNetAddrInfo::Format(), XrdNetAddrInfo::IPv4, XrdNetAddrInfo::isIPType(), XrdNetAddrInfo::isMapped(), XrdNetAddrInfo::noPortRaw, XrdNetAddrInfo::prefipv4, XrdNetAddr::Set(), SOCKLEN_t, XrdNetSockAddr::v4, and XrdNetSockAddr::v6.

Referenced by XrdNetPMarkFF::Start().

Here is the call graph for this function:
Here is the caller graph for this function:

## Hosts()

XrdOucTList * XrdNetUtils::Hosts | ( | const char * | hSpec,
|  | int | hPort = -1,
|  | int | hWant = 8,
|  | int * | sPort = 0,
|  | const char ** | eText = 0 )

static

Obtain an easily digestable list of hosts. This is the list of up to eight unique aliases (i.e. with different addresses) assigned to a base hostname.

Parameters

  hSpec | the host specification suitable for XrdNetAddr.Set().
  hPort | When >= 0 specified the port to use regardless of hSpec. When < 0 the port must be present in hSpec.
  hWant | Maximum number of list entries wanted. If hWant is greater that eight it is set eigth.
  sPort | If not nil, the *sPort will be set to hPort if and only if the IP address in one of the entries matches the host address. Otherwise, the value is unchanged.
  eText | When not nil, is where to place error message text.

Returns
  Success: Pointer to a list of XrdOucTList objects where p->val is the port number p->text is the host name. The list of objects belongs to the caller. Failure: A nil pointer is returned. If eText is supplied, the error message, in persistent storage, is returned.

Definition at line 576 of file XrdNetUtils.cc.

{
static const int hMax = 8;
XrdNetAddr myAddr(0), aList[hMax];
XrdOucTList *tList = 0;
const char *etext, *hName;
int numIP, i, k;
// Check if the port must be in the spec and set maximum
//
if (hPort < 0) hPort = XrdNetAddr::PortInSpec;
if (hWant > hMax) hWant = hMax;
else if (hWant < 1) hWant = 1;
// Initialze the list of addresses
//
if ((etext = aList[0].Set(hSpec, numIP, hWant, hPort)))
{if (eText) *eText = etext;
return 0;
}
// Create the tlist object list without duplicates. We may have duplicates as
// this may be a multi-homed node and we don't want to show that here.
//
for (i = 0; i < numIP; i++)
{if (sPort && myAddr.Same(&aList[i]))
{*sPort = aList[i].Port(); sPort = 0;}
hName = aList[i].Name("");
for (k = 0; k < i; k++) {if (!strcmp(hName, aList[k].Name(""))) break;}
if (k >= i) tList = new XrdOucTList(hName, aList[i].Port(), tList);
}
// All done, return the result
//
if (eText) *eText = (tList ? 0 : "unknown processing error");
return tList;
}
XrdNetAddrInfo::Name
const char * Name(const char *eName=0, const char **eText=0)
Definition XrdNetAddrInfo.cc:309
XrdNetAddr::Port
int Port(int pNum=-1)
Definition XrdNetAddr.cc:156
XrdNetAddr::PortInSpec
static const int PortInSpec
Definition XrdNetAddr.hh:112
XrdNetUtils::Port
static int Port(int fd, const char **eText=0)
Definition XrdNetUtils.cc:815

References XrdNetAddrInfo::Name(), XrdNetAddr::Port(), Port(), and XrdNetAddr::PortInSpec.

Referenced by XrdCmsUtils::ParseMan(), and Singleton().

Here is the call graph for this function:
Here is the caller graph for this function:

## IPFormat() [1/2]

int XrdNetUtils::IPFormat | ( | const struct sockaddr * | sAddr,
|  | char * | bP,
|  | int | bL,
|  | int | opts = 0 )

static

Definition at line 619 of file XrdNetUtils.cc.

{
XrdNetAddr theAddr;
int fmtopts = (opts & oldFmt ? XrdNetAddrInfo::old6Map4 : 0);
// Set the address
//
if (theAddr.Set(sAddr)) return 0;
// Now format the address
//
if (opts & noPort) fmtopts |= XrdNetAddrInfo::noPort;
return theAddr.Format(bP, bL, XrdNetAddrInfo::fmtAdv6, fmtopts);
}
XrdNetAddrInfo::noPort
static const int noPort
Do not add port number.
Definition XrdNetAddrInfo.hh:104
XrdNetAddrInfo::old6Map4
static const int old6Map4
Use deprecated IPV6 mapped format.
Definition XrdNetAddrInfo.hh:106
XrdNetAddrInfo::fmtAdv6
@ fmtAdv6
Definition XrdNetAddrInfo.hh:102
XrdNetUtils::oldFmt
static const int oldFmt
Definition XrdNetUtils.hh:274
XrdNetUtils::noPort
static const int noPort
Definition XrdNetUtils.hh:273

References XrdNetAddrInfo::fmtAdv6, XrdNetAddrInfo::Format(), XrdNetAddrInfo::noPort, noPort, XrdNetAddrInfo::old6Map4, oldFmt, opts, and XrdNetAddr::Set().

Referenced by XrdSecProtocolsss::getCredentials(), XrdCl::Socket::GetPeerName(), XrdCl::Socket::GetSockName(), and IPFormat().

Here is the call graph for this function:
Here is the caller graph for this function:

## IPFormat() [2/2]

int XrdNetUtils::IPFormat | ( | int | fd,
|  | char * | bP,
|  | int | bL,
|  | int | opts = 0 )

static

Convert an IP socket address/port (V4 or V6) into the standard V6 RFC ASCII representation: "[address]:port".

Parameters

  fd | The file descriptor of the socket whose address is to be converted. The sign of the fd indicates which address: fd > 0 the peer address is used (i.e. getpeername) fd < 0 the local address is used (i.e. getsockname)
  bP | points to a buffer large enough to hold the result. A buffer 64 characters long will always be big enough.
  bL | the actual size of the buffer.
  opts | Formating options: noPort - does not suffix the port number with ":port". oldFmt - use the deprecated format for an IPV4 mapped address: [::d.d.d.d] vs [::ffff:d.d.d.d].

Returns
  Success: The length of the formatted address is returned.
  Failure: Zero is returned and the buffer state is undefined. Failure occurs when the buffer is too small or the file descriptor does not refer to an open socket.

Definition at line 637 of file XrdNetUtils.cc.

{
XrdNetSockAddr theIP;
SOCKLEN_t addrSize = sizeof(theIP);
int rc;
// The the address wanted
//
rc = (fd > 0 ? getpeername( fd, &theIP.Addr, &addrSize)
: getsockname(-fd, &theIP.Addr, &addrSize));
if (rc) return 0;
// Now format it
//
return IPFormat(&theIP.Addr, bP, bL, opts);
}
XrdNetUtils::IPFormat
static int IPFormat(const struct sockaddr *sAddr, char *bP, int bL, int opts=0)
Definition XrdNetUtils.cc:619

References XrdNetSockAddr::Addr, IPFormat(), opts, and SOCKLEN_t.

Here is the call graph for this function:

## Match()

bool XrdNetUtils::Match | ( | const char * | hName,
|  | const char * | pattern )

static

Determine if a hostname matches a pattern.

Parameters

  hName | the name of the host.

  pattern

  the pattern to match against. The pattern may contain one If the pattern contains a single asterisk, then the prefix of hName is compared with the characters before the '*' and the suffix of hName is compared with the character after. If the pattern ends with a plus, the all then pattern is taken as a hostname (less '+') and expanded to all possible hostnames and each one is compared with hName. If the pattern contains both, the asterisk rule is used first. If it contains neither then strict equality is used.

Returns
  Success: True, the pattern matches. Failure: False, no match found.

Definition at line 658 of file XrdNetUtils.cc.

{
static const int maxIP = 16;
const char *mval;
int i, j, k;
// First check if this will match right away
//
if (!strcmp(HostPat, HostName)) return true;
// Check for an asterisk do prefix/suffix match
//
if ((mval = index(HostPat, (int)'*')))
{ i = mval - HostPat; mval++;
k = strlen(HostName); j = strlen(mval);
if ((i+j) > k
|| strncmp(HostName, HostPat,i)
|| strncmp((HostName+k-j),mval,j)) return false;
return 1;
}
// Now check for host expansion
//
i = strlen(HostPat);
if (i && HostPat[i-1] == '+')
{XrdNetAddr InetAddr[maxIP];
char hBuff[264];
if (i >= (int)sizeof(hBuff)) return false;
memcpy(hBuff, HostPat, i-1);
hBuff[i-1] = 0;
if (InetAddr[0].Set(hBuff, i, maxIP, 0)) return false;
while(i--) if ((mval = InetAddr[i].Name()) && !strcmp(mval, HostName))
return true;
}
// No matches
//
return false;
}

Referenced by XrdOucUtils::doIf().

Here is the caller graph for this function:

## MyHostName()

char * XrdNetUtils::MyHostName | ( | const char * | eName = "*unknown*",
|  | const char ** | eText = 0 )

static

Get the fully qualified name of the current host.

Parameters

  eName | The name to be returned when the host name or its true address could not be returned. The pointer may be nil.
  eText | When supplied will hold 0 if no errors occurred or error message text, in persistent storage, describing why the error-triggered alternate name was returned. If it contains neither then strict equality is used.

Returns
  An strdup() copy of the host name, address , or eName; unless eName is nil, in which case a nil pointer is returned. The caller is responsible for freeing any returned string using free().

Definition at line 702 of file XrdNetUtils.cc.

{
const char *fqn = XrdNetIdentity::FQN(eText);
// Return the appropriate result
//
if (!fqn) fqn = eName;
return (fqn ? strdup(fqn) : 0);
}
XrdNetIdentity::FQN
static const char * FQN(const char **etext=0)
Definition XrdNetIdentity.cc:187

References XrdNetIdentity::FQN().

Referenced by XrdNetPMarkCfg::Config(), XrdSecProtocolsss::Load_Client(), and XrdSecProtocolkrb5Init().

Here is the call graph for this function:
Here is the caller graph for this function:

## NetConfig()

XrdNetUtils::NetProt XrdNetUtils::NetConfig | ( | XrdNetUtils::NetType | netquery = qryINET,
|  | const char ** | eText = 0 )

static

Definition at line 716 of file XrdNetUtils.cc.

{
XrdNetAddr *myAddrs;
const char *eMsg;
char buff[1024];
NetProt hasProt = hasNone;
int aCnt, ifType;
// Make sure we support this query
//
if (netquery != qryINET && netquery != qryINIF)
{if (eText) *eText = "unsupported NetType query";
return hasNone;
}
// We base the nonfig of the interface addresses unless we can't query the if's
//
if (netquery == qryINIF && (ifType = XrdNetIF::GetIF((XrdOucTList **)0,0)))
{if (ifType & XrdNetIF::haveIPv4) hasProt = NetProt(hasProt | hasIPv4);
if (ifType & XrdNetIF::haveIPv6) hasProt = NetProt(hasProt | hasIPv6);
if (ifType & XrdNetIF::havePub4) hasProt = NetProt(hasProt | hasPub4);
if (ifType & XrdNetIF::havePub6) hasProt = NetProt(hasProt | hasPub6);
return hasProt;
}
// Get our host name and initialize this object with it
//
gethostname(buff, sizeof(buff));
XrdOucUtils::toLower(buff);
// Now get all of the addresses associated with this hostname
//
if ((eMsg = GetAddrs(buff, &myAddrs, aCnt, allIPv64, NoPortRaw)))
{if (eText) *eText = eMsg;
return hasNone;
}
// Now run through all of the addresses to see what we have
//
for (int i = 0; i < aCnt && hasProt != hasIP64; i++)
{ if (myAddrs[i].isIPType(XrdNetAddrInfo::IPv6))
{hasProt = NetProt(hasProt | hasIPv6);
if (!myAddrs[i].isPrivate())
hasProt = NetProt(hasProt | hasPub6);
}
else if (myAddrs[i].isIPType(XrdNetAddrInfo::IPv4))
{hasProt = NetProt(hasProt | hasIPv4);
if (!myAddrs[i].isPrivate())
hasProt = NetProt(hasProt | hasPub4);
}
}
// Delete the array and return what we have
//
delete [] myAddrs;
if (hasProt == hasNone && eText) *eText = "";
return hasProt;
}
eMsg
#define eMsg(x)
Definition XrdSecsssAdmin.cc:53
XrdNetAddrInfo::IPv6
@ IPv6
Definition XrdNetAddrInfo.hh:144
XrdNetIF::haveIPv4
static const int haveIPv4
ifList == 0 && non-local ipv4 i/f found (or'd)
Definition XrdNetIF.hh:150
XrdNetIF::GetIF
static int GetIF(XrdOucTList **ifList, const char **eText=0)
Definition XrdNetIF.cc:413
XrdNetIF::havePub6
static const int havePub6
ifList == 0 && public ipv6 i/f found (or'd)
Definition XrdNetIF.hh:160
XrdNetIF::havePub4
static const int havePub4
ifList == 0 && public ipv4 i/f found (or'd)
Definition XrdNetIF.hh:158
XrdNetIF::haveIPv6
static const int haveIPv6
ifList == 0 && non-local ipv6 i/f found (or'd)
Definition XrdNetIF.hh:152
XrdNetUtils::NoPortRaw
static const int NoPortRaw
Definition XrdNetUtils.hh:150
XrdNetUtils::NetProt
NetProt
Definition XrdNetUtils.hh:351
XrdNetUtils::GetAddrs
static const char * GetAddrs(const char *hSpec, XrdNetAddr *aListP[], int &aListN, AddrOpts opts=allIPMap, int pNum=PortInSpec)
Definition XrdNetUtils.cc:274
XrdOucUtils::toLower
static void toLower(char *str)
Definition XrdOucUtils.cc:1226

References allIPv64, eMsg, GetAddrs(), XrdNetIF::GetIF(), hasIP64, hasIPv4, hasIPv6, hasNone, hasPub4, hasPub6, XrdNetIF::haveIPv4, XrdNetIF::haveIPv6, XrdNetIF::havePub4, XrdNetIF::havePub6, XrdNetAddrInfo::IPv4, XrdNetAddrInfo::IPv6, NoPortRaw, qryINET, qryINIF, and XrdOucUtils::toLower().

Referenced by XrdCl::Stream::Stream().

Here is the call graph for this function:
Here is the caller graph for this function:

## Parse()

bool XrdNetUtils::Parse | ( | const char * | hSpec,
|  | const char ** | hName,
|  | const char ** | hNend,
|  | const char ** | hPort,
|  | const char ** | hPend )

static

Parse an IP or host name specification.

Parameters

  hSpec | the name or IP address of the host. As one of the following "[<ipv6>]:<port>", "<ipv4>:<port>", or "<name>:<port>".
  hName | place where the starting address of the host is placed.
  hNend | place where the ending address+1 is placed. This will point to either ']', ':', or a null byte.
  hPort | place where the starting address of the port is placed. If no ":port" was found, this will contain *hNend.
  hPend | place where the ending address+1 is placed. If no port If no ":port" was found, this will contain *hNend.

Returns
  Success: True. Failure: False, hSpec is not valid. Some output parameters may have been set but shlould be ignored.

Definition at line 780 of file XrdNetUtils.cc.

{
const char *asep = 0;
// Parse the specification
//
if (*hSpec == '[')
{if (!(*hNend = index(hSpec+1, ']'))) return false;
*hName = hSpec+1; asep = (*hNend)+1;
} else {
*hName = hSpec;
if (!(*hNend = index(hSpec, ':'))) *hNend = hSpec + strlen(hSpec);
else asep = *hNend;
}
// See if we have a port to parse. We stop on a non-alphameric.
//
if (asep && *asep == ':')
{*hPort = ++asep;
while(isalnum(*asep)) asep++;
if (*hPort == asep) return false;
*hPend = asep;
} else *hPort = *hPend = *hNend;
// All done
//
return true;
}

Referenced by XrdOucUtils::isFWD(), XrdNetAddr::Set(), and XrdFfsMisc_get_list_of_data_servers().

Here is the caller graph for this function:

## Port()

int XrdNetUtils::Port | ( | int | fd,
|  | const char ** | eText = 0 )

static

Obtain the numeric port associated with a file descriptor.

Parameters

  fd | the file descriptor number.
  eText | when not null, the reason for a failure is returned.

Returns
  Success: The positive port number. Failure: 0 is returned and if eText is not null, the error message.

Definition at line 815 of file XrdNetUtils.cc.

{
XrdNetSockAddr Inet;
SOCKLEN_t slen = (socklen_t)sizeof(Inet);
int rc;
if ((rc = getsockname(fd, &Inet.Addr, &slen)))
{rc = errno;
if (eText) setET(eText, errno);
return -rc;
}
return static_cast<int>(ntohs(Inet.v6.sin6_port));
}

References XrdNetSockAddr::Addr, SOCKLEN_t, and XrdNetSockAddr::v6.

Referenced by XrdNet::Bind(), and Hosts().

Here is the caller graph for this function:

## ProtoID()

int XrdNetUtils::ProtoID | ( | const char * | pName | ) |

static

Obtain the protocol identifier.

Parameters

  pName | the name of the protocol (e.g. "tcp").

Returns
  The protocol identifier.

Definition at line 838 of file XrdNetUtils.cc.

{
#ifdef HAVE_PROTOR
struct protoent pp;
char buff[1024];
#else
static XrdSysMutex protomutex;
struct protoent *pp;
int protoid;
#endif
// Note that POSIX did include getprotobyname_r() in the last minute. Many
// platforms do not document this variant but just about all include it.
//
#ifdef __solaris__
if (!getprotobyname_r(pname, &pp, buff, sizeof(buff)))
return IPPROTO_TCP;
return pp.p_proto;
#elif !defined(HAVE_PROTOR)
protomutex.Lock();
if (!(pp = getprotobyname(pname))) protoid = IPPROTO_TCP;
else protoid = pp->p_proto;
protomutex.UnLock();
return protoid;
#else
struct protoent *ppp;
if (getprotobyname_r(pname, &pp, buff, sizeof(buff), &ppp))
return IPPROTO_TCP;
return pp.p_proto;
#endif
}
IPPROTO_TCP
#define IPPROTO_TCP
Definition XrdNetUtils.cc:835
XrdSysMutex::Lock
void Lock()
Definition XrdSysPthread.hh:222
XrdSysMutex::UnLock
void UnLock()
Definition XrdSysPthread.hh:224

References IPPROTO_TCP, XrdSysMutex::Lock(), and XrdSysMutex::UnLock().

Referenced by XrdNetSocket::setOpts().

Here is the call graph for this function:
Here is the caller graph for this function:

## ServPort()

int XrdNetUtils::ServPort | ( | const char * | sName,
|  | bool | isUDP = false,
|  | const char ** | eText = 0 )

static

Obtain the numeric port corresponding to a symbolic name.

Parameters

  sName | the name of the service or a numeric port number.
  isUDP | if true, returns the UDP service port o/w the TCP service
  eText | when not null, the reason for a failure is returned.

Returns
  Success: The positive port number. Failure: 0 is returned and if eText is not null, the error message.

Definition at line 874 of file XrdNetUtils.cc.

{
struct addrinfo *rP = 0, myHints;
int rc, portnum = 0;
// First check if this is a plain number
//
if (isdigit(*sName))
{char *send;
portnum = strtol(sName, &send, 10);
if (portnum > 0 && portnum < 65536 && *send == 0) return portnum;
if (eText) *eText = "invalid port number";
return 0;
}
// Fill out the hints
//
memset(&myHints, 0, sizeof(myHints));
myHints.ai_socktype = (isUDP ? SOCK_DGRAM : SOCK_STREAM);
// Try to find the port number
//
rc = getaddrinfo(0, sName, &myHints, &rP);
if (rc || !rP)
{if (eText) *eText = (rc ? gai_strerror(rc) : "service not found");
if (rP) freeaddrinfo(rP);
return 0;
}
// Return the port number
//
portnum = int(ntohs(SIN_PORT(rP))) & 0x0000ffff;
freeaddrinfo(rP);
if (!portnum && eText) *eText = "service has no port";
return portnum;
}
SIN_PORT
#define SIN_PORT(x)
Definition XrdNetUtils.cc:199

References SIN_PORT.

Referenced by XrdOuca2x::a2p(), XrdCmsUtils::ParseMan(), and XrdNetAddr::Set().

Here is the caller graph for this function:

## SetAuto()

int XrdNetUtils::SetAuto | ( | XrdNetUtils::AddrOpts | aOpts = allIPMap | ) |

static

Set the family and hints to be used in GetAddrs() with prefAuto. This is used within this class and by XrdNetAddr when the IP mode changes. It is meant for internal use only.

Parameters

  aOpts | Is one of the following from the AddrOpts enum: allIPMap - Use IPv6 and mapped IPv4 addrs (default) onlyIPv4 - Use only IPv4 addresses. prefAuto - Determine proper options based on configuration.

Returns
  The getaddrinfo() hints value that should be used.

Definition at line 915 of file XrdNetUtils.cc.

{
// If a specific family is not specified, then determine which families to use
//
if (aOpts != onlyIPv4 && aOpts != allIPMap)
{int ifTypes = XrdNetIF::GetIF(0);
if (ifTypes & XrdNetIF::haveIPv6) aOpts = allIPMap;
else if (ifTypes & XrdNetIF::haveIPv4) aOpts = onlyIPv4;
else {autoFamily = AF_UNSPEC; autoHints = AI_V4MAPPED | AI_ADDRCONFIG;
return AI_V4MAPPED | AI_ADDRCONFIG;
}
}
// If this is forced IPv4 then we know how to set the hints
//
if (aOpts == onlyIPv4)
{autoFamily = AF_INET; autoHints = 0; return 0;}
// So, this is IPv6. Be as flexible as possible.
//
autoFamily = AF_INET6;
autoHints = AI_V4MAPPED | AI_ALL;
return AI_V4MAPPED | AI_ALL;
}

References allIPMap, XrdNetIF::GetIF(), XrdNetIF::haveIPv4, XrdNetIF::haveIPv6, and onlyIPv4.

Referenced by XrdNetAddr::SetIPV4(), and XrdNetAddr::SetIPV6().

Here is the call graph for this function:
Here is the caller graph for this function:

## Singleton()

bool XrdNetUtils::Singleton | ( | const char * | hSpec,
|  | const char ** | eText = 0 )

static

Check if whether or not a host name represents more than one unique host.

Parameters

  hSpec | the host specification suitable for XrdNetAddr.Set().
  eText | When not nil, is where to place error message text.

Returns
  True is this is a simple single host. False if the name represensts more than one single host.

Definition at line 956 of file XrdNetUtils.cc.

{
XrdOucTList *hList, *hNow;
bool isSingle;
// Obtain a list of unique hostnames associated with this host
//
hList = Hosts(hSpec, 1234, 2, 0, eText);
// If this is none or only one then this is a singleton
//
isSingle = !hList || hList->next == 0;
// Free up the list of hosts
//
while((hNow = hList))
{hList = hList->next;
delete hNow;
};
// All done
//
return isSingle;
}
XrdNetUtils::Hosts
static XrdOucTList * Hosts(const char *hSpec, int hPort=-1, int hWant=8, int *sPort=0, const char **eText=0)
Definition XrdNetUtils.cc:576
XrdOucTList::next
XrdOucTList * next
Definition XrdOucTList.hh:45

References Hosts(), and XrdOucTList::next.

Referenced by XrdSsiClientProvider::GetService().

Here is the call graph for this function:
Here is the caller graph for this function:

## Member Data Documentation

## noPort

const int XrdNetUtils::noPort = 1

static

Convert an IP address/port (V4 or V6) into the standard V6 RFC ASCII representation: "[address]:port".

Parameters

  sAddr | Address to convert. This is either sockaddr_in or sockaddr_in6 cast to struct sockaddr.
  bP | points to a buffer large enough to hold the result. A buffer 64 characters long will always be big enough.
  bL | the actual size of the buffer.
  opts | Formating options: noPort - does not suffix the port number with ":port". oldFmt - use the deprecated format for an IPV4 mapped address: [::d.d.d.d] vs [::ffff:d.d.d.d].

Returns
  Success: The length of the formatted address is returned.
  Failure: Zero is returned and the buffer state is undefined. Failure occurs when the buffer is too small or the address family (sAddr->sa_family) is neither AF_INET nor AF_INET6.

Definition at line 273 of file XrdNetUtils.hh.

Referenced by IPFormat().

## NoPortRaw

const int XrdNetUtils::NoPortRaw = (int)0xC0000000

static

Definition at line 150 of file XrdNetUtils.hh.

Referenced by NetConfig(), and XrdNetAddr::Register().

## oldFmt

const int XrdNetUtils::oldFmt = 2

static

Definition at line 274 of file XrdNetUtils.hh.

Referenced by XrdSecProtocolsss::getCredentials(), and IPFormat().

## PortInSpec

const int XrdNetUtils::PortInSpec = (int)0x80000000

static

Definition at line 149 of file XrdNetUtils.hh.

Referenced by GetAddrs().

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

- XrdNetUtils.hh
- XrdNetUtils.cc