Add CELL_NET_CTL_INFO_DHCP_HOSTNAME impl

This commit is contained in:
RipleyTom 2021-02-25 20:17:03 +01:00 committed by Ivan
parent c13039396c
commit 67378c7dea
3 changed files with 12 additions and 1 deletions

View file

@ -103,7 +103,8 @@ np_handler::np_handler()
bool np_handler::discover_ip_address()
{
std::array<char, 1024> hostname;
hostname.clear();
hostname.resize(1024);
if (gethostname(hostname.data(), hostname.size()) == -1)
{
@ -111,6 +112,8 @@ bool np_handler::discover_ip_address()
return false;
}
nph_log.notice("Hostname was determined to be %s", hostname);
hostent *host = gethostbyname(hostname.data());
if (!host)
{
@ -221,6 +224,11 @@ const std::array<u8, 6>& np_handler::get_ether_addr() const
return ether_address;
}
const std::string& np_handler::get_hostname() const
{
return hostname;
}
u32 np_handler::get_local_ip_addr() const
{
return local_ip_addr;