diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-10-23 23:23:54 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-10-23 23:23:54 +0000 |
commit | 5606e4d6f92c10af214b54a01db79cf561067e58 (patch) | |
tree | f50c5adf765ad7492736b3fb0e9ae669573e4e5e /libc/inet/socketcalls.c | |
parent | 56c9a8402ff4c9004331efc77e5a5fe62aa65014 (diff) |
More reorg. A place for everything and everything in its place...
Diffstat (limited to 'libc/inet/socketcalls.c')
-rw-r--r-- | libc/inet/socketcalls.c | 232 |
1 files changed, 232 insertions, 0 deletions
diff --git a/libc/inet/socketcalls.c b/libc/inet/socketcalls.c new file mode 100644 index 000000000..162e0770b --- /dev/null +++ b/libc/inet/socketcalls.c @@ -0,0 +1,232 @@ +#include <errno.h> +#include <syscall.h> +#include <sys/socket.h> +#include <sys/socketcall.h> + +extern int socketcall(int call, unsigned long *args); + +#ifdef L_accept +int accept(int s, struct sockaddr *addr, socklen_t * addrlen) +{ + unsigned long args[3]; + + args[0] = s; + args[1] = (unsigned long) addr; + args[2] = (unsigned long) addrlen; + return socketcall(SYS_ACCEPT, args); +} +#endif + +#ifdef L_bind +int bind(int sockfd, const struct sockaddr *myaddr, socklen_t addrlen) +{ + unsigned long args[3]; + + args[0] = sockfd; + args[1] = (unsigned long) myaddr; + args[2] = addrlen; + return socketcall(SYS_BIND, args); +} +#endif + +#ifdef L_connect +int connect(int sockfd, const struct sockaddr *saddr, socklen_t addrlen) +{ + unsigned long args[3]; + + args[0] = sockfd; + args[1] = (unsigned long) saddr; + args[2] = addrlen; + return socketcall(SYS_CONNECT, args); +} +#endif + +#ifdef L_getpeername +int getpeername(int sockfd, struct sockaddr *addr, socklen_t * paddrlen) +{ + unsigned long args[3]; + + args[0] = sockfd; + args[1] = (unsigned long) addr; + args[2] = (unsigned long) paddrlen; + return socketcall(SYS_GETPEERNAME, args); +} +#endif + +#ifdef L_getsockname +int getsockname(int sockfd, struct sockaddr *addr, socklen_t * paddrlen) +{ + unsigned long args[3]; + + args[0] = sockfd; + args[1] = (unsigned long) addr; + args[2] = (unsigned long) paddrlen; + return socketcall(SYS_GETSOCKNAME, args); +} +#endif + +#ifdef L_getsockopt +int getsockopt(int fd, int level, int optname, __ptr_t optval, + socklen_t * optlen) +{ + unsigned long args[5]; + + args[0] = fd; + args[1] = level; + args[2] = optname; + args[3] = (unsigned long) optval; + args[4] = (unsigned long) optlen; + return (socketcall(SYS_GETSOCKOPT, args)); +} +#endif + +#ifdef L_listen +int listen(int sockfd, unsigned int backlog) +{ + unsigned long args[2]; + + args[0] = sockfd; + args[1] = backlog; + return socketcall(SYS_LISTEN, args); +} +#endif + +#ifdef L_recv +/* recv, recvfrom added by bir7@leland.stanford.edu */ +int recv(int sockfd, __ptr_t buffer, size_t len, int flags) +{ + unsigned long args[4]; + + args[0] = sockfd; + args[1] = (unsigned long) buffer; + args[2] = len; + args[3] = flags; + return (socketcall(SYS_RECV, args)); +} +#endif + +#ifdef L_recvfrom +/* recv, recvfrom added by bir7@leland.stanford.edu */ +int recvfrom(int sockfd, __ptr_t buffer, size_t len, int flags, + struct sockaddr *to, socklen_t * tolen) +{ + unsigned long args[6]; + + args[0] = sockfd; + args[1] = (unsigned long) buffer; + args[2] = len; + args[3] = flags; + args[4] = (unsigned long) to; + args[5] = (unsigned long) tolen; + return (socketcall(SYS_RECVFROM, args)); +} +#endif + +#ifdef L_recvmsg +int recvmsg(int sockfd, struct msghdr *msg, int flags) +{ + unsigned long args[3]; + + args[0] = sockfd; + args[1] = (unsigned long) msg; + args[2] = flags; + return (socketcall(SYS_RECVMSG, args)); +} +#endif + +#ifdef L_send +/* send, sendto added by bir7@leland.stanford.edu */ +int send(int sockfd, const void *buffer, size_t len, int flags) +{ + unsigned long args[4]; + + args[0] = sockfd; + args[1] = (unsigned long) buffer; + args[2] = len; + args[3] = flags; + return (socketcall(SYS_SEND, args)); +} +#endif + +#ifdef L_sendmsg +int sendmsg(int sockfd, const struct msghdr *msg, int flags) +{ + unsigned long args[3]; + + args[0] = sockfd; + args[1] = (unsigned long) msg; + args[2] = flags; + return (socketcall(SYS_SENDMSG, args)); +} +#endif + +#ifdef L_sendto +/* send, sendto added by bir7@leland.stanford.edu */ +int sendto(int sockfd, const void *buffer, size_t len, int flags, + const struct sockaddr *to, socklen_t tolen) +{ + unsigned long args[6]; + + args[0] = sockfd; + args[1] = (unsigned long) buffer; + args[2] = len; + args[3] = flags; + args[4] = (unsigned long) to; + args[5] = tolen; + return (socketcall(SYS_SENDTO, args)); +} +#endif + +#ifdef L_setsockopt +/* [sg]etsockoptions by bir7@leland.stanford.edu */ +int setsockopt(int fd, int level, int optname, const void *optval, + socklen_t optlen) +{ + unsigned long args[5]; + + args[0] = fd; + args[1] = level; + args[2] = optname; + args[3] = (unsigned long) optval; + args[4] = optlen; + return (socketcall(SYS_SETSOCKOPT, args)); +} +#endif + +#ifdef L_shutdown +/* shutdown by bir7@leland.stanford.edu */ +int shutdown(int sockfd, int how) +{ + unsigned long args[2]; + + args[0] = sockfd; + args[1] = how; + return (socketcall(SYS_SHUTDOWN, args)); +} +#endif + +#ifdef L_socket +int socket(int family, int type, int protocol) +{ + unsigned long args[3]; + + args[0] = family; + args[1] = type; + args[2] = (unsigned long) protocol; + return socketcall(SYS_SOCKET, args); +} +#endif + +#ifdef L_socketpair +int socketpair(int family, int type, int protocol, int sockvec[2]) +{ + unsigned long args[4]; + + args[0] = family; + args[1] = type; + args[2] = protocol; + args[3] = (unsigned long) sockvec; + return socketcall(SYS_SOCKETPAIR, args); +} +#endif + |