update it
This commit is contained in:
parent
49aa7d3a13
commit
5d433a13ec
|
@ -108,6 +108,8 @@ status_t hss_context_init(void)
|
|||
ue->num_of_pdn = 1;
|
||||
memcpy(ue->rand, CORE_HEX(UE3_RAND, strlen(UE3_RAND), buf),
|
||||
RAND_LEN);
|
||||
ue->access_restriction_data = 32;
|
||||
ue->network_access_mode = 2;
|
||||
|
||||
ue = hss_ue_add(profile_id, UE4_IMSI);
|
||||
d_assert(ue, return -1, "UE context add failed");
|
||||
|
@ -115,6 +117,8 @@ status_t hss_context_init(void)
|
|||
ue->num_of_pdn = 1;
|
||||
memcpy(ue->rand, CORE_HEX(UE4_RAND, strlen(UE4_RAND), buf),
|
||||
RAND_LEN);
|
||||
ue->access_restriction_data = 32;
|
||||
ue->network_access_mode = 2;
|
||||
|
||||
hss_db_init();
|
||||
|
||||
|
|
|
@ -25,10 +25,11 @@ status_t hss_db_init()
|
|||
hss_db_subscription_data_t subscription_data;
|
||||
pdn_t *pdn = &subscription_data.pdn[0];
|
||||
hss_db_subscription_data("001010123456819", &subscription_data);
|
||||
printf("%d, %d, %d\n",
|
||||
printf("%d, %d, %d, %d\n",
|
||||
subscription_data.access_restriction_data,
|
||||
subscription_data.subscriber_status,
|
||||
subscription_data.network_access_mode);
|
||||
subscription_data.network_access_mode,
|
||||
subscription_data.subscribed_rau_tau_timer);
|
||||
printf("%d, %d\n",
|
||||
subscription_data.max_bandwidth_ul,
|
||||
subscription_data.max_bandwidth_dl);
|
||||
|
@ -36,6 +37,7 @@ status_t hss_db_init()
|
|||
printf("%d, %d\n", pdn->max_bandwidth_ul, pdn->max_bandwidth_dl);
|
||||
printf("%d, %d\n", pdn->qci, pdn->priority_level);
|
||||
printf("%d, %d\n", pdn->pre_emption_capability, pdn->pre_emption_vulnerability);
|
||||
printf("num = %d\n", subscription_data.num_of_pdn);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -62,7 +64,7 @@ status_t hss_db_auth_info(
|
|||
const bson_t *document;
|
||||
bson_iter_t iter;
|
||||
bson_iter_t inner_iter;
|
||||
char buf[HSS_DB_KEY_LEN];
|
||||
char buf[HSS_KEY_LEN];
|
||||
char *utf8 = NULL;
|
||||
c_uint32_t length = 0;
|
||||
|
||||
|
@ -101,17 +103,17 @@ status_t hss_db_auth_info(
|
|||
if (!strcmp(key, "k") && BSON_ITER_HOLDS_UTF8(&inner_iter))
|
||||
{
|
||||
utf8 = (char *)bson_iter_utf8(&inner_iter, &length);
|
||||
memcpy(auth_info->k, CORE_HEX(utf8, length, buf), HSS_DB_KEY_LEN);
|
||||
memcpy(auth_info->k, CORE_HEX(utf8, length, buf), HSS_KEY_LEN);
|
||||
}
|
||||
else if (!strcmp(key, "op") && BSON_ITER_HOLDS_UTF8(&inner_iter))
|
||||
{
|
||||
utf8 = (char *)bson_iter_utf8(&inner_iter, &length);
|
||||
memcpy(auth_info->op, CORE_HEX(utf8, length, buf), HSS_DB_KEY_LEN);
|
||||
memcpy(auth_info->op, CORE_HEX(utf8, length, buf), HSS_KEY_LEN);
|
||||
}
|
||||
else if (!strcmp(key, "amf") && BSON_ITER_HOLDS_UTF8(&inner_iter))
|
||||
{
|
||||
utf8 = (char *)bson_iter_utf8(&inner_iter, &length);
|
||||
memcpy(auth_info->amf, CORE_HEX(utf8, length, buf), HSS_DB_AMF_LEN);
|
||||
memcpy(auth_info->amf, CORE_HEX(utf8, length, buf), HSS_AMF_LEN);
|
||||
}
|
||||
else if (!strcmp(key, "rand") && BSON_ITER_HOLDS_UTF8(&inner_iter))
|
||||
{
|
||||
|
@ -274,6 +276,12 @@ status_t hss_db_subscription_data(
|
|||
subscription_data->network_access_mode =
|
||||
bson_iter_int32(&iter);
|
||||
}
|
||||
else if (!strcmp(key, "subscribed_rau_tau_timer") &&
|
||||
BSON_ITER_HOLDS_INT32(&iter))
|
||||
{
|
||||
subscription_data->subscribed_rau_tau_timer =
|
||||
bson_iter_int32(&iter);
|
||||
}
|
||||
else if (!strcmp(key, "ue_ambr") &&
|
||||
BSON_ITER_HOLDS_DOCUMENT(&iter))
|
||||
{
|
||||
|
@ -298,11 +306,12 @@ status_t hss_db_subscription_data(
|
|||
else if (!strcmp(key, "pdn") &&
|
||||
BSON_ITER_HOLDS_ARRAY(&iter))
|
||||
{
|
||||
int pdn_index = 0;
|
||||
|
||||
bson_iter_recurse(&iter, &child1_iter);
|
||||
while(bson_iter_next(&child1_iter))
|
||||
{
|
||||
const char *child1_key = bson_iter_key(&child1_iter);
|
||||
int pdn_index = 0;
|
||||
pdn_t *pdn = NULL;
|
||||
|
||||
d_assert(child1_key, return CORE_ERROR, "PDN is not ARRAY");
|
||||
|
@ -399,6 +408,8 @@ status_t hss_db_subscription_data(
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
subscription_data->num_of_pdn = pdn_index + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define HSS_DB_KEY_LEN 16
|
||||
#define HSS_DB_AMF_LEN 2
|
||||
#define HSS_KEY_LEN 16
|
||||
#define HSS_AMF_LEN 2
|
||||
|
||||
typedef struct _hss_db_auth_info_t {
|
||||
c_uint8_t k[HSS_DB_KEY_LEN];
|
||||
c_uint8_t op[HSS_DB_KEY_LEN];
|
||||
c_uint8_t amf[HSS_DB_AMF_LEN];
|
||||
c_uint8_t k[HSS_KEY_LEN];
|
||||
c_uint8_t op[HSS_KEY_LEN];
|
||||
c_uint8_t amf[HSS_AMF_LEN];
|
||||
c_uint8_t rand[RAND_LEN];
|
||||
c_uint64_t sqn;
|
||||
} hss_db_auth_info_t;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#include "s6a_lib.h"
|
||||
|
||||
#include "hss_db.h"
|
||||
#include "hss_context.h"
|
||||
#include "hss_db.h"
|
||||
#include "hss_kdf.h"
|
||||
#include "milenage.h"
|
||||
|
||||
|
@ -41,6 +41,7 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
|
|||
union avp_value val;
|
||||
|
||||
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
c_uint8_t opc[HSS_KEY_LEN];
|
||||
c_uint8_t sqn[HSS_SQN_LEN];
|
||||
c_uint8_t autn[AUTN_LEN];
|
||||
c_uint8_t ik[HSS_KEY_LEN];
|
||||
|
@ -51,7 +52,6 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
|
|||
size_t xres_len = 8;
|
||||
|
||||
hss_db_auth_info_t auth_info;
|
||||
c_uint8_t opc[HSS_KEY_LEN];
|
||||
c_uint8_t zero[RAND_LEN];
|
||||
status_t rv;
|
||||
|
||||
|
@ -190,8 +190,10 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
struct avp_hdr *hdr;
|
||||
union avp_value val;
|
||||
|
||||
hss_ue_t *ue = NULL;
|
||||
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
|
||||
status_t rv;
|
||||
hss_db_subscription_data_t subscription_data;
|
||||
|
||||
d_assert(msg, return EINVAL,);
|
||||
|
||||
|
@ -206,10 +208,11 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
|
||||
memcpy(imsi_bcd, (char*)hdr->avp_value->os.data, hdr->avp_value->os.len);
|
||||
imsi_bcd[hdr->avp_value->os.len] = 0;
|
||||
ue = hss_ue_find_by_imsi_bcd(imsi_bcd);
|
||||
if (!ue)
|
||||
|
||||
rv = hss_db_subscription_data(imsi_bcd, &subscription_data);
|
||||
if (rv != CORE_OK)
|
||||
{
|
||||
d_warn("Cannot find IMSI:%s", imsi_bcd);
|
||||
d_error("Cannot get Subscription-Data for IMSI:'%s'", imsi_bcd);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -218,8 +221,12 @@ static int hss_ulr_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,
|
||||
{
|
||||
#if 0 // TODO : check visited_plmn_id
|
||||
memcpy(visited_plmn_id,
|
||||
hdr->avp_value->os.data, hdr->avp_value->os.len);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */
|
||||
d_assert(fd_msg_rescode_set(ans, "DIAMETER_SUCCESS", NULL, NULL, 1) == 0,
|
||||
|
@ -255,18 +262,18 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
goto out,);
|
||||
|
||||
d_assert(fd_msg_avp_new(s6a_msisdn, 0, &avp_msisdn) == 0, goto out,);
|
||||
core_bcd_to_buffer(ue->imsi_bcd, msisdn, &msisdn_len);
|
||||
core_bcd_to_buffer(imsi_bcd, msisdn, &msisdn_len);
|
||||
val.os.data = msisdn;
|
||||
val.os.len = msisdn_len;
|
||||
d_assert(fd_msg_avp_setvalue(avp_msisdn, &val) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avp_msisdn) == 0,
|
||||
goto out,);
|
||||
|
||||
if (ue->access_restriction_data)
|
||||
if (subscription_data.access_restriction_data)
|
||||
{
|
||||
d_assert(fd_msg_avp_new(s6a_access_restriction_data, 0,
|
||||
&avp_access_restriction_data) == 0, goto out,);
|
||||
val.i32 = ue->access_restriction_data;
|
||||
val.i32 = subscription_data.access_restriction_data;
|
||||
d_assert(fd_msg_avp_setvalue(
|
||||
avp_access_restriction_data, &val) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD,
|
||||
|
@ -275,7 +282,7 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
|
||||
d_assert(fd_msg_avp_new(s6a_subscriber_status, 0,
|
||||
&avp_subscriber_status) == 0, goto out,);
|
||||
val.i32 = ue->subscriber_status;
|
||||
val.i32 = subscription_data.subscriber_status;
|
||||
d_assert(fd_msg_avp_setvalue(avp_subscriber_status, &val) == 0,
|
||||
goto out,);
|
||||
d_assert(fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD,
|
||||
|
@ -283,7 +290,7 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
|
||||
d_assert(fd_msg_avp_new(s6a_network_access_mode, 0,
|
||||
&avp_network_access_mode) == 0, goto out,);
|
||||
val.i32 = ue->network_access_mode;
|
||||
val.i32 = subscription_data.network_access_mode;
|
||||
d_assert(fd_msg_avp_setvalue(avp_network_access_mode, &val) == 0,
|
||||
goto out,);
|
||||
d_assert(fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD,
|
||||
|
@ -293,14 +300,14 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
d_assert(fd_msg_avp_new(s6a_ambr, 0, &avp_ambr) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_new(s6a_max_bandwidth_ul, 0,
|
||||
&avp_max_bandwidth_ul) == 0, goto out,);
|
||||
val.i32 = ue->max_bandwidth_ul * 1024; /* bits per second */
|
||||
val.i32 = subscription_data.max_bandwidth_ul * 1024; /* bits per second */
|
||||
d_assert(fd_msg_avp_setvalue(avp_max_bandwidth_ul, &val) == 0,
|
||||
goto out,);
|
||||
d_assert(fd_msg_avp_add(avp_ambr, MSG_BRW_LAST_CHILD,
|
||||
avp_max_bandwidth_ul) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_new(s6a_max_bandwidth_dl, 0,
|
||||
&avp_max_bandwidth_dl) == 0, goto out,);
|
||||
val.i32 = ue->max_bandwidth_dl * 1024; /* bitsper second */
|
||||
val.i32 = subscription_data.max_bandwidth_dl * 1024; /* bitsper second */
|
||||
d_assert(fd_msg_avp_setvalue(avp_max_bandwidth_dl, &val) == 0,
|
||||
goto out,);
|
||||
d_assert(fd_msg_avp_add(avp_ambr, MSG_BRW_LAST_CHILD,
|
||||
|
@ -308,7 +315,7 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
d_assert(fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avp_ambr) == 0,
|
||||
goto out,);
|
||||
|
||||
if (ue->num_of_pdn && ue->pdn[0])
|
||||
if (subscription_data.num_of_pdn)
|
||||
{
|
||||
/* Set the APN Configuration Profile */
|
||||
struct avp *apn_configuration_profile;
|
||||
|
@ -319,7 +326,7 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
|
||||
d_assert(fd_msg_avp_new(s6a_context_identifier, 0,
|
||||
&context_identifier) == 0, goto out,);
|
||||
val.i32 = ue->pdn[0]->id;
|
||||
val.i32 = 0; /* FIXME : default PDN Context Identifier */
|
||||
d_assert(fd_msg_avp_setvalue(context_identifier, &val) == 0,
|
||||
goto out,);
|
||||
d_assert(fd_msg_avp_add(apn_configuration_profile,
|
||||
|
@ -333,7 +340,7 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
d_assert(fd_msg_avp_add(apn_configuration_profile,
|
||||
MSG_BRW_LAST_CHILD, all_apn_conf_inc_ind) == 0, goto out,);
|
||||
|
||||
for (i = 0; i < ue->num_of_pdn; i++)
|
||||
for (i = 0; i < subscription_data.num_of_pdn; i++)
|
||||
{
|
||||
/* Set the APN Configuration */
|
||||
struct avp *apn_configuration, *context_identifier;
|
||||
|
@ -342,7 +349,7 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
struct avp *allocation_retention_priority, *priority_level;
|
||||
struct avp *pre_emption_capability, *pre_emption_vulnerability;
|
||||
|
||||
pdn_t *pdn = ue->pdn[i];
|
||||
pdn_t *pdn = &subscription_data.pdn[i];
|
||||
d_assert(pdn, goto out,);
|
||||
|
||||
d_assert(fd_msg_avp_new(s6a_apn_configuration, 0,
|
||||
|
@ -456,7 +463,7 @@ static int hss_ulr_cb( struct msg **msg, struct avp *avp,
|
|||
}
|
||||
|
||||
d_assert(fd_msg_avp_new(s6a_subscribed_rau_tau_timer, 0, &avp) == 0, goto out,);
|
||||
val.i32 = ue->subscribed_rau_tau_timer * 60; /* seconds */
|
||||
val.i32 = subscription_data.subscribed_rau_tau_timer * 60; /* seconds */
|
||||
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,);
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ static void nas_sm_test1(abts_case *tc, void *data)
|
|||
"000b402000000300 000005c00100009d 000800020001001a 000a092779012320"
|
||||
"010221d9";
|
||||
char *_initial_context_setup_request =
|
||||
"00090080e4000006 00000005c0010000 9d00080002000100 42000a1806400000"
|
||||
"6006400000001800 809200003400808c 4540092000000000 000000000f800a01"
|
||||
"00090080e4000006 00000005c0010000 9d00080002000100 42000a183e800000"
|
||||
"603e800000001800 809200003400808c 4540092000000000 000000000f800a01"
|
||||
"23d8000000017527 f5a0c49902074202 49064000f1105ba0 004c5221c10509ff"
|
||||
"ffffff0908696e74 65726e657405012d 2d2d015e06000000 000404272980c223"
|
||||
"0403000004802110 0200001081060808 0808830604040404 000d040808080800"
|
||||
|
|
|
@ -25,6 +25,11 @@ const Subscriber = new Schema({
|
|||
default: 2 // Only Packet
|
||||
},
|
||||
|
||||
subscribed_rau_tau_timer: {
|
||||
$type: Number,
|
||||
default: 12 // minites
|
||||
},
|
||||
|
||||
ue_ambr: {
|
||||
max_bandwidth_ul: Number,
|
||||
max_bandwidth_dl: Number
|
||||
|
|
Loading…
Reference in New Issue