Skip to content

Commit

Permalink
net: introduce proto_ports_offset()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Changli Gao authored and David S. Miller committed Aug 20, 2010
1 parent dbe5775 commit e760702
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions include/linux/in.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e760702

Please sign in to comment.