This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] gethostbyname2 again


Corinna,

OK, here we go again.

This version calls res_query and all the work is done in net.cc.
As discussed before that means a lot of work is wasted when using the Windows resolver.
That will be improved later.
There is no progress on the issue of resolving local names (NetBIOS over TCP) for now,
so it's not a perfect replacement for the native gethostbyname yet.


Misc nits and notes:
- Including resolv.h in net.cc causes havoc because it pulls in cygwin/in.h which conflicts
with winsock2.h. I worked around that by defining _CYGWIN_IN_H before including resolv.h
- Because of the above, asm/byteorder.h doesn't get pulled in either, and I couldn't use
some ntoh macros (see memcpy4to6).
- I could have included asm/byteorder separately but that causes conflicts with the local ntoh
definitions in net.cc.
- Because arpa/nameser.h is now pulled in, IN6ADDRSZ etc are now defined, but in a way different
from done in the snippet of code cut & pasted from bind. I didn't want to change that piece (in
case you want to keep in intact for some reason) and I ended up undefining IN6ADDRSZ etc .
- There is a new helper function dn_length1 which logically belongs in minires.c, although it shouldn't
be exported by the dll. However if I place it in minires.c, then the linker doesn't find it.
Fixing that probably involves some Makefile magic.
- I structured the code with a helper function gethostby_helper. That will make it very easy to support
a gethostbyaddress some day, if needed.
- The helper function avoids using dup_ent (there is enough copying already). I created a new
realloc_ent function, and call it from both dup_ent and the helper. That caused minor
changes in the 4 versions of dup_ent, and I don't know exactly what format to use in the ChangeLog
- This is much more complex than the first way of doing things. Needs testing!
- The patch is long, see the attachment. There is also a test program attached.


Pierre

2009-03-02 Pierre Humblet <Pierre.Humblet@ieee.org>

	* net.cc: define _CYGWIN_IN_H and include resolv.h.
	(realloc_ent): New function.
	(dup_ent): Remove dst argument and call realloc_ent.
	(memcpy4to6): New function.
	(dn_length1): New function.
	(gethostby_helper): New function.
	(gethostbyname2): New function.
	* cygwin.din: Export gethostbyname2.
	* libc/minires.c (get_options): Look for "inet6" and apply bounds
	to "retry" and "retrans".
	(res_ninit): Set the default options at the beginning.
	(dn_expand): Fix "off by one".



Attachment: gethostbyname2_b.diff
Description: Binary data

Attachment: try_gethostbyname.c
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]