aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/sock.c
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2009-08-04 03:28:28 -0400
committerDavid S. Miller <davem@davemloft.net>2009-08-05 16:02:56 -0400
commit49c794e94649020248e37b78db16cd25bad38b4f (patch)
tree76c455522d37fa0fa88c7466bb494523cb320fab /net/core/sock.c
parentc1c00ab8626298ac784ea344bf10e94b5bd9bcb5 (diff)
net: implement a SO_PROTOCOL getsockoption
Similar to SO_TYPE returning the socket type, SO_PROTOCOL allows to retrieve the protocol used with a given socket. I am not quite sure why we have that-many copies of socket.h, and why the values are not the same on all arches either, but for where hex numbers dominate, I use 0x1029 for SO_PROTOCOL as that seems to be the next free unused number across a bunch of operating systems, or so Google results make me want to believe. SO_PROTOCOL for others just uses the next free Linux number, 38. Signed-off-by: Jan Engelhardt <jengelh@medozas.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/sock.c')
-rw-r--r--net/core/sock.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index a324a80c163e..ebce661234ac 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -482,6 +482,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
482 sk->sk_reuse = valbool; 482 sk->sk_reuse = valbool;
483 break; 483 break;
484 case SO_TYPE: 484 case SO_TYPE:
485 case SO_PROTOCOL:
485 case SO_ERROR: 486 case SO_ERROR:
486 ret = -ENOPROTOOPT; 487 ret = -ENOPROTOOPT;
487 break; 488 break;
@@ -764,6 +765,10 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
764 v.val = sk->sk_type; 765 v.val = sk->sk_type;
765 break; 766 break;
766 767
768 case SO_PROTOCOL:
769 v.val = sk->sk_protocol;
770 break;
771
767 case SO_ERROR: 772 case SO_ERROR:
768 v.val = -sock_error(sk); 773 v.val = -sock_error(sk);
769 if (v.val == 0) 774 if (v.val == 0)