async patch to liblwres

Michael Richardson mcr at sandelman.ottawa.on.ca
Fri Sep 19 03:41:13 UTC 2003


-----BEGIN PGP SIGNED MESSAGE-----


Hi, I have been working on an asynchronous patch to -llwres.
We are using this in the experimental (DNSSEC-aware) branch of FreeSWAN.
(USE_LWRES=true in the top-level Makefile.inc). The 2.03 release, coming
soon, has the async version.

Our mechanism is that we send all DNS requests down a pipe to a program,
"lwdnsq" and get responses back asynchronously. The interface is ASCII,
and can also be used interactively.

The patch is at http://www.sandelman.ca/tmp/lwres.patch
The patch is slightly edited diff output - I would up with lots of 
$Id$ differences, which are annoying.

the program "lwdnsq" is included, placed in bin/lwdnsq, configure.in
is patched. That might not be good for distribution - if there is some
place that the lwdnsq program can go as example code, that would be
great.

lwdnsq is GPL'ed right now, but I can license it differently, as it is 
my original code. 

The lookup.c in lwdnsq is the main interface to the library. The essential
interface is:

0)	initialize by calling:

	lwres_async_init(&gs.lwctx) 

and, I need an isc_mem context for processing, so:

	if(isc_mem_create(0,0,&gs.iscmem) != ISC_R_SUCCESS) {
		fprintf(stderr, "Can not initialize isc memory allocator\n");
		exit(4);
	}

	if(isc_buffer_allocate(gs.iscmem, &gs.iscbuf, LWDNSQ_RESULT_LEN_MAX)) {
		fprintf(stderr, "Can not allocate a result buffer\n");
		exit(5);
	}

1)	call lwres_async_fd() to learn what file descriptor to pass to
	select(2)/poll(2).
	
	The fd won't change, but in my code, I get it each time.

2)	call lwres_getrrsetbyname_init(), similar arguments to
	lwres_getrrsetbyname().

	the last argument is of type "lwres_async_state", which is in the
	header file. It can be the first element of a larger state structure.

3)	call lwres_getrrsetbyname_xmit() to send the packet that was
	created.

4)	when the fd is ready, call lwres_getrrgetbyname_read().
	A pointer to a pointer is returned is provided, and the
	lwres_async_state that was provided is returned.

	Freeing the structure is the caller's problem.

TIMEOUTS.

No timeout/retransmit is implemented (yet?)
I'd like to believe that we don't need them when talking to localhost. 

MAN PAGES.

No man pages yet. I am willing to write them, yes, even in docbook format,
but I'd like some comments about the API first.
	
]      Out and about in Ottawa.    hmmm... beer.                |  firewalls  [
]   Michael Richardson, Sandelman Software Works, Ottawa, ON    |net architect[
] mcr at sandelman.ottawa.on.ca http://www.sandelman.ottawa.on.ca/ |device driver[
] panic("Just another Debian/notebook using, kernel hacking, security guy");  [
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
Comment: Finger me for keys - custom hacks make this fully PGP2 compat

iQCVAwUBP2p614qHRg3pndX9AQE1MAQAolUV81YdhY+G6/p7duV9tacdN50XEK6y
N62AYNdBHGNQV2RKkiWL+lgUDdc/VZs73seG/hiz6rz7jk1OEti3Sjb4fP+DG2cG
Ob0QLnZ9yrrS0JnJkCjNNiUsqHLUGHRW/bZyPZhxWdcjQ3dBeF1vwHExfVB1GFTC
FHCfSw3+KgY=
=lBVy
-----END PGP SIGNATURE-----


More information about the bind-workers mailing list