Mercurial > hg > freeDiameter
changeset 134:6b2989c066a6
Fixed loopback test for correct network order
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Tue, 15 Dec 2009 18:15:41 +0900 |
parents | 5a21124536b4 |
children | bbb8ddba4c85 |
files | freeDiameter/endpoints.c include/freeDiameter/libfreeDiameter.h |
diffstat | 2 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/freeDiameter/endpoints.c Thu Dec 10 18:51:47 2009 +0900 +++ b/freeDiameter/endpoints.c Tue Dec 15 18:15:41 2009 +0900 @@ -55,10 +55,10 @@ ptr.sa = sa; switch (sa->sa_family) { case AF_INET: - if (ptr.sin->sin_addr.s_addr == INADDR_LOOPBACK) + if (IN_IS_ADDR_LOOPBACK(&ptr.sin->sin_addr)) return 0; case AF_INET6: - if (!memcmp(&ptr.sin6->sin6_addr, &in6addr_loopback, sizeof(struct in6_addr))) + if (IN6_IS_ADDR_LOOPBACK(&ptr.sin6->sin6_addr)) return 0; }
--- a/include/freeDiameter/libfreeDiameter.h Thu Dec 10 18:51:47 2009 +0900 +++ b/include/freeDiameter/libfreeDiameter.h Tue Dec 15 18:15:41 2009 +0900 @@ -394,6 +394,13 @@ #define INADDR_LOOPBACK inet_addr("127.0.0.1") #endif /* INADDR_LOOPBACK */ +/* An IP equivalent to IN6_IS_ADDR_LOOPBACK */ +#ifndef IN_IS_ADDR_LOOPBACK +#define IN_IS_ADDR_LOOPBACK(a) \ + ((((long int) (a)->s_addr) & ntohl(0xff000000)) == ntohl(0x7f000000)) +#endif /* IN_IS_ADDR_LOOPBACK */ + + /* create a V4MAPPED address */ #define IN6_ADDR_V4MAP( a6, a4 ) { \ ((uint32_t *)(a6))[0] = 0; \