diff options
author | Svante Signell <svante.signell@gmail.com> | 2020-06-27 00:30:56 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-06-27 00:30:56 +0200 |
commit | 7f8a212698d49413af6f2682585a6bd7a3279fc4 (patch) | |
tree | 610a4156187e85f2da86eb1c1519858e085723b7 /pflocal | |
parent | 4533863157b43e1051270185d6e8f99b6c6a4d1d (diff) | |
download | hurd-7f8a212698d49413af6f2682585a6bd7a3279fc4.tar.gz hurd-7f8a212698d49413af6f2682585a6bd7a3279fc4.tar.bz2 hurd-7f8a212698d49413af6f2682585a6bd7a3279fc4.zip |
pflocal: Add support for getsockopt(SO_{RECV,SND}BUF)
* S_socket_getopt: Handle SO_RCVBUF and SO_SNDBUF cases.
Diffstat (limited to 'pflocal')
-rw-r--r-- | pflocal/socket.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/pflocal/socket.c b/pflocal/socket.c index 47ad037f..d0751c9f 100644 --- a/pflocal/socket.c +++ b/pflocal/socket.c @@ -434,11 +434,13 @@ S_socket_getopt (struct sock_user *user, data_t *value, size_t *value_len) { int ret = 0; + struct pipe *pipe; + struct sock *sock = user->sock; if (!user) return EOPNOTSUPP; - pthread_mutex_lock (&user->sock->lock); + pthread_mutex_lock (&sock->lock); switch (level) { case SOL_SOCKET: @@ -450,7 +452,37 @@ S_socket_getopt (struct sock_user *user, ret = EINVAL; break; } - *(int *)*value = user->sock->pipe_class->sock_type; + *(int *)*value = sock->pipe_class->sock_type; + *value_len = sizeof (int); + break; + case SO_RCVBUF: + if (*value_len < sizeof (int)) + { + ret = EINVAL; + break; + } + pipe = sock->read_pipe; + if (!pipe) + { + ret = EPIPE; + break; + } + *(int *)*value = pipe->write_limit; + *value_len = sizeof (int); + break; + case SO_SNDBUF: + if (*value_len < sizeof (int)) + { + ret = EINVAL; + break; + } + pipe = sock->write_pipe; + if (!pipe) + { + ret = EPIPE; + break; + } + *(int *)*value = pipe->write_limit; *value_len = sizeof (int); break; case SO_ERROR: @@ -481,7 +513,7 @@ S_socket_getopt (struct sock_user *user, ret = ENOPROTOOPT; break; } - pthread_mutex_unlock (&user->sock->lock); + pthread_mutex_unlock (&sock->lock); return ret; } |