Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*******************************************************************************
Eurecom OpenAirInterface
Copyright(c) 1999 - 2012 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope 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.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fr/openairinterface
Address : EURECOM, Campus SophiaTech, 450 Route des Chappes
06410 Biot FRANCE
*******************************************************************************/
/*! \file s1ap_eNB_decoder.c
* \brief s1ap pdu decode procedures for eNB
* \author Sebastien ROUX <sebastien.roux@eurecom.fr>
* \date 2013
* \version 0.1
*/
#include <stdio.h>
#include "assertions.h"
#include "s1ap_common.h"
#include "s1ap_ies_defs.h"
#include "s1ap_eNB_decoder.h"
static int s1ap_eNB_decode_initiating_message(s1ap_message *message,

Cédric Roux
committed
S1ap_InitiatingMessage_t *initiating_p)
MessageDef *message_p;
char *message_string = NULL;
size_t message_string_size;
message_string = calloc(10000, sizeof(char));
s1ap_string_total_size = 0;
message->procedureCode = initiating_p->procedureCode;
message->criticality = initiating_p->criticality;
switch(initiating_p->procedureCode)
{

Cédric Roux
committed
case S1ap_ProcedureCode_id_downlinkNASTransport:
ret = s1ap_decode_s1ap_downlinknastransporties(

Cédric Roux
committed
&message->msg.s1ap_DownlinkNASTransportIEs, &initiating_p->value);
s1ap_xer_print_s1ap_downlinknastransport(s1ap_xer__print2sp, message_string, message);

Cédric Roux
committed
case S1ap_ProcedureCode_id_InitialContextSetup:
ret = s1ap_decode_s1ap_initialcontextsetuprequesties(

Cédric Roux
committed
&message->msg.s1ap_InitialContextSetupRequestIEs, &initiating_p->value);
s1ap_xer_print_s1ap_initialcontextsetuprequest(s1ap_xer__print2sp, message_string, message);
message_id = S1AP_INITIAL_CONTEXT_SETUP_LOG;

Cédric Roux
committed
S1AP_ERROR("Unknown procedure ID (%d) for initiating message\n",
AssertFatal( 0 , "Unknown procedure ID (%d) for initiating message\n",
(int)initiating_p->procedureCode);
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_downlink_nas_log.size = message_string_size;
memcpy(&message_p->ittiMsg.s1ap_downlink_nas_log.text, message_string, message_string_size);
itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
free(message_string);
}
static int s1ap_eNB_decode_successful_outcome(s1ap_message *message,

Cédric Roux
committed
S1ap_SuccessfulOutcome_t *successfullOutcome_p)
int ret = -1;
MessageDef *message_p;
char *message_string = NULL;
size_t message_string_size;
message_string = malloc(sizeof(char) * 10000);
s1ap_string_total_size = 0;
message->procedureCode = successfullOutcome_p->procedureCode;
message->criticality = successfullOutcome_p->criticality;
switch(successfullOutcome_p->procedureCode)
{

Cédric Roux
committed
case S1ap_ProcedureCode_id_S1Setup:

Cédric Roux
committed
&message->msg.s1ap_S1SetupResponseIEs, &successfullOutcome_p->value);
s1ap_xer_print_s1ap_s1setupresponse(s1ap_xer__print2sp, message_string, message);
S1AP_ERROR("Unknown procedure ID (%d) for successfull outcome message\n",
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_s1_setup_log.size = message_string_size;
memcpy(&message_p->ittiMsg.s1ap_s1_setup_log.text, message_string, message_string_size);
itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
free(message_string);
return ret;
}
static int s1ap_eNB_decode_unsuccessful_outcome(s1ap_message *message,

Cédric Roux
committed
S1ap_UnsuccessfulOutcome_t *unSuccessfullOutcome_p)
DevAssert(unSuccessfullOutcome_p != NULL);
message->procedureCode = unSuccessfullOutcome_p->procedureCode;
message->criticality = unSuccessfullOutcome_p->criticality;
switch(unSuccessfullOutcome_p->procedureCode) {

Cédric Roux
committed
case S1ap_ProcedureCode_id_S1Setup:
return s1ap_decode_s1ap_s1setupfailureies(
&message->msg.s1ap_S1SetupFailureIEs, &unSuccessfullOutcome_p->value);
S1AP_ERROR("Unknown procedure ID (%d) for unsuccessfull outcome message\n",

Cédric Roux
committed
int s1ap_eNB_decode_pdu(s1ap_message *message, const uint8_t * const buffer,
const uint32_t length)
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
{
S1AP_PDU_t pdu;
S1AP_PDU_t *pdu_p = &pdu;
asn_dec_rval_t dec_ret;
DevAssert(buffer != NULL);
memset((void *)pdu_p, 0, sizeof(S1AP_PDU_t));
dec_ret = aper_decode(NULL,
&asn_DEF_S1AP_PDU,
(void **)&pdu_p,
buffer,
length,
0,
0);
if (dec_ret.code != RC_OK) {
S1AP_ERROR("Failed to decode pdu\n");
return -1;
}
message->direction = pdu_p->present;
switch(pdu_p->present) {
case S1AP_PDU_PR_initiatingMessage:
return s1ap_eNB_decode_initiating_message(message,
&pdu_p->choice.initiatingMessage);
case S1AP_PDU_PR_successfulOutcome:
return s1ap_eNB_decode_successful_outcome(message,
&pdu_p->choice.successfulOutcome);
case S1AP_PDU_PR_unsuccessfulOutcome:
return s1ap_eNB_decode_unsuccessful_outcome(message,
&pdu_p->choice.unsuccessfulOutcome);
default:
S1AP_DEBUG("Unknown presence (%d) or not implemented\n", (int)pdu_p->present);
break;
}
return -1;
}