![]() |
XRootD
|
#include <XrdNet.hh>
Public Member Functions | |
XrdNet (XrdSysError *erp, XrdNetSecurity *secp=0) | |
virtual | ~XrdNet () |
Destructor. | |
int | Accept (XrdNetAddr &myAddr, int opts=0, int timeout=-1) |
int | Accept (XrdNetPeer &myPeer, int opts=0, int timeout=-1) |
int | Bind (char *path, const char *contype="stream") |
int | Bind (int port, const char *contype="tcp") |
int | Connect (XrdNetAddr &myAddr, const char *dest, int port=-1, int opts=0, int timeout=-1) |
int | Connect (XrdNetPeer &myPeer, const char *dest, int port=-1, int opts=0, int timeout=-1) |
int | Port () |
int | Relay (const char *dest) |
int | Relay (XrdNetPeer &Peer, const char *dest, int opts=0) |
virtual void | Secure (XrdNetSecurity *secp) |
void | setDefaults (int options, int buffsz=0) |
void | setDomain (const char *dname) |
void | Trim (char *hname) |
void | unBind () |
Unbind the network from any bound resouces. | |
int | WSize () |
Protected Attributes | |
XrdNetBufferQ * | BuffQ |
int | BuffSize |
char * | Domain |
int | Domlen |
XrdSysError * | eDest |
int | iofd |
int | netOpts |
XrdNetSecurity * | Police |
int | Portnum |
int | PortType |
int | Windowsz |
XrdNet::XrdNet | ( | XrdSysError * | erp, |
XrdNetSecurity * | secp = 0 |
||
) |
Constructor
erp | The error object for printing error messages. It must be supplied. |
secp | The initial NetSecurity object. This secp object must not be deleted nor directly used after the call as this object assumes its ownership and may delete it at any time. |
Definition at line 60 of file XrdNet.cc.
References BuffQ, Domain, Domlen, eDest, iofd, netOpts, Police, Portnum, PortType, and Windowsz.
|
virtual |
int XrdNet::Accept | ( | XrdNetAddr & | myAddr, |
int | opts = 0 , |
||
int | timeout = -1 |
||
) |
Accept incoming TCP connection. This is the preferred method for TCP.
myAddr | the address object to contain connection information. |
opts | processing options: XRDNET_DELAY - do not set nodelay on socket. XRDNET_KEEPALIVE - use TCP keep alive on socket. XRDNET_NOCLOSEX - do not allow socket to close on exec() XRDNET_NOEMSG - supress printing error messages XRDNET_NOLINGER - Do not linger when closing socket. |
timeout | maximum seconds to wait for a conection. When negative, the default, no time limit applies. |
Definition at line 84 of file XrdNet.cc.
References eDest, XrdSysError::Emsg(), iofd, netOpts, opts, PortType, and XRDNET_NOEMSG.
Referenced by XrdInet::Accept().
int XrdNet::Accept | ( | XrdNetPeer & | myPeer, |
int | opts = 0 , |
||
int | timeout = -1 |
||
) |
Accept incoming TCP or UDP connection. This method should only be used for UDP-style networks. The previous method is preferred for TCP-style networks.
myPeer | the peer object to contain connection information. |
opts | processing options: XRDNET_DELAY - TCP: do not set nodelay on socket. XRDNET_KEEPALIVE - TCP: use TCP keep alive on socket. XRDNET_NEWFD - UDP: obtain new file descriptor XRDNET_NOCLOSEX - ALL: keep socket across exec() calls XRDNET_NODNTRIM - ALL: don't trim domain name in myPeer XRDNET_NOEMSG - ALL: supress printing error messages XRDNET_NORLKUP - ALL: avoid doing reverse DNS look-up XRDNET_USETLS - ALL: enable TLS upon connection |
timeout | maximum seconds to wait for a conection. When negative, the default, no time limit applies. |
Definition at line 125 of file XrdNet.cc.
References Domain, eDest, XrdSysError::Emsg(), XrdNetPeer::InetName, iofd, netOpts, opts, PortType, Trim(), XRDNET_NODNTRIM, and XRDNET_NOEMSG.
int XrdNet::Bind | ( | char * | path, |
const char * | contype = "stream" |
||
) |
Bind a network object to a Unix named socket.
path | the file system path to a named socket to bind with. |
contype | Either "stream" to use TCP-tyle streaming protocol or "datagram" to use UDP-style messaging. |
Definition at line 206 of file XrdNet.cc.
References BuffQ, BuffSize, XrdNetSocket::Detach(), eDest, XrdSysError::Emsg(), iofd, XrdNetSocket::LastError(), netOpts, XrdNetSocket::Open(), opts, PortType, unBind(), Windowsz, XRDNET_SERVER, XRDNET_UDPBUFFSZ, and XRDNET_UDPSOCKET.
int XrdNet::Bind | ( | int | port, |
const char * | contype = "tcp" |
||
) |
Bind a network object to a TCP or UDP port number.
port | the port number to bind to. Use 0 for arbitrary port. |
contype | Either "tcp" for TCP networks or "udp" for UDP networks. |
Definition at line 164 of file XrdNet.cc.
References BuffQ, BuffSize, XrdNetSocket::Detach(), eDest, iofd, XrdNetSocket::LastError(), netOpts, XrdNetSocket::Open(), opts, XrdNetUtils::Port(), Portnum, PortType, unBind(), Windowsz, XRDNET_SERVER, XRDNET_UDPBUFFSZ, and XRDNET_UDPSOCKET.
Referenced by XrdInet::BindSD(), and XrdCmsSupervisor::Init().
int XrdNet::Connect | ( | XrdNetAddr & | myAddr, |
const char * | dest, | ||
int | port = -1 , |
||
int | opts = 0 , |
||
int | timeout = -1 |
||
) |
Create a TCP socket and connect it to the given host and port. This is the preferred method for making TCP based connections.
myAddr | address object where connection information is returned. |
dest | destination hostname or IP address. |
port | the port number to connect to. If < 0 then the dest param must contain the port number preceeded by a colon. |
opts | processing options: XRDNET_NOCLOSEX - do not allow socket to close on exec() XRDNET_NOEMSG - supress printing error messages XRDNET_NORLKUP - avoid doing reverse DNS look-up |
timeout | the maximum number of seconds to wait for the connection to complete. A negative value waits forever. Values greater than 255 seconds are set to 255. |
Definition at line 252 of file XrdNet.cc.
References XrdNetSocket::Detach(), eDest, XrdNetAddrInfo::Name(), netOpts, XrdNetSocket::Open(), opts, XrdNetAddr::Set(), Windowsz, XRDNET_NOEMSG, XRDNET_NORLKUP, and XRDNET_UDPSOCKET.
Referenced by XrdInet::Connect(), Relay(), and Relay().
int XrdNet::Connect | ( | XrdNetPeer & | myPeer, |
const char * | dest, | ||
int | port = -1 , |
||
int | opts = 0 , |
||
int | timeout = -1 |
||
) |
Create a TCP or UDP socket and connect it to the given host and port. The previous method is preferred for creating TCP sockets.
myPeer | peer object where connection information is returned. |
dest | destination hostname or IP address. |
port | the port number to connect to. If < 0 then the dest param must contain the port number preceeded by a colon. |
opts | processing options: XRDNET_NOCLOSEX - do not allow socket to close on exec() XRDNET_NODNTRIM - do not trim domain name in myPeer. XRDNET_NOEMSG - supress printing error messages XRDNET_NORLKUP - avoid doing reverse DNS look-up XRDNET_UDPSOCKET - create a UDP socket (o/w use TCP). |
timeout | the maximum number of seconds to wait for the connection to complete. A negative value waits forever. Values greater than 255 seconds are set to 255. |
Definition at line 272 of file XrdNet.cc.
References XrdNetSocket::Detach(), Domain, eDest, XrdNetPeer::fd, XrdNetPeer::Inet, XrdNetPeer::InetName, netOpts, XrdNetSocket::Open(), opts, XrdNetSocket::Peername(), Trim(), Windowsz, XRDNET_NODNTRIM, XRDNET_NOEMSG, XRDNET_UDPBUFFSZ, and XRDNET_UDPSOCKET.
|
inline |
Get the port number, if any, bound to this network.
Definition at line 191 of file XrdNet.hh.
References Portnum.
Referenced by XrdgetProtocol().
int XrdNet::Relay | ( | const char * | dest | ) |
Definition at line 317 of file XrdNet.cc.
References Connect(), XrdNetPeer::fd, XRDNET_SENDONLY, and XRDNET_UDPSOCKET.
int XrdNet::Relay | ( | XrdNetPeer & | Peer, |
const char * | dest, | ||
int | opts = 0 |
||
) |
Definition at line 310 of file XrdNet.cc.
References Connect(), opts, and XRDNET_UDPSOCKET.
Referenced by XrdNetMsg::XrdNetMsg().
|
virtual |
Add a NetSecurity object to the existing accept() security constraints.
secp | Pointer to the network security object. This object must not be deleted nor directly used after the call as this object assumes its ownership and may delete it at any time. |
Reimplemented in XrdInet.
Definition at line 329 of file XrdNet.cc.
References XrdNetSecurity::Merge(), and Police.
|
inline |
Set network defaults.
options | The options to be added to Accept(), Bind() and Connect() calls. These options cannot be turned off, so be careful. |
buffsz | The UDP buffer size (the initial default is 32K) or the TCP window size (initial default is OS dependent). |
|
inline |
Set network domain name.
dname | The domain name which indicates to Trim() what part of the host name is so common that it can be trimmed. |
Definition at line 233 of file XrdNet.hh.
References Domain, and Domlen.
Referenced by XrdCmsSupervisor::Init().
void XrdNet::Trim | ( | char * | hname | ) |
Trims off the domain name in a host name.
hname | The host name to be trimmed (it is modified). |
Definition at line 343 of file XrdNet.cc.
References Domain, and Domlen.
Referenced by Accept(), XrdLinkCtl::Alloc(), and Connect().
void XrdNet::unBind | ( | ) |
int XrdNet::WSize | ( | ) |
Get the current TCP RCVBUF window size.
Definition at line 368 of file XrdNet.cc.
References eDest, XrdNetSocket::getWindow(), and iofd.
|
protected |
|
protected |
Definition at line 292 of file XrdNet.hh.
Referenced by Bind(), Bind(), and XrdInet::BindSD().
|
protected |
|
protected |
Definition at line 286 of file XrdNet.hh.
Referenced by XrdNet(), setDomain(), and Trim().
|
protected |
Definition at line 283 of file XrdNet.hh.
Referenced by XrdNet(), XrdInet::Accept(), Accept(), Accept(), Bind(), Bind(), XrdInet::BindSD(), XrdInet::Connect(), Connect(), Connect(), and WSize().
|
protected |
|
protected |
Definition at line 291 of file XrdNet.hh.
Referenced by XrdNet(), XrdInet::Accept(), Accept(), Accept(), Bind(), Bind(), XrdInet::BindSD(), Connect(), Connect(), and setDefaults().
|
protected |
|
protected |
Definition at line 288 of file XrdNet.hh.
Referenced by XrdNet(), XrdInet::Accept(), Bind(), XrdInet::BindSD(), Port(), and unBind().
|
protected |
|
protected |
Definition at line 290 of file XrdNet.hh.
Referenced by XrdNet(), Bind(), Bind(), XrdInet::BindSD(), Connect(), Connect(), and setDefaults().