VirtualBox

Changeset 14194 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
Nov 14, 2008 5:10:28 AM (16 years ago)
Author:
vboxsync
Message:

introduced new event for handling link state changings (need some testing)

Location:
trunk/src/VBox/Devices/Network
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvNAT.cpp

    r14189 r14194  
    8989    /*for send event from guest*/
    9090    HANDLE                  hSendEvent;
     91    HANDLE                  hNetEvent;
    9192#endif
    9293    /** Send buffer */
     
    193194            LogRel(("NAT: link up\n"));
    194195            slirp_link_up(pThis->pNATState);
     196#ifdef VBOX_WITH_SIMPLEFIED_SLIRP_SYNC
     197# ifndef RT_OS_WINDOWS
     198            int rc = RTFileWrite(pThis->PipeWrite, "2", 2, NULL);
     199            AssertRC(rc);
     200# else
     201            WSASetEvent(pThis->hNetEvent);
     202# endif
     203#endif
    195204            break;
    196205
     
    199208            LogRel(("NAT: link down\n"));
    200209            slirp_link_down(pThis->pNATState);
     210#ifdef VBOX_WITH_SIMPLEFIED_SLIRP_SYNC
     211# ifndef RT_OS_WINDOWS
     212            int rc = RTFileWrite(pThis->PipeWrite, "2", 2, NULL);
     213            AssertRC(rc);
     214# else
     215            WSASetEvent(pThis->hNetEvent);
     216# endif
     217#endif
    201218            break;
    202219
     
    325342         * see WSAWaitForMultipleEvents documentation: return value is a minimal index in array
    326343         */
    327         if ((event - WSA_WAIT_EVENT_0) > 0)
     344        if ((event - WSA_WAIT_EVENT_0) >= VBOX_SEND_EVENT_INDEX) {
    328345            slirp_select_poll(pThis->pNATState, &ReadFDs, &WriteFDs, &XcptFDs);
    329346
    330         if ((event - WSA_WAIT_EVENT_0) == 0)
     347        if ((event - WSA_WAIT_EVENT_0) == VBOX_SEND_EVENT_INDEX)
    331348        {
    332349            /** XXX distinguish between drvNATSend and wakeup only */
     
    335352            RTSemEventSignal(pThis->semSndMutex);
    336353        }
     354        if ((event - WSA_WAIT_EVENT_0) == VBOX_NET_EVENT_INDEX) {
     355                WSAResetEvent(pThis->hNetEvent);
     356                break;
     357        }
    337358# endif /* RT_OS_WINDOWS */
    338359    }
     
    355376    int rc = RTFileWrite(pThis->PipeWrite, "2", 2, NULL);
    356377    AssertRC(rc);
     378# else
     379   WSASetEvent(pThis->hNetEvent);
     380# endif
    357381    RTSemEventSignal(pThis->semSndMutex);
    358 #endif
    359382    return VINF_SUCCESS;
    360383}
     
    706729# else
    707730            pThis->hSendEvent = WSACreateEvent();
    708             slirp_register_external_event(pThis->pNATState, pThis->hSendEvent);
     731            pThis->hNetEvent = WSACreateEvent();
     732            slirp_register_external_event(pThis->pNATState, pThis->hSendEvent, VBOX_SEND_EVENT_INDEX);
     733            slirp_register_external_event(pThis->pNATState, pThis->hNetEvent, VBOX_NET_EVENT_INDEX);
    709734# endif
    710735
  • trunk/src/VBox/Devices/Network/slirp/libslirp.h

    r14130 r14194  
    5050
    5151#if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
     52#define VBOX_NET_EVENT_INDEX 0
     53#define VBOX_SEND_EVENT_INDEX 1
     54#define VBOX_SOCKET_EVENT_INDEX 2
    5255HANDLE *slirp_get_events(PNATState pData);
    53 void slirp_register_external_event(PNATState pData, HANDLE hEvent);
     56void slirp_register_external_event(PNATState pData, HANDLE hEvent, int index);
    5457#endif
    5558#ifdef __cplusplus
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r14188 r14194  
    935935        return pData->phEvents;
    936936}
    937 void slirp_register_external_event(PNATState pData, HANDLE hEvent)
    938 {
    939         pData->phEvents[VBOX_SEND_EVENT_INDEX] = hEvent;
    940 }
    941 #endif
     937void slirp_register_external_event(PNATState pData, HANDLE hEvent, int index)
     938{
     939        pData->phEvents[index] = hEvent;
     940}
     941#endif
  • trunk/src/VBox/Devices/Network/slirp/slirp_state.h

    r14186 r14194  
    117117    struct socket *udp_last_so;
    118118#if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
    119 #define VBOX_SEND_EVENT_INDEX 0
    120 #define VBOX_SOCKET_EVENT_INDEX 1
    121119#define VBOX_SOCKET_EVENT (pData->phEvents[VBOX_SOCKET_EVENT_INDEX])
    122 #define VBOX_EVENT_COUNT 2
     120#define VBOX_EVENT_COUNT 3
    123121    HANDLE phEvents[VBOX_EVENT_COUNT];
    124122#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette