"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "t/ipv6_lookup_in_ipv4_t.c" between
libmaxminddb-1.5.0.tar.gz and libmaxminddb-1.5.2.tar.gz

About: libmaxminddb is a library that provides functions for working with MaxMind DB files (free GeoLite 2 or commercial GeoIP2).

ipv6_lookup_in_ipv4_t.c  (libmaxminddb-1.5.0):ipv6_lookup_in_ipv4_t.c  (libmaxminddb-1.5.2)
#include "maxminddb_test_helper.h" #include "maxminddb_test_helper.h"
void run_tests(int mode, const char *mode_desc) void run_tests(int mode, const char *mode_desc) {
{
const char *filename = "MaxMind-DB-test-ipv4-28.mmdb"; const char *filename = "MaxMind-DB-test-ipv4-28.mmdb";
const char *path = test_database_path(filename); const char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc); MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path); free((void *)path);
const char *ip = "::abcd"; const char *ip = "::abcd";
int gai_error, mmdb_error; int gai_error, mmdb_error;
MMDB_lookup_result_s UNUSED(result) = MMDB_lookup_result_s UNUSED(result) =
MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error); MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error);
cmp_ok( cmp_ok(mmdb_error,
mmdb_error, "==", MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR, "==",
"MMDB_lookup_string sets mmdb_error to MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR,
_ERROR when we try to look up an IPv6 address in an IPv4-only database"); "MMDB_lookup_string sets mmdb_error to "
"MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR when we try to look up an "
struct addrinfo hints = { "IPv6 address in an IPv4-only database");
.ai_family = AF_INET6,
.ai_flags = AI_NUMERICHOST struct addrinfo hints = {.ai_family = AF_INET6, .ai_flags = AI_NUMERICHOST};
};
struct addrinfo *addresses; struct addrinfo *addresses;
gai_error = getaddrinfo("2001:db8:85a3:0:0:8a2e:370:7334", NULL, gai_error = getaddrinfo(
&hints, &addresses); "2001:db8:85a3:0:0:8a2e:370:7334", NULL, &hints, &addresses);
if (gai_error) { if (gai_error) {
BAIL_OUT("getaddrinfo failed: %s", gai_strerror(gai_error)); BAIL_OUT("getaddrinfo failed: %s", gai_strerror(gai_error));
} }
mmdb_error = 0; mmdb_error = 0;
MMDB_lookup_sockaddr(mmdb, addresses->ai_addr, &mmdb_error); MMDB_lookup_sockaddr(mmdb, addresses->ai_addr, &mmdb_error);
cmp_ok( cmp_ok(mmdb_error,
mmdb_error, "==", MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR, "==",
"MMDB_lookup_sockaddr sets mmdb_error to MMDB_IPV6_LOOKUP_IN_IPV4_DATABA MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR,
SE_ERROR when we try to look up an IPv6 address in an IPv4-only database"); "MMDB_lookup_sockaddr sets mmdb_error to "
"MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR when we try to look up an "
"IPv6 address in an IPv4-only database");
freeaddrinfo(addresses); freeaddrinfo(addresses);
MMDB_close(mmdb); MMDB_close(mmdb);
free(mmdb); free(mmdb);
} }
int main(void) int main(void) {
{
plan(NO_PLAN); plan(NO_PLAN);
for_all_modes(&run_tests); for_all_modes(&run_tests);
done_testing(); done_testing();
} }
 End of changes. 5 change blocks. 
19 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)