Debian Codegraph @

dbus/DBus-interface

raw
1 DBus support must be enabled at compile-time and run-time. Ensure
2 that src/config.h contains the line
3
4 #define HAVE_DBUS.
5
6 and that /etc/dnsmasq.conf contains the line
7
8 enable-dbus
9
10 Because dnsmasq can operate stand-alone from the DBus, and may need to provide
11 service before the dbus daemon is available, it will continue to run
12 if the DBus connection is not available at startup. The DBus will be polled
13 every 250ms until a connection is established. Start of polling and final
14 connection establishment are both logged. When dnsmasq establishes a
15 connection to the dbus, it sends the signal "Up". Anything controlling
16 the server settings in dnsmasq should re-invoke the SetServers method
17 (q.v.) when it sees this signal. This allows dnsmasq to be restarted
18 and avoids startup races with the provider of nameserver information.
19
20
21 Dnsmasq provides one service on the DBus: uk.org.thekelleys.dnsmasq
22 and a single object: /uk/org/thekelleys/dnsmasq
23 The name of the service may be changed by giving an argument to --enable-dbus.
24
25 1. METHODS
26 ----------
27
28 Methods are of the form
29
30 uk.org.thekelleys.<method>
31
32 Available methods are:
33
34 GetVersion
35 ----------
36 Returns a string containing the version of dnsmasq running.
37
38 ClearCache
39 ----------
40 Returns nothing. Clears the domain name cache and re-reads
41 /etc/hosts. The same as sending dnsmasq a HUP signal.
42
43 SetFilterWin2KOption
44 --------------------
45 Takes boolean, sets or resets the --filterwin2k option.
46
47 SetFilterA
48 ------------------------
49 Takes boolean, sets or resets the --filter-A option.
50
51 SetFilterAAAA
52 ------------------------
53 Takes boolean, sets or resets the --filter-AAAA option.
54
55 SetBogusPrivOption
56 ------------------
57 Takes boolean, sets or resets the --bogus-priv option.
58
59 SetLocaliseQueriesOption
60 ------------------------
61 Takes boolean, sets or resets the --localise-queries option.
62
63 SetServers
64 ----------
65 Returns nothing. Takes a set of arguments representing the new
66 upstream DNS servers to be used by dnsmasq. IPv4 addresses are
67 represented as a UINT32 (in network byte order) and IPv6 addresses
68 are represented as sixteen BYTEs (since there is no UINT128 type).
69 Each server address may be followed by one or more STRINGS, which are
70 the domains for which the preceding server should be used.
71
72 Examples.
73
74 UINT32: <address1>
75 UNIT32: <address2>
76
77 is equivalent to
78
79 --server=<address1> --server=<address2>
80
81
82 UINT32 <address1>
83 UINT32 <address2>
84 STRING "somedomain.com"
85
86 is equivalent to
87
88 --server=<address1> --server=/somedomain.com/<address2>
89
90 UINT32 <address1>
91 UINT32 <address2>
92 STRING "somedomain.com"
93 UINT32 <address3>
94 STRING "anotherdomain.com"
95 STRING "thirddomain.com"
96
97 is equivalent to
98
99 --server=<address1>
100 --server=/somedomain.com/<address2>
101 --server=/anotherdomain.com/thirddomain.com/<address3>
102
103 Am IPv4 address of 0.0.0.0 is interpreted as "no address, local only",
104 so
105
106 UINT32: <0.0.0.0>
107 STRING "local.domain"
108
109 is equivalent to
110
111 --local=/local.domain/
112
113
114 Each call to SetServers completely replaces the set of servers
115 specified by via the DBus, but it leaves any servers specified via the
116 command line or /etc/dnsmasq.conf or /etc/resolv.conf alone.
117
118 SetServersEx
119 ------------
120
121 This function is more flexible and the SetServers function, in that it can
122 handle address scoping, port numbers, and is easier for clients to use.
123
124 Returns nothing. Takes a set of arguments representing the new
125 upstream DNS servers to be used by dnsmasq. All addresses (both IPv4 and IPv6)
126 are represented as STRINGS. Each server address may be followed by one or more
127 STRINGS, which are the domains for which the preceding server should be used.
128
129 This function takes an array of STRING arrays, where each inner array represents
130 a set of DNS servers and domains for which those servers may be used. Each
131 string represents a list of upstream DNS servers first, and domains second.
132 Mixing of domains and servers within a the string array is not allowed.
133
134 Examples.
135
136 [
137 ["1.2.3.4", "foobar.com"],
138 ["1003:1234:abcd::1%eth0", "eng.mycorp.com", "lab.mycorp.com"]
139 ]
140
141 is equivalent to
142
143 --server=/foobar.com/1.2.3.4 \
144 --server=/eng.mycorp.com/lab.mycorp.com/1003:1234:abcd::1%eth0
145
146 An IPv4 address of 0.0.0.0 is interpreted as "no address, local only",
147 so
148
149 [ ["0.0.0.0", "local.domain"] ]
150
151 is equivalent to
152
153 --local=/local.domain/
154
155
156 Each call to SetServersEx completely replaces the set of servers
157 specified by via the DBus, but it leaves any servers specified via the
158 command line or /etc/dnsmasq.conf or /etc/resolv.conf alone.
159
160
161 SetDomainServers
162 ----------------
163
164 Yes another variation for setting DNS servers, with the capability of
165 SetServersEx, but without using arrays of arrays, which are not
166 sendable with dbus-send. The arguments are an array of strings which
167 are identical to the equivalent arguments --server, so the example
168 for SetServersEx is represented as
169
170 [
171 "/foobar.com/1.2.3.4"
172 "/eng.mycorp.com/lab.mycorp.com/1003:1234:abcd::1%eth0"
173 ]
174
175 GetLoopServers
176 --------------
177
178 (Only available if dnsmasq compiled with HAVE_LOOP)
179
180 Return an array of strings, each string is the IP address of an upstream
181 server which has been found to loop queries back to this dnsmasq instance, and
182 it therefore not being used.
183
184 AddDhcpLease
185 ------------
186
187 Returns nothing. Adds or updates a DHCP or DHCPv6 lease to the internal lease
188 database, as if a client requested and obtained a lease.
189
190 If a lease for the IPv4 or IPv6 address already exist, it is overwritten.
191
192 Note that this function will trigger the DhcpLeaseAdded or DhcpLeaseUpdated
193 D-Bus signal and will run the configured DHCP lease script accordingly.
194
195 This function takes many arguments which are the lease parameters:
196 - A string with the textual representation of the IPv4 or IPv6 address of the
197 client.
198
199 Examples:
200 "192.168.1.115"
201 "1003:1234:abcd::1%eth0"
202 "2001:db8:abcd::1"
203
204 - A string representing the hardware address of the client, using the same
205 format as the one used in the lease database.
206
207 Examples:
208
209 "00:23:45:67:89:ab"
210 "06-00:20:e0:3b:13:af" (token ring)
211
212 - The hostname of the client, as an array of bytes (so there is no problem
213 with non-ASCII character encoding). May be empty.
214
215 Example (for "hostname.or.fqdn"):
216 [104, 111, 115, 116, 110, 97, 109, 101, 46, 111, 114, 46, 102, 113, 100, 110]
217
218 - The client identifier (IPv4) or DUID (IPv6) as an array of bytes. May be
219 empty.
220
221 Examples:
222
223 DHCPv6 DUID:
224 [0, 3, 0, 1, 0, 35, 69, 103, 137, 171]
225 DHCPv4 client identifier:
226 [255, 12, 34, 56, 78, 0, 1, 0, 1, 29, 9, 99, 190, 35, 69, 103, 137, 171]
227
228 - The duration of the lease, in seconds. If the lease is updated, then
229 the duration replaces the previous duration.
230
231 Example:
232
233 7200
234
235 - The IAID (Identity association identifier) of the DHCPv6 lease, as a network
236 byte-order unsigned integer. For DHCPv4 leases, this must be set to 0.
237
238 Example (for IPv6):
239
240 203569230
241
242 - A boolean which, if true, indicates that the DHCPv6 lease is for a temporary
243 address (IA_TA). If false, the DHCPv6 lease is for a non-temporary address
244 (IA_NA). For DHCPv4 leases, this must be set to false.
245
246 RemoveDhcpLease
247 ---------------
248
249 Returns nothing. Removes a DHCP or DHCPv6 lease to the internal lease
250 database, as if a client sent a release message to abandon a lease.
251
252 This function takes only one parameter: the text representation of the
253 IPv4 or IPv6 address of the lease to remove.
254
255 Note that this function will trigger the DhcpLeaseRemoved signal and the
256 configured DHCP lease script will be run with the "del" action.
257
258 GetMetrics
259 ----------
260
261 Returns an array with various metrics for DNS and DHCP.
262
263 GetServerMetrics
264 ----------------
265
266 Returns per-DNS-server metrics.
267
268 ClearMetrics
269 ------------
270
271 Clear call metric counters, global and per-server.
272
273 2. SIGNALS
274 ----------
275
276 If dnsmasq's DHCP server is active, it will send signals over DBUS whenever
277 the DHCP lease database changes. Think of these signals as transactions on
278 a database with the IP address acting as the primary key.
279
280 Signals are of the form:
281
282 uk.org.thekelleys.<signal>
283
284 and their parameters are:
285
286 STRING "192.168.1.115"
287 STRING "01:23:45:67:89:ab"
288 STRING "hostname.or.fqdn"
289
290
291 Available signals are:
292
293 DhcpLeaseAdded
294 ---------------
295
296 This signal is emitted when a DHCP lease for a given IP address is created.
297
298 DhcpLeaseDeleted
299 ----------------
300
301 This signal is emitted when a DHCP lease for a given IP address is deleted.
302
303 DhcpLeaseUpdated
304 ----------------
305
306 This signal is emitted when a DHCP lease for a given IP address is updated.
307