Mercurial > pidgin
comparison src/win32/libc_interface.c @ 11364:e1840eb860e7
[gaim-migrate @ 13588]
Make the stun stuff compile on win32. This is largely untested since this code will not currently ever be called, but it compiles. This is based on a patch from Fran?ois Gagn?."
committer: Tailor Script <tailor@pidgin.im>
| author | Daniel Atallah <daniel.atallah@gmail.com> |
|---|---|
| date | Tue, 30 Aug 2005 00:32:32 +0000 |
| parents | e46b51de549a |
| children | d2e44c8085e0 |
comparison
equal
deleted
inserted
replaced
| 11363:78615ddd09ef | 11364:e1840eb860e7 |
|---|---|
| 185 errno = WSAGetLastError(); | 185 errno = WSAGetLastError(); |
| 186 return -1; | 186 return -1; |
| 187 } | 187 } |
| 188 return 0; | 188 return 0; |
| 189 } | 189 } |
| 190 case SIOCGIFCONF: | |
| 191 { | |
| 192 INTERFACE_INFO InterfaceList[20]; | |
| 193 unsigned long nBytesReturned; | |
| 194 if (WSAIoctl(fd, SIO_GET_INTERFACE_LIST, | |
| 195 0, 0, &InterfaceList, | |
| 196 sizeof(InterfaceList), &nBytesReturned, | |
| 197 0, 0) == SOCKET_ERROR) { | |
| 198 errno = WSAGetLastError(); | |
| 199 return -1; | |
| 200 } else { | |
| 201 int i; | |
| 202 struct ifconf *ifc = val; | |
| 203 char *tmp = ifc->ifc_buf; | |
| 204 int nNumInterfaces = | |
| 205 nBytesReturned / sizeof(INTERFACE_INFO); | |
| 206 for (i = 0; i < nNumInterfaces; i++) { | |
| 207 INTERFACE_INFO ii = InterfaceList[i]; | |
| 208 struct ifreq *ifr = (struct ifreq *) tmp; | |
| 209 struct sockaddr_in *sa = (struct sockaddr_in *) &ifr->ifr_addr; | |
| 210 | |
| 211 sa->sin_family = ii.iiAddress.AddressIn.sin_family; | |
| 212 sa->sin_port = ii.iiAddress.AddressIn.sin_port; | |
| 213 sa->sin_addr.s_addr = ii.iiAddress.AddressIn.sin_addr.s_addr; | |
| 214 tmp += sizeof(struct ifreq); | |
| 215 | |
| 216 /* Make sure that we can fit in the original buffer */ | |
| 217 if (tmp >= (ifc->ifc_buf + ifc->ifc_len + sizeof(struct ifreq))) { | |
| 218 break; | |
| 219 } | |
| 220 } | |
| 221 /* Replace the length with the actually used length */ | |
| 222 ifc->ifc_len = ifc->ifc_len - (ifc->ifc_buf - tmp); | |
| 223 } | |
| 224 } | |
| 190 default: | 225 default: |
| 191 errno = EINVAL; | 226 errno = EINVAL; |
| 192 return -1; | 227 return -1; |
| 193 }/*end switch*/ | 228 }/*end switch*/ |
| 194 } | 229 } |
