update it

This commit is contained in:
Sukchan Lee 2017-04-09 22:01:54 +09:00
parent c85785f4e3
commit 450b04a4d3
6 changed files with 474 additions and 116 deletions

View File

@ -13,8 +13,12 @@
#define HSS_SQN_LEN 6
#define HSS_AK_LEN 6
static struct disp_hdl *hdl_fb = NULL; /* handler for fallback cb */
static struct disp_hdl *hdl_air = NULL; /* handler for Auth-Info-Request cb */
/* handler for fallback cb */
static struct disp_hdl *hdl_fb = NULL;
/* handler for Authentication-Information-Request cb */
static struct disp_hdl *hdl_air = NULL;
/* handler for Update-Location-Request cb */
static struct disp_hdl *hdl_ulr = NULL;
/* Default callback for the application. */
static int hss_fb_cb(struct msg **msg, struct avp *avp,
@ -26,7 +30,7 @@ static int hss_fb_cb(struct msg **msg, struct avp *avp,
return ENOTSUP;
}
/* Callback for incoming Test-Request messages */
/* Callback for incoming Authentication-Information-Request messages */
static int hss_air_cb( struct msg **msg, struct avp *avp,
struct session *sess, void *opaque, enum disp_action *act)
{
@ -71,10 +75,8 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
d_assert(fd_msg_avp_hdr(avp, &hdr) == 0 && hdr,,);
if (hdr && hdr->avp_value && hdr->avp_value->os.data)
{
memcpy(&ue->visited_plmn_id,
hdr->avp_value->os.data, hdr->avp_value->os.len);
}
milenage_opc(ue->k, ue->op, ue->opc);
milenage_generate(ue->opc, ue->amf, ue->k,
@ -146,6 +148,75 @@ out:
return 0;
}
/* Callback for incoming Update-Location-Request messages */
static int hss_ulr_cb( struct msg **msg, struct avp *avp,
struct session *sess, void *opaque, enum disp_action *act)
{
struct msg *ans, *qry;
#if 0
struct avp *avpch1, *avpch2;
#endif
struct avp_hdr *hdr;
union avp_value val;
hss_ue_t *ue = NULL;
d_assert(msg, return EINVAL,);
/* Create answer header */
qry = *msg;
fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0);
ans = *msg;
d_assert(fd_msg_search_avp(qry, s6a_user_name, &avp) == 0 && avp,
goto out,);
d_assert(fd_msg_avp_hdr(avp, &hdr) == 0 && hdr,,);
ue = hss_ue_find_by_imsi(
hdr->avp_value->os.data, hdr->avp_value->os.len);
if (!ue)
{
char imsi[MAX_IMSI_LEN];
strncpy(imsi, (char*)hdr->avp_value->os.data, hdr->avp_value->os.len);
d_warn("Cannot find IMSI:%s\n", imsi);
goto out;
}
d_assert(fd_msg_search_avp(qry, s6a_visited_plmn_id, &avp) == 0 &&
avp, goto out,);
d_assert(fd_msg_avp_hdr(avp, &hdr) == 0 && hdr,,);
if (hdr && hdr->avp_value && hdr->avp_value->os.data)
memcpy(&ue->visited_plmn_id,
hdr->avp_value->os.data, hdr->avp_value->os.len);
/* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */
d_assert(fd_msg_rescode_set(ans, "DIAMETER_SUCCESS", NULL, NULL, 1) == 0,
goto out,);
/* Set the Auth-Session-Statee AVP */
d_assert(fd_msg_avp_new(s6a_auth_session_state, 0, &avp) == 0, goto out,);
val.i32 = 1;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* Send the answer */
fd_msg_send(msg, NULL, NULL);
/* Add this value to the stats */
pthread_mutex_lock(&s6a_config->stats_lock);
s6a_config->stats.nb_echoed++;
pthread_mutex_unlock(&s6a_config->stats_lock);
return 0;
out:
fd_msg_rescode_set(ans, "DIAMETER_AUTHENTICATION_REJECTED", NULL, NULL, 1);
fd_msg_send(msg, NULL, NULL);
return 0;
}
status_t hss_initialize(void)
{
status_t rv;
@ -160,16 +231,21 @@ status_t hss_initialize(void)
memset(&data, 0, sizeof(data));
data.app = s6a_appli;
data.command = s6a_cmd_air;
/* fallback CB if command != unexpected message received */
d_assert(fd_disp_register(hss_fb_cb, DISP_HOW_APPID, &data, NULL,
&hdl_fb) == 0, return CORE_ERROR,);
/* Now specific handler for Authentication-Information-Request */
/* specific handler for Authentication-Information-Request */
data.command = s6a_cmd_air;
d_assert(fd_disp_register(hss_air_cb, DISP_HOW_CC, &data, NULL,
&hdl_air) == 0, return CORE_ERROR,);
/* specific handler for Location-Update-Request */
data.command = s6a_cmd_ulr;
d_assert(fd_disp_register(hss_ulr_cb, DISP_HOW_CC, &data, NULL,
&hdl_ulr) == 0, return CORE_ERROR,);
return CORE_OK;
}
@ -181,6 +257,9 @@ void hss_terminate(void)
if (hdl_air) {
(void) fd_disp_unregister(&hdl_air, NULL);
}
if (hdl_ulr) {
(void) fd_disp_unregister(&hdl_ulr, NULL);
}
hss_context_final();
s6a_final();

View File

@ -193,4 +193,5 @@ void emm_handle_security_mode_complete(mme_ue_t *ue)
pkbuf_free(sendbuf);
d_assert(ue, return, "Null param");
mme_s6a_send_air(ue);
}

