From: [EMAIL PROTECTED]
Operating system: FreeBSD 4.4-STABLE i386
PHP version: 4.1.2
PHP Bug Type: Unknown/Other Function
Bug description: long2ip Returns Incorrect Results
I have found some problems where long2ip (and I would presume ip2long by
the same token) seems to return an IP address offset by one. I'm not sure
if it is the implmentation of inet_ntoa on the platform I am using or
something else.
Even if this is a problem with a particular version of a library on my
machine, maybe it might be worth using a method other than inet_ntoa for
ease of platform independance?
Perhaps something along there lines.... ?
struct inet4addr {
unsigned int a:8;
unsigned int b:8;
unsigned int c:8;
unsigned int d:8;
};
typedef union {
unsigned int inet4dec;
struct inet4addr inet4oct;
} inet4oct;
blah.inet4dec = <SOME LONG IP HERE>;
printf("%i.%i.%i.%i\n", blah.inet4oct.a,
blah.inet4oct.b,blah.inet4oct.c,blah.inet4oct.d);
--
Edit bug report at http://bugs.php.net/?id=16020&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=16020&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=16020&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=16020&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=16020&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=16020&r=support
Expected behavior: http://bugs.php.net/fix.php?id=16020&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=16020&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=16020&r=submittedtwice