[NetBSD logo]    &    [Google logo]

NetBSD-SoC: Zeroconf

What is it?

This is part of the NetBSD project for the Google Summer of code. Google gives to computer science students the opportunity to develop open source code, under the guide of important open source organization like NetBSD.

"NetBSD is a free, secure, and highly portable Unix-like Open Source operating system available for many platforms, from 64-bit, Opteron machines and desktop systems to handheld and embedded devices. Its clean design and advanced features make it excellent in both production and research environments, and it is user-supported with complete source."

The goal of this project is to add zeroconf support to NetBSD. The project is divided in two parts.

The first part consists in writing a daemon which autoconfigure IPv4 link-local address for a network interface, if there is no DHCP server and no manual configuration. The second part is about developing a library for multicast DNS, which is used to resolve local network host name and discover available services in network where there is no DNS server.



Specifications about this topics are found at this links:

Other operating systems already implements these features. There is an open source implementation howl of the daemon, the and the DNS library. It does not fully support IPv6 and does not fit well with NetBSD. Apple implementation, instead, is found here. But we like much more NetBSD licensed code. :-)

Technical Details


The zeroconfd deamon should interact with dhclient. I've put in the project directory a modified version of dhclient-script. When on an interface the dhclient fails in acquiring or in renewing a lease it adds that interface to the ones which the daemon runs on.


The responderd daemon implements the multicast DNS specification. It reads the resource records to announce from a file and then waits and listen on every multicast interface for queries it can answer. It also makes the query for every application on the host it is running on. There will be 2 interfaces: a syncronous one through gethostbyname/getnameinfo, and an asyncronous based on a callback system.

Cache implementation

The cache is implemented with a binary tree using functions tsearch tfind tdelete. The key of every element is the a string made up of the domain name and the number of the type of the record. Every element is actually a list since there could be more than one resource records with the same name and type according to the specification.

Events handling

There is a struct event_lists with a five lists of events.

So an event always belogs to 2 list: the events list and to his specific type list. So it's easier and quicker to find the correct event when we receive a packet.

A zc_event is simply a struct with all the necessary data for the event.

Conflict handling

See manual page.. The behaviour descripted is the same implemented by mDNSResponder.


The daemon is interacting well with howl implementation of mulicast dns.



  • test interaction with dhclient


  1. the 2 libraries

    The event handling took me more than I expected. Now it wont't be very difficult to implement this library, since in unix_sock.c there are already the function to communicate with the unix socket. I've made a little test program mdns_query to test it a little bit.

  2. implement txt records

    As you can see, dns.c is made of function which operates on the different types of resource records. I've not implemented the function to handle txt records, because I wanted to have a working responderd before the end and I was running out of time.

  3. add rr-expired event

    When we add a record to the cache we must schedule an event so that elements would be deleted from the cache when expired.

  4. reimplement configuration file parser

    I've code a very simple and lame parser for the configuration file, not to waste time and to concentrate to the dns and events stuff. The parser could be borrowed from bind.

SourceForge.net Logo
John Doe <john@doe.com>
$Id: index.html,v 1.7 2005/08/31 17:19:26 silvio-valenti Exp $