mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-27 09:12:46 +01:00
service: nifm: Cleanup GetCurrentIpConfigInfo
This commit is contained in:
parent
871e1c6315
commit
878d0225c5
1 changed files with 21 additions and 26 deletions
|
@ -352,38 +352,33 @@ private:
|
||||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||||
|
|
||||||
struct IpConfigInfo {
|
struct IpConfigInfo {
|
||||||
IpAddressSetting ip_address_setting;
|
IpAddressSetting ip_address_setting{};
|
||||||
DnsSetting dns_setting;
|
DnsSetting dns_setting{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(IpConfigInfo) == sizeof(IpAddressSetting) + sizeof(DnsSetting),
|
static_assert(sizeof(IpConfigInfo) == sizeof(IpAddressSetting) + sizeof(DnsSetting),
|
||||||
"IpConfigInfo has incorrect size.");
|
"IpConfigInfo has incorrect size.");
|
||||||
|
|
||||||
IpConfigInfo ip_config_info{
|
const auto net_iface = Network::GetSelectedNetworkInterface();
|
||||||
.ip_address_setting{
|
|
||||||
.is_automatic{true},
|
|
||||||
.current_address{0, 0, 0, 0},
|
|
||||||
.subnet_mask{255, 255, 255, 0},
|
|
||||||
.gateway{192, 168, 1, 1},
|
|
||||||
},
|
|
||||||
.dns_setting{
|
|
||||||
.is_automatic{true},
|
|
||||||
.primary_dns{1, 1, 1, 1},
|
|
||||||
.secondary_dns{1, 0, 0, 1},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto iface = Network::GetSelectedNetworkInterface();
|
const IpConfigInfo ip_config_info = [&net_iface] {
|
||||||
if (iface) {
|
if (!net_iface) {
|
||||||
ip_config_info.ip_address_setting =
|
return IpConfigInfo{};
|
||||||
IpAddressSetting{.is_automatic{true},
|
}
|
||||||
.current_address{Network::TranslateIPv4(iface->ip_address)},
|
|
||||||
.subnet_mask{Network::TranslateIPv4(iface->subnet_mask)},
|
|
||||||
.gateway{Network::TranslateIPv4(iface->gateway)}};
|
|
||||||
|
|
||||||
} else {
|
return IpConfigInfo{
|
||||||
LOG_ERROR(Service_NIFM,
|
.ip_address_setting{
|
||||||
"Couldn't get host network configuration info, using default values");
|
.is_automatic{true},
|
||||||
}
|
.current_address{Network::TranslateIPv4(net_iface->ip_address)},
|
||||||
|
.subnet_mask{Network::TranslateIPv4(net_iface->subnet_mask)},
|
||||||
|
.gateway{Network::TranslateIPv4(net_iface->gateway)},
|
||||||
|
},
|
||||||
|
.dns_setting{
|
||||||
|
.is_automatic{true},
|
||||||
|
.primary_dns{1, 1, 1, 1},
|
||||||
|
.secondary_dns{1, 0, 0, 1},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}();
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + (sizeof(IpConfigInfo) + 3) / sizeof(u32)};
|
IPC::ResponseBuilder rb{ctx, 2 + (sizeof(IpConfigInfo) + 3) / sizeof(u32)};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
|
Loading…
Reference in a new issue