/* It translates an address from the 'presentation' form into the 'network' form. 
This function does the reverse job of  */
int sock_present2network(const char *address, struct sockaddr_storage *sockaddr, int addr_family, char *errbuf, int errbuflen)
/* It translates an address from the 'presentation' form into the 'network' form. 
This function does the reverse job of  */
int sock_present2network(const char *address, struct sockaddr_storage *sockaddr, int addr_family, char *errbuf, int errbuflen)
{
	int retval;
	struct addrinfo *addrinfo;
	struct addrinfo hints;
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = addr_family;
	if ((retval = sock_initaddress(address, "22222", &hints, &addrinfo, errbuf, errbuflen)) == -1)
		return 0;
	if (addrinfo->ai_family == PF_INET)
		memcpy(sockaddr, addrinfo->ai_addr, sizeof(struct sockaddr_in));
	else
		memcpy(sockaddr, addrinfo->ai_addr, sizeof(struct sockaddr_in6));
	if (addrinfo->ai_next != NULL)
	{
		freeaddrinfo(addrinfo);
		if (errbuf)
			pcap_snprintf(errbuf, errbuflen, "More than one socket requested; using the first one returned");
		return -2;
	}
	freeaddrinfo(addrinfo);
	return -1;
}