[Development] Implementing of a DNS feature under Windows [QTBUG-30166]

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Thu Sep 26 10:33:49 CEST 2013


Hi All,

I'm working on adding support for a custom DNS server in QDnsLookup.

The *nix implementation is complete, however I needed some pointers on
doing it under Windows.

The process of specifying a specific DNS server is sort of 'undocumented'.
I've looked at the current implementation of DNS lookup under windows (in
src/network/kernel/qdnslookup_win.cpp).

1. We're using the DnsQuery_W function. The docs of this function state
that the 4th param
(pExtra) "is reserved for future use and must be set to NULL*".**
*
However, sample code on MSDN show this param being used for specifying a
custom DNS server*: *http://support.microsoft.com/kb/831226
My question is, can we use this feature (apparently the docs seem to
incorrect on this matter)?

2. For allocating memory for holding the IP addr of the nameserver, the
sample code (see above link) uses the 'LocalAlloc' function.

This function does NOT generate any exceptions and returns NULL (like
malloc) on failure. So in case of error, I'm not able to find a suitable
QDnsLookup::Error enum value for it as the current ones seem to be related
to DNS problems and not system related.

How should a failed mem alloc be handled in windows? (Should I use the
Heap* functions which are recommended for newer apps and generate
exceptions on failure?)

3. I'll be using the PIP4_ARRAY struct for specifying the nameserver (
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682139(v=vs.85).aspx
).

I'm not sure if AddrArray field of this struct requires the IP octet in
host or network order. All the examples seem to be showing converting from
a string using the inet_addr() function. Since I already have the ip addr
as a quint32, I can set it directly. Though I'm a little unsure about the
byte order.

Any pointers are highly appreciated.

Thanks,
-mandeep
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130926/656bf495/attachment.html>


More information about the Development mailing list