Loading include/net/sctp/constants.h +6 −30 Original line number Diff line number Diff line Loading @@ -366,35 +366,11 @@ typedef enum { * addresses. */ #define IS_IPV4_UNUSABLE_ADDRESS(a) \ ((htonl(INADDR_BROADCAST) == *a) || \ (MULTICAST(*a)) || \ (((unsigned char *)(a))[0] == 0) || \ ((((unsigned char *)(a))[0] == 198) && \ (((unsigned char *)(a))[1] == 18) && \ (((unsigned char *)(a))[2] == 0)) || \ ((((unsigned char *)(a))[0] == 192) && \ (((unsigned char *)(a))[1] == 88) && \ (((unsigned char *)(a))[2] == 99))) /* IPv4 Link-local addresses: 169.254.0.0/16. */ #define IS_IPV4_LINK_ADDRESS(a) \ ((((unsigned char *)(a))[0] == 169) && \ (((unsigned char *)(a))[1] == 254)) /* RFC 1918 "Address Allocation for Private Internets" defines the IPv4 * private address space as the following: * * 10.0.0.0 - 10.255.255.255 (10/8 prefix) * 172.16.0.0.0 - 172.31.255.255 (172.16/12 prefix) * 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) */ #define IS_IPV4_PRIVATE_ADDRESS(a) \ ((((unsigned char *)(a))[0] == 10) || \ ((((unsigned char *)(a))[0] == 172) && \ (((unsigned char *)(a))[1] >= 16) && \ (((unsigned char *)(a))[1] < 32)) || \ ((((unsigned char *)(a))[0] == 192) && \ (((unsigned char *)(a))[1] == 168))) ((htonl(INADDR_BROADCAST) == a) || \ ipv4_is_multicast(a) || \ ipv4_is_zeronet(a) || \ ipv4_is_test_198(a) || \ ipv4_is_anycast_6to4(a)) /* Flags used for the bind address copy functions. */ #define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by Loading net/sctp/protocol.c +7 −5 Original line number Diff line number Diff line Loading @@ -359,7 +359,7 @@ static int sctp_v4_addr_valid(union sctp_addr *addr, const struct sk_buff *skb) { /* Is this a non-unicast address or a unusable SCTP address? */ if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr)) if (IS_IPV4_UNUSABLE_ADDRESS(addr->v4.sin_addr.s_addr)) return 0; /* Is this a broadcast address? */ Loading Loading @@ -408,13 +408,15 @@ static sctp_scope_t sctp_v4_scope(union sctp_addr *addr) */ /* Check for unusable SCTP addresses. */ if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr)) { if (IS_IPV4_UNUSABLE_ADDRESS(addr->v4.sin_addr.s_addr)) { retval = SCTP_SCOPE_UNUSABLE; } else if (LOOPBACK(addr->v4.sin_addr.s_addr)) { } else if (ipv4_is_loopback(addr->v4.sin_addr.s_addr)) { retval = SCTP_SCOPE_LOOPBACK; } else if (IS_IPV4_LINK_ADDRESS(&addr->v4.sin_addr.s_addr)) { } else if (ipv4_is_linklocal_169(addr->v4.sin_addr.s_addr)) { retval = SCTP_SCOPE_LINK; } else if (IS_IPV4_PRIVATE_ADDRESS(&addr->v4.sin_addr.s_addr)) { } else if (ipv4_is_private_10(addr->v4.sin_addr.s_addr) || ipv4_is_private_172(addr->v4.sin_addr.s_addr) || ipv4_is_private_192(addr->v4.sin_addr.s_addr)) { retval = SCTP_SCOPE_PRIVATE; } else { retval = SCTP_SCOPE_GLOBAL; Loading Loading
include/net/sctp/constants.h +6 −30 Original line number Diff line number Diff line Loading @@ -366,35 +366,11 @@ typedef enum { * addresses. */ #define IS_IPV4_UNUSABLE_ADDRESS(a) \ ((htonl(INADDR_BROADCAST) == *a) || \ (MULTICAST(*a)) || \ (((unsigned char *)(a))[0] == 0) || \ ((((unsigned char *)(a))[0] == 198) && \ (((unsigned char *)(a))[1] == 18) && \ (((unsigned char *)(a))[2] == 0)) || \ ((((unsigned char *)(a))[0] == 192) && \ (((unsigned char *)(a))[1] == 88) && \ (((unsigned char *)(a))[2] == 99))) /* IPv4 Link-local addresses: 169.254.0.0/16. */ #define IS_IPV4_LINK_ADDRESS(a) \ ((((unsigned char *)(a))[0] == 169) && \ (((unsigned char *)(a))[1] == 254)) /* RFC 1918 "Address Allocation for Private Internets" defines the IPv4 * private address space as the following: * * 10.0.0.0 - 10.255.255.255 (10/8 prefix) * 172.16.0.0.0 - 172.31.255.255 (172.16/12 prefix) * 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) */ #define IS_IPV4_PRIVATE_ADDRESS(a) \ ((((unsigned char *)(a))[0] == 10) || \ ((((unsigned char *)(a))[0] == 172) && \ (((unsigned char *)(a))[1] >= 16) && \ (((unsigned char *)(a))[1] < 32)) || \ ((((unsigned char *)(a))[0] == 192) && \ (((unsigned char *)(a))[1] == 168))) ((htonl(INADDR_BROADCAST) == a) || \ ipv4_is_multicast(a) || \ ipv4_is_zeronet(a) || \ ipv4_is_test_198(a) || \ ipv4_is_anycast_6to4(a)) /* Flags used for the bind address copy functions. */ #define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by Loading
net/sctp/protocol.c +7 −5 Original line number Diff line number Diff line Loading @@ -359,7 +359,7 @@ static int sctp_v4_addr_valid(union sctp_addr *addr, const struct sk_buff *skb) { /* Is this a non-unicast address or a unusable SCTP address? */ if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr)) if (IS_IPV4_UNUSABLE_ADDRESS(addr->v4.sin_addr.s_addr)) return 0; /* Is this a broadcast address? */ Loading Loading @@ -408,13 +408,15 @@ static sctp_scope_t sctp_v4_scope(union sctp_addr *addr) */ /* Check for unusable SCTP addresses. */ if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr)) { if (IS_IPV4_UNUSABLE_ADDRESS(addr->v4.sin_addr.s_addr)) { retval = SCTP_SCOPE_UNUSABLE; } else if (LOOPBACK(addr->v4.sin_addr.s_addr)) { } else if (ipv4_is_loopback(addr->v4.sin_addr.s_addr)) { retval = SCTP_SCOPE_LOOPBACK; } else if (IS_IPV4_LINK_ADDRESS(&addr->v4.sin_addr.s_addr)) { } else if (ipv4_is_linklocal_169(addr->v4.sin_addr.s_addr)) { retval = SCTP_SCOPE_LINK; } else if (IS_IPV4_PRIVATE_ADDRESS(&addr->v4.sin_addr.s_addr)) { } else if (ipv4_is_private_10(addr->v4.sin_addr.s_addr) || ipv4_is_private_172(addr->v4.sin_addr.s_addr) || ipv4_is_private_192(addr->v4.sin_addr.s_addr)) { retval = SCTP_SCOPE_PRIVATE; } else { retval = SCTP_SCOPE_GLOBAL; Loading