Skip to content

Commit

Permalink
fixed acc to raise the proper event when using acc_evi_request()
Browse files Browse the repository at this point in the history
Credits go to Brett Nemeroff for reporting and testing
  • Loading branch information
razvancrainea committed Apr 3, 2014
1 parent edef0fd commit 24bd3a8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
12 changes: 4 additions & 8 deletions modules/acc/acc.c
Expand Up @@ -1417,22 +1417,18 @@ int acc_evi_request( struct sip_msg *rq, struct sip_msg *rpl)
int n;
int i;
int backup_idx = -1, ret = -1;
event_id_t event = EVI_ERROR;

/*
* if the code is not set, choose the missed calls event
* otherwise, check if the code is negative
*/
event = (!acc_env.code || acc_env.code > 300) ?
acc_missed_event : acc_event;

if (event == EVI_ERROR) {
if (acc_env.event == EVI_ERROR) {
LM_ERR("event not registered %d\n", acc_event);
return -1;
}

/* check if someone is interested in this event */
if (!evi_probe_event(event))
if (!evi_probe_event(acc_env.event))
return 1;

m = core2strar( rq, val_arr );
Expand Down Expand Up @@ -1466,7 +1462,7 @@ int acc_evi_request( struct sip_msg *rq, struct sip_msg *rpl)
backup_idx = m - 1;
evi_params[backup_idx]->next = NULL;

if (evi_raise_event(event, acc_event_params) < 0) {
if (evi_raise_event(acc_env.event, acc_event_params) < 0) {
LM_ERR("cannot raise ACC event\n");
goto end;
}
Expand All @@ -1482,7 +1478,7 @@ int acc_evi_request( struct sip_msg *rq, struct sip_msg *rpl)
backup_idx = i - 1;
evi_params[backup_idx]->next = NULL;

if (evi_raise_event(event, acc_event_params) < 0) {
if (evi_raise_event(acc_env.event, acc_event_params) < 0) {
LM_ERR("cannot raise ACC event\n");
goto end;
}
Expand Down
4 changes: 4 additions & 0 deletions modules/acc/acc.h
Expand Up @@ -112,6 +112,9 @@ int acc_evi_request( struct sip_msg *req, struct sip_msg *rpl);
int acc_evi_cdrs(struct dlg_cell *dlg, struct sip_msg *msg);
int store_evi_extra_values(struct dlg_cell *dlg, struct sip_msg *req,
struct sip_msg *reply);
extern event_id_t acc_cdr_event;
extern event_id_t acc_event;
extern event_id_t acc_missed_event;



Expand All @@ -120,4 +123,5 @@ int acc_diam_init();
int acc_diam_request( struct sip_msg *req, struct sip_msg *rpl);
#endif


#endif
12 changes: 10 additions & 2 deletions modules/acc/acc_logic.c
Expand Up @@ -158,6 +158,11 @@ static inline void env_set_comment(struct acc_param *accp)
acc_env.reason = accp->reason;
}

static inline void env_set_event(event_id_t ev)
{
acc_env.event = ev;
}


static inline int acc_preparse_req(struct sip_msg *req)
{
Expand Down Expand Up @@ -422,6 +427,7 @@ static inline void on_missed(struct cell *t, struct sip_msg *req,
*/

if (is_evi_mc_on(req)) {
env_set_event(acc_missed_event);
acc_evi_request( req, reply );
flags_to_reset |= evi_missed_flag;
}
Expand Down Expand Up @@ -589,8 +595,10 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req,
}
} else {
/* do old accounting */
if ( is_evi_acc_on(req) )
if ( is_evi_acc_on(req) ) {
env_set_event(acc_cdr_event);
acc_evi_request( req, reply );
}

if ( is_log_acc_on(req) ) {
env_set_text( ACC_ANSWERED, ACC_ANSWERED_LEN);
Expand Down Expand Up @@ -631,7 +639,7 @@ static void acc_dlg_callback(struct dlg_cell *dlg, int type,
flags = (unsigned int)(long)(*_params->param);

if (flags & evi_flag) {

env_set_event(acc_cdr_event);
if (acc_evi_cdrs(dlg, _params->msg) < 0) {
LM_ERR("cannot send accounting events\n");
return;
Expand Down
1 change: 1 addition & 0 deletions modules/acc/acc_logic.h
Expand Up @@ -43,6 +43,7 @@ struct acc_enviroment {
struct hdr_field *to;
str text;
time_t ts;
event_id_t event;
};

/* param trasnporter*/
Expand Down

0 comments on commit 24bd3a8

Please sign in to comment.