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/xapp-frame/pkg/xapp"
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
32 type Subscription struct {
33 mutex sync.Mutex // Lock
35 registry *Registry // Registry
37 Meid *xapp.RMRMeid // Meid/ RanName
38 EpList RmrEndpointList // Endpoints
39 TransLock sync.Mutex // Lock transactions, only one executed per time for subs
40 TheTrans *Transaction // Ongoing transaction from xapp
41 SubReqMsg *e2ap.E2APSubscriptionRequest // Subscription information
42 SubRespMsg *e2ap.E2APSubscriptionResponse // Subscription information
43 SubFailMsg *e2ap.E2APSubscriptionFailure // Subscription information
46 func (s *Subscription) String() string {
47 return "subs(" + strconv.FormatUint(uint64(s.Seq), 10) + "/" + s.Meid.RanName + "/" + s.EpList.String() + ")"
50 func (s *Subscription) GetSubId() uint16 {
52 defer s.mutex.Unlock()
56 func (s *Subscription) GetMeid() *xapp.RMRMeid {
58 defer s.mutex.Unlock()
65 func (s *Subscription) IsTransactionReserved() bool {
67 defer s.mutex.Unlock()
68 if s.TheTrans != nil {
75 func (s *Subscription) GetTransaction() *Transaction {
77 defer s.mutex.Unlock()
81 func (s *Subscription) WaitTransactionTurn(trans *Transaction) {
88 func (s *Subscription) ReleaseTransactionTurn(trans *Transaction) {
90 if trans != nil && trans == s.TheTrans {
97 func (s *Subscription) IsSame(trans *Transaction, subReqMsg *e2ap.E2APSubscriptionRequest) bool {
99 defer s.mutex.Unlock()
101 if s.valid == false {
105 if s.SubReqMsg == nil {
109 if s.Meid.RanName != trans.Meid.RanName {
113 if s.EpList.Size() == 0 {
117 //Somehow special case ... ?
118 if s.EpList.HasEndpoint(trans.GetEndpoint()) == true {
122 // EventTrigger check
123 if s.SubReqMsg.EventTriggerDefinition.InterfaceDirection != subReqMsg.EventTriggerDefinition.InterfaceDirection ||
124 s.SubReqMsg.EventTriggerDefinition.ProcedureCode != subReqMsg.EventTriggerDefinition.ProcedureCode ||
125 s.SubReqMsg.EventTriggerDefinition.TypeOfMessage != subReqMsg.EventTriggerDefinition.TypeOfMessage {
129 if s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.Present ||
130 s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.NodeId ||
131 s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Val[0] != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Val[0] ||
132 s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Val[1] != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Val[1] ||
133 s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Val[2] != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalEnbId.PlmnIdentity.Val[2] {
137 if s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.Present != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.Present ||
138 s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.NodeId != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.NodeId ||
139 s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.PlmnIdentity.Val[0] != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.PlmnIdentity.Val[0] ||
140 s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.PlmnIdentity.Val[1] != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.PlmnIdentity.Val[1] ||
141 s.SubReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.PlmnIdentity.Val[2] != subReqMsg.EventTriggerDefinition.InterfaceId.GlobalGnbId.PlmnIdentity.Val[2] {
146 if len(s.SubReqMsg.ActionSetups) != len(subReqMsg.ActionSetups) {
150 for _, acts := range s.SubReqMsg.ActionSetups {
151 for _, actt := range subReqMsg.ActionSetups {
152 if acts.ActionId != actt.ActionId {
155 if acts.ActionType != actt.ActionType {
159 if acts.ActionDefinition.Present != actt.ActionDefinition.Present ||
160 acts.ActionDefinition.StyleId != actt.ActionDefinition.StyleId ||
161 acts.ActionDefinition.ParamId != actt.ActionDefinition.ParamId {
164 if acts.SubsequentAction.Present != actt.SubsequentAction.Present ||
165 acts.SubsequentAction.Type != actt.SubsequentAction.Type ||
166 acts.SubsequentAction.TimetoWait != actt.SubsequentAction.TimetoWait {