return nil, fmt.Errorf("Registry: Failed to reserve subscription no free ids")
}
-func (r *Registry) findExistingSubs(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest) *Subscription {
+func (r *Registry) findExistingSubs(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest) (*Subscription, bool) {
for _, subs := range r.register {
if subs.IsMergeable(trans, subReqMsg) {
subs.mutex.Unlock()
continue
}
- // try to add to endpointlist.
+ // Try to add to endpointlist. Adding fails if endpoint is already in the list
if subs.EpList.AddEndpoint(trans.GetEndpoint()) == false {
subs.mutex.Unlock()
- continue
+ xapp.Logger.Debug("Registry: Subs with requesting endpoint found. %s for %s", subs.String(), trans.String())
+ return subs, true
}
subs.mutex.Unlock()
- xapp.Logger.Debug("Registry: Mergeable subs found %s for %s", subs.String(), trans.String())
- return subs
+ xapp.Logger.Debug("Registry: Mergeable subs found. %s for %s", subs.String(), trans.String())
+ return subs, false
}
}
- return nil
+ return nil, false
}
func (r *Registry) AssignToSubscription(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest) (*Subscription, error) {
//
if actionType == e2ap.E2AP_ActionTypePolicy {
if subs, ok := r.register[trans.GetSubId()]; ok {
- xapp.Logger.Debug("CREATE %s. Existing subscription for Policy found", subs.String())
+ xapp.Logger.Debug("CREATE %s. Existing subscription for Policy found.", subs.String())
// Update message data to subscription
subs.SubReqMsg = subReqMsg
subs.SetCachedResponse(nil, true)
}
}
- subs := r.findExistingSubs(trans, subReqMsg)
+ subs, endPointFound := r.findExistingSubs(trans, subReqMsg)
if subs == nil {
subs, err = r.allocateSubs(trans, subReqMsg)
if err != nil {
return nil, err
}
newAlloc = true
+ } else if endPointFound == true {
+ // Requesting endpoint is already present in existing subscription. This can happen if xApp is restarted.
+ xapp.Logger.Debug("CREATE: subscription already exists. %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
+ var insertFound bool = false
for _, acts := range subReqMsg.ActionSetups {
if acts.ActionType == e2ap.E2AP_ActionTypeReport {
if acts.ActionType == e2ap.E2AP_ActionTypePolicy {
policyFound = true
}
+ if acts.ActionType == e2ap.E2AP_ActionTypeInsert {
+ insertFound = true
+ }
}
- if reportFound == true && policyFound == true {
- return e2ap.E2AP_ActionTypeInvalid, fmt.Errorf("Report and Policy in same RICactions-ToBeSetup-List")
+ if reportFound == true && policyFound == true || reportFound == true && insertFound == true || policyFound == true && insertFound == true {
+ return e2ap.E2AP_ActionTypeInvalid, fmt.Errorf("Different action types (Report, Policy or Insert) in same RICactions-ToBeSetup-List")
}
if reportFound == true {
return e2ap.E2AP_ActionTypeReport, nil
if policyFound == true {
return e2ap.E2AP_ActionTypePolicy, nil
}
+ if insertFound == true {
+ return e2ap.E2AP_ActionTypeInsert, nil
+ }
return e2ap.E2AP_ActionTypeInvalid, fmt.Errorf("Invalid action type in RICactions-ToBeSetup-List")
}