static int save_siptrace(struct sip_msg *msg,struct usr_avp *avp, int_str *first_val,db_key_t *keys,db_val_t *vals) { if (duplicate_with_hep) trace_send_hep_duplicate(&db_vals[0].val.blob_val, &db_vals[4].val.str_val, &db_vals[5].val.str_val, db_vals[6].val.int_val, &db_vals[7].val.str_val, &db_vals[8].val.str_val, db_vals[9].val.int_val); else trace_send_duplicate(db_vals[0].val.blob_val.s, db_vals[0].val.blob_val.len); if(trace_to_database_flag!=NULL && *trace_to_database_flag!=0) { LM_DBG("saving siptrace\n"); db_funcs.use_table(db_con, siptrace_get_table()); if (flag_trace_is_set(msg) && insert_siptrace_flag(msg,keys,vals) < 0) return -1; if (avp==NULL) return 0; if (insert_siptrace_avp(avp,first_val,keys,vals) < 0) return -1; } return 0; }
static int sip_trace_store(struct _siptrace_data *sto, struct dest_info *dst) { if(sto==NULL) { LM_DBG("invalid parameter\n"); return -1; } gettimeofday(&sto->tv, NULL); if (sip_trace_xheaders_read(sto) != 0) return -1; int ret = sip_trace_store_db(sto); if (sip_trace_xheaders_write(sto) != 0) return -1; if(hep_mode_on) trace_send_hep_duplicate(&sto->body, &sto->fromip, &sto->toip, dst); else trace_send_duplicate(sto->body.s, sto->body.len, dst); if (sip_trace_xheaders_free(sto) != 0) return -1; return ret; }
int siptrace_net_data_send(void *data) { sr_net_info_t *nd; struct dest_info new_dst; struct _siptrace_data sto; if(data==0) return -1; nd = (sr_net_info_t*)data; if(nd->dst==NULL || nd->data.s==NULL || nd->data.len<=0) return -1; new_dst=*nd->dst; new_dst.send_sock=get_send_socket(0, &nd->dst->to, nd->dst->proto); memset(&sto, 0, sizeof(struct _siptrace_data)); sto.body.s = nd->data.s; sto.body.len = nd->data.len; if (unlikely(new_dst.send_sock==0)) { LM_WARN("no sending socket found\n"); strcpy(sto.fromip_buff, "any:255.255.255.255:5060"); } else { strncpy(sto.fromip_buff, new_dst.send_sock->sock_str.s, new_dst.send_sock->sock_str.len); } sto.fromip.s = sto.fromip_buff; sto.fromip.len = strlen(sto.fromip_buff); siptrace_copy_proto(new_dst.send_sock->proto, sto.toip_buff); strcat(sto.toip_buff, suip2a(&new_dst.to, sizeof(new_dst.to))); strcat(sto.toip_buff,":"); strcat(sto.toip_buff, int2str((int)su_getport(&new_dst.to), NULL)); sto.toip.s = sto.toip_buff; sto.toip.len = strlen(sto.toip_buff); sto.dir = "out"; trace_send_hep_duplicate(&sto.body, &sto.fromip, &sto.toip, NULL); return 0; }
int siptrace_net_data_recv(void *data) { sr_net_info_t *nd; struct _siptrace_data sto; if(data==0) return -1; nd = (sr_net_info_t*)data; if(nd->rcv==NULL || nd->data.s==NULL || nd->data.len<=0) return -1; memset(&sto, 0, sizeof(struct _siptrace_data)); sto.body.s = nd->data.s; sto.body.len = nd->data.len; siptrace_copy_proto(nd->rcv->proto, sto.fromip_buff); strcat(sto.fromip_buff, ip_addr2a(&nd->rcv->src_ip)); strcat(sto.fromip_buff,":"); strcat(sto.fromip_buff, int2str(nd->rcv->src_port, NULL)); sto.fromip.s = sto.fromip_buff; sto.fromip.len = strlen(sto.fromip_buff); siptrace_copy_proto(nd->rcv->proto, sto.toip_buff); strcat(sto.toip_buff, ip_addr2a(&nd->rcv->dst_ip)); strcat(sto.toip_buff,":"); strcat(sto.toip_buff, int2str(nd->rcv->dst_port, NULL)); sto.toip.s = sto.toip_buff; sto.toip.len = strlen(sto.toip_buff); sto.dir = "in"; trace_send_hep_duplicate(&sto.body, &sto.fromip, &sto.toip, NULL); return 0; }