/* initiate a report if we previously enabled accounting for this t */ static void acc_onreply( struct cell* t, struct sip_msg *reply, int code, void *param ) { /* validation */ if (t->uas.request==0) { DBG("DBG: acc: onreply: no uas.request, local t; skipping\n"); return; } /* acc_onreply is bound to TMCB_REPLY which may be called from _reply, like when FR hits; we should not miss this event for missed calls either */ on_missed(t, reply, code, param ); if (!should_acc_reply(t, code)) return; if (is_log_acc_on(t->uas.request)) acc_log_reply(t, reply, code); #ifdef SQL_ACC if (is_db_acc_on(t->uas.request)) acc_db_reply(t, reply, code); #endif #ifdef RAD_ACC if (is_rad_acc_on(t->uas.request)) acc_rad_reply(t, reply, code); #endif }
static inline void acc_onack( struct cell* t, struct sip_msg *req, struct sip_msg *ack, int code) { if (acc_preparse_req(ack)<0) return; /* set env variables */ env_set_to( ack->to?ack->to:req->to ); env_set_code_status( t->uas.status, 0 ); if (is_log_acc_on(req)) { env_set_text( ACC_ACKED, ACC_ACKED_LEN); acc_log_request( ack ); } #ifdef SQL_ACC if (is_db_acc_on(req)) { if(acc_db_set_table_name(ack, db_table_acc_data, &db_table_acc)<0) { LM_ERR("cannot set acc db table name\n"); return; } acc_db_request( ack ); } #endif #ifdef RAD_ACC if (is_rad_acc_on(req)) { acc_rad_request(ack); } #endif /* DIAMETER */ #ifdef DIAM_ACC if (is_diam_acc_on(req)) { acc_diam_request(ack); } #endif /* run extra acc engines */ acc_run_engines(ack, 0, NULL); }
static void acc_onack( struct cell* t , struct sip_msg *ack, int code, void *param ) { /* only for those guys who insist on seeing ACKs as well */ if (!report_ack) return; /* if acc enabled for flagged transaction, check if flag matches */ if (is_log_acc_on(t->uas.request)) { acc_preparse_req(ack); acc_log_ack(t, ack); } #ifdef SQL_ACC if (is_db_acc_on(t->uas.request)) { acc_preparse_req(ack); acc_db_ack(t, ack); } #endif #ifdef RAD_ACC if (is_rad_acc_on(t->uas.request)) { acc_preparse_req(ack); acc_rad_ack(t,ack); } #endif }
/* initiate a report if we previously enabled accounting for this t */ static inline void acc_onreply( struct cell* t, struct sip_msg *req, struct sip_msg *reply, int code) { str new_uri_bk; int br = -1; hdr_field_t *hdr; sip_msg_t tmsg; sip_msg_t *preq; /* acc_onreply is bound to TMCB_REPLY which may be called from _reply, like when FR hits; we should not miss this event for missed calls either */ if (is_invite(t) && code>=300 && is_mc_on(req) ) on_missed(t, req, reply, code); if (!should_acc_reply(req, reply, code)) return; if(_acc_clone_msg==1) { memcpy(&tmsg, req, sizeof(sip_msg_t)); preq = &tmsg; } else { preq = req; } /* get winning branch index, if set */ if (t->relayed_reply_branch>=0) { br = t->relayed_reply_branch; } else { if(code>=300) { br = tmb.t_get_picked_branch(); } } /* for reply processing, set as new_uri the one from selected branch */ if (br>=0) { new_uri_bk = preq->new_uri; preq->new_uri = t->uac[br].uri; preq->parsed_uri_ok = 0; } else { new_uri_bk.len = -1; new_uri_bk.s = 0; } /* set env variables */ env_set_to( get_rpl_to(t,reply) ); env_set_code_status( code, reply); if ( is_log_acc_on(preq) ) { env_set_text( ACC_ANSWERED, ACC_ANSWERED_LEN); acc_log_request(preq); } #ifdef SQL_ACC if (is_db_acc_on(preq)) { if(acc_db_set_table_name(preq, db_table_acc_data, &db_table_acc)<0) { LM_ERR("cannot set acc db table name\n"); } else { acc_db_request(preq); } } #endif #ifdef RAD_ACC if (is_rad_acc_on(preq)) acc_rad_request(preq); #endif /* DIAMETER */ #ifdef DIAM_ACC if (is_diam_acc_on(preq)) acc_diam_request(preq); #endif /* run extra acc engines */ acc_run_engines(preq, 0, NULL); if (new_uri_bk.len>=0) { req->new_uri = new_uri_bk; req->parsed_uri_ok = 0; } /* free header's parsed structures that were added by resolving acc attributes */ for( hdr=req->headers ; hdr ; hdr=hdr->next ) { if ( hdr->parsed && hdr_allocs_parse(hdr) && (hdr->parsed<(void*)t->uas.request || hdr->parsed>=(void*)t->uas.end_request)) { /* header parsed filed doesn't point inside uas.request memory * chunck -> it was added by resolving acc attributes -> free it as pkg */ DBG("removing hdr->parsed %d\n", hdr->type); clean_hdr_field(hdr); hdr->parsed = 0; } } }