Minor bugfix

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@12799 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-02-26 18:23:32 +00:00
parent e3526bbda3
commit 55cec8fe8a
2 changed files with 35 additions and 10 deletions

View file

@ -1,3 +1,11 @@
2002-02-26 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/gdomap.c: Improve fetching interface info on mingw ...
ignore non-internet interfaces.
NB. The mingw winsock2.h header is buggy ... to work properly
you need to change the size of a struct sockaddr field from
sa_data[14] to sa_data[22]
Tue Feb 26 18:01:26 2002 Nicola Pero <nicola@brainstorm.co.uk>
* Source/NSBundle.m: Removed all _releasedBundles machinery.

View file

@ -1132,17 +1132,18 @@ init_iface()
#ifdef __MINGW__
INTERFACE_INFO InterfaceList[20];
unsigned long nBytesReturned;
int i, nNumInterfaces;
SOCKET desc = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0);
int i, countActive, nNumInterfaces;
SOCKET desc = WSASocket(PF_INET, SOCK_RAW, AF_INET, 0, 0, 0);
if (desc == SOCKET_ERROR)
if (desc == INVALID_SOCKET)
{
sprintf(ebuf, "Failed to get a socket. Error %s\n", WSAGetLastError());
log(LOG_CRIT);
exit(1);
}
if (WSAIoctl(desc, SIO_GET_INTERFACE_LIST, 0, 0, &InterfaceList,
memset((void*)InterfaceList, '\0', sizeof(InterfaceList));
if (WSAIoctl(desc, SIO_GET_INTERFACE_LIST, 0, 0, (void*)InterfaceList,
sizeof(InterfaceList), &nBytesReturned, 0, 0) == SOCKET_ERROR)
{
sprintf(ebuf, "Failed WSAIoctl. Error %s\n", WSAGetLastError());
@ -1152,23 +1153,39 @@ init_iface()
nNumInterfaces = nBytesReturned / sizeof(INTERFACE_INFO);
/*
* See how many active entries there are.
*/
countActive = 0;
for (i = 0; i < nNumInterfaces; i++)
{
u_long nFlags = InterfaceList[i].iiFlags;
if ((nFlags & IFF_UP)
&& (InterfaceList[i].iiAddress.sa_family == AF_INET))
{
countActive++;
}
}
/*
* Allocate enough space for all interfaces.
*/
if (addr != 0) free(addr);
addr = (struct in_addr*)malloc((nNumInterfaces+1)*IASIZE);
addr = (struct in_addr*)malloc((countActive+1)*IASIZE);
if (bcok != 0) free(bcok);
bcok = (char*)malloc((nNumInterfaces+1)*sizeof(char));
bcok = (char*)malloc((countActive+1)*sizeof(char));
if (bcst != 0) free(bcst);
bcst = (struct in_addr*)malloc((nNumInterfaces+1)*IASIZE);
bcst = (struct in_addr*)malloc((countActive+1)*IASIZE);
if (mask != 0) free(mask);
mask = (struct in_addr*)malloc((nNumInterfaces+1)*IASIZE);
mask = (struct in_addr*)malloc((countActive+1)*IASIZE);
for (i = 0; i < nNumInterfaces; i++)
{
u_long nFlags = InterfaceList[i].iiFlags;
if (nFlags & IFF_UP)
if ((nFlags & IFF_UP)
&& (InterfaceList[i].iiAddress.sa_family == AF_INET))
{
int broadcast = 0;
int pointopoint = 0;
@ -4106,7 +4123,7 @@ main(int argc, char** argv)
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD(2, 0);
wVersionRequested = MAKEWORD(2, 2);
WSAStartup(wVersionRequested, &wsaData);
#endif