Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
BIND
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
634
Issues
634
List
Boards
Labels
Service Desk
Milestones
Merge Requests
107
Merge Requests
107
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
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
ISC Open Source Projects
BIND
Commits
31d3464c
Commit
31d3464c
authored
Oct 22, 2001
by
Mark Andrews
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1065. [func] Runtime support to select new / old style interface
scanning using ioctls.
parent
2f6d1483
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
397 additions
and
94 deletions
+397
-94
CHANGES
CHANGES
+3
-0
config.h.in
config.h.in
+4
-1
configure.in
configure.in
+24
-2
lib/isc/include/isc/platform.h.in
lib/isc/include/isc/platform.h.in
+12
-1
lib/isc/unix/ifiter_ioctl.c
lib/isc/unix/ifiter_ioctl.c
+348
-88
lib/isc/unix/interfaceiter.c
lib/isc/unix/interfaceiter.c
+6
-2
No files found.
CHANGES
View file @
31d3464c
1065. [func] Runtime support to select new / old style interface
scanning using ioctls.
1064. [bug] Do not shutdown active interfaces if we are unable
to scan the list of interfaces. [RT #1921]
...
...
config.h.in
View file @
31d3464c
...
...
@@ -16,7 +16,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: config.h.in,v 1.4
8 2001/08/30 04:33:17
marka Exp $ */
/* $Id: config.h.in,v 1.4
9 2001/10/22 04:01:26
marka Exp $ */
/***
*** This file is not to be included by any public header files, because
...
...
@@ -165,6 +165,9 @@ int sigwait(const unsigned int *set, int *sig);
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the <net/if6.h> header file. */
#undef NET_IF6_H
/* Define if you have the nsl library (-lnsl). */
#undef HAVE_LIBNSL
...
...
configure.in
View file @
31d3464c
...
...
@@ -18,7 +18,7 @@ AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
esyscmd([sed "s/^/# /" COPYRIGHT])dnl
AC_DIVERT_POP()dnl
AC_REVISION($Revision: 1.30
4
$)
AC_REVISION($Revision: 1.30
5
$)
AC_INIT(lib/dns/name.c)
AC_PREREQ(2.13)
...
...
@@ -194,7 +194,7 @@ AC_PROG_CC
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h sys/sockio.h sys/select.h sys/sysctl.h)
AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h sys/sockio.h sys/select.h sys/sysctl.h
net/if6.h
)
AC_C_CONST
AC_C_INLINE
...
...
@@ -1109,6 +1109,28 @@ AC_SUBST(ISC_ISCIPV6_O)
AC_SUBST(ISC_IPV6_C)
AC_SUBST(LWRES_HAVE_SIN6_SCOPE_ID)
AC_MSG_CHECKING([for struct if_laddrreq])
AC_TRY_LINK([
#include <sys/types.h>
#include <net/if6.h>
],[ struct if_laddrreq a; ],
[AC_MSG_RESULT(yes)
ISC_PLATFORM_HAVEIF_LADDRREQ="#define ISC_PLATFORM_HAVEIF_LADDRREQ 1"],
[AC_MSG_RESULT(no)
ISC_PLATFORM_HAVEIF_LADDRREQ="#undef ISC_PLATFORM_HAVEIF_LADDRREQ"])
AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRREQ)
AC_MSG_CHECKING([for struct if_laddrconf])
AC_TRY_LINK([
#include <sys/types.h>
#include <net/if6.h>
],[ struct if_laddrconf a; ],
[AC_MSG_RESULT(yes)
ISC_PLATFORM_HAVEIF_LADDRCONF="#define ISC_PLATFORM_HAVEIF_LADDRCONF 1"],
[AC_MSG_RESULT(no)
ISC_PLATFORM_HAVEIF_LADDRCONF="#undef ISC_PLATFORM_HAVEIF_LADDRCONF"])
AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRCONF)
#
# Check for network functions that are often missing. We do this
# after the libtool checking, so we can put the right suffix on
...
...
lib/isc/include/isc/platform.h.in
View file @
31d3464c
...
...
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: platform.h.in,v 1.2
5 2001/10/03 05:08:30
marka Exp $ */
/* $Id: platform.h.in,v 1.2
6 2001/10/22 04:01:29
marka Exp $ */
#ifndef ISC_PLATFORM_H
#define ISC_PLATFORM_H 1
...
...
@@ -153,6 +153,17 @@
*/
@ISC_PLATFORM_HAVELIFCONF@
/*
* Define if the system has struct if_laddrconf which is a extended struct
* ifconf for IPv6.
*/
@ISC_PLATFORM_HAVEIF_LADDRCONF@
/*
* Define if the system has struct if_laddrreq.
*/
@ISC_PLATFORM_HAVEIF_LADDRREQ@
/*
* Used to control how extern data is linked; needed for Win32 platforms.
*/
...
...
lib/isc/unix/ifiter_ioctl.c
View file @
31d3464c
...
...
@@ -15,44 +15,36 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: ifiter_ioctl.c,v 1.2
2 2001/10/03 05:08:32
marka Exp $ */
/* $Id: ifiter_ioctl.c,v 1.2
3 2001/10/22 04:01:31
marka Exp $ */
/*
* Obtain the list of network interfaces using the SIOCGLIFCONF ioctl.
* See netintro(4).
*/
#ifndef ISC_PLATFORM_HAVELIFCONF
/*
* HP uses these differently to Sun.
*/
#undef SIOCGLIFCONF
#undef SIOCGLIFADDR
#endif
#ifndef SIOCGLIFCONF
#define SIOCGLIFCONF SIOCGIFCONF
#define lifc_len ifc_len
#define lifc_buf ifc_buf
#define lifc_req ifc_req
#define lifconf ifconf
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
#ifdef ISC_PLATFORM_HAVEIF_LADDRCONF
#define lifc_len iflc_len
#define lifc_buf iflc_buf
#define lifc_req iflc_req
#define LIFCONF if_laddrconf
#else
#define ISC_HAVE_LIFC_FAMILY 1
#define ISC_HAVE_LIFC_FLAGS 1
#define LIFCONF lifconf
#endif
#ifndef SIOCGLIFADDR
#define SIOCGLIFADDR SIOCGIFADDR
#define SIOCGLIFFLAGS SIOCGIFFLAGS
#define SIOCGLIFDSTADDR SIOCGIFDSTADDR
#define SIOCGLIFNETMASK SIOCGIFNETMASK
#define lifr_addr ifr_addr
#define lifr_name ifr_name
#define lifr_dstaddr ifr_dstaddr
#define lifr_flags ifr_flags
#ifdef ISC_PLATFORM_HAVEIF_LADDRREQ
#define lifr_addr iflr_addr
#define lifr_name iflr_name
#define lifr_dstaddr iflr_dstaddr
#define lifr_flags iflr_flags
#define ss_family sa_family
#define lifreq ifreq
#define LIFREQ if_laddrreq
#else
#define LIFREQ lifreq
#endif
#endif
#define IFITER_MAGIC ISC_MAGIC('I', 'F', 'I', 'T')
#define VALID_IFITER(t) ISC_MAGIC_VALID(t, IFITER_MAGIC)
...
...
@@ -61,7 +53,11 @@ struct isc_interfaceiter {
unsigned
int
magic
;
/* Magic number. */
isc_mem_t
*
mctx
;
int
socket
;
struct
lifconf
ifc
;
int
mode
;
struct
ifconf
ifc
;
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
struct
LIFCONF
lifc
;
#endif
void
*
buf
;
/* Buffer for sysctl data. */
unsigned
int
bufsize
;
/* Bytes allocated. */
unsigned
int
pos
;
/* Current offset in
...
...
@@ -78,67 +74,109 @@ struct isc_interfaceiter {
#define IFCONF_BUFSIZE_INITIAL 4096
#define IFCONF_BUFSIZE_MAX 1048576
isc_result_t
isc_interfaceiter_create
(
isc_mem_t
*
mctx
,
isc_interfaceiter_t
**
iterp
)
{
isc_interfaceiter_t
*
iter
;
isc_result_t
result
;
static
isc_result_t
getbuf4
(
isc_interfaceiter_t
*
iter
)
{
char
strbuf
[
ISC_STRERRORSIZE
];
REQUIRE
(
mctx
!=
NULL
);
REQUIRE
(
iterp
!=
NULL
);
REQUIRE
(
*
iterp
==
NULL
);
iter
->
bufsize
=
IFCONF_BUFSIZE_INITIAL
;
iter
=
isc_mem_get
(
mctx
,
sizeof
(
*
iter
));
if
(
iter
==
NULL
)
for
(;;)
{
iter
->
buf
=
isc_mem_get
(
iter
->
mctx
,
iter
->
bufsize
);
if
(
iter
->
buf
==
NULL
)
return
(
ISC_R_NOMEMORY
);
iter
->
mctx
=
mctx
;
iter
->
buf
=
NULL
;
memset
(
&
iter
->
ifc
.
ifc_len
,
0
,
sizeof
(
iter
->
ifc
.
ifc_len
))
;
iter
->
ifc
.
ifc_len
=
iter
->
bufsize
;
iter
->
ifc
.
ifc_buf
=
iter
->
buf
;
/*
* Create an unbound datagram socket to do the SIOCGLIFADDR ioctl on.
* Ignore the HP/UX warning about "interger overflow during
* conversion". It comes from its own macro definition,
* and is really hard to shut up.
*/
if
((
iter
->
socket
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
))
<
0
)
{
if
(
ioctl
(
iter
->
socket
,
SIOCGIFCONF
,
(
char
*
)
&
iter
->
ifc
)
==
-
1
)
{
if
(
errno
!=
EINVAL
)
{
isc__strerror
(
errno
,
strbuf
,
sizeof
(
strbuf
));
UNEXPECTED_ERROR
(
__FILE__
,
__LINE__
,
isc_msgcat_get
(
isc_msgcat
,
ISC_MSGSET_IFITERIOCTL
,
ISC_MSG_MAKESCANSOCKET
,
"making
interface "
"scan socket
: %s"
),
ISC_MSG_GETIFCONFIG
,
"get
interface "
"configuration
: %s"
),
strbuf
);
result
=
ISC_R_UNEXPECTED
;
goto
socket_failure
;
goto
unexpected
;
}
/*
* Get the interface configuration, allocating more memory if
* necessary.
* EINVAL. Retry with a bigger buffer.
*/
}
else
{
/*
* The ioctl succeeded.
* Some OS's just return what will fit rather
* than set EINVAL if the buffer is too small
* to fit all the interfaces in. If
* ifc.lifc_len is too near to the end of the
* buffer we will grow it just in case and
* retry.
*/
if
(
iter
->
ifc
.
ifc_len
+
2
*
sizeof
(
struct
ifreq
)
<
iter
->
bufsize
)
break
;
}
if
(
iter
->
bufsize
>=
IFCONF_BUFSIZE_MAX
)
{
UNEXPECTED_ERROR
(
__FILE__
,
__LINE__
,
isc_msgcat_get
(
isc_msgcat
,
ISC_MSGSET_IFITERIOCTL
,
ISC_MSG_BUFFERMAX
,
"get interface "
"configuration: "
"maximum buffer "
"size exceeded"
));
goto
unexpected
;
}
isc_mem_put
(
iter
->
mctx
,
iter
->
buf
,
iter
->
bufsize
);
iter
->
bufsize
*=
2
;
}
iter
->
mode
=
4
;
return
(
ISC_R_SUCCESS
);
unexpected:
isc_mem_put
(
iter
->
mctx
,
iter
->
buf
,
iter
->
bufsize
);
iter
->
buf
=
NULL
;
return
(
ISC_R_UNEXPECTED
);
}
static
isc_result_t
getbuf6
(
isc_interfaceiter_t
*
iter
)
{
#if !defined(SIOCGLIFCONF) || !defined(SIOCGLIFADDR)
UNUSED
(
iter
);
return
(
ISC_R_NOTIMPLEMENTED
);
#else
char
strbuf
[
ISC_STRERRORSIZE
];
iter
->
bufsize
=
IFCONF_BUFSIZE_INITIAL
;
for
(;;)
{
iter
->
buf
=
isc_mem_get
(
mctx
,
iter
->
bufsize
);
if
(
iter
->
buf
==
NULL
)
{
result
=
ISC_R_NOMEMORY
;
goto
alloc_failure
;
}
iter
->
buf
=
isc_mem_get
(
iter
->
mctx
,
iter
->
bufsize
);
if
(
iter
->
buf
==
NULL
)
return
(
ISC_R_NOMEMORY
);
memset
(
&
iter
->
ifc
.
lifc_len
,
0
,
sizeof
(
iter
->
ifc
.
lifc_len
));
memset
(
&
iter
->
lifc
.
lifc_len
,
0
,
sizeof
(
iter
->
l
ifc
.
lifc_len
));
#ifdef ISC_HAVE_LIFC_FAMILY
iter
->
ifc
.
lifc_family
=
AF_UNSPEC
;
iter
->
l
ifc
.
lifc_family
=
AF_UNSPEC
;
#endif
#ifdef ISC_HAVE_LIFC_FLAGS
iter
->
ifc
.
lifc_flags
=
0
;
iter
->
l
ifc
.
lifc_flags
=
0
;
#endif
iter
->
ifc
.
lifc_len
=
iter
->
bufsize
;
iter
->
ifc
.
lifc_buf
=
iter
->
buf
;
iter
->
l
ifc
.
lifc_len
=
iter
->
bufsize
;
iter
->
l
ifc
.
lifc_buf
=
iter
->
buf
;
/*
* Ignore the HP/UX warning about "interger overflow during
* conversion". It comes from its own macro definition,
* and is really hard to shut up.
*/
if
(
ioctl
(
iter
->
socket
,
SIOCGLIFCONF
,
(
char
*
)
&
iter
->
ifc
)
if
(
ioctl
(
iter
->
socket
,
SIOCGLIFCONF
,
(
char
*
)
&
iter
->
l
ifc
)
==
-
1
)
{
if
(
errno
!=
EINVAL
)
{
isc__strerror
(
errno
,
strbuf
,
sizeof
(
strbuf
));
...
...
@@ -149,8 +187,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
"get interface "
"configuration: %s"
),
strbuf
);
result
=
ISC_R_UNEXPECTED
;
goto
ioctl_failure
;
goto
unexpected
;
}
/*
* EINVAL. Retry with a bigger buffer.
...
...
@@ -161,11 +198,11 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
* Some OS's just return what will fit rather
* than set EINVAL if the buffer is too small
* to fit all the interfaces in. If
* ifc.
l
ifc_len is too near to the end of the
* ifc.ifc_len is too near to the end of the
* buffer we will grow it just in case and
* retry.
*/
if
(
iter
->
ifc
.
lifc_len
+
2
*
sizeof
(
struct
lifreq
)
if
(
iter
->
lifc
.
lifc_len
+
2
*
sizeof
(
struct
LIFREQ
)
<
iter
->
bufsize
)
break
;
}
...
...
@@ -178,14 +215,70 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
"configuration: "
"maximum buffer "
"size exceeded"
));
result
=
ISC_R_UNEXPECTED
;
goto
ioctl_failure
;
goto
unexpected
;
}
isc_mem_put
(
mctx
,
iter
->
buf
,
iter
->
bufsize
);
isc_mem_put
(
iter
->
mctx
,
iter
->
buf
,
iter
->
bufsize
);
iter
->
bufsize
*=
2
;
}
iter
->
mode
=
6
;
return
(
ISC_R_SUCCESS
);
unexpected:
isc_mem_put
(
iter
->
mctx
,
iter
->
buf
,
iter
->
bufsize
);
iter
->
buf
=
NULL
;
return
(
ISC_R_UNEXPECTED
);
#endif
}
isc_result_t
isc_interfaceiter_create
(
isc_mem_t
*
mctx
,
isc_interfaceiter_t
**
iterp
)
{
isc_interfaceiter_t
*
iter
;
isc_result_t
result
;
char
strbuf
[
ISC_STRERRORSIZE
];
REQUIRE
(
mctx
!=
NULL
);
REQUIRE
(
iterp
!=
NULL
);
REQUIRE
(
*
iterp
==
NULL
);
iter
=
isc_mem_get
(
mctx
,
sizeof
(
*
iter
));
if
(
iter
==
NULL
)
return
(
ISC_R_NOMEMORY
);
iter
->
mctx
=
mctx
;
iter
->
buf
=
NULL
;
iter
->
mode
=
0
;
/*
* Create an unbound datagram socket to do the SIOCGLIFADDR ioctl on.
*/
if
((
iter
->
socket
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
))
<
0
)
{
isc__strerror
(
errno
,
strbuf
,
sizeof
(
strbuf
));
UNEXPECTED_ERROR
(
__FILE__
,
__LINE__
,
isc_msgcat_get
(
isc_msgcat
,
ISC_MSGSET_IFITERIOCTL
,
ISC_MSG_MAKESCANSOCKET
,
"making interface "
"scan socket: %s"
),
strbuf
);
result
=
ISC_R_UNEXPECTED
;
goto
socket_failure
;
}
/*
* Get the interface configuration, allocating more memory if
* necessary.
*/
result
=
isc_net_probeipv6
();
if
(
result
==
ISC_R_SUCCESS
)
result
=
getbuf6
(
iter
);
if
(
result
!=
ISC_R_SUCCESS
)
result
=
getbuf4
(
iter
);
if
(
result
!=
ISC_R_SUCCESS
)
goto
ioctl_failure
;
/*
* A newly created iterator has an undefined position
* until isc_interfaceiter_first() is called.
...
...
@@ -198,9 +291,8 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
return
(
ISC_R_SUCCESS
);
ioctl_failure:
if
(
iter
->
buf
!=
NULL
)
isc_mem_put
(
mctx
,
iter
->
buf
,
iter
->
bufsize
);
alloc_failure:
(
void
)
close
(
iter
->
socket
);
socket_failure:
...
...
@@ -217,22 +309,149 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
*/
static
isc_result_t
internal_current
(
isc_interfaceiter_t
*
iter
)
{
struct
l
ifreq
*
ifrp
;
struct
lifreq
l
ifreq
;
internal_current
4
(
isc_interfaceiter_t
*
iter
)
{
struct
ifreq
*
ifrp
;
struct
ifreq
ifreq
;
int
family
;
char
strbuf
[
ISC_STRERRORSIZE
];
REQUIRE
(
VALID_IFITER
(
iter
));
REQUIRE
(
iter
->
pos
<
(
unsigned
int
)
iter
->
ifc
.
lifc_len
);
REQUIRE
(
iter
->
pos
<
(
unsigned
int
)
iter
->
ifc
.
ifc_len
);
ifrp
=
(
struct
ifreq
*
)((
char
*
)
iter
->
ifc
.
ifc_req
+
iter
->
pos
);
memset
(
&
ifreq
,
0
,
sizeof
ifreq
);
memcpy
(
&
ifreq
,
ifrp
,
sizeof
ifreq
);
family
=
ifreq
.
ifr_addr
.
sa_family
;
#ifdef ISC_PLATFORM_HAVEIPV6
if
(
family
!=
AF_INET
&&
family
!=
AF_INET6
)
#else
if
(
family
!=
AF_INET
)
#endif
return
(
ISC_R_IGNORE
);
memset
(
&
iter
->
current
,
0
,
sizeof
(
iter
->
current
));
iter
->
current
.
af
=
family
;
INSIST
(
sizeof
(
ifreq
.
ifr_name
)
<=
sizeof
(
iter
->
current
.
name
));
memset
(
iter
->
current
.
name
,
0
,
sizeof
(
iter
->
current
.
name
));
memcpy
(
iter
->
current
.
name
,
ifreq
.
ifr_name
,
sizeof
(
ifreq
.
ifr_name
));
get_addr
(
family
,
&
iter
->
current
.
address
,
(
struct
sockaddr
*
)
&
ifreq
.
ifr_addr
);
/*
* Get interface flags.
*/
iter
->
current
.
flags
=
0
;
/*
* Ignore the HP/UX warning about "interger overflow during
* conversion. It comes from its own macro definition,
* and is really hard to shut up.
*/
if
(
ioctl
(
iter
->
socket
,
SIOCGIFFLAGS
,
(
char
*
)
&
ifreq
)
<
0
)
{
isc__strerror
(
errno
,
strbuf
,
sizeof
(
strbuf
));
UNEXPECTED_ERROR
(
__FILE__
,
__LINE__
,
"%s: getting interface flags: %s"
,
ifreq
.
ifr_name
,
strbuf
);
return
(
ISC_R_IGNORE
);
}
if
((
ifreq
.
ifr_flags
&
IFF_UP
)
!=
0
)
iter
->
current
.
flags
|=
INTERFACE_F_UP
;
if
((
ifreq
.
ifr_flags
&
IFF_POINTOPOINT
)
!=
0
)
iter
->
current
.
flags
|=
INTERFACE_F_POINTTOPOINT
;
if
((
ifreq
.
ifr_flags
&
IFF_LOOPBACK
)
!=
0
)
iter
->
current
.
flags
|=
INTERFACE_F_LOOPBACK
;
ifrp
=
(
struct
lifreq
*
)((
char
*
)
iter
->
ifc
.
lifc_req
+
iter
->
pos
);
/*
* If the interface is point-to-point, get the destination address.
*/
if
((
iter
->
current
.
flags
&
INTERFACE_F_POINTTOPOINT
)
!=
0
)
{
/*
* Ignore the HP/UX warning about "interger overflow during
* conversion. It comes from its own macro definition,
* and is really hard to shut up.
*/
if
(
ioctl
(
iter
->
socket
,
SIOCGIFDSTADDR
,
(
char
*
)
&
ifreq
)
<
0
)
{
isc__strerror
(
errno
,
strbuf
,
sizeof
(
strbuf
));
UNEXPECTED_ERROR
(
__FILE__
,
__LINE__
,
isc_msgcat_get
(
isc_msgcat
,
ISC_MSGSET_IFITERIOCTL
,
ISC_MSG_GETDESTADDR
,
"%s: getting "
"destination address: %s"
),
ifreq
.
ifr_name
,
strbuf
);
return
(
ISC_R_IGNORE
);
}
get_addr
(
family
,
&
iter
->
current
.
dstaddress
,
(
struct
sockaddr
*
)
&
ifreq
.
ifr_dstaddr
);
}
/*
* Get the network mask.
*/
memset
(
&
ifreq
,
0
,
sizeof
ifreq
);
memcpy
(
&
ifreq
,
ifrp
,
sizeof
ifreq
);
switch
(
family
)
{
case
AF_INET
:
/*
* Ignore the HP/UX warning about "interger overflow during
* conversion. It comes from its own macro definition,
* and is really hard to shut up.
*/
if
(
ioctl
(
iter
->
socket
,
SIOCGIFNETMASK
,
(
char
*
)
&
ifreq
)
<
0
)
{
isc__strerror
(
errno
,
strbuf
,
sizeof
(
strbuf
));
UNEXPECTED_ERROR
(
__FILE__
,
__LINE__
,
isc_msgcat_get
(
isc_msgcat
,
ISC_MSGSET_IFITERIOCTL
,
ISC_MSG_GETNETMASK
,
"%s: getting netmask: %s"
),
ifreq
.
ifr_name
,
strbuf
);
return
(
ISC_R_IGNORE
);
}
get_addr
(
family
,
&
iter
->
current
.
netmask
,
(
struct
sockaddr
*
)
&
ifreq
.
ifr_addr
);
break
;
case
AF_INET6
:
break
;
}
return
(
ISC_R_SUCCESS
);
}
static
isc_result_t
internal_current6
(
isc_interfaceiter_t
*
iter
)
{
#if !defined(SIOCGLIFCONF) || !defined(SIOCGLIFADDR)
UNUSED
(
iter
);
return
(
ISC_R_NOTIMPLEMENTED
);
#else
struct
LIFREQ
*
ifrp
;
struct
LIFREQ
lifreq
;
int
family
;
char
strbuf
[
ISC_STRERRORSIZE
];
REQUIRE
(
VALID_IFITER
(
iter
));
REQUIRE
(
iter
->
pos
<
(
unsigned
int
)
iter
->
lifc
.
lifc_len
);
ifrp
=
(
struct
LIFREQ
*
)((
char
*
)
iter
->
lifc
.
lifc_req
+
iter
->
pos
);
memset
(
&
lifreq
,
0
,
sizeof
lifreq
);
memcpy
(
&
lifreq
,
ifrp
,
sizeof
lifreq
);
family
=
lifreq
.
lifr_addr
.
ss_family
;
#ifdef ISC_PLATFORM_HAVEIPV6
if
(
family
!=
AF_INET
&&
family
!=
AF_INET6
)
#else
if
(
family
!=
AF_INET
)
#endif
return
(
ISC_R_IGNORE
);
memset
(
&
iter
->
current
,
0
,
sizeof
(
iter
->
current
));
...
...
@@ -344,6 +563,14 @@ internal_current(isc_interfaceiter_t *iter) {
}
return
(
ISC_R_SUCCESS
);
#endif
}
static
isc_result_t
internal_current
(
isc_interfaceiter_t
*
iter
)
{
if
(
iter
->
mode
==
6
)
return
(
internal_current6
(
iter
));
return
(
internal_current4
(
iter
));
}
/*
...
...
@@ -354,12 +581,37 @@ internal_current(isc_interfaceiter_t *iter) {
* interfaces, otherwise ISC_R_SUCCESS.
*/
static
isc_result_t
internal_next
(
isc_interfaceiter_t
*
iter
)
{
struct
l
ifreq
*
ifrp
;
internal_next
4
(
isc_interfaceiter_t
*
iter
)
{
struct
ifreq
*
ifrp
;
REQUIRE
(
iter
->
pos
<
(
unsigned
int
)
iter
->
ifc
.
l
ifc_len
);
REQUIRE
(
iter
->
pos
<
(
unsigned
int
)
iter
->
ifc
.
ifc_len
);
ifrp
=
(
struct
lifreq
*
)((
char
*
)
iter
->
ifc
.
lifc_req
+
iter
->
pos
);
ifrp
=
(
struct
ifreq
*
)((
char
*
)
iter
->
ifc
.
ifc_req
+
iter
->
pos
);
#ifdef ISC_PLATFORM_HAVESALEN
if
(
ifrp
->
ifr_addr
.
sa_len
>
sizeof
(
struct
sockaddr
))
iter
->
pos
+=
sizeof
(
ifrp
->
ifr_name
)
+
ifrp
->
ifr_addr
.
sa_len
;
else
#endif
iter
->
pos
+=
sizeof
*
ifrp
;
if
(
iter
->
pos
>=
(
unsigned
int
)
iter
->
ifc
.
ifc_len
)
return
(
ISC_R_NOMORE
);
return
(
ISC_R_SUCCESS
);
}
static
isc_result_t
internal_next6
(
isc_interfaceiter_t
*
iter
)
{
#if !defined(SIOCGLIFCONF) || !defined(SIOCGLIFADDR)
UNUSED
(
iter
);
return
(
ISC_R_NOTIMPLEMENTED
);
#else
struct
LIFREQ
*
ifrp
;