emm_asDef.h 11 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.0  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

gauthier's avatar
 
gauthier committed
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
/*****************************************************************************

Source      emm_asDef.h

Version     0.1

Date        2012/10/16

Product     NAS stack

Subsystem   EPS Mobility Management

Author      Frederic Maurel

Description Defines the EMM primitives available at the EMMAS Service
        Access Point to transfer NAS messages to/from the Access
        Stratum sublayer.

*****************************************************************************/
#ifndef __EMM_ASDEF_H__
#define __EMM_ASDEF_H__

#include "commonDef.h"
#include "OctetString.h"

/****************************************************************************/
/*********************  G L O B A L    C O N S T A N T S  *******************/
/****************************************************************************/

/*
 * EMMAS-SAP primitives
 */
typedef enum emm_as_primitive_u {
  _EMMAS_START = 200,
  _EMMAS_SECURITY_REQ,  /* EMM->AS: Security request          */
  _EMMAS_SECURITY_IND,  /* AS->EMM: Security indication       */
  _EMMAS_SECURITY_RES,  /* EMM->AS: Security response         */
  _EMMAS_SECURITY_REJ,  /* EMM->AS: Security reject           */
  _EMMAS_ESTABLISH_REQ, /* EMM->AS: Connection establish request  */
  _EMMAS_ESTABLISH_CNF, /* AS->EMM: Connection establish confirm  */
  _EMMAS_ESTABLISH_REJ, /* AS->EMM: Connection establish reject   */
  _EMMAS_RELEASE_REQ,   /* EMM->AS: Connection release request    */
  _EMMAS_RELEASE_IND,   /* AS->EMM: Connection release indication */
  _EMMAS_DATA_REQ,      /* EMM->AS: Data transfer request     */
  _EMMAS_DATA_IND,      /* AS->EMM: Data transfer indication      */
  _EMMAS_PAGE_IND,      /* AS->EMM: Paging data indication        */
  _EMMAS_STATUS_IND,    /* AS->EMM: Status indication         */
  _EMMAS_CELL_INFO_REQ, /* EMM->AS: Cell information request      */
  _EMMAS_CELL_INFO_RES, /* AS->EMM: Cell information response     */
  _EMMAS_CELL_INFO_IND, /* AS->EMM: Cell information indication   */
  _EMMAS_END
} emm_as_primitive_t;

/* Data used to setup EPS NAS security */
typedef struct emm_as_security_data_s {
77
  uint8_t is_new;     /* New security data indicator      */
gauthier's avatar
 
gauthier committed
78
#define EMM_AS_NO_KEY_AVAILABLE     0xff
79 80 81
  uint8_t ksi;        /* NAS key set identifier       */
  uint8_t sqn;        /* Sequence number          */
  uint32_t count;     /* NAS counter              */
gauthier's avatar
 
gauthier committed
82 83 84 85 86 87 88 89 90 91 92 93 94
  const OctetString *k_enc;   /* NAS cyphering key            */
  const OctetString *k_int;   /* NAS integrity key            */
} emm_as_security_data_t;

/****************************************************************************/
/************************  G L O B A L    T Y P E S  ************************/
/****************************************************************************/

/*
 * EMMAS primitive for security
 * ----------------------------
 */
