Skip to content

Commit e33296a

Browse files
aero_syscall: update socket constants
Signed-off-by: Andy-Python-Programmer <[email protected]>
1 parent b1c067b commit e33296a

File tree

3 files changed

+52
-14
lines changed

3 files changed

+52
-14
lines changed

patches/mlibc/mlibc.patch

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 1f388ec59a355c18a21aa23226159d90fcb35912 Mon Sep 17 00:00:00 2001
1+
From ded2749ee28c99c1ec8a6fe4dbb6423a5287bf91 Mon Sep 17 00:00:00 2001
22
From: Andy-Python-Programmer <[email protected]>
33
Date: Thu, 10 Feb 2022 19:12:25 +1100
44
Subject: [PATCH] yes
@@ -10,8 +10,9 @@ Signed-off-by: Andy-Python-Programmer <[email protected]>
1010
sysdeps/aero/generic/aero.cpp | 12 ++++-
1111
sysdeps/aero/generic/filesystem.cpp | 79 ++++++++++++++++++++++++++---
1212
sysdeps/aero/generic/signals.cpp | 8 ++-
13+
sysdeps/aero/generic/sockets.cpp | 18 +++++++
1314
sysdeps/aero/include/aero/syscall.h | 12 +++++
14-
6 files changed, 103 insertions(+), 13 deletions(-)
15+
7 files changed, 121 insertions(+), 13 deletions(-)
1516

1617
diff --git a/.gitignore b/.gitignore
1718
index dbb35e8b..20c8d4c3 100644
@@ -208,6 +209,29 @@ index 3527370c..a6f69fff 100644
208209
}
209210
} // namespace mlibc
210211
\ No newline at end of file
212+
diff --git a/sysdeps/aero/generic/sockets.cpp b/sysdeps/aero/generic/sockets.cpp
213+
index e69de29b..347556cd 100644
214+
--- a/sysdeps/aero/generic/sockets.cpp
215+
+++ b/sysdeps/aero/generic/sockets.cpp
216+
@@ -0,0 +1,18 @@
217+
+#include <mlibc/all-sysdeps.hpp>
218+
+#include <mlibc/thread-entry.hpp>
219+
+
220+
+#include <aero/syscall.h>
221+
+#include <stdint.h>
222+
+
223+
+namespace mlibc {
224+
+int sys_socket(int family, int type, int protocol, int *fd) {
225+
+ auto result = syscall(SYS_SOCKET, family, type, protocol);
226+
+
227+
+ if (result < 0) {
228+
+ return -result;
229+
+ }
230+
+
231+
+ *fd = result;
232+
+ return 0;
233+
+}
234+
+} // namespace mlibc
211235
diff --git a/sysdeps/aero/include/aero/syscall.h b/sysdeps/aero/include/aero/syscall.h
212236
index 07b1b51b..ef797e40 100644
213237
--- a/sysdeps/aero/include/aero/syscall.h

src/aero_kernel/src/syscall/net.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ pub fn socket(
1212
(AF_UNIX, SOCK_STREAM, 0) => UnixSocket::new(),
1313
(_, _, _) => {
1414
log::warn!(
15-
"unsupported socket type: domain={}, socket_type={}, protocol={}",
16-
domain,
17-
socket_type,
18-
protocol
15+
"unsupported socket type: domain={domain}, socket_type={socket_type}, protocol={protocol}"
1916
);
2017

2118
return Err(AeroSyscallError::EINVAL);

src/aero_syscall/src/lib.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -680,14 +680,31 @@ pub enum SocketAddr {
680680
Inet(SocketAddrInet),
681681
}
682682

683-
pub const AF_UNIX: usize = 1;
684-
pub const AF_INET: usize = 2;
685-
686-
pub const SOCK_STREAM: usize = 1;
687-
pub const SOCK_DGRAM: usize = 2;
688-
689-
pub const IPPROTO_TCP: usize = 6;
690-
pub const IPPROTO_UDP: usize = 17;
683+
// constants for the socket types:
684+
//
685+
// mlibc/sysdeps/aero/include/abi-bits/socket.h
686+
pub const SOCK_DGRAM: usize = 1;
687+
pub const SOCK_RAW: usize = 2;
688+
pub const SOCK_SEQPACKET: usize = 3;
689+
pub const SOCK_STREAM: usize = 4;
690+
pub const SOCK_NONBLOCK: usize = 0x10000;
691+
pub const SOCK_CLOEXEC: usize = 0x20000;
692+
693+
pub const PF_INET: usize = 1;
694+
pub const PF_INET6: usize = 2;
695+
pub const PF_UNIX: usize = 3;
696+
pub const PF_LOCAL: usize = 3;
697+
pub const PF_UNSPEC: usize = 4;
698+
pub const PF_NETLINK: usize = 5;
699+
pub const PF_BRIDGE: usize = 6;
700+
701+
pub const AF_INET: usize = PF_INET;
702+
pub const AF_INET6: usize = PF_INET6;
703+
pub const AF_UNIX: usize = PF_UNIX;
704+
pub const AF_LOCAL: usize = PF_LOCAL;
705+
pub const AF_UNSPEC: usize = PF_UNSPEC;
706+
pub const AF_NETLINK: usize = PF_NETLINK;
707+
pub const AF_BRIDGE: usize = PF_BRIDGE;
691708

692709
pub fn sys_socket(
693710
domain: usize,

0 commit comments

Comments
 (0)