blob: f3d24cdcefcca617dafae93a96d3ba122a5d8edd [file] [log] [blame]
Harald Welted328c1a2015-12-16 23:04:21 +01001
Harald Welte091039d2015-12-17 20:37:40 +01002#include "asn1helpers.h"
3#include "iu_helpers.h"
4
5#include "ranap_common.h"
6#include "ranap_ies_defs.h"
Harald Welted328c1a2015-12-16 23:04:21 +01007
8/* This is just some non-compiling work in progress code to generate the
9 * minimum set of RANAP messages that the core network side needs to send
10 * towards the RNC */
11
Harald Welted062df52015-12-17 23:18:40 +010012static long *new_long(long in)
13{
14 long *out = CALLOC(1, sizeof(long));
15 *out = in;
16 return out;
17}
18
Harald Welted328c1a2015-12-16 23:04:21 +010019int ranap_tx_dt(uint8_t sapi, const uint8_t *nas, unsigned int nas_len)
20{
21 RANAP_DirectTransferIEs_t ies;
22 RANAP_DirectTransfer_t dt;
23 struct msgb *msg;
24 int rc;
25
26 memset(&ies, 0, sizeof(ies));
27
28 /* only SAPI optional field shall be present for CN->RNC */
29 ies.presenceMask = DIRECTTRANSFERIES_RANAP_SAPI_PRESENT;
30
31 if (sapi == 3)
32 ies.sapi = RANAP_SAPI_sapi_3;
33 else
34 ies.sapi = RANAP_SAPI_sapi_0;
35
Harald Welted062df52015-12-17 23:18:40 +010036 ies.nas_pdu.buf = (uint8_t *) nas;
Harald Welted328c1a2015-12-16 23:04:21 +010037 ies.nas_pdu.size = nas_len;
38
39 rc = ranap_encode_directtransferies(&dt, &ies);
40
41 msg = ranap_generate_initiating_message(RANAP_ProcedureCode_id_DirectTransfer,
42 RANAP_Criticality_reject,
43 &asn_DEF_RANAP_DirectTransfer,
44 &dt);
45 /* FIXME: Hand that to RUA or SCCP */
46}
47
48static const enum RANAP_IntegrityProtectionAlgorithm ip_alg[2] = {
49 RANAP_IntegrityProtectionAlgorithm_standard_UMTS_integrity_algorithm_UIA1,
50 RANAP_IntegrityProtectionAlgorithm_standard_UMTS_integrity_algorithm_UIA2,
51};
52
Harald Welte091039d2015-12-17 20:37:40 +010053static const RANAP_EncryptionAlgorithm_t enc_alg[2] = {
54 RANAP_EncryptionAlgorithm_standard_UMTS_encryption_algorith_UEA1,
Harald Welted328c1a2015-12-16 23:04:21 +010055 RANAP_EncryptionAlgorithm_standard_UMTS_encryption_algorithm_UEA2,
56};
57
58int ranap_tx_sec_mod_cmd(void)
59{
60 RANAP_SecurityModeCommandIEs_t ies;
61 RANAP_SecurityModeCommand_t out;
62 struct msgb *msg;
Harald Welte091039d2015-12-17 20:37:40 +010063 int i, rc;
Harald Welted328c1a2015-12-16 23:04:21 +010064
65 memset(&ies, 0, sizeof(ies));
66
67 ies.presenceMask = SECURITYMODECOMMANDIES_RANAP_ENCRYPTIONINFORMATION_PRESENT;
68
Harald Welte091039d2015-12-17 20:37:40 +010069 for (i = 0; i < ARRAY_SIZE(ip_alg); i++) {
70 /* needs to be dynamically allocated, as
71 * SET_OF_free() will call FREEMEM() on it */
Harald Welted062df52015-12-17 23:18:40 +010072 RANAP_IntegrityProtectionAlgorithm_t *alg = CALLOC(1, sizeof(*alg));
Harald Welte091039d2015-12-17 20:37:40 +010073 *alg = ip_alg[i];
74 ASN_SEQUENCE_ADD(&ies.integrityProtectionInformation.permittedAlgorithms, alg);
75 }
Harald Welted328c1a2015-12-16 23:04:21 +010076
77 ies.integrityProtectionInformation.key; /* FIXME */
78 if (0) {
Harald Welte091039d2015-12-17 20:37:40 +010079 for (i = 0; i < ARRAY_SIZE(ip_alg); i++) {
80 /* needs to be dynamically allocated, as
81 * SET_OF_free() will call FREEMEM() on it */
Harald Welted062df52015-12-17 23:18:40 +010082 RANAP_EncryptionAlgorithm_t *alg = CALLOC(1, sizeof(*alg));
Harald Welte091039d2015-12-17 20:37:40 +010083 *alg = enc_alg[i];
84 ASN_SEQUENCE_ADD(&ies.encryptionInformation.permittedAlgorithms, alg);
85 }
Harald Welted328c1a2015-12-16 23:04:21 +010086 ies.encryptionInformation.key; /* FIXME */
87 }
Harald Welte091039d2015-12-17 20:37:40 +010088
Harald Welted328c1a2015-12-16 23:04:21 +010089 ies.keyStatus = RANAP_KeyStatus_new; /* FIXME */
90
91 rc = ranap_encode_securitymodecommandies(&out, &ies);
92
93 asn_sequence_empty(&ies.integrityProtectionInformation.permittedAlgorithms);
94 asn_sequence_empty(&ies.encryptionInformation.permittedAlgorithms);
95
96 msg = ranap_generate_initiating_message(RANAP_ProcedureCode_id_SecurityModeControl,
97 RANAP_Criticality_reject,
98 &asn_DEF_RANAP_SecurityModeCommand,
99 &out);
100}
101
102int ranap_tx_common_id(const char *imsi)
103{
104 RANAP_CommonID_IEs_t ies;
105 RANAP_CommonID_t out;
106 struct msgb *msg;
107 int rc;
108
109 memset(&ies, 0, sizeof(ies));
110
111 if (imsi) {
112 ies.permanentNAS_UE_ID.present = RANAP_PermanentNAS_UE_ID_PR_iMSI;
113 ies.permanentNAS_UE_ID.choice.iMSI; /* FIXME */
114 } else
115 ies.permanentNAS_UE_ID.present = RANAP_PermanentNAS_UE_ID_PR_NOTHING;
116
Harald Welted062df52015-12-17 23:18:40 +0100117 rc = ranap_encode_commonid_ies(&out, &ies);
Harald Welted328c1a2015-12-16 23:04:21 +0100118
119 msg = ranap_generate_initiating_message(RANAP_ProcedureCode_id_CommonID,
120 RANAP_Criticality_ignore,
121 &asn_DEF_RANAP_CommonID,
122 &out);
123}
124
125int ranap_tx_iu_rel_cmd(RANAP_Cause_t cause)
126{
127 RANAP_Iu_ReleaseCommandIEs_t ies;
128 RANAP_Iu_ReleaseCommand_t out;
129 struct msgb *msg;
130 int rc;
131
132 memset(&ies, 0, sizeof(ies));
133
134 ies.cause = cause;
135
136 rc = ranap_encode_iu_releasecommandies(&out, &ies);
137
138 msg = ranap_generate_initiating_message(RANAP_ProcedureCode_id_Iu_Release,
139 RANAP_Criticality_reject,
Harald Welte091039d2015-12-17 20:37:40 +0100140 &asn_DEF_RANAP_Iu_ReleaseCommand,
Harald Welted328c1a2015-12-16 23:04:21 +0100141 &out);
142}
143
Harald Welte091039d2015-12-17 20:37:40 +0100144int ranap_tx_paging_cmd(const char *imsi, uint32_t *tmsi, int is_ps, uint32_t cause)
Harald Welted328c1a2015-12-16 23:04:21 +0100145{
Harald Welte091039d2015-12-17 20:37:40 +0100146 RANAP_PagingIEs_t ies;
Harald Welted328c1a2015-12-16 23:04:21 +0100147 RANAP_Paging_t out;
Harald Welte091039d2015-12-17 20:37:40 +0100148 struct msgb *msg;
149 uint8_t *imsi_buf = CALLOC(1, 16);
150 int rc;
Harald Welted328c1a2015-12-16 23:04:21 +0100151
152 memset(&ies, 0, sizeof(ies));
153
154 if (is_ps)
155 ies.cN_DomainIndicator = RANAP_CN_DomainIndicator_ps_domain;
156 else
157 ies.cN_DomainIndicator = RANAP_CN_DomainIndicator_cs_domain;
158
Harald Welte091039d2015-12-17 20:37:40 +0100159 rc = encode_iu_imsi(imsi_buf, 16, imsi);
160 ies.permanentNAS_UE_ID.present = RANAP_PermanentNAS_UE_ID_PR_iMSI;
161 ies.permanentNAS_UE_ID.choice.iMSI.buf = imsi_buf;
162 ies.permanentNAS_UE_ID.choice.iMSI.size = rc;
Harald Welted328c1a2015-12-16 23:04:21 +0100163
164 if (tmsi) {
165 ies.presenceMask |= PAGINGIES_RANAP_TEMPORARYUE_ID_PRESENT;
166 if (is_ps) {
167 ies.temporaryUE_ID.present = RANAP_TemporaryUE_ID_PR_p_TMSI;
168 ies.temporaryUE_ID.choice.tMSI;
169 } else {
170 ies.temporaryUE_ID.present = RANAP_TemporaryUE_ID_PR_tMSI;
171 ies.temporaryUE_ID.choice.p_TMSI;
172 }
173 }
174
175 if (cause) {
176 ies.presenceMask |= PAGINGIES_RANAP_PAGINGCAUSE_PRESENT;
177 ies.pagingCause = cause;
178 }
179
Harald Welted062df52015-12-17 23:18:40 +0100180 rc = ranap_encode_pagingies(&out, &ies);
Harald Welted328c1a2015-12-16 23:04:21 +0100181
Harald Welte091039d2015-12-17 20:37:40 +0100182 msg = ranap_generate_initiating_message(RANAP_ProcedureCode_id_Paging,
Harald Welted328c1a2015-12-16 23:04:21 +0100183 RANAP_Criticality_reject,
184 &asn_DEF_RANAP_Paging,
185 &out);
186}
187
Harald Welte091039d2015-12-17 20:37:40 +0100188static RANAP_SDU_ErrorRatio_t *new_sdu_error_ratio(long mantissa, long exponent)
189{
190 RANAP_SDU_ErrorRatio_t *err = CALLOC(1, sizeof(*err));
191
192 err->mantissa = mantissa;
193 err->exponent = exponent;
194
195 return err;
196}
Harald Welted328c1a2015-12-16 23:04:21 +0100197
198
Harald Welted062df52015-12-17 23:18:40 +0100199static RANAP_SDU_FormatInformationParameterItem_t *
Harald Welte091039d2015-12-17 20:37:40 +0100200new_format_info_pars(long sdu_size)
201{
Harald Welted062df52015-12-17 23:18:40 +0100202 RANAP_SDU_FormatInformationParameterItem_t *fmti = CALLOC(1, sizeof(*fmti));
Harald Welte091039d2015-12-17 20:37:40 +0100203 fmti->subflowSDU_Size = new_long(sdu_size);
204 return fmti;
205}
206
207enum sdu_par_profile {
208 SDUPAR_P_VOICE0,
209 SDUPAR_P_VOICE1,
210 SDUPAR_P_VOICE2,
211 SDUPAR_P_DATA,
Harald Welted328c1a2015-12-16 23:04:21 +0100212};
213
Harald Welted062df52015-12-17 23:18:40 +0100214/* See Chapter 5 of TS 26.102 */
215static RANAP_SDU_ParameterItem_t *new_sdu_par_item(enum sdu_par_profile profile)
Harald Welte091039d2015-12-17 20:37:40 +0100216{
Harald Welted062df52015-12-17 23:18:40 +0100217 RANAP_SDU_ParameterItem_t *sdui = CALLOC(1, sizeof(*sdui));
218 RANAP_SDU_FormatInformationParameters_t *fmtip = CALLOC(1, sizeof(*fmtip));
219 RANAP_SDU_FormatInformationParameterItem_t *fmti;
Harald Welte091039d2015-12-17 20:37:40 +0100220
221 switch (profile) {
222 case SDUPAR_P_VOICE0:
Harald Welted062df52015-12-17 23:18:40 +0100223 sdui->sDU_ErrorRatio = new_sdu_error_ratio(1, 5);
224 sdui->residualBitErrorRatio.mantissa = 1;
225 sdui->residualBitErrorRatio.exponent = 6;
226 sdui->deliveryOfErroneousSDU = RANAP_DeliveryOfErroneousSDU_yes;
227 sdui->sDU_FormatInformationParameters = fmtip;
Harald Welte091039d2015-12-17 20:37:40 +0100228 fmti = new_format_info_pars(81);
Harald Welted062df52015-12-17 23:18:40 +0100229 ASN_SEQUENCE_ADD(fmtip, fmti);
Harald Welte091039d2015-12-17 20:37:40 +0100230 fmti = new_format_info_pars(39);
Harald Welted062df52015-12-17 23:18:40 +0100231 ASN_SEQUENCE_ADD(fmtip, fmti);
Harald Welte091039d2015-12-17 20:37:40 +0100232 /* FIXME: could be 10 SDU descriptors for AMR! */
233 break;
234 case SDUPAR_P_VOICE1:
Harald Welted062df52015-12-17 23:18:40 +0100235 sdui->residualBitErrorRatio.mantissa = 1;
236 sdui->residualBitErrorRatio.exponent = 3;
237 sdui->deliveryOfErroneousSDU = RANAP_DeliveryOfErroneousSDU_no_error_detection_consideration;
Harald Welte091039d2015-12-17 20:37:40 +0100238 fmti = new_format_info_pars(103);
Harald Welted062df52015-12-17 23:18:40 +0100239 ASN_SEQUENCE_ADD(fmtip, fmti);
Harald Welte091039d2015-12-17 20:37:40 +0100240 fmti = new_format_info_pars(0);
Harald Welted062df52015-12-17 23:18:40 +0100241 ASN_SEQUENCE_ADD(fmtip, fmti);
Harald Welte091039d2015-12-17 20:37:40 +0100242 /* FIXME: could be 10 SDU descriptors for AMR! */
243 break;
244 case SDUPAR_P_VOICE2:
Harald Welted062df52015-12-17 23:18:40 +0100245 sdui->residualBitErrorRatio.mantissa = 5;
246 sdui->residualBitErrorRatio.exponent = 3;
247 sdui->deliveryOfErroneousSDU = RANAP_DeliveryOfErroneousSDU_no_error_detection_consideration;
Harald Welte091039d2015-12-17 20:37:40 +0100248 fmti = new_format_info_pars(60);
Harald Welted062df52015-12-17 23:18:40 +0100249 ASN_SEQUENCE_ADD(fmtip, fmti);
Harald Welte091039d2015-12-17 20:37:40 +0100250 fmti = new_format_info_pars(0);
Harald Welted062df52015-12-17 23:18:40 +0100251 ASN_SEQUENCE_ADD(fmtip, fmti);
Harald Welte091039d2015-12-17 20:37:40 +0100252 /* FIXME: could be 10 SDU descriptors for AMR! */
253 break;
254 case SDUPAR_P_DATA:
Harald Welted062df52015-12-17 23:18:40 +0100255 sdui->sDU_ErrorRatio = new_sdu_error_ratio(1, 4);
256 sdui->residualBitErrorRatio.mantissa = 1;
257 sdui->residualBitErrorRatio.exponent = 5;
258 sdui->deliveryOfErroneousSDU = RANAP_DeliveryOfErroneousSDU_no;
Harald Welte091039d2015-12-17 20:37:40 +0100259 break;
260 }
261
Harald Welted062df52015-12-17 23:18:40 +0100262 return sdui;
Harald Welte091039d2015-12-17 20:37:40 +0100263}
264
265static RANAP_AllocationOrRetentionPriority_t *
Harald Welted062df52015-12-17 23:18:40 +0100266new_alloc_ret_prio(RANAP_PriorityLevel_t level, int capability, int vulnerability,
267 int queueing_allowed)
Harald Welte091039d2015-12-17 20:37:40 +0100268{
Harald Welted062df52015-12-17 23:18:40 +0100269 RANAP_AllocationOrRetentionPriority_t *arp = CALLOC(1, sizeof(*arp));
Harald Welte091039d2015-12-17 20:37:40 +0100270
271 arp->priorityLevel = level;
272
273 if (capability)
274 arp->pre_emptionCapability = RANAP_Pre_emptionCapability_may_trigger_pre_emption;
275 else
276 arp->pre_emptionCapability = RANAP_Pre_emptionCapability_shall_not_trigger_pre_emption;
277
278 if (vulnerability)
279 arp->pre_emptionVulnerability = RANAP_Pre_emptionVulnerability_pre_emptable;
280 else
281 arp->pre_emptionVulnerability = RANAP_Pre_emptionVulnerability_not_pre_emptable;
282
283 if (queueing_allowed)
284 arp->queuingAllowed = RANAP_QueuingAllowed_queueing_allowed;
285 else
286 arp->queuingAllowed = RANAP_QueuingAllowed_queueing_not_allowed;
287
288 return arp;
289}
290
Harald Welted062df52015-12-17 23:18:40 +0100291/* See Chapter 5 of TS 26.102 */
Harald Welte091039d2015-12-17 20:37:40 +0100292static RANAP_RAB_Parameters_t *new_rab_par_voice(void)
293{
294 RANAP_RAB_Parameters_t *rab = CALLOC(1, sizeof(*rab));
Harald Welted062df52015-12-17 23:18:40 +0100295 RANAP_SDU_ParameterItem_t *sdui;
Harald Welte091039d2015-12-17 20:37:40 +0100296
297 rab->trafficClass = RANAP_TrafficClass_conversational;
298 rab->rAB_AsymmetryIndicator = RANAP_RAB_AsymmetryIndicator_symmetric_bidirectional;
299
300 ASN_SEQUENCE_ADD(&rab->maxBitrate, new_long(12200));
Harald Welted062df52015-12-17 23:18:40 +0100301 rab->guaranteedBitRate = CALLOC(1, sizeof(*rab->guaranteedBitRate));
302 ASN_SEQUENCE_ADD(&rab->guaranteedBitRate, new_long(12200));
Harald Welte091039d2015-12-17 20:37:40 +0100303 rab->deliveryOrder = RANAP_DeliveryOrder_delivery_order_requested;
304 rab->maxSDU_Size = 244;
305
Harald Welted062df52015-12-17 23:18:40 +0100306 RANAP_SDU_Parameters_t *sdup = CALLOC(1, sizeof(*sdup));
307 ASN_SEQUENCE_ADD(&sdup->list, sdui);
308
309 sdui = new_sdu_par_item(SDUPAR_P_VOICE0);
310 ASN_SEQUENCE_ADD(&rab->sDU_Parameters, sdui);
311 sdui = new_sdu_par_item(SDUPAR_P_VOICE1);
312 ASN_SEQUENCE_ADD(&rab->sDU_Parameters, sdui);
313 sdui = new_sdu_par_item(SDUPAR_P_VOICE2);
314 ASN_SEQUENCE_ADD(&rab->sDU_Parameters, sdui);
Harald Welte091039d2015-12-17 20:37:40 +0100315
316 rab->transferDelay = new_long(80);
317 rab->allocationOrRetentionPriority = new_alloc_ret_prio(RANAP_PriorityLevel_no_priority, 0, 1, 0);
318
319 rab->sourceStatisticsDescriptor = new_long(RANAP_SourceStatisticsDescriptor_speech);
320
321 return rab;
322}
323
324static RANAP_RAB_Parameters_t *new_rab_par_data(void)
325{
326 RANAP_RAB_Parameters_t *rab = CALLOC(1, sizeof(*rab));
Harald Welted062df52015-12-17 23:18:40 +0100327 RANAP_SDU_ParameterItem_t *sdui;
Harald Welte091039d2015-12-17 20:37:40 +0100328
329 rab->trafficClass = RANAP_TrafficClass_background;
330 rab->rAB_AsymmetryIndicator = RANAP_RAB_AsymmetryIndicator_asymmetric_bidirectional;
331
332 ASN_SEQUENCE_ADD(&rab->maxBitrate, new_long(16000000));
333 ASN_SEQUENCE_ADD(&rab->maxBitrate, new_long(8000000));
334 rab->deliveryOrder = RANAP_DeliveryOrder_delivery_order_requested;
335 rab->maxSDU_Size = 8000;
336
Harald Welted062df52015-12-17 23:18:40 +0100337 sdui = new_sdu_par_item(SDUPAR_P_DATA);
338 ASN_SEQUENCE_ADD(&rab->sDU_Parameters, sdui);
Harald Welte091039d2015-12-17 20:37:40 +0100339
340 rab->allocationOrRetentionPriority = new_alloc_ret_prio(RANAP_PriorityLevel_no_priority, 0, 0, 0);
341
342 /* FIXME: RAB-Parameter-ExtendedMaxBitrateList for 42Mbps? */
343
344 return rab;
345}
346
347static RANAP_TransportLayerInformation_t *new_transp_info_rtp(uint32_t ip, uint16_t port)
348{
349 RANAP_TransportLayerInformation_t *tli = CALLOC(1, sizeof(*tli));
350 uint32_t *ipbuf = CALLOC(1, sizeof(*ipbuf));
351 uint8_t binding_id[4];
352
353 binding_id[0] = port >> 8;
354 binding_id[1] = port & 0xff;
355 binding_id[2] = binding_id[3] = 0;
356
357 asn1_u32_to_bitstring(&tli->transportLayerAddress, ipbuf, htonl(ip));
358 tli->iuTransportAssociation.present = RANAP_IuTransportAssociation_PR_bindingID;
Harald Welted062df52015-12-17 23:18:40 +0100359 OCTET_STRING_fromBuf(&tli->iuTransportAssociation.choice.bindingID,
Harald Welte091039d2015-12-17 20:37:40 +0100360 (const char *) binding_id, sizeof(binding_id));
361
362 return tli;
363}
364
365static RANAP_TransportLayerInformation_t *new_transp_info_gtp(uint32_t ip, uint32_t tei)
366{
367 RANAP_TransportLayerInformation_t *tli = CALLOC(1, sizeof(*tli));
368 uint32_t *ipbuf = CALLOC(1, sizeof(*ipbuf));
369 uint32_t binding_buf = htonl(tei);
370
371 asn1_u32_to_bitstring(&tli->transportLayerAddress, ipbuf, htonl(ip));
372 tli->iuTransportAssociation.present = RANAP_IuTransportAssociation_PR_gTP_TEI;
373 OCTET_STRING_fromBuf(&tli->iuTransportAssociation.choice.bindingID,
Harald Welted062df52015-12-17 23:18:40 +0100374 (const char *) &binding_buf, sizeof(binding_buf));
Harald Welte091039d2015-12-17 20:37:40 +0100375
376 return tli;
377}
378
379static RANAP_UserPlaneInformation_t *new_upi(long mode, uint8_t mode_versions)
380{
381 RANAP_UserPlaneInformation_t *upi = CALLOC(1, sizeof(*upi));
382 uint8_t *buf = CALLOC(1, sizeof(*buf));
383
384 *buf = mode_versions;
385
386 upi->userPlaneMode = mode;
387 upi->uP_ModeVersions.buf = buf;
388 upi->uP_ModeVersions.size = 1;
389 upi->uP_ModeVersions.bits_unused = 0;
390
391 return upi;
392}
393
Harald Welted062df52015-12-17 23:18:40 +0100394
395static void assign_new_ra_id(RANAP_RAB_ID_t *id, uint8_t rab_id)
396{
397 uint8_t *buf = CALLOC(1, sizeof(*buf));
398 *buf = rab_id << 3;
399
400 id->buf = buf;
401 id->size = 1;
402 id->bits_unused = 0;
403}
404
405int ranap_tx_rab_assign_voice(uint8_t rab_id, uint32_t rtp_ip, uint16_t rtp_port)
Harald Welted328c1a2015-12-16 23:04:21 +0100406{
407 RANAP_ProtocolIE_FieldPair_t *pair;
408 RANAP_RAB_AssignmentRequestIEs_t ies;
409 RANAP_RAB_AssignmentRequest_t out;
Harald Welted062df52015-12-17 23:18:40 +0100410 int rc;
Harald Welted328c1a2015-12-16 23:04:21 +0100411
Harald Welted328c1a2015-12-16 23:04:21 +0100412 memset(&ies, 0, sizeof(ies));
413
Harald Welted062df52015-12-17 23:18:40 +0100414 /* only assingnment is present, no release */
Harald Welted328c1a2015-12-16 23:04:21 +0100415 ies.presenceMask = RAB_ASSIGNMENTREQUESTIES_RANAP_RAB_SETUPORMODIFYLIST_PRESENT;
Harald Welted328c1a2015-12-16 23:04:21 +0100416
417 RANAP_RAB_SetupOrModifyItemFirst_t first;
418
Harald Welted062df52015-12-17 23:18:40 +0100419 assign_new_ra_id(&first.rAB_ID, rab_id);
420 //first.nAS_SynchronisationIndicator = FIXME;
Harald Welte091039d2015-12-17 20:37:40 +0100421 first.rAB_Parameters = new_rab_par_voice();
422 first.userPlaneInformation = new_upi(RANAP_UserPlaneMode_support_mode_for_predefined_SDU_sizes, 1); /* 2? */
Harald Welted062df52015-12-17 23:18:40 +0100423 first.transportLayerInformation = new_transp_info_rtp(rtp_ip, rtp_port);
Harald Welted328c1a2015-12-16 23:04:21 +0100424
425 RANAP_RAB_SetupOrModifyItemSecond_t second;
Harald Welte091039d2015-12-17 20:37:40 +0100426 memset(&second, 0, sizeof(second));
Harald Welted328c1a2015-12-16 23:04:21 +0100427
428 pair = ranap_new_ie_pair(RANAP_ProtocolIE_ID_id_RAB_SetupOrModifyItem,
429 RANAP_Criticality_reject,
Harald Welte091039d2015-12-17 20:37:40 +0100430 &asn_DEF_RANAP_RAB_SetupOrModifyItemFirst, &first,
Harald Welted328c1a2015-12-16 23:04:21 +0100431 RANAP_Criticality_ignore,
Harald Welte091039d2015-12-17 20:37:40 +0100432 &asn_DEF_RANAP_RAB_SetupOrModifyItemSecond, &second);
433
434 ASN_SEQUENCE_ADD(&ies.raB_SetupOrModifyList.list, pair);
435
436 rc = ranap_encode_rab_assignmentrequesties(&out, &ies);
437}
438
439int ranap_tx_rab_assign_data(uint8_t rab_id, uint32_t gtp_ip, uint16_t gtp_port)
440{
441 RANAP_ProtocolIE_FieldPair_t *pair;
442 RANAP_RAB_AssignmentRequestIEs_t ies;
443 RANAP_RAB_AssignmentRequest_t out;
444 RANAP_DataVolumeReportingIndication_t *dat_vol_ind = CALLOC(1, sizeof(*dat_vol_ind));
445 int rc;
446
447 memset(&ies, 0, sizeof(ies));
448
Harald Welted062df52015-12-17 23:18:40 +0100449 /* only assingnment is present, no release */
Harald Welte091039d2015-12-17 20:37:40 +0100450 ies.presenceMask = RAB_ASSIGNMENTREQUESTIES_RANAP_RAB_SETUPORMODIFYLIST_PRESENT;
Harald Welte091039d2015-12-17 20:37:40 +0100451
452 RANAP_RAB_SetupOrModifyItemFirst_t first;
453
Harald Welted062df52015-12-17 23:18:40 +0100454 assign_new_ra_id(&first.rAB_ID, rab_id);
455 //first.nAS_SynchronisationIndicator = FIXME;
Harald Welte091039d2015-12-17 20:37:40 +0100456 first.rAB_Parameters = new_rab_par_data();
457 first.userPlaneInformation = new_upi(RANAP_UserPlaneMode_transparent_mode, 1);
458 first.transportLayerInformation = new_transp_info_rtp(gtp_ip, gtp_port);
459
460 RANAP_RAB_SetupOrModifyItemSecond_t second;
461 memset(&second, 0, sizeof(second));
462 second.pDP_TypeInformation = CALLOC(1, sizeof(*second.pDP_TypeInformation));
463 ASN_SEQUENCE_ADD(&second.pDP_TypeInformation, new_long(RANAP_PDP_Type_ipv4));
464 *dat_vol_ind = RANAP_DataVolumeReportingIndication_do_not_report;
465 second.dataVolumeReportingIndication = dat_vol_ind;
466 second.dl_GTP_PDU_SequenceNumber = new_long(0);
467 second.ul_GTP_PDU_SequenceNumber = new_long(0);
468
469 pair = ranap_new_ie_pair(RANAP_ProtocolIE_ID_id_RAB_SetupOrModifyItem,
470 RANAP_Criticality_reject,
471 &asn_DEF_RANAP_RAB_SetupOrModifyItemFirst, &first,
472 RANAP_Criticality_ignore,
473 &asn_DEF_RANAP_RAB_SetupOrModifyItemSecond, &second);
Harald Welted328c1a2015-12-16 23:04:21 +0100474
475 ASN_SEQUENCE_ADD(&ies.raB_SetupOrModifyList.list, pair);
476
477 rc = ranap_encode_rab_assignmentrequesties(&out, &ies);
478}