s1ap_eNB_encoder.c 19 KB
Newer Older
Cedric Roux's avatar
   
Cedric Roux committed
1
/*******************************************************************************
gauthier's avatar
GPLv3    
gauthier committed
2
3
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom
Cedric Roux's avatar
   
Cedric Roux committed
4

gauthier's avatar
GPLv3    
gauthier committed
5
6
7
8
    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
Cedric Roux's avatar
   
Cedric Roux committed
9
10


gauthier's avatar
GPLv3    
gauthier committed
11
12
13
14
    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
Cedric Roux's avatar
   
Cedric Roux committed
15

gauthier's avatar
GPLv3    
gauthier committed
16
17
18
19
    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is
   included in this distribution in the file called "COPYING". If not,
   see <http://www.gnu.org/licenses/>.
Cedric Roux's avatar
   
Cedric Roux committed
20
21

  Contact Information
gauthier's avatar
GPLv3    
gauthier committed
22
23
24
25
26
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
  OpenAirInterface Dev  : openair4g-devel@eurecom.fr

  Address      : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
Cedric Roux's avatar
   
Cedric Roux committed
27

gauthier's avatar
GPLv3    
gauthier committed
28
 *******************************************************************************/
Cedric Roux's avatar
   
Cedric Roux committed
29
30
31
32
33
34
35
36
37
38

/*! \file s1ap_eNB_encoder.c
 * \brief s1ap pdu encode procedures for eNB
 * \author Sebastien ROUX <sebastien.roux@eurecom.fr>
 * \date 2013
 * \version 0.1
 */

#include <stdio.h>
#include <string.h>
39
40
41
42
43
#include <stdint.h>

#include "conversions.h"

#include "intertask_interface.h"
Cedric Roux's avatar
   
Cedric Roux committed
44
45
46
47
48
49

#include "s1ap_common.h"
#include "s1ap_ies_defs.h"
#include "s1ap_eNB_encoder.h"

static inline int s1ap_eNB_encode_initiating(s1ap_message *message,
50
51
    uint8_t **buffer,
    uint32_t *len);
52

Cedric Roux's avatar
   
Cedric Roux committed
53
static inline int s1ap_eNB_encode_successfull_outcome(s1ap_message *message,
54
    uint8_t **buffer, uint32_t *len);
55

Cedric Roux's avatar
   
Cedric Roux committed
56
static inline int s1ap_eNB_encode_unsuccessfull_outcome(s1ap_message *message,
57
    uint8_t **buffer, uint32_t *len);
58
59

static inline int s1ap_eNB_encode_s1_setup_request(
60
  S1ap_S1SetupRequestIEs_t *s1SetupRequestIEs, uint8_t **buffer, uint32_t *length);
61
62

static inline int s1ap_eNB_encode_trace_failure(S1ap_TraceFailureIndicationIEs_t
63
64
    *trace_failure_ies_p, uint8_t **buffer,
    uint32_t *length);
65
66

static inline int s1ap_eNB_encode_initial_ue_message(S1ap_InitialUEMessageIEs_t
67
68
    *initialUEmessageIEs_p, uint8_t **buffer,
    uint32_t *length);
69
70

static inline int s1ap_eNB_encode_uplink_nas_transport(S1ap_UplinkNASTransportIEs_t
71
    *uplinkNASTransportIEs,
Cedric Roux's avatar
   
Cedric Roux committed
72
73
    uint8_t **buffer,
    uint32_t *length);
74

75
76
77
78
79
static inline int s1ap_eNB_encode_ue_capability_info_indication(
  S1ap_UECapabilityInfoIndicationIEs_t *ueCapabilityInfoIndicationIEs,
  uint8_t **buffer,
  uint32_t *length);

Cedric Roux's avatar
   
Cedric Roux committed
80
static inline int s1ap_eNB_encode_initial_context_setup_response(
81
82
83
  S1ap_InitialContextSetupResponseIEs_t *initialContextSetupResponseIEs,
  uint8_t **buffer,
  uint32_t *length);
Cedric Roux's avatar
   
Cedric Roux committed
84

85
86
static inline
int s1ap_eNB_encode_nas_non_delivery(
87
88
89
  S1ap_NASNonDeliveryIndication_IEs_t *nasNonDeliveryIndicationIEs,
  uint8_t                            **buffer,
  uint32_t                            *length);
90

gauthier's avatar
gauthier committed
91
92
static inline
int s1ap_eNB_encode_ue_context_release_complete(
93
94
95
  S1ap_UEContextReleaseCompleteIEs_t *s1ap_UEContextReleaseCompleteIEs,
  uint8_t                           **buffer,
  uint32_t                           *length);
gauthier's avatar
gauthier committed
96

gauthier's avatar
gauthier committed
97
98
static inline
int s1ap_eNB_encode_ue_context_release_request(
99
100
101
  S1ap_UEContextReleaseRequestIEs_t *s1ap_UEContextReleaseRequestIEs,
  uint8_t                              **buffer,
  uint32_t                              *length);
gauthier's avatar
gauthier committed
102

Cedric Roux's avatar
   
Cedric Roux committed
103
104
int s1ap_eNB_encode_pdu(s1ap_message *message, uint8_t **buffer, uint32_t *len)
{
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
  DevAssert(message != NULL);
  DevAssert(buffer != NULL);
  DevAssert(len != NULL);

  switch(message->direction) {
  case S1AP_PDU_PR_initiatingMessage:
    return s1ap_eNB_encode_initiating(message, buffer, len);

  case S1AP_PDU_PR_successfulOutcome:
    return s1ap_eNB_encode_successfull_outcome(message, buffer, len);

  case S1AP_PDU_PR_unsuccessfulOutcome:
    return s1ap_eNB_encode_unsuccessfull_outcome(message, buffer, len);

  default:
    S1AP_DEBUG("Unknown message outcome (%d) or not implemented",
               (int)message->direction);
    break;
  }

  return -1;
Cedric Roux's avatar
   
Cedric Roux committed
126
127
128
}

static inline
129
int s1ap_eNB_encode_initiating(s1ap_message *s1ap_message_p,
130
                               uint8_t **buffer, uint32_t *len)
Cedric Roux's avatar
   
Cedric Roux committed
131
{
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
  int ret = -1;
  MessageDef *message_p;
  char       *message_string = NULL;
  size_t      message_string_size;
  MessagesIds message_id;

  DevAssert(s1ap_message_p != NULL);

  message_string = calloc(10000, sizeof(char));

  s1ap_string_total_size = 0;

  switch(s1ap_message_p->procedureCode) {
  case S1ap_ProcedureCode_id_S1Setup:
    ret = s1ap_eNB_encode_s1_setup_request(
            &s1ap_message_p->msg.s1ap_S1SetupRequestIEs, buffer, len);
    s1ap_xer_print_s1ap_s1setuprequest(s1ap_xer__print2sp, message_string, s1ap_message_p);
    message_id = S1AP_S1_SETUP_LOG;
    break;

  case S1ap_ProcedureCode_id_uplinkNASTransport:
    ret = s1ap_eNB_encode_uplink_nas_transport(
            &s1ap_message_p->msg.s1ap_UplinkNASTransportIEs, buffer, len);
    s1ap_xer_print_s1ap_uplinknastransport(s1ap_xer__print2sp, message_string, s1ap_message_p);
    message_id = S1AP_UPLINK_NAS_LOG;
    break;

  case S1ap_ProcedureCode_id_UECapabilityInfoIndication:
    ret = s1ap_eNB_encode_ue_capability_info_indication(
            &s1ap_message_p->msg.s1ap_UECapabilityInfoIndicationIEs, buffer, len);
    s1ap_xer_print_s1ap_uecapabilityinfoindication(s1ap_xer__print2sp, message_string, s1ap_message_p);
    message_id = S1AP_UE_CAPABILITY_IND_LOG;
    break;

  case S1ap_ProcedureCode_id_initialUEMessage:
    ret = s1ap_eNB_encode_initial_ue_message(
            &s1ap_message_p->msg.s1ap_InitialUEMessageIEs, buffer, len);
    s1ap_xer_print_s1ap_initialuemessage(s1ap_xer__print2sp, message_string, s1ap_message_p);
    message_id = S1AP_INITIAL_UE_MESSAGE_LOG;
    break;

  case S1ap_ProcedureCode_id_NASNonDeliveryIndication:
    ret = s1ap_eNB_encode_nas_non_delivery(
            &s1ap_message_p->msg.s1ap_NASNonDeliveryIndication_IEs, buffer, len);
    s1ap_xer_print_s1ap_nasnondeliveryindication_(s1ap_xer__print2sp,
        message_string, s1ap_message_p);
    message_id = S1AP_NAS_NON_DELIVERY_IND_LOG;
    break;

  case S1ap_ProcedureCode_id_UEContextReleaseRequest:
    ret = s1ap_eNB_encode_ue_context_release_request(
            &s1ap_message_p->msg.s1ap_UEContextReleaseRequestIEs, buffer, len);
    s1ap_xer_print_s1ap_uecontextreleaserequest(s1ap_xer__print2sp,
        message_string, s1ap_message_p);
    message_id = S1AP_UE_CONTEXT_RELEASE_REQ_LOG;
    break;


  default:
    S1AP_DEBUG("Unknown procedure ID (%d) for initiating message\n",
               (int)s1ap_message_p->procedureCode);
    return ret;
    break;
  }
196

197
  message_string_size = strlen(message_string);
198

199
200
201
  message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
  message_p->ittiMsg.s1ap_s1_setup_log.size = message_string_size;
  memcpy(&message_p->ittiMsg.s1ap_s1_setup_log.text, message_string, message_string_size);
202

203
  itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
204

205
206
207
  free(message_string);

  return ret;
Cedric Roux's avatar
   
Cedric Roux committed
208
209
210
}

