[En-Nut-Discussion] NutDnsGetHostByName dotted quad hostname
    Coleman Brumley 
    cbrumley at polarsoft.biz
       
    Tue Feb 24 18:14:54 CET 2015
    
    
  
Hello,
In working with DNS name resolution recently (4.10.3), I realized that
NutDnsGetHostByName doesn't accept hostnames in IPv4 dotted quad format. 
Since gethostbyname() allows it, and the dotted quad format is an accepted
hostname per RFC1123, I was thinking it would be nice if NutDnsGetHostByName
did the same thing. 
To accomplish this, I propose the following:
u_long NutDnsGetHostByName(CONST u_char * hostname)
{
    u_long ip=0;
    ip=inet_addr(hostname);
    if(ip==0)
    	ip=NutDnsGetResource(hostname, 1);
    return ip;
}
Or, alternatively, only call inet_addr if NutDnsGetResource fails:
u_long NutDnsGetHostByName(CONST u_char * hostname)
{
    u_long ip=0;
    ip=NutDnsGetResource(hostname, 1);
    if(ip==0)
         ip=inet_addr(hostname);        	
    return ip;
}
Regards,
Coleman
    
    
More information about the En-Nut-Discussion
mailing list