| version 1.1.1.2, 2014/06/15 16:31:38 | version 1.1.1.3, 2016/11/02 09:57:01 | 
| Line 1 | Line 1 | 
| /* dnsmasq is Copyright (c) 2000-2014 Simon Kelley | /* dnsmasq is Copyright (c) 2000-2016 Simon Kelley | 
 |  |  | 
 | This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | 
| Line 14 | Line 14 | 
 | along with this program.  If not, see <http://www.gnu.org/licenses/>. | along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
 | */ | */ | 
 |  |  | 
| #define COPYRIGHT "Copyright (c) 2000-2014 Simon Kelley" | #define COPYRIGHT "Copyright (c) 2000-2016 Simon Kelley" | 
 |  |  | 
 | #ifndef NO_LARGEFILE | #ifndef NO_LARGEFILE | 
 | /* Ensure we can use files >2GB (log files may grow this big) */ | /* Ensure we can use files >2GB (log files may grow this big) */ | 
| Line 82  typedef unsigned long long u64; | Line 82  typedef unsigned long long u64; | 
 | #if defined(HAVE_SOLARIS_NETWORK) | #if defined(HAVE_SOLARIS_NETWORK) | 
 | #  include <sys/sockio.h> | #  include <sys/sockio.h> | 
 | #endif | #endif | 
| #include <sys/select.h> | #include <sys/poll.h> | 
 | #include <sys/wait.h> | #include <sys/wait.h> | 
 | #include <sys/time.h> | #include <sys/time.h> | 
 | #include <sys/un.h> | #include <sys/un.h> | 
| Line 117  typedef unsigned long long u64; | Line 117  typedef unsigned long long u64; | 
 | #include <sys/uio.h> | #include <sys/uio.h> | 
 | #include <syslog.h> | #include <syslog.h> | 
 | #include <dirent.h> | #include <dirent.h> | 
 |  | #include <utime.h> | 
 | #ifndef HAVE_LINUX_NETWORK | #ifndef HAVE_LINUX_NETWORK | 
 | #  include <net/if_dl.h> | #  include <net/if_dl.h> | 
 | #endif | #endif | 
| Line 165  struct event_desc { | Line 166  struct event_desc { | 
 | #define EVENT_LUA_ERR   19 | #define EVENT_LUA_ERR   19 | 
 | #define EVENT_TFTP_ERR  20 | #define EVENT_TFTP_ERR  20 | 
 | #define EVENT_INIT      21 | #define EVENT_INIT      21 | 
 |  | #define EVENT_NEWADDR   22 | 
 |  | #define EVENT_NEWROUTE  23 | 
 |  | #define EVENT_TIME_ERR  24 | 
 |  |  | 
 | /* Exit codes. */ | /* Exit codes. */ | 
 | #define EC_GOOD        0 | #define EC_GOOD        0 | 
| Line 175  struct event_desc { | Line 179  struct event_desc { | 
 | #define EC_MISC        5 | #define EC_MISC        5 | 
 | #define EC_INIT_OFFSET 10 | #define EC_INIT_OFFSET 10 | 
 |  |  | 
 | /* Min buffer size: we check after adding each record, so there must be |  | 
 | memory for the largest packet, and the largest record so the |  | 
 | min for DNS is PACKETSZ+MAXDNAME+RRFIXEDSZ which is < 1000. |  | 
 | This might be increased is EDNS packet size if greater than the minimum. |  | 
 | */ |  | 
 | #define DNSMASQ_PACKETSZ PACKETSZ+MAXDNAME+RRFIXEDSZ |  | 
 |  |  | 
 | /* Trust the compiler dead-code eliminator.... */ | /* Trust the compiler dead-code eliminator.... */ | 
 | #define option_bool(x) (((x) < 32) ? daemon->options & (1u << (x)) : daemon->options2 & (1u << ((x) - 32))) | #define option_bool(x) (((x) < 32) ? daemon->options & (1u << (x)) : daemon->options2 & (1u << ((x) - 32))) | 
 |  |  | 
| Line 235  struct event_desc { | Line 232  struct event_desc { | 
 | #define OPT_DNSSEC_DEBUG   47 | #define OPT_DNSSEC_DEBUG   47 | 
 | #define OPT_DNSSEC_NO_SIGN 48 | #define OPT_DNSSEC_NO_SIGN 48 | 
 | #define OPT_LOCAL_SERVICE  49 | #define OPT_LOCAL_SERVICE  49 | 
| #define OPT_LAST           50 | #define OPT_LOOP_DETECT    50 | 
|  | #define OPT_EXTRALOG       51 | 
|  | #define OPT_TFTP_NO_FAIL   52 | 
|  | #define OPT_SCRIPT_ARP     53 | 
|  | #define OPT_MAC_B64        54 | 
|  | #define OPT_MAC_HEX        55 | 
|  | #define OPT_LAST           56 | 
 |  |  | 
 | /* extra flags for my_syslog, we use a couple of facilities since they are known | /* 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. */ | not to occupy the same bits as priorities, no matter how syslog.h is set up. */ | 
| Line 249  struct all_addr { | Line 252  struct all_addr { | 
 | struct in6_addr addr6; | struct in6_addr addr6; | 
 | #endif | #endif | 
 | /* for log_query */ | /* for log_query */ | 
 | unsigned int keytag; |  | 
 | /* for cache_insert if RRSIG, DNSKEY, DS */ |  | 
 | struct { | struct { | 
 |  | unsigned short keytag, algo, digest; | 
 |  | } log; | 
 |  | /* for cache_insert of DNSKEY, DS */ | 
 |  | struct { | 
 | unsigned short class, type; | unsigned short class, type; | 
 | } dnssec; | } dnssec; | 
 | } addr; | } addr; | 
| Line 303  struct ptr_record { | Line 308  struct ptr_record { | 
 | }; | }; | 
 |  |  | 
 | struct cname { | struct cname { | 
 |  | int ttl; | 
 | char *alias, *target; | char *alias, *target; | 
 | struct cname *next; | struct cname *next; | 
 | }; | }; | 
| Line 315  struct ds_config { | Line 321  struct ds_config { | 
 |  |  | 
 | #define ADDRLIST_LITERAL 1 | #define ADDRLIST_LITERAL 1 | 
 | #define ADDRLIST_IPV6    2 | #define ADDRLIST_IPV6    2 | 
 |  | #define ADDRLIST_REVONLY 4 | 
 |  |  | 
 | struct addrlist { | struct addrlist { | 
 | struct all_addr addr; | struct all_addr addr; | 
| Line 338  struct auth_zone { | Line 345  struct auth_zone { | 
 |  |  | 
 |  |  | 
 | struct host_record { | struct host_record { | 
 |  | int ttl; | 
 | struct name_list { | struct name_list { | 
 | char *name; | char *name; | 
 | struct name_list *next; | struct name_list *next; | 
| Line 390  struct crec { | Line 398  struct crec { | 
 | unsigned char algo; | unsigned char algo; | 
 | unsigned char digest; | unsigned char digest; | 
 | } ds; | } ds; | 
 | struct { |  | 
 | struct blockdata *keydata; |  | 
 | unsigned short keylen, type_covered, keytag; |  | 
 | char algo; |  | 
 | } sig; |  | 
 | } addr; | } addr; | 
 | time_t ttd; /* time to die */ | time_t ttd; /* time to die */ | 
| /* used as class if DNSKEY/DS/RRSIG, index to source for F_HOSTS */ | /* used as class if DNSKEY/DS, index to source for F_HOSTS */ | 
 | unsigned int uid; | unsigned int uid; | 
 | unsigned short flags; | unsigned short flags; | 
 | union { | union { | 
| Line 437  struct crec { | Line 440  struct crec { | 
 | #define F_SECSTAT   (1u<<24) | #define F_SECSTAT   (1u<<24) | 
 | #define F_NO_RR     (1u<<25) | #define F_NO_RR     (1u<<25) | 
 | #define F_IPSET     (1u<<26) | #define F_IPSET     (1u<<26) | 
 |  | #define F_NOEXTRA   (1u<<27) | 
 |  |  | 
 | /* Values of uid in crecs with F_CONFIG bit set. */ | /* Values of uid in crecs with F_CONFIG bit set. */ | 
 | #define SRC_INTERFACE 0 | #define SRC_INTERFACE 0 | 
| Line 476  union mysockaddr { | Line 480  union mysockaddr { | 
 | #define SERV_USE_RESOLV     1024  /* forward this domain in the normal way */ | #define SERV_USE_RESOLV     1024  /* forward this domain in the normal way */ | 
 | #define SERV_NO_REBIND      2048  /* inhibit dns-rebind protection */ | #define SERV_NO_REBIND      2048  /* inhibit dns-rebind protection */ | 
 | #define SERV_FROM_FILE      4096  /* read from --servers-file */ | #define SERV_FROM_FILE      4096  /* read from --servers-file */ | 
 |  | #define SERV_LOOP           8192  /* server causes forwarding loop */ | 
 |  | #define SERV_DO_DNSSEC     16384  /* Validate DNSSEC when using this server */ | 
 |  |  | 
 | struct serverfd { | struct serverfd { | 
 | int fd; | int fd; | 
| Line 494  struct server { | Line 500  struct server { | 
 | char interface[IF_NAMESIZE+1]; | char interface[IF_NAMESIZE+1]; | 
 | struct serverfd *sfd; | struct serverfd *sfd; | 
 | char *domain; /* set if this server only handles a domain. */ | char *domain; /* set if this server only handles a domain. */ | 
| int flags, tcpfd; | int flags, tcpfd, edns_pktsz; | 
 | unsigned int queries, failed_queries; | unsigned int queries, failed_queries; | 
 |  | #ifdef HAVE_LOOP | 
 |  | u32 uid; | 
 |  | #endif | 
 | struct server *next; | struct server *next; | 
 | }; | }; | 
 |  |  | 
| Line 527  struct iname { | Line 536  struct iname { | 
 | struct iname *next; | struct iname *next; | 
 | }; | }; | 
 |  |  | 
 |  | /* subnet parameters from command line */ | 
 |  | struct mysubnet { | 
 |  | union mysockaddr addr; | 
 |  | int addr_used; | 
 |  | int mask; | 
 |  | }; | 
 |  |  | 
 | /* resolv-file parms from command-line */ | /* resolv-file parms from command-line */ | 
 | struct resolvc { | struct resolvc { | 
 | struct resolvc *next; | struct resolvc *next; | 
 | int is_default, logged; | int is_default, logged; | 
 | time_t mtime; | time_t mtime; | 
 | char *name; | char *name; | 
 |  | #ifdef HAVE_INOTIFY | 
 |  | int wd; /* inotify watch descriptor */ | 
 |  | char *file; /* pointer to file part if path */ | 
 |  | #endif | 
 | }; | }; | 
 |  |  | 
| /* adn-hosts parms from command-line (also dhcp-hostsfile and dhcp-optsfile */ | /* adn-hosts parms from command-line (also dhcp-hostsfile and dhcp-optsfile and dhcp-hostsdir*/ | 
 | #define AH_DIR      1 | #define AH_DIR      1 | 
 | #define AH_INACTIVE 2 | #define AH_INACTIVE 2 | 
 |  | #define AH_WD_DONE  4 | 
 |  | #define AH_HOSTS    8 | 
 |  | #define AH_DHCP_HST 16 | 
 |  | #define AH_DHCP_OPT 32 | 
 | struct hostsfile { | struct hostsfile { | 
 | struct hostsfile *next; | struct hostsfile *next; | 
 | int flags; | int flags; | 
 | char *fname; | char *fname; | 
 |  | #ifdef HAVE_INOTIFY | 
 |  | int wd; /* inotify watch descriptor */ | 
 |  | #endif | 
 | unsigned int index; /* matches to cache entries for logging */ | unsigned int index; /* matches to cache entries for logging */ | 
 | }; | }; | 
 |  |  | 
| Line 554  struct hostsfile { | Line 581  struct hostsfile { | 
 | #define STAT_NEED_KEY           5 | #define STAT_NEED_KEY           5 | 
 | #define STAT_TRUNCATED          6 | #define STAT_TRUNCATED          6 | 
 | #define STAT_SECURE_WILDCARD    7 | #define STAT_SECURE_WILDCARD    7 | 
| #define STAT_NO_SIG             8 | #define STAT_OK                 8 | 
| #define STAT_NO_DS              9 | #define STAT_ABANDONED          9 | 
| #define STAT_NEED_DS_NEG       10 |  | 
| #define STAT_CHASE_CNAME       11 |  | 
 |  |  | 
 | #define FREC_NOREBIND           1 | #define FREC_NOREBIND           1 | 
 | #define FREC_CHECKING_DISABLED  2 | #define FREC_CHECKING_DISABLED  2 | 
| Line 567  struct hostsfile { | Line 592  struct hostsfile { | 
 | #define FREC_AD_QUESTION       32 | #define FREC_AD_QUESTION       32 | 
 | #define FREC_DO_QUESTION       64 | #define FREC_DO_QUESTION       64 | 
 | #define FREC_ADDED_PHEADER    128 | #define FREC_ADDED_PHEADER    128 | 
| #define FREC_CHECK_NOSIGN     256 | #define FREC_TEST_PKTSZ       256 | 
|  | #define FREC_HAS_EXTRADATA    512 | 
 |  |  | 
 | #ifdef HAVE_DNSSEC | #ifdef HAVE_DNSSEC | 
 | #define HASH_SIZE 20 /* SHA-1 digest size */ | #define HASH_SIZE 20 /* SHA-1 digest size */ | 
| Line 585  struct frec { | Line 611  struct frec { | 
 | #endif | #endif | 
 | unsigned int iface; | unsigned int iface; | 
 | unsigned short orig_id, new_id; | unsigned short orig_id, new_id; | 
| int fd, forwardall, flags; | int log_id, fd, forwardall, flags; | 
 | time_t time; | time_t time; | 
 | unsigned char *hash[HASH_SIZE]; | unsigned char *hash[HASH_SIZE]; | 
 | #ifdef HAVE_DNSSEC | #ifdef HAVE_DNSSEC | 
| Line 613  struct frec { | Line 639  struct frec { | 
 | #define ACTION_OLD           3 | #define ACTION_OLD           3 | 
 | #define ACTION_ADD           4 | #define ACTION_ADD           4 | 
 | #define ACTION_TFTP          5 | #define ACTION_TFTP          5 | 
 |  | #define ACTION_ARP           6 | 
 |  | #define ACTION_ARP_DEL       7 | 
 |  |  | 
 | #define LEASE_NEW            1  /* newly created */ | #define LEASE_NEW            1  /* newly created */ | 
 | #define LEASE_CHANGED        2  /* modified */ | #define LEASE_CHANGED        2  /* modified */ | 
| Line 639  struct dhcp_lease { | Line 667  struct dhcp_lease { | 
 | unsigned char *extradata; | unsigned char *extradata; | 
 | unsigned int extradata_len, extradata_size; | unsigned int extradata_len, extradata_size; | 
 | int last_interface; | int last_interface; | 
 |  | int new_interface;     /* save possible originated interface */ | 
 |  | int new_prefixlen;     /* and its prefix length */ | 
 | #ifdef HAVE_DHCP6 | #ifdef HAVE_DHCP6 | 
 | struct in6_addr addr6; | struct in6_addr addr6; | 
 | int iaid; | int iaid; | 
| Line 823  struct dhcp_context { | Line 853  struct dhcp_context { | 
 | #define CONTEXT_NETMASK        (1u<<1) | #define CONTEXT_NETMASK        (1u<<1) | 
 | #define CONTEXT_BRDCAST        (1u<<2) | #define CONTEXT_BRDCAST        (1u<<2) | 
 | #define CONTEXT_PROXY          (1u<<3) | #define CONTEXT_PROXY          (1u<<3) | 
| #define CONTEXT_RA_ONLY        (1u<<4) | #define CONTEXT_RA_ROUTER      (1u<<4) | 
 | #define CONTEXT_RA_DONE        (1u<<5) | #define CONTEXT_RA_DONE        (1u<<5) | 
 | #define CONTEXT_RA_NAME        (1u<<6) | #define CONTEXT_RA_NAME        (1u<<6) | 
 | #define CONTEXT_RA_STATELESS   (1u<<7) | #define CONTEXT_RA_STATELESS   (1u<<7) | 
| Line 837  struct dhcp_context { | Line 867  struct dhcp_context { | 
 | #define CONTEXT_USED           (1u<<15) | #define CONTEXT_USED           (1u<<15) | 
 | #define CONTEXT_OLD            (1u<<16) | #define CONTEXT_OLD            (1u<<16) | 
 | #define CONTEXT_V6             (1u<<17) | #define CONTEXT_V6             (1u<<17) | 
 |  | #define CONTEXT_RA_OFF_LINK    (1u<<18) | 
 |  |  | 
 |  |  | 
 | struct ping_result { | struct ping_result { | 
 | struct in_addr addr; | struct in_addr addr; | 
 | time_t time; | time_t time; | 
| Line 874  struct addr_list { | Line 904  struct addr_list { | 
 | struct tftp_prefix { | struct tftp_prefix { | 
 | char *interface; | char *interface; | 
 | char *prefix; | char *prefix; | 
 |  | int missing; | 
 | struct tftp_prefix *next; | struct tftp_prefix *next; | 
 | }; | }; | 
 |  |  | 
| Line 902  extern struct daemon { | Line 933  extern struct daemon { | 
 | struct auth_zone *auth_zones; | struct auth_zone *auth_zones; | 
 | struct interface_name *int_names; | struct interface_name *int_names; | 
 | char *mxtarget; | char *mxtarget; | 
| int addr4_netmask; | struct mysubnet *add_subnet4; | 
| int addr6_netmask; | struct mysubnet *add_subnet6; | 
| char *lease_file; | char *lease_file; | 
 | char *username, *groupname, *scriptuser; | char *username, *groupname, *scriptuser; | 
 | char *luascript; | char *luascript; | 
 | char *authserver, *hostmaster; | char *authserver, *hostmaster; | 
| Line 916  extern struct daemon { | Line 947  extern struct daemon { | 
 | char *runfile; | char *runfile; | 
 | char *lease_change_command; | char *lease_change_command; | 
 | struct iname *if_names, *if_addrs, *if_except, *dhcp_except, *auth_peers, *tftp_interfaces; | struct iname *if_names, *if_addrs, *if_except, *dhcp_except, *auth_peers, *tftp_interfaces; | 
| struct bogus_addr *bogus_addr; | struct bogus_addr *bogus_addr, *ignore_addr; | 
 | struct server *servers; | struct server *servers; | 
 | struct ipsets *ipsets; | struct ipsets *ipsets; | 
 | int log_fac; /* log facility */ | int log_fac; /* log facility */ | 
 | char *log_file; /* optional log file */ | char *log_file; /* optional log file */ | 
 | int max_logs;  /* queue limit */ | int max_logs;  /* queue limit */ | 
 | int cachesize, ftabsize; | int cachesize, ftabsize; | 
| int port, query_port, min_port; | int port, query_port, min_port, max_port; | 
| unsigned long local_ttl, neg_ttl, max_ttl, max_cache_ttl, auth_ttl; | unsigned long local_ttl, neg_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl, dhcp_ttl, use_dhcp_ttl; | 
|  | char *dns_client_id; | 
 | struct hostsfile *addn_hosts; | struct hostsfile *addn_hosts; | 
 | struct dhcp_context *dhcp, *dhcp6; | struct dhcp_context *dhcp, *dhcp6; | 
 | struct ra_interface *ra_interfaces; | struct ra_interface *ra_interfaces; | 
| Line 942  extern struct daemon { | Line 974  extern struct daemon { | 
 | int doing_ra, doing_dhcp6; | int doing_ra, doing_dhcp6; | 
 | struct dhcp_netid_list *dhcp_ignore, *dhcp_ignore_names, *dhcp_gen_names; | struct dhcp_netid_list *dhcp_ignore, *dhcp_ignore_names, *dhcp_gen_names; | 
 | struct dhcp_netid_list *force_broadcast, *bootp_dynamic; | struct dhcp_netid_list *force_broadcast, *bootp_dynamic; | 
| struct hostsfile *dhcp_hosts_file, *dhcp_opts_file; | struct hostsfile *dhcp_hosts_file, *dhcp_opts_file, *dynamic_dirs; | 
| int dhcp_max, tftp_max; | int dhcp_max, tftp_max, tftp_mtu; | 
 | int dhcp_server_port, dhcp_client_port; | int dhcp_server_port, dhcp_client_port; | 
 | int start_tftp_port, end_tftp_port; | int start_tftp_port, end_tftp_port; | 
 | unsigned int min_leasetime; | unsigned int min_leasetime; | 
| Line 960  extern struct daemon { | Line 992  extern struct daemon { | 
 | #endif | #endif | 
 | #ifdef HAVE_DNSSEC | #ifdef HAVE_DNSSEC | 
 | struct ds_config *ds; | struct ds_config *ds; | 
 |  | int back_to_the_future; | 
 |  | char *timestamp_file; | 
 | #endif | #endif | 
 |  |  | 
 | /* globally used stuff for DNS */ | /* globally used stuff for DNS */ | 
| Line 985  extern struct daemon { | Line 1019  extern struct daemon { | 
 | struct randfd randomsocks[RANDOM_SOCKS]; | struct randfd randomsocks[RANDOM_SOCKS]; | 
 | int v6pktinfo; | int v6pktinfo; | 
 | struct addrlist *interface_addrs; /* list of all addresses/prefix lengths associated with all local interfaces */ | struct addrlist *interface_addrs; /* list of all addresses/prefix lengths associated with all local interfaces */ | 
 |  | int log_id, log_display_id; /* ids of transactions for logging */ | 
 |  | union mysockaddr *log_source_addr; | 
 |  |  | 
 | /* DHCP state */ | /* DHCP state */ | 
 | int dhcpfd, helperfd, pxefd; | int dhcpfd, helperfd, pxefd; | 
 |  | #ifdef HAVE_INOTIFY | 
 |  | int inotifyfd; | 
 |  | #endif | 
 | #if defined(HAVE_LINUX_NETWORK) | #if defined(HAVE_LINUX_NETWORK) | 
 | int netlinkfd; | int netlinkfd; | 
 | #elif defined(HAVE_BSD_NETWORK) | #elif defined(HAVE_BSD_NETWORK) | 
| Line 1016  extern struct daemon { | Line 1055  extern struct daemon { | 
 |  |  | 
 | /* utility string buffer, hold max sized IP address as string */ | /* utility string buffer, hold max sized IP address as string */ | 
 | char *addrbuff; | char *addrbuff; | 
 |  | char *addrbuff2; /* only allocated when OPT_EXTRALOG */ | 
 |  |  | 
 | } *daemon; | } *daemon; | 
 |  |  | 
| Line 1042  int cache_make_stat(struct txt_record *t); | Line 1082  int cache_make_stat(struct txt_record *t); | 
 | char *cache_get_name(struct crec *crecp); | char *cache_get_name(struct crec *crecp); | 
 | char *cache_get_cname_target(struct crec *crecp); | char *cache_get_cname_target(struct crec *crecp); | 
 | struct crec *cache_enumerate(int init); | struct crec *cache_enumerate(int init); | 
 |  | int read_hostsfile(char *filename, unsigned int index, int cache_size, | 
 |  | struct crec **rhash, int hashsz); | 
 |  |  | 
 | /* blockdata.c */ | /* blockdata.c */ | 
 | #ifdef HAVE_DNSSEC | #ifdef HAVE_DNSSEC | 
| Line 1076  int extract_addresses(struct dns_header *header, size_ | Line 1118  int extract_addresses(struct dns_header *header, size_ | 
 | int no_cache, int secure, int *doctored); | int no_cache, int secure, int *doctored); | 
 | size_t answer_request(struct dns_header *header, char *limit, size_t qlen, | size_t answer_request(struct dns_header *header, char *limit, size_t qlen, | 
 | struct in_addr local_addr, struct in_addr local_netmask, | struct in_addr local_addr, struct in_addr local_netmask, | 
| time_t now, int *ad_reqd, int *do_bit); | time_t now, int ad_reqd, int do_bit, int have_pseudoheader); | 
 | int check_for_bogus_wildcard(struct dns_header *header, size_t qlen, char *name, | int check_for_bogus_wildcard(struct dns_header *header, size_t qlen, char *name, | 
 | struct bogus_addr *addr, time_t now); | struct bogus_addr *addr, time_t now); | 
| unsigned char *find_pseudoheader(struct dns_header *header, size_t plen, | int check_for_ignored_address(struct dns_header *header, size_t qlen, struct bogus_addr *baddr); | 
| size_t *len, unsigned char **p, int *is_sign); |  | 
 | int check_for_local_domain(char *name, time_t now); | int check_for_local_domain(char *name, time_t now); | 
 | unsigned int questions_crc(struct dns_header *header, size_t plen, char *buff); | unsigned int questions_crc(struct dns_header *header, size_t plen, char *buff); | 
 | size_t resize_packet(struct dns_header *header, size_t plen, | size_t resize_packet(struct dns_header *header, size_t plen, | 
 | unsigned char *pheader, size_t hlen); | unsigned char *pheader, size_t hlen); | 
 | size_t add_mac(struct dns_header *header, size_t plen, char *limit, union mysockaddr *l3); |  | 
 | size_t add_source_addr(struct dns_header *header, size_t plen, char *limit, union mysockaddr *source); |  | 
 | #ifdef HAVE_DNSSEC |  | 
 | size_t add_do_bit(struct dns_header *header, size_t plen, char *limit); |  | 
 | #endif |  | 
 | int check_source(struct dns_header *header, size_t plen, unsigned char *pseudoheader, union mysockaddr *peer); |  | 
 | int add_resource_record(struct dns_header *header, char *limit, int *truncp, | int add_resource_record(struct dns_header *header, char *limit, int *truncp, | 
 | int nameoffset, unsigned char **pp, unsigned long ttl, | int nameoffset, unsigned char **pp, unsigned long ttl, | 
 | int *offset, unsigned short type, unsigned short class, char *format, ...); | int *offset, unsigned short type, unsigned short class, char *format, ...); | 
| Line 1103  int private_net(struct in_addr addr, int ban_localhost | Line 1138  int private_net(struct in_addr addr, int ban_localhost | 
 | /* auth.c */ | /* auth.c */ | 
 | #ifdef HAVE_AUTH | #ifdef HAVE_AUTH | 
 | size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, | size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, | 
| time_t now, union mysockaddr *peer_addr, int local_query); | time_t now, union mysockaddr *peer_addr, int local_query, | 
|  | int do_bit, int have_pseudoheader); | 
 | int in_zone(struct auth_zone *zone, char *name, char **cut); | int in_zone(struct auth_zone *zone, char *name, char **cut); | 
 | #endif | #endif | 
 |  |  | 
 | /* dnssec.c */ | /* dnssec.c */ | 
| size_t dnssec_generate_query(struct dns_header *header, char *end, char *name, int class, int type, union mysockaddr *addr); | size_t dnssec_generate_query(struct dns_header *header, unsigned char *end, char *name, int class, int type, union mysockaddr *addr, int edns_pktsz); | 
 | int dnssec_validate_by_ds(time_t now, struct dns_header *header, size_t n, char *name, char *keyname, int class); | int dnssec_validate_by_ds(time_t now, struct dns_header *header, size_t n, char *name, char *keyname, int class); | 
 | int dnssec_validate_ds(time_t now, struct dns_header *header, size_t plen, char *name, char *keyname, int class); | int dnssec_validate_ds(time_t now, struct dns_header *header, size_t plen, char *name, char *keyname, int class); | 
| int dnssec_validate_reply(time_t now, struct dns_header *header, size_t plen, char *name, char *keyname, int *class, int *neganswer); | int dnssec_validate_reply(time_t now, struct dns_header *header, size_t plen, char *name, char *keyname, int *class, | 
| int dnssec_chase_cname(time_t now, struct dns_header *header, size_t plen, char *name, char *keyname); | int check_unsigned, int *neganswer, int *nons); | 
 | int dnskey_keytag(int alg, int flags, unsigned char *rdata, int rdlen); | int dnskey_keytag(int alg, int flags, unsigned char *rdata, int rdlen); | 
 | size_t filter_rrsigs(struct dns_header *header, size_t plen); | size_t filter_rrsigs(struct dns_header *header, size_t plen); | 
 | unsigned char* hash_questions(struct dns_header *header, size_t plen, char *name); | unsigned char* hash_questions(struct dns_header *header, size_t plen, char *name); | 
 |  | int setup_timestamp(void); | 
 |  |  | 
 | /* util.c */ | /* util.c */ | 
 | void rand_init(void); | void rand_init(void); | 
 | unsigned short rand16(void); | unsigned short rand16(void); | 
 |  | u32 rand32(void); | 
 | u64 rand64(void); | u64 rand64(void); | 
 | int legal_hostname(char *c); | int legal_hostname(char *c); | 
 | char *canonicalise(char *s, int *nomem); | char *canonicalise(char *s, int *nomem); | 
| Line 1131  int sa_len(union mysockaddr *addr); | Line 1169  int sa_len(union mysockaddr *addr); | 
 | int sockaddr_isequal(union mysockaddr *s1, union mysockaddr *s2); | int sockaddr_isequal(union mysockaddr *s1, union mysockaddr *s2); | 
 | int hostname_isequal(const char *a, const char *b); | int hostname_isequal(const char *a, const char *b); | 
 | time_t dnsmasq_time(void); | time_t dnsmasq_time(void); | 
 |  | int netmask_length(struct in_addr mask); | 
 | int is_same_net(struct in_addr a, struct in_addr b, struct in_addr mask); | int is_same_net(struct in_addr a, struct in_addr b, struct in_addr mask); | 
 | #ifdef HAVE_IPV6 | #ifdef HAVE_IPV6 | 
 | int is_same_net6(struct in6_addr *a, struct in6_addr *b, int prefixlen); | int is_same_net6(struct in6_addr *a, struct in6_addr *b, int prefixlen); | 
 | u64 addr6part(struct in6_addr *addr); | u64 addr6part(struct in6_addr *addr); | 
 | void setaddr6part(struct in6_addr *addr, u64 host); | void setaddr6part(struct in6_addr *addr, u64 host); | 
 | #endif | #endif | 
| int retry_send(void); | int retry_send(ssize_t rc); | 
 | void prettyprint_time(char *buf, unsigned int t); | void prettyprint_time(char *buf, unsigned int t); | 
 | int prettyprint_addr(union mysockaddr *addr, char *buf); | int prettyprint_addr(union mysockaddr *addr, char *buf); | 
 | int parse_hex(char *in, unsigned char *out, int maxlen, | int parse_hex(char *in, unsigned char *out, int maxlen, | 
| Line 1146  int memcmp_masked(unsigned char *a, unsigned char *b, | Line 1185  int memcmp_masked(unsigned char *a, unsigned char *b, | 
 | unsigned int mask); | unsigned int mask); | 
 | int expand_buf(struct iovec *iov, size_t size); | int expand_buf(struct iovec *iov, size_t size); | 
 | char *print_mac(char *buff, unsigned char *mac, int len); | char *print_mac(char *buff, unsigned char *mac, int len); | 
 | void bump_maxfd(int fd, int *max); |  | 
 | int read_write(int fd, unsigned char *packet, int size, int rw); | int read_write(int fd, unsigned char *packet, int size, int rw); | 
 |  |  | 
 | int wildcard_match(const char* wildcard, const char* match); | int wildcard_match(const char* wildcard, const char* match); | 
 |  | int wildcard_matchn(const char* wildcard, const char* match, int num); | 
 |  |  | 
 | /* log.c */ | /* log.c */ | 
 | void die(char *message, char *arg1, int exit_code); | void die(char *message, char *arg1, int exit_code); | 
 | int log_start(struct passwd *ent_pw, int errfd); | int log_start(struct passwd *ent_pw, int errfd); | 
 | int log_reopen(char *log_file); | int log_reopen(char *log_file); | 
 | void my_syslog(int priority, const char *format, ...); | void my_syslog(int priority, const char *format, ...); | 
| void set_log_writer(fd_set *set, int *maxfdp); | void set_log_writer(void); | 
| void check_log_writer(fd_set *set); | void check_log_writer(int force); | 
 | void flush_log(void); | void flush_log(void); | 
 |  |  | 
 | /* option.c */ | /* option.c */ | 
| Line 1171  void reset_option_bool(unsigned int opt); | Line 1210  void reset_option_bool(unsigned int opt); | 
 | struct hostsfile *expand_filelist(struct hostsfile *list); | struct hostsfile *expand_filelist(struct hostsfile *list); | 
 | char *parse_server(char *arg, union mysockaddr *addr, | char *parse_server(char *arg, union mysockaddr *addr, | 
 | union mysockaddr *source_addr, char *interface, int *flags); | union mysockaddr *source_addr, char *interface, int *flags); | 
 |  | int option_read_dynfile(char *file, int flags); | 
 |  |  | 
 | /* forward.c */ | /* forward.c */ | 
 | void reply_query(int fd, int family, time_t now); | void reply_query(int fd, int family, time_t now); | 
| Line 1182  struct frec *get_new_frec(time_t now, int *wait, int f | Line 1222  struct frec *get_new_frec(time_t now, int *wait, int f | 
 | int send_from(int fd, int nowild, char *packet, size_t len, | int send_from(int fd, int nowild, char *packet, size_t len, | 
 | union mysockaddr *to, struct all_addr *source, | union mysockaddr *to, struct all_addr *source, | 
 | unsigned int iface); | unsigned int iface); | 
 |  | void resend_query(); | 
 |  | struct randfd *allocate_rfd(int family); | 
 |  | void free_rfd(struct randfd *rfd); | 
 |  |  | 
 | /* network.c */ | /* network.c */ | 
 | int indextoname(int fd, int index, char *name); | int indextoname(int fd, int index, char *name); | 
| Line 1256  void lease_update_slaac(time_t now); | Line 1299  void lease_update_slaac(time_t now); | 
 | void lease_set_iaid(struct dhcp_lease *lease, int iaid); | void lease_set_iaid(struct dhcp_lease *lease, int iaid); | 
 | void lease_make_duid(time_t now); | void lease_make_duid(time_t now); | 
 | #endif | #endif | 
| void lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr, | void lease_set_hwaddr(struct dhcp_lease *lease, const unsigned char *hwaddr, | 
| unsigned char *clid, int hw_len, int hw_type, int clid_len, time_t now, int force); | const unsigned char *clid, int hw_len, int hw_type, | 
| void lease_set_hostname(struct dhcp_lease *lease, char *name, int auth, char *domain, char *config_domain); | int clid_len, time_t now, int force); | 
|  | void lease_set_hostname(struct dhcp_lease *lease, const 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_expires(struct dhcp_lease *lease, unsigned int len, time_t now); | 
 | void lease_set_interface(struct dhcp_lease *lease, int interface, time_t now); | 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, | struct dhcp_lease *lease_find_by_client(unsigned char *hwaddr, int hw_len, int hw_type, | 
| Line 1289  unsigned char *extended_hwaddr(int hwtype, int hwlen, | Line 1333  unsigned char *extended_hwaddr(int hwtype, int hwlen, | 
 | int make_icmp_sock(void); | int make_icmp_sock(void); | 
 | int icmp_ping(struct in_addr addr); | int icmp_ping(struct in_addr addr); | 
 | #endif | #endif | 
 |  | void queue_event(int event); | 
 | void send_alarm(time_t event, time_t now); | void send_alarm(time_t event, time_t now); | 
 | void send_event(int fd, int event, int data, char *msg); | void send_event(int fd, int event, int data, char *msg); | 
 | void clear_cache_and_reload(time_t now); | void clear_cache_and_reload(time_t now); | 
 | void poll_resolv(int force, int do_reload, time_t now); |  | 
 |  |  | 
 | /* netlink.c */ | /* netlink.c */ | 
 | #ifdef HAVE_LINUX_NETWORK | #ifdef HAVE_LINUX_NETWORK | 
 | void netlink_init(void); | void netlink_init(void); | 
| void netlink_multicast(time_t now); | void netlink_multicast(void); | 
 | #endif | #endif | 
 |  |  | 
 | /* bpf.c */ | /* bpf.c */ | 
| Line 1306  void init_bpf(void); | Line 1350  void init_bpf(void); | 
 | void send_via_bpf(struct dhcp_packet *mess, size_t len, | void send_via_bpf(struct dhcp_packet *mess, size_t len, | 
 | struct in_addr iface_addr, struct ifreq *ifr); | struct in_addr iface_addr, struct ifreq *ifr); | 
 | void route_init(void); | void route_init(void); | 
| void route_sock(time_t now); | void route_sock(void); | 
 | #endif | #endif | 
 |  |  | 
 | /* bpf.c or netlink.c */ | /* bpf.c or netlink.c */ | 
| Line 1315  int iface_enumerate(int family, void *parm, int (callb | Line 1359  int iface_enumerate(int family, void *parm, int (callb | 
 | /* dbus.c */ | /* dbus.c */ | 
 | #ifdef HAVE_DBUS | #ifdef HAVE_DBUS | 
 | char *dbus_init(void); | char *dbus_init(void); | 
| void check_dbus_listeners(fd_set *rset, fd_set *wset, fd_set *eset); | void check_dbus_listeners(void); | 
| void set_dbus_listeners(int *maxfdp, fd_set *rset, fd_set *wset, fd_set *eset); | void set_dbus_listeners(void); | 
 | #  ifdef HAVE_DHCP | #  ifdef HAVE_DHCP | 
 | void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname); | void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname); | 
 | #  endif | #  endif | 
| Line 1337  void queue_script(int action, struct dhcp_lease *lease | Line 1381  void queue_script(int action, struct dhcp_lease *lease | 
 | #ifdef HAVE_TFTP | #ifdef HAVE_TFTP | 
 | void queue_tftp(off_t file_len, char *filename, union mysockaddr *peer); | void queue_tftp(off_t file_len, char *filename, union mysockaddr *peer); | 
 | #endif | #endif | 
 |  | void queue_arp(int action, unsigned char *mac, int maclen, | 
 |  | int family, struct all_addr *addr); | 
 | int helper_buf_empty(void); | int helper_buf_empty(void); | 
 | #endif | #endif | 
 |  |  | 
 | /* tftp.c */ | /* tftp.c */ | 
 | #ifdef HAVE_TFTP | #ifdef HAVE_TFTP | 
 | void tftp_request(struct listener *listen, time_t now); | void tftp_request(struct listener *listen, time_t now); | 
| void check_tftp_listeners(fd_set *rset, time_t now); | void check_tftp_listeners(time_t now); | 
 | int do_tftp_script_run(void); | int do_tftp_script_run(void); | 
 | #endif | #endif | 
 |  |  | 
| Line 1373  struct dhcp_config *config_find_by_address6(struct dhc | Line 1419  struct dhcp_config *config_find_by_address6(struct dhc | 
 | void make_duid(time_t now); | void make_duid(time_t now); | 
 | void dhcp_construct_contexts(time_t now); | void dhcp_construct_contexts(time_t now); | 
 | void get_client_mac(struct in6_addr *client, int iface, unsigned char *mac, | void get_client_mac(struct in6_addr *client, int iface, unsigned char *mac, | 
| unsigned int *maclenp, unsigned int *mactypep); | unsigned int *maclenp, unsigned int *mactypep, time_t now); | 
 | #endif | #endif | 
 |  |  | 
 | /* rfc3315.c */ | /* rfc3315.c */ | 
| Line 1381  void get_client_mac(struct in6_addr *client, int iface | Line 1427  void get_client_mac(struct in6_addr *client, int iface | 
 | unsigned short dhcp6_reply(struct dhcp_context *context, int interface, char *iface_name, | unsigned short dhcp6_reply(struct dhcp_context *context, int interface, char *iface_name, | 
 | struct in6_addr *fallback, struct in6_addr *ll_addr, struct in6_addr *ula_addr, | struct in6_addr *fallback, struct in6_addr *ll_addr, struct in6_addr *ula_addr, | 
 | size_t sz, struct in6_addr *client_addr, time_t now); | size_t sz, struct in6_addr *client_addr, time_t now); | 
| void relay_upstream6(struct dhcp_relay *relay, ssize_t sz, struct in6_addr *peer_address, u32 scope_id); | void relay_upstream6(struct dhcp_relay *relay, ssize_t sz, struct in6_addr *peer_address, | 
|  | u32 scope_id, time_t now); | 
 |  |  | 
 | unsigned short relay_reply6( struct sockaddr_in6 *peer, ssize_t sz, char *arrival_interface); | unsigned short relay_reply6( struct sockaddr_in6 *peer, ssize_t sz, char *arrival_interface); | 
 | #endif | #endif | 
| Line 1447  void slaac_add_addrs(struct dhcp_lease *lease, time_t | Line 1494  void slaac_add_addrs(struct dhcp_lease *lease, time_t | 
 | time_t periodic_slaac(time_t now, struct dhcp_lease *leases); | 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); | void slaac_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface, struct dhcp_lease *leases); | 
 | #endif | #endif | 
 |  |  | 
 |  | /* loop.c */ | 
 |  | #ifdef HAVE_LOOP | 
 |  | void loop_send_probes(); | 
 |  | int detect_loop(char *query, int type); | 
 |  | #endif | 
 |  |  | 
 |  | /* inotify.c */ | 
 |  | #ifdef HAVE_INOTIFY | 
 |  | void inotify_dnsmasq_init(); | 
 |  | int inotify_check(time_t now); | 
 |  | void set_dynamic_inotify(int flag, int total_size, struct crec **rhash, int revhashsz); | 
 |  | #endif | 
 |  |  | 
 |  | /* poll.c */ | 
 |  | void poll_reset(void); | 
 |  | int poll_check(int fd, short event); | 
 |  | void poll_listen(int fd, short event); | 
 |  | int do_poll(int timeout); | 
 |  |  | 
 |  | /* rrfilter.c */ | 
 |  | size_t rrfilter(struct dns_header *header, size_t plen, int mode); | 
 |  | u16 *rrfilter_desc(int type); | 
 |  | int expand_workspace(unsigned char ***wkspc, int *szp, int new); | 
 |  |  | 
 |  | /* edns0.c */ | 
 |  | unsigned char *find_pseudoheader(struct dns_header *header, size_t plen, | 
 |  | size_t *len, unsigned char **p, int *is_sign, int *is_last); | 
 |  | size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *limit, | 
 |  | unsigned short udp_sz, int optno, unsigned char *opt, size_t optlen, int set_do, int replace); | 
 |  | size_t add_do_bit(struct dns_header *header, size_t plen, unsigned char *limit); | 
 |  | size_t add_edns0_config(struct dns_header *header, size_t plen, unsigned char *limit, | 
 |  | union mysockaddr *source, time_t now, int *check_subnet); | 
 |  | int check_source(struct dns_header *header, size_t plen, unsigned char *pseudoheader, union mysockaddr *peer); | 
 |  |  | 
 |  | /* arp.c */ | 
 |  | int find_mac(union mysockaddr *addr, unsigned char *mac, int lazy, time_t now); | 
 |  | int do_arp_script_run(void); |