static inline
211
int s1ap_eNB_encode_successfull_outcome(s1ap_message *s1ap_message_p,
212
                                        uint8_t **buffer, uint32_t *len)
Cedric Roux's avatar
   
Cedric Roux committed
213
{
214
215
216
217
218
  int ret = -1;
  MessageDef *message_p;
  char       *message_string = NULL;
  size_t      message_string_size;
  MessagesIds message_id;
219

220
  DevAssert(s1ap_message_p != NULL);
221

222
  message_string = calloc(10000, sizeof(char));
223

224
225
  s1ap_string_total_size = 0;
  message_string_size = strlen(message_string);
gauthier's avatar
gauthier committed
226

227

228
229
230
  switch(s1ap_message_p->procedureCode) {
  case S1ap_ProcedureCode_id_InitialContextSetup:
    ret = s1ap_eNB_encode_initial_context_setup_response(
gauthier's avatar
gauthier committed
231
232
            &s1ap_message_p->msg.s1ap_InitialContextSetupResponseIEs, buffer, len);

233
234
235
236
237
238
239
240
    s1ap_xer_print_s1ap_initialcontextsetupresponse(s1ap_xer__print2sp, message_string, s1ap_message_p);
    message_id = S1AP_INITIAL_CONTEXT_SETUP_LOG;
    message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
    message_p->ittiMsg.s1ap_initial_context_setup_log.size = message_string_size;
    memcpy(&message_p->ittiMsg.s1ap_initial_context_setup_log.text, message_string, message_string_size);
    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
    free(message_string);
    break;
241

242
243
244
245
246
247
248
249
250
251
252
  case S1ap_ProcedureCode_id_UEContextRelease:
    ret = s1ap_eNB_encode_ue_context_release_complete(
            &s1ap_message_p->msg.s1ap_UEContextReleaseCompleteIEs, buffer, len);
    s1ap_xer_print_s1ap_uecontextreleasecomplete(s1ap_xer__print2sp, message_string, s1ap_message_p);
    message_id = S1AP_UE_CONTEXT_RELEASE_COMPLETE_LOG;
    message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
    message_p->ittiMsg.s1ap_ue_context_release_complete_log.size = message_string_size;
    memcpy(&message_p->ittiMsg.s1ap_ue_context_release_complete_log.text, message_string, message_string_size);
    itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
    free(message_string);
    break;
253

254
255
256
  default:
    S1AP_DEBUG("Unknown procedure ID (%d) for successfull outcome message\n",
               (int)s1ap_message_p->procedureCode);
257
    return ret;
258
259
260
261
262
    break;
  }


  return ret;
Cedric Roux's avatar
   
Cedric Roux committed
263
264
265
}

