I need to store IP address in the most compact way possible, searching is not a concern. This also needs to be compatible on Windows, Linux, and Mac using any DB (MySQL, SQLite, Postgre, etc).
Thanks to the ip2long() and long2ip() functions in PHP I can convert a IP4 address to a small int field rather than a varchar(15) or whatever. The problem is that we are in a transition stage to IP6 which means that most of the existing best-practices are failing - including those functions which don't work with IP6. Further more, DB specific functions like INET_ATON() and INET_NTOA() aren't options here.
So how do you store IP address as INT's (or any other compact format) in a way that will work on any system?
EDIT: The thread Wrang-wrang pointed mentions the use of inet_ntop() and inet_ptop() to pack and unpack either IP4 or IP6. The problem is that they only work on Linux/Mac with PHP +5.1 (which isn't a too big of a problem) and on windows with +5.3 (which is).
If that was not a problem are their replacements for the varbinary(16) field that was recommended in each database?