rem: DBG(" reply forwarded to %s:%d\n", msg->via2->host.s, (unsigned short) msg->via2->port);
add: DBG(" reply forwarded to %.*s:%d\n", msg->via2->host.len, msg->via2->host.s, (unsigned short) msg->via2->port);
context: int forward_reply(struct sip_msg* msg){	char* new_buf;	union sockaddr_union* to;	struct socket_info* send_sock;	unsigned int new_len;	struct sr_module *mod;	int proto;#ifdef USE_TCP	char* s;	int len;	int id;#endif		to=0;	new_buf=0;	/*check if first via host = us */	if (check_via){		if (check_self(&msg->via1->host,					msg->via1->port?msg->via1->port:SIP_PORT)!=1){			LOG(L_NOTICE, "ERROR: forward_reply: host in first via!=me :"					" %.*s:%d\n", msg->via1->host.len, msg->via1->host.s,									msg->via1->port);			/* send error msg back? */			goto error;		}	}	/* quick hack, slower for mutliple modules*/	for (mod=modules;mod;mod=mod->next){		if ((mod->exports) && (mod->exports->response_f)){			DBG("forward_reply: found module %s, passing reply to it\n",					mod->exports->name);			if (mod->exports->response_f(msg)==0) goto skip;		}	}	/* we have to forward the reply stateless, so we need second via -bogdan*/	if (parse_headers( msg, HDR_VIA2, 0 )==-1 		|| (msg->via2==0) || (msg->via2->error!=PARSE_OK))	{		/* no second via => error */		LOG(L_ERR, "ERROR: forward_msg: no 2nd via found in reply\n");		goto error;	}	to=(union sockaddr_union*)malloc(sizeof(union sockaddr_union));	if (to==0){		LOG(L_ERR, "ERROR: forward_reply: out of memory\n");		goto error;	}	new_buf = build_res_buf_from_sip_res( msg, &new_len);	if (!new_buf){		LOG(L_ERR, "ERROR: forward_reply: building failed\n");		goto error;	}	proto=msg->via2->proto;	if (update_sock_struct_from_via( to, msg->via2 )==-1) goto error;	send_sock=get_send_socket(to, proto);	if (send_sock==0){		LOG(L_ERR, "forward_reply: ERROR: no sending socket found\n");		goto error;	}	if (proto==PROTO_UDP){		if (udp_send(send_sock, new_buf,new_len,  to)==-1)		{			STATS_TX_DROPS;			goto error;		}	}#ifdef USE_TCP	 else if (proto==PROTO_TCP){		 id=0;		/* find id in i param if it exists */		if (msg->via1->i&&msg->via1->i->value.s){			s=msg->via1->i->value.s;			len=msg->via1->i->value.len;			DBG("forward_reply: i=%.*s\n",len, s);			id=reverse_hex2int(s, len);			DBG("forward_reply: id= %x\n", id);		}								if (tcp_send(new_buf, new_len,  to, id)<0)		{			STATS_TX_DROPS;			goto error;		}	} #endif	else{		LOG(L_CRIT, "BUG: forward_reply: unknown proto %d\n", proto);		goto error;	}#ifdef STATS		STATS_TX_RESPONSE(  (msg->first_line.u.reply.statuscode/100) );#endif	DBG(" reply forwarded to %s:%d\n", msg->via2->host.s,		(unsigned short) msg->via2->port);	pkg_free(new_buf);	free(to);skip:	return 0;error:	if (new_buf) pkg_free(new_buf);	if (to) free(to);	return -1;}