From f2767bebfb2a944a0dfdf7deb8eac47be62f4455 Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Wed, 13 Nov 2013 09:07:25 +0000
Subject: [PATCH] - Updated S1AP to integrate instance id instead of mod id -
Updated some messages for S1AP
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4375 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
openair-cn/S1AP/s1ap_eNB.c | 29 ++-
openair-cn/S1AP/s1ap_eNB_defs.h | 46 +---
openair-cn/S1AP/s1ap_eNB_handlers.c | 3 +-
openair-cn/S1AP/s1ap_eNB_itti_messaging.c | 5 +-
openair-cn/S1AP/s1ap_eNB_itti_messaging.h | 2 +-
.../S1AP/s1ap_eNB_management_procedures.c | 71 +-----
openair-cn/S1AP/s1ap_eNB_nas_procedures.c | 234 +++++++++++-------
openair-cn/S1AP/s1ap_eNB_nas_procedures.h | 12 +-
8 files changed, 188 insertions(+), 214 deletions(-)
diff --git a/openair-cn/S1AP/s1ap_eNB.c b/openair-cn/S1AP/s1ap_eNB.c
index 255f521954..1c5b08f1b2 100644
--- a/openair-cn/S1AP/s1ap_eNB.c
+++ b/openair-cn/S1AP/s1ap_eNB.c
@@ -61,6 +61,9 @@
static int s1ap_eNB_generate_s1_setup_request(
s1ap_eNB_instance_t *instance_p, s1ap_eNB_mme_data_t *s1ap_mme_data_p);
+static
+void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_eNB_t *s1ap_register_eNB);
+
uint32_t s1ap_generate_eNB_id(void)
{
char *out;
@@ -121,7 +124,8 @@ static void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p,
itti_send_msg_to_task(TASK_SCTP, INSTANCE_DEFAULT, message_p);
}
-void s1ap_eNB_handle_register_eNB(s1ap_register_eNB_t *s1ap_register_eNB)
+static
+void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_eNB_t *s1ap_register_eNB)
{
s1ap_eNB_instance_t *new_instance;
uint8_t index;
@@ -131,7 +135,7 @@ void s1ap_eNB_handle_register_eNB(s1ap_register_eNB_t *s1ap_register_eNB)
/* Look if the provided mod id already exists
* If so notify user...
*/
- new_instance = s1ap_eNB_get_instance(s1ap_register_eNB->mod_id);
+ new_instance = s1ap_eNB_get_instance(instance);
DevAssert(new_instance == NULL);
new_instance = calloc(1, sizeof(s1ap_eNB_instance_t));
@@ -141,7 +145,7 @@ void s1ap_eNB_handle_register_eNB(s1ap_register_eNB_t *s1ap_register_eNB)
RB_INIT(&new_instance->s1ap_mme_head);
/* Copy usefull parameters */
- new_instance->mod_id = s1ap_register_eNB->mod_id;
+ new_instance->instance = instance;
new_instance->eNB_name = s1ap_register_eNB->eNB_name;
new_instance->eNB_id = s1ap_register_eNB->eNB_id;
new_instance->cell_type = s1ap_register_eNB->cell_type;
@@ -153,8 +157,8 @@ void s1ap_eNB_handle_register_eNB(s1ap_register_eNB_t *s1ap_register_eNB)
/* Add the new instance to the list of eNB (meaningfull in virtual mode) */
s1ap_eNB_insert_new_instance(new_instance);
- S1AP_DEBUG("Registered new eNB with mod_id %u and %s eNB id %u\n",
- s1ap_register_eNB->mod_id,
+ S1AP_DEBUG("Registered new eNB[%d] %u and %s eNB id %u\n",
+ instance,
s1ap_register_eNB->cell_type == CELL_MACRO_ENB ? "macro" : "home",
s1ap_register_eNB->eNB_id);
@@ -232,7 +236,8 @@ void *s1ap_eNB_task(void *arg)
* Each eNB has to send an S1AP_REGISTER_ENB message with its
* own parameters.
*/
- s1ap_eNB_handle_register_eNB(&received_msg->msg.s1ap_register_eNB);
+ s1ap_eNB_handle_register_eNB(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+ &received_msg->msg.s1ap_register_eNB);
} break;
case SCTP_NEW_ASSOCIATION_RESP: {
s1ap_eNB_handle_sctp_association_resp(&received_msg->msg.sctp_new_association_resp);
@@ -241,7 +246,17 @@ void *s1ap_eNB_task(void *arg)
s1ap_eNB_handle_sctp_data_ind(&received_msg->msg.sctp_data_ind);
} break;
case S1AP_NAS_FIRST_REQ: {
- s1ap_eNB_handle_nas_first_req(&received_msg->msg.s1ap_nas_first_req);
+ s1ap_eNB_handle_nas_first_req(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+ &received_msg->msg.s1ap_nas_first_req);
+ } break;
+ case S1AP_UPLINK_NAS: {
+ s1ap_eNB_nas_uplink(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+ &received_msg->msg.s1ap_uplink_nas);
+ } break;
+ case S1AP_INITIAL_CONTEXT_SETUP_RESP: {
+ s1ap_eNB_initial_ctxt_resp(
+ ITTI_MESSAGE_GET_INSTANCE(received_msg),
+ &received_msg->msg.s1ap_initial_context_setup_resp);
} break;
default:
S1AP_ERROR("Received unhandled message with id %d\n",
diff --git a/openair-cn/S1AP/s1ap_eNB_defs.h b/openair-cn/S1AP/s1ap_eNB_defs.h
index fdcaf72aba..8c2f2530b8 100644
--- a/openair-cn/S1AP/s1ap_eNB_defs.h
+++ b/openair-cn/S1AP/s1ap_eNB_defs.h
@@ -82,50 +82,6 @@ typedef enum {
S1AP_OVERLOAD_MAX,
} s1ap_overload_state_t;
-typedef struct {
- uint8_t qci;
-
-} e_rab_level_qos_parameter_t;
-
-typedef struct {
- /* Length of the transport layer address buffer. S1AP layer received a
- * bit string<1..160> containing one of the following addresses: ipv4,
- * ipv6, or ipv4 and ipv6. The layer doesn't interpret the buffer but
- * silently forward it to S1-U.
- */
- uint8_t length;
- uint8_t buffer[20];
-} transport_layer_addr_t;
-
-typedef struct {
- /* Unique e_rab_id for the UE. */
- uint8_t e_rab_id;
- /* Quality of service for this e_rab */
- e_rab_level_qos_parameter_t qos;
- /* The NAS PDU should be forwarded by the RRC layer to the NAS layer */
- nas_pdu_t nas_pdu;
- /* The transport layer address for the IP packets */
- transport_layer_addr_t sgw_addr;
- /* S-GW Tunnel endpoint identifier */
- uint32_t gtp_teid;
-} e_rab_t;
-
-typedef struct {
- /* Unique e_rab_id for the UE. */
- uint8_t e_rab_id;
- /* The transport layer address for the IP packets */
- transport_layer_addr_t eNB_addr;
- /* S-GW Tunnel endpoint identifier */
- uint32_t gtp_teid;
-} e_rab_setup_t;
-
-typedef struct {
- /* Unique e_rab_id for the UE. */
- uint8_t e_rab_id;
- /* Cause of the failure */
-// cause_t cause;
-} e_rab_failed_t;
-
/* Served PLMN identity element */
struct plmn_identity_s {
uint16_t mcc;
@@ -225,7 +181,7 @@ typedef struct s1ap_eNB_instance_s {
RB_HEAD(s1ap_ue_map, s1ap_eNB_ue_context_s) s1ap_ue_head;
/* For virtual mode, mod_id as defined in the rest of the L1/L2 stack */
- uint8_t mod_id;
+ instance_t instance;
/* Displayable name of eNB */
char *eNB_name;
diff --git a/openair-cn/S1AP/s1ap_eNB_handlers.c b/openair-cn/S1AP/s1ap_eNB_handlers.c
index c0908d4cb7..b44ce61f41 100644
--- a/openair-cn/S1AP/s1ap_eNB_handlers.c
+++ b/openair-cn/S1AP/s1ap_eNB_handlers.c
@@ -327,7 +327,8 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id,
s1ap_nas_first_req.nas_pdu.buffer = nas_attach_req_guti;
s1ap_nas_first_req.nas_pdu.length = sizeof(nas_attach_req_guti);
- s1ap_eNB_handle_nas_first_req(&s1ap_nas_first_req);
+ s1ap_eNB_handle_nas_first_req(mme_desc_p->s1ap_eNB_instance->instance,
+ &s1ap_nas_first_req);
}
return 0;
diff --git a/openair-cn/S1AP/s1ap_eNB_itti_messaging.c b/openair-cn/S1AP/s1ap_eNB_itti_messaging.c
index 04549272e0..485e80d7aa 100644
--- a/openair-cn/S1AP/s1ap_eNB_itti_messaging.c
+++ b/openair-cn/S1AP/s1ap_eNB_itti_messaging.c
@@ -20,7 +20,7 @@ void s1ap_eNB_itti_send_sctp_data_req(int32_t assoc_id, uint8_t *buffer,
itti_send_msg_to_task(TASK_SCTP, INSTANCE_DEFAULT, message_p);
}
-void s1ap_eNB_itti_send_nas_downlink_ind(uint8_t mod_id, uint8_t *nas_pdu,
+void s1ap_eNB_itti_send_nas_downlink_ind(instance_t instance, uint8_t *nas_pdu,
uint32_t nas_pdu_length)
{
MessageDef *message_p;
@@ -30,9 +30,8 @@ void s1ap_eNB_itti_send_nas_downlink_ind(uint8_t mod_id, uint8_t *nas_pdu,
s1ap_downlink_nas = &message_p->msg.s1ap_downlink_nas;
- s1ap_downlink_nas->mod_id = mod_id;
s1ap_downlink_nas->nas_pdu.buffer = nas_pdu;
s1ap_downlink_nas->nas_pdu.length = nas_pdu_length;
- itti_send_msg_to_task(TASK_RRC_ENB, INSTANCE_DEFAULT, message_p);
+ itti_send_msg_to_task(TASK_RRC_ENB, instance, message_p);
}
diff --git a/openair-cn/S1AP/s1ap_eNB_itti_messaging.h b/openair-cn/S1AP/s1ap_eNB_itti_messaging.h
index dd244ef45f..8b0de73418 100644
--- a/openair-cn/S1AP/s1ap_eNB_itti_messaging.h
+++ b/openair-cn/S1AP/s1ap_eNB_itti_messaging.h
@@ -4,7 +4,7 @@
void s1ap_eNB_itti_send_sctp_data_req(int32_t assoc_id, uint8_t *buffer,
uint32_t buffer_length, uint16_t stream);
-void s1ap_eNB_itti_send_nas_downlink_ind(uint8_t mod_id, uint8_t *nas_pdu,
+void s1ap_eNB_itti_send_nas_downlink_ind(instance_t instance, uint8_t *nas_pdu,
uint32_t nas_pdu_length);
#endif /* S1AP_ENB_ITTI_MESSAGING_H_ */
diff --git a/openair-cn/S1AP/s1ap_eNB_management_procedures.c b/openair-cn/S1AP/s1ap_eNB_management_procedures.c
index 058a56fc7b..ee91c67065 100644
--- a/openair-cn/S1AP/s1ap_eNB_management_procedures.c
+++ b/openair-cn/S1AP/s1ap_eNB_management_procedures.c
@@ -118,14 +118,14 @@ inline struct s1ap_eNB_mme_data_s *s1ap_eNB_get_MME(
return NULL;
}
-s1ap_eNB_instance_t *s1ap_eNB_get_instance(uint8_t mod_id)
+s1ap_eNB_instance_t *s1ap_eNB_get_instance(instance_t instance)
{
s1ap_eNB_instance_t *temp = NULL;
STAILQ_FOREACH(temp, &s1ap_eNB_internal_data.s1ap_eNB_instances_head,
s1ap_eNB_entries)
{
- if (temp->mod_id == mod_id) {
+ if (temp->instance == instance) {
/* Matching occurence */
return temp;
}
@@ -133,70 +133,3 @@ s1ap_eNB_instance_t *s1ap_eNB_get_instance(uint8_t mod_id)
return NULL;
}
-
-// int s1ap_eNB_ue_capabilities(eNB_mme_desc_t *eNB_desc_p,
-// s1ap_ue_cap_info_ind_t *ue_cap_info_ind_p)
-// {
-// struct s1ap_eNB_ue_context_s *ue_context_p;
-// UECapabilityInfoIndicationIEs_t *ue_cap_info_ind_ies_p;
-//
-// s1ap_message message;
-//
-// uint8_t *buffer;
-// uint32_t length;
-// int ret = -1;
-//
-// DevAssert(ue_cap_info_ind_p != NULL);
-// DevAssert(eNB_desc_p != NULL);
-//
-// if ((ue_context_p = s1ap_eNB_get_ue_context(eNB_desc_p, ue_cap_info_ind_p->eNB_ue_s1ap_id)) == NULL)
-// {
-// /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */
-// S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: %u\n",
-// ue_cap_info_ind_p->eNB_ue_s1ap_id);
-// return -1;
-// }
-//
-// /* UE capabilities message can occur either during an s1ap connected state
-// * or during initial attach (for example: NAS authentication).
-// */
-// if (!(ue_context_p->ue_state == S1AP_UE_CONNECTED ||
-// ue_context_p->ue_state == S1AP_UE_WAITING_CSR))
-// {
-// S1AP_WARN("You are attempting to send NAS data over non-connected "
-// "eNB ue s1ap id: %u, current state: %d\n",
-// ue_cap_info_ind_p->eNB_ue_s1ap_id, ue_context_p->ue_state);
-// return -1;
-// }
-//
-// /* Prepare the S1AP message to encode */
-// memset(&message, 0, sizeof(s1ap_message));
-//
-// message.direction = S1AP_PDU_PR_initiatingMessage;
-// message.procedureCode = ProcedureCode_id_UECapabilityInfoIndication;
-//
-// ue_cap_info_ind_ies_p = &message.msg.ueCapabilityInfoIndicationIEs;
-//
-// ue_cap_info_ind_ies_p->ueRadioCapability.buf = ue_cap_info_ind_p->ue_radio_cap.buffer;
-// ue_cap_info_ind_ies_p->ueRadioCapability.size = ue_cap_info_ind_p->ue_radio_cap.length;
-//
-// ue_cap_info_ind_ies_p->eNB_UE_S1AP_ID = ue_cap_info_ind_p->eNB_ue_s1ap_id;
-// ue_cap_info_ind_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
-//
-// if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
-// /* Encode procedure has failed... */
-// S1AP_ERROR("Failed to encode UE capabilities indication\n");
-// return -1;
-// }
-//
-// /* UE associated signalling -> use the allocated stream */
-// if ((ret = sctp_send_msg(&ue_context_p->mme_ref->sctp_data, S1AP_SCTP_PPID,
-// ue_context_p->stream, buffer, length)) < 0)
-// {
-// S1AP_ERROR("[SCTP %d] Failed to send message over SCTP: %d\n",
-// ue_context_p->mme_ref->sctp_data.assoc_id, ret);
-// }
-//
-// free(buffer);
-// return ret;
-// }
diff --git a/openair-cn/S1AP/s1ap_eNB_nas_procedures.c b/openair-cn/S1AP/s1ap_eNB_nas_procedures.c
index 934a4b9765..b119985de7 100644
--- a/openair-cn/S1AP/s1ap_eNB_nas_procedures.c
+++ b/openair-cn/S1AP/s1ap_eNB_nas_procedures.c
@@ -49,7 +49,8 @@
#include "s1ap_eNB_nas_procedures.h"
#include "s1ap_eNB_management_procedures.h"
-int s1ap_eNB_handle_nas_first_req(s1ap_nas_first_req_t *s1ap_nas_first_req_p)
+int s1ap_eNB_handle_nas_first_req(
+ instance_t instance, s1ap_nas_first_req_t *s1ap_nas_first_req_p)
{
s1ap_eNB_instance_t *instance_p;
struct s1ap_eNB_mme_data_s *mme_desc_p;
@@ -65,7 +66,7 @@ int s1ap_eNB_handle_nas_first_req(s1ap_nas_first_req_t *s1ap_nas_first_req_p)
DevAssert(s1ap_nas_first_req_p != NULL);
/* Retrieve the S1AP eNB instance associated with Mod_id */
- instance_p = s1ap_eNB_get_instance(s1ap_nas_first_req_p->mod_id);
+ instance_p = s1ap_eNB_get_instance(instance);
DevAssert(instance_p != NULL);
memset(&message, 0, sizeof(s1ap_message));
@@ -236,14 +237,14 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id,
}
/* Forward the NAS PDU to RRC */
- s1ap_eNB_itti_send_nas_downlink_ind(s1ap_eNB_instance->mod_id,
+ s1ap_eNB_itti_send_nas_downlink_ind(s1ap_eNB_instance->instance,
downlink_NAS_transport_p->nas_pdu.buf,
downlink_NAS_transport_p->nas_pdu.size);
return 0;
}
-int s1ap_eNB_nas_uplink(s1ap_uplink_nas_t *s1ap_uplink_nas_p)
+int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_p)
{
struct s1ap_eNB_ue_context_s *ue_context_p;
s1ap_eNB_instance_t *s1ap_eNB_instance_p;
@@ -257,7 +258,7 @@ int s1ap_eNB_nas_uplink(s1ap_uplink_nas_t *s1ap_uplink_nas_p)
DevAssert(s1ap_uplink_nas_p != NULL);
/* Retrieve the S1AP eNB instance associated with Mod_id */
- s1ap_eNB_instance_p = s1ap_eNB_get_instance(s1ap_uplink_nas_p->mod_id);
+ s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance);
DevAssert(s1ap_eNB_instance_p != NULL);
if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p, s1ap_uplink_nas_p->eNB_ue_s1ap_id)) == NULL)
@@ -317,83 +318,146 @@ int s1ap_eNB_nas_uplink(s1ap_uplink_nas_t *s1ap_uplink_nas_p)
return 0;
}
-// int s1ap_eNB_initial_ctxt_resp(eNB_mme_desc_t *s1ap_eNB_instance_p,
-// s1ap_initial_ctxt_setup_resp_t *initial_ctxt_resp_p)
-// {
-// struct s1ap_eNB_ue_context_s *ue_context_p;
-// InitialContextSetupResponseIEs_t *initial_ies_p;
-//
-// s1ap_message message;
-//
-// uint8_t *buffer;
-// uint32_t length;
-// int ret = -1;
-// int i;
-//
-// DevAssert(initial_ctxt_resp_p != NULL);
-// DevAssert(s1ap_eNB_instance_p != NULL);
-//
-// if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p,
-// initial_ctxt_resp_p->eNB_ue_s1ap_id)) == NULL)
-// {
-// /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */
-// S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: %u\n",
-// initial_ctxt_resp_p->eNB_ue_s1ap_id);
-// return -1;
-// }
-//
-// /* Uplink NAS transport can occur either during an s1ap connected state
-// * or during initial attach (for example: NAS authentication).
-// */
-// if (!(ue_context_p->ue_state == S1AP_UE_CONNECTED ||
-// ue_context_p->ue_state == S1AP_UE_WAITING_CSR))
-// {
-// S1AP_WARN("You are attempting to send NAS data over non-connected "
-// "eNB ue s1ap id: %u, current state: %d\n",
-// initial_ctxt_resp_p->eNB_ue_s1ap_id, ue_context_p->ue_state);
-// return -1;
-// }
-//
-// /* Prepare the S1AP message to encode */
-// memset(&message, 0, sizeof(s1ap_message));
-//
-// message.direction = S1AP_PDU_PR_successfulOutcome;
-// message.procedureCode = ProcedureCode_id_InitialContextSetup;
-//
-// initial_ies_p = &message.msg.initialContextSetupResponseIEs;
-//
-// initial_ies_p->eNB_UE_S1AP_ID = initial_ctxt_resp_p->eNB_ue_s1ap_id;
-// initial_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
-//
-// for (i = 0; i < initial_ctxt_resp_p->nb_of_e_rabs; i++)
-// {
-// E_RABSetupItemCtxtSURes_t *new_item;
-//
-// new_item = calloc(1, sizeof(E_RABSetupItemCtxtSURes_t));
-//
-// new_item->e_RAB_ID = initial_ctxt_resp_p->e_rabs[i].e_rab_id;
-// GTP_TEID_TO_ASN1(initial_ctxt_resp_p->e_rabs[i].gtp_teid, &new_item->gTP_TEID);
-// new_item->transportLayerAddress.buf = initial_ctxt_resp_p->e_rabs[i].eNB_addr.buffer;
-// new_item->transportLayerAddress.size = initial_ctxt_resp_p->e_rabs[i].eNB_addr.length;
-// new_item->transportLayerAddress.bits_unused = 0;
-//
-// ASN_SEQUENCE_ADD(&initial_ies_p->e_RABSetupListCtxtSURes.e_RABSetupItemCtxtSURes, new_item);
-// }
-//
-// if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
-// S1AP_ERROR("Failed to encode uplink NAS transport\n");
-// /* Encode procedure has failed... */
-// return -1;
-// }
-//
-// /* UE associated signalling -> use the allocated stream */
-// if ((ret = sctp_send_msg(&ue_context_p->mme_ref->sctp_data, S1AP_SCTP_PPID,
-// ue_context_p->stream, buffer, length)) < 0)
-// {
-// S1AP_ERROR("[SCTP %d] Failed to send message over SCTP: %d\n",
-// ue_context_p->mme_ref->sctp_data.assoc_id, ret);
-// }
-//
-// free(buffer);
-// return ret;
-// }
+int s1ap_eNB_initial_ctxt_resp(
+ instance_t instance, s1ap_initial_context_setup_resp_t *initial_ctxt_resp_p)
+{
+ s1ap_eNB_instance_t *s1ap_eNB_instance_p;
+ struct s1ap_eNB_ue_context_s *ue_context_p;
+
+ S1ap_InitialContextSetupResponseIEs_t *initial_ies_p;
+
+ s1ap_message message;
+
+ uint8_t *buffer;
+ uint32_t length;
+ int ret = -1;
+ int i;
+
+ DevAssert(initial_ctxt_resp_p != NULL);
+ DevAssert(s1ap_eNB_instance_p != NULL);
+
+ if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p,
+ initial_ctxt_resp_p->eNB_ue_s1ap_id)) == NULL)
+ {
+ /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */
+ S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: %u\n",
+ initial_ctxt_resp_p->eNB_ue_s1ap_id);
+ return -1;
+ }
+
+ /* Uplink NAS transport can occur either during an s1ap connected state
+ * or during initial attach (for example: NAS authentication).
+ */
+ if (!(ue_context_p->ue_state == S1AP_UE_CONNECTED ||
+ ue_context_p->ue_state == S1AP_UE_WAITING_CSR))
+ {
+ S1AP_WARN("You are attempting to send NAS data over non-connected "
+ "eNB ue s1ap id: %u, current state: %d\n",
+ initial_ctxt_resp_p->eNB_ue_s1ap_id, ue_context_p->ue_state);
+ return -1;
+ }
+
+ /* Prepare the S1AP message to encode */
+ memset(&message, 0, sizeof(s1ap_message));
+
+ message.direction = S1AP_PDU_PR_successfulOutcome;
+ message.procedureCode = S1ap_ProcedureCode_id_InitialContextSetup;
+
+ initial_ies_p = &message.msg.s1ap_InitialContextSetupResponseIEs;
+
+ initial_ies_p->eNB_UE_S1AP_ID = initial_ctxt_resp_p->eNB_ue_s1ap_id;
+ initial_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
+
+ for (i = 0; i < initial_ctxt_resp_p->nb_of_e_rabs; i++)
+ {
+ S1ap_E_RABSetupItemCtxtSURes_t *new_item;
+
+ new_item = calloc(1, sizeof(S1ap_E_RABSetupItemCtxtSURes_t));
+
+ new_item->e_RAB_ID = initial_ctxt_resp_p->e_rabs[i].e_rab_id;
+ GTP_TEID_TO_ASN1(initial_ctxt_resp_p->e_rabs[i].gtp_teid, &new_item->gTP_TEID);
+ new_item->transportLayerAddress.buf = initial_ctxt_resp_p->e_rabs[i].eNB_addr.buffer;
+ new_item->transportLayerAddress.size = initial_ctxt_resp_p->e_rabs[i].eNB_addr.length;
+ new_item->transportLayerAddress.bits_unused = 0;
+
+ ASN_SEQUENCE_ADD(&initial_ies_p->e_RABSetupListCtxtSURes.s1ap_E_RABSetupItemCtxtSURes,
+ new_item);
+ }
+
+ if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+ S1AP_ERROR("Failed to encode uplink NAS transport\n");
+ /* Encode procedure has failed... */
+ return -1;
+ }
+
+ /* UE associated signalling -> use the allocated stream */
+ s1ap_eNB_itti_send_sctp_data_req(ue_context_p->mme_ref->assoc_id, buffer,
+ length, ue_context_p->stream);
+
+ return ret;
+}
+
+int s1ap_eNB_ue_capabilities(instance_t instance,
+ s1ap_ue_cap_info_ind_t *ue_cap_info_ind_p)
+{
+ s1ap_eNB_instance_t *s1ap_eNB_instance_p;
+ struct s1ap_eNB_ue_context_s *ue_context_p;
+
+ S1ap_UECapabilityInfoIndicationIEs_t *ue_cap_info_ind_ies_p;
+
+ s1ap_message message;
+
+ uint8_t *buffer;
+ uint32_t length;
+ int ret = -1;
+
+ DevAssert(ue_cap_info_ind_p != NULL);
+ DevAssert(s1ap_eNB_instance_p != NULL);
+
+ if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p,
+ ue_cap_info_ind_p->eNB_ue_s1ap_id)) == NULL)
+ {
+ /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */
+ S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: %u\n",
+ ue_cap_info_ind_p->eNB_ue_s1ap_id);
+ return -1;
+ }
+
+ /* UE capabilities message can occur either during an s1ap connected state
+ * or during initial attach (for example: NAS authentication).
+ */
+ if (!(ue_context_p->ue_state == S1AP_UE_CONNECTED ||
+ ue_context_p->ue_state == S1AP_UE_WAITING_CSR))
+ {
+ S1AP_WARN("You are attempting to send NAS data over non-connected "
+ "eNB ue s1ap id: %u, current state: %d\n",
+ ue_cap_info_ind_p->eNB_ue_s1ap_id, ue_context_p->ue_state);
+ return -1;
+ }
+
+ /* Prepare the S1AP message to encode */
+ memset(&message, 0, sizeof(s1ap_message));
+
+ message.direction = S1AP_PDU_PR_initiatingMessage;
+ message.procedureCode = S1ap_ProcedureCode_id_UECapabilityInfoIndication;
+
+ ue_cap_info_ind_ies_p = &message.msg.s1ap_UECapabilityInfoIndicationIEs;
+
+ ue_cap_info_ind_ies_p->ueRadioCapability.buf = ue_cap_info_ind_p->ue_radio_cap.buffer;
+ ue_cap_info_ind_ies_p->ueRadioCapability.size = ue_cap_info_ind_p->ue_radio_cap.length;
+
+ ue_cap_info_ind_ies_p->eNB_UE_S1AP_ID = ue_cap_info_ind_p->eNB_ue_s1ap_id;
+ ue_cap_info_ind_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
+
+ if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+ /* Encode procedure has failed... */
+ S1AP_ERROR("Failed to encode UE capabilities indication\n");
+ return -1;
+ }
+
+ /* UE associated signalling -> use the allocated stream */
+ s1ap_eNB_itti_send_sctp_data_req(ue_context_p->mme_ref->assoc_id, buffer,
+ length, ue_context_p->stream);
+
+ return ret;
+}
diff --git a/openair-cn/S1AP/s1ap_eNB_nas_procedures.h b/openair-cn/S1AP/s1ap_eNB_nas_procedures.h
index 6445f1e00d..fa9ab4c8b5 100644
--- a/openair-cn/S1AP/s1ap_eNB_nas_procedures.h
+++ b/openair-cn/S1AP/s1ap_eNB_nas_procedures.h
@@ -35,9 +35,15 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id,
uint32_t stream,
struct s1ap_message_s *message_p);
-int s1ap_eNB_handle_nas_first_req(s1ap_nas_first_req_t *s1ap_nas_first_req_p);
+int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_p);
-// int s1ap_eNB_initial_ctxt_resp(eNB_mme_desc_t *eNB_desc_p,
-// s1ap_initial_ctxt_setup_resp_t *initial_ctxt_resp_p);
+int s1ap_eNB_handle_nas_first_req(
+ instance_t instance, s1ap_nas_first_req_t *s1ap_nas_first_req_p);
+
+int s1ap_eNB_initial_ctxt_resp(
+ instance_t instance, s1ap_initial_context_setup_resp_t *initial_ctxt_resp_p);
+
+int s1ap_eNB_ue_capabilities(instance_t instance,
+ s1ap_ue_cap_info_ind_t *ue_cap_info_ind_p);
#endif /* S1AP_ENB_NAS_PROCEDURES_H_ */
--
GitLab