support pcrf gx session maintained mode
This commit is contained in:
parent
779d5e88d0
commit
e4397176cf
|
@ -26,6 +26,7 @@ extern "C" {
|
|||
#define MAX_POOL_OF_BEARER (MAX_POOL_OF_SESS * MAX_NUM_OF_BEARER)
|
||||
#define MAX_POOL_OF_TUNNEL (MAX_POOL_OF_BEARER * MAX_NUM_OF_TUNNEL)
|
||||
#define MAX_POOL_OF_PF (MAX_POOL_OF_BEARER * MAX_NUM_OF_PF)
|
||||
#define MAX_POOL_OF_DIAMETER_SESS 32
|
||||
|
||||
#define MAX_NUM_OF_HOSTNAME 16
|
||||
#define MAX_NUM_OF_PCC_RULE 8
|
||||
|
|
|
@ -585,15 +585,12 @@ int hss_fd_init(void)
|
|||
|
||||
void hss_fd_final(void)
|
||||
{
|
||||
if (hdl_s6a_fb) {
|
||||
if (hdl_s6a_fb)
|
||||
(void) fd_disp_unregister(&hdl_s6a_fb, NULL);
|
||||
}
|
||||
if (hdl_s6a_air) {
|
||||
if (hdl_s6a_air)
|
||||
(void) fd_disp_unregister(&hdl_s6a_air, NULL);
|
||||
}
|
||||
if (hdl_s6a_ulr) {
|
||||
if (hdl_s6a_ulr)
|
||||
(void) fd_disp_unregister(&hdl_s6a_ulr, NULL);
|
||||
}
|
||||
|
||||
fd_final();
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include "mme_event.h"
|
||||
#include "mme_fd_path.h"
|
||||
|
||||
#define MAX_NUM_SESSION_STATE 32
|
||||
|
||||
static struct session_handler *mme_s6a_reg = NULL;
|
||||
|
||||
struct sess_state {
|
||||
|
@ -20,7 +18,7 @@ struct sess_state {
|
|||
struct timespec ts; /* Time of sending the message */
|
||||
};
|
||||
|
||||
pool_declare(mme_s6a_sess_pool, struct sess_state, MAX_NUM_SESSION_STATE);
|
||||
pool_declare(mme_s6a_sess_pool, struct sess_state, MAX_POOL_OF_DIAMETER_SESS);
|
||||
|
||||
static void mme_s6a_aia_cb(void *data, struct msg **msg);
|
||||
static void mme_s6a_ula_cb(void *data, struct msg **msg);
|
||||
|
@ -918,7 +916,7 @@ static void mme_s6a_ula_cb(void *data, struct msg **msg)
|
|||
|
||||
int mme_fd_init(void)
|
||||
{
|
||||
pool_init(&mme_s6a_sess_pool, MAX_NUM_SESSION_STATE);
|
||||
pool_init(&mme_s6a_sess_pool, MAX_POOL_OF_DIAMETER_SESS);
|
||||
|
||||
CHECK_FCT( fd_init(FD_MODE_CLIENT,
|
||||
mme_self()->fd_conf_path, mme_self()->fd_config) );
|
||||
|
@ -926,6 +924,7 @@ int mme_fd_init(void)
|
|||
/* Install objects definitions for this application */
|
||||
CHECK_FCT( s6a_dict_init() );
|
||||
|
||||
/* Create handler for sessions */
|
||||
CHECK_FCT( fd_sess_handler_create(&mme_s6a_reg, &mme_s6a_sess_cleanup,
|
||||
NULL, NULL) );
|
||||
|
||||
|
@ -941,14 +940,11 @@ void mme_fd_final(void)
|
|||
|
||||
fd_final();
|
||||
|
||||
if (pool_size(&mme_s6a_sess_pool) != pool_avail(&mme_s6a_sess_pool))
|
||||
d_error("%d not freed in mme_s6a_sess_pool[%d] of S6A-SM",
|
||||
pool_size(&mme_s6a_sess_pool) - pool_avail(&mme_s6a_sess_pool),
|
||||
pool_size(&mme_s6a_sess_pool));
|
||||
|
||||
d_trace(3, "%d not freed in mme_s6a_sess_pool[%d] of S6A-SM\n",
|
||||
pool_size(&mme_s6a_sess_pool) - pool_avail(&mme_s6a_sess_pool),
|
||||
pool_size(&mme_s6a_sess_pool));
|
||||
if (pool_used(&mme_s6a_sess_pool))
|
||||
d_error("%d not freed in mme_s6a_sess_pool[%d] of GX-SM",
|
||||
pool_used(&mme_s6a_sess_pool), pool_size(&mme_s6a_sess_pool));
|
||||
d_trace(3, "%d not freed in mme_s6a_sess_pool[%d] of GX-SM\n",
|
||||
pool_used(&mme_s6a_sess_pool), pool_size(&mme_s6a_sess_pool));
|
||||
|
||||
pool_final(&mme_s6a_sess_pool);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "core_lib.h"
|
||||
#include "core_debug.h"
|
||||
#include "core_pool.h"
|
||||
|
||||
#include "fd/fd_lib.h"
|
||||
#include "fd/gx/gx_dict.h"
|
||||
|
@ -9,14 +10,22 @@
|
|||
|
||||
#include "pcrf_context.h"
|
||||
|
||||
struct sess_state {
|
||||
c_uint32_t cc_request_type;
|
||||
struct timespec ts; /* Time of sending the message */
|
||||
};
|
||||
|
||||
static struct session_handler *pcrf_gx_reg = NULL;
|
||||
static struct disp_hdl *hdl_gx_fb = NULL;
|
||||
static struct disp_hdl *hdl_gx_ccr = NULL;
|
||||
|
||||
pool_declare(pcrf_gx_sess_pool, struct sess_state, MAX_POOL_OF_DIAMETER_SESS);
|
||||
|
||||
void pcrf_gx_sess_cleanup(
|
||||
struct sess_state *sess_data, os0_t sid, void *opaque)
|
||||
{
|
||||
// pool_free_node(&pgw_gx_sess_pool, sess_data);
|
||||
printf("cleanup\n");
|
||||
pool_free_node(&pcrf_gx_sess_pool, sess_data);
|
||||
}
|
||||
|
||||
static int pcrf_gx_fb_cb(struct msg **msg, struct avp *avp,
|
||||
|
@ -35,9 +44,7 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
struct avp *avpch1, *avpch2, *avpch3, *avpch4;
|
||||
struct avp_hdr *hdr;
|
||||
union avp_value val;
|
||||
#if 0
|
||||
struct sess_state *sess_data = NULL;
|
||||
#endif
|
||||
|
||||
status_t rv;
|
||||
gx_cca_message_t cca_message;
|
||||
|
@ -45,22 +52,19 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
c_int8_t apn[MAX_APN_LEN+1];
|
||||
int i, j;
|
||||
|
||||
c_uint32_t cc_request_type = 0;
|
||||
c_uint32_t cc_request_number = 0;
|
||||
c_uint32_t result_code = GX_DIAMETER_ERROR_USER_UNKNOWN;
|
||||
|
||||
d_assert(msg, return EINVAL,);
|
||||
|
||||
#if 0
|
||||
d_assert( fd_sess_state_retrieve(pcrf_gx_reg, sess, &sess_data) == 0,
|
||||
return EINVAL,);
|
||||
if (!sess_data)
|
||||
{
|
||||
pool_alloc_node(&pgw_gx_sess_pool, &sess_data);
|
||||
pool_alloc_node(&pcrf_gx_sess_pool, &sess_data);
|
||||
d_assert(sess_data, return EINVAL,);
|
||||
memset(sess_data, 0, sizeof *sess_data);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize Message */
|
||||
memset(&cca_message, 0, sizeof(gx_cca_message_t));
|
||||
|
@ -73,7 +77,7 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
/* Get CC-Request-Type */
|
||||
CHECK_FCT( fd_msg_search_avp(qry, gx_cc_request_type, &avp) );
|
||||
CHECK_FCT( fd_msg_avp_hdr(avp, &hdr) );
|
||||
cc_request_type = hdr->avp_value->i32;
|
||||
sess_data->cc_request_type = hdr->avp_value->i32;
|
||||
|
||||
/* Get CC-Request-Number */
|
||||
CHECK_FCT( fd_msg_search_avp(qry, gx_cc_request_number, &avp) );
|
||||
|
@ -88,7 +92,7 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
|
||||
/* Set CC-Request-Type */
|
||||
CHECK_FCT_DO( fd_msg_avp_new(gx_cc_request_type, 0, &avp), goto out );
|
||||
val.i32 = cc_request_type;
|
||||
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 );
|
||||
|
||||
|
@ -126,7 +130,7 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (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 */
|
||||
if (cca_message.num_of_pcc_rule)
|
||||
|
@ -328,6 +332,18 @@ static int pcrf_gx_ccr_cb( struct msg **msg, struct avp *avp,
|
|||
/* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */
|
||||
CHECK_FCT( fd_msg_rescode_set(ans, "DIAMETER_SUCCESS", NULL, NULL, 1) );
|
||||
|
||||
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 );
|
||||
d_assert(sess_data == NULL,,);
|
||||
}
|
||||
else
|
||||
{
|
||||
pcrf_gx_sess_cleanup(sess_data, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Send the answer */
|
||||
CHECK_FCT( fd_msg_send(msg, NULL, NULL) );
|
||||
|
||||
|
@ -362,9 +378,12 @@ int pcrf_gx_init(void)
|
|||
{
|
||||
struct disp_when data;
|
||||
|
||||
/* GX Interface */
|
||||
pool_init(&pcrf_gx_sess_pool, MAX_POOL_OF_DIAMETER_SESS);
|
||||
|
||||
/* Install objects definitions for this application */
|
||||
CHECK_FCT( gx_dict_init() );
|
||||
|
||||
/* Create handler for sessions */
|
||||
CHECK_FCT( fd_sess_handler_create(&pcrf_gx_reg, pcrf_gx_sess_cleanup,
|
||||
NULL, NULL) );
|
||||
|
||||
|
@ -378,6 +397,7 @@ int pcrf_gx_init(void)
|
|||
CHECK_FCT( fd_disp_register(pcrf_gx_ccr_cb, DISP_HOW_CC, &data, NULL,
|
||||
&hdl_gx_ccr) );
|
||||
|
||||
/* Advertise the support for the application in the peer */
|
||||
CHECK_FCT( fd_disp_app_support(gx_application, fd_vendor, 1, 0) );
|
||||
|
||||
return 0;
|
||||
|
@ -390,4 +410,12 @@ void pcrf_gx_final(void)
|
|||
(void) fd_disp_unregister(&hdl_gx_fb, NULL);
|
||||
if (hdl_gx_ccr)
|
||||
(void) fd_disp_unregister(&hdl_gx_ccr, NULL);
|
||||
|
||||
if (pool_used(&pcrf_gx_sess_pool))
|
||||
d_error("%d not freed in pcrf_gx_sess_pool[%d] of GX-SM",
|
||||
pool_used(&pcrf_gx_sess_pool), pool_size(&pcrf_gx_sess_pool));
|
||||
d_trace(3, "%d not freed in pcrf_gx_sess_pool[%d] of GX-SM\n",
|
||||
pool_used(&pcrf_gx_sess_pool), pool_size(&pcrf_gx_sess_pool));
|
||||
|
||||
pool_final(&pcrf_gx_sess_pool);
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
#include "pgw_event.h"
|
||||
#include "pgw_fd_path.h"
|
||||
|
||||
#define MAX_NUM_SESSION_STATE 32
|
||||
|
||||
static struct session_handler *pgw_gx_reg = NULL;
|
||||
|
||||
struct sess_state {
|
||||
|
@ -26,7 +24,7 @@ struct sess_state {
|
|||
struct timespec ts; /* Time of sending the message */
|
||||
};
|
||||
|
||||
pool_declare(pgw_gx_sess_pool, struct sess_state, MAX_NUM_SESSION_STATE);
|
||||
pool_declare(pgw_gx_sess_pool, struct sess_state, MAX_POOL_OF_DIAMETER_SESS);
|
||||
|
||||
static void pgw_gx_cca_cb(void *data, struct msg **msg);
|
||||
|
||||
|
@ -345,7 +343,7 @@ void pgw_gx_send_ccr(gtp_xact_t *xact, pgw_sess_t *sess,
|
|||
|
||||
/* Store this value in the session */
|
||||
CHECK_FCT_DO( fd_sess_state_store(pgw_gx_reg, session, &mi), goto out );
|
||||
d_assert(mi == NULL, return,);
|
||||
d_assert(mi == NULL,,);
|
||||
|
||||
/* Send the request */
|
||||
CHECK_FCT_DO( fd_msg_send(&req, pgw_gx_cca_cb, svg), goto out );
|
||||
|
@ -799,25 +797,22 @@ out:
|
|||
if (mi->cc_request_type != GX_CC_REQUEST_TYPE_TERMINATION_REQUEST)
|
||||
{
|
||||
CHECK_FCT_DO( fd_sess_state_store(pgw_gx_reg, session, &mi), goto out );
|
||||
d_assert(mi == NULL, return,);
|
||||
|
||||
CHECK_FCT_DO( fd_msg_free(*msg), return );
|
||||
*msg = NULL;
|
||||
d_assert(mi == NULL,,);
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_free(*msg), return );
|
||||
*msg = NULL;
|
||||
|
||||
pgw_gx_sess_cleanup(mi, NULL, NULL);
|
||||
}
|
||||
|
||||
CHECK_FCT_DO( fd_msg_free(*msg), return );
|
||||
*msg = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int pgw_fd_init(void)
|
||||
{
|
||||
pool_init(&pgw_gx_sess_pool, MAX_NUM_SESSION_STATE);
|
||||
pool_init(&pgw_gx_sess_pool, MAX_POOL_OF_DIAMETER_SESS);
|
||||
|
||||
CHECK_FCT( fd_init(FD_MODE_CLIENT|FD_MODE_SERVER,
|
||||
pgw_self()->fd_conf_path, pgw_self()->fd_config) );
|
||||
|
@ -842,9 +837,9 @@ void pgw_fd_final(void)
|
|||
fd_final();
|
||||
|
||||
if (pool_used(&pgw_gx_sess_pool))
|
||||
d_error("%d not freed in pgw_gx_sess_pool[%d] of S6A-SM",
|
||||
d_error("%d not freed in pgw_gx_sess_pool[%d] of GX-SM",
|
||||
pool_used(&pgw_gx_sess_pool), pool_size(&pgw_gx_sess_pool));
|
||||
d_trace(3, "%d not freed in pgw_gx_sess_pool[%d] of S6A-SM\n",
|
||||
d_trace(3, "%d not freed in pgw_gx_sess_pool[%d] of GX-SM\n",
|
||||
pool_used(&pgw_gx_sess_pool), pool_size(&pgw_gx_sess_pool));
|
||||
|
||||
pool_final(&pgw_gx_sess_pool);
|
||||
|
|
Loading…
Reference in New Issue