Add ability to have sockets bind to a local IP address (#12998)

This commit is contained in:
Team XLink Developers 2022-11-30 10:35:42 -05:00 committed by GitHub
parent 630edde10f
commit b4757b514d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 55 additions and 2 deletions

View file

@ -371,6 +371,18 @@ namespace np
{
dns_ip = conv.s_addr;
}
// Convert bind address
conv = {};
if (!inet_pton(AF_INET, g_cfg.net.bind_address.to_string().c_str(), &conv))
{
// Do not set to disconnected on invalid IP just error and continue using default (0.0.0.0)
nph_log.error("Provided IP(%s) address for bind is invalid!", g_cfg.net.bind_address.to_string());
}
else
{
bind_ip = conv.s_addr;
}
}
}
@ -585,6 +597,11 @@ namespace np
return dns_ip;
}
u32 np_handler::get_bind_ip() const
{
return bind_ip;
}
s32 np_handler::get_net_status() const
{
return is_connected ? CELL_NET_CTL_STATE_IPObtained : CELL_NET_CTL_STATE_Disconnected;