diff options
author | Changli Gao <xiaosuo@gmail.com> | 2010-08-17 15:03:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-08-19 20:16:23 -0400 |
commit | e760702ed8333588f9f21e7bf6597873993006f1 (patch) | |
tree | 75a0be41c269d953a48edfa3d052a08352f85bcd /include/linux/in.h | |
parent | dbe5775bbc00116ed5699babfe17c54f32eb34c3 (diff) |
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/linux/in.h')
-rw-r--r-- | include/linux/in.h | 19 |
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 { | |||
250 | 250 | ||
251 | #ifdef __KERNEL__ | 251 | #ifdef __KERNEL__ |
252 | 252 | ||
253 | #include <linux/errno.h> | ||
254 | |||
255 | static inline int proto_ports_offset(int proto) | ||
256 | { | ||
257 | switch (proto) { | ||
258 | case IPPROTO_TCP: | ||
259 | case IPPROTO_UDP: | ||
260 | case IPPROTO_DCCP: | ||
261 | case IPPROTO_ESP: /* SPI */ | ||
262 | case IPPROTO_SCTP: | ||
263 | case IPPROTO_UDPLITE: | ||
264 | return 0; | ||
265 | case IPPROTO_AH: /* SPI */ | ||
266 | return 4; | ||
267 | default: | ||
268 | return -EINVAL; | ||
269 | } | ||
270 | } | ||
271 | |||
253 | static inline bool ipv4_is_loopback(__be32 addr) | 272 | static inline bool ipv4_is_loopback(__be32 addr) |
254 | { | 273 | { |
255 | return (addr & htonl(0xff000000)) == htonl(0x7f000000); | 274 | return (addr & htonl(0xff000000)) == htonl(0x7f000000); |