|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
From f04851984efe68c101d3d80b9e02a722a6c8b80a Mon Sep 17 00:00:00 2001
|
|
|
|
|
From 63e8b7e2d31d86930111bced932329d612a268f7 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
|
|
|
|
Date: Wed, 6 Aug 2014 16:45:00 +0200
|
|
|
|
|
Subject: [PATCH] MT#8517 add lookup force dbflag
|
|
|
|
|
@ -9,16 +9,18 @@ Now we can force lookup to read from DB
|
|
|
|
|
modules/registrar/api.h | 4 +++
|
|
|
|
|
modules/registrar/lookup.c | 36 ++++++++++++++++++---
|
|
|
|
|
modules/registrar/lookup.h | 6 ++++
|
|
|
|
|
modules/registrar/reg_mod.c | 32 +++++++++++++++---
|
|
|
|
|
modules/registrar/reg_mod.c | 38 ++++++++++++++++++++++
|
|
|
|
|
modules/usrloc/udomain.c | 79 ++++++++++++++++++++++++++++++++++++++++++---
|
|
|
|
|
modules/usrloc/udomain.h | 23 +++++++++++++
|
|
|
|
|
modules/usrloc/usrloc.c | 3 ++
|
|
|
|
|
modules/usrloc/usrloc.h | 7 ++++
|
|
|
|
|
9 files changed, 191 insertions(+), 14 deletions(-)
|
|
|
|
|
9 files changed, 202 insertions(+), 9 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/modules/registrar/api.c b/modules/registrar/api.c
|
|
|
|
|
index a8c5b50..90adf91 100644
|
|
|
|
|
--- a/modules/registrar/api.c
|
|
|
|
|
+++ b/modules/registrar/api.c
|
|
|
|
|
@@ -96,6 +96,21 @@
|
|
|
|
|
@@ -96,6 +96,21 @@ int regapi_lookup_uri(struct sip_msg *msg, char *table, str * uri)
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@ -40,9 +42,11 @@ Now we can force lookup to read from DB
|
|
|
|
|
int regapi_registered(struct sip_msg *msg, char *table)
|
|
|
|
|
{
|
|
|
|
|
udomain_t* d;
|
|
|
|
|
diff --git a/modules/registrar/api.h b/modules/registrar/api.h
|
|
|
|
|
index b3109de..148fd33 100644
|
|
|
|
|
--- a/modules/registrar/api.h
|
|
|
|
|
+++ b/modules/registrar/api.h
|
|
|
|
|
@@ -43,6 +43,9 @@
|
|
|
|
|
@@ -43,6 +43,9 @@ int regapi_lookup(struct sip_msg *msg, char *table);
|
|
|
|
|
typedef int (*regapi_lookup_uri_f)(struct sip_msg *msg, char *table, str *uri);
|
|
|
|
|
int regapi_lookup_uri(struct sip_msg *msg, char *table, str *uri);
|
|
|
|
|
|
|
|
|
|
@ -52,7 +56,7 @@ Now we can force lookup to read from DB
|
|
|
|
|
typedef int (*regapi_set_q_override_f)(struct sip_msg *msg, str *new_q);
|
|
|
|
|
int regapi_set_q_override(struct sip_msg *msg, str *new_q);
|
|
|
|
|
|
|
|
|
|
@@ -54,6 +57,7 @@
|
|
|
|
|
@@ -54,6 +57,7 @@ typedef struct registrar_api {
|
|
|
|
|
regapi_save_uri_f save_uri;
|
|
|
|
|
regapi_lookup_f lookup;
|
|
|
|
|
regapi_lookup_uri_f lookup_uri;
|
|
|
|
|
@ -60,9 +64,11 @@ Now we can force lookup to read from DB
|
|
|
|
|
regapi_lookup_f registered;
|
|
|
|
|
regapi_set_q_override_f set_q_override;
|
|
|
|
|
} registrar_api_t;
|
|
|
|
|
diff --git a/modules/registrar/lookup.c b/modules/registrar/lookup.c
|
|
|
|
|
index 2b3ad96..176bbbd 100644
|
|
|
|
|
--- a/modules/registrar/lookup.c
|
|
|
|
|
+++ b/modules/registrar/lookup.c
|
|
|
|
|
@@ -87,7 +87,7 @@
|
|
|
|
|
@@ -87,7 +87,7 @@ int reg_cmp_instances(str *i1, str *i2)
|
|
|
|
|
* -2 : found but method not allowed
|
|
|
|
|
* -3 : error
|
|
|
|
|
*/
|
|
|
|
|
@ -71,7 +77,7 @@ Now we can force lookup to read from DB
|
|
|
|
|
{
|
|
|
|
|
urecord_t* r;
|
|
|
|
|
str aor, uri;
|
|
|
|
|
@@ -109,7 +109,7 @@
|
|
|
|
|
@@ -109,7 +109,7 @@ int lookup(struct sip_msg* _m, udomain_t* _d, str* _uri)
|
|
|
|
|
|
|
|
|
|
if (_m->new_uri.s) uri = _m->new_uri;
|
|
|
|
|
else uri = _m->first_line.u.request.uri;
|
|
|
|
|
@ -80,7 +86,7 @@ Now we can force lookup to read from DB
|
|
|
|
|
if (extract_aor((_uri)?_uri:&uri, &aor, &puri) < 0) {
|
|
|
|
|
LM_ERR("failed to extract address of record\n");
|
|
|
|
|
return -3;
|
|
|
|
|
@@ -153,7 +153,10 @@
|
|
|
|
|
@@ -153,7 +153,10 @@ int lookup(struct sip_msg* _m, udomain_t* _d, str* _uri)
|
|
|
|
|
{
|
|
|
|
|
/* aor or pub-gruu lookup */
|
|
|
|
|
ul.lock_udomain(_d, &aor);
|
|
|
|
|
@ -92,7 +98,7 @@ Now we can force lookup to read from DB
|
|
|
|
|
if (res > 0) {
|
|
|
|
|
LM_DBG("'%.*s' Not found in usrloc\n", aor.len, ZSW(aor.s));
|
|
|
|
|
ul.unlock_udomain(_d, &aor);
|
|
|
|
|
@@ -196,7 +199,10 @@
|
|
|
|
|
@@ -196,7 +199,10 @@ int lookup(struct sip_msg* _m, udomain_t* _d, str* _uri)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* temp-gruu lookup */
|
|
|
|
|
@ -104,7 +110,7 @@ Now we can force lookup to read from DB
|
|
|
|
|
if(res<0) {
|
|
|
|
|
LM_DBG("temp gruu '%.*s' not found in usrloc\n", aor.len, ZSW(aor.s));
|
|
|
|
|
return -1;
|
|
|
|
|
@@ -353,6 +359,28 @@
|
|
|
|
|
@@ -353,6 +359,28 @@ done:
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -133,6 +139,8 @@ Now we can force lookup to read from DB
|
|
|
|
|
|
|
|
|
|
int reset_ruri_branch(sip_msg_t *msg)
|
|
|
|
|
{
|
|
|
|
|
diff --git a/modules/registrar/lookup.h b/modules/registrar/lookup.h
|
|
|
|
|
index e2703ad..3da81f4 100644
|
|
|
|
|
--- a/modules/registrar/lookup.h
|
|
|
|
|
+++ b/modules/registrar/lookup.h
|
|
|
|
|
@@ -42,6 +42,12 @@
|
|
|
|
|
@ -148,43 +156,42 @@ Now we can force lookup to read from DB
|
|
|
|
|
* Lookup r-uri and additional branches in usrloc
|
|
|
|
|
*/
|
|
|
|
|
int lookup_branches(sip_msg_t *msg, udomain_t *d);
|
|
|
|
|
diff --git a/modules/registrar/reg_mod.c b/modules/registrar/reg_mod.c
|
|
|
|
|
index ce0d823..53f3c7f 100644
|
|
|
|
|
--- a/modules/registrar/reg_mod.c
|
|
|
|
|
+++ b/modules/registrar/reg_mod.c
|
|
|
|
|
@@ -90,7 +90,7 @@
|
|
|
|
|
static void mod_destroy(void);
|
|
|
|
|
@@ -91,6 +91,7 @@ static void mod_destroy(void);
|
|
|
|
|
static int w_save2(struct sip_msg* _m, char* _d, char* _cflags);
|
|
|
|
|
static int w_save3(struct sip_msg* _m, char* _d, char* _cflags, char* _uri);
|
|
|
|
|
-static int w_lookup(struct sip_msg* _m, char* _d, char* _p2);
|
|
|
|
|
+static int w_lookup(struct sip_msg* _m, char* _d, char* _p2, char* _dbflag);
|
|
|
|
|
static int w_lookup(struct sip_msg* _m, char* _d, char* _p2);
|
|
|
|
|
+static int w_lookup3(struct sip_msg* _m, char* _d, char* _p2, char* _dbflag);
|
|
|
|
|
static int w_lookup_branches(struct sip_msg* _m, char* _d, char* _p2);
|
|
|
|
|
static int w_registered(struct sip_msg* _m, char* _d, char* _uri);
|
|
|
|
|
static int w_unregister(struct sip_msg* _m, char* _d, char* _uri);
|
|
|
|
|
@@ -180,6 +180,8 @@
|
|
|
|
|
@@ -181,6 +182,8 @@ static cmd_export_t cmds[] = {
|
|
|
|
|
REQUEST_ROUTE | FAILURE_ROUTE },
|
|
|
|
|
{"lookup", (cmd_function)w_lookup, 2, domain_uri_fixup, 0,
|
|
|
|
|
REQUEST_ROUTE | FAILURE_ROUTE },
|
|
|
|
|
+ {"lookup", (cmd_function)w_lookup, 3, domain_uri_fixup, 0,
|
|
|
|
|
+ {"lookup", (cmd_function)w_lookup3, 3, domain_uri_fixup, 0,
|
|
|
|
|
+ REQUEST_ROUTE | FAILURE_ROUTE },
|
|
|
|
|
{"registered", (cmd_function)w_registered, 1, domain_uri_fixup, 0,
|
|
|
|
|
REQUEST_ROUTE | FAILURE_ROUTE },
|
|
|
|
|
{"registered", (cmd_function)w_registered, 2, domain_uri_fixup, 0,
|
|
|
|
|
@@ -470,16 +472,23 @@
|
|
|
|
|
@@ -475,6 +478,28 @@ static int w_lookup(struct sip_msg* _m, char* _d, char* _uri)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief
|
|
|
|
|
* Wrapper to lookup(location)
|
|
|
|
|
*/
|
|
|
|
|
-static int w_lookup(struct sip_msg* _m, char* _d, char* _uri)
|
|
|
|
|
+static int w_lookup(struct sip_msg* _m, char* _d, char* _uri, char* _dbflag)
|
|
|
|
|
{
|
|
|
|
|
- str uri = {0};
|
|
|
|
|
+ str uri = STR_NULL;
|
|
|
|
|
+ * Wrapper to lookup[db](location)
|
|
|
|
|
+ */
|
|
|
|
|
+static int w_lookup3(struct sip_msg* _m, char* _d, char* _uri, char* _dbflag)
|
|
|
|
|
+{
|
|
|
|
|
+ str uri = {STR_NULL};
|
|
|
|
|
+ unsigned int dbflag = 0;
|
|
|
|
|
if(_uri!=NULL && (fixup_get_svalue(_m, (gparam_p)_uri, &uri)!=0 || uri.len<=0))
|
|
|
|
|
{
|
|
|
|
|
LM_ERR("invalid uri parameter\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
-
|
|
|
|
|
- return lookup(_m, (udomain_t*)_d, (uri.len>0)?&uri:NULL);
|
|
|
|
|
+ if(_uri!=NULL && (fixup_get_svalue(_m, (gparam_p)_uri, &uri)!=0 || uri.len<=0))
|
|
|
|
|
+ {
|
|
|
|
|
+ LM_ERR("invalid uri parameter\n");
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(_dbflag!=NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ dbflag = (unsigned long)_dbflag;
|
|
|
|
|
@ -193,10 +200,13 @@ Now we can force lookup to read from DB
|
|
|
|
|
+ return lookup_db(_m, (udomain_t*)_d, (uri.len>0)?&uri:NULL);
|
|
|
|
|
+ else
|
|
|
|
|
+ return lookup(_m, (udomain_t*)_d, (uri.len>0)?&uri:NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief
|
|
|
|
|
@@ -556,10 +565,23 @@
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/*! \brief
|
|
|
|
|
* Wrapper to lookup_branches(location)
|
|
|
|
|
*/
|
|
|
|
|
static int w_lookup_branches(sip_msg_t* _m, char* _d, char* _p2)
|
|
|
|
|
@@ -548,10 +573,23 @@ static int domain_fixup(void** param, int param_no)
|
|
|
|
|
*/
|
|
|
|
|
static int domain_uri_fixup(void** param, int param_no)
|
|
|
|
|
{
|
|
|
|
|
@ -220,9 +230,11 @@ Now we can force lookup to read from DB
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
diff --git a/modules/usrloc/udomain.c b/modules/usrloc/udomain.c
|
|
|
|
|
index 4178906..41f7847 100644
|
|
|
|
|
--- a/modules/usrloc/udomain.c
|
|
|
|
|
+++ b/modules/usrloc/udomain.c
|
|
|
|
|
@@ -993,14 +993,16 @@
|
|
|
|
|
@@ -993,14 +993,16 @@ int insert_urecord(udomain_t* _d, str* _aor, struct urecord** _r)
|
|
|
|
|
* \param _d domain to search the record
|
|
|
|
|
* \param _aor address of record
|
|
|
|
|
* \param _r new created record
|
|
|
|
|
@ -241,7 +253,7 @@ Now we can force lookup to read from DB
|
|
|
|
|
/* search in cache */
|
|
|
|
|
aorhash = ul_get_aorhash(_aor);
|
|
|
|
|
sl = aorhash&(_d->size-1);
|
|
|
|
|
@@ -1034,10 +1036,12 @@
|
|
|
|
|
@@ -1034,10 +1036,12 @@ int get_urecord(udomain_t* _d, str* _aor, struct urecord** _r)
|
|
|
|
|
* \param _ruid record internal unique id
|
|
|
|
|
* \param _r store pointer to location record
|
|
|
|
|
* \param _c store pointer to contact structure
|
|
|
|
|
@ -256,7 +268,7 @@ Now we can force lookup to read from DB
|
|
|
|
|
{
|
|
|
|
|
unsigned int sl, i;
|
|
|
|
|
urecord_t* r;
|
|
|
|
|
@@ -1046,7 +1050,7 @@
|
|
|
|
|
@@ -1046,7 +1050,7 @@ int get_urecord_by_ruid(udomain_t* _d, unsigned int _aorhash,
|
|
|
|
|
sl = _aorhash&(_d->size-1);
|
|
|
|
|
lock_ulslot(_d, sl);
|
|
|
|
|
|
|
|
|
|
@ -265,7 +277,7 @@ Now we can force lookup to read from DB
|
|
|
|
|
/* search in cache */
|
|
|
|
|
r = _d->table[sl].first;
|
|
|
|
|
|
|
|
|
|
@@ -1089,6 +1093,71 @@
|
|
|
|
|
@@ -1089,6 +1093,71 @@ int get_urecord_by_ruid(udomain_t* _d, unsigned int _aorhash,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
@ -337,9 +349,11 @@ Now we can force lookup to read from DB
|
|
|
|
|
* \brief Delete a urecord from domain
|
|
|
|
|
* \param _d domain where the record should be deleted
|
|
|
|
|
* \param _aor address of record
|
|
|
|
|
diff --git a/modules/usrloc/udomain.h b/modules/usrloc/udomain.h
|
|
|
|
|
index 6f2d295..215c773 100644
|
|
|
|
|
--- a/modules/usrloc/udomain.h
|
|
|
|
|
+++ b/modules/usrloc/udomain.h
|
|
|
|
|
@@ -204,6 +204,29 @@
|
|
|
|
|
@@ -204,6 +204,29 @@ int get_urecord_by_ruid(udomain_t* _d, unsigned int _aorhash,
|
|
|
|
|
str *_ruid, struct urecord** _r, struct ucontact** _c);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
@ -369,9 +383,11 @@ Now we can force lookup to read from DB
|
|
|
|
|
* \brief Delete a urecord from domain
|
|
|
|
|
* \param _d domain where the record should be deleted
|
|
|
|
|
* \param _aor address of record
|
|
|
|
|
diff --git a/modules/usrloc/usrloc.c b/modules/usrloc/usrloc.c
|
|
|
|
|
index 1399bd5..89acfb9 100644
|
|
|
|
|
--- a/modules/usrloc/usrloc.c
|
|
|
|
|
+++ b/modules/usrloc/usrloc.c
|
|
|
|
|
@@ -87,6 +87,9 @@
|
|
|
|
|
@@ -86,6 +86,9 @@ int bind_usrloc(usrloc_api_t* api)
|
|
|
|
|
api->db_mode = db_mode;
|
|
|
|
|
api->nat_flag = nat_bflag;
|
|
|
|
|
|
|
|
|
|
@ -381,9 +397,11 @@ Now we can force lookup to read from DB
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diff --git a/modules/usrloc/usrloc.h b/modules/usrloc/usrloc.h
|
|
|
|
|
index 82490ae..8e93f66 100644
|
|
|
|
|
--- a/modules/usrloc/usrloc.h
|
|
|
|
|
+++ b/modules/usrloc/usrloc.h
|
|
|
|
|
@@ -153,6 +153,11 @@
|
|
|
|
|
@@ -151,6 +151,11 @@ typedef int (*get_urecord_t)(struct udomain* _d, str* _aor, struct urecord** _r)
|
|
|
|
|
typedef int (*get_urecord_by_ruid_t)(udomain_t* _d, unsigned int _aorhash,
|
|
|
|
|
str *_ruid, struct urecord** _r, struct ucontact** _c);
|
|
|
|
|
|
|
|
|
|
@ -395,7 +413,7 @@ Now we can force lookup to read from DB
|
|
|
|
|
typedef int (*delete_urecord_t)(struct udomain* _d, str* _aor, struct urecord* _r);
|
|
|
|
|
|
|
|
|
|
typedef int (*delete_urecord_by_ruid_t)(struct udomain* _d, str* _ruid);
|
|
|
|
|
@@ -211,6 +216,7 @@
|
|
|
|
|
@@ -205,6 +210,7 @@ typedef struct usrloc_api {
|
|
|
|
|
delete_urecord_t delete_urecord;
|
|
|
|
|
delete_urecord_by_ruid_t delete_urecord_by_ruid;
|
|
|
|
|
get_urecord_t get_urecord;
|
|
|
|
|
@ -403,7 +421,7 @@ Now we can force lookup to read from DB
|
|
|
|
|
lock_udomain_t lock_udomain;
|
|
|
|
|
unlock_udomain_t unlock_udomain;
|
|
|
|
|
|
|
|
|
|
@@ -220,6 +226,7 @@
|
|
|
|
|
@@ -214,6 +220,7 @@ typedef struct usrloc_api {
|
|
|
|
|
get_ucontact_t get_ucontact;
|
|
|
|
|
|
|
|
|
|
get_urecord_by_ruid_t get_urecord_by_ruid;
|
|
|
|
|
@ -411,3 +429,6 @@ Now we can force lookup to read from DB
|
|
|
|
|
get_ucontact_by_instance_t get_ucontact_by_instance;
|
|
|
|
|
|
|
|
|
|
update_ucontact_t update_ucontact;
|
|
|
|
|
--
|
|
|
|
|
2.1.0.rc1
|
|
|
|
|
|
|
|
|
|
|