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
5ef33279
Commit
5ef33279
authored
Mar 30, 2012
by
Simon Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tidying radv
parent
1e02a859
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
37 deletions
+28
-37
src/lease.c
src/lease.c
+4
-1
src/radv.c
src/radv.c
+24
-36
No files found.
src/lease.c
View file @
5ef33279
...
@@ -373,7 +373,10 @@ static int find_interface_v6(struct in6_addr *local, int prefix,
...
@@ -373,7 +373,10 @@ static int find_interface_v6(struct in6_addr *local, int prefix,
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
)
{
{
slaac_ping_reply
(
sender
,
packet
,
interface
,
leases
);
/* We may be doing RA but not DHCPv4, in which case the lease
database may not exist and we have nothing to do anyway */
if
(
daemon
->
dhcp
)
slaac_ping_reply
(
sender
,
packet
,
interface
,
leases
);
}
}
#endif
#endif
...
...
src/radv.c
View file @
5ef33279
...
@@ -116,8 +116,7 @@ void icmp6_packet(void)
...
@@ -116,8 +116,7 @@ void icmp6_packet(void)
char
control6
[
CMSG_SPACE
(
sizeof
(
struct
in6_pktinfo
))];
char
control6
[
CMSG_SPACE
(
sizeof
(
struct
in6_pktinfo
))];
}
control_u
;
}
control_u
;
struct
sockaddr_in6
from
;
struct
sockaddr_in6
from
;
unsigned
char
*
p
;
unsigned
char
*
packet
;
char
*
mac
=
""
;
struct
iname
*
tmp
;
struct
iname
*
tmp
;
struct
dhcp_context
*
context
;
struct
dhcp_context
*
context
;
...
@@ -132,6 +131,8 @@ void icmp6_packet(void)
...
@@ -132,6 +131,8 @@ void icmp6_packet(void)
if
((
sz
=
recv_dhcp_packet
(
daemon
->
icmp6fd
,
&
msg
))
==
-
1
||
sz
<
8
)
if
((
sz
=
recv_dhcp_packet
(
daemon
->
icmp6fd
,
&
msg
))
==
-
1
||
sz
<
8
)
return
;
return
;
packet
=
(
unsigned
char
*
)
daemon
->
outpacket
.
iov_base
;
for
(
cmptr
=
CMSG_FIRSTHDR
(
&
msg
);
cmptr
;
cmptr
=
CMSG_NXTHDR
(
&
msg
,
cmptr
))
for
(
cmptr
=
CMSG_FIRSTHDR
(
&
msg
);
cmptr
;
cmptr
=
CMSG_NXTHDR
(
&
msg
,
cmptr
))
if
(
cmptr
->
cmsg_level
==
IPPROTO_IPV6
&&
cmptr
->
cmsg_type
==
daemon
->
v6pktinfo
)
if
(
cmptr
->
cmsg_level
==
IPPROTO_IPV6
&&
cmptr
->
cmsg_type
==
daemon
->
v6pktinfo
)
...
@@ -160,36 +161,25 @@ void icmp6_packet(void)
...
@@ -160,36 +161,25 @@ void icmp6_packet(void)
if
(
!
context
->
interface
||
strcmp
(
context
->
interface
,
interface
)
==
0
)
if
(
!
context
->
interface
||
strcmp
(
context
->
interface
,
interface
)
==
0
)
break
;
break
;
if
(
!
context
)
if
(
!
context
||
packet
[
1
]
!=
0
)
return
;
return
;
p
=
(
unsigned
char
*
)
daemon
->
outpacket
.
iov_base
;
if
(
packet
[
0
]
==
ICMP6_ECHO_REPLY
)
lease_ping_reply
(
&
from
.
sin6_addr
,
packet
,
interface
);
if
(
p
[
1
]
!=
0
)
else
if
(
packet
[
0
]
==
ND_ROUTER_SOLICIT
)
return
;
if
(
p
[
0
]
==
ICMP6_ECHO_REPLY
)
{
{
/* We may be doing RA but not DHCPv4, in which case the lease
char
*
mac
=
""
;
database may not exist and we have nothing to do anyway */
if
(
daemon
->
dhcp
)
/* look for link-layer address option for logging */
lease_ping_reply
(
&
from
.
sin6_addr
,
p
,
interface
);
if
(
sz
>=
16
&&
packet
[
8
]
==
ICMP6_OPT_SOURCE_MAC
&&
(
packet
[
9
]
*
8
)
+
8
<=
sz
)
return
;
{
}
print_mac
(
daemon
->
namebuff
,
&
packet
[
10
],
(
packet
[
9
]
*
8
)
-
2
);
mac
=
daemon
->
namebuff
;
if
(
p
[
0
]
!=
ND_ROUTER_SOLICIT
)
}
return
;
my_syslog
(
MS_DHCP
|
LOG_INFO
,
"RTR-SOLICIT(%s) %s"
,
interface
,
mac
);
/* look for link-layer address option for logging */
send_ra
(
if_index
,
interface
,
&
from
.
sin6_addr
);
if
(
sz
>=
16
&&
p
[
8
]
==
ICMP6_OPT_SOURCE_MAC
&&
(
p
[
9
]
*
8
)
+
8
<=
sz
)
{
print_mac
(
daemon
->
namebuff
,
&
p
[
10
],
(
p
[
9
]
*
8
)
-
2
);
mac
=
daemon
->
namebuff
;
}
}
my_syslog
(
MS_DHCP
|
LOG_INFO
,
"RTR-SOLICIT(%s) %s"
,
interface
,
mac
);
send_ra
(
if_index
,
interface
,
&
from
.
sin6_addr
);
}
}
static
void
send_ra
(
int
iface
,
char
*
iface_name
,
struct
in6_addr
*
dest
)
static
void
send_ra
(
int
iface
,
char
*
iface_name
,
struct
in6_addr
*
dest
)
...
@@ -343,9 +333,9 @@ static int add_prefixes(struct in6_addr *local, int prefix,
...
@@ -343,9 +333,9 @@ static int add_prefixes(struct in6_addr *local, int prefix,
if
((
opt
=
expand
(
sizeof
(
struct
prefix_opt
))))
if
((
opt
=
expand
(
sizeof
(
struct
prefix_opt
))))
{
{
u64
addrpart
=
addr6part
(
local
);
/* zero net part of address */
u64
mask
=
(
prefix
==
64
)
?
(
u64
)
-
1LL
:
(
1LLU
<<
(
128
-
prefix
))
-
1LLU
;
setaddr6part
(
local
,
addr6part
(
local
)
&
~
((
prefix
==
64
)
?
(
u64
)
-
1LL
:
(
1LLU
<<
(
128
-
prefix
))
-
1LLU
))
;
/* lifetimes must be min 2 hrs, by RFC 2462 */
/* lifetimes must be min 2 hrs, by RFC 2462 */
if
(
time
<
7200
)
if
(
time
<
7200
)
time
=
7200
;
time
=
7200
;
...
@@ -353,16 +343,14 @@ static int add_prefixes(struct in6_addr *local, int prefix,
...
@@ -353,16 +343,14 @@ static int add_prefixes(struct in6_addr *local, int prefix,
opt
->
type
=
ICMP6_OPT_PREFIX
;
opt
->
type
=
ICMP6_OPT_PREFIX
;
opt
->
len
=
4
;
opt
->
len
=
4
;
opt
->
prefix_len
=
prefix
;
opt
->
prefix_len
=
prefix
;
/* autonomous only i
s
we're not doing dhcp */
/* autonomous only i
f
we're not doing dhcp */
opt
->
flags
=
do_slaac
?
0x40
:
0x00
;
opt
->
flags
=
do_slaac
?
0x40
:
0x00
;
opt
->
valid_lifetime
=
htonl
(
time
);
opt
->
valid_lifetime
=
htonl
(
time
);
opt
->
preferred_lifetime
=
htonl
(
deprecate
?
0
:
time
);
opt
->
preferred_lifetime
=
htonl
(
deprecate
?
0
:
time
);
opt
->
reserved
=
0
;
opt
->
reserved
=
0
;
opt
->
prefix
=
*
local
;
opt
->
prefix
=
*
local
;
setaddr6part
(
&
opt
->
prefix
,
addrpart
&
~
mask
);
inet_ntop
(
AF_INET6
,
&
opt
->
prefix
,
daemon
->
addrbuff
,
ADDRSTRLEN
);
inet_ntop
(
AF_INET6
,
local
,
daemon
->
addrbuff
,
ADDRSTRLEN
);
my_syslog
(
MS_DHCP
|
LOG_INFO
,
"RTR-ADVERT(%s) %s"
,
param
->
if_name
,
daemon
->
addrbuff
);
my_syslog
(
MS_DHCP
|
LOG_INFO
,
"RTR-ADVERT(%s) %s"
,
param
->
if_name
,
daemon
->
addrbuff
);
}
}
}
}
...
...
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