update it
This commit is contained in:
parent
32d1d630bc
commit
3cc810e74f
|
@ -12,6 +12,30 @@
|
|||
static struct disp_hdl *hss_hdl_fb = NULL; /* handler for fallback cb */
|
||||
static struct disp_hdl *hss_hdl_tr = NULL; /* handler for Test-Request req cb */
|
||||
|
||||
static void hss_auth_send_err_msg(struct msg **msg)
|
||||
{
|
||||
struct msg *ans;
|
||||
|
||||
d_assert(fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0) == 0
|
||||
&& *msg, goto out1,);
|
||||
ans = *msg;
|
||||
|
||||
/* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */
|
||||
d_assert(fd_msg_rescode_set(ans, "DIAMETER_AUTHENTICATION_REJECTED",
|
||||
NULL, NULL, 1) == 0, goto out2,);
|
||||
|
||||
/* Send the answer */
|
||||
d_assert(fd_msg_send(msg, NULL, NULL) == 0, goto out2,);
|
||||
|
||||
return;
|
||||
|
||||
out2:
|
||||
d_assert(fd_msg_free(ans) == 0,,);
|
||||
|
||||
out1:
|
||||
return;
|
||||
}
|
||||
|
||||
/* Default callback for the application. */
|
||||
static int hss_fb_cb(struct msg **msg, struct avp *avp,
|
||||
struct session *sess, void *opaque, enum disp_action *act)
|
||||
|
@ -39,21 +63,17 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
|
|||
c_uint8_t autn[16];
|
||||
int i;
|
||||
|
||||
if (msg == NULL)
|
||||
return EINVAL;
|
||||
d_assert(msg, return EINVAL,);
|
||||
|
||||
/* Create answer header */
|
||||
/* Parse request message */
|
||||
qry = *msg;
|
||||
d_assert(fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0) == 0,
|
||||
return -1,);
|
||||
ans = *msg;
|
||||
|
||||
d_assert(fd_msg_search_avp(qry, s6a_user_name, &avp) && avp,goto out,);
|
||||
d_assert(fd_msg_search_avp(qry, s6a_user_name, &avp) && avp, goto out1,);
|
||||
d_assert(fd_msg_avp_hdr(avp, &hdr) && hdr,,);
|
||||
|
||||
ue = hss_ue_ctx_find_by_imsi(hdr->avp_value->os.data,
|
||||
hdr->avp_value->os.len);
|
||||
d_assert(ue, goto out,);
|
||||
ue = hss_ue_ctx_find_by_imsi(
|
||||
hdr->avp_value->os.data, hdr->avp_value->os.len);
|
||||
d_assert(ue, goto out1,);
|
||||
|
||||
core_generate_random_bytes(ue->rand, MAX_KEY_LEN);
|
||||
milenage_opc(ue->k, hss_self()->op, ue->opc);
|
||||
|
@ -68,57 +88,62 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
|
|||
|
||||
ue->seq = (ue->seq + 32) & 0x7ffffffffff;
|
||||
|
||||
/* Set the Origin-Host, Origin-Realm, Result-Code AVPs */
|
||||
/* Create answer header */
|
||||
d_assert(fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0) == 0
|
||||
&& *msg, goto out1,);
|
||||
ans = *msg;
|
||||
|
||||
/* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */
|
||||
d_assert(fd_msg_rescode_set(ans, "DIAMETER_SUCCESS", NULL, NULL, 1) == 0,
|
||||
goto out,);
|
||||
goto out2,);
|
||||
|
||||
/* Set the Auth-Session-Statee AVP */
|
||||
d_assert(fd_msg_avp_new(s6a_auth_session_state, 0, &avp) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_new(s6a_auth_session_state, 0, &avp) == 0, goto out2,);
|
||||
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,);
|
||||
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out2,);
|
||||
d_assert(fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp) == 0, goto out2,);
|
||||
|
||||
/* Set the Authentication-Info */
|
||||
d_assert(fd_msg_avp_new(s6a_authentication_info, 0, &avp) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_new(s6a_e_utran_vector, 0, &avpch1) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_new(s6a_authentication_info, 0, &avp) == 0, goto out2,);
|
||||
d_assert(fd_msg_avp_new(s6a_e_utran_vector, 0, &avpch1) == 0, goto out2,);
|
||||
|
||||
#define TEST_RAND "RAND_123456"
|
||||
d_assert(fd_msg_avp_new(s6a_rand, 0, &avpch2) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_new(s6a_rand, 0, &avpch2) == 0, goto out2,);
|
||||
val.os.data = (unsigned char*)TEST_RAND;
|
||||
val.os.len = strlen(TEST_RAND);
|
||||
d_assert(fd_msg_avp_setvalue(avpch2, &val) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_setvalue(avpch2, &val) == 0, goto out2,);
|
||||
d_assert(fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2) == 0,
|
||||
goto out,);
|
||||
goto out2,);
|
||||
|
||||
#define TEST_XRES "XRES_123456"
|
||||
d_assert(fd_msg_avp_new(s6a_xres, 0, &avpch2) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_new(s6a_xres, 0, &avpch2) == 0, goto out2,);
|
||||
val.os.data = (unsigned char*)TEST_XRES;
|
||||
val.os.len = strlen(TEST_XRES);
|
||||
d_assert(fd_msg_avp_setvalue(avpch2, &val) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_setvalue(avpch2, &val) == 0, goto out2,);
|
||||
d_assert(fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2) == 0,
|
||||
goto out,);
|
||||
goto out2,);
|
||||
|
||||
#define TEST_AUTH "AUTH_123456"
|
||||
d_assert(fd_msg_avp_new(s6a_autn, 0, &avpch2) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_new(s6a_autn, 0, &avpch2) == 0, goto out2,);
|
||||
val.os.data = (unsigned char*)TEST_AUTH;
|
||||
val.os.len = strlen(TEST_AUTH);
|
||||
d_assert(fd_msg_avp_setvalue(avpch2, &val) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_setvalue(avpch2, &val) == 0, goto out2,);
|
||||
d_assert(fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2) == 0,
|
||||
goto out,);
|
||||
goto out2,);
|
||||
|
||||
#define TEST_KASME "KASME_123456"
|
||||
d_assert(fd_msg_avp_new(s6a_kasme, 0, &avpch2) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_new(s6a_kasme, 0, &avpch2) == 0, goto out2,);
|
||||
val.os.data = (unsigned char*)TEST_KASME;
|
||||
val.os.len = strlen(TEST_KASME);
|
||||
d_assert(fd_msg_avp_setvalue(avpch2, &val) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_setvalue(avpch2, &val) == 0, goto out2,);
|
||||
d_assert(fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2) == 0,
|
||||
goto out,);
|
||||
goto out2,);
|
||||
|
||||
d_assert(fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avpch1) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avpch1) == 0, goto out2,);
|
||||
d_assert(fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp) == 0, goto out2,);
|
||||
|
||||
/* Send the answer */
|
||||
d_assert(fd_msg_send(msg, NULL, NULL) == 0, goto out,);
|
||||
d_assert(fd_msg_send(msg, NULL, NULL) == 0, goto out2,);
|
||||
|
||||
/* Add this value to the stats */
|
||||
d_assert(pthread_mutex_lock(&s6a_config->stats_lock) == 0,,) ;
|
||||
|
@ -128,10 +153,13 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
|
|||
d_assert(fd_msg_free(qry) == 0,,);
|
||||
|
||||
return 0;
|
||||
out:
|
||||
d_assert(fd_msg_free(qry) == 0,,);
|
||||
out2:
|
||||
d_assert(fd_msg_free(ans) == 0,,);
|
||||
|
||||
|
||||
out1:
|
||||
hss_auth_send_err_msg(msg);
|
||||
d_assert(fd_msg_free(qry) == 0,,);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -156,6 +184,7 @@ int hss_init(void)
|
|||
strcpy((char*)ue->imsi, UE1_IMSI);
|
||||
ue->imsi_len = strlen(UE1_IMSI);
|
||||
memcpy(ue->k, core_ascii_to_hex(K, strlen(K), buf), MAX_KEY_LEN);
|
||||
ue->seq = 32;
|
||||
|
||||
ue = hss_ue_ctx_add();
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
@ -163,6 +192,7 @@ int hss_init(void)
|
|||
strcpy((char*)ue->imsi, UE2_IMSI);
|
||||
ue->imsi_len = strlen(UE2_IMSI);
|
||||
memcpy(ue->k, core_ascii_to_hex(K, strlen(K), buf), MAX_KEY_LEN);
|
||||
ue->seq = 32;
|
||||
}
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
|
|
|
@ -70,12 +70,8 @@ extern struct dict_object *s6a_origin_realm;
|
|||
extern struct dict_object *s6a_destination_host;
|
||||
extern struct dict_object *s6a_destination_realm;
|
||||
extern struct dict_object *s6a_user_name;
|
||||
extern struct dict_object *s6a_session_id;
|
||||
extern struct dict_object *s6a_auth_session_state;
|
||||
extern struct dict_object *s6a_result_code;
|
||||
extern struct dict_object *s6a_experimental_result;
|
||||
extern struct dict_object *s6a_vendor_id;
|
||||
extern struct dict_object *s6a_experimental_result_code;
|
||||
|
||||
extern struct dict_object *s6a_visited_plmn_id;
|
||||
extern struct dict_object *s6a_rat_type;
|
||||
|
|
|
@ -21,12 +21,8 @@ struct dict_object *s6a_origin_realm = NULL;
|
|||
struct dict_object *s6a_destination_host = NULL;
|
||||
struct dict_object *s6a_destination_realm = NULL;
|
||||
struct dict_object *s6a_user_name = NULL;
|
||||
struct dict_object *s6a_session_id = NULL;
|
||||
struct dict_object *s6a_auth_session_state = NULL;
|
||||
struct dict_object *s6a_result_code = NULL;
|
||||
struct dict_object *s6a_experimental_result = NULL;
|
||||
struct dict_object *s6a_vendor_id = NULL;
|
||||
struct dict_object *s6a_experimental_result_code = NULL;
|
||||
|
||||
struct dict_object *s6a_visited_plmn_id = NULL;
|
||||
struct dict_object *s6a_rat_type = NULL;
|
||||
|
@ -131,27 +127,19 @@ int s6a_dict_init(void)
|
|||
"Cancel-Location-Answer", &s6a_cmd_cla, ENOENT));
|
||||
|
||||
CHECK_FCT(fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME,
|
||||
"Origin-Host", &s6a_origin_host, ENOENT));
|
||||
"Origin-Host", &s6a_origin_host, ENOENT));
|
||||
CHECK_FCT(fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME,
|
||||
"Origin-Realm", &s6a_origin_realm, ENOENT));
|
||||
"Origin-Realm", &s6a_origin_realm, ENOENT));
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME,
|
||||
"Destination-Host", &s6a_destination_host, ENOENT));
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME,
|
||||
"Destination-Realm", &s6a_destination_realm, ENOENT));
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME,
|
||||
"User-Name", &s6a_user_name, ENOENT));
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME,
|
||||
"Session-Id", &s6a_session_id, ENOENT));
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME,
|
||||
"Auth-Session-State", &s6a_auth_session_state, ENOENT));
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME,
|
||||
"Result-Code", &s6a_result_code, ENOENT));
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME,
|
||||
"Experimental-Result", &s6a_experimental_result, ENOENT));
|
||||
CHECK_FCT(fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME,
|
||||
"Vendor-Id", &s6a_vendor_id, ENOENT));
|
||||
CHECK_FCT(fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME,
|
||||
"Experimental-Result-Code", &s6a_experimental_result_code, ENOENT));
|
||||
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
|
||||
AVP_BY_NAME_ALL_VENDORS, "Visited-PLMN-Id",
|
||||
|
|
|
@ -14,7 +14,7 @@ int s6a_fd_init(const char *conffile)
|
|||
{
|
||||
int ret;
|
||||
|
||||
d_trace_level(&_s6a_fd, 0);
|
||||
d_trace_level(&_s6a_fd, 100);
|
||||
|
||||
gnutls_global_set_log_function(s6a_gnutls_log_func);
|
||||
gnutls_global_set_log_level(TRACE_MODULE);
|
||||
|
|
Loading…
Reference in New Issue