19#include <netinet/in.h>
92 CPPUNIT_ASSERT( !anIPA.
isIPv4() );
94 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, anIPA.
port() );
95 CPPUNIT_ASSERT( anIPA.
isIPv6() );
101 struct in_addr inval;
102 struct in_addr outval;
104 inval.s_addr = htonl(0xC0A8640C);
105 outval.s_addr = htonl(0x00000000);
111 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
112 CPPUNIT_ASSERT( anIPA.
isIPv4() );
113 CPPUNIT_ASSERT( !anIPA.
isIPv6() );
115 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, anIPA.
port() );
117 CPPUNIT_ASSERT( memcmp(&inval, &outval,
sizeof(
struct in_addr)) == 0 );
123 struct in6_addr inval;
124 struct in6_addr outval = IN6ADDR_ANY_INIT;
126 inval.s6_addr32[0] = htonl(0xC0A8640C);
127 inval.s6_addr32[1] = htonl(0xFFFFFFFF);
128 inval.s6_addr32[2] = htonl(0xFFFFFFFF);
129 inval.s6_addr32[3] = htonl(0xFFFFFFFF);
135 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
136 CPPUNIT_ASSERT( !anIPA.
isIPv4() );
137 CPPUNIT_ASSERT( anIPA.
isIPv6() );
139 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, anIPA.
port() );
141 CPPUNIT_ASSERT( memcmp( &inval, &outval,
sizeof(
struct in6_addr)) == 0 );
147 struct sockaddr_in insock;
148 struct sockaddr_in outsock;
150 memset(&insock, 0,
sizeof(
struct sockaddr_in));
151 memset(&outsock, 0,
sizeof(
struct sockaddr_in));
153 insock.sin_family = AF_INET;
154 insock.sin_port = htons(80);
155 insock.sin_addr.s_addr = htonl(0xC0A8640C);
156#if HAVE_SIN_LEN_IN_SAI
157 insock.sin_len =
sizeof(
struct sockaddr_in);
164 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
165 CPPUNIT_ASSERT( anIPA.
isIPv4() );
166 CPPUNIT_ASSERT( !anIPA.
isIPv6() );
168 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 80, anIPA.
port() );
170 CPPUNIT_ASSERT( memcmp( &insock, &outsock,
sizeof(
struct sockaddr_in)) == 0 );
176 struct sockaddr_in6 insock;
177 struct sockaddr_in6 outsock;
179 memset(&insock, 0,
sizeof(
struct sockaddr_in6));
180 memset(&outsock, 0,
sizeof(
struct sockaddr_in6));
182 insock.sin6_family = AF_INET6;
183 insock.sin6_port = htons(80);
184 insock.sin6_addr.s6_addr32[0] = htonl(0xFFFFFFFF);
185 insock.sin6_addr.s6_addr32[1] = htonl(0x00000000);
186 insock.sin6_addr.s6_addr32[2] = htonl(0x0000FFFF);
187 insock.sin6_addr.s6_addr32[3] = htonl(0xC0A8640C);
188#if HAVE_SIN6_LEN_IN_SAI
189 insock.sin6_len =
sizeof(
struct sockaddr_in6);
192 Ip::Address anIPA((
const struct sockaddr_in6)insock);
196 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
197 CPPUNIT_ASSERT( !anIPA.
isIPv4() );
198 CPPUNIT_ASSERT( anIPA.
isIPv6() );
200 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 80, anIPA.
port() );
202 CPPUNIT_ASSERT( memcmp( &insock, &outsock,
sizeof(
struct sockaddr_in6)) == 0 );
208 struct sockaddr_in insock;
209 struct sockaddr_in outsock;
211 memset(&insock, 0,
sizeof(
struct sockaddr_in));
212 memset(&outsock, 0,
sizeof(
struct sockaddr_in));
214 insock.sin_family = AF_INET;
215 insock.sin_port = htons(80);
216 insock.sin_addr.s_addr = htonl(0xC0A8640C);
217#if HAVE_SIN_LEN_IN_SAI
218 insock.sin_len =
sizeof(
struct sockaddr_in);
226 CPPUNIT_ASSERT( !outIPA.
isNoAddr() );
227 CPPUNIT_ASSERT( outIPA.
isIPv4() );
228 CPPUNIT_ASSERT( !outIPA.
isIPv6() );
230 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 80, outIPA.
port() );
232 CPPUNIT_ASSERT( memcmp( &insock, &outsock,
sizeof(
struct sockaddr_in)) == 0 );
238 struct hostent *hp =
nullptr;
239 struct in_addr outval;
240 struct in_addr expectval;
242 expectval.s_addr = htonl(0xC0A8640C);
244 hp = gethostbyname(
"192.168.100.12");
245 CPPUNIT_ASSERT( hp !=
nullptr );
251 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
252 CPPUNIT_ASSERT( anIPA.
isIPv4() );
253 CPPUNIT_ASSERT( !anIPA.
isIPv6() );
255 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, anIPA.
port() );
257 CPPUNIT_ASSERT( memcmp( &expectval, &outval,
sizeof(
struct in_addr)) == 0 );
263 struct in_addr outval;
264 struct in_addr expectval;
266 expectval.s_addr = htonl(0xC0A8640C);
272 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
273 CPPUNIT_ASSERT( anIPA.
isIPv4() );
274 CPPUNIT_ASSERT( !anIPA.
isIPv6() );
275 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, anIPA.
port() );
278 CPPUNIT_ASSERT( memcmp( &expectval, &outval,
sizeof(
struct in_addr)) == 0 );
280 struct in6_addr expectv6;
281 struct in6_addr outval6;
283 expectv6.s6_addr32[0] = htonl(0x20000800);
284 expectv6.s6_addr32[1] = htonl(0x00000000);
285 expectv6.s6_addr32[2] = htonl(0x00000000);
286 expectv6.s6_addr32[3] = htonl(0x00000045);
296 CPPUNIT_ASSERT( !bnIPA.
isNoAddr() );
297 CPPUNIT_ASSERT( !bnIPA.
isIPv4() );
298 CPPUNIT_ASSERT( bnIPA.
isIPv6() );
300 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, bnIPA.
port() );
302 CPPUNIT_ASSERT( memcmp( &expectv6, &outval6,
sizeof(
struct in6_addr)) == 0 );
307 expectv6.s6_addr32[0] = htonl(0xFFFFFFFF);
308 expectv6.s6_addr32[1] = htonl(0xFFF00000);
309 expectv6.s6_addr32[2] = htonl(0x00000000);
310 expectv6.s6_addr32[3] = htonl(0x00000000);
314 CPPUNIT_ASSERT( !cnIPA.
isNoAddr() );
315 CPPUNIT_ASSERT( !cnIPA.
isIPv4() );
316 CPPUNIT_ASSERT( cnIPA.
isIPv6() );
318 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, cnIPA.
port() );
320 CPPUNIT_ASSERT( memcmp( &expectv6, &outval6,
sizeof(
struct in6_addr)) == 0 );
327 struct in_addr inval;
329 inval.s_addr = htonl(0xC0A8640C);
335 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
336 CPPUNIT_ASSERT( anIPA.
isIPv4() );
337 CPPUNIT_ASSERT( !anIPA.
isIPv6() );
339 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, anIPA.
port() );
345 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
346 CPPUNIT_ASSERT( !anIPA.
isIPv4() );
347 CPPUNIT_ASSERT( anIPA.
isIPv6() );
349 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, anIPA.
port() );
357 struct in_addr valLow;
358 struct in_addr valHigh;
360 valLow.s_addr = htonl(0xC0A8640C);
361 valHigh.s_addr = htonl(0xC0A8640F);
367 CPPUNIT_ASSERT( ( lhsIPA == rhsIPA ) );
368 CPPUNIT_ASSERT( !( lhsIPA != rhsIPA ) );
369 CPPUNIT_ASSERT( ( lhsIPA >= rhsIPA ) );
370 CPPUNIT_ASSERT( !( lhsIPA > rhsIPA ) );
371 CPPUNIT_ASSERT( ( lhsIPA <= rhsIPA ) );
372 CPPUNIT_ASSERT( !( lhsIPA < rhsIPA ) );
378 CPPUNIT_ASSERT( ( lhsIPA == rhsIPA ) );
379 CPPUNIT_ASSERT( !( lhsIPA != rhsIPA ) );
380 CPPUNIT_ASSERT( ( lhsIPA >= rhsIPA ) );
381 CPPUNIT_ASSERT( !( lhsIPA > rhsIPA ) );
382 CPPUNIT_ASSERT( ( lhsIPA <= rhsIPA ) );
383 CPPUNIT_ASSERT( !( lhsIPA < rhsIPA ) );
389 CPPUNIT_ASSERT( ( lhsIPA == rhsIPA ) );
390 CPPUNIT_ASSERT( !( lhsIPA != rhsIPA ) );
391 CPPUNIT_ASSERT( ( lhsIPA >= rhsIPA ) );
392 CPPUNIT_ASSERT( !( lhsIPA > rhsIPA ) );
393 CPPUNIT_ASSERT( ( lhsIPA <= rhsIPA ) );
394 CPPUNIT_ASSERT( !( lhsIPA < rhsIPA ) );
400 CPPUNIT_ASSERT( !( lhsIPA == rhsIPA ) );
401 CPPUNIT_ASSERT( ( lhsIPA != rhsIPA ) );
402 CPPUNIT_ASSERT( !( lhsIPA >= rhsIPA ) );
403 CPPUNIT_ASSERT( !( lhsIPA > rhsIPA ) );
404 CPPUNIT_ASSERT( ( lhsIPA <= rhsIPA ) );
405 CPPUNIT_ASSERT( ( lhsIPA < rhsIPA ) );
411 CPPUNIT_ASSERT( !( lhsIPA == rhsIPA ) );
412 CPPUNIT_ASSERT( ( lhsIPA != rhsIPA ) );
413 CPPUNIT_ASSERT( !( lhsIPA >= rhsIPA ) );
414 CPPUNIT_ASSERT( !( lhsIPA > rhsIPA ) );
415 CPPUNIT_ASSERT( ( lhsIPA <= rhsIPA ) );
416 CPPUNIT_ASSERT( ( lhsIPA < rhsIPA ) );
422 CPPUNIT_ASSERT( !( lhsIPA == rhsIPA ) );
423 CPPUNIT_ASSERT( ( lhsIPA != rhsIPA ) );
424 CPPUNIT_ASSERT( !( lhsIPA >= rhsIPA ) );
425 CPPUNIT_ASSERT( !( lhsIPA > rhsIPA ) );
426 CPPUNIT_ASSERT( ( lhsIPA <= rhsIPA ) );
427 CPPUNIT_ASSERT( ( lhsIPA < rhsIPA ) );
433 CPPUNIT_ASSERT( !( lhsIPA == rhsIPA ) );
434 CPPUNIT_ASSERT( ( lhsIPA != rhsIPA ) );
435 CPPUNIT_ASSERT( ( lhsIPA >= rhsIPA ) );
436 CPPUNIT_ASSERT( ( lhsIPA > rhsIPA ) );
437 CPPUNIT_ASSERT( !( lhsIPA <= rhsIPA ) );
438 CPPUNIT_ASSERT( !( lhsIPA < rhsIPA ) );
444 CPPUNIT_ASSERT( !( lhsIPA == rhsIPA ) );
445 CPPUNIT_ASSERT( ( lhsIPA != rhsIPA ) );
446 CPPUNIT_ASSERT( ( lhsIPA >= rhsIPA ) );
447 CPPUNIT_ASSERT( ( lhsIPA > rhsIPA ) );
448 CPPUNIT_ASSERT( !( lhsIPA <= rhsIPA ) );
449 CPPUNIT_ASSERT( !( lhsIPA < rhsIPA ) );
455 CPPUNIT_ASSERT( !( lhsIPA == rhsIPA ) );
456 CPPUNIT_ASSERT( ( lhsIPA != rhsIPA ) );
457 CPPUNIT_ASSERT( ( lhsIPA >= rhsIPA ) );
458 CPPUNIT_ASSERT( ( lhsIPA > rhsIPA ) );
459 CPPUNIT_ASSERT( !( lhsIPA <= rhsIPA ) );
460 CPPUNIT_ASSERT( !( lhsIPA < rhsIPA ) );
467 struct in_addr inval;
476 inval.s_addr = htonl(0xC0A8640C);
480 CPPUNIT_ASSERT( memcmp(
"192.168.100.12",anIPA.
toStr(buf,
MAX_IPSTRLEN), 14) == 0 );
485 CPPUNIT_ASSERT( memcmp(
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",anIPA.
toStr(buf,
MAX_IPSTRLEN), 39) == 0 );
493 struct in_addr inval;
495 inval.s_addr = htonl(0xC0A8640C);
501 CPPUNIT_ASSERT( memcmp(
"192.168.100.12", buf, 14) == 0 );
504 struct in6_addr ip6val;
506 ip6val.s6_addr32[0] = htonl(0xC0A8640C);
507 ip6val.s6_addr32[1] = htonl(0xFFFFFFFF);
508 ip6val.s6_addr32[2] = htonl(0xFFFFFFFF);
509 ip6val.s6_addr32[3] = htonl(0xFFFFFFFF);
514 CPPUNIT_ASSERT( memcmp(
"[c0a8:640c:ffff:ffff:ffff:ffff:ffff:ffff]", buf, 41) == 0 );
520 struct sockaddr_in sock;
521 sock.sin_addr.s_addr = htonl(0xC0A8640C);
522 sock.sin_port = htons(80);
523 sock.sin_family = AF_INET;
524#if HAVE_SIN_LEN_IN_SAI
525 sock.sin_len =
sizeof(
struct sockaddr_in);
533 CPPUNIT_ASSERT( memcmp(
"192.168.100.12:80", buf, 17) == 0 );
536 struct sockaddr_in6 ip6val;
538 ip6val.sin6_addr.s6_addr32[0] = htonl(0xC0A8640C);
539 ip6val.sin6_addr.s6_addr32[1] = htonl(0xFFFFFFFF);
540 ip6val.sin6_addr.s6_addr32[2] = htonl(0xFFFFFFFF);
541 ip6val.sin6_addr.s6_addr32[3] = htonl(0xFFFFFFFF);
542 ip6val.sin6_port = htons(80);
543 ip6val.sin6_family = AF_INET6;
544#if HAVE_SIN6_LEN_IN_SAI
545 ip6val.sin6_len =
sizeof(
struct sockaddr_in6);
551 CPPUNIT_ASSERT( memcmp(
"[c0a8:640c:ffff:ffff:ffff:ffff:ffff:ffff]:80", buf, 44) == 0 );
559 struct in_addr ipv4val;
560 ipv4val.s_addr = htonl(0xC0A8640C);
566 CPPUNIT_ASSERT( memcmp(
"12.100.168.192.in-addr.arpa.",buf, 28) == 0 );
569 CPPUNIT_ASSERT( memcmp(
"12.100.168.192.in-addr.arpa.",buf, 28) == 0 );
572 CPPUNIT_ASSERT( memcmp(
"",buf, 1) == 0 );
574 struct in6_addr ip6val;
576 ip6val.s6_addr32[0] = htonl(0xC0A8640C);
577 ip6val.s6_addr32[1] = htonl(0xFFFFFFFF);
578 ip6val.s6_addr32[2] = htonl(0xFFFFFFFF);
579 ip6val.s6_addr32[3] = htonl(0xFFFFFFFF);
585 CPPUNIT_ASSERT( memcmp(
"f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.c.0.4.6.8.a.0.c.ip6.arpa.",buf,73) == 0 );
597 CPPUNIT_ASSERT_EQUAL( 0,anIPA.
cidr() );
600 CPPUNIT_ASSERT_EQUAL( 128, anIPA.
cidr() );
604 CPPUNIT_ASSERT( !anIPA.
applyMask(129,AF_INET6) );
605 CPPUNIT_ASSERT( !anIPA.
applyMask(33,AF_INET) );
608 CPPUNIT_ASSERT( anIPA.
applyMask(31,AF_INET) );
609 CPPUNIT_ASSERT_EQUAL( 127, anIPA.
cidr() );
612 CPPUNIT_ASSERT( anIPA.
applyMask(127,AF_INET6) );
613 CPPUNIT_ASSERT_EQUAL( 127, anIPA.
cidr() );
617 CPPUNIT_ASSERT_EQUAL( 80, anIPA.
cidr() );
621 CPPUNIT_ASSERT( memcmp(
"ffff:ffff:ffff:ffff:ffff::", buf, 26) == 0 );
625 maskIPA =
"255.255.240.0";
626 CPPUNIT_ASSERT_EQUAL( 20, maskIPA.
cidr() );
628 CPPUNIT_ASSERT_EQUAL( 20, anIPA.
cidr() );
631 struct in_addr btest;
632 CPPUNIT_ASSERT( anIPA.
isIPv4() );
633 CPPUNIT_ASSERT( !anIPA.
isIPv6() );
635 CPPUNIT_ASSERT_EQUAL( (uint32_t)htonl(0xFFFFF000), btest.s_addr );
638 CPPUNIT_ASSERT( memcmp(
"255.255.240.0",anIPA.
toStr(buf,
MAX_IPSTRLEN), 13) == 0 );
645 maskIPA =
"ffff:ffff:fff0::";
647 CPPUNIT_ASSERT( !maskIPA.
isNoAddr() );
649 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
650 CPPUNIT_ASSERT_EQUAL( 44, anIPA.
cidr() );
656 maskIPA =
"::ffff:ffff:f000";
658 CPPUNIT_ASSERT( !maskIPA.
isNoAddr() );
659 CPPUNIT_ASSERT( maskIPA.
isIPv4() );
660 CPPUNIT_ASSERT( !maskIPA.
isIPv6() );
663 CPPUNIT_ASSERT( !maskIPA.
isNoAddr() );
664 CPPUNIT_ASSERT( maskIPA.
isIPv4() );
665 CPPUNIT_ASSERT( !maskIPA.
isIPv6() );
666 CPPUNIT_ASSERT_EQUAL( 20, anIPA.
cidr() );
672 struct addrinfo *expect;
673 struct addrinfo *ipval =
nullptr;
674 struct addrinfo hints;
676 memset(&hints, 0,
sizeof(
struct addrinfo));
678 hints.ai_flags = AI_NUMERICHOST;
683 CPPUNIT_ASSERT( getaddrinfo(
"127.0.0.1",
nullptr, &hints, &expect ) == 0 );
689 CPPUNIT_ASSERT_EQUAL( expect->ai_flags, ipval->ai_flags );
690 CPPUNIT_ASSERT_EQUAL( expect->ai_family, ipval->ai_family );
692 CPPUNIT_ASSERT_EQUAL( expect->ai_addrlen, ipval->ai_addrlen );
695 CPPUNIT_ASSERT_EQUAL( ((
struct sockaddr_storage*)expect->ai_addr)->ss_len,
696 ((
struct sockaddr_storage*)ipval->ai_addr)->ss_len );
697 CPPUNIT_ASSERT_EQUAL( (
socklen_t)((
struct sockaddr_storage*)ipval->ai_addr)->ss_len, ipval->ai_addrlen );
699#if HAVE_SIN6_LEN_IN_SAI
700 CPPUNIT_ASSERT_EQUAL( ((
struct sockaddr_in6*)expect->ai_addr)->sin6_len,
701 ((
struct sockaddr_in6*)ipval->ai_addr)->sin6_len );
702 CPPUNIT_ASSERT_EQUAL( (
socklen_t)((
struct sockaddr_in6*)ipval->ai_addr)->sin6_len, ipval->ai_addrlen );
704#if HAVE_SIN_LEN_IN_SAI
705 CPPUNIT_ASSERT_EQUAL( ((
struct sockaddr_in*)expect->ai_addr)->sin_len,
706 ((
struct sockaddr_in*)ipval->ai_addr)->sin_len );
707 CPPUNIT_ASSERT_EQUAL( (
socklen_t)((
struct sockaddr_in*)ipval->ai_addr)->sin_len, ipval->ai_addrlen );
710 if (expect->ai_addrlen ==
sizeof(
struct sockaddr_in)) {
712 CPPUNIT_ASSERT_EQUAL( ((
struct sockaddr_in*)expect->ai_addr)->sin_family,
713 ((
struct sockaddr_in*)ipval->ai_addr)->sin_family );
715 CPPUNIT_ASSERT_EQUAL( ((
struct sockaddr_in*)expect->ai_addr)->sin_port,
716 ((
struct sockaddr_in*)ipval->ai_addr)->sin_port );
718 if (expect->ai_addrlen ==
sizeof(
struct sockaddr_in6)) {
720 CPPUNIT_ASSERT_EQUAL( ((
struct sockaddr_in6*)expect->ai_addr)->sin6_family,
721 ((
struct sockaddr_in6*)ipval->ai_addr)->sin6_family );
723 CPPUNIT_ASSERT_EQUAL( ((
struct sockaddr_in6*)expect->ai_addr)->sin6_port,
724 ((
struct sockaddr_in6*)ipval->ai_addr)->sin6_port );
727 CPPUNIT_ASSERT( memcmp( expect->ai_addr, ipval->ai_addr, expect->ai_addrlen ) == 0 );
729 freeaddrinfo(expect);
744 struct in_addr outval;
745 struct in_addr expectval;
747 expectval.s_addr = htonl(0xC0A8640C);
753 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
754 CPPUNIT_ASSERT( anIPA.
isIPv4() );
755 CPPUNIT_ASSERT( !anIPA.
isIPv6() );
756 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, anIPA.
port() );
759 CPPUNIT_ASSERT( memcmp( &expectval, &outval,
sizeof(
struct in_addr)) == 0 );
766 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
767 CPPUNIT_ASSERT( anIPA.
isIPv4() );
768 CPPUNIT_ASSERT( !anIPA.
isIPv6() );
769 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, anIPA.
port() );
772 CPPUNIT_ASSERT( memcmp( &expectval, &outval,
sizeof(
struct in_addr)) == 0 );
779 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
780 CPPUNIT_ASSERT( anIPA.
isIPv4() );
781 CPPUNIT_ASSERT( !anIPA.
isIPv6() );
782 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, anIPA.
port() );
785 CPPUNIT_ASSERT( memcmp( &expectval, &outval,
sizeof(
struct in_addr)) == 0 );
792 CPPUNIT_ASSERT( !anIPA.
isNoAddr() );
793 CPPUNIT_ASSERT( anIPA.
isIPv4() );
794 CPPUNIT_ASSERT( !anIPA.
isIPv6() );
795 CPPUNIT_ASSERT_EQUAL( (
unsigned short) 0, anIPA.
port() );
798 CPPUNIT_ASSERT( memcmp( &expectval, &outval,
sizeof(
struct in_addr)) == 0 );
char * toStr(char *buf, const unsigned int blen, int force=AF_UNSPEC) const
void setEmpty()
Fast reset of the stored content to what would be after default constructor.
void getSockAddr(struct sockaddr_storage &addr, const int family) const
unsigned int toHostStr(char *buf, const unsigned int len) const
static void FreeAddr(struct addrinfo *&ai)
void getAddrInfo(struct addrinfo *&ai, int force=AF_UNSPEC) const
int matchIPAddr(const Address &rhs) const
bool getReverseString(char buf[MAX_IPSTRLEN], int show_type=AF_UNSPEC) const
char * toUrl(char *buf, unsigned int len) const
bool getInAddr(struct in_addr &) const
int applyMask(const Address &mask)
void setAnyAddr()
NOTE: Does NOT clear the Port stored. Only the Address and Type.
unsigned short port() const
CPPUNIT_TEST(testBugNullingDisplay)
CPPUNIT_TEST(testtoUrl_fromSockAddr)
CPPUNIT_TEST(testtoUrl_fromInAddr)
CPPUNIT_TEST(testInAddrConstructor)
void testBugNullingDisplay()
CPPUNIT_TEST(testsetEmpty)
void testSockAddrConstructor()
void testSockAddr6Constructor()
CPPUNIT_TEST(testCopyConstructor)
CPPUNIT_TEST_SUITE(TestIpAddress)
CPPUNIT_TEST(testSockAddr6Constructor)
CPPUNIT_TEST(testAddrInfo)
CPPUNIT_TEST(testSockAddrConstructor)
void testtoUrl_fromSockAddr()
void testInAddr6Constructor()
void testInAddrConstructor()
CPPUNIT_TEST(testStringConstructor)
void testgetReverseString()
void testtoUrl_fromInAddr()
CPPUNIT_TEST(testDefaults)
void testCopyConstructor()
void testStringConstructor()
void testHostentConstructor()
CPPUNIT_TEST(testHostentConstructor)
CPPUNIT_TEST(testInAddr6Constructor)
CPPUNIT_TEST(testBooleans)
CPPUNIT_TEST(testMasking)
CPPUNIT_TEST(testgetReverseString)
implements test program's main() function while enabling customization
int run(int argc, char *argv[])
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
int main(int argc, char *argv[])
CPPUNIT_TEST_SUITE_REGISTRATION(TestIpAddress)