Make socket port binding a separate step with ipc_netsockbindport() syscall
This commit is contained in:
@ -6,12 +6,11 @@
|
||||
#include "util/util.h"
|
||||
#include "errors.h"
|
||||
|
||||
int32_t SYSCALL3(sys_ipc_netsockmake, net1, proto1, port1) {
|
||||
int32_t SYSCALL2(sys_ipc_netsockmake, net1, proto1) {
|
||||
uint16_t net = net1;
|
||||
uint16_t proto = proto1;
|
||||
uint16_t port = port1;
|
||||
|
||||
IpcNetSock *netsock = ipc_netsockmake(net, proto, port, _caller_pid);
|
||||
IpcNetSock *netsock = ipc_netsockmake(net, proto, _caller_pid);
|
||||
|
||||
if (netsock == NULL) {
|
||||
return E_NOMEMORY;
|
||||
@ -102,3 +101,24 @@ int32_t SYSCALL1(sys_ipc_netsockdelete, socknum1) {
|
||||
|
||||
return ipc_netsockdelete(ns);
|
||||
}
|
||||
|
||||
int32_t SYSCALL2(sys_ipc_netsockbindport, socknum1, port1) {
|
||||
size_t socknum = socknum1;
|
||||
uint16_t port = port1;
|
||||
|
||||
spinlock_acquire(&IPC_NETSOCKS.spinlock);
|
||||
size_t idx = 0;
|
||||
IpcNetSock *ns, *nstmp;
|
||||
LL_FOREACH_SAFE_IDX(IPC_NETSOCKS.netsocks, ns, nstmp, idx) {
|
||||
if (idx == socknum) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
spinlock_release(&IPC_NETSOCKS.spinlock);
|
||||
|
||||
if (ns == NULL) {
|
||||
return E_NOENTRY;
|
||||
}
|
||||
|
||||
return ipc_netsockbindport(ns, port);
|
||||
}
|
||||
|
||||
@ -5,9 +5,10 @@
|
||||
#include <stdint.h>
|
||||
#include "syscall.h"
|
||||
|
||||
int32_t SYSCALL3(sys_ipc_netsockmake, net1, proto1, port1);
|
||||
int32_t SYSCALL2(sys_ipc_netsockmake, net1, proto1);
|
||||
int32_t SYSCALL2(sys_ipc_netsocklisten, socknum1, maxlisteners1);
|
||||
int32_t SYSCALL1(sys_ipc_netsockpollev, socknum1);
|
||||
int32_t SYSCALL1(sys_ipc_netsockdelete, socknum1);
|
||||
int32_t SYSCALL2(sys_ipc_netsockbindport, socknum1, port1);
|
||||
|
||||
#endif // SYSCALL_IPC_NETSOCK_H_
|
||||
|
||||
@ -69,4 +69,5 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
|
||||
[SYS_IPC_NETSOCKLISTEN] = &sys_ipc_netsocklisten,
|
||||
[SYS_IPC_NETSOCKPOLLEV] = &sys_ipc_netsockpollev,
|
||||
[SYS_IPC_NETSOCKDELETE] = &sys_ipc_netsockdelete,
|
||||
[SYS_IPC_NETSOCKBINDPORT] = &sys_ipc_netsockbindport,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user