rem: str body, body1, oldport, oldip, oldip1, newport, newip; str callid, from_tag, to_tag; int create, port, len; char buf[16]; char *cp, *cp1; struct lump* anchor; struct iovec v[6 + 5] = {{"U", 1}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL, 7}, {" ", 1}, {NULL, 1}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL, 0}};                                     if (rtpproxy_disable != 0) { LOG(L_ERR, "ERROR: force_rtp_proxy: support for RTP proxy " "is disabled\n"); return -1; } if (msg->first_line.type == SIP_REQUEST && msg->first_line.u.request.method_value == METHOD_INVITE) { create = 1; } else if (msg->first_line.type == SIP_REPLY) { create = 0; } else { return -1; } if (get_callid(msg, &callid) == -1 || callid.len == 0) { LOG(L_ERR, "ERROR: force_rtp_proxy: can't get Call-Id field\n"); return -1; } if (get_to_tag(msg, &to_tag) == -1) { LOG(L_ERR, "ERROR: force_rtp_proxy: can't get To tag\n"); return -1; } if (get_from_tag(msg, &from_tag) == -1 || from_tag.len == 0) { LOG(L_ERR, "ERROR: force_rtp_proxy: can't get From tag\n"); return -1; } if (extract_body(msg, &body) == -1) { LOG(L_ERR, "ERROR: force_rtp_proxy: can't extract body " "from the message\n"); return -1; } for (cp = body.s; (len = body.s + body.len - cp) >= ANORTPPROXY_LEN;) { cp1 = ser_memmem(cp, ANORTPPROXY, len, ANORTPPROXY_LEN); if (cp1 == NULL) break; if (cp1[-1] == '\n' || cp1[-1] == '\r') return -1; cp = cp1 + ANORTPPROXY_LEN; } anchor = anchor_lump(msg, body.s + body.len - msg->buf, 0, 0); if (anchor == NULL) { LOG(L_ERR, "ERROR: force_rtp_proxy: anchor_lump failed\n"); return -1; } if (extract_mediaip(&body, &oldip) == -1) { LOG(L_ERR, "ERROR: force_rtp_proxy: can't extract media IP " "from the message\n"); return -1; } body1.s = oldip.s + oldip.len; body1.len = body.s + body.len - body1.s; if (extract_mediaip(&body1, &oldip1) == -1) { oldip1.len = 0; } if (extract_mediaport(&body, &oldport) == -1) { LOG(L_ERR, "ERROR: force_rtp_proxy: can't extract media port " "from the message\n"); return -1; } newip.s = ip_addr2a(&msg->rcv.src_ip); newip.len = strlen(newip.s); if (create == 0) v[0].iov_base = "L"; STR2IOVEC(callid, v[2]); STR2IOVEC(newip, v[4]); STR2IOVEC(oldport, v[6]); STR2IOVEC(from_tag, v[8]); STR2IOVEC(to_tag, v[10]); cp = send_rtpp_command(v, (to_tag.len > 0) ? 11 : 9, 1); if (cp == NULL) return -1; port = atoi(cp); if (port <= 0 || port > 65535) return -1;  newport.s = buf; newport.len = sprintf(buf, "%d", port);
add: str newip;
context: force_rtp_proxy_f(struct sip_msg* msg, char* str1, char* str2){	str body, body1, oldport, oldip, oldip1, newport, newip;	str callid, from_tag, to_tag;	int create, port, len;	char buf[16];	char *cp, *cp1;	struct lump* anchor;	struct iovec v[6 + 5] = {{"U", 1}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL, 7}, {" ", 1}, {NULL, 1}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL, 0}};				 /* 0 */   /* 1 */   /* 2 */    /* 3 */   /* 4 */    /* 5 */   /* 6 */    /* 7 */   /* 8 */    /* 9 */   /* 10 */	if (rtpproxy_disable != 0) {		LOG(L_ERR, "ERROR: force_rtp_proxy: support for RTP proxy "		    "is disabled\n");		return -1;	}	if (msg->first_line.type == SIP_REQUEST &&	    msg->first_line.u.request.method_value == METHOD_INVITE) {		create = 1;	} else if (msg->first_line.type == SIP_REPLY) {		create = 0;	} else {		return -1;	}	if (get_callid(msg, &callid) == -1 || callid.len == 0) {		LOG(L_ERR, "ERROR: force_rtp_proxy: can't get Call-Id field\n");		return -1;	}	if (get_to_tag(msg, &to_tag) == -1) {		LOG(L_ERR, "ERROR: force_rtp_proxy: can't get To tag\n");		return -1;	}	if (get_from_tag(msg, &from_tag) == -1 || from_tag.len == 0) {		LOG(L_ERR, "ERROR: force_rtp_proxy: can't get From tag\n");		return -1;	}	if (extract_body(msg, &body) == -1) {		LOG(L_ERR, "ERROR: force_rtp_proxy: can't extract body "		    "from the message\n");		return -1;	}	for (cp = body.s; (len = body.s + body.len - cp) >= ANORTPPROXY_LEN;) {		cp1 = ser_memmem(cp, ANORTPPROXY, len, ANORTPPROXY_LEN);		if (cp1 == NULL)			break;		if (cp1[-1] == '\n' || cp1[-1] == '\r')			return -1;		cp = cp1 + ANORTPPROXY_LEN;	}	anchor = anchor_lump(msg, body.s + body.len - msg->buf, 0, 0);	if (anchor == NULL) {		LOG(L_ERR, "ERROR: force_rtp_proxy: anchor_lump failed\n");		return -1;	}	if (extract_mediaip(&body, &oldip) == -1) {		LOG(L_ERR, "ERROR: force_rtp_proxy: can't extract media IP "		    "from the message\n");		return -1;	}	body1.s = oldip.s + oldip.len;	body1.len = body.s + body.len - body1.s;	if (extract_mediaip(&body1, &oldip1) == -1) {		oldip1.len = 0;	}	if (extract_mediaport(&body, &oldport) == -1) {		LOG(L_ERR, "ERROR: force_rtp_proxy: can't extract media port "		    "from the message\n");		return -1;	}	newip.s = ip_addr2a(&msg->rcv.src_ip);	newip.len = strlen(newip.s);	if (create == 0)		v[0].iov_base = "L";	STR2IOVEC(callid, v[2]);	STR2IOVEC(newip, v[4]);	STR2IOVEC(oldport, v[6]);	STR2IOVEC(from_tag, v[8]);	STR2IOVEC(to_tag, v[10]);	cp = send_rtpp_command(v, (to_tag.len > 0) ? 11 : 9, 1);	if (cp == NULL)		return -1;	port = atoi(cp);	if (port <= 0 || port > 65535)		return -1;	newport.s = buf;	newport.len = sprintf(buf, "%d", port);	newip.s = ip_addr2a(&msg->rcv.dst_ip);	newip.len = strlen(newip.s);	if (alter_mediaip(msg, &body, &oldip, &newip, 0) == -1)		return -1;	if (oldip1.len > 0 &&	    alter_mediaip(msg, &body1, &oldip1, &newip, 0) == -1)		return -1;	if (alter_mediaport(msg, &body, &oldport, &newport, 0) == -1)		return -1;	cp = pkg_malloc(ANORTPPROXY_LEN * sizeof(char));	if (cp == NULL) {		LOG(L_ERR, "ERROR: force_rtp_proxy: out of memory\n");		return -1;	}	memcpy(cp, ANORTPPROXY, ANORTPPROXY_LEN);	if (insert_new_lump_after(anchor, cp, ANORTPPROXY_LEN, 0) == NULL) {		LOG(L_ERR, "ERROR: force_rtp_proxy: insert_new_lump_after failed\n");		pkg_free(cp);		return -1;	}	return 1;}