Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using apple resolver libraries



Following up on my earlier response and those of several others on this list.

The whole story from API like gethostbyname() or getaddrinfo() is, as has been pointed out, more complex than just DNS.

A number of APIs with sources in the Libinfo project, and found in libSystem, have been modified to forward queries to lookupd. The man page for lookupd describes how this works in some detail. Briefly, lookupd is a search engine. When given a query, it searches for the desired information by consulting a set of "Agents". An agent is a module that forwards a query to a particular directory service, such as NetInfo, NIS, or DNS. It also has a "Cache" agent that caches results from previous queries to improve system performance, and an agent that forwards queries on to the Open Directory daemon (DirectoryService), which may continue the search in other directory systems. lookupd has a couple of static agents, and has a plugin mechanism to dynamically load others. It queries these agents following a search order defined for each category of query. For example, user queries such as those generated by calls to getpwnam(), or host queries such as those generated by gethostbyname(). Depending on the particular query, lookupd may stop as soon as it has found one answer for a query, or it may do exhaustive searches for many items.

Thus, for example, a gethostbyname() call will go from libSystem to lookupd. lookupd's default search order for hosts is to first check the cache, then to search the /etc/hosts file, then query the multi-client DNS search API (described in my previous message), then to query NetInfo, and finally to forward the query to the DirectroyServices daemon. The gethostbyname() query stops as soon as it finds any result.

One added wrinkle: libSystem also contains a small cache, so a call might actually be resolved in the library without ever getting sent to lookupd.

--
Marc Majka
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.


References: 
 >Using apple resolver libraries (From: Andrew White <email@hidden>)
 >Re: Using apple resolver libraries (From: Marc Majka <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.