+ if err != nil {
+ if newAlloc {
+ r.subIds = append(r.subIds, subs.ReqId.Seq)
+ }
+ return nil, err
+ }
+
+ if newAlloc {
+ r.register[subs.ReqId.Seq] = subs
+ }
+ xapp.Logger.Debug("CREATE %s", subs.String())
+ xapp.Logger.Debug("Registry: substable=%v", r.register)
+ return subs, nil
+}
+
+func (r *Registry) CheckActionTypes(subReqMsg *e2ap.E2APSubscriptionRequest) (uint64, error) {
+ var reportFound bool = false
+ var policyFound bool = false
+
+ for _, acts := range subReqMsg.ActionSetups {
+ if acts.ActionType == e2ap.E2AP_ActionTypeReport {
+ reportFound = true
+ }
+ if acts.ActionType == e2ap.E2AP_ActionTypePolicy {
+ policyFound = true
+ }
+ }
+ if reportFound == true && policyFound == true {
+ return e2ap.E2AP_ActionTypeInvalid, fmt.Errorf("Report and Policy in same RICactions-ToBeSetup-List")
+ }
+ if reportFound == true {
+ return e2ap.E2AP_ActionTypeReport, nil
+ }
+ if policyFound == true {
+ return e2ap.E2AP_ActionTypePolicy, nil
+ }
+ return e2ap.E2AP_ActionTypeInvalid, fmt.Errorf("Invalid action type in RICactions-ToBeSetup-List")
+}
+
+// TODO: Works with concurrent calls, but check if can be improved
+func (r *Registry) RemoveFromSubscription(subs *Subscription, trans *TransactionXapp, waitRouteClean time.Duration) error {
+
+ r.mutex.Lock()
+ defer r.mutex.Unlock()
+ subs.mutex.Lock()
+ defer subs.mutex.Unlock()
+
+ delStatus := subs.EpList.DelEndpoint(trans.GetEndpoint())
+ epamount := subs.EpList.Size()
+ seqId := subs.ReqId.Seq
+
+ if delStatus == false {
+ return nil
+ }
+
+ go func() {
+ if waitRouteClean > 0 {
+ time.Sleep(waitRouteClean)
+ }
+
+ subs.mutex.Lock()
+ defer subs.mutex.Unlock()
+ xapp.Logger.Info("CLEAN %s", subs.String())
+
+ if epamount == 0 {
+ //
+ // Subscription route delete
+ //
+ tmpList := RmrEndpointList{}
+ tmpList.AddEndpoint(trans.GetEndpoint())
+ subRouteAction := SubRouteInfo{tmpList, uint16(seqId)}
+ r.rtmgrClient.SubscriptionRequestDelete(subRouteAction)
+
+ //
+ // Subscription release
+ //