mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fixes for variable length socket addresses.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@12215 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d9a332a927
commit
a945079509
6 changed files with 363 additions and 266 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2002-01-25 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* acconfig.h: Add HAVE_SA_LEN
|
||||
* configure.in: Check for sa_len in sockaddr in struct ifreq
|
||||
* configure: regenerate
|
||||
* Headers/gnustep/base/config.h.in: regenerate
|
||||
* Tools/gdomap.c: Add patch by Pete French <pete@twisted.org.uk>
|
||||
to handle variable length socket addresses ... modified to work
|
||||
with the rest of the world where we don't have such things.
|
||||
|
||||
2002-01-24 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSRunLoop.m: Correct returns from within exception handler.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Headers/gnustep/base/config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
/* Headers/gnustep/base/config.h.in. Generated automatically from configure.in by autoheader 2.13. */
|
||||
|
||||
/* Define as __inline if that's what the C compiler calls it. */
|
||||
#undef inline
|
||||
|
@ -42,6 +42,9 @@
|
|||
/* Define if your Lib C defines program_invocation_name */
|
||||
#undef HAVE_PROGRAM_INVOCATION_NAME
|
||||
|
||||
/* Define if your system has variable length network addresses */
|
||||
#undef HAVE_SA_LEN
|
||||
|
||||
/* Define if using the libffi library for invocations */
|
||||
#undef USE_LIBFFI
|
||||
|
||||
|
|
|
@ -1082,11 +1082,10 @@ init_iface()
|
|||
#ifdef SIOCGIFCONF
|
||||
struct ifconf ifc;
|
||||
struct ifreq ifreq;
|
||||
struct ifreq *ifr;
|
||||
struct ifreq *final;
|
||||
void *final;
|
||||
void *ifr_ptr;
|
||||
char buf[MAX_IFACE * sizeof(struct ifreq)];
|
||||
int desc;
|
||||
int num_iface;
|
||||
|
||||
if ((desc = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
{
|
||||
|
@ -1120,8 +1119,7 @@ init_iface()
|
|||
/*
|
||||
* Find the IP address of each active network interface.
|
||||
*/
|
||||
num_iface = ifc.ifc_len / sizeof(struct ifreq);
|
||||
if (num_iface == 0)
|
||||
if (ifc.ifc_len == 0)
|
||||
{
|
||||
int res = errno;
|
||||
|
||||
|
@ -1129,9 +1127,7 @@ init_iface()
|
|||
if (res == EINVAL)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Either you have too many network interfaces on your machine (in which case\n"
|
||||
"you need to change the 'MAX_IFACE' constant in gdomap.c and rebuild it), or\n"
|
||||
"your system is buggy, and you need to use the '-a' command line flag for\n"
|
||||
"Your system is buggy, thus you need to use the '-a' command line flag for\n"
|
||||
"gdomap to manually set the interface addresses and masks to be used.\n");
|
||||
}
|
||||
#ifdef __MINGW__
|
||||
|
@ -1141,19 +1137,29 @@ init_iface()
|
|||
#endif
|
||||
exit(1);
|
||||
}
|
||||
/*
|
||||
* We cannot know the number of interfaces in advance, thus we
|
||||
* need to malloc to MAX_IFACE toensure sufficient space
|
||||
*/
|
||||
if (addr != 0) free(addr);
|
||||
addr = (struct in_addr*)malloc((num_iface+1)*IASIZE);
|
||||
addr = (struct in_addr*)malloc((MAX_IFACE+1)*IASIZE);
|
||||
if (bcok != 0) free(bcok);
|
||||
bcok = (char*)malloc((num_iface+1)*sizeof(char));
|
||||
bcok = (char*)malloc((MAX_IFACE+1)*sizeof(char));
|
||||
if (bcst != 0) free(bcst);
|
||||
bcst = (struct in_addr*)malloc((num_iface+1)*IASIZE);
|
||||
bcst = (struct in_addr*)malloc((MAX_IFACE+1)*IASIZE);
|
||||
if (mask != 0) free(mask);
|
||||
mask = (struct in_addr*)malloc((num_iface+1)*IASIZE);
|
||||
mask = (struct in_addr*)malloc((MAX_IFACE+1)*IASIZE);
|
||||
|
||||
final = (struct ifreq*)&ifc.ifc_buf[ifc.ifc_len];
|
||||
for (ifr = ifc.ifc_req; ifr < final; ifr++)
|
||||
final = &ifc.ifc_buf[ifc.ifc_len];
|
||||
for (ifr_ptr = ifc.ifc_req; ifr_ptr < final;)
|
||||
{
|
||||
ifreq = *ifr;
|
||||
ifreq = *(struct ifreq*)ifr_ptr;
|
||||
#ifdef HAVE_SA_LEN
|
||||
ifr_ptr += sizeof(ifreq) - sizeof(ifreq.ifr_name) + ifreq.ifr_addr.sa_len;
|
||||
#else
|
||||
ifr_ptr += sizeof(ifreq);
|
||||
#endif
|
||||
|
||||
if (ioctl(desc, SIOCGIFFLAGS, (char *)&ifreq) < 0)
|
||||
{
|
||||
perror("SIOCGIFFLAGS");
|
||||
|
@ -1162,6 +1168,7 @@ init_iface()
|
|||
{ /* interface is up */
|
||||
int broadcast = 0;
|
||||
int pointopoint = 0;
|
||||
int loopback = 0;
|
||||
|
||||
if (ifreq.ifr_flags & IFF_BROADCAST)
|
||||
{
|
||||
|
@ -1172,6 +1179,12 @@ init_iface()
|
|||
{
|
||||
pointopoint = 1;
|
||||
}
|
||||
#endif
|
||||
#ifdef IFF_LOOPBACK
|
||||
if (ifreq.ifr_flags & IFF_LOOPBACK)
|
||||
{
|
||||
loopback = 1;
|
||||
}
|
||||
#endif
|
||||
if (ioctl(desc, SIOCGIFADDR, (char *)&ifreq) < 0)
|
||||
{
|
||||
|
@ -1213,7 +1226,8 @@ init_iface()
|
|||
else
|
||||
#endif
|
||||
{
|
||||
if (ioctl(desc, SIOCGIFBRDADDR, (char*)&ifreq) < 0)
|
||||
if (!loopback &&
|
||||
ioctl(desc, SIOCGIFBRDADDR, (char*)&ifreq) < 0)
|
||||
{
|
||||
perror("SIOCGIFBRDADDR");
|
||||
bcok[interfaces] = 0;
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
/* Define if your Lib C defines program_invocation_name */
|
||||
#undef HAVE_PROGRAM_INVOCATION_NAME
|
||||
|
||||
/* Define if your system has variable length network addresses */
|
||||
#undef HAVE_SA_LEN
|
||||
|
||||
|
||||
/* Define if using the libffi library for invocations */
|
||||
#undef USE_LIBFFI
|
||||
|
||||
|
|
19
configure.in
19
configure.in
|
@ -132,6 +132,25 @@ if test $ac_cv_header_objc_objc_h = no; then
|
|||
AC_MSG_ERROR(Could not find Objective-C headers)
|
||||
fi
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Check for strange network stuff used by gdomap
|
||||
#--------------------------------------------------------------------
|
||||
AC_MSG_CHECKING(for gdomap network details)
|
||||
AC_MSG_CHECKING(for variable length socket addresses)
|
||||
AC_TRY_COMPILE([#include <net/if.h>],
|
||||
[struct ifreq s; s.ifr_addr.sa_len = 0;],
|
||||
sa_len=1, sa_len=0)
|
||||
if test $sa_len = 1; then
|
||||
AC_MSG_RESULT([found])
|
||||
AC_DEFINE(HAVE_SA_LEN)
|
||||
else
|
||||
AC_MSG_RESULT([not found])
|
||||
fi
|
||||
|
||||
#
|
||||
|
||||
#
|
||||
AC_MSG_CHECKING(for objc threading flags)
|
||||
#--------------------------------------------------------------------
|
||||
# Check for thread flags for libobjc.
|
||||
#--------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue