addressdb revision 816e576f77e2c46df3e3d97d65822aa8aded7c4b
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian WellingtonCopyright (C) 2000 Internet Software Consortium.
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark AndrewsSee COPYRIGHT in the source root or http://isc.org/copyright.html for terms.
5bf504f5534eab29c9e52f6e8b75c73b3901743fMark Andrews
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews$Id: addressdb,v 1.4 2000/08/09 04:37:12 tale Exp $
5bf504f5534eab29c9e52f6e8b75c73b3901743fMark Andrews
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark AndrewsYou are lost in a maze of twisty little pointers, all alike...
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian WellingtonADB |-> 0 |-> handle ---> handle ---> 0
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington | | |
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington |-lists of names --------> name -------> name -------> 0
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington | | |
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews | namehook namehook
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews | | | | |
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews | | 0 0 -> fetch
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews | |
a7038d1a0513c8e804937ebc95fc9cb3a46c04f5Mark Andrews | V
5bf504f5534eab29c9e52f6e8b75c73b3901743fMark Andrews |-lists of elements -----> element ----> element ----> element ---> 0
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews | | | |
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews | |-> zoneinfo |-> 0 |-> zoneinfo
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews |-lists of dead handles
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews ...
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews
91216cff91b34c9ff6e846dc23f248219cafe660Andreas GustafssonA handle contains a task, taskaction, and event argument, and is linkable
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafssonin two ways. One, for the list returned to the caller, and two to be
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrewsattached to either a name (so events can be generated) or to the dead handle
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrewslist, where no events are generated.
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark AndrewsHANDLE
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington |
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews |--- addrinfo ---> addrinfo ---> 0
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews | |-> entry |-> entry
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews |--- task, action, arg
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews |
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews V
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark AndrewsHANDLE
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews |
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews V
5bf504f5534eab29c9e52f6e8b75c73b3901743fMark Andrews 0
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews
4f087942583014b241adca1bc78c6db89ed96e94Mark AndrewsNotes and questions:
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson o If a handle is on the dead handle list, it is only waiting for
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews the caller to dns_adb_done() it.
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson o If a handle is on a name list, it will generate at most one
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews event, and then be moved to the dead handle list.
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson o If events are not requested, it is NEVER placed on the name's
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews list, even though fetches for that name may be started.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews o Names will have to have a reference count for each fetch
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews in progress. They will also have a bit that says some
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews previous fetches failed. XXX How in the world would I
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews "refresh" the data? If I only got 2 of 9 A6 chains to converge,
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews when and how do I restart them later?
09ab886382ad9e7149d9b72b4cf9a03ae4a1cddfDavid Lawrence
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews o The caller will give us a name, and we will return two items:
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews a handle and a list of addresses. If the list was non-empty when
09ab886382ad9e7149d9b72b4cf9a03ae4a1cddfDavid Lawrence it was given to us, we will append (unique) addrinfo's to the list.
09ab886382ad9e7149d9b72b4cf9a03ae4a1cddfDavid Lawrence
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews o How in the world do you shut this thing down?
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews If you cancel the fetches first:
09ab886382ad9e7149d9b72b4cf9a03ae4a1cddfDavid Lawrence 1. The handles are sent an event saying "no more
09ab886382ad9e7149d9b72b4cf9a03ae4a1cddfDavid Lawrence names are coming."
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews 2. The handles are moved to the dead handle list.
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews
09ab886382ad9e7149d9b72b4cf9a03ae4a1cddfDavid Lawrence If you cancel the handles first:
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews 1. The handles are moved to the dead handle list.
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson It would therefore seem simpler to cancel/done all handles first,
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson then all fetches.
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson o If a fetch returns a CNAME, what do we do?
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson o If a fetch returns a DNAME, what do we do?
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson o If a fetch returns 4 ipv4 addresses, we will have to allocate
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson 3 more (total of 4) namehooks, 4 entries, and fill them in.
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson What happens if only some of these can be allocated?
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson o ipv6 raises the memory problem to a new level. What if we
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson have to fork into multiple chains, but we run out of memory?
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews----------------------------------------------------------------------
a7038d1a0513c8e804937ebc95fc9cb3a46c04f5Mark Andrews
4f087942583014b241adca1bc78c6db89ed96e94Mark AndrewsLooking up entries via names:
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews Look for the name in the database.
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews FOUND:
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington For each complete address, allocate an addrinfo structure
17453368fa0136f6287c56d6600bee58809334bcAndreas Gustafsson and add it to the handle.
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews
5bf504f5534eab29c9e52f6e8b75c73b3901743fMark Andrews If any fetches are in progress for this name, attach this
4f087942583014b241adca1bc78c6db89ed96e94Mark Andrews handle to this name so events can be posted to the handle,
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews if the handle wants events.
5bf504f5534eab29c9e52f6e8b75c73b3901743fMark Andrews
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington If no fetches are in progress and the name is incomplete,
5bf504f5534eab29c9e52f6e8b75c73b3901743fMark Andrews see if we can start a fetch for this name.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington NOT FOUND:
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington Create a new adbname structure.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington Create a new namehook structure.
5bf504f5534eab29c9e52f6e8b75c73b3901743fMark Andrews
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington Start a fetch on this name.
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews If more data is coming (fetches are in progress) attach
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington the handle to the name, so it can get notification of
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington new data.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews If the name is incomplete (due to fetches in progress,
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington recently failed fetches, or the inability to start new
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington fetches) copy the incomplete flag to the handle, so the
a7038d1a0513c8e804937ebc95fc9cb3a46c04f5Mark Andrews caller can know this.
5bf504f5534eab29c9e52f6e8b75c73b3901743fMark Andrews
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington