blob: 9ecef4e07b55ead84f2e7eccdb07c68608356748 [file] [log] [blame]
kalnagy45114752019-06-18 14:40:39 +02001/*
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
20package control
21
Peter Szilagyifbc56f92019-07-23 19:29:46 +000022/*
23#include <wrapper.h>
24
25#cgo LDFLAGS: -lwrapper
26*/
27import "C"
28
kalnagy45114752019-06-18 14:40:39 +020029import (
Peter Szilagyifbc56f92019-07-23 19:29:46 +000030 "errors"
31 "unsafe"
kalnagy45114752019-06-18 14:40:39 +020032)
33
34type E2ap struct {
35}
36
Peter Szilagyifbc56f92019-07-23 19:29:46 +000037func (c *E2ap) GetSubscriptionRequestSequenceNumber(payload []byte) (sub_id uint16, err error) {
38 cptr := unsafe.Pointer(&payload[0])
39 cret := C.e2ap_get_ric_subscription_request_sequence_number(cptr, C.size_t(len(payload)))
40 if cret < 0 {
41 return 0, errors.New("e2ap wrapper is unable to get Subscirption Request Sequence Number due to wrong or invalid payload")
42 }
43 sub_id = uint16(cret)
44 return
kalnagy45114752019-06-18 14:40:39 +020045}
46
Peter Szilagyifbc56f92019-07-23 19:29:46 +000047func (c *E2ap) SetSubscriptionRequestSequenceNumber(payload []byte, newSubscriptionid uint16) (new_payload []byte, err error) {
48 cptr := unsafe.Pointer(&payload[0])
49 size := C.e2ap_set_ric_subscription_request_sequence_number(cptr, C.size_t(len(payload)), C.long(newSubscriptionid))
50 if size < 0 {
51 return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscirption Request Sequence Number due to wrong or invalid payload")
52 }
53 new_payload = C.GoBytes(cptr, C.int(size))
54 return
kalnagy45114752019-06-18 14:40:39 +020055}
56
Peter Szilagyifbc56f92019-07-23 19:29:46 +000057func (c *E2ap) GetSubscriptionResponseSequenceNumber(payload []byte) (sub_id uint16, err error) {
58 cptr := unsafe.Pointer(&payload[0])
59 cret := C.e2ap_get_ric_subscription_response_sequence_number(cptr, C.size_t(len(payload)))
60 if cret < 0 {
61 return 0, errors.New("e2ap wrapper is unable to get Subscirption Response Sequence Number due to wrong or invalid payload")
62 }
63 sub_id = uint16(cret)
64 return
kalnagy45114752019-06-18 14:40:39 +020065}
66
Peter Szilagyifbc56f92019-07-23 19:29:46 +000067func (c *E2ap) SetSubscriptionResponseSequenceNumber(payload []byte, newSubscriptionid uint16) (new_payload []byte, err error) {
68 cptr := unsafe.Pointer(&payload[0])
69 size := C.e2ap_set_ric_subscription_response_sequence_number(cptr, C.size_t(len(payload)), C.long(newSubscriptionid))
70 if size < 0 {
71 return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscirption Reponse Sequence Number due to wrong or invalid payload")
72 }
73 new_payload = C.GoBytes(cptr, C.int(size))
74 return
kalnagy45114752019-06-18 14:40:39 +020075}
kalnagy93cc3e22019-09-19 11:29:29 +020076
77/* RICsubscriptionDeleteRequest */
78
79func (c *E2ap) GetSubscriptionDeleteRequestSequenceNumber(payload []byte) (sub_id uint16, err error) {
80 cptr := unsafe.Pointer(&payload[0])
81 cret := C.e2ap_get_ric_subscription_delete_request_sequence_number(cptr, C.size_t(len(payload)))
82 if cret < 0 {
83 return 0, errors.New("e2ap wrapper is unable to get Subscirption Delete Request Sequence Number due to wrong or invalid payload")
84 }
85 sub_id = uint16(cret)
86 return
87}
88
89func (c *E2ap) SetSubscriptionDeleteRequestSequenceNumber(payload []byte, newSubscriptionid uint16) (new_payload []byte, err error) {
90 cptr := unsafe.Pointer(&payload[0])
91 size := C.e2ap_set_ric_subscription_delete_request_sequence_number(cptr, C.size_t(len(payload)), C.long(newSubscriptionid))
92 if size < 0 {
93 return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscirption Request Sequence Number due to wrong or invalid payload")
94 }
95 new_payload = C.GoBytes(cptr, C.int(size))
96 return
97}
98
99/* RICsubscriptionDeleteResponse */
100
101func (c *E2ap) GetSubscriptionDeleteResponseSequenceNumber(payload []byte) (sub_id uint16, err error) {
102 cptr := unsafe.Pointer(&payload[0])
103 cret := C.e2ap_get_ric_subscription_delete_response_sequence_number(cptr, C.size_t(len(payload)))
104 if cret < 0 {
105 return 0, errors.New("e2ap wrapper is unable to get Subscirption Delete Response Sequence Number due to wrong or invalid payload")
106 }
107 sub_id = uint16(cret)
108 return
109}
110
111func (c *E2ap) SetSubscriptionDeleteResponseSequenceNumber(payload []byte, newSubscriptionid uint16) (new_payload []byte, err error) {
112 cptr := unsafe.Pointer(&payload[0])
113 size := C.e2ap_set_ric_subscription_delete_response_sequence_number(cptr, C.size_t(len(payload)), C.long(newSubscriptionid))
114 if size < 0 {
115 return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscirption Reponse Sequence Number due to wrong or invalid payload")
116 }
117 new_payload = C.GoBytes(cptr, C.int(size))
118 return
119}