summaryrefslogtreecommitdiff
path: root/pflocal
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <pochu27@gmail.com>2010-07-14 18:40:36 +0200
committerCarl Fredrik Hammar <hammy.lite@gmail.com>2010-07-17 14:50:42 +0200
commit5d8d06e878036629343f269132cb9097d5504742 (patch)
treeef1de20acd99d80505048ee9e156cc96f916fce6 /pflocal
parent25e2524f2bc6c90dbaad93fe63aec18c1f73fb5f (diff)
Implement getsockopt (fd, SOL_SOCKET, SO_TYPE)
* pflocal/socket.c (S_socket_getopt): Add SO_TYPE support. (S_socket_setopt): Fix return value.
Diffstat (limited to 'pflocal')
-rw-r--r--pflocal/socket.c49
1 files changed, 44 insertions, 5 deletions
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 <miles@gnu.ai.mit.edu>
@@ -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;
}