summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChangli Gao <xiaosuo@gmail.com>2010-08-17 19:03:44 +0000
committerDavid S. Miller <davem@davemloft.net>2010-08-19 17:16:23 -0700
commite760702ed8333588f9f21e7bf6597873993006f1 (patch)
tree75a0be41c269d953a48edfa3d052a08352f85bcd /include
parentdbe5775bbc00116ed5699babfe17c54f32eb34c3 (diff)
downloadlinux-e760702ed8333588f9f21e7bf6597873993006f1.tar.gz
linux-e760702ed8333588f9f21e7bf6597873993006f1.tar.bz2
linux-e760702ed8333588f9f21e7bf6597873993006f1.zip
net: introduce proto_ports_offset()
Introduce proto_ports_offset() for getting the position of the ports or SPI in the message of a protocol. Signed-off-by: Changli Gao <xiaosuo@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/in.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/in.h b/include/linux/in.h
index 41d88a4689af..beeb6dee2b49 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -250,6 +250,25 @@ struct sockaddr_in {
#ifdef __KERNEL__
+#include <linux/errno.h>
+
+static inline int proto_ports_offset(int proto)
+{
+ switch (proto) {
+ case IPPROTO_TCP:
+ case IPPROTO_UDP:
+ case IPPROTO_DCCP:
+ case IPPROTO_ESP: /* SPI */
+ case IPPROTO_SCTP:
+ case IPPROTO_UDPLITE:
+ return 0;
+ case IPPROTO_AH: /* SPI */
+ return 4;
+ default:
+ return -EINVAL;
+ }
+}
+
static inline bool ipv4_is_loopback(__be32 addr)
{
return (addr & htonl(0xff000000)) == htonl(0x7f000000);