diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-22 09:14:34 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-22 09:25:11 +0200 |
commit | 1641088178538e4ae409d53bbcbbb06fa80ffca0 (patch) | |
tree | 6b32afcc32f8f82c2e20c517bdbc71e14afae7f2 /cpukit/libnetworking | |
parent | network: Delete unused in4_cksum() (diff) | |
download | rtems-1641088178538e4ae409d53bbcbbb06fa80ffca0.tar.bz2 |
network: Ensure matching syscall prototypes
Ensure that kernel and user space system call protoypes are identical.
Diffstat (limited to 'cpukit/libnetworking')
-rw-r--r-- | cpukit/libnetworking/Makefile.am | 1 | ||||
-rw-r--r-- | cpukit/libnetworking/kern/kern_sysctl.c | 14 | ||||
-rw-r--r-- | cpukit/libnetworking/rtems/rtems_syscall.c | 30 | ||||
-rw-r--r-- | cpukit/libnetworking/rtems/rtems_syscall.h | 70 | ||||
-rw-r--r-- | cpukit/libnetworking/rtems/rtems_syscall_api.c | 20 | ||||
-rw-r--r-- | cpukit/libnetworking/sys/sysctl.h | 8 |
6 files changed, 117 insertions, 26 deletions
diff --git a/cpukit/libnetworking/Makefile.am b/cpukit/libnetworking/Makefile.am index 2a8e06aafd..4f3dd0c4f8 100644 --- a/cpukit/libnetworking/Makefile.am +++ b/cpukit/libnetworking/Makefile.am @@ -255,6 +255,7 @@ lib_a_CPPFLAGS = $(AM_CPPFLAGS) $(lib_CPPFLAGS) -D__BSD_VISIBLE lib_a_SOURCES = lib/getprotoby.c lib/rtems_bsdnet_ntp.c lib/ftpfs.c \ lib/syslog.c lib/tftpDriver.c +lib_a_SOURCES += rtems/rtems_syscall_api.c endif EXTRA_DIST += $(UNUSED_FILES) diff --git a/cpukit/libnetworking/kern/kern_sysctl.c b/cpukit/libnetworking/kern/kern_sysctl.c index 993c20f5d2..e2de690d55 100644 --- a/cpukit/libnetworking/kern/kern_sysctl.c +++ b/cpukit/libnetworking/kern/kern_sysctl.c @@ -94,7 +94,8 @@ static struct sx sysctllock; #define SYSCTL_INIT() sx_init(&sysctllock, "sysctl lock") #endif -static int sysctl_root(SYSCTL_HANDLER_ARGS); +static int sysctl_root(struct sysctl_oid *oidp, const void *arg1, + intptr_t arg2, struct sysctl_req *req); struct sysctl_oid_list sysctl__children; /* root list */ @@ -1094,7 +1095,7 @@ sysctl_wire_old_buffer(struct sysctl_req *req, size_t len) } int -sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, +sysctl_find_oid(const int *name, u_int namelen, struct sysctl_oid **noid, int *nindx, struct sysctl_req *req) { struct sysctl_oid *oid; @@ -1138,7 +1139,8 @@ sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, */ static int -sysctl_root(SYSCTL_HANDLER_ARGS) +sysctl_root(struct sysctl_oid *oidp, const void *arg1, intptr_t arg2, + struct sysctl_req *req) { struct sysctl_oid *oid; int error, indx; @@ -1197,6 +1199,7 @@ sysctl_root(SYSCTL_HANDLER_ARGS) return (error); } +#ifndef __rtems__ #ifndef _SYS_SYSPROTO_H_ struct sysctl_args { int *name; @@ -1240,14 +1243,15 @@ done2: mtx_unlock(&Giant); return (error); } +#endif /* __rtems__ */ /* * This is used from various compatibility syscalls too. That's why name * must be in kernel space. */ int -userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, - size_t *oldlenp, int inkernel, void *new, size_t newlen, size_t *retval) +userland_sysctl(struct thread *td, const int *name, u_int namelen, void *old, + size_t *oldlenp, int inkernel, const void *new, size_t newlen, size_t *retval) { int error = 0; struct sysctl_req req, req2; diff --git a/cpukit/libnetworking/rtems/rtems_syscall.c b/cpukit/libnetworking/rtems/rtems_syscall.c index c0dccf6fca..6bef21afc4 100644 --- a/cpukit/libnetworking/rtems/rtems_syscall.c +++ b/cpukit/libnetworking/rtems/rtems_syscall.c @@ -28,11 +28,7 @@ #include <net/if.h> #include <net/route.h> -/* - * Since we are "in the kernel", these do not get prototyped in sys/socket.h - */ -ssize_t send(int, const void *, size_t, int); -ssize_t recv(int, void *, size_t, int); +#include "rtems_syscall.h" /* * Hooks to RTEMS I/O system @@ -145,7 +141,7 @@ socket (int domain, int type, int protocol) } int -bind (int s, struct sockaddr *name, int namelen) +bind (int s, const struct sockaddr *name, socklen_t namelen) { int error; int ret = -1; @@ -172,7 +168,7 @@ bind (int s, struct sockaddr *name, int namelen) } int -connect (int s, struct sockaddr *name, int namelen) +connect (int s, const struct sockaddr *name, socklen_t namelen) { int error; int ret = -1; @@ -244,7 +240,7 @@ listen (int s, int backlog) } int -accept (int s, struct sockaddr *name, int *namelen) +accept (int s, struct sockaddr *name, socklen_t *namelen) { int fd; struct socket *head, *so; @@ -412,7 +408,7 @@ sendmsg (int s, const struct msghdr *mp, int flags) * Send a message to a host */ ssize_t -sendto (int s, const void *buf, size_t buflen, int flags, const struct sockaddr *to, int tolen) +sendto (int s, const void *buf, size_t buflen, int flags, const struct sockaddr *to, socklen_t tolen) { struct msghdr msg; struct iovec iov; @@ -526,7 +522,7 @@ recvmsg (int s, struct msghdr *mp, int flags) * Receive a message from a host */ ssize_t -recvfrom (int s, void *buf, size_t buflen, int flags, const struct sockaddr *from, int *fromlen) +recvfrom (int s, void *buf, size_t buflen, int flags, struct sockaddr *from, socklen_t *fromlen) { struct msghdr msg; struct iovec iov; @@ -550,7 +546,7 @@ recvfrom (int s, void *buf, size_t buflen, int flags, const struct sockaddr *fro } int -setsockopt (int s, int level, int name, const void *val, int len) +setsockopt (int s, int level, int name, const void *val, socklen_t len) { struct socket *so; struct mbuf *m = NULL; @@ -585,7 +581,7 @@ setsockopt (int s, int level, int name, const void *val, int len) } int -getsockopt (int s, int level, int name, void *aval, int *avalsize) +getsockopt (int s, int level, int name, void *aval, socklen_t *avalsize) { struct socket *so; struct mbuf *m = NULL, *m0; @@ -628,7 +624,7 @@ getsockopt (int s, int level, int name, void *aval, int *avalsize) } static int -getpeersockname (int s, struct sockaddr *name, int *namelen, int pflag) +getpeersockname (int s, struct sockaddr *name, socklen_t *namelen, int pflag) { struct socket *so; struct mbuf *m; @@ -667,19 +663,19 @@ getpeersockname (int s, struct sockaddr *name, int *namelen, int pflag) } int -getpeername (int s, struct sockaddr *name, int *namelen) +getpeername (int s, struct sockaddr *name, socklen_t *namelen) { return getpeersockname (s, name, namelen, 1); } int -getsockname (int s, struct sockaddr *name, int *namelen) +getsockname (int s, struct sockaddr *name, socklen_t *namelen) { return getpeersockname (s, name, namelen, 0); } int -sysctl(int *name, u_int namelen, void *oldp, - size_t *oldlenp, void *newp, size_t newlen) +sysctl(const int *name, u_int namelen, void *oldp, + size_t *oldlenp, const void *newp, size_t newlen) { int error; size_t j; diff --git a/cpukit/libnetworking/rtems/rtems_syscall.h b/cpukit/libnetworking/rtems/rtems_syscall.h new file mode 100644 index 0000000000..b0d38a6e2a --- /dev/null +++ b/cpukit/libnetworking/rtems/rtems_syscall.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _LIBNETWORKING_RTEMS_SYSCALL_H_ +#define _LIBNETWORKING_RTEMS_SYSCALL_H_ + +#include <sys/cdefs.h> +#include <sys/types.h> +#include <sys/select.h> +#include <sys/socket.h> +#include <sys/time.h> + +__BEGIN_DECLS + +int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); + +int accept(int, struct sockaddr * __restrict, socklen_t * __restrict); + +int bind(int, const struct sockaddr *, socklen_t); + +int connect(int, const struct sockaddr *, socklen_t); + +int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict); + +int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict); + +int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict); + +int listen(int, int); + +ssize_t recv(int, void *, size_t, int); + +ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, socklen_t * __restrict); + +ssize_t recvmsg(int, struct msghdr *, int); + +ssize_t send(int, const void *, size_t, int); + +ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t); + +ssize_t sendmsg(int, const struct msghdr *, int); + +int setsockopt(int, int, int, const void *, socklen_t); + +int shutdown(int, int); + +int socket(int, int, int); + +int socketpair(int, int, int, int *); + +int sysctl(const int *, u_int, void *, size_t *, const void *, size_t); + +int sysctlbyname(const char *, void *, size_t *, const void *, size_t); + +int sysctlnametomib(const char *, int *, size_t *); + +__END_DECLS + +#endif /* _LIBNETWORKING_RTEMS_SYSCALL_H_ */ diff --git a/cpukit/libnetworking/rtems/rtems_syscall_api.c b/cpukit/libnetworking/rtems/rtems_syscall_api.c new file mode 100644 index 0000000000..ac3ab6e4e2 --- /dev/null +++ b/cpukit/libnetworking/rtems/rtems_syscall_api.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +/* Ensure that kernel and user space system call protoypes are identical */ +#include "rtems_syscall.h" diff --git a/cpukit/libnetworking/sys/sysctl.h b/cpukit/libnetworking/sys/sysctl.h index 58ac3e007b..12e3845402 100644 --- a/cpukit/libnetworking/sys/sysctl.h +++ b/cpukit/libnetworking/sys/sysctl.h @@ -132,7 +132,7 @@ struct sysctl_req { size_t oldlen; size_t oldidx; int (*oldfunc)(struct sysctl_req *, const void *, size_t); - void *newptr; + const void *newptr; size_t newlen; size_t newidx; int (*newfunc)(struct sysctl_req *, void *, size_t); @@ -622,10 +622,10 @@ int kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old, int kernel_sysctlbyname(struct thread *td, char *name, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval); -int userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, - size_t *oldlenp, int inkernel, void *new, size_t newlen, +int userland_sysctl(struct thread *td, const int *name, u_int namelen, void *old, + size_t *oldlenp, int inkernel, const void *new, size_t newlen, size_t *retval); -int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, +int sysctl_find_oid(const int *name, u_int namelen, struct sysctl_oid **noid, int *nindx, struct sysctl_req *req); int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len); |