|
@@ -37,44 +37,62 @@
|
|
|
#include "ts_hash.h"
|
|
|
#include "ts_store.h"
|
|
|
|
|
|
+extern int use_domain;
|
|
|
+
|
|
|
int ts_store(struct sip_msg* msg) {
|
|
|
- struct cell *t;
|
|
|
- str ruri;
|
|
|
+ struct cell *t;
|
|
|
+ str aor;
|
|
|
+ struct sip_uri ruri;
|
|
|
+
|
|
|
ts_urecord_t* r;
|
|
|
int res;
|
|
|
|
|
|
- t = _tmb.t_gett();
|
|
|
- ruri = msg->first_line.u.request.uri;
|
|
|
|
|
|
+
|
|
|
+ if (use_domain) {
|
|
|
+ aor = msg->first_line.u.request.uri;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (parse_uri(msg->first_line.u.request.uri.s, msg->first_line.u.request.uri.len, &ruri)!=0)
|
|
|
+ {
|
|
|
+ LM_ERR("bad uri [%.*s]\n",
|
|
|
+ msg->first_line.u.request.uri.len,
|
|
|
+ msg->first_line.u.request.uri.s);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ aor = ruri.user;
|
|
|
+ }
|
|
|
+
|
|
|
+ t = _tmb.t_gett();
|
|
|
if (!t || t==T_UNDEFINED) {
|
|
|
- LM_ERR("no transaction defined for %.*s\n", ruri.len, ruri.s);
|
|
|
+ LM_ERR("no transaction defined for %.*s\n", aor.len, aor.s);
|
|
|
return -1;
|
|
|
}
|
|
|
-
|
|
|
- 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);
|
|
|
+ LM_DBG("storing transaction %u:%u for r-uri: %.*s\n", t->hash_index, t->label, aor.len, aor.s);
|
|
|
+
|
|
|
+ lock_entry_by_ruri(&aor);
|
|
|
|
|
|
- res = get_ts_urecord(&ruri, &r);
|
|
|
+ res = get_ts_urecord(&aor, &r);
|
|
|
|
|
|
if (res < 0) {
|
|
|
- LM_ERR("failed to retrieve record for %.*s\n", ruri.len, ruri.s);
|
|
|
- unlock_entry_by_ruri(&ruri);
|
|
|
+ LM_ERR("failed to retrieve record for %.*s\n", aor.len, aor.s);
|
|
|
+ unlock_entry_by_ruri(&aor);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
if (res != 0) { /* entry not found for the ruri */
|
|
|
- if (insert_ts_urecord(&ruri, &r) < 0) {
|
|
|
+ if (insert_ts_urecord(&aor, &r) < 0) {
|
|
|
LM_ERR("failed to insert new record structure\n");
|
|
|
- unlock_entry_by_ruri(&ruri);
|
|
|
+ unlock_entry_by_ruri(&aor);
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
insert_ts_transaction(t, msg, r);
|
|
|
- unlock_entry_by_ruri(&ruri);
|
|
|
+ unlock_entry_by_ruri(&aor);
|
|
|
|
|
|
- LM_DBG("transaction %u:%u (ruri: %.*s) inserted\n", t->hash_index, t->label, ruri.len, ruri.s);
|
|
|
+ LM_DBG("transaction %u:%u (ruri: %.*s) inserted\n", t->hash_index, t->label, aor.len, aor.s);
|
|
|
|
|
|
return 1;
|
|
|
}
|