[getdns-api] data structures/arguments to getdns_hostname and getdns_hostname_sync

Matt Miller linuxwolf at outer-planes.net
Wed Nov 20 09:12:08 MST 2013


On Nov 19, 2013, at 4:36 PM, Paul Hoffman <paul.hoffman at vpnc.org> wrote:

> On Nov 19, 2013, at 3:25 PM, Melinda Shore <melinda.shore at nomountain.net> wrote:
> 
>> As specified, the address to resolve is passed into getdns_hostname
>> and getdns_hostname_sync as a dict containing an address type, encoded
>> as a string (or octet sequence - this should be made explicit if it
>> stays), and the address itself, also a bindata.  There's an awful lot
>> of memory allocation and data movement in the API and I think that
>> this (getdns_hostname) is an example of the cost/benefit tradeoff being
>> a little sketchy.  If we do hang onto the dict encoding and make the
>> address type explicit, I think the address type should be an int (i.e.
>> a constant/macro) rather than an octet sequence, but since there are
>> reliable heuristics for determining whether a given ASCII octet sequence
>> is a v4 or v6 address it strikes me as redundant to pass that in, with
>> the additional complexity and execution cost that comes from using a
>> getdns_dict rather than just a string.
> 
> If we change this from being an admittedly verbose dict to an array, for sanity's sake I would want it to be a array of either 4 or 16 octets. That is, the application prepares whatever input it has into the actual on-the-wire address and ships it. Shipping what is hopefully ASCII text, hopefully null-terminated, seems ripe for errors. With the raw address, the only possible error is "that wasn't exactly 4 or 16 byte long".
> 

What I've consistently seen done right is dealing with null-termination for ASCII strings.  What I've consistently seen done wrong is the preparing of whatever input the API user has into the actual on-the-wire address.

If not an ASCII null-terminated string, then we really ought to provide a helper function to do the most common preparation -- converting a string into binary address structure.


- m&m

Matthew A. Miller
< http://goo.gl/LK55L >

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://www.vpnc.org/pipermail/getdns-api/attachments/20131120/cefe39cc/attachment.bin>


More information about the getdns-api mailing list