Files
RedBear-OS/local/patches/relibc/P3-tcp-nodelay.patch
T
vasilito 752bceb3e9 Enable IPv6 foundation in relibc: inet_pton/ntop, TCP socket options, DNS AAAA
Add three relibc patches (42 total) to close QtNetwork-critical socket gaps:
- P3-inet6-pton-ntop: AF_INET6 address parsing/formatting with RFC 5952
  shorthand, IPv4-mapped suffix support
- P3-tcp-sockopt-forward: forward IPPROTO_TCP getsockopt/setsockopt to
  scheme daemon instead of hitting todo_skip
- P3-dns-aaaa-getaddrinfo-ipv6: AAAA DNS record queries, lookup_host_v6,
  dual-stack getaddrinfo with sockaddr_in6 entries

Also fix P3-tcp-nodelay to use sys_call_wo + from_raw_parts (const) in the
SOL_SOCKET setsockopt fallback — setsockopt sends data to the kernel, not
reads from it.
2026-04-25 21:20:47 +01:00

54 lines
2.2 KiB
Diff

diff --git a/src/header/sys_socket/constants.rs b/src/header/sys_socket/constants.rs
index ec42889b..c91ffb1a 100644
--- a/src/header/sys_socket/constants.rs
+++ b/src/header/sys_socket/constants.rs
@@ -75,3 +75,6 @@ pub const SHUT_WR: c_int = 1;
pub const SCM_RIGHTS: c_int = 1;
pub const SCM_CREDENTIALS: c_int = 2;
+
+pub const IPPROTO_TCP: c_int = 6;
+pub const TCP_NODELAY: c_int = 1;
diff --git a/src/platform/redox/socket.rs b/src/platform/redox/socket.rs
index d223c36f..2faae4f5 100644
--- a/src/platform/redox/socket.rs
+++ b/src/platform/redox/socket.rs
@@ -1051,10 +1051,10 @@ impl PalSocket for Sys {
_ => {
let metadata = [SocketCall::SetSockOpt as u64, option_name as u64];
let payload = unsafe {
- slice::from_raw_parts_mut(option_value as *mut u8, option_len as usize)
+ slice::from_raw_parts(option_value as *const u8, option_len as usize)
};
let call_flags = CallFlags::empty();
- redox_rt::sys::sys_call_rw(
+ redox_rt::sys::sys_call_wo(
socket as usize,
payload,
CallFlags::empty(),
@@ -1063,6 +1063,24 @@ impl PalSocket for Sys {
return Ok(());
}
},
+ crate::header::sys_socket::constants::IPPROTO_TCP => {
+ match option_name {
+ crate::header::sys_socket::constants::TCP_NODELAY => {
+ let metadata = [SocketCall::SetSockOpt as u64, option_name as u64];
+ let payload = unsafe {
+ slice::from_raw_parts(option_value as *const u8, option_len as usize)
+ };
+ redox_rt::sys::sys_call_wo(
+ socket as usize,
+ payload,
+ CallFlags::empty(),
+ &metadata,
+ )?;
+ return Ok(());
+ }
+ _ => (),
+ }
+ }
_ => (),
}