static inline
266
int s1ap_eNB_encode_unsuccessfull_outcome(s1ap_message *s1ap_message_p,
Cedric Roux's avatar
   
Cedric Roux committed
267
268
    uint8_t **buffer, uint32_t *len)
{
269
270
271
272
273
  int ret = -1;
  MessageDef *message_p;
  char       *message_string = NULL;
  size_t      message_string_size;
  MessagesIds message_id;
274

275
  DevAssert(s1ap_message_p != NULL);
276

277
  message_string = calloc(10000, sizeof(char));
278

279
280
281
282
283
284
285
286
287
  s1ap_string_total_size = 0;

  switch(s1ap_message_p->procedureCode) {
  case S1ap_ProcedureCode_id_InitialContextSetup:
    //             ret = s1ap_encode_s1ap_initialcontextsetupfailureies(
    //                 &s1ap_message_p->ittiMsg.s1ap_InitialContextSetupFailureIEs, buffer, len);
    s1ap_xer_print_s1ap_initialcontextsetupfailure(s1ap_xer__print2sp, message_string, s1ap_message_p);
    message_id = S1AP_INITIAL_CONTEXT_SETUP_LOG;
    break;
288

289
290
291
  default:
    S1AP_DEBUG("Unknown procedure ID (%d) for unsuccessfull outcome message\n",
               (int)s1ap_message_p->procedureCode);
292
    return ret;
293
294
295
296
297
298
299
300
301
302
303
304
305
306
    break;
  }

  message_string_size = strlen(message_string);

  message_p = itti_alloc_new_message_sized(TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
  message_p->ittiMsg.s1ap_initial_context_setup_log.size = message_string_size;
  memcpy(&message_p->ittiMsg.s1ap_initial_context_setup_log.text, message_string, message_string_size);

  itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);

  free(message_string);

  return ret;
Cedric Roux's avatar
   
Cedric Roux committed
307
308
309
310
}

static inline
int s1ap_eNB_encode_ue_capability_info_indication(
311
312
313
  S1ap_UECapabilityInfoIndicationIEs_t *ueCapabilityInfoIndicationIEs,
  uint8_t                             **buffer,
  uint32_t                             *length)
Cedric Roux's avatar
   
Cedric Roux committed
314
{
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
  S1ap_UECapabilityInfoIndication_t  ueCapabilityInfoIndication;
  S1ap_UECapabilityInfoIndication_t *ueCapabilityInfoIndication_p =
    &ueCapabilityInfoIndication;

  memset((void *)ueCapabilityInfoIndication_p, 0,  sizeof(ueCapabilityInfoIndication));

  if (s1ap_encode_s1ap_uecapabilityinfoindicationies(
        ueCapabilityInfoIndication_p, ueCapabilityInfoIndicationIEs) < 0) {
    return -1;
  }

  return s1ap_generate_initiating_message(buffer,
                                          length,
                                          S1ap_ProcedureCode_id_UECapabilityInfoIndication,
                                          S1ap_Criticality_ignore,
                                          &asn_DEF_S1ap_UECapabilityInfoIndication,
                                          ueCapabilityInfoIndication_p);
Cedric Roux's avatar
   
Cedric Roux committed
332
333
334
}

static inline
335
int s1ap_eNB_encode_uplink_nas_transport(
336
337
338
  S1ap_UplinkNASTransportIEs_t *uplinkNASTransportIEs,
  uint8_t                     **buffer,
  uint32_t                     *length)
Cedric Roux's avatar
   
Cedric Roux committed
339
{
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
  S1ap_UplinkNASTransport_t  uplinkNASTransport;
  S1ap_UplinkNASTransport_t *uplinkNASTransport_p = &uplinkNASTransport;

  memset((void *)uplinkNASTransport_p, 0, sizeof(uplinkNASTransport));

  if (s1ap_encode_s1ap_uplinknastransporties(
        uplinkNASTransport_p, uplinkNASTransportIEs) < 0) {
    return -1;
  }

  return s1ap_generate_initiating_message(buffer,
                                          length,
                                          S1ap_ProcedureCode_id_uplinkNASTransport,
                                          S1ap_Criticality_ignore,
                                          &asn_DEF_S1ap_UplinkNASTransport,
                                          uplinkNASTransport_p);
Cedric Roux's avatar
   
Cedric Roux committed
356
357
}

