Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
Dnsmasq
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Dnsmasq
Commits
c5ad4e79
Commit
c5ad4e79
authored
Feb 24, 2012
by
Simon Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Router Advertisement
parent
270dc2e1
Changes
15
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
758 additions
and
121 deletions
+758
-121
Makefile
Makefile
+4
-2
bld/Android.mk
bld/Android.mk
+2
-1
man/dnsmasq.8
man/dnsmasq.8
+28
-2
src/bpf.c
src/bpf.c
+2
-1
src/dhcp-common.c
src/dhcp-common.c
+3
-3
src/dhcp6.c
src/dhcp6.c
+14
-6
src/dnsmasq.c
src/dnsmasq.c
+40
-4
src/dnsmasq.h
src/dnsmasq.h
+29
-3
src/lease.c
src/lease.c
+9
-1
src/netlink.c
src/netlink.c
+12
-1
src/option.c
src/option.c
+20
-2
src/outpacket.c
src/outpacket.c
+108
-0
src/radv.c
src/radv.c
+433
-0
src/radv_protocol.h
src/radv_protocol.h
+44
-0
src/rfc3315.c
src/rfc3315.c
+10
-95
No files found.
Makefile
View file @
c5ad4e79
...
@@ -47,9 +47,11 @@ VERSION= -DVERSION='\"`../bld/get-version`\"'
...
@@ -47,9 +47,11 @@ VERSION= -DVERSION='\"`../bld/get-version`\"'
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
\
dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o
\
dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o
\
helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o dhcp-common.o
helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o
\
dhcp-common.o outpacket.o radv.o
HDRS
=
dnsmasq.h config.h dhcp_protocol.h dhcp6_protocol.h dns_protocol.h
HDRS
=
dnsmasq.h config.h dhcp_protocol.h dhcp6_protocol.h
\
dns_protocol.h radv_protocol.h
all
:
$(BUILDDIR)
all
:
$(BUILDDIR)
...
...
bld/Android.mk
View file @
c5ad4e79
...
@@ -7,7 +7,8 @@ LOCAL_SRC_FILES := bpf.c cache.c dbus.c dhcp.c dnsmasq.c \
...
@@ -7,7 +7,8 @@ LOCAL_SRC_FILES := bpf.c cache.c dbus.c dhcp.c dnsmasq.c \
forward.c helper.c lease.c log.c
\
forward.c helper.c lease.c log.c
\
netlink.c network.c option.c rfc1035.c
\
netlink.c network.c option.c rfc1035.c
\
rfc2131.c tftp.c util.c conntrack.c
\
rfc2131.c tftp.c util.c conntrack.c
\
dhcp6.c rfc3315.c dhcp-common.c
dhcp6.c rfc3315.c dhcp-common.c outpacket.c
\
radv.c
LOCAL_MODULE
:=
dnsmasq
LOCAL_MODULE
:=
dnsmasq
...
...
man/dnsmasq.8
View file @
c5ad4e79
...
@@ -529,14 +529,18 @@ The optional
...
@@ -529,14 +529,18 @@ The optional
sets an alphanumeric label which marks this network so that
sets an alphanumeric label which marks this network so that
dhcp options may be specified on a per-network basis.
dhcp options may be specified on a per-network basis.
When it is prefixed with 'tag:' instead, then its meaning changes from setting
When it is prefixed with 'tag:' instead, then its meaning changes from setting
a tag to matching it. Only one tag may be set, but more than one tag may be matched.
a tag to matching it. Only one tag may be set, but more than one tag
may be matched.
The end address may be replaced by the keyword
The end address may be replaced by the keyword
.B static
.B static
which tells dnsmasq to enable DHCP for the network specified, but not
which tells dnsmasq to enable DHCP for the network specified, but not
to dynamically allocate IP addresses: only hosts which have static
to dynamically allocate IP addresses: only hosts which have static
addresses given via
addresses given via
.B dhcp-host
.B dhcp-host
or from /etc/ethers will be served. The end address may be replaced by
or from /etc/ethers will be served.
The end address may be replaced by
the keyword
the keyword
.B proxy
.B proxy
in which case dnsmasq will provide proxy-DHCP on the specified
in which case dnsmasq will provide proxy-DHCP on the specified
...
@@ -546,6 +550,14 @@ and
...
@@ -546,6 +550,14 @@ and
.B pxe-service
.B pxe-service
for details, applies to IPv4 only.)
for details, applies to IPv4 only.)
The end address may be replaced by
the keyword
.B ra-only
which tells dnsmasq to offer Router Advertisement only on this subnet,
and not DHCP. This applies to IPv6 only, see
.B enable-ra
for details.
The interface:<interface name> section is not normally used. See the
The interface:<interface name> section is not normally used. See the
NOTES section for details of this.
NOTES section for details of this.
.TP
.TP
...
@@ -1234,6 +1246,20 @@ added into dnsmasq's DNS view. This flag suppresses that behaviour,
...
@@ -1234,6 +1246,20 @@ added into dnsmasq's DNS view. This flag suppresses that behaviour,
this is useful, for instance, to allow Windows clients to update
this is useful, for instance, to allow Windows clients to update
Active Directory servers. See RFC 4702 for details.
Active Directory servers. See RFC 4702 for details.
.TP
.TP
.B --enable-ra
Enable dnsmasq's IPv6 Router Advertisement feature. DHCPv6 doesn't
handle complete network configuration in the same way as DHCPv4. Router
discovery and (possibly) prefix discovery for autonomous address
creation are handled by a different protocol. When DHCP is in use,
only a subset of this is needed, and dnsmasq can handle it, using
existing DHCP configuration to provide most data. When RA is enabled,
dnsmasq will advertise a prefix for each dhcp-range, with default
router and recursive DNS server as the relevant link-local address on
the machine running dnsmasq. The "managed address" bits are set,
except for a dhcp-range which is marked as "ra-only". In which case RA
is provided by no DHCPv6 service and the managed address bits are
cleared.
.TP
.B --enable-tftp[=<interface>]
.B --enable-tftp[=<interface>]
Enable the TFTP server function. This is deliberately limited to that
Enable the TFTP server function. This is deliberately limited to that
needed to net-boot a client. Only reading is allowed; the tsize and
needed to net-boot a client. Only reading is allowed; the tsize and
...
...
src/bpf.c
View file @
c5ad4e79
...
@@ -199,7 +199,8 @@ int iface_enumerate(int family, void *parm, int (*callback)())
...
@@ -199,7 +199,8 @@ int iface_enumerate(int family, void *parm, int (*callback)())
{
{
/* Assume ethernet again here */
/* Assume ethernet again here */
struct
sockaddr_dl
*
sdl
=
(
struct
sockaddr_dl
*
)
&
ifr
->
ifr_addr
;
struct
sockaddr_dl
*
sdl
=
(
struct
sockaddr_dl
*
)
&
ifr
->
ifr_addr
;
if
(
sdl
->
sdl_alen
!=
0
&&
!
((
*
callback
)(
ARPHRD_ETHER
,
LLADDR
(
sdl
),
sdl
->
sdl_alen
,
parm
)))
if
(
sdl
->
sdl_alen
!=
0
&&
!
((
*
callback
)((
int
)
if_nametoindex
(
ifr
->
ifr_name
),
ARPHRD_ETHER
,
LLADDR
(
sdl
),
sdl
->
sdl_alen
,
parm
)))
goto
err
;
goto
err
;
}
}
#endif
#endif
...
...
src/dhcp-common.c
View file @
c5ad4e79
...
@@ -53,14 +53,14 @@ ssize_t recv_dhcp_packet(int fd, struct msghdr *msg)
...
@@ -53,14 +53,14 @@ ssize_t recv_dhcp_packet(int fd, struct msghdr *msg)
/* Very new Linux kernels return the actual size needed,
/* Very new Linux kernels return the actual size needed,
older ones always return truncated size */
older ones always return truncated size */
if
((
size_t
)
sz
==
daemon
->
dhcp_packet
.
iov_len
)
if
((
size_t
)
sz
==
msg
->
msg_iov
->
iov_len
)
{
{
if
(
!
expand_buf
(
&
daemon
->
dhcp_packet
,
sz
+
100
))
if
(
!
expand_buf
(
msg
->
msg_iov
,
sz
+
100
))
return
-
1
;
return
-
1
;
}
}
else
else
{
{
expand_buf
(
&
daemon
->
dhcp_packet
,
sz
);
expand_buf
(
msg
->
msg_iov
,
sz
);
break
;
break
;
}
}
}
}
...
...
src/dhcp6.c
View file @
c5ad4e79
...
@@ -35,7 +35,7 @@ static int join_multicast(struct in6_addr *local, int prefix,
...
@@ -35,7 +35,7 @@ static int join_multicast(struct in6_addr *local, int prefix,
static
int
complete_context6
(
struct
in6_addr
*
local
,
int
prefix
,
static
int
complete_context6
(
struct
in6_addr
*
local
,
int
prefix
,
int
scope
,
int
if_index
,
int
dad
,
void
*
vparam
);
int
scope
,
int
if_index
,
int
dad
,
void
*
vparam
);
static
int
make_duid1
(
unsigned
int
type
,
char
*
mac
,
size_t
maclen
,
void
*
parm
);
static
int
make_duid1
(
int
index
,
unsigned
int
type
,
char
*
mac
,
size_t
maclen
,
void
*
parm
);
void
dhcp6_init
(
void
)
void
dhcp6_init
(
void
)
{
{
...
@@ -101,6 +101,13 @@ static int join_multicast(struct in6_addr *local, int prefix,
...
@@ -101,6 +101,13 @@ static int join_multicast(struct in6_addr *local, int prefix,
if
(
if_index
==
listenp
->
fd_or_iface
)
if
(
if_index
==
listenp
->
fd_or_iface
)
return
1
;
return
1
;
mreq
.
ipv6mr_interface
=
if_index
;
inet_pton
(
AF_INET6
,
ALL_ROUTERS
,
&
mreq
.
ipv6mr_multiaddr
);
if
(
daemon
->
icmp6fd
!=
-
1
&&
setsockopt
(
daemon
->
icmp6fd
,
IPPROTO_IPV6
,
IPV6_JOIN_GROUP
,
&
mreq
,
sizeof
(
mreq
))
==
-
1
)
return
0
;
if
(
!
indextoname
(
fd
,
if_index
,
ifrn_name
))
if
(
!
indextoname
(
fd
,
if_index
,
ifrn_name
))
return
0
;
return
0
;
...
@@ -120,7 +127,6 @@ static int join_multicast(struct in6_addr *local, int prefix,
...
@@ -120,7 +127,6 @@ static int join_multicast(struct in6_addr *local, int prefix,
if
(
!
context
)
if
(
!
context
)
return
1
;
return
1
;
mreq
.
ipv6mr_interface
=
if_index
;
inet_pton
(
AF_INET6
,
ALL_RELAY_AGENTS_AND_SERVERS
,
&
mreq
.
ipv6mr_multiaddr
);
inet_pton
(
AF_INET6
,
ALL_RELAY_AGENTS_AND_SERVERS
,
&
mreq
.
ipv6mr_multiaddr
);
if
(
setsockopt
(
fd
,
IPPROTO_IPV6
,
IPV6_JOIN_GROUP
,
&
mreq
,
sizeof
(
mreq
))
==
-
1
)
if
(
setsockopt
(
fd
,
IPPROTO_IPV6
,
IPV6_JOIN_GROUP
,
&
mreq
,
sizeof
(
mreq
))
==
-
1
)
...
@@ -151,7 +157,7 @@ void dhcp6_packet(time_t now)
...
@@ -151,7 +157,7 @@ void dhcp6_packet(time_t now)
struct
cmsghdr
align
;
/* this ensures alignment */
struct
cmsghdr
align
;
/* this ensures alignment */
char
control6
[
CMSG_SPACE
(
sizeof
(
struct
in6_pktinfo
))];
char
control6
[
CMSG_SPACE
(
sizeof
(
struct
in6_pktinfo
))];
}
control_u
;
}
control_u
;
union
mysockaddr
from
;
struct
sockaddr_in6
from
;
struct
all_addr
dest
;
struct
all_addr
dest
;
ssize_t
sz
;
ssize_t
sz
;
struct
ifreq
ifr
;
struct
ifreq
ifr
;
...
@@ -215,8 +221,8 @@ void dhcp6_packet(time_t now)
...
@@ -215,8 +221,8 @@ void dhcp6_packet(time_t now)
lease_prune
(
NULL
,
now
);
/* lose any expired leases */
lease_prune
(
NULL
,
now
);
/* lose any expired leases */
msg
.
msg_iov
=
&
daemon
->
dhcp_packet
;
sz
=
dhcp6_reply
(
parm
.
current
,
if_index
,
ifr
.
ifr_name
,
&
parm
.
fallback
,
sz
=
dhcp6_reply
(
parm
.
current
,
if_index
,
ifr
.
ifr_name
,
&
parm
.
fallback
,
sz
,
IN6_IS_ADDR_MULTICAST
(
&
from
.
in6
.
sin6_addr
),
now
);
sz
,
IN6_IS_ADDR_MULTICAST
(
&
from
.
sin6_addr
),
now
);
lease_update_file
(
now
);
lease_update_file
(
now
);
lease_update_dns
();
lease_update_dns
();
...
@@ -455,13 +461,15 @@ void make_duid(time_t now)
...
@@ -455,13 +461,15 @@ void make_duid(time_t now)
die
(
"Cannot create DHCPv6 server DUID: %s"
,
NULL
,
EC_MISC
);
die
(
"Cannot create DHCPv6 server DUID: %s"
,
NULL
,
EC_MISC
);
}
}
static
int
make_duid1
(
unsigned
int
type
,
char
*
mac
,
size_t
maclen
,
void
*
parm
)
static
int
make_duid1
(
int
index
,
unsigned
int
type
,
char
*
mac
,
size_t
maclen
,
void
*
parm
)
{
{
/* create DUID as specified in RFC3315. We use the MAC of the
/* create DUID as specified in RFC3315. We use the MAC of the
first interface we find that isn't loopback or P-to-P */
first interface we find that isn't loopback or P-to-P */
unsigned
char
*
p
;
unsigned
char
*
p
;
(
void
)
index
;
daemon
->
duid
=
p
=
safe_malloc
(
maclen
+
8
);
daemon
->
duid
=
p
=
safe_malloc
(
maclen
+
8
);
daemon
->
duid_len
=
maclen
+
8
;
daemon
->
duid_len
=
maclen
+
8
;
...
...
src/dnsmasq.c
View file @
c5ad4e79
...
@@ -157,8 +157,14 @@ int main (int argc, char **argv)
...
@@ -157,8 +157,14 @@ int main (int argc, char **argv)
if
(
daemon
->
dhcp
)
if
(
daemon
->
dhcp
)
dhcp_init
();
dhcp_init
();
#ifdef HAVE_DHCP6
#ifdef HAVE_DHCP6
daemon
->
icmp6fd
=
-
1
;
if
(
daemon
->
dhcp6
)
if
(
daemon
->
dhcp6
)
{
/* ra_init before dhcp6_init, so dhcp6_init can setup multicast listening */
if
(
option_bool
(
OPT_RA
))
ra_init
(
now
);
dhcp6_init
();
dhcp6_init
();
}
#endif
#endif
}
}
#endif
#endif
...
@@ -496,6 +502,9 @@ int main (int argc, char **argv)
...
@@ -496,6 +502,9 @@ int main (int argc, char **argv)
if
(
daemon
->
max_logs
!=
0
)
if
(
daemon
->
max_logs
!=
0
)
my_syslog
(
LOG_INFO
,
_
(
"asynchronous logging enabled, queue limit is %d messages"
),
daemon
->
max_logs
);
my_syslog
(
LOG_INFO
,
_
(
"asynchronous logging enabled, queue limit is %d messages"
),
daemon
->
max_logs
);
if
(
option_bool
(
OPT_RA
))
my_syslog
(
MS_DHCP
|
LOG_INFO
,
_
(
"IPv6 router advertisement enabled"
));
#ifdef HAVE_DHCP
#ifdef HAVE_DHCP
if
(
daemon
->
dhcp
||
daemon
->
dhcp6
)
if
(
daemon
->
dhcp
||
daemon
->
dhcp6
)
{
{
...
@@ -525,6 +534,8 @@ int main (int argc, char **argv)
...
@@ -525,6 +534,8 @@ int main (int argc, char **argv)
my_syslog
(
MS_DHCP
|
LOG_INFO
,
my_syslog
(
MS_DHCP
|
LOG_INFO
,
(
dhcp_tmp
->
flags
&
CONTEXT_STATIC
)
?
(
dhcp_tmp
->
flags
&
CONTEXT_STATIC
)
?
_
(
"DHCP, static leases only on %.0s%s, lease time %s"
)
:
_
(
"DHCP, static leases only on %.0s%s, lease time %s"
)
:
(
dhcp_tmp
->
flags
&
CONTEXT_RA_ONLY
)
?
_
(
"router advertisement only on %.0s%s, lifetime %s"
)
:
(
dhcp_tmp
->
flags
&
CONTEXT_PROXY
)
?
(
dhcp_tmp
->
flags
&
CONTEXT_PROXY
)
?
_
(
"DHCP, proxy on subnet %.0s%s%.0s"
)
:
_
(
"DHCP, proxy on subnet %.0s%s%.0s"
)
:
_
(
"DHCP, IP range %s -- %s, lease time %s"
),
_
(
"DHCP, IP range %s -- %s, lease time %s"
),
...
@@ -535,6 +546,9 @@ int main (int argc, char **argv)
...
@@ -535,6 +546,9 @@ int main (int argc, char **argv)
if
(
family
==
AF_INET
)
if
(
family
==
AF_INET
)
{
{
family
=
AF_INET6
;
family
=
AF_INET6
;
if
(
daemon
->
ra_contexts
)
dhcp_tmp
=
daemon
->
ra_contexts
;
else
dhcp_tmp
=
daemon
->
dhcp6
;
dhcp_tmp
=
daemon
->
dhcp6
;
goto
again
;
goto
again
;
}
}
...
@@ -653,6 +667,12 @@ int main (int argc, char **argv)
...
@@ -653,6 +667,12 @@ int main (int argc, char **argv)
{
{
FD_SET
(
daemon
->
dhcp6fd
,
&
rset
);
FD_SET
(
daemon
->
dhcp6fd
,
&
rset
);
bump_maxfd
(
daemon
->
dhcp6fd
,
&
maxfd
);
bump_maxfd
(
daemon
->
dhcp6fd
,
&
maxfd
);
if
(
daemon
->
icmp6fd
!=
-
1
)
{
FD_SET
(
daemon
->
icmp6fd
,
&
rset
);
bump_maxfd
(
daemon
->
icmp6fd
,
&
maxfd
);
}
}
}
#endif
#endif
...
@@ -756,6 +776,9 @@ int main (int argc, char **argv)
...
@@ -756,6 +776,9 @@ int main (int argc, char **argv)
{
{
if
(
FD_ISSET
(
daemon
->
dhcp6fd
,
&
rset
))
if
(
FD_ISSET
(
daemon
->
dhcp6fd
,
&
rset
))
dhcp6_packet
(
now
);
dhcp6_packet
(
now
);
if
(
daemon
->
icmp6fd
!=
-
1
&&
FD_ISSET
(
daemon
->
icmp6fd
,
&
rset
))
icmp6_packet
();
}
}
#endif
#endif
...
@@ -1373,6 +1396,14 @@ int icmp_ping(struct in_addr addr)
...
@@ -1373,6 +1396,14 @@ int icmp_ping(struct in_addr addr)
set_dns_listeners
(
now
,
&
rset
,
&
maxfd
);
set_dns_listeners
(
now
,
&
rset
,
&
maxfd
);
set_log_writer
(
&
wset
,
&
maxfd
);
set_log_writer
(
&
wset
,
&
maxfd
);
#ifdef HAVE_DHCP6
if
(
daemon
->
icmp6fd
!=
-
1
)
{
FD_SET
(
daemon
->
icmp6fd
,
&
rset
);
bump_maxfd
(
daemon
->
icmp6fd
,
&
maxfd
);
}
#endif
if
(
select
(
maxfd
+
1
,
&
rset
,
&
wset
,
NULL
,
&
tv
)
<
0
)
if
(
select
(
maxfd
+
1
,
&
rset
,
&
wset
,
NULL
,
&
tv
)
<
0
)
{
{
FD_ZERO
(
&
rset
);
FD_ZERO
(
&
rset
);
...
@@ -1384,6 +1415,11 @@ int icmp_ping(struct in_addr addr)
...
@@ -1384,6 +1415,11 @@ int icmp_ping(struct in_addr addr)
check_log_writer
(
&
wset
);
check_log_writer
(
&
wset
);
check_dns_listeners
(
&
rset
,
now
);
check_dns_listeners
(
&
rset
,
now
);
#ifdef HAVE_DHCP6
if
(
daemon
->
icmp6fd
!=
-
1
&&
FD_ISSET
(
daemon
->
icmp6fd
,
&
rset
))
icmp6_packet
();
#endif
#ifdef HAVE_TFTP
#ifdef HAVE_TFTP
check_tftp_listeners
(
&
rset
,
now
);
check_tftp_listeners
(
&
rset
,
now
);
#endif
#endif
...
...
src/dnsmasq.h
View file @
c5ad4e79
...
@@ -60,6 +60,7 @@ typedef unsigned long long u64;
...
@@ -60,6 +60,7 @@ typedef unsigned long long u64;
#include "dhcp_protocol.h"
#include "dhcp_protocol.h"
#ifdef HAVE_DHCP6
#ifdef HAVE_DHCP6
#include "dhcp6_protocol.h"
#include "dhcp6_protocol.h"
#include "radv_protocol.h"
#endif
#endif
#define gettext_noop(S) (S)
#define gettext_noop(S) (S)
...
@@ -215,7 +216,8 @@ struct event_desc {
...
@@ -215,7 +216,8 @@ struct event_desc {
#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
#define OPT_LAST 37
#define OPT_RA 37
#define OPT_LAST 38
/* 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. */
...
@@ -605,6 +607,7 @@ struct dhcp_context {
...
@@ -605,6 +607,7 @@ 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
;
int
prefix
;
time_t
ra_time
;
#endif
#endif
int
flags
;
int
flags
;
char
*
interface
;
char
*
interface
;
...
@@ -616,6 +619,8 @@ struct dhcp_context {
...
@@ -616,6 +619,8 @@ struct dhcp_context {
#define CONTEXT_NETMASK 2
#define CONTEXT_NETMASK 2
#define CONTEXT_BRDCAST 4
#define CONTEXT_BRDCAST 4
#define CONTEXT_PROXY 8
#define CONTEXT_PROXY 8
#define CONTEXT_RA_ONLY 16
#define CONTEXT_RA_DONE 32
struct
ping_result
{
struct
ping_result
{
struct
in_addr
addr
;
struct
in_addr
addr
;
...
@@ -694,7 +699,7 @@ extern struct daemon {
...
@@ -694,7 +699,7 @@ extern struct daemon {
int
port
,
query_port
,
min_port
;
int
port
,
query_port
,
min_port
;
unsigned
long
local_ttl
,
neg_ttl
,
max_ttl
;
unsigned
long
local_ttl
,
neg_ttl
,
max_ttl
;
struct
hostsfile
*
addn_hosts
;
struct
hostsfile
*
addn_hosts
;
struct
dhcp_context
*
dhcp
,
*
dhcp6
;
struct
dhcp_context
*
dhcp
,
*
dhcp6
,
*
ra_contexts
;
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
;
...
@@ -754,7 +759,7 @@ extern struct daemon {
...
@@ -754,7 +759,7 @@ extern struct daemon {
int
duid_len
;
int
duid_len
;
unsigned
char
*
duid
;
unsigned
char
*
duid
;
struct
iovec
outpacket
;
struct
iovec
outpacket
;
int
dhcp6fd
;
int
dhcp6fd
,
icmp6fd
;
#endif
#endif
/* DBus stuff */
/* DBus stuff */
/* void * here to avoid depending on dbus headers outside dbus.c */
/* void * here to avoid depending on dbus headers outside dbus.c */
...
@@ -1054,3 +1059,24 @@ int match_bytes(struct dhcp_opt *o, unsigned char *p, int len);
...
@@ -1054,3 +1059,24 @@ 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
check_dhcp_hosts
(
int
fatal
);
void
check_dhcp_hosts
(
int
fatal
);
#endif
#endif
/* outpacket.c */
#ifdef HAVE_DHCP6
void
end_opt6
(
int
container
);
int
save_counter
(
int
newval
);
void
*
expand
(
size_t
headroom
);
int
new_opt6
(
int
opt
);
void
*
put_opt6
(
void
*
data
,
size_t
len
);
void
put_opt6_long
(
unsigned
int
val
);
void
put_opt6_short
(
unsigned
int
val
);
void
put_opt6_char
(
unsigned
int
val
);
void
put_opt6_string
(
char
*
s
);
#endif
/* radv.c */
#ifdef HAVE_DHCP6
void
ra_init
(
time_t
now
);
void
icmp6_packet
(
void
);
time_t
periodic_ra
(
time_t
now
);
void
ra_start_unsolicted
(
time_t
now
);
#endif
src/lease.c
View file @
c5ad4e79
...
@@ -313,7 +313,15 @@ void lease_update_file(time_t now)
...
@@ -313,7 +313,15 @@ void lease_update_file(time_t now)
}
}
/* Set alarm for when the first lease expires + slop. */
/* Set alarm for when the first lease expires + slop. */
for
(
next_event
=
0
,
lease
=
leases
;
lease
;
lease
=
lease
->
next
)
next_event
=
0
;
#ifdef HAVE_DHCP6
/* do timed RAs and determine when the next is */
if
(
option_bool
(
OPT_RA
))
next_event
=
periodic_ra
(
now
);
#endif
for
(
lease
=
leases
;
lease
;
lease
=
lease
->
next
)
if
(
lease
->
expires
!=
0
&&
if
(
lease
->
expires
!=
0
&&
(
next_event
==
0
||
difftime
(
next_event
,
lease
->
expires
+
10
)
>
0
.
0
))
(
next_event
==
0
||
difftime
(
next_event
,
lease
->
expires
+
10
)
>
0
.
0
))
next_event
=
lease
->
expires
+
10
;
next_event
=
lease
->
expires
+
10
;
...
...
src/netlink.c
View file @
c5ad4e79
...
@@ -284,7 +284,7 @@ int iface_enumerate(int family, void *parm, int (*callback)())
...
@@ -284,7 +284,7 @@ int iface_enumerate(int family, void *parm, int (*callback)())
}
}
if
(
mac
&&
callback_ok
&&
!
((
link
->
ifi_flags
&
(
IFF_LOOPBACK
|
IFF_POINTOPOINT
)))
&&
if
(
mac
&&
callback_ok
&&
!
((
link
->
ifi_flags
&
(
IFF_LOOPBACK
|
IFF_POINTOPOINT
)))
&&
!
((
*
callback
)((
unsigned
int
)
link
->
ifi_type
,
mac
,
maclen
,
parm
)))
!
((
*
callback
)((
int
)
link
->
ifi_index
,
(
unsigned
int
)
link
->
ifi_type
,
mac
,
maclen
,
parm
)))
callback_ok
=
0
;
callback_ok
=
0
;
}
}
#endif
#endif
...
@@ -341,6 +341,17 @@ static void nl_routechange(struct nlmsghdr *h)
...
@@ -341,6 +341,17 @@ static void nl_routechange(struct nlmsghdr *h)
/* Force re-reading resolv file right now, for luck. */
/* Force re-reading resolv file right now, for luck. */
daemon
->
last_resolv
=
0
;
daemon
->
last_resolv
=
0
;
#ifdef HAVE_DHCP6
/* force RAs to sync new network and pick up new interfaces. */
if
(
option_bool
(
OPT_RA
))
{
ra_start_unsolicted
(
dnsmasq_time
());
/* cause lease_update_file to run after we return, in case we were called from
iface_enumerate and can't re-enter it now */
alarm
(
1
);
}
#endif
if
(
daemon
->
srv_save
)
if
(
daemon
->
srv_save
)
{
{
if
(
daemon
->
srv_save
->
sfd
)
if
(
daemon
->
srv_save
->
sfd
)
...
...
src/option.c
View file @
c5ad4e79
...
@@ -114,6 +114,7 @@ struct myoption {
...
@@ -114,6 +114,7 @@ struct myoption {
#define LOPT_CONNTRACK 303
#define LOPT_CONNTRACK 303
#define LOPT_FQDN 304
#define LOPT_FQDN 304
#define LOPT_LUASCRIPT 305
#define LOPT_LUASCRIPT 305
#define LOPT_RA 306
#ifdef HAVE_GETOPT_LONG
#ifdef HAVE_GETOPT_LONG
static
const
struct
option
opts
[]
=
static
const
struct
option
opts
[]
=
...
@@ -233,6 +234,7 @@ static const struct myoption opts[] =
...
@@ -233,6 +234,7 @@ static const struct myoption opts[] =
{
"conntrack"
,
0
,
0
,
LOPT_CONNTRACK
},
{
"conntrack"
,
0
,
0
,
LOPT_CONNTRACK
},
{
"dhcp-client-update"
,
0
,
0
,
LOPT_FQDN
},
{
"dhcp-client-update"
,
0
,
0
,
LOPT_FQDN
},
{
"dhcp-luascript"
,
1
,
0
,
LOPT_LUASCRIPT
},
{
"dhcp-luascript"
,
1
,
0
,
LOPT_LUASCRIPT
},
{
"enable-ra"
,
0
,
0
,
LOPT_RA
},
{
NULL
,
0
,
0
,
0
}
{
NULL
,
0
,
0
,
0
}
};
};
...
@@ -359,6 +361,7 @@ static struct {
...
@@ -359,6 +361,7 @@ static struct {
{
LOPT_INCR_ADDR
,
OPT_CONSEC_ADDR
,
NULL
,
gettext_noop
(
"Attempt to allocate sequential IP addresses to DHCP clients."
),
NULL
},
{
LOPT_INCR_ADDR
,
OPT_CONSEC_ADDR
,
NULL
,
gettext_noop
(
"Attempt to allocate sequential IP addresses to DHCP clients."
),
NULL
},
{
LOPT_CONNTRACK
,
OPT_CONNTRACK
,
NULL
,
gettext_noop
(
"Copy connection-track mark from queries to upstream connections."
),
NULL
},
{
LOPT_CONNTRACK
,
OPT_CONNTRACK
,
NULL
,
gettext_noop
(
"Copy connection-track mark from queries to upstream connections."
),
NULL
},
{
LOPT_FQDN
,
OPT_FQDN_UPDATE
,
NULL
,
gettext_noop
(
"Allow DHCP clients to do their own DDNS updates."
),
NULL
},
{
LOPT_FQDN
,
OPT_FQDN_UPDATE
,
NULL
,
gettext_noop
(
"Allow DHCP clients to do their own DDNS updates."
),
NULL
},
{
LOPT_RA
,
OPT_RA
,
NULL
,
gettext_noop
(
"Send router-advertisements for interfaces doing DHCPv6"
),
NULL
},
{
0
,
0
,
NULL
,
NULL
,
NULL
}
{
0
,
0
,
NULL
,
NULL
,
NULL
}
};
};
...
@@ -2330,17 +2333,32 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
...
@@ -2330,17 +2333,32 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
#ifdef HAVE_DHCP6
#ifdef HAVE_DHCP6
else
if
(
inet_pton
(
AF_INET6
,
a
[
0
],
&
new
->
start6
))
else
if
(
inet_pton
(
AF_INET6
,
a
[
0
],
&
new
->
start6
))
{
{
new
->
next
=
daemon
->
dhcp6
;
new
->
prefix
=
64
;
/* default */
new
->
prefix
=
64
;
/* default */
daemon
->
dhcp6
=
new
;
if
(
strcmp
(
a
[
1
],
"static"
)
==
0
)
if
(
strcmp
(
a
[
1
],
"static"
)
==
0
)
{
{
memcpy
(
&
new
->
end6
,
&
new
->
start6
,
IN6ADDRSZ
);
memcpy
(
&
new
->
end6
,
&
new
->
start6
,
IN6ADDRSZ
);
new
->
flags
|=
CONTEXT_STATIC
;
new
->
flags
|=
CONTEXT_STATIC
;
}
}
else
if
(
strcmp
(
a
[
1
],
"ra-only"
)
==
0
)
{
memcpy
(
&
new
->
end6
,
&
new
->
start6
,
IN6ADDRSZ
);
new
->
flags
|=
CONTEXT_RA_ONLY
;
}
else
if
(
!
inet_pton
(
AF_INET6
,
a
[
1
],
&
new
->
end6
))
else
if
(
!
inet_pton
(
AF_INET6
,
a
[
1
],
&
new
->
end6
))
option
=
'?'
;
option
=
'?'
;
if
(
new
->
flags
&
CONTEXT_RA_ONLY
)
{
new
->
next
=
daemon
->
ra_contexts
;
daemon
->
ra_contexts
=
new
;
}
else
{
new
->
next
=
daemon
->
dhcp6
;
daemon
->
dhcp6
=
new
;
}
/* bare integer < 128 is prefix value */
/* bare integer < 128 is prefix value */
if
(
option
!=
'?'
&&
k
>=
3
)
if
(
option
!=
'?'
&&
k
>=
3
)
{
{
...
...
src/outpacket.c
0 → 100644
View file @
c5ad4e79
/* dnsmasq is Copyright (c) 2000-2012 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/>.
*/
#include "dnsmasq.h"
#ifdef HAVE_DHCP6
static
size_t
outpacket_counter
;
void
end_opt6
(
int
container
)
{
void
*
p
=
daemon
->
outpacket
.
iov_base
+
container
+
2
;
u16
len
=
outpacket_counter
-
container
-
4
;
PUTSHORT
(
len
,
p
);
}
int
save_counter
(
int
newval
)
{
int
ret
=
outpacket_counter
;
if
(
newval
!=
-
1
)
outpacket_counter
=
newval
;
return
ret
;
}
void
*
expand
(
size_t
headroom
)
{
void
*
ret
;
if
(
expand_buf
(
&
daemon
->
outpacket
,
outpacket_counter
+
headroom
))
{
ret
=
daemon
->
outpacket
.
iov_base
+
outpacket_counter
;
outpacket_counter
+=
headroom
;
return
ret
;
}
return
NULL
;
}
int
new_opt6
(
int
opt
)
{
int
ret
=
outpacket_counter
;
void
*
p
;
if
((
p
=
expand
(
4
)))
{
PUTSHORT
(
opt
,
p
);
PUTSHORT
(
0
,
p
);
}
return
ret
;
}
void
*
put_opt6
(
void
*
data
,
size_t
len
)
{
void
*
p
;
if
((
p
=
expand
(
len
)))
memcpy
(
p
,
data
,
len
);
return
p
;
}
void
put_opt6_long
(
unsigned
int
val
)
{
void
*
p
;
if
((
p
=
expand
(
4
)))
PUTLONG
(
val
,
p
);
}
void
put_opt6_short
(
unsigned
int
val
)
{
void
*
p
;
if
((
p
=
expand
(
2
)))
PUTSHORT
(
val
,
p
);
}
void
put_opt6_char
(
unsigned
int
val
)
{
unsigned
char
*
p
;
if
((
p
=
expand
(
1
)))
*
p
=
val
;
}
void
put_opt6_string
(
char
*
s
)
{
put_opt6
(
s
,
strlen
(
s
));
}
#endif
src/radv.c
0 → 100644
View file @
c5ad4e79
This diff is collapsed.
Click to expand it.
src/radv_protocol.h
0 → 100644
View file @
c5ad4e79
/* dnsmasq is Copyright (c) 2000-2012 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 ALL_HOSTS "FF02::1"
#define ALL_ROUTERS "FF02::2"
struct
ra_packet
{
u8
type
,
code
;
u16
checksum
;
u8
hop_limit
,
flags
;
u16
lifetime
;
u32
reachable_time
;
u32
retrans_time
;
};
struct
prefix_opt
{
u8
type
,
len
,
prefix_len
,
flags
;
u32
valid_lifetime
,
preferred_lifetime
,
reserved
;
struct
in6_addr
prefix
;
};
#define ICMP6_ROUTER_SOLICIT 133
#define ICMP6_ROUTER_ADVERT 134
#define ICMP6_OPT_SOURCE_MAC 1
#define ICMP6_OPT_PREFIX 3
#define ICMP6_OPT_MTU 5
#define ICMP6_OPT_RDNSS 25
src/rfc3315.c
View file @
c5ad4e79
...
@@ -19,17 +19,6 @@
...
@@ -19,17 +19,6 @@
#ifdef HAVE_DHCP6
#ifdef HAVE_DHCP6
static
size_t
outpacket_counter
;
static
void
end_opt6
(
int
container
);
static
int
save_counter
(
int
newval
);
static
void
*
expand
(
size_t
headroom
);
static
int
new_opt6
(
int
opt
);
static
void
*
put_opt6
(
void
*
data
,
size_t
len
);
static
void
put_opt6_short
(
unsigned
int
val
);
static
void
put_opt6_long
(
unsigned
int
val
);
static
void
put_opt6_string
(
char
*
s
);
static
int
dhcp6_maybe_relay
(
struct
in6_addr
*
link_address
,
struct
dhcp_netid
**
relay_tagsp
,
struct
dhcp_context
*
context
,
static
int
dhcp6_maybe_relay
(
struct
in6_addr
*
link_address
,
struct
dhcp_netid
**
relay_tagsp
,
struct
dhcp_context
*
context
,
int
interface
,
char
*
iface_name
,
struct
in6_addr
*
fallback
,
void
*
inbuff
,
size_t
sz
,
int
is_unicast
,
time_t
now
);
int
interface
,
char
*
iface_name
,
struct
in6_addr
*
fallback
,
void
*
inbuff
,
size_t
sz
,
int
is_unicast
,
time_t
now
);
static
int
dhcp6_no_relay
(
int
msg_type
,
struct
in6_addr
*
link_address
,
struct
dhcp_netid
*
tags
,
struct
dhcp_context
*
context
,
static
int
dhcp6_no_relay
(
int
msg_type
,
struct
in6_addr
*
link_address
,
struct
dhcp_netid
*
tags
,
struct
dhcp_context
*
context
,
...
@@ -55,10 +44,10 @@ size_t dhcp6_reply(struct dhcp_context *context, int interface, char *iface_name
...
@@ -55,10 +44,10 @@ size_t dhcp6_reply(struct dhcp_context *context, int interface, char *iface_name
for
(
vendor
=
daemon
->
dhcp_vendors
;
vendor
;
vendor
=
vendor
->
next
)
for
(
vendor
=
daemon
->
dhcp_vendors
;
vendor
;
vendor
=
vendor
->
next
)
vendor
->
netid
.
next
=
&
vendor
->
netid
;
vendor
->
netid
.
next
=
&
vendor
->
netid
;
outpacket_counter
=
0
;
save_counter
(
0
)
;
if
(
dhcp6_maybe_relay
(
NULL
,
&
relay_tags
,
context
,
interface
,
iface_name
,
fallback
,
daemon
->
dhcp_packet
.
iov_base
,
sz
,
is_unicast
,
now
))
if
(
dhcp6_maybe_relay
(
NULL
,
&
relay_tags
,
context
,
interface
,
iface_name
,
fallback
,
daemon
->
dhcp_packet
.
iov_base
,
sz
,
is_unicast
,
now
))
return
outpacket_counter
;
return
save_counter
(
0
)
;
return
0
;
return
0
;
}
}
...
@@ -1274,12 +1263,14 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
...
@@ -1274,12 +1263,14 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
len
+=
strlen
(
send_domain
)
+
1
;
len
+=
strlen
(
send_domain
)
+
1
;
o
=
new_opt6
(
OPTION6_FQDN
);
o
=
new_opt6
(
OPTION6_FQDN
);
p
=
expand
(
len
+
3
);
if
((
p
=
expand
(
len
+
3
)))
{
*
(
p
++
)
=
fqdn_flags
;
*
(
p
++
)
=
fqdn_flags
;
p
=
do_rfc1035_name
(
p
,
hostname
);
p
=
do_rfc1035_name
(
p
,
hostname
);
if
(
send_domain
)
if
(
send_domain
)
p
=
do_rfc1035_name
(
p
,
send_domain
);
p
=
do_rfc1035_name
(
p
,
send_domain
);
*
p
=
0
;
*
p
=
0
;
}
end_opt6
(
o
);
end_opt6
(
o
);
}
}
...
@@ -1422,80 +1413,4 @@ static unsigned int opt6_uint(unsigned char *opt, int offset, int size)
...
@@ -1422,80 +1413,4 @@ static unsigned int opt6_uint(unsigned char *opt, int offset, int size)
return
ret
;
return
ret
;
}
}
static
void
end_opt6
(
int
container
)
{
void
*
p
=
daemon
->
outpacket
.
iov_base
+
container
+
2
;
u16
len
=
outpacket_counter
-
container
-
4
;
PUTSHORT
(
len
,
p
);
}
static
int
save_counter
(
int
newval
)
{
int
ret
=
outpacket_counter
;
if
(
newval
!=
-
1
)
outpacket_counter
=
newval
;
return
ret
;
}
static
void
*
expand
(
size_t
headroom
)
{
void
*
ret
;
if
(
expand_buf
(
&
daemon
->
outpacket
,
outpacket_counter
+
headroom
))
{
ret
=
daemon
->
outpacket
.
iov_base
+
outpacket_counter
;
outpacket_counter
+=
headroom
;
return
ret
;
}
return
NULL
;
}
static
int
new_opt6
(
int
opt
)
{
int
ret
=
outpacket_counter
;
void
*
p
;
if
((
p
=
expand
(
4
)))
{
PUTSHORT
(
opt
,
p
);
PUTSHORT
(
0
,
p
);
}
return
ret
;
}
static
void
*
put_opt6
(
void
*
data
,
size_t
len
)
{
void
*
p
;
if
((
p
=
expand
(
len
)))
memcpy
(
p
,
data
,
len
);
return
p
;
}
static
void
put_opt6_long
(
unsigned
int
val
)
{
void
*
p
;
if
((
p
=
expand
(
4
)))
PUTLONG
(
val
,
p
);
}
static
void
put_opt6_short
(
unsigned
int
val
)
{
void
*
p
;
if
((
p
=
expand
(
2
)))
PUTSHORT
(
val
,
p
);
}
static
void
put_opt6_string
(
char
*
s
)
{
put_opt6
(
s
,
strlen
(
s
));
}
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment