diff options
| author | 2021-08-16 10:32:25 +0200 | |
|---|---|---|
| committer | 2021-08-16 10:32:25 +0200 | |
| commit | 70419f7a17880fd1e7834e7fe6e1aad14b0565bb (patch) | |
| tree | e1eb243069df47057ba98c77dcce4588bf34ae31 /src/core/hle | |
| parent | configuration: fix mingw-w64 build (diff) | |
| download | yuzu-70419f7a17880fd1e7834e7fe6e1aad14b0565bb.tar.gz yuzu-70419f7a17880fd1e7834e7fe6e1aad14b0565bb.tar.xz yuzu-70419f7a17880fd1e7834e7fe6e1aad14b0565bb.zip | |
network: retrieve subnet mask and gateway info
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/nifm/nifm.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 796c89d47..0a53c0c81 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "core/hle/service/nifm/nifm.h" | 11 | #include "core/hle/service/nifm/nifm.h" |
| 12 | #include "core/hle/service/service.h" | 12 | #include "core/hle/service/service.h" |
| 13 | #include "core/network/network.h" | 13 | #include "core/network/network.h" |
| 14 | #include "core/network/network_interface.h" | ||
| 14 | 15 | ||
| 15 | namespace Service::NIFM { | 16 | namespace Service::NIFM { |
| 16 | 17 | ||
| @@ -357,16 +358,10 @@ private: | |||
| 357 | static_assert(sizeof(IpConfigInfo) == sizeof(IpAddressSetting) + sizeof(DnsSetting), | 358 | static_assert(sizeof(IpConfigInfo) == sizeof(IpAddressSetting) + sizeof(DnsSetting), |
| 358 | "IpConfigInfo has incorrect size."); | 359 | "IpConfigInfo has incorrect size."); |
| 359 | 360 | ||
| 360 | auto ipv4 = Network::GetHostIPv4Address(); | 361 | IpConfigInfo ip_config_info{ |
| 361 | if (!ipv4) { | ||
| 362 | LOG_ERROR(Service_NIFM, "Couldn't get host IPv4 address, defaulting to 0.0.0.0"); | ||
| 363 | ipv4.emplace(Network::IPv4Address{0, 0, 0, 0}); | ||
| 364 | } | ||
| 365 | |||
| 366 | const IpConfigInfo ip_config_info{ | ||
| 367 | .ip_address_setting{ | 362 | .ip_address_setting{ |
| 368 | .is_automatic{true}, | 363 | .is_automatic{true}, |
| 369 | .current_address{*ipv4}, | 364 | .current_address{0, 0, 0, 0}, |
| 370 | .subnet_mask{255, 255, 255, 0}, | 365 | .subnet_mask{255, 255, 255, 0}, |
| 371 | .gateway{192, 168, 1, 1}, | 366 | .gateway{192, 168, 1, 1}, |
| 372 | }, | 367 | }, |
| @@ -377,6 +372,19 @@ private: | |||
| 377 | }, | 372 | }, |
| 378 | }; | 373 | }; |
| 379 | 374 | ||
| 375 | const auto iface = Network::GetSelectedNetworkInterface(); | ||
| 376 | if (iface) { | ||
| 377 | ip_config_info.ip_address_setting = | ||
| 378 | IpAddressSetting{.is_automatic{true}, | ||
| 379 | .current_address{Network::TranslateIPv4(iface->ip_address)}, | ||
| 380 | .subnet_mask{Network::TranslateIPv4(iface->subnet_mask)}, | ||
| 381 | .gateway{Network::TranslateIPv4(iface->gateway)}}; | ||
| 382 | |||
| 383 | } else { | ||
| 384 | LOG_ERROR(Service_NIFM, | ||
| 385 | "Couldn't get host network configuration info, using default values"); | ||
| 386 | } | ||
| 387 | |||
| 380 | IPC::ResponseBuilder rb{ctx, 2 + (sizeof(IpConfigInfo) + 3) / sizeof(u32)}; | 388 | IPC::ResponseBuilder rb{ctx, 2 + (sizeof(IpConfigInfo) + 3) / sizeof(u32)}; |
| 381 | rb.Push(ResultSuccess); | 389 | rb.Push(ResultSuccess); |
| 382 | rb.PushRaw<IpConfigInfo>(ip_config_info); | 390 | rb.PushRaw<IpConfigInfo>(ip_config_info); |