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 | |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 37 | func (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 |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 45 | } |
| 46 | |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 47 | func (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 |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 55 | } |
| 56 | |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 57 | func (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 |
kalnagy | 4511475 | 2019-06-18 14:40:39 +0200 | [diff] [blame] | 65 | } |
| 66 | |
Peter Szilagyi | fbc56f9 | 2019-07-23 19:29:46 +0000 | [diff] [blame] | 67 | func (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 |
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 | |
| 79 | func (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 | |
| 89 | func (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 | |
| 101 | func (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 | |
| 111 | func (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 | } |