version 1.1.1.1, 2013/07/29 19:37:40
|
version 1.1.1.2, 2014/06/15 16:31:38
|
Line 1
|
Line 1
|
/* dnsmasq is Copyright (c) 2000-2013 Simon Kelley | /* dnsmasq is Copyright (c) 2000-2014 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-2013 Simon Kelley" | #define COPYRIGHT "Copyright (c) 2000-2014 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 50
|
Line 50
|
#include <getopt.h> |
#include <getopt.h> |
|
|
#include "config.h" |
#include "config.h" |
|
#include "ip6addr.h" |
|
|
typedef unsigned char u8; |
typedef unsigned char u8; |
typedef unsigned short u16; |
typedef unsigned short u16; |
typedef unsigned int u32; |
typedef unsigned int u32; |
typedef unsigned long long u64; |
typedef unsigned long long u64; |
|
|
|
#define countof(x) (long)(sizeof(x) / sizeof(x[0])) |
|
#define MIN(a,b) ((a) < (b) ? (a) : (b)) |
|
|
#include "dns-protocol.h" |
#include "dns-protocol.h" |
#include "dhcp-protocol.h" |
#include "dhcp-protocol.h" |
#ifdef HAVE_DHCP6 |
#ifdef HAVE_DHCP6 |
Line 160 struct event_desc {
|
Line 164 struct event_desc {
|
#define EVENT_FORK_ERR 18 |
#define EVENT_FORK_ERR 18 |
#define EVENT_LUA_ERR 19 |
#define EVENT_LUA_ERR 19 |
#define EVENT_TFTP_ERR 20 |
#define EVENT_TFTP_ERR 20 |
|
#define EVENT_INIT 21 |
|
|
/* Exit codes. */ |
/* Exit codes. */ |
#define EC_GOOD 0 |
#define EC_GOOD 0 |
Line 213 struct event_desc {
|
Line 218 struct event_desc {
|
#define OPT_NO_OVERRIDE 30 |
#define OPT_NO_OVERRIDE 30 |
#define OPT_NO_REBIND 31 |
#define OPT_NO_REBIND 31 |
#define OPT_ADD_MAC 32 |
#define OPT_ADD_MAC 32 |
#define OPT_DNSSEC 33 | #define OPT_DNSSEC_PROXY 33 |
#define OPT_CONSEC_ADDR 34 |
#define OPT_CONSEC_ADDR 34 |
#define OPT_CONNTRACK 35 |
#define OPT_CONNTRACK 35 |
#define OPT_FQDN_UPDATE 36 |
#define OPT_FQDN_UPDATE 36 |
Line 221 struct event_desc {
|
Line 226 struct event_desc {
|
#define OPT_TFTP_LC 38 |
#define OPT_TFTP_LC 38 |
#define OPT_CLEVERBIND 39 |
#define OPT_CLEVERBIND 39 |
#define OPT_TFTP 40 |
#define OPT_TFTP 40 |
#define OPT_LAST 41 | #define OPT_CLIENT_SUBNET 41 |
| #define OPT_QUIET_DHCP 42 |
| #define OPT_QUIET_DHCP6 43 |
| #define OPT_QUIET_RA 44 |
| #define OPT_DNSSEC_VALID 45 |
| #define OPT_DNSSEC_TIME 46 |
| #define OPT_DNSSEC_DEBUG 47 |
| #define OPT_DNSSEC_NO_SIGN 48 |
| #define OPT_LOCAL_SERVICE 49 |
| #define OPT_LAST 50 |
|
|
/* 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 234 struct all_addr {
|
Line 248 struct all_addr {
|
#ifdef HAVE_IPV6 |
#ifdef HAVE_IPV6 |
struct in6_addr addr6; |
struct in6_addr addr6; |
#endif |
#endif |
|
/* for log_query */ |
|
unsigned int keytag; |
|
/* for cache_insert if RRSIG, DNSKEY, DS */ |
|
struct { |
|
unsigned short class, type; |
|
} dnssec; |
} addr; |
} addr; |
}; |
}; |
|
|
Line 261 struct naptr {
|
Line 281 struct naptr {
|
struct naptr *next; |
struct naptr *next; |
}; |
}; |
|
|
|
#define TXT_STAT_CACHESIZE 1 |
|
#define TXT_STAT_INSERTS 2 |
|
#define TXT_STAT_EVICTIONS 3 |
|
#define TXT_STAT_MISSES 4 |
|
#define TXT_STAT_HITS 5 |
|
#define TXT_STAT_AUTH 6 |
|
#define TXT_STAT_SERVERS 7 |
|
|
struct txt_record { |
struct txt_record { |
char *name; |
char *name; |
unsigned char *txt; |
unsigned char *txt; |
unsigned short class, len; |
unsigned short class, len; |
|
int stat; |
struct txt_record *next; |
struct txt_record *next; |
}; |
}; |
|
|
Line 276 struct ptr_record {
|
Line 305 struct ptr_record {
|
struct cname { |
struct cname { |
char *alias, *target; |
char *alias, *target; |
struct cname *next; |
struct cname *next; |
|
}; |
|
|
|
struct ds_config { |
|
char *name, *digest; |
|
int digestlen, class, algo, keytag, digest_type; |
|
struct ds_config *next; |
}; |
}; |
|
|
|
#define ADDRLIST_LITERAL 1 |
|
#define ADDRLIST_IPV6 2 |
|
|
|
struct addrlist { |
|
struct all_addr addr; |
|
int flags, prefixlen; |
|
struct addrlist *next; |
|
}; |
|
|
|
#define AUTH6 1 |
|
#define AUTH4 2 |
|
|
struct auth_zone { |
struct auth_zone { |
char *domain; |
char *domain; |
struct subnet { | struct auth_name_list { |
int is6, prefixlen; | char *name; |
struct in_addr addr4; | int flags; |
#ifdef HAVE_IPV6 | struct auth_name_list *next; |
struct in6_addr addr6; | } *interface_names; |
#endif | struct addrlist *subnet; |
struct subnet *next; | |
} *subnet; | |
struct auth_zone *next; |
struct auth_zone *next; |
}; |
}; |
|
|
Line 307 struct host_record {
|
Line 352 struct host_record {
|
struct interface_name { |
struct interface_name { |
char *name; /* domain name */ |
char *name; /* domain name */ |
char *intr; /* interface name */ |
char *intr; /* interface name */ |
|
int family; /* AF_INET, AF_INET6 or zero for both */ |
|
struct addrlist *addr; |
struct interface_name *next; |
struct interface_name *next; |
}; |
}; |
|
|
Line 315 union bigname {
|
Line 362 union bigname {
|
union bigname *next; /* freelist */ |
union bigname *next; /* freelist */ |
}; |
}; |
|
|
struct keydata { | struct blockdata { |
struct keydata *next; | struct blockdata *next; |
unsigned char key[KEYBLOCK_LEN]; |
unsigned char key[KEYBLOCK_LEN]; |
}; |
}; |
|
|
Line 326 struct crec {
|
Line 373 struct crec {
|
union { |
union { |
struct all_addr addr; |
struct all_addr addr; |
struct { |
struct { |
struct crec *cache; | union { |
int uid; | struct crec *cache; |
| struct interface_name *int_name; |
| } target; |
| unsigned int uid; /* 0 if union is interface-name */ |
} cname; |
} cname; |
struct { |
struct { |
struct keydata *keydata; | struct blockdata *keydata; |
| unsigned short keylen, flags, keytag; |
unsigned char algo; |
unsigned char algo; |
unsigned char digest; /* DS only */ | } key; |
unsigned short flags_or_keyid; /* flags for DNSKEY, keyid for DS */ | struct { |
} key; | struct blockdata *keydata; |
| unsigned short keylen, keytag; |
| unsigned char algo; |
| unsigned char digest; |
| } 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 keylen if F_DS or F_DNSKEY, index to source for F_HOSTS */ | /* used as class if DNSKEY/DS/RRSIG, index to source for F_HOSTS */ |
int uid; | unsigned int uid; |
unsigned short flags; |
unsigned short flags; |
union { |
union { |
char sname[SMALLDNAME]; |
char sname[SMALLDNAME]; |
Line 372 struct crec {
|
Line 432 struct crec {
|
#define F_QUERY (1u<<19) |
#define F_QUERY (1u<<19) |
#define F_NOERR (1u<<20) |
#define F_NOERR (1u<<20) |
#define F_AUTH (1u<<21) |
#define F_AUTH (1u<<21) |
|
#define F_DNSSEC (1u<<22) |
|
#define F_KEYTAG (1u<<23) |
|
#define F_SECSTAT (1u<<24) |
|
#define F_NO_RR (1u<<25) |
|
#define F_IPSET (1u<<26) |
|
|
/* composites */ | /* Values of uid in crecs with F_CONFIG bit set. */ |
#define F_TYPE (F_IPV4 | F_IPV6 | F_DNSKEY | F_DS) /* Only one may be set */ | #define SRC_INTERFACE 0 |
| #define SRC_CONFIG 1 |
| #define SRC_HOSTS 2 |
| #define SRC_AH 3 |
|
|
|
|
|
|
/* struct sockaddr is not large enough to hold any address, |
/* struct sockaddr is not large enough to hold any address, |
and specifically not big enough to hold an IPv6 address. |
and specifically not big enough to hold an IPv6 address. |
Blech. Roll our own. */ |
Blech. Roll our own. */ |
Line 392 union mysockaddr {
|
Line 459 union mysockaddr {
|
/* bits in flag param to IPv6 callbacks from iface_enumerate() */ |
/* bits in flag param to IPv6 callbacks from iface_enumerate() */ |
#define IFACE_TENTATIVE 1 |
#define IFACE_TENTATIVE 1 |
#define IFACE_DEPRECATED 2 |
#define IFACE_DEPRECATED 2 |
|
#define IFACE_PERMANENT 4 |
|
|
|
|
#define SERV_FROM_RESOLV 1 /* 1 for servers from resolv, 0 for command line. */ |
#define SERV_FROM_RESOLV 1 /* 1 for servers from resolv, 0 for command line. */ |
Line 407 union mysockaddr {
|
Line 475 union mysockaddr {
|
#define SERV_COUNTED 512 /* workspace for log code */ |
#define SERV_COUNTED 512 /* workspace for log code */ |
#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 */ |
|
|
struct serverfd { |
struct serverfd { |
int fd; |
int fd; |
Line 439 struct ipsets {
|
Line 508 struct ipsets {
|
struct irec { |
struct irec { |
union mysockaddr addr; |
union mysockaddr addr; |
struct in_addr netmask; /* only valid for IPv4 */ |
struct in_addr netmask; /* only valid for IPv4 */ |
int tftp_ok, dhcp_ok, mtu, done, dad, dns_auth, index, multicast_done; | int tftp_ok, dhcp_ok, mtu, done, warned, dad, dns_auth, index, multicast_done, found; |
char *name; |
char *name; |
struct irec *next; |
struct irec *next; |
}; |
}; |
Line 473 struct hostsfile {
|
Line 542 struct hostsfile {
|
struct hostsfile *next; |
struct hostsfile *next; |
int flags; |
int flags; |
char *fname; |
char *fname; |
int index; /* matches to cache entries for logging */ | unsigned int index; /* matches to cache entries for logging */ |
}; |
}; |
|
|
|
|
|
/* DNSSEC status values. */ |
|
#define STAT_SECURE 1 |
|
#define STAT_INSECURE 2 |
|
#define STAT_BOGUS 3 |
|
#define STAT_NEED_DS 4 |
|
#define STAT_NEED_KEY 5 |
|
#define STAT_TRUNCATED 6 |
|
#define STAT_SECURE_WILDCARD 7 |
|
#define STAT_NO_SIG 8 |
|
#define STAT_NO_DS 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 |
|
#define FREC_HAS_SUBNET 4 |
|
#define FREC_DNSKEY_QUERY 8 |
|
#define FREC_DS_QUERY 16 |
|
#define FREC_AD_QUESTION 32 |
|
#define FREC_DO_QUESTION 64 |
|
#define FREC_ADDED_PHEADER 128 |
|
#define FREC_CHECK_NOSIGN 256 |
|
|
|
#ifdef HAVE_DNSSEC |
|
#define HASH_SIZE 20 /* SHA-1 digest size */ |
|
#else |
|
#define HASH_SIZE sizeof(int) |
|
#endif |
|
|
struct frec { |
struct frec { |
union mysockaddr source; |
union mysockaddr source; |
struct all_addr dest; |
struct all_addr dest; |
Line 490 struct frec {
|
Line 586 struct frec {
|
unsigned int iface; |
unsigned int iface; |
unsigned short orig_id, new_id; |
unsigned short orig_id, new_id; |
int fd, forwardall, flags; |
int fd, forwardall, flags; |
unsigned int crc; |
|
time_t time; |
time_t time; |
|
unsigned char *hash[HASH_SIZE]; |
|
#ifdef HAVE_DNSSEC |
|
int class, work_counter; |
|
struct blockdata *stash; /* Saved reply, whilst we validate */ |
|
size_t stash_len; |
|
struct frec *dependent; /* Query awaiting internally-generated DNSKEY or DS query */ |
|
struct frec *blocking_query; /* Query which is blocking us. */ |
|
#endif |
struct frec *next; |
struct frec *next; |
}; |
}; |
|
|
Line 530 struct dhcp_lease {
|
Line 633 struct dhcp_lease {
|
#ifdef HAVE_BROKEN_RTC |
#ifdef HAVE_BROKEN_RTC |
unsigned int length; |
unsigned int length; |
#endif |
#endif |
int hwaddr_len, hwaddr_type; /* hw_type used for iaid in v6 */ | int hwaddr_len, hwaddr_type; |
unsigned char hwaddr[DHCP_CHADDR_MAX]; /* also IPv6 address */ | unsigned char hwaddr[DHCP_CHADDR_MAX]; |
struct in_addr addr, override, giaddr; |
struct in_addr addr, override, giaddr; |
unsigned char *extradata; |
unsigned char *extradata; |
unsigned int extradata_len, extradata_size; |
unsigned int extradata_len, extradata_size; |
int last_interface; |
int last_interface; |
#ifdef HAVE_DHCP6 |
#ifdef HAVE_DHCP6 |
|
struct in6_addr addr6; |
|
int iaid; |
struct slaac_address { |
struct slaac_address { |
struct in6_addr addr, local; | struct in6_addr addr; |
time_t ping_time; |
time_t ping_time; |
int backoff; /* zero -> confirmed */ |
int backoff; /* zero -> confirmed */ |
struct slaac_address *next; |
struct slaac_address *next; |
Line 673 struct dhcp_bridge {
|
Line 778 struct dhcp_bridge {
|
}; |
}; |
|
|
struct cond_domain { |
struct cond_domain { |
char *domain; | char *domain, *prefix; |
struct in_addr start, end; |
struct in_addr start, end; |
#ifdef HAVE_IPV6 |
#ifdef HAVE_IPV6 |
struct in6_addr start6, end6; |
struct in6_addr start6, end6; |
Line 690 struct prefix_class {
|
Line 795 struct prefix_class {
|
}; |
}; |
#endif |
#endif |
|
|
|
struct ra_interface { |
|
char *name; |
|
int interval, lifetime, prio; |
|
struct ra_interface *next; |
|
}; |
|
|
struct dhcp_context { |
struct dhcp_context { |
unsigned int lease_time, addr_epoch; |
unsigned int lease_time, addr_epoch; |
struct in_addr netmask, broadcast; |
struct in_addr netmask, broadcast; |
Line 699 struct dhcp_context {
|
Line 810 struct dhcp_context {
|
struct in6_addr start6, end6; /* range of available addresses */ |
struct in6_addr start6, end6; /* range of available addresses */ |
struct in6_addr local6; |
struct in6_addr local6; |
int prefix, if_index; |
int prefix, if_index; |
unsigned int valid, preferred; | unsigned int valid, preferred, saved_valid; |
time_t ra_time, ra_short_period_start; | time_t ra_time, ra_short_period_start, address_lost_time; |
char *template_interface; |
char *template_interface; |
#endif |
#endif |
int flags; |
int flags; |
Line 708 struct dhcp_context {
|
Line 819 struct dhcp_context {
|
struct dhcp_context *next, *current; |
struct dhcp_context *next, *current; |
}; |
}; |
|
|
#define CONTEXT_STATIC 1 | #define CONTEXT_STATIC (1u<<0) |
#define CONTEXT_NETMASK 2 | #define CONTEXT_NETMASK (1u<<1) |
#define CONTEXT_BRDCAST 4 | #define CONTEXT_BRDCAST (1u<<2) |
#define CONTEXT_PROXY 8 | #define CONTEXT_PROXY (1u<<3) |
#define CONTEXT_RA_ONLY 16 | #define CONTEXT_RA_ONLY (1u<<4) |
#define CONTEXT_RA_DONE 32 | #define CONTEXT_RA_DONE (1u<<5) |
#define CONTEXT_RA_NAME 64 | #define CONTEXT_RA_NAME (1u<<6) |
#define CONTEXT_RA_STATELESS 128 | #define CONTEXT_RA_STATELESS (1u<<7) |
#define CONTEXT_DHCP 256 | #define CONTEXT_DHCP (1u<<8) |
#define CONTEXT_DEPRECATE 512 | #define CONTEXT_DEPRECATE (1u<<9) |
#define CONTEXT_TEMPLATE 1024 /* create contexts using addresses */ | #define CONTEXT_TEMPLATE (1u<<10) /* create contexts using addresses */ |
#define CONTEXT_CONSTRUCTED 2048 | #define CONTEXT_CONSTRUCTED (1u<<11) |
#define CONTEXT_GC 4096 | #define CONTEXT_GC (1u<<12) |
#define CONTEXT_RA 8192 | #define CONTEXT_RA (1u<<13) |
#define CONTEXT_CONF_USED 16384 | #define CONTEXT_CONF_USED (1u<<14) |
#define CONTEXT_USED 32768 | #define CONTEXT_USED (1u<<15) |
| #define CONTEXT_OLD (1u<<16) |
| #define CONTEXT_V6 (1u<<17) |
|
|
|
|
struct ping_result { |
struct ping_result { |
struct in_addr addr; |
struct in_addr addr; |
time_t time; |
time_t time; |
Line 763 struct tftp_prefix {
|
Line 877 struct tftp_prefix {
|
struct tftp_prefix *next; |
struct tftp_prefix *next; |
}; |
}; |
|
|
|
struct dhcp_relay { |
|
struct all_addr local, server; |
|
char *interface; /* Allowable interface for replies from server, and dest for IPv6 multicast */ |
|
int iface_index; /* working - interface in which requests arrived, for return */ |
|
struct dhcp_relay *current, *next; |
|
}; |
|
|
extern struct daemon { |
extern struct daemon { |
/* datastuctures representing the command-line and |
/* datastuctures representing the command-line and |
Line 772 extern struct daemon {
|
Line 892 extern struct daemon {
|
unsigned int options, options2; |
unsigned int options, options2; |
struct resolvc default_resolv, *resolv_files; |
struct resolvc default_resolv, *resolv_files; |
time_t last_resolv; |
time_t last_resolv; |
|
char *servers_file; |
struct mx_srv_record *mxnames; |
struct mx_srv_record *mxnames; |
struct naptr *naptr; |
struct naptr *naptr; |
struct txt_record *txt, *rr; |
struct txt_record *txt, *rr; |
Line 781 extern struct daemon {
|
Line 902 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; |
|
int addr6_netmask; |
char *lease_file; |
char *lease_file; |
char *username, *groupname, *scriptuser; |
char *username, *groupname, *scriptuser; |
char *luascript; |
char *luascript; |
Line 789 extern struct daemon {
|
Line 912 extern struct daemon {
|
struct name_list *secondary_forward_server; |
struct name_list *secondary_forward_server; |
int group_set, osport; |
int group_set, osport; |
char *domain_suffix; |
char *domain_suffix; |
struct cond_domain *cond_domain; | struct cond_domain *cond_domain, *synth_domains; |
char *runfile; |
char *runfile; |
char *lease_change_command; |
char *lease_change_command; |
struct iname *if_names, *if_addrs, *if_except, *dhcp_except, *auth_peers; | struct iname *if_names, *if_addrs, *if_except, *dhcp_except, *auth_peers, *tftp_interfaces; |
struct bogus_addr *bogus_addr; |
struct bogus_addr *bogus_addr; |
struct server *servers; |
struct server *servers; |
struct ipsets *ipsets; |
struct ipsets *ipsets; |
Line 804 extern struct daemon {
|
Line 927 extern struct daemon {
|
unsigned long local_ttl, neg_ttl, max_ttl, max_cache_ttl, auth_ttl; |
unsigned long local_ttl, neg_ttl, max_ttl, max_cache_ttl, auth_ttl; |
struct hostsfile *addn_hosts; |
struct hostsfile *addn_hosts; |
struct dhcp_context *dhcp, *dhcp6; |
struct dhcp_context *dhcp, *dhcp6; |
|
struct ra_interface *ra_interfaces; |
struct dhcp_config *dhcp_conf; |
struct dhcp_config *dhcp_conf; |
struct dhcp_opt *dhcp_opts, *dhcp_match, *dhcp_opts6, *dhcp_match6; |
struct dhcp_opt *dhcp_opts, *dhcp_match, *dhcp_opts6, *dhcp_match6; |
struct dhcp_vendor *dhcp_vendors; |
struct dhcp_vendor *dhcp_vendors; |
Line 812 extern struct daemon {
|
Line 936 extern struct daemon {
|
struct pxe_service *pxe_services; |
struct pxe_service *pxe_services; |
struct tag_if *tag_if; |
struct tag_if *tag_if; |
struct addr_list *override_relays; |
struct addr_list *override_relays; |
|
struct dhcp_relay *relay4, *relay6; |
int override; |
int override; |
int enable_pxe; |
int enable_pxe; |
int doing_ra, doing_dhcp6; |
int doing_ra, doing_dhcp6; |
Line 833 extern struct daemon {
|
Line 958 extern struct daemon {
|
#ifdef OPTION6_PREFIX_CLASS |
#ifdef OPTION6_PREFIX_CLASS |
struct prefix_class *prefix_classes; |
struct prefix_class *prefix_classes; |
#endif |
#endif |
|
#ifdef HAVE_DNSSEC |
|
struct ds_config *ds; |
|
#endif |
|
|
/* globally used stuff for DNS */ |
/* globally used stuff for DNS */ |
char *packet; /* packet buffer */ |
char *packet; /* packet buffer */ |
int packet_buff_sz; /* size of above */ |
int packet_buff_sz; /* size of above */ |
char *namebuff; /* MAXDNAME size buffer */ |
char *namebuff; /* MAXDNAME size buffer */ |
unsigned int local_answer, queries_forwarded; | #ifdef HAVE_DNSSEC |
| char *keyname; /* MAXDNAME size buffer */ |
| char *workspacename; /* ditto */ |
| #endif |
| unsigned int local_answer, queries_forwarded, auth_answer; |
struct frec *frec_list; |
struct frec *frec_list; |
struct serverfd *sfds; |
struct serverfd *sfds; |
struct irec *interfaces; |
struct irec *interfaces; |
Line 852 extern struct daemon {
|
Line 984 extern struct daemon {
|
pid_t tcp_pids[MAX_PROCS]; |
pid_t tcp_pids[MAX_PROCS]; |
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 */ |
|
|
/* DHCP state */ |
/* DHCP state */ |
int dhcpfd, helperfd, pxefd; |
int dhcpfd, helperfd, pxefd; |
#if defined(HAVE_LINUX_NETWORK) |
#if defined(HAVE_LINUX_NETWORK) |
int netlinkfd; |
int netlinkfd; |
#elif defined(HAVE_BSD_NETWORK) |
#elif defined(HAVE_BSD_NETWORK) |
int dhcp_raw_fd, dhcp_icmp_fd; | int dhcp_raw_fd, dhcp_icmp_fd, routefd; |
#endif |
#endif |
struct iovec dhcp_packet; |
struct iovec dhcp_packet; |
char *dhcp_buff, *dhcp_buff2, *dhcp_buff3; |
char *dhcp_buff, *dhcp_buff2, *dhcp_buff3; |
Line 889 extern struct daemon {
|
Line 1022 extern struct daemon {
|
/* cache.c */ |
/* cache.c */ |
void cache_init(void); |
void cache_init(void); |
void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg); |
void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg); |
char *record_source(int index); | char *record_source(unsigned int index); |
void querystr(char *desc, char *str, unsigned short type); | char *querystr(char *desc, unsigned short type); |
struct crec *cache_find_by_addr(struct crec *crecp, |
struct crec *cache_find_by_addr(struct crec *crecp, |
struct all_addr *addr, time_t now, |
struct all_addr *addr, time_t now, |
unsigned short prot); | unsigned int prot); |
struct crec *cache_find_by_name(struct crec *crecp, |
struct crec *cache_find_by_name(struct crec *crecp, |
char *name, time_t now, unsigned short prot); | char *name, time_t now, unsigned int prot); |
void cache_end_insert(void); |
void cache_end_insert(void); |
void cache_start_insert(void); |
void cache_start_insert(void); |
struct crec *cache_insert(char *name, struct all_addr *addr, |
struct crec *cache_insert(char *name, struct all_addr *addr, |
Line 905 void cache_add_dhcp_entry(char *host_name, int prot, s
|
Line 1038 void cache_add_dhcp_entry(char *host_name, int prot, s
|
struct in_addr a_record_from_hosts(char *name, time_t now); |
struct in_addr a_record_from_hosts(char *name, time_t now); |
void cache_unhash_dhcp(void); |
void cache_unhash_dhcp(void); |
void dump_cache(time_t now); |
void dump_cache(time_t now); |
|
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); |
struct crec *cache_enumerate(int init); |
struct crec *cache_enumerate(int init); |
|
|
|
/* blockdata.c */ |
|
#ifdef HAVE_DNSSEC |
|
void blockdata_init(void); |
|
void blockdata_report(void); |
|
struct blockdata *blockdata_alloc(char *data, size_t len); |
|
void *blockdata_retrieve(struct blockdata *block, size_t len, void *data); |
|
void blockdata_free(struct blockdata *blocks); |
|
#endif |
|
|
|
/* domain.c */ |
char *get_domain(struct in_addr addr); |
char *get_domain(struct in_addr addr); |
#ifdef HAVE_IPV6 |
#ifdef HAVE_IPV6 |
char *get_domain6(struct in6_addr *addr); |
char *get_domain6(struct in6_addr *addr); |
#endif |
#endif |
#ifdef HAVE_DNSSEC | int is_name_synthetic(int flags, char *name, struct all_addr *addr); |
struct keydata *keydata_alloc(char *data, size_t len); | int is_rev_synth(int flag, struct all_addr *addr, char *name); |
void keydata_free(struct keydata *blocks); | |
#endif | |
|
|
/* rfc1035.c */ |
/* rfc1035.c */ |
|
int extract_name(struct dns_header *header, size_t plen, unsigned char **pp, |
|
char *name, int isExtract, int extrabytes); |
|
unsigned char *skip_name(unsigned char *ansp, struct dns_header *header, size_t plen, int extrabytes); |
|
unsigned char *skip_questions(struct dns_header *header, size_t plen); |
|
unsigned char *skip_section(unsigned char *ansp, int count, struct dns_header *header, size_t plen); |
unsigned int extract_request(struct dns_header *header, size_t qlen, |
unsigned int extract_request(struct dns_header *header, size_t qlen, |
char *name, unsigned short *typep); |
char *name, unsigned short *typep); |
size_t setup_reply(struct dns_header *header, size_t qlen, |
size_t setup_reply(struct dns_header *header, size_t qlen, |
Line 924 size_t setup_reply(struct dns_header *header, size_t
|
Line 1073 size_t setup_reply(struct dns_header *header, size_t
|
unsigned long local_ttl); |
unsigned long local_ttl); |
int extract_addresses(struct dns_header *header, size_t qlen, char *namebuff, |
int extract_addresses(struct dns_header *header, size_t qlen, char *namebuff, |
time_t now, char **ipsets, int is_sign, int checkrebind, |
time_t now, char **ipsets, int is_sign, int checkrebind, |
int checking_disabled); | 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, time_t now); | struct in_addr local_addr, struct in_addr local_netmask, |
| time_t now, int *ad_reqd, int *do_bit); |
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, |
unsigned char *find_pseudoheader(struct dns_header *header, size_t plen, |
Line 936 unsigned int questions_crc(struct dns_header *header,
|
Line 1086 unsigned int questions_crc(struct dns_header *header,
|
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_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 943 unsigned char *skip_questions(struct dns_header *heade
|
Line 1098 unsigned char *skip_questions(struct dns_header *heade
|
int extract_name(struct dns_header *header, size_t plen, unsigned char **pp, |
int extract_name(struct dns_header *header, size_t plen, unsigned char **pp, |
char *name, int isExtract, int extrabytes); |
char *name, int isExtract, int extrabytes); |
int in_arpa_name_2_addr(char *namein, struct all_addr *addrp); |
int in_arpa_name_2_addr(char *namein, struct all_addr *addrp); |
|
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, time_t now, union mysockaddr *peer_addr); | size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, |
| time_t now, union mysockaddr *peer_addr, int local_query); |
| int in_zone(struct auth_zone *zone, char *name, char **cut); |
#endif |
#endif |
|
|
|
/* dnssec.c */ |
|
size_t dnssec_generate_query(struct dns_header *header, char *end, char *name, int class, int type, union mysockaddr *addr); |
|
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_reply(time_t now, struct dns_header *header, size_t plen, char *name, char *keyname, int *class, int *neganswer); |
|
int dnssec_chase_cname(time_t now, struct dns_header *header, size_t plen, char *name, char *keyname); |
|
int dnskey_keytag(int alg, int flags, unsigned char *rdata, int rdlen); |
|
size_t filter_rrsigs(struct dns_header *header, size_t plen); |
|
unsigned char* hash_questions(struct dns_header *header, size_t plen, char *name); |
|
|
/* util.c */ |
/* util.c */ |
void rand_init(void); |
void rand_init(void); |
unsigned short rand16(void); |
unsigned short rand16(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); |
unsigned char *do_rfc1035_name(unsigned char *p, char *sval); |
unsigned char *do_rfc1035_name(unsigned char *p, char *sval); |
Line 996 void read_opts (int argc, char **argv, char *compile_o
|
Line 1165 void read_opts (int argc, char **argv, char *compile_o
|
char *option_string(int prot, unsigned int opt, unsigned char *val, |
char *option_string(int prot, unsigned int opt, unsigned char *val, |
int opt_len, char *buf, int buf_len); |
int opt_len, char *buf, int buf_len); |
void reread_dhcp(void); |
void reread_dhcp(void); |
|
void read_servers_file(void); |
void set_option_bool(unsigned int opt); |
void set_option_bool(unsigned int opt); |
void reset_option_bool(unsigned int opt); |
void reset_option_bool(unsigned int opt); |
struct hostsfile *expand_filelist(struct hostsfile *list); |
struct hostsfile *expand_filelist(struct hostsfile *list); |
Line 1008 void receive_query(struct listener *listen, time_t now
|
Line 1178 void receive_query(struct listener *listen, time_t now
|
unsigned char *tcp_request(int confd, time_t now, |
unsigned char *tcp_request(int confd, time_t now, |
union mysockaddr *local_addr, struct in_addr netmask, int auth_dns); |
union mysockaddr *local_addr, struct in_addr netmask, int auth_dns); |
void server_gone(struct server *server); |
void server_gone(struct server *server); |
struct frec *get_new_frec(time_t now, int *wait); | struct frec *get_new_frec(time_t now, int *wait, int force); |
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); |
Line 1019 int local_bind(int fd, union mysockaddr *addr, char *i
|
Line 1189 int local_bind(int fd, union mysockaddr *addr, char *i
|
int random_sock(int family); |
int random_sock(int family); |
void pre_allocate_sfds(void); |
void pre_allocate_sfds(void); |
int reload_servers(char *fname); |
int reload_servers(char *fname); |
|
void mark_servers(int flag); |
|
void cleanup_servers(void); |
|
void add_update_server(int flags, |
|
union mysockaddr *addr, |
|
union mysockaddr *source_addr, |
|
const char *interface, |
|
const char *domain); |
void check_servers(void); |
void check_servers(void); |
int enumerate_interfaces(); | int enumerate_interfaces(int reset); |
void create_wildcard_listeners(void); |
void create_wildcard_listeners(void); |
void create_bound_listeners(int die); |
void create_bound_listeners(int die); |
|
void warn_bound_listeners(void); |
|
void warn_int_names(void); |
int is_dad_listeners(void); |
int is_dad_listeners(void); |
int iface_check(int family, struct all_addr *addr, char *name, int *auth_dns); |
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 loopback_exception(int fd, int family, struct all_addr *addr, char *name); |
|
int label_exception(int index, int family, struct all_addr *addr); |
int fix_fd(int fd); |
int fix_fd(int fd); |
int tcp_interface(int fd, int af); |
int tcp_interface(int fd, int af); |
struct in_addr get_ifaddr(char *intr); |
|
#ifdef HAVE_IPV6 |
#ifdef HAVE_IPV6 |
int set_ipv6pktinfo(int fd); |
int set_ipv6pktinfo(int fd); |
#endif |
#endif |
#ifdef HAVE_DHCP6 |
#ifdef HAVE_DHCP6 |
void join_multicast(int dienow); |
void join_multicast(int dienow); |
#endif |
#endif |
|
#if defined(HAVE_LINUX_NETWORK) || defined(HAVE_BSD_NETWORK) |
|
void newaddress(time_t now); |
|
#endif |
|
|
|
|
/* dhcp.c */ |
/* dhcp.c */ |
#ifdef HAVE_DHCP |
#ifdef HAVE_DHCP |
void dhcp_init(void); |
void dhcp_init(void); |
Line 1049 struct dhcp_context *narrow_context(struct dhcp_contex
|
Line 1232 struct dhcp_context *narrow_context(struct dhcp_contex
|
int address_allocate(struct dhcp_context *context, |
int address_allocate(struct dhcp_context *context, |
struct in_addr *addrp, unsigned char *hwaddr, int hw_len, |
struct in_addr *addrp, unsigned char *hwaddr, int hw_len, |
struct dhcp_netid *netids, time_t now); |
struct dhcp_netid *netids, time_t now); |
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_read_ethers(void); |
void dhcp_read_ethers(void); |
struct dhcp_config *config_find_by_address(struct dhcp_config *configs, struct in_addr addr); |
struct dhcp_config *config_find_by_address(struct dhcp_config *configs, struct in_addr addr); |
char *host_from_dns(struct in_addr addr); |
char *host_from_dns(struct in_addr addr); |
Line 1076 struct dhcp_lease *lease6_find_by_addr(struct in6_addr
|
Line 1253 struct dhcp_lease *lease6_find_by_addr(struct in6_addr
|
u64 lease_find_max_addr6(struct dhcp_context *context); |
u64 lease_find_max_addr6(struct dhcp_context *context); |
void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface); |
void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface); |
void lease_update_slaac(time_t now); |
void lease_update_slaac(time_t now); |
|
void lease_set_iaid(struct dhcp_lease *lease, int iaid); |
|
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, unsigned char *hwaddr, |
unsigned char *clid, int hw_len, int hw_type, int clid_len, time_t now, int force); |
unsigned char *clid, int hw_len, int hw_type, int clid_len, time_t now, int force); |
Line 1126 void netlink_multicast(time_t now);
|
Line 1305 void netlink_multicast(time_t now);
|
void init_bpf(void); |
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_sock(time_t now); |
#endif |
#endif |
|
|
/* bpf.c or netlink.c */ |
/* bpf.c or netlink.c */ |
Line 1176 int get_incoming_mark(union mysockaddr *peer_addr, str
|
Line 1357 int get_incoming_mark(union mysockaddr *peer_addr, str
|
#ifdef HAVE_DHCP6 |
#ifdef HAVE_DHCP6 |
void dhcp6_init(void); |
void dhcp6_init(void); |
void dhcp6_packet(time_t now); |
void dhcp6_packet(time_t now); |
struct dhcp_context *address6_allocate(struct dhcp_context *context, unsigned char *clid, int clid_len, | struct dhcp_context *address6_allocate(struct dhcp_context *context, unsigned char *clid, int clid_len, int temp_addr, |
int iaid, int serial, struct dhcp_netid *netids, int plain_range, struct in6_addr *ans); |
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); |
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 dhcp_context *address6_available(struct dhcp_context *context, |
Line 1187 struct dhcp_context *address6_valid(struct dhcp_contex
|
Line 1368 struct dhcp_context *address6_valid(struct dhcp_contex
|
struct in6_addr *taddr, |
struct in6_addr *taddr, |
struct dhcp_netid *netids, |
struct dhcp_netid *netids, |
int plain_range); |
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, |
struct dhcp_config *config_find_by_address6(struct dhcp_config *configs, struct in6_addr *net, |
int prefix, u64 addr); |
int prefix, u64 addr); |
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, |
|
unsigned int *maclenp, unsigned int *mactypep); |
#endif |
#endif |
| |
/* rfc3315.c */ |
/* rfc3315.c */ |
#ifdef HAVE_DHCP6 |
#ifdef HAVE_DHCP6 |
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, size_t sz, int is_multicast, time_t now); | 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); |
| void relay_upstream6(struct dhcp_relay *relay, ssize_t sz, struct in6_addr *peer_address, u32 scope_id); |
| |
| unsigned short relay_reply6( struct sockaddr_in6 *peer, ssize_t sz, char *arrival_interface); |
#endif |
#endif |
|
|
/* dhcp-common.c */ |
/* dhcp-common.c */ |
Line 1216 void log_tags(struct dhcp_netid *netid, u32 xid);
|
Line 1399 void log_tags(struct dhcp_netid *netid, u32 xid);
|
int match_bytes(struct dhcp_opt *o, unsigned char *p, int len); |
int match_bytes(struct dhcp_opt *o, unsigned char *p, int len); |
void dhcp_update_configs(struct dhcp_config *configs); |
void dhcp_update_configs(struct dhcp_config *configs); |
void display_opts(void); |
void display_opts(void); |
u16 lookup_dhcp_opt(int prot, char *name); | int lookup_dhcp_opt(int prot, char *name); |
u16 lookup_dhcp_len(int prot, u16 val); | int lookup_dhcp_len(int prot, int val); |
char *option_string(int prot, unsigned int opt, unsigned char *val, |
char *option_string(int prot, unsigned int opt, unsigned char *val, |
int opt_len, char *buf, int buf_len); |
int opt_len, char *buf, int buf_len); |
|
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); |
|
int config_has_mac(struct dhcp_config *config, unsigned char *hwaddr, int len, int type); |
#ifdef HAVE_LINUX_NETWORK |
#ifdef HAVE_LINUX_NETWORK |
void bindtodevice(int fd); | char *whichdevice(void); |
| void bindtodevice(char *device, int fd); |
#endif |
#endif |
# ifdef HAVE_DHCP6 |
# ifdef HAVE_DHCP6 |
void display_opts6(void); |
void display_opts6(void); |
# endif |
# endif |
void log_context(int family, struct dhcp_context *context); |
void log_context(int family, struct dhcp_context *context); |
|
void log_relay(int family, struct dhcp_relay *relay); |
#endif |
#endif |
|
|
/* outpacket.c */ |
/* outpacket.c */ |