summaryrefslogtreecommitdiff
path: root/geoip.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2014-05-27 10:59:52 +0200
committerTobias Klauser <tklauser@distanz.ch>2014-05-27 10:59:52 +0200
commit5160c9212e0e55e0dc518aadca0e6a370cf1420d (patch)
treeb5fb172ab10010321fb383b2aa3b8e0c058a0da7 /geoip.c
parent2e7e42af61fea74bfbb40abdc8318366638672fb (diff)
geoip: Pass struct sockaddr_in{,6} as pointer instead of by value
Change the interface to the geoip_* functions to take a pointer to a struct sockaddr_in{,6} instead of the struct itself. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'geoip.c')
-rw-r--r--geoip.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/geoip.c b/geoip.c
index 8d879a6..b1ddeeb 100644
--- a/geoip.c
+++ b/geoip.c
@@ -256,86 +256,86 @@ again:
return 0;
}
-static GeoIPRecord *geoip4_get_record(struct sockaddr_in sa)
+static GeoIPRecord *geoip4_get_record(struct sockaddr_in *sa)
{
bug_on(gi4_city == NULL);
- return GeoIP_record_by_ipnum(gi4_city, ntohl(sa.sin_addr.s_addr)) ? : &empty;
+ return GeoIP_record_by_ipnum(gi4_city, ntohl(sa->sin_addr.s_addr)) ? : &empty;
}
-static GeoIPRecord *geoip6_get_record(struct sockaddr_in6 sa)
+static GeoIPRecord *geoip6_get_record(struct sockaddr_in6 *sa)
{
bug_on(gi6_city == NULL);
- return GeoIP_record_by_ipnum_v6(gi6_city, sa.sin6_addr) ? : &empty;
+ return GeoIP_record_by_ipnum_v6(gi6_city, sa->sin6_addr) ? : &empty;
}
-const char *geoip4_as_name(struct sockaddr_in sa)
+const char *geoip4_as_name(struct sockaddr_in *sa)
{
bug_on(gi4_asname == NULL);
- return GeoIP_name_by_ipnum(gi4_asname, ntohl(sa.sin_addr.s_addr));
+ return GeoIP_name_by_ipnum(gi4_asname, ntohl(sa->sin_addr.s_addr));
}
-const char *geoip6_as_name(struct sockaddr_in6 sa)
+const char *geoip6_as_name(struct sockaddr_in6 *sa)
{
bug_on(gi6_asname == NULL);
- return GeoIP_name_by_ipnum_v6(gi6_asname, sa.sin6_addr);
+ return GeoIP_name_by_ipnum_v6(gi6_asname, sa->sin6_addr);
}
-float geoip4_longitude(struct sockaddr_in sa)
+float geoip4_longitude(struct sockaddr_in *sa)
{
return geoip4_get_record(sa)->longitude;
}
-float geoip4_latitude(struct sockaddr_in sa)
+float geoip4_latitude(struct sockaddr_in *sa)
{
return geoip4_get_record(sa)->latitude;
}
-float geoip6_longitude(struct sockaddr_in6 sa)
+float geoip6_longitude(struct sockaddr_in6 *sa)
{
return geoip6_get_record(sa)->longitude;
}
-float geoip6_latitude(struct sockaddr_in6 sa)
+float geoip6_latitude(struct sockaddr_in6 *sa)
{
return geoip6_get_record(sa)->latitude;
}
-const char *geoip4_city_name(struct sockaddr_in sa)
+const char *geoip4_city_name(struct sockaddr_in *sa)
{
return geoip4_get_record(sa)->city;
}
-const char *geoip6_city_name(struct sockaddr_in6 sa)
+const char *geoip6_city_name(struct sockaddr_in6 *sa)
{
return geoip6_get_record(sa)->city;
}
-const char *geoip4_region_name(struct sockaddr_in sa)
+const char *geoip4_region_name(struct sockaddr_in *sa)
{
return geoip4_get_record(sa)->region;
}
-const char *geoip6_region_name(struct sockaddr_in6 sa)
+const char *geoip6_region_name(struct sockaddr_in6 *sa)
{
return geoip6_get_record(sa)->region;
}
-const char *geoip4_country_name(struct sockaddr_in sa)
+const char *geoip4_country_name(struct sockaddr_in *sa)
{
bug_on(gi4_country == NULL);
- return GeoIP_country_name_by_ipnum(gi4_country, ntohl(sa.sin_addr.s_addr));
+ return GeoIP_country_name_by_ipnum(gi4_country, ntohl(sa->sin_addr.s_addr));
}
-const char *geoip6_country_name(struct sockaddr_in6 sa)
+const char *geoip6_country_name(struct sockaddr_in6 *sa)
{
bug_on(gi6_country == NULL);
- return GeoIP_country_name_by_ipnum_v6(gi6_country, sa.sin6_addr);
+ return GeoIP_country_name_by_ipnum_v6(gi6_country, sa->sin6_addr);
}
static int fdout, fderr;