/*! * \brief Show the transactions for a given R-URI * \param rpc RPC node that should be filled * \param c RPC void pointer */ static void rpc_tsilo_lookup(rpc_t *rpc, void *c) { ts_transaction_t* trans; struct ts_urecord* record; str ruri = {0, 0}; int res; void* th; if (rpc->scan(c, "S", &ruri) != 1) { rpc->fault(c, 500, "No RURI to lookup specified"); return; } lock_entry_by_ruri(&ruri); /* look for urecord */ res = get_ts_urecord(&ruri, &record); if (res) { unlock_entry_by_ruri(&ruri); rpc->fault(c, 404, "RURI not found in tsilo table"); return; } if (rpc->add(c, "{", &th) < 0) { unlock_entry_by_ruri(&ruri); rpc->fault(c, 500, "Internal error creating top rpc"); return; } /* add the transactions */ for( trans=record->transactions ; trans ; trans=trans->next) { if (rpc_dump_transaction(rpc, c, th, trans) == -1) { unlock_entry_by_ruri(&ruri); return; } } unlock_entry_by_ruri(&ruri); return; }
int ts_append(struct sip_msg* msg, str *ruri, char *table) { ts_urecord_t* _r; ts_transaction_t* ptr; struct sip_uri p_uri; str *t_uri; int res; int appended; lock_entry_by_ruri(ruri); if (use_domain) { t_uri = ruri; } else { parse_uri(ruri->s, ruri->len, &p_uri); t_uri = &p_uri.user; } res = get_ts_urecord(t_uri, &_r); if (res != 0) { LM_ERR("failed to retrieve record for %.*s\n", ruri->len, ruri->s); unlock_entry_by_ruri(ruri); return -1; } ptr = _r->transactions; while(ptr) { LM_DBG("transaction %u:%u found for %.*s, going to append branches\n",ptr->tindex, ptr->tlabel, ruri->len, ruri->s); appended = ts_append_to(msg, ptr->tindex, ptr->tlabel, table, ruri); if (appended > 0) update_stat(added_branches, appended); ptr = ptr->next; } unlock_entry_by_ruri(ruri); return 1; }
int t_store(struct sip_msg* msg) { struct cell *t; str ruri; ts_urecord_t* r; int res; t = _tmb.t_gett(); ruri = msg->first_line.u.request.uri; LM_DBG("storing transaction %u:%u for r-uri: %.*s\n", t->hash_index, t->label, ruri.len, ruri.s); lock_entry_by_ruri(&ruri); res = get_ts_urecord(&ruri, &r); if (res < 0) { LM_ERR("failed to retrieve record for %.*s\n", ruri.len, ruri.s); unlock_entry_by_ruri(&ruri); return -1; } if (res != 0) { /* entry not found for the ruri */ if (insert_ts_urecord(&ruri, &r) < 0) { LM_ERR("failed to insert new record structure\n"); unlock_entry_by_ruri(&ruri); return -1; } } insert_ts_transaction(t, msg, r); unlock_entry_by_ruri(&ruri); LM_DBG("transaction %u:%u (ruri: %.*s) inserted\n", t->hash_index, t->label, ruri.len, ruri.s); return 1; }