2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
23 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
24 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
25 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
33 type Subscription struct {
34 mutex sync.Mutex // Lock
36 registry *Registry // Registry
37 ReqId RequestId // ReqId (Requestor Id + Seq Nro a.k.a subsid)
38 Meid *xapp.RMRMeid // Meid/ RanName
39 EpList xapptweaks.RmrEndpointList // Endpoints
40 TransLock sync.Mutex // Lock transactions, only one executed per time for subs
41 TheTrans TransactionIf // Ongoing transaction
42 SubReqMsg *e2ap.E2APSubscriptionRequest // Subscription information
43 SubRFMsg interface{} // Subscription information
46 func (s *Subscription) String() string {
47 return "subs(" + s.ReqId.String() + "/" + (&xapptweaks.RMRMeid{s.Meid}).String() + "/" + s.EpList.String() + ")"
50 func (s *Subscription) GetCachedResponse() (interface{}, bool) {
52 defer s.mutex.Unlock()
53 return s.SubRFMsg, s.valid
56 func (s *Subscription) SetCachedResponse(subRFMsg interface{}, valid bool) (interface{}, bool) {
58 defer s.mutex.Unlock()
61 return s.SubRFMsg, s.valid
64 func (s *Subscription) GetReqId() *RequestId {
66 defer s.mutex.Unlock()
70 func (s *Subscription) GetMeid() *xapp.RMRMeid {
72 defer s.mutex.Unlock()
79 func (s *Subscription) GetTransaction() TransactionIf {
81 defer s.mutex.Unlock()
85 func (s *Subscription) WaitTransactionTurn(trans TransactionIf) {
92 func (s *Subscription) ReleaseTransactionTurn(trans TransactionIf) {
94 if trans != nil && trans == s.TheTrans {
101 func (s *Subscription) IsMergeable(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest) bool {
103 defer s.mutex.Unlock()
105 if s.valid == false {
109 if s.SubReqMsg == nil {
113 if s.Meid.RanName != trans.Meid.RanName {
117 // EventTrigger check
118 if s.SubReqMsg.EventTriggerDefinition.InterfaceDirection != subReqMsg.EventTriggerDefinition.InterfaceDirection ||
119 s.SubReqMsg.EventTriggerDefinition.ProcedureCode != subReqMsg.EventTriggerDefinition.ProcedureCode ||
120 s.SubReqMsg.EventTriggerDefinition.TypeOfMessage != subReqMsg.EventTriggerDefinition.TypeOfMessage {
124 if s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present ||
125 s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId ||
126 s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.String() != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.String() {
130 if s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.Present != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.Present ||
131 s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.NodeId != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.NodeId ||
132 s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.PlmnIdentity.String() != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.PlmnIdentity.String() {
137 if len(s.SubReqMsg.ActionSetups) != len(subReqMsg.ActionSetups) {
141 for _, acts := range s.SubReqMsg.ActionSetups {
142 for _, actt := range subReqMsg.ActionSetups {
143 if acts.ActionId != actt.ActionId {
146 if acts.ActionType != actt.ActionType {
150 if acts.ActionType != e2ap.E2AP_ActionTypeReport {
154 if acts.RicActionDefinitionPresent != actt.RicActionDefinitionPresent ||
155 reflect.DeepEqual(acts.ActionDefinitionChoice, actt.ActionDefinitionChoice) == false {
159 if acts.SubsequentAction.Present != actt.SubsequentAction.Present ||
160 acts.SubsequentAction.Type != actt.SubsequentAction.Type ||
161 acts.SubsequentAction.TimetoWait != actt.SubsequentAction.TimetoWait {