コード例 #1
0
ファイル: geoiplookup6.c プロジェクト: Asinox/sinatra-geoip
void
geoiplookup(GeoIP * gi, char *hostname, int i)
{
	const char     *country_code;
	const char     *country_name;
	const char     *domain_name;
	int             netspeed;
	int             country_id;
	GeoIPRegion    *region;
	GeoIPRecord    *gir;
	const char     *org;

	geoipv6_t       ipnum;
	ipnum = _GeoIP_lookupaddress_v6(hostname);
	if (__GEOIP_V6_IS_NULL(ipnum)) {
		printf("%s: can't resolve hostname ( %s )\n", GeoIPDBDescription[i], hostname);

	}
	else {


#if 0
		if (GEOIP_DOMAIN_EDITION_V6 == i) {
			domain_name = GeoIP_name_by_name_v6(gi, hostname);
			if (domain_name == NULL) {
				printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
			}
			else {
				printf("%s: %s\n", GeoIPDBDescription[i], domain_name);
			}
		}
#endif

		if (GEOIP_COUNTRY_EDITION_V6 == i) {

			country_id = GeoIP_id_by_ipnum_v6(gi, ipnum);
			country_code = GeoIP_country_code[country_id];
			country_name = GeoIP_country_name[country_id];
			if (country_id == 0) {
				printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
			}
			else {
				printf("%s: %s, %s\n", GeoIPDBDescription[i], country_code, country_name);
			}
		}
	}

#if 0

	else
	if (GEOIP_REGION_EDITION_REV0 == i || GEOIP_REGION_EDITION_REV1 == i) {
コード例 #2
0
int IpToGeo::lookUpV6(in6_addr addr, GeoInfo *pInfo)
{
    if (m_pLocation)
    {
        switch (m_locDbType)
        {
        case GEOIP_REGION_EDITION_REV0:
        case GEOIP_REGION_EDITION_REV1:
            pInfo->m_pRegion = GeoIP_region_by_ipnum_v6(m_pLocation, addr);
            break;
        case GEOIP_COUNTRY_EDITION_V6:
            pInfo->m_countryId = GeoIP_id_by_ipnum_v6(m_pLocation, addr);
            break;
        }

    }
    if (m_pOrg)
        pInfo->m_pOrg = GeoIP_name_by_ipnum_v6(m_pOrg, addr);
    if (m_pIsp)
        pInfo->m_pIsp = GeoIP_name_by_ipnum_v6(m_pIsp, addr);
    if (m_pNetspeed)
        pInfo->m_netspeed = GeoIP_id_by_ipnum_v6(m_pNetspeed, addr);
    return 0;
}
コード例 #3
0
const gchar *
sim_geoip_lookup (SimInet *inet)
{
  uint8_t *inet_addr;
  const gchar *ret;

  g_return_val_if_fail (SIM_IS_INET (inet), 0);

  inet_addr = sim_inet_get_in_addr (inet);

  if (sim_inet_is_ipv4 (inet))
  {
    if (inet_addr[0] || inet_addr[1] || inet_addr[2] || inet_addr[3])
    {
      unsigned long r_addr;

      r_addr = inet_addr[0] << 24 | inet_addr[1] << 16 | inet_addr[2] << 8 | inet_addr[3];
      ret = GeoIP_code_by_id (GeoIP_id_by_ipnum (geoip_db, r_addr));

    }
    else
    {
      ret = "--";
    }
  }
  else
  {
    geoipv6_t r_addr;
    memcpy (r_addr.__in6_u.__u6_addr8, inet_addr, sizeof (geoipv6_t));

    ret = GeoIP_code_by_id (GeoIP_id_by_ipnum_v6 (geoipV6_db, r_addr));
  }

  g_free (inet_addr);

  return ret;
}
コード例 #4
0
ファイル: geoiplookup6.c プロジェクト: 3sOx/asuswrt-merlin
void
geoiplookup(GeoIP * gi, char *hostname, int i)
{
    const char *country_code;
    const char *country_name;
    const char *asnum_name;
    int country_id;
    GeoIPRecord *gir;

    geoipv6_t ipnum;
    ipnum = _GeoIP_lookupaddress_v6(hostname);
    if (__GEOIP_V6_IS_NULL(ipnum)) {
        printf("%s: can't resolve hostname ( %s )\n", GeoIPDBDescription[i],
               hostname);

    }else {


#if 0
        if (GEOIP_DOMAIN_EDITION_V6 == i) {
            domain_name = GeoIP_name_by_name_v6(gi, hostname);
            if (domain_name == NULL) {
                printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
            }else {
                printf("%s: %s\n", GeoIPDBDescription[i], domain_name);
            }
        }
#endif



        if (GEOIP_LOCATIONA_EDITION_V6 == i || GEOIP_ASNUM_EDITION_V6 == i ||
            GEOIP_USERTYPE_EDITION_V6 == i || GEOIP_REGISTRAR_EDITION_V6 ==
            i ||
            GEOIP_DOMAIN_EDITION_V6 == i || GEOIP_ORG_EDITION_V6 == i ||
            GEOIP_ISP_EDITION_V6 == i || GEOIP_NETSPEED_EDITION_REV1_V6 == i) {
            asnum_name = GeoIP_name_by_ipnum_v6(gi, ipnum);
            if (asnum_name == NULL) {
                printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
            }else {
                printf("%s: %s\n", GeoIPDBDescription[i], asnum_name);
                //  _say_range_by_ip(gi, ipnum);
            }
        }else if (GEOIP_CITY_EDITION_REV0_V6 == i) {
            gir = GeoIP_record_by_ipnum_v6(gi, ipnum);
            if (NULL == gir) {
                printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
            }else {
                printf("%s: %s, %s, %s, %s, %f, %f\n", GeoIPDBDescription[i],
                       gir->country_code, _mk_NA(
                           gir->region),
                       _mk_NA(gir->city), _mk_NA(
                           gir->postal_code), gir->latitude, gir->longitude);
            }
        }else if (GEOIP_CITY_EDITION_REV1_V6 == i) {
            gir = GeoIP_record_by_ipnum_v6(gi, ipnum);
            if (NULL == gir) {
                printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
            }else {
                printf("%s: %s, %s, %s, %s, %f, %f, %d, %d\n",
                       GeoIPDBDescription[i], gir->country_code, _mk_NA(
                           gir->region), _mk_NA(gir->city), _mk_NA(
                           gir->postal_code),
                       gir->latitude, gir->longitude, gir->metro_code,
                       gir->area_code);
            }
        }else if (GEOIP_COUNTRY_EDITION_V6 == i) {

            country_id = GeoIP_id_by_ipnum_v6(gi, ipnum);
            country_code = GeoIP_country_code[country_id];
            country_name = GeoIP_country_name[country_id];
            if (country_id == 0) {
                printf("%s: IP Address not found\n", GeoIPDBDescription[i]);
            }else {
                printf("%s: %s, %s\n", GeoIPDBDescription[i], country_code,
                       country_name);
            }
        }
    }

#if 0

    else
    if (GEOIP_REGION_EDITION_REV0 == i || GEOIP_REGION_EDITION_REV1 == i) {