diff options
author | Joe Perches <joe@perches.com> | 2007-12-16 16:46:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:58:17 -0500 |
commit | b5cb2bbc4c6cb489941be881e8adfe136ee45b8e (patch) | |
tree | f7a1280cfb46609910d8e6189bc96edc5375b645 | |
parent | 37ef8dd7f3f2f228336e3779e7cec762d90e1f00 (diff) |
[IPV4] sctp: Use ipv4_is_<type>
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/sctp/constants.h | 36 | ||||
-rw-r--r-- | 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 05f22a6afbcd..fefcba67bd1e 100644 --- a/include/net/sctp/constants.h +++ b/include/net/sctp/constants.h | |||
@@ -365,36 +365,12 @@ typedef enum { | |||
365 | * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP | 365 | * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP |
366 | * addresses. | 366 | * addresses. |
367 | */ | 367 | */ |
368 | #define IS_IPV4_UNUSABLE_ADDRESS(a) \ | 368 | #define IS_IPV4_UNUSABLE_ADDRESS(a) \ |
369 | ((htonl(INADDR_BROADCAST) == *a) || \ | 369 | ((htonl(INADDR_BROADCAST) == a) || \ |
370 | (MULTICAST(*a)) || \ | 370 | ipv4_is_multicast(a) || \ |
371 | (((unsigned char *)(a))[0] == 0) || \ | 371 | ipv4_is_zeronet(a) || \ |
372 | ((((unsigned char *)(a))[0] == 198) && \ | 372 | ipv4_is_test_198(a) || \ |
373 | (((unsigned char *)(a))[1] == 18) && \ | 373 | ipv4_is_anycast_6to4(a)) |
374 | (((unsigned char *)(a))[2] == 0)) || \ | ||
375 | ((((unsigned char *)(a))[0] == 192) && \ | ||
376 | (((unsigned char *)(a))[1] == 88) && \ | ||
377 | (((unsigned char *)(a))[2] == 99))) | ||
378 | |||
379 | /* IPv4 Link-local addresses: 169.254.0.0/16. */ | ||
380 | #define IS_IPV4_LINK_ADDRESS(a) \ | ||
381 | ((((unsigned char *)(a))[0] == 169) && \ | ||
382 | (((unsigned char *)(a))[1] == 254)) | ||
383 | |||
384 | /* RFC 1918 "Address Allocation for Private Internets" defines the IPv4 | ||
385 | * private address space as the following: | ||
386 | * | ||
387 | * 10.0.0.0 - 10.255.255.255 (10/8 prefix) | ||
388 | * 172.16.0.0.0 - 172.31.255.255 (172.16/12 prefix) | ||
389 | * 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) | ||
390 | */ | ||
391 | #define IS_IPV4_PRIVATE_ADDRESS(a) \ | ||
392 | ((((unsigned char *)(a))[0] == 10) || \ | ||
393 | ((((unsigned char *)(a))[0] == 172) && \ | ||
394 | (((unsigned char *)(a))[1] >= 16) && \ | ||
395 | (((unsigned char *)(a))[1] < 32)) || \ | ||
396 | ((((unsigned char *)(a))[0] == 192) && \ | ||
397 | (((unsigned char *)(a))[1] == 168))) | ||
398 | 374 | ||
399 | /* Flags used for the bind address copy functions. */ | 375 | /* Flags used for the bind address copy functions. */ |
400 | #define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by | 376 | #define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index d50f610d1b02..dc22d7108494 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, | |||
359 | const struct sk_buff *skb) | 359 | const struct sk_buff *skb) |
360 | { | 360 | { |
361 | /* Is this a non-unicast address or a unusable SCTP address? */ | 361 | /* Is this a non-unicast address or a unusable SCTP address? */ |
362 | if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr)) | 362 | if (IS_IPV4_UNUSABLE_ADDRESS(addr->v4.sin_addr.s_addr)) |
363 | return 0; | 363 | return 0; |
364 | 364 | ||
365 | /* Is this a broadcast address? */ | 365 | /* Is this a broadcast address? */ |
@@ -408,13 +408,15 @@ static sctp_scope_t sctp_v4_scope(union sctp_addr *addr) | |||
408 | */ | 408 | */ |
409 | 409 | ||
410 | /* Check for unusable SCTP addresses. */ | 410 | /* Check for unusable SCTP addresses. */ |
411 | if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr)) { | 411 | if (IS_IPV4_UNUSABLE_ADDRESS(addr->v4.sin_addr.s_addr)) { |
412 | retval = SCTP_SCOPE_UNUSABLE; | 412 | retval = SCTP_SCOPE_UNUSABLE; |
413 | } else if (LOOPBACK(addr->v4.sin_addr.s_addr)) { | 413 | } else if (ipv4_is_loopback(addr->v4.sin_addr.s_addr)) { |
414 | retval = SCTP_SCOPE_LOOPBACK; | 414 | retval = SCTP_SCOPE_LOOPBACK; |
415 | } else if (IS_IPV4_LINK_ADDRESS(&addr->v4.sin_addr.s_addr)) { | 415 | } else if (ipv4_is_linklocal_169(addr->v4.sin_addr.s_addr)) { |
416 | retval = SCTP_SCOPE_LINK; | 416 | retval = SCTP_SCOPE_LINK; |
417 | } else if (IS_IPV4_PRIVATE_ADDRESS(&addr->v4.sin_addr.s_addr)) { | 417 | } else if (ipv4_is_private_10(addr->v4.sin_addr.s_addr) || |
418 | ipv4_is_private_172(addr->v4.sin_addr.s_addr) || | ||
419 | ipv4_is_private_192(addr->v4.sin_addr.s_addr)) { | ||
418 | retval = SCTP_SCOPE_PRIVATE; | 420 | retval = SCTP_SCOPE_PRIVATE; |
419 | } else { | 421 | } else { |
420 | retval = SCTP_SCOPE_GLOBAL; | 422 | retval = SCTP_SCOPE_GLOBAL; |