typedef struct emm_as_security_s {
95
  uint32_t ueid;      /* UE lower layer identifier        */
gauthier's avatar
 
gauthier committed
96 97 98 99 100 101
  const GUTI_t *guti;     /* GUTI temporary mobile identity   */
  emm_as_security_data_t sctx;/* EPS NAS security context     */
  int emm_cause;      /* EMM failure cause code       */
  /*
   * Identity request/response
   */
102
  uint8_t identType;      /* Type of requested UE's identity  */
gauthier's avatar
 
gauthier committed
103 104
  const imsi_t *imsi;     /* The requested IMSI of the UE     */
  const imei_t *imei;     /* The requested IMEI of the UE     */
105
  uint32_t tmsi;      /* The requested TMSI of the UE     */
gauthier's avatar
 
gauthier committed
106 107 108
  /*
   * Authentication request/response
   */
109
  uint8_t ksi;        /* NAS key set identifier       */
gauthier's avatar
 
gauthier committed
110 111 112 113 114 115 116
  const OctetString *rand;    /* Random challenge number      */
  const OctetString *autn;    /* Authentication token         */
  const OctetString *res; /* Authentication response      */
  const OctetString *auts;    /* Synchronisation failure      */
  /*
   * Security Mode Command
   */
117 118 119
  uint8_t eea;        /* Replayed EPS encryption algorithms   */
  uint8_t eia;        /* Replayed EPS integrity algorithms    */
  uint8_t uea;        /* Replayed UMTS encryption algorithms  */
gauthier's avatar
 
gauthier committed
120
  uint8_t ucs2;
121 122
  uint8_t uia;        /* Replayed UMTS integrity algorithms   */
  uint8_t gea;        /* Replayed GPRS encryption algorithms   */
123
  uint8_t imeisv_request;
124 125
  uint8_t umts_present;
  uint8_t gprs_present;
gauthier's avatar
 
gauthier committed
126 127

  // Added by LG
128 129
  uint8_t selected_eea; /* Selected EPS encryption algorithms   */
  uint8_t selected_eia; /* Selected EPS integrity algorithms    */
gauthier's avatar
 
gauthier committed
130 131 132 133

#define EMM_AS_MSG_TYPE_IDENT   0x01    /* Identification message   */
#define EMM_AS_MSG_TYPE_AUTH    0x02    /* Authentication message   */
#define EMM_AS_MSG_TYPE_SMC 0x03    /* Security Mode Command    */
134
  uint8_t msgType;    /* Type of NAS security message to transfer */
gauthier's avatar
 
gauthier committed
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
} emm_as_security_t;

/*
 * EMMAS primitive for connection establishment
 * --------------------------------------------
 */
typedef struct emm_as_EPS_identity_s {
  const GUTI_t *guti; /* The GUTI, if valid               */
  const tai_t  *tai;  /* The last visited registered Tracking
             * Area Identity, if available          */
  const imsi_t *imsi; /* IMSI in case of "AttachWithImsi"     */
  const imei_t *imei; /* UE's IMEI for emergency bearer services  */
} emm_as_EPS_identity_t;

typedef struct emm_as_establish_s {
150
  uint32_t ueid;      /* UE lower layer identifier         */
gauthier's avatar
 
gauthier committed
151 152 153
  emm_as_EPS_identity_t UEid; /* UE's EPS mobile identity      */
  emm_as_security_data_t sctx;/* EPS NAS security context      */
  int switch_off;     /* TRUE if the UE is switched off    */
154 155 156
  uint8_t type;       /* Network attach/detach type        */
  uint8_t RRCcause;       /* Connection establishment cause    */
  uint8_t RRCtype;        /* Associated call type          */
gauthier's avatar
 
gauthier committed
157
  const plmn_t *plmnID;   /* Identifier of the selected PLMN   */
158 159 160
  uint8_t ksi;        /* NAS key set identifier        */
  uint8_t encryption:4;   /* Ciphering algorithm           */
  uint8_t integrity:4;    /* Integrity protection algorithm    */
gauthier's avatar
 
gauthier committed
161 162 163 164 165 166 167 168 169 170 171
  int emm_cause;      /* EMM failure cause code        */
  const GUTI_t *new_guti; /* New GUTI, if re-allocated         */
  int n_tacs;         /* Number of concecutive tracking areas
                 * the UE is registered to       */
  tac_t tac;          /* Code of the first tracking area the UE
                 * is registered to          */
#define EMM_AS_NAS_INFO_ATTACH  0x01    /* Attach request        */
#define EMM_AS_NAS_INFO_DETACH  0x02    /* Detach request        */
#define EMM_AS_NAS_INFO_TAU 0x03    /* Tracking Area Update request  */
#define EMM_AS_NAS_INFO_SR  0x04    /* Service Request       */
#define EMM_AS_NAS_INFO_EXTSR   0x05    /* Extended Service Request  */
172
  uint8_t NASinfo;    /* Type of initial NAS information to transfer   */
gauthier's avatar
 
gauthier committed
173 174 175 176 177 178 179 180 181
  OctetString NASmsg;     /* NAS message to be transfered within
                 * initial NAS information message   */
} emm_as_establish_t;

