Changeset 50321 in vbox for trunk/src/VBox/HostDrivers/VBoxNetAdp/darwin
- Timestamp:
- Feb 5, 2014 8:30:46 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 92043
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetAdp/darwin/VBoxNetAdp-darwin.cpp
r49686 r50321 32 32 #include <VBox/err.h> 33 33 #include <VBox/version.h> 34 #include <VBox/VBoxNetSend.h> 34 35 #include <iprt/assert.h> 35 36 #include <iprt/initterm.h> … … 233 234 } 234 235 235 236 /**237 * Constructs and submits a dummy packet to ifnet_input(). This is a workaround238 * for "stuck dock icon" issue. When the first packet goes through the interface239 * DLIL grabs a reference to the thread that submits the packet and holds it240 * until the interface is destroyed. By submitting this dummy we make DLIL grab241 * the thread of a non-GUI process.242 *243 * Most of this function was copied from vboxNetFltDarwinMBufFromSG().244 *245 * @returns VBox status code.246 * @param pIfNet The interface that will hold the reference to the calling247 * thread. We submit dummy as if it was coming from this interface.248 */249 static int vboxNetSendDummy(ifnet_t pIfNet)250 {251 int rc = 0;252 size_t cbTotal = 50; /* No Ethernet header */253 mbuf_how_t How = MBUF_WAITOK;254 255 mbuf_t pPkt = NULL;256 errno_t err = mbuf_allocpacket(How, cbTotal, NULL, &pPkt);257 if (!err)258 {259 /* Skip zero sized memory buffers (paranoia). */260 mbuf_t pCur = pPkt;261 while (pCur && !mbuf_maxlen(pCur))262 pCur = mbuf_next(pCur);263 Assert(pCur);264 265 /* Set the required packet header attributes. */266 mbuf_pkthdr_setlen(pPkt, cbTotal);267 mbuf_pkthdr_setheader(pPkt, mbuf_data(pCur));268 269 mbuf_setlen(pCur, cbTotal);270 memset(mbuf_data(pCur), 0, cbTotal);271 272 mbuf_pkthdr_setrcvif(pPkt, pIfNet); /* will crash without this. */273 274 errno_t err = ifnet_input(pIfNet, pPkt, NULL);275 if (err)276 {277 rc = RTErrConvertFromErrno(err);278 mbuf_freem(pPkt);279 }280 }281 else282 rc = RTErrConvertFromErrno(err);283 284 return rc;285 }286 236 287 237 int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMACAddress) … … 347 297 { 348 298 ifnet_set_mtu(pThis->u.s.pIface, VBOXNETADP_MTU); 349 vboxNetSendDummy(pThis->u.s.pIface);299 VboxNetSendDummy(pThis->u.s.pIface); 350 300 return VINF_SUCCESS; 351 301 }
Note:
See TracChangeset
for help on using the changeset viewer.