rajalakshmisv | b8bc34d | 2022-01-03 06:14:50 +0000 | [diff] [blame] | 1 | package control
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 2 |
|
| 3 | import (
|
| 4 | "errors"
|
| 5 | "fmt"
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 6 | "log"
|
| 7 | "os"
|
| 8 | "strconv"
|
| 9 | "sync"
|
| 10 | "time"
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 11 |
|
| 12 | "gerrit.o-ran-sc.org/r/ric-app/rc/protocol/grpc/ricmsgcommrpc/rc"
|
| 13 | "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 14 | )
|
| 15 |
|
| 16 | var (
|
| 17 | gControlData *Control
|
| 18 | gChan_RicControlReq_handle = make(chan *rc.RicControlGrpcReq, 2000) //Make it configurable
|
| 19 | )
|
| 20 |
|
| 21 | func NewControl() Control {
|
| 22 |
|
| 23 | file := "/opt/rc.log"
|
| 24 | logFile, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0766)
|
| 25 | if err != nil {
|
| 26 | panic(err)
|
| 27 | }
|
| 28 | log.SetOutput(logFile)
|
| 29 | log.SetPrefix("[qSkipTool]")
|
| 30 | log.SetFlags(log.LstdFlags | log.Lshortfile | log.LUTC)
|
| 31 | logLevel := xapp.Config.GetInt("controls.logLevel")
|
| 32 | xapp.Logger.SetLevel(logLevel)
|
| 33 |
|
| 34 | xapp.Logger.Debug("GRPC Server Port = %v ", xapp.Config.GetString("controls.ricHOControlgRpcServerPort"))
|
| 35 | xapp.Logger.Debug("Log Level = %d ", xapp.Config.GetInt("controls.logLevel"))
|
| 36 |
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 37 | go StartgRPCRCControlCommServerRoutine()
|
| 38 | xapp.Logger.Debug("StartgRPCRCControlCommServerRoutine done")
|
| 39 |
|
| 40 | //To Handle RIC Control Message
|
| 41 | go StartHandleControlReqRoutine()
|
| 42 |
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 43 | return Control{5,
|
| 44 | make(chan *xapp.RMRParams, 1000), //Make it configurable
|
| 45 | make(map[int]bool),
|
| 46 | &sync.Mutex{},
|
| 47 | 0}
|
| 48 | }
|
| 49 |
|
| 50 | func ReadyCB(i interface{}) {
|
| 51 | gControlData = i.(*Control)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 52 | go controlLoop()
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 53 | }
|
| 54 |
|
| 55 | func (aControlData *Control) Run() {
|
| 56 | xapp.SetReadyCB(ReadyCB, aControlData)
|
| 57 | xapp.Run(aControlData)
|
| 58 | }
|
| 59 |
|
| 60 | func (aControlData *Control) Consume(rp *xapp.RMRParams) (err error) {
|
| 61 | gControlData.rcChan <- rp
|
| 62 | return
|
| 63 | }
|
| 64 |
|
| 65 | func (aControlData *Control) rmrSend(params *xapp.RMRParams) (err error) {
|
| 66 | if !xapp.Rmr.Send(params, false) {
|
| 67 | err = errors.New("rmr.Send() failed")
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 68 | xapp.Logger.Info("Failed to rmrSend to %v", err)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 69 | log.Printf("Failed to rmrSend to %v", err)
|
| 70 | }
|
| 71 | return
|
| 72 | }
|
| 73 |
|
| 74 | func (aControlData *Control) rmrReplyToSender(params *xapp.RMRParams) (err error) {
|
| 75 | if !xapp.Rmr.Send(params, true) {
|
| 76 | err = errors.New("rmr.Send() failed")
|
| 77 | xapp.Logger.Error("Failed to rmrReplyToSender to %v", err)
|
| 78 | log.Printf("Failed to rmrReplyToSender to %v", err)
|
| 79 | }
|
| 80 | return
|
| 81 | }
|
| 82 |
|
| 83 | func controlLoop() {
|
| 84 | for {
|
| 85 | msg := <-gControlData.rcChan
|
| 86 | xapp.Logger.Debug("Received message type: %d", msg.Mtype)
|
| 87 | log.Printf("Received message type: %d", msg.Mtype)
|
| 88 | switch msg.Mtype {
|
| 89 | case 12041:
|
| 90 | go HandleControlResponse(msg)
|
| 91 | case 12042:
|
| 92 | go HandleControlFailure(msg)
|
| 93 | default:
|
| 94 | err := errors.New("Message Type " + strconv.Itoa(msg.Mtype) + " is discarded")
|
| 95 | xapp.Logger.Error("Unknown message type: %v", err)
|
| 96 | log.Printf("Unknown message type: %v", err)
|
| 97 | }
|
| 98 | }
|
| 99 | }
|
| 100 |
|
| 101 | func StartHandleControlReqRoutine() {
|
| 102 |
|
| 103 | log.Printf("Starting Go Routine for Handling GRPC RIC Control msg ")
|
| 104 | xapp.Logger.Info("Starting Go Routine for Handling GRPC RIC Control msg ")
|
| 105 | for {
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 106 | HandlegRPCRICControlMsgReq(<-gChan_RicControlReq_handle)
|
| 107 | }
|
| 108 | xapp.Logger.Debug("StartHandleControlReqRoutine Done")
|
| 109 | }
|
| 110 |
|
| 111 | func HandlegRPCRICControlMsgReq(aPtrRicControlGrpcReq *rc.RicControlGrpcReq) {
|
| 112 |
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 113 | xapp.Logger.Debug("HandlegRPCRICControlMsgReq :%v", *aPtrRicControlGrpcReq)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 114 | lRicHoControlMsg := RicHoControlMsg{}
|
| 115 | lRicHoControlMsg.RicControlGrpcReqPtr = aPtrRicControlGrpcReq
|
| 116 |
|
| 117 | lUEID := lRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 118 | xapp.Logger.Debug("HandlegRPCRICControlMsgReq UEID = %v ", lUEID)
|
| 119 | //Mandatory parameters validation
|
| 120 | if lRicHoControlMsg.RicControlGrpcReqPtr.E2NodeID == "" ||
|
| 121 | lRicHoControlMsg.RicControlGrpcReqPtr.RICControlMessageData.TargetCellID == "" ||
|
| 122 | lRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID.GnbUEID.AmfUENGAPID < 0 ||
|
| 123 | lRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID.GnbUEID.Guami.PLMNIdentity == "" ||
|
| 124 | lRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID.GnbUEID.Guami.AMFRegionID == "" ||
|
| 125 | lRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID.GnbUEID.Guami.AMFSetID == "" ||
|
| 126 | lRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID.GnbUEID.Guami.AMFPointer == "" ||
|
| 127 | len(lRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID.GnbUEID.GNBCUUEF1APID) == 0 ||
|
| 128 | len(lRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID.GnbUEID.GNBCUCPUEE1APID) == 0 ||
|
| 129 | lRicHoControlMsg.RicControlGrpcReqPtr.PlmnID == "" ||
|
| 130 | lRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.ControlActionId < 0 ||
|
| 131 | lRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.ControlStyle < 0 ||
|
| 132 | lRicHoControlMsg.RicControlGrpcReqPtr.RICControlMessageData.RICControlCellTypeVal < 0 ||
|
| 133 | lRicHoControlMsg.RicControlGrpcReqPtr.RICE2APHeaderData.RICRequestorID < 0 ||
|
| 134 | lRicHoControlMsg.RicControlGrpcReqPtr.RICE2APHeaderData.RanFuncId < 0 {
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 135 | xapp.Logger.Error("Mandaroty parameters missing, dont send control request ")
|
| 136 | return
|
| 137 | }
|
| 138 |
|
| 139 | lRicHoControlMsg.GetSequenceNumber()
|
| 140 |
|
| 141 | go lRicHoControlMsg.SendRicControlRequest(lRicHoControlMsg.GetSequenceNumber())
|
| 142 |
|
| 143 | return
|
| 144 | }
|
| 145 |
|
| 146 | func (aRicHoControlMsg *RicHoControlMsg) GetSequenceNumber() int {
|
| 147 |
|
| 148 | //Incrementing the RIC Requestor Instance Id to make the request unique and traceable.
|
| 149 | gControlData.eventRicControlReqExpiredMu.Lock()
|
| 150 | gControlData.ricRequestInstanceID = gControlData.ricRequestInstanceID + 1
|
| 151 | gControlData.eventRicControlReqExpiredMu.Unlock()
|
| 152 |
|
| 153 | return gControlData.ricRequestInstanceID
|
| 154 | }
|
| 155 |
|
| 156 | func (aRicHoControlMsg *RicHoControlMsg) setEventRicControlCreateExpiredTimer(aSeqNum int) {
|
| 157 |
|
| 158 | gControlData.eventRicControlReqExpiredMu.Lock()
|
| 159 | gControlData.eventRicControlReqExpiredMap[aSeqNum] = false
|
| 160 | gControlData.eventRicControlReqExpiredMu.Unlock()
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 161 | controlAckTimer := xapp.Config.GetInt("controls.controlAckTimer")
|
| 162 | xapp.Logger.Debug("configured controlAckTimer = %d and controlAckTimer = %d ", xapp.Config.GetInt("controls.controlAckTimer"),controlAckTimer)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 163 |
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 164 | timer := time.NewTimer(time.Duration(controlAckTimer) * time.Second)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 165 | go func(t *time.Timer) {
|
| 166 | defer t.Stop()
|
| 167 | xapp.Logger.Debug("RIC_CONTROL_REQ[%s]: Waiting for RIC_CONTROL_RESP...", aSeqNum)
|
| 168 | log.Printf("RIC_CONTROL_REQ[%s]: Waiting for RIC_CONTROL_RESP...", aSeqNum)
|
| 169 | for {
|
| 170 | select {
|
| 171 | case <-t.C:
|
| 172 | gControlData.eventRicControlReqExpiredMu.Lock()
|
| 173 | isResponsed := gControlData.eventRicControlReqExpiredMap[aSeqNum]
|
| 174 | delete(gControlData.eventRicControlReqExpiredMap, aSeqNum)
|
| 175 | gControlData.eventRicControlReqExpiredMu.Unlock()
|
| 176 | if !isResponsed {
|
| 177 | xapp.Logger.Debug("RIC_CONTROL_REQ[%s]: RIC Event Create Timer experied!", aSeqNum)
|
| 178 | log.Printf("RIC_CONTROL_REQ[%s]: RIC Event Create Timer experied!", aSeqNum)
|
| 179 | //Send ErrorIndication message on Timeout
|
| 180 | return
|
| 181 | }
|
| 182 | default:
|
| 183 | gControlData.eventRicControlReqExpiredMu.Lock()
|
| 184 | flag := gControlData.eventRicControlReqExpiredMap[aSeqNum]
|
| 185 | if flag {
|
| 186 | delete(gControlData.eventRicControlReqExpiredMap, aSeqNum)
|
| 187 | gControlData.eventRicControlReqExpiredMu.Unlock()
|
| 188 | xapp.Logger.Debug("RIC_CONTROL_REQ[%s]: RIC Event Create Timer canceled!", aSeqNum)
|
| 189 | log.Printf("RIC_CONTROL_REQ[%s]: RIC Event Create Timer canceled!", aSeqNum)
|
| 190 | return
|
| 191 | } else {
|
| 192 | gControlData.eventRicControlReqExpiredMu.Unlock()
|
| 193 | }
|
| 194 | }
|
| 195 | time.Sleep(100 * time.Millisecond)
|
| 196 | }
|
| 197 | }(timer)
|
| 198 | }
|
| 199 | func (aRicHoControlMsg *RicHoControlMsg) SendRicControlRequest(aRequestSN int) (err error) {
|
| 200 | var e2ap *E2ap
|
| 201 | var e2sm *E2sm
|
| 202 |
|
| 203 | xapp.Logger.Info("SendRicControlRequest Enter for RanName = %s", aRicHoControlMsg.RicControlGrpcReqPtr.RanName)
|
| 204 |
|
| 205 | if aRicHoControlMsg.RicControlGrpcReqPtr == nil {
|
| 206 | return err
|
| 207 | }
|
| 208 |
|
| 209 | var lRicControlStyleType int64 = aRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.ControlStyle
|
| 210 | var lRicControlActionID int64 = aRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.ControlActionId
|
| 211 | lUEID := aRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID
|
| 212 |
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 213 | var ueId_data UEid
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 214 |
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 215 | xapp.Logger.Debug("UEID:%v, ueId_data strct :%v", aRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID,
|
| 216 | ueId_data)
|
| 217 | ueId_data.amf_UE_NGAP_Id = lUEID.GnbUEID.AmfUENGAPID
|
| 218 | ueId_data.pLMNIdentitybuf = lUEID.GnbUEID.Guami.PLMNIdentity
|
| 219 | ueId_data.aMFRegionIDbuf = lUEID.GnbUEID.Guami.AMFRegionID
|
| 220 | ueId_data.aMFSetIDbuf = lUEID.GnbUEID.Guami.AMFSetID
|
| 221 | ueId_data.aMFPointerbuf = lUEID.GnbUEID.Guami.AMFPointer
|
| 222 | ueId_data.F1AP_id = lUEID.GnbUEID.GNBCUUEF1APID
|
| 223 | ueId_data.E1AP_id = lUEID.GnbUEID.GNBCUCPUEE1APID
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 224 |
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 225 | var lRicControlHeader []byte = make([]byte, 1024) //Check the Size
|
| 226 | lRicControlHeaderEncoded, err := e2sm.SetRicControlHeader(lRicControlHeader, &ueId_data, lRicControlStyleType, lRicControlActionID)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 227 | if err != nil {
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 228 | xapp.Logger.Error("SetRicControlHeader Failed: %v, UEID:%v", err, aRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID)
|
| 229 | log.Printf("SetRicControlHeader Failed: %v, UEID:%v", err, aRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 230 | return err
|
| 231 | } else {
|
| 232 | xapp.Logger.Info("SetRicControlHeader is success: %x", lRicControlHeaderEncoded)
|
| 233 | fmt.Fprintf(os.Stderr, "Encoded RIC Control Header PDU:\n")
|
| 234 | for i := 0; i < len(lRicControlHeaderEncoded); i++ {
|
| 235 | fmt.Fprintf(os.Stderr, " %02x", lRicControlHeaderEncoded[i])
|
| 236 | }
|
| 237 | fmt.Fprintf(os.Stderr, "\n")
|
| 238 | }
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 239 | var lTargetPrimaryCell int64 = RIC_CONTROL_TARGET_PRIMARY_CELL
|
| 240 | var lTargetCell int64 = RIC_CONTROL_TARGET_CELL
|
| 241 | var lNrCGIOrECGI int64 = RIC_CONTROL_CGI_TYPE
|
| 242 |
|
| 243 | lNrOrEUtraCellType := aRicHoControlMsg.RicControlGrpcReqPtr.RICControlMessageData.RICControlCellTypeVal
|
| 244 | lTargetCellVal := aRicHoControlMsg.RicControlGrpcReqPtr.RICControlMessageData.TargetCellID
|
| 245 | lTargetCellValBuf := []byte(lTargetCellVal)
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 246 | //lNRPlmnId := []byte(aRicHoControlMsg.RicControlGrpcReqPtr.RICControlMessageData.TargetCellID.PlmnID)
|
| 247 | //lNRCellId := aRicHoControlMsg.RicControlGrpcReqPtr.RICControlMessageData.TargetCellID.NRCellID
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 248 |
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 249 |
|
| 250 | var lRicControlMessage []byte = make([]byte, 1024)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 251 | lRicControlMessageEncoded, err := e2sm.SetRicControlMessage(lRicControlMessage, lTargetPrimaryCell, lTargetCell, lNrCGIOrECGI, int64(lNrOrEUtraCellType), lTargetCellValBuf)
|
| 252 | if err != nil {
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 253 | xapp.Logger.Error("SetRicControlMessage Failed: %v, UEID:%v", err, aRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID)
|
| 254 | log.Printf("SetRicControlMessage Failed: %v, UEID:%v", err, aRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 255 | return err
|
| 256 | } else {
|
| 257 | xapp.Logger.Debug("SetRicControlMessage is success: %x", lRicControlMessageEncoded)
|
| 258 | fmt.Fprintf(os.Stderr, "Encoded RIC Control Message PDU:\n")
|
| 259 | for i := 0; i < len(lRicControlMessageEncoded); i++ {
|
| 260 | fmt.Fprintf(os.Stderr, " %02x", lRicControlMessageEncoded[i])
|
| 261 | }
|
| 262 | fmt.Fprintf(os.Stderr, "\n")
|
| 263 | }
|
| 264 |
|
| 265 | lParams := &xapp.RMRParams{}
|
| 266 | lParams.Mtype = 12040 //RIC_CONTROL_REQ
|
| 267 | lParams.SubId = -1
|
| 268 |
|
| 269 | var lRequestorId uint16 = uint16(aRicHoControlMsg.RicControlGrpcReqPtr.RICE2APHeaderData.RICRequestorID)
|
| 270 | var lFuncId uint16 = uint16(aRicHoControlMsg.RicControlGrpcReqPtr.RICE2APHeaderData.RanFuncId)
|
| 271 |
|
| 272 | lParams.Payload = make([]byte, 2048)
|
| 273 | lParams.Payload, err = e2ap.SetRicControlRequestPayload(lParams.Payload, lRequestorId, uint16(aRequestSN), lFuncId,
|
| 274 | lRicControlHeaderEncoded, lRicControlMessageEncoded)
|
| 275 | if err != nil {
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 276 | xapp.Logger.Error("SetRicControlRequestPayload Failed: %v, UEID:%v", err, aRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID)
|
| 277 | log.Printf("SetRicControlRequestPayload Failed: %v, UEID:%v", err, aRicHoControlMsg.RicControlGrpcReqPtr.RICControlHeaderData.UEID)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 278 | return err
|
| 279 | } else {
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 280 |
|
| 281 | xapp.Logger.Debug("Encoding RicControlRequestPayload is success. UEID: %v, Payload: %x", lUEID, lParams.Payload)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 282 | fmt.Fprintf(os.Stderr, "Encoded RIC Control Req PDU:\n")
|
| 283 | for i := 0; i < len(lParams.Payload); i++ {
|
| 284 | fmt.Fprintf(os.Stderr, " %02x", lParams.Payload[i])
|
| 285 | }
|
| 286 | fmt.Fprintf(os.Stderr, "\n")
|
| 287 | }
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 288 | lParams.PayloadLen = len(lParams.Payload)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 289 | valEnbId := aRicHoControlMsg.RicControlGrpcReqPtr.E2NodeID
|
| 290 | valRanName := aRicHoControlMsg.RicControlGrpcReqPtr.RanName
|
| 291 | valPlmnId := aRicHoControlMsg.RicControlGrpcReqPtr.PlmnID
|
| 292 | lParams.Meid = &xapp.RMRMeid{PlmnID: valPlmnId, EnbID: valEnbId, RanName: valRanName}
|
| 293 |
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 294 | xapp.Logger.Debug("The RIC Control RMR message to be sent is with MsgType:%d SubId=%d, lParams.Meid: %v, UEID: %v", lParams.Mtype, lParams.SubId, lParams.Meid, lUEID)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 295 |
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 296 | xapp.Logger.Debug("Sending RIC Control message to RanName: %s, UEID: %v ", aRicHoControlMsg.RicControlGrpcReqPtr.RanName, lUEID)
|
| 297 |
|
| 298 | xapp.Logger.Info("lParams %v ",lParams)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 299 | err = gControlData.rmrSend(lParams)
|
| 300 | if err != nil {
|
| 301 | xapp.Logger.Error("Failed to send RIC_CONTROL_REQ: %v", err)
|
| 302 | log.Printf("Failed to send RIC_CONTROL_REQ: %v", err)
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 303 | xapp.Logger.Info("Failed to send RIC_CONTROL_REQ: %v", err)
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 304 | return err
|
| 305 | }
|
| 306 |
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 307 | xapp.Logger.Info("Sending RIC Control message to RanName: %s, UEID: %v Success", aRicHoControlMsg.RicControlGrpcReqPtr.RanName, lUEID)
|
| 308 | //Start Timer Operation.
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 309 | aRicHoControlMsg.setEventRicControlCreateExpiredTimer(aRequestSN) //TODO check if this is required as we are not expecting Control ACK
|
| 310 |
|
| 311 | return nil
|
| 312 | }
|
| 313 |
|
| 314 | func HandleControlResponse(params *xapp.RMRParams) (err error) {
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 315 |
|
| 316 | var e2ap *E2ap
|
| 317 | var e2sm *E2sm
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 318 | xapp.Logger.Debug("The SubId in RIC_CONTROL_RESP is %d", params.SubId)
|
| 319 | log.Printf("The SubId in RIC_CONTROL_RESP is %d", params.SubId)
|
| 320 |
|
rajalakshmisv | 960885a | 2022-05-31 14:59:10 +0000 | [diff] [blame] | 321 |
|
| 322 |
|
| 323 | //Decode the RIC Control Ack message
|
| 324 | controlAck, err := e2ap.GetControlAckMsg(params.Payload)
|
| 325 | if err != nil {
|
| 326 | xapp.Logger.Error("Failed to decode RIC Control Ack: %v", err)
|
| 327 | log.Println("Failed to decode RIC Control Ack: %v", err)
|
| 328 | return
|
| 329 | }
|
| 330 | log.Println("E2ap RIC RIC Control Ack message decoded \n")
|
| 331 | xapp.Logger.Info("E2ap RIC RIC Control Ack message decoded \n")
|
| 332 | gControlData.eventRicControlReqExpiredMu.Lock()
|
| 333 | _,ok := gControlData.eventRicControlReqExpiredMap[int(controlAck.InstanceId)]
|
| 334 | if !ok {
|
| 335 | gControlData.eventRicControlReqExpiredMu.Unlock()
|
| 336 | xapp.Logger.Debug("RIC_CONTROL_REQ has been deleted!")
|
| 337 | log.Printf("RIC_CONTROL_REQ has been deleted!")
|
| 338 | return nil
|
| 339 | } else {
|
| 340 | gControlData.eventRicControlReqExpiredMap[int(controlAck.InstanceId)] = true
|
| 341 | gControlData.eventRicControlReqExpiredMu.Unlock()
|
| 342 | }
|
| 343 |
|
| 344 | controlOutcome, err := e2sm.GetControlOutcome(controlAck.ControlOutcome)
|
| 345 | if err != nil {
|
| 346 | xapp.Logger.Error("Failed to decode RIC Control Outcome: %v", err)
|
| 347 | log.Println("Failed to decode RIC Control Outcome: %v", err)
|
| 348 | return
|
| 349 | }
|
| 350 | log.Println("E2SM-RC RIC Control Outcome decoded \n",controlOutcome)
|
| 351 | xapp.Logger.Info("E2SM-RC RIC Control Outcome decoded \n",controlOutcome)
|
| 352 |
|
| 353 |
|
| 354 |
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 355 | return nil
|
| 356 | }
|
| 357 |
|
| 358 | func HandleControlFailure(params *xapp.RMRParams) (err error) {
|
| 359 |
|
rajalakshmisv | 90fe232 | 2022-06-30 14:00:14 +0000 | [diff] [blame] | 360 | var e2ap *E2ap
|
| 361 |
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 362 | xapp.Logger.Debug("The SubId in RIC_CONTROL_FAILURE is %d", params.SubId)
|
| 363 | log.Printf("The SubId in RIC_CONTROL_FAILURE is %d", params.SubId)
|
| 364 |
|
rajalakshmisv | 90fe232 | 2022-06-30 14:00:14 +0000 | [diff] [blame] | 365 | controlAck, err := e2ap.GetControlFailureMsg(params.Payload)
|
| 366 | if err != nil {
|
| 367 | xapp.Logger.Debug("Failed to decode RIC Control message: %v", err)
|
| 368 | log.Println("Failed to decode RIC Control Ack: %v", err)
|
| 369 | return
|
| 370 | }
|
| 371 | log.Println("E2ap RIC Control Ack message decoded \n")
|
| 372 | xapp.Logger.Debug("E2ap RIC Control Ack message decoded \n")
|
| 373 |
|
| 374 | gControlData.eventRicControlReqExpiredMu.Lock()
|
| 375 | _, ok := gControlData.eventRicControlReqExpiredMap[int(controlAck.InstanceId)]
|
| 376 | if !ok {
|
| 377 | gControlData.eventRicControlReqExpiredMu.Unlock()
|
| 378 | xapp.Logger.Debug("RIC_CONTROL_REQ has been deleted!")
|
| 379 | log.Printf("RIC_CONTROL_REQ has been deleted!")
|
| 380 | return nil
|
| 381 | } else {
|
| 382 | gControlData.eventRicControlReqExpiredMap[int(controlAck.InstanceId)] = true
|
| 383 | gControlData.eventRicControlReqExpiredMu.Unlock()
|
| 384 | }
|
rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 385 | return nil
|
| 386 | }
|