VOL-3835: Add support for reporting L2 PM counters

Change-Id: Ibe64b94d442b7ce83965824beb18d0a281c64a6b
diff --git a/internal/common/omci/sync_time.go b/internal/common/omci/sync_time.go
new file mode 100644
index 0000000..a5e6474
--- /dev/null
+++ b/internal/common/omci/sync_time.go
@@ -0,0 +1,74 @@
+/*
+ * 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 omci
+
+import (
+	"errors"
+	"github.com/google/gopacket"
+	"github.com/opencord/omci-lib-go"
+	me "github.com/opencord/omci-lib-go/generated"
+	log "github.com/sirupsen/logrus"
+)
+
+func ParseSyncTimeRequest(omciPkt gopacket.Packet) (*omci.SynchronizeTimeRequest, error) {
+	msgLayer := omciPkt.Layer(omci.LayerTypeSynchronizeTimeRequest)
+	if msgLayer == nil {
+		err := "omci Msg layer could not be detected for LayerTypeSynchronizeTimeRequest"
+		omciLogger.Error(err)
+		return nil, errors.New(err)
+	}
+	msgObj, msgOk := msgLayer.(*omci.SynchronizeTimeRequest)
+	if !msgOk {
+		err := "omci Msg layer could not be assigned for LayerTypeSynchronizeTimeRequest"
+		omciLogger.Error(err)
+		return nil, errors.New(err)
+	}
+	return msgObj, nil
+}
+
+func CreateSyncTimeResponse(omciPkt gopacket.Packet, omciMsg *omci.OMCI) ([]byte, error) {
+
+	msgObj, err := ParseSyncTimeRequest(omciPkt)
+
+	if err != nil {
+		return nil, err
+	}
+
+	omciLogger.WithFields(log.Fields{
+		"EntityClass":    msgObj.EntityClass,
+		"EntityInstance": msgObj.EntityInstance,
+	}).Trace("received-omci-sync-time-request")
+
+	response := &omci.SynchronizeTimeResponse{
+		MeBasePacket: omci.MeBasePacket{
+			EntityClass:    msgObj.EntityClass,
+			EntityInstance: msgObj.EntityInstance,
+		},
+		Result: me.Success,
+	}
+
+	pkt, err := Serialize(omci.SynchronizeTimeResponseType, response, omciMsg.TransactionID)
+	if err != nil {
+		omciLogger.WithFields(log.Fields{
+			"Err": err,
+		}).Error("cannot-Serialize-SyncTimeResponse")
+		return nil, err
+	}
+
+	return pkt, nil
+
+}