|
|
@ -186,7 +186,7 @@ void BSD::Poll(Kernel::HLERequestContext& ctx) {
|
|
|
|
ExecuteWork(ctx, PollWork{
|
|
|
|
ExecuteWork(ctx, PollWork{
|
|
|
|
.nfds = nfds,
|
|
|
|
.nfds = nfds,
|
|
|
|
.timeout = timeout,
|
|
|
|
.timeout = timeout,
|
|
|
|
.read_buffer = ctx.ReadBuffer(),
|
|
|
|
.read_buffer = ctx.ReadBufferSpan(),
|
|
|
|
.write_buffer = std::vector<u8>(ctx.GetWriteBufferSize()),
|
|
|
|
.write_buffer = std::vector<u8>(ctx.GetWriteBufferSize()),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -208,8 +208,7 @@ void BSD::Bind(Kernel::HLERequestContext& ctx) {
|
|
|
|
const s32 fd = rp.Pop<s32>();
|
|
|
|
const s32 fd = rp.Pop<s32>();
|
|
|
|
|
|
|
|
|
|
|
|
LOG_DEBUG(Service, "called. fd={} addrlen={}", fd, ctx.GetReadBufferSize());
|
|
|
|
LOG_DEBUG(Service, "called. fd={} addrlen={}", fd, ctx.GetReadBufferSize());
|
|
|
|
|
|
|
|
BuildErrnoResponse(ctx, BindImpl(fd, ctx.ReadBufferSpan()));
|
|
|
|
BuildErrnoResponse(ctx, BindImpl(fd, ctx.ReadBuffer()));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BSD::Connect(Kernel::HLERequestContext& ctx) {
|
|
|
|
void BSD::Connect(Kernel::HLERequestContext& ctx) {
|
|
|
@ -220,7 +219,7 @@ void BSD::Connect(Kernel::HLERequestContext& ctx) {
|
|
|
|
|
|
|
|
|
|
|
|
ExecuteWork(ctx, ConnectWork{
|
|
|
|
ExecuteWork(ctx, ConnectWork{
|
|
|
|
.fd = fd,
|
|
|
|
.fd = fd,
|
|
|
|
.addr = ctx.ReadBuffer(),
|
|
|
|
.addr = ctx.ReadBufferSpan(),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -312,7 +311,7 @@ void BSD::SetSockOpt(Kernel::HLERequestContext& ctx) {
|
|
|
|
const u32 level = rp.Pop<u32>();
|
|
|
|
const u32 level = rp.Pop<u32>();
|
|
|
|
const OptName optname = static_cast<OptName>(rp.Pop<u32>());
|
|
|
|
const OptName optname = static_cast<OptName>(rp.Pop<u32>());
|
|
|
|
|
|
|
|
|
|
|
|
const std::vector<u8> buffer = ctx.ReadBuffer();
|
|
|
|
const auto buffer = ctx.ReadBufferSpan();
|
|
|
|
const u8* optval = buffer.empty() ? nullptr : buffer.data();
|
|
|
|
const u8* optval = buffer.empty() ? nullptr : buffer.data();
|
|
|
|
size_t optlen = buffer.size();
|
|
|
|
size_t optlen = buffer.size();
|
|
|
|
|
|
|
|
|
|
|
@ -383,7 +382,7 @@ void BSD::Send(Kernel::HLERequestContext& ctx) {
|
|
|
|
ExecuteWork(ctx, SendWork{
|
|
|
|
ExecuteWork(ctx, SendWork{
|
|
|
|
.fd = fd,
|
|
|
|
.fd = fd,
|
|
|
|
.flags = flags,
|
|
|
|
.flags = flags,
|
|
|
|
.message = ctx.ReadBuffer(),
|
|
|
|
.message = ctx.ReadBufferSpan(),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -398,8 +397,8 @@ void BSD::SendTo(Kernel::HLERequestContext& ctx) {
|
|
|
|
ExecuteWork(ctx, SendToWork{
|
|
|
|
ExecuteWork(ctx, SendToWork{
|
|
|
|
.fd = fd,
|
|
|
|
.fd = fd,
|
|
|
|
.flags = flags,
|
|
|
|
.flags = flags,
|
|
|
|
.message = ctx.ReadBuffer(0),
|
|
|
|
.message = ctx.ReadBufferSpan(0),
|
|
|
|
.addr = ctx.ReadBuffer(1),
|
|
|
|
.addr = ctx.ReadBufferSpan(1),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -412,7 +411,7 @@ void BSD::Write(Kernel::HLERequestContext& ctx) {
|
|
|
|
ExecuteWork(ctx, SendWork{
|
|
|
|
ExecuteWork(ctx, SendWork{
|
|
|
|
.fd = fd,
|
|
|
|
.fd = fd,
|
|
|
|
.flags = 0,
|
|
|
|
.flags = 0,
|
|
|
|
.message = ctx.ReadBuffer(),
|
|
|
|
.message = ctx.ReadBufferSpan(),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -489,7 +488,7 @@ std::pair<s32, Errno> BSD::SocketImpl(Domain domain, Type type, Protocol protoco
|
|
|
|
return {fd, Errno::SUCCESS};
|
|
|
|
return {fd, Errno::SUCCESS};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<s32, Errno> BSD::PollImpl(std::vector<u8>& write_buffer, std::vector<u8> read_buffer,
|
|
|
|
std::pair<s32, Errno> BSD::PollImpl(std::vector<u8>& write_buffer, std::span<const u8> read_buffer,
|
|
|
|
s32 nfds, s32 timeout) {
|
|
|
|
s32 nfds, s32 timeout) {
|
|
|
|
if (write_buffer.size() < nfds * sizeof(PollFD)) {
|
|
|
|
if (write_buffer.size() < nfds * sizeof(PollFD)) {
|
|
|
|
return {-1, Errno::INVAL};
|
|
|
|
return {-1, Errno::INVAL};
|
|
|
@ -584,7 +583,7 @@ std::pair<s32, Errno> BSD::AcceptImpl(s32 fd, std::vector<u8>& write_buffer) {
|
|
|
|
return {new_fd, Errno::SUCCESS};
|
|
|
|
return {new_fd, Errno::SUCCESS};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Errno BSD::BindImpl(s32 fd, const std::vector<u8>& addr) {
|
|
|
|
Errno BSD::BindImpl(s32 fd, std::span<const u8> addr) {
|
|
|
|
if (!IsFileDescriptorValid(fd)) {
|
|
|
|
if (!IsFileDescriptorValid(fd)) {
|
|
|
|
return Errno::BADF;
|
|
|
|
return Errno::BADF;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -595,7 +594,7 @@ Errno BSD::BindImpl(s32 fd, const std::vector<u8>& addr) {
|
|
|
|
return Translate(file_descriptors[fd]->socket->Bind(Translate(addr_in)));
|
|
|
|
return Translate(file_descriptors[fd]->socket->Bind(Translate(addr_in)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Errno BSD::ConnectImpl(s32 fd, const std::vector<u8>& addr) {
|
|
|
|
Errno BSD::ConnectImpl(s32 fd, std::span<const u8> addr) {
|
|
|
|
if (!IsFileDescriptorValid(fd)) {
|
|
|
|
if (!IsFileDescriptorValid(fd)) {
|
|
|
|
return Errno::BADF;
|
|
|
|
return Errno::BADF;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -800,15 +799,15 @@ std::pair<s32, Errno> BSD::RecvFromImpl(s32 fd, u32 flags, std::vector<u8>& mess
|
|
|
|
return {ret, bsd_errno};
|
|
|
|
return {ret, bsd_errno};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<s32, Errno> BSD::SendImpl(s32 fd, u32 flags, const std::vector<u8>& message) {
|
|
|
|
std::pair<s32, Errno> BSD::SendImpl(s32 fd, u32 flags, std::span<const u8> message) {
|
|
|
|
if (!IsFileDescriptorValid(fd)) {
|
|
|
|
if (!IsFileDescriptorValid(fd)) {
|
|
|
|
return {-1, Errno::BADF};
|
|
|
|
return {-1, Errno::BADF};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Translate(file_descriptors[fd]->socket->Send(message, flags));
|
|
|
|
return Translate(file_descriptors[fd]->socket->Send(message, flags));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<s32, Errno> BSD::SendToImpl(s32 fd, u32 flags, const std::vector<u8>& message,
|
|
|
|
std::pair<s32, Errno> BSD::SendToImpl(s32 fd, u32 flags, std::span<const u8> message,
|
|
|
|
const std::vector<u8>& addr) {
|
|
|
|
std::span<const u8> addr) {
|
|
|
|
if (!IsFileDescriptorValid(fd)) {
|
|
|
|
if (!IsFileDescriptorValid(fd)) {
|
|
|
|
return {-1, Errno::BADF};
|
|
|
|
return {-1, Errno::BADF};
|
|
|
|
}
|
|
|
|
}
|
|
|
|