Home/Support/Support Forum/DNSgethostbyname
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

DNSgethostbyname

0 votes
We recently got a new set of boards with DigiConnectME's on them where DNSgethostbyname does not seem to work. The modules look just like the older modules we have (same part numbers). But if I take my application and load it into the newer modules, DNSgethostbyname does not function correctly, and if I load the exact same image.bin into an older module, it works just fine. I was under the impression that image.bin contained 100% of the application and NetOS/ThreadX libraries. What could be the difference, then? Could possibly the new modules have a different ethernet chip in them that somehow doesn't work for DNS, but works fine for HTTP, UPD and TCP connects? Doesn't sound likely, but that's the behavior I am seeing.
asked May 13, 2008 in NET+OS by jwormsley Community Contributor (78 points)
recategorized Dec 18, 2013 by tuxembb

Please log in or register to answer this question.

7 Answers

0 votes
Update: There is a difference between the modules. The ones that work all have an R under the far right of the bar code. The ones that do not all have a T at the far right of the bar code.
answered May 13, 2008 by jwormsley Community Contributor (78 points)
0 votes
Hi,

I am currently using NetOS 7.3, and trying to work out exactly how the DNS works.

1. There seems to be a problem with DNSGetServers as this allways indicates that there are two servers set up but does not appear to return the correct addresses for them. If you call DNSGetServers followed by DNSRemoveServer and then DNSGetServers it still says there are two servers.

2. When using Static IP configuration with DNS servers defined they do not seem to be used by the stack.

3. When using DCHP the DHCP options appear to get DNS Server definitions but once again they do not seem to be used.

Overall my recommendation is to wait till the stack comes up and then call DNSGetServers, followed by DNSRemoveServer for each of the returned values (even though they are wrong) and then call DNSAddServer to set up the required servers. Once this is done DNSGetHostByName does seem to work correctly.
answered May 14, 2008 by rdeabill Community Contributor (142 points)
0 votes
Update

I have just noticed that Digi have posted an update for TCP which includes a fix for the DNS returning the wrong address. I will download this and try it out
answered May 14, 2008 by rdeabill Community Contributor (142 points)
0 votes
Well, I dowloaded the patch, worked out that it does not patch the (dbg) libraries, so I had to copy the main libray and rename it to get the new verion in the Debug build.

The patch does give the correct number of servers, but after startup it says 2 server but with address 0.0.0.0. This is the same with using DHCP or with a static IP and defined DNS Servers. As i said above it seems that the way to get it to work is to remove the DNS servers that get set up at startup and then set up the required servers once the app is running
answered May 14, 2008 by rdeabill Community Contributor (142 points)
0 votes
In the tcp/ip library patch is the following file:
netos\src\examples\nadnsclnt\root.c

This is an update to the root.c file for the dns client sample application. The (updated) root.c file now (as you describe in your own application) deletes the existing 0.0.0.0 DNS servers before attempting to add new ones.

The other defect was that the get function for the number of servers was returning the sizeof the array of servers instead of the actual current number of servers. Between the updated tcp/ip library and the updated root.c file, these should be addressed

Also if you are using ESP as your development environment, you will have to physically move the (updated) root.c file from where it is installed to your ESP development environment (which is generally in my Documents.......)
answered May 14, 2008 by sparkys_dad Community Contributor (99 points)
0 votes
Hi,

Yes I have got things working now as you describe. It is a bit problematic as

1. The patch does not have (dbg) libraries so a standard ESP build still uses old libraries unless you rename the standard one from the patch with (dbg) on the end. It would be better if the patches contained (dbg) version of the libraries or if the standard ESP debug configuration just used standard libraries as you cannot debug through the libraries as there is no source.

2. The documentation for the DNS says:
>>You must register a domain name server before calling DNSgethostbyname, getaddrinfo or getnameinfo. There are two ways to do this:
>>Calling DNSAddServer()
>>Using IAM's DHCP or Static methods during startup to configure IP parameters

The DNSAddServer works but I have tried setting up DNS servers in the NaIamStaticParams_t structure and they do not automatically get used. With DHCP the DHCP requests options and is given an IP for the DNS from the server but it does not seem to use this. I have not been clever eneough to get into the initialisation code to try to sort out how to get the DNS IP address from the DHCP options, but it could be fairly siomple to use the static IAM parameter settings to set up manually at the application start.
answered May 14, 2008 by rdeabill Community Contributor (142 points)
0 votes
I suppose I should have mentioned I am still on 7.0 (I have 7.1, but haven't used it yet) and use command line only (this app has been migrated from 5.x and it is far too much trouble to convert to ESP). Aside: I can't understand why Digi can't get updates to people in a timely fashion.

The odd thing is that the code works on modules with R in under the barcode, but not with modules marked with T. I have no idea what the internal differences are. This is the first time I've seen a failure. I have never called DNSAddServer.
answered May 15, 2008 by jwormsley Community Contributor (78 points)
...