Module: kamailio
Branch: master
Commit: 18beef305002e6b2a4a6504273a33db3aa9a3cf4
URL: 
https://github.com/kamailio/kamailio/commit/18beef305002e6b2a4a6504273a33db3aa9a3cf4

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2025-11-03T08:38:35+01:00

dialog: exported dlg_refer_did()/_cid() to kemi

---

Modified: src/modules/dialog/dialog.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/18beef305002e6b2a4a6504273a33db3aa9a3cf4.diff
Patch: 
https://github.com/kamailio/kamailio/commit/18beef305002e6b2a4a6504273a33db3aa9a3cf4.patch

---

diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index a7e2e575ce1..42ea5fefdab 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -1582,6 +1582,37 @@ static int w_dlg_refer(struct sip_msg *msg, char *side, 
char *to)
        return -1;
 }
 
+static int ki_dlg_refer_did(
+               sip_msg_t *msg, int h_entry, int h_id, str *side, str *to)
+{
+       dlg_cell_t *dlg = NULL;
+       if(to->s == NULL || to->len == 0) {
+               LM_ERR("invalid To parameter\n");
+               goto error;
+       }
+       dlg = dlg_lookup((unsigned int)h_entry, (unsigned int)h_id);
+       if(dlg == NULL) {
+               LM_DBG("dialog not found (%d:%d)\n", h_entry, h_id);
+               goto error;
+       }
+       if(side->len == 6 && strncasecmp(side->s, "caller", 6) == 0) {
+               if(dlg_transfer(dlg, to, DLG_CALLER_LEG) != 0)
+                       goto error;
+       } else {
+               if(dlg_transfer(dlg, to, DLG_CALLEE_LEG) != 0)
+                       goto error;
+       }
+
+       dlg_release(dlg);
+       return 1;
+
+error:
+       if(dlg != NULL) {
+               dlg_release(dlg);
+       }
+       return -1;
+}
+
 static int w_dlg_refer_did(
                sip_msg_t *msg, char *entry, char *id, char *side, char *to)
 {
@@ -1634,6 +1665,37 @@ static int w_dlg_refer_did(
        return -1;
 }
 
+static int ki_dlg_refer_cid(sip_msg_t *msg, str *callid, str *side, str *to)
+{
+       dlg_cell_t *dlg = NULL;
+
+       if(to->s == NULL || to->len == 0) {
+               LM_ERR("invalid To parameter\n");
+               goto error;
+       }
+       dlg = dlg_search_cid(callid, 0);
+       if(dlg == NULL) {
+               LM_DBG("dialog not found (%.*s)\n", callid->len, callid->s);
+               goto error;
+       }
+       if(side->len == 6 && strncasecmp(side->s, "caller", 6) == 0) {
+               if(dlg_transfer(dlg, to, DLG_CALLER_LEG) != 0)
+                       goto error;
+       } else {
+               if(dlg_transfer(dlg, to, DLG_CALLEE_LEG) != 0)
+                       goto error;
+       }
+
+       dlg_release(dlg);
+       return 1;
+
+error:
+       if(dlg != NULL) {
+               dlg_release(dlg);
+       }
+       return -1;
+}
+
 static int w_dlg_refer_cid(sip_msg_t *msg, char *callid, char *side, char *to)
 {
        dlg_cell_t *dlg = NULL;
@@ -2929,6 +2991,16 @@ static sr_kemi_t sr_kemi_dialog_exports[] = {
                { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
                        SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
        },
+       { str_init("dialog"), str_init("dlg_refer_did"),
+               SR_KEMIP_INT, ki_dlg_refer_did,
+               { SR_KEMIP_INT, SR_KEMIP_INT, SR_KEMIP_STR,
+                       SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE }
+       },
+       { str_init("dialog"), str_init("dlg_refer_cid"),
+               SR_KEMIP_INT, ki_dlg_refer_cid,
+               { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
+                       SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+       },
        { str_init("dialog"), str_init("dlg_req_within4"),
                SR_KEMIP_INT, ki_dlg_req_within4,
                { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to