EmmRegistered.c 5.86 KB
Newer Older
Cedric Roux's avatar
 
Cedric Roux committed
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 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 196
/*****************************************************************************
			Eurecom OpenAirInterface 3
			Copyright(c) 2012 Eurecom

Source		EmmRegistered.c

Version		0.1

Date		2012/10/03

Product		NAS stack

Subsystem	EPS Mobility Management

Author		Frederic Maurel

Description	Implements the EPS Mobility Management procedures executed
		when the EMM-SAP is in EMM-REGISTERED state.

		In EMM-REGISTERED state, an EMM context has been established
		and a default EPS bearer context has been activated in the UE
		and the MME.
		The UE may initiate sending and receiving user data and signal-
		ling information and reply to paging. Additionally, tracking
		area updating or combined tracking area updating procedure is
		performed.

*****************************************************************************/

#include "emm_fsm.h"
#include "commonDef.h"
#include "networkDef.h"
#include "nas_log.h"

#include "emm_proc.h"

#include <assert.h>

/****************************************************************************/
/****************  E X T E R N A L    D E F I N I T I O N S  ****************/
/****************************************************************************/

/****************************************************************************/
/*******************  L O C A L    D E F I N I T I O N S  *******************/
/****************************************************************************/

/****************************************************************************/
/******************  E X P O R T E D    F U N C T I O N S  ******************/
/****************************************************************************/

/****************************************************************************
 **                                                                        **
 ** Name:	 EmmRegistered()                                           **
 **                                                                        **
 ** Description: Handles the behaviour of the UE and the MME while the     **
 **		 EMM-SAP is in EMM-REGISTERED state.                       **
 **                                                                        **
 ** Inputs:	 evt:		The received EMM-SAP event                 **
 **		 Others:	emm_fsm_status                             **
 **                                                                        **
 ** Outputs:	 None                                                      **
 **		 Return:	RETURNok, RETURNerror                      **
 **		 Others:	emm_fsm_status                             **
 **                                                                        **
 ***************************************************************************/
int EmmRegistered(const emm_reg_t* evt)
{
    LOG_FUNC_IN;

    int rc = RETURNerror;

#ifdef NAS_UE
    assert(emm_fsm_get_status() == EMM_REGISTERED);
#endif
#ifdef NAS_MME
    assert(emm_fsm_get_status(evt->ueid, evt->ctx) == EMM_REGISTERED);
#endif

    switch (evt->primitive)
    {
#ifdef NAS_UE
	case _EMMREG_DETACH_INIT:
	    /*
	     * Initiate detach procedure for EPS services
	     */
	    rc = emm_proc_detach(EMM_DETACH_TYPE_EPS, evt->u.detach.switch_off);
	    break;

	case _EMMREG_DETACH_REQ:
	    /*
	     * Network detach has been requested (Detach Request
	     * message successfully delivered to the network);
	     * enter state EMM-DEREGISTERED-INITIATED
	     */
	    rc = emm_fsm_set_status(EMM_DEREGISTERED_INITIATED);
	    break;

	case _EMMREG_DETACH_CNF:
	    /*
	     * The UE implicitly detached from the network (all EPS
	     * bearer contexts may have been deactivated)
	     */
	    rc = emm_fsm_set_status(EMM_DEREGISTERED);
	    break;

	case _EMMREG_TAU_REQ:
	    /*
	     * TODO: Tracking Area Update has been requested
	     */
	    LOG_TRACE(ERROR, "EMM-FSM   - Tracking Area Update procedure "
		      "is not implemented");
	    break;

	case _EMMREG_SERVICE_REQ:
	    /*
	     * TODO: Service Request has been requested
	     */
	    LOG_TRACE(ERROR, "EMM-FSM   - Service Request procedure "
		      "is not implemented");
	    break;

	case _EMMREG_LOWERLAYER_SUCCESS:
	    /*
	     * Data transfer message has been successfully delivered
	     */
	    rc = emm_proc_lowerlayer_success();
	    break;

	case _EMMREG_LOWERLAYER_FAILURE:
	    /*
	     * Data transfer message failed to be delivered
	     */
	    rc = emm_proc_lowerlayer_failure(FALSE);
	    break;

	case _EMMREG_LOWERLAYER_RELEASE:
	    /*
	     * NAS signalling connection has been released
	     */
	    rc = emm_proc_lowerlayer_release();
	    break;
#endif

#ifdef NAS_MME
	case _EMMREG_DETACH_REQ:
	    /*
	     * Network detach has been requested (implicit detach);
	     * enter state EMM-DEREGISTERED
	     */
            rc = emm_fsm_set_status(evt->ueid, evt->ctx, EMM_DEREGISTERED);
	    break;

	case _EMMREG_COMMON_PROC_REQ:
	    /*
	     * An EMM common procedure has been initiated;
	     * enter state EMM-COMMON-PROCEDURE-INITIATED.
	     */
            rc = emm_fsm_set_status(evt->ueid, evt->ctx, EMM_COMMON_PROCEDURE_INITIATED);
	    break;

	case _EMMREG_TAU_REJ:
	    /*
	     * TODO: Tracking Area Update has been rejected
	     */
	    LOG_TRACE(ERROR, "EMM-FSM   - Tracking Area Update procedure "
		      "is not implemented");
	    break;

	case _EMMREG_LOWERLAYER_SUCCESS:
	    /*
	     * Data successfully delivered to the network
	     */
	    rc = RETURNok;
	    break;

	case _EMMREG_LOWERLAYER_FAILURE:
	    /*
	     * Data failed to be delivered to the network
	     */
	    rc = RETURNok;
	    break;
#endif

	default:
	    LOG_TRACE(ERROR, "EMM-FSM   - Primitive is not valid (%d)",
		      evt->primitive);
	    break;
    }

    LOG_FUNC_RETURN (rc);
}

/****************************************************************************/
/*********************  L O C A L    F U N C T I O N S  *********************/
/****************************************************************************/