90
86
struct VBoxNetAdapter
92
#ifdef VBOXANETADP_DO_NOT_USE_NETFLT
93
/** The spinlock protecting the state variables and host interface handle. */
96
/* --- Protected with spinlock. --- */
98
#endif /* !VBOXANETADP_DO_NOT_USE_NETFLT */
99
88
/** Denotes availability of this slot in adapter array. */
100
89
VBOXNETADPSTATE enmState;
101
#ifdef VBOXANETADP_DO_NOT_USE_NETFLT
103
/* --- Unprotected. Atomic access. --- */
105
/** Reference count. */
106
uint32_t volatile cRefs;
108
* This counts the number of current callers and pending packet. */
109
uint32_t volatile cBusy;
111
/* --- Unprotected. Do not modify when cBusy > 0. --- */
114
* This is what the internal network plugs into. */
115
INTNETTRUNKIFPORT MyPort;
116
/** The RJ-45 port on the INTNET "switch".
117
* This is what we're connected to. */
118
PINTNETTRUNKSWPORT pSwitchPort;
119
/** Pointer to the globals. */
120
PVBOXNETADPGLOBALS pGlobals;
121
/** The event that is signaled when we go idle and that pfnWaitForIdle blocks on. */
122
RTSEMEVENT hEventIdle;
123
#endif /* !VBOXANETADP_DO_NOT_USE_NETFLT */
124
90
/** Corresponds to the digit at the end of device name. */
176
142
DECLHIDDEN(int) vboxNetAdpCreate (PVBOXNETADP *ppNew);
177
143
DECLHIDDEN(int) vboxNetAdpDestroy(PVBOXNETADP pThis);
178
144
DECLHIDDEN(PVBOXNETADP) vboxNetAdpFindByName(const char *pszName);
180
#ifdef VBOXANETADP_DO_NOT_USE_NETFLT
182
* The global data of the VBox filter driver.
184
* This contains the bit required for communicating with support driver, VBoxDrv
185
* (start out as SupDrv).
187
typedef struct VBOXNETADPGLOBALS
189
/** Mutex protecting the list of instances and state changes. */
190
RTSEMFASTMUTEX hFastMtx;
191
/** Array of adapter instances. */
192
VBOXNETADP aAdapters[VBOXNETADP_MAX_INSTANCES];
194
/** The INTNET trunk network interface factory. */
195
INTNETTRUNKFACTORY TrunkFactory;
196
/** The SUPDRV component factory registration. */
197
SUPDRVFACTORY SupDrvFactory;
198
/** The number of current factory references. */
199
int32_t volatile cFactoryRefs;
200
/** The SUPDRV IDC handle (opaque struct). */
201
SUPDRVIDCHANDLE SupDrvIDC;
205
145
DECLHIDDEN(void) vboxNetAdpComposeMACAddress(PVBOXNETADP pThis, PRTMAC pMac);
206
DECLHIDDEN(void) vboxNetAdpReceive(PVBOXNETADP pThis, PINTNETSG pSG);
207
DECLHIDDEN(bool) vboxNetAdpPrepareToReceive(PVBOXNETADP pThis);
208
DECLHIDDEN(void) vboxNetAdpCancelReceive(PVBOXNETADP pThis);
210
DECLHIDDEN(int) vboxNetAdpInitGlobals(PVBOXNETADPGLOBALS pGlobals);
211
DECLHIDDEN(int) vboxNetAdpTryDeleteGlobals(PVBOXNETADPGLOBALS pGlobals);
212
DECLHIDDEN(bool) vboxNetAdpCanUnload(PVBOXNETADPGLOBALS pGlobals);
214
DECLHIDDEN(void) vboxNetAdpRetain(PVBOXNETADP pThis);
215
DECLHIDDEN(void) vboxNetAdpRelease(PVBOXNETADP pThis);
216
DECLHIDDEN(void) vboxNetAdpBusy(PVBOXNETADP pThis);
217
DECLHIDDEN(void) vboxNetAdpIdle(PVBOXNETADP pThis);
219
DECLHIDDEN(int) vboxNetAdpInitGlobalsBase(PVBOXNETADPGLOBALS pGlobals);
220
DECLHIDDEN(int) vboxNetAdpInitIdc(PVBOXNETADPGLOBALS pGlobals);
221
DECLHIDDEN(void) vboxNetAdpDeleteGlobalsBase(PVBOXNETADPGLOBALS pGlobals);
222
DECLHIDDEN(int) vboxNetAdpTryDeleteIdc(PVBOXNETADPGLOBALS pGlobals);
226
/** @name The OS specific interface.
231
* @return IPRT status code.
232
* @param pThis The new instance.
233
* @param pSG The (scatter/)gather list.
234
* @param fDst The destination mask. At least one bit will be set.
236
* @remarks Owns the out-bound trunk port semaphore.
238
DECLHIDDEN(int) vboxNetAdpPortOsXmit(PVBOXNETADP pThis, PINTNETSG pSG, uint32_t fDst);
241
* Checks if the interface is in promiscuous mode from the host perspective.
243
* If it is, then the internal networking switch will send frames
244
* heading for the wire to the host as well.
246
* @see INTNETTRUNKIFPORT::pfnIsPromiscuous for more details.
248
* @returns true / false accordingly.
249
* @param pThis The instance.
251
* @remarks Owns the network lock and the out-bound trunk port semaphores.
253
DECLHIDDEN(bool) vboxNetAdpPortOsIsPromiscuous(PVBOXNETADP pThis);
256
* Get the MAC address of the interface we're attached to.
258
* Used by the internal networking switch for implementing the
259
* shared-MAC-on-the-wire mode.
261
* @param pThis The instance.
262
* @param pMac Where to store the MAC address.
263
* If you don't know, set all the bits except the first (the multicast one).
265
* @remarks Owns the network lock and the out-bound trunk port semaphores.
267
DECLHIDDEN(void) vboxNetAdpPortOsGetMacAddress(PVBOXNETADP pThis, PRTMAC pMac);
270
* Checks if the specified MAC address is for any of the host interfaces.
272
* Used by the internal networking switch to decide the destination(s)
275
* @returns true / false accordingly.
276
* @param pThis The instance.
277
* @param pMac The MAC address.
279
* @remarks Owns the network lock and the out-bound trunk port semaphores.
281
DECLHIDDEN(bool) vboxNetAdpPortOsIsHostMac(PVBOXNETADP pThis, PCRTMAC pMac);
284
* This is called to when disconnecting from a network.
286
* @return IPRT status code.
287
* @param pThis The new instance.
289
* @remarks May own the semaphores for the global list, the network lock and the out-bound trunk port.
291
DECLHIDDEN(int) vboxNetAdpOsDisconnectIt(PVBOXNETADP pThis);
294
* This is called to when connecting to a network.
296
* @return IPRT status code.
297
* @param pThis The new instance.
299
* @remarks Owns the semaphores for the global list, the network lock and the out-bound trunk port.
301
DECLHIDDEN(int) vboxNetAdpOsConnectIt(PVBOXNETADP pThis);
304
#endif /* !VBOXANETADP_DO_NOT_USE_NETFLT */
307
149
* This is called to perform OS-specific structure initializations.