Commit 97fdf8bb authored by Frédéric Leroy's avatar Frédéric Leroy

UE/ESM: move _esm_ebr_data to nas_user_t

parent 47db200c
......@@ -131,7 +131,7 @@ int esm_proc_dedicated_eps_bearer_context_request(nas_user_t *user, int ebi, int
}
/* Assign dedicated EPS bearer context */
int new_ebi = esm_ebr_assign(ebi, pid+1, FALSE);
int new_ebi = esm_ebr_assign(user->esm_ebr_data, ebi, pid+1, FALSE);
if (new_ebi == ESM_EBI_UNASSIGNED) {
/* 3GPP TS 24.301, section 6.4.2.5, abnormal cases a and b
......@@ -149,7 +149,7 @@ int esm_proc_dedicated_eps_bearer_context_request(nas_user_t *user, int ebi, int
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
} else {
/* Assign new dedicated EPS bearer context */
ebi = esm_ebr_assign(ebi, pid+1, FALSE);
ebi = esm_ebr_assign(user->esm_ebr_data, ebi, pid+1, FALSE);
}
}
......@@ -229,7 +229,7 @@ int esm_proc_dedicated_eps_bearer_context_accept(nas_user_t *user, int is_standa
if (rc != RETURNerror) {
/* Set the EPS bearer context state to ACTIVE */
rc = esm_ebr_set_status(ebi, ESM_EBR_ACTIVE, ue_triggered);
rc = esm_ebr_set_status(user->esm_ebr_data, ebi, ESM_EBR_ACTIVE, ue_triggered);
if (rc != RETURNok) {
/* The EPS bearer context was already in ACTIVE state */
......@@ -276,9 +276,9 @@ int esm_proc_dedicated_eps_bearer_context_reject(nas_user_t *user, int is_standa
LOG_TRACE(WARNING, "ESM-PROC - Dedicated EPS bearer context activation "
"not accepted by the UE (ebi=%d)", ebi);
if ( !esm_ebr_is_not_in_use(ebi) ) {
if ( !esm_ebr_is_not_in_use(user->esm_ebr_data, ebi) ) {
/* Release EPS bearer data currently in use */
rc = esm_ebr_release(ebi);
rc = esm_ebr_release(user->esm_ebr_data, ebi);
}
if (rc != RETURNok) {
......
......@@ -116,7 +116,7 @@ int esm_proc_default_eps_bearer_context_request(nas_user_t *user, int pid, int e
"requested by the network (ebi=%d)", ebi);
/* Assign default EPS bearer context */
int new_ebi = esm_ebr_assign(ebi, pid+1, TRUE);
int new_ebi = esm_ebr_assign(user->esm_ebr_data, ebi, pid+1, TRUE);
if (new_ebi == ESM_EBI_UNASSIGNED) {
/* 3GPP TS 24.301, section 6.4.1.5, abnormal cases a and b
......@@ -134,7 +134,7 @@ int esm_proc_default_eps_bearer_context_request(nas_user_t *user, int pid, int e
*esm_cause = ESM_CAUSE_PROTOCOL_ERROR;
} else {
/* Assign new default EPS bearer context */
ebi = esm_ebr_assign(ebi, pid+1, TRUE);
ebi = esm_ebr_assign(user->esm_ebr_data, ebi, pid+1, TRUE);
}
}
......@@ -213,7 +213,7 @@ int esm_proc_default_eps_bearer_context_accept(nas_user_t *user, int is_standalo
if (rc != RETURNerror) {
/* Set the EPS bearer context state to ACTIVE */
rc = esm_ebr_set_status(ebi, ESM_EBR_ACTIVE, ue_triggered);
rc = esm_ebr_set_status(user->esm_ebr_data, ebi, ESM_EBR_ACTIVE, ue_triggered);
if (rc != RETURNok) {
/* The EPS bearer context was already in ACTIVE state */
......@@ -266,9 +266,9 @@ int esm_proc_default_eps_bearer_context_reject(nas_user_t *user, int is_standalo
LOG_TRACE(WARNING, "ESM-PROC - Default EPS bearer context activation "
"not accepted by the UE (ebi=%d)", ebi);
if ( !esm_ebr_is_not_in_use(ebi) ) {
if ( !esm_ebr_is_not_in_use(user->esm_ebr_data, ebi) ) {
/* Release EPS bearer data currently in use */
rc = esm_ebr_release(ebi);
rc = esm_ebr_release(user->esm_ebr_data, ebi);
}
if (rc != RETURNok) {
......@@ -280,6 +280,7 @@ int esm_proc_default_eps_bearer_context_reject(nas_user_t *user, int is_standalo
* Notity EMM that ESM PDU has to be forwarded to lower layers
*/
emm_sap.primitive = EMMESM_UNITDATA_REQ;
// FIXME REVIEW
emm_sap.u.emm_esm.ueid = 0;
emm_esm->msg.length = msg->length;
emm_esm->msg.value = msg->value;
......
......@@ -281,6 +281,7 @@ int esm_proc_eps_bearer_context_deactivate_accept(nas_user_t *user, int is_stand
LOG_FUNC_IN;
int rc = RETURNok;
esm_ebr_data_t *esm_ebr_data = user->esm_ebr_data;
LOG_TRACE(INFO,"ESM-PROC - EPS bearer context deactivation accepted");
......@@ -298,7 +299,7 @@ int esm_proc_eps_bearer_context_deactivate_accept(nas_user_t *user, int is_stand
if (rc != RETURNerror) {
/* Set the EPS bearer context state to INACTIVE */
rc = esm_ebr_set_status(ebi, ESM_EBR_INACTIVE, ue_triggered);
rc = esm_ebr_set_status(esm_ebr_data, ebi, ESM_EBR_INACTIVE, ue_triggered);
if (rc != RETURNok) {
/* The EPS bearer context was already in INACTIVE state */
......@@ -309,7 +310,7 @@ int esm_proc_eps_bearer_context_deactivate_accept(nas_user_t *user, int is_stand
}
/* Release EPS bearer data */
rc = esm_ebr_release(ebi);
rc = esm_ebr_release(esm_ebr_data, ebi);
}
LOG_FUNC_RETURN (rc);
......@@ -357,6 +358,7 @@ static int _eps_bearer_release(nas_user_t *user, int ebi, int *pid, int *bid)
LOG_FUNC_IN;
int rc = RETURNerror;
esm_ebr_data_t *esm_ebr_data = user->esm_ebr_data;
/* Release the EPS bearer context entry */
ebi = esm_ebr_context_release(user, ebi, pid, bid);
......@@ -365,14 +367,14 @@ static int _eps_bearer_release(nas_user_t *user, int ebi, int *pid, int *bid)
LOG_TRACE(WARNING, "ESM-PROC - Failed to release EPS bearer context");
} else {
/* Set the EPS bearer context state to INACTIVE */
rc = esm_ebr_set_status(ebi, ESM_EBR_INACTIVE, FALSE);
rc = esm_ebr_set_status(esm_ebr_data, ebi, ESM_EBR_INACTIVE, FALSE);
if (rc != RETURNok) {
/* The EPS bearer context was already in INACTIVE state */
LOG_TRACE(WARNING, "ESM-PROC - EBI %d was already INACTIVE", ebi);
} else {
/* Release EPS bearer data */
rc = esm_ebr_release(ebi);
rc = esm_ebr_release(esm_ebr_data, ebi);
if (rc != RETURNok) {
LOG_TRACE(WARNING,
......
......@@ -74,7 +74,7 @@ Description Defines functions executed at the ESM Service Access
** **
** Description: Processes ESM status message **
** **
** Inputs: ueid: UE local identifier **
** Inputs: **
** pti: Procedure transaction identity **
** ebi: EPS bearer identity **
** msg: The received ESM message **
......@@ -164,7 +164,7 @@ int esm_recv_pdn_connectivity_reject(nas_user_t *user, int pti, int ebi,
/*
* EPS bearer identity checking
*/
else if ( (ebi != ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(ebi) ) {
else if ( (ebi != ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(user->esm_ebr_data, ebi) ) {
/* 3GPP TS 24.301, section 7.3.2, case a
* Assigned or reserved EPS bearer identity value */
LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)",
......@@ -235,7 +235,7 @@ int esm_recv_pdn_disconnect_reject(nas_user_t *user, int pti, int ebi,
/*
* EPS bearer identity checking
*/
else if ( (ebi != ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(ebi) ) {
else if ( (ebi != ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(user->esm_ebr_data, ebi) ) {
/* 3GPP TS 24.301, section 7.3.2, case b
* Assigned or reserved EPS bearer identity value */
LOG_TRACE(WARNING, "ESM-SAP - Invalid EPS bearer identity (ebi=%d)",
......@@ -308,7 +308,7 @@ int esm_recv_activate_default_eps_bearer_context_request(nas_user_t *user, int p
/*
* EPS bearer identity checking
*/
else if ( (ebi == ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(ebi) ) {
else if ( (ebi == ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(user->esm_ebr_data, ebi) ) {
/* 3GPP TS 24.301, section 7.3.2, case g
* Reserved or unassigned EPS bearer identity value
*/
......@@ -439,7 +439,7 @@ int esm_recv_activate_dedicated_eps_bearer_context_request(nas_user_t *user, int
/*
* EPS bearer identity checking
*/
else if ( (ebi == ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(ebi) ) {
else if ( (ebi == ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(user->esm_ebr_data, ebi) ) {
/* 3GPP TS 24.301, section 7.3.2, case h
* Reserved or unassigned EPS bearer identity value
*/
......@@ -647,8 +647,8 @@ int esm_recv_deactivate_eps_bearer_context_request(nas_user_t *user, int pti, in
/*
* EPS bearer identity checking
*/
else if ( (ebi == ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(ebi) ||
esm_ebr_is_not_in_use(ebi) ) {
else if ( (ebi == ESM_EBI_UNASSIGNED) || esm_ebr_is_reserved(user->esm_ebr_data, ebi) ||
esm_ebr_is_not_in_use(user->esm_ebr_data, ebi) ) {
/* 3GPP TS 24.301, section 7.3.2, case j
* Reserved or unassigned EPS bearer identity value or,
* assigned value that does not match an existing EPS bearer context
......
This diff is collapsed.
......@@ -45,6 +45,7 @@ Description Defines functions used to handle state of EPS bearer contexts
#include "esmData.h"
#include "nas_timer.h"
#include "user_defs.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
......@@ -72,15 +73,17 @@ typedef int (*esm_indication_callback_t) (int, network_pdn_state_t);
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
int esm_ebr_is_reserved(int ebi);
void esm_ebr_register_callback(esm_indication_callback_t cb);
void esm_ebr_initialize(esm_indication_callback_t cb);
int esm_ebr_assign(int ebi, int cid, int default_ebr);
int esm_ebr_release(int ebi);
int esm_ebr_is_reserved(esm_ebr_data_t *esm_ebr_data, int ebi);
int esm_ebr_set_status(int ebi, esm_ebr_state status, int ue_requested);
esm_ebr_state esm_ebr_get_status(int ebi);
esm_ebr_data_t *esm_ebr_initialize(void);
int esm_ebr_assign(esm_ebr_data_t *esm_ebr_data, int ebi, int cid, int default_ebr);
int esm_ebr_release(esm_ebr_data_t *esm_ebr_data, int ebi);
int esm_ebr_is_not_in_use(int ebi);
int esm_ebr_set_status(esm_ebr_data_t *esm_ebr_data, int ebi, esm_ebr_state status, int ue_requested);
esm_ebr_state esm_ebr_get_status(esm_ebr_data_t *esm_ebr_data, int ebi);
int esm_ebr_is_not_in_use(esm_ebr_data_t *esm_ebr_data, int ebi);
#endif /* __ESM_EBR_H__*/
......@@ -82,7 +82,7 @@ static int _esm_ebr_context_check_precedence(const network_tft_t *,
** Description: Creates a new EPS bearer context to the PDN with the spe- **
** cified PDN connection identifier **
** **
** Inputs: ueid: UE identifier **
** Inputs: **
** pid: PDN connection identifier **
** ebi: EPS bearer identity **
** is_default: TRUE if the new bearer is a default EPS **
......@@ -105,7 +105,6 @@ int esm_ebr_context_create(
int bid = 0;
esm_data_context_t *esm_ctx = NULL;
esm_pdn_t *pdn = NULL;
//unsigned int ueid = 0;
LOG_FUNC_IN;
......@@ -314,7 +313,7 @@ int esm_ebr_context_create(
** Description: Releases EPS bearer context entry previously allocated **
** to the EPS bearer with the specified EPS bearer identity **
** **
** Inputs: ueid: UE identifier **
** Inputs: **
** ebi: EPS bearer identity **
** **
** Outputs: pid: Identifier of the PDN connection entry the **
......@@ -333,8 +332,6 @@ int esm_ebr_context_release(nas_user_t *user,
esm_pdn_t *pdn = NULL;
esm_data_context_t *esm_ctx;
//unsigned int ueid = 0;
LOG_FUNC_IN;
esm_ctx = user->esm_data;
......@@ -451,11 +448,11 @@ int esm_ebr_context_release(nas_user_t *user,
}
/* Set the EPS bearer context state to INACTIVE */
(void) esm_ebr_set_status(pdn->bearer[i]->ebi,
esm_ebr_set_status(user->esm_ebr_data, pdn->bearer[i]->ebi,
ESM_EBR_INACTIVE, TRUE);
/* Release EPS bearer data */
(void) esm_ebr_release(pdn->bearer[i]->ebi);
esm_ebr_release(user->esm_ebr_data, pdn->bearer[i]->ebi);
// esm_ebr_release()
/* Release dedicated EPS bearer data */
......
......@@ -102,8 +102,9 @@ void esm_main_initialize(nas_user_t *user, esm_indication_callback_t cb)
user->esm_pt_data = esm_pt_initialize();
/* Initialize the EPS bearer context manager */
esm_ebr_initialize(cb);
user->esm_ebr_data = esm_ebr_initialize();
// FIXME only one callback for all user or many for many ?
esm_ebr_register_callback(cb);
LOG_FUNC_OUT;
}
......@@ -247,11 +248,13 @@ int esm_main_has_emergency(esm_data_t *esm_data)
** Others: None **
** **
***************************************************************************/
int esm_main_get_pdn_status(esm_data_t *esm_data, int cid, int *state)
int esm_main_get_pdn_status(nas_user_t *user, int cid, int *state)
{
LOG_FUNC_IN;
unsigned int pid = cid - 1;
esm_data_t *esm_data = user->esm_data;
esm_ebr_data_t *esm_ebr_data = user-> esm_ebr_data;
if (pid >= ESM_DATA_PDN_MAX) {
return (FALSE);
......@@ -268,7 +271,7 @@ int esm_main_get_pdn_status(esm_data_t *esm_data, int cid, int *state)
/* The status of a PDN connection is the status of the default EPS bearer
* that has been assigned to this PDN connection at activation time */
int ebi = esm_data->pdn[pid].data->bearer[0]->ebi;
*state = (esm_ebr_get_status(ebi) == ESM_EBR_ACTIVE);
*state = (esm_ebr_get_status(esm_ebr_data, ebi) == ESM_EBR_ACTIVE);
}
/* The PDN connection has not been activated yet */
......
......@@ -70,7 +70,7 @@ void esm_main_cleanup(esm_data_t *esm_data);
int esm_main_get_nb_pdns_max(esm_data_t *esm_data);
int esm_main_get_nb_pdns(esm_data_t *esm_data);
int esm_main_has_emergency(esm_data_t *esm_data);
int esm_main_get_pdn_status(esm_data_t *esm_data, int cid, int *state);
int esm_main_get_pdn_status(nas_user_t *user, int cid, int *state);
int esm_main_get_pdn(esm_data_t *esm_data, int cid, int *type, const char **apn, int *is_emergency,
int *is_active);
int esm_main_get_pdn_addr(esm_data_t *esm_data, int cid, const char **ipv4addr, const char **ipv6addr);
......
......@@ -674,7 +674,7 @@ int nas_proc_get_pdn_range(esm_data_t *esm_data)
** Others: None **
** **
***************************************************************************/
int nas_proc_get_pdn_status(esm_data_t *esm_data, int *cids, int *states, int n_pdn_max)
int nas_proc_get_pdn_status(nas_user_t *user, int *cids, int *states, int n_pdn_max)
{
LOG_FUNC_IN;
......@@ -682,13 +682,13 @@ int nas_proc_get_pdn_status(esm_data_t *esm_data, int *cids, int *states, int n_
int n_defined_pdn = 0;
/* Get the maximum number of supported PDN contexts */
int n_pdn = esm_main_get_nb_pdns_max(esm_data);
int n_pdn = esm_main_get_nb_pdns_max(user->esm_data);
/* For all PDN contexts */
for (cid = 1; (cid < n_pdn+1) && (n_defined_pdn < n_pdn_max); cid++) {
/* Get the status of this PDN */
int state = FALSE;
int is_defined = esm_main_get_pdn_status(esm_data, cid, &state);
int is_defined = esm_main_get_pdn_status(user, cid, &state);
if (is_defined != FALSE) {
/* This PDN has been defined */
......
......@@ -98,7 +98,7 @@ int nas_proc_reset_pdn(nas_user_t *user, int cid);
int nas_proc_set_pdn(nas_user_t *user, int cid, int type, const char *apn, int ipv4_addr,
int emergency, int p_cscf, int im_cn_signal);
int nas_proc_get_pdn_range(esm_data_t *esm_data);
int nas_proc_get_pdn_status(esm_data_t *esm_data, int *cids, int *states, int n_pdn_max);
int nas_proc_get_pdn_status(nas_user_t *user, int *cids, int *states, int n_pdn_max);
int nas_proc_get_pdn_param(esm_data_t *esm_data, int *cids, int *types, const char **apns,
int n_pdn_max);
int nas_proc_get_pdn_addr(nas_user_t *user, int cid, int *cids, const char **addr1,
......
......@@ -2184,7 +2184,7 @@ static int _nas_user_proc_cgact(nas_user_t *user, const at_command_t *data)
* The read command returns the current activation states for
* all the defined PDN/EPS bearer contexts
*/
cgact->n_pdns = nas_proc_get_pdn_status(user->esm_data, cgact->cid, cgact->state,
cgact->n_pdns = nas_proc_get_pdn_status(user, cgact->cid, cgact->state,
AT_CGACT_RESP_SIZE);
if (cgact->n_pdns == 0) {
......
......@@ -56,6 +56,7 @@ typedef struct {
esm_data_t *esm_data; // ESM internal data (used within ESM only)
esm_pt_data_t *esm_pt_data;
emm_fsm_state_t emm_fsm_status; // Current EPS Mobility Management status
esm_ebr_data_t *esm_ebr_data; // EPS bearer contexts
} nas_user_t;
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment