-/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
+/* dnsmasq is Copyright (c) 2000-2013 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define COPYRIGHT "Copyright (c) 2000-2011 Simon Kelley"
+#define COPYRIGHT "Copyright (c) 2000-2013 Simon Kelley"
#ifndef NO_LARGEFILE
/* Ensure we can use files >2GB (log files may grow this big) */
/* get these before config.h for IPv6 stuff... */
#include <sys/types.h>
#include <sys/socket.h>
+
+#ifdef __APPLE__
+/* Define before netinet/in.h to select API. OSX Lion onwards. */
+# define __APPLE_USE_RFC_3542
+#endif
#include <netinet/in.h>
-/* and this. */
+/* Also needed before config.h. */
#include <getopt.h>
#include "config.h"
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
+typedef unsigned long long u64;
-#include "dns_protocol.h"
-#include "dhcp_protocol.h"
+#include "dns-protocol.h"
+#include "dhcp-protocol.h"
+#ifdef HAVE_DHCP6
+#include "dhcp6-protocol.h"
+#include "radv-protocol.h"
+#endif
#define gettext_noop(S) (S)
#ifndef LOCALEDIR
/* Async event queue */
struct event_desc {
- int event, data;
+ int event, data, msg_sz;
};
#define EVENT_RELOAD 1
#define EVENT_DIE 16
#define EVENT_LOG_ERR 17
#define EVENT_FORK_ERR 18
+#define EVENT_LUA_ERR 19
+#define EVENT_TFTP_ERR 20
/* Exit codes. */
#define EC_GOOD 0
#define OPT_DNSSEC 33
#define OPT_CONSEC_ADDR 34
#define OPT_CONNTRACK 35
-#define OPT_LAST 36
+#define OPT_FQDN_UPDATE 36
+#define OPT_RA 37
+#define OPT_TFTP_LC 38
+#define OPT_CLEVERBIND 39
+#define OPT_TFTP 40
+#define OPT_LAST 41
/* extra flags for my_syslog, we use a couple of facilities since they are known
not to occupy the same bits as priorities, no matter how syslog.h is set up. */
struct cname *next;
};
+struct auth_zone {
+ char *domain;
+ struct subnet {
+ int is6, prefixlen;
+ struct in_addr addr4;
+#ifdef HAVE_IPV6
+ struct in6_addr addr6;
+#endif
+ struct subnet *next;
+ } *subnet;
+ struct auth_zone *next;
+};
+
+
+struct host_record {
+ struct name_list {
+ char *name;
+ struct name_list *next;
+ } *names;
+ struct in_addr addr;
+#ifdef HAVE_IPV6
+ struct in6_addr addr6;
+#endif
+ struct host_record *next;
+};
+
struct interface_name {
char *name; /* domain name */
char *intr; /* interface name */
union bigname *next; /* freelist */
};
+struct keydata {
+ struct keydata *next;
+ unsigned char key[KEYBLOCK_LEN];
+};
+
struct crec {
struct crec *next, *prev, *hash_next;
- time_t ttd; /* time to die */
- int uid;
+ /* union is 16 bytes when doing IPv6, 8 bytes on 32 bit machines without IPv6 */
union {
struct all_addr addr;
struct {
struct crec *cache;
int uid;
} cname;
+ struct {
+ struct keydata *keydata;
+ unsigned char algo;
+ unsigned char digest; /* DS only */
+ unsigned short flags_or_keyid; /* flags for DNSKEY, keyid for DS */
+ } key;
} addr;
+ time_t ttd; /* time to die */
+ /* used as keylen if F_DS or F_DNSKEY, index to source for F_HOSTS */
+ int uid;
unsigned short flags;
union {
char sname[SMALLDNAME];
#define F_BIGNAME (1u<<9)
#define F_NXDOMAIN (1u<<10)
#define F_CNAME (1u<<11)
-#define F_NOERR (1u<<12)
+#define F_DNSKEY (1u<<12)
#define F_CONFIG (1u<<13)
+#define F_DS (1u<<14)
+#define F_DNSSECOK (1u<<15)
+
/* below here are only valid as args to log_query: cache
entries are limited to 16 bits */
#define F_UPSTREAM (1u<<16)
#define F_RRNAME (1u<<17)
#define F_SERVER (1u<<18)
#define F_QUERY (1u<<19)
+#define F_NOERR (1u<<20)
+#define F_AUTH (1u<<21)
+
+/* composites */
+#define F_TYPE (F_IPV4 | F_IPV6 | F_DNSKEY | F_DS) /* Only one may be set */
+
/* struct sockaddr is not large enough to hold any address,
#endif
};
+/* bits in flag param to IPv6 callbacks from iface_enumerate() */
+#define IFACE_TENTATIVE 1
+#define IFACE_DEPRECATED 2
+
+
#define SERV_FROM_RESOLV 1 /* 1 for servers from resolv, 0 for command line. */
#define SERV_NO_ADDR 2 /* no server, this domain is local only */
#define SERV_LITERAL_ADDRESS 4 /* addr is the answer, not the server */
struct server *next;
};
+struct ipsets {
+ char **sets;
+ char *domain;
+ struct ipsets *next;
+};
+
struct irec {
union mysockaddr addr;
struct in_addr netmask; /* only valid for IPv4 */
- int tftp_ok, mtu, done, dad;
- char *name;
+ int tftp_ok, dhcp_ok, mtu, done, dad, dns_auth, index, multicast_done;
+ char *name;
struct irec *next;
};
struct listener {
int fd, tcpfd, tftpfd, family;
- struct irec *iface; /* only valid for non-wildcard */
+ struct irec *iface; /* only sometimes valid for non-wildcard */
struct listener *next;
};
struct iname {
char *name;
union mysockaddr addr;
- int isloop, used;
+ int used;
struct iname *next;
};
struct frec *next;
};
+/* flags in top of length field for DHCP-option tables */
+#define OT_ADDR_LIST 0x8000
+#define OT_RFC1035_NAME 0x4000
+#define OT_INTERNAL 0x2000
+#define OT_NAME 0x1000
+#define OT_CSTRING 0x0800
+#define OT_DEC 0x0400
+#define OT_TIME 0x0200
+
/* actions in the daemon->helper RPC */
#define ACTION_DEL 1
#define ACTION_OLD_HOSTNAME 2
#define ACTION_OLD 3
#define ACTION_ADD 4
+#define ACTION_TFTP 5
+
+#define LEASE_NEW 1 /* newly created */
+#define LEASE_CHANGED 2 /* modified */
+#define LEASE_AUX_CHANGED 4 /* CLID or expiry changed */
+#define LEASE_AUTH_NAME 8 /* hostname came from config, not from client */
+#define LEASE_USED 16 /* used this DHCPv6 transaction */
+#define LEASE_NA 32 /* IPv6 no-temporary lease */
+#define LEASE_TA 64 /* IPv6 temporary lease */
+#define LEASE_HAVE_HWADDR 128 /* Have set hwaddress */
struct dhcp_lease {
int clid_len; /* length of client identifier */
unsigned char *clid; /* clientid */
char *hostname, *fqdn; /* name from client-hostname option or config */
char *old_hostname; /* hostname before it moved to another lease */
- char auth_name; /* hostname came from config, not from client */
- char new; /* newly created */
- char changed; /* modified */
- char aux_changed; /* CLID or expiry changed */
+ int flags;
time_t expires; /* lease expiry */
#ifdef HAVE_BROKEN_RTC
unsigned int length;
#endif
- int hwaddr_len, hwaddr_type;
- unsigned char hwaddr[DHCP_CHADDR_MAX];
+ int hwaddr_len, hwaddr_type; /* hw_type used for iaid in v6 */
+ unsigned char hwaddr[DHCP_CHADDR_MAX]; /* also IPv6 address */
struct in_addr addr, override, giaddr;
unsigned char *extradata;
unsigned int extradata_len, extradata_size;
int last_interface;
+#ifdef HAVE_DHCP6
+ struct slaac_address {
+ struct in6_addr addr, local;
+ time_t ping_time;
+ int backoff; /* zero -> confirmed */
+ struct slaac_address *next;
+ } *slaac_address;
+ int vendorclass_count;
+#endif
struct dhcp_lease *next;
};
unsigned char *clid; /* clientid */
char *hostname, *domain;
struct dhcp_netid_list *netid;
+#ifdef HAVE_DHCP6
+ struct in6_addr addr6;
+#endif
struct in_addr addr;
time_t decline_time;
unsigned int lease_time;
struct dhcp_config *next;
};
+#define have_config(config, mask) ((config) && ((config)->flags & (mask)))
+
#define CONFIG_DISABLE 1
#define CONFIG_CLID 2
#define CONFIG_TIME 8
#define CONFIG_ADDR_HOSTS 512 /* address added by from /etc/hosts */
#define CONFIG_DECLINED 1024 /* address declined by client */
#define CONFIG_BANK 2048 /* from dhcp hosts file */
+#define CONFIG_ADDR6 4096
+#define CONFIG_WILDCARD 8192
struct dhcp_opt {
int opt, len, flags;
#define DHOPT_VENDOR_MATCH 1024
#define DHOPT_RFC3925 2048
#define DHOPT_TAGOK 4096
+#define DHOPT_ADDR6 8192
struct dhcp_boot {
char *file, *sname, *tftp_sname;
struct pxe_service {
unsigned short CSA, type;
- char *menu, *basename;
+ char *menu, *basename, *sname;
struct in_addr server;
struct dhcp_netid *netid;
struct pxe_service *next;
/* vendorclass, userclass, remote-id or cicuit-id */
struct dhcp_vendor {
- int len, match_type, option;
+ int len, match_type;
+ unsigned int enterprise;
char *data;
struct dhcp_netid netid;
struct dhcp_vendor *next;
struct cond_domain {
char *domain;
struct in_addr start, end;
+#ifdef HAVE_IPV6
+ struct in6_addr start6, end6;
+#endif
+ int is6;
struct cond_domain *next;
+};
+
+#ifdef OPTION6_PREFIX_CLASS
+struct prefix_class {
+ int class;
+ struct dhcp_netid tag;
+ struct prefix_class *next;
};
+#endif
struct dhcp_context {
unsigned int lease_time, addr_epoch;
struct in_addr netmask, broadcast;
struct in_addr local, router;
struct in_addr start, end; /* range of available addresses */
+#ifdef HAVE_DHCP6
+ struct in6_addr start6, end6; /* range of available addresses */
+ struct in6_addr local6;
+ int prefix, if_index;
+ unsigned int valid, preferred;
+ time_t ra_time, ra_short_period_start;
+ char *template_interface;
+#endif
int flags;
- char *interface;
struct dhcp_netid netid, *filter;
struct dhcp_context *next, *current;
};
-#define CONTEXT_STATIC 1
-#define CONTEXT_NETMASK 2
-#define CONTEXT_BRDCAST 4
-#define CONTEXT_PROXY 8
+#define CONTEXT_STATIC 1
+#define CONTEXT_NETMASK 2
+#define CONTEXT_BRDCAST 4
+#define CONTEXT_PROXY 8
+#define CONTEXT_RA_ONLY 16
+#define CONTEXT_RA_DONE 32
+#define CONTEXT_RA_NAME 64
+#define CONTEXT_RA_STATELESS 128
+#define CONTEXT_DHCP 256
+#define CONTEXT_DEPRECATE 512
+#define CONTEXT_TEMPLATE 1024 /* create contexts using addresses */
+#define CONTEXT_CONSTRUCTED 2048
+#define CONTEXT_GC 4096
+#define CONTEXT_RA 8192
+#define CONTEXT_CONF_USED 16384
+#define CONTEXT_USED 32768
struct ping_result {
struct in_addr addr;
struct addr_list *next;
};
-struct interface_list {
- char *interface;
- struct interface_list *next;
-};
-
struct tftp_prefix {
char *interface;
char *prefix;
time_t last_resolv;
struct mx_srv_record *mxnames;
struct naptr *naptr;
- struct txt_record *txt;
+ struct txt_record *txt, *rr;
struct ptr_record *ptr;
+ struct host_record *host_records, *host_records_tail;
struct cname *cnames;
+ struct auth_zone *auth_zones;
struct interface_name *int_names;
char *mxtarget;
char *lease_file;
char *username, *groupname, *scriptuser;
+ char *luascript;
+ char *authserver, *hostmaster;
+ struct iname *authinterface;
+ struct name_list *secondary_forward_server;
int group_set, osport;
char *domain_suffix;
- struct cond_domain *cond_domain;
+ struct cond_domain *cond_domain, *synth_domains;
char *runfile;
char *lease_change_command;
- struct iname *if_names, *if_addrs, *if_except, *dhcp_except;
+ struct iname *if_names, *if_addrs, *if_except, *dhcp_except, *auth_peers;
struct bogus_addr *bogus_addr;
struct server *servers;
+ struct ipsets *ipsets;
int log_fac; /* log facility */
char *log_file; /* optional log file */
int max_logs; /* queue limit */
int cachesize, ftabsize;
int port, query_port, min_port;
- unsigned long local_ttl, neg_ttl, max_ttl;
+ unsigned long local_ttl, neg_ttl, max_ttl, max_cache_ttl, auth_ttl;
struct hostsfile *addn_hosts;
- struct dhcp_context *dhcp;
+ struct dhcp_context *dhcp, *dhcp6;
struct dhcp_config *dhcp_conf;
- struct dhcp_opt *dhcp_opts, *dhcp_match;
+ struct dhcp_opt *dhcp_opts, *dhcp_match, *dhcp_opts6, *dhcp_match6;
struct dhcp_vendor *dhcp_vendors;
struct dhcp_mac *dhcp_macs;
struct dhcp_boot *boot_config;
struct addr_list *override_relays;
int override;
int enable_pxe;
+ int doing_ra, doing_dhcp6;
struct dhcp_netid_list *dhcp_ignore, *dhcp_ignore_names, *dhcp_gen_names;
struct dhcp_netid_list *force_broadcast, *bootp_dynamic;
struct hostsfile *dhcp_hosts_file, *dhcp_opts_file;
unsigned short edns_pktsz;
char *tftp_prefix;
struct tftp_prefix *if_prefix; /* per-interface TFTP prefixes */
- struct interface_list *tftp_interfaces; /* interfaces for limited TFTP service */
- int tftp_unlimited;
+ unsigned int duid_enterprise, duid_config_len;
+ unsigned char *duid_config;
+ char *dbus_name;
+ unsigned long soa_sn, soa_refresh, soa_retry, soa_expiry;
+#ifdef OPTION6_PREFIX_CLASS
+ struct prefix_class *prefix_classes;
+#endif
/* globally used stuff for DNS */
char *packet; /* packet buffer */
struct ping_result *ping_results;
FILE *lease_stream;
struct dhcp_bridge *bridges;
-
+#ifdef HAVE_DHCP6
+ int duid_len;
+ unsigned char *duid;
+ struct iovec outpacket;
+ int dhcp6fd, icmp6fd;
+#endif
/* DBus stuff */
/* void * here to avoid depending on dbus headers outside dbus.c */
void *dbus;
#endif
/* TFTP stuff */
- struct tftp_transfer *tftp_trans;
+ struct tftp_transfer *tftp_trans, *tftp_done_trans;
+
+ /* utility string buffer, hold max sized IP address as string */
+ char *addrbuff;
} *daemon;
void cache_init(void);
void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg);
char *record_source(int index);
-void querystr(char *str, unsigned short type);
+void querystr(char *desc, char *str, unsigned short type);
struct crec *cache_find_by_addr(struct crec *crecp,
struct all_addr *addr, time_t now,
unsigned short prot);
struct crec *cache_insert(char *name, struct all_addr *addr,
time_t now, unsigned long ttl, unsigned short flags);
void cache_reload(void);
-void cache_add_dhcp_entry(char *host_name, struct in_addr *host_address, time_t ttd);
+void cache_add_dhcp_entry(char *host_name, int prot, struct all_addr *host_address, time_t ttd);
struct in_addr a_record_from_hosts(char *name, time_t now);
void cache_unhash_dhcp(void);
void dump_cache(time_t now);
char *cache_get_name(struct crec *crecp);
+struct crec *cache_enumerate(int init);
+#ifdef HAVE_DNSSEC
+struct keydata *keydata_alloc(char *data, size_t len);
+void keydata_free(struct keydata *blocks);
+#endif
+
+/* domain.c */
char *get_domain(struct in_addr addr);
+#ifdef HAVE_IPV6
+char *get_domain6(struct in6_addr *addr);
+#endif
+int is_name_synthetic(int flags, char *name, struct all_addr *addr);
+int is_rev_synth(int flag, struct all_addr *addr, char *name);
/* rfc1035.c */
unsigned int extract_request(struct dns_header *header, size_t qlen,
struct all_addr *addrp, unsigned int flags,
unsigned long local_ttl);
int extract_addresses(struct dns_header *header, size_t qlen, char *namebuff,
- time_t now, int is_sign, int checkrebind, int checking_disabled);
+ time_t now, char **ipsets, int is_sign, int checkrebind,
+ int checking_disabled);
size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
struct in_addr local_addr, struct in_addr local_netmask, time_t now);
int check_for_bogus_wildcard(struct dns_header *header, size_t qlen, char *name,
size_t resize_packet(struct dns_header *header, size_t plen,
unsigned char *pheader, size_t hlen);
size_t add_mac(struct dns_header *header, size_t plen, char *limit, union mysockaddr *l3);
+int add_resource_record(struct dns_header *header, char *limit, int *truncp,
+ int nameoffset, unsigned char **pp, unsigned long ttl,
+ int *offset, unsigned short type, unsigned short class, char *format, ...);
+unsigned char *skip_questions(struct dns_header *header, size_t plen);
+int extract_name(struct dns_header *header, size_t plen, unsigned char **pp,
+ char *name, int isExtract, int extrabytes);
+int in_arpa_name_2_addr(char *namein, struct all_addr *addrp);
+
+/* auth.c */
+#ifdef HAVE_AUTH
+size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, time_t now, union mysockaddr *peer_addr);
+#endif
/* util.c */
void rand_init(void);
void *whine_malloc(size_t size);
int sa_len(union mysockaddr *addr);
int sockaddr_isequal(union mysockaddr *s1, union mysockaddr *s2);
-int hostname_isequal(char *a, char *b);
+int hostname_isequal(const char *a, const char *b);
time_t dnsmasq_time(void);
int is_same_net(struct in_addr a, struct in_addr b, struct in_addr mask);
+#ifdef HAVE_IPV6
+int is_same_net6(struct in6_addr *a, struct in6_addr *b, int prefixlen);
+u64 addr6part(struct in6_addr *addr);
+void setaddr6part(struct in6_addr *addr, u64 host);
+#endif
int retry_send(void);
void prettyprint_time(char *buf, unsigned int t);
int prettyprint_addr(union mysockaddr *addr, char *buf);
void bump_maxfd(int fd, int *max);
int read_write(int fd, unsigned char *packet, int size, int rw);
+int wildcard_match(const char* wildcard, const char* match);
+
/* log.c */
void die(char *message, char *arg1, int exit_code);
int log_start(struct passwd *ent_pw, int errfd);
/* option.c */
void read_opts (int argc, char **argv, char *compile_opts);
-char *option_string(unsigned char opt, int *is_ip, int *is_name);
+char *option_string(int prot, unsigned int opt, unsigned char *val,
+ int opt_len, char *buf, int buf_len);
void reread_dhcp(void);
void set_option_bool(unsigned int opt);
+void reset_option_bool(unsigned int opt);
struct hostsfile *expand_filelist(struct hostsfile *list);
+char *parse_server(char *arg, union mysockaddr *addr,
+ union mysockaddr *source_addr, char *interface, int *flags);
/* forward.c */
void reply_query(int fd, int family, time_t now);
void receive_query(struct listener *listen, time_t now);
unsigned char *tcp_request(int confd, time_t now,
- union mysockaddr *local_addr, struct in_addr netmask);
+ union mysockaddr *local_addr, struct in_addr netmask, int auth_dns);
void server_gone(struct server *server);
struct frec *get_new_frec(time_t now, int *wait);
+int send_from(int fd, int nowild, char *packet, size_t len,
+ union mysockaddr *to, struct all_addr *source,
+ unsigned int iface);
/* network.c */
int indextoname(int fd, int index, char *name);
void create_wildcard_listeners(void);
void create_bound_listeners(int die);
int is_dad_listeners(void);
-int iface_check(int family, struct all_addr *addr, char *name, int *indexp);
+int iface_check(int family, struct all_addr *addr, char *name, int *auth_dns);
+int loopback_exception(int fd, int family, struct all_addr *addr, char *name);
int fix_fd(int fd);
+int tcp_interface(int fd, int af);
struct in_addr get_ifaddr(char *intr);
+#ifdef HAVE_IPV6
+int set_ipv6pktinfo(int fd);
+#endif
+#ifdef HAVE_DHCP6
+void join_multicast(int dienow);
+#endif
/* dhcp.c */
#ifdef HAVE_DHCP
struct dhcp_context *narrow_context(struct dhcp_context *context,
struct in_addr taddr,
struct dhcp_netid *netids);
-int match_netid(struct dhcp_netid *check, struct dhcp_netid *pool, int negonly);
int address_allocate(struct dhcp_context *context,
struct in_addr *addrp, unsigned char *hwaddr, int hw_len,
struct dhcp_netid *netids, time_t now);
-struct dhcp_netid *run_tag_if(struct dhcp_netid *input);
int config_has_mac(struct dhcp_config *config, unsigned char *hwaddr, int len, int type);
struct dhcp_config *find_config(struct dhcp_config *configs,
struct dhcp_context *context,
unsigned char *clid, int clid_len,
unsigned char *hwaddr, int hw_len,
int hw_type, char *hostname);
-void dhcp_update_configs(struct dhcp_config *configs);
void dhcp_read_ethers(void);
-void check_dhcp_hosts(int fatal);
struct dhcp_config *config_find_by_address(struct dhcp_config *configs, struct in_addr addr);
-char *strip_hostname(char *hostname);
char *host_from_dns(struct in_addr addr);
-char *get_domain(struct in_addr addr);
#endif
/* lease.c */
#ifdef HAVE_DHCP
void lease_update_file(time_t now);
-void lease_update_dns();
+void lease_update_dns(int force);
void lease_init(time_t now);
-struct dhcp_lease *lease_allocate(struct in_addr addr);
+struct dhcp_lease *lease4_allocate(struct in_addr addr);
+#ifdef HAVE_DHCP6
+struct dhcp_lease *lease6_allocate(struct in6_addr *addrp, int lease_type);
+struct dhcp_lease *lease6_find(unsigned char *clid, int clid_len,
+ int lease_type, int iaid, struct in6_addr *addr);
+void lease6_reset(void);
+struct dhcp_lease *lease6_find_by_client(struct dhcp_lease *first, int lease_type, unsigned char *clid, int clid_len, int iaid);
+struct dhcp_lease *lease6_find_by_addr(struct in6_addr *net, int prefix, u64 addr);
+u64 lease_find_max_addr6(struct dhcp_context *context);
+void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface);
+void lease_update_slaac(time_t now);
+#endif
void lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
- unsigned char *clid, int hw_len, int hw_type, int clid_len);
-void lease_set_hostname(struct dhcp_lease *lease, char *name, int auth);
+ unsigned char *clid, int hw_len, int hw_type, int clid_len, time_t now, int force);
+void lease_set_hostname(struct dhcp_lease *lease, char *name, int auth, char *domain, char *config_domain);
void lease_set_expires(struct dhcp_lease *lease, unsigned int len, time_t now);
-void lease_set_interface(struct dhcp_lease *lease, int interface);
+void lease_set_interface(struct dhcp_lease *lease, int interface, time_t now);
struct dhcp_lease *lease_find_by_client(unsigned char *hwaddr, int hw_len, int hw_type,
unsigned char *clid, int clid_len);
struct dhcp_lease *lease_find_by_addr(struct in_addr addr);
void lease_update_from_configs(void);
int do_script_run(time_t now);
void rerun_scripts(void);
+void lease_find_interfaces(time_t now);
+#ifdef HAVE_SCRIPT
+void lease_add_extradata(struct dhcp_lease *lease, unsigned char *data,
+ unsigned int len, int delim);
+#endif
#endif
/* rfc2131.c */
int make_icmp_sock(void);
int icmp_ping(struct in_addr addr);
#endif
-void send_event(int fd, int event, int data);
+void send_alarm(time_t event, time_t now);
+void send_event(int fd, int event, int data, char *msg);
void clear_cache_and_reload(time_t now);
void poll_resolv(int force, int do_reload, time_t now);
/* netlink.c */
#ifdef HAVE_LINUX_NETWORK
void netlink_init(void);
-void netlink_multicast(void);
+void netlink_multicast(time_t now);
#endif
/* bpf.c */
# endif
#endif
+/* ipset.c */
+#ifdef HAVE_IPSET
+void ipset_init(void);
+int add_to_ipset(const char *setname, const struct all_addr *ipaddr, int flags, int remove);
+#endif
+
/* helper.c */
-#if defined(HAVE_DHCP) && !defined(NO_FORK)
+#if defined(HAVE_SCRIPT)
int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd);
void helper_write(void);
void queue_script(int action, struct dhcp_lease *lease,
char *hostname, time_t now);
+#ifdef HAVE_TFTP
+void queue_tftp(off_t file_len, char *filename, union mysockaddr *peer);
+#endif
int helper_buf_empty(void);
#endif
#ifdef HAVE_TFTP
void tftp_request(struct listener *listen, time_t now);
void check_tftp_listeners(fd_set *rset, time_t now);
+int do_tftp_script_run(void);
#endif
/* conntrack.c */
int get_incoming_mark(union mysockaddr *peer_addr, struct all_addr *local_addr,
int istcp, unsigned int *markp);
#endif
+
+/* dhcp6.c */
+#ifdef HAVE_DHCP6
+void dhcp6_init(void);
+void dhcp6_packet(time_t now);
+struct dhcp_context *address6_allocate(struct dhcp_context *context, unsigned char *clid, int clid_len,
+ int iaid, int serial, struct dhcp_netid *netids, int plain_range, struct in6_addr *ans);
+int config_valid(struct dhcp_config *config, struct dhcp_context *context, struct in6_addr *addr);
+struct dhcp_context *address6_available(struct dhcp_context *context,
+ struct in6_addr *taddr,
+ struct dhcp_netid *netids,
+ int plain_range);
+struct dhcp_context *address6_valid(struct dhcp_context *context,
+ struct in6_addr *taddr,
+ struct dhcp_netid *netids,
+ int plain_range);
+struct dhcp_config *find_config6(struct dhcp_config *configs,
+ struct dhcp_context *context,
+ unsigned char *duid, int duid_len,
+ char *hostname);
+struct dhcp_config *config_find_by_address6(struct dhcp_config *configs, struct in6_addr *net,
+ int prefix, u64 addr);
+void make_duid(time_t now);
+void dhcp_construct_contexts(time_t now);
+#endif
+
+/* rfc3315.c */
+#ifdef HAVE_DHCP6
+unsigned short dhcp6_reply(struct dhcp_context *context, int interface, char *iface_name,
+ struct in6_addr *fallback, size_t sz, int is_multicast, time_t now);
+#endif
+
+/* dhcp-common.c */
+#ifdef HAVE_DHCP
+void dhcp_common_init(void);
+ssize_t recv_dhcp_packet(int fd, struct msghdr *msg);
+struct dhcp_netid *run_tag_if(struct dhcp_netid *input);
+struct dhcp_netid *option_filter(struct dhcp_netid *tags, struct dhcp_netid *context_tags,
+ struct dhcp_opt *opts);
+int match_netid(struct dhcp_netid *check, struct dhcp_netid *pool, int negonly);
+char *strip_hostname(char *hostname);
+void log_tags(struct dhcp_netid *netid, u32 xid);
+int match_bytes(struct dhcp_opt *o, unsigned char *p, int len);
+void dhcp_update_configs(struct dhcp_config *configs);
+void display_opts(void);
+int lookup_dhcp_opt(int prot, char *name);
+int lookup_dhcp_len(int prot, int val);
+char *option_string(int prot, unsigned int opt, unsigned char *val,
+ int opt_len, char *buf, int buf_len);
+#ifdef HAVE_LINUX_NETWORK
+void bindtodevice(int fd);
+#endif
+# ifdef HAVE_DHCP6
+void display_opts6(void);
+# endif
+void log_context(int family, struct dhcp_context *context);
+#endif
+
+/* outpacket.c */
+#ifdef HAVE_DHCP6
+void end_opt6(int container);
+int save_counter(int newval);
+void *expand(size_t headroom);
+int new_opt6(int opt);
+void *put_opt6(void *data, size_t len);
+void put_opt6_long(unsigned int val);
+void put_opt6_short(unsigned int val);
+void put_opt6_char(unsigned int val);
+void put_opt6_string(char *s);
+#endif
+
+/* radv.c */
+#ifdef HAVE_DHCP6
+void ra_init(time_t now);
+void icmp6_packet(time_t now);
+time_t periodic_ra(time_t now);
+void ra_start_unsolicted(time_t now, struct dhcp_context *context);
+#endif
+
+/* slaac.c */
+#ifdef HAVE_DHCP6
+void slaac_add_addrs(struct dhcp_lease *lease, time_t now, int force);
+time_t periodic_slaac(time_t now, struct dhcp_lease *leases);
+void slaac_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface, struct dhcp_lease *leases);
+#endif