mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: discovery code cleanups (#6856)
* Use foreach $key => value * use get_port_by_ifIndex get rid of the rest of the array_keys() * improve hex_to_ip() function, add tests, use in more places * Simplify can_skip_discovery logic
This commit is contained in:
committed by
Neil Lathwood
parent
03a273f722
commit
90aa485149
@@ -50,4 +50,22 @@ class FunctionsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse(isHexString('a5 fj 53'));
|
||||
$this->assertFalse(isHexString('a5fe53'));
|
||||
}
|
||||
|
||||
public function testHexToIp()
|
||||
{
|
||||
$this->assertSame("192.168.1.254", hex_to_ip("c0 a8 01 fe"));
|
||||
$this->assertSame("192.168.1.254", hex_to_ip("c0a801fe"));
|
||||
$this->assertSame("192.168.1.254", hex_to_ip("c0 a8 01 fe "));
|
||||
$this->assertNotSame("192.168.1.1.254", hex_to_ip("c0 a8 01 01 fe"));
|
||||
$this->assertSame("192.168.1.254", hex_to_ip("\"c0 a8 01 fe\""));
|
||||
$this->assertSame("192.168.1.254", hex_to_ip("192.168.1.254"));
|
||||
|
||||
$this->assertSame('2001:db8:0:0:0:0:2:1', hex_to_ip('2001:db8:0:0:0:0:2:1'));
|
||||
$this->assertSame('2001:db8:0:0:0:0:2:1', hex_to_ip('20 01 0d b8 00 00 00 00 00 00 00 00 00 02 00 01'));
|
||||
$this->assertSame('2001:db8:0:0:0:0:2:1', hex_to_ip('20010db8000000000000000000020001'));
|
||||
$this->assertNotSame(
|
||||
'2001:db8:0:0:0:0:2:0:1',
|
||||
hex_to_ip('20 01 0d b8 00 00 00 00 00 00 00 00 00 02 00 00 00 01')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user