forked from haesbaert/mdnsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
103 lines (88 loc) · 4.15 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Copyright (c) 2010, Christiano F. Haesbaert <[email protected]>
Multicast Domain Name System for OpenBSD
----------------------------------------
Intro
-----
This is an attempt to bring native mdns/dns-sd to OpenBSD. Mainly
cause all the other options suck and proper network browsing is a nice
feature these days.
Why not Apple's mdnsd ?
1 - It sucks big time.
2 - No BSD License (Apache-2).
3 - Overcomplex API.
4 - Not OpenBSD-like.
Why not Avahi ?
1 - No BSD License (LGPL).
2 - Overcomplex API.
3 - Not OpenBSD-like
4 - DBUS and lots of dependencies.
My goal is to first provide a solid mdns framework without the
service-discovery capabilities which are much more complex. When that
is working properly, work on service-discovery will begin, the
architecture was designed in order to support it. So goals:
* Have a mdns responder/querier as an user process (mdnsd).
* Have integration with libc's resolver, read: make
gethostbyname and friends resolve names through mdns.
* Have an application interface so other software can
publish names/services as they see fit.
* Have a mdns control program, which is mainly a crude
interface to the API.
MDNSD Design
------------
The "Multicast Domain Name System Daemon" is an user process that runs
without privileges, it binds to udp port 5353 and acts as the
querier/responder for all mdns requests. By responder we understand
who is responsible for answering mdns queries, and by querier the
other way around, read: This is different from libc's unicast
resolver, we *NEED* to cache answers and maintain state.
As most OpenBSD daemons, it drops privilege upon startup and none task
requires super-user privilege. All work is done on a single process,
my first design had a process per interface, but that became overkill
and overcomplex.
The API is designed above Henning Brauer imsg framework, so we have a
unix domain socket that listen to requests from other processes, much
like ripctl and ospfctl do, but we need a fancier API. We use
libevent and all it's glorious features to have a proper unix daemon.
There is a routing socket in order to be notified when link goes up
and down, or when an interface address changes, this is *required* in
order to publish records, every time link comes up we need to re-probe
for our records and things like that, we use as our main name the
short name from /etc/myname in the .local domain.
The basic data flow would be:
__________ _______
| Programs | <--Control Socket (API)--> | MDNSD | <-- Mcast Packets -->
---------- -------
LIBMDNS Design (API)
--------------------
Libmdns is a shared library in which programs can link against in
order to have mdns capabilities, like publishing services, browsing
the network and so on, by now the only thing it does is resolving mdns
names and browsing for services, no publishing capabilities yet. All
the library does is sending and receiving messages to mdnsd through
the imsg framework. The library should provide in the near future:
* Means for looking up names. (DONE)
* Means for publishing names.
* Means for browsing services (dns-service-discovery). (DONE)
* Means for publishing services.
By now no library is being used to make it easier for people to test
mdnsctl, everything is being kept on mdnsl.c in mdnsctl/.
On libc integration:
After a chat with nicm@ we have decided not to worry about libc right
now, maybe never. See the README file on mdns-libc branch if you're
curious.
MDNSCTL
-------
It's a simple interface for the library, code is inspired in
ripctl. By now you can use it to lookup hosts and browse
services.
How do I use this thing ?
-------------------------
Get the source from http://github.com/haesbaert/mdnsd
Add user and group _mdnsd
Compile and install mdnsd and mdnsctl
Make sure you have proper multicast setup (man 7 netstart), or
just add a route to lo0:
route delete 224/4
route add 224/4 127.0.0.1
Run mdnsd on the desired interface: mdnsd -d iface
Play with mdnsctl :)