VOL-1432 BUG Fix: Segmentation error in GetGemPortId ()

Change-Id: I8c0fe0fe37a13ee760900b58efa8d90a405b4b95
diff --git a/omci_state.go b/omci_state.go
index 8e4af35..be2da36 100644
--- a/omci_state.go
+++ b/omci_state.go
@@ -15,6 +15,11 @@
  */
 package core
 
+import (
+	"errors"
+	"fmt"
+)
+
 type OnuOmciState struct {
 	gemPortId     uint16
 	mibUploadCtr  uint16
@@ -38,7 +43,7 @@
 	return &OnuOmciState{gemPortId: 0, mibUploadCtr: 0, uniGInstance: 1, tcontInstance: 0, pptpInstance: 1}
 }
 
-func GetOnuOmciState(onuId uint32, intfId uint32) istate {
+func GetOnuOmciState(intfId uint32, onuId uint32) istate {
 	key := OnuKey{intfId, onuId}
 	if onu, ok := OnuOmciStateMap[key]; ok {
 		return onu.state
@@ -47,7 +52,11 @@
 	}
 }
 
-func GetGemPortId(onuId uint32, intfId uint32) uint16 {
+func GetGemPortId(intfId uint32, onuId uint32) (uint16, error) {
 	key := OnuKey{intfId, onuId}
-	return (OnuOmciStateMap[key].gemPortId)
+	if OnuOmciState, ok := OnuOmciStateMap[key]; ok {
+		return OnuOmciState.gemPortId, nil
+	}
+	errmsg := fmt.Sprintf("Failed to find a key in OnuOmciStateMap key{intfid:%d, onuid:%d}", intfId, onuId)
+	return 0, errors.New(errmsg)
 }