VOL-2452: Add new omci get functions
- Provide functions that encode omci get responses needed
to lookup a MIB template. Other fields added for completeness
Change-Id: I906cb0559afe40f0c4ab31bb44ff09135738823f
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a9f04a3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+# GoLand
+.idea
diff --git a/VERSION b/VERSION
index 4e379d2..bcab45a 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.0.2
+0.0.3
diff --git a/omci_common.go b/omci_common.go
index c878780..a140141 100644
--- a/omci_common.go
+++ b/omci_common.go
@@ -49,10 +49,26 @@
pkt, _ = GetANIGAttributes(&pos, pkt, content)
return pkt
+ case SoftwareImage:
+ pos := uint(11)
+ pkt, _ = GetSoftwareImageAttributes(&pos, pkt, content)
+ return pkt
+
+ case ONUG:
+ pos := uint(11)
+ pkt, _ = GetOnuGAttributes(&pos, pkt, content)
+ return pkt
+
+ case ONU2G:
+ pos := uint(11)
+ pkt, _ = GetOnu2GAttributes(&pos, pkt, content)
+ return pkt
+
case EthernetPMHistoryData:
pos := uint(11)
pkt, _ = GetEthernetPMHistoryDataAttributes(&pos, pkt, content)
return pkt
+
default:
// For unimplemented MEs, just fill in the attribute mask and return 0 values for the requested attributes
// TODO implement Get for unimplemented MEs as well
diff --git a/omci_defs.go b/omci_defs.go
index d84e878..90ea0af 100644
--- a/omci_defs.go
+++ b/omci_defs.go
@@ -159,10 +159,14 @@
func (c OmciClass) PrettyPrint() string {
switch c {
+ case SoftwareImage:
+ return "SoftwareImage"
case EthernetPMHistoryData:
return "EthernetPMHistoryData"
case ONUG:
return "ONUG"
+ case ONU2G:
+ return "ONU2G"
case ANIG:
return "ANIG"
case GEMPortNetworkCTP:
@@ -175,8 +179,10 @@
const (
// Managed Entity Class values
+ SoftwareImage OmciClass = 7
EthernetPMHistoryData OmciClass = 24
ONUG OmciClass = 256
+ ONU2G OmciClass = 257
ANIG OmciClass = 263
GEMPortNetworkCTP OmciClass = 268
)
diff --git a/omci_onu2g.go b/omci_onu2g.go
new file mode 100644
index 0000000..0c2329d
--- /dev/null
+++ b/omci_onu2g.go
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package core
+
+import (
+ "encoding/binary"
+)
+
+type Onu2GAttributes int
+
+const (
+ _ = iota
+ EquipmentID Onu2GAttributes = 0x8000
+ OmccVersion Onu2GAttributes = 0x4000
+ VendorProductCode Onu2GAttributes = 0x2000
+ SecurityCapability Onu2GAttributes = 0x1000
+ SecurityMode Onu2GAttributes = 0x0800
+ TotalPriorityQueueNumber Onu2GAttributes = 0x0400
+ TotalTrafficSchedulerNumber Onu2GAttributes = 0x0200
+ Mode Onu2GAttributes = 0x0100
+ TotalGemPortIDNumber Onu2GAttributes = 0x0080
+ SysUptime Onu2GAttributes = 0x0040
+ ConnectivityCapability Onu2GAttributes = 0x0020
+ CurrentConnectivityMode Onu2GAttributes = 0x0010
+ QosConfigurationFlexibility Onu2GAttributes = 0x0008
+ PriorityQueueScaleFactor Onu2GAttributes = 0x0004
+)
+
+type Onu2GAttributeHandler func(*uint, []byte) ([]byte, error)
+
+var Onu2GAttributeHandlers = map[Onu2GAttributes]Onu2GAttributeHandler{
+ EquipmentID: GetEquipmentID,
+ OmccVersion: GetOmccVersion,
+ VendorProductCode: GetVendorProductCode,
+ SecurityCapability: GetSecurityCapability,
+ SecurityMode: GetSecurityMode,
+ TotalPriorityQueueNumber: GetTotalPriorityQueueNumber,
+ TotalTrafficSchedulerNumber: GetTotalTrafficSchedulerNumber,
+ Mode: GetMode,
+ TotalGemPortIDNumber: GetTotalGemPortIDNumber,
+ SysUptime: GetSysUptime,
+ ConnectivityCapability: GetConnectivityCapability,
+ CurrentConnectivityMode: GetCurrentConnectivityMode,
+ QosConfigurationFlexibility: GetQosConfigurationFlexibility,
+ PriorityQueueScaleFactor: GetPriorityQueueScaleFactor,
+}
+
+func GetOnu2GAttributes(pos *uint, pkt []byte, content OmciContent) ([]byte, error) {
+ AttributesMask := getAttributeMask(content)
+
+ for index := uint(16); index >= 1; index-- {
+ Attribute := 1 << (index - 1)
+ reqAttribute := Attribute & AttributesMask
+
+ if reqAttribute != 0 {
+ pkt, _ = Onu2GAttributeHandlers[Onu2GAttributes(reqAttribute)](pos, pkt)
+ }
+ }
+
+ pkt[8] = 0x00 // Command Processed Successfully
+ pkt[9] = uint8(AttributesMask >> 8)
+ pkt[10] = uint8(AttributesMask & 0x00FF)
+
+ return pkt, nil
+
+}
+
+func GetEquipmentID(pos *uint, pkt []byte) ([]byte, error) {
+ // 20 bytes
+ equipid := []byte("12345123451234512345")
+ for _, ch := range equipid {
+ pkt[*pos] = ch
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetOmccVersion(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 bytes
+ pkt[*pos] = 0xB4
+ *pos++
+ return pkt, nil
+}
+
+func GetVendorProductCode(pos *uint, pkt []byte) ([]byte, error) {
+ // 2 bytes
+ prodcode := []byte{0x00, 0x00}
+ for _, ch := range prodcode {
+ pkt[*pos] = ch
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetSecurityCapability(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x01
+ *pos++
+ return pkt, nil
+}
+
+func GetSecurityMode(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x01
+ *pos++
+ return pkt, nil
+}
+
+func GetTotalPriorityQueueNumber(pos *uint, pkt []byte) ([]byte, error) {
+ // 2 bytes
+ // report 0 queues because thats what BRCM does...
+ numqueues := 0
+ bs := make([]byte, 2)
+ binary.BigEndian.PutUint16(bs, uint16(numqueues))
+ for _, ch := range bs {
+ pkt[*pos] = ch
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetTotalTrafficSchedulerNumber(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetMode(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x01
+ *pos++
+ return pkt, nil
+}
+
+func GetTotalGemPortIDNumber(pos *uint, pkt []byte) ([]byte, error) {
+ // 2 bytes
+ gemports := 32
+ bs := make([]byte, 2)
+ binary.BigEndian.PutUint16(bs, uint16(gemports))
+ for _, ch := range bs {
+ pkt[*pos] = ch
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetSysUptime(pos *uint, pkt []byte) ([]byte, error) {
+ // 4 byte int
+ uptime := 0
+ bs := make([]byte, 4)
+ binary.BigEndian.PutUint32(bs, uint32(uptime))
+ for _, ch := range bs {
+ pkt[*pos] = ch
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetConnectivityCapability(pos *uint, pkt []byte) ([]byte, error) {
+ // 2 bytes
+ caps := []byte{0x00, 0x7F}
+ for _, ch := range caps {
+ pkt[*pos] = ch
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetCurrentConnectivityMode(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetQosConfigurationFlexibility(pos *uint, pkt []byte) ([]byte, error) {
+ // 2 bytes
+ qosconf := []byte{0x00, 0x30}
+ for _, ch := range qosconf {
+ pkt[*pos] = ch
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetPriorityQueueScaleFactor(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 bytes
+ pkt[*pos] = 0x01
+ *pos++
+ return pkt, nil
+}
diff --git a/omci_onug.go b/omci_onug.go
new file mode 100644
index 0000000..1cf6b0d
--- /dev/null
+++ b/omci_onug.go
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package core
+
+type OnuGAttributes int
+
+const (
+ _ = iota
+ VendorID OnuGAttributes = 0x8000
+ Version OnuGAttributes = 0x4000
+ SerialNumber OnuGAttributes = 0x2000
+ TrafficManagementOptions OnuGAttributes = 0x1000
+ VpVcCrossConnectOptions OnuGAttributes = 0x0800
+ BatteryBackup OnuGAttributes = 0x0400
+ AdministrativeState OnuGAttributes = 0x0200
+ OperationalState OnuGAttributes = 0x0100
+ OntSurvivalTime OnuGAttributes = 0x0080
+ LogicalOnuID OnuGAttributes = 0x0040
+ LogicalPassword OnuGAttributes = 0x0020
+ CredentialsStatus OnuGAttributes = 0x0010
+ ExtendedTcLayerOptions OnuGAttributes = 0x0008
+)
+
+type OnuGAttributeHandler func(*uint, []byte) ([]byte, error)
+
+var OnuGAttributeHandlers = map[OnuGAttributes]OnuGAttributeHandler{
+ VendorID: GetVendorID,
+ Version: GetVersion,
+ SerialNumber: GetSerialNumber,
+ TrafficManagementOptions: GetTrafficManagementOptions,
+ VpVcCrossConnectOptions: GetVpVcCrossConnectOptions,
+ BatteryBackup: GetBatteryBackup,
+ AdministrativeState: GetAdministrativeState,
+ OperationalState: GetOperationalState,
+ OntSurvivalTime: GetOntSurvivalTime,
+ LogicalOnuID: GetLogicalOnuID,
+ LogicalPassword: GetLogicalPassword,
+ CredentialsStatus: GetCredentialsStatus,
+ ExtendedTcLayerOptions: GetExtendedTcLayerOptions,
+}
+
+func GetOnuGAttributes(pos *uint, pkt []byte, content OmciContent) ([]byte, error) {
+ AttributesMask := getAttributeMask(content)
+
+ for index := uint(16); index >= 1; index-- {
+ Attribute := 1 << (index - 1)
+ reqAttribute := Attribute & AttributesMask
+
+ if reqAttribute != 0 {
+ pkt, _ = OnuGAttributeHandlers[OnuGAttributes(reqAttribute)](pos, pkt)
+ }
+ }
+
+ pkt[8] = 0x00 // Command Processed Successfully
+ pkt[9] = uint8(AttributesMask >> 8)
+ pkt[10] = uint8(AttributesMask & 0x00FF)
+
+ return pkt, nil
+
+}
+
+func GetVendorID(pos *uint, pkt []byte) ([]byte, error) {
+ // 4 bytes
+ vendorid := []byte("BBSM")
+ for _, ch := range vendorid {
+ pkt[*pos] = ch
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetVersion(pos *uint, pkt []byte) ([]byte, error) {
+ // 14 bytes
+ for i := 1; i <= 14; i++ {
+ b := byte(' ')
+ pkt[*pos] = b
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetSerialNumber(pos *uint, pkt []byte) ([]byte, error) {
+ // 8 bytes
+ vendorid := []byte("BBSM")
+ serialhex := []byte{0x00, 0x00, 0x00, 0x01}
+ serialnumber := append(vendorid, serialhex...)
+ for _, ch := range serialnumber {
+ pkt[*pos] = ch
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetTrafficManagementOptions(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetVpVcCrossConnectOptions(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetBatteryBackup(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetAdministrativeState(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetOperationalState(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetOntSurvivalTime(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetLogicalOnuID(pos *uint, pkt []byte) ([]byte, error) {
+ // 24 bytes
+ for i := 1; i <= 24; i++ {
+ b := byte(' ')
+ pkt[*pos] = b
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetLogicalPassword(pos *uint, pkt []byte) ([]byte, error) {
+ // 24 bytes
+ for i := 1; i <= 24; i++ {
+ b := byte(' ')
+ pkt[*pos] = b
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetCredentialsStatus(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetExtendedTcLayerOptions(pos *uint, pkt []byte) ([]byte, error) {
+ // 2 bytes
+ tcbits := []byte{0x00, 0x00}
+ for _, ch := range tcbits {
+ pkt[*pos] = ch
+ *pos++
+ }
+ return pkt, nil
+}
diff --git a/omci_softwareimage.go b/omci_softwareimage.go
new file mode 100644
index 0000000..f0d2f9e
--- /dev/null
+++ b/omci_softwareimage.go
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package core
+
+type SoftwareImageAttributes int
+
+const (
+ _ = iota
+ SoftwareVersion SoftwareImageAttributes = 0x8000
+ IsCommited SoftwareImageAttributes = 0x4000
+ IsActive SoftwareImageAttributes = 0x2000
+ IsValid SoftwareImageAttributes = 0x1000
+ ProductCode SoftwareImageAttributes = 0x0800
+ ImageHash SoftwareImageAttributes = 0x0400
+)
+
+type SoftwareImageAttributeHandler func(*uint, []byte) ([]byte, error)
+
+var SoftwareImageAttributeHandlers = map[SoftwareImageAttributes]SoftwareImageAttributeHandler{
+ SoftwareVersion: GetSoftwareVersion,
+ IsCommited: GetIsCommited,
+ IsActive: GetIsActive,
+ IsValid: GetIsValid,
+ ProductCode: GetProductCode,
+ ImageHash: GetImageHash,
+}
+
+func GetSoftwareImageAttributes(pos *uint, pkt []byte, content OmciContent) ([]byte, error) {
+ AttributesMask := getAttributeMask(content)
+
+ for index := uint(16); index >= 1; index-- {
+ Attribute := 1 << (index - 1)
+ reqAttribute := Attribute & AttributesMask
+
+ if reqAttribute != 0 {
+ pkt, _ = SoftwareImageAttributeHandlers[SoftwareImageAttributes(reqAttribute)](pos, pkt)
+ }
+ }
+
+ pkt[8] = 0x00 // Command Processed Successfully
+ pkt[9] = uint8(AttributesMask >> 8)
+ pkt[10] = uint8(AttributesMask & 0x00FF)
+
+ return pkt, nil
+
+}
+
+func GetSoftwareVersion(pos *uint, pkt []byte) ([]byte, error) {
+ // 14 bytes
+ version := []byte("00000000000001")
+ for _, ch := range version {
+ pkt[*pos] = ch
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetIsCommited(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 bytes
+ pkt[*pos] = 0x01
+ *pos++
+ return pkt, nil
+}
+
+func GetIsActive(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 bytes
+ pkt[*pos] = 0x01
+ *pos++
+ return pkt, nil
+}
+
+func GetIsValid(pos *uint, pkt []byte) ([]byte, error) {
+ // 1 byte
+ pkt[*pos] = 0x01
+ *pos++
+ return pkt, nil
+}
+
+func GetProductCode(pos *uint, pkt []byte) ([]byte, error) {
+ // 25 bytes
+ // BRCM has 25 nulls
+ for i := 1; i <= 25; i++ {
+ pkt[*pos] = 0x00
+ *pos++
+ }
+ return pkt, nil
+}
+
+func GetImageHash(pos *uint, pkt []byte) ([]byte, error) {
+ // 16 bytes
+ // BRCM has 16 nulls
+ for i := 1; i <= 16; i++ {
+ pkt[*pos] = 0x00
+ *pos++
+ }
+ return pkt, nil
+}