]> git.ipfire.org Git - people/ms/dnsmasq.git/blame - dbus/DBus-interface
Fix boilerplate code for re-running system calls on EINTR and EAGAIN etc.
[people/ms/dnsmasq.git] / dbus / DBus-interface
CommitLineData
3d8df260
SK
1DBus support must be enabled at compile-time and run-time. Ensure
2that src/config.h contains the line
3
4#define HAVE_DBUS.
5
6and that /etc/dnsmasq.conf contains the line
7
8enable-dbus
9
10Because dnsmasq can operate stand-alone from the DBus, and may need to provide
11service before the dbus daemon is available, it will continue to run
12if the DBus connection is not available at startup. The DBus will be polled
13every 250ms until a connection is established. Start of polling and final
14connection establishment are both logged. When dnsmasq establishes a
15connection to the dbus, it sends the signal "Up". Anything controlling
16the server settings in dnsmasq should re-invoke the SetServers method
17(q.v.) when it sees this signal. This allows dnsmasq to be restarted
18and avoids startup races with the provider of nameserver information.
19
20
21Dnsmasq provides one service on the DBus: uk.org.thekelleys.dnsmasq
ad094275
SK
22and a single object: /uk/org/thekelleys/dnsmasq
23The name of the service may be changed by giving an argument to --enable-dbus.
3d8df260 24
9009d746
SK
251. METHODS
26----------
27
3d8df260
SK
28Methods are of the form
29
30uk.org.thekelleys.<method>
31
32Available methods are:
33
34GetVersion
35----------
36Returns a string containing the version of dnsmasq running.
37
38ClearCache
39----------
40Returns nothing. Clears the domain name cache and re-reads
41/etc/hosts. The same as sending dnsmasq a HUP signal.
42
c4638f9e
DC
43SetFilterWin2KOption
44--------------------
45Takes boolean, sets or resets the --filterwin2k option.
46
47SetBogusPrivOption
48------------------
49Takes boolean, sets or resets the --bogus-priv option.
50
3d8df260
SK
51SetServers
52----------
53Returns nothing. Takes a set of arguments representing the new
54upstream DNS servers to be used by dnsmasq. IPv4 addresses are
55represented as a UINT32 (in network byte order) and IPv6 addresses
56are represented as sixteen BYTEs (since there is no UINT128 type).
57Each server address may be followed by one or more STRINGS, which are
58the domains for which the preceding server should be used.
59
60Examples.
61
62UINT32: <address1>
63UNIT32: <address2>
64
65is equivalent to
66
67--server=<address1> --server=<address2>
68
69
70UINT32 <address1>
71UINT32 <address2>
72STRING "somedomain.com"
73
74is equivalent to
75
76--server=<address1> --server=/somedomain.com/<address2>
77
78UINT32 <address1>
79UINT32 <address2>
80STRING "somedomain.com"
81UINT32 <address3>
82STRING "anotherdomain.com"
83STRING "thirddomain.com"
84
85is equivalent to
86
87--server=<address1>
88--server=/somedomain.com/<address2>
89--server=/anotherdomain.com/thirddomain.com/<address3>
90
91Am IPv4 address of 0.0.0.0 is interpreted as "no address, local only",
92so
93
94UINT32: <0.0.0.0>
95STRING "local.domain"
96
97is equivalent to
98
99--local=/local.domain/
100
101
102Each call to SetServers completely replaces the set of servers
103specified by via the DBus, but it leaves any servers specified via the
104command line or /etc/dnsmasq.conf or /etc/resolv.conf alone.
105
faafb3f7
SK
106SetServersEx
107------------
108
109This function is more flexible and the SetServers function, in that it can
110handle address scoping, port numbers, and is easier for clients to use.
111
112Returns nothing. Takes a set of arguments representing the new
113upstream DNS servers to be used by dnsmasq. All addresses (both IPv4 and IPv6)
114are represented as STRINGS. Each server address may be followed by one or more
115STRINGS, which are the domains for which the preceding server should be used.
116
117This function takes an array of STRING arrays, where each inner array represents
118a set of DNS servers and domains for which those servers may be used. Each
119string represents a list of upstream DNS servers first, and domains second.
120Mixing of domains and servers within a the string array is not allowed.
121
122Examples.
123
124[
125 ["1.2.3.4", "foobar.com"],
126 ["1003:1234:abcd::1%eth0", "eng.mycorp.com", "lab.mycorp.com"]
127]
128
129is equivalent to
130
131--server=/foobar.com/1.2.3.4 \
132 --server=/eng.mycorp.com/lab.mycorp.com/1003:1234:abcd::1%eth0
133
134An IPv4 address of 0.0.0.0 is interpreted as "no address, local only",
135so
136
137[ ["0.0.0.0", "local.domain"] ]
138
139is equivalent to
140
141--local=/local.domain/
142
143
144Each call to SetServersEx completely replaces the set of servers
145specified by via the DBus, but it leaves any servers specified via the
146command line or /etc/dnsmasq.conf or /etc/resolv.conf alone.
147
295a54ee
SK
148
149SetDomainServers
150----------------
151
152Yes another variation for setting DNS servers, with the capability of
153SetServersEx, but without using arrays of arrays, which are not
154sendable with dbus-send. The arguments are an array of strings which
155are identical to the equivalent arguments --server, so the example
156for SetServersEx is represented as
157
158[
159 "/foobar.com/1.2.3.4"
160 "/eng.mycorp.com/lab.mycorp.com/1003:1234:abcd::1%eth0"
161]
162
aaeea9f6
SK
163GetLoopServers
164--------------
165
166(Only available if dnsmasq compiled with HAVE_LOOP)
167
168Return an array of strings, each string is the IP address of an upstream
169server which has been found to loop queries back to this dnsmasq instance, and
170it therefore not being used.
171
295a54ee
SK
172
173
9009d746
SK
1742. SIGNALS
175----------
176
177If dnsmasq's DHCP server is active, it will send signals over DBUS whenever
178the DHCP lease database changes. Think of these signals as transactions on
179a database with the IP address acting as the primary key.
180
181Signals are of the form:
182
183uk.org.thekelleys.<signal>
184
185and their parameters are:
186
187STRING "192.168.1.115"
188STRING "01:23:45:67:89:ab"
189STRING "hostname.or.fqdn"
190
191
192Available signals are:
193
194DhcpLeaseAdded
195---------------
196
197This signal is emitted when a DHCP lease for a given IP address is created.
198
199DhcpLeaseDeleted
200----------------
201
202This signal is emitted when a DHCP lease for a given IP address is deleted.
203
204DhcpLeaseUpdated
205----------------
3d8df260 206
9009d746
SK
207This signal is emitted when a DHCP lease for a given IP address is updated.
208