From 5d8d06e878036629343f269132cb9097d5504742 Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Wed, 14 Jul 2010 18:40:36 +0200 Subject: Implement getsockopt (fd, SOL_SOCKET, SO_TYPE) * pflocal/socket.c (S_socket_getopt): Add SO_TYPE support. (S_socket_setopt): Fix return value. --- pflocal/socket.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'pflocal') diff --git a/pflocal/socket.c b/pflocal/socket.c index 06777cab..69838f11 100644 --- a/pflocal/socket.c +++ b/pflocal/socket.c @@ -1,6 +1,6 @@ /* Socket-specific operations - Copyright (C) 1995, 2008 Free Software Foundation, Inc. + Copyright (C) 1995, 2008, 2010 Free Software Foundation, Inc. Written by Miles Bader @@ -411,19 +411,58 @@ S_socket_recv (struct sock_user *user, return err; } -/* Stubs for currently unsupported rpcs. */ - error_t S_socket_getopt (struct sock_user *user, int level, int opt, char **value, size_t *value_len) { - return EOPNOTSUPP; + int ret = 0; + + if (!user) + return EOPNOTSUPP; + + mutex_lock (&user->sock->lock); + switch (level) + { + case SOL_SOCKET: + switch (opt) + { + case SO_TYPE: + assert (*value_len >= sizeof (int)); + *(int *)*value = user->sock->pipe_class->sock_type; + *value_len = sizeof (int); + break; + default: + ret = ENOPROTOOPT; + break; + } + break; + default: + ret = ENOPROTOOPT; + break; + } + mutex_unlock (&user->sock->lock); + + return ret; } error_t S_socket_setopt (struct sock_user *user, int level, int opt, char *value, size_t value_len) { - return EOPNOTSUPP; + int ret = 0; + + if (!user) + return EOPNOTSUPP; + + mutex_lock (&user->sock->lock); + switch (level) + { + default: + ret = ENOPROTOOPT; + break; + } + mutex_unlock (&user->sock->lock); + + return ret; } -- cgit v1.2.3