[XAM/Net] Implemented NetDll_getsockname
This commit is contained in:
parent
5e31429128
commit
0b90d5edf9
|
@ -1031,6 +1031,29 @@ void NetDll_WSASetLastError_entry(dword_t error_code) {
|
|||
}
|
||||
DECLARE_XAM_EXPORT1(NetDll_WSASetLastError, kNetworking, kImplemented);
|
||||
|
||||
dword_result_t NetDll_getsockname_entry(dword_t caller, dword_t socket_handle,
|
||||
lpvoid_t buf_ptr, lpdword_t len_ptr) {
|
||||
auto socket =
|
||||
kernel_state()->object_table()->LookupObject<XSocket>(socket_handle);
|
||||
if (!socket) {
|
||||
// WSAENOTSOCK
|
||||
XThread::SetLastError(0x2736);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int buffer_len = *len_ptr;
|
||||
|
||||
X_STATUS status = socket->GetSockName(buf_ptr, &buffer_len);
|
||||
if (XFAILED(status)) {
|
||||
XThread::SetLastError(xboxkrnl::xeRtlNtStatusToDosError(status));
|
||||
return -1;
|
||||
}
|
||||
|
||||
*len_ptr = buffer_len;
|
||||
return 0;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(NetDll_getsockname, kNetworking, kImplemented);
|
||||
|
||||
} // namespace xam
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
|
|
@ -257,5 +257,17 @@ bool XSocket::QueuePacket(uint32_t src_ip, uint16_t src_port,
|
|||
return true;
|
||||
}
|
||||
|
||||
X_STATUS XSocket::GetSockName(uint8_t* buf, int* buf_len) {
|
||||
struct sockaddr sa = {};
|
||||
|
||||
int ret = getsockname(native_handle_, &sa, (socklen_t*)buf_len);
|
||||
if (ret < 0) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
std::memcpy(buf, &sa, *buf_len);
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
|
@ -106,6 +106,7 @@ class XSocket : public XObject {
|
|||
X_STATUS Connect(N_XSOCKADDR* name, int name_len);
|
||||
X_STATUS Bind(N_XSOCKADDR_IN* name, int name_len);
|
||||
X_STATUS Listen(int backlog);
|
||||
X_STATUS GetSockName(uint8_t* buf, int* buf_len);
|
||||
object_ref<XSocket> Accept(N_XSOCKADDR* name, int* name_len);
|
||||
int Shutdown(int how);
|
||||
|
||||
|
|
Loading…
Reference in New Issue