comparison tests/testmesg.c @ 1414:f6f12521c2aa

Fix strict-aliasing warnings with gcc 4.8 Rewrite IN6_ADDR_V4MAP() to not rely upon aliasing rules. Add test for IN6_ADDR_V4MAP() and IN6_ADDR_V4UNMAP(). Rewrite MD5Final() to not rely upon aliasing rules. (Not tested)
author Luke Mewburn <luke@mewburn.net>
date Tue, 18 Feb 2020 19:01:49 +1100
parents 3f1e79e1273e
children 67c263056d78
comparison
equal deleted inserted replaced
1413:1979715b744f 1414:f6f12521c2aa
1446 CHECK( -1099511627777LL, avpdata->avp_value->f64 ); 1446 CHECK( -1099511627777LL, avpdata->avp_value->f64 );
1447 1447
1448 CHECK( 0, fd_msg_free( msg ) ); 1448 CHECK( 0, fd_msg_free( msg ) );
1449 } 1449 }
1450 } 1450 }
1451
1452 /* Check IPv4 -> IPv6 and IPv6->IPv4 mapping */
1453 {
1454 struct in_addr i4;
1455 memset(&i4, 0xff, sizeof(i4));
1456 CHECK( 1, inet_pton( AF_INET, TEST_IP4, &i4 ) );
1457
1458 #define TEST_IP6MAP "::ffff:" TEST_IP4
1459
1460 struct in6_addr i6;
1461 memset(&i6, 0xff, sizeof(i6));
1462 IN6_ADDR_V4MAP(&i6.s6_addr, i4.s_addr);
1463 char buf6[INET6_ADDRSTRLEN];
1464 CHECK( 0, (inet_ntop( AF_INET6, &i6, buf6, sizeof(buf6) ) == NULL) ? errno : 0 );
1465 LOG_D("buf6='%s'", buf6);
1466 CHECK( 0, strcasecmp( buf6, TEST_IP6MAP ) );
1467
1468 struct in_addr o4;
1469 o4.s_addr = IN6_ADDR_V4UNMAP(&i6);
1470 char buf4[INET_ADDRSTRLEN];
1471 CHECK( 0, (inet_ntop( AF_INET, &o4.s_addr, buf4, sizeof(buf4) ) == NULL) ? errno : 0 );
1472 CHECK( 0, strcmp( buf4, TEST_IP4 ) );
1473 }
1451 1474
1452 /* That's all for the tests yet */ 1475 /* That's all for the tests yet */
1453 PASSTEST(); 1476 PASSTEST();
1454 } 1477 }
1455 1478
"Welcome to our mercurial repository"