diff options
author | 2019-07-22 15:34:07 +0000 | |
---|---|---|
committer | 2019-07-22 15:34:07 +0000 | |
commit | 15b62b7eb58273c052caf9c854e2aa813dbaa7d3 (patch) | |
tree | 5359a635f24ddc981341bb3bbc79b23f56d3bb46 | |
parent | Even when polling is requested, install ihidev's interrupt handler (diff) | |
download | wireguard-openbsd-15b62b7eb58273c052caf9c854e2aa813dbaa7d3.tar.xz wireguard-openbsd-15b62b7eb58273c052caf9c854e2aa813dbaa7d3.zip |
implement SO_DOMAIN and SO_PROTOCOL so that the domain and the protocol
can also be retrieved with getsockopt(3)
it looks like these will also be in the next issue of posix:
http://austingroupbugs.net/view.php?id=840#c2263
ok claudio@, sthen@
-rw-r--r-- | lib/libc/sys/getsockopt.2 | 18 | ||||
-rw-r--r-- | sys/kern/uipc_socket.c | 10 | ||||
-rw-r--r-- | sys/sys/socket.h | 4 |
3 files changed, 27 insertions, 5 deletions
diff --git a/lib/libc/sys/getsockopt.2 b/lib/libc/sys/getsockopt.2 index f3c618035f6..39bcb8026f8 100644 --- a/lib/libc/sys/getsockopt.2 +++ b/lib/libc/sys/getsockopt.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: getsockopt.2,v 1.55 2019/02/13 11:55:21 martijn Exp $ +.\" $OpenBSD: getsockopt.2,v 1.56 2019/07/22 15:34:07 robert Exp $ .\" $NetBSD: getsockopt.2,v 1.7 1995/02/27 12:33:29 cgd Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)getsockopt.2 8.3 (Berkeley) 4/19/94 .\" -.Dd $Mdocdate: February 13 2019 $ +.Dd $Mdocdate: July 22 2019 $ .Dt GETSOCKOPT 2 .Os .Sh NAME @@ -174,6 +174,10 @@ clear all memory containing user supplied data get the type of the socket (get only) .It Dv SO_ERROR get and clear error on the socket (get only) +.It Dv SO_DOMAIN +get the domain of the socket (get only) +.It Dv SO_PROTOCOL +get the protocol of the socket (get only) .El .Pp .Dv SO_DEBUG @@ -451,7 +455,9 @@ If is set, overwrite kernel memory after sending data. .Pp Finally, -.Dv SO_TYPE +.Dv SO_TYPE , +.Dv SO_DOMAIN , +.Dv SO_PROTOCOL and .Dv SO_ERROR are options used only with @@ -460,6 +466,12 @@ are options used only with returns the type of the socket, such as .Dv SOCK_STREAM ; it is useful for servers that inherit sockets on startup. +.Dv SO_DOMAIN +returns the domain of the socket, such as +.Dv AF_INET . +.Dv SO_PROTOCOL +returns the protocol of the socket such as +.Dv IPPROTO_TCP . .Dv SO_ERROR returns any pending error on the socket and clears the error status. It may be used to check for asynchronous errors on connected diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 2f3f37b9408..974f6c962ae 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.233 2019/07/11 11:57:35 bluhm Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.234 2019/07/22 15:34:07 robert Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -1868,6 +1868,14 @@ sogetopt(struct socket *so, int level, int optname, struct mbuf *m) so->so_error = 0; break; + case SO_DOMAIN: + *mtod(m, int *) = so->so_proto->pr_domain->dom_family; + break; + + case SO_PROTOCOL: + *mtod(m, int *) = so->so_proto->pr_protocol; + break; + case SO_SNDBUF: *mtod(m, int *) = so->so_snd.sb_hiwat; break; diff --git a/sys/sys/socket.h b/sys/sys/socket.h index be8c53bdbba..927fd26ed92 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -1,4 +1,4 @@ -/* $OpenBSD: socket.h,v 1.97 2019/07/03 10:08:10 dlg Exp $ */ +/* $OpenBSD: socket.h,v 1.98 2019/07/22 15:34:07 robert Exp $ */ /* $NetBSD: socket.h,v 1.14 1996/02/09 18:25:36 christos Exp $ */ /* @@ -113,6 +113,8 @@ typedef __sa_family_t sa_family_t; /* sockaddr address family type */ #define SO_RTABLE 0x1021 /* routing table to be used */ #define SO_PEERCRED 0x1022 /* get connect-time credentials */ #define SO_SPLICE 0x1023 /* splice data to other socket */ +#define SO_DOMAIN 0x1024 /* get socket domain */ +#define SO_PROTOCOL 0x1025 /* get socket protocol */ /* * Structure used for manipulating linger option. |