summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-16 03:22:13 +0100
committerMichael Adam <obnox@samba.org>2008-02-19 21:56:52 +0100
commit7728a23d43a79eefaf2cc7e1998283e3d1e095f8 (patch)
tree4c639e11bb9d39a54f040c6839ab77751f08be57
parentd0d4fc5f5412bcf2977afc01edee92107e995c80 (diff)
downloadsamba-7728a23d43a79eefaf2cc7e1998283e3d1e095f8.tar.gz
samba-7728a23d43a79eefaf2cc7e1998283e3d1e095f8.tar.bz2
samba-7728a23d43a79eefaf2cc7e1998283e3d1e095f8.zip
r26469: Fix paths, only include IPv4 addresses for now.
(cherry picked from commit fa9e3b6fa871b7541878f836ea54e882e614a3cf) (This used to be commit a2d6f6b4ae7fb6711d4228b9e255eebb6bf344bd)
-rw-r--r--source3/lib/replace/getifaddrs.c21
-rw-r--r--source3/lib/replace/getifaddrs.m413
-rw-r--r--source3/lib/replace/system/network.h2
3 files changed, 19 insertions, 17 deletions
diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c
index a4f16ddb76..e04c023209 100644
--- a/source3/lib/replace/getifaddrs.c
+++ b/source3/lib/replace/getifaddrs.c
@@ -360,20 +360,25 @@ int getifaddrs(struct ifaddrs **ifap)
int main()
{
- struct ifaddrs *ifs;
- int total = get_interfaces(ifaces, MAX_INTERFACES);
- int i;
-
- int ret = getifaddrs(&ifs);
+ struct ifaddrs *ifs = NULL;
+ int ret;
+
+ ret = getifaddrs(&ifs);
if (ret != 0) {
perror("getifaddrs() failed");
return 1;
}
while (ifs) {
- printf("%-10s ", ifs->ifr_name);
- printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifr_addr)->sin_addr));
- printf("NETMASK=%s\n", inet_ntoa(((struct sockaddr_in *)ifs->ifr_netmask)->sin_addr));
+ printf("%-10s ", ifs->ifa_name);
+ if (ifs->ifa_addr != NULL &&
+ ifs->ifa_addr->sa_family == AF_INET) {
+ printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifa_addr)->sin_addr));
+ if (ifs->ifa_netmask != NULL)
+ printf("NETMASK=%s", inet_ntoa(((struct sockaddr_in *)ifs->ifa_netmask)->sin_addr));
+ }
+ printf("\n");
+ ifs = ifs->ifa_next;
}
return 0;
}
diff --git a/source3/lib/replace/getifaddrs.m4 b/source3/lib/replace/getifaddrs.m4
index f38827406d..7e6016ed8f 100644
--- a/source3/lib/replace/getifaddrs.m4
+++ b/source3/lib/replace/getifaddrs.m4
@@ -26,10 +26,8 @@ fi
#
# This tests need LIBS="$NSL_LIBS $SOCKET_LIBS"
#
-old_CFLAGS=$CFLAGS
old_LIBS=$LIBS
LIBS="$NSL_LIBS $SOCKET_LIBS"
-CFLAGS="$CFLAGS -Ilib/replace"
iface=no;
##################
# look for a method of finding the list of network interfaces
@@ -41,8 +39,8 @@ AC_TRY_RUN([
#define NO_CONFIG_H 1
#define HAVE_IFACE_GETIFADDRS 1
#define AUTOCONF_TEST 1
-#include "${srcdir-.}/lib/replace/replace.c"
-#include "${srcdir-.}/lib/replace/getifaddrs.c"],
+#include "$libreplacedir/replace.c"
+#include "$libreplacedir/getifaddrs.c"],
samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)])
CPPFLAGS="$SAVE_CPPFLAGS"
if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then
@@ -58,7 +56,7 @@ AC_TRY_RUN([
#define HAVE_IFACE_AIX 1
#define AUTOCONF_TEST 1
#undef _XOPEN_SOURCE_EXTENDED
-#include "${srcdir-.}/lib/replace/getifaddrs.c"],
+#include "$libreplacedir/getifaddrs.c"],
samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
@@ -71,7 +69,7 @@ AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
AC_TRY_RUN([
#define HAVE_IFACE_IFCONF 1
#define AUTOCONF_TEST 1
-#include "${srcdir-.}/lib/replace/getifaddrs.c"],
+#include "$libreplacedir/getifaddrs.c"],
samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
@@ -83,12 +81,11 @@ AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
AC_TRY_RUN([
#define HAVE_IFACE_IFREQ 1
#define AUTOCONF_TEST 1
-#include "${srcdir-.}/lib/replace/getifaddrs.c"],
+#include "$libreplacedir/getifaddrs.c"],
samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
fi
fi
-CFLAGS=$old_CFLAGS
LIBS=$old_LIBS
diff --git a/source3/lib/replace/system/network.h b/source3/lib/replace/system/network.h
index 61be51744c..0b5fbcddd1 100644
--- a/source3/lib/replace/system/network.h
+++ b/source3/lib/replace/system/network.h
@@ -106,7 +106,7 @@ const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size);
struct ifaddrs {
struct ifaddrs *ifa_next; /* Pointer to next struct */
char *ifa_name; /* Interface name */
- u_int ifa_flags; /* Interface flags */
+ unsigned int ifa_flags; /* Interface flags */
struct sockaddr *ifa_addr; /* Interface address */
struct sockaddr *ifa_netmask; /* Interface netmask */
struct sockaddr *ifa_dstaddr; /* P2P interface destination */