From: Joe Perches <joe@perches.com>
To: netdev@vger.kernel.org
Cc: Sridhar Samudrala <sri@us.ibm.com>,
Vlad Yasevich <vladislav.yasevich@hp.com>,
lksctp-developers@lists.sourceforge.net
Subject: [PATCH net-2.6.25 6/8] sctp: Use ipv4_is_<type>
Date: Thu, 13 Dec 2007 15:38:59 -0800 [thread overview]
Message-ID: <1197589141-7020-6-git-send-email-joe@perches.com> (raw)
Message-ID: <1bb329b93a1f75766b7b89afdfa5ae673e9355ec.1197432867.git.joe@perches.com> (raw)
In-Reply-To: <1197589141-7020-5-git-send-email-joe@perches.com>
In-Reply-To: <e2ebcbf24539c0a3ef2ac77147dbfa55d8ac9e33.1197432867.git.joe@perches.com>
Signed-off-by: Joe Perches <joe@perches.com>
---
include/net/sctp/constants.h | 36 ++++++------------------------------
net/sctp/protocol.c | 12 +++++++-----
2 files changed, 13 insertions(+), 35 deletions(-)
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index 05f22a6..fefcba6 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -365,36 +365,12 @@ typedef enum {
* Also, RFC 8.4, non-unicast addresses are not considered valid SCTP
* 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)))
+#define IS_IPV4_UNUSABLE_ADDRESS(a) \
+ ((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
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index d50f610..dc22d71 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -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? */
@@ -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;
--
1.5.3.7.949.g2221a6
next prev parent reply other threads:[~2007-12-13 23:39 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <e2ebcbf24539c0a3ef2ac77147dbfa55d8ac9e33.1197432867.git.joe@perches.com>
2007-12-13 23:38 ` [PATCH net-2.6.25 1/8] Create ipv4_is_<type>(__be32 addr) functions Joe Perches
2007-12-13 23:38 ` Joe Perches
2007-12-16 21:42 ` David Miller
2007-12-17 22:37 ` Jan Engelhardt
2007-12-17 22:41 ` David Miller
2007-12-17 22:42 ` Joe Perches
2007-12-17 22:43 ` David Miller
2007-12-17 23:02 ` Jan Engelhardt
[not found] ` <40bae850207de9257479a535ea5ab4e7d1cdeab5.1197432867.git.joe@perches.com>
2007-12-13 23:38 ` [PATCH net-2.6.25 2/8] include/net: Use ipv4_is_<type> Joe Perches
2007-12-16 21:43 ` David Miller
[not found] ` <63aaea4664a57e3b9a0b7454da94e72b6d462e22.1197432867.git.joe@perches.com>
2007-12-13 23:38 ` [PATCH net-2.6.25 3/8] net/core: " Joe Perches
2007-12-16 21:44 ` David Miller
[not found] ` <9ab25b88c4c02bb7ba14ff68a8e99bdf4bdef9dd.1197432867.git.joe@perches.com>
2007-12-13 23:38 ` [PATCH net-2.6.25 4/8] net/ipv4: " Joe Perches
2007-12-16 21:45 ` David Miller
[not found] ` <350bda1cfd4ac57b354451157b9009b3c8ce334e.1197432867.git.joe@perches.com>
2007-12-13 23:38 ` [PATCH net-2.6.25 5/8] net/netfilter: " Joe Perches
2007-12-13 23:38 ` Joe Perches
2007-12-16 21:46 ` David Miller
2007-12-13 23:38 ` Joe Perches
[not found] ` <1bb329b93a1f75766b7b89afdfa5ae673e9355ec.1197432867.git.joe@perches.com>
2007-12-13 23:38 ` Joe Perches [this message]
2007-12-14 19:11 ` [PATCH net-2.6.25 6/8] sctp: " Vlad Yasevich
2007-12-14 19:14 ` David Miller
2007-12-14 19:17 ` Vlad Yasevich
2007-12-16 21:47 ` David Miller
[not found] ` <aaf1cd18672fdabaa410bff09200c6a74534bdb0.1197432867.git.joe@perches.com>
2007-12-13 23:39 ` [PATCH net-2.6.25 7/8] drivers/infiniband: " Joe Perches
2007-12-13 23:39 ` [ofa-general] " Joe Perches
2007-12-16 21:47 ` David Miller
[not found] ` <885ea24008e2b1c07e6bff0344f260a0ff104a35.1197432867.git.joe@perches.com>
2007-12-13 23:39 ` [PATCH net-2.6.25 8/8] Remove unused IPV4TYPE macros Joe Perches
2007-12-13 23:39 ` Joe Perches
2007-12-16 21:48 ` David Miller
2007-12-17 4:01 ` Joe Perches
2007-12-17 4:28 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1197589141-7020-6-git-send-email-joe@perches.com \
--to=joe@perches.com \
--cc=lksctp-developers@lists.sourceforge.net \
--cc=netdev@vger.kernel.org \
--cc=sri@us.ibm.com \
--cc=vladislav.yasevich@hp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).