Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 200 lines (149 sloc) 6.65 kb
a54e34f @oschwald Added our MS COM API to Git
oschwald authored
1 GeoIPEx 1.2
2
3 Copyright 2012 MaxMind, Inc.
4
5 General
6 -------
7
0cf50b4 @oschwald Make clear that this is for the legacy format
oschwald authored
8 GeoIPEx is a COM object wrapper around the Maxmind GeoIP Legacy library. It
9 returns data from the City, ISP and Organization databases. The only added
10 functionality is recognition of non-routed IP addresses, for which "dummy"
11 data are returned (and no DB lookup is done). See "Special addresses" below.
a54e34f @oschwald Added our MS COM API to Git
oschwald authored
12
13
14 Implementation
15 --------------
16
0cf50b4 @oschwald Make clear that this is for the legacy format
oschwald authored
17 The wrapper code was written in Visual C++ using the wizards etc. in Visual
18 Studio 6 (SP5) The C code of the GeoIP Legacy library (GeoIp.c, GeoIPCity.c)
19 remains almost unchanged, except for some #ifdef's in GeoIPCity.c to enable it
20 to be built in Visual Studio. (Commented to indicate where.) To minimize
21 modifications to the library code, while avoiding a fixed DB location, the
22 GeoIP_open_type() routine is not used. GeoIP_open() is used instead. This
23 leads to a slight maintenance issue; the names of the three DB files are
24 duplicated in GeoIPEx.cpp.
a54e34f @oschwald Added our MS COM API to Git
oschwald authored
25
26 Source File list
27 ----------------
28
29 GeoIPComEx.dsw VS workspace file; open this to load project etc.
30 GeoIPComEx.dsp VS project file
31
32 GeoIPComEx.cpp standard Com-object interface file, created by VS; registration code etc
33 GeoIPComEx.idl -"-; interface specification
34 GeoIPComEx.h -"-
35 GeoIPComEx.tlb -"-
36 GeoIPComEx._i.c -"-
37 StdAfx.h -"-; precompiled hdrs src
38 StdAfx.cpp -"-; precompiled hdrs src
39 GeoIpEx.rgs -"-
40 GeoIPComEx.rc -"-; resource file stuff, registration and version use
41 Resource.h -"-; resource file stuff, registration and version use
42 GeoIPComEx.def -"-; resource file stuff, registration and version use
43 basetsd.h -"-
44
45 GeoIPEx.h declaration of CGeoIpEx c++ class
46 GeoIPEx.cpp implementation of CGeoIpEx c++ class
47
48 libgeoip\GeoIP.h header for Maxmind c library, std functions
49 libgeoip\GeoIP.c Maxmind c library, std functions
50 libgeoip\GeoIPCity.h Maxmind c library header, city & isp/organization functions
51 libgeoip\GeoIPCity.c Maxmind c library code, city & isp/organization functions
52
53
54
55 GeoIpEx routines
56 ----------------
57
58 CGeoIPEx::set_db_path(BSTR newVal, VARIANT_BOOL *present)
59 Method; must be called before any other method or property is used
60 Sets all the suports_* properties.
61 Note that the booleans returned by methods
62 must be either VARIANT_TRUE or VARIANT_FALSE.
63 newVal should be a DIRECTORY not the full path to the
64 database. The COM object will look for the files
65 using the directory plus the standard name for the
66 database as given at the end of this document.
67
68 CGeoIPEx::find_by_name(BSTR ip_address, VARIANT_BOOL *found)
69 Method to find info by DNS name; calls find_ip()
70 Sets property fields
71
72 CGeoIPEx::find_by_addr(BSTR ip_address, VARIANT_BOOL *found)
73 Method to find info by ip address (dotted quad string); calls find_ip()
74
75 CGeoIPEx::get_country_code(BSTR *pVal)
76 CGeoIPEx::get_country_code3(BSTR *pVal)
77 CGeoIPEx::get_country_name(BSTR *pVal)
78 CGeoIPEx::get_region(BSTR *pVal)
79 CGeoIPEx::get_city(BSTR *pVal)
80 CGeoIPEx::get_postal_code(BSTR *pVal)
81 CGeoIPEx::get_latitude(double *pVal)
82 CGeoIPEx::get_longitude(double *pVal)
83 CGeoIPEx::get_dma_code(long *pVal)
84 CGeoIPEx::get_area_code(long *pVal)
85 CGeoIPEx::get_ISP(BSTR *pVal)
86 CGeoIPEx::get_organization(BSTR *pVal)
87 CGeoIPEx::get_error_msg(BSTR *pVal)
88 Data property reader methods; All return the value from the field with the same name.
0cf50b4 @oschwald Make clear that this is for the legacy format
oschwald authored
89
a54e34f @oschwald Added our MS COM API to Git
oschwald authored
90 CGeoIPEx::get_supports_country_code(VARIANT_BOOL *pVal)
91 CGeoIPEx::get_supports_country_name(VARIANT_BOOL *pVal)
92 CGeoIPEx::get_supports_city(VARIANT_BOOL *pVal)
93 CGeoIPEx::get_supports_country_code3(VARIANT_BOOL *pVal)
94 CGeoIPEx::get_supports_area_code(VARIANT_BOOL *pVal)
95 CGeoIPEx::get_supports_region(VARIANT_BOOL *pVal)
96 CGeoIPEx::get_supports_dma_code(VARIANT_BOOL *pVal)
97 CGeoIPEx::get_supports_postal_code(VARIANT_BOOL *pVal)
98 CGeoIPEx::get_supports_position(VARIANT_BOOL *pVal)
99 Property reader methods; All return true if city DB was loaded.
100
101 CGeoIPEx::get_supports_ISP(VARIANT_BOOL *pVal)
102 Property getter method; Return true if ISP DB was loaded.
103
104 CGeoIPEx::get_supports_organization(VARIANT_BOOL *pVal)
105 Property getter method; Return true if org DB was loaded.
106
107 CGeoIPEx::find_ip(LPCSTR addr, bool byname)
108 Private method to fetch property values from the databases.
109
110 CGeoIPEx::clear_db()
111 Private metod to clear DB pointers.
112
113
114
115
116 Building
117 --------
118
0cf50b4 @oschwald Make clear that this is for the legacy format
oschwald authored
119 After opening the project in VS, select Build->Set Active Configuration,
120 choose ("Debug" or "Release MinSize") and select Build->Build GeoIpComEx.dll.
a54e34f @oschwald Added our MS COM API to Git
oschwald authored
121
0cf50b4 @oschwald Make clear that this is for the legacy format
oschwald authored
122 If you wish to use other configurations, note that precompiled headers are
123 turned off for the C files, and wsock32.dll is linked to (for dns lookups).
a54e34f @oschwald Added our MS COM API to Git
oschwald authored
124
125
126
127
128 Object interface
129 ----------------
130
131 Methods:
132 bool set_db_path(string path) (must be set before any other operations, true if all dbs found)
133 bool find_by_addr(string ipvalue) (return true if address found, sets all properties)
134 bool find_by_name(string dns_name) (-"-)
135
136 Properties: (string type unless otherwise noted)
137 country_code (2 chars; "LN" if non-routed addr, "LH" if localhost)
138 country_code3 (3 chars)
139 country_name ("Local Area Network" if non-routed addr,"Localhost" if localhost)
140 region (2 chars, state abbrev for US/Canada, FIPS 10-4 region code for others)
141 city
142 postal_code (max 6 chars, US and Canada only)
143 latitude (real number)
144 longitude (real number)
145 dma_code (integer)
146 area_code (integer)
147
148 ISP
149 organization
150
151 supports_country_code (bool, true if db file exists)
152 supports_country_code3 (bool, true if db file exists)
153 supports_country_name (bool, true if db file exists)
154 supports_city (bool, true if db file exists)
155 supports_region (bool, true if db file exists)
156 supports_postal_code (bool, true if db file exists)
157 supports_position (bool, true if db file exists)
158 supports_area_code (bool, true if db file exists)
159 supports_dma_code (bool, true if db file exists)
160
161 supports_organization (bool, true if db file exists)
162
163 supports_isp (bool, true if db file exists)
164
165 error_msg (for debugging, set on unexpected failures)
166
167
168
169 Special addresses
170 -----------------
171
0cf50b4 @oschwald Make clear that this is for the legacy format
oschwald authored
172 If one of the non-routed ip addresses
a54e34f @oschwald Added our MS COM API to Git
oschwald authored
173 10.*.*.*
174 172.16.*.* ... 172.31.*.*
175 192.168.*.*
176 are given as input to find_by_addr(),
177 country_code is set to "LN"
178 country_name to "Local Area Network" and
179 all other fields are cleared.
180
181 If ip addresses of the form 127.*.*.* (localhost)
182 are given as input to find_by_addr(),
183 country_code is set to "LH",
184 country_name to "Localhost" and
185 all other fields are cleared.
186
187
188 Database Paths
189 --------------
190
191 Install the databases in the directory set by set_db_path
192
193 The names of the files should be the ones listed below.
194
195 /path/GeoIP.dat (country)
196 /path/GeoIPRegion.dat (region)
197 /path/GeoIPCity.dat (City)
198 /path/GeoIPISP.dat (ISP)
199 /path/GeoIPOrg.dat (Organization)
Something went wrong with that request. Please try again.