summaryrefslogtreecommitdiffstats
path: root/source/lib/interfaces.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2007-02-28 14:35:26 +0000
committerGerald Carter <jerry@samba.org>2007-02-28 14:35:26 +0000
commit80236f0d60ce013134c1ed5422d148e541f70a4f (patch)
treef71326fa71c0323e6b5d87b75b289d0608480f87 /source/lib/interfaces.c
parentf05f5dce39b11e937fb19270b7bcc888582edf35 (diff)
downloadsamba-80236f0d60ce013134c1ed5422d148e541f70a4f.tar.gz
samba-80236f0d60ce013134c1ed5422d148e541f70a4f.tar.xz
samba-80236f0d60ce013134c1ed5422d148e541f70a4f.zip
r21585: Start syncing the monster that will become 3.0.25pre1
Still todo: * release notes * few minor outstanding patches * additional idmap man pages
Diffstat (limited to 'source/lib/interfaces.c')
-rw-r--r--source/lib/interfaces.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/source/lib/interfaces.c b/source/lib/interfaces.c
index dc30bdce47a..839cab1286c 100644
--- a/source/lib/interfaces.c
+++ b/source/lib/interfaces.c
@@ -30,27 +30,21 @@
*/
+#ifndef AUTOCONF_TEST
+#include "config.h"
+#endif
+
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+#include <netdb.h>
+#include <sys/ioctl.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <sys/time.h>
-#include <net/if.h>
-
-#ifdef AUTOCONF_TEST
-struct iface_struct {
- char name[16];
- struct in_addr ip;
- struct in_addr netmask;
-};
-#else
-#include "config.h"
-#include "interfaces.h"
-#endif
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
@@ -82,6 +76,12 @@ struct iface_struct {
#define QSORT_CAST (int (*)(const void *, const void *))
#endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+
+#include "interfaces.h"
+
#if HAVE_IFACE_IFCONF
/* this works for Linux 2.2, Solaris 2.5, SunOS4, HPUX 10.20, OSF1
@@ -154,7 +154,9 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
return total;
}
-#elif HAVE_IFACE_IFREQ
+#define _FOUND_IFACE_ANY
+#endif /* HAVE_IFACE_IFCONF */
+#ifdef HAVE_IFACE_IFREQ
#ifndef I_STR
#include <sys/stropts.h>
@@ -249,7 +251,9 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
return total;
}
-#elif HAVE_IFACE_AIX
+#define _FOUND_IFACE_ANY
+#endif /* HAVE_IFACE_IFREQ */
+#ifdef HAVE_IFACE_AIX
/****************************************************************************
this one is for AIX (tested on 4.2)
@@ -284,7 +288,7 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
i = ifc.ifc_len;
while (i > 0 && total < max_interfaces) {
- unsigned inc;
+ uint_t inc;
inc = ifr->ifr_addr.sa_len;
@@ -337,7 +341,9 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
return total;
}
-#else /* a dummy version */
+#define _FOUND_IFACE_ANY
+#endif /* HAVE_IFACE_AIX */
+#ifndef _FOUND_IFACE_ANY
static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
{
return -1;
@@ -356,10 +362,9 @@ static int iface_comp(struct iface_struct *i1, struct iface_struct *i2)
return r;
}
+int get_interfaces(struct iface_struct *ifaces, int max_interfaces);
/* this wrapper is used to remove duplicates from the interface list generated
above */
-int get_interfaces(struct iface_struct *ifaces, int max_interfaces);
-
int get_interfaces(struct iface_struct *ifaces, int max_interfaces)
{
int total, i, j;
@@ -388,8 +393,6 @@ int get_interfaces(struct iface_struct *ifaces, int max_interfaces)
#ifdef AUTOCONF_TEST
/* this is the autoconf driver to test get_interfaces() */
-#define MAX_INTERFACES 128
-
int main()
{
struct iface_struct ifaces[MAX_INTERFACES];