docs folder change
[ric-app/rc.git] / control / rcE2SmRc.go
1 package control
2
3 /*
4 #include <e2sm/wrapper.h>
5 #cgo LDFLAGS: -le2smwrapper -lm
6 #cgo CFLAGS: -I/usr/local/include/e2sm
7 */
8 import "C"
9
10 import (
11         "errors"
12         "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
13         "unsafe"
14 )
15
16 type E2sm struct {
17 }
18
19 func (c *E2sm) SetRicControlHeader(buffer []byte, ueIDbuf []byte, ricControlStyleType int64, ricControlActionID int64) (newBuffer []byte, err error) {
20         cptr := unsafe.Pointer(&buffer[0])
21         cptr_ueIDbuf := unsafe.Pointer(&ueIDbuf[0])
22         size := C.e2sm_encode_ric_control_header(cptr, C.size_t(len(buffer)), cptr_ueIDbuf, C.size_t(len(ueIDbuf)),
23                 C.long(ricControlStyleType), C.long(ricControlActionID))
24
25         if size < 0 {
26                 return make([]byte, 0), errors.New("e2sm wrapper is unable to set EventTriggerDefinition due to wrong or invalid input")
27         }
28         newBuffer = C.GoBytes(cptr, (C.int(size)+7)/8)
29         xapp.Logger.Info("E2sm SetRicControlHeader is success")
30         return
31 }
32
33 func (c *E2sm) SetRicControlMessage(buffer []byte, targetPrimaryCell int64, targetCell int64, nrCGIOrECGI int64, nrOrEUtraCell int64, ranParameterValue []byte) (newBuffer []byte, err error) {
34         cptr := unsafe.Pointer(&buffer[0])
35         cptrRanParameterValue := unsafe.Pointer(&ranParameterValue[0])
36
37         size := C.e2sm_encode_ric_control_message(cptr, C.size_t(len(buffer)), C.long(targetPrimaryCell),
38                 C.long(targetCell), C.long(nrOrEUtraCell), C.long(nrCGIOrECGI), cptrRanParameterValue, C.size_t(len(ranParameterValue)))
39         if size < 0 {
40                 return make([]byte, 0), errors.New("e2sm wrapper is unable to set RicControlMessage due to wrong or invalid input")
41         }
42         newBuffer = C.GoBytes(cptr, (C.int(size)+7)/8) //TOCHECK: if C.int(size) is returning bits not bytes to get correct size of the buffer.
43         xapp.Logger.Info("E2sm SetRicControlMessage is success")
44         return
45 }