]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
net: implement a SO_PROTOCOL getsockoption
authorJan Engelhardt <jengelh@medozas.de>
Tue, 4 Aug 2009 07:28:28 +0000 (07:28 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 5 Aug 2009 20:02:56 +0000 (13:02 -0700)
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>
20 files changed:
arch/alpha/include/asm/socket.h
arch/arm/include/asm/socket.h
arch/avr32/include/asm/socket.h
arch/cris/include/asm/socket.h
arch/frv/include/asm/socket.h
arch/h8300/include/asm/socket.h
arch/ia64/include/asm/socket.h
arch/m32r/include/asm/socket.h
arch/m68k/include/asm/socket.h
arch/microblaze/include/asm/socket.h
arch/mips/include/asm/socket.h
arch/mn10300/include/asm/socket.h
arch/parisc/include/asm/socket.h
arch/powerpc/include/asm/socket.h
arch/s390/include/asm/socket.h
arch/sparc/include/asm/socket.h
arch/x86/include/asm/socket.h
arch/xtensa/include/asm/socket.h
include/asm-generic/socket.h
net/core/sock.c

index 3641ec1452f49f14f3082e543a93bfa38e3da972..2f8b4d3777497ea0f640573feacfa5656dc96a1d 100644 (file)
@@ -32,6 +32,7 @@
 #define        SO_RCVTIMEO     0x1012
 #define        SO_SNDTIMEO     0x1013
 #define SO_ACCEPTCONN  0x1014
+#define SO_PROTOCOL    0x1028
 
 /* linux-specific, might as well be the same as on i386 */
 #define SO_NO_CHECK    11
index 537de4e0ef50657ff4d855443043ca73e33ec689..7f47454ffbf3ebcf440e658a639421ab266440f1 100644 (file)
@@ -57,4 +57,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _ASM_SOCKET_H */
index 04c8606197007b9003d650e100ff4ff54ba8bd2b..6af2866a4f003eb3a315010e8b6d69ab887cd61f 100644 (file)
@@ -57,4 +57,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* __ASM_AVR32_SOCKET_H */
index d5cf740054082d5ca51fd184bd9d88cef4d5e4bb..f3859fb0990c6502c9f5b95e435af38832562164 100644 (file)
@@ -59,6 +59,8 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _ASM_SOCKET_H */
 
 
index 57c3d4054e8bd9bf082eb151d632b0ab841f9035..8dab3486ffa40f6feae5cd312e1d3fa2e8a91605 100644 (file)
@@ -57,5 +57,7 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _ASM_SOCKET_H */
 
index 602518a70a1a4a32d4771e869b884f3becc6721e..ba770d09cd6370371218b6156f04fbe845672ed1 100644 (file)
@@ -57,4 +57,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _ASM_SOCKET_H */
index 745421225ec6b5a4c6eec31897cc8d7199883ab4..091cd9d47d0fe261b35fd6b9ecef8784d2d8eda4 100644 (file)
@@ -66,4 +66,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _ASM_IA64_SOCKET_H */
index be7ed589af5cbd37231ee8851677bbf09231a892..d36f5928fb7981e58ff382f224fd24e88e7f0245 100644 (file)
@@ -57,4 +57,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _ASM_M32R_SOCKET_H */
index ca87f938b03f15ac041492791bab3e3e5aceca27..060cb7ed024fcf4c5cc680f574cd8d37d1821b12 100644 (file)
@@ -57,4 +57,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _ASM_SOCKET_H */
index 8259368603149ea09320b079b1d41bebfb385211..96bf8bfa935e114e5ced1662f9bc66b9b84e3ff5 100644 (file)
@@ -66,4 +66,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _ASM_MICROBLAZE_SOCKET_H */
index 2abca17801696314c979fb2997761649e977bb36..289ce5f5f2a30d97a892745484d8ab7cf1d8cd4d 100644 (file)
@@ -42,6 +42,7 @@ To add: #define SO_REUSEPORT 0x0200   /* Allow local address and port reuse.  */
 #define SO_SNDTIMEO    0x1005  /* send timeout */
 #define SO_RCVTIMEO    0x1006  /* receive timeout */
 #define SO_ACCEPTCONN  0x1009
+#define SO_PROTOCOL    0x1028  /* protocol type */
 
 /* linux-specific, might as well be the same as on i386 */
 #define SO_NO_CHECK    11
index fb5daf438ec92b0fb244f29b094357272e5a1362..19d7cf709b77bf661cdd72d3b03b2e49a4623e4f 100644 (file)
@@ -57,4 +57,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _ASM_SOCKET_H */
index 885472bf7b7883254afe15bf4c3c3d408731efc2..a658b09df624ed7a5412ad52f6ae9be651b44577 100644 (file)
@@ -24,6 +24,7 @@
 #define SO_RCVTIMEO    0x1006
 #define SO_ERROR       0x1007
 #define SO_TYPE                0x1008
+#define SO_PROTOCOL    0x1028
 #define SO_PEERNAME    0x2000
 
 #define SO_NO_CHECK    0x400b
index 1e5cfad0e3f7d664220ebcb4f93a3ab9ae67979e..609049d7117e9460826d3868e7551b389925cbc1 100644 (file)
@@ -64,4 +64,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _ASM_POWERPC_SOCKET_H */
index 02330c50241b161a50b748e501d0b386054f88a1..65baa9a83abc318aa07348e0aaadc85db7faf924 100644 (file)
@@ -65,4 +65,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _ASM_SOCKET_H */
index 982a12f959f476ea9c55c37bb27ce790f2b250ca..9cbbfafd05384196b49194a0e421693fde01e379 100644 (file)
@@ -29,6 +29,8 @@
 #define SO_RCVBUFFORCE 0x100b
 #define SO_ERROR       0x1007
 #define SO_TYPE                0x1008
+#define SO_PROTOCOL    0x1028
+
 
 /* Linux specific, keep the same. */
 #define SO_NO_CHECK    0x000b
index ca8bf2cd0ba99278af42bdd46a1747e8ea6e7f43..1077d2535a3200a975777c5283ede2370e13625c 100644 (file)
@@ -57,4 +57,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _ASM_X86_SOCKET_H */
index dd1a7a4a1ceaa122a403fa7c173e0720c9d4a1d2..e47f172142f1e340b43630feb974c2b016519b01 100644 (file)
@@ -68,4 +68,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* _XTENSA_SOCKET_H */
index 5d79e409241cec82ee367c60807192b5e7fad268..7e24d186616e08bcbcf748f87c244a2f4ba0bb08 100644 (file)
@@ -60,4 +60,6 @@
 #define SO_TIMESTAMPING                37
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
+#define SO_PROTOCOL            38
+
 #endif /* __ASM_GENERIC_SOCKET_H */
index a324a80c163ef6c25099dcb53ea431caa98121e3..ebce661234acd049e565d363def2408216a9ace1 100644 (file)
@@ -482,6 +482,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
                sk->sk_reuse = valbool;
                break;
        case SO_TYPE:
+       case SO_PROTOCOL:
        case SO_ERROR:
                ret = -ENOPROTOOPT;
                break;
@@ -764,6 +765,10 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
                v.val = sk->sk_type;
                break;
 
+       case SO_PROTOCOL:
+               v.val = sk->sk_protocol;
+               break;
+
        case SO_ERROR:
                v.val = -sock_error(sk);
                if (v.val == 0)