geoip_admin.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?xml version="1.0" encoding='ISO-8859-1'?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  4. <!-- Include general documentation entities -->
  5. <!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
  6. %docentities;
  7. ]>
  8. <!-- Module User's Guide -->
  9. <chapter>
  10. <title>&adminguide;</title>
  11. <section>
  12. <title>Overview</title>
  13. <para>
  14. This module allows real-time queries against the Max Mind GeoIP
  15. database to be performed from the config script.
  16. </para>
  17. <para>
  18. The Max Mind GeoIP database is a map of IP network address assignments
  19. to geographical locales that can be useful -- though approximate --
  20. in identifying the physical location with which an IP host address
  21. is associated on a relatively granular level.
  22. </para>
  23. <para>
  24. This database itself can be obtained on a free or commercial basis
  25. from <ulink url="http://www.maxmind.com/app/ip-location">
  26. http://www.maxmind.com/app/ip-location</ulink>. The
  27. library that interfaces with the Max Mind API, as well as scripts to
  28. automate downloading of the on-disk version of the open-source
  29. database is also packaged by the Debian Linux distribution and
  30. its derivatives as <emphasis>libgeoip</emphasis>, and probably by
  31. other distributions as well.
  32. </para>
  33. <para>
  34. Debian Linux squeeze includes already a database as dependency, but as
  35. this contain the wrong data, it will not work correctly with the module.
  36. More acurate, the module expect the <emphasis>GeoIP City Edition</emphasis>,
  37. and will not work with the <emphasis>GeoIP Country Edition</emphasis>. In
  38. newer Debian Linux releases the package <emphasis>geoip-database-contrib</emphasis>
  39. should contain the necessary database. You can download the Lite edition
  40. of the DB from <ulink url="http://www.maxmind.com/app/geolitecity">
  41. http://www.maxmind.com/app/geolitecity</ulink>.
  42. </para>
  43. <para>
  44. This module exports a new class of pseudo-variables -
  45. $gip(pvc=&gt;key) - to enable access to the results of a query to the
  46. database.
  47. </para>
  48. <para>
  49. Many queries can be done and store results in different containers to
  50. be able to use in parallel. Database is loaded at startup in cache.
  51. </para>
  52. </section>
  53. <section>
  54. <title>Dependencies</title>
  55. <section>
  56. <title>&kamailio; Modules</title>
  57. <para>
  58. The following modules must be loaded before this module:
  59. <itemizedlist>
  60. <listitem>
  61. <para>
  62. <emphasis>none</emphasis>.
  63. </para>
  64. </listitem>
  65. </itemizedlist>
  66. </para>
  67. </section>
  68. <section>
  69. <title>External Libraries or Applications</title>
  70. <para>
  71. The following libraries or applications must be installed before running
  72. &kamailio; with this module loaded:
  73. <itemizedlist>
  74. <listitem>
  75. <para>
  76. <emphasis>libgeoip</emphasis> - the GeoIP library.
  77. </para>
  78. </listitem>
  79. </itemizedlist>
  80. </para>
  81. </section>
  82. </section>
  83. <section>
  84. <title>Parameters</title>
  85. <section>
  86. <title><varname>path</varname> (string)</title>
  87. <para>
  88. Path to the GeoIP database file.
  89. </para>
  90. <para>
  91. <emphasis>
  92. Default value is <quote>null</quote>.
  93. </emphasis>
  94. </para>
  95. <example>
  96. <title>Set <varname>path</varname> parameter</title>
  97. <programlisting format="linespecific">
  98. ...
  99. modparam("geoip", "path", "/usr/local/share/GeoLiteCity.dat")
  100. ...
  101. </programlisting>
  102. </example>
  103. </section>
  104. </section>
  105. <section>
  106. <title>Functions</title>
  107. <section>
  108. <title>
  109. <function moreinfo="none">geoip_match(ipaddr, pvc)</function>
  110. </title>
  111. <para>
  112. Match ipaddr against the GeoIP database and set the pvc container. The
  113. function has to be called before accessing a key via: $gip(pvc=&gt;key).
  114. </para>
  115. <example>
  116. <title><function>geoip_match</function> usage</title>
  117. <programlisting format="linespecific">
  118. ...
  119. if(geoip_match("$si", "src"))
  120. xlog("SIP message from: $gip(src=&gt;cc)\n");
  121. ...
  122. </programlisting>
  123. </example>
  124. </section>
  125. </section>
  126. <section>
  127. <title>Exported pseudo-variables</title>
  128. <itemizedlist>
  129. <listitem><para>
  130. <emphasis>$gip(pvc=&gt;key)</emphasis> - <emphasis>pvc</emphasis> is an
  131. identifier for this query result; it is designated by the second
  132. parameter of geoip_match(). The <emphasis>key</emphasis> can be one of
  133. the following:
  134. </para>
  135. <itemizedlist>
  136. <listitem><para>
  137. <emphasis>cc</emphasis> - country code
  138. </para></listitem>
  139. <listitem><para>
  140. <emphasis>tz</emphasis> - time zone
  141. </para></listitem>
  142. <listitem><para>
  143. <emphasis>zip</emphasis> - postal code
  144. </para></listitem>
  145. <listitem><para>
  146. <emphasis>lat</emphasis> - latitude
  147. </para></listitem>
  148. <listitem><para>
  149. <emphasis>lon</emphasis> - longitude
  150. </para></listitem>
  151. <listitem><para>
  152. <emphasis>dma</emphasis> - dma code
  153. </para></listitem>
  154. <listitem><para>
  155. <emphasis>ips</emphasis> - ip start
  156. </para></listitem>
  157. <listitem><para>
  158. <emphasis>ipe</emphasis> - ip end
  159. </para></listitem>
  160. <listitem><para>
  161. <emphasis>city</emphasis> - city
  162. </para></listitem>
  163. <listitem><para>
  164. <emphasis>area</emphasis> - area code
  165. </para></listitem>
  166. <listitem><para>
  167. <emphasis>regc</emphasis> - region
  168. </para></listitem>
  169. <listitem><para>
  170. <emphasis>regn</emphasis> - region name
  171. </para></listitem>
  172. <listitem><para>
  173. <emphasis>metro</emphasis> - metro code
  174. </para></listitem>
  175. </itemizedlist>
  176. </listitem>
  177. </itemizedlist>
  178. <para>
  179. Exported pseudo-variables are documented at &kamwikilink;.
  180. </para>
  181. </section>
  182. </chapter>