Module: sip-router
Branch: master
Commit: 393893a9d6b1fe586abe2a6cfa03680d494bb871
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=393893a…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Oct 17 21:25:00 2012 +0200
rtpproxy: propage flags from rtpproxy_manage() to unforce_rtp_proxy()
- unforce_rtp_proxy() can take flags 1 or 2, previously it didn't take
any
- ignore all the other valid flags for rtpproxy_manage() in
unforce_rtp_proxy()
- added flag 3 - add first via branch if it request (like flag 1) or add
second via branch if it reply (like flag 2) - suitable for auto-pilot
usage with rtpproxy_manage() function
---
modules/rtpproxy/rtpproxy.c | 49 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/modules/rtpproxy/rtpproxy.c b/modules/rtpproxy/rtpproxy.c
index d2e145c..055998e 100644
--- a/modules/rtpproxy/rtpproxy.c
+++ b/modules/rtpproxy/rtpproxy.c
@@ -1667,7 +1667,7 @@ found:
}
static int
-unforce_rtp_proxy_f(struct sip_msg* msg, char* str1, char* str2)
+unforce_rtp_proxy_f(struct sip_msg* msg, char* flags, char* str2)
{
str callid, from_tag, to_tag, viabranch;
char *cp;
@@ -1677,7 +1677,7 @@ unforce_rtp_proxy_f(struct sip_msg* msg, char* str1, char* str2)
struct iovec v[1 + 4 + 3 + 2] = {{NULL, 0}, {"D", 1}, {" ", 1},
{NULL, 0}, {NULL, 0}, {NULL, 0}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL,
0}};
/* 1 */ /* 2 */ /* 3 */ /* 4 */ /* 5 */ /* 6 */ /* 7 */ /* 8
*/ /* 9 */
- for (cp = str1; cp && *cp; cp++) {
+ for (cp = flags; cp && *cp; cp++) {
switch (*cp) {
case '1':
via = 1;
@@ -1687,6 +1687,38 @@ unforce_rtp_proxy_f(struct sip_msg* msg, char* str1, char* str2)
via = 2;
break;
+ case '3':
+ if(msg && msg->first_line.type == SIP_REPLY)
+ via = 2;
+ else
+ via = 1;
+ break;
+
+ case 'a':
+ case 'A':
+ case 'i':
+ case 'I':
+ case 'e':
+ case 'E':
+ case 'l':
+ case 'L':
+ case 'f':
+ case 'F':
+ case 'r':
+ case 'R':
+ case 'c':
+ case 'C':
+ case 'o':
+ case 'O':
+ case 'x':
+ case 'X':
+ case 'w':
+ case 'W':
+ case 'z':
+ case 'Z':
+ /* ignore them - they can be sent by rtpproxy_manage() */
+ break;
+
default:
LM_ERR("unknown option `%c'\n", *cp);
return -1;
@@ -1794,7 +1826,7 @@ rtpproxy_manage(struct sip_msg *msg, char *flags, char *ip)
return -1;
if(method==METHOD_CANCEL || method==METHOD_BYE)
- return unforce_rtp_proxy_f(msg, 0, 0);
+ return unforce_rtp_proxy_f(msg, flags, 0);
if(ip==NULL)
{
@@ -1820,13 +1852,13 @@ rtpproxy_manage(struct sip_msg *msg, char *flags, char *ip)
&& tmb.t_gett()!=T_UNDEFINED)
tmb.t_gett()->uas.request->msg_flags |= FL_SDP_BODY;
if(route_type==FAILURE_ROUTE)
- return unforce_rtp_proxy_f(msg, 0, 0);
+ return unforce_rtp_proxy_f(msg, flags, 0);
return force_rtp_proxy(msg, flags, (cp!=NULL)?newip:ip, 1,
(ip!=NULL)?1:0);
}
} else if(msg->first_line.type == SIP_REPLY) {
if(msg->first_line.u.reply.statuscode>=300)
- return unforce_rtp_proxy_f(msg, 0, 0);
+ return unforce_rtp_proxy_f(msg, flags, 0);
if(nosdp==0) {
if(method==METHOD_UPDATE)
return force_rtp_proxy(msg, flags, (cp!=NULL)?newip:ip, 0,
@@ -2024,6 +2056,13 @@ force_rtp_proxy(struct sip_msg* msg, char* str1, char* str2, int
offer, int forc
via = 2;
break;
+ case '3':
+ if(msg && msg->first_line.type == SIP_REPLY)
+ via = 2;
+ else
+ via = 1;
+ break;
+
case 'a':
case 'A':
if (append_opts(&opts, 'A') == -1) {