Skip to content

Commit

Permalink
modules/ims_charging: fixed charging stats
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybeepee committed Jan 20, 2016
1 parent 475a244 commit c084e0b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions modules/ims_charging/dialog.c
Expand Up @@ -4,13 +4,15 @@
#include "../ims_usrloc_scscf/usrloc.h"
#include "../ims_usrloc_scscf/udomain.h"
#include "ro_db_handler.h"
#include "ims_charging_stats.h"

struct cdp_binds cdpb;

extern usrloc_api_t ul;
extern int ro_db_mode;
extern char *domain;
extern struct dlg_binds dlgb;
extern struct ims_charging_counters_h ims_charging_cnts_h;

void dlg_callback_received(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params) {
LM_DBG("Received dialog callback event [%d]\n", type);
Expand Down
10 changes: 8 additions & 2 deletions modules/ims_charging/ims_ro.c
Expand Up @@ -721,6 +721,7 @@ static void resume_on_interim_ccr(int is_timeout, void *param, AAAMessage *cca,
goto success;

error:
counter_inc(ims_charging_cnts_h.failed_interim_ccr);
if (ro_cca_data)
Ro_free_CCA(ro_cca_data);

Expand Down Expand Up @@ -904,7 +905,7 @@ void send_ccr_stop(struct ro_session *ro_session) {
Ro_free_CCR(ro_ccr_data);

counter_inc(ims_charging_cnts_h.final_ccrs);
counter_add(ims_charging_cnts_h.active_ro_sessions, -1);
// counter_add(ims_charging_cnts_h.active_ro_sessions, -1);
return;

error1:
Expand Down Expand Up @@ -935,13 +936,15 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c

if (!cca) {
LM_ERR("Error in termination CCR.\n");
counter_inc(ims_charging_cnts_h.failed_final_ccrs);
return;
}

ro_cca_data = Ro_parse_CCA_avps(cca);

if (ro_cca_data == NULL) {
LM_DBG("Could not parse CCA message response.\n");
counter_inc(ims_charging_cnts_h.failed_final_ccrs);
return;
}

Expand All @@ -955,6 +958,7 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c
counter_inc(ims_charging_cnts_h.successful_final_ccrs);

error:
counter_inc(ims_charging_cnts_h.failed_final_ccrs);
Ro_free_CCA(ro_cca_data);
if (!is_timeout && cca) {
cdpb.AAAFreeMessage(&cca);
Expand Down Expand Up @@ -1184,6 +1188,7 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
}

counter_inc(ims_charging_cnts_h.initial_ccrs);
counter_inc(ims_charging_cnts_h.active_ro_sessions);

if (free_called_asserted_identity) shm_free(called_asserted_identity.s); // shm_malloc in cscf_get_public_identity_from_requri
return RO_RETURN_BREAK;
Expand Down Expand Up @@ -1305,7 +1310,6 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca,
shm_free(ssd);

counter_inc(ims_charging_cnts_h.successful_initial_ccrs);
counter_inc(ims_charging_cnts_h.active_ro_sessions);

return;

Expand All @@ -1314,6 +1318,8 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca,

error0:
LM_DBG("Trying to reserve credit on initial INVITE failed on cdp callback\n");
// counter_add(ims_charging_cnts_h.active_ro_sessions, -1); /*we bumped active on the original initial ccr sent */
counter_inc(ims_charging_cnts_h.failed_initial_ccrs); /* drop by one as theoretically this is failed initial ccr */
create_cca_return_code(error_code);

if (!is_timeout && cca) {
Expand Down
3 changes: 3 additions & 0 deletions modules/ims_charging/mod.c
Expand Up @@ -21,6 +21,8 @@
#include "../../lib/ims/ims_getters.h"
#include "ro_db_handler.h"
#include "ims_charging_stats.h"
#include "ro_session_hash.h"
#include "ims_charging_stats.h"

MODULE_VERSION

Expand Down Expand Up @@ -57,6 +59,7 @@ client_ro_cfg cfg = { str_init("scscf.ims.smilecoms.com"),
0
};

extern struct ims_charging_counters_h ims_charging_cnts_h;
struct cdp_binds cdpb;
struct dlg_binds dlgb;
cdp_avp_bind_t *cdp_avp;
Expand Down
7 changes: 6 additions & 1 deletion modules/ims_charging/ro_session_hash.h
Expand Up @@ -11,6 +11,7 @@
#include "ro_timer.h"
#include "../../mem/shm_mem.h"
#include "../ims_usrloc_scscf/usrloc.h"
#include "ims_charging_stats.h"
#include <stdlib.h>


Expand All @@ -22,6 +23,8 @@

#define MAX_PANI_LEN 100

extern struct ims_charging_counters_h ims_charging_cnts_h;

enum ro_session_event_type {
pending,
answered,
Expand Down Expand Up @@ -72,7 +75,7 @@ struct ro_session {
int rating_group;
int service_identifier;
unsigned int is_final_allocation;
unsigned int billed;
long billed;
};

/*! entries in the main ro_session table */
Expand Down Expand Up @@ -163,6 +166,8 @@ static inline void unlink_unsafe_ro_session(struct ro_session_entry *ro_session_
ro_session_entry->first = ro_session->next;

ro_session->next = ro_session->prev = 0;

counter_add(ims_charging_cnts_h.active_ro_sessions, -1);

return;
}
Expand Down

0 comments on commit c084e0b

Please sign in to comment.