blob: ef27530e14491858efea0884c01815d4d988f98b [file] [log] [blame]
kalnagy45114752019-06-18 14:40:39 +02001/*
2==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
5
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
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
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==================================================================================
18*/
19
20package control
21
kalnagy45114752019-06-18 14:40:39 +020022import (
Juha Hyttinene406a342020-01-13 13:02:26 +020023 "fmt"
Juha Hyttinen86a46202020-01-14 12:49:09 +020024 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
kalnagy93cc3e22019-09-19 11:29:29 +020025 rtmgrclient "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client"
26 rtmgrhandle "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client/handle"
kalnagy1455c852019-10-21 13:06:23 +020027 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
28 httptransport "github.com/go-openapi/runtime/client"
29 "github.com/go-openapi/strfmt"
30 "github.com/spf13/viper"
Peter Szilagyifbc56f92019-07-23 19:29:46 +000031 "math/rand"
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020032 "sync"
Peter Szilagyifbc56f92019-07-23 19:29:46 +000033 "time"
kalnagy45114752019-06-18 14:40:39 +020034)
35
Juha Hyttinene406a342020-01-13 13:02:26 +020036//-----------------------------------------------------------------------------
37//
38//-----------------------------------------------------------------------------
39
Anssi Mannilaf1d0eb62019-12-17 15:29:55 +020040var subReqTime time.Duration = 5 * time.Second
Anssi Mannila8046c702020-01-02 13:39:05 +020041var subDelReqTime time.Duration = 5 * time.Second
42var maxSubReqTryCount uint64 = 2 // Initial try + retry
43var maxSubDelReqTryCount uint64 = 2 // Initial try + retry
Anssi Mannila2e99e2f2019-12-05 13:57:06 +020044
kalnagy45114752019-06-18 14:40:39 +020045type Control struct {
Juha Hyttinenc65f5b02019-12-30 14:24:04 +020046 e2ap *E2ap
47 registry *Registry
Juha Hyttinenc65f5b02019-12-30 14:24:04 +020048 tracker *Tracker
49 timerMap *TimerMap
50 rmrSendMutex sync.Mutex
Juha Hyttinen47b842b2020-01-08 13:01:52 +020051 msgCounter uint64
kalnagy93cc3e22019-09-19 11:29:29 +020052}
53
54type RMRMeid struct {
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020055 PlmnID string
56 EnbID string
Anssi Mannila2e99e2f2019-12-05 13:57:06 +020057 RanName string
kalnagy93cc3e22019-09-19 11:29:29 +020058}
59
kalnagy1455c852019-10-21 13:06:23 +020060var seedSN uint16
kalnagy93cc3e22019-09-19 11:29:29 +020061
62const (
63 CREATE Action = 0
kalnagy1455c852019-10-21 13:06:23 +020064 MERGE Action = 1
Anssi Mannila90fa0212019-12-12 10:47:47 +020065 NONE Action = 2
kalnagy93cc3e22019-09-19 11:29:29 +020066 DELETE Action = 3
67)
Peter Szilagyifbc56f92019-07-23 19:29:46 +000068
69func init() {
Anssi Mannila8046c702020-01-02 13:39:05 +020070 xapp.Logger.Info("SUBMGR")
Peter Szilagyifbc56f92019-07-23 19:29:46 +000071 viper.AutomaticEnv()
72 viper.SetEnvPrefix("submgr")
73 viper.AllowEmptyEnv(true)
kalnagy1455c852019-10-21 13:06:23 +020074 seedSN = uint16(viper.GetInt("seed_sn"))
75 if seedSN == 0 {
Peter Szilagyifbc56f92019-07-23 19:29:46 +000076 rand.Seed(time.Now().UnixNano())
kalnagy1455c852019-10-21 13:06:23 +020077 seedSN = uint16(rand.Intn(65535))
Peter Szilagyifbc56f92019-07-23 19:29:46 +000078 }
kalnagy1455c852019-10-21 13:06:23 +020079 if seedSN > 65535 {
80 seedSN = 0
Peter Szilagyifbc56f92019-07-23 19:29:46 +000081 }
kalnagy1455c852019-10-21 13:06:23 +020082 xapp.Logger.Info("SUBMGR: Initial Sequence Number: %v", seedSN)
kalnagy45114752019-06-18 14:40:39 +020083}
84
Juha Hyttinenff8dccd2019-12-10 14:34:07 +020085func NewControl() *Control {
Juha Hyttinen0388dd92020-01-09 14:14:16 +020086
Juha Hyttinen56e03832020-01-14 17:08:43 +020087 transport := httptransport.New(viper.GetString("rtmgr.HostAddr")+":"+viper.GetString("rtmgr.port"), viper.GetString("rtmgr.baseUrl"), []string{"http"})
88 client := rtmgrclient.New(transport, strfmt.Default)
89 handle := rtmgrhandle.NewProvideXappSubscriptionHandleParamsWithTimeout(10 * time.Second)
90 deleteHandle := rtmgrhandle.NewDeleteXappSubscriptionHandleParamsWithTimeout(10 * time.Second)
91 rtmgrClient := RtmgrClient{client, handle, deleteHandle}
92
Peter Szilagyifbc56f92019-07-23 19:29:46 +000093 registry := new(Registry)
kalnagy1455c852019-10-21 13:06:23 +020094 registry.Initialize(seedSN)
Juha Hyttinen56e03832020-01-14 17:08:43 +020095 registry.rtmgrClient = &rtmgrClient
kalnagy93cc3e22019-09-19 11:29:29 +020096
Balint Uvegese9608cd2019-09-20 18:00:32 +000097 tracker := new(Tracker)
98 tracker.Init()
99
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200100 timerMap := new(TimerMap)
101 timerMap.Init()
102
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200103 return &Control{e2ap: new(E2ap),
Juha Hyttinen56e03832020-01-14 17:08:43 +0200104 registry: registry,
105 tracker: tracker,
106 timerMap: timerMap,
107 msgCounter: 0,
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200108 }
kalnagy45114752019-06-18 14:40:39 +0200109}
110
111func (c *Control) Run() {
Peter Szilagyifbc56f92019-07-23 19:29:46 +0000112 xapp.Run(c)
kalnagy45114752019-06-18 14:40:39 +0200113}
114
Juha Hyttinene406a342020-01-13 13:02:26 +0200115func (c *Control) rmrSendRaw(desc string, params *RMRParams) (err error) {
116
117 xapp.Logger.Info("%s: %s", desc, params.String())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200118 status := false
119 i := 1
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200120 for ; i <= 10 && status == false; i++ {
Anssi Mannila90fa0212019-12-12 10:47:47 +0200121 c.rmrSendMutex.Lock()
Juha Hyttinene406a342020-01-13 13:02:26 +0200122 status = xapp.Rmr.Send(params.RMRParams, false)
Anssi Mannila90fa0212019-12-12 10:47:47 +0200123 c.rmrSendMutex.Unlock()
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200124 if status == false {
Juha Hyttinene406a342020-01-13 13:02:26 +0200125 xapp.Logger.Info("rmr.Send() failed. Retry count %d, %s", i, params.String())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200126 time.Sleep(500 * time.Millisecond)
127 }
128 }
129 if status == false {
Juha Hyttinene406a342020-01-13 13:02:26 +0200130 err = fmt.Errorf("rmr.Send() failed. Retry count %d, %s", i, params.String())
131 xapp.Logger.Error("%s: %s", desc, err.Error())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200132 xapp.Rmr.Free(params.Mbuf)
133 }
Peter Szilagyifbc56f92019-07-23 19:29:46 +0000134 return
kalnagy45114752019-06-18 14:40:39 +0200135}
136
Juha Hyttinen63284a22020-01-15 10:45:11 +0200137func (c *Control) rmrSend(desc string, subs *Subscription, trans *Transaction) (err error) {
Juha Hyttinene406a342020-01-13 13:02:26 +0200138 params := &RMRParams{&xapp.RMRParams{}}
139 params.Mtype = trans.GetMtype()
140 params.SubId = int(subs.GetSubId())
Juha Hyttinen86a46202020-01-14 12:49:09 +0200141 params.Xid = ""
Juha Hyttinene406a342020-01-13 13:02:26 +0200142 params.Meid = subs.GetMeid()
143 params.Src = ""
Juha Hyttinen63284a22020-01-15 10:45:11 +0200144 params.PayloadLen = len(trans.Payload.Buf)
145 params.Payload = trans.Payload.Buf
Juha Hyttinene406a342020-01-13 13:02:26 +0200146 params.Mbuf = nil
147
148 return c.rmrSendRaw(desc, params)
kalnagye0018682019-09-26 16:28:25 +0200149}
150
Juha Hyttinen63284a22020-01-15 10:45:11 +0200151func (c *Control) rmrReplyToSender(desc string, subs *Subscription, trans *Transaction) (err error) {
Juha Hyttinene406a342020-01-13 13:02:26 +0200152 params := &RMRParams{&xapp.RMRParams{}}
Juha Hyttinen63284a22020-01-15 10:45:11 +0200153 params.Mtype = trans.GetMtype()
Juha Hyttinene406a342020-01-13 13:02:26 +0200154 params.SubId = int(subs.GetSubId())
155 params.Xid = trans.GetXid()
Juha Hyttinen86a46202020-01-14 12:49:09 +0200156 params.Meid = trans.GetMeid()
Juha Hyttinene406a342020-01-13 13:02:26 +0200157 params.Src = ""
Juha Hyttinen63284a22020-01-15 10:45:11 +0200158 params.PayloadLen = len(trans.Payload.Buf)
159 params.Payload = trans.Payload.Buf
Juha Hyttinene406a342020-01-13 13:02:26 +0200160 params.Mbuf = nil
161
162 return c.rmrSendRaw(desc, params)
163}
164
165func (c *Control) Consume(params *xapp.RMRParams) (err error) {
166 xapp.Rmr.Free(params.Mbuf)
167 params.Mbuf = nil
Juha Hyttinene406a342020-01-13 13:02:26 +0200168 msg := &RMRParams{params}
Juha Hyttinen47b842b2020-01-08 13:01:52 +0200169 c.msgCounter++
Anssi Mannila90fa0212019-12-12 10:47:47 +0200170 switch msg.Mtype {
171 case xapp.RICMessageTypes["RIC_SUB_REQ"]:
172 go c.handleSubscriptionRequest(msg)
173 case xapp.RICMessageTypes["RIC_SUB_RESP"]:
174 go c.handleSubscriptionResponse(msg)
175 case xapp.RICMessageTypes["RIC_SUB_FAILURE"]:
176 go c.handleSubscriptionFailure(msg)
177 case xapp.RICMessageTypes["RIC_SUB_DEL_REQ"]:
178 go c.handleSubscriptionDeleteRequest(msg)
179 case xapp.RICMessageTypes["RIC_SUB_DEL_RESP"]:
180 go c.handleSubscriptionDeleteResponse(msg)
Anssi Mannilaf1d0eb62019-12-17 15:29:55 +0200181 case xapp.RICMessageTypes["RIC_SUB_DEL_FAILURE"]:
182 go c.handleSubscriptionDeleteFailure(msg)
Anssi Mannila90fa0212019-12-12 10:47:47 +0200183 default:
184 xapp.Logger.Info("Unknown Message Type '%d', discarding", msg.Mtype)
Balint Uvegescd3881b2019-10-02 15:01:43 +0000185 }
Juha Hyttinen86a46202020-01-14 12:49:09 +0200186
Anssi Mannila90fa0212019-12-12 10:47:47 +0200187 return nil
Balint Uvegescd3881b2019-10-02 15:01:43 +0000188}
189
Juha Hyttinene406a342020-01-13 13:02:26 +0200190func (c *Control) handleSubscriptionRequest(params *RMRParams) {
191 xapp.Logger.Info("SubReq from xapp: %s", params.String())
kalnagy93cc3e22019-09-19 11:29:29 +0200192
Juha Hyttinen86a46202020-01-14 12:49:09 +0200193 //
194 //
195 //
196 trans, err := c.tracker.TrackTransaction(NewRmrEndpoint(params.Src),
Juha Hyttinen86a46202020-01-14 12:49:09 +0200197 params.Xid,
198 params.Meid,
199 false,
200 true)
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200201
Juha Hyttinen0388dd92020-01-09 14:14:16 +0200202 if err != nil {
Juha Hyttinen86a46202020-01-14 12:49:09 +0200203 xapp.Logger.Error("SubReq: %s, Dropping this msg. %s", err.Error(), params.String())
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200204 return
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200205 }
kalnagy93cc3e22019-09-19 11:29:29 +0200206
Juha Hyttinene406a342020-01-13 13:02:26 +0200207 //
Juha Hyttinene406a342020-01-13 13:02:26 +0200208 //
209 //
Juha Hyttinen86a46202020-01-14 12:49:09 +0200210 trans.SubReqMsg, err = c.e2ap.UnpackSubscriptionRequest(params.Payload)
Peter Szilagyifbc56f92019-07-23 19:29:46 +0000211 if err != nil {
Juha Hyttinen86a46202020-01-14 12:49:09 +0200212 xapp.Logger.Error("SubReq: %s Dropping this msg. %s", err.Error(), trans)
213 trans.Release()
Peter Szilagyifbc56f92019-07-23 19:29:46 +0000214 return
215 }
kalnagy93cc3e22019-09-19 11:29:29 +0200216
Juha Hyttinen86a46202020-01-14 12:49:09 +0200217 //
218 //
219 //
220 subs, err := c.registry.ReserveSubscription(&trans.RmrEndpoint, trans.Meid)
kalnagy93cc3e22019-09-19 11:29:29 +0200221 if err != nil {
Juha Hyttinen86a46202020-01-14 12:49:09 +0200222 xapp.Logger.Error("SubReq: %s, Dropping this msg. %s", err.Error(), trans)
223 trans.Release()
Juha Hyttinenc65f5b02019-12-30 14:24:04 +0200224 return
Anssi Mannila90fa0212019-12-12 10:47:47 +0200225 }
kalnagy93cc3e22019-09-19 11:29:29 +0200226
Juha Hyttinene406a342020-01-13 13:02:26 +0200227 err = subs.SetTransaction(trans)
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200228 if err != nil {
Juha Hyttinen86a46202020-01-14 12:49:09 +0200229 xapp.Logger.Error("SubReq: %s, Dropping this msg. %s", err.Error(), trans)
Juha Hyttinen56e03832020-01-14 17:08:43 +0200230 subs.Release()
Juha Hyttinene406a342020-01-13 13:02:26 +0200231 trans.Release()
232 return
Anssi Mannilaf1d0eb62019-12-17 15:29:55 +0200233 }
Juha Hyttinene406a342020-01-13 13:02:26 +0200234
Juha Hyttinen86a46202020-01-14 12:49:09 +0200235 trans.SubReqMsg.RequestId.Seq = uint32(subs.GetSubId())
236
237 //
238 // TODO: subscription create is in fact owned by subscription and not transaction.
239 // Transaction is toward xapp while Subscription is toward ran.
240 // In merge several xapps may wake transactions, while only one subscription
241 // toward ran occurs -> subscription owns subscription creation toward ran
242 //
243 // This is intermediate solution while improving message handling
244 //
Juha Hyttinen63284a22020-01-15 10:45:11 +0200245 trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionRequest(trans.SubReqMsg)
Juha Hyttinen86a46202020-01-14 12:49:09 +0200246 if err != nil {
247 xapp.Logger.Error("SubReq: %s for trans %s", err.Error(), trans)
Juha Hyttinen56e03832020-01-14 17:08:43 +0200248 subs.Release()
Juha Hyttinen86a46202020-01-14 12:49:09 +0200249 trans.Release()
250 return
251 }
252
Juha Hyttinen63284a22020-01-15 10:45:11 +0200253 c.rmrSend("SubReq: SubReq to E2T", subs, trans)
Juha Hyttinene406a342020-01-13 13:02:26 +0200254
Juha Hyttinenaafee7f2020-01-14 14:54:51 +0200255 c.timerMap.StartTimer("RIC_SUB_REQ", int(subs.GetSubId()), subReqTime, FirstTry, c.handleSubscriptionRequestTimer)
Juha Hyttinene406a342020-01-13 13:02:26 +0200256 xapp.Logger.Debug("SubReq: Debugging trans table = %v", c.tracker.transactionXappTable)
Peter Szilagyifbc56f92019-07-23 19:29:46 +0000257 return
kalnagy45114752019-06-18 14:40:39 +0200258}
259
Juha Hyttinene406a342020-01-13 13:02:26 +0200260func (c *Control) handleSubscriptionResponse(params *RMRParams) {
261 xapp.Logger.Info("SubResp from E2T: %s", params.String())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200262
Juha Hyttinenaafee7f2020-01-14 14:54:51 +0200263 //
264 //
265 //
266 SubRespMsg, err := c.e2ap.UnpackSubscriptionResponse(params.Payload)
Peter Szilagyifbc56f92019-07-23 19:29:46 +0000267 if err != nil {
Juha Hyttinen662f68d2020-01-15 14:49:18 +0200268 xapp.Logger.Error("SubResp: %s Dropping this msg. %s", err.Error(), params.String())
Peter Szilagyifbc56f92019-07-23 19:29:46 +0000269 return
270 }
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200271
Juha Hyttinenaafee7f2020-01-14 14:54:51 +0200272 //
273 //
274 //
275 subs := c.registry.GetSubscription(uint16(SubRespMsg.RequestId.Seq))
276 if subs == nil && params.SubId > 0 {
277 subs = c.registry.GetSubscription(uint16(params.SubId))
278 }
279
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200280 if subs == nil {
Juha Hyttinenaafee7f2020-01-14 14:54:51 +0200281 xapp.Logger.Error("SubResp: Not valid subscription found payloadSeqNum: %d, SubId: %d. Dropping this msg. %s", SubRespMsg.RequestId.Seq, params.SubId, params.String())
282 return
283 }
284 xapp.Logger.Info("SubResp: subscription found payloadSeqNum: %d, SubId: %d", SubRespMsg.RequestId.Seq, subs.GetSubId())
285
286 //
287 //
288 //
289 trans := subs.GetTransaction()
290 if trans == nil {
291 xapp.Logger.Error("SubResp: Unknown trans. Dropping this msg. SubId: %d", subs.GetSubId())
Peter Szilagyifbc56f92019-07-23 19:29:46 +0000292 return
293 }
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200294
Juha Hyttinenaafee7f2020-01-14 14:54:51 +0200295 trans.SubRespMsg = SubRespMsg
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200296
Juha Hyttinenaafee7f2020-01-14 14:54:51 +0200297 //
298 //
299 //
300 c.timerMap.StopTimer("RIC_SUB_REQ", int(subs.GetSubId()))
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200301
Juha Hyttinene406a342020-01-13 13:02:26 +0200302 responseReceived := trans.CheckResponseReceived()
Anssi Mannila8046c702020-01-02 13:39:05 +0200303 if responseReceived == true {
304 // Subscription timer already received
305 return
306 }
Anssi Mannila8046c702020-01-02 13:39:05 +0200307
Juha Hyttinen63284a22020-01-15 10:45:11 +0200308 trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionResponse(trans.SubRespMsg)
Juha Hyttinenaafee7f2020-01-14 14:54:51 +0200309 if err != nil {
310 xapp.Logger.Error("SubResp: %s for trans %s", err.Error(), trans)
311 trans.Release()
312 return
313 }
314
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200315 subs.Confirmed()
Juha Hyttinene406a342020-01-13 13:02:26 +0200316 trans.Release()
Juha Hyttinen63284a22020-01-15 10:45:11 +0200317 c.rmrReplyToSender("SubResp: SubResp to xapp", subs, trans)
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200318 return
319}
320
Juha Hyttinene406a342020-01-13 13:02:26 +0200321func (c *Control) handleSubscriptionFailure(params *RMRParams) {
322 xapp.Logger.Info("SubFail from E2T: %s", params.String())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200323
Juha Hyttinen60bfcf92020-01-14 15:14:24 +0200324 //
325 //
326 //
327 SubFailMsg, err := c.e2ap.UnpackSubscriptionFailure(params.Payload)
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200328 if err != nil {
Juha Hyttinen60bfcf92020-01-14 15:14:24 +0200329 xapp.Logger.Error("SubFail: %s Dropping this msg. %s", err.Error(), params.String())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200330 return
331 }
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200332
Juha Hyttinen60bfcf92020-01-14 15:14:24 +0200333 //
334 //
335 //
336 subs := c.registry.GetSubscription(uint16(SubFailMsg.RequestId.Seq))
337 if subs == nil && params.SubId > 0 {
338 subs = c.registry.GetSubscription(uint16(params.SubId))
339 }
340
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200341 if subs == nil {
Juha Hyttinen60bfcf92020-01-14 15:14:24 +0200342 xapp.Logger.Error("SubFail: Not valid subscription found payloadSeqNum: %d, SubId: %d. Dropping this msg. %s", SubFailMsg.RequestId.Seq, params.SubId, params.String())
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200343 return
344 }
Juha Hyttinen60bfcf92020-01-14 15:14:24 +0200345 xapp.Logger.Info("SubFail: subscription found payloadSeqNum: %d, SubId: %d", SubFailMsg.RequestId.Seq, subs.GetSubId())
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200346
Juha Hyttinen60bfcf92020-01-14 15:14:24 +0200347 //
348 //
349 //
Juha Hyttinene406a342020-01-13 13:02:26 +0200350 trans := subs.GetTransaction()
351 if trans == nil {
Juha Hyttinen60bfcf92020-01-14 15:14:24 +0200352 xapp.Logger.Error("SubFail: Unknown trans. Dropping this msg. SubId: %d", subs.GetSubId())
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200353 return
354 }
Juha Hyttinen60bfcf92020-01-14 15:14:24 +0200355 trans.SubFailMsg = SubFailMsg
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200356
Juha Hyttinen60bfcf92020-01-14 15:14:24 +0200357 //
358 //
359 //
360 c.timerMap.StopTimer("RIC_SUB_REQ", int(subs.GetSubId()))
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200361
Juha Hyttinene406a342020-01-13 13:02:26 +0200362 responseReceived := trans.CheckResponseReceived()
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200363 if err != nil {
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200364 return
365 }
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200366
Anssi Mannila8046c702020-01-02 13:39:05 +0200367 if responseReceived == true {
368 // Subscription timer already received
369 return
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200370 }
371
Juha Hyttinen63284a22020-01-15 10:45:11 +0200372 trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionFailure(trans.SubFailMsg)
Juha Hyttinen375c1412020-01-14 20:17:50 +0200373 if err == nil {
Juha Hyttinen63284a22020-01-15 10:45:11 +0200374 c.rmrReplyToSender("SubFail: SubFail to xapp", subs, trans)
Juha Hyttinen60bfcf92020-01-14 15:14:24 +0200375 time.Sleep(3 * time.Second)
Juha Hyttinen375c1412020-01-14 20:17:50 +0200376 } else {
377 //TODO error handling improvement
378 xapp.Logger.Error("SubFail: %s for trans %s (continuing cleaning)", err.Error(), trans)
Juha Hyttinen60bfcf92020-01-14 15:14:24 +0200379 }
Anssi Mannilaa189c862020-01-10 11:36:35 +0200380
Juha Hyttinene406a342020-01-13 13:02:26 +0200381 trans.Release()
Juha Hyttinen56e03832020-01-14 17:08:43 +0200382 subs.Release()
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200383 return
384}
385
Anssi Mannila8046c702020-01-02 13:39:05 +0200386func (c *Control) handleSubscriptionRequestTimer(strId string, nbrId int, tryCount uint64) {
Juha Hyttinene406a342020-01-13 13:02:26 +0200387 xapp.Logger.Info("SubReq timeout: subId: %v, tryCount: %v", nbrId, tryCount)
Anssi Mannilaf1d0eb62019-12-17 15:29:55 +0200388
Juha Hyttinene406a342020-01-13 13:02:26 +0200389 subs := c.registry.GetSubscription(uint16(nbrId))
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200390 if subs == nil {
Juha Hyttinene406a342020-01-13 13:02:26 +0200391 xapp.Logger.Error("SubReq timeout: Unknown payloadSeqNum. Dropping this msg. SubId: %v", nbrId)
Anssi Mannilaf1d0eb62019-12-17 15:29:55 +0200392 return
393 }
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200394
Juha Hyttinene406a342020-01-13 13:02:26 +0200395 trans := subs.GetTransaction()
396 if trans == nil {
397 xapp.Logger.Error("SubReq timeout: Unknown trans. Dropping this msg. SubId: %v", subs.GetSubId())
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200398 return
399 }
400
Juha Hyttinene406a342020-01-13 13:02:26 +0200401 responseReceived := trans.CheckResponseReceived()
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200402
Anssi Mannila8046c702020-01-02 13:39:05 +0200403 if responseReceived == true {
404 // Subscription Response or Failure already received
405 return
406 }
407
408 if tryCount < maxSubReqTryCount {
Juha Hyttinen63284a22020-01-15 10:45:11 +0200409 xapp.Logger.Info("SubReq timeout: subs: %s trans: %s", subs, trans)
Anssi Mannila8046c702020-01-02 13:39:05 +0200410
Juha Hyttinene406a342020-01-13 13:02:26 +0200411 trans.RetryTransaction()
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200412
Juha Hyttinen63284a22020-01-15 10:45:11 +0200413 c.rmrSend("SubReq timeout: SubReq to E2T", subs, trans)
Anssi Mannila8046c702020-01-02 13:39:05 +0200414
415 tryCount++
Juha Hyttinene406a342020-01-13 13:02:26 +0200416 c.timerMap.StartTimer("RIC_SUB_REQ", int(subs.GetSubId()), subReqTime, tryCount, c.handleSubscriptionRequestTimer)
Anssi Mannila8046c702020-01-02 13:39:05 +0200417 return
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200418 }
Anssi Mannila8046c702020-01-02 13:39:05 +0200419
Juha Hyttinen375c1412020-01-14 20:17:50 +0200420 // Release CREATE transaction
Juha Hyttinene406a342020-01-13 13:02:26 +0200421 trans.Release()
Anssi Mannila8046c702020-01-02 13:39:05 +0200422
Juha Hyttinene406a342020-01-13 13:02:26 +0200423 // Create DELETE transaction (internal and no messages toward xapp)
Juha Hyttinen86a46202020-01-14 12:49:09 +0200424 deltrans, err := c.tracker.TrackTransaction(&trans.RmrEndpoint,
Juha Hyttinen86a46202020-01-14 12:49:09 +0200425 trans.GetXid(),
426 trans.GetMeid(),
427 false,
428 false)
429
Anssi Mannila8046c702020-01-02 13:39:05 +0200430 if err != nil {
Juha Hyttinene406a342020-01-13 13:02:26 +0200431 xapp.Logger.Error("SubReq timeout: %s, Dropping this msg.", err.Error())
Juha Hyttinen86a46202020-01-14 12:49:09 +0200432 //TODO improve error handling. Important at least in merge
Juha Hyttinen56e03832020-01-14 17:08:43 +0200433 subs.Release()
Anssi Mannila8046c702020-01-02 13:39:05 +0200434 return
435 }
436
Juha Hyttinen86a46202020-01-14 12:49:09 +0200437 deltrans.SubDelReqMsg = &e2ap.E2APSubscriptionDeleteRequest{}
438 deltrans.SubDelReqMsg.RequestId.Id = trans.SubReqMsg.RequestId.Id
439 deltrans.SubDelReqMsg.RequestId.Seq = uint32(subs.GetSubId())
440 deltrans.SubDelReqMsg.FunctionId = trans.SubReqMsg.FunctionId
Juha Hyttinen63284a22020-01-15 10:45:11 +0200441 deltrans.Mtype, deltrans.Payload, err = c.e2ap.PackSubscriptionDeleteRequest(deltrans.SubDelReqMsg)
Juha Hyttinen86a46202020-01-14 12:49:09 +0200442 if err != nil {
443 xapp.Logger.Error("SubReq timeout: Packing SubDelReq failed. Err: %v", err)
444 //TODO improve error handling. Important at least in merge
445 deltrans.Release()
Juha Hyttinen56e03832020-01-14 17:08:43 +0200446 subs.Release()
Juha Hyttinen86a46202020-01-14 12:49:09 +0200447 return
448 }
Juha Hyttinen86a46202020-01-14 12:49:09 +0200449
Juha Hyttinene406a342020-01-13 13:02:26 +0200450 err = subs.SetTransaction(deltrans)
Anssi Mannila8046c702020-01-02 13:39:05 +0200451 if err != nil {
Juha Hyttinene406a342020-01-13 13:02:26 +0200452 xapp.Logger.Error("SubReq timeout: %s, Dropping this msg.", err.Error())
Juha Hyttinen86a46202020-01-14 12:49:09 +0200453 //TODO improve error handling. Important at least in merge
Juha Hyttinene406a342020-01-13 13:02:26 +0200454 deltrans.Release()
455 return
Anssi Mannila8046c702020-01-02 13:39:05 +0200456 }
Juha Hyttinene406a342020-01-13 13:02:26 +0200457
Juha Hyttinen63284a22020-01-15 10:45:11 +0200458 c.rmrSend("SubReq timer: SubDelReq to E2T", subs, deltrans)
Juha Hyttinene406a342020-01-13 13:02:26 +0200459 c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()), subDelReqTime, FirstTry, c.handleSubscriptionDeleteRequestTimer)
kalnagy93cc3e22019-09-19 11:29:29 +0200460 return
461}
462
Juha Hyttinene406a342020-01-13 13:02:26 +0200463func (c *Control) handleSubscriptionDeleteRequest(params *RMRParams) {
464 xapp.Logger.Info("SubDelReq from xapp: %s", params.String())
kalnagy93cc3e22019-09-19 11:29:29 +0200465
Juha Hyttinenaafee7f2020-01-14 14:54:51 +0200466 //
467 //
468 //
Juha Hyttinen86a46202020-01-14 12:49:09 +0200469 trans, err := c.tracker.TrackTransaction(NewRmrEndpoint(params.Src),
Juha Hyttinen86a46202020-01-14 12:49:09 +0200470 params.Xid,
471 params.Meid,
472 false,
473 true)
474
Juha Hyttinene406a342020-01-13 13:02:26 +0200475 if err != nil {
Juha Hyttinen86a46202020-01-14 12:49:09 +0200476 xapp.Logger.Error("SubDelReq: %s, Dropping this msg. %s", err.Error(), params.String())
Juha Hyttinene406a342020-01-13 13:02:26 +0200477 return
kalnagy93cc3e22019-09-19 11:29:29 +0200478 }
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200479
Juha Hyttinenb3dc1562020-01-14 14:32:17 +0200480 //
481 //
482 //
483 trans.SubDelReqMsg, err = c.e2ap.UnpackSubscriptionDeleteRequest(params.Payload)
484 if err != nil {
485 xapp.Logger.Error("SubDelReq: %s Dropping this msg. %s", err.Error(), trans)
486 trans.Release()
487 return
kalnagy93cc3e22019-09-19 11:29:29 +0200488 }
Juha Hyttinenb3dc1562020-01-14 14:32:17 +0200489
Juha Hyttinenaafee7f2020-01-14 14:54:51 +0200490 //
491 //
492 //
493 subs := c.registry.GetSubscription(uint16(trans.SubDelReqMsg.RequestId.Seq))
Juha Hyttinen86a46202020-01-14 12:49:09 +0200494 if subs == nil && params.SubId > 0 {
495 subs = c.registry.GetSubscription(uint16(params.SubId))
496 }
Anssi Mannila26c922a2019-12-17 11:18:08 +0200497
Juha Hyttinene406a342020-01-13 13:02:26 +0200498 if subs == nil {
Juha Hyttinenb3dc1562020-01-14 14:32:17 +0200499 xapp.Logger.Error("SubDelReq: Not valid subscription found payloadSeqNum: %d, SubId: %d. Dropping this msg. %s", trans.SubDelReqMsg.RequestId.Seq, params.SubId, trans)
Juha Hyttinen86a46202020-01-14 12:49:09 +0200500 trans.Release()
Anssi Mannila90fa0212019-12-12 10:47:47 +0200501 return
kalnagy93cc3e22019-09-19 11:29:29 +0200502 }
Juha Hyttinenb3dc1562020-01-14 14:32:17 +0200503 xapp.Logger.Info("SubDelReq: subscription found payloadSeqNum: %d, SubId: %d. %s", trans.SubDelReqMsg.RequestId.Seq, params.SubId, trans)
Juha Hyttinene406a342020-01-13 13:02:26 +0200504
505 err = subs.SetTransaction(trans)
506 if err != nil {
Juha Hyttinen86a46202020-01-14 12:49:09 +0200507 xapp.Logger.Error("SubDelReq: %s, Dropping this msg. %s", err.Error(), trans)
Juha Hyttinene406a342020-01-13 13:02:26 +0200508 trans.Release()
509 return
510 }
511
Juha Hyttinenb3dc1562020-01-14 14:32:17 +0200512 //
513 // TODO: subscription delete is in fact owned by subscription and not transaction.
514 // Transaction is toward xapp while Subscription is toward ran.
515 // In merge several xapps may wake transactions, while only one subscription
516 // toward ran occurs -> subscription owns subscription creation toward ran
517 //
518 // This is intermediate solution while improving message handling
519 //
Juha Hyttinen63284a22020-01-15 10:45:11 +0200520 trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionDeleteRequest(trans.SubDelReqMsg)
Juha Hyttinenb3dc1562020-01-14 14:32:17 +0200521 if err != nil {
522 xapp.Logger.Error("SubDelReq: %s for trans %s", err.Error(), trans)
523 trans.Release()
524 return
525 }
526
Juha Hyttinene406a342020-01-13 13:02:26 +0200527 subs.UnConfirmed()
528
Juha Hyttinen63284a22020-01-15 10:45:11 +0200529 c.rmrSend("SubDelReq: SubDelReq to E2T", subs, trans)
Juha Hyttinene406a342020-01-13 13:02:26 +0200530
531 c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()), subDelReqTime, FirstTry, c.handleSubscriptionDeleteRequestTimer)
kalnagye0018682019-09-26 16:28:25 +0200532 return
533}
534
Juha Hyttinene406a342020-01-13 13:02:26 +0200535func (c *Control) handleSubscriptionDeleteResponse(params *RMRParams) (err error) {
536 xapp.Logger.Info("SubDelResp from E2T:%s", params.String())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200537
Juha Hyttinen4e7c8c52020-01-14 19:25:00 +0200538 //
539 //
540 //
541 SubDelRespMsg, err := c.e2ap.UnpackSubscriptionDeleteResponse(params.Payload)
kalnagye0018682019-09-26 16:28:25 +0200542 if err != nil {
Juha Hyttinen4e7c8c52020-01-14 19:25:00 +0200543 xapp.Logger.Error("SubDelResp: %s Dropping this msg. %s", err.Error(), params.String())
kalnagye0018682019-09-26 16:28:25 +0200544 return
545 }
kalnagye0018682019-09-26 16:28:25 +0200546
Juha Hyttinen4e7c8c52020-01-14 19:25:00 +0200547 //
548 //
549 //
550 subs := c.registry.GetSubscription(uint16(SubDelRespMsg.RequestId.Seq))
551 if subs == nil && params.SubId > 0 {
552 subs = c.registry.GetSubscription(uint16(params.SubId))
553 }
554
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200555 if subs == nil {
Juha Hyttinen4e7c8c52020-01-14 19:25:00 +0200556 xapp.Logger.Error("SubDelResp: Not valid subscription found payloadSeqNum: %d, SubId: %d. Dropping this msg. %s", SubDelRespMsg.RequestId.Seq, params.SubId, params.String())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200557 return
558 }
Juha Hyttinen4e7c8c52020-01-14 19:25:00 +0200559 xapp.Logger.Info("SubDelResp: subscription found payloadSeqNum: %d, SubId: %d", SubDelRespMsg.RequestId.Seq, subs.GetSubId())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200560
Juha Hyttinen4e7c8c52020-01-14 19:25:00 +0200561 //
562 //
563 //
Juha Hyttinene406a342020-01-13 13:02:26 +0200564 trans := subs.GetTransaction()
565 if trans == nil {
Juha Hyttinen4e7c8c52020-01-14 19:25:00 +0200566 xapp.Logger.Error("SubDelResp: Unknown trans. Dropping this msg. SubId: %d", subs.GetSubId())
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200567 return
568 }
569
Juha Hyttinen4e7c8c52020-01-14 19:25:00 +0200570 trans.SubDelRespMsg = SubDelRespMsg
571
572 //
573 //
574 //
Juha Hyttinene406a342020-01-13 13:02:26 +0200575 c.timerMap.StopTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()))
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200576
Juha Hyttinene406a342020-01-13 13:02:26 +0200577 responseReceived := trans.CheckResponseReceived()
Anssi Mannila8046c702020-01-02 13:39:05 +0200578 if responseReceived == true {
579 // Subscription Delete timer already received
580 return
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200581 }
582
Juha Hyttinen375c1412020-01-14 20:17:50 +0200583 c.sendSubscriptionDeleteResponse("SubDelResp", trans, subs)
kalnagye0018682019-09-26 16:28:25 +0200584 return
585}
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200586
Juha Hyttinene406a342020-01-13 13:02:26 +0200587func (c *Control) handleSubscriptionDeleteFailure(params *RMRParams) {
588 xapp.Logger.Info("SubDelFail from E2T:%s", params.String())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200589
Juha Hyttinen375c1412020-01-14 20:17:50 +0200590 //
591 //
592 //
593 SubDelFailMsg, err := c.e2ap.UnpackSubscriptionDeleteFailure(params.Payload)
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200594 if err != nil {
Juha Hyttinen375c1412020-01-14 20:17:50 +0200595 xapp.Logger.Error("SubDelFail: %s Dropping this msg. %s", err.Error(), params.String())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200596 return
597 }
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200598
Juha Hyttinen375c1412020-01-14 20:17:50 +0200599 //
600 //
601 //
602 subs := c.registry.GetSubscription(uint16(SubDelFailMsg.RequestId.Seq))
603 if subs == nil && params.SubId > 0 {
604 subs = c.registry.GetSubscription(uint16(params.SubId))
605 }
606
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200607 if subs == nil {
Juha Hyttinen375c1412020-01-14 20:17:50 +0200608 xapp.Logger.Error("SubDelFail: Not valid subscription found payloadSeqNum: %d, SubId: %d. Dropping this msg. %s", SubDelFailMsg.RequestId.Seq, params.SubId, params.String())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200609 return
610 }
Juha Hyttinen375c1412020-01-14 20:17:50 +0200611 xapp.Logger.Info("SubDelFail: subscription found payloadSeqNum: %d, SubId: %d", SubDelFailMsg.RequestId.Seq, subs.GetSubId())
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200612
Juha Hyttinen375c1412020-01-14 20:17:50 +0200613 //
614 //
615 //
Juha Hyttinene406a342020-01-13 13:02:26 +0200616 trans := subs.GetTransaction()
617 if trans == nil {
Juha Hyttinen375c1412020-01-14 20:17:50 +0200618 xapp.Logger.Error("SubDelFail: Unknown trans. Dropping this msg. SubId: %d", subs.GetSubId())
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200619 return
620 }
Juha Hyttinen375c1412020-01-14 20:17:50 +0200621 trans.SubDelFailMsg = SubDelFailMsg
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200622
Juha Hyttinen375c1412020-01-14 20:17:50 +0200623 //
624 //
625 //
Juha Hyttinene406a342020-01-13 13:02:26 +0200626 c.timerMap.StopTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()))
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200627
Juha Hyttinene406a342020-01-13 13:02:26 +0200628 responseReceived := trans.CheckResponseReceived()
Anssi Mannila8046c702020-01-02 13:39:05 +0200629 if responseReceived == true {
630 // Subscription Delete timer already received
631 return
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200632 }
Anssi Mannila8046c702020-01-02 13:39:05 +0200633
Juha Hyttinen375c1412020-01-14 20:17:50 +0200634 c.sendSubscriptionDeleteResponse("SubDelFail", trans, subs)
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200635 return
636}
637
Anssi Mannila8046c702020-01-02 13:39:05 +0200638func (c *Control) handleSubscriptionDeleteRequestTimer(strId string, nbrId int, tryCount uint64) {
Juha Hyttinene406a342020-01-13 13:02:26 +0200639 xapp.Logger.Info("SubDelReq timeout: subId: %v, tryCount: %v", nbrId, tryCount)
Anssi Mannilaf1d0eb62019-12-17 15:29:55 +0200640
Juha Hyttinene406a342020-01-13 13:02:26 +0200641 subs := c.registry.GetSubscription(uint16(nbrId))
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200642 if subs == nil {
Juha Hyttinene406a342020-01-13 13:02:26 +0200643 xapp.Logger.Error("SubDelReq timeout: Unknown payloadSeqNum. Dropping this msg. SubId: %v", nbrId)
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200644 return
645 }
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200646
Juha Hyttinene406a342020-01-13 13:02:26 +0200647 trans := subs.GetTransaction()
648 if trans == nil {
649 xapp.Logger.Error("SubDelReq timeout: Unknown trans. Dropping this msg. SubId: %v", subs.GetSubId())
Juha Hyttinen0d064ec2020-01-09 09:08:53 +0200650 return
651 }
652
Juha Hyttinene406a342020-01-13 13:02:26 +0200653 responseReceived := trans.CheckResponseReceived()
Anssi Mannila8046c702020-01-02 13:39:05 +0200654 if responseReceived == true {
655 // Subscription Delete Response or Failure already received
656 return
Anssi Mannila2e99e2f2019-12-05 13:57:06 +0200657 }
Juha Hyttinenff8dccd2019-12-10 14:34:07 +0200658
Anssi Mannila8046c702020-01-02 13:39:05 +0200659 if tryCount < maxSubDelReqTryCount {
Anssi Mannila8046c702020-01-02 13:39:05 +0200660 // Set possible to handle new response for the subId
Juha Hyttinene406a342020-01-13 13:02:26 +0200661 trans.RetryTransaction()
Juha Hyttinen63284a22020-01-15 10:45:11 +0200662 c.rmrSend("SubDelReq timeout: SubDelReq to E2T", subs, trans)
Anssi Mannila8046c702020-01-02 13:39:05 +0200663 tryCount++
Juha Hyttinene406a342020-01-13 13:02:26 +0200664 c.timerMap.StartTimer("RIC_SUB_DEL_REQ", int(subs.GetSubId()), subReqTime, tryCount, c.handleSubscriptionDeleteRequestTimer)
Anssi Mannila8046c702020-01-02 13:39:05 +0200665 return
666 }
667
Juha Hyttinen375c1412020-01-14 20:17:50 +0200668 c.sendSubscriptionDeleteResponse("SubDelReq(timer)", trans, subs)
669 return
670}
671
672func (c *Control) sendSubscriptionDeleteResponse(desc string, trans *Transaction, subs *Subscription) {
673
Juha Hyttinene406a342020-01-13 13:02:26 +0200674 if trans.ForwardRespToXapp == true {
Juha Hyttinen375c1412020-01-14 20:17:50 +0200675 //Always generate SubDelResp
676 trans.SubDelRespMsg = &e2ap.E2APSubscriptionDeleteResponse{}
677 trans.SubDelRespMsg.RequestId.Id = trans.SubDelReqMsg.RequestId.Id
678 trans.SubDelRespMsg.RequestId.Seq = uint32(subs.GetSubId())
679 trans.SubDelRespMsg.FunctionId = trans.SubDelReqMsg.FunctionId
680
Juha Hyttinen93400722020-01-15 09:25:13 +0200681 var err error
Juha Hyttinen63284a22020-01-15 10:45:11 +0200682 trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionDeleteResponse(trans.SubDelRespMsg)
Juha Hyttinen375c1412020-01-14 20:17:50 +0200683 if err == nil {
Juha Hyttinen63284a22020-01-15 10:45:11 +0200684 c.rmrReplyToSender(desc+": SubDelResp to xapp", subs, trans)
Juha Hyttinen375c1412020-01-14 20:17:50 +0200685 time.Sleep(3 * time.Second)
686 } else {
687 //TODO error handling improvement
688 xapp.Logger.Error("%s: %s for trans %s (continuing cleaning)", desc, err.Error(), trans)
Anssi Mannila8046c702020-01-02 13:39:05 +0200689 }
Anssi Mannila8046c702020-01-02 13:39:05 +0200690 }
Juha Hyttinen375c1412020-01-14 20:17:50 +0200691
Juha Hyttinene406a342020-01-13 13:02:26 +0200692 trans.Release()
Juha Hyttinen56e03832020-01-14 17:08:43 +0200693 subs.Release()
Anssi Mannilaf1d0eb62019-12-17 15:29:55 +0200694}