358
359
static inline
int s1ap_eNB_encode_nas_non_delivery(
360
361
362
  S1ap_NASNonDeliveryIndication_IEs_t *nasNonDeliveryIndicationIEs,
  uint8_t                            **buffer,
  uint32_t                            *length)
363
{
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
  S1ap_NASNonDeliveryIndication_t  nasNonDeliveryIndication;
  S1ap_NASNonDeliveryIndication_t *nasNonDeliveryIndication_p = &nasNonDeliveryIndication;

  memset((void *)nasNonDeliveryIndication_p, 0, sizeof(nasNonDeliveryIndication));

  if (s1ap_encode_s1ap_nasnondeliveryindication_ies(
        nasNonDeliveryIndication_p, nasNonDeliveryIndicationIEs) < 0) {
    return -1;
  }

  return s1ap_generate_initiating_message(buffer,
                                          length,
                                          S1ap_ProcedureCode_id_NASNonDeliveryIndication,
                                          S1ap_Criticality_ignore,
                                          &asn_DEF_S1ap_NASNonDeliveryIndication,
                                          nasNonDeliveryIndication_p);
380
381
}

Cedric Roux's avatar
   
Cedric Roux committed
382
static inline
383
int s1ap_eNB_encode_s1_setup_request(
384
385
386
  S1ap_S1SetupRequestIEs_t *s1SetupRequestIEs,
  uint8_t                 **buffer,
  uint32_t                 *length)
Cedric Roux's avatar
   
Cedric Roux committed
387
{
388
389
  S1ap_S1SetupRequest_t  s1SetupRequest;
  S1ap_S1SetupRequest_t *s1SetupRequest_p = &s1SetupRequest;
Cedric Roux's avatar
   
Cedric Roux committed
390

391
  memset((void *)s1SetupRequest_p, 0, sizeof(s1SetupRequest));
Cedric Roux's avatar
   
Cedric Roux committed
392

393
394
395
396
397
398
399
400
401
402
  if (s1ap_encode_s1ap_s1setuprequesties(s1SetupRequest_p, s1SetupRequestIEs) < 0) {
    return -1;
  }

  return s1ap_generate_initiating_message(buffer,
                                          length,
                                          S1ap_ProcedureCode_id_S1Setup,
                                          S1ap_Criticality_reject,
                                          &asn_DEF_S1ap_S1SetupRequest,
                                          s1SetupRequest_p);
Cedric Roux's avatar
   
Cedric Roux committed
403
404
405
}

static inline
406
int s1ap_eNB_encode_initial_ue_message(
407
408
409
  S1ap_InitialUEMessageIEs_t *initialUEmessageIEs_p,
  uint8_t                   **buffer,
  uint32_t                   *length)
Cedric Roux's avatar
   
Cedric Roux committed
410
{
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
  S1ap_InitialUEMessage_t  initialUEMessage;
  S1ap_InitialUEMessage_t *initialUEMessage_p = &initialUEMessage;

  memset((void *)initialUEMessage_p, 0, sizeof(initialUEMessage));

  if (s1ap_encode_s1ap_initialuemessageies(
        initialUEMessage_p, initialUEmessageIEs_p) < 0) {
    return -1;
  }

  return s1ap_generate_initiating_message(buffer,
                                          length,
                                          S1ap_ProcedureCode_id_initialUEMessage,
                                          S1ap_Criticality_reject,
                                          &asn_DEF_S1ap_InitialUEMessage,
                                          initialUEMessage_p);
Cedric Roux's avatar
   
Cedric Roux committed
427
428
429
}

static inline
430
int s1ap_eNB_encode_trace_failure(
431
432
433
  S1ap_TraceFailureIndicationIEs_t *trace_failure_ies_p,
  uint8_t                         **buffer,
  uint32_t                         *length)
Cedric Roux's avatar
   
