summaryrefslogtreecommitdiff
path: root/src/core/hle/service/sockets
diff options
context:
space:
mode:
authorGravatar Liam2023-07-22 23:29:45 -0400
committerGravatar Liam2023-07-22 23:29:45 -0400
commit3e3294e1c25ab67f967d63c1232c579ad3c1e90b (patch)
treeac3b16adef97a2a4e6bbb38141b2dd76bf0887c1 /src/core/hle/service/sockets
parentMerge pull request #11042 from lat9nq/wayland-appimage (diff)
downloadyuzu-3e3294e1c25ab67f967d63c1232c579ad3c1e90b.tar.gz
yuzu-3e3294e1c25ab67f967d63c1232c579ad3c1e90b.tar.xz
yuzu-3e3294e1c25ab67f967d63c1232c579ad3c1e90b.zip
core: implement GetGaiStringErrorRequest, IContextRegistrar
Diffstat (limited to 'src/core/hle/service/sockets')
-rw-r--r--src/core/hle/service/sockets/bsd.cpp2
-rw-r--r--src/core/hle/service/sockets/nsd.cpp10
-rw-r--r--src/core/hle/service/sockets/nsd.h1
-rw-r--r--src/core/hle/service/sockets/sfdnsres.cpp16
-rw-r--r--src/core/hle/service/sockets/sfdnsres.h1
-rw-r--r--src/core/hle/service/sockets/sockets_translate.cpp38
-rw-r--r--src/core/hle/service/sockets/sockets_translate.h3
7 files changed, 68 insertions, 3 deletions
diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp
index e63b0a357..11f8efbac 100644
--- a/src/core/hle/service/sockets/bsd.cpp
+++ b/src/core/hle/service/sockets/bsd.cpp
@@ -559,7 +559,7 @@ std::pair<s32, Errno> BSD::PollImpl(std::vector<u8>& write_buffer, std::span<con
559 559
560 const std::optional<FileDescriptor>& descriptor = file_descriptors[pollfd.fd]; 560 const std::optional<FileDescriptor>& descriptor = file_descriptors[pollfd.fd];
561 if (!descriptor) { 561 if (!descriptor) {
562 LOG_ERROR(Service, "File descriptor handle={} is not allocated", pollfd.fd); 562 LOG_TRACE(Service, "File descriptor handle={} is not allocated", pollfd.fd);
563 pollfd.revents = PollEvents::Nval; 563 pollfd.revents = PollEvents::Nval;
564 return {0, Errno::SUCCESS}; 564 return {0, Errno::SUCCESS};
565 } 565 }
diff --git a/src/core/hle/service/sockets/nsd.cpp b/src/core/hle/service/sockets/nsd.cpp
index 36c6cd05c..5dfcaabb1 100644
--- a/src/core/hle/service/sockets/nsd.cpp
+++ b/src/core/hle/service/sockets/nsd.cpp
@@ -24,7 +24,7 @@ NSD::NSD(Core::System& system_, const char* name) : ServiceFramework{system_, na
24 static const FunctionInfo functions[] = { 24 static const FunctionInfo functions[] = {
25 {5, nullptr, "GetSettingUrl"}, 25 {5, nullptr, "GetSettingUrl"},
26 {10, nullptr, "GetSettingName"}, 26 {10, nullptr, "GetSettingName"},
27 {11, nullptr, "GetEnvironmentIdentifier"}, 27 {11, &NSD::GetEnvironmentIdentifier, "GetEnvironmentIdentifier"},
28 {12, nullptr, "GetDeviceId"}, 28 {12, nullptr, "GetDeviceId"},
29 {13, nullptr, "DeleteSettings"}, 29 {13, nullptr, "DeleteSettings"},
30 {14, nullptr, "ImportSettings"}, 30 {14, nullptr, "ImportSettings"},
@@ -103,6 +103,14 @@ void NSD::ResolveEx(HLERequestContext& ctx) {
103 rb.Push(ResultSuccess); 103 rb.Push(ResultSuccess);
104} 104}
105 105
106void NSD::GetEnvironmentIdentifier(HLERequestContext& ctx) {
107 const std::string environment_identifier = "lp1";
108 ctx.WriteBuffer(environment_identifier);
109
110 IPC::ResponseBuilder rb{ctx, 2};
111 rb.Push(ResultSuccess);
112}
113
106void NSD::GetApplicationServerEnvironmentType(HLERequestContext& ctx) { 114void NSD::GetApplicationServerEnvironmentType(HLERequestContext& ctx) {
107 IPC::ResponseBuilder rb{ctx, 3}; 115 IPC::ResponseBuilder rb{ctx, 3};
108 rb.Push(ResultSuccess); 116 rb.Push(ResultSuccess);
diff --git a/src/core/hle/service/sockets/nsd.h b/src/core/hle/service/sockets/nsd.h
index 57760a0c8..b0cfec507 100644
--- a/src/core/hle/service/sockets/nsd.h
+++ b/src/core/hle/service/sockets/nsd.h
@@ -19,6 +19,7 @@ public:
19private: 19private:
20 void Resolve(HLERequestContext& ctx); 20 void Resolve(HLERequestContext& ctx);
21 void ResolveEx(HLERequestContext& ctx); 21 void ResolveEx(HLERequestContext& ctx);
22 void GetEnvironmentIdentifier(HLERequestContext& ctx);
22 void GetApplicationServerEnvironmentType(HLERequestContext& ctx); 23 void GetApplicationServerEnvironmentType(HLERequestContext& ctx);
23}; 24};
24 25
diff --git a/src/core/hle/service/sockets/sfdnsres.cpp b/src/core/hle/service/sockets/sfdnsres.cpp
index 84cc79de8..22e4a6f49 100644
--- a/src/core/hle/service/sockets/sfdnsres.cpp
+++ b/src/core/hle/service/sockets/sfdnsres.cpp
@@ -24,7 +24,7 @@ SFDNSRES::SFDNSRES(Core::System& system_) : ServiceFramework{system_, "sfdnsres"
24 {2, &SFDNSRES::GetHostByNameRequest, "GetHostByNameRequest"}, 24 {2, &SFDNSRES::GetHostByNameRequest, "GetHostByNameRequest"},
25 {3, nullptr, "GetHostByAddrRequest"}, 25 {3, nullptr, "GetHostByAddrRequest"},
26 {4, nullptr, "GetHostStringErrorRequest"}, 26 {4, nullptr, "GetHostStringErrorRequest"},
27 {5, nullptr, "GetGaiStringErrorRequest"}, 27 {5, &SFDNSRES::GetGaiStringErrorRequest, "GetGaiStringErrorRequest"},
28 {6, &SFDNSRES::GetAddrInfoRequest, "GetAddrInfoRequest"}, 28 {6, &SFDNSRES::GetAddrInfoRequest, "GetAddrInfoRequest"},
29 {7, nullptr, "GetNameInfoRequest"}, 29 {7, nullptr, "GetNameInfoRequest"},
30 {8, nullptr, "RequestCancelHandleRequest"}, 30 {8, nullptr, "RequestCancelHandleRequest"},
@@ -300,6 +300,20 @@ void SFDNSRES::GetAddrInfoRequest(HLERequestContext& ctx) {
300 }); 300 });
301} 301}
302 302
303void SFDNSRES::GetGaiStringErrorRequest(HLERequestContext& ctx) {
304 struct InputParameters {
305 GetAddrInfoError gai_errno;
306 };
307 IPC::RequestParser rp{ctx};
308 auto input = rp.PopRaw<InputParameters>();
309
310 const std::string result = Translate(input.gai_errno);
311 ctx.WriteBuffer(result);
312
313 IPC::ResponseBuilder rb{ctx, 2};
314 rb.Push(ResultSuccess);
315}
316
303void SFDNSRES::GetAddrInfoRequestWithOptions(HLERequestContext& ctx) { 317void SFDNSRES::GetAddrInfoRequestWithOptions(HLERequestContext& ctx) {
304 // Additional options are ignored 318 // Additional options are ignored
305 auto [data_size, emu_gai_err] = GetAddrInfoRequestImpl(ctx); 319 auto [data_size, emu_gai_err] = GetAddrInfoRequestImpl(ctx);
diff --git a/src/core/hle/service/sockets/sfdnsres.h b/src/core/hle/service/sockets/sfdnsres.h
index d99a9d560..282ef9071 100644
--- a/src/core/hle/service/sockets/sfdnsres.h
+++ b/src/core/hle/service/sockets/sfdnsres.h
@@ -18,6 +18,7 @@ public:
18 18
19private: 19private:
20 void GetHostByNameRequest(HLERequestContext& ctx); 20 void GetHostByNameRequest(HLERequestContext& ctx);
21 void GetGaiStringErrorRequest(HLERequestContext& ctx);
21 void GetHostByNameRequestWithOptions(HLERequestContext& ctx); 22 void GetHostByNameRequestWithOptions(HLERequestContext& ctx);
22 void GetAddrInfoRequest(HLERequestContext& ctx); 23 void GetAddrInfoRequest(HLERequestContext& ctx);
23 void GetAddrInfoRequestWithOptions(HLERequestContext& ctx); 24 void GetAddrInfoRequestWithOptions(HLERequestContext& ctx);
diff --git a/src/core/hle/service/sockets/sockets_translate.cpp b/src/core/hle/service/sockets/sockets_translate.cpp
index 2f9a0e39c..c1187209f 100644
--- a/src/core/hle/service/sockets/sockets_translate.cpp
+++ b/src/core/hle/service/sockets/sockets_translate.cpp
@@ -81,6 +81,44 @@ GetAddrInfoError Translate(Network::GetAddrInfoError error) {
81 } 81 }
82} 82}
83 83
84const char* Translate(GetAddrInfoError error) {
85 // https://android.googlesource.com/platform/bionic/+/085543106/libc/dns/net/getaddrinfo.c#254
86 switch (error) {
87 case GetAddrInfoError::SUCCESS:
88 return "Success";
89 case GetAddrInfoError::ADDRFAMILY:
90 return "Address family for hostname not supported";
91 case GetAddrInfoError::AGAIN:
92 return "Temporary failure in name resolution";
93 case GetAddrInfoError::BADFLAGS:
94 return "Invalid value for ai_flags";
95 case GetAddrInfoError::FAIL:
96 return "Non-recoverable failure in name resolution";
97 case GetAddrInfoError::FAMILY:
98 return "ai_family not supported";
99 case GetAddrInfoError::MEMORY:
100 return "Memory allocation failure";
101 case GetAddrInfoError::NODATA:
102 return "No address associated with hostname";
103 case GetAddrInfoError::NONAME:
104 return "hostname nor servname provided, or not known";
105 case GetAddrInfoError::SERVICE:
106 return "servname not supported for ai_socktype";
107 case GetAddrInfoError::SOCKTYPE:
108 return "ai_socktype not supported";
109 case GetAddrInfoError::SYSTEM:
110 return "System error returned in errno";
111 case GetAddrInfoError::BADHINTS:
112 return "Invalid value for hints";
113 case GetAddrInfoError::PROTOCOL:
114 return "Resolved protocol is unknown";
115 case GetAddrInfoError::OVERFLOW_:
116 return "Argument buffer overflow";
117 default:
118 return "Unknown error";
119 }
120}
121
84Network::Domain Translate(Domain domain) { 122Network::Domain Translate(Domain domain) {
85 switch (domain) { 123 switch (domain) {
86 case Domain::Unspecified: 124 case Domain::Unspecified:
diff --git a/src/core/hle/service/sockets/sockets_translate.h b/src/core/hle/service/sockets/sockets_translate.h
index 694868b37..bd6721fd3 100644
--- a/src/core/hle/service/sockets/sockets_translate.h
+++ b/src/core/hle/service/sockets/sockets_translate.h
@@ -20,6 +20,9 @@ std::pair<s32, Errno> Translate(std::pair<s32, Network::Errno> value);
20/// Translate abstract getaddrinfo error to guest getaddrinfo error 20/// Translate abstract getaddrinfo error to guest getaddrinfo error
21GetAddrInfoError Translate(Network::GetAddrInfoError value); 21GetAddrInfoError Translate(Network::GetAddrInfoError value);
22 22
23/// Translate guest error to string
24const char* Translate(GetAddrInfoError value);
25
23/// Translate guest domain to abstract domain 26/// Translate guest domain to abstract domain
24Network::Domain Translate(Domain domain); 27Network::Domain Translate(Domain domain);
25 28