Refactor MAC utilities into a single class (#15379)

* Refactor MAC utils to a new utility class

* Apply fixes from StyleCI

* Inline functions
Add tests
Handle bridgeid format

* Apply fixes from StyleCI

* Dedicated code path for stp bridge parsing, and improve STP output a bit

* Correctly parse dot1dBaseBridgeAddress and don't store int in bool field

* trim any unexpected character from bridge addresses, add extra test data.

* better comment

* barsBridge can handle dot1dBaseBridgeAddress correctly now

* parseBridge, check for properly formatted mac first.

* update test data, empty data = empty mac

* Fix new usage after rebase

* import

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
This commit is contained in:
Tony Murray
2023-10-06 07:34:14 -05:00
committed by GitHub
parent 908aef6596
commit d8c372bbf4
36 changed files with 340 additions and 264 deletions

View File

@@ -27,16 +27,10 @@ namespace LibreNMS\Tests;
use LibreNMS\Device\YamlDiscovery;
use LibreNMS\Util\Number;
use LibreNMS\Util\Rewrite;
use LibreNMS\Util\Time;
class FunctionsTest extends TestCase
{
public function testMacCleanToReadable(): void
{
$this->assertEquals('de:ad:be:ef:a0:c3', Rewrite::readableMac('deadbeefa0c3'));
}
public function testHex2Str(): void
{
$this->assertEquals('Big 10 UP', hex2str('426967203130205550'));