git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4234 818b1a75-f10b-46b9-bf7c-635c3b92a50f

This commit is contained in:
Cedric Roux
2013-10-21 08:08:15 +00:00
parent ff4360527c
commit d7c8c99e2d
860 changed files with 212101 additions and 0 deletions
@@ -0,0 +1,249 @@
/*****************************************************************************
Eurecom OpenAirInterface 3
Copyright(c) 2012 Eurecom
Source commonDef.h
Version 0.1
Date 2012/02/27
Product NAS stack
Subsystem include
Author Frederic Maurel
Description Contains global common definitions
*****************************************************************************/
#ifndef __COMMONDEF_H__
#define __COMMONDEF_H__
#include <stdint.h>
#include <stddef.h>
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
#define RETURNok (0)
#define RETURNerror (-1)
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (1)
#endif
/*
* Name of the environment variable which defines the default directory
* where the NAS application is executed and where are located files
* where non-volatile data are stored
*/
#define DEFAULT_NAS_PATH "PWD"
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/*
-----------------------------------------------------------------------------
Standard data type definitions
-----------------------------------------------------------------------------
*/
typedef int8_t SByte_t; /* 8 bit signed integer */
typedef int8_t Int8_t; /* 8 bit signed integer */
typedef int16_t Int16_t; /* 16 bit signed integer */
typedef int32_t Int32_t; /* 32 bit signed integer */
typedef int64_t Int64_t; /* 64 bit signed integer */
typedef uint8_t Byte_t; /* 8 bit unsigned integer */
typedef uint8_t UInt8_t; /* 8 bit unsigned integer */
typedef uint16_t UInt16_t; /* 16 bit unsigned integer */
typedef uint32_t UInt32_t; /* 32 bit unsigned integer */
typedef uint64_t UInt64_t; /* 64 bit unsigned integer */
/*
-----------------------------------------------------------------------------
Common NAS data type definitions
-----------------------------------------------------------------------------
*/
typedef UInt8_t Stat_t; /* Registration status */
typedef UInt16_t lac_t; /* Location Area Code */
typedef UInt8_t rac_t; /* Routing Area Code */
typedef UInt16_t tac_t; /* Tracking Area Code */
typedef UInt32_t ci_t; /* Cell Identifier */
typedef UInt8_t AcT_t; /* Access Technology */
/*
* International Mobile Subscriber Identity
*/
typedef struct {
Byte_t length;
union {
struct {
Byte_t digit15:4;
Byte_t digit14:4;
Byte_t digit13:4;
Byte_t digit12:4;
Byte_t digit11:4;
Byte_t digit10:4;
Byte_t digit9:4;
Byte_t digit8:4;
Byte_t digit7:4;
Byte_t digit6:4;
Byte_t digit5:4;
Byte_t digit4:4;
Byte_t digit3:4;
Byte_t digit2:4;
Byte_t digit1:4;
#define EVEN_PARITY 0
#define ODD_PARITY 1
Byte_t parity:4;
} num;
#define IMSI_SIZE 8
Byte_t value[IMSI_SIZE];
} u;
} imsi_t;
/*
* Mobile subscriber dialing number
*/
typedef struct {
Byte_t ext:1;
/* Type Of Number */
#define MSISDN_TON_UNKNOWKN 0b000
#define MSISDN_TON_INTERNATIONAL 0b001
#define MSISDN_TON_NATIONAL 0b010
#define MSISDN_TON_NETWORK 0b011
#define MSISDN_TON_SUBCRIBER 0b100
#define MSISDN_TON_ABBREVIATED 0b110
#define MSISDN_TON_RESERVED 0b111
Byte_t ton:3;
/* Numbering Plan Identification */
#define MSISDN_NPI_UNKNOWN 0b0000
#define MSISDN_NPI_ISDN_TELEPHONY 0b0001
#define MSISDN_NPI_GENERIC 0b0010
#define MSISDN_NPI_DATA 0b0011
#define MSISDN_NPI_TELEX 0b0100
#define MSISDN_NPI_MARITIME_MOBILE 0b0101
#define MSISDN_NPI_LAND_MOBILE 0b0110
#define MSISDN_NPI_ISDN_MOBILE 0b0111
#define MSISDN_NPI_PRIVATE 0b1110
#define MSISDN_NPI_RESERVED 0b1111
Byte_t npi:4;
/* Dialing Number */
struct {
Byte_t lsb:4;
Byte_t msb:4;
#define MSISDN_DIGIT_SIZE 10
} digit[MSISDN_DIGIT_SIZE];
} msisdn_t;
/*
* International Mobile Equipment Identity
*/
typedef imsi_t imei_t;
/*
* Public Land Mobile Network identifier
* PLMN = BCD encoding (Mobile Country Code + Mobile Network Code)
*/
typedef struct {
Byte_t MCCdigit2:4;
Byte_t MCCdigit1:4;
Byte_t MNCdigit3:4;
Byte_t MCCdigit3:4;
Byte_t MNCdigit2:4;
Byte_t MNCdigit1:4;
} plmn_t;
/*
* Location Area Identification
*/
typedef struct {
plmn_t plmn; /* <MCC> + <MNC> */
lac_t lac; /* Location Area Code */
} lai_t;
/*
* GPRS Routing Area Identification
*/
typedef struct {
plmn_t plmn; /* <MCC> + <MNC> */
lac_t lac; /* Location Area Code */
rac_t rac; /* Routing Area Code */
} RAI_t;
/*
* EPS Tracking Area Identification
*/
typedef struct {
plmn_t plmn; /* <MCC> + <MNC> */
tac_t tac; /* Tracking Area Code */
} tai_t;
/*
* EPS Globally Unique MME Identity
*/
typedef struct {
plmn_t plmn; /* <MCC> + <MNC> */
UInt16_t MMEgid; /* MME group identifier */
UInt8_t MMEcode; /* MME code */
} gummei_t;
/*
* EPS Globally Unique Temporary UE Identity
*/
typedef struct {
gummei_t gummei; /* Globally Unique MME Identity */
UInt32_t m_tmsi; /* M-Temporary Mobile Subscriber Identity */
} GUTI_t;
/* Checks PLMN validity */
#define PLMN_IS_VALID(plmn) (((plmn).MCCdigit1 & \
(plmn).MCCdigit2 & \
(plmn).MCCdigit3) != 0x0F)
/* Checks TAC validity */
#define TAC_IS_VALID(tac) (((tac) != 0x0000) && ((tac) != 0xFFF0))
/* Checks TAI validity */
#define TAI_IS_VALID(tai) (PLMN_IS_VALID((tai).plmn) && \
TAC_IS_VALID((tai).tac))
/*
* A list of PLMNs
*/
#define PLMN_LIST_T(SIZE) struct {Byte_t n_plmns; plmn_t plmn[SIZE];}
/*
* A list of TACs
*/
#define TAC_LIST_T(SIZE) struct {Byte_t n_tacs; TAC_t tac[SIZE];}
/*
* A list of TAIs
*/
#define TAI_LIST_T(SIZE) struct {Byte_t n_tais; tai_t tai[SIZE];}
/*
* User notification callback, executed whenever a change of data with
* respect of network information (e.g. network registration and/or
* location change, new PLMN becomes available) is notified by the
* EPS Mobility Management sublayer
*/
typedef int (*emm_indication_callback_t) (Stat_t, tac_t, ci_t, AcT_t, const char*, size_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 ******************/
/****************************************************************************/
#endif /* __COMMONDEF_H__*/
@@ -0,0 +1,251 @@
/*****************************************************************************
Eurecom OpenAirInterface 3
Copyright(c) 2012 Eurecom
Source networkDef.h
Version 0.1
Date 2012/09/21
Product NAS stack
Subsystem include
Author Frederic Maurel
Description Contains network's global definitions
*****************************************************************************/
#ifndef __NETWORKDEF_H__
#define __NETWORKDEF_H__
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/*
* ----------------------
* Network selection mode
* ----------------------
*/
#define NET_PLMN_AUTO 0
#define NET_PLMN_MANUAL 1
/*
* ---------------------------
* Network registration status
* ---------------------------
*/
/* not registered, not currently searching an operator to register to */
#define NET_REG_STATE_OFF 0
/* registered, home network */
#define NET_REG_STATE_HN 1
/* not registered, currently trying to attach or searching an operator
* to register to */
#define NET_REG_STATE_ON 2
/* registration denied */
#define NET_REG_STATE_DENIED 3
/* unknown (e.g. out of GERAN/UTRAN/E-UTRAN coverage) */
#define NET_REG_STATE_UNKNOWN 4
/* registered, roaming */
#define NET_REG_STATE_ROAMING 5
/* registered for "SMS only", home network */
#define NET_REG_STATE_SMS_HN 6
/* registered, for "SMS only", roaming */
#define NET_REG_STATE_SMS_ROAMING 7
/* attached for emergency bearer services only (applicable to UTRAN) */
#define NET_REG_STATE_EMERGENCY 8
/*
* ------------------------------------
* Network access technology indicators
* ------------------------------------
*/
#define NET_ACCESS_UNAVAILABLE (-1) /* Not available */
#define NET_ACCESS_GSM 0 /* GSM */
#define NET_ACCESS_COMPACT 1 /* GSM Compact */
#define NET_ACCESS_UTRAN 2 /* UTRAN */
#define NET_ACCESS_EGPRS 3 /* GSM w/EGPRS */
#define NET_ACCESS_HSDPA 4 /* UTRAN w/HSDPA */
#define NET_ACCESS_HSUPA 5 /* UTRAN w/HSUPA */
#define NET_ACCESS_HSDUPA 6 /* UTRAN w/HSDPA and HSUPA */
#define NET_ACCESS_EUTRAN 7 /* E-UTRAN */
/*
* ---------------------------------------
* Network operator representation formats
* ---------------------------------------
*/
#define NET_FORMAT_LONG 0 /* long format alphanumeric */
#define NET_FORMAT_SHORT 1 /* short format alphanumeric */
#define NET_FORMAT_NUM 2 /* numeric format */
#define NET_FORMAT_MAX_SIZE NET_FORMAT_LONG_SIZE
/*
* -----------------------------
* Network operator availability
* -----------------------------
*/
#define NET_OPER_UNKNOWN 0 /* unknown operator */
#define NET_OPER_AVAILABLE 1 /* available operator */
#define NET_OPER_CURRENT 2 /* currently selected operator */
#define NET_OPER_FORBIDDEN 3 /* forbidden operator */
/*
* --------------------------------------
* Network connection establishment cause
* --------------------------------------
*/
#define NET_ESTABLISH_CAUSE_EMERGENCY 0x01
#define NET_ESTABLISH_CAUSE_HIGH_PRIO 0x02
#define NET_ESTABLISH_CAUSE_MT_ACCESS 0x03
#define NET_ESTABLISH_CAUSE_MO_SIGNAL 0x04
#define NET_ESTABLISH_CAUSE_MO_DATA 0x05
#define NET_ESTABLISH_CAUSE_V1020 0x06
/*
* --------------------------------------
* Network connection establishment type
* --------------------------------------
*/
#define NET_ESTABLISH_TYPE_ORIGINATING_SIGNAL 0x10
#define NET_ESTABLISH_TYPE_EMERGENCY_CALLS 0x20
#define NET_ESTABLISH_TYPE_ORIGINATING_CALLS 0x30
#define NET_ESTABLISH_TYPE_TERMINATING_CALLS 0x40
#define NET_ESTABLISH_TYPE_MO_CS_FALLBACK 0x50
/*
* -------------------
* PDN connection type
* -------------------
*/
#define NET_PDN_TYPE_IPV4 0
#define NET_PDN_TYPE_IPV6 1
#define NET_PDN_TYPE_IPV4V6 2
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/*
* ---------------------
* PDN connection status
* ---------------------
*/
typedef enum {
/* MT = The Mobile Terminal, NW = The Network */
NET_PDN_MT_DEFAULT_ACT = 1, /* MT has activated a PDN connection */
NET_PDN_NW_DEFAULT_DEACT, /* NW has deactivated a PDN connection */
NET_PDN_MT_DEFAULT_DEACT, /* MT has deactivated a PDN connection */
NET_PDN_NW_DEDICATED_ACT, /* NW has activated an EPS bearer context */
NET_PDN_MT_DEDICATED_ACT, /* MT has activated an EPS bearer context */
NET_PDN_NW_DEDICATED_DEACT, /* NW has deactivated an EPS bearer context */
NET_PDN_MT_DEDICATED_DEACT, /* MT has deactivated an EPS bearer context */
} network_pdn_state_t;
/*
* ---------------------------
* Network operator identifier
* ---------------------------
*/
typedef struct {
#define NET_FORMAT_LONG_SIZE 16 /* Long alphanumeric format */
#define NET_FORMAT_SHORT_SIZE 8 /* Short alphanumeric format */
#define NET_FORMAT_NUM_SIZE 6 /* Numeric format (PLMN identifier */
union {
unsigned char alpha_long[NET_FORMAT_LONG_SIZE+1];
unsigned char alpha_short[NET_FORMAT_SHORT_SIZE+1];
unsigned char num[NET_FORMAT_NUM_SIZE+1];
} id;
} network_plmn_t;
/*
* -------------------------------
* EPS bearer level QoS parameters
* -------------------------------
*/
typedef struct {
int gbrUL; /* Guaranteed Bit Rate for uplink */
int gbrDL; /* Guaranteed Bit Rate for downlink */
int mbrUL; /* Maximum Bit Rate for uplink */
int mbrDL; /* Maximum Bit Rate for downlink */
int qci; /* QoS Class Identifier */
} network_qos_t;
/*
* -----------------------------
* IPv4 packet filter parameters
* -----------------------------
*/
typedef struct {
unsigned char protocol; /* Protocol identifier */
unsigned char tos; /* Type of service */
#define NET_PACKET_FILTER_IPV4_ADDR_SIZE 4
unsigned char addr[NET_PACKET_FILTER_IPV4_ADDR_SIZE];
unsigned char mask[NET_PACKET_FILTER_IPV4_ADDR_SIZE];
} network_ipv4_data_t;
/*
* -----------------------------
* IPv6 packet filter parameters
* -----------------------------
*/
typedef struct {
unsigned char nh; /* Next header type */
unsigned char tf; /* Traffic class */
#define NET_PACKET_FILTER_IPV6_ADDR_SIZE 16
unsigned char addr[NET_PACKET_FILTER_IPV6_ADDR_SIZE];
unsigned char mask[NET_PACKET_FILTER_IPV6_ADDR_SIZE];
unsigned int ipsec; /* IPSec security parameter index */
unsigned int fl; /* Flow label */
} network_ipv6_data_t;
/*
* -------------
* Packet Filter
* -------------
*/
typedef struct {
unsigned char id; /* Packet filter identifier */
#define NET_PACKET_FILTER_DOWNLINK 0x01
#define NET_PACKET_FILTER_UPLINK 0x02
#define NET_PACKET_FILTER_BIDIR 0x03
unsigned char dir; /* Packet filter direction */
unsigned char precedence; /* Evaluation precedence */
union {
network_ipv4_data_t ipv4;
network_ipv6_data_t ipv6;
} data;
unsigned short lport; /* Local (UE) port number */
unsigned short rport; /* Remote (network) port number */
} network_pkf_t;
/*
* ---------------------
* Traffic Flow Template
* ---------------------
*/
typedef struct {
int n_pkfs;
#define NET_PACKET_FILTER_MAX 16
network_pkf_t* pkf[NET_PACKET_FILTER_MAX];
} network_tft_t;
/*
* User notification callback, executed whenever a change of status with
* respect of PDN connection or EPS bearer context is notified by the EPS
* Session Management sublayer
*/
typedef int (*esm_indication_callback_t) (int, network_pdn_state_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 ******************/
/****************************************************************************/
#endif /* __NETWORKDEF_H__*/
@@ -0,0 +1,85 @@
/*****************************************************************************
Eurecom OpenAirInterface 3
Copyright(c) 2012 Eurecom
Source securityDef.h
Version 0.1
Date 2013/05/02
Product NAS stack
Subsystem include
Author Frederic Maurel
Description Contains global security definitions
*****************************************************************************/
#ifndef __SECURITYDEF_H__
#define __SECURITYDEF_H__
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/*
* Index of the first byte of each fields of the AUTN parameter
*/
#define AUTH_SQN_INDEX 0
#define AUTH_AMF_INDEX (AUTH_SQN_INDEX + AUTH_SQN_SIZE)
#define AUTH_MAC_INDEX (AUTH_AMF_INDEX + AUTH_AMF_SIZE)
/*
* Size of the authentication challenge parameters in bytes
*/
#define AUTH_SQN_SIZE 6 /* Sequence number: 48 bits */
#define AUTH_AK_SIZE 6 /* Anonymity key: 48 bits */
#define AUTH_AMF_SIZE 2 /* Authentication Management Field: 16 bits */
#define AUTH_MAC_SIZE 8 /* Message Authentication Code: 64 bits */
#define AUTH_AUTN_SIZE 16 /* Authentication token: 128 bits
AUTN = (SQN ⊕ AK) || AMF || MAC */
#define AUTH_MACS_SIZE 8 /* Re-synchronization MAC: 64 bits */
#define AUTH_AUTS_SIZE 16 /* Re-synchronization AUT: 128 bits */
#define AUTH_RAND_SIZE 16 /* Random challenge: 128 bits */
#define AUTH_CK_SIZE 16 /* Ciphering key: 128 bits */
#define AUTH_IK_SIZE 16 /* Integrity key: 128 bits */
#define AUTH_RES_SIZE 16 /* Authentication response: 128 bits */
#define AUTH_SNID_SIZE 3 /* Serving network's identity: 24 bits */
#define AUTH_KASME_SIZE 32 /* ASME security key: 256 bits */
#define AUTH_KNAS_INT_SIZE AUTH_KASME_SIZE /* NAS integrity key */
#define AUTH_KNAS_ENC_SIZE AUTH_KASME_SIZE /* NAS cyphering key */
#define AUTH_KENB_SIZE AUTH_KASME_SIZE /* eNodeB security key */
/* "Separation bit" of AMF field */
#define AUTH_AMF_SEPARATION_BIT(a) ((a) & 0x80)
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/*
* EPS authentication vector
*/
typedef struct {
/* ASME security key */
char kasme[AUTH_KASME_SIZE + 1];
/* Random challenge parameter */
char rand[AUTH_RAND_SIZE + 1];
/* Authentication token parameter */
char autn[AUTH_AUTN_SIZE + 1];
/* Expected Authentication response parameter */
#define AUTH_XRES_SIZE AUTH_RES_SIZE
char xres[AUTH_XRES_SIZE + 1];
} auth_vector_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 ******************/
/****************************************************************************/
#endif /* __SECURITYDEF_H__*/
@@ -0,0 +1,73 @@
/*****************************************************************************
Eurecom OpenAirInterface 3
Copyright(c) 2012 Eurecom
Source userDef.h
Version 0.1
Date 2012/09/21
Product NAS stack
Subsystem include
Author Frederic Maurel
Description Contains user's global definitions
*****************************************************************************/
#ifndef __USERDEF_H__
#define __USERDEF_H__
#include <stdint.h>
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
/*
* The name of the file used as non-volatile memory device to store
* UE data parameters
*/
#define USER_NVRAM_FILENAME ".ue.nvram"
/*
* The name of the environment variable which defines the directory
* where the UE data file is located
*/
#define USER_NVRAM_DIRNAME "NVRAM_DIR"
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
/****************************************************************************/
/*
* ------------------------------
* Structure of the UE parameters
* ------------------------------
*/
typedef struct {
/* International Mobile Equipment Identity */
#define USER_IMEI_SIZE 15
char IMEI[USER_IMEI_SIZE+1];
/* Manufacturer identifier */
#define USER_MANUFACTURER_SIZE 16
char manufacturer[USER_MANUFACTURER_SIZE+1];
/* Model identifier */
#define USER_MODEL_SIZE 16
char model[USER_MODEL_SIZE+1];
/* SIM Personal Identification Number */
#define USER_PIN_SIZE 4
char PIN[USER_PIN_SIZE+1];
} user_nvdata_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 ******************/
/****************************************************************************/
#endif /* __USERDEF_H__*/