View File

@ -6,6 +6,7 @@
#include "mme_event.h"
#include "emm_handler.h"
#include "mme_s6a_handler.h"
void emm_state_initial(emm_sm_t *s, event_t *e)
{
@ -79,7 +80,7 @@ void emm_state_operational(emm_sm_t *s, event_t *e)
d_assert(ue->imsi, return,);
d_info("[NAS] Security mode complete : UE[%s] --> EMM",
ue->imsi);
emm_handle_security_mode_complete(ue);
mme_s6a_send_ulr(ue);
break;
}
default:

View File

@ -21,113 +21,7 @@ struct sess_state {
pool_declare(sess_state_pool, struct sess_state, MAX_NUM_SESSION_STATE);
static void mme_s6a_aia_cb(void *data, struct msg **msg);
/* Cb called when an answer is received */
int mme_s6a_send_air(mme_ue_t *ue)
{
struct msg *req = NULL;
struct avp *avp;
struct avp *avpch;
union avp_value val;
struct sess_state *mi = NULL, *svg;
struct session *sess = NULL;
d_assert(ue, return -1, "Null Param");
/* Create the random value to store with the session */
pool_alloc_node(&sess_state_pool, &mi);
d_assert(mi, return -1, "malloc failed: %s", strerror(errno));
mi->ue = ue;
/* Create the request */
d_assert(fd_msg_new(s6a_cmd_air, MSGFL_ALLOC_ETEID, &req) == 0,
pool_free_node(&sess_state_pool, mi); return -1,);
/* Create a new session */
#define S6A_APP_SID_OPT "app_s6a"
d_assert(fd_msg_new_session(req, (os0_t)S6A_APP_SID_OPT,
CONSTSTRLEN(S6A_APP_SID_OPT)) == 0, goto out,);
d_assert(fd_msg_sess_get(fd_g_config->cnf_dict, req, &sess, NULL) == 0,
goto out, );
/* Set the Auth-Session-Statee AVP */
d_assert(fd_msg_avp_new(s6a_auth_session_state, 0, &avp) == 0, goto out,);
val.i32 = 1;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* Set Origin-Host & Origin-Realm */
d_assert(fd_msg_add_origin(req, 0) == 0, goto out, );
/* Set the Destination-Realm AVP */
d_assert(fd_msg_avp_new(s6a_destination_realm, 0, &avp) == 0, goto out,);
val.os.data = (unsigned char *)(fd_g_config->cnf_diamrlm);
val.os.len = strlen(fd_g_config->cnf_diamrlm);
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out, );
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out, );
/* Set the User-Name AVP if needed*/
d_assert(fd_msg_avp_new(s6a_user_name, 0, &avp) == 0, goto out,);
val.os.data = ue->imsi;
val.os.len = ue->imsi_len;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out, );
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* Add the Authentication-Info */
d_assert(fd_msg_avp_new(s6a_req_eutran_auth_info, 0, &avp) == 0, goto out,);
d_assert(fd_msg_avp_new(s6a_number_of_requested_vectors, 0,
&avpch) == 0, goto out,);
val.u32 = 1;
d_assert(fd_msg_avp_setvalue (avpch, &val) == 0, goto out,);
d_assert(fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch) == 0, goto out,);
d_assert(fd_msg_avp_new(s6a_immediate_response_preferred, 0,
&avpch) == 0, goto out,);
val.u32 = 1;
d_assert(fd_msg_avp_setvalue(avpch, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avpch) == 0, goto out,);
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* Set the Visited-PLMN-Id AVP if needed*/
d_assert(fd_msg_avp_new(s6a_visited_plmn_id, 0, &avp) == 0, goto out,);
val.os.data = (c_uint8_t *)&ue->visited_plmn_id;
val.os.len = PLMN_ID_LEN;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
d_assert(clock_gettime(CLOCK_REALTIME, &mi->ts) == 0, goto out,);
/* Keep a pointer to the session data for debug purpose,
* in real life we would not need it */
svg = mi;
/* Store this value in the session */
d_assert(fd_sess_state_store(mme_s6a_reg, sess, &mi) == 0, goto out,);
/* Send the request */
d_assert(fd_msg_send(&req, mme_s6a_aia_cb, svg) == 0, goto out,);
/* Increment the counter */
d_assert(pthread_mutex_lock(&s6a_config->stats_lock) == 0,,);
s6a_config->stats.nb_sent++;
d_assert(pthread_mutex_unlock(&s6a_config->stats_lock) == 0,, );
d_assert(ue->imsi, return 0,);
d_info("[S6A] Authentication-Information-Request : UE[%s] --> HSS",
ue->imsi);
return 0;
out:
d_assert(fd_msg_free(req) == 0,,);
pool_free_node(&sess_state_pool, mi);
return -1;
}
/* MME received Authentication Information Answer from HSS */
static void mme_s6a_aia_cb(void *data, struct msg **msg)
{
struct sess_state *mi = NULL;
@ -265,6 +159,386 @@ out:
pool_free_node(&sess_state_pool, mi);
}
/* MME Sends Authentication Information Request to HSS */
int mme_s6a_send_air(mme_ue_t *ue)
{
struct msg *req = NULL;
struct avp *avp;
struct avp *avpch;
union avp_value val;
struct sess_state *mi = NULL, *svg;
struct session *sess = NULL;
d_assert(ue, return -1, "Null Param");
/* Create the random value to store with the session */
pool_alloc_node(&sess_state_pool, &mi);
d_assert(mi, return -1, "malloc failed: %s", strerror(errno));
mi->ue = ue;
/* Create the request */
d_assert(fd_msg_new(s6a_cmd_air, MSGFL_ALLOC_ETEID, &req) == 0,
pool_free_node(&sess_state_pool, mi); return -1,);
/* Create a new session */
#define S6A_APP_SID_OPT "app_s6a"
d_assert(fd_msg_new_session(req, (os0_t)S6A_APP_SID_OPT,
CONSTSTRLEN(S6A_APP_SID_OPT)) == 0, goto out,);
d_assert(fd_msg_sess_get(fd_g_config->cnf_dict, req, &sess, NULL) == 0,
goto out, );
/* Set the Auth-Session-State AVP */
d_assert(fd_msg_avp_new(s6a_auth_session_state, 0, &avp) == 0, goto out,);
val.i32 = 1;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* Set Origin-Host & Origin-Realm */
d_assert(fd_msg_add_origin(req, 0) == 0, goto out, );
/* Set the Destination-Realm AVP */
d_assert(fd_msg_avp_new(s6a_destination_realm, 0, &avp) == 0, goto out,);
val.os.data = (unsigned char *)(fd_g_config->cnf_diamrlm);
val.os.len = strlen(fd_g_config->cnf_diamrlm);
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out, );
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out, );
/* Set the User-Name AVP */
d_assert(fd_msg_avp_new(s6a_user_name, 0, &avp) == 0, goto out,);
val.os.data = ue->imsi;
val.os.len = ue->imsi_len;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out, );
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* Add the Authentication-Info */
d_assert(fd_msg_avp_new(s6a_req_eutran_auth_info, 0, &avp) == 0, goto out,);
d_assert(fd_msg_avp_new(s6a_number_of_requested_vectors, 0,
&avpch) == 0, goto out,);
val.u32 = 1;
d_assert(fd_msg_avp_setvalue (avpch, &val) == 0, goto out,);
d_assert(fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch) == 0, goto out,);
d_assert(fd_msg_avp_new(s6a_immediate_response_preferred, 0,
&avpch) == 0, goto out,);
val.u32 = 1;
d_assert(fd_msg_avp_setvalue(avpch, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avpch) == 0, goto out,);
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* Set the Visited-PLMN-Id AVP */
d_assert(fd_msg_avp_new(s6a_visited_plmn_id, 0, &avp) == 0, goto out,);
val.os.data = (c_uint8_t *)&ue->visited_plmn_id;
val.os.len = PLMN_ID_LEN;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
d_assert(clock_gettime(CLOCK_REALTIME, &mi->ts) == 0, goto out,);
/* Keep a pointer to the session data for debug purpose,
* in real life we would not need it */
svg = mi;
/* Store this value in the session */
d_assert(fd_sess_state_store(mme_s6a_reg, sess, &mi) == 0, goto out,);
/* Send the request */
d_assert(fd_msg_send(&req, mme_s6a_aia_cb, svg) == 0, goto out,);
/* Increment the counter */
d_assert(pthread_mutex_lock(&s6a_config->stats_lock) == 0,,);
s6a_config->stats.nb_sent++;
d_assert(pthread_mutex_unlock(&s6a_config->stats_lock) == 0,, );
d_assert(ue->imsi, return 0,);
d_info("[S6A] Authentication-Information-Request : UE[%s] --> HSS",
ue->imsi);
return 0;
out:
d_assert(fd_msg_free(req) == 0,,);
pool_free_node(&sess_state_pool, mi);
return -1;
}
/* MME received Update Location Answer from HSS */
static void mme_s6a_ula_cb(void *data, struct msg **msg)
{
struct sess_state *mi = NULL;
struct timespec ts;
struct session *sess;
struct avp *avp;
#if 0
struct avp *avpch1, *avpch2;
#endif
struct avp_hdr *hdr;
unsigned long dur;
int error = 0;
int new;
mme_ue_t *ue = NULL;
nas_message_t message;
#if 0
pkbuf_t *sendbuf = NULL;
event_t e;
nas_authentication_request_t *authentication_request =
&message.emm.authentication_request;
#endif
CHECK_SYS_DO(clock_gettime(CLOCK_REALTIME, &ts), return);
/* Search the session, retrieve its data */
d_assert(fd_msg_sess_get(fd_g_config->cnf_dict, *msg, &sess, &new) == 0 &&
new == 0, return,);
d_assert(fd_sess_state_retrieve(mme_s6a_reg, sess, &mi) == 0 &&
mi && (void *)mi == data, fd_msg_free(*msg); *msg = NULL; return,);
ue = mi->ue;
d_assert(ue, error++; goto out,);
d_assert(ue->imsi, error++; goto out,);
d_info("[S6A] Authentication-Information-Response : UE[%s] <-- HSS",
ue->imsi);
/* Value of Result Code */
d_assert(fd_msg_search_avp(*msg, s6a_result_code, &avp) == 0 && avp,
error++; goto out,);
d_assert(fd_msg_avp_hdr(avp, &hdr) == 0 && hdr, error++; goto out,);
if (hdr->avp_value->i32 != ER_DIAMETER_SUCCESS)
{
d_error("ERROR DIAMETER Result Code(%d)", hdr->avp_value->i32);
error++;
goto out;
}
memset(&message, 0, sizeof(message));
message.emm.h.protocol_discriminator = NAS_PROTOCOL_DISCRIMINATOR_EMM;
message.emm.h.message_type = NAS_AUTHENTICATION_REQUEST;
#if 0
d_assert(fd_msg_search_avp(*msg, s6a_authentication_info, &avp) == 0 && avp,
error++; goto out,);
d_assert(fd_msg_avp_hdr(avp, &hdr) == 0 && hdr, error++; goto out,);
d_assert(fd_avp_search_avp(avp, s6a_e_utran_vector, &avpch1) == 0 && avp,
error++; goto out,);
d_assert(fd_msg_avp_hdr(avpch1, &hdr) == 0 && hdr, error++; goto out,);
d_assert(fd_avp_search_avp(avpch1, s6a_xres, &avpch2) == 0 && avp,
error++; goto out,);
d_assert(fd_msg_avp_hdr(avpch2, &hdr) == 0 && hdr, error++; goto out,);
memcpy(ue->xres, hdr->avp_value->os.data, hdr->avp_value->os.len);
ue->xres_len = hdr->avp_value->os.len;
d_assert(fd_avp_search_avp(avpch1, s6a_kasme, &avpch2) == 0 && avp,
error++; goto out,);
d_assert(fd_msg_avp_hdr(avpch2, &hdr) == 0 && hdr, error++; goto out,);
memcpy(ue->kasme, hdr->avp_value->os.data, hdr->avp_value->os.len);
d_assert(fd_avp_search_avp(avpch1, s6a_rand, &avpch2) == 0 && avp,
error++; goto out,);
d_assert(fd_msg_avp_hdr(avpch2, &hdr) == 0 && hdr, error++; goto out,);
memcpy(authentication_request->authentication_parameter_rand.rand,
hdr->avp_value->os.data, hdr->avp_value->os.len);
d_assert(fd_avp_search_avp(avpch1, s6a_autn, &avpch2) == 0 && avp,
error++; goto out,);
d_assert(fd_msg_avp_hdr(avpch2, &hdr) == 0 && hdr, error++; goto out,);
authentication_request->authentication_parameter_autn.length =
hdr->avp_value->os.len;
memcpy(authentication_request->authentication_parameter_autn.autn,
hdr->avp_value->os.data, hdr->avp_value->os.len);
d_assert(nas_plain_encode(&sendbuf, &message) == CORE_OK && sendbuf,
error++; goto out,);
event_set(&e, EVT_MSG_MME_EMM);
event_set_param1(&e, (c_uintptr_t)ue);
event_set_param2(&e, (c_uintptr_t)sendbuf);
if (mme_event_send(&e) != CORE_OK)
{
d_error("mme_event_send failed");
pkbuf_free(sendbuf);
error++;
}
#endif
out:
/* Free the message */
d_assert(pthread_mutex_lock(&s6a_config->stats_lock) == 0,,);
dur = ((ts.tv_sec - mi->ts.tv_sec) * 1000000) +
((ts.tv_nsec - mi->ts.tv_nsec) / 1000);
if (s6a_config->stats.nb_recv)
{
/* Ponderate in the avg */
s6a_config->stats.avg = (s6a_config->stats.avg *
s6a_config->stats.nb_recv + dur) / (s6a_config->stats.nb_recv + 1);
/* Min, max */
if (dur < s6a_config->stats.shortest)
s6a_config->stats.shortest = dur;
if (dur > s6a_config->stats.longest)
s6a_config->stats.longest = dur;
}
else
{
s6a_config->stats.shortest = dur;
s6a_config->stats.longest = dur;
s6a_config->stats.avg = dur;
}
if (error)
s6a_config->stats.nb_errs++;
else
s6a_config->stats.nb_recv++;
d_assert(pthread_mutex_unlock(&s6a_config->stats_lock) == 0,,);
/* Display how long it took */
if (ts.tv_nsec > mi->ts.tv_nsec)
d_trace(1, "in %d.%06ld sec\n",
(int)(ts.tv_sec - mi->ts.tv_sec),
(long)(ts.tv_nsec - mi->ts.tv_nsec) / 1000);
else
d_trace(1, "in %d.%06ld sec\n",
(int)(ts.tv_sec + 1 - mi->ts.tv_sec),
(long)(1000000000 + ts.tv_nsec - mi->ts.tv_nsec) / 1000);
d_assert(fd_msg_free(*msg) == 0,,);
*msg = NULL;
pool_free_node(&sess_state_pool, mi);
}
/* MME Sends Update Location Request to HSS */
int mme_s6a_send_ulr(mme_ue_t *ue)
{
struct msg *req = NULL;
struct avp *avp;
union avp_value val;
struct sess_state *mi = NULL, *svg;
struct session *sess = NULL;
d_assert(ue, return -1, "Null Param");
/* Create the random value to store with the session */
pool_alloc_node(&sess_state_pool, &mi);
d_assert(mi, return -1, "malloc failed: %s", strerror(errno));
mi->ue = ue;
/* Create the request */
d_assert(fd_msg_new(s6a_cmd_ulr, MSGFL_ALLOC_ETEID, &req) == 0,
pool_free_node(&sess_state_pool, mi); return -1,);
/* Create a new session */
#define S6A_APP_SID_OPT "app_s6a"
d_assert(fd_msg_new_session(req, (os0_t)S6A_APP_SID_OPT,
CONSTSTRLEN(S6A_APP_SID_OPT)) == 0, goto out,);
d_assert(fd_msg_sess_get(fd_g_config->cnf_dict, req, &sess, NULL) == 0,
goto out, );
/* Set the Auth-Session-State AVP */
d_assert(fd_msg_avp_new(s6a_auth_session_state, 0, &avp) == 0, goto out,);
val.i32 = 1;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* Set Origin-Host & Origin-Realm */
d_assert(fd_msg_add_origin(req, 0) == 0, goto out, );
/* Set the Destination-Realm AVP */
d_assert(fd_msg_avp_new(s6a_destination_realm, 0, &avp) == 0, goto out,);
val.os.data = (unsigned char *)(fd_g_config->cnf_diamrlm);
val.os.len = strlen(fd_g_config->cnf_diamrlm);
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out, );
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out, );
/* Set the User-Name AVP */
d_assert(fd_msg_avp_new(s6a_user_name, 0, &avp) == 0, goto out,);
val.os.data = ue->imsi;
val.os.len = ue->imsi_len;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out, );
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* Set the RAT-Type */
d_assert(fd_msg_avp_new(s6a_rat_type, 0, &avp) == 0, goto out,);
#define S6A_RAT_TYPE_WLAN 0
#define S6A_RAT_TYPE_VIRTUAL 1
#define S6A_RAT_TYPE_UTRAN 1000
#define S6A_RAT_TYPE_GERAN 1001
#define S6A_RAT_TYPE_GAN 1002
#define S6A_RAT_TYPE_HSPA_EVOLUTION 1003
#define S6A_RAT_TYPE_EUTRAN 1004
#define S6A_RAT_TYPE_EUTRAN_NB_IOT 1005
#define S6A_RAT_TYPE_CDMA2000_1X 2000
#define S6A_RAT_TYPE_HRPD 2001
#define S6A_RAT_TYPE_UMB 2002
#define S6A_RAT_TYPE_EHRPD 2003
val.u32 = S6A_RAT_TYPE_EUTRAN;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* Set the ULR-Flags */
d_assert(fd_msg_avp_new(s6a_ulr_flags, 0, &avp) == 0, goto out,);
#define S6A_ULR_SINGLE_REGISTRATION_IND (1)
#define S6A_ULR_S6A_S6D_INDICATOR (1 << 1)
#define S6A_ULR_SKIP_SUBSCRIBER_DATA (1 << 2)
#define S6A_ULR_GPRS_SUBSCRIPTION_DATA_IND (1 << 3)
#define S6A_ULR_NODE_TYPE_IND (1 << 4)
#define S6A_ULR_INITIAL_ATTACH_IND (1 << 5)
#define S6A_ULR_PS_LCS_SUPPORTED_BY_UE (1 << 6)
val.u32 = S6A_ULR_S6A_S6D_INDICATOR;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* Set the Visited-PLMN-Id */
d_assert(fd_msg_avp_new(s6a_visited_plmn_id, 0, &avp) == 0, goto out,);
val.os.data = (c_uint8_t *)&ue->visited_plmn_id;
val.os.len = PLMN_ID_LEN;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* Set the UE-SRVCC Capability */
d_assert(fd_msg_avp_new(s6a_ue_srvcc_cap, 0, &avp) == 0, goto out,);
#define S6A_UE_SRVCC_NOT_SUPPORTED (0)
#define S6A_UE_SRVCC_SUPPORTED (1)
val.u32 = S6A_UE_SRVCC_NOT_SUPPORTED;
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
/* FIXME : Supported-Features */
d_assert(clock_gettime(CLOCK_REALTIME, &mi->ts) == 0, goto out,);
/* Keep a pointer to the session data for debug purpose,
* in real life we would not need it */
svg = mi;
/* Store this value in the session */
d_assert(fd_sess_state_store(mme_s6a_reg, sess, &mi) == 0, goto out,);
/* Send the request */
d_assert(fd_msg_send(&req, mme_s6a_ula_cb, svg) == 0, goto out,);
/* Increment the counter */
d_assert(pthread_mutex_lock(&s6a_config->stats_lock) == 0,,);
s6a_config->stats.nb_sent++;
d_assert(pthread_mutex_unlock(&s6a_config->stats_lock) == 0,, );
d_assert(ue->imsi, return 0,);
d_info("[S6A] Update-Location-Request : UE[%s] --> HSS",
ue->imsi);
return 0;
out:
d_assert(fd_msg_free(req) == 0,,);
pool_free_node(&sess_state_pool, mi);
return -1;
}
status_t mme_s6a_init(void)
{
status_t rv;

View File

@ -12,7 +12,10 @@ extern "C" {
CORE_DECLARE(status_t) mme_s6a_init(void);
CORE_DECLARE(void) mme_s6a_final(void);
/* MME Sends Authentication Information Request to HSS */
CORE_DECLARE(int) mme_s6a_send_air(mme_ue_t *ue);
/* MME Sends Update Location Request to HSS */
CORE_DECLARE(int) mme_s6a_send_ulr(mme_ue_t *ue);
#ifdef __cplusplus
}

View File

@ -98,7 +98,7 @@ abts_suite *test_nas_sm(abts_suite *suite)
{
suite = ADD_SUITE(suite)
#if 0
#if 1
d_log_set_level(D_MSG_TO_STDOUT, D_LOG_LEVEL_FULL);
#endif