Module: sip-router
Branch: ez/uac
Commit: 30681c471504bfafd804d8422b341d18184a17c2
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=30681c471504bfafd804d8422b341d18184a17c2

Author: Konstantin Mosesov <[email protected]>
Committer: Konstantin Mosesov <[email protected]>
Date:   Sat May 11 21:41:21 2013 +0300

modules/uac: added ability to change Call-Id header through pseudo variables 
via uac_req_send()

---

 modules/tm/uac.c              |    5 ++++-
 modules/uac/doc/uac_admin.xml |    1 +
 modules/uac/uac_send.c        |   27 +++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/modules/tm/uac.c b/modules/tm/uac.c
index c1f8256..38ead71 100644
--- a/modules/tm/uac.c
+++ b/modules/tm/uac.c
@@ -762,7 +762,10 @@ int request(uac_req_t *uac_r, str* ruri, str* to, str* 
from, str *next_hop)
 
        if (check_params(uac_r, to, from) < 0) goto err;
 
-       generate_callid(&callid);
+       if (uac_r->callid == NULL || uac_r->callid->len <= 0)
+           generate_callid(&callid);
+       else
+           callid = *uac_r->callid;
        generate_fromtag(&fromtag, &callid);
 
        if (new_dlg_uac(&callid, &fromtag, DEFAULT_CSEQ, from, to, &dialog) < 
0) {
diff --git a/modules/uac/doc/uac_admin.xml b/modules/uac/doc/uac_admin.xml
index 3610f12..a7604b7 100644
--- a/modules/uac/doc/uac_admin.xml
+++ b/modules/uac/doc/uac_admin.xml
@@ -703,6 +703,7 @@ $uac_req(method)="OPTIONS";
 $uac_req(ruri)="sip:kamailio.org";
 $uac_req(furi)="sip:kamailio.org";
 $uac_req(turi)="sip:kamailio.org";
+$uac_req(callid)=$(mb{s.md5});
 uac_req_send();
 ...
                                </programlisting>
diff --git a/modules/uac/uac_send.c b/modules/uac/uac_send.c
index 50bff25..91ad56c 100644
--- a/modules/uac/uac_send.c
+++ b/modules/uac/uac_send.c
@@ -61,6 +61,8 @@ typedef struct _uac_send_info {
        char  b_apasswd[64];
        str   s_apasswd;
        unsigned int onreply;
+       char  b_callid[128];
+       str   s_callid;
 } uac_send_info_t;
 
 static struct _uac_send_info _uac_req;
@@ -84,6 +86,7 @@ uac_send_info_t *uac_send_info_clone(uac_send_info_t *ur)
        tp->s_ouri.s    = tp->b_ouri;
        tp->s_auser.s   = tp->b_auser;
        tp->s_apasswd.s = tp->b_apasswd;
+       tp->s_callid.s  = tp->b_callid;
 
        return tp;
 }
@@ -134,6 +137,10 @@ int pv_get_uac_req(struct sip_msg *msg, pv_param_t *param,
                        if(_uac_req.s_apasswd.len<=0)
                                return pv_get_null(msg, param, res);
                        return pv_get_strval(msg, param, res, 
&_uac_req.s_apasswd);
+               case 11:
+                       if(_uac_req.s_callid.len<=0)
+                               return pv_get_null(msg, param, res);
+                       return pv_get_strval(msg, param, res, 
&_uac_req.s_callid);
                default:
                        return pv_get_uintval(msg, param, res, _uac_req.flags);
        }
@@ -160,6 +167,7 @@ int pv_set_uac_req(struct sip_msg* msg, pv_param_t *param,
                                _uac_req.s_body.len = 0;
                                _uac_req.s_method.len = 0;
                                _uac_req.onreply = 0;
+                               _uac_req.s_callid.len = 0;
                        }
                        break;
                case 1:
@@ -360,6 +368,21 @@ int pv_set_uac_req(struct sip_msg* msg, pv_param_t *param,
                        _uac_req.s_apasswd.s[val->rs.len] = '\0';
                        _uac_req.s_apasswd.len = val->rs.len;
                        break;
+               case 11:
+                       if(val==NULL)
+                       {
+                               _uac_req.s_callid.len = 0;
+                               return 0;
+                       }
+                       if(!(val->flags&PV_VAL_STR))
+                       {
+                               LM_ERR("Invalid value type\n");
+                               return -1;
+                       }
+                        memcpy(_uac_req.s_callid.s, val->rs.s, val->rs.len);
+                        _uac_req.s_callid.s[val->rs.len] = '\0';
+                        _uac_req.s_callid.len = val->rs.len;
+                       break;
        }
        return 0;
 }
@@ -399,6 +422,8 @@ int pv_parse_uac_req_name(pv_spec_p sp, str *in)
                case 6: 
                        if(strncmp(in->s, "method", 6)==0)
                                sp->pvp.pvn.u.isname.name.n = 7;
+                       else if(strncmp(in->s, "callid", 6)==0)
+                               sp->pvp.pvn.u.isname.name.n = 11;
                        else goto error;
                break;
                case 7: 
@@ -439,6 +464,7 @@ void uac_req_init(void)
        _uac_req.s_method.s = _uac_req.b_method;
        _uac_req.s_auser.s  = _uac_req.b_auser;
        _uac_req.s_apasswd.s  = _uac_req.b_apasswd;
+       _uac_req.s_callid.s  = _uac_req.b_callid;
        return;
 }
 
@@ -612,6 +638,7 @@ int uac_req_send(struct sip_msg *msg, char *s1, char *s2)
                /* Callback parameter */
                uac_r.cbp = (void*)tp;
        }
+        uac_r.callid = (_uac_req.s_callid.len <= 0) ? NULL : 
&_uac_req.s_callid;
        ret = tmb.t_request(&uac_r,  /* UAC Req */
                                                &_uac_req.s_ruri,        /* 
Request-URI */
                                                
(_uac_req.s_turi.len<=0)?&_uac_req.s_ruri:&_uac_req.s_turi, /* To */


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to