Module: kamailio
Branch: master
Commit: 26ba1d9f42c77362de5ceb185d2fc1d1bb3f2d0c
URL:
https://github.com/kamailio/kamailio/commit/26ba1d9f42c77362de5ceb185d2fc1d…
Author: Xenofon Karamanos <xk(a)gilawa.com>
Committer: Henning Westerholt <hw(a)gilawa.com>
Date: 2023-11-21T08:50:18+01:00
dmq: Add find dmq node by IP
- Add find_dmq_node_ip
- Add cmp_dmq_node_ip
- Add check in notification peer
---
Modified: src/modules/dmq/dmqnode.c
Modified: src/modules/dmq/dmqnode.h
Modified: src/modules/dmq/notification_peer.c
---
Diff:
https://github.com/kamailio/kamailio/commit/26ba1d9f42c77362de5ceb185d2fc1d…
Patch:
https://github.com/kamailio/kamailio/commit/26ba1d9f42c77362de5ceb185d2fc1d…
---
diff --git a/src/modules/dmq/dmqnode.c b/src/modules/dmq/dmqnode.c
index 75bfdb7dbef..28b2b3e5f7b 100644
--- a/src/modules/dmq/dmqnode.c
+++ b/src/modules/dmq/dmqnode.c
@@ -91,6 +91,18 @@ int cmp_dmq_node(dmq_node_t *node, dmq_node_t *cmpnode)
&& (node->uri.proto == cmpnode->uri.proto);
}
+/**
+ * @brief compare dmq node ip addresses
+ */
+int cmp_dmq_node_ip(dmq_node_t *node, dmq_node_t *cmpnode)
+{
+ if(!node || !cmpnode) {
+ LM_ERR("cmp_dmq_node_ip - null node received\n");
+ return -1;
+ }
+ return ip_addr_cmp(&node->ip_address, &cmpnode->ip_address);
+}
+
/**
* @brief get the value of a parameter
*/
@@ -271,6 +283,21 @@ dmq_node_t *find_dmq_node(dmq_node_list_t *list, dmq_node_t *node)
return NULL;
}
+/**
+ * @brief find dmq node ip
+ */
+dmq_node_t *find_dmq_node_ip(dmq_node_list_t *list, dmq_node_t *node)
+{
+ dmq_node_t *cur = list->nodes;
+ while(cur) {
+ if(cmp_dmq_node_ip(cur, node)) {
+ return cur;
+ }
+ cur = cur->next;
+ }
+ return NULL;
+}
+
/**
* @brief duplicate dmq node
*/
diff --git a/src/modules/dmq/dmqnode.h b/src/modules/dmq/dmqnode.h
index cba9968e106..dad5dd23c52 100644
--- a/src/modules/dmq/dmqnode.h
+++ b/src/modules/dmq/dmqnode.h
@@ -68,9 +68,11 @@ dmq_node_t *add_dmq_node(dmq_node_list_t *list, str *uri);
dmq_node_t *find_dmq_node(dmq_node_list_t *list, dmq_node_t *node);
dmq_node_t *find_dmq_node_uri(dmq_node_list_t *list, str *uri);
dmq_node_t *find_dmq_node_uri2(str *uri);
+dmq_node_t *find_dmq_node_ip(dmq_node_list_t *list, dmq_node_t *node);
int del_dmq_node(dmq_node_list_t *list, dmq_node_t *node);
int dmq_node_del_by_uri(dmq_node_list_t *list, str *suri);
int cmp_dmq_node(dmq_node_t *node, dmq_node_t *cmpnode);
+int cmp_dmq_node_ip(dmq_node_t *node, dmq_node_t *cmpnode);
int update_dmq_node_status(dmq_node_list_t *list, dmq_node_t *node, int status);
dmq_node_t *shm_dup_node(dmq_node_t *node);
void destroy_dmq_node(dmq_node_t *node, int shm);
diff --git a/src/modules/dmq/notification_peer.c b/src/modules/dmq/notification_peer.c
index b2470d5ff86..6189acf5359 100644
--- a/src/modules/dmq/notification_peer.c
+++ b/src/modules/dmq/notification_peer.c
@@ -408,6 +408,12 @@ int extract_node_list(dmq_node_list_t *update_list, struct sip_msg
*msg)
if(find == NULL)
return -1;
ret = find_dmq_node(update_list, find);
+
+ if(!ret) {
+ LM_INFO("dmq node not found by name,try again with IP address\n");
+ ret = find_dmq_node_ip(update_list, find);
+ }
+
if(!ret) {
LM_DBG("found new node %.*s\n", STR_FMT(&tmp_uri));
cur = build_dmq_node(&tmp_uri, 1);