blob: 74521d7271fd1b2d6a31b538b3437bd8c432150c [file] [log] [blame]
ss412g510afe02020-05-19 13:08:05 +03001//
2// Copyright 2019 AT&T Intellectual Property
3// Copyright 2019 Nokia
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17// This source code is part of the near-RT RIC (RAN Intelligent Controller)
18// platform project (RICP).
19
Irinae281b3f2020-01-02 14:06:17 +020020package main
21
22import (
23 "encoding/json"
24 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
Irina4748d132020-01-06 15:07:15 +020025 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
Irinae281b3f2020-01-02 14:06:17 +020026 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
27 "gerrit.o-ran-sc.org/r/ric-plt/sdlgo"
28 "unsafe"
29)
30
31//#include <string.h>
32import "C"
33
34var sdl common.ISdlInstance
35var instance reader.RNibReader
36
37type response struct {
Irina4748d132020-01-06 15:07:15 +020038 GnbList []*entities.NbIdentity `json:"gnb_list"`
39 ErrorMsg string `json:"error_msg,omitempty"`
Irinae281b3f2020-01-02 14:06:17 +020040}
41
Irina964bdfd2020-04-02 00:17:09 +030042//export openSdl
43func openSdl() {
Irinae281b3f2020-01-02 14:06:17 +020044 sdl = sdlgo.NewSdlInstance("e2Manager", sdlgo.NewDatabase())
45 instance = reader.GetRNibReader(sdl)
46}
47
Irina964bdfd2020-04-02 00:17:09 +030048//export closeSdl
49func closeSdl() {
Irinae281b3f2020-01-02 14:06:17 +020050 _ = sdl.Close()
51}
52
53//export getListGnbIds
54func getListGnbIds() unsafe.Pointer {
55 listGnbIds, err := instance.GetListGnbIds()
Irina4748d132020-01-06 15:07:15 +020056 res := &response{}
Irinae281b3f2020-01-02 14:06:17 +020057
Irinac2678e22020-01-04 23:28:15 +020058 if err != nil {
59 res.ErrorMsg = err.Error()
60
61 return createCBytesResponse(res)
62 }
63
Irina4748d132020-01-06 15:07:15 +020064 if listGnbIds != nil {
65 res.GnbList = listGnbIds
Irinac2678e22020-01-04 23:28:15 +020066 }
67
68 return createCBytesResponse(res)
69}
70
71func createCBytesResponse(res *response) unsafe.Pointer {
Irinae281b3f2020-01-02 14:06:17 +020072 byteResponse, err := json.Marshal(res)
73 if err != nil {
74 return nil
75 }
76
77 return C.CBytes(byteResponse)
78}
79
Irina4748d132020-01-06 15:07:15 +020080func main() {}