blob: 6f5edcb372fc7dd9e880ead271bccefdc462d554 [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
kalnagy1455c852019-10-21 13:06:23 +020037func (c *E2ap) GetSubscriptionRequestSequenceNumber(payload []byte) (subId uint16, err error) {
Peter Szilagyifbc56f92019-07-23 19:29:46 +000038 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 }
kalnagy1455c852019-10-21 13:06:23 +020043 subId = uint16(cret)
Peter Szilagyifbc56f92019-07-23 19:29:46 +000044 return
kalnagy45114752019-06-18 14:40:39 +020045}
46
kalnagy1455c852019-10-21 13:06:23 +020047func (c *E2ap) SetSubscriptionRequestSequenceNumber(payload []byte, newSubscriptionid uint16) (newPayload []byte, err error) {
Peter Szilagyifbc56f92019-07-23 19:29:46 +000048 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 {
kalnagy1455c852019-10-21 13:06:23 +020051 return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Request Sequence Number due to wrong or invalid payload")
Peter Szilagyifbc56f92019-07-23 19:29:46 +000052 }
kalnagy1455c852019-10-21 13:06:23 +020053 newPayload = C.GoBytes(cptr, C.int(size))
Peter Szilagyifbc56f92019-07-23 19:29:46 +000054 return
kalnagy45114752019-06-18 14:40:39 +020055}
56
kalnagy1455c852019-10-21 13:06:23 +020057func (c *E2ap) GetSubscriptionResponseSequenceNumber(payload []byte) (subId uint16, err error) {
Peter Szilagyifbc56f92019-07-23 19:29:46 +000058 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 }
kalnagy1455c852019-10-21 13:06:23 +020063 subId = uint16(cret)
Peter Szilagyifbc56f92019-07-23 19:29:46 +000064 return
kalnagy45114752019-06-18 14:40:39 +020065}
66
kalnagy1455c852019-10-21 13:06:23 +020067func (c *E2ap) SetSubscriptionResponseSequenceNumber(payload []byte, newSubscriptionid uint16) (newPayload []byte, err error) {
Peter Szilagyifbc56f92019-07-23 19:29:46 +000068 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 {
kalnagy1455c852019-10-21 13:06:23 +020071 return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Response Sequence Number due to wrong or invalid payload")
Peter Szilagyifbc56f92019-07-23 19:29:46 +000072 }
kalnagy1455c852019-10-21 13:06:23 +020073 newPayload = C.GoBytes(cptr, C.int(size))
Peter Szilagyifbc56f92019-07-23 19:29:46 +000074 return
kalnagy45114752019-06-18 14:40:39 +020075}
kalnagy93cc3e22019-09-19 11:29:29 +020076
77/* RICsubscriptionDeleteRequest */
78
kalnagy1455c852019-10-21 13:06:23 +020079func (c *E2ap) GetSubscriptionDeleteRequestSequenceNumber(payload []byte) (subId uint16, err error) {
kalnagy93cc3e22019-09-19 11:29:29 +020080 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 }
kalnagy1455c852019-10-21 13:06:23 +020085 subId = uint16(cret)
kalnagy93cc3e22019-09-19 11:29:29 +020086 return
87}
88
kalnagy1455c852019-10-21 13:06:23 +020089func (c *E2ap) SetSubscriptionDeleteRequestSequenceNumber(payload []byte, newSubscriptionid uint16) (newPayload []byte, err error) {
kalnagy93cc3e22019-09-19 11:29:29 +020090 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 {
kalnagy1455c852019-10-21 13:06:23 +020093 return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Delete Request Sequence Number due to wrong or invalid payload")
kalnagy93cc3e22019-09-19 11:29:29 +020094 }
kalnagy1455c852019-10-21 13:06:23 +020095 newPayload = C.GoBytes(cptr, C.int(size))
kalnagy93cc3e22019-09-19 11:29:29 +020096 return
97}
98
99/* RICsubscriptionDeleteResponse */
100
kalnagy1455c852019-10-21 13:06:23 +0200101func (c *E2ap) GetSubscriptionDeleteResponseSequenceNumber(payload []byte) (subId uint16, err error) {
kalnagy93cc3e22019-09-19 11:29:29 +0200102 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 }
kalnagy1455c852019-10-21 13:06:23 +0200107 subId = uint16(cret)
kalnagy93cc3e22019-09-19 11:29:29 +0200108 return
109}
110
kalnagy1455c852019-10-21 13:06:23 +0200111func (c *E2ap) SetSubscriptionDeleteResponseSequenceNumber(payload []byte, newSubscriptionid uint16) (newPayload []byte, err error) {
kalnagy93cc3e22019-09-19 11:29:29 +0200112 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 {
kalnagy1455c852019-10-21 13:06:23 +0200115 return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Delete Response Sequence Number due to wrong or invalid payload")
kalnagy93cc3e22019-09-19 11:29:29 +0200116 }
kalnagy1455c852019-10-21 13:06:23 +0200117 newPayload = C.GoBytes(cptr, C.int(size))
kalnagy93cc3e22019-09-19 11:29:29 +0200118 return
119}