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

@ -216,6 +216,7 @@ error_code cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
case CELL_NET_CTL_INFO_IP_ADDRESS: strcpy_trunc(info->ip_address, np_handler::ip_to_string(nph->get_local_ip_addr())); break;
case CELL_NET_CTL_INFO_NETMASK: strcpy_trunc(info->netmask, "255.255.255.255"); break;
case CELL_NET_CTL_INFO_HTTP_PROXY_CONFIG: info->http_proxy_config = 0; break;
case CELL_NET_CTL_INFO_DHCP_HOSTNAME: strcpy_trunc(info->dhcp_hostname, nph->get_hostname()); break;
default: cellNetCtl.error("Unsupported request: %s", InfoCodeToName(code)); break;
}

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;

View File

@ -19,6 +19,7 @@ public:
np_handler();
const std::array<u8, 6>& get_ether_addr() const;
const std::string& get_hostname() const;
u32 get_local_ip_addr() const;
u32 get_public_ip_addr() const;
u32 get_dns_ip() const;
@ -174,6 +175,7 @@ protected:
std::vector<u8> current_ticket;
// IP & DNS info
std::string hostname = "localhost";
std::array<u8, 6> ether_address{};
be_t<u32> local_ip_addr{};
be_t<u32> public_ip_addr{};