/*
 * EMMAS primitive for connection release
 * --------------------------------------
 */
typedef struct emm_as_release_s {
182
  uint32_t ueid;      /* UE lower layer identifier          */
gauthier's avatar
 
gauthier committed
183 184 185
  const GUTI_t *guti;     /* GUTI temporary mobile identity     */
#define EMM_AS_CAUSE_AUTHENTICATION 0x01    /* Authentication failure */
#define EMM_AS_CAUSE_DETACH     0x02    /* Detach requested   */
186
  uint8_t cause;  /* Release cause */
gauthier's avatar
 
gauthier committed
187 188 189 190 191 192 193
} emm_as_release_t;

/*
 * EMMAS primitive for data transfer
 * ---------------------------------
 */
typedef struct emm_as_data_s {
194
  uint32_t ueid;      /* UE lower layer identifier        */
gauthier's avatar
 
gauthier committed
195 196 197
  const GUTI_t *guti;     /* GUTI temporary mobile identity   */
  emm_as_security_data_t sctx;/* EPS NAS security context     */
  int switch_off;     /* TRUE if the UE is switched off   */
198 199
  uint8_t type;       /* Network detach type          */
  uint8_t delivered;      /* Data message delivery indicator  */
gauthier's avatar
 
gauthier committed
200 201
#define EMM_AS_NAS_DATA_ATTACH  0x01    /* Attach complete      */
#define EMM_AS_NAS_DATA_DETACH  0x02    /* Detach request       */
202
  uint8_t NASinfo;        /* Type of NAS information to transfer  */
gauthier's avatar
 
gauthier committed
203 204 205 206 207 208 209 210 211 212 213 214 215 216
  OctetString NASmsg;     /* NAS message to be transfered     */
} emm_as_data_t;

/*
 * EMMAS primitive for paging
 * --------------------------
 */
typedef struct emm_as_page_s {} emm_as_page_t;

/*
 * EMMAS primitive for status indication
 * -------------------------------------
 */
typedef struct emm_as_status_s {
217
  uint32_t ueid;      /* UE lower layer identifier        */
gauthier's avatar
 
gauthier committed
218 219 220 221 222 223 224 225 226 227
  const GUTI_t *guti;     /* GUTI temporary mobile identity   */
  emm_as_security_data_t sctx;/* EPS NAS security context     */
  int emm_cause;      /* EMM failure cause code       */
} emm_as_status_t;

/*
 * EMMAS primitive for cell information
 * ------------------------------------
 */
typedef struct emm_as_cell_info_s {
228
  uint8_t found;  /* Indicates whether a suitable cell is found   */
gauthier's avatar
 
gauthier committed
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
#define EMM_AS_PLMN_LIST_SIZE   6
  PLMN_LIST_T(EMM_AS_PLMN_LIST_SIZE) plmnIDs;
  /* List of identifiers of available PLMNs   */
  Byte_t rat;     /* Bitmap of Radio Access Technologies      */
  tac_t tac;      /* Tracking Area Code               */
  ci_t cellID;    /* cell identity                */
} emm_as_cell_info_t;

/*
 * --------------------------------
 * Structure of EMMAS-SAP primitive
 * --------------------------------
 */
typedef struct emm_as_s {
  emm_as_primitive_t primitive;
  union {
    emm_as_security_t security;
    emm_as_establish_t establish;
    emm_as_release_t release;
    emm_as_data_t data;
    emm_as_page_t page;
    emm_as_status_t status;
    emm_as_cell_info_t cell_info;
  } u;
} emm_as_t;

/****************************************************************************/
/********************  G L O B A L    V A R I A B L E S  ********************/
/****************************************************************************/

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

/*
 * Defined in LowerLayer.c
 * Setup security data according to the given EPS security context
 */
void emm_as_set_security_data(emm_as_security_data_t *data, const void *context,
                              int is_new, int is_ciphered);

#endif /* __EMM_ASDEF_H__*/