+
+ subs := r.findExistingSubs(trans, subReqMsg)
+ if subs == nil {
+ subs, err = r.allocateSubs(trans, subReqMsg)
+ if err != nil {
+ return nil, err
+ }
+ newAlloc = true
+ }
+
+ //
+ // Add to subscription
+ //
+ subs.mutex.Lock()
+ defer subs.mutex.Unlock()
+
+ epamount := subs.EpList.Size()
+
+ r.mutex.Unlock()
+ //
+ // Subscription route updates
+ //
+ if epamount == 1 {
+ subRouteAction := SubRouteInfo{subs.EpList, uint16(subs.ReqId.Seq)}
+ err = r.rtmgrClient.SubscriptionRequestCreate(subRouteAction)
+ } else {
+ subRouteAction := SubRouteInfo{subs.EpList, uint16(subs.ReqId.Seq)}
+ err = r.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
+ }
+ r.mutex.Lock()
+
+ 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")