summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--astraceroute.c16
-rw-r--r--flowtop.c8
-rw-r--r--geoip.c40
-rw-r--r--geoip.h48
-rw-r--r--proto_ipv4.c12
-rw-r--r--proto_ipv6.c12
6 files changed, 68 insertions, 68 deletions
diff --git a/astraceroute.c b/astraceroute.c
index e9d876d..2f3449e 100644
--- a/astraceroute.c
+++ b/astraceroute.c
@@ -469,9 +469,9 @@ static void handle_ipv4(uint8_t *packet, size_t len __maybe_unused,
getnameinfo((struct sockaddr *) &sd, sizeof(sd),
hbuff, sizeof(hbuff), NULL, 0, NI_NUMERICHOST);
- as = geoip4_as_name(sd);
- country = geoip4_country_name(sd);
- city = geoip4_city_name(sd);
+ as = geoip4_as_name(&sd);
+ country = geoip4_country_name(&sd);
+ city = geoip4_city_name(&sd);
if (dns_resolv) {
hent = gethostbyaddr(&sd.sin_addr, sizeof(sd.sin_addr), PF_INET);
@@ -490,7 +490,7 @@ static void handle_ipv4(uint8_t *packet, size_t len __maybe_unused,
printf(", %s", city);
}
if (latitude)
- printf(" (%f/%f)", geoip4_latitude(sd), geoip4_longitude(sd));
+ printf(" (%f/%f)", geoip4_latitude(&sd), geoip4_longitude(&sd));
}
static int check_ipv6(uint8_t *packet, size_t len, int ttl __maybe_unused,
@@ -536,9 +536,9 @@ static void handle_ipv6(uint8_t *packet, size_t len __maybe_unused,
getnameinfo((struct sockaddr *) &sd, sizeof(sd),
hbuff, sizeof(hbuff), NULL, 0, NI_NUMERICHOST);
- as = geoip6_as_name(sd);
- country = geoip6_country_name(sd);
- city = geoip6_city_name(sd);
+ as = geoip6_as_name(&sd);
+ country = geoip6_country_name(&sd);
+ city = geoip6_city_name(&sd);
if (dns_resolv) {
hent = gethostbyaddr(&sd.sin6_addr, sizeof(sd.sin6_addr), PF_INET6);
@@ -557,7 +557,7 @@ static void handle_ipv6(uint8_t *packet, size_t len __maybe_unused,
printf(", %s", city);
}
if (latitude)
- printf(" (%f/%f)", geoip6_latitude(sd), geoip6_longitude(sd));
+ printf(" (%f/%f)", geoip6_latitude(&sd), geoip6_longitude(&sd));
}
static void show_trace_info(struct ctx *ctx, const struct sockaddr_storage *ss,
diff --git a/flowtop.c b/flowtop.c
index 5f7b7d5..ce43d93 100644
--- a/flowtop.c
+++ b/flowtop.c
@@ -595,12 +595,12 @@ flow_entry_geo_city_lookup_generic(struct flow_entry *n,
case AF_INET:
flow_entry_get_sain4_obj(n, dir, &sa4);
- city = geoip4_city_name(sa4);
+ city = geoip4_city_name(&sa4);
break;
case AF_INET6:
flow_entry_get_sain6_obj(n, dir, &sa6);
- city = geoip6_city_name(sa6);
+ city = geoip6_city_name(&sa6);
break;
}
@@ -629,12 +629,12 @@ flow_entry_geo_country_lookup_generic(struct flow_entry *n,
case AF_INET:
flow_entry_get_sain4_obj(n, dir, &sa4);
- country = geoip4_country_name(sa4);
+ country = geoip4_country_name(&sa4);
break;
case AF_INET6:
flow_entry_get_sain6_obj(n, dir, &sa6);
- country = geoip6_country_name(sa6);
+ country = geoip6_country_name(&sa6);
break;
}
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)) ? : ∅
+ return GeoIP_record_by_ipnum(gi4_city, ntohl(sa->sin_addr.s_addr)) ? : ∅
}
-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) ? : ∅
+ return GeoIP_record_by_ipnum_v6(gi6_city, sa->sin6_addr) ? : ∅
}
-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;
diff --git a/geoip.h b/geoip.h
index 3a49b2b..66ed20b 100644
--- a/geoip.h
+++ b/geoip.h
@@ -11,18 +11,18 @@
extern void init_geoip(int enforce);
extern void update_geoip(void);
extern int geoip_working(void);
-extern const char *geoip4_city_name(struct sockaddr_in sa);
-extern const char *geoip6_city_name(struct sockaddr_in6 sa);
-extern const char *geoip4_region_name(struct sockaddr_in sa);
-extern const char *geoip6_region_name(struct sockaddr_in6 sa);
-extern const char *geoip4_country_name(struct sockaddr_in sa);
-extern const char *geoip6_country_name(struct sockaddr_in6 sa);
-extern float geoip4_longitude(struct sockaddr_in sa);
-extern float geoip4_latitude(struct sockaddr_in sa);
-extern float geoip6_longitude(struct sockaddr_in6 sa);
-extern float geoip6_latitude(struct sockaddr_in6 sa);
-extern const char *geoip4_as_name(struct sockaddr_in sa);
-extern const char *geoip6_as_name(struct sockaddr_in6 sa);
+extern const char *geoip4_city_name(struct sockaddr_in *sa);
+extern const char *geoip6_city_name(struct sockaddr_in6 *sa);
+extern const char *geoip4_region_name(struct sockaddr_in *sa);
+extern const char *geoip6_region_name(struct sockaddr_in6 *sa);
+extern const char *geoip4_country_name(struct sockaddr_in *sa);
+extern const char *geoip6_country_name(struct sockaddr_in6 *sa);
+extern float geoip4_longitude(struct sockaddr_in *sa);
+extern float geoip4_latitude(struct sockaddr_in *sa);
+extern float geoip6_longitude(struct sockaddr_in6 *sa);
+extern float geoip6_latitude(struct sockaddr_in6 *sa);
+extern const char *geoip4_as_name(struct sockaddr_in *sa);
+extern const char *geoip6_as_name(struct sockaddr_in6 *sa);
extern void destroy_geoip(void);
#else
static inline void init_geoip(int enforce)
@@ -43,62 +43,62 @@ static inline int geoip_working(void)
return 0;
}
-static inline const char *geoip4_city_name(struct sockaddr_in sa)
+static inline const char *geoip4_city_name(struct sockaddr_in *sa)
{
return NULL;
}
-static inline const char *geoip6_city_name(struct sockaddr_in6 sa)
+static inline const char *geoip6_city_name(struct sockaddr_in6 *sa)
{
return NULL;
}
-static inline const char *geoip4_region_name(struct sockaddr_in sa)
+static inline const char *geoip4_region_name(struct sockaddr_in *sa)
{
return NULL;
}
-static inline const char *geoip6_region_name(struct sockaddr_in6 sa)
+static inline const char *geoip6_region_name(struct sockaddr_in6 *sa)
{
return NULL;
}
-static inline const char *geoip4_country_name(struct sockaddr_in sa)
+static inline const char *geoip4_country_name(struct sockaddr_in *sa)
{
return NULL;
}
-static inline const char *geoip6_country_name(struct sockaddr_in6 sa)
+static inline const char *geoip6_country_name(struct sockaddr_in6 *sa)
{
return NULL;
}
-static inline float geoip4_longitude(struct sockaddr_in sa)
+static inline float geoip4_longitude(struct sockaddr_in *sa)
{
return .0f;
}
-static inline float geoip4_latitude(struct sockaddr_in sa)
+static inline float geoip4_latitude(struct sockaddr_in *sa)
{
return .0f;
}
-static inline float geoip6_longitude(struct sockaddr_in6 sa)
+static inline float geoip6_longitude(struct sockaddr_in6 *sa)
{
return .0f;
}
-static inline float geoip6_latitude(struct sockaddr_in6 sa)
+static inline float geoip6_latitude(struct sockaddr_in6 *sa)
{
return .0f;
}
-static inline const char *geoip4_as_name(struct sockaddr_in sa)
+static inline const char *geoip4_as_name(struct sockaddr_in *sa)
{
return NULL;
}
-static inline const char *geoip6_as_name(struct sockaddr_in6 sa)
+static inline const char *geoip6_as_name(struct sockaddr_in6 *sa)
{
return NULL;
}
diff --git a/proto_ipv4.c b/proto_ipv4.c
index 2eb5e4f..47eca29 100644
--- a/proto_ipv4.c
+++ b/proto_ipv4.c
@@ -98,21 +98,21 @@ static void ipv4(struct pkt_buff *pkt)
if (geoip_working()) {
tprintf("\t[ Geo (");
- if ((country = geoip4_country_name(sas))) {
+ if ((country = geoip4_country_name(&sas))) {
tprintf("%s", country);
- if ((region = geoip4_region_name(sas)))
+ if ((region = geoip4_region_name(&sas)))
tprintf(" / %s", region);
- if ((city = geoip4_city_name(sas)))
+ if ((city = geoip4_city_name(&sas)))
tprintf(" / %s", city);
} else {
tprintf("local");
}
tprintf(" => ");
- if ((country = geoip4_country_name(sad))) {
+ if ((country = geoip4_country_name(&sad))) {
tprintf("%s", country);
- if ((region = geoip4_region_name(sad)))
+ if ((region = geoip4_region_name(&sad)))
tprintf(" / %s", region);
- if ((city = geoip4_city_name(sad)))
+ if ((city = geoip4_city_name(&sad)))
tprintf(" / %s", city);
} else {
tprintf("local");
diff --git a/proto_ipv6.c b/proto_ipv6.c
index 4149602..1cc93ba 100644
--- a/proto_ipv6.c
+++ b/proto_ipv6.c
@@ -60,21 +60,21 @@ void ipv6(struct pkt_buff *pkt)
if (geoip_working()) {
tprintf("\t[ Geo (");
- if ((country = geoip6_country_name(sas))) {
+ if ((country = geoip6_country_name(&sas))) {
tprintf("%s", country);
- if ((region = geoip6_region_name(sas)))
+ if ((region = geoip6_region_name(&sas)))
tprintf(" / %s", region);
- if ((city = geoip6_city_name(sas)))
+ if ((city = geoip6_city_name(&sas)))
tprintf(" / %s", city);
} else {
tprintf("local");
}
tprintf(" => ");
- if ((country = geoip6_country_name(sad))) {
+ if ((country = geoip6_country_name(&sad))) {
tprintf("%s", country);
- if ((region = geoip6_region_name(sad)))
+ if ((region = geoip6_region_name(&sad)))
tprintf(" / %s", region);
- if ((city = geoip6_city_name(sad)))
+ if ((city = geoip6_city_name(&sad)))
tprintf(" / %s", city);
} else {
tprintf("local");