Changeset 14041 in vbox for trunk/src/VBox/Devices/Network/slirp/slirp.c
- Timestamp:
- Nov 10, 2008 8:24:43 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/slirp.c
r14028 r14041 347 347 int nfds; 348 348 int tmp_time; 349 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 349 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 350 350 int rc; 351 int chEvents = 1; /*store for send see DrvNAT*/ 352 int cchEvents = 0; /*counter*/ 351 /* Number of valid entries. 352 * 1st event for drvNATSend() */ 353 int cElements; 354 int cEvents = 1; 353 355 #endif 354 356 … … 366 368 ((struct ipasfrag *)&ipq != u32_to_ptr(pData, ipq.next, struct ipasfrag *))); 367 369 368 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 369 for (so = tcb.so_next; so != &tcb; so = so_next, chEvents++); 370 for (so = udb.so_next; so != &udb; so = so_next, chEvents++); 371 if (pData->phEvents != NULL) free(pData->phEvents); 372 pData->phEvents = malloc(sizeof(HANDLE) * chEvents); 373 #endif 374 370 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 371 /* 372 * Make this array static with a fixed maximum 373 * 1st event for drvNATSend() 374 */ 375 cElements = 1; 376 for (so = tcb.so_next; so != &tcb; so = so_next, cElements++) 377 ; 378 for (so = udb.so_next; so != &udb; so = so_next, cElements++) 379 ; 380 if (pData->phEvents != NULL) 381 free(pData->phEvents); 382 pData->phEvents = malloc(sizeof(HANDLE) * cElements); 383 #endif 384 375 385 for (so = tcb.so_next; so != &tcb; so = so_next) { 376 386 so_next = so->so_next; … … 393 403 */ 394 404 if (so->so_state & SS_FACCEPTCONN) { 395 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 405 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 396 406 FD_SET(so->s, readfds); 397 407 UPD_NFDS(so->s); … … 399 409 rc = WSAEventSelect(so->s, so->hNetworkEvent, FD_READ); 400 410 AssertRelease(rc != SOCKET_ERROR); 401 pData->phEvents[cchEvents] = so->hNetworkEvent; 411 pData->phEvents[cEvents] = so->hNetworkEvent; 412 cEvents++; 402 413 #endif 403 414 continue; … … 408 419 */ 409 420 if (so->so_state & SS_ISFCONNECTING) { 410 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 421 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 411 422 FD_SET(so->s, writefds); 412 423 UPD_NFDS(so->s); … … 414 425 rc = WSAEventSelect(so->s, so->hNetworkEvent, FD_READ); 415 426 AssertRelease(rc != SOCKET_ERROR); 416 pData->phEvents[cchEvents] = so->hNetworkEvent; 427 pData->phEvents[cEvents] = so->hNetworkEvent; 428 cEvents++; 417 429 #endif 418 430 continue; … … 424 436 */ 425 437 if (CONN_CANFSEND(so) && so->so_rcv.sb_cc) { 426 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 438 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 427 439 FD_SET(so->s, writefds); 428 440 UPD_NFDS(so->s); … … 430 442 rc = WSAEventSelect(so->s, so->hNetworkEvent, FD_WRITE); 431 443 AssertRelease(rc != SOCKET_ERROR); 432 pData->phEvents[cchEvents] = so->hNetworkEvent; 444 pData->phEvents[cEvents] = so->hNetworkEvent; 445 cEvents++; 433 446 #endif 434 447 } … … 439 452 */ 440 453 if (CONN_CANFRCV(so) && (so->so_snd.sb_cc < (so->so_snd.sb_datalen/2))) { 441 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 454 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 442 455 FD_SET(so->s, readfds); 443 456 FD_SET(so->s, xfds); … … 446 459 rc = WSAEventSelect(so->s, so->hNetworkEvent, FD_OOB|FD_READ); 447 460 AssertRelease(rc != SOCKET_ERROR); 448 pData->phEvents[cchEvents] = so->hNetworkEvent; 461 pData->phEvents[cEvents] = so->hNetworkEvent; 462 cEvents++; 449 463 #endif 450 464 } 451 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)452 cchEvents++;453 #endif454 465 } 455 466 … … 482 493 */ 483 494 if ((so->so_state & SS_ISFCONNECTED) && so->so_queued <= 4) { 484 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 495 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 485 496 FD_SET(so->s, readfds); 486 497 UPD_NFDS(so->s); … … 488 499 rc = WSAEventSelect(so->s, so->hNetworkEvent, FD_READ); 489 500 AssertRelease(rc != SOCKET_ERROR); 490 pData->phEvents[cchEvents] = so->hNetworkEvent; 501 pData->phEvents[cEvents] = so->hNetworkEvent; 502 cEvents++; 491 503 #endif 492 504 } 493 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)494 cchEvents++;495 #endif496 505 } 497 506 } … … 530 539 } 531 540 } 532 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 541 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 533 542 *pnfds = nfds; 534 543 #else 535 *pnfds = c hEvents;544 *pnfds = cEvents; 536 545 #endif 537 546 } … … 541 550 struct socket *so, *so_next; 542 551 int ret; 543 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 552 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 544 553 WSANETWORKEVENTS NetworkEvents; 545 554 int rc; … … 573 582 for (so = tcb.so_next; so != &tcb; so = so_next) { 574 583 so_next = so->so_next; 575 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 584 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 576 585 rc = WSAEnumNetworkEvents(so->s, so->hNetworkEvent, &NetworkEvents); 577 586 AssertRelease(rc != SOCKET_ERROR); … … 590 599 * test for readfds below if this succeeds 591 600 */ 592 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 601 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 593 602 if (FD_ISSET(so->s, xfds)) 594 603 #else … … 599 608 * Check sockets for reading 600 609 */ 601 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 610 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 602 611 else if (FD_ISSET(so->s, readfds)) { 603 612 #else … … 609 618 if (so->so_state & SS_FACCEPTCONN) { 610 619 tcp_connect(pData, so); 611 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 620 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 612 621 WSAResetEvent(so->hNetworkEvent); 613 622 #endif … … 624 633 * Check sockets for writing 625 634 */ 626 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 635 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 627 636 if (FD_ISSET(so->s, writefds)) { 628 637 #else … … 648 657 if (errno == EAGAIN || errno == EWOULDBLOCK || 649 658 errno == EINPROGRESS || errno == ENOTCONN) { 650 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 659 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 651 660 WSAResetEvent(so->hNetworkEvent); 652 661 #endif … … 687 696 if (errno == EAGAIN || errno == EWOULDBLOCK || 688 697 errno == EINPROGRESS || errno == ENOTCONN) { 689 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 698 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 690 699 WSAResetEvent(so->hNetworkEvent); 691 700 #endif … … 703 712 if (errno == EAGAIN || errno == EWOULDBLOCK || 704 713 errno == EINPROGRESS || errno == ENOTCONN) { 705 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 714 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 706 715 WSAResetEvent(so->hNetworkEvent); 707 716 #endif … … 727 736 so_next = so->so_next; 728 737 729 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 738 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 730 739 rc = WSAEnumNetworkEvents(so->s, so->hNetworkEvent, &NetworkEvents); 731 740 AssertRelease(rc != SOCKET_ERROR); 732 741 #endif 733 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 742 #if !defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS) 734 743 if (so->s != -1 && FD_ISSET(so->s, readfds)) { 735 744 #else … … 737 746 #endif 738 747 sorecvfrom(pData, so); 739 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 748 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 740 749 WSAResetEvent(so->hNetworkEvent); 741 750 #endif … … 918 927 } 919 928 920 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 929 #if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 921 930 HANDLE *slirp_get_events(PNATState pData) 922 931 {
Note:
See TracChangeset
for help on using the changeset viewer.