![]() |
XRootD
|
#include <XrdNetAddr.hh>
Public Member Functions | |
XrdNetAddr () | |
Assignment operator and copy constructor are inherited, no need to define. More... | |
XrdNetAddr (const sockaddr *addr) | |
XrdNetAddr (const sockaddr_in *addr) | |
XrdNetAddr (const sockaddr_in6 *addr) | |
XrdNetAddr (const XrdNetAddr *addr) | |
XrdNetAddr (int port) | |
~XrdNetAddr () | |
Destructor. More... | |
int | Port (int pNum=-1) |
bool | Register (const char *hName) |
const char * | Set (const char *hSpec, int &numIP, int maxIP, int pNum=PortInSpec, bool forUDP=false) |
const char * | Set (const char *hSpec, int pNum=PortInSpec) |
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) |
![]() | |
XrdNetAddrInfo () | |
Constructor. More... | |
XrdNetAddrInfo (const XrdNetAddrInfo *addr) | |
XrdNetAddrInfo (XrdNetAddrInfo const &oP) | |
Copy constructor. More... | |
~XrdNetAddrInfo () | |
Destructor. More... | |
const char * | Dialect () |
int | Family () const |
int | Format (char *bAddr, int bLen, fmtUse fmtType=fmtAuto, int fmtOpts=0) |
bool | isIPType (IPType ipType) const |
bool | isLoopback () |
bool | isMapped () const |
bool | isPrivate () |
bool | isRegistered () |
bool | isUsingTLS () |
const struct LocInfo * | Location () |
const char * | Name (const char *eName=0, const char **eText=0) |
const XrdNetSockAddr * | NetAddr () |
XrdNetAddrInfo & | operator= (XrdNetAddrInfo const &rhs) |
Assignment operator. More... | |
int | Port () |
int | Protocol () |
int | Same (const XrdNetAddrInfo *ipAddr, bool plusPort=false) |
const sockaddr * | SockAddr () |
int | SockFD () |
SOCKLEN_t | SockSize () |
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 bool | isHostName (const char *name) |
Static Public Attributes | |
static const int | PortInSpec = (int)0x80000000 |
![]() | |
static const int | noPort = 0x0000001 |
Do not add port number. More... | |
static const int | noPortRaw = 0x0000002 |
Use raw address format (no port) More... | |
static const int | old6Map4 = 0x0000004 |
Use deprecated IPV6 mapped format. More... | |
static const int | prefipv4 = 0x0000008 |
Use if mapped IPV4 actual format. More... | |
Additional Inherited Members | |
![]() | |
enum | fmtUse { fmtAuto =0 , fmtName , fmtAddr , fmtAdv6 } |
enum | IPType { IPv4 = AF_INET , IPv6 = AF_INET6 , IPuX = AF_UNIX } |
![]() | |
char * | LowCase (char *str) |
int | QFill (char *bAddr, int bLen) |
int | Resolve () |
![]() | |
union { | |
struct sockaddr * | sockAddr |
struct sockaddr_un * | unixPipe |
}; | |
LocInfo | addrLoc |
unsigned short | addrSize |
char * | hostName |
XrdNetSockAddr | IP |
unsigned char | protFlgs |
const char * | protName |
unsigned char | protType |
int | sockNum |
![]() | |
static XrdNetCache * | dnsCache = 0 |
static const char | isTLS = 0x01 |
Location using TLS. More... | |
Definition at line 41 of file XrdNetAddr.hh.
|
inline |
Assignment operator and copy constructor are inherited, no need to define.
Constructor
addr | A pointer to an initialized and valid sockaddr or sockaddr compatible structure used to initialize the address. |
port | Uses the address of the current host and the speoified port number to initilize the address. |
Definition at line 265 of file XrdNetAddr.hh.
|
inline |
Definition at line 267 of file XrdNetAddr.hh.
|
inline |
Definition at line 269 of file XrdNetAddr.hh.
References Set().
|
inline |
Definition at line 272 of file XrdNetAddr.hh.
References Set().
|
inline |
Definition at line 275 of file XrdNetAddr.hh.
References Set().
XrdNetAddr::XrdNetAddr | ( | int | port | ) |
Definition at line 95 of file XrdNetAddr.cc.
References XrdNetIdentity::FQN(), XrdNetAddrInfo::hostName, and Set().
|
inline |
|
inlinestatic |
Determine if dynamic DNS has been set.
Definition at line 52 of file XrdNetAddr.hh.
Referenced by XrdCmsUtils::ParseMan().
|
inlinestatic |
Determine if IPV4 mode has been set.
Definition at line 61 of file XrdNetAddr.hh.
Referenced by XrdInet::BindSD(), and XrdConfig::Configure().
int XrdNetAddr::Port | ( | int | pNum = -1 | ) |
Optionally set and also returns the port number for our address.
pNum | when negative it only returns the current port. Otherwise, it is taken as the value to be set. |
Definition at line 156 of file XrdNetAddr.cc.
References XrdNetSockAddr::Addr, XrdNetAddrInfo::IP, and XrdNetSockAddr::v6.
Referenced by XrdBwm::XrdBwm(), XrdPosixAdmin::FanOut(), XrdNetUtils::Hosts(), and XrdCmsManager::Rerun().
bool XrdNetAddr::Register | ( | const char * | hName | ) |
Register a host name with this IP address. This is not MT-safe!
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. |
Definition at line 180 of file XrdNetAddr.cc.
References XrdNetUtils::allIPMap, XrdNetUtils::GetAddrs(), XrdNetAddrInfo::hostName, XrdNetAddrInfo::isHostName(), XrdNetUtils::NoPortRaw, and XrdNetAddrInfo::Same().
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.
hSpec | 0 -> 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() |
maxIP | number of elements in the array. |
numIP | the 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. |
forUDP | when true addresses are usable for UDP connections. Otherwise, they are for TCP connections. |
Definition at line 343 of file XrdNetAddr.cc.
References eMsg, XrdNetUtils::Parse(), PortInSpec, XrdNetUtils::ServPort(), and Set().
const char * XrdNetAddr::Set | ( | const char * | hSpec, |
int | pNum = PortInSpec |
||
) |
Definition at line 216 of file XrdNetAddr.cc.
References XrdNetSockAddr::Addr, XrdNetAddrInfo::addrSize, XrdNetAddrInfo::hostName, XrdNetAddrInfo::IP, XrdNetAddrInfo::isHostName(), XrdNetAddrInfo::LowCase(), PortInSpec, XrdNetAddrInfo::protType, XrdNetSockAddr::v4, and XrdNetSockAddr::v6.
Referenced by XrdTpc::PMarkManager::SocketInfo::SocketInfo(), XrdNetAddr(), XrdNetMsg::XrdNetMsg(), XrdSecProtocolgsi::XrdSecProtocolgsi(), XrdNetSecurity::Authorize(), XrdNetPMarkCfg::Config(), XrdNet::Connect(), XrdCmsNode::do_SelAvoid(), XrdPosixAdmin::FanOut(), XrdNetIF::GetIF(), XrdSsiClientProvider::GetService(), XrdNetUtils::GetSokInfo(), XrdNetUtils::IPFormat(), XrdOucReqID::isMine(), XrdCmsRedirLocal::Locate(), main(), XrdNetSocket::Open(), XrdCmsUtils::ParseMan(), XrdCmsManager::Rerun(), XrdMpxOut::Run(), XrdNetMsg::Send(), XrdOfsTPCInfo::Set(), Set(), XrdOfsTPC::Verify(), XrdFfsMisc_get_list_of_data_servers(), and XrdFfsMisc_getNameByAddr().
const char * XrdNetAddr::Set | ( | const struct sockaddr * | sockP, |
int | sockFD = -1 |
||
) |
Set our address via a sockaddr structure.
sockP | a pointer to an initialized and valid sockaddr structure. |
sockFD | the associated file descriptor and can be used to record the file descriptor returned by accept(). |
Definition at line 406 of file XrdNetAddr.cc.
References XrdNetSockAddr::Addr, XrdNetAddrInfo::addrSize, XrdNetAddrInfo::hostName, XrdNetAddrInfo::IP, XrdNetAddrInfo::protType, XrdNetAddrInfo::sockNum, XrdNetSockAddr::v4, and XrdNetSockAddr::v6.
const char * XrdNetAddr::Set | ( | int | sockFD, |
bool | peer = true |
||
) |
Set our address from the supplied socket file descriptor.
sockFD | a connected socket file descriptor. The value is also recorded as the associated file descriptor. |
peer | When true the address is set from getpeername() When false the address is set from getsockname() |
Definition at line 442 of file XrdNetAddr.cc.
References XrdNetSockAddr::Addr, XrdNetAddrInfo::addrSize, XrdNetAddrInfo::hostName, XrdNetAddrInfo::IP, XrdNetAddrInfo::protType, SOCKLEN_t, XrdNetAddrInfo::sockNum, and XrdSysE2T().
const char * XrdNetAddr::Set | ( | struct addrinfo * | rP, |
int | port, | ||
bool | mapit = false |
||
) |
Set our address via and addrinfo structure and initialize the port.
rP | pointer to an addrinfo structure. |
port | the port number to set. |
mapit | when true maps IPv4 addresses to IPv6. Otherwise, does not. |
Definition at line 474 of file XrdNetAddr.cc.
References XrdNetSockAddr::Addr, XrdNetAddrInfo::addrSize, XrdNetAddrInfo::hostName, XrdNetAddrInfo::IP, XrdNetAddrInfo::LowCase(), XrdNetAddrInfo::Port(), XrdNetAddrInfo::protType, XrdNetAddrInfo::sockNum, and XrdNetSockAddr::v6.
|
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.
Definition at line 507 of file XrdNetAddr.cc.
References XrdNetAddrInfo::dnsCache, and XrdPosixGlobals::theCache.
Referenced by XrdConfig::XrdConfig().
|
inline |
Set the dialect being spoken on this network link.
dP | Pointer to the dialect name. It must be permanently stable. |
Definition at line 205 of file XrdNetAddr.hh.
References XrdNetAddrInfo::protName.
Referenced by XrdHttpProtocol::Match(), and XrdLinkXeq::setProtName().
|
static |
Indicate whether or not dynamic DNS is being used. This method should only be called during initialization time. The default is fixed DNS.
onoff | True if dynamic DNS is being used, false otherwise. |
Definition at line 521 of file XrdNetAddr.cc.
|
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).
Definition at line 527 of file XrdNetAddr.cc.
References XrdNetUtils::onlyIPv4, and XrdNetUtils::SetAuto().
Referenced by XrdConfig::Configure().
|
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).
Definition at line 553 of file XrdNetAddr.cc.
References XrdNetUtils::allIPMap, and XrdNetUtils::SetAuto().
Referenced by XrdConfig::Configure().
void XrdNetAddr::SetLocation | ( | XrdNetAddrInfo::LocInfo & | loc | ) |
Set the location for this address
loc | pointer to the structure that describes the location. See XrdnetAddrInfo for the definition of the stucture. |
Definition at line 579 of file XrdNetAddr.cc.
References XrdNetAddrInfo::addrLoc.
Referenced by XrdLinkXeq::setLocation().
void XrdNetAddr::SetTLS | ( | bool | val | ) |
Set the location's TLS state.
val | True if TLS is being used, false otherwise. |
Definition at line 590 of file XrdNetAddr.cc.
References XrdNetAddrInfo::isTLS, and XrdNetAddrInfo::protFlgs.
Referenced by XrdHttpProtocol::Match(), and XrdLinkXeq::setTLS().
|
static |
Set the IP address and possibly the port number.
hSpec | 0 -> 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. |
Definition at line 112 of file XrdNetAddr.hh.
Referenced by XrdNetUtils::Hosts(), XrdNetSocket::Open(), and Set().