static void trace_sl_ack_in(sl_cbp_t *slcbp) { sip_msg_t *req; LM_DBG("storing ack...\n"); req = slcbp->req; sip_trace(req, 0, 0); }
/* siptrace wrapper that verifies if the trace is on */ static int sip_trace_w(struct sip_msg *msg) { if( trace_is_off() ) { LM_DBG("trace off...\n"); return -1; } return sip_trace(msg); }
static void trace_transaction(struct dlg_cell* dlg, int type, struct dlg_cb_params * params) { unsigned char n; static int_str avp_value; str *name; if (params->msg==NULL) return; /* restore the AVPs from the dialog values */ n = 0; do { name = generate_val_name(n); if (dlgb.fetch_dlg_value( dlg, name, &avp_value.s, 0)!=0) break; add_avp( traced_user_avp_type|AVP_VAL_STR, traced_user_avp, avp_value); n++; }while(1); /* set the flag */ if ( dlgb.fetch_dlg_value( dlg, &st_flag_val, &avp_value.s, 0)==0 ) params->msg->flags |= trace_flag; params->msg->msg_flags |= FL_USE_SIPTRACE; /* trace current request */ sip_trace(params->msg); if(tmb.register_tmcb( params->msg, 0, TMCB_REQUEST_BUILT, trace_onreq_out, 0, 0) <=0) { LM_ERR("can't register trace_onreq_out\n"); return; } /* doesn't make sense to register the reply callbacks for ACK or PRACK */ if (params->msg->REQ_METHOD & (METHOD_ACK | METHOD_PRACK)) return; if(tmb.register_tmcb( params->msg, 0, TMCB_RESPONSE_IN, trace_onreply_in, 0, 0) <=0) { LM_ERR("can't register trace_onreply_in\n"); return; } if(tmb.register_tmcb( params->msg, 0, TMCB_RESPONSE_OUT, trace_onreply_out, 0, 0) <=0) { LM_ERR("can't register trace_onreply_out\n"); return; } }
static void siptrace_dlg_cancel(struct cell* t, int type, struct tmcb_params *param) { int_str avp_value; struct sip_msg *req; req = param->req; LM_DBG("Tracing incoming cancel due to trace_dialog() \n"); /* set the flag */ if ( dlgb.fetch_dlg_value( (struct dlg_cell*)t->dialog_ctx, &st_flag_val, &avp_value.s, 0)==0 ) req->flags |= trace_flag; req->msg_flags |= FL_USE_SIPTRACE; /* trace current request */ sip_trace(req); }
static int trace_dialog(struct sip_msg *msg) { unsigned char n; struct dlg_cell* dlg; struct usr_avp *avp; static int_str avp_value; str *name; if (!msg) { LM_ERR("no msg specified\n"); return -1; } if (trace_is_off()) { LM_DBG("Trace if off...\n"); return -1; } /* any need to do tracing here ? check the triggers */ avp = traced_user_avp<0 ? NULL : search_first_avp(traced_user_avp_type, traced_user_avp, &avp_value, 0); if (avp==NULL && (msg->flags&trace_flag)==0) { LM_DBG("Nothing to trace here\n"); return -1; } if (dlgb.create_dlg(msg,0)<1) { LM_ERR("failed to create dialog\n"); return -1; } dlg = dlgb.get_dlg(); if (dlg==NULL) { LM_CRIT("BUG: no dialog found after create dialog\n"); return -1; } if(dlgb.register_dlgcb(dlg, DLGCB_REQ_WITHIN|DLGCB_TERMINATED, trace_transaction,0,0)!=0) { LM_ERR("failed to register dialog callback\n"); return -1; } /* store in dialog the user avps for tracing ; we will restore them for each transactin from the dialog */ if(traced_user_avp>=0) { n = 0; while(avp!=NULL) { /* generate a name */ name = generate_val_name(n); if (!is_avp_str_val(avp)) avp_value.s.s=int2str(avp_value.n, &avp_value.s.len); /* add the avp value as dialog var */ dlgb.store_dlg_value( dlg, name, &avp_value.s); /* next avp */ avp = search_next_avp( avp, &avp_value); n++; } } /* set the flag to trace the rest of the transaction */ if (msg->flags&trace_flag) { avp_value.s.s = "1"; avp_value.s.len = 1; dlgb.store_dlg_value( dlg, &st_flag_val, &avp_value.s); } /* trace current request */ sip_trace(msg); /* we also want to catch the incoming cancel */ if ( tmb.register_tmcb( msg, NULL,TMCB_TRANS_CANCELLED, siptrace_dlg_cancel, NULL, NULL)<0 ) { LM_ERR("failed to register trans cancelled TMCB\n"); } return 1; }
static void trace_sl_ack_in( unsigned int types, struct sip_msg* req, struct sl_cb_param *sl_param) { LM_DBG("storing ack...\n"); sip_trace(req, 0, 0); }