add: if (update_sock_struct_from_via( to, msg->via2 )==-1) goto error;
context: int forward_reply(struct sip_msg* msg){	int  r;	char* new_buf;	struct hostent* he;	struct sockaddr_in* to;	unsigned int new_len;	struct sr_module *mod;#ifdef DNS_IP_HACK	int err;#endif	/*check if first via host = us */	if (check_via){		for (r=0; r<addresses_no; r++)			if(strcmp(msg->via1->host.s, names[r])==0) break;		if (r==addresses_no){			LOG(L_NOTICE, "ERROR: forward_reply: host in first via!=me :"					" %s\n", msg->via1->host);			/* send error msg back? */			goto error;		}	}	/* here will be called the T Module !!!!!!  */	/* 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;		}	}		to=0;	to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr));	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;	}	 /* send it! */	DBG("Sending: to %s:%d, \n%s.\n",			msg->via2->host.s,			(unsigned short)msg->via2->port,			new_buf);#ifdef DNS_IP_HACK	to->sin_addr.s_addr=str2ip(msg->via2->host.s, msg->via2->host.len, &err);	if (err==0){		to->sin_family = AF_INET;		to->sin_port = (msg->via2->port)?htons(msg->via2->port):						htons(SIP_PORT);	}else{#endif		/* fork? gethostbyname will probably block... */		he=gethostbyname(msg->via2->host.s);		if (he==0){			LOG(L_NOTICE, "ERROR:forward_reply:gethostbyname(%s) failure\n",					msg->via2->host.s);			goto error;		}		to->sin_family = AF_INET;		to->sin_port = (msg->via2->port)?htons(msg->via2->port):						htons(SIP_PORT);		to->sin_addr.s_addr=*((long*)he->h_addr_list[0]);#ifdef DNS_IP_HACK	}#endif	if (udp_send(new_buf,new_len, (struct sockaddr*) to,					sizeof(struct sockaddr_in))==-1)	{#ifdef STATS		update_fail_on_send;#endif		goto error;	}#ifdef STATS	else update_sent_response(  msg->first_line.u.reply.statusclass );#endif	free(new_buf);	free(to);skip:	return 0;error:	if (new_buf) free(new_buf);	if (to) free(to);	return -1;}