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
8c3bdb4f
Commit
8c3bdb4f
authored
Aug 19, 2013
by
Vladislav Grishenko
Committed by
Simon Kelley
Aug 19, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add code to get IPv6 address lifetimes and flags for *BSD.
parent
ffbad34b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
10 deletions
+47
-10
src/bpf.c
src/bpf.c
+47
-10
No files found.
src/bpf.c
View file @
8c3bdb4f
...
...
@@ -25,6 +25,10 @@
#include <net/route.h>
#include <net/if_dl.h>
#include <netinet/if_ether.h>
#if defined(__FreeBSD__)
# include <net/if_var.h>
#endif
#include <netinet/in_var.h>
#ifndef SA_SIZE
#define SA_SIZE(sa) \
...
...
@@ -89,7 +93,7 @@ int arp_enumerate(void *parm, int (*callback)())
int
iface_enumerate
(
int
family
,
void
*
parm
,
int
(
*
callback
)())
{
struct
ifaddrs
*
head
,
*
addrs
;
int
errsav
,
ret
=
0
;
int
errsav
,
fd
=
-
1
,
ret
=
0
;
if
(
family
==
AF_UNSPEC
)
#if defined(HAVE_BSD_NETWORK) && !defined(__APPLE__)
...
...
@@ -105,6 +109,11 @@ int iface_enumerate(int family, void *parm, int (*callback)())
if
(
getifaddrs
(
&
head
)
==
-
1
)
return
0
;
#if defined(HAVE_BSD_NETWORK) && defined(HAVE_IPV6)
if
(
family
==
AF_INET6
)
fd
=
socket
(
PF_INET6
,
SOCK_DGRAM
,
0
);
#endif
for
(
addrs
=
head
;
addrs
;
addrs
=
addrs
->
ifa_next
)
{
if
(
addrs
->
ifa_addr
->
sa_family
==
family
)
...
...
@@ -134,6 +143,31 @@ int iface_enumerate(int family, void *parm, int (*callback)())
unsigned
char
*
netmask
=
(
unsigned
char
*
)
&
((
struct
sockaddr_in6
*
)
addrs
->
ifa_netmask
)
->
sin6_addr
;
int
scope_id
=
((
struct
sockaddr_in6
*
)
addrs
->
ifa_addr
)
->
sin6_scope_id
;
int
i
,
j
,
prefix
=
0
;
u32
valid
=
0xffffffff
,
preferred
=
0xffffffff
;
int
flags
=
0
;
#ifdef HAVE_BSD_NETWORK
struct
in6_ifreq
ifr6
;
memset
(
&
ifr6
,
0
,
sizeof
(
ifr6
));
strncpy
(
ifr6
.
ifr_name
,
addrs
->
ifa_name
,
sizeof
(
ifr6
.
ifr_name
));
ifr6
.
ifr_addr
=
*
((
struct
sockaddr_in6
*
)
addrs
->
ifa_addr
);
if
(
fd
!=
-
1
&&
ioctl
(
fd
,
SIOCGIFAFLAG_IN6
,
&
ifr6
)
!=
-
1
)
{
if
(
ifr6
.
ifr_ifru
.
ifru_flags6
&
IN6_IFF_TENTATIVE
)
flags
|=
IFACE_TENTATIVE
;
if
(
ifr6
.
ifr_ifru
.
ifru_flags6
&
IN6_IFF_DEPRECATED
)
flags
|=
IFACE_DEPRECATED
;
}
ifr6
.
ifr_addr
=
*
((
struct
sockaddr_in6
*
)
addrs
->
ifa_addr
);
if
(
fd
!=
-
1
&&
ioctl
(
fd
,
SIOCGIFALIFETIME_IN6
,
&
ifr6
)
!=
-
1
)
{
valid
=
ifr6
.
ifr_ifru
.
ifru_lifetime
.
ia6t_vltime
;
preferred
=
ifr6
.
ifr_ifru
.
ifru_lifetime
.
ia6t_pltime
;
}
#endif
for
(
i
=
0
;
i
<
IN6ADDRSZ
;
i
++
,
prefix
+=
8
)
if
(
netmask
[
i
]
!=
0xff
)
...
...
@@ -151,11 +185,12 @@ int iface_enumerate(int family, void *parm, int (*callback)())
addr
->
s6_addr
[
3
]
=
0
;
}
/* preferred and valid times == forever until we known how to dtermine them. */
if
(
!
((
*
callback
)(
addr
,
prefix
,
scope_id
,
iface_index
,
0
,
-
1
,
-
1
,
parm
)))
if
(
!
((
*
callback
)(
addr
,
prefix
,
scope_id
,
iface_index
,
flags
,
(
int
)
preferred
,
(
int
)
valid
,
parm
)))
goto
err
;
}
#endif
#endif
/* HAVE_IPV6 */
#ifdef HAVE_DHCP6
else
if
(
family
==
AF_LINK
)
{
...
...
@@ -174,6 +209,8 @@ int iface_enumerate(int family, void *parm, int (*callback)())
err:
errsav
=
errno
;
freeifaddrs
(
head
);
if
(
fd
!=
-
1
)
close
(
fd
);
errno
=
errsav
;
return
ret
;
...
...
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