Cedric Roux committed
434
{
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
  S1ap_TraceFailureIndication_t  trace_failure;
  S1ap_TraceFailureIndication_t *trace_failure_p = &trace_failure;

  memset((void *)trace_failure_p, 0, sizeof(trace_failure));

  if (s1ap_encode_s1ap_tracefailureindicationies(
        trace_failure_p, trace_failure_ies_p) < 0) {
    return -1;
  }

  return s1ap_generate_initiating_message(buffer,
                                          length,
                                          S1ap_ProcedureCode_id_TraceFailureIndication,
                                          S1ap_Criticality_reject,
                                          &asn_DEF_S1ap_TraceFailureIndication,
                                          trace_failure_p);
Cedric Roux's avatar
   
Cedric Roux committed
451
452
453
454
}

static inline
int s1ap_eNB_encode_initial_context_setup_response(
455
456
457
  S1ap_InitialContextSetupResponseIEs_t *initialContextSetupResponseIEs,
  uint8_t                              **buffer,
  uint32_t                              *length)
Cedric Roux's avatar
   
Cedric Roux committed
458
{
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
  S1ap_InitialContextSetupResponse_t  initial_context_setup_response;
  S1ap_InitialContextSetupResponse_t *initial_context_setup_response_p =
    &initial_context_setup_response;

  memset((void *)initial_context_setup_response_p, 0,
         sizeof(initial_context_setup_response));

  if (s1ap_encode_s1ap_initialcontextsetupresponseies(
        initial_context_setup_response_p, initialContextSetupResponseIEs) < 0) {
    return -1;
  }

  return s1ap_generate_successfull_outcome(buffer,
         length,
         S1ap_ProcedureCode_id_InitialContextSetup,
         S1ap_Criticality_reject,
         &asn_DEF_S1ap_InitialContextSetupResponse,
         initial_context_setup_response_p);
Cedric Roux's avatar
   
Cedric Roux committed
477
}
gauthier's avatar
gauthier committed
478
479
480

static inline
int s1ap_eNB_encode_ue_context_release_complete(
481
482
483
  S1ap_UEContextReleaseCompleteIEs_t *s1ap_UEContextReleaseCompleteIEs,
  uint8_t                              **buffer,
  uint32_t                              *length)
gauthier's avatar
gauthier committed
484
{
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
  S1ap_UEContextReleaseComplete_t  ue_context_release_complete;
  S1ap_UEContextReleaseComplete_t *ue_context_release_complete_p =
    &ue_context_release_complete;

  memset((void *)ue_context_release_complete_p, 0,
         sizeof(ue_context_release_complete));

  if (s1ap_encode_s1ap_uecontextreleasecompleteies(
        ue_context_release_complete_p, s1ap_UEContextReleaseCompleteIEs) < 0) {
    return -1;
  }

  return s1ap_generate_successfull_outcome(buffer,
         length,
         S1ap_ProcedureCode_id_UEContextRelease,
         S1ap_Criticality_reject,
         &asn_DEF_S1ap_UEContextReleaseComplete,
         ue_context_release_complete_p);
gauthier's avatar
gauthier committed
503
504
}

gauthier's avatar
gauthier committed
505
506
static inline
int s1ap_eNB_encode_ue_context_release_request(
507
508
509
  S1ap_UEContextReleaseRequestIEs_t *s1ap_UEContextReleaseRequestIEs,
  uint8_t                              **buffer,
  uint32_t                              *length)
gauthier's avatar
gauthier committed
510
{
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
  S1ap_UEContextReleaseRequest_t  ue_context_release_request;
  S1ap_UEContextReleaseRequest_t *ue_context_release_request_p =
    &ue_context_release_request;

  memset((void *)ue_context_release_request_p, 0,
         sizeof(ue_context_release_request));

  if (s1ap_encode_s1ap_uecontextreleaserequesties(
        ue_context_release_request_p, s1ap_UEContextReleaseRequestIEs) < 0) {
    return -1;
  }

  return s1ap_generate_initiating_message(buffer,
                                          length,
                                          S1ap_ProcedureCode_id_UEContextReleaseRequest,
                                          S1ap_Criticality_reject,
                                          &asn_DEF_S1ap_UEContextReleaseRequest,
                                          ue_context_release_request_p);
gauthier's avatar
gauthier committed
529
530
}