Module: sip-router
Branch: master
Commit: 121c5a49f81effdac42977d716332215d6a95e4f
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=121c5a4…
Author: Konstantin Mosesov <ez(a)voipgroup.org.ua>
Committer: Konstantin Mosesov <ez(a)voipgroup.org.ua>
Date: Fri May 17 21:14:29 2013 +0300
uac: Added ability to set Call-Id through $uac_req(callid).
---
modules/tm/uac.c | 5 ++++-
modules/tm/uac.h | 1 +
modules/uac/README | 1 +
modules/uac/doc/uac_admin.xml | 1 +
modules/uac/uac_send.c | 27 +++++++++++++++++++++++++++
5 files changed, 34 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/tm/uac.h b/modules/tm/uac.h
index 619d43e..69376b4 100644
--- a/modules/tm/uac.h
+++ b/modules/tm/uac.h
@@ -58,6 +58,7 @@ typedef struct uac_req {
int cb_flags;
transaction_cb *cb;
void *cbp;
+ str *callid;
} uac_req_t;
/* macro for setting the values of uac_req_t struct */
diff --git a/modules/uac/README b/modules/uac/README
index cd5cf5c..fc3846d 100644
--- a/modules/uac/README
+++ b/modules/uac/README
@@ -605,6 +605,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();
...
diff --git a/modules/uac/doc/uac_admin.xml b/modules/uac/doc/uac_admin.xml
index ec86950..d3a3c54 100644
--- a/modules/uac/doc/uac_admin.xml
+++ b/modules/uac/doc/uac_admin.xml
@@ -713,6 +713,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 */