Changeset 3044 for pjproject/trunk/pjlib/src/pjlib-test/sock.c
- Timestamp:
- Jan 4, 2010 4:54:50 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pjlib-test/sock.c
r3016 r3044 72 72 static char bigdata[BIG_DATA_LEN]; 73 73 static char bigbuffer[BIG_DATA_LEN]; 74 75 /* Macro for checking the value of "sin_len" member of sockaddr 76 * (it must always be zero). 77 */ 78 #if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 79 # define CHECK_SA_ZERO_LEN(addr, ret) \ 80 if (((pj_addr_hdr*)(addr))->sa_zero_len != 0) \ 81 return ret 82 #else 83 # define CHECK_SA_ZERO_LEN(addr, ret) 84 #endif 85 74 86 75 87 static int format_test(void) … … 285 297 } 286 298 299 /* Check "sin_len" member of parse result */ 300 CHECK_SA_ZERO_LEN(&addr, -20); 301 287 302 /* Build the correct result */ 288 303 status = pj_sockaddr_init(valid_tests[i].result_af, … … 312 327 return -50; 313 328 } 329 330 /* Check "sin_len" member of parse result */ 331 CHECK_SA_ZERO_LEN(&addr, -55); 314 332 315 333 /* Compare the result again */ … … 348 366 } 349 367 } 368 369 return 0; 370 } 371 372 static int purity_test(void) 373 { 374 PJ_LOG(3,("test", "...purity_test()")); 375 376 #if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 377 /* Check on "sin_len" member of sockaddr */ 378 { 379 const pj_str_t str_ip = {"1.1.1.1", 7}; 380 pj_sockaddr addr[16]; 381 pj_addrinfo ai[16]; 382 unsigned cnt; 383 pj_status_t rc; 384 385 /* pj_enum_ip_interface() */ 386 cnt = PJ_ARRAY_SIZE(addr); 387 rc = pj_enum_ip_interface(pj_AF_UNSPEC(), &cnt, addr); 388 if (rc == PJ_SUCCESS) { 389 while (cnt--) 390 CHECK_SA_ZERO_LEN(&addr[cnt], -10); 391 } 392 393 /* pj_gethostip() on IPv4 */ 394 rc = pj_gethostip(pj_AF_INET(), &addr[0]); 395 if (rc == PJ_SUCCESS) 396 CHECK_SA_ZERO_LEN(&addr[0], -20); 397 398 /* pj_gethostip() on IPv6 */ 399 rc = pj_gethostip(pj_AF_INET6(), &addr[0]); 400 if (rc == PJ_SUCCESS) 401 CHECK_SA_ZERO_LEN(&addr[0], -30); 402 403 /* pj_getdefaultipinterface() on IPv4 */ 404 rc = pj_getdefaultipinterface(pj_AF_INET(), &addr[0]); 405 if (rc == PJ_SUCCESS) 406 CHECK_SA_ZERO_LEN(&addr[0], -40); 407 408 /* pj_getdefaultipinterface() on IPv6 */ 409 rc = pj_getdefaultipinterface(pj_AF_INET6(), &addr[0]); 410 if (rc == PJ_SUCCESS) 411 CHECK_SA_ZERO_LEN(&addr[0], -50); 412 413 /* pj_getaddrinfo() on a host name */ 414 cnt = PJ_ARRAY_SIZE(ai); 415 rc = pj_getaddrinfo(pj_AF_UNSPEC(), pj_gethostname(), &cnt, ai); 416 if (rc == PJ_SUCCESS) { 417 while (cnt--) 418 CHECK_SA_ZERO_LEN(&ai[cnt].ai_addr, -60); 419 } 420 421 /* pj_getaddrinfo() on an IP address */ 422 cnt = PJ_ARRAY_SIZE(ai); 423 rc = pj_getaddrinfo(pj_AF_UNSPEC(), &str_ip, &cnt, ai); 424 if (rc == PJ_SUCCESS) { 425 pj_assert(cnt == 1); 426 CHECK_SA_ZERO_LEN(&ai[0].ai_addr, -70); 427 } 428 } 429 #endif 350 430 351 431 return 0; … … 761 841 return rc; 762 842 843 rc = purity_test(); 844 if (rc != 0) 845 return rc; 846 763 847 rc = gethostbyname_test(); 764 848 if (rc != 0)
Note: See TracChangeset
for help on using the changeset viewer.