#define N_SYNC_PPP 14
#define N_HCI 15
+#define FIOSETOWN 0x8901
+#define SIOCSPGRP 0x8902
+#define FIOGETOWN 0x8903
+#define SIOCGPGRP 0x8904
+#define SIOCATMARK 0x8905
+#define SIOCGSTAMP 0x8906
+
#define SIOCADDRT 0x890B
#define SIOCDELRT 0x890C
#define SIOCRTMSG 0x890D
#define __NR_pread __NR_pread64
#define __NR_pwrite __NR_pwrite64
+#define __SC_socket 1
+#define __SC_bind 2
+#define __SC_connect 3
+#define __SC_listen 4
+#define __SC_accept 5
+#define __SC_getsockname 6
+#define __SC_getpeername 7
+#define __SC_socketpair 8
+#define __SC_send 9
+#define __SC_recv 10
+#define __SC_sendto 11
+#define __SC_recvfrom 12
+#define __SC_shutdown 13
+#define __SC_setsockopt 14
+#define __SC_getsockopt 15
+#define __SC_sendmsg 16
+#define __SC_recvmsg 17
+
+
+#define socketcall(nm, a, b, c, d, e, f) syscall2(__NR_socketcall, __SC_##nm, \
+ (long)(long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f })
#undef O_LARGEFILE
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
#include "libc.h"
int accept(int fd, struct sockaddr *addr, socklen_t *len)
{
- unsigned long args[] = { fd, (unsigned long)addr, (unsigned long)len };
int ret;
CANCELPT_BEGIN;
- ret = syscall2(__NR_socketcall, SYS_ACCEPT, (long)args);
+ ret = socketcall(accept, fd, addr, len, 0, 0, 0);
CANCELPT_END;
return ret;
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
int bind(int fd, const struct sockaddr *addr, socklen_t len)
{
- unsigned long args[] = { fd, (unsigned long)addr, len };
- return syscall2(__NR_socketcall, SYS_BIND, (long)args);
+ return socketcall(bind, fd, addr, len, 0, 0, 0);
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
#include "libc.h"
int connect(int fd, const struct sockaddr *addr, socklen_t len)
{
- unsigned long args[] = { fd, (unsigned long)addr, len };
int ret;
CANCELPT_BEGIN;
- ret = syscall2(__NR_socketcall, SYS_CONNECT, (long)args);
+ ret = socketcall(connect, fd, addr, len, 0, 0, 0);
CANCELPT_END;
return ret;
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
int getpeername(int fd, struct sockaddr *addr, socklen_t *len)
{
- unsigned long args[] = { fd, (unsigned long)addr, (unsigned long)len };
- return syscall2(__NR_socketcall, SYS_GETPEERNAME, (long)args);
+ return socketcall(getpeername, fd, addr, len, 0, 0, 0);
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
int getsockname(int fd, struct sockaddr *addr, socklen_t *len)
{
- unsigned long args[] = { fd, (unsigned long)addr, (unsigned long)len };
- return syscall2(__NR_socketcall, SYS_GETSOCKNAME, (long)args);
+ return socketcall(getsockname, fd, addr, len, 0, 0, 0);
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
int getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen)
{
- unsigned long args[] = {
- fd, level, optname,
- (unsigned long)optval,
- (unsigned long)optlen
- };
- return syscall2(__NR_socketcall, SYS_GETSOCKOPT, (long)args);
+ return socketcall(getsockopt, fd, level, optname, optval, optlen, 0);
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
int listen(int fd, int backlog)
{
- unsigned long args[] = { fd, backlog };
- return syscall2(__NR_socketcall, SYS_LISTEN, (long)args);
+ return socketcall(listen, fd, backlog, 0, 0, 0, 0);
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
#include "libc.h"
ssize_t recv(int fd, void *buf, size_t len, int flags)
{
- unsigned long args[] = { fd, (unsigned long)buf, len, flags };
- ssize_t r;
- CANCELPT_BEGIN;
- r = syscall2(__NR_socketcall, SYS_RECV, (long)args);
- CANCELPT_END;
- return r;
+ return recvfrom(fd, buf, len, flags, 0, 0);
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
#include "libc.h"
ssize_t recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *alen)
{
- unsigned long args[] = {
- fd, (unsigned long)buf, len, flags,
- (unsigned long)addr, (unsigned long)alen
- };
ssize_t r;
CANCELPT_BEGIN;
- r = syscall2(__NR_socketcall, SYS_RECVFROM, (long)args);
+ r = socketcall(recvfrom, fd, buf, len, flags, addr, alen);
CANCELPT_END;
return r;
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
#include "libc.h"
ssize_t recvmsg(int fd, struct msghdr *msg, int flags)
{
- unsigned long args[] = { fd, (unsigned long)msg, flags };
ssize_t r;
CANCELPT_BEGIN;
- r = syscall2(__NR_socketcall, SYS_RECVMSG, (long)args);
+ r = socketcall(recvmsg, fd, msg, flags, 0, 0, 0);
CANCELPT_END;
return r;
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
#include "libc.h"
ssize_t send(int fd, const void *buf, size_t len, int flags)
{
- unsigned long args[] = { fd, (unsigned long)buf, len, flags };
- ssize_t r;
- CANCELPT_BEGIN;
- r = syscall2(__NR_socketcall, SYS_SEND, (long)args);
- CANCELPT_END;
- return r;
+ return sendto(fd, buf, len, flags, 0, 0);
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
#include "libc.h"
ssize_t sendmsg(int fd, const struct msghdr *msg, int flags)
{
- unsigned long args[] = { fd, (unsigned long)msg, flags };
ssize_t r;
CANCELPT_BEGIN;
- r = syscall2(__NR_socketcall, SYS_SENDMSG, (long)args);
+ r = socketcall(sendmsg, fd, msg, flags, 0, 0, 0);
CANCELPT_END;
return r;
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
#include "libc.h"
ssize_t sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen)
{
- unsigned long args[] = {
- fd, (unsigned long)buf, len, flags,
- (unsigned long)addr, alen
- };
ssize_t r;
CANCELPT_BEGIN;
- r = syscall2(__NR_socketcall, SYS_SENDTO, (long)args);
+ r = socketcall(sendto, fd, buf, len, flags, addr, alen);
CANCELPT_END;
return r;
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
int setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen)
{
- unsigned long args[] = { fd, level, optname, (unsigned long)optval, optlen };
- return syscall2(__NR_socketcall, SYS_SETSOCKOPT, (long)args);
+ return socketcall(setsockopt, fd, level, optname, optval, optlen, 0);
}
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
int shutdown(int fd, int how)
{
- unsigned long args[] = { fd, how };
- return syscall2(__NR_socketcall, SYS_SHUTDOWN, (long)args);
+ return socketcall(shutdown, fd, how, 0, 0, 0, 0);
}
#include <sys/socket.h>
#include <sys/ioctl.h>
-#include "socketcall.h"
int sockatmark(int s)
{
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
int socket(int domain, int type, int protocol)
{
- unsigned long args[] = { domain, type, protocol };
- return syscall2(__NR_socketcall, SYS_SOCKET, (long)args);
+ return socketcall(socket, domain, type, protocol, 0, 0, 0);
}
+++ /dev/null
-#define SYS_SOCKET 1
-#define SYS_BIND 2
-#define SYS_CONNECT 3
-#define SYS_LISTEN 4
-#define SYS_ACCEPT 5
-#define SYS_GETSOCKNAME 6
-#define SYS_GETPEERNAME 7
-#define SYS_SOCKETPAIR 8
-#define SYS_SEND 9
-#define SYS_RECV 10
-#define SYS_SENDTO 11
-#define SYS_RECVFROM 12
-#define SYS_SHUTDOWN 13
-#define SYS_SETSOCKOPT 14
-#define SYS_GETSOCKOPT 15
-#define SYS_SENDMSG 16
-#define SYS_RECVMSG 17
-
-#define FIOSETOWN 0x8901
-#define SIOCSPGRP 0x8902
-#define FIOGETOWN 0x8903
-#define SIOCGPGRP 0x8904
-#define SIOCATMARK 0x8905
-#define SIOCGSTAMP 0x8906
#include <sys/socket.h>
#include "syscall.h"
-#include "socketcall.h"
int socketpair(int domain, int type, int protocol, int fd[2])
{
- unsigned long args[] = { domain, type, protocol, (unsigned long)fd };
- return syscall2(__NR_socketcall, SYS_SOCKETPAIR, (long)args);
+ return socketcall(socketpair, domain, type, protocol, fd, 0, 0);
}