sockaddrtest.c (ntp-4.2.8p14) | : | sockaddrtest.c (ntp-4.2.8p15) | ||
---|---|---|---|---|
skipping to change at line 28 | skipping to change at line 28 | |||
IsEqual(const sockaddr_u expected, const sockaddr_u actual) { | IsEqual(const sockaddr_u expected, const sockaddr_u actual) { | |||
struct in_addr in; | struct in_addr in; | |||
struct in6_addr in6; | struct in6_addr in6; | |||
if (expected.sa.sa_family != actual.sa.sa_family) { | if (expected.sa.sa_family != actual.sa.sa_family) { | |||
printf("Expected sa_family: %d but got: %d", expected.sa.sa_famil y, actual.sa.sa_family); | printf("Expected sa_family: %d but got: %d", expected.sa.sa_famil y, actual.sa.sa_family); | |||
return FALSE; | return FALSE; | |||
} | } | |||
if (actual.sa.sa_family == AF_INET) { // IPv4 | if (actual.sa.sa_family == AF_INET) { // IPv4 | |||
if (expected.sa4.sin_port == actual.sa4.sin_port && | if ( expected.sa4.sin_port == actual.sa4.sin_port | |||
memcmp(&expected.sa4.sin_addr, &actual.sa4.sin_addr, | && memcmp(&expected.sa4.sin_addr, &actual.sa4.sin_addr, | |||
sizeof( in )) == 0) { | sizeof( in )) == 0) { | |||
return TRUE; | return TRUE; | |||
} else { | } else { | |||
char buf[4][32]; | char buf[4][32]; | |||
strlcpy(buf[0], inet_ntoa(expected.sa4.sin_addr), sizeof( buf[0])); | strlcpy(buf[0], inet_ntoa(expected.sa4.sin_addr), sizeof( buf[0])); | |||
strlcpy(buf[1], socktoa(&expected) , sizeof( buf[1])); | strlcpy(buf[1], socktoa(&expected) , sizeof( buf[1])); | |||
strlcpy(buf[2], inet_ntoa(actual.sa4.sin_addr) , sizeof( buf[2])); | strlcpy(buf[2], inet_ntoa(actual.sa4.sin_addr) , sizeof( buf[2])); | |||
strlcpy(buf[3], socktoa(&actual) , sizeof( buf[3])); | strlcpy(buf[3], socktoa(&actual) , sizeof( buf[3])); | |||
printf("IPv4 comparision failed, expected: %s(%s) but was : %s(%s)", | printf("IPv4 comparision failed, expected: %s(%s) but was : %s(%s)", | |||
buf[0], buf[1], buf[2], buf[3]); | buf[0], buf[1], buf[2], buf[3]); | |||
return FALSE; | return FALSE; | |||
} | } | |||
} else if (actual.sa.sa_family == AF_INET6) { //IPv6 | } else if (actual.sa.sa_family == AF_INET6) { //IPv6 | |||
if (expected.sa6.sin6_port == actual.sa6.sin6_port && | if ( expected.sa6.sin6_port == actual.sa6.sin6_port | |||
memcmp(&expected.sa6.sin6_addr, &actual.sa6.sin6_addr, | && expected.sa6.sin6_scope_id == actual.sa6.sin6_scope_id | |||
sizeof(in6)) == 0) { | && memcmp(&expected.sa6.sin6_addr, &actual.sa6.sin6_addr, | |||
sizeof(in6)) == 0) { | ||||
return TRUE; | return TRUE; | |||
} else { | } else { | |||
printf("IPv6 comparision failed"); | printf("IPv6 comparision failed"); | |||
return FALSE; | return FALSE; | |||
} | } | |||
} else { // Unknown family | } else { // Unknown family | |||
printf("Unknown sa_family: %d",actual.sa.sa_family); | printf("Unknown sa_family: %d",actual.sa.sa_family); | |||
return FALSE; | return FALSE; | |||
} | } | |||
} | } | |||
End of changes. 2 change blocks. | ||||
6 lines changed or deleted | 7 lines changed or added |