Отак це робиться для будь кого Ethernet порту ONU
// для 1/2/12:13
$shelf = 1;
$slot = 2;
$olt = 12;
$onu_number= 13;
$index_type = str_pad(decbin(1), 4, '0', STR_PAD_LEFT);
$rack = str_pad(decbin(1), 4, '0', STR_PAD_LEFT);
$shelf = str_pad(decbin($shelf), 8, '0', STR_PAD_LEFT);
$slot = str_pad(decbin($slot), 8, '0', STR_PAD_LEFT);
$olt = str_pad(decbin($olt), 8, '0', STR_PAD_LEFT);
$olt_port_index = bindec($index_type . $rack . $shelf . $slot . $olt);
if ($onu_number == null){
return("$olt_port_index.0");// convert bin to dec
}else{
$index_type = str_pad(decbin(2), 5, '0', STR_PAD_LEFT);
$ont_id = str_pad(decbin($onu_number), 11, '0', STR_PAD_LEFT);
$bridgeportID = str_pad(decbin(ETHERNET_PORT_NUMBER), 8, '0', STR_PAD_LEFT);
$lsb = str_pad(decbin(0), 8, '0', STR_PAD_LEFT);
$onu_index = bindec($index_type . $ont_id . $bridgeportID . $lsb);
return("$olt_port_index.$onu_index");// convert bin to dec
}