Commit 572b41eb authored by Simon Kelley's avatar Simon Kelley

import of dnsmasq-2.57.tar.gz

parent 28866e95
ifneq ($(TARGET_SIMULATOR),true)
include $(call all-subdir-makefiles)
endif
version 2.57
Add patches to allow build under Android.
Provide our own header for the DNS protocol, rather than
relying on arpa/nameser.h. This has proved more or less
defective over the years and the final straw is that it's
effectively empty on Android.
Fix regression in 2.56 which caused hex constants in
configuration to be rejected if they contain the '*'
wildcard.
Correct wrong casts of arguments to ctype.h functions,
isdigit(), isxdigit() etc. Thanks to Matthias Andree for
spotting this.
Allow build with IDN support independently from i18n.
IDN support continues to be included automatically
when i18n is included.
'make COPTS=-DHAVE_IDN' is the magic incantation.
Modify check on extraneous command line junk (added in
2.56) so that it doesn't complain about extra _empty_
arguments. Otherwise this breaks libvirt.
version 2.56 version 2.56
Add a patch to allow dnsmasq to get interface names right in a Add a patch to allow dnsmasq to get interface names right in a
Solaris zone. Thanks to Dj Padzensky for this. Solaris zone. Thanks to Dj Padzensky for this.
...@@ -117,9 +143,9 @@ version 2.56 ...@@ -117,9 +143,9 @@ version 2.56
request meant for another DHCP server. NAKing this is request meant for another DHCP server. NAKing this is
wrong. Thanks to Brad D'Hondt for assistance with this. wrong. Thanks to Brad D'Hondt for assistance with this.
Fix cosmetic bug which produced strange output when Fix cosmetic bug which produced strange output when
dumping cache statistics with some configurations. Thanks dumping cache statistics with some configurations. Thanks
to Fedor Kozhevnikov for spotting this. to Fedor Kozhevnikov for spotting this.
version 2.55 version 2.55
......
# dnsmasq is Copyright (c) 2000-2010 Simon Kelley # dnsmasq is Copyright (c) 2000-2011 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
...@@ -34,6 +34,8 @@ MAN = man ...@@ -34,6 +34,8 @@ MAN = man
DNSMASQ_CFLAGS=`echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1` DNSMASQ_CFLAGS=`echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1`
DNSMASQ_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1` DNSMASQ_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1`
IDN_CFLAGS=`echo $(COPTS) | ../bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --cflags libidn`
IDN_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --libs libidn`
SUNOS_LIBS= `if uname | grep SunOS 2>&1 >/dev/null; then echo -lsocket -lnsl -lposix4; fi` SUNOS_LIBS= `if uname | grep SunOS 2>&1 >/dev/null; then echo -lsocket -lnsl -lposix4; fi`
OBJS = cache.o rfc1035.o util.o option.o forward.o network.o \ OBJS = cache.o rfc1035.o util.o option.o forward.o network.o \
...@@ -42,8 +44,8 @@ OBJS = cache.o rfc1035.o util.o option.o forward.o network.o \ ...@@ -42,8 +44,8 @@ OBJS = cache.o rfc1035.o util.o option.o forward.o network.o \
all : all :
@cd $(SRC) && $(MAKE) \ @cd $(SRC) && $(MAKE) \
BUILD_CFLAGS="$(DNSMASQ_CFLAGS)" \ BUILD_CFLAGS="$(DNSMASQ_CFLAGS) $(IDN_CFLAGS)" \
BUILD_LIBS="$(DNSMASQ_LIBS) $(SUNOS_LIBS)" \ BUILD_LIBS="$(DNSMASQ_LIBS) $(IDN_LIBS) $(SUNOS_LIBS)" \
-f ../Makefile dnsmasq -f ../Makefile dnsmasq
clean : clean :
......
LOCAL_PATH := external/dnsmasq/src
#########################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := bpf.c cache.c dbus.c dhcp.c dnsmasq.c \
forward.c helper.c lease.c log.c \
netlink.c network.c option.c rfc1035.c \
rfc2131.c tftp.c util.c
LOCAL_MODULE := dnsmasq
LOCAL_C_INCLUDES := external/dnsmasq/src
LOCAL_CFLAGS := -O2 -g -W -Wall -D__ANDROID__ -DNO_IPV6 -DNO_TFTP -DNO_SCRIPT
LOCAL_SYSTEM_SHARED_LIBRARIES := libc libcutils
include $(BUILD_EXECUTABLE)
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
# The following two options make you a better netizen, since they # The following two options make you a better netizen, since they
# tell dnsmasq to filter out queries which the public DNS cannot # tell dnsmasq to filter out queries which the public DNS cannot
# answer, and which load the servers (especially the root servers) # answer, and which load the servers (especially the root servers)
# necessarily. If you have a dial-on-demand link they also stop # unnecessarily. If you have a dial-on-demand link they also stop
# these requests from bringing up the link necessarily. # these requests from bringing up the link unnecessarily.
# Never forward plain names (without a dot or domain part) # Never forward plain names (without a dot or domain part)
#domain-needed #domain-needed
...@@ -161,7 +161,8 @@ ...@@ -161,7 +161,8 @@
# of valid alternatives, so we will give examples of each. Note that # of valid alternatives, so we will give examples of each. Note that
# IP addresses DO NOT have to be in the range given above, they just # IP addresses DO NOT have to be in the range given above, they just
# need to be on the same network. The order of the parameters in these # need to be on the same network. The order of the parameters in these
# do not matter, it's permissible to give name,address and MAC in any order # do not matter, it's permissible to give name, address and MAC in any
# order.
# Always allocate the host with Ethernet address 11:22:33:44:55:66 # Always allocate the host with Ethernet address 11:22:33:44:55:66
# The IP address 192.168.0.60 # The IP address 192.168.0.60
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
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 VERSION "2.56" #define VERSION "2.57"
#define FTABSIZ 150 /* max number of outstanding requests (default) */ #define FTABSIZ 150 /* max number of outstanding requests (default) */
#define MAX_PROCS 20 /* max no children for TCP requests */ #define MAX_PROCS 20 /* max no children for TCP requests */
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
# define LEASEFILE "/var/db/dnsmasq.leases" # define LEASEFILE "/var/db/dnsmasq.leases"
# elif defined(__sun__) || defined (__sun) # elif defined(__sun__) || defined (__sun)
# define LEASEFILE "/var/cache/dnsmasq.leases" # define LEASEFILE "/var/cache/dnsmasq.leases"
# elif defined(__ANDROID__)
# define LEASEFILE "/data/misc/dhcp/dnsmasq.leases"
# else # else
# define LEASEFILE "/var/lib/misc/dnsmasq.leases" # define LEASEFILE "/var/lib/misc/dnsmasq.leases"
# endif # endif
...@@ -62,6 +64,7 @@ ...@@ -62,6 +64,7 @@
#define DEFLEASE 3600 /* default lease time, 1 hour */ #define DEFLEASE 3600 /* default lease time, 1 hour */
#define CHUSER "nobody" #define CHUSER "nobody"
#define CHGRP "dip" #define CHGRP "dip"
#define NAMESERVER_PORT 53
#define DHCP_SERVER_PORT 67 #define DHCP_SERVER_PORT 67
#define DHCP_CLIENT_PORT 68 #define DHCP_CLIENT_PORT 68
#define DHCP_SERVER_ALTPORT 1067 #define DHCP_SERVER_ALTPORT 1067
...@@ -78,29 +81,6 @@ ...@@ -78,29 +81,6 @@
#define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq" #define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq"
#define DNSMASQ_PATH "/uk/org/thekelleys/dnsmasq" #define DNSMASQ_PATH "/uk/org/thekelleys/dnsmasq"
/* A small collection of RR-types which are missing on some platforms */
#ifndef T_SIG
# define T_SIG 24
#endif
#ifndef T_SRV
# define T_SRV 33
#endif
#ifndef T_OPT
# define T_OPT 41
#endif
#ifndef T_TKEY
# define T_TKEY 249
#endif
#ifndef T_TSIG
# define T_TSIG 250
#endif
/* Follows system specific switches. If you run on a /* Follows system specific switches. If you run on a
new system, you may want to edit these. new system, you may want to edit these.
May replace this with Autoconf one day. May replace this with Autoconf one day.
...@@ -144,10 +124,16 @@ HAVE_SOCKADDR_SA_LEN ...@@ -144,10 +124,16 @@ HAVE_SOCKADDR_SA_LEN
define this if struct sockaddr has sa_len field (*BSD) define this if struct sockaddr has sa_len field (*BSD)
HAVE_DBUS HAVE_DBUS
Define this if you want to link against libdbus, and have dnsmasq define this if you want to link against libdbus, and have dnsmasq
define some methods to allow (re)configuration of the upstream DNS support some methods to allow (re)configuration of the upstream DNS
servers via DBus. servers via DBus.
HAVE_IDN
define this if you want international domain name support.
NOTE: for backwards compatibility, IDN support is automatically
included when internationalisation support is built, using the
*-i18n makefile targets, even if HAVE_IDN is not explicitly set.
NOTES: NOTES:
For Linux you should define For Linux you should define
HAVE_LINUX_NETWORK HAVE_LINUX_NETWORK
...@@ -172,6 +158,7 @@ NOTES: ...@@ -172,6 +158,7 @@ NOTES:
#define HAVE_SCRIPT #define HAVE_SCRIPT
/* #define HAVE_BROKEN_RTC */ /* #define HAVE_BROKEN_RTC */
/* #define HAVE_DBUS */ /* #define HAVE_DBUS */
/* #define HAVE_IDN */
/* Allow TFTP to be disabled with COPTS=-DNO_TFTP */ /* Allow TFTP to be disabled with COPTS=-DNO_TFTP */
#ifdef NO_TFTP #ifdef NO_TFTP
......
/* dnsmasq is Copyright (c) 2000-2011 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
the Free Software Foundation; version 2 dated June, 1991, or
(at your option) version 3 dated 29 June, 2007.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define BOOTREQUEST 1
#define BOOTREPLY 2
#define DHCP_COOKIE 0x63825363
/* The Linux in-kernel DHCP client silently ignores any packet
smaller than this. Sigh........... */
#define MIN_PACKETSZ 300
#define OPTION_PAD 0
#define OPTION_NETMASK 1
#define OPTION_ROUTER 3
#define OPTION_DNSSERVER 6
#define OPTION_HOSTNAME 12
#define OPTION_DOMAINNAME 15
#define OPTION_BROADCAST 28
#define OPTION_VENDOR_CLASS_OPT 43
#define OPTION_REQUESTED_IP 50
#define OPTION_LEASE_TIME 51
#define OPTION_OVERLOAD 52
#define OPTION_MESSAGE_TYPE 53
#define OPTION_SERVER_IDENTIFIER 54
#define OPTION_REQUESTED_OPTIONS 55
#define OPTION_MESSAGE 56
#define OPTION_MAXMESSAGE 57
#define OPTION_T1 58
#define OPTION_T2 59
#define OPTION_VENDOR_ID 60
#define OPTION_CLIENT_ID 61
#define OPTION_SNAME 66
#define OPTION_FILENAME 67
#define OPTION_USER_CLASS 77
#define OPTION_CLIENT_FQDN 81
#define OPTION_AGENT_ID 82
#define OPTION_ARCH 93
#define OPTION_PXE_UUID 97
#define OPTION_SUBNET_SELECT 118
#define OPTION_DOMAIN_SEARCH 119
#define OPTION_SIP_SERVER 120
#define OPTION_VENDOR_IDENT 124
#define OPTION_VENDOR_IDENT_OPT 125
#define OPTION_END 255
#define SUBOPT_CIRCUIT_ID 1
#define SUBOPT_REMOTE_ID 2
#define SUBOPT_SUBNET_SELECT 5 /* RFC 3527 */
#define SUBOPT_SUBSCR_ID 6 /* RFC 3393 */
#define SUBOPT_SERVER_OR 11 /* RFC 5107 */
#define SUBOPT_PXE_BOOT_ITEM 71 /* PXE standard */
#define SUBOPT_PXE_DISCOVERY 6
#define SUBOPT_PXE_SERVERS 8
#define SUBOPT_PXE_MENU 9
#define SUBOPT_PXE_MENU_PROMPT 10
#define DHCPDISCOVER 1
#define DHCPOFFER 2
#define DHCPREQUEST 3
#define DHCPDECLINE 4
#define DHCPACK 5
#define DHCPNAK 6
#define DHCPRELEASE 7
#define DHCPINFORM 8
#define BRDBAND_FORUM_IANA 3561 /* Broadband forum IANA enterprise */
#define DHCP_CHADDR_MAX 16
struct dhcp_packet {
u8 op, htype, hlen, hops;
u32 xid;
u16 secs, flags;
struct in_addr ciaddr, yiaddr, siaddr, giaddr;
u8 chaddr[DHCP_CHADDR_MAX], sname[64], file[128];
u8 options[312];
};
/* dnsmasq is Copyright (c) 2000-2011 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
the Free Software Foundation; version 2 dated June, 1991, or
(at your option) version 3 dated 29 June, 2007.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define IN6ADDRSZ 16
#define INADDRSZ 4
#define PACKETSZ 512 /* maximum packet size */
#define MAXDNAME 1025 /* maximum presentation domain name */
#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
#define MAXLABEL 63 /* maximum length of domain label */
#define NOERROR 0 /* no error */
#define FORMERR 1 /* format error */
#define SERVFAIL 2 /* server failure */
#define NXDOMAIN 3 /* non existent domain */
#define NOTIMP 4 /* not implemented */
#define REFUSED 5 /* query refused */
#define QUERY 0 /* opcode */
#define C_IN 1 /* the arpa internet */
#define C_CHAOS 3 /* for chaos net (MIT) */
#define C_ANY 255 /* wildcard match */
#define T_A 1
#define T_NS 2
#define T_CNAME 5
#define T_SOA 6
#define T_PTR 12
#define T_MX 15
#define T_TXT 16
#define T_SIG 24
#define T_AAAA 28
#define T_SRV 33
#define T_NAPTR 35
#define T_OPT 41
#define T_TKEY 249
#define T_TSIG 250
#define T_MAILB 253
#define T_ANY 255
struct dns_header {
u16 id;
u8 hb3,hb4;
u16 qdcount,ancount,nscount,arcount;
} ;
#define HB3_QR 0x80
#define HB3_OPCODE 0x78
#define HB3_AA 0x04
#define HB3_TC 0x02
#define HB3_RD 0x01
#define HB4_RA 0x80
#define HB4_AD 0x20
#define HB4_CD 0x10
#define HB4_RCODE 0x0f
#define OPCODE(x) (((x)->hb3 & HB3_OPCODE) >> 3)
#define RCODE(x) ((x)->hb4 & HB4_RCODE)
#define SET_RCODE(x, code) (x)->hb4 = ((x)->hb4 & ~HB4_RCODE) | code
#define GETSHORT(s, cp) { \
unsigned char *t_cp = (unsigned char *)(cp); \
(s) = ((u16)t_cp[0] << 8) \
| ((u16)t_cp[1]) \
; \
(cp) += 2; \
}
#define GETLONG(l, cp) { \
unsigned char *t_cp = (unsigned char *)(cp); \
(l) = ((u32)t_cp[0] << 24) \
| ((u32)t_cp[1] << 16) \
| ((u32)t_cp[2] << 8) \
| ((u32)t_cp[3]) \
; \
(cp) += 4; \
}
#define PUTSHORT(s, cp) { \
u16 t_s = (u16)(s); \
unsigned char *t_cp = (unsigned char *)(cp); \
*t_cp++ = t_s >> 8; \
*t_cp = t_s; \
(cp) += 2; \
}
#define PUTLONG(l, cp) { \
u32 t_l = (u32)(l); \
unsigned char *t_cp = (unsigned char *)(cp); \
*t_cp++ = t_l >> 24; \
*t_cp++ = t_l >> 16; \
*t_cp++ = t_l >> 8; \
*t_cp = t_l; \
(cp) += 4; \
}
...@@ -51,8 +51,11 @@ static char *compile_opts = ...@@ -51,8 +51,11 @@ static char *compile_opts =
#ifndef HAVE_TFTP #ifndef HAVE_TFTP
"no-" "no-"
#endif #endif
"TFTP"; "TFTP "
#if !defined(LOCALEDIR) && !defined(HAVE_IDN)
"no-"
#endif
"IDN";
static volatile pid_t pid = 0; static volatile pid_t pid = 0;
...@@ -150,6 +153,11 @@ int main (int argc, char **argv) ...@@ -150,6 +153,11 @@ int main (int argc, char **argv)
die(_("asychronous logging is not available under Solaris"), NULL, EC_BADCONF); die(_("asychronous logging is not available under Solaris"), NULL, EC_BADCONF);
#endif #endif
#ifdef __ANDROID__
if (daemon->max_logs != 0)
die(_("asychronous logging is not available under Android"), NULL, EC_BADCONF);
#endif
rand_init(); rand_init();
now = dnsmasq_time(); now = dnsmasq_time();
...@@ -384,7 +392,7 @@ int main (int argc, char **argv) ...@@ -384,7 +392,7 @@ int main (int argc, char **argv)
(1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW) | (1 << CAP_SETUID); (1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW) | (1 << CAP_SETUID);
/* Tell kernel to not clear capabilities when dropping root */ /* Tell kernel to not clear capabilities when dropping root */
if (capset(hdr, data) == -1 || prctl(PR_SET_KEEPCAPS, 1) == -1) if (capset(hdr, data) == -1 || prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) == -1)
bad_capabilities = errno; bad_capabilities = errno;
#elif defined(HAVE_SOLARIS_NETWORK) #elif defined(HAVE_SOLARIS_NETWORK)
...@@ -440,7 +448,7 @@ int main (int argc, char **argv) ...@@ -440,7 +448,7 @@ int main (int argc, char **argv)
#ifdef HAVE_LINUX_NETWORK #ifdef HAVE_LINUX_NETWORK
if (option_bool(OPT_DEBUG)) if (option_bool(OPT_DEBUG))
prctl(PR_SET_DUMPABLE, 1); prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
#endif #endif
if (daemon->port == 0) if (daemon->port == 0)
......
...@@ -24,7 +24,9 @@ ...@@ -24,7 +24,9 @@
/* Get linux C library versions and define _GNU_SOURCE for kFreeBSD. */ /* Get linux C library versions and define _GNU_SOURCE for kFreeBSD. */
#if defined(__linux__) || defined(__GLIBC__) #if defined(__linux__) || defined(__GLIBC__)
# define _GNU_SOURCE # ifndef __ANDROID__
# define _GNU_SOURCE
# endif
# include <features.h> # include <features.h>
#endif #endif
...@@ -39,18 +41,18 @@ ...@@ -39,18 +41,18 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#ifdef __APPLE__
# include <nameser.h>
# include <arpa/nameser_compat.h>
#else
# include <arpa/nameser.h>
#endif
/* and this. */ /* and this. */
#include <getopt.h> #include <getopt.h>
#include "config.h" #include "config.h"
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
#include "dns_protocol.h"
#include "dhcp_protocol.h"
#define gettext_noop(S) (S) #define gettext_noop(S) (S)
#ifndef LOCALEDIR #ifndef LOCALEDIR
# define _(S) (S) # define _(S) (S)
...@@ -89,7 +91,7 @@ ...@@ -89,7 +91,7 @@
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>
#include <stdarg.h> #include <stdarg.h>
#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__sun__) || defined (__sun) #if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__sun__) || defined (__sun) || defined (__ANDROID__)
# include <netinet/if_ether.h> # include <netinet/if_ether.h>
#else #else
# include <net/ethernet.h> # include <net/ethernet.h>
...@@ -163,7 +165,7 @@ struct event_desc { ...@@ -163,7 +165,7 @@ struct event_desc {
*/ */
#define DNSMASQ_PACKETSZ PACKETSZ+MAXDNAME+RRFIXEDSZ #define DNSMASQ_PACKETSZ PACKETSZ+MAXDNAME+RRFIXEDSZ
/* Trust the compiler dead-code elimator.... */ /* 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)))
#define OPT_BOGUSPRIV 0 #define OPT_BOGUSPRIV 0
...@@ -422,8 +424,6 @@ struct frec { ...@@ -422,8 +424,6 @@ struct frec {
#define ACTION_OLD 3 #define ACTION_OLD 3
#define ACTION_ADD 4 #define ACTION_ADD 4
#define DHCP_CHADDR_MAX 16
struct dhcp_lease { struct dhcp_lease {
int clid_len; /* length of client identifier */ int clid_len; /* length of client identifier */
unsigned char *clid; /* clientid */ unsigned char *clid; /* clientid */
...@@ -582,21 +582,6 @@ struct dhcp_context { ...@@ -582,21 +582,6 @@ struct dhcp_context {
#define CONTEXT_BRDCAST 4 #define CONTEXT_BRDCAST 4
#define CONTEXT_PROXY 8 #define CONTEXT_PROXY 8
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
struct dhcp_packet {
u8 op, htype, hlen, hops;
u32 xid;
u16 secs, flags;
struct in_addr ciaddr, yiaddr, siaddr, giaddr;
u8 chaddr[DHCP_CHADDR_MAX], sname[64], file[128];
u8 options[312];
};
struct ping_result { struct ping_result {
struct in_addr addr; struct in_addr addr;
time_t time; time_t time;
...@@ -763,24 +748,24 @@ char *cache_get_name(struct crec *crecp); ...@@ -763,24 +748,24 @@ char *cache_get_name(struct crec *crecp);
char *get_domain(struct in_addr addr); char *get_domain(struct in_addr addr);
/* rfc1035.c */ /* rfc1035.c */
unsigned int extract_request(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(HEADER *header, size_t qlen, size_t setup_reply(struct dns_header *header, size_t qlen,
struct all_addr *addrp, unsigned int flags, struct all_addr *addrp, unsigned int flags,
unsigned long local_ttl); unsigned long local_ttl);
int extract_addresses(HEADER *header, size_t qlen, char *namebuff, 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, int is_sign, int checkrebind, int checking_disabled);
size_t answer_request(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 check_for_bogus_wildcard(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(HEADER *header, size_t plen, unsigned char *find_pseudoheader(struct dns_header *header, size_t plen,
size_t *len, unsigned char **p, int *is_sign); 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(HEADER *header, size_t plen, char *buff); unsigned int questions_crc(struct dns_header *header, size_t plen, char *buff);
size_t resize_packet(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(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);
/* util.c */ /* util.c */
void rand_init(void); void rand_init(void);
......
This diff is collapsed.
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
#include "dnsmasq.h" #include "dnsmasq.h"
#ifdef __ANDROID__
# include <android/log.h>
#endif
/* Implement logging to /dev/log asynchronously. If syslogd is /* Implement logging to /dev/log asynchronously. If syslogd is
making DNS lookups through dnsmasq, and dnsmasq blocks awaiting making DNS lookups through dnsmasq, and dnsmasq blocks awaiting
syslogd, then the two daemons can deadlock. We get around this syslogd, then the two daemons can deadlock. We get around this
...@@ -117,7 +121,7 @@ int log_reopen(char *log_file) ...@@ -117,7 +121,7 @@ int log_reopen(char *log_file)
log_fd = open(log_file, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP); log_fd = open(log_file, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP);
else else
{ {
#ifdef HAVE_SOLARIS_NETWORK #if defined(HAVE_SOLARIS_NETWORK) || defined(__ANDROID__)
/* Solaris logging is "different", /dev/log is not unix-domain socket. /* Solaris logging is "different", /dev/log is not unix-domain socket.
Just leave log_fd == -1 and use the vsyslog call for everything.... */ Just leave log_fd == -1 and use the vsyslog call for everything.... */
# define _PATH_LOG "" /* dummy */ # define _PATH_LOG "" /* dummy */
...@@ -289,8 +293,28 @@ void my_syslog(int priority, const char *format, ...) ...@@ -289,8 +293,28 @@ void my_syslog(int priority, const char *format, ...)
if (log_fd == -1) if (log_fd == -1)
{ {
/* fall-back to syslog if we die during startup or fail during running. */ #ifdef __ANDROID__
/* do android-specific logging.
log_fd is always -1 on Android except when logging to a file. */
int alog_lvl;
if (priority <= LOG_ERR)
alog_lvl = ANDROID_LOG_ERROR;
else if (priority == LOG_WARNING)
alog_lvl = ANDROID_LOG_WARN;
else if (priority <= LOG_INFO)
alog_lvl = ANDROID_LOG_INFO;
else
alog_lvl = ANDROID_LOG_DEBUG;
va_start(ap, format);
__android_log_vprint(alog_lvl, "dnsmasq", format, ap);
va_end(ap);
#else
/* fall-back to syslog if we die during startup or
fail during running (always on Solaris). */
static int isopen = 0; static int isopen = 0;
if (!isopen) if (!isopen)
{ {
openlog("dnsmasq", LOG_PID, log_fac); openlog("dnsmasq", LOG_PID, log_fac);
...@@ -299,6 +323,8 @@ void my_syslog(int priority, const char *format, ...) ...@@ -299,6 +323,8 @@ void my_syslog(int priority, const char *format, ...)
va_start(ap, format); va_start(ap, format);
vsyslog(priority, format, ap); vsyslog(priority, format, ap);
va_end(ap); va_end(ap);
#endif
return; return;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment