in sample_app/onvif_camera_mock/artifacts/wsdd/src/net_utils.c [42:71]
int host_or_ip_to_addr(const char *host_or_IP, int af, void *addr)
{
struct hostent *host;
if( !host_or_IP || !addr )
{
errno = EINVAL;
return -1;
}
host = gethostbyname2(host_or_IP, af);
if( !host )
return -1; //possible DNS is not configured
if( host->h_addrtype != af )
return -1; //addrtype(format) not correct
if( !host->h_addr_list[0] )
return -1; //host is found, but no associated IP.
memcpy(addr, host->h_addr_list[0], host->h_length);
return 0; //good job
}