update it

This commit is contained in:
Sukchan Lee 2017-08-25 20:31:08 +09:00
parent 7cae17562d
commit 0ecc05e9d3
19 changed files with 155 additions and 110 deletions

View File

@ -3,7 +3,7 @@
noinst_LTLIBRARIES = libfds6a.la
libfds6a_la_SOURCES = \
s6a_lib.h dict_init.c
s6a_dict.h s6a_message.h dict_init.c
AM_CFLAGS = \
-Wall -Werror

View File

@ -1,4 +1,4 @@
#include "s6a_lib.h"
#include "s6a_dict.h"
#define CHECK_dict_search( _type, _criteria, _what, _result ) \
CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) );

View File

@ -8,14 +8,7 @@
extern "C" {
#endif /* __cplusplus */
#define S6A_APPLICATION_ID 16777251
#define S6A_DIAMETER_AUTHENTICATION_DATA_UNAVAILABLE 4181
#define S6A_DIAMETER_ERROR_ROAMING_NOT_ALLOWED 5004
#define S6A_DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION 5420
#define S6A_DIAMETER_ERROR_RAT_NOT_ALLOWED 5421
#define S6A_DIAMETER_ERROR_EQUIPMENT_UNKNOWN 5422
#define S6A_DIAMETER_ERROR_UNKOWN_SERVING_NODE 5423
#define S6A_APPLICATION_ID 16777251
#define S6A_AVP_CODE_CONTEXT_IDENTIFIER (1423)
#define S6A_AVP_CODE_ALL_APN_CONFIG_INC_IND (1428)
@ -42,9 +35,6 @@ extern "C" {
#define S6A_ULR_INITIAL_ATTACH_IND (1 << 5)
#define S6A_ULR_PS_LCS_SUPPORTED_BY_UE (1 << 6)
#define S6A_ULA_SEPARATION_INDICATION (0)
#define S6A_ULA_MME_REGISTERED_FOR_SMS (1)
#define S6A_UE_SRVCC_NOT_SUPPORTED (0)
#define S6A_UE_SRVCC_SUPPORTED (1)

76
lib/fd/s6a/s6a_message.h Normal file
View File

@ -0,0 +1,76 @@
#ifndef __S6A_MESSAGE_H__
#define __S6A_MESSAGE_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "core_sha2.h"
#include "types.h"
typedef struct _e_utran_vector_t {
c_uint8_t xres[MAX_RES_LEN];
c_uint8_t xres_len;
c_uint8_t kasme[SHA256_DIGEST_SIZE];
c_uint8_t rand[RAND_LEN];
c_uint8_t autn[AUTN_LEN];
} e_utran_vector_t;
typedef struct _s6a_aia_message_t {
e_utran_vector_t e_utran_vector;
} s6a_aia_message_t;
typedef struct _s6a_subscription_data_t {
#define HSS_ACCESS_RESTRICTION_UTRAN_NOT_ALLOWED (1)
#define HSS_ACCESS_RESTRICTION_GERAN_NOT_ALLOWED (1<<1)
#define HSS_ACCESS_RESTRICTION_GAN_NOT_ALLOWED (1<<2)
#define HSS_ACCESS_RESTRICTION_I_HSPA_EVOLUTION_NOT_ALLOWED (1<<3)
#define HSS_ACCESS_RESTRICTION_WB_E_UTRAN_NOT_ALLOWED (1<<4)
#define HSS_ACCESS_RESTRICTION_HO_TO_NON_3GPP_ACCESS_NOT_ALLOWED (1<<5)
#define HSS_ACCESS_RESTRICTION_NB_IOT_NOT_ALLOWED (1<<6)
c_uint32_t access_restriction_data;
#define HSS_SUBSCRIBER_STATUS_SERVICE_GRANTED 0
#define HSS_SUBSCRIBER_STATUS_OPERATOR_DETERMINED_BARRING 1
c_uint32_t subscriber_status;
#define HSS_NETWORK_ACCESS_MODE_PACKET_AND_CIRCUIT 0
#define HSS_NETWORK_ACCESS_MODE_RESERVED 1
#define HSS_NETWORK_ACCESS_MODE_ONLY_PACKET 2
c_uint32_t network_access_mode;
bitrate_t ambr; /* UE-AMBR */
c_uint32_t subscribed_rau_tau_timer; /* unit : minutes */
pdn_t pdn[MAX_NUM_OF_PDN];
int num_of_pdn;
} s6a_subscription_data_t;
typedef struct _s6a_ula_message_t {
#define S6A_ULA_FLAGS_SEPARATION_INDICATION (0)
#define S6A_ULA_FLAGS_MME_REGISTERED_FOR_SMS (1)
c_uint32_t ula_flags;
s6a_subscription_data_t subscription_data;
} s6a_ula_message_t;
typedef struct _s6a_message_t {
#define S6A_CMD_CODE_UPDATE_LOCATION 316
#define S6A_CMD_CODE_AUTHENTICATION_INFORMATION 318
c_uint16_t cmd_code;
#define S6A_DIAMETER_AUTHENTICATION_DATA_UNAVAILABLE 4181
#define S6A_DIAMETER_ERROR_ROAMING_NOT_ALLOWED 5004
#define S6A_DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION 5420
#define S6A_DIAMETER_ERROR_RAT_NOT_ALLOWED 5421
#define S6A_DIAMETER_ERROR_EQUIPMENT_UNKNOWN 5422
#define S6A_DIAMETER_ERROR_UNKOWN_SERVING_NODE 5423
c_uint32_t result_code;
s6a_aia_message_t aia_message;
s6a_ula_message_t ula_message;
} s6a_message_t;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __S6A_MESSAGE_H__ */

View File

@ -3,8 +3,8 @@
noinst_LTLIBRARIES = libhss.la
libhss_la_SOURCES = \
milenage.h hss_kdf.h hss_context.h hss_s6a_handler.h \
milenage.c hss_kdf.c hss_init.c hss_context.c hss_s6a_handler.c
milenage.h hss_kdf.h hss_context.h hss_fd_path.h \
milenage.c hss_kdf.c hss_init.c hss_context.c hss_fd_path.c
libhss_la_DEPENDENCIES = \
$(top_srcdir)/lib/core/src/libcore.la \

View File

@ -185,8 +185,8 @@ status_t hss_context_setup_trace_module()
else if (fd <= 5) fd_g_debug_lvl = FD_LOG_DEBUG;
else fd_g_debug_lvl = FD_LOG_ANNOYING;
extern int _hss_s6a_handler;
d_trace_level(&_hss_s6a_handler, fd);
extern int _hss_fd_path;
d_trace_level(&_hss_fd_path, fd);
extern int _fd_init;
d_trace_level(&_fd_init, fd);
extern int _fd_logger;
@ -407,7 +407,7 @@ out:
}
status_t hss_db_subscription_data(
char *imsi_bcd, hss_db_subscription_data_t *subscription_data)
char *imsi_bcd, s6a_subscription_data_t *subscription_data)
{
status_t rv = CORE_OK;
mongoc_cursor_t *cursor = NULL;
@ -452,7 +452,7 @@ status_t hss_db_subscription_data(
goto out;
}
memset(subscription_data, 0, sizeof(hss_db_subscription_data_t));
memset(subscription_data, 0, sizeof(s6a_subscription_data_t));
while(bson_iter_next(&iter))
{
const char *key = bson_iter_key(&iter);

View File

@ -3,7 +3,8 @@
#include "core_errno.h"
#include "core_mutex.h"
#include "types.h"
#include "s6a_message.h"
#ifdef __cplusplus
extern "C" {
@ -20,30 +21,6 @@ typedef struct _hss_db_auth_info_t {
c_uint64_t sqn;
} hss_db_auth_info_t;
typedef struct _hss_db_subscription_data_t {
#define HSS_ACCESS_RESTRICTION_UTRAN_NOT_ALLOWED (1)
#define HSS_ACCESS_RESTRICTION_GERAN_NOT_ALLOWED (1<<1)
#define HSS_ACCESS_RESTRICTION_GAN_NOT_ALLOWED (1<<2)
#define HSS_ACCESS_RESTRICTION_I_HSPA_EVOLUTION_NOT_ALLOWED (1<<3)
#define HSS_ACCESS_RESTRICTION_WB_E_UTRAN_NOT_ALLOWED (1<<4)
#define HSS_ACCESS_RESTRICTION_HO_TO_NON_3GPP_ACCESS_NOT_ALLOWED (1<<5)
#define HSS_ACCESS_RESTRICTION_NB_IOT_NOT_ALLOWED (1<<6)
c_uint32_t access_restriction_data;
#define HSS_SUBSCRIBER_STATUS_SERVICE_GRANTED 0
#define HSS_SUBSCRIBER_STATUS_OPERATOR_DETERMINED_BARRING 1
c_uint32_t subscriber_status;
#define HSS_NETWORK_ACCESS_MODE_PACKET_AND_CIRCUIT 0
#define HSS_NETWORK_ACCESS_MODE_RESERVED 1
#define HSS_NETWORK_ACCESS_MODE_ONLY_PACKET 2
c_uint32_t network_access_mode;
bitrate_t ambr; /* UE-AMBR */
c_uint32_t subscribed_rau_tau_timer; /* unit : minutes */
pdn_t pdn[MAX_NUM_OF_PDN];
int num_of_pdn;
} hss_db_subscription_data_t;
typedef struct _hss_context_t {
char *fd_conf_path; /* HSS freeDiameter conf path */
@ -68,7 +45,7 @@ CORE_DECLARE(status_t) hss_db_update_rand_and_sqn(
CORE_DECLARE(status_t) hss_db_increment_sqn(char *imsi_bcd);
CORE_DECLARE(status_t) hss_db_subscription_data(
char *imsi_bcd, hss_db_subscription_data_t *subscription_data);
char *imsi_bcd, s6a_subscription_data_t *subscription_data);
#ifdef __cplusplus
}

View File

@ -1,11 +1,12 @@
#define TRACE_MODULE _hss_s6a_handler
#define TRACE_MODULE _hss_fd_path
#include "core_debug.h"
#include "core_lib.h"
#include "core_sha2.h"
#include "fd_lib.h"
#include "s6a_lib.h"
#include "s6a_dict.h"
#include "s6a_message.h"
#include "hss_context.h"
#include "hss_kdf.h"
@ -15,14 +16,14 @@
#define HSS_AK_LEN 6
/* handler for fallback cb */
static struct disp_hdl *hdl_fb = NULL;
static struct disp_hdl *hdl_s6a_fb = NULL;
/* handler for Authentication-Information-Request cb */
static struct disp_hdl *hdl_air = NULL;
static struct disp_hdl *hdl_s6a_air = NULL;
/* handler for Update-Location-Request cb */
static struct disp_hdl *hdl_ulr = NULL;
static struct disp_hdl *hdl_s6a_ulr = NULL;
/* Default callback for the application. */
static int hss_fb_cb(struct msg **msg, struct avp *avp,
static int hss_s6a_fb_cb(struct msg **msg, struct avp *avp,
struct session *session, void *opaque, enum disp_action *act)
{
/* This CB should never be called */
@ -32,7 +33,7 @@ static int hss_fb_cb(struct msg **msg, struct avp *avp,
}
/* Callback for incoming Authentication-Information-Request messages */
static int hss_air_cb( struct msg **msg, struct avp *avp,
static int hss_s6a_air_cb( struct msg **msg, struct avp *avp,
struct session *session, void *opaque, enum disp_action *act)
{
struct msg *ans, *qry;
@ -179,7 +180,7 @@ out:
}
/* Callback for incoming Update-Location-Request messages */
static int hss_ulr_cb( struct msg **msg, struct avp *avp,
static int hss_s6a_ulr_cb( struct msg **msg, struct avp *avp,
struct session *session, void *opaque, enum disp_action *act)
{
struct msg *ans, *qry;
@ -190,7 +191,7 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
status_t rv;
hss_db_subscription_data_t subscription_data;
s6a_subscription_data_t subscription_data;
d_assert(msg, return EINVAL,);
@ -228,7 +229,7 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
/* Set the ULA Flags */
CHECK_FCT( fd_msg_avp_new(s6a_ula_flags, 0, &avp) );
val.i32 = S6A_ULA_MME_REGISTERED_FOR_SMS;
val.i32 = S6A_ULA_FLAGS_MME_REGISTERED_FOR_SMS;
CHECK_FCT( fd_msg_avp_setvalue(avp, &val) );
CHECK_FCT( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp) );
@ -445,7 +446,7 @@ out:
return 0;
}
int hss_s6a_init(void)
int hss_fd_init(void)
{
struct disp_when data;
@ -458,18 +459,18 @@ int hss_s6a_init(void)
data.app = s6a_application;
/* fallback CB if command != unexpected message received */
CHECK_FCT( fd_disp_register(hss_fb_cb, DISP_HOW_APPID, &data, NULL,
&hdl_fb) );
CHECK_FCT( fd_disp_register(hss_s6a_fb_cb, DISP_HOW_APPID, &data, NULL,
&hdl_s6a_fb) );
/* specific handler for Authentication-Information-Request */
data.command = s6a_cmd_air;
CHECK_FCT( fd_disp_register(hss_air_cb, DISP_HOW_CC, &data, NULL,
&hdl_air) );
CHECK_FCT( fd_disp_register(hss_s6a_air_cb, DISP_HOW_CC, &data, NULL,
&hdl_s6a_air) );
/* specific handler for Location-Update-Request */
data.command = s6a_cmd_ulr;
CHECK_FCT( fd_disp_register(hss_ulr_cb, DISP_HOW_CC, &data, NULL,
&hdl_ulr) );
CHECK_FCT( fd_disp_register(hss_s6a_ulr_cb, DISP_HOW_CC, &data, NULL,
&hdl_s6a_ulr) );
/* Advertise the support for the application in the peer */
CHECK_FCT( fd_disp_app_support(s6a_application, fd_vendor, 1, 0) );
@ -477,16 +478,16 @@ int hss_s6a_init(void)
return 0;
}
void hss_s6a_final(void)
void hss_fd_final(void)
{
if (hdl_fb) {
(void) fd_disp_unregister(&hdl_fb, NULL);
if (hdl_s6a_fb) {
(void) fd_disp_unregister(&hdl_s6a_fb, NULL);
}
if (hdl_air) {
(void) fd_disp_unregister(&hdl_air, NULL);
if (hdl_s6a_air) {
(void) fd_disp_unregister(&hdl_s6a_air, NULL);
}
if (hdl_ulr) {
(void) fd_disp_unregister(&hdl_ulr, NULL);
if (hdl_s6a_ulr) {
(void) fd_disp_unregister(&hdl_s6a_ulr, NULL);
}
fd_final();

18
src/hss/hss_fd_path.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef __HSS_FD_PATH_H__
#define __HSS_FD_PATH_H__
#include "core_errno.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(int) hss_fd_init(void);
CORE_DECLARE(void) hss_fd_final(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __HSS_FD_PATH_H__ */

View File

@ -1,7 +1,7 @@
#define TRACE_MODULE _hss_init
#include "hss_context.h"
#include "hss_s6a_handler.h"
#include "hss_fd_path.h"
static int initialized = 0;
@ -22,7 +22,7 @@ status_t hss_initialize(void)
rv = hss_db_init();
if (rv != CORE_OK) return rv;
ret = hss_s6a_init();
ret = hss_fd_init();
if (ret != CORE_OK) return CORE_ERROR;
initialized = 1;
@ -34,7 +34,7 @@ void hss_terminate(void)
{
if (!initialized) return;
hss_s6a_final();
hss_fd_final();
hss_db_final();
hss_context_final();

View File

@ -1,18 +0,0 @@
#ifndef __HSS_S6A_HANDLER_H__
#define __HSS_S6A_HANDLER_H__
#include "core_errno.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(int) hss_s6a_init(void);
CORE_DECLARE(void) hss_s6a_final(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __HSS_S6A_HANDLER_H__ */

View File

@ -6,7 +6,7 @@ libmme_la_SOURCES = \
mme_kdf.h kasumi.h snow_3g.h zuc.h \
mme_event.h mme_context.h \
s1ap_build.h s1ap_handler.h s1ap_conv.h s1ap_path.h \
mme_s6a_handler.h \
mme_fd_path.h \
nas_conv.h nas_security.h nas_path.h \
emm_handler.h emm_build.h \
esm_handler.h esm_build.h \
@ -15,7 +15,7 @@ libmme_la_SOURCES = \
mme_kdf.c kasumi.c snow_3g.c zuc.c \
mme_init.c mme_event.c mme_context.c \
s1ap_sm.c s1ap_build.c s1ap_handler.c s1ap_conv.c s1ap_path.c \
mme_s6a_handler.c \
mme_fd_path.c \
nas_conv.c nas_security.c nas_path.c \
emm_sm.c emm_handler.c emm_build.c \
esm_sm.c esm_handler.c esm_build.c \

View File

@ -8,7 +8,7 @@
#include "mme_event.h"
#include "mme_kdf.h"
#include "s1ap_handler.h"
#include "mme_s6a_handler.h"
#include "mme_fd_path.h"
#include "emm_handler.h"
#include "emm_build.h"
#include "esm_handler.h"

View File

@ -5,7 +5,7 @@
#include "nas_message.h"
#include "mme_event.h"
#include "mme_s6a_handler.h"
#include "mme_fd_path.h"
#include "emm_handler.h"
#include "esm_build.h"
#include "esm_handler.h"

View File

@ -745,8 +745,8 @@ status_t mme_context_setup_trace_module()
else if (fd <= 5) fd_g_debug_lvl = FD_LOG_DEBUG;
else fd_g_debug_lvl = FD_LOG_ANNOYING;
extern int _mme_s6a_handler;
d_trace_level(&_mme_s6a_handler, fd);
extern int _mme_fd_path;
d_trace_level(&_mme_fd_path, fd);
extern int _fd_init;
d_trace_level(&_fd_init, fd);
extern int _fd_logger;

View File

@ -1,14 +1,15 @@
#define TRACE_MODULE _mme_s6a_handler
#define TRACE_MODULE _mme_fd_path
#include "core_debug.h"
#include "core_pool.h"
#include "core_lib.h"
#include "fd_lib.h"
#include "s6a_lib.h"
#include "s6a_dict.h"
#include "s6a_message.h"
#include "mme_event.h"
#include "mme_s6a_handler.h"
#include "mme_fd_path.h"
#define MAX_NUM_SESSION_STATE 32
@ -804,7 +805,7 @@ static void mme_s6a_ula_cb(void *data, struct msg **msg)
}
int mme_s6a_init(void)
int mme_fd_init(void)
{
pool_init(&mme_s6a_sess_pool, MAX_NUM_SESSION_STATE);
@ -821,7 +822,7 @@ int mme_s6a_init(void)
return 0;
}
void mme_s6a_final(void)
void mme_fd_final(void)
{
CHECK_FCT_DO( fd_sess_handler_destroy(&mme_s6a_reg, NULL), );

View File

@ -1,5 +1,5 @@
#ifndef __MME_S6A_HANDLER_H__
#define __MME_S6A_HANDLER_H__
#ifndef __MME_FD_PATH_H__
#define __MME_FD_PATH_H__
#include "core_errno.h"
@ -9,8 +9,8 @@
extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(int) mme_s6a_init(void);
CORE_DECLARE(void) mme_s6a_final(void);
CORE_DECLARE(int) mme_fd_init(void);
CORE_DECLARE(void) mme_fd_final(void);
/* MME Sends Authentication Information Request to HSS */
CORE_DECLARE(void) mme_s6a_send_air(mme_ue_t *mme_ue);
@ -21,5 +21,5 @@ CORE_DECLARE(void) mme_s6a_send_ulr(mme_ue_t *mme_ue);
}
#endif /* __cplusplus */
#endif /* __MME_S6A_HANDLER_H__ */
#endif /* __MME_FD_PATH_H__ */

View File

@ -5,7 +5,7 @@
#include "mme_event.h"
#include "mme_s6a_handler.h"
#include "mme_fd_path.h"
static thread_id sm_thread;
static void *THREAD_FUNC sm_main(thread_id id, void *data);
@ -29,7 +29,7 @@ status_t mme_initialize()
rv = mme_context_setup_trace_module();
if (rv != CORE_OK) return rv;
ret = mme_s6a_init();
ret = mme_fd_init();
if (ret != 0) return CORE_ERROR;
rv = thread_create(&sm_thread, NULL, sm_main, NULL);
@ -49,7 +49,7 @@ void mme_terminate(void)
thread_delete(net_thread);
thread_delete(sm_thread);
mme_s6a_final();
mme_fd_final();
mme_context_final();

View File

@ -8,7 +8,7 @@
#include "s1ap_handler.h"
#include "s1ap_path.h"
#include "mme_s6a_handler.h"
#include "mme_fd_path.h"
#include "nas_security.h"
#include "emm_handler.h"
#include "mme_s11_path.h"