mirror of
https://github.com/open5gs/open5gs.git
synced 2025-11-03 13:33:26 +00:00
continue to implement RAR
This commit is contained in:
@@ -9,7 +9,7 @@ void gx_message_free(gx_message_t *gx_message)
|
|||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
d_assert(gx_message, return, "Null param");
|
d_assert(gx_message, return,);
|
||||||
|
|
||||||
for (i = 0; i < gx_message->num_of_pcc_rule; i++)
|
for (i = 0; i < gx_message->num_of_pcc_rule; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ status_t pcrf_db_final()
|
|||||||
return CORE_OK;
|
return CORE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t pcrf_db_pdn_data(
|
status_t pcrf_db_qos_data(
|
||||||
c_int8_t *imsi_bcd, c_int8_t *apn, gx_message_t *gx_message)
|
c_int8_t *imsi_bcd, c_int8_t *apn, gx_message_t *gx_message)
|
||||||
{
|
{
|
||||||
status_t rv = CORE_OK;
|
status_t rv = CORE_OK;
|
||||||
@@ -746,6 +746,10 @@ status_t pcrf_db_pdn_data(
|
|||||||
pcc_rule->num_of_flow = flow_index;
|
pcc_rule->num_of_flow = flow_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Charing-Rule-Name is automatically configured */
|
||||||
|
snprintf(pcc_rule->name, sizeof pcc_rule->name,
|
||||||
|
"%s%d", apn, pcc_rule_index+1);
|
||||||
|
pcc_rule->precedence = pcc_rule_index+1;
|
||||||
pcc_rule_index++;
|
pcc_rule_index++;
|
||||||
}
|
}
|
||||||
gx_message->num_of_pcc_rule = pcc_rule_index;
|
gx_message->num_of_pcc_rule = pcc_rule_index;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ CORE_DECLARE(status_t) pcrf_context_setup_trace_module(void);
|
|||||||
CORE_DECLARE(status_t) pcrf_db_init(void);
|
CORE_DECLARE(status_t) pcrf_db_init(void);
|
||||||
CORE_DECLARE(status_t) pcrf_db_final(void);
|
CORE_DECLARE(status_t) pcrf_db_final(void);
|
||||||
|
|
||||||
CORE_DECLARE(status_t) pcrf_db_pdn_data(
|
CORE_DECLARE(status_t) pcrf_db_qos_data(
|
||||||
c_int8_t *imsi_bcd, c_int8_t *apn, gx_message_t *gx_message);
|
c_int8_t *imsi_bcd, c_int8_t *apn, gx_message_t *gx_message);
|
||||||
|
|
||||||
CORE_DECLARE(status_t) pcrf_sess_set_ipv4(const void *key, c_uint8_t *sid);
|
CORE_DECLARE(status_t) pcrf_sess_set_ipv4(const void *key, c_uint8_t *sid);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ static struct disp_hdl *hdl_gx_ccr = NULL;
|
|||||||
|
|
||||||
pool_declare(pcrf_gx_sess_pool, struct sess_state, MAX_POOL_OF_DIAMETER_SESS);
|
pool_declare(pcrf_gx_sess_pool, struct sess_state, MAX_POOL_OF_DIAMETER_SESS);
|
||||||
|
|
||||||
|
static status_t encode_pcc_rule_install(struct msg *msg, pcc_rule_t *pcc_rule);
|
||||||
static void pcrf_gx_raa_cb(void *data, struct msg **msg);
|
static void pcrf_gx_raa_cb(void *data, struct msg **msg);
|
||||||
|
|
||||||
static __inline__ struct sess_state *new_state(os0_t sid)
|
static __inline__ struct sess_state *new_state(os0_t sid)
|
||||||
@@ -93,16 +94,15 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||||||
struct session *sess, void *opaque, enum disp_action *act)
|
struct session *sess, void *opaque, enum disp_action *act)
|
||||||
{
|
{
|
||||||
status_t rv;
|
status_t rv;
|
||||||
int ret = 0;
|
int ret = 0, i;
|
||||||
|
|
||||||
struct msg *ans, *qry;
|
struct msg *ans, *qry;
|
||||||
struct avp *avpch1, *avpch2, *avpch3, *avpch4;
|
struct avp *avpch1, *avpch2;
|
||||||
struct avp_hdr *hdr;
|
struct avp_hdr *hdr;
|
||||||
union avp_value val;
|
union avp_value val;
|
||||||
struct sess_state *sess_data = NULL;
|
struct sess_state *sess_data = NULL;
|
||||||
|
|
||||||
gx_message_t gx_message;
|
gx_message_t gx_message;
|
||||||
int i, j;
|
|
||||||
|
|
||||||
c_uint32_t cc_request_number = 0;
|
c_uint32_t cc_request_number = 0;
|
||||||
c_uint32_t result_code = FD_DIAMETER_MISSING_AVP;
|
c_uint32_t result_code = FD_DIAMETER_MISSING_AVP;
|
||||||
@@ -312,7 +312,8 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = pcrf_db_pdn_data(sess_data->imsi_bcd, sess_data->apn, &gx_message);
|
/* Retrieve QoS Data from Database */
|
||||||
|
rv = pcrf_db_qos_data(sess_data->imsi_bcd, sess_data->apn, &gx_message);
|
||||||
if (rv != CORE_OK)
|
if (rv != CORE_OK)
|
||||||
{
|
{
|
||||||
d_error("Cannot get data for IMSI(%s)+APN(%s)'\n",
|
d_error("Cannot get data for IMSI(%s)+APN(%s)'\n",
|
||||||
@@ -323,179 +324,14 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||||||
|
|
||||||
if (sess_data->cc_request_type != GX_CC_REQUEST_TYPE_TERMINATION_REQUEST)
|
if (sess_data->cc_request_type != GX_CC_REQUEST_TYPE_TERMINATION_REQUEST)
|
||||||
{
|
{
|
||||||
/* Set Charging-Rule-Install */
|
|
||||||
int charging_rule_install = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < gx_message.num_of_pcc_rule; i++)
|
for (i = 0; i < gx_message.num_of_pcc_rule; i++)
|
||||||
{
|
{
|
||||||
pcc_rule_t *pcc_rule = &gx_message.pcc_rule[i];
|
pcc_rule_t *pcc_rule = &gx_message.pcc_rule[i];
|
||||||
if (pcc_rule->num_of_flow)
|
if (pcc_rule->num_of_flow)
|
||||||
charging_rule_install = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (charging_rule_install)
|
|
||||||
{
|
{
|
||||||
ret = fd_msg_avp_new(gx_charging_rule_install, 0, &avp);
|
rv = encode_pcc_rule_install(ans, pcc_rule);
|
||||||
d_assert(ret == 0, return EINVAL,);
|
d_assert(rv == CORE_OK, return EINVAL,);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < gx_message.num_of_pcc_rule; i++)
|
|
||||||
{
|
|
||||||
pcc_rule_t *pcc_rule = &gx_message.pcc_rule[i];
|
|
||||||
|
|
||||||
ret = fd_msg_avp_new(gx_charging_rule_definition, 0, &avpch1);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_new(gx_charging_rule_name, 0, &avpch2);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
/* Charing-Rule-Name is automatically configured by order */
|
|
||||||
sprintf(pcc_rule->name, "%s%d", sess_data->apn, i+1);
|
|
||||||
val.os.data = (c_uint8_t *)pcc_rule->name;
|
|
||||||
val.os.len = strlen(pcc_rule->name);
|
|
||||||
ret = fd_msg_avp_setvalue(avpch2, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
for (j = 0; j < pcc_rule->num_of_flow; j++)
|
|
||||||
{
|
|
||||||
flow_t *flow = &pcc_rule->flow[j];
|
|
||||||
|
|
||||||
ret = fd_msg_avp_new(gx_flow_information, 0, &avpch2);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
ret = fd_msg_avp_new(gx_flow_direction, 0, &avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
val.i32 = flow->direction;
|
|
||||||
ret = fd_msg_avp_setvalue(avpch3, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add(avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
ret = fd_msg_avp_new(gx_flow_description, 0, &avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
val.os.data = (c_uint8_t *)flow->description;
|
|
||||||
val.os.len = strlen(flow->description);
|
|
||||||
ret = fd_msg_avp_setvalue(avpch3, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add(avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = fd_msg_avp_new(gx_flow_status, 0, &avpch2);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
val.i32 = GX_FLOW_STATUS_ENABLED;
|
|
||||||
ret = fd_msg_avp_setvalue(avpch2, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
ret = fd_msg_avp_new(gx_qos_information, 0, &avpch2);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
ret = fd_msg_avp_new(gx_qos_class_identifier, 0, &avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
val.u32 = pcc_rule->qos.qci;
|
|
||||||
ret = fd_msg_avp_setvalue (avpch3, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
ret = fd_msg_avp_new(gx_allocation_retention_priority, 0, &avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
ret = fd_msg_avp_new(gx_priority_level, 0, &avpch4);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
val.u32 = pcc_rule->qos.arp.priority_level;
|
|
||||||
ret = fd_msg_avp_setvalue (avpch4, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add (avpch3, MSG_BRW_LAST_CHILD, avpch4);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
ret = fd_msg_avp_new(gx_pre_emption_capability, 0, &avpch4);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
val.u32 = pcc_rule->qos.arp.pre_emption_capability;
|
|
||||||
ret = fd_msg_avp_setvalue (avpch4, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add (avpch3, MSG_BRW_LAST_CHILD, avpch4);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
ret = fd_msg_avp_new(gx_pre_emption_vulnerability, 0, &avpch4);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
val.u32 = pcc_rule->qos.arp.pre_emption_vulnerability;
|
|
||||||
ret = fd_msg_avp_setvalue (avpch4, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add (avpch3, MSG_BRW_LAST_CHILD, avpch4);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
if (pcc_rule->qos.mbr.uplink)
|
|
||||||
{
|
|
||||||
ret = fd_msg_avp_new(gx_max_requested_bandwidth_ul, 0, &avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
val.u32 = pcc_rule->qos.mbr.uplink;
|
|
||||||
ret = fd_msg_avp_setvalue (avpch3, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pcc_rule->qos.mbr.downlink)
|
|
||||||
{
|
|
||||||
ret = fd_msg_avp_new(gx_max_requested_bandwidth_dl, 0, &avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
val.u32 = pcc_rule->qos.mbr.downlink;
|
|
||||||
ret = fd_msg_avp_setvalue (avpch3, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pcc_rule->qos.gbr.uplink)
|
|
||||||
{
|
|
||||||
ret = fd_msg_avp_new(gx_guaranteed_bitrate_ul, 0, &avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
val.u32 = pcc_rule->qos.gbr.uplink;
|
|
||||||
ret = fd_msg_avp_setvalue (avpch3, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pcc_rule->qos.gbr.downlink)
|
|
||||||
{
|
|
||||||
ret = fd_msg_avp_new(gx_guaranteed_bitrate_dl, 0, &avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
val.u32 = pcc_rule->qos.gbr.downlink;
|
|
||||||
ret = fd_msg_avp_setvalue (avpch3, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
ret = fd_msg_avp_new(gx_precedence, 0, &avpch2);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
val.u32 = i + 1; /* Precendence is automatically configured by order */
|
|
||||||
ret = fd_msg_avp_setvalue (avpch2, &val);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
|
|
||||||
ret = fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avpch1);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (charging_rule_install)
|
|
||||||
{
|
|
||||||
ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp);
|
|
||||||
d_assert(ret == 0, return EINVAL,);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set QoS-Information */
|
/* Set QoS-Information */
|
||||||
@@ -678,7 +514,8 @@ out:
|
|||||||
status_t pcrf_gx_send_rar(
|
status_t pcrf_gx_send_rar(
|
||||||
c_uint8_t *gx_sid, c_uint8_t *rx_sid, rx_message_t *rx_message)
|
c_uint8_t *gx_sid, c_uint8_t *rx_sid, rx_message_t *rx_message)
|
||||||
{
|
{
|
||||||
int ret;
|
status_t rv;
|
||||||
|
int ret = 0, i;
|
||||||
|
|
||||||
struct msg *req = NULL;
|
struct msg *req = NULL;
|
||||||
struct avp *avp;
|
struct avp *avp;
|
||||||
@@ -691,10 +528,15 @@ status_t pcrf_gx_send_rar(
|
|||||||
int new;
|
int new;
|
||||||
size_t sidlen;
|
size_t sidlen;
|
||||||
|
|
||||||
|
gx_message_t gx_message;
|
||||||
|
|
||||||
d_assert(gx_sid, return CORE_ERROR,);
|
d_assert(gx_sid, return CORE_ERROR,);
|
||||||
d_assert(rx_sid, return CORE_ERROR,);
|
d_assert(rx_sid, return CORE_ERROR,);
|
||||||
d_assert(rx_message, return CORE_ERROR,);
|
d_assert(rx_message, return CORE_ERROR,);
|
||||||
|
|
||||||
|
/* Initialize Message */
|
||||||
|
memset(&gx_message, 0, sizeof(gx_message_t));
|
||||||
|
|
||||||
/* Set default error result code */
|
/* Set default error result code */
|
||||||
rx_message->result_code = RX_DIAMETER_TEMPORARY_NETWORK_FAILURE;
|
rx_message->result_code = RX_DIAMETER_TEMPORARY_NETWORK_FAILURE;
|
||||||
|
|
||||||
@@ -737,10 +579,39 @@ status_t pcrf_gx_send_rar(
|
|||||||
d_error("No session data");
|
d_error("No session data");
|
||||||
ret = fd_msg_free(req);
|
ret = fd_msg_free(req);
|
||||||
d_assert(ret == 0,,);
|
d_assert(ret == 0,,);
|
||||||
rx_message->result_code = RX_DIAMETER_REQUESTED_SERVICE_NOT_AUTHORIZED;
|
rx_message->result_code = FD_DIAMETER_UNKNOWN_SESSION_ID;
|
||||||
return CORE_ERROR;
|
return CORE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Retrieve QoS Data from Database */
|
||||||
|
rv = pcrf_db_qos_data(sess_data->imsi_bcd, sess_data->apn, &gx_message);
|
||||||
|
if (rv != CORE_OK)
|
||||||
|
{
|
||||||
|
d_error("Cannot get data for IMSI(%s)+APN(%s)'\n",
|
||||||
|
sess_data->imsi_bcd, sess_data->apn);
|
||||||
|
rx_message->result_code = RX_DIAMETER_REQUESTED_SERVICE_NOT_AUTHORIZED;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find PCC Rule based on QCI and Media-Type */
|
||||||
|
pcc_rule_t *pcc_rule = NULL;
|
||||||
|
for (i = 0; i < gx_message.num_of_pcc_rule; i++)
|
||||||
|
{
|
||||||
|
// pcc_rule = &gx_message.pcc_rule[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if PCC Rule is existed, encode PCC Rule */
|
||||||
|
if (pcc_rule == NULL)
|
||||||
|
{
|
||||||
|
d_error("No PCC Rule");
|
||||||
|
rx_message->result_code = RX_DIAMETER_REQUESTED_SERVICE_NOT_AUTHORIZED;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Encode PCC Rule */
|
||||||
|
rv = encode_pcc_rule_install(req, pcc_rule);
|
||||||
|
d_assert(rv == CORE_OK, return EINVAL,);
|
||||||
|
|
||||||
/* Save Rx Session-Id */
|
/* Save Rx Session-Id */
|
||||||
if (sess_data->rx_sid)
|
if (sess_data->rx_sid)
|
||||||
CORE_FREE(sess_data->rx_sid);
|
CORE_FREE(sess_data->rx_sid);
|
||||||
@@ -815,7 +686,18 @@ status_t pcrf_gx_send_rar(
|
|||||||
/* Set no error */
|
/* Set no error */
|
||||||
rx_message->result_code = ER_DIAMETER_SUCCESS;
|
rx_message->result_code = ER_DIAMETER_SUCCESS;
|
||||||
|
|
||||||
|
gx_message_free(&gx_message);
|
||||||
|
|
||||||
return CORE_OK;
|
return CORE_OK;
|
||||||
|
|
||||||
|
out:
|
||||||
|
/* Store this value in the session */
|
||||||
|
ret = fd_sess_state_store(pcrf_gx_reg, session, &sess_data);
|
||||||
|
d_assert(sess_data == NULL,,);
|
||||||
|
|
||||||
|
gx_message_free(&gx_message);
|
||||||
|
|
||||||
|
return CORE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pcrf_gx_raa_cb(void *data, struct msg **msg)
|
static void pcrf_gx_raa_cb(void *data, struct msg **msg)
|
||||||
@@ -1019,3 +901,167 @@ void pcrf_gx_final(void)
|
|||||||
|
|
||||||
pool_final(&pcrf_gx_sess_pool);
|
pool_final(&pcrf_gx_sess_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static status_t encode_pcc_rule_install(struct msg *msg, pcc_rule_t *pcc_rule)
|
||||||
|
{
|
||||||
|
struct avp *avp, *avpch1, *avpch2, *avpch3, *avpch4;
|
||||||
|
union avp_value val;
|
||||||
|
int ret = 0, i;
|
||||||
|
|
||||||
|
d_assert(msg, return CORE_ERROR,);
|
||||||
|
d_assert(pcc_rule, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_charging_rule_install, 0, &avp);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_charging_rule_definition, 0, &avpch1);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_new(gx_charging_rule_name, 0, &avpch2);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.os.data = (c_uint8_t *)pcc_rule->name;
|
||||||
|
val.os.len = strlen(pcc_rule->name);
|
||||||
|
ret = fd_msg_avp_setvalue(avpch2, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
for (i = 0; i < pcc_rule->num_of_flow; i++)
|
||||||
|
{
|
||||||
|
flow_t *flow = &pcc_rule->flow[i];
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_flow_information, 0, &avpch2);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_flow_direction, 0, &avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.i32 = flow->direction;
|
||||||
|
ret = fd_msg_avp_setvalue(avpch3, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add(avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_flow_description, 0, &avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.os.data = (c_uint8_t *)flow->description;
|
||||||
|
val.os.len = strlen(flow->description);
|
||||||
|
ret = fd_msg_avp_setvalue(avpch3, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add(avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_flow_status, 0, &avpch2);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.i32 = GX_FLOW_STATUS_ENABLED;
|
||||||
|
ret = fd_msg_avp_setvalue(avpch2, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_qos_information, 0, &avpch2);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_qos_class_identifier, 0, &avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.u32 = pcc_rule->qos.qci;
|
||||||
|
ret = fd_msg_avp_setvalue (avpch3, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_allocation_retention_priority, 0, &avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_priority_level, 0, &avpch4);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.u32 = pcc_rule->qos.arp.priority_level;
|
||||||
|
ret = fd_msg_avp_setvalue (avpch4, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add (avpch3, MSG_BRW_LAST_CHILD, avpch4);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_pre_emption_capability, 0, &avpch4);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.u32 = pcc_rule->qos.arp.pre_emption_capability;
|
||||||
|
ret = fd_msg_avp_setvalue (avpch4, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add (avpch3, MSG_BRW_LAST_CHILD, avpch4);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_pre_emption_vulnerability, 0, &avpch4);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.u32 = pcc_rule->qos.arp.pre_emption_vulnerability;
|
||||||
|
ret = fd_msg_avp_setvalue (avpch4, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add (avpch3, MSG_BRW_LAST_CHILD, avpch4);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
if (pcc_rule->qos.mbr.uplink)
|
||||||
|
{
|
||||||
|
ret = fd_msg_avp_new(gx_max_requested_bandwidth_ul, 0, &avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.u32 = pcc_rule->qos.mbr.uplink;
|
||||||
|
ret = fd_msg_avp_setvalue (avpch3, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pcc_rule->qos.mbr.downlink)
|
||||||
|
{
|
||||||
|
ret = fd_msg_avp_new(gx_max_requested_bandwidth_dl, 0, &avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.u32 = pcc_rule->qos.mbr.downlink;
|
||||||
|
ret = fd_msg_avp_setvalue (avpch3, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pcc_rule->qos.gbr.uplink)
|
||||||
|
{
|
||||||
|
ret = fd_msg_avp_new(gx_guaranteed_bitrate_ul, 0, &avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.u32 = pcc_rule->qos.gbr.uplink;
|
||||||
|
ret = fd_msg_avp_setvalue (avpch3, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pcc_rule->qos.gbr.downlink)
|
||||||
|
{
|
||||||
|
ret = fd_msg_avp_new(gx_guaranteed_bitrate_dl, 0, &avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.u32 = pcc_rule->qos.gbr.downlink;
|
||||||
|
ret = fd_msg_avp_setvalue (avpch3, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_new(gx_precedence, 0, &avpch2);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
val.u32 = pcc_rule->precedence;
|
||||||
|
ret = fd_msg_avp_setvalue (avpch2, &val);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avpch1);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
ret = fd_msg_avp_add(msg, MSG_BRW_LAST_CHILD, avp);
|
||||||
|
d_assert(ret == 0, return CORE_ERROR,);
|
||||||
|
|
||||||
|
return CORE_OK;
|
||||||
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
|
|||||||
struct avp *avpch1, *avpch2, *avpch3;
|
struct avp *avpch1, *avpch2, *avpch3;
|
||||||
struct avp_hdr *hdr;
|
struct avp_hdr *hdr;
|
||||||
union avp_value val;
|
union avp_value val;
|
||||||
struct sess_state *sess_data = NULL;
|
struct sess_state *sess_data = NULL, *svg = NULL;
|
||||||
size_t sidlen;
|
size_t sidlen;
|
||||||
|
|
||||||
rx_message_t rx_message;
|
rx_message_t rx_message;
|
||||||
@@ -369,6 +369,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Store this value in the session */
|
/* Store this value in the session */
|
||||||
|
svg = sess_data;
|
||||||
ret = fd_sess_state_store(pcrf_rx_reg, sess, &sess_data);
|
ret = fd_sess_state_store(pcrf_rx_reg, sess, &sess_data);
|
||||||
d_assert(ret == 0,,);
|
d_assert(ret == 0,,);
|
||||||
d_assert(sess_data == NULL,,);
|
d_assert(sess_data == NULL,,);
|
||||||
@@ -376,7 +377,7 @@ out:
|
|||||||
ret = fd_msg_send(msg, NULL, NULL);
|
ret = fd_msg_send(msg, NULL, NULL);
|
||||||
d_assert(ret == 0,,);
|
d_assert(ret == 0,,);
|
||||||
|
|
||||||
state_cleanup(sess_data, NULL, NULL);
|
state_cleanup(svg, NULL, NULL);
|
||||||
rx_message_free(&rx_message);
|
rx_message_free(&rx_message);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -236,8 +236,9 @@ static void volte_test1(abts_case *tc, void *data)
|
|||||||
core_sleep(time_from_msec(300));
|
core_sleep(time_from_msec(300));
|
||||||
|
|
||||||
/* Send AA-Request */
|
/* Send AA-Request */
|
||||||
pcscf_rx_send_aar("45.45.0.2");
|
pcscf_rx_send_aar("45.45.0.3");
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* Send PDN disconnectivity request */
|
/* Send PDN disconnectivity request */
|
||||||
rv = tests1ap_build_pdn_disconnectivity_request(&sendbuf, msgindex);
|
rv = tests1ap_build_pdn_disconnectivity_request(&sendbuf, msgindex);
|
||||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||||
@@ -276,6 +277,7 @@ static void volte_test1(abts_case *tc, void *data)
|
|||||||
rv = tests1ap_enb_read(sock, recvbuf);
|
rv = tests1ap_enb_read(sock, recvbuf);
|
||||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||||
pkbuf_free(recvbuf);
|
pkbuf_free(recvbuf);
|
||||||
|
#endif
|
||||||
|
|
||||||
core_sleep(time_from_msec(1000));
|
core_sleep(time_from_msec(1000));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user