kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 1 | #include <errno.h> |
| 2 | #include "wrapper.h" |
| 3 | |
Balint Uveges | e9608cd | 2019-09-20 18:00:32 +0000 | [diff] [blame] | 4 | size_t encode_E2AP_PDU(E2AP_PDU_t* pdu, void* buffer, size_t buf_size) |
| 5 | { |
| 6 | asn_enc_rval_t encode_result; |
| 7 | encode_result = aper_encode_to_buffer(&asn_DEF_E2AP_PDU, NULL, pdu, buffer, buf_size); |
| 8 | if(encode_result.encoded == -1) { |
| 9 | return -1; |
| 10 | } |
| 11 | return encode_result.encoded; |
| 12 | } |
| 13 | |
| 14 | E2AP_PDU_t* decode_E2AP_PDU(const void* buffer, size_t buf_size) |
| 15 | { |
| 16 | asn_dec_rval_t decode_result; |
| 17 | E2AP_PDU_t *pdu = 0; |
| 18 | decode_result = aper_decode_complete(NULL, &asn_DEF_E2AP_PDU, (void **)&pdu, buffer, buf_size); |
| 19 | if(decode_result.code == RC_OK) { |
| 20 | return pdu; |
| 21 | } else { |
| 22 | ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu); |
| 23 | return 0; |
| 24 | } |
| 25 | } |
| 26 | |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 27 | long e2ap_get_ric_subscription_request_sequence_number(void *buffer, size_t buf_size) |
| 28 | { |
Balint Uveges | e9608cd | 2019-09-20 18:00:32 +0000 | [diff] [blame] | 29 | E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size); |
| 30 | if ( pdu != NULL && pdu->present == E2AP_PDU_PR_initiatingMessage) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 31 | { |
Balint Uveges | e9608cd | 2019-09-20 18:00:32 +0000 | [diff] [blame] | 32 | InitiatingMessageE2_t* initiatingMessage = pdu->choice.initiatingMessage; |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 33 | if ( initiatingMessage->procedureCode == ProcedureCode_id_ricSubscription |
| 34 | && initiatingMessage->value.present == InitiatingMessageE2__value_PR_RICsubscriptionRequest) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 35 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 36 | RICsubscriptionRequest_t *ric_subscription_request = &(initiatingMessage->value.choice.RICsubscriptionRequest); |
| 37 | for (int i = 0; i < ric_subscription_request->protocolIEs.list.count; ++i ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 38 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 39 | if ( ric_subscription_request->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID ) |
| 40 | { |
| 41 | return ric_subscription_request->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestSequenceNumber; |
| 42 | } |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 43 | } |
| 44 | } |
| 45 | } |
| 46 | return -1; |
| 47 | } |
| 48 | |
| 49 | ssize_t e2ap_set_ric_subscription_request_sequence_number(void *buffer, size_t buf_size, long sequence_number) |
| 50 | { |
Balint Uveges | e9608cd | 2019-09-20 18:00:32 +0000 | [diff] [blame] | 51 | E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size); |
| 52 | if ( pdu != NULL && pdu->present == E2AP_PDU_PR_initiatingMessage) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 53 | { |
Balint Uveges | e9608cd | 2019-09-20 18:00:32 +0000 | [diff] [blame] | 54 | InitiatingMessageE2_t* initiatingMessage = pdu->choice.initiatingMessage; |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 55 | if ( initiatingMessage->procedureCode == ProcedureCode_id_ricSubscription |
| 56 | && initiatingMessage->value.present == InitiatingMessageE2__value_PR_RICsubscriptionRequest) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 57 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 58 | RICsubscriptionRequest_t *ricSubscriptionRequest = &initiatingMessage->value.choice.RICsubscriptionRequest; |
| 59 | for (int i = 0; i < ricSubscriptionRequest->protocolIEs.list.count; ++i ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 60 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 61 | if ( ricSubscriptionRequest->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID ) |
| 62 | { |
| 63 | ricSubscriptionRequest->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestSequenceNumber = sequence_number; |
| 64 | return encode_E2AP_PDU(pdu, buffer, buf_size); |
| 65 | } |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 66 | } |
| 67 | } |
| 68 | } |
| 69 | return -1; |
| 70 | } |
| 71 | |
| 72 | /* RICsubscriptionResponse */ |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 73 | long e2ap_get_ric_subscription_response_sequence_number(void *buffer, size_t buf_size) |
| 74 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 75 | E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size); |
| 76 | if ( pdu != NULL && pdu->present == E2AP_PDU_PR_successfulOutcome ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 77 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 78 | SuccessfulOutcomeE2_t* successfulOutcome = pdu->choice.successfulOutcome; |
| 79 | if ( successfulOutcome->procedureCode == ProcedureCode_id_ricSubscription |
| 80 | && successfulOutcome->value.present == SuccessfulOutcomeE2__value_PR_RICsubscriptionResponse) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 81 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 82 | RICsubscriptionResponse_t *ricSubscriptionResponse = &successfulOutcome->value.choice.RICsubscriptionResponse; |
| 83 | for (int i = 0; i < ricSubscriptionResponse->protocolIEs.list.count; ++i ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 84 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 85 | if ( ricSubscriptionResponse->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID ) |
| 86 | { |
| 87 | return ricSubscriptionResponse->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestSequenceNumber; |
| 88 | } |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 89 | } |
| 90 | } |
| 91 | } |
| 92 | return -1; |
| 93 | } |
| 94 | |
| 95 | ssize_t e2ap_set_ric_subscription_response_sequence_number(void *buffer, size_t buf_size, long sequence_number) |
| 96 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 97 | E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size); |
| 98 | if ( pdu != NULL && pdu->present == E2AP_PDU_PR_successfulOutcome ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 99 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 100 | SuccessfulOutcomeE2_t* successfulOutcome = pdu->choice.successfulOutcome; |
| 101 | if ( successfulOutcome->procedureCode == ProcedureCode_id_ricSubscription |
| 102 | && successfulOutcome->value.present == SuccessfulOutcomeE2__value_PR_RICsubscriptionResponse) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 103 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 104 | RICsubscriptionResponse_t *ricSubscriptionResponse = &successfulOutcome->value.choice.RICsubscriptionResponse; |
| 105 | for (int i = 0; i < ricSubscriptionResponse->protocolIEs.list.count; ++i ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 106 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 107 | if ( ricSubscriptionResponse->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID ) |
| 108 | { |
| 109 | ricSubscriptionResponse->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestSequenceNumber = sequence_number; |
| 110 | return encode_E2AP_PDU(pdu, buffer, buf_size); |
| 111 | } |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 112 | } |
| 113 | } |
| 114 | } |
| 115 | return -1; |
| 116 | } |
| 117 | |
| 118 | /* RICsubscriptionDeleteRequest */ |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 119 | long e2ap_get_ric_subscription_delete_request_sequence_number(void *buffer, size_t buf_size) |
| 120 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 121 | E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size); |
| 122 | if ( pdu != NULL && pdu->present == E2AP_PDU_PR_initiatingMessage ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 123 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 124 | InitiatingMessageE2_t* initiatingMessage = pdu->choice.initiatingMessage; |
| 125 | if ( initiatingMessage->procedureCode == ProcedureCode_id_ricSubscriptionDelete |
| 126 | && initiatingMessage->value.present == InitiatingMessageE2__value_PR_RICsubscriptionDeleteRequest ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 127 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 128 | RICsubscriptionDeleteRequest_t *subscriptionDeleteRequest = &initiatingMessage->value.choice.RICsubscriptionDeleteRequest; |
| 129 | for (int i = 0; i < subscriptionDeleteRequest->protocolIEs.list.count; ++i ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 130 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 131 | if ( subscriptionDeleteRequest->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID ) |
| 132 | { |
| 133 | return subscriptionDeleteRequest->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestSequenceNumber; |
| 134 | } |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 135 | } |
| 136 | } |
| 137 | } |
| 138 | return -1; |
| 139 | } |
| 140 | |
| 141 | ssize_t e2ap_set_ric_subscription_delete_request_sequence_number(void *buffer, size_t buf_size, long sequence_number) |
| 142 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 143 | E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size); |
| 144 | if ( pdu != NULL && pdu->present == E2AP_PDU_PR_initiatingMessage ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 145 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 146 | InitiatingMessageE2_t* initiatingMessage = pdu->choice.initiatingMessage; |
| 147 | if ( initiatingMessage->procedureCode == ProcedureCode_id_ricSubscriptionDelete |
| 148 | && initiatingMessage->value.present == InitiatingMessageE2__value_PR_RICsubscriptionDeleteRequest ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 149 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 150 | RICsubscriptionDeleteRequest_t* subscriptionDeleteRequest = &initiatingMessage->value.choice.RICsubscriptionDeleteRequest; |
| 151 | for (int i = 0; i < subscriptionDeleteRequest->protocolIEs.list.count; ++i ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 152 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 153 | if ( subscriptionDeleteRequest->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID ) |
| 154 | { |
| 155 | subscriptionDeleteRequest->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestSequenceNumber = sequence_number; |
| 156 | return encode_E2AP_PDU(pdu, buffer, buf_size); |
| 157 | } |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 158 | } |
| 159 | } |
| 160 | } |
| 161 | return -1; |
| 162 | } |
| 163 | |
| 164 | /* RICsubscriptionDeleteResponse */ |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 165 | long e2ap_get_ric_subscription_delete_response_sequence_number(void *buffer, size_t buf_size) |
| 166 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 167 | E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size); |
| 168 | if ( pdu != NULL && pdu->present == E2AP_PDU_PR_successfulOutcome ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 169 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 170 | SuccessfulOutcomeE2_t* successfulOutcome = pdu->choice.successfulOutcome; |
| 171 | if ( successfulOutcome->procedureCode == ProcedureCode_id_ricSubscriptionDelete |
| 172 | && successfulOutcome->value.present == SuccessfulOutcomeE2__value_PR_RICsubscriptionDeleteResponse ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 173 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 174 | RICsubscriptionDeleteResponse_t* subscriptionDeleteResponse = &successfulOutcome->value.choice.RICsubscriptionDeleteResponse; |
| 175 | for (int i = 0; i < subscriptionDeleteResponse->protocolIEs.list.count; ++i ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 176 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 177 | if ( subscriptionDeleteResponse->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID ) |
| 178 | { |
| 179 | return subscriptionDeleteResponse->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestSequenceNumber; |
| 180 | } |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 181 | } |
| 182 | } |
| 183 | } |
| 184 | return -1; |
| 185 | } |
| 186 | |
| 187 | ssize_t e2ap_set_ric_subscription_delete_response_sequence_number(void *buffer, size_t buf_size, long sequence_number) |
| 188 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 189 | E2AP_PDU_t *pdu = decode_E2AP_PDU(buffer, buf_size); |
| 190 | if ( pdu != NULL && pdu->present == E2AP_PDU_PR_successfulOutcome ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 191 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 192 | SuccessfulOutcomeE2_t* successfulOutcome = pdu->choice.successfulOutcome; |
| 193 | if ( successfulOutcome->procedureCode == ProcedureCode_id_ricSubscriptionDelete |
| 194 | && successfulOutcome->value.present == SuccessfulOutcomeE2__value_PR_RICsubscriptionDeleteResponse ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 195 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 196 | RICsubscriptionDeleteResponse_t* subscriptionDeleteResponse; |
| 197 | for (int i = 0; i < subscriptionDeleteResponse->protocolIEs.list.count; ++i ) |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 198 | { |
kalnagy | e001868 | 2019-09-26 16:28:25 +0200 | [diff] [blame^] | 199 | if ( subscriptionDeleteResponse->protocolIEs.list.array[i]->id == ProtocolIE_ID_id_RICrequestID ) |
| 200 | { |
| 201 | subscriptionDeleteResponse->protocolIEs.list.array[i]->value.choice.RICrequestID.ricRequestSequenceNumber = sequence_number; |
| 202 | return encode_E2AP_PDU(pdu, buffer, buf_size); |
| 203 | } |
kalnagy | 93cc3e2 | 2019-09-19 11:29:29 +0200 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | } |
| 207 | return -1; |
| 208 | } |