Browse code

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

Daniel-Constantin Mierla authored on 17/10/2012 19:25:00
Showing 1 changed files
... ...
@@ -1667,7 +1667,7 @@ found:
1667 1667
 }
1668 1668
 
1669 1669
 static int
1670
-unforce_rtp_proxy_f(struct sip_msg* msg, char* str1, char* str2)
1670
+unforce_rtp_proxy_f(struct sip_msg* msg, char* flags, char* str2)
1671 1671
 {
1672 1672
 	str callid, from_tag, to_tag, viabranch;
1673 1673
 	char *cp;
... ...
@@ -1677,7 +1677,7 @@ unforce_rtp_proxy_f(struct sip_msg* msg, char* str1, char* str2)
1677 1677
 	struct iovec v[1 + 4 + 3 + 2] = {{NULL, 0}, {"D", 1}, {" ", 1}, {NULL, 0}, {NULL, 0}, {NULL, 0}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL, 0}};
1678 1678
 						    /* 1 */   /* 2 */   /* 3 */    /* 4 */    /* 5 */    /* 6 */   /* 7 */    /* 8 */   /* 9 */
1679 1679
 
1680
-	for (cp = str1; cp && *cp; cp++) {
1680
+	for (cp = flags; cp && *cp; cp++) {
1681 1681
 		switch (*cp) {
1682 1682
 			case '1':
1683 1683
 				via = 1;
... ...
@@ -1687,6 +1687,38 @@ unforce_rtp_proxy_f(struct sip_msg* msg, char* str1, char* str2)
1687 1687
 				via = 2;
1688 1688
 				break;
1689 1689
 
1690
+			case '3':
1691
+				if(msg && msg->first_line.type == SIP_REPLY)
1692
+					via = 2;
1693
+				else
1694
+					via = 1;
1695
+				break;
1696
+
1697
+			case 'a':
1698
+			case 'A':
1699
+			case 'i':
1700
+			case 'I':
1701
+			case 'e':
1702
+			case 'E':
1703
+			case 'l':
1704
+			case 'L':
1705
+			case 'f':
1706
+			case 'F':
1707
+			case 'r':
1708
+			case 'R':
1709
+			case 'c':
1710
+			case 'C':
1711
+			case 'o':
1712
+			case 'O':
1713
+			case 'x':
1714
+			case 'X':
1715
+			case 'w':
1716
+			case 'W':
1717
+			case 'z':
1718
+			case 'Z':
1719
+				/* ignore them - they can be sent by rtpproxy_manage() */
1720
+				break;
1721
+
1690 1722
 			default:
1691 1723
 				LM_ERR("unknown option `%c'\n", *cp);
1692 1724
 				return -1;
... ...
@@ -1794,7 +1826,7 @@ rtpproxy_manage(struct sip_msg *msg, char *flags, char *ip)
1794 1826
 		return -1;
1795 1827
 
1796 1828
 	if(method==METHOD_CANCEL || method==METHOD_BYE)
1797
-		return unforce_rtp_proxy_f(msg, 0, 0);
1829
+		return unforce_rtp_proxy_f(msg, flags, 0);
1798 1830
 
1799 1831
 	if(ip==NULL)
1800 1832
 	{
... ...
@@ -1820,13 +1852,13 @@ rtpproxy_manage(struct sip_msg *msg, char *flags, char *ip)
1820 1852
 					&& tmb.t_gett()!=T_UNDEFINED)
1821 1853
 				tmb.t_gett()->uas.request->msg_flags |= FL_SDP_BODY;
1822 1854
 			if(route_type==FAILURE_ROUTE)
1823
-				return unforce_rtp_proxy_f(msg, 0, 0);
1855
+				return unforce_rtp_proxy_f(msg, flags, 0);
1824 1856
 			return force_rtp_proxy(msg, flags, (cp!=NULL)?newip:ip, 1,
1825 1857
 					(ip!=NULL)?1:0);
1826 1858
 		}
1827 1859
 	} else if(msg->first_line.type == SIP_REPLY) {
1828 1860
 		if(msg->first_line.u.reply.statuscode>=300)
1829
-			return unforce_rtp_proxy_f(msg, 0, 0);
1861
+			return unforce_rtp_proxy_f(msg, flags, 0);
1830 1862
 		if(nosdp==0) {
1831 1863
 			if(method==METHOD_UPDATE)
1832 1864
 				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
2024 2056
 			via = 2;
2025 2057
 			break;
2026 2058
 
2059
+		case '3':
2060
+			if(msg && msg->first_line.type == SIP_REPLY)
2061
+				via = 2;
2062
+			else
2063
+				via = 1;
2064
+			break;
2065
+
2027 2066
 		case 'a':
2028 2067
 		case 'A':
2029 2068
 			if (append_opts(&opts, 'A') == -1) {