Committing vendored dependencies and generated protos
Change-Id: I349c149b513d9de7d9f60bde2c954a939da2fc54
diff --git a/vendor/github.com/opencord/omci-sim/.gitreview b/vendor/github.com/opencord/omci-sim/.gitreview
new file mode 100644
index 0000000..36dffab
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.opencord.org
+port=29418
+project=omci-sim.git
+defaultremote=origin
diff --git a/vendor/github.com/opencord/omci-sim/README.md b/vendor/github.com/opencord/omci-sim/README.md
new file mode 100644
index 0000000..7183f6e
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/README.md
@@ -0,0 +1,3 @@
+# omci-sim
+
+Test
diff --git a/vendor/github.com/opencord/omci-sim/VERSION b/vendor/github.com/opencord/omci-sim/VERSION
new file mode 100644
index 0000000..c0ab82c
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/VERSION
@@ -0,0 +1 @@
+0.0.1-dev
diff --git a/vendor/github.com/opencord/omci-sim/go.mod b/vendor/github.com/opencord/omci-sim/go.mod
new file mode 100644
index 0000000..516906d
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/go.mod
@@ -0,0 +1,5 @@
+module github.com/opencord/omci-sim
+
+go 1.12
+
+require github.com/sirupsen/logrus v1.4.2
diff --git a/vendor/github.com/opencord/omci-sim/go.sum b/vendor/github.com/opencord/omci-sim/go.sum
new file mode 100644
index 0000000..46e5ef0
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/go.sum
@@ -0,0 +1,9 @@
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
+github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
+golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/vendor/github.com/opencord/omci-sim/omci_anig.go b/vendor/github.com/opencord/omci-sim/omci_anig.go
new file mode 100644
index 0000000..49734a7
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/omci_anig.go
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2018-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 AniGAttributes int
+const (
+ _ = iota
+ SRIndication AniGAttributes = 0x8000
+ TotalTcontNumber AniGAttributes = 0x4000
+ GEMBlockLength AniGAttributes = 0x2000
+ PiggybackDBAReporting AniGAttributes = 0x1000
+ WholeONTDBAReporting AniGAttributes = 0x0800
+ SFThreshold AniGAttributes = 0x0400
+ SDThreshold AniGAttributes = 0x0200
+ ARC AniGAttributes = 0x0100
+ ARCInterval AniGAttributes = 0x0080
+ OpticalSignalLevel AniGAttributes = 0x0040
+ LowerOpticalThreshold AniGAttributes = 0x0020
+ UpperOpticalThreshold AniGAttributes = 0x0010
+ ONTResponseTime AniGAttributes = 0x0008
+ TransmitOpticalLeval AniGAttributes = 0x0004
+ LowerTransmitPowerThreshold AniGAttributes = 0x0002
+ UpperTransmitPowerThreshold AniGAttributes = 0x0001
+)
+
+type ANIGAttributeHandler func(*uint, []byte) ([]byte, error)
+
+var ANIGAttributeHandlers = map[AniGAttributes]ANIGAttributeHandler{
+ SRIndication: GetSRIndication,
+ OpticalSignalLevel: GetOpticalSignalLevel,
+ LowerOpticalThreshold: GetLowerOpticalThreshold,
+ UpperOpticalThreshold: GetUpperOpticalThreshold,
+ TotalTcontNumber: GetTotalTcontNumber,
+ GEMBlockLength: GetGEMBlockLength,
+ PiggybackDBAReporting: GetPiggybackDBAReporting,
+ WholeONTDBAReporting: GetWholeONTDBAReporting,
+ SFThreshold: GetSFThreshold,
+ SDThreshold: GetSDThreshold,
+ ARC: GetARC,
+ ARCInterval: GetARCInterval,
+ ONTResponseTime: GetONTResponseTime,
+ TransmitOpticalLeval: GetTransmitOpticalLeval,
+ LowerTransmitPowerThreshold: GetLowerTransmitPowerThreshold,
+ UpperTransmitPowerThreshold: GetUpperTransmitPowerThreshold,
+}
+
+
+func GetANIGAttributes(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, _ = ANIGAttributeHandlers[AniGAttributes(reqAttribute)](pos, pkt)
+ }
+ }
+
+ pkt[8] = 0x00 // Command Processed Successfully
+ pkt[9] = uint8(AttributesMask >> 8)
+ pkt[10] = uint8(AttributesMask & 0x00FF)
+
+ return pkt, nil
+
+}
+
+
+func GetSRIndication(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x01
+ *pos++
+ return pkt, nil
+}
+
+func GetOpticalSignalLevel(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0xd7
+ *pos++
+ pkt[*pos] = 0xa9
+ *pos++
+ return pkt, nil
+}
+
+func GetTotalTcontNumber(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x08
+ *pos++
+ return pkt, nil
+}
+
+func GetGEMBlockLength(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x00
+ *pos++
+ pkt[*pos] = 0x30
+ return pkt, nil
+}
+
+func GetPiggybackDBAReporting (pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetWholeONTDBAReporting(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetUpperOpticalThreshold(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0xff
+ *pos++
+ return pkt, nil
+}
+
+func GetSFThreshold(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x03
+ *pos++
+ return pkt, nil
+}
+
+func GetSDThreshold(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x05
+ *pos++
+ return pkt, nil
+}
+
+func GetARC(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetARCInterval(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetONTResponseTime(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x00
+ *pos++
+ pkt[*pos] = 0x00
+ *pos++
+ return pkt, nil
+}
+
+func GetLowerOpticalThreshold(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0xff
+ *pos++
+ return pkt, nil
+}
+
+func GetTransmitOpticalLeval(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x07
+ *pos++
+ pkt[*pos] = 0x1e
+ *pos++
+ return pkt, nil
+}
+
+func GetLowerTransmitPowerThreshold(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x81
+ *pos++
+ return pkt, nil
+}
+
+func GetUpperTransmitPowerThreshold(pos *uint, pkt []byte) ([]byte, error) {
+ pkt[*pos] = 0x81
+ *pos++
+ return pkt, nil
+}
diff --git a/vendor/github.com/opencord/omci-sim/omci_common.go b/vendor/github.com/opencord/omci-sim/omci_common.go
new file mode 100644
index 0000000..c878780
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/omci_common.go
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2018-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 (
+ "fmt"
+ log "github.com/sirupsen/logrus"
+)
+
+type OmciError struct {
+ Msg string
+}
+
+func (e *OmciError) Error() string {
+ return fmt.Sprintf("%s", e.Msg)
+}
+
+type OnuKey struct {
+ IntfId, OnuId uint32
+}
+
+func (k OnuKey) String() string {
+ return fmt.Sprintf("Onu {intfid:%d, onuid:%d}", k.IntfId, k.OnuId)
+}
+
+func GetAttributes(class OmciClass, content OmciContent, key OnuKey, pkt []byte) []byte {
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("GetAttributes() invoked")
+
+ switch class {
+ case ANIG:
+ pos := uint(11)
+ pkt, _ = GetANIGAttributes(&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
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ "class": class,
+ }).Tracef("Unimplemeted GetAttributes for ME Class: %v " +
+ "Filling with zero value for the requested attributes", class)
+ AttributesMask := getAttributeMask(content)
+ pkt[8] = 0x00 // Command Processed Successfully
+ pkt[9] = uint8(AttributesMask >> 8)
+ pkt[10] = uint8(AttributesMask & 0xFF)
+
+ return pkt
+ }
+}
+
+func getAttributeMask(content OmciContent) int {
+ // mask is present in pkt[8] and pkt[9]
+ log.WithFields(log.Fields{
+ "content[0]": content[0],
+ "content[1]": content[1],
+ }).Tracef("GetAttributeMask() invoked")
+ return (int(content[0]) << 8) | int(content[1])
+}
diff --git a/vendor/github.com/opencord/omci-sim/omci_defs.go b/vendor/github.com/opencord/omci-sim/omci_defs.go
new file mode 100644
index 0000000..44347ef
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/omci_defs.go
@@ -0,0 +1,224 @@
+/*
+ * Copyright 2018-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 (
+ "bytes"
+ "encoding/binary"
+ "errors"
+ "fmt"
+ log "github.com/sirupsen/logrus"
+)
+
+// OMCI Sim definitions
+
+type ChMessageType int
+
+const (
+ GemPortAdded ChMessageType = iota
+)
+
+func (m ChMessageType) String() string {
+ names := [...]string{
+ "GemPortAdded",
+ }
+ return names[m]
+}
+
+type OmciChMessageData struct {
+ IntfId uint32
+ OnuId uint32
+}
+
+type OmciChMessage struct {
+ Type ChMessageType
+ Data OmciChMessageData
+}
+
+//
+// OMCI definitions
+//
+
+// OmciMsgType represents a OMCI message-type
+type OmciMsgType byte
+
+func (t OmciMsgType) PrettyPrint() string {
+ switch t {
+ case Create:
+ return "Create"
+ case Delete:
+ return "Delete"
+ case Set:
+ return "Set"
+ case Get:
+ return "Get"
+ case GetAllAlarms:
+ return "GetAllAlarms"
+ case GetAllAlarmsNext:
+ return "GetAllAlarmsNext"
+ case MibUpload:
+ return "MibUpload"
+ case MibUploadNext:
+ return "MibUploadNext"
+ case MibReset:
+ return "MibReset"
+ case AlarmNotification:
+ return "AlarmNotification"
+ case AttributeValueChange:
+ return "AttributeValueChange"
+ case Test:
+ return "Test"
+ case StartSoftwareDownload:
+ return "StartSoftwareDownload"
+ case DownloadSection:
+ return "DownloadSection"
+ case EndSoftwareDownload:
+ return "EndSoftwareDownload"
+ case ActivateSoftware:
+ return "ActivateSoftware"
+ case CommitSoftware:
+ return "CommitSoftware"
+ case SynchronizeTime:
+ return "SynchronizeTime"
+ case Reboot:
+ return "Reboot"
+ case GetNext:
+ return "GetNext"
+ case TestResult:
+ return "TestResult"
+ case GetCurrentData:
+ return "GetCurrentData"
+ case SetTable:
+ return "SetTable"
+ default:
+ // FIXME
+ // msg="Cant't convert state 68 to string"
+ // msg="Cant't convert state 72 to string"
+ // msg="Cant't convert state 73 to string"
+ // msg="Cant't convert state 75 to string"
+ // msg="Cant't convert state 76 to string"
+ // msg="Cant't convert state 77 to string"
+ // msg="Cant't convert state 78 to string"
+ // msg="Cant't convert state 79 to string"
+ // msg="Cant't convert state 88 to string"
+
+ log.Tracef("Cant't convert OmciMsgType %v to string", t)
+ return string(t)
+ }
+}
+
+const (
+ // Message Types
+ _ = iota
+ Create OmciMsgType = 4
+ Delete OmciMsgType = 6
+ Set OmciMsgType = 8
+ Get OmciMsgType = 9
+ GetAllAlarms OmciMsgType = 11
+ GetAllAlarmsNext OmciMsgType = 12
+ MibUpload OmciMsgType = 13
+ MibUploadNext OmciMsgType = 14
+ MibReset OmciMsgType = 15
+ AlarmNotification OmciMsgType = 16
+ AttributeValueChange OmciMsgType = 17
+ Test OmciMsgType = 18
+ StartSoftwareDownload OmciMsgType = 19
+ DownloadSection OmciMsgType = 20
+ EndSoftwareDownload OmciMsgType = 21
+ ActivateSoftware OmciMsgType = 22
+ CommitSoftware OmciMsgType = 23
+ SynchronizeTime OmciMsgType = 24
+ Reboot OmciMsgType = 25
+ GetNext OmciMsgType = 26
+ TestResult OmciMsgType = 27
+ GetCurrentData OmciMsgType = 28
+ SetTable OmciMsgType = 29 // Defined in Extended Message Set Only
+)
+
+
+// OMCI Managed Entity Class
+type OmciClass uint16
+
+func (c OmciClass) PrettyPrint() string {
+ switch c {
+ case EthernetPMHistoryData:
+ return "EthernetPMHistoryData"
+ case ONUG:
+ return "ONUG"
+ case ANIG:
+ return "ANIG"
+ case GEMPortNetworkCTP:
+ return "GEMPortNetworkCTP"
+ default:
+ log.Tracef("Cant't convert OmciClass %v to string", c)
+ return string(c)
+ }
+}
+
+const (
+ // Managed Entity Class values
+ EthernetPMHistoryData OmciClass = 24
+ ONUG OmciClass = 256
+ ANIG OmciClass = 263
+ GEMPortNetworkCTP OmciClass = 268
+)
+
+// OMCI Message Identifier
+type OmciMessageIdentifier struct {
+ Class OmciClass
+ Instance uint16
+}
+
+type OmciContent [32]byte
+
+type OmciMessage struct {
+ TransactionId uint16
+ MessageType OmciMsgType
+ DeviceId uint8
+ MessageId OmciMessageIdentifier
+ Content OmciContent
+}
+
+func ParsePkt(pkt []byte) (uint16, uint8, OmciMsgType, OmciClass, uint16, OmciContent, error) {
+ var m OmciMessage
+
+ r := bytes.NewReader(pkt)
+
+ if err := binary.Read(r, binary.BigEndian, &m); err != nil {
+ log.WithFields(log.Fields{
+ "Packet": pkt,
+ "omciMsg": fmt.Sprintf("%x", pkt),
+ }).Errorf("Failed to read packet: %s", err)
+ return 0, 0, 0, 0, 0, OmciContent{}, errors.New("Failed to read packet")
+ }
+ /* Message Type = Set
+ 0... .... = Destination Bit: 0x0
+ .1.. .... = Acknowledge Request: 0x1
+ ..0. .... = Acknowledgement: 0x0
+ ...0 1000 = Message Type: Set (8)
+ */
+
+ log.WithFields(log.Fields{
+ "TransactionId": m.TransactionId,
+ "MessageType": m.MessageType.PrettyPrint(),
+ "MeClass": m.MessageId.Class,
+ "MeInstance": m.MessageId.Instance,
+ "Conent": m.Content,
+ "Packet": pkt,
+ }).Tracef("Parsing OMCI Packet")
+
+ return m.TransactionId, m.DeviceId, m.MessageType & 0x1F, m.MessageId.Class, m.MessageId.Instance, m.Content, nil
+}
diff --git a/vendor/github.com/opencord/omci-sim/omci_handlers.go b/vendor/github.com/opencord/omci-sim/omci_handlers.go
new file mode 100644
index 0000000..67a57e7
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/omci_handlers.go
@@ -0,0 +1,566 @@
+/*
+ * Copyright 2018-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"
+ "errors"
+ "fmt"
+ log "github.com/sirupsen/logrus"
+)
+
+type OmciMsgHandler func(class OmciClass, content OmciContent, key OnuKey) ([]byte, error)
+
+var Handlers = map[OmciMsgType]OmciMsgHandler{
+ MibReset: mibReset,
+ MibUpload: mibUpload,
+ MibUploadNext: mibUploadNext,
+ Set: set,
+ Create: create,
+ Get: get,
+ GetAllAlarms: getAllAlarms,
+ GetAllAlarmsNext: getAllAlarmsNext,
+ SynchronizeTime: syncTime,
+ Delete: delete,
+ Reboot: reboot,
+}
+
+func mibReset(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
+ var pkt []byte
+
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("Omci MibReset")
+ OnuOmciStateMapLock.RLock()
+ if state, ok := OnuOmciStateMap[key]; ok {
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("Reseting OnuOmciState")
+ state.ResetOnuOmciState()
+ }
+ OnuOmciStateMapLock.RUnlock()
+
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ return pkt, nil
+}
+
+func mibUpload(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
+ var pkt []byte
+
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("Omci MibUpload")
+
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+ pkt[8] = NumMibUploadsHigherByte
+ pkt[9] = NumMibUploadsLowerByte
+
+ return pkt, nil
+}
+
+func mibUploadNext(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
+ var pkt []byte
+ OnuOmciStateMapLock.RLock()
+ state := OnuOmciStateMap[key]
+ OnuOmciStateMapLock.RUnlock()
+ // commandNumber is the "Command number" attribute received in "MIB Upload Next" OMCI message
+ commandNumber := (uint16(content[1])) | (uint16(content[0])<<8)
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ "CommandNumber": commandNumber,
+ }).Tracef("Omci MibUploadNext")
+
+ switch commandNumber {
+ case 0:
+ // ONT Data (2)
+ // log.Println("ONT DATA")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ case 1:
+ // Circuit Pack (6) - #1
+ // log.Println("Circuit Pack")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x06, 0x01, 0x01, 0xf0, 0x00, 0x2f, 0x04,
+ 0x49, 0x53, 0x4b, 0x54, 0x71, 0xe8, 0x00, 0x80,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ case 2:
+ // Circuit Pack (6) - #2
+ // log.Println("Circuit Pack")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x06, 0x01, 0x01, 0x0f, 0x00, 0x42, 0x52,
+ 0x43, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ case 3:
+ // Circuit Pack (6) - #3
+ // log.Println("Circuit Pack")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x06, 0x01, 0x01, 0x00, 0xf8, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ case 4:
+ // Circuit Pack (6) - #4
+ // log.Println("Circuit Pack")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x06, 0x01, 0x01, 0x00, 0x04, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ case 5:
+ // Circuit Pack (6) - #5
+ // log.Println("Circuit Pack")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x06, 0x01, 0x80, 0xf0, 0x00, 0xee, 0x01,
+ 0x49, 0x53, 0x4b, 0x54, 0x71, 0xe8, 0x00, 0x80,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ case 6:
+ // Circuit Pack (6) - #6
+ // log.Println("Circuit Pack")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x06, 0x01, 0x80, 0x0f, 0x00, 0x42, 0x52,
+ 0x43, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ case 7:
+ // Circuit Pack (6) - #7
+ // log.Println("Circuit Pack")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x06, 0x01, 0x80, 0x00, 0xf8, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x00, 0x08, 0x40, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ case 8:
+ // Circuit Pack (6) - #8
+ // log.Println("Circuit Pack")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x06, 0x01, 0x80, 0x00, 0x04, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ case 9, 10, 11, 12:
+ // PPTP (11)
+ // log.Println("PPTP")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x0b, 0x01, 0x01, 0xff, 0xfe, 0x00, 0x2f,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x05, 0xee, 0x00,
+ 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ pkt[11] = state.pptpInstance // ME Instance
+ state.pptpInstance++
+ case 13, 14, 15, 16, 17, 18, 19, 20:
+ // T-CONT (262)
+ // log.Println("T-CONT")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x01, 0x06, 0x80, 0x00, 0xe0, 0x00, 0xff, 0xff,
+ 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+ state.tcontInstance++
+ pkt[11] = state.tcontInstance // TCONT ME Instance
+
+ case 21:
+ // ANI-G (263)
+ // log.Println("ANI-G")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x01, 0x07, 0x80, 0x01, 0xff, 0xff, 0x01, 0x00,
+ 0x08, 0x00, 0x30, 0x00, 0x00, 0x05, 0x09, 0x00,
+ 0x00, 0xe0, 0x54, 0xff, 0xff, 0x00, 0x00, 0x0c,
+ 0x63, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ case 22, 23, 24, 25:
+ // UNI-G (264)
+ // log.Println("UNI-G")
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x01, 0x08, 0x01, 0x01, 0xf8, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ pkt[11] = state.uniGInstance // UNI-G ME Instance
+ state.uniGInstance++
+
+ case 26, 30, 34, 38, 42, 46, 50, 54,
+ 58, 62, 66, 70, 74, 78, 82, 86,
+ 90, 94, 98, 102, 106, 110, 114, 118,
+ 122, 126, 130, 134, 138, 142, 146, 150,
+ 154, 158, 162, 166, 170, 174, 178, 182,
+ 186, 190, 194, 198, 202, 206, 210, 214,
+ 218, 222, 226, 230, 234, 238, 242, 246,
+ 250, 254, 258, 262, 266, 270, 274, 278:
+ // Prior-Q with mask downstream
+ log.Tracef("Mib-upload for prior-q with mask")
+ // For downstream PQ, pkt[10] is 0x00
+ // So the instanceId will be like 0x0001, 0x0002,... etc
+ pkt = []byte{
+ 0x00, 0x42, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
+ 0x01, 0x15, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ }
+ state.priorQInstance++
+ pkt[11] = state.priorQInstance
+
+ case 27, 31, 35, 39, 43, 47, 51, 55,
+ 59, 63, 67, 71, 75, 79, 83, 87,
+ 91, 95, 99, 103, 107, 111, 115, 119,
+ 123, 127, 131, 135, 139, 143, 147, 151,
+ 155, 159, 163, 167, 171, 175, 179, 183,
+ 187, 191, 195, 199, 203, 207, 211, 215,
+ 219, 223, 227, 231, 235, 239, 243, 247,
+ 251, 255, 259, 263, 267, 271, 275, 279:
+ // Prior-Q with attribute list downstream
+ // log.Println("Mib-upload for prior-q with attribute list")
+ pkt = []byte{
+ 0x00, 0x43, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
+ 0x01, 0x15, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x01,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x20, 0x00, 0x00, 0x01, 0x20, 0x01, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ }
+
+ pkt[11] = state.priorQInstance
+
+ // Group 8 PriorQ to point to a particular TCONT
+ // Priority for each group of PriorQ is 0 - 7
+ if state.priorQPriority % NumPriorQPerTcont == 0 {
+ state.tcontPointer++
+ }
+
+ // Only for verification. To be removed
+ if state.tcontPointer > state.tcontInstance {
+ log.Tracef("Error: Invalid TcontPointer")
+ break
+ }
+
+ pkt[24] = state.tcontPointer
+ pkt[26] = state.priorQPriority % NumPriorQPerTcont
+ pkt[28] = state.tcontInstance
+
+ case 28, 32, 36, 40, 44, 48, 52, 56,
+ 60, 64, 68, 72, 76, 80, 84, 88,
+ 92, 96, 100, 104, 108, 112, 116, 120,
+ 124, 128, 132, 136, 140, 144, 148, 152,
+ 156, 160, 164, 168, 172, 176, 180, 184,
+ 188, 192, 196, 200, 204, 208, 212, 216,
+ 220, 224, 228, 232, 236, 240, 244, 248,
+ 252, 256, 260, 264, 268, 272, 276, 280:
+ // Prior-Q with mask upstream
+ // log.Println("Mib-upload for prior-q with mask")
+ pkt = []byte{
+ 0x00, 0x42, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
+ 0x01, 0x15, 0x80, 0x00, 0x00, 0x0f, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ }
+ pkt[11] = state.priorQInstance
+
+ case 29, 33, 37, 41, 45, 49, 53, 57,
+ 61, 65, 69, 73, 77, 81, 85, 89,
+ 93, 97, 101, 105, 109, 113, 117, 121,
+ 125, 129, 133, 137, 141, 145, 149, 153,
+ 157, 161, 165, 169, 173, 177, 181, 185,
+ 189, 193, 197, 201, 205, 209, 213, 217,
+ 221, 225, 229, 233, 237, 241, 245, 249,
+ 253, 257, 261, 265, 269, 273, 277, 281:
+ // Prior-Q with attribute list upstream
+ // log.Println("Mib-upload for prior-q with attribute list")
+ // For upstream pkt[10] is fixed as 80
+ // So for upstream PQ, instanceId will be like 0x8001, 0x8002 ... etc
+ pkt = []byte{
+ 0x00, 0x43, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
+ 0x01, 0x15, 0x80, 0x00, 0xff, 0xf0, 0x00, 0x01,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0x20, 0x00, 0x00, 0x80, 0x20, 0x01, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ }
+
+ pkt[11] = state.priorQInstance
+ pkt[24] = state.tcontPointer
+ pkt[26] = state.priorQPriority % NumPriorQPerTcont // Priority of this PriorQ
+ pkt[28] = state.tcontInstance
+ state.priorQPriority++
+
+
+ case 282, 283, 284, 285, 286, 287, 288, 289:
+ // Traffic Scheduler
+ // log.Println("Traffic Scheduler")
+ pkt = []byte{
+ 0x02, 0xa4, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
+ 0x01, 0x16, 0x80, 0x00, 0xf0, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ }
+
+ pkt[15] = state.tcontInstance
+ state.tcontInstance++
+
+ case 290:
+ // ONT-2G
+ // log.Println("ONT-2G")
+ pkt = []byte{
+ 0x00, 0x16, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
+ 0x01, 0x01, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x40,
+ 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x7f, 0x00, 0x00, 0x3f, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ }
+
+ default:
+ state.extraMibUploadCtr++
+ errstr := fmt.Sprintf("%v - Invalid MibUpload request: %d, extras: %d", key, state.mibUploadCtr, state)
+ return nil, errors.New(errstr)
+ }
+
+ state.mibUploadCtr++
+ return pkt, nil
+}
+
+func set(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
+ var pkt []byte
+
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("Omci Set")
+
+ return pkt, nil
+}
+
+func create(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
+ var pkt []byte
+
+ if class == GEMPortNetworkCTP {
+ OnuOmciStateMapLock.RLock()
+ defer OnuOmciStateMapLock.RUnlock()
+ if onuOmciState, ok := OnuOmciStateMap[key]; !ok {
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("ONU Key Error")
+ return nil, errors.New("ONU Key Error")
+ } else {
+ onuOmciState.gemPortId = binary.BigEndian.Uint16(content[:2])
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("Gem Port Id %d", key, onuOmciState)
+ // FIXME
+ OnuOmciStateMap[key].state = DONE
+ omciCh <- OmciChMessage{
+ Type: GemPortAdded,
+ Data: OmciChMessageData{
+ OnuId: key.OnuId,
+ IntfId: key.IntfId,
+ },
+ }
+ }
+ }
+
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("Omci Create")
+
+ return pkt, nil
+}
+
+func get(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
+ var pkt []byte
+
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x02, 0x01,
+ 0x00, 0x20, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+ pkt = GetAttributes(class, content, key, pkt)
+
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("Omci Get")
+ return pkt, nil
+}
+
+func getAllAlarms(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
+ var pkt []byte
+
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("Omci GetAllAlarms")
+
+ return pkt, nil
+}
+
+func syncTime(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
+ var pkt []byte
+
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("Omci syncTime")
+
+ return pkt, nil
+}
+
+func getAllAlarmsNext(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
+ var pkt []byte
+
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("Omci GetAllAlarmsNext")
+
+ return pkt, nil
+}
+
+func delete(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
+ var pkt []byte
+
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0b, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("Omci Delete")
+
+ return pkt, nil
+}
+
+func reboot(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
+ var pkt []byte
+ pkt = []byte{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+ log.WithFields(log.Fields{
+ "IntfId": key.IntfId,
+ "OnuId": key.OnuId,
+ }).Tracef("Omci Reboot")
+ return pkt, nil
+}
+
diff --git a/vendor/github.com/opencord/omci-sim/omci_mib.go b/vendor/github.com/opencord/omci-sim/omci_mib.go
new file mode 100644
index 0000000..b8d2cdc
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/omci_mib.go
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2018-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
+
+const NumMibUploadsHigherByte byte = 0x01
+const NumMibUploadsLowerByte byte = 0x23
+const NumPriorQPerTcont = 0x08 // NumPriorQPerTcont is the number of priority queues associated with a single tcont
+
diff --git a/vendor/github.com/opencord/omci-sim/omci_pm_history_data.go b/vendor/github.com/opencord/omci-sim/omci_pm_history_data.go
new file mode 100644
index 0000000..60ddd80
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/omci_pm_history_data.go
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2018-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 PerformanceMonitoringHistoryData int
+
+const (
+ _ = iota
+ IntervalEndTime PerformanceMonitoringHistoryData = 0x8000
+ ThresholdDataId PerformanceMonitoringHistoryData = 0x4000
+ FCSErrors PerformanceMonitoringHistoryData = 0x2000
+ ExcessiveCollisionCounter PerformanceMonitoringHistoryData = 0x1000
+ LateCollisionCounter PerformanceMonitoringHistoryData = 0x0800
+ FrameTooLong PerformanceMonitoringHistoryData = 0x0400
+ BufferOverflowOnReceive PerformanceMonitoringHistoryData = 0x0200
+ BufferOverflowOnTransmit PerformanceMonitoringHistoryData = 0x0100
+ SingleCollisionFrameCounter PerformanceMonitoringHistoryData = 0x0080
+ MultipleCollisionFrameCounter PerformanceMonitoringHistoryData = 0x0040
+ SQECounter PerformanceMonitoringHistoryData = 0x0020
+ DeferredTransmissionCounter PerformanceMonitoringHistoryData = 0x0010
+ InternalMACTransmitErrorCounter PerformanceMonitoringHistoryData = 0x0008
+ CarrierSenseErrorCounter PerformanceMonitoringHistoryData = 0x0004
+ AllignmentErrorCounter PerformanceMonitoringHistoryData = 0x0002
+ InternalMACReceiveErrorCounter PerformanceMonitoringHistoryData = 0x0001
+)
+
+type PMHistoryAttributeHandler func(*uint, []byte) ([]byte, error)
+
+var PMHistoryAttributeHandlers = map[PerformanceMonitoringHistoryData]ANIGAttributeHandler{
+ IntervalEndTime : GetIntervalEndTime,
+ ThresholdDataId: GetThresholdDataId,
+ FCSErrors: GetFCSErrors,
+ ExcessiveCollisionCounter: GetExcessiveCollisionCounter,
+ LateCollisionCounter: GetLateCollisionCounter,
+ FrameTooLong: GetFrameTooLong,
+ BufferOverflowOnReceive: GetBufferOverflowOnReceive,
+ BufferOverflowOnTransmit: GetBufferOverflowOnTransmit,
+ SingleCollisionFrameCounter: GetSingleCollisionFrameCounter,
+ MultipleCollisionFrameCounter: GetMultipleCollisionFrameCounter,
+ SQECounter: GetSQECounter,
+ DeferredTransmissionCounter: GetDeferredTransmissionCounter,
+ InternalMACTransmitErrorCounter: GetInternalMACTransmitErrorCounter,
+ CarrierSenseErrorCounter: GetCarrierSenseErrorCounter,
+ AllignmentErrorCounter: GetAllignmentErrorCounter,
+ InternalMACReceiveErrorCounter: GetInternalMACReceiveErrorCounter,
+}
+
+func GetEthernetPMHistoryDataAttributes(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, _ = PMHistoryAttributeHandlers[PerformanceMonitoringHistoryData(reqAttribute)](pos, pkt)
+ }
+ }
+
+ pkt[8] = 0x00 // Command Processed Successfully
+ pkt[9] = uint8(AttributesMask >> 8)
+ pkt[10] = uint8(AttributesMask & 0x00FF)
+
+ return pkt, nil
+
+}
+
+func GetIntervalEndTime(pos *uint, pkt []byte) ([]byte, error) {
+ // With the hardware, it is seen that all attributes are 0x00
+ // Nevertheless these functions are made to provide specific values in future if required
+ *pos++
+ return pkt, nil
+}
+
+func GetThresholdDataId(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetFCSErrors(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetExcessiveCollisionCounter(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetLateCollisionCounter(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetFrameTooLong(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetBufferOverflowOnReceive(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetBufferOverflowOnTransmit(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetSingleCollisionFrameCounter(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetMultipleCollisionFrameCounter(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetSQECounter(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetDeferredTransmissionCounter(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetInternalMACTransmitErrorCounter(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetCarrierSenseErrorCounter(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetAllignmentErrorCounter(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+func GetInternalMACReceiveErrorCounter(pos *uint, pkt []byte) ([]byte, error) {
+ *pos++
+ *pos++
+ *pos++
+ *pos++
+ return pkt, nil
+}
+
+
diff --git a/vendor/github.com/opencord/omci-sim/omci_sim.go b/vendor/github.com/opencord/omci-sim/omci_sim.go
new file mode 100644
index 0000000..a792911
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/omci_sim.go
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2018-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 (
+ "fmt"
+ log "github.com/sirupsen/logrus"
+)
+
+var omciCh = make(chan OmciChMessage)
+
+func GetChannel() chan OmciChMessage {
+ return omciCh
+}
+
+func OmciSim(intfId uint32, onuId uint32, request []byte) ([]byte, error) {
+ var resp []byte
+
+ transactionId, deviceId, msgType, class, instance, content, err := ParsePkt(request)
+ if err != nil {
+ log.WithFields(log.Fields{
+ "IntfId": intfId,
+ "OnuId": onuId,
+ }).Errorf("Cannot parse OMCI msg")
+ return resp, &OmciError{"Cannot parse OMCI msg"}
+ }
+
+ log.WithFields(log.Fields{
+ "IntfId": intfId,
+ "OnuId": onuId,
+ "TransactionId": transactionId,
+ "MessageType": msgType.PrettyPrint(),
+ "MeClass": class,
+ "MeInstance": instance,
+ //"Conent": content,
+ "omciMsg": fmt.Sprintf("%x", content),
+ }).Tracef("Processing OMCI pakcet")
+
+ key := OnuKey{intfId, onuId}
+ OnuOmciStateMapLock.Lock()
+ if _, ok := OnuOmciStateMap[key]; !ok {
+ OnuOmciStateMap[key] = NewOnuOmciState()
+ }
+ OnuOmciStateMapLock.Unlock()
+
+ if _, ok := Handlers[msgType]; !ok {
+ log.WithFields(log.Fields{
+ "IntfId": intfId,
+ "OnuId": onuId,
+ "msgType": msgType,
+ }).Errorf("Ignoring omci msg (msgType %d not handled)", msgType)
+ return resp, &OmciError{"Unimplemented omci msg"}
+ }
+
+ resp, err = Handlers[msgType](class, content, key)
+ if err != nil {
+ log.WithFields(log.Fields{
+ "IntfId": intfId,
+ "OnuId": onuId,
+ "msgType": msgType,
+ }).Errorf("Unable to send a successful response, error: %s", err)
+ return resp, nil
+ }
+
+ // In the OMCI message, first 2-bytes is the Transaction Correlation ID
+ resp[0] = byte(transactionId >> 8)
+ resp[1] = byte(transactionId & 0xFF)
+ resp[2] = 0x2<<4 | byte(msgType) // Upper nibble 0x2 is fixed (0010), Lower nibbles defines the msg type (i.e., mib-upload, mib-upload-next, etc)
+ resp[3] = deviceId
+
+ // for create, get and set
+ if ((msgType & 0xFF) != MibUploadNext) && ((msgType & 0xFF) != MibReset) && ((msgType & 0xFF) != MibUpload) {
+ // Common fields for create, get, and set
+ resp[4] = byte(class >> 8)
+ resp[5] = byte(class & 0xFF)
+ resp[6] = byte(instance >> 8)
+ resp[7] = byte(instance & 0xFF)
+ resp[8] = 0 // Result: Command Processed Successfully
+
+ // Hardcoding class specific values for Get
+ if (class == 0x82) && ((msgType & 0x0F) == Get) {
+ resp[9] = 0
+ resp[10] = 0x78
+
+ } else if (class == 0x2F) && ((msgType & 0x0F) == Get) {
+ resp[9] = 0x0F
+ resp[10] = 0xB8
+ } else if (class == 0x138) && ((msgType & 0x0F) == Get) {
+ resp[9] = content[0] // 0xBE
+ resp[10] = 0x00
+ }
+ }
+
+ log.WithFields(log.Fields{
+ "IntfId": intfId,
+ "OnuId": onuId,
+ "msgType": msgType.PrettyPrint(),
+ "omciMsg": fmt.Sprintf("%x", resp),
+ }).Tracef("OMCI-SIM Response")
+
+ return resp, nil
+}
diff --git a/vendor/github.com/opencord/omci-sim/omci_state.go b/vendor/github.com/opencord/omci-sim/omci_state.go
new file mode 100644
index 0000000..eb923ba
--- /dev/null
+++ b/vendor/github.com/opencord/omci-sim/omci_state.go
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2018-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 (
+ "errors"
+ "fmt"
+ "sync"
+ log "github.com/sirupsen/logrus"
+)
+
+type OnuOmciState struct {
+ gemPortId uint16
+ mibUploadCtr uint16
+ extraMibUploadCtr uint16 // this is only for debug purposes, will be removed in the future
+ uniGInstance uint8
+ tcontInstance uint8
+ pptpInstance uint8
+ priorQInstance uint8 // To assign incrementing value to PQ instance-Id
+ priorQPriority uint8 // Priority of the PriorityQueueG (0-7)
+ tcontPointer uint8 // Tcont Pointer for PriorQ
+ state istate
+}
+
+type istate int
+
+// TODO - Needs to reflect real ONU/OMCI state
+const (
+ INCOMPLETE istate = iota
+ DONE
+)
+
+var OnuOmciStateMap = map[OnuKey]*OnuOmciState{}
+var OnuOmciStateMapLock = sync.RWMutex{}
+
+func NewOnuOmciState() *OnuOmciState {
+ return &OnuOmciState{gemPortId: 0, mibUploadCtr: 0, uniGInstance: 1, tcontInstance: 0, pptpInstance: 1}
+}
+func (s *OnuOmciState) ResetOnuOmciState() {
+ // Resetting the counters
+ s.mibUploadCtr = 0
+ s.extraMibUploadCtr = 0
+ s.gemPortId = 0
+ s.uniGInstance = 1
+ s.tcontInstance = 0
+ s.pptpInstance = 1
+ s.tcontPointer = 0
+ s.priorQPriority = 0
+}
+func GetOnuOmciState(intfId uint32, onuId uint32) istate {
+ key := OnuKey{intfId, onuId}
+ OnuOmciStateMapLock.RLock()
+ defer OnuOmciStateMapLock.RUnlock()
+ if onu, ok := OnuOmciStateMap[key]; ok {
+ return onu.state
+ } else {
+ return INCOMPLETE
+ }
+}
+
+func GetGemPortId(intfId uint32, onuId uint32) (uint16, error) {
+ key := OnuKey{intfId, onuId}
+ OnuOmciStateMapLock.RLock()
+ defer OnuOmciStateMapLock.RUnlock()
+ if OnuOmciState, ok := OnuOmciStateMap[key]; ok {
+ if OnuOmciState.state != DONE {
+ errmsg := fmt.Sprintf("ONU {intfid:%d, onuid:%d} - Not DONE (GemportID is not set)", intfId, onuId)
+ return 0, errors.New(errmsg)
+ }
+ return OnuOmciState.gemPortId, nil
+ }
+ errmsg := fmt.Sprintf("ONU {intfid:%d, onuid:%d} - Failed to find a key in OnuOmciStateMap", intfId, onuId)
+ return 0, errors.New(errmsg)
+}
+
+func CheckIsTeo() string {
+ log.Warn("It's TEO!")
+ return "It's TEO!"
+}