+func (c *Control) handleSubscriptionRequestTimer(strId string, nbrId int, tryCount uint64) {
+ xapp.Logger.Info("SubReq timeout: subId: %v, tryCount: %v", nbrId, tryCount)
+
+ subs, trans, err := c.findSubsAndTrans(([]int{nbrId}))
+ if err != nil {
+ xapp.Logger.Error("SubReq timeout: %s", idstring(nil, nil, err))
+ return
+ }
+ xapp.Logger.Debug("SubReq timeout: Handling %s", idstring(trans, subs, nil))
+
+ responseReceived := trans.CheckResponseReceived()
+ if responseReceived == true {
+ // Subscription Response or Failure already received
+ return
+ }
+
+ if tryCount < maxSubReqTryCount {
+ xapp.Logger.Info("SubReq timeout: %s", idstring(trans, subs, nil))
+
+ trans.RetryTransaction()
+
+ c.rmrSend("SubReq timeout: SubReq to E2T", subs, trans)
+
+ tryCount++
+ c.timerMap.StartTimer("RIC_SUB_REQ", int(subs.GetSubId()), subReqTime, tryCount, c.handleSubscriptionRequestTimer)
+ return
+ }
+
+ // Release CREATE transaction
+ trans.Release()
+
+ // Create DELETE transaction (internal and no messages toward xapp)
+ deltrans, err := c.tracker.TrackTransaction(&trans.RmrEndpoint, trans.GetXid(), trans.GetMeid(), false, false)
+ if err != nil {
+ xapp.Logger.Error("SubReq timeout: %s", idstring(trans, subs, err))
+ //TODO improve error handling. Important at least in merge
+ subs.Release()
+ return
+ }
+
+ deltrans.SubDelReqMsg = &e2ap.E2APSubscriptionDeleteRequest{}
+ deltrans.SubDelReqMsg.RequestId.Id = trans.SubReqMsg.RequestId.Id
+ deltrans.SubDelReqMsg.RequestId.Seq = uint32(subs.GetSubId())
+ deltrans.SubDelReqMsg.FunctionId = trans.SubReqMsg.FunctionId
+ deltrans.Mtype, deltrans.Payload, err = c.e2ap.PackSubscriptionDeleteRequest(deltrans.SubDelReqMsg)
+ if err != nil {
+ xapp.Logger.Error("SubReq timeout: %s", idstring(trans, subs, err))
+ //TODO improve error handling. Important at least in merge
+ deltrans.Release()
+ subs.Release()
+ return
+ }
+
+ err = subs.SetTransaction(deltrans)
+ if err != nil {
+ xapp.Logger.Error("SubReq timeout: %s", idstring(trans, subs, err))
+ //TODO improve error handling. Important at least in merge
+ deltrans.Release()
+ return
+ }
+
+ c.rmrSend("SubReq timer: SubDelReq to E2T", subs, deltrans)
+ c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()), subDelReqTime, FirstTry, c.handleSubscriptionDeleteRequestTimer)
+ return
+}
+
+func (c *Control) handleSubscriptionDeleteRequest(params *RMRParams) {
+ xapp.Logger.Info("SubDelReq from xapp: %s", params.String())
+
+ SubDelReqMsg, err := c.e2ap.UnpackSubscriptionDeleteRequest(params.Payload)
+ if err != nil {
+ xapp.Logger.Error("SubDelReq Drop %s", idstring(params, nil, err))
+ return
+ }
+
+ trans, err := c.tracker.TrackTransaction(NewRmrEndpoint(params.Src), params.Xid, params.Meid, false, true)
+ if err != nil {
+ xapp.Logger.Error("SubDelReq Drop %s", idstring(params, nil, err))
+ return
+ }
+ trans.SubDelReqMsg = SubDelReqMsg
+
+ subs, err := c.findSubs([]int{int(trans.SubDelReqMsg.RequestId.Seq), params.SubId})
+ if err != nil {
+ xapp.Logger.Error("SubDelReq: %s", idstring(params, nil, err))
+ trans.Release()
+ return
+ }
+
+ err = subs.SetTransaction(trans)