- Timestamp:
- Nov 28, 2013 8:51:10 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/pxping.c
r49690 r49709 73 73 74 74 SOCKET sock6; 75 #ifdef RT_OS_WINDOWS 76 LPFN_WSARECVMSG pfWSARecvMsg6; 77 #endif 75 78 int hopl; 76 79 … … 168 171 169 172 173 #ifdef RT_OS_WINDOWS 174 static int pxping_init_windows(struct pxping *pxping); 175 #endif 170 176 static void pxping_recv4(void *arg, struct pbuf *p); 171 177 static void pxping_recv6(void *arg, struct pbuf *p); … … 257 263 258 264 g_pxping.sock6 = sock6; 265 #ifdef RT_OS_WINDOWS 266 /* we need recvmsg */ 267 if (g_pxping.sock6 != INVALID_SOCKET) { 268 status = pxping_init_windows(&g_pxping); 269 if (status == SOCKET_ERROR) { 270 g_pxping.sock6 = INVALID_SOCKET; 271 /* close(sock6); */ 272 } 273 } 274 #endif 259 275 if (g_pxping.sock6 != INVALID_SOCKET) { 260 276 g_pxping.hopl = -1; … … 293 309 return ERR_OK; 294 310 } 311 312 313 #ifdef RT_OS_WINDOWS 314 static int 315 pxping_init_windows(struct pxping *pxping) 316 { 317 GUID WSARecvMsgGUID = WSAID_WSARECVMSG; 318 DWORD nread; 319 int status; 320 321 pxping->pfWSARecvMsg6 = NULL; 322 status = WSAIoctl(pxping->sock6, 323 SIO_GET_EXTENSION_FUNCTION_POINTER, 324 &WSARecvMsgGUID, sizeof(WSARecvMsgGUID), 325 &pxping->pfWSARecvMsg6, sizeof(pxping->pfWSARecvMsg6), 326 &nread, 327 NULL, NULL); 328 return status; 329 } 330 #endif /* RT_OS_WINDOWS */ 295 331 296 332 … … 1217 1253 pxping_pmgr_icmp6(struct pxping *pxping) 1218 1254 { 1255 #ifndef RT_OS_WINDOWS 1219 1256 struct msghdr mh; 1220 struct iovec iov[1]; 1257 ssize_t nread; 1258 #else 1259 WSAMSG mh; 1260 DWORD nread; 1261 #endif 1262 IOVEC iov[1]; 1221 1263 static u8_t cmsgbuf[128]; 1222 1264 struct cmsghdr *cmh; 1223 1265 struct sockaddr_in6 sin6; 1224 1266 socklen_t salen = sizeof(sin6); 1225 ssize_t nread;1226 1267 struct icmp6_echo_hdr *icmph; 1227 1268 struct in6_pktinfo *pktinfo; 1228 1269 int hopl, tclass; 1270 int status; 1229 1271 1230 1272 char addrbuf[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"]; … … 1235 1277 * headers are available via recvmsg(2)/cmsg(3). 1236 1278 */ 1279 IOVEC_SET_BASE(iov[0], pollmgr_udpbuf); 1280 IOVEC_SET_LEN(iov[0], sizeof(pollmgr_udpbuf)); 1281 1237 1282 memset(&mh, 0, sizeof(mh)); 1283 #ifndef RT_OS_WINDOWS 1238 1284 mh.msg_name = &sin6; 1239 1285 mh.msg_namelen = sizeof(sin6); 1240 iov[0].iov_base = pollmgr_udpbuf;1241 iov[0].iov_len = sizeof(pollmgr_udpbuf);1242 1286 mh.msg_iov = iov; 1243 1287 mh.msg_iovlen = 1; … … 1251 1295 return; 1252 1296 } 1253 addrstr = inet_ntop(AF_INET6, (void *)&sin6.sin6_addr, addrbuf, sizeof(addrbuf)); 1297 #else /* RT_OS_WINDOWS */ 1298 mh.name = (LPSOCKADDR)&sin6; 1299 mh.namelen = sizeof(sin6); 1300 mh.lpBuffers = iov; 1301 mh.dwBufferCount = 1; 1302 mh.Control.buf = cmsgbuf; 1303 mh.Control.len = sizeof(cmsgbuf); 1304 mh.dwFlags = 0; 1305 1306 status = (*pxping->pfWSARecvMsg6)(pxping->sock6, &mh, &nread, NULL, NULL); 1307 if (status == SOCKET_ERROR) { 1308 DPRINTF2(("%s: error %d\n", __func__, WSAGetLastError())); 1309 return; 1310 } 1311 #endif 1254 1312 1255 1313 icmph = (struct icmp6_echo_hdr *)pollmgr_udpbuf; 1314 1315 addrstr = inet_ntop(AF_INET6, (void *)&sin6.sin6_addr, 1316 addrbuf, sizeof(addrbuf)); 1256 1317 DPRINTF2(("%s: %s ICMPv6: ", __func__, addrstr)); 1257 1318
Note:
See TracChangeset
for help on using the changeset viewer.