-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
202 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
|
||
namespace SwitcherCore\Modules\CData\FD16xxV3; | ||
|
||
|
||
use Exception; | ||
use SnmpWrapper\Oid; | ||
use SwitcherCore\Modules\AbstractModule; | ||
use SwitcherCore\Modules\Helper; | ||
use SwitcherCore\Switcher\Objects\WrappedResponse; | ||
|
||
class SnmpUnregisteredOnts extends CDataAbstractModuleFD16xxV3 | ||
{ | ||
/** | ||
* @var WrappedResponse[] | ||
*/ | ||
protected $response = null; | ||
|
||
function getRaw() | ||
{ | ||
return $this->response; | ||
} | ||
|
||
function getPretty() | ||
{ | ||
return $this->response; | ||
} | ||
|
||
/** | ||
* @param array $filter | ||
* @return $this|AbstractModule | ||
* @throws Exception | ||
*/ | ||
public function run($filter = []) | ||
{ | ||
$oids = array_map(function ($e) { | ||
return Oid::init($e->getOid()); | ||
}, $this->oids->getOidsByRegex('ont.autofind..*')); | ||
$response = $this->formatResponse($this->snmp->walk($oids)); | ||
$this->response = array_values($this->getGponUnregisteredFromResponses($response)); | ||
return $this; | ||
} | ||
|
||
function getGponUnregisteredFromResponses($response) | ||
{ | ||
$data = []; | ||
if (isset($response['ont.autofind.ident'])) { | ||
if ($response['ont.autofind.ident']->error()) { | ||
return []; | ||
} | ||
foreach ($response['ont.autofind.ident']->fetchAll() as $onuId => $sn) { | ||
$uniqId = Helper::getIndexByOid($sn->getOid()); | ||
$ifacePort = explode(":", $this->parseInterface($uniqId, '_snmp_id')['name'])[0]; | ||
$iface = $this->parseInterface($ifacePort . ":" . ($onuId + 1)); | ||
$val = $sn->getValue(); | ||
$hexVal = strtoupper(bin2hex(substr($val, 0, 4))) . substr($val, 5); | ||
$data[$uniqId] = [ | ||
'_serial_ascii' => $sn->getValue(), | ||
'_serial_hex' => $hexVal, | ||
'serial' => str_replace("-", "", $sn->getValue()), | ||
'_ident' => str_replace("-", "", $sn->getValue()), | ||
'interface' => $iface, | ||
'password' => null, | ||
'version' => null, | ||
'equipment_id' => null, | ||
'fw_version' => null, | ||
'check_code' => null, | ||
'loid' => null, | ||
'reg_time' => null, | ||
'model' => null, | ||
'type' => null, | ||
]; | ||
} | ||
} | ||
foreach ($response['ont.autofind.equipmentId']->fetchAll() as $d) { | ||
$uniqId = Helper::getIndexByOid($d->getOid()); | ||
$data[$uniqId]['equipment_id'] = $this->convertHexToString($d->getHexValue()); | ||
} | ||
foreach ($response['ont.autofind.password']->fetchAll() as $d) { | ||
$uniqId = Helper::getIndexByOid($d->getOid()); | ||
$data[$uniqId]['password'] = $this->convertHexToString($d->getHexValue()); | ||
} | ||
foreach ($response['ont.autofind.softwareVer']->fetchAll() as $d) { | ||
$uniqId = Helper::getIndexByOid($d->getOid()); | ||
$data[$uniqId]['fw_version'] = $this->convertHexToString($d->getHexValue()); | ||
} | ||
return $data; | ||
} | ||
|
||
function getPrettyFiltered($filter = [], $fromCache = false) | ||
{ | ||
return parent::getPrettyFiltered($filter, $fromCache); // TODO: Change the autogenerated stub | ||
} | ||
} | ||
|
Oops, something went wrong.