kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 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 control |
| 21 | |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 22 | /* |
| 23 | #include <wrapper.h> |
| 24 | |
| 25 | #cgo LDFLAGS: -lwrapper |
| 26 | */ |
| 27 | import "C" |
| 28 | |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 29 | import ( |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 30 | "errors" |
| 31 | "unsafe" |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 32 | ) |
| 33 | |
| 34 | type E2ap struct { |
| 35 | } |
| 36 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 37 | func (c *E2ap) GetSubscriptionRequestSequenceNumber(payload []byte) (subId uint16, err error) { |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 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 | } |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 43 | subId = uint16(cret) |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 44 | return |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 45 | } |
| 46 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 47 | func (c *E2ap) SetSubscriptionRequestSequenceNumber(payload []byte, newSubscriptionid uint16) (newPayload []byte, err error) { |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 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 { |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 51 | return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Request Sequence Number due to wrong or invalid payload") |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 52 | } |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 53 | newPayload = C.GoBytes(cptr, C.int(size)) |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 54 | return |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 55 | } |
| 56 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 57 | func (c *E2ap) GetSubscriptionResponseSequenceNumber(payload []byte) (subId uint16, err error) { |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 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 | } |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 63 | subId = uint16(cret) |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 64 | return |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 65 | } |
| 66 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 67 | func (c *E2ap) SetSubscriptionResponseSequenceNumber(payload []byte, newSubscriptionid uint16) (newPayload []byte, err error) { |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 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 { |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 71 | return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Response Sequence Number due to wrong or invalid payload") |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 72 | } |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 73 | newPayload = C.GoBytes(cptr, C.int(size)) |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 74 | return |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 75 | } |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 76 | |
| 77 | /* RICsubscriptionDeleteRequest */ |
| 78 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 79 | func (c *E2ap) GetSubscriptionDeleteRequestSequenceNumber(payload []byte) (subId uint16, err error) { |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 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 | } |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 85 | subId = uint16(cret) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 86 | return |
| 87 | } |
| 88 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 89 | func (c *E2ap) SetSubscriptionDeleteRequestSequenceNumber(payload []byte, newSubscriptionid uint16) (newPayload []byte, err error) { |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 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 { |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 93 | return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Delete Request Sequence Number due to wrong or invalid payload") |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 94 | } |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 95 | newPayload = C.GoBytes(cptr, C.int(size)) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 96 | return |
| 97 | } |
| 98 | |
| 99 | /* RICsubscriptionDeleteResponse */ |
| 100 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 101 | func (c *E2ap) GetSubscriptionDeleteResponseSequenceNumber(payload []byte) (subId uint16, err error) { |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 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 | } |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 107 | subId = uint16(cret) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 108 | return |
| 109 | } |
| 110 | |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 111 | func (c *E2ap) SetSubscriptionDeleteResponseSequenceNumber(payload []byte, newSubscriptionid uint16) (newPayload []byte, err error) { |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 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 { |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 115 | return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Delete Response Sequence Number due to wrong or invalid payload") |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 116 | } |
kalnagy | 1455c85 | 2019-10-21 13:06:23 +0200 | [diff] [blame] | 117 | newPayload = C.GoBytes(cptr, C.int(size)) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 118 | return |
| 119 | } |
Anssi Mannila | 2e99e2f | 2019-12-05 13:57:06 +0200 | [diff] [blame^] | 120 | |
| 121 | /* RICsubscriptionRequestFailure */ |
| 122 | |
| 123 | func (c *E2ap) GetSubscriptionFailureSequenceNumber(payload []byte) (subId uint16, err error) { |
| 124 | cptr := unsafe.Pointer(&payload[0]) |
| 125 | cret := C.e2ap_get_ric_subscription_failure_sequence_number(cptr, C.size_t(len(payload))) |
| 126 | if cret < 0 { |
| 127 | return 0, errors.New("e2ap wrapper is unable to get Subscirption Failure Sequence Number due to wrong or invalid payload") |
| 128 | } |
| 129 | subId = uint16(cret) |
| 130 | return |
| 131 | } |
| 132 | |
| 133 | // This function is not used currently. Can be deleted if not needed |
| 134 | func (c *E2ap) SetSubscriptionFailureSequenceNumber(payload []byte, newSubscriptionid uint16) (newPayload []byte, err error) { |
| 135 | cptr := unsafe.Pointer(&payload[0]) |
| 136 | size := C.e2ap_set_ric_subscription_failure_sequence_number(cptr, C.size_t(len(payload)), C.long(newSubscriptionid)) |
| 137 | if size < 0 { |
| 138 | return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Failure Sequence Number due to wrong or invalid payload") |
| 139 | } |
| 140 | newPayload = C.GoBytes(cptr, C.int(size)) |
| 141 | return |
| 142 | } |
| 143 | |
| 144 | /* RICsubscriptionDeleteFailure */ |
| 145 | |
| 146 | func (c *E2ap) GetSubscriptionDeleteFailureSequenceNumber(payload []byte) (subId uint16, err error) { |
| 147 | cptr := unsafe.Pointer(&payload[0]) |
| 148 | cret := C.e2ap_get_ric_subscription_delete_failure_sequence_number(cptr, C.size_t(len(payload))) |
| 149 | if cret < 0 { |
| 150 | return 0, errors.New("e2ap wrapper is unable to get Subscirption Delete Failure Sequence Number due to wrong or invalid payload") |
| 151 | } |
| 152 | subId = uint16(cret) |
| 153 | return |
| 154 | } |
| 155 | |
| 156 | // This function is not used currently. Can be deleted if not needed |
| 157 | func (c *E2ap) SetSubscriptionDeleteFailureSequenceNumber(payload []byte, newSubscriptionid uint16) (newPayload []byte, err error) { |
| 158 | cptr := unsafe.Pointer(&payload[0]) |
| 159 | size := C.e2ap_set_ric_subscription_delete_failure_sequence_number(cptr, C.size_t(len(payload)), C.long(newSubscriptionid)) |
| 160 | if size < 0 { |
| 161 | return make([]byte, 0), errors.New("e2ap wrapper is unable to set Subscription Delete Failure Sequence Number due to wrong or invalid payload") |
| 162 | } |
| 163 | newPayload = C.GoBytes(cptr, C.int(size)) |
| 164 | return |
| 165 | } |