From: <no...@so...> - 2002-03-01 10:47:15
|
Bugs item #523084, was opened at 2002-02-26 19:02 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=102435&aid=523084&group_id=2435 Category: w32api Group: None Status: Open Resolution: None Priority: 5 Submitted By: Richard Frith-Macdonald (tiptree) Assigned to: Earnie Boyd (earnie) Summary: winsock2.h struct sizeerror in mingw 1.1 Initial Comment: Looks like some structure size (probably sockaddr) is wrong for newer versions of windoze. On my windoze-xp system, getting a list of interfaces doesn't quite work as expected and only the first address in the list looks ok, with the netmask and broadcast address being all zeros. If I hack the sa_data field of struct sockaddr in winsock2.h to be char sa_data[22]; rather than char sa_data[14]; then things work fine. ---------------------------------------------------------------------- >Comment By: Richard Frith-Macdonald (tiptree) Date: 2002-03-01 10:47 Message: Logged In: YES user_id=470508 With the new headers, my compile falls over at line 472 in winsock2.h, saying 'parse error before inet_ntoa' then 'warning: data definition has no type or storage class' followed by similar errors at 481, 482, 483 ... I looked at the MSDN win32 api docs and couldn't find INTERFACE_INFO_EX or SIO_GET_INTERFACE_LIST_EX Are these documented in some special section somewhere? ---------------------------------------------------------------------- Comment By: Danny Smith (dannysmith) Date: 2002-02-28 20:39 Message: Logged In: YES user_id=11494 While, we've got each other's attention, would you mind testing updated winsock2.h and ws2tcpip.h with your problem on XP. They are in the "Existing Files" box below. have a look at MSDN docs on INTERFACE_INFO_EX and SIO_GET_INTERFACE_LIST_EX ---------------------------------------------------------------------- Comment By: Richard Frith-Macdonald (tiptree) Date: 2002-02-28 10:06 Message: Logged In: YES user_id=470508 Thanks ipv6 up reports that the protocol stack is not installed I haven;t noticed INTERFACE_INFO_EX in the documentation anywhere ... I'll have a look for it and see if it makes any sense to me. ---------------------------------------------------------------------- Comment By: Danny Smith (dannysmith) Date: 2002-02-28 09:49 Message: Logged In: YES user_id=11494 Thanks for the testcase. To find out if you have IPv6 installed type "ipv6 if" at the command prompt. Some changes are indeed needed to both winsock2.h and ws2tcpip.h to provide IPv6/v4 compatability. In particular INTERFACE_INFO has changed and their is a new structure INTERFACE_INFO_EX which does not depend on size of address. I'm in process of testing patches. I don't know whether they are relevant to your problem or not. Cheers ---------------------------------------------------------------------- Comment By: Richard Frith-Macdonald (tiptree) Date: 2002-02-28 09:08 Message: Logged In: YES user_id=470508 OK. Code fragment follows. I'm only assuming this code would work on earlier versions of windows ... I only have an XP system, and haven't had that for long (I'm a GNU/Linux user). I did a standard install of XP - so if there is an option to turn on/off IPv6 support, I didn't see it, and am using the default. I would expect the data structure size to be the same (big enough for IPv6) irrespective of whether the IP code in the kernel was actually using IPv6 ... so I suspect that the winsock2.h file needs some code to vary the size of the structure depending on which version of windows it's being used on. { INTERFACE_INFO InterfaceList[20]; unsigned long nBytesReturned; int i, nNumInterfaces; SOCKET desc = WSASocket(PF_INET, SOCK_RAW, AF_INET, 0, 0, 0); if (desc == INVALID_SOCKET) { fprintf(stderr, "Failed to get a socket. Error %s\n", WSAGetLastError()); exit(1); } memset((void*)InterfaceList, '\0', sizeof(InterfaceList)); if (WSAIoctl(desc, SIO_GET_INTERFACE_LIST, 0, 0, (void*)InterfaceList, sizeof(InterfaceList), &nBytesReturned, 0, 0) == SOCKET_ERROR) { fprintf(stderr, "Failed WSAIoctl. Error %s\n", WSAGetLastError()); exit(1); } nNumInterfaces = nBytesReturned / sizeof(INTERFACE_INFO); for (i = 0; i < nNumInterfaces; i++) { u_long nFlags = InterfaceList[i].iiFlags; if ((nFlags & IFF_UP) && (InterfaceList[i].iiAddress.sa_family == AF_INET)) { fprintf(stderr, "address (%s)\n", inet_ntoa(((struct sockaddr_in*) &(InterfaceList[i].iiAddress))->sin_addr)); fprintf(stderr, "metmask (%s)\n", inet_ntoa(((struct sockaddr_in*) &(InterfaceList[i].iiNetmask))->sin_addr)); fprintf(stderr, "broadcast (%s)\n", inet_ntoa(((struct sockaddr_in*) &(InterfaceList[i].iiBroadcast))->sin_addr)); } } closesocket(desc); } ---------------------------------------------------------------------- Comment By: Danny Smith (dannysmith) Date: 2002-02-26 21:50 Message: Logged In: YES user_id=11494 Can you submit sample code that shows the bug on XP but not on earlier win. XP has IPv6 support and there may be a conflict if you are using that protocol. Danny ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=102435&aid=523084&group_id=2435 |