PGW/PCRF diameter code refine
This commit is contained in:
parent
60b82c75e6
commit
b25082cb06
|
@ -7,15 +7,19 @@
|
|||
#include "pcrf_context.h"
|
||||
#include "pcrf_fd_path.h"
|
||||
|
||||
int pcrf_fd_init(void)
|
||||
status_t pcrf_fd_init(void)
|
||||
{
|
||||
CHECK_FCT( fd_init(FD_MODE_CLIENT|FD_MODE_SERVER,
|
||||
pcrf_self()->fd_conf_path, pcrf_self()->fd_config) );
|
||||
status_t rv;
|
||||
int ret = fd_init(FD_MODE_CLIENT|FD_MODE_SERVER,
|
||||
pcrf_self()->fd_conf_path, pcrf_self()->fd_config);
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
CHECK_FCT( pcrf_gx_init() );
|
||||
CHECK_FCT( pcrf_rx_init() );
|
||||
rv = pcrf_gx_init();
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
rv = pcrf_rx_init();
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
|
||||
return 0;
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
void pcrf_fd_final(void)
|
||||
|
|
|
@ -9,12 +9,12 @@ extern "C" {
|
|||
|
||||
struct sess_state;
|
||||
|
||||
CORE_DECLARE(int) pcrf_fd_init(void);
|
||||
CORE_DECLARE(status_t) pcrf_fd_init(void);
|
||||
CORE_DECLARE(void) pcrf_fd_final(void);
|
||||
|
||||
CORE_DECLARE(int) pcrf_gx_init(void);
|
||||
CORE_DECLARE(status_t) pcrf_gx_init(void);
|
||||
CORE_DECLARE(void) pcrf_gx_final(void);
|
||||
CORE_DECLARE(int) pcrf_rx_init(void);
|
||||
CORE_DECLARE(status_t) pcrf_rx_init(void);
|
||||
CORE_DECLARE(void) pcrf_rx_final(void);
|
||||
|
||||
CORE_DECLARE(status_t) pcrf_sess_gx_associate_rx(
|
||||
|
|
|
@ -22,6 +22,8 @@ ED3(c_uint8_t ipv4:1;,
|
|||
c_uint8_t reserved:6;)
|
||||
c_uint32_t addr; /* Framed-IPv4-Address */
|
||||
c_uint8_t addr6[IPV6_LEN]; /* Framed-IPv6-Prefix */
|
||||
|
||||
struct timespec ts; /* Time of sending the message */
|
||||
};
|
||||
|
||||
static struct session_handler *pcrf_gx_reg = NULL;
|
||||
|
@ -30,6 +32,8 @@ static struct disp_hdl *hdl_gx_ccr = NULL;
|
|||
|
||||
pool_declare(pcrf_gx_sess_pool, struct sess_state, MAX_POOL_OF_DIAMETER_SESS);
|
||||
|
||||
static void pcrf_gx_raa_cb(void *data, struct msg **msg);
|
||||
|
||||
static __inline__ struct sess_state *new_state(os0_t sid)
|
||||
{
|
||||
struct sess_state *new = NULL;
|
||||
|
@ -73,13 +77,15 @@ static int pcrf_gx_fb_cb(struct msg **msg, struct avp *avp,
|
|||
static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
||||
struct session *sess, void *opaque, enum disp_action *act)
|
||||
{
|
||||
status_t rv;
|
||||
int ret = 0;
|
||||
|
||||
struct msg *ans, *qry;
|
||||
struct avp *avpch1, *avpch2, *avpch3, *avpch4;
|
||||
struct avp_hdr *hdr;
|
||||
union avp_value val;
|
||||
struct sess_state *sess_data = NULL;
|
||||
|
||||
status_t rv;
|
||||
gx_cca_message_t cca_message;
|
||||
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
c_int8_t apn[MAX_APN_LEN+1];
|
||||
|
@ -90,14 +96,16 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
|
||||
d_assert(msg, return EINVAL,);
|
||||
|
||||
d_assert( fd_sess_state_retrieve(pcrf_gx_reg, sess, &sess_data) == 0,
|
||||
return EINVAL,);
|
||||
ret = fd_sess_state_retrieve(pcrf_gx_reg, sess, &sess_data);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
if (!sess_data)
|
||||
{
|
||||
os0_t sid;
|
||||
size_t sidlen;
|
||||
|
||||
d_assert( fd_sess_getsid(sess, &sid, &sidlen) == 0, return EINVAL,);
|
||||
ret = fd_sess_getsid(sess, &sid, &sidlen);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
sess_data = new_state(sid);
|
||||
d_assert(sess_data, return EINVAL,);
|
||||
|
@ -108,14 +116,17 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
|
||||
/* Create answer header */
|
||||
qry = *msg;
|
||||
CHECK_FCT( fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0) );
|
||||
ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ans = *msg;
|
||||
|
||||
/* Get CC-Request-Type */
|
||||
CHECK_FCT( fd_msg_search_avp(qry, gx_cc_request_type, &avp) );
|
||||
ret = fd_msg_search_avp(qry, gx_cc_request_type, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
if (avp)
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_hdr(avp, &hdr) );
|
||||
ret = fd_msg_avp_hdr(avp, &hdr);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
sess_data->cc_request_type = hdr->avp_value->i32;
|
||||
}
|
||||
else
|
||||
|
@ -125,18 +136,23 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
}
|
||||
|
||||
/* Get CC-Request-Number */
|
||||
CHECK_FCT( fd_msg_search_avp(qry, gx_cc_request_number, &avp) );
|
||||
ret = fd_msg_search_avp(qry, gx_cc_request_number, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
if (avp)
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_hdr(avp, &hdr) );
|
||||
ret = fd_msg_avp_hdr(avp, &hdr);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
cc_request_number = hdr->avp_value->i32;
|
||||
}
|
||||
|
||||
/* Get Framed-IP-Address */
|
||||
CHECK_FCT( fd_msg_search_avp(qry, gx_framed_ip_address, &avp) );
|
||||
ret = fd_msg_search_avp(qry, gx_framed_ip_address, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
if (avp)
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_hdr(avp, &hdr) );
|
||||
ret = fd_msg_avp_hdr(avp, &hdr);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
memcpy(&sess_data->addr, hdr->avp_value->os.data,
|
||||
sizeof sess_data->addr);
|
||||
pcrf_sess_set_ipv4(&sess_data->addr, sess_data->gx_sid);
|
||||
|
@ -144,15 +160,18 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
}
|
||||
|
||||
/* Get Framed-IPv6-Prefix */
|
||||
CHECK_FCT( fd_msg_search_avp(qry, gx_framed_ipv6_prefix, &avp) );
|
||||
ret = fd_msg_search_avp(qry, gx_framed_ipv6_prefix, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
if (avp)
|
||||
{
|
||||
paa_t *paa = NULL;
|
||||
|
||||
CHECK_FCT( fd_msg_avp_hdr(avp, &hdr) );
|
||||
ret = fd_msg_avp_hdr(avp, &hdr);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
paa = (paa_t *)hdr->avp_value->os.data;
|
||||
d_assert(paa, goto out,);
|
||||
d_assert(paa->len == IPV6_LEN * 8 /* 128bit */, goto out,
|
||||
d_assert(paa, return EINVAL,);
|
||||
d_assert(paa->len == IPV6_LEN * 8 /* 128bit */, return EINVAL,
|
||||
"Invalid Framed-IPv6-Prefix Length:%d", paa->len);
|
||||
memcpy(sess_data->addr6, paa->addr6, sizeof sess_data->addr6);
|
||||
pcrf_sess_set_ipv6(sess_data->addr6, sess_data->gx_sid);
|
||||
|
@ -160,41 +179,58 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
}
|
||||
|
||||
/* Set the Auth-Application-Id AVP */
|
||||
CHECK_FCT_DO( fd_msg_avp_new(fd_auth_application_id, 0, &avp), goto out );
|
||||
ret = fd_msg_avp_new(fd_auth_application_id, 0, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.i32 = GX_APPLICATION_ID;
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue(avp, &val), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp), goto out );
|
||||
ret = fd_msg_avp_setvalue(avp, &val);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
/* Set CC-Request-Type */
|
||||
CHECK_FCT_DO( fd_msg_avp_new(gx_cc_request_type, 0, &avp), goto out );
|
||||
ret = fd_msg_avp_new(gx_cc_request_type, 0, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.i32 = sess_data->cc_request_type;
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue(avp, &val), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp), goto out );
|
||||
ret = fd_msg_avp_setvalue(avp, &val);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
/* Set CC-Request-Number */
|
||||
CHECK_FCT_DO( fd_msg_avp_new(gx_cc_request_number, 0, &avp), goto out );
|
||||
ret = fd_msg_avp_new(gx_cc_request_number, 0, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.i32 = cc_request_number;
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue(avp, &val), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp), goto out );
|
||||
ret = fd_msg_avp_setvalue(avp, &val);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
/* Get IMSI + APN */
|
||||
CHECK_FCT( fd_msg_search_avp(qry, gx_subscription_id, &avp) );
|
||||
CHECK_FCT( fd_msg_avp_hdr(avp, &hdr) );
|
||||
CHECK_FCT( fd_avp_search_avp(avp, gx_subscription_id_type, &avpch1) );
|
||||
CHECK_FCT( fd_msg_avp_hdr(avpch1, &hdr) );
|
||||
ret = fd_msg_search_avp(qry, gx_subscription_id, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_hdr(avp, &hdr);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_avp_search_avp(avp, gx_subscription_id_type, &avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_hdr(avpch1, &hdr);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
if (hdr->avp_value->i32 != GX_SUBSCRIPTION_ID_TYPE_END_USER_IMSI)
|
||||
{
|
||||
d_error("Not implemented Subscription-Id-Type(%d)",
|
||||
hdr->avp_value->i32);
|
||||
goto out;
|
||||
}
|
||||
CHECK_FCT( fd_avp_search_avp(avp, gx_subscription_id_data, &avpch1) );
|
||||
CHECK_FCT( fd_msg_avp_hdr(avpch1, &hdr) );
|
||||
ret = fd_avp_search_avp(avp, gx_subscription_id_data, &avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_hdr(avpch1, &hdr);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
core_cpystrn(imsi_bcd, (char*)hdr->avp_value->os.data,
|
||||
c_min(hdr->avp_value->os.len, MAX_IMSI_BCD_LEN)+1);
|
||||
|
||||
CHECK_FCT( fd_msg_search_avp(qry, gx_called_station_id, &avp) );
|
||||
CHECK_FCT( fd_msg_avp_hdr(avp, &hdr) );
|
||||
ret = fd_msg_search_avp(qry, gx_called_station_id, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_hdr(avp, &hdr);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
core_cpystrn(apn, (char*)hdr->avp_value->os.data,
|
||||
c_min(hdr->avp_value->os.len, MAX_APN_LEN)+1);
|
||||
|
||||
|
@ -209,209 +245,282 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
{
|
||||
/* Set Charging-Rule-Install */
|
||||
if (cca_message.num_of_pcc_rule)
|
||||
CHECK_FCT( fd_msg_avp_new(gx_charging_rule_install, 0, &avp) );
|
||||
{
|
||||
ret = fd_msg_avp_new(gx_charging_rule_install, 0, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
}
|
||||
|
||||
for (i = 0; i < cca_message.num_of_pcc_rule; i++)
|
||||
{
|
||||
pcc_rule_t *pcc_rule = &cca_message.pcc_rule[i];
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_charging_rule_definition, 0,
|
||||
&avpch1) );
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_charging_rule_name, 0, &avpch2) );
|
||||
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", apn, i+1);
|
||||
val.os.data = (c_uint8_t *)pcc_rule->name;
|
||||
val.os.len = strlen(pcc_rule->name);
|
||||
CHECK_FCT( fd_msg_avp_setvalue(avpch2, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2) );
|
||||
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];
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_flow_information, 0, &avpch2) );
|
||||
ret = fd_msg_avp_new(gx_flow_information, 0, &avpch2);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_flow_direction, 0, &avpch3) );
|
||||
ret = fd_msg_avp_new(gx_flow_direction, 0, &avpch3);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.i32 = flow->direction;
|
||||
CHECK_FCT( fd_msg_avp_setvalue(avpch3, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add(avpch2, MSG_BRW_LAST_CHILD, avpch3) );
|
||||
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,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_flow_description, 0, &avpch3) );
|
||||
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);
|
||||
CHECK_FCT( fd_msg_avp_setvalue(avpch3, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add(avpch2, MSG_BRW_LAST_CHILD, avpch3) );
|
||||
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,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2) );
|
||||
ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
}
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_flow_status, 0, &avpch2) );
|
||||
ret = fd_msg_avp_new(gx_flow_status, 0, &avpch2);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.i32 = GX_FLOW_STATUS_ENABLED;
|
||||
CHECK_FCT( fd_msg_avp_setvalue(avpch2, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2) );
|
||||
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,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_qos_information, 0, &avpch2) )
|
||||
ret = fd_msg_avp_new(gx_qos_information, 0, &avpch2);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_qos_class_identifier, 0, &avpch3) );
|
||||
ret = fd_msg_avp_new(gx_qos_class_identifier, 0, &avpch3);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.u32 = pcc_rule->qos.qci;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch3, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3) );
|
||||
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,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_allocation_retention_priority, 0,
|
||||
&avpch3) );
|
||||
ret = fd_msg_avp_new(gx_allocation_retention_priority, 0, &avpch3);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_priority_level, 0, &avpch4) );
|
||||
ret = fd_msg_avp_new(gx_priority_level, 0, &avpch4);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.u32 = pcc_rule->qos.arp.priority_level;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch4, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add (avpch3, MSG_BRW_LAST_CHILD, avpch4) );
|
||||
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,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_pre_emption_capability, 0, &avpch4) );
|
||||
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;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch4, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add (avpch3, MSG_BRW_LAST_CHILD, avpch4) );
|
||||
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,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_pre_emption_vulnerability, 0,
|
||||
&avpch4) );
|
||||
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;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch4, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add (avpch3, MSG_BRW_LAST_CHILD, avpch4) );
|
||||
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,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3) );
|
||||
ret = fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
if (pcc_rule->qos.mbr.uplink)
|
||||
{
|
||||
CHECK_FCT(
|
||||
fd_msg_avp_new(gx_max_requested_bandwidth_ul, 0, &avpch3) );
|
||||
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;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch3, &val) );
|
||||
CHECK_FCT(
|
||||
fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3) );
|
||||
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)
|
||||
{
|
||||
CHECK_FCT(
|
||||
fd_msg_avp_new(gx_max_requested_bandwidth_dl, 0, &avpch3) );
|
||||
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;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch3, &val) );
|
||||
CHECK_FCT(
|
||||
fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3) );
|
||||
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)
|
||||
{
|
||||
CHECK_FCT(
|
||||
fd_msg_avp_new(gx_guaranteed_bitrate_ul, 0, &avpch3) );
|
||||
ret = fd_msg_avp_new(gx_guaranteed_bitrate_ul, 0, &avpch3);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.u32 = pcc_rule->qos.gbr.uplink;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch3, &val) );
|
||||
CHECK_FCT(
|
||||
fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3) );
|
||||
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)
|
||||
{
|
||||
CHECK_FCT(
|
||||
fd_msg_avp_new(gx_guaranteed_bitrate_dl, 0, &avpch3) );
|
||||
ret = fd_msg_avp_new(gx_guaranteed_bitrate_dl, 0, &avpch3);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.u32 = pcc_rule->qos.gbr.downlink;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch3, &val) );
|
||||
CHECK_FCT(
|
||||
fd_msg_avp_add (avpch2, MSG_BRW_LAST_CHILD, avpch3) );
|
||||
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,);
|
||||
}
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2) );
|
||||
ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_precedence, 0, &avpch2) )
|
||||
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 */
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch2, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2) );
|
||||
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,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avpch1) );
|
||||
ret = fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
}
|
||||
|
||||
if (cca_message.num_of_pcc_rule)
|
||||
CHECK_FCT( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp) );
|
||||
{
|
||||
ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
}
|
||||
|
||||
/* Set QoS-Information */
|
||||
if (cca_message.pdn.ambr.downlink || cca_message.pdn.ambr.uplink)
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new(gx_qos_information, 0, &avp) );
|
||||
ret = fd_msg_avp_new(gx_qos_information, 0, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
if (cca_message.pdn.ambr.uplink)
|
||||
{
|
||||
CHECK_FCT(
|
||||
fd_msg_avp_new(gx_apn_aggregate_max_bitrate_ul, 0, &avpch1) );
|
||||
ret = fd_msg_avp_new(gx_apn_aggregate_max_bitrate_ul, 0,
|
||||
&avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.u32 = cca_message.pdn.ambr.uplink;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch1, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1) );
|
||||
ret = fd_msg_avp_setvalue (avpch1, &val);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
}
|
||||
|
||||
if (cca_message.pdn.ambr.downlink)
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new(gx_apn_aggregate_max_bitrate_dl, 0,
|
||||
&avpch1) );
|
||||
ret = fd_msg_avp_new(gx_apn_aggregate_max_bitrate_dl, 0,
|
||||
&avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.u32 = cca_message.pdn.ambr.downlink;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch1, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1) );
|
||||
ret = fd_msg_avp_setvalue (avpch1, &val);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
}
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp) );
|
||||
ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
}
|
||||
|
||||
/* Set Default-EPS-Bearer-QoS */
|
||||
CHECK_FCT( fd_msg_avp_new(gx_default_eps_bearer_qos, 0, &avp) );
|
||||
ret = fd_msg_avp_new(gx_default_eps_bearer_qos, 0, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_qos_class_identifier, 0, &avpch1) );
|
||||
ret = fd_msg_avp_new(gx_qos_class_identifier, 0, &avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.u32 = cca_message.pdn.qos.qci;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch1, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1) );
|
||||
ret = fd_msg_avp_setvalue (avpch1, &val);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
CHECK_FCT(
|
||||
fd_msg_avp_new(gx_allocation_retention_priority, 0, &avpch1) );
|
||||
ret = fd_msg_avp_new(gx_allocation_retention_priority, 0, &avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_priority_level, 0, &avpch2) );
|
||||
ret = fd_msg_avp_new(gx_priority_level, 0, &avpch2);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.u32 = cca_message.pdn.qos.arp.priority_level;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch2, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add (avpch1, MSG_BRW_LAST_CHILD, avpch2) );
|
||||
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,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_pre_emption_capability, 0, &avpch2) );
|
||||
ret = fd_msg_avp_new(gx_pre_emption_capability, 0, &avpch2);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.u32 = cca_message.pdn.qos.arp.pre_emption_capability;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch2, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add (avpch1, MSG_BRW_LAST_CHILD, avpch2) );
|
||||
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,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_pre_emption_vulnerability, 0, &avpch2) );
|
||||
ret = fd_msg_avp_new(gx_pre_emption_vulnerability, 0, &avpch2);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.u32 = cca_message.pdn.qos.arp.pre_emption_vulnerability;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch2, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add (avpch1, MSG_BRW_LAST_CHILD, avpch2) );
|
||||
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,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1) );
|
||||
ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp) );
|
||||
ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
/* Set Supported Features */
|
||||
CHECK_FCT( fd_msg_avp_new(gx_supported_features, 0, &avp) );
|
||||
ret = fd_msg_avp_new(gx_supported_features, 0, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_feature_list_id, 0, &avpch1) );
|
||||
ret = fd_msg_avp_new(gx_feature_list_id, 0, &avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.i32 = 1;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch1, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1) );
|
||||
ret = fd_msg_avp_setvalue (avpch1, &val);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_new(gx_feature_list, 0, &avpch1) );
|
||||
ret = fd_msg_avp_new(gx_feature_list, 0, &avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.u32 = 0x0000000b;
|
||||
CHECK_FCT( fd_msg_avp_setvalue (avpch1, &val) );
|
||||
CHECK_FCT( fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1) );
|
||||
ret = fd_msg_avp_setvalue (avpch1, &val);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp) );
|
||||
ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
}
|
||||
|
||||
/* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */
|
||||
CHECK_FCT( fd_msg_rescode_set(ans, "DIAMETER_SUCCESS", NULL, NULL, 1) );
|
||||
ret = fd_msg_rescode_set(ans, "DIAMETER_SUCCESS", NULL, NULL, 1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
if (sess_data->cc_request_type != GX_CC_REQUEST_TYPE_TERMINATION_REQUEST)
|
||||
{
|
||||
/* Store this value in the session */
|
||||
CHECK_FCT_DO( fd_sess_state_store(pcrf_gx_reg, sess, &sess_data),
|
||||
goto out );
|
||||
ret = fd_sess_state_store(pcrf_gx_reg, sess, &sess_data);
|
||||
d_assert(ret == 0,,);
|
||||
d_assert(sess_data == NULL,,);
|
||||
}
|
||||
else
|
||||
|
@ -420,68 +529,189 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
}
|
||||
|
||||
/* Send the answer */
|
||||
CHECK_FCT( fd_msg_send(msg, NULL, NULL) );
|
||||
ret = fd_msg_send(msg, NULL, NULL);
|
||||
d_assert(ret == 0,,);
|
||||
|
||||
/* Add this value to the stats */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&fd_logger_self()->stats_lock), );
|
||||
d_assert(pthread_mutex_lock(&fd_logger_self()->stats_lock) == 0,,);
|
||||
fd_logger_self()->stats.nb_echoed++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&fd_logger_self()->stats_lock), );
|
||||
d_assert(pthread_mutex_unlock(&fd_logger_self()->stats_lock) ==0,, );
|
||||
|
||||
gx_cca_message_free(&cca_message);
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
/* Set the Result-Code */
|
||||
if (result_code == GX_DIAMETER_ERROR_USER_UNKNOWN)
|
||||
{
|
||||
CHECK_FCT( fd_msg_rescode_set(ans,
|
||||
"DIAMETER_ERROR_USER_UNKNOWN", NULL, NULL, 1) );
|
||||
ret = fd_msg_rescode_set(ans,
|
||||
"DIAMETER_ERROR_USER_UNKNOWN", NULL, NULL, 1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK_FCT( fd_message_experimental_rescode_set(ans, result_code) );
|
||||
ret = fd_message_experimental_rescode_set(ans, result_code);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
}
|
||||
|
||||
CHECK_FCT( fd_msg_send(msg, NULL, NULL) );
|
||||
if (sess_data->cc_request_type != GX_CC_REQUEST_TYPE_TERMINATION_REQUEST)
|
||||
{
|
||||
/* Store this value in the session */
|
||||
ret = fd_sess_state_store(pcrf_gx_reg, sess, &sess_data);
|
||||
d_assert(sess_data == NULL,,);
|
||||
}
|
||||
else
|
||||
{
|
||||
state_cleanup(sess_data, NULL, NULL);
|
||||
}
|
||||
|
||||
ret = fd_msg_send(msg, NULL, NULL);
|
||||
d_assert(ret == 0,,);
|
||||
|
||||
state_cleanup(sess_data, NULL, NULL);
|
||||
gx_cca_message_free(&cca_message);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcrf_gx_init(void)
|
||||
void pcrf_gx_send_rar(c_uint8_t *gx_sid)
|
||||
{
|
||||
int ret;
|
||||
|
||||
struct msg *req = NULL;
|
||||
struct avp *avp;
|
||||
#if 0
|
||||
struct avp *avpch1, *avpch2;
|
||||
#endif
|
||||
union avp_value val;
|
||||
struct sess_state *sess_data = NULL, *svg;
|
||||
struct session *session = NULL;
|
||||
int new;
|
||||
size_t sidlen;
|
||||
|
||||
d_assert(gx_sid, return,);
|
||||
|
||||
/* Create the request */
|
||||
ret = fd_msg_new(gx_cmd_rar, MSGFL_ALLOC_ETEID, &req);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Retrieve session by Session-Id */
|
||||
sidlen = strlen((char *)gx_sid);
|
||||
ret = fd_sess_fromsid_msg((os0_t)gx_sid, sidlen, &session, &new);
|
||||
d_assert(ret == 0, return,);
|
||||
d_assert(new == 0, return,);
|
||||
|
||||
/* Add Session-Id to the message */
|
||||
ret = fd_message_session_id_set(req, (os0_t)gx_sid, sidlen);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Save the session associated with the message */
|
||||
ret = fd_msg_sess_set(req, session);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Retrieve session state in this session */
|
||||
ret = fd_sess_state_retrieve(pcrf_gx_reg, session, &sess_data);
|
||||
d_assert(ret == 0, return,);
|
||||
if (sess_data == NULL)
|
||||
{
|
||||
d_error("No session data");
|
||||
ret = fd_msg_free(req);
|
||||
d_assert(ret == 0,,);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set Origin-Host & Origin-Realm */
|
||||
ret = fd_msg_add_origin(req, 0);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Set the Destination-Realm AVP */
|
||||
ret = fd_msg_avp_new(fd_destination_realm, 0, &avp);
|
||||
d_assert(ret == 0, return,);
|
||||
val.os.data = (unsigned char *)(fd_g_config->cnf_diamrlm);
|
||||
val.os.len = strlen(fd_g_config->cnf_diamrlm);
|
||||
ret = fd_msg_avp_setvalue(avp, &val);
|
||||
d_assert(ret == 0, return,);
|
||||
ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Set the Auth-Application-Id AVP */
|
||||
ret = fd_msg_avp_new(fd_auth_application_id, 0, &avp);
|
||||
d_assert(ret == 0, return,);
|
||||
val.i32 = GX_APPLICATION_ID;
|
||||
ret = fd_msg_avp_setvalue(avp, &val);
|
||||
d_assert(ret == 0, return,);
|
||||
ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
ret = clock_gettime(CLOCK_REALTIME, &sess_data->ts);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Keep a pointer to the session data for debug purpose,
|
||||
* in real life we would not need it */
|
||||
svg = sess_data;
|
||||
|
||||
/* Store this value in the session */
|
||||
ret = fd_sess_state_store(pcrf_gx_reg, session, &sess_data);
|
||||
d_assert(ret == 0, return,);
|
||||
d_assert(sess_data == NULL, return,);
|
||||
|
||||
/* Send the request */
|
||||
ret = fd_msg_send(&req, pcrf_gx_raa_cb, svg);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Increment the counter */
|
||||
d_assert(pthread_mutex_lock(&fd_logger_self()->stats_lock) == 0,,);
|
||||
fd_logger_self()->stats.nb_sent++;
|
||||
d_assert(pthread_mutex_unlock(&fd_logger_self()->stats_lock) == 0,, );
|
||||
|
||||
d_trace(3, "[Gx] Re-Auth-Request : PCRF --> PGW\n");
|
||||
}
|
||||
|
||||
static void pcrf_gx_raa_cb(void *data, struct msg **msg)
|
||||
{
|
||||
}
|
||||
|
||||
status_t pcrf_gx_init(void)
|
||||
{
|
||||
int ret;
|
||||
struct disp_when data;
|
||||
|
||||
pool_init(&pcrf_gx_sess_pool, MAX_POOL_OF_DIAMETER_SESS);
|
||||
|
||||
/* Install objects definitions for this application */
|
||||
CHECK_FCT( gx_dict_init() );
|
||||
ret = gx_dict_init();
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
/* Create handler for sessions */
|
||||
CHECK_FCT( fd_sess_handler_create(&pcrf_gx_reg, state_cleanup,
|
||||
NULL, NULL) );
|
||||
ret = fd_sess_handler_create(&pcrf_gx_reg, state_cleanup, NULL, NULL);
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.app = gx_application;
|
||||
|
||||
CHECK_FCT( fd_disp_register(pcrf_gx_fb_cb, DISP_HOW_APPID, &data, NULL,
|
||||
&hdl_gx_fb) );
|
||||
ret = fd_disp_register(pcrf_gx_fb_cb, DISP_HOW_APPID, &data, NULL,
|
||||
&hdl_gx_fb);
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
data.command = gx_cmd_ccr;
|
||||
CHECK_FCT( fd_disp_register(pcrf_gx_ccr_cb, DISP_HOW_CC, &data, NULL,
|
||||
&hdl_gx_ccr) );
|
||||
ret = fd_disp_register(pcrf_gx_ccr_cb, DISP_HOW_CC, &data, NULL,
|
||||
&hdl_gx_ccr);
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
/* Advertise the support for the application in the peer */
|
||||
CHECK_FCT( fd_disp_app_support(gx_application, fd_vendor, 1, 0) );
|
||||
ret = fd_disp_app_support(gx_application, fd_vendor, 1, 0);
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
return 0;
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
void pcrf_gx_final(void)
|
||||
{
|
||||
CHECK_FCT_DO( fd_sess_handler_destroy(&pcrf_gx_reg, NULL), );
|
||||
int ret;
|
||||
|
||||
ret = fd_sess_handler_destroy(&pcrf_gx_reg, NULL);
|
||||
d_assert(ret == 0,,);
|
||||
|
||||
if (hdl_gx_fb)
|
||||
(void) fd_disp_unregister(&hdl_gx_fb, NULL);
|
||||
if (hdl_gx_ccr)
|
||||
|
|
|
@ -8,7 +8,6 @@ static int initialized = 0;
|
|||
status_t pcrf_initialize(void)
|
||||
{
|
||||
status_t rv;
|
||||
int ret;
|
||||
|
||||
rv = pcrf_context_init();
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
@ -22,8 +21,8 @@ status_t pcrf_initialize(void)
|
|||
rv = pcrf_db_init();
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
||||
ret = pcrf_fd_init();
|
||||
if (ret != CORE_OK) return CORE_ERROR;
|
||||
rv = pcrf_fd_init();
|
||||
if (rv != CORE_OK) return CORE_ERROR;
|
||||
|
||||
initialized = 1;
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
|
|||
struct session *sess, void *opaque, enum disp_action *act)
|
||||
{
|
||||
status_t rv;
|
||||
int ret;
|
||||
|
||||
struct msg *ans, *qry;
|
||||
#if 0
|
||||
|
@ -70,6 +71,7 @@ static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
|
|||
struct avp_hdr *hdr;
|
||||
union avp_value val;
|
||||
struct sess_state *sess_data = NULL;
|
||||
size_t sidlen;
|
||||
|
||||
#if 0
|
||||
gx_cca_message_t cca_message;
|
||||
|
@ -82,17 +84,17 @@ static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
|
|||
char buf[CORE_ADDRSTRLEN];
|
||||
os0_t rx_sid = NULL;
|
||||
os0_t gx_sid = NULL;
|
||||
size_t sidlen;
|
||||
c_uint32_t result_code = RX_DIAMETER_IP_CAN_SESSION_NOT_AVAILABLE;
|
||||
|
||||
d_assert(msg, return EINVAL,);
|
||||
d_assert(sess, return EINVAL,);
|
||||
|
||||
d_assert( fd_sess_state_retrieve(pcrf_rx_reg, sess, &sess_data) == 0,
|
||||
return EINVAL,);
|
||||
ret = fd_sess_state_retrieve(pcrf_rx_reg, sess, &sess_data);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
if (!sess_data)
|
||||
{
|
||||
d_assert( fd_sess_getsid(sess, &rx_sid, &sidlen) == 0, return EINVAL,);
|
||||
ret = fd_sess_getsid(sess, &rx_sid, &sidlen);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
sess_data = new_state(rx_sid);
|
||||
d_assert(sess_data, return EINVAL,);
|
||||
|
@ -105,26 +107,35 @@ static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
|
|||
|
||||
/* Create answer header */
|
||||
qry = *msg;
|
||||
CHECK_FCT( fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0) );
|
||||
ret = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, msg, 0);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ans = *msg;
|
||||
|
||||
/* Set the Auth-Application-Id AVP */
|
||||
CHECK_FCT_DO( fd_msg_avp_new(fd_auth_application_id, 0, &avp), goto out );
|
||||
ret = fd_msg_avp_new(fd_auth_application_id, 0, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.i32 = RX_APPLICATION_ID;
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue(avp, &val), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp), goto out );
|
||||
ret = fd_msg_avp_setvalue(avp, &val);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
/* Set the Auth-Request-Type AVP */
|
||||
CHECK_FCT_DO( fd_msg_avp_new(fd_auth_request_type, 0, &avp), goto out );
|
||||
ret = fd_msg_avp_new(fd_auth_request_type, 0, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
val.i32 = 1;
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue(avp, &val), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp), goto out );
|
||||
ret = fd_msg_avp_setvalue(avp, &val);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
ret = fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
/* Get Framed-IP-Address */
|
||||
CHECK_FCT( fd_msg_search_avp(qry, rx_framed_ip_address, &avp) );
|
||||
ret = fd_msg_search_avp(qry, rx_framed_ip_address, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
if (avp)
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_hdr(avp, &hdr) );
|
||||
ret = fd_msg_avp_hdr(avp, &hdr);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
gx_sid = (os0_t)pcrf_sess_find_by_ipv4(hdr->avp_value->os.data);
|
||||
if (!gx_sid)
|
||||
{
|
||||
|
@ -136,12 +147,14 @@ static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
|
|||
if (!gx_sid)
|
||||
{
|
||||
/* Get Framed-IPv6-Prefix */
|
||||
CHECK_FCT( fd_msg_search_avp(qry, rx_framed_ipv6_prefix, &avp) );
|
||||
ret = fd_msg_search_avp(qry, rx_framed_ipv6_prefix, &avp);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
if (avp)
|
||||
{
|
||||
paa_t *paa = NULL;
|
||||
|
||||
CHECK_FCT( fd_msg_avp_hdr(avp, &hdr) );
|
||||
ret = fd_msg_avp_hdr(avp, &hdr);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
paa = (paa_t *)hdr->avp_value->os.data;
|
||||
d_assert(paa, goto out,);
|
||||
d_assert(paa->len == IPV6_LEN * 8 /* 128bit */, goto out,
|
||||
|
@ -155,11 +168,15 @@ static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
|
|||
}
|
||||
}
|
||||
|
||||
if (!gx_sid) goto out;
|
||||
if (!gx_sid)
|
||||
{
|
||||
d_error("No Gx Session");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Associate Gx-session with Rx-session */
|
||||
rv = pcrf_sess_gx_associate_rx(gx_sid, rx_sid);
|
||||
d_assert(rv == CORE_OK, goto out,);
|
||||
d_assert(rv == CORE_OK, goto out, "Cannot Associate Gx/Rx Session");
|
||||
|
||||
/* Store Gx Session-Id in this session */
|
||||
if (sess_data->gx_sid)
|
||||
|
@ -168,20 +185,22 @@ static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
|
|||
d_assert(sess_data->gx_sid, goto out,);
|
||||
|
||||
/* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */
|
||||
CHECK_FCT( fd_msg_rescode_set(ans, "DIAMETER_SUCCESS", NULL, NULL, 1) );
|
||||
ret = fd_msg_rescode_set(ans, "DIAMETER_SUCCESS", NULL, NULL, 1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
|
||||
/* Store this value in the session */
|
||||
CHECK_FCT_DO( fd_sess_state_store(pcrf_rx_reg, sess, &sess_data),
|
||||
goto out );
|
||||
ret = fd_sess_state_store(pcrf_rx_reg, sess, &sess_data);
|
||||
d_assert(ret == 0,,);
|
||||
d_assert(sess_data == NULL,,);
|
||||
|
||||
/* Send the answer */
|
||||
CHECK_FCT( fd_msg_send(msg, NULL, NULL) );
|
||||
ret = fd_msg_send(msg, NULL, NULL);
|
||||
d_assert(ret == 0,,);
|
||||
|
||||
/* Add this value to the stats */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&fd_logger_self()->stats_lock), );
|
||||
d_assert(pthread_mutex_lock(&fd_logger_self()->stats_lock) == 0,,);
|
||||
fd_logger_self()->stats.nb_echoed++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&fd_logger_self()->stats_lock), );
|
||||
d_assert(pthread_mutex_unlock(&fd_logger_self()->stats_lock) == 0,,);
|
||||
|
||||
#if 0
|
||||
gx_cca_message_free(&cca_message);
|
||||
|
@ -192,16 +211,19 @@ static int pcrf_rx_aar_cb( struct msg **msg, struct avp *avp,
|
|||
out:
|
||||
if (result_code == RX_DIAMETER_REQUESTED_SERVICE_TEMPORARILY_NOT_AUTHORIZED)
|
||||
{
|
||||
CHECK_FCT( fd_msg_rescode_set(ans,
|
||||
ret = fd_msg_rescode_set(ans,
|
||||
"RX_DIAMETER_REQUESTED_SERVICE_TEMPORARILY_NOT_AUTHORIZED",
|
||||
NULL, NULL, 1) );
|
||||
NULL, NULL, 1);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK_FCT( fd_message_experimental_rescode_set(ans, result_code) );
|
||||
ret = fd_message_experimental_rescode_set(ans, result_code);
|
||||
d_assert(ret == 0, return EINVAL,);
|
||||
}
|
||||
|
||||
CHECK_FCT( fd_msg_send(msg, NULL, NULL) );
|
||||
ret = fd_msg_send(msg, NULL, NULL);
|
||||
d_assert(ret == 0,,);
|
||||
|
||||
state_cleanup(sess_data, NULL, NULL);
|
||||
#if 0
|
||||
|
@ -211,38 +233,47 @@ out:
|
|||
return 0;
|
||||
}
|
||||
|
||||
int pcrf_rx_init(void)
|
||||
status_t pcrf_rx_init(void)
|
||||
{
|
||||
int ret;
|
||||
struct disp_when data;
|
||||
|
||||
pool_init(&pcrf_rx_sess_pool, MAX_POOL_OF_DIAMETER_SESS);
|
||||
|
||||
/* Install objects definitions for this application */
|
||||
CHECK_FCT( rx_dict_init() );
|
||||
ret = rx_dict_init();
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
/* Create handler for sessions */
|
||||
CHECK_FCT( fd_sess_handler_create(&pcrf_rx_reg, state_cleanup,
|
||||
NULL, NULL) );
|
||||
ret = fd_sess_handler_create(&pcrf_rx_reg, state_cleanup, NULL, NULL);
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.app = rx_application;
|
||||
|
||||
CHECK_FCT( fd_disp_register(pcrf_rx_fb_cb, DISP_HOW_APPID, &data, NULL,
|
||||
&hdl_rx_fb) );
|
||||
ret = fd_disp_register(pcrf_rx_fb_cb, DISP_HOW_APPID, &data, NULL,
|
||||
&hdl_rx_fb);
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
data.command = rx_cmd_aar;
|
||||
CHECK_FCT( fd_disp_register(pcrf_rx_aar_cb, DISP_HOW_CC, &data, NULL,
|
||||
&hdl_rx_aar) );
|
||||
ret = fd_disp_register(pcrf_rx_aar_cb, DISP_HOW_CC, &data, NULL,
|
||||
&hdl_rx_aar);
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
/* Advertise the support for the application in the peer */
|
||||
CHECK_FCT( fd_disp_app_support(rx_application, fd_vendor, 1, 0) );
|
||||
ret = fd_disp_app_support(rx_application, fd_vendor, 1, 0);
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
return 0;
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
void pcrf_rx_final(void)
|
||||
{
|
||||
CHECK_FCT_DO( fd_sess_handler_destroy(&pcrf_rx_reg, NULL), );
|
||||
int ret;
|
||||
|
||||
ret = fd_sess_handler_destroy(&pcrf_rx_reg, NULL);
|
||||
d_assert(ret == 0,,);
|
||||
|
||||
if (hdl_rx_fb)
|
||||
(void) fd_disp_unregister(&hdl_rx_fb, NULL);
|
||||
if (hdl_rx_aar)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,7 +11,7 @@ extern "C" {
|
|||
|
||||
typedef struct _gtp_xact_t gtp_xact_t;
|
||||
|
||||
CORE_DECLARE(int) pgw_fd_init(void);
|
||||
CORE_DECLARE(status_t) pgw_fd_init(void);
|
||||
CORE_DECLARE(void) pgw_fd_final(void);
|
||||
|
||||
CORE_DECLARE(void) pgw_gx_send_ccr(gtp_xact_t *xact, pgw_sess_t *sess,
|
||||
|
|
|
@ -19,7 +19,6 @@ static int initialized = 0;
|
|||
status_t pgw_initialize()
|
||||
{
|
||||
status_t rv;
|
||||
int ret;
|
||||
|
||||
rv = pgw_context_init();
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
@ -33,8 +32,8 @@ status_t pgw_initialize()
|
|||
rv = pgw_ue_pool_generate();
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
||||
ret = pgw_fd_init();
|
||||
if (ret != 0) return CORE_ERROR;
|
||||
rv = pgw_fd_init();
|
||||
if (rv != 0) return CORE_ERROR;
|
||||
|
||||
rv = thread_create(&pgw_thread, NULL, pgw_main, NULL);
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
|
|
@ -35,6 +35,7 @@ void pcscf_rx_sess_cleanup(
|
|||
void pcscf_rx_send_aar(const char *ip)
|
||||
{
|
||||
status_t rv;
|
||||
int ret;
|
||||
|
||||
struct msg *req = NULL;
|
||||
struct avp *avp;
|
||||
|
@ -44,7 +45,7 @@ void pcscf_rx_send_aar(const char *ip)
|
|||
struct avp *avpch1;
|
||||
#endif
|
||||
union avp_value val;
|
||||
struct sess_state *mi = NULL, *svg;
|
||||
struct sess_state *sess_data = NULL, *svg;
|
||||
struct session *session = NULL;
|
||||
|
||||
paa_t paa;
|
||||
|
@ -55,76 +56,92 @@ void pcscf_rx_send_aar(const char *ip)
|
|||
d_assert(rv == CORE_OK, return,);
|
||||
|
||||
/* Create the random value to store with the session */
|
||||
pool_alloc_node(&pcscf_rx_sess_pool, &mi);
|
||||
d_assert(mi, return, "malloc failed: %s", strerror(errno));
|
||||
pool_alloc_node(&pcscf_rx_sess_pool, &sess_data);
|
||||
d_assert(sess_data, return,);
|
||||
|
||||
/* Create the request */
|
||||
CHECK_FCT_DO( fd_msg_new(rx_cmd_aar, MSGFL_ALLOC_ETEID, &req), goto out );
|
||||
ret = fd_msg_new(rx_cmd_aar, MSGFL_ALLOC_ETEID, &req);
|
||||
d_assert(ret == 0, return,);
|
||||
{
|
||||
struct msg_hdr * h;
|
||||
CHECK_FCT_DO( fd_msg_hdr( req, &h ), goto out );
|
||||
ret = fd_msg_hdr( req, &h );
|
||||
d_assert(ret == 0, return,);
|
||||
h->msg_appl = RX_APPLICATION_ID;
|
||||
}
|
||||
|
||||
/* Create a new session */
|
||||
#define RX_APP_SID_OPT "app_rx"
|
||||
CHECK_FCT_DO( fd_msg_new_session(req, (os0_t)RX_APP_SID_OPT,
|
||||
CONSTSTRLEN(RX_APP_SID_OPT)), goto out );
|
||||
CHECK_FCT_DO( fd_msg_sess_get(fd_g_config->cnf_dict, req, &session, NULL),
|
||||
goto out );
|
||||
ret = fd_msg_new_session(req, (os0_t)RX_APP_SID_OPT,
|
||||
CONSTSTRLEN(RX_APP_SID_OPT));
|
||||
d_assert(ret == 0, return,);
|
||||
ret = fd_msg_sess_get(fd_g_config->cnf_dict, req, &session, NULL);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Set Origin-Host & Origin-Realm */
|
||||
CHECK_FCT_DO( fd_msg_add_origin(req, 0), goto out );
|
||||
ret = fd_msg_add_origin(req, 0);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Set the Destination-Realm AVP */
|
||||
CHECK_FCT_DO( fd_msg_avp_new(fd_destination_realm, 0, &avp), goto out );
|
||||
ret = fd_msg_avp_new(fd_destination_realm, 0, &avp);
|
||||
d_assert(ret == 0, return,);
|
||||
val.os.data = (unsigned char *)(fd_g_config->cnf_diamrlm);
|
||||
val.os.len = strlen(fd_g_config->cnf_diamrlm);
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue(avp, &val), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp), goto out );
|
||||
ret = fd_msg_avp_setvalue(avp, &val);
|
||||
d_assert(ret == 0, return,);
|
||||
ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Set the Auth-Application-Id AVP */
|
||||
CHECK_FCT_DO( fd_msg_avp_new(fd_auth_application_id, 0, &avp), goto out );
|
||||
ret = fd_msg_avp_new(fd_auth_application_id, 0, &avp);
|
||||
d_assert(ret == 0, return,);
|
||||
val.i32 = RX_APPLICATION_ID;
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue(avp, &val), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp), goto out );
|
||||
ret = fd_msg_avp_setvalue(avp, &val);
|
||||
d_assert(ret == 0, return,);
|
||||
ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Set Subscription-Id */
|
||||
CHECK_FCT_DO( fd_msg_avp_new(rx_subscription_id, 0, &avp),
|
||||
goto out );
|
||||
ret = fd_msg_avp_new(rx_subscription_id, 0, &avp);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
CHECK_FCT_DO( fd_msg_avp_new(rx_subscription_id_type, 0, &avpch1),
|
||||
goto out );
|
||||
ret = fd_msg_avp_new(rx_subscription_id_type, 0, &avpch1);
|
||||
d_assert(ret == 0, return,);
|
||||
val.i32 = RX_SUBSCRIPTION_ID_TYPE_END_USER_IMSI;
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue (avpch1, &val), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1), goto out );
|
||||
ret = fd_msg_avp_setvalue (avpch1, &val);
|
||||
d_assert(ret == 0, return,);
|
||||
ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
#define RX_APP_IMSI_BCD "0123456789012345"
|
||||
CHECK_FCT_DO( fd_msg_avp_new(rx_subscription_id_data, 0, &avpch1),
|
||||
goto out );
|
||||
ret = fd_msg_avp_new(rx_subscription_id_data, 0, &avpch1);
|
||||
d_assert(ret == 0, return,);
|
||||
val.os.data = (c_uint8_t *)RX_APP_IMSI_BCD;
|
||||
val.os.len = strlen(RX_APP_IMSI_BCD);
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue (avpch1, &val), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1), goto out );
|
||||
ret = fd_msg_avp_setvalue (avpch1, &val);
|
||||
d_assert(ret == 0, return,);
|
||||
ret = fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch1);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
CHECK_FCT_DO( fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp), goto out );
|
||||
ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
if (ipsub.family == AF_INET)
|
||||
{
|
||||
/* Set Framed-IP-Address */
|
||||
CHECK_FCT_DO( fd_msg_avp_new(rx_framed_ip_address, 0, &avp),
|
||||
goto out );
|
||||
ret = fd_msg_avp_new(rx_framed_ip_address, 0, &avp);
|
||||
d_assert(ret == 0, return,);
|
||||
val.os.data = (c_uint8_t*)ipsub.sub;
|
||||
val.os.len = IPV4_LEN;
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue(avp, &val), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp),
|
||||
goto out );
|
||||
ret = fd_msg_avp_setvalue(avp, &val);
|
||||
d_assert(ret == 0, return,);
|
||||
ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return,);
|
||||
}
|
||||
else if (ipsub.family == AF_INET6)
|
||||
{
|
||||
/* Set Framed-IPv6-Prefix */
|
||||
CHECK_FCT_DO( fd_msg_avp_new(rx_framed_ipv6_prefix, 0, &avp),
|
||||
goto out );
|
||||
ret = fd_msg_avp_new(rx_framed_ipv6_prefix, 0, &avp);
|
||||
d_assert(ret == 0, return,);
|
||||
memset(&paa, 0, sizeof(paa_t));
|
||||
|
||||
memcpy(paa.addr6, ipsub.sub, IPV6_LEN);
|
||||
|
@ -133,35 +150,38 @@ void pcscf_rx_send_aar(const char *ip)
|
|||
paa.len = FRAMED_IPV6_PREFIX_LENGTH;
|
||||
val.os.data = (c_uint8_t*)&paa;
|
||||
val.os.len = PAA_IPV6_LEN;
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue(avp, &val), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp),
|
||||
goto out );
|
||||
ret = fd_msg_avp_setvalue(avp, &val);
|
||||
d_assert(ret == 0, return,);
|
||||
ret = fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp);
|
||||
d_assert(ret == 0, return,);
|
||||
}
|
||||
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &mi->ts), goto out );
|
||||
ret = clock_gettime(CLOCK_REALTIME, &sess_data->ts);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Keep a pointer to the session data for debug purpose,
|
||||
* in real life we would not need it */
|
||||
svg = mi;
|
||||
svg = sess_data;
|
||||
|
||||
/* Store this value in the session */
|
||||
CHECK_FCT_DO( fd_sess_state_store(pcscf_rx_reg, session, &mi), goto out );
|
||||
ret = fd_sess_state_store(pcscf_rx_reg, session, &sess_data);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Send the request */
|
||||
CHECK_FCT_DO( fd_msg_send(&req, pcscf_rx_aaa_cb, svg), goto out );
|
||||
ret = fd_msg_send(&req, pcscf_rx_aaa_cb, svg);
|
||||
d_assert(ret == 0,,);
|
||||
|
||||
/* Increment the counter */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&fd_logger_self()->stats_lock), );
|
||||
d_assert(pthread_mutex_lock(&fd_logger_self()->stats_lock) == 0,,);
|
||||
fd_logger_self()->stats.nb_sent++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&fd_logger_self()->stats_lock), );
|
||||
|
||||
out:
|
||||
return;
|
||||
d_assert(pthread_mutex_unlock(&fd_logger_self()->stats_lock) == 0,,);
|
||||
}
|
||||
|
||||
static void pcscf_rx_aaa_cb(void *data, struct msg **msg)
|
||||
{
|
||||
struct sess_state *mi = NULL;
|
||||
int ret;
|
||||
|
||||
struct sess_state *sess_data = NULL;
|
||||
struct timespec ts;
|
||||
struct session *session;
|
||||
#if 0
|
||||
|
@ -175,35 +195,40 @@ static void pcscf_rx_aaa_cb(void *data, struct msg **msg)
|
|||
int new;
|
||||
c_int32_t result_code = 0;
|
||||
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &ts), return );
|
||||
ret = clock_gettime(CLOCK_REALTIME, &ts);
|
||||
d_assert(ret == 0, return,);
|
||||
|
||||
/* Search the session, retrieve its data */
|
||||
CHECK_FCT_DO( fd_msg_sess_get(fd_g_config->cnf_dict, *msg, &session, &new),
|
||||
return );
|
||||
ret = fd_msg_sess_get(fd_g_config->cnf_dict, *msg, &session, &new);
|
||||
d_assert(ret == 0, return,);
|
||||
d_assert(new == 0, return, );
|
||||
|
||||
CHECK_FCT_DO( fd_sess_state_retrieve(pcscf_rx_reg, session, &mi), return );
|
||||
d_assert(mi && (void *)mi == data, return, );
|
||||
ret = fd_sess_state_retrieve(pcscf_rx_reg, session, &sess_data);
|
||||
d_assert(ret == 0, return,);
|
||||
d_assert(sess_data && (void *)sess_data == data, return, );
|
||||
|
||||
/* Value of Result Code */
|
||||
CHECK_FCT_DO( fd_msg_search_avp(*msg, fd_result_code, &avp), return );
|
||||
ret = fd_msg_search_avp(*msg, fd_result_code, &avp);
|
||||
d_assert(ret == 0, return,);
|
||||
if (avp)
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_hdr(avp, &hdr), return);
|
||||
ret = fd_msg_avp_hdr(avp, &hdr);
|
||||
d_assert(ret == 0, return,);
|
||||
result_code = hdr->avp_value->i32;
|
||||
d_trace(3, "Result Code: %d\n", hdr->avp_value->i32);
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_search_avp(*msg,
|
||||
fd_experimental_result, &avp), return );
|
||||
ret = fd_msg_search_avp(*msg, fd_experimental_result, &avp);
|
||||
d_assert(ret == 0, return,);
|
||||
if (avp)
|
||||
{
|
||||
CHECK_FCT_DO( fd_avp_search_avp(avp,
|
||||
fd_experimental_result_code, &avpch1), return );
|
||||
ret = fd_avp_search_avp(avp, fd_experimental_result_code, &avpch1);
|
||||
d_assert(ret == 0, return,);
|
||||
if (avpch1)
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_hdr(avpch1, &hdr), return);
|
||||
ret = fd_msg_avp_hdr(avpch1, &hdr);
|
||||
d_assert(ret == 0, return,);
|
||||
result_code = hdr->avp_value->i32;
|
||||
d_trace(3, "Experimental Result Code: %d\n",
|
||||
result_code);
|
||||
|
@ -217,10 +242,12 @@ static void pcscf_rx_aaa_cb(void *data, struct msg **msg)
|
|||
}
|
||||
|
||||
/* Value of Origin-Host */
|
||||
CHECK_FCT_DO( fd_msg_search_avp(*msg, fd_origin_host, &avp), return );
|
||||
ret = fd_msg_search_avp(*msg, fd_origin_host, &avp);
|
||||
d_assert(ret == 0, return,);
|
||||
if (avp)
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_hdr(avp, &hdr), return );
|
||||
ret = fd_msg_avp_hdr(avp, &hdr);
|
||||
d_assert(ret == 0, return,);
|
||||
d_trace(3, "From '%.*s' ",
|
||||
(int)hdr->avp_value->os.len, hdr->avp_value->os.data);
|
||||
}
|
||||
|
@ -231,10 +258,12 @@ static void pcscf_rx_aaa_cb(void *data, struct msg **msg)
|
|||
}
|
||||
|
||||
/* Value of Origin-Realm */
|
||||
CHECK_FCT_DO( fd_msg_search_avp(*msg, fd_origin_realm, &avp), return );
|
||||
ret = fd_msg_search_avp(*msg, fd_origin_realm, &avp);
|
||||
d_assert(ret == 0, return,);
|
||||
if (avp)
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_hdr(avp, &hdr), return );
|
||||
ret = fd_msg_avp_hdr(avp, &hdr);
|
||||
d_assert(ret == 0, return,);
|
||||
d_trace(3, "('%.*s') ",
|
||||
(int)hdr->avp_value->os.len, hdr->avp_value->os.data);
|
||||
}
|
||||
|
@ -253,9 +282,9 @@ static void pcscf_rx_aaa_cb(void *data, struct msg **msg)
|
|||
|
||||
out:
|
||||
/* Free the message */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&fd_logger_self()->stats_lock), );
|
||||
dur = ((ts.tv_sec - mi->ts.tv_sec) * 1000000) +
|
||||
((ts.tv_nsec - mi->ts.tv_nsec) / 1000);
|
||||
d_assert(pthread_mutex_lock(&fd_logger_self()->stats_lock) == 0,, );
|
||||
dur = ((ts.tv_sec - sess_data->ts.tv_sec) * 1000000) +
|
||||
((ts.tv_nsec - sess_data->ts.tv_nsec) / 1000);
|
||||
if (fd_logger_self()->stats.nb_recv)
|
||||
{
|
||||
/* Ponderate in the avg */
|
||||
|
@ -279,22 +308,23 @@ out:
|
|||
else
|
||||
fd_logger_self()->stats.nb_recv++;
|
||||
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&fd_logger_self()->stats_lock), );
|
||||
d_assert(pthread_mutex_unlock(&fd_logger_self()->stats_lock) == 0,, );
|
||||
|
||||
/* Display how long it took */
|
||||
if (ts.tv_nsec > mi->ts.tv_nsec)
|
||||
if (ts.tv_nsec > sess_data->ts.tv_nsec)
|
||||
d_trace(3, "in %d.%06ld sec\n",
|
||||
(int)(ts.tv_sec - mi->ts.tv_sec),
|
||||
(long)(ts.tv_nsec - mi->ts.tv_nsec) / 1000);
|
||||
(int)(ts.tv_sec - sess_data->ts.tv_sec),
|
||||
(long)(ts.tv_nsec - sess_data->ts.tv_nsec) / 1000);
|
||||
else
|
||||
d_trace(3, "in %d.%06ld sec\n",
|
||||
(int)(ts.tv_sec + 1 - mi->ts.tv_sec),
|
||||
(long)(1000000000 + ts.tv_nsec - mi->ts.tv_nsec) / 1000);
|
||||
(int)(ts.tv_sec + 1 - sess_data->ts.tv_sec),
|
||||
(long)(1000000000 + ts.tv_nsec - sess_data->ts.tv_nsec) / 1000);
|
||||
|
||||
CHECK_FCT_DO( fd_msg_free(*msg), return );
|
||||
ret = fd_msg_free(*msg);
|
||||
d_assert(ret == 0,,);
|
||||
*msg = NULL;
|
||||
|
||||
pcscf_rx_sess_cleanup(mi, NULL, NULL);
|
||||
pcscf_rx_sess_cleanup(sess_data, NULL, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -330,28 +360,35 @@ void pcscf_fd_config()
|
|||
fd_config.num_of_conn++;
|
||||
}
|
||||
|
||||
int pcscf_fd_init(void)
|
||||
status_t pcscf_fd_init(void)
|
||||
{
|
||||
int ret;
|
||||
pool_init(&pcscf_rx_sess_pool, MAX_NUM_SESSION_STATE);
|
||||
|
||||
pcscf_fd_config();
|
||||
|
||||
CHECK_FCT( fd_init(FD_MODE_CLIENT, NULL, &fd_config) );
|
||||
ret = fd_init(FD_MODE_CLIENT, NULL, &fd_config);
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
CHECK_FCT( rx_dict_init() );
|
||||
ret = rx_dict_init();
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
CHECK_FCT( fd_sess_handler_create(&pcscf_rx_reg, pcscf_rx_sess_cleanup,
|
||||
NULL, NULL) );
|
||||
ret = fd_sess_handler_create(&pcscf_rx_reg, pcscf_rx_sess_cleanup,
|
||||
NULL, NULL);
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
/* Advertise the support for the application in the peer */
|
||||
CHECK_FCT( fd_disp_app_support(rx_application, fd_vendor, 1, 0) );
|
||||
ret = fd_disp_app_support(rx_application, fd_vendor, 1, 0);
|
||||
d_assert(ret == 0, return CORE_ERROR,);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pcscf_fd_final(void)
|
||||
{
|
||||
CHECK_FCT_DO( fd_sess_handler_destroy(&pcscf_rx_reg, NULL), );
|
||||
int ret;
|
||||
ret = fd_sess_handler_destroy(&pcscf_rx_reg, NULL);
|
||||
d_assert(ret == 0,,);
|
||||
|
||||
fd_final();
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
CORE_DECLARE(int) pcscf_fd_init(void);
|
||||
CORE_DECLARE(status_t) pcscf_fd_init(void);
|
||||
CORE_DECLARE(void) pcscf_fd_final(void);
|
||||
|
||||
CORE_DECLARE(void) pcscf_rx_send_aar(const char *ip);
|
||||
|
|
Loading…
Reference in New Issue