kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | package control |
| 21 | |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 22 | import "C" |
| 23 | |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 24 | import ( |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 25 | "errors" |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 26 | rtmgrclient "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client" |
| 27 | rtmgrhandle "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client/handle" |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 28 | "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" |
| 29 | httptransport "github.com/go-openapi/runtime/client" |
| 30 | "github.com/go-openapi/strfmt" |
| 31 | "github.com/spf13/viper" |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 32 | "math/rand" |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 33 | "time" |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 34 | "sync" |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 35 | ) |
| 36 | |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 37 | var subReqTime time.Duration = 2 * time.Second |
| 38 | var SubDelReqTime time.Duration = 2 * time.Second |
| 39 | |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 40 | type Control struct { |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 41 | e2ap *E2ap |
| 42 | registry *Registry |
| 43 | rtmgrClient *RtmgrClient |
| 44 | tracker *Tracker |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 45 | timerMap *TimerMap |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 46 | rmrSendMutex *sync.Mutex |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | type RMRMeid struct { |
| 50 | PlmnID string |
| 51 | EnbID string |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 52 | RanName string |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 53 | } |
| 54 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 55 | var seedSN uint16 |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 56 | |
| 57 | const ( |
| 58 | CREATE Action = 0 |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 59 | MERGE Action = 1 |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 60 | NONE Action = 2 |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 61 | DELETE Action = 3 |
| 62 | ) |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 63 | |
| 64 | func init() { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 65 | xapp.Logger.Info("SUBMGR /ric-plt-submgr:r3-test-v4") |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 66 | viper.AutomaticEnv() |
| 67 | viper.SetEnvPrefix("submgr") |
| 68 | viper.AllowEmptyEnv(true) |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 69 | seedSN = uint16(viper.GetInt("seed_sn")) |
| 70 | if seedSN == 0 { |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 71 | rand.Seed(time.Now().UnixNano()) |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 72 | seedSN = uint16(rand.Intn(65535)) |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 73 | } |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 74 | if seedSN > 65535 { |
| 75 | seedSN = 0 |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 76 | } |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 77 | xapp.Logger.Info("SUBMGR: Initial Sequence Number: %v", seedSN) |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | func NewControl() Control { |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 81 | registry := new(Registry) |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 82 | registry.Initialize(seedSN) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 83 | |
Balint Uveges | e9608cd | 2019-09-20 18:00:32 +0000 | [diff] [blame] | 84 | tracker := new(Tracker) |
| 85 | tracker.Init() |
| 86 | |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 87 | timerMap := new(TimerMap) |
| 88 | timerMap.Init() |
| 89 | |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 90 | rmrSendMutex := &sync.Mutex{} |
| 91 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 92 | transport := httptransport.New(viper.GetString("rtmgr.HostAddr")+":"+viper.GetString("rtmgr.port"), viper.GetString("rtmgr.baseUrl"), []string{"http"}) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 93 | client := rtmgrclient.New(transport, strfmt.Default) |
| 94 | handle := rtmgrhandle.NewProvideXappSubscriptionHandleParamsWithTimeout(10 * time.Second) |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 95 | deleteHandle := rtmgrhandle.NewDeleteXappSubscriptionHandleParamsWithTimeout(10 * time.Second) |
| 96 | rtmgrClient := RtmgrClient{client, handle, deleteHandle} |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 97 | |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 98 | return Control{new(E2ap), registry, &rtmgrClient, tracker, timerMap, rmrSendMutex} |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | func (c *Control) Run() { |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 102 | xapp.Run(c) |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 103 | } |
| 104 | |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 105 | func (c *Control) rmrSend(params *xapp.RMRParams) (err error) { |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 106 | status := false |
| 107 | i := 1 |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 108 | for ; i <= 10 && status == false; i++ { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 109 | c.rmrSendMutex.Lock() |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 110 | status = xapp.Rmr.Send(params, false) |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 111 | c.rmrSendMutex.Unlock() |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 112 | if status == false { |
| 113 | xapp.Logger.Info("rmr.Send() failed. Retry count %v, Mtype: %v, SubId: %v, Xid %s",i, params.Mtype, params.SubId, params.Xid) |
| 114 | time.Sleep(500 * time.Millisecond) |
| 115 | } |
| 116 | } |
| 117 | if status == false { |
| 118 | err = errors.New("rmr.Send() failed") |
| 119 | xapp.Rmr.Free(params.Mbuf) |
| 120 | } |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 121 | return |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 122 | } |
| 123 | |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 124 | func (c *Control) rmrReplyToSender(params *xapp.RMRParams) (err error) { |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 125 | c.rmrSend(params) |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 126 | return |
| 127 | } |
| 128 | |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 129 | func (c *Control) Consume(msg *xapp.RMRParams) (err error) { |
| 130 | switch msg.Mtype { |
| 131 | case xapp.RICMessageTypes["RIC_SUB_REQ"]: |
| 132 | go c.handleSubscriptionRequest(msg) |
| 133 | case xapp.RICMessageTypes["RIC_SUB_RESP"]: |
| 134 | go c.handleSubscriptionResponse(msg) |
| 135 | case xapp.RICMessageTypes["RIC_SUB_FAILURE"]: |
| 136 | go c.handleSubscriptionFailure(msg) |
| 137 | case xapp.RICMessageTypes["RIC_SUB_DEL_REQ"]: |
| 138 | go c.handleSubscriptionDeleteRequest(msg) |
| 139 | case xapp.RICMessageTypes["RIC_SUB_DEL_RESP"]: |
| 140 | go c.handleSubscriptionDeleteResponse(msg) |
| 141 | default: |
| 142 | xapp.Logger.Info("Unknown Message Type '%d', discarding", msg.Mtype) |
Balint Uveges | cd3881b | 2019-10-02 15:01:43 +0000 | [diff] [blame] | 143 | } |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 144 | return nil |
Balint Uveges | cd3881b | 2019-10-02 15:01:43 +0000 | [diff] [blame] | 145 | } |
| 146 | |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 147 | func (c *Control) handleSubscriptionRequest(params *xapp.RMRParams) { |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 148 | xapp.Logger.Info("Subscription Request Received from Src: %s, Mtype: %v, SubId: %v, Xid: %s, Meid: %v",params.Src, params.Mtype, params.SubId, params.Xid, params.Meid) |
| 149 | xapp.Rmr.Free(params.Mbuf) |
| 150 | params.Mbuf = nil |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 151 | |
| 152 | /* Reserve a sequence number and set it in the payload */ |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 153 | newSubId, isIdValid := c.registry.ReserveSequenceNumber() |
| 154 | if isIdValid != true { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 155 | xapp.Logger.Error("Further processing of this SubscriptionRequest stopped. SubId: %v, Xid: %s",params.SubId, params.Xid) |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 156 | return |
| 157 | } |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 158 | |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 159 | err := c.e2ap.SetSubscriptionRequestSequenceNumber(params.Payload, newSubId) |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 160 | if err != nil { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 161 | xapp.Logger.Error("Unable to set Subscription Sequence Number in Payload. Dropping this Subscription Request message. Err: v%, SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 162 | return |
| 163 | } |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 164 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 165 | srcAddr, srcPort, err := c.rtmgrClient.SplitSource(params.Src) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 166 | if err != nil { |
| 167 | xapp.Logger.Error("Failed to update routing-manager about the subscription request with reason: %s", err) |
| 168 | return |
| 169 | } |
| 170 | |
| 171 | /* Create transatcion records for every subscription request */ |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 172 | xactKey := TransactionKey{newSubId, CREATE} |
| 173 | xactValue := Transaction{*srcAddr, *srcPort, params} |
| 174 | err = c.tracker.TrackTransaction(xactKey, xactValue) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 175 | if err != nil { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 176 | xapp.Logger.Error("Failed to create a Subscription Request transaction record. Err: %v", err) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 177 | return |
| 178 | } |
| 179 | |
| 180 | /* Update routing manager about the new subscription*/ |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 181 | subRouteAction := SubRouteInfo{CREATE, *srcAddr, *srcPort, newSubId} |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 182 | xapp.Logger.Info("Starting routing manager update") |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 183 | err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction) |
| 184 | if err != nil { |
| 185 | xapp.Logger.Error("Failed to update routing manager. Dropping this Subscription Request message. Err: %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 186 | return |
| 187 | } |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 188 | |
| 189 | // Setting new subscription ID in the RMR header |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 190 | params.SubId = int(newSubId) |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 191 | xapp.Logger.Info("Forwarding Subscription Request to E2T: Mtype: %v, SubId: %v, Xid %s, Meid %v",params.Mtype, params.SubId, params.Xid, params.Meid) |
| 192 | err = c.rmrSend(params) |
| 193 | if err != nil { |
| 194 | xapp.Logger.Error("Failed to send request to E2T %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 195 | } /*else { |
| 196 | c.timerMap.StartTimer(newSubId, subReqTime, c.handleSubscriptionRequestTimer) |
| 197 | }*/ |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 198 | xapp.Logger.Debug("--- Debugging transaction table = %v", c.tracker.transactionTable) |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 199 | return |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 200 | } |
| 201 | |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 202 | func (c *Control) handleSubscriptionResponse(params *xapp.RMRParams) { |
Anssi Mannila | 0a9f260 | 2019-12-09 15:26:44 +0200 | [diff] [blame] | 203 | xapp.Logger.Info("Subscription Response Received from Src: %s, Mtype: %v, SubId: %v, Meid: %v",params.Src, params.Mtype, params.SubId, params.Meid) |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 204 | xapp.Rmr.Free(params.Mbuf) |
| 205 | params.Mbuf = nil |
| 206 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 207 | payloadSeqNum, err := c.e2ap.GetSubscriptionResponseSequenceNumber(params.Payload) |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 208 | if err != nil { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 209 | xapp.Logger.Error("Unable to get Subscription Sequence Number from Payload. Dropping this Subscription Responsemessage. Err: v%, SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 210 | return |
| 211 | } |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 212 | |
| 213 | xapp.Logger.Info("Received payloadSeqNum: %v",payloadSeqNum) |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 214 | if !c.registry.IsValidSequenceNumber(payloadSeqNum) { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 215 | xapp.Logger.Error("Unknown payloadSeqNum. Dropping this Subscription Response message. PayloadSeqNum: %v, SubId: %v, Xid: %s", payloadSeqNum, params.SubId, params.Xid) |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 216 | return |
| 217 | } |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 218 | |
| 219 | // c.timerMap.StopTimer(payloadSeqNum) |
| 220 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 221 | c.registry.setSubscriptionToConfirmed(payloadSeqNum) |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 222 | var transaction Transaction |
| 223 | transaction, err = c.tracker.RetriveTransaction(payloadSeqNum, CREATE) |
| 224 | if err != nil { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 225 | xapp.Logger.Error("Failed to retrive transaction record. Dropping this Subscription Response message. Err: v%, SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 226 | return |
| 227 | } |
| 228 | xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Retrieved old subId...", int(payloadSeqNum), transaction.XappInstanceAddress, transaction.XappPort) |
| 229 | |
| 230 | params.SubId = int(payloadSeqNum) |
| 231 | params.Xid = transaction.OrigParams.Xid |
| 232 | |
| 233 | xapp.Logger.Info("Forwarding Subscription Response to UEEC: Mtype: %v, SubId: %v, Xid: %s, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid) |
| 234 | err = c.rmrReplyToSender(params) |
| 235 | if err != nil { |
| 236 | xapp.Logger.Error("Failed to send response to requestor %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 237 | } |
| 238 | |
| 239 | xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Deleting transaction record", int(payloadSeqNum), transaction.XappInstanceAddress, transaction.XappPort) |
| 240 | transaction, err = c.tracker.completeTransaction(payloadSeqNum, CREATE) |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 241 | if err != nil { |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 242 | xapp.Logger.Error("Failed to delete a Subscription Request transaction record due to %v", err) |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 243 | return |
| 244 | } |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 245 | return |
| 246 | } |
| 247 | |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 248 | func (c *Control) handleSubscriptionFailure(params *xapp.RMRParams) { |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 249 | xapp.Logger.Info("Subscription Failure Received from Src: %s, Mtype: %v, SubId: %v, Meid: %v",params.Src, params.Mtype, params.SubId, params.Meid) |
| 250 | xapp.Rmr.Free(params.Mbuf) |
| 251 | params.Mbuf = nil |
| 252 | |
| 253 | payloadSeqNum, err := c.e2ap.GetSubscriptionFailureSequenceNumber(params.Payload) |
| 254 | if err != nil { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 255 | xapp.Logger.Error("Unable to get Subscription Sequence Number from Payload. Dropping this Subscription Failure message. Err: v%, SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 256 | return |
| 257 | } |
| 258 | xapp.Logger.Info("Received payloadSeqNum: %v", payloadSeqNum) |
| 259 | |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 260 | // c.timerMap.StopTimer(payloadSeqNum) |
| 261 | |
| 262 | var transaction Transaction |
| 263 | transaction, err = c.tracker.RetriveTransaction(payloadSeqNum, CREATE) |
| 264 | if err != nil { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 265 | xapp.Logger.Error("Failed to retrive transaction record. Dropping this Subscription Failure message. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 266 | return |
| 267 | } |
| 268 | xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Forwarding response to requestor...", int(payloadSeqNum), transaction.XappInstanceAddress, transaction.XappPort) |
| 269 | |
| 270 | params.SubId = int(payloadSeqNum) |
| 271 | params.Xid = transaction.OrigParams.Xid |
| 272 | |
| 273 | xapp.Logger.Info("Forwarding Subscription Failure to UEEC: Mtype: %v, SubId: %v, Xid: %v, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid) |
| 274 | err = c.rmrReplyToSender(params) |
| 275 | if err != nil { |
| 276 | xapp.Logger.Error("Failed to send response to requestor %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 277 | } |
| 278 | |
| 279 | time.Sleep(3 * time.Second) |
| 280 | |
| 281 | xapp.Logger.Info("Starting routing manager update") |
Anssi Mannila | 0a9f260 | 2019-12-09 15:26:44 +0200 | [diff] [blame] | 282 | subRouteAction := SubRouteInfo{CREATE, transaction.XappInstanceAddress, transaction.XappPort, payloadSeqNum} |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 283 | err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction) |
| 284 | if err != nil { |
| 285 | xapp.Logger.Error("Failed to update routing manager. Err: %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 286 | } |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 287 | |
| 288 | xapp.Logger.Info("Deleting trancaction record") |
| 289 | if c.registry.releaseSequenceNumber(payloadSeqNum) { |
| 290 | transaction, err = c.tracker.completeTransaction(payloadSeqNum, CREATE) |
| 291 | if err != nil { |
| 292 | xapp.Logger.Error("Failed to delete a Subscription Request transaction record due to %v", err) |
| 293 | return |
| 294 | } |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 295 | } else { |
| 296 | xapp.Logger.Error("Failed to release sequency number. SubId: %v, Xid: %s", params.SubId, params.Xid) |
| 297 | return |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 298 | } |
| 299 | return |
| 300 | } |
| 301 | |
| 302 | func (c *Control) handleSubscriptionRequestTimer(subId uint16) { |
| 303 | xapp.Logger.Info("Subscription Request timer expired. SubId: %v",subId) |
| 304 | /* |
| 305 | transaction, err := c.tracker.completeTransaction(subId, CREATE) |
| 306 | if err != nil { |
| 307 | xapp.Logger.Error("Failed to delete a Subscription Request transaction record due to %v", err) |
| 308 | return |
| 309 | } |
| 310 | xapp.Logger.Info("SubId: %v, Xid %v, Meid: %v",subId, transaction.OrigParams.Xid, transaction.OrigParams.Meid) |
| 311 | |
| 312 | var params xapp.RMRParams |
| 313 | params.Mtype = 12012 //xapp.RICMessageTypes["RIC_SUB_FAILURE"] |
| 314 | params.SubId = int(subId) |
| 315 | params.Meid = transaction.OrigParams.Meid |
| 316 | params.Xid = transaction.OrigParams.Xid |
| 317 | payload := []byte("40C9408098000003EA7E00050000010016EA6300020021EA6E00808180EA6F000400000000EA6F000400010040EA6F000400020080EA6F0004000300C0EA6F000400040100EA6F000400050140EA6F000400060180EA6F0004000701C0EA6F000400080200EA6F000400090240EA6F0004000A0280EA6F0004000B02C0EA6F0004000C0300EA6F0004000D0340EA6F0004000E0380EA6F0004000F03C0") |
| 318 | params.PayloadLen = len(payload) |
| 319 | params.Payload = payload |
| 320 | |
| 321 | xapp.Logger.Info("Forwarding Subscription Failure to UEEC: Mtype: %v, SubId: %v, Xid: %s, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid) |
| 322 | err = c.rmrReplyToSender(¶ms) |
| 323 | if err != nil { |
| 324 | xapp.Logger.Error("Failed to send response to requestor %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 325 | } |
| 326 | */ |
| 327 | /* |
| 328 | time.Sleep(3 * time.Second) |
| 329 | |
| 330 | xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Deleting transaction record", int(subId), transaction.XappInstanceAddress, transaction.XappPort) |
| 331 | |
| 332 | xapp.Logger.Info("Starting routing manager update") |
| 333 | subRouteAction := SubRouteInfo{DELETE, transaction.XappInstanceAddress, transaction.XappPort, payloadSeqNum} |
| 334 | c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction) |
| 335 | |
| 336 | xapp.Logger.Info("Deleting trancaction record") |
| 337 | if c.registry.releaseSequenceNumber(payloadSeqNum) { |
| 338 | transaction, err = c.tracker.completeTransaction(payloadSeqNum, CREATE) |
| 339 | if err != nil { |
| 340 | xapp.Logger.Error("Failed to delete a Subscription Request transaction record due to %v", err) |
| 341 | return |
| 342 | } |
| 343 | } |
| 344 | */ |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 345 | return |
| 346 | } |
| 347 | |
| 348 | func (act Action) String() string { |
| 349 | actions := [...]string{ |
| 350 | "CREATE", |
| 351 | "MERGE", |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 352 | "NONE", |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 353 | "DELETE", |
| 354 | } |
| 355 | |
| 356 | if act < CREATE || act > DELETE { |
| 357 | return "Unknown" |
| 358 | } |
| 359 | return actions[act] |
| 360 | } |
| 361 | |
| 362 | func (act Action) valid() bool { |
| 363 | switch act { |
| 364 | case CREATE, MERGE, DELETE: |
| 365 | return true |
| 366 | default: |
| 367 | return false |
| 368 | } |
| 369 | } |
| 370 | |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 371 | func (c *Control) handleSubscriptionDeleteRequest(params *xapp.RMRParams) { |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 372 | xapp.Logger.Info("Subscription Delete Request Received from Src: %s, Mtype: %v, SubId: %v, Xid: %s, Meid: %v",params.Src, params.Mtype, params.SubId, params.Xid, params.Meid) |
| 373 | xapp.Rmr.Free(params.Mbuf) |
| 374 | params.Mbuf = nil |
| 375 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 376 | payloadSeqNum, err := c.e2ap.GetSubscriptionDeleteRequestSequenceNumber(params.Payload) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 377 | if err != nil { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 378 | xapp.Logger.Error("Unable to get Subscription Sequence Number from Payload. Dropping this Subscription Delete Request message. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 379 | return |
| 380 | } |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 381 | xapp.Logger.Info("Received payloadSeqNum: %v", payloadSeqNum) |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 382 | if c.registry.IsValidSequenceNumber(payloadSeqNum) { |
| 383 | c.registry.deleteSubscription(payloadSeqNum) |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 384 | err = c.trackDeleteTransaction(params, payloadSeqNum) |
| 385 | if err != nil { |
| 386 | xapp.Logger.Error("Failed to create transaction record. Dropping this Subscription Delete Request message. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 387 | return |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 388 | } |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 389 | } else { |
| 390 | xapp.Logger.Error("Not valid sequence number. Dropping this Subscription Delete Request message. SubId: %v, Xid: %s", params.SubId, params.Xid) |
| 391 | return |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 392 | } |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 393 | |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 394 | xapp.Logger.Info("Forwarding Delete Subscription Request to E2T: Mtype: %v, SubId: %v, Xid: %s, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 395 | c.rmrSend(params) |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 396 | if err != nil { |
| 397 | xapp.Logger.Error("Failed to send request to E2T %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 398 | } /*else { |
| 399 | c.timerMap.StartTimer(payloadSeqNum, SubDelReqTime, c.handleSubscriptionDeleteRequestTimer) |
| 400 | }*/ |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 401 | return |
| 402 | } |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 403 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 404 | func (c *Control) trackDeleteTransaction(params *xapp.RMRParams, payloadSeqNum uint16) (err error) { |
| 405 | srcAddr, srcPort, err := c.rtmgrClient.SplitSource(params.Src) |
| 406 | if err != nil { |
| 407 | xapp.Logger.Error("Failed to update routing-manager about the subscription delete request with reason: %s", err) |
| 408 | } |
| 409 | xactKey := TransactionKey{payloadSeqNum, DELETE} |
| 410 | xactValue := Transaction{*srcAddr, *srcPort, params} |
| 411 | err = c.tracker.TrackTransaction(xactKey, xactValue) |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 412 | return |
| 413 | } |
| 414 | |
| 415 | func (c *Control) handleSubscriptionDeleteResponse(params *xapp.RMRParams) (err error) { |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 416 | xapp.Logger.Info("Subscription Delete Response Received from Src: %s, Mtype: %v, SubId: %v, Meid: %v",params.Src, params.Mtype, params.SubId, params.Meid) |
| 417 | xapp.Rmr.Free(params.Mbuf) |
| 418 | params.Mbuf = nil |
| 419 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 420 | payloadSeqNum, err := c.e2ap.GetSubscriptionDeleteResponseSequenceNumber(params.Payload) |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 421 | if err != nil { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 422 | xapp.Logger.Error("Unable to get Subscription Sequence Number from Payload. Dropping this Subscription Delete Response message. Err: %, SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 423 | return |
| 424 | } |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 425 | xapp.Logger.Info("Received payloadSeqNum: %v", payloadSeqNum) |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 426 | |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 427 | // c.timerMap.StopTimer(payloadSeqNum) |
| 428 | |
| 429 | var transaction Transaction |
| 430 | transaction, err = c.tracker.RetriveTransaction(payloadSeqNum, DELETE) |
| 431 | if err != nil { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 432 | xapp.Logger.Error("Failed to retrive transaction record. Dropping this Subscription Delete Response message. Err: %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 433 | return |
| 434 | } |
| 435 | xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Forwarding response to requestor...", int(payloadSeqNum), transaction.XappInstanceAddress, transaction.XappPort) |
| 436 | |
| 437 | params.SubId = int(payloadSeqNum) |
| 438 | params.Xid = transaction.OrigParams.Xid |
| 439 | xapp.Logger.Info("Forwarding Subscription Delete Response to UEEC: Mtype: %v, SubId: %v, Xid: %v, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid) |
| 440 | err = c.rmrReplyToSender(params) |
| 441 | if err != nil { |
| 442 | xapp.Logger.Error("Failed to send response to requestor %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 443 | // return |
| 444 | } |
| 445 | |
| 446 | time.Sleep(3 * time.Second) |
| 447 | |
| 448 | xapp.Logger.Info("Starting routing manager update") |
| 449 | subRouteAction := SubRouteInfo{DELETE, transaction.XappInstanceAddress, transaction.XappPort, payloadSeqNum} |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 450 | err = c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction) |
| 451 | if err != nil { |
| 452 | xapp.Logger.Error("Failed to update routing manager %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 453 | return |
| 454 | } |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 455 | |
| 456 | xapp.Logger.Info("Deleting trancaction record") |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 457 | if c.registry.releaseSequenceNumber(payloadSeqNum) { |
| 458 | transaction, err = c.tracker.completeTransaction(payloadSeqNum, DELETE) |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 459 | if err != nil { |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 460 | xapp.Logger.Error("Failed to delete a Subscription Delete Request transaction record due to %v", err) |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 461 | return |
| 462 | } |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 463 | } else { |
| 464 | xapp.Logger.Error("Failed to release sequency number. SubId: %v, Xid: %s", params.SubId, params.Xid) |
| 465 | return |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame] | 466 | } |
| 467 | return |
| 468 | } |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 469 | |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 470 | func (c *Control) handleSubscriptionDeleteFailure(params *xapp.RMRParams) { |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 471 | xapp.Logger.Info("Subscription Delete Failure Received from Src: %s, Mtype: %v, SubId: %v, Meid: %v",params.Src, params.Mtype, params.SubId, params.Meid) |
| 472 | xapp.Rmr.Free(params.Mbuf) |
| 473 | params.Mbuf = nil |
| 474 | |
| 475 | payloadSeqNum, err := c.e2ap.GetSubscriptionDeleteFailureSequenceNumber(params.Payload) |
| 476 | if err != nil { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 477 | xapp.Logger.Error("Unable to get Subscription Sequence Number from Payload. Dropping this Subscription Delete Failure message. Err: %, SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 478 | return |
| 479 | } |
| 480 | xapp.Logger.Info("Received payloadSeqNum: %v", payloadSeqNum) |
| 481 | |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 482 | // c.timerMap.StopTimer(payloadSeqNum) |
| 483 | |
| 484 | var transaction Transaction |
| 485 | transaction, err = c.tracker.RetriveTransaction(payloadSeqNum, DELETE) |
| 486 | if err != nil { |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 487 | xapp.Logger.Error("Failed to retrive transaction record. Dropping this Subscription Delete Failure message. Err %v, SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 488 | return |
| 489 | } |
| 490 | xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Forwarding response to requestor...", int(payloadSeqNum), transaction.XappInstanceAddress, transaction.XappPort) |
| 491 | |
| 492 | params.SubId = int(payloadSeqNum) |
| 493 | params.Xid = transaction.OrigParams.Xid |
| 494 | xapp.Logger.Info("Forwarding Subscription Delete Failure to UEEC: Mtype: %v, SubId: %v, Xid: %v, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid) |
| 495 | err = c.rmrReplyToSender(params) |
| 496 | if err != nil { |
| 497 | xapp.Logger.Error("Failed to send response to requestor %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 498 | // return |
| 499 | } |
| 500 | |
| 501 | time.Sleep(3 * time.Second) |
| 502 | |
| 503 | xapp.Logger.Info("Starting routing manager update") |
| 504 | subRouteAction := SubRouteInfo{DELETE, transaction.XappInstanceAddress, transaction.XappPort, payloadSeqNum} |
| 505 | c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction) |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 506 | if err != nil { |
| 507 | xapp.Logger.Error("Failed to update routing manager %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 508 | return |
| 509 | } |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 510 | |
| 511 | xapp.Logger.Info("Deleting trancaction record") |
| 512 | if c.registry.releaseSequenceNumber(payloadSeqNum) { |
| 513 | transaction, err = c.tracker.completeTransaction(payloadSeqNum, DELETE) |
| 514 | if err != nil { |
| 515 | xapp.Logger.Error("Failed to delete a Subscription Delete Request transaction record due to %v", err) |
| 516 | return |
| 517 | } |
Anssi Mannila | 90fa021 | 2019-12-12 10:47:47 +0200 | [diff] [blame^] | 518 | } else { |
| 519 | xapp.Logger.Error("Failed to release sequency number. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 520 | return |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame] | 521 | } |
| 522 | return |
| 523 | } |
| 524 | |
| 525 | func (c *Control) handleSubscriptionDeleteRequestTimer(subId uint16) { |
| 526 | xapp.Logger.Info("Subscription Delete Request timer expired. SubId: %v",subId) |
| 527 | /* |
| 528 | transaction, err := c.tracker.completeTransaction(subId, DELETE) |
| 529 | if err != nil { |
| 530 | xapp.Logger.Error("Failed to delete a Subscription Delete Request transaction record due to %v", err) |
| 531 | return |
| 532 | } |
| 533 | xapp.Logger.Info("SubId: %v, Xid %v, Meid: %v",subId, transaction.OrigParams.Xid, transaction.OrigParams.Meid) |
| 534 | |
| 535 | var params xapp.RMRParams |
| 536 | params.Mtype = 12022 //xapp.RICMessageTypes["RIC_SUB_DEL_FAILURE"] |
| 537 | params.SubId = int(subId) |
| 538 | params.Meid = transaction.OrigParams.Meid |
| 539 | params.Xid = transaction.OrigParams.Xid |
| 540 | payload := []byte("40CA4018000003EA7E00050000010016EA6300020021EA74000200C0") |
| 541 | params.PayloadLen = len(payload) |
| 542 | params.Payload = payload |
| 543 | |
| 544 | xapp.Logger.Info("Forwarding Subscription Delete Failure to UEEC: Mtype: %v, SubId: %v, Xid: %s, Meid: %v",params.Mtype, params.SubId, params.Xid, params.Meid) |
| 545 | err = c.rmrReplyToSender(¶ms) |
| 546 | if err != nil { |
| 547 | xapp.Logger.Error("Failed to send response to requestor %v. SubId: %v, Xid: %s", err, params.SubId, params.Xid) |
| 548 | } |
| 549 | */ |
| 550 | /* |
| 551 | time.Sleep(3 * time.Second) |
| 552 | xapp.Logger.Info("Subscription ID: %v, from address: %v:%v. Deleting transaction record", int(subId), transaction.XappInstanceAddress, transaction.XappPort) |
| 553 | |
| 554 | xapp.Logger.Info("Starting routing manager update") |
| 555 | subRouteAction := SubRouteInfo{DELETE, transaction.XappInstanceAddress, transaction.XappPort, payloadSeqNum} |
| 556 | c.rtmgrClient.SubscriptionRequestUpdate(subRouteAction) |
| 557 | |
| 558 | xapp.Logger.Info("Deleting trancaction record") |
| 559 | if c.registry.releaseSequenceNumber(payloadSeqNum) { |
| 560 | transaction, err = c.tracker.completeTransaction(payloadSeqNum, DELETE) |
| 561 | if err != nil { |
| 562 | xapp.Logger.Error("Failed to delete a Subscription Delete Request transaction record due to %v", err) |
| 563 | return |
| 564 | } |
| 565 | } |
| 566 | */ |
| 567 | return |
| 568 | } |