Forum Topics : Development / DLL for easy use of IPs and ip-to-country list
I have developed a DLL which contains some basic functions that are used to get IPs in different formats and get different info from it, the library also uses this great ip-to-country list to enable you lookup of the country info for selected IP.
I have seen several requests in forum(s) for formulas how to calculate longint from IP and vice versa etc. I needed it too, so I did this for my own use, but since I got this list for free, why shouldn't I give something back?
Some basic functions are here:
ValidateIP <-- check if IP is in valid format
IP2Longint <-- convert IP to it's longint representative (i.e. for searching the list)
Longint2IP <-- convert from longint to IP
IPWithBits2Hosts <-- convert from IP/bits (127.0.0.0/24) format to number of hosts (256) in subnet
IPWithBits2Range <-- convert from IP/bits format to number of hosts and range of IPs in subnet (i.e. 127.0.0.5/24 --> 256 hosts --> 127.0.0.0 - 127.0.0.255)
IPBits2Netmask <-- convert the bits to netmask i.e. 24 -> 255.255.255.0
Netmask2IPBits <-- convert the netmask to bits i.e. 255.255.255.0 -> 24
GetIPCountry <-- returns country codes (2 and 3 char), country name and true/false if country info was found
The implementation is made default in Delphi and Kylix, if there will be enough requests for a C++ .h file I will make it but I think that if this library should show usefull that someone else will do it faster than me.
DLL is available free of charge for use and can be obtained from me directly, if there is a place on this site where I could post it I would do it.
Uros
I have seen several requests in forum(s) for formulas how to calculate longint from IP and vice versa etc. I needed it too, so I did this for my own use, but since I got this list for free, why shouldn't I give something back?
Some basic functions are here:
ValidateIP <-- check if IP is in valid format
IP2Longint <-- convert IP to it's longint representative (i.e. for searching the list)
Longint2IP <-- convert from longint to IP
IPWithBits2Hosts <-- convert from IP/bits (127.0.0.0/24) format to number of hosts (256) in subnet
IPWithBits2Range <-- convert from IP/bits format to number of hosts and range of IPs in subnet (i.e. 127.0.0.5/24 --> 256 hosts --> 127.0.0.0 - 127.0.0.255)
IPBits2Netmask <-- convert the bits to netmask i.e. 24 -> 255.255.255.0
Netmask2IPBits <-- convert the netmask to bits i.e. 255.255.255.0 -> 24
GetIPCountry <-- returns country codes (2 and 3 char), country name and true/false if country info was found
The implementation is made default in Delphi and Kylix, if there will be enough requests for a C++ .h file I will make it but I think that if this library should show usefull that someone else will do it faster than me.
DLL is available free of charge for use and can be obtained from me directly, if there is a place on this site where I could post it I would do it.
Uros
