Browse code

Merge 84d741892fa279d6c390ebd8ffb1086bfd0c6a4f into 5c2890d90297ef66b0216c46dd1fe12dae5ecd0e

Dmitry Wagin authored on 14/06/2021 15:22:01 • GitHub committed on 14/06/2021 15:22:01
Showing 1 changed files
... ...
@@ -1650,13 +1650,12 @@ static int is_rfc1918_f(struct sip_msg *msg, char *str1, char *str2)
1650 1650
 #define AOLDMEDPRT_LEN (sizeof(AOLDMEDPRT) - 1)
1651 1651
 
1652 1652
 
1653
-/* replace ip addresses in SDP and return umber of replacements */
1653
+/* replace ip addresses in SDP and return number of replacements */
1654 1654
 static inline int replace_sdp_ip(
1655 1655
 		struct sip_msg *msg, str *org_body, char *line, str *ip, int linelen)
1656 1656
 {
1657 1657
 	str body1, oldip, newip;
1658 1658
 	str body = *org_body;
1659
-	unsigned hasreplaced = 0;
1660 1659
 	int pf, pf1 = 0;
1661 1660
 	str body2;
1662 1661
 	char *bodylimit = body.s + body.len;
... ...
@@ -1672,10 +1671,11 @@ static inline int replace_sdp_ip(
1672 1671
 	}
1673 1672
 	body1 = body;
1674 1673
 	for(;;) {
1675
-		if(nh_extract_mediaip(&body1, &oldip, &pf, line, linelen) == -1)
1674
+		ret = nh_extract_mediaip(&body1, &oldip, &pf, line, linelen);
1675
+		if(ret == 0)
1676 1676
 			break;
1677
-		if(pf != AF_INET) {
1678
-			LM_ERR("not an IPv4 address in '%s' SDP\n", line);
1677
+		if(ret == -1) {
1678
+			LM_ERR("can't extract '%s' IP from the SDP\n", line);
1679 1679
 			return -1;
1680 1680
 		}
1681 1681
 		if(!pf1)
... ...
@@ -1693,13 +1693,8 @@ static inline int replace_sdp_ip(
1693 1693
 			return -1;
1694 1694
 		}
1695 1695
 		count += ret;
1696
-		hasreplaced = 1;
1697 1696
 		body1 = body2;
1698 1697
 	}
1699
-	if(!hasreplaced) {
1700
-		LM_ERR("can't extract '%s' IP from the SDP\n", line);
1701
-		return -1;
1702
-	}
1703 1698
 
1704 1699
 	return count;
1705 1700
 }
... ...
@@ -1780,9 +1775,8 @@ static int ki_fix_nated_sdp_ip(sip_msg_t *msg, int level, str *ip)
1780 1775
 		/* Iterate all a=rtcp and replace ips in them. rfc3605 */
1781 1776
 		ret = replace_sdp_ip(msg, &body, "a=rtcp", (ip && ip->len>0) ? ip : 0, 6);
1782 1777
 		if(ret == -1)
1783
-			LM_DBG("a=rtcp parameter does not exist. nothing to do.\n");
1784
-		else 
1785
-			count += ret;
1778
+			return -1;
1779
+		count += ret;
1786 1780
 
1787 1781
 		if(level & FIX_MEDIP) {
1788 1782
 			/* Iterate all c= and replace ips in them. */
... ...
@@ -1841,7 +1835,7 @@ static int nh_extract_mediaip(str *body, str *mediaip, int *pf, char *line,
1841 1835
 		cp = cp1 + linelen;
1842 1836
 	}
1843 1837
 	if(cp1 == NULL)
1844
-		return -1;
1838
+		return 0;
1845 1839
 
1846 1840
 	mediaip->s = cp1 + linelen;
1847 1841
 	mediaip->len =