docs folder change
[ric-app/rc.git] / control / rcE2AP.go
1 package control
2
3 /*
4 #include <stdlib.h>
5 #include <e2ap/wrapper.h>
6 #cgo LDFLAGS: -le2apwrapper
7 #cgo CFLAGS: -I/usr/local/include/e2ap
8 */
9 import "C"
10
11 import (
12         "errors"
13         "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
14         "unsafe"
15 )
16
17 type E2ap struct {
18 }
19
20 func (c *E2ap) SetRicControlRequestPayload(payload []byte, ricRequestorID uint16, ricRequestSequenceNumber uint16, ranFunctionID uint16,
21         ricControlHdr []byte, ricControlMsg []byte) (newPayload []byte, err error) {
22
23         cptr := unsafe.Pointer(&payload[0])
24         cptr_ricControlHdr := unsafe.Pointer(&ricControlHdr[0])
25         cptr_ricControlMsg := unsafe.Pointer(&ricControlMsg[0])
26
27         xapp.Logger.Debug("\n")
28         xapp.Logger.Debug("ricControlHdr\n", ricControlHdr)
29         xapp.Logger.Debug("\n")
30         xapp.Logger.Debug("ricControlMsg\n", ricControlMsg)
31         xapp.Logger.Debug("\n")
32
33         size := C.e2ap_encode_ric_control_request_message(cptr, C.size_t(len(payload)), C.long(ricRequestorID), C.long(ricRequestSequenceNumber),
34                 C.long(ranFunctionID), cptr_ricControlHdr, C.size_t(len(ricControlHdr)), cptr_ricControlMsg, C.size_t(len(ricControlMsg)))
35         if size < 0 {
36                 return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Request Payload due to wrong or invalid payload")
37         }
38         newPayload = C.GoBytes(cptr, (C.int(size)+7)/8)
39         xapp.Logger.Info("SetRicControlHeader is success")
40         return
41 }
42