1 """
2 Misc. utility functions. It is part of the pygeoip package.
3
4 @author: Jennifer Ennis <zaylea at gmail dot com>
5
6 @license:
7 Copyright(C) 2004 MaxMind LLC
8
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
21 """
22
24 """
25 Convert a IPv4 address into a 32-bit integer.
26
27 @param ip: quad-dotted IPv4 address
28 @type ip: str
29 @return: network byte order 32-bit integer
30 @rtype: int
31 """
32 ip_array = ip.split('.')
33 ip_long = long(ip_array[0]) * 16777216 + long(ip_array[1]) * 65536 + long(ip_array[2]) * 256 + long(ip_array[3])
34 return ip_long
35