ss412g | 510afe0 | 2020-05-19 13:08:05 +0300 | [diff] [blame] | 1 | // |
| 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 | |
Irina | e281b3f | 2020-01-02 14:06:17 +0200 | [diff] [blame] | 20 | package main |
| 21 | |
| 22 | import ( |
| 23 | "encoding/json" |
| 24 | "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common" |
Irina | 4748d13 | 2020-01-06 15:07:15 +0200 | [diff] [blame] | 25 | "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities" |
Irina | e281b3f | 2020-01-02 14:06:17 +0200 | [diff] [blame] | 26 | "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> |
| 32 | import "C" |
| 33 | |
| 34 | var sdl common.ISdlInstance |
| 35 | var instance reader.RNibReader |
| 36 | |
| 37 | type response struct { |
Irina | 4748d13 | 2020-01-06 15:07:15 +0200 | [diff] [blame] | 38 | GnbList []*entities.NbIdentity `json:"gnb_list"` |
| 39 | ErrorMsg string `json:"error_msg,omitempty"` |
Irina | e281b3f | 2020-01-02 14:06:17 +0200 | [diff] [blame] | 40 | } |
| 41 | |
Irina | 964bdfd | 2020-04-02 00:17:09 +0300 | [diff] [blame] | 42 | //export openSdl |
| 43 | func openSdl() { |
Irina | e281b3f | 2020-01-02 14:06:17 +0200 | [diff] [blame] | 44 | sdl = sdlgo.NewSdlInstance("e2Manager", sdlgo.NewDatabase()) |
| 45 | instance = reader.GetRNibReader(sdl) |
| 46 | } |
| 47 | |
Irina | 964bdfd | 2020-04-02 00:17:09 +0300 | [diff] [blame] | 48 | //export closeSdl |
| 49 | func closeSdl() { |
Irina | e281b3f | 2020-01-02 14:06:17 +0200 | [diff] [blame] | 50 | _ = sdl.Close() |
| 51 | } |
| 52 | |
| 53 | //export getListGnbIds |
| 54 | func getListGnbIds() unsafe.Pointer { |
| 55 | listGnbIds, err := instance.GetListGnbIds() |
Irina | 4748d13 | 2020-01-06 15:07:15 +0200 | [diff] [blame] | 56 | res := &response{} |
Irina | e281b3f | 2020-01-02 14:06:17 +0200 | [diff] [blame] | 57 | |
Irina | c2678e2 | 2020-01-04 23:28:15 +0200 | [diff] [blame] | 58 | if err != nil { |
| 59 | res.ErrorMsg = err.Error() |
| 60 | |
| 61 | return createCBytesResponse(res) |
| 62 | } |
| 63 | |
Irina | 4748d13 | 2020-01-06 15:07:15 +0200 | [diff] [blame] | 64 | if listGnbIds != nil { |
| 65 | res.GnbList = listGnbIds |
Irina | c2678e2 | 2020-01-04 23:28:15 +0200 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | return createCBytesResponse(res) |
| 69 | } |
| 70 | |
| 71 | func createCBytesResponse(res *response) unsafe.Pointer { |
Irina | e281b3f | 2020-01-02 14:06:17 +0200 | [diff] [blame] | 72 | byteResponse, err := json.Marshal(res) |
| 73 | if err != nil { |
| 74 | return nil |
| 75 | } |
| 76 | |
| 77 | return C.CBytes(byteResponse) |
| 78 | } |
| 79 | |
Irina | 4748d13 | 2020-01-06 15:07:15 +0200 | [diff] [blame] | 80 | func main() {} |