netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/8] net: introduce proto_ports_offset()
@ 2010-08-18  5:03 Changli Gao
  2010-08-20  0:16 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Changli Gao @ 2010-08-18  5:03 UTC (permalink / raw)
  To: David S. Miller
  Cc: Patrick McHardy, Jamal Hadi Salim, netdev, netfilter-devel,
	Changli Gao

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>
---
 include/linux/in.h |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff --git a/include/linux/in.h b/include/linux/in.h
index 41d88a4..beeb6de 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);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/8] net: introduce proto_ports_offset()
  2010-08-18  5:03 [PATCH 3/8] net: introduce proto_ports_offset() Changli Gao
@ 2010-08-20  0:16 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-08-20  0:16 UTC (permalink / raw)
  To: xiaosuo; +Cc: kaber, hadi, netdev, netfilter-devel

From: Changli Gao <xiaosuo@gmail.com>
Date: Wed, 18 Aug 2010 13:03:44 +0800

> 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>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-20  0:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-18  5:03 [PATCH 3/8] net: introduce proto_ports_offset() Changli Gao
2010-08-20  0:16 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).