Module: kamailio
Branch: master
Commit: f59dacf7993da83553cd67de516fc31f493d2a7d
URL:
https://github.com/kamailio/kamailio/commit/f59dacf7993da83553cd67de516fc31…
Author: Stefan-Cristian Mititelu <stefan-cristian.mititelu(a)1and1.ro>
Committer: Stefan-Cristian Mititelu <stefan-cristian.mititelu(a)1and1.ro>
Date: 2024-01-19T15:54:24+02:00
p_usrloc: Add missing api function get_udomain()
When registrar kemi save()/save_uri() function is called,
then usrloc api function get_udomain() is called.
This usrloc api function is missing in p_usrloc module
and results in a segfault.
---
Modified: src/modules/p_usrloc/dlist.c
Modified: src/modules/p_usrloc/dlist.h
Modified: src/modules/p_usrloc/usrloc.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f59dacf7993da83553cd67de516fc31…
Patch:
https://github.com/kamailio/kamailio/commit/f59dacf7993da83553cd67de516fc31…
---
diff --git a/src/modules/p_usrloc/dlist.c b/src/modules/p_usrloc/dlist.c
index fa66b20b9a7..0a7080e2c63 100644
--- a/src/modules/p_usrloc/dlist.c
+++ b/src/modules/p_usrloc/dlist.c
@@ -171,3 +171,42 @@ int synchronize_all_udomains(void)
LM_INFO("not available with partitioned interface\n");
return res;
}
+
+/*!
+ * \brief Registers a new domain with usrloc
+ *
+ * Find and return a usrloc domain (location table)
+ * \param _n domain name
+ * \param _d usrloc domain
+ * \return 0 on success, -1 on failure
+ */
+int get_udomain(const char *_n, udomain_t **_d)
+{
+ struct domain_list_item *item;
+ str s;
+
+ if(_n == NULL) {
+ LM_ERR("null location table name\n");
+ goto notfound;
+ }
+
+ s.s = (char *)_n;
+ s.len = strlen(_n);
+ if(s.len <= 0) {
+ LM_ERR("empty location table name\n");
+ goto notfound;
+ }
+
+ item = find_dlist(&s);
+ if(item == NULL) {
+ LM_ERR("domain %s not found.\n", _n);
+ goto notfound;
+ }
+
+ *_d = &item->domain;
+ return 0;
+
+notfound:
+ *_d = NULL;
+ return -1;
+}
diff --git a/src/modules/p_usrloc/dlist.h b/src/modules/p_usrloc/dlist.h
index 20152694f4f..662847fb131 100644
--- a/src/modules/p_usrloc/dlist.h
+++ b/src/modules/p_usrloc/dlist.h
@@ -118,5 +118,13 @@ int get_all_ucontacts(void *, int, unsigned int, unsigned int
part_idx,
*/
int find_domain(str *_d, udomain_t **_p);
+/*!
+ * \brief Find and return usrloc domain
+ *
+ * \param _n domain name
+ * \param _d usrloc domain (location table)
+ * \return 0 on success, -1 on failure
+ */
+int get_udomain(const char *_n, udomain_t **_d);
#endif
diff --git a/src/modules/p_usrloc/usrloc.c b/src/modules/p_usrloc/usrloc.c
index 6de32f2eeda..221f2d68262 100644
--- a/src/modules/p_usrloc/usrloc.c
+++ b/src/modules/p_usrloc/usrloc.c
@@ -79,5 +79,6 @@ int bind_usrloc(usrloc_api_t *api)
api->db_mode = db_mode;
api->nat_flag = nat_bflag;
+ api->get_udomain = get_udomain;
return 0;
}