blob: 3d8b808cf01a0886d960ace4d98fb026aa0cdf18 [file] [log] [blame]
Harald Welte77847ad2015-10-06 22:07:04 +02001/* common RANAP code */
2
3/* (C) 2015 by Harald Welte <laforge@gnumonks.org>
4 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
Harald Welteac9c0242015-09-10 21:18:16 +020021#include <stdint.h>
22
23#include <osmocom/core/msgb.h>
24
Harald Welteace1d242015-12-16 23:07:19 +010025#include "ranap_common.h"
Harald Welteac9c0242015-09-10 21:18:16 +020026#include "hnbgw.h"
27
28extern int asn1_xer_print;
29
Harald Welteefef6fb2015-12-25 15:35:01 +010030const struct value_string ranap_presence_vals[5] = {
31 { RANAP_RANAP_PDU_PR_initiatingMessage, "Initiating" },
32 { RANAP_RANAP_PDU_PR_successfulOutcome, "Successful Outcome" },
33 { RANAP_RANAP_PDU_PR_unsuccessfulOutcome, "Unsuccessful Outcome" },
34 { RANAP_RANAP_PDU_PR_outcome, "(Intermediate) Outcome" },
35 { 0, NULL }
36};
37
38const struct value_string ranap_procedure_code_vals[48] = {
39 { RANAP_ProcedureCode_id_RAB_Assignment, "RAB Assignment" },
40 { RANAP_ProcedureCode_id_Iu_Release, "Iu Release" },
41 { RANAP_ProcedureCode_id_RelocationPreparation, "Relocation Preparation" },
42 { RANAP_ProcedureCode_id_RelocationResourceAllocation, "Relocation Resource Allocation" },
43 { RANAP_ProcedureCode_id_RelocationCancel, "Relocation Cancel" },
44 { RANAP_ProcedureCode_id_SRNS_ContextTransfer, "SRNS Context Transfer" },
45 { RANAP_ProcedureCode_id_SecurityModeControl, "Security Mode Control" },
46 { RANAP_ProcedureCode_id_DataVolumeReport, "Data Volume Report" },
47 { RANAP_ProcedureCode_id_Reset, "Reset" },
48 { RANAP_ProcedureCode_id_RAB_ReleaseRequest, "RAB Release Request" },
49 { RANAP_ProcedureCode_id_Iu_ReleaseRequest, "Iu Release Request" },
50 { RANAP_ProcedureCode_id_RelocationDetect, "Relocation Detect" },
51 { RANAP_ProcedureCode_id_RelocationComplete, "Relocation Complete" },
52 { RANAP_ProcedureCode_id_Paging, "Paging" },
53 { RANAP_ProcedureCode_id_CommonID, "Common ID" },
54 { RANAP_ProcedureCode_id_CN_InvokeTrace, "CN Invoke Trace" },
55 { RANAP_ProcedureCode_id_LocationReportingControl, "Location Reporting Control" },
56 { RANAP_ProcedureCode_id_LocationReport, "Location Report" },
57 { RANAP_ProcedureCode_id_InitialUE_Message, "Initial UE Message" },
58 { RANAP_ProcedureCode_id_DirectTransfer, "Direct Transfer" },
59 { RANAP_ProcedureCode_id_OverloadControl, "Overload Control" },
60 { RANAP_ProcedureCode_id_ErrorIndication, "Error Indication" },
61 { RANAP_ProcedureCode_id_SRNS_DataForward, "SRNS Data Forward" },
62 { RANAP_ProcedureCode_id_ForwardSRNS_Context, "Forward SRNS Context" },
63 { RANAP_ProcedureCode_id_privateMessage, "Private Message" },
64 { RANAP_ProcedureCode_id_CN_DeactivateTrace, "CN Deactivate Trace" },
65 { RANAP_ProcedureCode_id_ResetResource, "Reset Resource" },
66 { RANAP_ProcedureCode_id_RANAP_Relocation, "RANAP Relocation" },
67 { RANAP_ProcedureCode_id_RAB_ModifyRequest, "RAB Modify Request" },
68 { RANAP_ProcedureCode_id_LocationRelatedData, "Location Related Data" },
69 { RANAP_ProcedureCode_id_InformationTransfer, "Information Transfer" },
70 { RANAP_ProcedureCode_id_UESpecificInformation, "UE Specific Information" },
71 { RANAP_ProcedureCode_id_UplinkInformationExchange, "Uplink Information Transfer" },
72 { RANAP_ProcedureCode_id_DirectInformationTransfer, "Direct Information Transfer" },
73 { RANAP_ProcedureCode_id_MBMSSessionStart, "MBMS Session Start" },
74 { RANAP_ProcedureCode_id_MBMSSessionUpdate, "MBMS Session Update" },
75 { RANAP_ProcedureCode_id_MBMSSessionStop, "MBMS Session Stop" },
76 { RANAP_ProcedureCode_id_MBMSUELinking, "MBMS UE Linking" },
77 { RANAP_ProcedureCode_id_MBMSRegistration, "MBMS Registration" },
78 { RANAP_ProcedureCode_id_MBMSCNDe_Registration_Procedure, "MBMS CN De-Registration" },
79 { RANAP_ProcedureCode_id_MBMSRABEstablishmentIndication, "MBMS RAB Establishment Indication" },
80 { RANAP_ProcedureCode_id_MBMSRABRelease, "MBMS RAB Release" },
81 { RANAP_ProcedureCode_id_enhancedRelocationComplete, "Enhanced Relocation Complete" },
82 { RANAP_ProcedureCode_id_enhancedRelocationCompleteConfirm, "Enhanced Relocation Complete Confirm" },
83 { RANAP_ProcedureCode_id_RANAPenhancedRelocation, "RANAP Enhanced Relocation" },
84 { RANAP_ProcedureCode_id_SRVCCPreparation, "SRVCC Preparation" },
85 { RANAP_ProcedureCode_id_UeRadioCapabilityMatch, "UE Radio Capability Match" },
86 { 0, NULL }
87};
88
Harald Welte3d39f842015-12-25 09:40:07 +010089static const struct value_string ranap_cause_radio_vals[] = {
90 { RANAP_CauseRadioNetwork_rab_pre_empted, "RAB pre-empted" },
91 { RANAP_CauseRadioNetwork_trelocoverall_expiry, "Treloc_overall expiry" },
92 { RANAP_CauseRadioNetwork_trelocprep_expiry, "Treloc_prep expiry" },
93 { RANAP_CauseRadioNetwork_treloccomplete_expiry,"Treloc_complete expiry" },
94 { RANAP_CauseRadioNetwork_tqueing_expiry, "Tqueueing expiry" },
95 { RANAP_CauseRadioNetwork_relocation_triggered, "Relocation triggered" },
96 { RANAP_CauseRadioNetwork_trellocalloc_expiry, "Treloc_alloc expiry" },
97 { RANAP_CauseRadioNetwork_unable_to_establish_during_relocation,
98 "unable to establish during relocation" },
99 { RANAP_CauseRadioNetwork_unknown_target_rnc,
100 "unknown target RNC" },
101 { RANAP_CauseRadioNetwork_relocation_cancelled, "Relocation cancelled" },
102 { RANAP_CauseRadioNetwork_successful_relocation, "Successful relocation" },
103 { RANAP_CauseRadioNetwork_requested_ciphering_and_or_integrity_protection_algorithms_not_supported,
104 "requested ciph. and/or int. prot. algorithms not supported" },
105 { RANAP_CauseRadioNetwork_conflict_with_already_existing_integrity_protection_and_or_ciphering_information,
106 "conflict with existing int. prot. and/or ciph. information" },
107 { RANAP_CauseRadioNetwork_failure_in_the_radio_interface_procedure,
108 "failure in the radio interface procedure" },
109 { RANAP_CauseRadioNetwork_release_due_to_utran_generated_reason,
110 "release due to UTRAN generated reason" },
111 { RANAP_CauseRadioNetwork_user_inactivity, "user inactivity" },
112 { RANAP_CauseRadioNetwork_time_critical_relocation,
113 "time critical relocation" },
114 { RANAP_CauseRadioNetwork_requested_traffic_class_not_available,
115 "requested traffic class not available" },
116 { RANAP_CauseRadioNetwork_invalid_rab_parameters_value,
117 "invalid RAB parameters value" },
118 { RANAP_CauseRadioNetwork_requested_maximum_bit_rate_not_available,
119 "requested max. bit-rate not available" },
120 { RANAP_CauseRadioNetwork_requested_guaranteed_bit_rate_not_available,
121 "requested guaranteed bit-rate not available" },
122 { RANAP_CauseRadioNetwork_requested_transfer_delay_not_achievable,
123 "requested transfer delay not achievable" },
124 { RANAP_CauseRadioNetwork_invalid_rab_parameters_combination,
125 "invalid RAB parameters combination" },
126 { RANAP_CauseRadioNetwork_condition_violation_for_sdu_parameters,
127 "condition violation for SDU parameters" },
128 { RANAP_CauseRadioNetwork_condition_violation_for_traffic_handling_priority,
129 "condition violation for traffic handling priority" },
130 { RANAP_CauseRadioNetwork_condition_violation_for_guaranteed_bit_rate,
131 "condition violation for guaranteed bit-rate" },
132 { RANAP_CauseRadioNetwork_user_plane_versions_not_supported,
133 "user-plane versions not supported" },
134 { RANAP_CauseRadioNetwork_iu_up_failure, "Iu-UP failure" },
135 { RANAP_CauseRadioNetwork_relocation_failure_in_target_CN_RNC_or_target_system,
136 "relocation failure in target CN/RNC or target system" },
137 { RANAP_CauseRadioNetwork_invalid_RAB_ID, "Invalid RAB ID" },
138 { RANAP_CauseRadioNetwork_no_remaining_rab, "No remaining RAB" },
139 { RANAP_CauseRadioNetwork_interaction_with_other_procedure,
140 "interaction with other procedure" },
141 { RANAP_CauseRadioNetwork_requested_maximum_bit_rate_for_dl_not_available,
142 "requested maximum bit-rate for DL not available" },
143 { RANAP_CauseRadioNetwork_requested_maximum_bit_rate_for_ul_not_available,
144 "requested maximum bit-rate for UL not available" },
145 { RANAP_CauseRadioNetwork_requested_guaranteed_bit_rate_for_dl_not_available,
146 "requested guaranteed bit-rate for DL not available" },
147 { RANAP_CauseRadioNetwork_requested_guaranteed_bit_rate_for_ul_not_available,
148 "requested guaranteed bit-rate for UL not available" },
149 { RANAP_CauseRadioNetwork_repeated_integrity_checking_failure,
150 "repeated integrity checking failure" },
151 { RANAP_CauseRadioNetwork_requested_request_type_not_supported,
152 "requested request type not supported" },
153 { RANAP_CauseRadioNetwork_request_superseded, "request superseded" },
154 { RANAP_CauseRadioNetwork_release_due_to_UE_generated_signalling_connection_release,
155 "release due to UE-generated signalling connection release" },
156 { RANAP_CauseRadioNetwork_resource_optimisation_relocation,
157 "resource optimisation relocation" },
158 { RANAP_CauseRadioNetwork_requested_information_not_available,
159 "requested information not available" },
160 { RANAP_CauseRadioNetwork_relocation_desirable_for_radio_reasons,
161 "relocation desirable for radio reasons" },
162 { RANAP_CauseRadioNetwork_relocation_not_supported_in_target_RNC_or_target_system,
163 "relocation not supported in target RNC or target system" },
164 { RANAP_CauseRadioNetwork_directed_retry, "directed retry" },
165 { RANAP_CauseRadioNetwork_radio_connection_with_UE_Lost,
166 "radio connection with UE lost" },
167 { RANAP_CauseRadioNetwork_rNC_unable_to_establish_all_RFCs,
168 "RNC unable to establish al RFCs" },
169 { RANAP_CauseRadioNetwork_deciphering_keys_not_available,
170 "de-ciphering keys not available" },
171 { RANAP_CauseRadioNetwork_dedicated_assistance_data_not_available,
172 "dedicated assistance data not available" },
173 { RANAP_CauseRadioNetwork_relocation_target_not_allowed,
174 "relocation target not allowed" },
175 { RANAP_CauseRadioNetwork_location_reporting_congestion,
176 "relocation reporting congestion" },
177 { RANAP_CauseRadioNetwork_reduce_load_in_serving_cell,
178 "reduce load in serving cell" },
179 { RANAP_CauseRadioNetwork_no_radio_resources_available_in_target_cell,
180 "no radio resources available in target cell" },
181 { RANAP_CauseRadioNetwork_gERAN_Iumode_failure,
182 "GERAN Iu-Mode failure" },
183 { RANAP_CauseRadioNetwork_access_restricted_due_to_shared_networks,
184 "access restricted due to shared networks" },
185 { RANAP_CauseRadioNetwork_incoming_relocation_not_supported_due_to_PUESBINE_feature,
186 "incoming relocation not supported due to PUESBINE feature" },
187 { RANAP_CauseRadioNetwork_traffic_load_in_the_target_cell_higher_than_in_the_source_cell,
188 "traffic load in the target cell higher than in the source cell" },
189 { RANAP_CauseRadioNetwork_mBMS_no_multicast_service_for_this_UE,
190 "MBMS: no multicast service for this UE" },
191 { RANAP_CauseRadioNetwork_mBMS_unknown_UE_ID, "MBMS: unknown UE ID" },
192 { RANAP_CauseRadioNetwork_successful_MBMS_session_start_no_data_bearer_necessary,
193 "successful MBMS session start; no data bearer necessarry" },
194 { RANAP_CauseRadioNetwork_mBMS_superseded_due_to_NNSF,
195 "MBMS superseded due to NNSF" },
196 { RANAP_CauseRadioNetwork_mBMS_UE_linking_already_done,
197 "MBMS: UE linking already done" },
198 { RANAP_CauseRadioNetwork_mBMS_UE_de_linking_failure_no_existing_UE_linking,
199 "MBMS: UE de-linking failure; no existing UE linking" },
200 { RANAP_CauseRadioNetwork_tMGI_unknown, "TMGI unknown" },
201 { 0, NULL }
202};
203
204static const struct value_string ranap_cause_transm_vals[] = {
205 { RANAP_CauseTransmissionNetwork_signalling_transport_resource_failure,
206 "signalling transport resource failure" },
207 { RANAP_CauseTransmissionNetwork_iu_transport_connection_failed_to_establish,
208 "Iu transport connection failed to establish" },
209 { 0, NULL }
210};
211
212static const struct value_string ranap_cause_nas_vals[] = {
213 { RANAP_CauseNAS_user_restriction_start_indication,
214 "user restriction; start indication" },
215 { RANAP_CauseNAS_user_restriction_end_indication,
216 "user restriction; stop indication" },
217 { RANAP_CauseNAS_normal_release,
218 "normal release" },
219 { RANAP_CauseNAS_csg_subscription_expiry,
220 "CSG subscription expiry" },
221 { 0, NULL }
222};
223
224static const struct value_string ranap_cause_prot_vals[] = {
225 { RANAP_CauseProtocol_transfer_syntax_error,
226 "transfer sytax error" },
227 { RANAP_CauseProtocol_semantic_error,
228 "semantic error" },
229 { RANAP_CauseProtocol_message_not_compatible_with_receiver_state,
230 "message not compatible with receiver state" },
231 { RANAP_CauseProtocol_abstract_syntax_error_reject,
232 "syntax error: reject" },
233 { RANAP_CauseProtocol_abstract_syntax_error_ignore_and_notify,
234 "syntax error: ignore and notify" },
235 { RANAP_CauseProtocol_abstract_syntax_error_falsely_constructed_message,
236 "syntax error: falsely constructed message" },
237 { 0, NULL }
238};
239
240static const struct value_string ranap_cause_misc_vals[] = {
241 { RANAP_CauseMisc_om_intervention, "OAM intervention" },
242 { RANAP_CauseMisc_no_resource_available, "no resource available" },
243 { RANAP_CauseMisc_unspecified_failure, "unspecified failure" },
244 { RANAP_CauseMisc_network_optimisation, "network optimisation" },
245 { 0, NULL }
246};
247
248char *ranap_cause_str(const RANAP_Cause_t *cause)
249{
250 static char buf[128];
251
252 switch (cause->present) {
253 case RANAP_Cause_PR_radioNetwork:
254 snprintf(buf, sizeof(buf), "radio(%s)",
255 get_value_string(ranap_cause_radio_vals,
256 cause->choice.radioNetwork));
257 break;
258 case RANAP_Cause_PR_transmissionNetwork:
259 snprintf(buf, sizeof(buf), "transmission(%s)",
260 get_value_string(ranap_cause_transm_vals,
261 cause->choice.transmissionNetwork));
262 break;
263 case RANAP_Cause_PR_nAS:
264 snprintf(buf, sizeof(buf), "nas(%s)",
265 get_value_string(ranap_cause_nas_vals,
266 cause->choice.nAS));
267 break;
268 case RANAP_Cause_PR_protocol:
269 snprintf(buf, sizeof(buf), "protocol(%s)",
270 get_value_string(ranap_cause_prot_vals,
271 cause->choice.protocol));
272 break;
273 case RANAP_Cause_PR_misc:
274 snprintf(buf, sizeof(buf), "misc(%s)",
275 get_value_string(ranap_cause_misc_vals,
276 cause->choice.misc));
277 break;
278 case RANAP_Cause_PR_non_Standard:
279 snprintf(buf, sizeof(buf), "non-standard(%u)",
280 cause->choice.non_Standard);
281 break;
282 default:
283 strcpy(buf, "unknown");
284 break;
285 }
286 return buf;
287}
288
289
Harald Welteac9c0242015-09-10 21:18:16 +0200290static struct msgb *ranap_msgb_alloc(void)
291{
292 return msgb_alloc(1024, "RANAP Tx");
293}
294
Harald Welte8dacb072015-12-16 20:27:14 +0100295static struct msgb *_ranap_gen_msg(RANAP_RANAP_PDU_t *pdu)
Harald Welteac9c0242015-09-10 21:18:16 +0200296{
Harald Weltecbaaeef2015-12-16 20:17:26 +0100297 struct msgb *msg = ranap_msgb_alloc();
298 asn_enc_rval_t rval;
Harald Welteac9c0242015-09-10 21:18:16 +0200299
Harald Welte8dacb072015-12-16 20:27:14 +0100300 if (!msg)
Harald Weltecbaaeef2015-12-16 20:17:26 +0100301 return NULL;
Harald Welteac9c0242015-09-10 21:18:16 +0200302
Harald Welte8dacb072015-12-16 20:27:14 +0100303 rval = aper_encode_to_buffer(&asn_DEF_RANAP_RANAP_PDU, pdu,
Harald Weltecbaaeef2015-12-16 20:17:26 +0100304 msg->data, msgb_tailroom(msg));
305 if (rval.encoded < 0) {
Harald Weltef42317b2015-12-23 15:36:31 +0100306 LOGP(DRANAP, LOGL_ERROR, "Error encoding type: %s\n",
Harald Weltecbaaeef2015-12-16 20:17:26 +0100307 rval.failed_type->name);
308
309 }
310
311 msgb_put(msg, rval.encoded/8);
312
313 return msg;
Harald Welteac9c0242015-09-10 21:18:16 +0200314}
Harald Welteac9c0242015-09-10 21:18:16 +0200315
Harald Welte8dacb072015-12-16 20:27:14 +0100316struct msgb *ranap_generate_initiating_message(e_RANAP_ProcedureCode procedureCode,
317 RANAP_Criticality_t criticality,
318 asn_TYPE_descriptor_t *td, void *sptr)
319{
320 RANAP_RANAP_PDU_t pdu;
Harald Welte26765542015-12-18 13:33:00 +0100321 struct msgb *msg;
Harald Welte8dacb072015-12-16 20:27:14 +0100322 int rc;
323
324 memset(&pdu, 0, sizeof(pdu));
325
326 pdu.present = RANAP_RANAP_PDU_PR_initiatingMessage;
327 pdu.choice.initiatingMessage.procedureCode = procedureCode;
328 pdu.choice.initiatingMessage.criticality = criticality;
329 rc = ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, sptr);
330 if (rc < 0) {
Harald Weltef42317b2015-12-23 15:36:31 +0100331 LOGP(DRANAP, LOGL_ERROR, "Error in ANY_fromType_aper\n");
Harald Welte8dacb072015-12-16 20:27:14 +0100332 return NULL;
333 }
334
Harald Welte26765542015-12-18 13:33:00 +0100335 msg = _ranap_gen_msg(&pdu);
336 ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_RANAP_PDU, &pdu);
337
338 return msg;
Harald Welte8dacb072015-12-16 20:27:14 +0100339}
340
Harald Welteac9c0242015-09-10 21:18:16 +0200341struct msgb *ranap_generate_successful_outcome(
342 e_RANAP_ProcedureCode procedureCode,
343 RANAP_Criticality_t criticality,
344 asn_TYPE_descriptor_t * td,
345 void *sptr)
346{
Harald Welteac9c0242015-09-10 21:18:16 +0200347 RANAP_RANAP_PDU_t pdu;
Harald Welte26765542015-12-18 13:33:00 +0100348 struct msgb *msg;
Harald Welteac9c0242015-09-10 21:18:16 +0200349 int rc;
350
351 memset(&pdu, 0, sizeof(pdu));
Harald Welte8dacb072015-12-16 20:27:14 +0100352
Harald Welteac9c0242015-09-10 21:18:16 +0200353 pdu.present = RANAP_RANAP_PDU_PR_successfulOutcome;
354 pdu.choice.successfulOutcome.procedureCode = procedureCode;
355 pdu.choice.successfulOutcome.criticality = criticality;
356 rc = ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
357 if (rc < 0) {
Harald Weltef42317b2015-12-23 15:36:31 +0100358 LOGP(DRANAP, LOGL_ERROR, "Error in ANY_fromType_aper\n");
Harald Welteac9c0242015-09-10 21:18:16 +0200359 return NULL;
360 }
361
Harald Welte26765542015-12-18 13:33:00 +0100362 msg = _ranap_gen_msg(&pdu);
363 ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_RANAP_PDU, &pdu);
364
365 return msg;
Harald Welteac9c0242015-09-10 21:18:16 +0200366}
367
Harald Weltecbaaeef2015-12-16 20:17:26 +0100368struct msgb *ranap_generate_unsuccessful_outcome(
Harald Welteac9c0242015-09-10 21:18:16 +0200369 e_RANAP_ProcedureCode procedureCode,
370 RANAP_Criticality_t criticality,
371 asn_TYPE_descriptor_t * td,
372 void *sptr)
373{
Harald Welteac9c0242015-09-10 21:18:16 +0200374 RANAP_RANAP_PDU_t pdu;
Harald Welte26765542015-12-18 13:33:00 +0100375 struct msgb *msg;
Harald Weltecbaaeef2015-12-16 20:17:26 +0100376 int rc;
Harald Welteac9c0242015-09-10 21:18:16 +0200377
378 memset(&pdu, 0, sizeof(pdu));
379
380 pdu.present = RANAP_RANAP_PDU_PR_unsuccessfulOutcome;
Harald Weltec16117a2015-12-16 20:30:11 +0100381 pdu.choice.unsuccessfulOutcome.procedureCode = procedureCode;
382 pdu.choice.unsuccessfulOutcome.criticality = criticality;
383 rc = ANY_fromType_aper(&pdu.choice.unsuccessfulOutcome.value, td, sptr);
Harald Weltecbaaeef2015-12-16 20:17:26 +0100384 if (rc < 0) {
Harald Weltef42317b2015-12-23 15:36:31 +0100385 LOGP(DRANAP, LOGL_ERROR, "Error in ANY_fromType_aper\n");
Harald Weltecbaaeef2015-12-16 20:17:26 +0100386 return NULL;
Harald Welteac9c0242015-09-10 21:18:16 +0200387 }
388
Harald Welte26765542015-12-18 13:33:00 +0100389 msg = _ranap_gen_msg(&pdu);
390 ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_RANAP_PDU, &pdu);
391
392 return msg;
Harald Welteac9c0242015-09-10 21:18:16 +0200393}
Harald Welteac9c0242015-09-10 21:18:16 +0200394
Harald Weltec16117a2015-12-16 20:30:11 +0100395struct msgb *ranap_generate_outcome(
396 e_RANAP_ProcedureCode procedureCode,
397 RANAP_Criticality_t criticality,
398 asn_TYPE_descriptor_t * td,
399 void *sptr)
400{
401 RANAP_RANAP_PDU_t pdu;
Harald Welte26765542015-12-18 13:33:00 +0100402 struct msgb *msg;
Harald Weltec16117a2015-12-16 20:30:11 +0100403 int rc;
404
405 memset(&pdu, 0, sizeof(pdu));
406
407 pdu.present = RANAP_RANAP_PDU_PR_outcome;
408 pdu.choice.outcome.procedureCode = procedureCode;
409 pdu.choice.outcome.criticality = criticality;
410 rc = ANY_fromType_aper(&pdu.choice.outcome.value, td, sptr);
411 if (rc < 0) {
Harald Weltef42317b2015-12-23 15:36:31 +0100412 LOGP(DRANAP, LOGL_ERROR, "Error in ANY_fromType_aper\n");
Harald Weltec16117a2015-12-16 20:30:11 +0100413 return NULL;
414 }
415
Harald Welte26765542015-12-18 13:33:00 +0100416 msg = _ranap_gen_msg(&pdu);
417 ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_RANAP_PDU, &pdu);
418
419 return msg;
Harald Weltec16117a2015-12-16 20:30:11 +0100420}
421
422
Harald Welteac9c0242015-09-10 21:18:16 +0200423RANAP_IE_t *ranap_new_ie(RANAP_ProtocolIE_ID_t id,
424 RANAP_Criticality_t criticality,
425 asn_TYPE_descriptor_t * type, void *sptr)
426{
Harald Welteac9c0242015-09-10 21:18:16 +0200427 RANAP_IE_t *buff;
Harald Welte04329dc2015-12-18 15:17:21 +0100428 int rc;
Harald Welteac9c0242015-09-10 21:18:16 +0200429
Harald Welte9c397d42015-12-18 13:33:20 +0100430 if ((buff = CALLOC(1, sizeof(*buff))) == NULL) {
Harald Welteac9c0242015-09-10 21:18:16 +0200431 // Possible error on malloc
432 return NULL;
433 }
Harald Welteac9c0242015-09-10 21:18:16 +0200434
435 buff->id = id;
436 buff->criticality = criticality;
437
Harald Welte04329dc2015-12-18 15:17:21 +0100438 rc = ANY_fromType_aper(&buff->value, type, sptr);
439 if (rc < 0) {
Harald Weltef42317b2015-12-23 15:36:31 +0100440 LOGP(DRANAP, LOGL_ERROR, "Error in ANY_fromType_aper\n");
Harald Welte04329dc2015-12-18 15:17:21 +0100441 FREEMEM(buff);
442 return NULL;
443 }
Harald Welteac9c0242015-09-10 21:18:16 +0200444
445 if (asn1_xer_print)
446 if (xer_fprint(stdout, &asn_DEF_RANAP_IE, buff) < 0) {
Harald Welte62939132015-12-18 14:57:04 +0100447 FREEMEM(buff);
Harald Welteac9c0242015-09-10 21:18:16 +0200448 return NULL;
449 }
450
451 return buff;
452}
Harald Welteace1d242015-12-16 23:07:19 +0100453
454RANAP_ProtocolIE_FieldPair_t *ranap_new_ie_pair(RANAP_ProtocolIE_ID_t id,
455 RANAP_Criticality_t criticality1,
456 asn_TYPE_descriptor_t *type1, void *sptr1,
457 RANAP_Criticality_t criticality2,
458 asn_TYPE_descriptor_t *type2, void *sptr2)
459{
Harald Welteace1d242015-12-16 23:07:19 +0100460 RANAP_ProtocolIE_FieldPair_t *buff;
Harald Welte04329dc2015-12-18 15:17:21 +0100461 int rc;
Harald Welteace1d242015-12-16 23:07:19 +0100462
Harald Welte9c397d42015-12-18 13:33:20 +0100463 if ((buff = CALLOC(1, sizeof(*buff))) == NULL) {
Harald Welteace1d242015-12-16 23:07:19 +0100464 // Possible error on malloc
465 return NULL;
466 }
Harald Welteace1d242015-12-16 23:07:19 +0100467
468 buff->id = id;
469 buff->firstCriticality = criticality1;
470 buff->secondCriticality = criticality2;
471
Harald Welte04329dc2015-12-18 15:17:21 +0100472 rc = ANY_fromType_aper(&buff->firstValue, type1, sptr1);
473 if (rc < 0) {
Harald Weltef42317b2015-12-23 15:36:31 +0100474 LOGP(DRANAP, LOGL_ERROR, "Error in ANY_fromType_aper\n");
Harald Welte04329dc2015-12-18 15:17:21 +0100475 FREEMEM(buff);
476 return NULL;
477 }
478
479 rc = ANY_fromType_aper(&buff->secondValue, type2, sptr2);
480 if (rc < 0) {
Harald Weltef42317b2015-12-23 15:36:31 +0100481 LOGP(DRANAP, LOGL_ERROR, "Error in ANY_fromType_aper\n");
Harald Welte16232782015-12-18 17:22:04 +0100482 ASN_STRUCT_FREE(asn_DEF_RANAP_ProtocolIE_FieldPair, buff);
Harald Welte04329dc2015-12-18 15:17:21 +0100483 return NULL;
484 }
Harald Welteace1d242015-12-16 23:07:19 +0100485
486 if (asn1_xer_print)
Harald Welte62939132015-12-18 14:57:04 +0100487 if (xer_fprint(stdout, &asn_DEF_RANAP_ProtocolIE_FieldPair, buff) < 0) {
Harald Welte16232782015-12-18 17:22:04 +0100488 ASN_STRUCT_FREE(asn_DEF_RANAP_ProtocolIE_FieldPair, buff);
Harald Welteace1d242015-12-16 23:07:19 +0100489 return NULL;
490 }
491
492 return buff;
493}