Module: kamailio Branch: master Commit: aac107d3539239fc40f7c82638a21e85ab9c5438 URL: https://github.com/kamailio/kamailio/commit/aac107d3539239fc40f7c82638a21e85ab9c5438
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2025-10-16T18:16:50+02:00 dialog: added dlg_refer_cid(...) - send refer within a dialog matched by call-id --- Modified: src/modules/dialog/dialog.c --- Diff: https://github.com/kamailio/kamailio/commit/aac107d3539239fc40f7c82638a21e85ab9c5438.diff Patch: https://github.com/kamailio/kamailio/commit/aac107d3539239fc40f7c82638a21e85ab9c5438.patch --- diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c index 93d547e4ea9..a7e2e575ce1 100644 --- a/src/modules/dialog/dialog.c +++ b/src/modules/dialog/dialog.c @@ -191,6 +191,7 @@ static int w_dlg_manage(struct sip_msg *, char *, char *); static int w_dlg_bye(struct sip_msg *, char *, char *); static int w_dlg_refer(struct sip_msg *, char *, char *); static int w_dlg_refer_did(sip_msg_t *, char *, char *, char *, char *); +static int w_dlg_refer_cid(sip_msg_t *, char *, char *, char *); static int w_dlg_bridge(struct sip_msg *, char *, char *, char *); static int w_dlg_set_timeout(struct sip_msg *, char *, char *, char *); static int w_dlg_set_timeout_by_profile2(struct sip_msg *, char *, char *); @@ -268,6 +269,8 @@ static cmd_export_t cmds[]={ 0, ANY_ROUTE }, {"dlg_refer_did",(cmd_function)w_dlg_refer_did, 4,fixup_iiss, fixup_free_iiss, ANY_ROUTE }, + {"dlg_refer_cid",(cmd_function)w_dlg_refer_cid, 3,fixup_spve_all, + fixup_free_spve_all, ANY_ROUTE }, {"dlg_bridge",(cmd_function)w_dlg_bridge, 3,fixup_dlg_bridge, 0, ANY_ROUTE }, {"dlg_get",(cmd_function)w_dlg_get, 3,fixup_dlg_bridge, @@ -1631,6 +1634,52 @@ static int w_dlg_refer_did( return -1; } +static int w_dlg_refer_cid(sip_msg_t *msg, char *callid, char *side, char *to) +{ + dlg_cell_t *dlg = NULL; + str scallid = {0, 0}; + str sside = {0, 0}; + str sto = {0, 0}; + + if(fixup_get_svalue(msg, (gparam_t *)callid, &scallid) != 0) { + LM_ERR("unable to get id\n"); + goto error; + } + if(fixup_get_svalue(msg, (gparam_t *)side, &sside) != 0) { + LM_ERR("unable to get side\n"); + goto error; + } + if(fixup_get_svalue(msg, (gparam_t *)to, &sto) != 0) { + LM_ERR("unable to get To\n"); + goto error; + } + if(sto.s == NULL || sto.len == 0) { + LM_ERR("invalid To parameter\n"); + goto error; + } + dlg = dlg_search_cid(&scallid, 0); + if(dlg == NULL) { + LM_DBG("dialog not found (%.*s)\n", scallid.len, scallid.s); + goto error; + } + if(sside.len == 6 && strncasecmp(sside.s, "caller", 6) == 0) { + if(dlg_transfer(dlg, &sto, DLG_CALLER_LEG) != 0) + goto error; + } else { + if(dlg_transfer(dlg, &sto, DLG_CALLEE_LEG) != 0) + goto error; + } + + dlg_release(dlg); + return 1; + +error: + if(dlg != NULL) { + dlg_release(dlg); + } + return -1; +} + static int w_dlg_bridge(struct sip_msg *msg, char *from, char *to, char *op) { str sf = {0, 0}; _______________________________________________ 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!
