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

Change-Id: I8c0fe0fe37a13ee760900b58efa8d90a405b4b95
diff --git a/omci_handlers.go b/omci_handlers.go
index 1f0e919..3354f2a 100644
--- a/omci_handlers.go
+++ b/omci_handlers.go
@@ -233,7 +233,7 @@
 			return nil, errors.New("ONU Key Error")
 		} else {
 			onuOmciState.gemPortId = binary.BigEndian.Uint16(content[:2])
-			log.Printf("Gem Port Id %d", onuOmciState.gemPortId)
+			log.Printf("ONU Key {intfid:%d, onuid:%d} Gem Port Id %d", key.IntfId, key.OnuId, onuOmciState.gemPortId)
 			// FIXME
 			OnuOmciStateMap[key].state = DONE
 		}
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)
 }