[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...)
From: |
Emilio Pozuelo Monfort |
Subject: |
Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...) |
Date: |
Sat, 17 Jul 2010 12:49:31 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100619 Icedove/3.0.5 |
This fixed Carl and Samuel's comments. I haven't retested since the changes are
trivial.
Cheers,
Emilio
>From 6892a23b4387eab9cde63fa86a04b3e7efd615cf Mon Sep 17 00:00:00 2001
From: Emilio Pozuelo Monfort <pochu27@gmail.com>
Date: Wed, 14 Jul 2010 18:40:36 +0200
Subject: [PATCH] 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 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/pflocal/socket.c b/pflocal/socket.c
index 06777ca..544bffe 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>
@@ -410,20 +410,59 @@ 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;
}
--
1.7.1
- [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Emilio Pozuelo Monfort, 2010/07/15
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Jérémie Koenig, 2010/07/15
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Emilio Pozuelo Monfort, 2010/07/15
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Emilio Pozuelo Monfort, 2010/07/15
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Emilio Pozuelo Monfort, 2010/07/15
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Carl Fredrik Hammar, 2010/07/15
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Emilio Pozuelo Monfort, 2010/07/17
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Samuel Thibault, 2010/07/17
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Carl Fredrik Hammar, 2010/07/17
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Carl Fredrik Hammar, 2010/07/17
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...),
Emilio Pozuelo Monfort <=
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Ludovic Courtès, 2010/07/17
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Carl Fredrik Hammar, 2010/07/17
- Re: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...), Ludovic Courtès, 2010/07/17
- RPC port classes (was: [PATCH] Implement getsockopt (fd, SOL_SOCKET, SO_TYPE, ...)), olafBuddenhagen, 2010/07/30