From 0258d3c9eb6e32991b3c9f498ccc109d4cdae591 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 30 Sep 2021 10:36:56 +0000 Subject: [PATCH] network: Rename "match" functions to "matches" Gramatically, this makes more sense. Signed-off-by: Michael Tremer --- src/database.c | 2 +- src/libloc.sym | 4 ++-- src/libloc/network.h | 4 ++-- src/network.c | 12 ++++++------ src/test-country.c | 6 +++--- src/test-network.c | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/database.c b/src/database.c index d37e70f..01c30c6 100644 --- a/src/database.c +++ b/src/database.c @@ -785,7 +785,7 @@ static int __loc_database_lookup_handle_leaf(struct loc_database* db, const stru } // Check if the given IP address is inside the network - if (!loc_network_match_address(*network, address)) { + if (!loc_network_matches_address(*network, address)) { DEBUG(db->ctx, "Searched address is not part of the network\n"); loc_network_unref(*network); diff --git a/src/libloc.sym b/src/libloc.sym index df6f4d8..975bb62 100644 --- a/src/libloc.sym +++ b/src/libloc.sym @@ -98,8 +98,8 @@ global: loc_network_get_last_address; loc_network_has_flag; loc_network_is_subnet; - loc_network_match_address; - loc_network_match_country_code; + loc_network_matches_address; + loc_network_matches_country_code; loc_network_new; loc_network_new_from_string; loc_network_overlaps; diff --git a/src/libloc/network.h b/src/libloc/network.h index fcfa548..3b8b95f 100644 --- a/src/libloc/network.h +++ b/src/libloc/network.h @@ -45,11 +45,11 @@ const struct in6_addr* loc_network_get_first_address(struct loc_network* network char* loc_network_format_first_address(struct loc_network* network); const struct in6_addr* loc_network_get_last_address(struct loc_network* network); char* loc_network_format_last_address(struct loc_network* network); -int loc_network_match_address(struct loc_network* network, const struct in6_addr* address); +int loc_network_matches_address(struct loc_network* network, const struct in6_addr* address); const char* loc_network_get_country_code(struct loc_network* network); int loc_network_set_country_code(struct loc_network* network, const char* country_code); -int loc_network_match_country_code(struct loc_network* network, const char* country_code); +int loc_network_matches_country_code(struct loc_network* network, const char* country_code); uint32_t loc_network_get_asn(struct loc_network* network); int loc_network_set_asn(struct loc_network* network, uint32_t asn); diff --git a/src/network.c b/src/network.c index de024cc..4b2b279 100644 --- a/src/network.c +++ b/src/network.c @@ -353,7 +353,7 @@ LOC_EXPORT char* loc_network_format_last_address(struct loc_network* network) { return loc_network_format_address(network, &network->last_address); } -LOC_EXPORT int loc_network_match_address(struct loc_network* network, const struct in6_addr* address) { +LOC_EXPORT int loc_network_matches_address(struct loc_network* network, const struct in6_addr* address) { // Address must be larger than the start address if (in6_addr_cmp(&network->first_address, address) > 0) return 0; @@ -386,7 +386,7 @@ LOC_EXPORT int loc_network_set_country_code(struct loc_network* network, const c return 0; } -LOC_EXPORT int loc_network_match_country_code(struct loc_network* network, const char* country_code) { +LOC_EXPORT int loc_network_matches_country_code(struct loc_network* network, const char* country_code) { // Search for any special flags const int flag = loc_country_special_code_to_flag(country_code); @@ -441,17 +441,17 @@ LOC_EXPORT int loc_network_cmp(struct loc_network* self, struct loc_network* oth LOC_EXPORT int loc_network_overlaps(struct loc_network* self, struct loc_network* other) { // Either of the start addresses must be in the other subnet - if (loc_network_match_address(self, &other->first_address)) + if (loc_network_matches_address(self, &other->first_address)) return 1; - if (loc_network_match_address(other, &self->first_address)) + if (loc_network_matches_address(other, &self->first_address)) return 1; // Or either of the end addresses is in the other subnet - if (loc_network_match_address(self, &other->last_address)) + if (loc_network_matches_address(self, &other->last_address)) return 1; - if (loc_network_match_address(other, &self->last_address)) + if (loc_network_matches_address(other, &self->last_address)) return 1; return 0; diff --git a/src/test-country.c b/src/test-country.c index 6320c36..c6aff49 100644 --- a/src/test-country.c +++ b/src/test-country.c @@ -165,21 +165,21 @@ int main(int argc, char** argv) { loc_network_set_flag(network, LOC_NETWORK_FLAG_ANONYMOUS_PROXY); // Check if this network matches its own country code - err = loc_network_match_country_code(network, "YY"); + err = loc_network_matches_country_code(network, "YY"); if (!err) { fprintf(stderr, "Network does not match its own country code\n"); exit(EXIT_FAILURE); } // Check if this network matches the special country code - err = loc_network_match_country_code(network, "A1"); + err = loc_network_matches_country_code(network, "A1"); if (!err) { fprintf(stderr, "Network does not match the special country code A1\n"); exit(EXIT_FAILURE); } // Check if this network does not match another special country code - err = loc_network_match_country_code(network, "A2"); + err = loc_network_matches_country_code(network, "A2"); if (err) { fprintf(stderr, "Network matches another special country code A2\n"); exit(EXIT_FAILURE); diff --git a/src/test-network.c b/src/test-network.c index 2a577c6..4582fbe 100644 --- a/src/test-network.c +++ b/src/test-network.c @@ -100,7 +100,7 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } - err = loc_network_match_address(network1, &address); + err = loc_network_matches_address(network1, &address); if (!err) { fprintf(stderr, "Network1 does not match address\n"); exit(EXIT_FAILURE); -- 2.39.5