Module: kamailio
Branch: master
Commit: 96ca5c95e9380a56d886fad699a5966b7b00f5b6
URL: 
https://github.com/kamailio/kamailio/commit/96ca5c95e9380a56d886fad699a5966b7b00f5b6

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2017-01-17T11:54:57+01:00

tm: generate from tag if not provided for request_within()

- related to GH #931

---

Modified: src/modules/tm/t_msgbuilder.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/96ca5c95e9380a56d886fad699a5966b7b00f5b6.diff
Patch: 
https://github.com/kamailio/kamailio/commit/96ca5c95e9380a56d886fad699a5966b7b00f5b6.patch

---

diff --git a/src/modules/tm/t_msgbuilder.c b/src/modules/tm/t_msgbuilder.c
index dadba50..5a20dcf 100644
--- a/src/modules/tm/t_msgbuilder.c
+++ b/src/modules/tm/t_msgbuilder.c
@@ -1491,11 +1491,20 @@ char* build_uac_req(str* method, str* headers, str* 
body, dlg_t* dialog,
        str content_length, cseq, via;
        unsigned int maxfwd_len;
        int tbracket, fbracket;
+       str fromtag = STR_NULL;
+       str loc_tag = STR_NULL;
 
        if (!method || !dialog) {
                LM_ERR("invalid parameter value\n");
                return 0;
        }
+
+       if (dialog->id.loc_tag.len<=0) {
+               /* From Tag is mandatory in RFC3261 - generate one if not 
provided */
+               generate_fromtag(&fromtag, &dialog->id.call_id);
+               loc_tag = dialog->id.loc_tag;
+               dialog->id.loc_tag = fromtag;
+       }
        if (print_content_length(&content_length, body) < 0) {
                LM_ERR("error while printing content-length\n");
                return 0;
@@ -1580,6 +1589,9 @@ char* build_uac_req(str* method, str* headers, str* body, 
dlg_t* dialog,
        memapp(w, via.s, via.len);                            /* Top-most Via */
        w = print_to(w, dialog, t, tbracket);                 /* To */
        w = print_from(w, dialog, t, fbracket);               /* From */
+       if(fromtag.len>0) {
+               dialog->id.loc_tag = loc_tag;
+       }
        w = print_cseq(w, &cseq, method, t);                  /* CSeq */
        w = print_callid(w, dialog, t);                       /* Call-ID */
        w = print_routeset(w, dialog);                        /* Route set */


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to