]> git.ipfire.org Git - people/ms/dnsmasq.git/blame - src/dnsmasq.h
import of dnsmasq-2.33.tar.gz
[people/ms/dnsmasq.git] / src / dnsmasq.h
CommitLineData
f6b7dc47 1/* dnsmasq is Copyright (c) 2000-2005 Simon Kelley
9e4abcb5
SK
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 dated June, 1991.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11*/
12
e17fb629 13#define COPYRIGHT "Copyright (C) 2000-2006 Simon Kelley"
9e4abcb5 14
9e4abcb5 15/* get these before config.h for IPv6 stuff... */
44a2a316 16#include <sys/types.h>
9e4abcb5
SK
17#include <netinet/in.h>
18
f6b7dc47
SK
19#ifdef __APPLE__
20/* need this before arpa/nameser.h */
21# define BIND_8_COMPAT
22#endif
3be34541 23#include <arpa/nameser.h>
9e4abcb5 24
59353a6b
SK
25/* and this. */
26#include <getopt.h>
27
9e4abcb5 28#include "config.h"
b8187c80
SK
29
30#define gettext_noop(S) (S)
31#ifdef NO_GETTEXT
32# define _(S) (S)
33#else
34# include <libintl.h>
35# include <locale.h>
36# define _(S) gettext(S)
37#endif
38
9e4abcb5
SK
39#include <arpa/inet.h>
40#include <sys/stat.h>
41#include <sys/socket.h>
9e4abcb5
SK
42#include <sys/ioctl.h>
43#include <sys/select.h>
feba5c1d 44#include <sys/wait.h>
9e4abcb5 45#include <sys/time.h>
8a911ccc 46#include <limits.h>
9e4abcb5
SK
47#include <net/if.h>
48#include <unistd.h>
49#include <stdio.h>
50#include <string.h>
51#include <stdlib.h>
52#include <fcntl.h>
53#include <ctype.h>
54#include <signal.h>
9e4abcb5
SK
55#include <time.h>
56#include <errno.h>
57#include <pwd.h>
58#include <grp.h>
f6b7dc47 59#include <stdarg.h>
de37951c 60#if defined(__OpenBSD__) || defined(__NetBSD__)
44a2a316
SK
61# include <netinet/if_ether.h>
62#else
63# include <net/ethernet.h>
64#endif
9e4abcb5
SK
65#include <net/if_arp.h>
66#include <netinet/in_systm.h>
67#include <netinet/ip.h>
3be34541 68#include <netinet/ip_icmp.h>
5e9e0efb 69#include <sys/uio.h>
849a8357
SK
70#include <syslog.h>
71#include <dirent.h>
5e9e0efb 72#ifndef HAVE_LINUX_NETWORK
44a2a316 73# include <net/if_dl.h>
9e4abcb5 74#endif
5e9e0efb
SK
75
76#ifdef HAVE_LINUX_NETWORK
77#include <linux/capability.h>
78/* There doesn't seem to be a universally-available
79 userpace header for this. */
80extern int capset(cap_user_header_t header, cap_user_data_t data);
81#include <sys/prctl.h>
82#endif
9e4abcb5 83
0a852541
SK
84/* Min buffer size: we check after adding each record, so there must be
85 memory for the largest packet, and the largest record so the
86 min for DNS is PACKETSZ+MAXDNAME+RRFIXEDSZ which is < 1000.
87 This might be increased is EDNS packet size if greater than the minimum.
cdeda28f
SK
88*/
89#define DNSMASQ_PACKETSZ PACKETSZ+MAXDNAME+RRFIXEDSZ
44a2a316 90
9e4abcb5
SK
91#define OPT_BOGUSPRIV 1
92#define OPT_FILTER 2
93#define OPT_LOG 4
94#define OPT_SELFMX 8
95#define OPT_NO_HOSTS 16
96#define OPT_NO_POLL 32
97#define OPT_DEBUG 64
98#define OPT_ORDER 128
99#define OPT_NO_RESOLV 256
100#define OPT_EXPAND 512
101#define OPT_LOCALMX 1024
102#define OPT_NO_NEG 2048
103#define OPT_NODOTS_LOCAL 4096
44a2a316
SK
104#define OPT_NOWILD 8192
105#define OPT_ETHERS 16384
de37951c 106#define OPT_RESOLV_DOMAIN 32768
3be34541 107#define OPT_NO_FORK 65536
fd9fa481 108#define OPT_AUTHORITATIVE 131072
f6b7dc47 109#define OPT_LOCALISE 262144
3d8df260
SK
110#define OPT_DBUS 524288
111#define OPT_BOOTP_DYNAMIC 1048576
5e9e0efb 112#define OPT_NO_PING 2097152
208b65c5 113#define OPT_LEASE_RO 4194304
9e4abcb5
SK
114
115struct all_addr {
116 union {
117 struct in_addr addr4;
118#ifdef HAVE_IPV6
119 struct in6_addr addr6;
120#endif
121 } addr;
122};
123
124struct bogus_addr {
125 struct in_addr addr;
126 struct bogus_addr *next;
127};
128
1cff166d
SK
129/* dns doctor param */
130struct doctor {
131 struct in_addr in, out, mask;
132 struct doctor *next;
133};
134
0a852541
SK
135struct mx_srv_record {
136 char *name, *target;
3d8df260
SK
137 int issrv, srvport, priority, weight;
138 unsigned int offset;
0a852541 139 struct mx_srv_record *next;
de37951c
SK
140};
141
0a852541
SK
142struct txt_record {
143 char *name, *txt;
144 unsigned short class, len;
145 struct txt_record *next;
f6b7dc47
SK
146};
147
9e4abcb5
SK
148union bigname {
149 char name[MAXDNAME];
150 union bigname *next; /* freelist */
151};
152
153struct crec {
154 struct crec *next, *prev, *hash_next;
155 time_t ttd; /* time to die */
fd9fa481
SK
156 int uid;
157 union {
158 struct all_addr addr;
159 struct {
160 struct crec *cache;
161 int uid;
162 } cname;
163 } addr;
9e4abcb5
SK
164 unsigned short flags;
165 union {
166 char sname[SMALLDNAME];
167 union bigname *bname;
168 char *namep;
169 } name;
170};
171
172#define F_IMMORTAL 1
fd9fa481 173#define F_CONFIG 2
9e4abcb5
SK
174#define F_REVERSE 4
175#define F_FORWARD 8
176#define F_DHCP 16
177#define F_NEG 32
178#define F_HOSTS 64
179#define F_IPV4 128
180#define F_IPV6 256
181#define F_BIGNAME 512
182#define F_UPSTREAM 1024
183#define F_SERVER 2048
184#define F_NXDOMAIN 4096
185#define F_QUERY 8192
fd9fa481 186#define F_CNAME 16384
9e4abcb5
SK
187#define F_NOERR 32768
188
189/* struct sockaddr is not large enough to hold any address,
cdeda28f 190 and specifically not big enough to hold an IPv6 address.
9e4abcb5
SK
191 Blech. Roll our own. */
192union mysockaddr {
193 struct sockaddr sa;
194 struct sockaddr_in in;
195#ifdef HAVE_BROKEN_SOCKADDR_IN6
196 /* early versions of glibc don't include sin6_scope_id in sockaddr_in6
197 but latest kernels _require_ it to be set. The choice is to have
198 dnsmasq fail to compile on back-level libc or fail to run
199 on latest kernels with IPv6. Or to do this: sorry that it's so gross. */
200 struct my_sockaddr_in6 {
201 sa_family_t sin6_family; /* AF_INET6 */
202 uint16_t sin6_port; /* transport layer port # */
203 uint32_t sin6_flowinfo; /* IPv6 traffic class & flow info */
204 struct in6_addr sin6_addr; /* IPv6 address */
205 uint32_t sin6_scope_id; /* set of interfaces for a scope */
206 } in6;
207#elif defined(HAVE_IPV6)
208 struct sockaddr_in6 in6;
209#endif
210};
211
0a852541
SK
212#define SERV_FROM_RESOLV 1 /* 1 for servers from resolv, 0 for command line. */
213#define SERV_NO_ADDR 2 /* no server, this domain is local only */
214#define SERV_LITERAL_ADDRESS 4 /* addr is the answer, not the server */
215#define SERV_HAS_SOURCE 8 /* source address specified */
216#define SERV_HAS_DOMAIN 16 /* server for one domain only */
217#define SERV_FOR_NODOTS 32 /* server for names with no domain part only */
218#define SERV_WARNED_RECURSIVE 64 /* avoid warning spam */
3d8df260
SK
219#define SERV_FROM_DBUS 128 /* 1 if source is DBus */
220#define SERV_MARK 256 /* for mark-and-delete */
9e4abcb5
SK
221#define SERV_TYPE (SERV_HAS_DOMAIN | SERV_FOR_NODOTS)
222
0a852541 223
9e4abcb5
SK
224struct serverfd {
225 int fd;
226 union mysockaddr source_addr;
227 struct serverfd *next;
228};
229
230struct server {
231 union mysockaddr addr, source_addr;
232 struct serverfd *sfd; /* non-NULL if this server has its own fd bound to
233 a source port */
234 char *domain; /* set if this server only handles a domain. */
feba5c1d 235 int flags, tcpfd;
9e4abcb5
SK
236 struct server *next;
237};
238
9e4abcb5
SK
239struct irec {
240 union mysockaddr addr;
f6b7dc47 241 struct in_addr netmask; /* only valid for IPv4 */
9e4abcb5
SK
242 struct irec *next;
243};
244
44a2a316 245struct listener {
feba5c1d 246 int fd, tcpfd, family;
f6b7dc47 247 struct irec *iface; /* only valid for non-wildcard */
44a2a316
SK
248 struct listener *next;
249};
250
9e4abcb5
SK
251/* interface and address parms from command line. */
252struct iname {
253 char *name;
254 union mysockaddr addr;
de37951c 255 int isloop, used;
9e4abcb5
SK
256 struct iname *next;
257};
258
259/* resolv-file parms from command-line */
260struct resolvc {
261 struct resolvc *next;
3d8df260
SK
262 int is_default, logged;
263 time_t mtime;
9e4abcb5
SK
264 char *name;
265};
266
fd9fa481
SK
267/* adn-hosts parms from command-line */
268struct hostsfile {
269 struct hostsfile *next;
270 char *fname;
cdeda28f 271 int index; /* matches to cache entries for logging */
fd9fa481
SK
272};
273
9e4abcb5
SK
274struct frec {
275 union mysockaddr source;
44a2a316 276 struct all_addr dest;
9e4abcb5 277 struct server *sentto;
dfa666f2 278 unsigned int iface;
9e4abcb5 279 unsigned short orig_id, new_id;
0a852541 280 int fd, forwardall;
fd9fa481 281 unsigned int crc;
9e4abcb5
SK
282 time_t time;
283 struct frec *next;
284};
285
cdeda28f
SK
286#define DHCP_CHADDR_MAX 16
287
9e4abcb5
SK
288struct dhcp_lease {
289 int clid_len; /* length of client identifier */
290 unsigned char *clid; /* clientid */
291 char *hostname, *fqdn; /* name from client-hostname option or config */
7cebd20f
SK
292 char auth_name; /* hostname came from config, not from client */
293 char new; /* newly created */
208b65c5
SK
294 char changed; /* modified */
295 char aux_changed; /* CLID or expiry changed */
9e4abcb5 296 time_t expires; /* lease expiry */
5e9e0efb
SK
297#ifdef HAVE_BROKEN_RTC
298 unsigned int length;
299#endif
cdeda28f
SK
300 int hwaddr_len, hwaddr_type;
301 unsigned char hwaddr[DHCP_CHADDR_MAX];
9e4abcb5
SK
302 struct in_addr addr;
303 struct dhcp_lease *next;
304};
305
a222641c
SK
306struct dhcp_netid {
307 char *net;
308 struct dhcp_netid *next;
309};
310
26128d27
SK
311struct dhcp_netid_list {
312 struct dhcp_netid *list;
313 struct dhcp_netid_list *next;
314};
9e4abcb5 315struct dhcp_config {
33820b7e 316 unsigned int flags;
9e4abcb5
SK
317 int clid_len; /* length of client identifier */
318 unsigned char *clid; /* clientid */
cdeda28f
SK
319 int hwaddr_len, hwaddr_type;
320 unsigned char hwaddr[DHCP_CHADDR_MAX];
a222641c
SK
321 char *hostname;
322 struct dhcp_netid netid;
9e4abcb5 323 struct in_addr addr;
849a8357 324 time_t decline_time;
0a852541 325 unsigned int lease_time, wildcard_mask;
9e4abcb5
SK
326 struct dhcp_config *next;
327};
328
0a852541
SK
329#define CONFIG_DISABLE 1
330#define CONFIG_CLID 2
331#define CONFIG_HWADDR 4
332#define CONFIG_TIME 8
333#define CONFIG_NAME 16
334#define CONFIG_ADDR 32
335#define CONFIG_NETID 64
336#define CONFIG_NOCLID 128
849a8357
SK
337#define CONFIG_FROM_ETHERS 256 /* entry created by /etc/ethers */
338#define CONFIG_ADDR_HOSTS 512 /* address added by from /etc/hosts */
339#define CONFIG_DECLINED 1024 /* address declined by client */
33820b7e 340
9e4abcb5 341struct dhcp_opt {
cdeda28f 342 int opt, len, flags;
91dccd09 343 unsigned char *val, *vendor_class;
26128d27 344 struct dhcp_netid *netid;
9e4abcb5 345 struct dhcp_opt *next;
a84fa1d0
SK
346};
347
cdeda28f
SK
348#define DHOPT_ADDR 1
349#define DHOPT_STRING 2
350
26128d27
SK
351struct dhcp_boot {
352 char *file, *sname;
353 struct in_addr next_server;
354 struct dhcp_netid *netid;
355 struct dhcp_boot *next;
356};
357
a84fa1d0 358struct dhcp_vendor {
26128d27 359 int len, is_vendor;
a222641c
SK
360 char *data;
361 struct dhcp_netid netid;
a84fa1d0
SK
362 struct dhcp_vendor *next;
363};
9e4abcb5 364
cdeda28f
SK
365struct dhcp_mac {
366 unsigned int mask;
367 int hwaddr_len, hwaddr_type;
368 unsigned char hwaddr[DHCP_CHADDR_MAX];
369 struct dhcp_netid netid;
370 struct dhcp_mac *next;
371};
372
9e4abcb5 373struct dhcp_context {
feba5c1d 374 unsigned int lease_time, addr_epoch;
0a852541
SK
375 struct in_addr netmask, broadcast;
376 struct in_addr local, router;
a84fa1d0 377 struct in_addr start, end; /* range of available addresses */
0a852541 378 int flags;
cdeda28f 379 struct dhcp_netid netid, *filter;
36717eee 380 struct dhcp_context *next, *current;
9e4abcb5
SK
381};
382
0a852541 383#define CONTEXT_STATIC 1
cdeda28f
SK
384#define CONTEXT_NETMASK 2
385#define CONTEXT_BRDCAST 4
0a852541
SK
386
387
9e4abcb5
SK
388typedef unsigned char u8;
389typedef unsigned short u16;
390typedef unsigned int u32;
391
392
5e9e0efb
SK
393struct dhcp_packet {
394 u8 op, htype, hlen, hops;
395 u32 xid;
396 u16 secs, flags;
397 struct in_addr ciaddr, yiaddr, siaddr, giaddr;
398 u8 chaddr[DHCP_CHADDR_MAX], sname[64], file[128];
399 u8 options[312];
9e4abcb5
SK
400};
401
3d8df260
SK
402struct ping_result {
403 struct in_addr addr;
404 time_t time;
405 struct ping_result *next;
406};
9e4abcb5 407
3be34541
SK
408struct daemon {
409 /* datastuctures representing the command-line and
410 config file arguments. All set (including defaults)
411 in option.c */
412
413 unsigned int options;
414 struct resolvc default_resolv, *resolv_files;
0a852541
SK
415 struct mx_srv_record *mxnames;
416 struct txt_record *txt;
3be34541
SK
417 char *mxtarget;
418 char *lease_file;
419 char *username, *groupname;
420 char *domain_suffix;
421 char *runfile;
7cebd20f 422 char *lease_change_command;
3d8df260 423 struct iname *if_names, *if_addrs, *if_except, *dhcp_except;
3be34541
SK
424 struct bogus_addr *bogus_addr;
425 struct server *servers;
849a8357 426 int log_fac; /* log facility */
208b65c5 427 int cachesize, ftabsize;
3be34541
SK
428 int port, query_port;
429 unsigned long local_ttl;
fd9fa481 430 struct hostsfile *addn_hosts;
3be34541
SK
431 struct dhcp_context *dhcp;
432 struct dhcp_config *dhcp_conf;
91dccd09 433 struct dhcp_opt *dhcp_opts, *vendor_opts;
3be34541 434 struct dhcp_vendor *dhcp_vendors;
cdeda28f 435 struct dhcp_mac *dhcp_macs;
26128d27
SK
436 struct dhcp_boot *boot_config;
437 struct dhcp_netid_list *dhcp_ignore;
3be34541
SK
438 int dhcp_max;
439 unsigned int min_leasetime;
440 struct doctor *doctors;
441 unsigned short edns_pktsz;
442
443 /* globally used stuff for DNS */
444 char *packet; /* packet buffer */
0a852541 445 int packet_buff_sz; /* size of above */
3be34541
SK
446 char *namebuff; /* MAXDNAME size buffer */
447 struct serverfd *sfds;
3d8df260 448 struct irec *interfaces;
3be34541
SK
449 struct listener *listeners;
450 struct server *last_server;
cdeda28f
SK
451 struct server *srv_save; /* Used for resend on DoD */
452 size_t packet_len; /* " " */
7cebd20f 453 pid_t script_pid, tcp_pids[MAX_PROCS];
5e9e0efb 454 int num_kids;
3be34541
SK
455
456 /* DHCP state */
5e9e0efb
SK
457 int dhcpfd;
458#ifdef HAVE_LINUX_NETWORK
0a852541 459 int netlinkfd;
5e9e0efb
SK
460#else
461 int dhcp_raw_fd, dhcp_icmp_fd;
0a852541 462#endif
5e9e0efb 463 struct iovec dhcp_packet;
3be34541 464 char *dhcp_buff, *dhcp_buff2;
3d8df260 465 struct ping_result *ping_results;
cdeda28f 466 FILE *lease_stream;
3d8df260
SK
467
468 /* DBus stuff */
469#ifdef HAVE_DBUS
470 /* void * here to avoid depending on dbus headers outside dbus.c */
471 void *dbus;
472 struct watch *watches;
473#endif
474
3be34541
SK
475};
476
9e4abcb5
SK
477/* cache.c */
478void cache_init(int cachesize, int log);
fd9fa481
SK
479void log_query(unsigned short flags, char *name, struct all_addr *addr,
480 unsigned short type, struct hostsfile *addn_hosts, int index);
9e4abcb5
SK
481struct crec *cache_find_by_addr(struct crec *crecp,
482 struct all_addr *addr, time_t now,
483 unsigned short prot);
484struct crec *cache_find_by_name(struct crec *crecp,
485 char *name, time_t now, unsigned short prot);
486void cache_end_insert(void);
487void cache_start_insert(void);
fd9fa481
SK
488struct crec *cache_insert(char *name, struct all_addr *addr,
489 time_t now, unsigned long ttl, unsigned short flags);
490void cache_reload(int opts, char *buff, char *domain_suffix, struct hostsfile *addn_hosts);
491void cache_add_dhcp_entry(struct daemon *daemon, char *host_name, struct in_addr *host_address, time_t ttd);
9e4abcb5 492void cache_unhash_dhcp(void);
5e9e0efb 493void dump_cache(struct daemon *daemon, time_t now);
9e4abcb5
SK
494char *cache_get_name(struct crec *crecp);
495
496/* rfc1035.c */
cdeda28f 497unsigned short extract_request(HEADER *header, size_t qlen,
c1bb8504 498 char *name, unsigned short *typep);
cdeda28f
SK
499size_t setup_reply(HEADER *header, size_t qlen,
500 struct all_addr *addrp, unsigned short flags,
501 unsigned long local_ttl);
502void extract_addresses(HEADER *header, size_t qlen, char *namebuff,
fd9fa481 503 time_t now, struct daemon *daemon);
cdeda28f 504size_t answer_request(HEADER *header, char *limit, size_t qlen, struct daemon *daemon,
f6b7dc47 505 struct in_addr local_addr, struct in_addr local_netmask, time_t now);
cdeda28f 506int check_for_bogus_wildcard(HEADER *header, size_t qlen, char *name,
9e4abcb5 507 struct bogus_addr *addr, time_t now);
cdeda28f
SK
508unsigned char *find_pseudoheader(HEADER *header, size_t plen,
509 size_t *len, unsigned char **p);
f6b7dc47 510int check_for_local_domain(char *name, time_t now, struct daemon *daemon);
cdeda28f
SK
511unsigned int questions_crc(HEADER *header, size_t plen, char *buff);
512size_t resize_packet(HEADER *header, size_t plen,
513 unsigned char *pheader, size_t hlen);
9e4abcb5
SK
514
515/* util.c */
516unsigned short rand16(void);
517int legal_char(char c);
518int canonicalise(char *s);
3d8df260 519unsigned char *do_rfc1035_name(unsigned char *p, char *sval);
9e4abcb5 520void die(char *message, char *arg1);
0a852541
SK
521void complain(char *message, int lineno, char *file);
522void *safe_malloc(size_t size);
9e4abcb5
SK
523int sa_len(union mysockaddr *addr);
524int sockaddr_isequal(union mysockaddr *s1, union mysockaddr *s2);
3d8df260 525int hostname_isequal(char *a, char *b);
5e9e0efb 526time_t dnsmasq_time(void);
a84fa1d0 527int is_same_net(struct in_addr a, struct in_addr b, struct in_addr mask);
fd9fa481 528int retry_send(void);
0a852541 529void prettyprint_time(char *buf, unsigned int t);
3d8df260 530int prettyprint_addr(union mysockaddr *addr, char *buf);
0a852541 531int parse_hex(char *in, unsigned char *out, int maxlen,
cdeda28f 532 unsigned int *wildcard_mask, int *mac_type);
5e9e0efb
SK
533int memcmp_masked(unsigned char *a, unsigned char *b, int len,
534 unsigned int mask);
535int expand_buf(struct iovec *iov, size_t size);
7cebd20f
SK
536char *print_mac(struct daemon *daemon, unsigned char *mac, int len);
537
9e4abcb5 538/* option.c */
3d8df260 539struct daemon *read_opts (int argc, char **argv, char *compile_opts);
9e4abcb5
SK
540
541/* forward.c */
3be34541
SK
542void reply_query(struct serverfd *sfd, struct daemon *daemon, time_t now);
543void receive_query(struct listener *listen, struct daemon *daemon, time_t now);
3d8df260
SK
544unsigned char *tcp_request(struct daemon *daemon, int confd, time_t now,
545 struct in_addr local_addr, struct in_addr netmask);
849a8357 546void server_gone(struct daemon *daemon, struct server *server);
3be34541 547
9e4abcb5 548/* network.c */
feba5c1d 549struct serverfd *allocate_sfd(union mysockaddr *addr, struct serverfd **sfds);
849a8357 550int reload_servers(char *fname, struct daemon *daemon);
3d8df260 551void check_servers(struct daemon *daemon);
5e9e0efb 552int enumerate_interfaces(struct daemon *daemon);
44a2a316 553struct listener *create_wildcard_listeners(int port);
5e9e0efb
SK
554struct listener *create_bound_listeners(struct daemon *daemon);
555int iface_check(struct daemon *daemon, int family,
556 struct all_addr *addr, char *name);
7cebd20f 557int fix_fd(int fd);
3be34541 558
9e4abcb5 559/* dhcp.c */
3be34541
SK
560void dhcp_init(struct daemon *daemon);
561void dhcp_packet(struct daemon *daemon, time_t now);
562
59353a6b
SK
563struct dhcp_context *address_available(struct dhcp_context *context, struct in_addr addr);
564struct dhcp_context *narrow_context(struct dhcp_context *context, struct in_addr taddr);
cdeda28f 565int match_netid(struct dhcp_netid *check, struct dhcp_netid *pool, int negonly);
3be34541 566int address_allocate(struct dhcp_context *context, struct daemon *daemon,
cdeda28f 567 struct in_addr *addrp, unsigned char *hwaddr, int hw_len,
3d8df260 568 struct dhcp_netid *netids, time_t now);
9e4abcb5
SK
569struct dhcp_config *find_config(struct dhcp_config *configs,
570 struct dhcp_context *context,
571 unsigned char *clid, int clid_len,
cdeda28f
SK
572 unsigned char *hwaddr, int hw_len,
573 int hw_type, char *hostname);
44a2a316 574void dhcp_update_configs(struct dhcp_config *configs);
3be34541 575void dhcp_read_ethers(struct daemon *daemon);
dfa666f2 576struct dhcp_config *config_find_by_address(struct dhcp_config *configs, struct in_addr addr);
bb01cb96
SK
577char *strip_hostname(struct daemon *daemon, char *hostname);
578char *host_from_dns(struct daemon *daemon, struct in_addr addr);
3be34541 579
9e4abcb5 580/* lease.c */
7cebd20f 581void lease_update_file(struct daemon *daemon, time_t now);
fd9fa481 582void lease_update_dns(struct daemon *daemon);
3be34541 583void lease_init(struct daemon *daemon, time_t now);
7cebd20f
SK
584struct dhcp_lease *lease_allocate(struct in_addr addr);
585void lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
cdeda28f 586 unsigned char *clid, int hw_len, int hw_type, int clid_len);
b8187c80
SK
587void lease_set_hostname(struct dhcp_lease *lease, char *name,
588 char *suffix, int auth);
5e9e0efb 589void lease_set_expires(struct dhcp_lease *lease, unsigned int len, time_t now);
cdeda28f 590struct dhcp_lease *lease_find_by_client(unsigned char *hwaddr, int hw_len, int hw_type,
0a852541 591 unsigned char *clid, int clid_len);
9e4abcb5
SK
592struct dhcp_lease *lease_find_by_addr(struct in_addr addr);
593void lease_prune(struct dhcp_lease *target, time_t now);
b8187c80 594void lease_update_from_configs(struct daemon *daemon);
7cebd20f 595void lease_collect(struct daemon *daemon);
a84fa1d0 596
9e4abcb5 597/* rfc2131.c */
cdeda28f 598size_t dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_name, size_t sz, time_t now, int unicast_dest);
3be34541
SK
599
600/* dnsmasq.c */
5e9e0efb 601int make_icmp_sock(void);
3be34541 602int icmp_ping(struct daemon *daemon, struct in_addr addr);
7cebd20f 603void clear_cache_and_reload(struct daemon *daemon, time_t now);
44a2a316 604
33820b7e
SK
605/* isc.c */
606#ifdef HAVE_ISC_READER
fd9fa481 607void load_dhcp(struct daemon *daemon, time_t now);
33820b7e 608#endif
feba5c1d 609
0a852541 610/* netlink.c */
5e9e0efb 611#ifdef HAVE_LINUX_NETWORK
cdeda28f 612void netlink_init(struct daemon *daemon);
5e9e0efb
SK
613int iface_enumerate(struct daemon *daemon, void *parm,
614 int (*ipv4_callback)(), int (*ipv6_callback)());
cdeda28f 615void netlink_multicast(struct daemon *daemon);
5e9e0efb
SK
616#endif
617
618/* bpf.c */
619#ifndef HAVE_LINUX_NETWORK
620void init_bpf(struct daemon *daemon);
621void send_via_bpf(struct daemon *daemon, struct dhcp_packet *mess, size_t len,
622 struct in_addr iface_addr, struct ifreq *ifr);
623int iface_enumerate(struct daemon *daemon, void *parm,
624 int (*ipv4_callback)(), int (*ipv6_callback)());
0a852541 625#endif
3d8df260
SK
626
627/* dbus.c */
628#ifdef HAVE_DBUS
629char *dbus_init(struct daemon *daemon);
630void check_dbus_listeners(struct daemon *daemon,
631 fd_set *rset, fd_set *wset, fd_set *eset);
632int set_dbus_listeners(struct daemon *daemon, int maxfd,
633 fd_set *rset, fd_set *wset, fd_set *eset);
634#endif