summaryrefslogtreecommitdiffstats
path: root/lib/socket_wrapper/socket_wrapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/socket_wrapper/socket_wrapper.c')
-rw-r--r--lib/socket_wrapper/socket_wrapper.c51
1 files changed, 46 insertions, 5 deletions
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index c52f3d7182..19ac1840cd 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -2844,6 +2844,12 @@ int getsockname(int s, struct sockaddr *name, socklen_t *addrlen)
* GETSOCKOPT
***************************************************************************/
+#ifndef SO_PROTOCOL
+# ifdef SO_PROTOTYPE /* The Solaris name */
+# define SO_PROTOCOL SO_PROTOTYPE
+# endif /* SO_PROTOTYPE */
+#endif /* SO_PROTOCOL */
+
static int swrap_getsockopt(int s, int level, int optname,
void *optval, socklen_t *optlen)
{
@@ -2858,11 +2864,46 @@ static int swrap_getsockopt(int s, int level, int optname,
}
if (level == SOL_SOCKET) {
- return libc_getsockopt(s,
- level,
- optname,
- optval,
- optlen);
+ switch (optname) {
+#ifdef SO_DOMAIN
+ case SO_DOMAIN:
+ if (optval == NULL || optlen == NULL ||
+ *optlen < (socklen_t)sizeof(int)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ *optlen = sizeof(int);
+ *(int *)optval = si->family;
+ return 0;
+#endif /* SO_DOMAIN */
+ case SO_PROTOCOL:
+ if (optval == NULL || optlen == NULL ||
+ *optlen < (socklen_t)sizeof(int)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ *optlen = sizeof(int);
+ *(int *)optval = si->protocol;
+ return 0;
+ case SO_TYPE:
+ if (optval == NULL || optlen == NULL ||
+ *optlen < (socklen_t)sizeof(int)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ *optlen = sizeof(int);
+ *(int *)optval = si->type;
+ return 0;
+ default:
+ return libc_getsockopt(s,
+ level,
+ optname,
+ optval,
+ optlen);
+ }
}
errno = ENOPROTOOPT;