Skip to content

Commit

Permalink
[XrdCl] Introduce StreamQuery::HostName.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed Jun 3, 2022
1 parent cc064c6 commit 18210b0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/XrdCl/XrdClAsyncSocketHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -846,12 +846,23 @@ namespace XrdCl
}

//------------------------------------------------------------------------
// Get hostname
// Get IP address
//------------------------------------------------------------------------
std::string AsyncSocketHandler::GetIpAddr()
{
char nameBuff[256];
pSockAddr.Format( nameBuff, sizeof(nameBuff), XrdNetAddrInfo::fmtAuto, XrdNetAddrInfo::noPort );
pSockAddr.Format( nameBuff, sizeof(nameBuff), XrdNetAddrInfo::fmtAddr, XrdNetAddrInfo::noPort );
return nameBuff;
}

//------------------------------------------------------------------------
//! Get hostname
//------------------------------------------------------------------------
std::string AsyncSocketHandler::GetHostName()
{
const char *cstr = pSockAddr.Name();
if( !cstr )
return std::string();
return cstr;
}
}
7 changes: 6 additions & 1 deletion src/XrdCl/XrdClAsyncSocketHandler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,15 @@ namespace XrdCl
std::string GetIpStack() const;

//------------------------------------------------------------------------
//! Get hostname
//! Get IP address
//------------------------------------------------------------------------
std::string GetIpAddr();

//------------------------------------------------------------------------
//! Get hostname
//------------------------------------------------------------------------
std::string GetHostName();

protected:

//------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/XrdCl/XrdClPostMasterInterfaces.hh
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ namespace XrdCl
{
static const uint16_t IpAddr = 2001;
static const uint16_t IpStack = 2002;
static const uint16_t HostName = 2003;
};

//----------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions src/XrdCl/XrdClStream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,12 @@ namespace XrdCl
return Status();
}

case StreamQuery::HostName:
{
result.Set( new std::string( pSubStreams[0]->socket->GetHostName() ), false );
return Status();
}

default:
return Status( stError, errQueryNotSupported );
}
Expand Down

0 comments on commit 18210b0

Please sign in to comment.