Changeset 36023 in vbox
- Timestamp:
- Feb 18, 2011 3:01:20 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevINIP.cpp
r35353 r36023 75 75 /** The network port this device provides (LUN\#0). */ 76 76 PDMINETWORKDOWN INetworkDown; 77 /** Tzhe network configuration port this device provides (LUN\#0). */ 78 PDMINETWORKCONFIG INetworkConfig; 77 79 /** The base interface of the network driver below us. */ 78 80 PPDMIBASE pDrvBase; … … 102 104 * provides a proper interface to all IP stack functions. */ 103 105 const void *pLinkHack; 106 /** Flag whether the link is up. */ 107 bool fLnkUp; 104 108 } DEVINTNETIP, *PDEVINTNETIP; 105 109 … … 226 230 { 227 231 PPDMSCATTERGATHER pSgBuf; 232 233 rc = g_pDevINIPData->pDrv->pfnBeginXmit(g_pDevINIPData->pDrv, true /* fOnWorkerThread */); 234 if (RT_FAILURE(rc)) 235 return ERR_IF; 236 228 237 rc = g_pDevINIPData->pDrv->pfnAllocBuf(g_pDevINIPData->pDrv, DEVINIP_MAX_FRAME, NULL /*pGso*/, &pSgBuf); 229 238 if (RT_SUCCESS(rc)) … … 253 262 } 254 263 if (cbBuf) 255 rc = g_pDevINIPData->pDrv->pfnSendBuf(g_pDevINIPData->pDrv, pSgBuf, false); 264 { 265 pSgBuf->cbUsed = cbBuf; 266 rc = g_pDevINIPData->pDrv->pfnSendBuf(g_pDevINIPData->pDrv, pSgBuf, true /* fOnWorkerThread */); 267 } 256 268 else 257 269 rc = g_pDevINIPData->pDrv->pfnFreeBuf(g_pDevINIPData->pDrv, pSgBuf); … … 261 273 #endif 262 274 } 275 276 g_pDevINIPData->pDrv->pfnEndXmit(g_pDevINIPData->pDrv); 263 277 } 264 278 … … 400 414 } 401 415 416 417 /** 418 * Gets the current Media Access Control (MAC) address. 419 * 420 * @returns VBox status code. 421 * @param pInterface Pointer to the interface structure containing the called function pointer. 422 * @param pMac Where to store the MAC address. 423 * @thread EMT 424 */ 425 static DECLCALLBACK(int) devINIPGetMac(PPDMINETWORKCONFIG pInterface, PRTMAC pMac) 426 { 427 PDEVINTNETIP pThis = RT_FROM_MEMBER(pInterface, DEVINTNETIP, INetworkConfig); 428 memcpy(pMac, pThis->MAC.au8, sizeof(RTMAC)); 429 return VINF_SUCCESS; 430 } 431 432 /** 433 * Gets the new link state. 434 * 435 * @returns The current link state. 436 * @param pInterface Pointer to the interface structure containing the called function pointer. 437 * @thread EMT 438 */ 439 static DECLCALLBACK(PDMNETWORKLINKSTATE) devINIPGetLinkState(PPDMINETWORKCONFIG pInterface) 440 { 441 PDEVINTNETIP pThis = RT_FROM_MEMBER(pInterface, DEVINTNETIP, INetworkConfig); 442 if (pThis->fLnkUp) 443 return PDMNETWORKLINKSTATE_UP; 444 return PDMNETWORKLINKSTATE_DOWN; 445 } 446 447 448 /** 449 * Sets the new link state. 450 * 451 * @returns VBox status code. 452 * @param pInterface Pointer to the interface structure containing the called function pointer. 453 * @param enmState The new link state 454 */ 455 static DECLCALLBACK(int) devINIPSetLinkState(PPDMINETWORKCONFIG pInterface, PDMNETWORKLINKSTATE enmState) 456 { 457 PDEVINTNETIP pThis = RT_FROM_MEMBER(pInterface, DEVINTNETIP, INetworkConfig); 458 bool fNewUp = enmState == PDMNETWORKLINKSTATE_UP; 459 460 if (fNewUp != pThis->fLnkUp) 461 { 462 if (fNewUp) 463 { 464 LogFlowFunc(("Link is up\n")); 465 pThis->fLnkUp = true; 466 } 467 else 468 { 469 LogFlowFunc(("Link is down\n")); 470 pThis->fLnkUp = false; 471 } 472 if (pThis->pDrv) 473 pThis->pDrv->pfnNotifyLinkChanged(pThis->pDrv, enmState); 474 } 475 return VINF_SUCCESS; 476 } 477 402 478 /* -=-=-=-=- PDMIBASE -=-=-=-=- */ 403 479 … … 411 487 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase); 412 488 PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKDOWN, &pThis->INetworkDown); 489 PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONFIG, &pThis->INetworkConfig); 413 490 return NULL; 414 491 } … … 491 568 pThis->INetworkDown.pfnReceive = devINIPNetworkDown_Input; 492 569 pThis->INetworkDown.pfnXmitPending = devINIPNetworkDown_XmitPending; 570 /* INetworkConfig */ 571 pThis->INetworkConfig.pfnGetMac = devINIPGetMac; 572 pThis->INetworkConfig.pfnGetLinkState = devINIPGetLinkState; 573 pThis->INetworkConfig.pfnSetLinkState = devINIPSetLinkState; 493 574 494 575 /*
Note:
See TracChangeset
for help on using the changeset viewer.