2e1f4aceca9ec8d0291f646d3c3efac21d142625
[ric-plt/submgr.git] / test / e2t / e2t.go
1 /*
2 ==================================================================================
3   Copyright (c) 2019 AT&T Intellectual Property.
4   Copyright (c) 2019 Nokia
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 */
19
20 package main
21
22 import (
23         "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
24         /* TODO: removed to being able to integrate with UEMGR
25         submgr "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/control"
26         */
27         "errors"
28 )
29
30 type E2t struct {
31 }
32
33 func (e E2t ) Consume(mtype, sub_id int, len int, payload []byte) (err error) {
34         /* TODO: removed to being able to integrate with UEMGR
35         asn1 := submgr.Asn1{}
36         message, err := asn1.Decode(payload)
37         if err != nil {
38                 xapp.Logger.Debug("E2T asn1Decoding failure due to "+ err.Error())
39                 return
40         }
41         */
42         xapp.Logger.Info("E2T Received Message with RMR Subsriprion ID: %v, Responding...", sub_id)
43         err = e.subscriptionResponse(sub_id, payload)
44         return
45 }
46
47 func (e E2t ) subscriptionResponse(sub_id int, payload []byte) (err error) {
48         /* TODO: removed to being able to integrate with UEMGR
49         asn1 := submgr.Asn1{}
50         payload, err := asn1.Encode(submgr.RmrPayload{8, sub_id, "E2T: RCO Subscribed"})
51         if err != nil {
52                 return
53         }
54         */
55         if !xapp.Rmr.Send(12011, sub_id, len(payload), payload) {
56                 err = errors.New("rmr.Send() failed")   
57         }
58         return
59 }
60
61 func main() {
62         e2t := E2t{}
63         xapp.Run(e2t)
64 }