1 | /** @file
|
---|
2 | * INTNET - Internal Networking. (DEV,++)
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2011 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___VBox_intnet_h
|
---|
27 | #define ___VBox_intnet_h
|
---|
28 |
|
---|
29 | #include <VBox/types.h>
|
---|
30 | #include <VBox/vmm/stam.h>
|
---|
31 | #include <VBox/sup.h>
|
---|
32 | #include <iprt/assert.h>
|
---|
33 | #include <iprt/asm.h>
|
---|
34 |
|
---|
35 | RT_C_DECLS_BEGIN
|
---|
36 |
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Generic two-sided ring buffer.
|
---|
40 | *
|
---|
41 | * The deal is that there is exactly one writer and one reader.
|
---|
42 | * When offRead equals offWrite the buffer is empty. In the other
|
---|
43 | * extreme the writer will not use the last free byte in the buffer.
|
---|
44 | */
|
---|
45 | typedef struct INTNETRINGBUF
|
---|
46 | {
|
---|
47 | /** The offset from this structure to the start of the buffer. */
|
---|
48 | uint32_t offStart;
|
---|
49 | /** The offset from this structure to the end of the buffer. (exclusive). */
|
---|
50 | uint32_t offEnd;
|
---|
51 | /** The current read offset. */
|
---|
52 | uint32_t volatile offReadX;
|
---|
53 | /** Alignment. */
|
---|
54 | uint32_t u32Align0;
|
---|
55 |
|
---|
56 | /** The committed write offset. */
|
---|
57 | uint32_t volatile offWriteCom;
|
---|
58 | /** Writer internal current write offset.
|
---|
59 | * This is ahead of offWriteCom when buffer space is handed to a third party for
|
---|
60 | * data gathering. offWriteCom will be assigned this value by the writer then
|
---|
61 | * the frame is ready. */
|
---|
62 | uint32_t volatile offWriteInt;
|
---|
63 | /** The number of bytes written (not counting overflows). */
|
---|
64 | STAMCOUNTER cbStatWritten;
|
---|
65 | /** The number of frames written (not counting overflows). */
|
---|
66 | STAMCOUNTER cStatFrames;
|
---|
67 | /** The number of overflows. */
|
---|
68 | STAMCOUNTER cOverflows;
|
---|
69 | } INTNETRINGBUF;
|
---|
70 | AssertCompileSize(INTNETRINGBUF, 48);
|
---|
71 | /** Pointer to a ring buffer. */
|
---|
72 | typedef INTNETRINGBUF *PINTNETRINGBUF;
|
---|
73 |
|
---|
74 | /** The alignment of a ring buffer. */
|
---|
75 | #define INTNETRINGBUF_ALIGNMENT sizeof(INTNETHDR)
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Asserts the sanity of the specified INTNETRINGBUF structure.
|
---|
79 | */
|
---|
80 | #ifdef VBOX_STRICT
|
---|
81 | # define INTNETRINGBUF_ASSERT_SANITY(pRingBuf) \
|
---|
82 | do \
|
---|
83 | { \
|
---|
84 | AssertPtr(pRingBuf); \
|
---|
85 | { \
|
---|
86 | uint32_t const offWriteCom = (pRingBuf)->offWriteCom; \
|
---|
87 | uint32_t const offRead = (pRingBuf)->offReadX; \
|
---|
88 | uint32_t const offWriteInt = (pRingBuf)->offWriteInt; \
|
---|
89 | \
|
---|
90 | AssertMsg(offWriteCom == RT_ALIGN_32(offWriteCom, INTNETHDR_ALIGNMENT), ("%#x\n", offWriteCom)); \
|
---|
91 | AssertMsg(offWriteCom >= (pRingBuf)->offStart, ("%#x %#x\n", offWriteCom, (pRingBuf)->offStart)); \
|
---|
92 | AssertMsg(offWriteCom < (pRingBuf)->offEnd, ("%#x %#x\n", offWriteCom, (pRingBuf)->offEnd)); \
|
---|
93 | \
|
---|
94 | AssertMsg(offRead == RT_ALIGN_32(offRead, INTNETHDR_ALIGNMENT), ("%#x\n", offRead)); \
|
---|
95 | AssertMsg(offRead >= (pRingBuf)->offStart, ("%#x %#x\n", offRead, (pRingBuf)->offStart)); \
|
---|
96 | AssertMsg(offRead < (pRingBuf)->offEnd, ("%#x %#x\n", offRead, (pRingBuf)->offEnd)); \
|
---|
97 | \
|
---|
98 | AssertMsg(offWriteInt == RT_ALIGN_32(offWriteInt, INTNETHDR_ALIGNMENT), ("%#x\n", offWriteInt)); \
|
---|
99 | AssertMsg(offWriteInt >= (pRingBuf)->offStart, ("%#x %#x\n", offWriteInt, (pRingBuf)->offStart)); \
|
---|
100 | AssertMsg(offWriteInt < (pRingBuf)->offEnd, ("%#x %#x\n", offWriteInt, (pRingBuf)->offEnd)); \
|
---|
101 | AssertMsg( offRead <= offWriteCom \
|
---|
102 | ? offWriteCom <= offWriteInt || offWriteInt < offRead \
|
---|
103 | : offWriteCom <= offWriteInt, \
|
---|
104 | ("W=%#x W'=%#x R=%#x\n", offWriteCom, offWriteInt, offRead)); \
|
---|
105 | } \
|
---|
106 | } while (0)
|
---|
107 | #else
|
---|
108 | # define INTNETRINGBUF_ASSERT_SANITY(pRingBuf) do { } while (0)
|
---|
109 | #endif
|
---|
110 |
|
---|
111 |
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * A interface buffer.
|
---|
115 | */
|
---|
116 | typedef struct INTNETBUF
|
---|
117 | {
|
---|
118 | /** Magic number (INTNETBUF_MAGIC). */
|
---|
119 | uint32_t u32Magic;
|
---|
120 | /** The size of the entire buffer. */
|
---|
121 | uint32_t cbBuf;
|
---|
122 | /** The size of the send area. */
|
---|
123 | uint32_t cbSend;
|
---|
124 | /** The size of the receive area. */
|
---|
125 | uint32_t cbRecv;
|
---|
126 | /** The receive buffer. */
|
---|
127 | INTNETRINGBUF Recv;
|
---|
128 | /** The send buffer. */
|
---|
129 | INTNETRINGBUF Send;
|
---|
130 | /** Number of times yields help solve an overflow. */
|
---|
131 | STAMCOUNTER cStatYieldsOk;
|
---|
132 | /** Number of times yields didn't help solve an overflow. */
|
---|
133 | STAMCOUNTER cStatYieldsNok;
|
---|
134 | /** Number of lost packets due to overflows. */
|
---|
135 | STAMCOUNTER cStatLost;
|
---|
136 | /** Number of bad frames (both rings). */
|
---|
137 | STAMCOUNTER cStatBadFrames;
|
---|
138 | /** Reserved for future use. */
|
---|
139 | STAMCOUNTER aStatReserved[2];
|
---|
140 | /** Reserved for future send profiling. */
|
---|
141 | STAMPROFILE StatSend1;
|
---|
142 | /** Reserved for future send profiling. */
|
---|
143 | STAMPROFILE StatSend2;
|
---|
144 | /** Reserved for future receive profiling. */
|
---|
145 | STAMPROFILE StatRecv1;
|
---|
146 | /** Reserved for future receive profiling. */
|
---|
147 | STAMPROFILE StatRecv2;
|
---|
148 | /** Reserved for future profiling. */
|
---|
149 | STAMPROFILE StatReserved;
|
---|
150 | } INTNETBUF;
|
---|
151 | AssertCompileSize(INTNETBUF, 320);
|
---|
152 | AssertCompileMemberOffset(INTNETBUF, Recv, 16);
|
---|
153 | AssertCompileMemberOffset(INTNETBUF, Send, 64);
|
---|
154 |
|
---|
155 | /** Pointer to an interface buffer. */
|
---|
156 | typedef INTNETBUF *PINTNETBUF;
|
---|
157 | /** Pointer to a const interface buffer. */
|
---|
158 | typedef INTNETBUF const *PCINTNETBUF;
|
---|
159 |
|
---|
160 | /** Magic number for INTNETBUF::u32Magic (Sir William Gerald Golding). */
|
---|
161 | #define INTNETBUF_MAGIC UINT32_C(0x19110919)
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * Asserts the sanity of the specified INTNETBUF structure.
|
---|
165 | */
|
---|
166 | #define INTNETBUF_ASSERT_SANITY(pBuf) \
|
---|
167 | do \
|
---|
168 | { \
|
---|
169 | AssertPtr(pBuf); \
|
---|
170 | Assert((pBuf)->u32Magic == INTNETBUF_MAGIC); \
|
---|
171 | { \
|
---|
172 | uint32_t const offRecvStart = (pBuf)->Recv.offStart + RT_OFFSETOF(INTNETBUF, Recv); \
|
---|
173 | uint32_t const offRecvEnd = (pBuf)->Recv.offStart + RT_OFFSETOF(INTNETBUF, Recv); \
|
---|
174 | uint32_t const offSendStart = (pBuf)->Send.offStart + RT_OFFSETOF(INTNETBUF, Send); \
|
---|
175 | uint32_t const offSendEnd = (pBuf)->Send.offStart + RT_OFFSETOF(INTNETBUF, Send); \
|
---|
176 | \
|
---|
177 | Assert(offRecvEnd > offRecvStart); \
|
---|
178 | Assert(offRecvEnd - offRecvStart == (pBuf)->cbRecv); \
|
---|
179 | Assert(offRecvStart == sizeof(INTNETBUF)); \
|
---|
180 | \
|
---|
181 | Assert(offSendEnd > offSendStart); \
|
---|
182 | Assert(offSendEnd - offSendStart == (pBuf)->cbSend); \
|
---|
183 | Assert(pffSendEnd <= (pBuf)->cbBuf); \
|
---|
184 | \
|
---|
185 | Assert(offSendStart == offRecvEnd); \
|
---|
186 | } \
|
---|
187 | } while (0)
|
---|
188 |
|
---|
189 |
|
---|
190 | /** Internal networking interface handle. */
|
---|
191 | typedef uint32_t INTNETIFHANDLE;
|
---|
192 | /** Pointer to an internal networking interface handle. */
|
---|
193 | typedef INTNETIFHANDLE *PINTNETIFHANDLE;
|
---|
194 |
|
---|
195 | /** Or mask to obscure the handle index. */
|
---|
196 | #define INTNET_HANDLE_MAGIC 0x88880000
|
---|
197 | /** Mask to extract the handle index. */
|
---|
198 | #define INTNET_HANDLE_INDEX_MASK 0xffff
|
---|
199 | /** The maximum number of handles (exclusive) */
|
---|
200 | #define INTNET_HANDLE_MAX 0xffff
|
---|
201 | /** Invalid handle. */
|
---|
202 | #define INTNET_HANDLE_INVALID (0)
|
---|
203 |
|
---|
204 |
|
---|
205 | /**
|
---|
206 | * The frame header.
|
---|
207 | *
|
---|
208 | * The header is intentionally 8 bytes long. It will always
|
---|
209 | * start at an 8 byte aligned address. Assuming that the buffer
|
---|
210 | * size is a multiple of 8 bytes, that means that we can guarantee
|
---|
211 | * that the entire header is contiguous in both virtual and physical
|
---|
212 | * memory.
|
---|
213 | */
|
---|
214 | typedef struct INTNETHDR
|
---|
215 | {
|
---|
216 | /** The size of the frame. */
|
---|
217 | uint32_t cbFrame : 24;
|
---|
218 | /** Header type. This is currently serving as a magic, it
|
---|
219 | * can be extended later to encode special command frames and stuff. */
|
---|
220 | uint32_t u8Type : 8;
|
---|
221 | /** The offset from the start of this header to where the actual frame starts.
|
---|
222 | * This is used to keep the frame it self contiguous in virtual memory and
|
---|
223 | * thereby both simplify access as well as the descriptor. */
|
---|
224 | int32_t offFrame;
|
---|
225 | } INTNETHDR;
|
---|
226 | AssertCompileSize(INTNETHDR, 8);
|
---|
227 | AssertCompileSizeAlignment(INTNETBUF, sizeof(INTNETHDR));
|
---|
228 | /** Pointer to a frame header.*/
|
---|
229 | typedef INTNETHDR *PINTNETHDR;
|
---|
230 | /** Pointer to a const frame header.*/
|
---|
231 | typedef INTNETHDR const *PCINTNETHDR;
|
---|
232 |
|
---|
233 | /** The alignment of a frame header. */
|
---|
234 | #define INTNETHDR_ALIGNMENT sizeof(INTNETHDR)
|
---|
235 | AssertCompile(sizeof(INTNETHDR) == INTNETHDR_ALIGNMENT);
|
---|
236 | AssertCompile(INTNETHDR_ALIGNMENT <= INTNETRINGBUF_ALIGNMENT);
|
---|
237 |
|
---|
238 | /** @name Frame types (INTNETHDR::u8Type).
|
---|
239 | * @{ */
|
---|
240 | /** Normal frames. */
|
---|
241 | #define INTNETHDR_TYPE_FRAME 0x42
|
---|
242 | /** Padding frames. */
|
---|
243 | #define INTNETHDR_TYPE_PADDING 0x53
|
---|
244 | /** Generic segment offload frames.
|
---|
245 | * The frame starts with a PDMNETWORKGSO structure which is followed by the
|
---|
246 | * header template and data. */
|
---|
247 | #define INTNETHDR_TYPE_GSO 0x64
|
---|
248 | AssertCompileSize(PDMNETWORKGSO, 8);
|
---|
249 | /** @} */
|
---|
250 |
|
---|
251 | /**
|
---|
252 | * Asserts the sanity of the specified INTNETHDR.
|
---|
253 | */
|
---|
254 | #ifdef VBOX_STRICT
|
---|
255 | #define INTNETHDR_ASSERT_SANITY(pHdr, pRingBuf) \
|
---|
256 | do \
|
---|
257 | { \
|
---|
258 | AssertPtr(pHdr); \
|
---|
259 | Assert(RT_ALIGN_PT(pHdr, INTNETHDR_ALIGNMENT, INTNETHDR *) == pHdr); \
|
---|
260 | Assert( (pHdr)->u8Type == INTNETHDR_TYPE_FRAME \
|
---|
261 | || (pHdr)->u8Type == INTNETHDR_TYPE_GSO \
|
---|
262 | || (pHdr)->u8Type == INTNETHDR_TYPE_PADDING); \
|
---|
263 | { \
|
---|
264 | uintptr_t const offHdr = (uintptr_t)pHdr - (uintptr_t)pRingBuf; \
|
---|
265 | uintptr_t const offFrame = offHdr + (pHdr)->offFrame; \
|
---|
266 | \
|
---|
267 | Assert(offHdr >= (pRingBuf)->offStart); \
|
---|
268 | Assert(offHdr < (pRingBuf)->offEnd); \
|
---|
269 | \
|
---|
270 | /* could do more thorough work here... later, perhaps. */ \
|
---|
271 | Assert(offFrame >= (pRingBuf)->offStart); \
|
---|
272 | Assert(offFrame < (pRingBuf)->offEnd); \
|
---|
273 | } \
|
---|
274 | } while (0)
|
---|
275 | #else
|
---|
276 | # define INTNETHDR_ASSERT_SANITY(pHdr, pRingBuf) do { } while (0)
|
---|
277 | #endif
|
---|
278 |
|
---|
279 |
|
---|
280 | /**
|
---|
281 | * Scatter / Gather segment (internal networking).
|
---|
282 | */
|
---|
283 | typedef struct INTNETSEG
|
---|
284 | {
|
---|
285 | /** The physical address. NIL_RTHCPHYS is not set. */
|
---|
286 | RTHCPHYS Phys;
|
---|
287 | /** Pointer to the segment data. */
|
---|
288 | void *pv;
|
---|
289 | /** The segment size. */
|
---|
290 | uint32_t cb;
|
---|
291 | } INTNETSEG;
|
---|
292 | /** Pointer to a internal networking frame segment. */
|
---|
293 | typedef INTNETSEG *PINTNETSEG;
|
---|
294 | /** Pointer to a internal networking frame segment. */
|
---|
295 | typedef INTNETSEG const *PCINTNETSEG;
|
---|
296 |
|
---|
297 |
|
---|
298 | /**
|
---|
299 | * Scatter / Gather list (internal networking).
|
---|
300 | *
|
---|
301 | * This is used when communicating with the trunk port.
|
---|
302 | */
|
---|
303 | typedef struct INTNETSG
|
---|
304 | {
|
---|
305 | /** Owner data, don't touch! */
|
---|
306 | void *pvOwnerData;
|
---|
307 | /** User data. */
|
---|
308 | void *pvUserData;
|
---|
309 | /** User data 2 in case anyone needs it. */
|
---|
310 | void *pvUserData2;
|
---|
311 | /** GSO context information, set the type to invalid if not relevant. */
|
---|
312 | PDMNETWORKGSO GsoCtx;
|
---|
313 | /** The total length of the scatter gather list. */
|
---|
314 | uint32_t cbTotal;
|
---|
315 | /** The number of users (references).
|
---|
316 | * This is used by the SGRelease code to decide when it can be freed. */
|
---|
317 | uint16_t volatile cUsers;
|
---|
318 | /** Flags, see INTNETSG_FLAGS_* */
|
---|
319 | uint16_t volatile fFlags;
|
---|
320 | #if ARCH_BITS == 64
|
---|
321 | /** Alignment padding. */
|
---|
322 | uint16_t uPadding;
|
---|
323 | #endif
|
---|
324 | /** The number of segments allocated. */
|
---|
325 | uint16_t cSegsAlloc;
|
---|
326 | /** The number of segments actually used. */
|
---|
327 | uint16_t cSegsUsed;
|
---|
328 | /** Variable sized list of segments. */
|
---|
329 | INTNETSEG aSegs[1];
|
---|
330 | } INTNETSG;
|
---|
331 | AssertCompileSizeAlignment(INTNETSG, 8);
|
---|
332 | /** Pointer to a scatter / gather list. */
|
---|
333 | typedef INTNETSG *PINTNETSG;
|
---|
334 | /** Pointer to a const scatter / gather list. */
|
---|
335 | typedef INTNETSG const *PCINTNETSG;
|
---|
336 |
|
---|
337 | /** @name INTNETSG::fFlags definitions.
|
---|
338 | * @{ */
|
---|
339 | /** Set if the SG is free. */
|
---|
340 | #define INTNETSG_FLAGS_FREE RT_BIT_32(1)
|
---|
341 | /** Set if the SG is a temporary one that will become invalid upon return.
|
---|
342 | * Try to finish using it before returning, and if that's not possible copy
|
---|
343 | * to other buffers.
|
---|
344 | * When not set, the callee should always free the SG.
|
---|
345 | * Attempts to free it made by the callee will be quietly ignored. */
|
---|
346 | #define INTNETSG_FLAGS_TEMP RT_BIT_32(2)
|
---|
347 | /** ARP packet, IPv4 + MAC.
|
---|
348 | * @internal */
|
---|
349 | #define INTNETSG_FLAGS_ARP_IPV4 RT_BIT_32(3)
|
---|
350 | /** Copied to the temporary buffer.
|
---|
351 | * @internal */
|
---|
352 | #define INTNETSG_FLAGS_PKT_CP_IN_TMP RT_BIT_32(4)
|
---|
353 | /** @} */
|
---|
354 |
|
---|
355 |
|
---|
356 | /** @name Direction (frame source or destination)
|
---|
357 | * @{ */
|
---|
358 | /** To/From the wire. */
|
---|
359 | #define INTNETTRUNKDIR_WIRE RT_BIT_32(0)
|
---|
360 | /** To/From the host. */
|
---|
361 | #define INTNETTRUNKDIR_HOST RT_BIT_32(1)
|
---|
362 | /** Mask of valid bits. */
|
---|
363 | #define INTNETTRUNKDIR_VALID_MASK UINT32_C(3)
|
---|
364 | /** @} */
|
---|
365 |
|
---|
366 | /**
|
---|
367 | * Switch decisions returned by INTNETTRUNKSWPORT::pfnPreRecv.
|
---|
368 | */
|
---|
369 | typedef enum INTNETSWDECISION
|
---|
370 | {
|
---|
371 | /** The usual invalid zero value. */
|
---|
372 | INTNETSWDECISION_INVALID = 0,
|
---|
373 | /** Everywhere. */
|
---|
374 | INTNETSWDECISION_BROADCAST,
|
---|
375 | /** Only to the internal network. */
|
---|
376 | INTNETSWDECISION_INTNET,
|
---|
377 | /** Only for the trunk (host/wire). */
|
---|
378 | INTNETSWDECISION_TRUNK,
|
---|
379 | /** Used internally to indicate that the packet cannot be handled in the
|
---|
380 | * current context. */
|
---|
381 | INTNETSWDECISION_BAD_CONTEXT,
|
---|
382 | /** Used internally to indicate that the packet should be dropped. */
|
---|
383 | INTNETSWDECISION_DROP,
|
---|
384 | /** The usual 32-bit type expansion. */
|
---|
385 | INTNETSWDECISION_32BIT_HACK = 0x7fffffff
|
---|
386 | } INTNETSWDECISION;
|
---|
387 |
|
---|
388 |
|
---|
389 | /** Pointer to the interface side of a trunk port. */
|
---|
390 | typedef struct INTNETTRUNKIFPORT *PINTNETTRUNKIFPORT;
|
---|
391 |
|
---|
392 |
|
---|
393 | /**
|
---|
394 | * Special variation of INTNETTRUNKIFPORT::pfnRelease for use with
|
---|
395 | * INTNETTRUNKSWPORT::pfnDisconnect.
|
---|
396 | *
|
---|
397 | * @param pIfPort Pointer to the INTNETTRUNKIFPORT instance.
|
---|
398 | */
|
---|
399 | typedef DECLCALLBACK(void) FNINTNETTRUNKIFPORTRELEASEBUSY(PINTNETTRUNKIFPORT pIfPort);
|
---|
400 | /** Pointer to a FNINTNETTRUNKIFPORTRELEASEBUSY function. */
|
---|
401 | typedef FNINTNETTRUNKIFPORTRELEASEBUSY *PFNINTNETTRUNKIFPORTRELEASEBUSY;
|
---|
402 |
|
---|
403 |
|
---|
404 | /** Pointer to the switch side of a trunk port. */
|
---|
405 | typedef struct INTNETTRUNKSWPORT *PINTNETTRUNKSWPORT;
|
---|
406 | /**
|
---|
407 | * This is the port on the internal network 'switch', i.e.
|
---|
408 | * what the driver is connected to.
|
---|
409 | *
|
---|
410 | * This is only used for the in-kernel trunk connections.
|
---|
411 | */
|
---|
412 | typedef struct INTNETTRUNKSWPORT
|
---|
413 | {
|
---|
414 | /** Structure version number. (INTNETTRUNKSWPORT_VERSION) */
|
---|
415 | uint32_t u32Version;
|
---|
416 |
|
---|
417 | /**
|
---|
418 | * Examine the packet and figure out where it is going.
|
---|
419 | *
|
---|
420 | * This method is for making packet switching decisions in contexts where
|
---|
421 | * pfnRecv cannot be called or is no longer applicable. This method can be
|
---|
422 | * called from any context.
|
---|
423 | *
|
---|
424 | * @returns INTNETSWDECISION_BROADCAST, INTNETSWDECISION_INTNET or
|
---|
425 | * INTNETSWDECISION_TRUNK. The source is excluded from broadcast &
|
---|
426 | * trunk, of course.
|
---|
427 | *
|
---|
428 | * @param pSwitchPort Pointer to this structure.
|
---|
429 | * @param pvHdrs Pointer to the packet headers.
|
---|
430 | * @param cbHdrs Size of the packet headers. This must be at least 6
|
---|
431 | * bytes (the destination MAC address), but should if
|
---|
432 | * possible also include any VLAN tag and network
|
---|
433 | * layer header (wireless mac address sharing).
|
---|
434 | * @param fSrc Where this frame comes from. Only one bit should be
|
---|
435 | * set!
|
---|
436 | *
|
---|
437 | * @remarks Will only grab the switch table spinlock (interrupt safe). May
|
---|
438 | * signal an event semaphore iff we're racing network cleanup. The
|
---|
439 | * caller must be busy when calling.
|
---|
440 | */
|
---|
441 | DECLR0CALLBACKMEMBER(INTNETSWDECISION, pfnPreRecv,(PINTNETTRUNKSWPORT pSwitchPort,
|
---|
442 | void const *pvHdrs, size_t cbHdrs, uint32_t fSrc));
|
---|
443 |
|
---|
444 | /**
|
---|
445 | * Incoming frame.
|
---|
446 | *
|
---|
447 | * The frame may be modified when the trunk port on the switch is set to share
|
---|
448 | * the mac address of the host when hitting the wire. Currently frames
|
---|
449 | * containing ARP packets are subject to this, later other protocols like
|
---|
450 | * NDP/ICMPv6 may need editing as well when operating in this mode. The edited
|
---|
451 | * packet should be forwarded to the host/wire when @c false is returned.
|
---|
452 | *
|
---|
453 | * @returns true if we've handled it and it should be dropped.
|
---|
454 | * false if it should hit the wire/host.
|
---|
455 | *
|
---|
456 | * @param pSwitchPort Pointer to this structure.
|
---|
457 | * @param pvIf Pointer to the interface which received this frame
|
---|
458 | * if available. Can be NULL.
|
---|
459 | * @param pSG The (scatter /) gather structure for the frame. This
|
---|
460 | * will only be use during the call, so a temporary one can
|
---|
461 | * be used. The Phys member will not be used.
|
---|
462 | * @param fSrc Where this frame comes from. Exactly one bit shall be
|
---|
463 | * set!
|
---|
464 | *
|
---|
465 | * @remarks Will only grab the switch table spinlock (interrupt safe). Will
|
---|
466 | * signal event semaphores. The caller must be busy when calling.
|
---|
467 | *
|
---|
468 | * @remarks NAT and TAP will use this interface.
|
---|
469 | *
|
---|
470 | * @todo Do any of the host require notification before frame modifications?
|
---|
471 | * If so, we'll add a callback to INTNETTRUNKIFPORT for this
|
---|
472 | * (pfnSGModifying) and a SG flag.
|
---|
473 | */
|
---|
474 | DECLR0CALLBACKMEMBER(bool, pfnRecv,(PINTNETTRUNKSWPORT pSwitchPort, void *pvIf, PINTNETSG pSG, uint32_t fSrc));
|
---|
475 |
|
---|
476 | /**
|
---|
477 | * Retain a SG.
|
---|
478 | *
|
---|
479 | * @param pSwitchPort Pointer to this structure.
|
---|
480 | * @param pSG Pointer to the (scatter /) gather structure.
|
---|
481 | *
|
---|
482 | * @remarks Will not grab any locks. The caller must be busy when calling.
|
---|
483 | */
|
---|
484 | DECLR0CALLBACKMEMBER(void, pfnSGRetain,(PINTNETTRUNKSWPORT pSwitchPort, PINTNETSG pSG));
|
---|
485 |
|
---|
486 | /**
|
---|
487 | * Release a SG.
|
---|
488 | *
|
---|
489 | * This is called by the pfnXmit code when done with a SG. This may safe
|
---|
490 | * be done in an asynchronous manner.
|
---|
491 | *
|
---|
492 | * @param pSwitchPort Pointer to this structure.
|
---|
493 | * @param pSG Pointer to the (scatter /) gather structure.
|
---|
494 | *
|
---|
495 | * @remarks May signal an event semaphore later on, currently code won't though.
|
---|
496 | * The caller is busy when making this call.
|
---|
497 | */
|
---|
498 | DECLR0CALLBACKMEMBER(void, pfnSGRelease,(PINTNETTRUNKSWPORT pSwitchPort, PINTNETSG pSG));
|
---|
499 |
|
---|
500 | /**
|
---|
501 | * Selects whether outgoing SGs should have their physical address set.
|
---|
502 | *
|
---|
503 | * By enabling physical addresses in the scatter / gather segments it should
|
---|
504 | * be possible to save some unnecessary address translation and memory locking
|
---|
505 | * in the network stack. (Internal networking knows the physical address for
|
---|
506 | * all the INTNETBUF data and that it's locked memory.) There is a negative
|
---|
507 | * side effects though, frames that crosses page boundaries will require
|
---|
508 | * multiple scather / gather segments.
|
---|
509 | *
|
---|
510 | * @returns The old setting.
|
---|
511 | *
|
---|
512 | * @param pSwitchPort Pointer to this structure.
|
---|
513 | * @param fEnable Whether to enable or disable it.
|
---|
514 | *
|
---|
515 | * @remarks Will not grab any locks. The caller must be busy when calling.
|
---|
516 | */
|
---|
517 | DECLR0CALLBACKMEMBER(bool, pfnSetSGPhys,(PINTNETTRUNKSWPORT pSwitchPort, bool fEnable));
|
---|
518 |
|
---|
519 | /**
|
---|
520 | * Reports the MAC address of the trunk.
|
---|
521 | *
|
---|
522 | * This is supposed to be called when creating, connection or reconnecting the
|
---|
523 | * trunk and when the MAC address is changed by the system admin.
|
---|
524 | *
|
---|
525 | * @param pSwitchPort Pointer to this structure.
|
---|
526 | * @param pMacAddr The MAC address.
|
---|
527 | *
|
---|
528 | * @remarks May take a spinlock or two. The caller must be busy when calling.
|
---|
529 | */
|
---|
530 | DECLR0CALLBACKMEMBER(void, pfnReportMacAddress,(PINTNETTRUNKSWPORT pSwitchPort, PCRTMAC pMacAddr));
|
---|
531 |
|
---|
532 | /**
|
---|
533 | * Reports the promicuousness of the interface.
|
---|
534 | *
|
---|
535 | * This is supposed to be called when creating, connection or reconnecting the
|
---|
536 | * trunk and when the mode is changed by the system admin.
|
---|
537 | *
|
---|
538 | * @param pSwitchPort Pointer to this structure.
|
---|
539 | * @param fPromiscuous True if the host operates the interface in
|
---|
540 | * promiscuous mode, false if not.
|
---|
541 | *
|
---|
542 | * @remarks May take a spinlock or two. The caller must be busy when calling.
|
---|
543 | */
|
---|
544 | DECLR0CALLBACKMEMBER(void, pfnReportPromiscuousMode,(PINTNETTRUNKSWPORT pSwitchPort, bool fPromiscuous));
|
---|
545 |
|
---|
546 | /**
|
---|
547 | * Reports the GSO capabilities of the host, wire or both.
|
---|
548 | *
|
---|
549 | * This is supposed to be used only when creating, connecting or reconnecting
|
---|
550 | * the trunk. It is assumed that the GSO capabilities are kind of static the
|
---|
551 | * rest of the time.
|
---|
552 | *
|
---|
553 | * @param pSwitchPort Pointer to this structure.
|
---|
554 | * @param fGsoCapabilities The GSO capability bit mask. The bits
|
---|
555 | * corresponds to the GSO type with the same value.
|
---|
556 | * @param fDst The destination mask (INTNETTRUNKDIR_XXX).
|
---|
557 | *
|
---|
558 | * @remarks Does not take any locks. The caller must be busy when calling.
|
---|
559 | */
|
---|
560 | DECLR0CALLBACKMEMBER(void, pfnReportGsoCapabilities,(PINTNETTRUNKSWPORT pSwitchPort, uint32_t fGsoCapabilities, uint32_t fDst));
|
---|
561 |
|
---|
562 | /**
|
---|
563 | * Reports the no-preemption-xmit capabilities of the host and wire.
|
---|
564 | *
|
---|
565 | * This is supposed to be used only when creating, connecting or reconnecting
|
---|
566 | * the trunk. It is assumed that the GSO capabilities are kind of static the
|
---|
567 | * rest of the time.
|
---|
568 | *
|
---|
569 | * @param pSwitchPort Pointer to this structure.
|
---|
570 | * @param fNoPreemptDsts The destinations (INTNETTRUNKDIR_XXX) which it
|
---|
571 | * is safe to transmit to with preemption disabled.
|
---|
572 | * @param fDst The destination mask (INTNETTRUNKDIR_XXX).
|
---|
573 | *
|
---|
574 | * @remarks Does not take any locks. The caller must be busy when calling.
|
---|
575 | */
|
---|
576 | DECLR0CALLBACKMEMBER(void, pfnReportNoPreemptDsts,(PINTNETTRUNKSWPORT pSwitchPort, uint32_t fNoPreemptDsts));
|
---|
577 |
|
---|
578 | /**
|
---|
579 | * OS triggered trunk disconnect.
|
---|
580 | *
|
---|
581 | * The caller shall must be busy when calling this method to prevent racing the
|
---|
582 | * network destruction code. This method will always consume this busy reference
|
---|
583 | * (released via @a pfnReleaseBusy using @a pIfPort).
|
---|
584 | *
|
---|
585 | * The caller shall guarantee that there are absolutely no chance of concurrent
|
---|
586 | * calls to this method on the same instance.
|
---|
587 | *
|
---|
588 | * @param pSwitchPort Pointer to this structure.
|
---|
589 | * @param pIfPort The interface port structure corresponding to @a
|
---|
590 | * pSwitchPort and which should be used when
|
---|
591 | * calling @a pfnReleaseBusy. This is required as
|
---|
592 | * the method may no longer have access to a valid
|
---|
593 | * @a pIfPort pointer.
|
---|
594 | * @param pfnReleaseBusy Callback for releasing the callers busy
|
---|
595 | * reference to it's side of things.
|
---|
596 | */
|
---|
597 | DECLR0CALLBACKMEMBER(void, pfnDisconnect,(PINTNETTRUNKSWPORT pSwitchPort, PINTNETTRUNKIFPORT pIfPort,
|
---|
598 | PFNINTNETTRUNKIFPORTRELEASEBUSY pfnReleaseBusy));
|
---|
599 |
|
---|
600 | /** Structure version number. (INTNETTRUNKSWPORT_VERSION) */
|
---|
601 | uint32_t u32VersionEnd;
|
---|
602 | } INTNETTRUNKSWPORT;
|
---|
603 |
|
---|
604 | /** Version number for the INTNETTRUNKIFPORT::u32Version and INTNETTRUNKIFPORT::u32VersionEnd fields. */
|
---|
605 | # define INTNETTRUNKSWPORT_VERSION UINT32_C(0xA2CDf003)
|
---|
606 |
|
---|
607 |
|
---|
608 | /**
|
---|
609 | * The trunk interface state used set by INTNETTRUNKIFPORT::pfnSetState.
|
---|
610 | */
|
---|
611 | typedef enum INTNETTRUNKIFSTATE
|
---|
612 | {
|
---|
613 | /** The invalid zero entry. */
|
---|
614 | INTNETTRUNKIFSTATE_INVALID = 0,
|
---|
615 | /** The trunk is inactive. No calls to INTNETTRUNKSWPORT::pfnRecv or
|
---|
616 | * INTNETTRUNKSWPORT::pfnPreRecv. Calling other methods is OK. */
|
---|
617 | INTNETTRUNKIFSTATE_INACTIVE,
|
---|
618 | /** The trunk is active, no restrictions on methods or anything. */
|
---|
619 | INTNETTRUNKIFSTATE_ACTIVE,
|
---|
620 | /** The trunk is about to be disconnected from the internal network. No
|
---|
621 | * calls to any INTNETRUNKSWPORT methods. */
|
---|
622 | INTNETTRUNKIFSTATE_DISCONNECTING,
|
---|
623 | /** The end of the valid states. */
|
---|
624 | INTNETTRUNKIFSTATE_END,
|
---|
625 | /** The usual 32-bit type blow up hack. */
|
---|
626 | INTNETTRUNKIFSTATE_32BIT_HACK = 0x7fffffff
|
---|
627 | } INTNETTRUNKIFSTATE;
|
---|
628 |
|
---|
629 |
|
---|
630 | /**
|
---|
631 | * This is the port on the trunk interface, i.e. the driver side which the
|
---|
632 | * internal network is connected to.
|
---|
633 | *
|
---|
634 | * This is only used for the in-kernel trunk connections.
|
---|
635 | */
|
---|
636 | typedef struct INTNETTRUNKIFPORT
|
---|
637 | {
|
---|
638 | /** Structure version number. (INTNETTRUNKIFPORT_VERSION) */
|
---|
639 | uint32_t u32Version;
|
---|
640 |
|
---|
641 | /**
|
---|
642 | * Retain the object.
|
---|
643 | *
|
---|
644 | * It will normally be called while owning the internal network semaphore.
|
---|
645 | *
|
---|
646 | * @param pIfPort Pointer to this structure.
|
---|
647 | *
|
---|
648 | * @remarks May own the big mutex, no spinlocks.
|
---|
649 | */
|
---|
650 | DECLR0CALLBACKMEMBER(void, pfnRetain,(PINTNETTRUNKIFPORT pIfPort));
|
---|
651 |
|
---|
652 | /**
|
---|
653 | * Releases the object.
|
---|
654 | *
|
---|
655 | * This must be called for every pfnRetain call.
|
---|
656 | *
|
---|
657 | * @param pIfPort Pointer to this structure.
|
---|
658 | *
|
---|
659 | * @remarks May own the big mutex, no spinlocks.
|
---|
660 | */
|
---|
661 | DECLR0CALLBACKMEMBER(void, pfnRelease,(PINTNETTRUNKIFPORT pIfPort));
|
---|
662 |
|
---|
663 | /**
|
---|
664 | * Disconnect from the switch and release the object.
|
---|
665 | *
|
---|
666 | * The is the counter action of the
|
---|
667 | * INTNETTRUNKNETFLTFACTORY::pfnCreateAndConnect method.
|
---|
668 | *
|
---|
669 | * @param pIfPort Pointer to this structure.
|
---|
670 | *
|
---|
671 | * @remarks Owns the big mutex.
|
---|
672 | */
|
---|
673 | DECLR0CALLBACKMEMBER(void, pfnDisconnectAndRelease,(PINTNETTRUNKIFPORT pIfPort));
|
---|
674 |
|
---|
675 | /**
|
---|
676 | * Changes the state of the trunk interface.
|
---|
677 | *
|
---|
678 | * The interface is created in the inactive state (INTNETTRUNKIFSTATE_INACTIVE).
|
---|
679 | * When the first connect VM or service is activated, the internal network
|
---|
680 | * activates the trunk (INTNETTRUNKIFSTATE_ACTIVE). The state may then be set
|
---|
681 | * back and forth between INACTIVE and ACTIVE as VMs are paused, added and
|
---|
682 | * removed.
|
---|
683 | *
|
---|
684 | * Eventually though, the network is destroyed as a result of there being no
|
---|
685 | * more VMs left in it and the state is changed to disconnecting
|
---|
686 | * (INTNETTRUNKIFSTATE_DISCONNECTING) and pfnWaitForIdle is called to make sure
|
---|
687 | * there are no active calls in either direction when pfnDisconnectAndRelease is
|
---|
688 | * called.
|
---|
689 | *
|
---|
690 | * A typical operation to performed by this method is to enable/disable promiscuous
|
---|
691 | * mode on the host network interface when entering/leaving the active state.
|
---|
692 | *
|
---|
693 | * @returns The previous state.
|
---|
694 | *
|
---|
695 | * @param pIfPort Pointer to this structure.
|
---|
696 | * @param enmState The new state.
|
---|
697 | *
|
---|
698 | * @remarks Owns the big mutex. No racing pfnSetState, pfnWaitForIdle,
|
---|
699 | * pfnDisconnectAndRelease or INTNETTRUNKFACTORY::pfnCreateAndConnect
|
---|
700 | * calls.
|
---|
701 | */
|
---|
702 | DECLR0CALLBACKMEMBER(INTNETTRUNKIFSTATE, pfnSetState,(PINTNETTRUNKIFPORT pIfPort, INTNETTRUNKIFSTATE enmState));
|
---|
703 |
|
---|
704 | /**
|
---|
705 | * Notifies when the MAC address of an interface is set or changes.
|
---|
706 | *
|
---|
707 | * @param pIfPort Pointer to this structure.
|
---|
708 | * @param pvIfData Pointer to the trunk's interface data (see
|
---|
709 | * pfnConnectInterface).
|
---|
710 | * @param pMac Pointer to the MAC address of the connecting VM NIC.
|
---|
711 | *
|
---|
712 | * @remarks Only busy references to the trunk and the interface.
|
---|
713 | */
|
---|
714 | DECLR0CALLBACKMEMBER(void, pfnNotifyMacAddress,(PINTNETTRUNKIFPORT pIfPort, void *pvIfData, PCRTMAC pMac));
|
---|
715 |
|
---|
716 | /**
|
---|
717 | * Called when an interface is connected to the network.
|
---|
718 | *
|
---|
719 | * @returns IPRT status code.
|
---|
720 | * @param pIfPort Pointer to this structure.
|
---|
721 | * @param pvIf Opaque pointer to the interface being connected.
|
---|
722 | * For use INTNETTRUNKSWPORT::pfnRecv.
|
---|
723 | * @param ppvIfData Pointer to a pointer variable that the trunk
|
---|
724 | * implementation can use to associate data with the
|
---|
725 | * interface. This pointer will be passed to the
|
---|
726 | * pfnXmit, pfnNotifyMacAddress and
|
---|
727 | * pfnDisconnectInterface methods.
|
---|
728 | *
|
---|
729 | * @remarks Owns the big mutex. No racing pfnDisconnectAndRelease.
|
---|
730 | */
|
---|
731 | DECLR0CALLBACKMEMBER(int, pfnConnectInterface,(PINTNETTRUNKIFPORT pIfPort, void *pvIf, void **ppvIfData));
|
---|
732 |
|
---|
733 | /**
|
---|
734 | * Called when an interface is disconnected from the network.
|
---|
735 | *
|
---|
736 | * @param pIfPort Pointer to this structure.
|
---|
737 | * @param pvIfData Pointer to the trunk's interface data (see
|
---|
738 | * pfnConnectInterface).
|
---|
739 | *
|
---|
740 | * @remarks Owns the big mutex. No racing pfnDisconnectAndRelease.
|
---|
741 | */
|
---|
742 | DECLR0CALLBACKMEMBER(void, pfnDisconnectInterface,(PINTNETTRUNKIFPORT pIfPort, void *pvIfData));
|
---|
743 |
|
---|
744 | /**
|
---|
745 | * Waits for the interface to become idle.
|
---|
746 | *
|
---|
747 | * This method must be called before disconnecting and releasing the object in
|
---|
748 | * order to prevent racing incoming/outgoing frames and device
|
---|
749 | * enabling/disabling.
|
---|
750 | *
|
---|
751 | * @returns IPRT status code (see RTSemEventWait).
|
---|
752 | * @param pIfPort Pointer to this structure.
|
---|
753 | * @param cMillies The number of milliseconds to wait. 0 means
|
---|
754 | * no waiting at all. Use RT_INDEFINITE_WAIT for
|
---|
755 | * an indefinite wait.
|
---|
756 | *
|
---|
757 | * @remarks Owns the big mutex. No racing pfnDisconnectAndRelease.
|
---|
758 | */
|
---|
759 | DECLR0CALLBACKMEMBER(int, pfnWaitForIdle,(PINTNETTRUNKIFPORT pIfPort, uint32_t cMillies));
|
---|
760 |
|
---|
761 | /**
|
---|
762 | * Transmit a frame.
|
---|
763 | *
|
---|
764 | * @return VBox status code. Error generally means we'll drop the frame.
|
---|
765 | * @param pIfPort Pointer to this structure.
|
---|
766 | * @param pvIfData Pointer to the trunk's interface data (see
|
---|
767 | * pfnConnectInterface).
|
---|
768 | * @param pSG Pointer to the (scatter /) gather structure for the frame.
|
---|
769 | * This may or may not be a temporary buffer. If it's temporary
|
---|
770 | * the transmit operation(s) then it's required to make a copy
|
---|
771 | * of the frame unless it can be transmitted synchronously.
|
---|
772 | * @param fDst The destination mask. At least one bit will be set.
|
---|
773 | *
|
---|
774 | * @remarks No locks. May be called concurrently on several threads.
|
---|
775 | */
|
---|
776 | DECLR0CALLBACKMEMBER(int, pfnXmit,(PINTNETTRUNKIFPORT pIfPort, void *pvIfData, PINTNETSG pSG, uint32_t fDst));
|
---|
777 |
|
---|
778 | /** Structure version number. (INTNETTRUNKIFPORT_VERSION) */
|
---|
779 | uint32_t u32VersionEnd;
|
---|
780 | } INTNETTRUNKIFPORT;
|
---|
781 |
|
---|
782 | /** Version number for the INTNETTRUNKIFPORT::u32Version and INTNETTRUNKIFPORT::u32VersionEnd fields. */
|
---|
783 | #define INTNETTRUNKIFPORT_VERSION UINT32_C(0xA2CDe001)
|
---|
784 |
|
---|
785 |
|
---|
786 | /**
|
---|
787 | * The component factory interface for create a network
|
---|
788 | * interface filter (like VBoxNetFlt).
|
---|
789 | */
|
---|
790 | typedef struct INTNETTRUNKFACTORY
|
---|
791 | {
|
---|
792 | /**
|
---|
793 | * Release this factory.
|
---|
794 | *
|
---|
795 | * SUPR0ComponentQueryFactory (SUPDRVFACTORY::pfnQueryFactoryInterface to be precise)
|
---|
796 | * will retain a reference to the factory and the caller has to call this method to
|
---|
797 | * release it once the pfnCreateAndConnect call(s) has been done.
|
---|
798 | *
|
---|
799 | * @param pIfFactory Pointer to this structure.
|
---|
800 | */
|
---|
801 | DECLR0CALLBACKMEMBER(void, pfnRelease,(struct INTNETTRUNKFACTORY *pIfFactory));
|
---|
802 |
|
---|
803 | /**
|
---|
804 | * Create an instance for the specfied host interface and connects it
|
---|
805 | * to the internal network trunk port.
|
---|
806 | *
|
---|
807 | * The initial interface active state is false (suspended).
|
---|
808 | *
|
---|
809 | *
|
---|
810 | * @returns VBox status code.
|
---|
811 | * @retval VINF_SUCCESS and *ppIfPort set on success.
|
---|
812 | * @retval VERR_INTNET_FLT_IF_NOT_FOUND if the interface was not found.
|
---|
813 | * @retval VERR_INTNET_FLT_IF_BUSY if the interface is already connected.
|
---|
814 | * @retval VERR_INTNET_FLT_IF_FAILED if it failed for some other reason.
|
---|
815 | *
|
---|
816 | * @param pIfFactory Pointer to this structure.
|
---|
817 | * @param pszName The interface name (OS specific).
|
---|
818 | * @param pSwitchPort Pointer to the port interface on the switch that
|
---|
819 | * this interface is being connected to.
|
---|
820 | * @param fFlags Creation flags, see below.
|
---|
821 | * @param ppIfPort Where to store the pointer to the interface port
|
---|
822 | * on success.
|
---|
823 | *
|
---|
824 | * @remarks Called while owning the network and the out-bound trunk semaphores.
|
---|
825 | */
|
---|
826 | DECLR0CALLBACKMEMBER(int, pfnCreateAndConnect,(struct INTNETTRUNKFACTORY *pIfFactory, const char *pszName,
|
---|
827 | PINTNETTRUNKSWPORT pSwitchPort, uint32_t fFlags,
|
---|
828 | PINTNETTRUNKIFPORT *ppIfPort));
|
---|
829 | } INTNETTRUNKFACTORY;
|
---|
830 | /** Pointer to the trunk factory. */
|
---|
831 | typedef INTNETTRUNKFACTORY *PINTNETTRUNKFACTORY;
|
---|
832 |
|
---|
833 | /** The UUID for the (current) trunk factory. (case sensitive) */
|
---|
834 | #define INTNETTRUNKFACTORY_UUID_STR "de504d93-1d1e-4781-8b73-6ea39a0e36a2"
|
---|
835 |
|
---|
836 | /** @name INTNETTRUNKFACTORY::pfnCreateAndConnect flags.
|
---|
837 | * @{ */
|
---|
838 | /** Don't put the filtered interface in promiscuous mode.
|
---|
839 | * This is used for wireless interface since these can misbehave if
|
---|
840 | * we try to put them in promiscuous mode. (Wireless interfaces are
|
---|
841 | * normally bridged on level 3 instead of level 2.) */
|
---|
842 | #define INTNETTRUNKFACTORY_FLAG_NO_PROMISC RT_BIT_32(0)
|
---|
843 | /** @} */
|
---|
844 |
|
---|
845 |
|
---|
846 | /**
|
---|
847 | * The trunk connection type.
|
---|
848 | *
|
---|
849 | * Used by IntNetR0Open and associated interfaces.
|
---|
850 | */
|
---|
851 | typedef enum INTNETTRUNKTYPE
|
---|
852 | {
|
---|
853 | /** Invalid trunk type. */
|
---|
854 | kIntNetTrunkType_Invalid = 0,
|
---|
855 | /** No trunk connection. */
|
---|
856 | kIntNetTrunkType_None,
|
---|
857 | /** We don't care which kind of trunk connection if the network exists,
|
---|
858 | * if it doesn't exist create it without a connection. */
|
---|
859 | kIntNetTrunkType_WhateverNone,
|
---|
860 | /** VirtualBox host network interface filter driver.
|
---|
861 | * The trunk name is the name of the host network interface. */
|
---|
862 | kIntNetTrunkType_NetFlt,
|
---|
863 | /** VirtualBox adapter host driver. */
|
---|
864 | kIntNetTrunkType_NetAdp,
|
---|
865 | /** Nat service (ring-0). */
|
---|
866 | kIntNetTrunkType_SrvNat,
|
---|
867 | /** The end of valid types. */
|
---|
868 | kIntNetTrunkType_End,
|
---|
869 | /** The usual 32-bit hack. */
|
---|
870 | kIntNetTrunkType_32bitHack = 0x7fffffff
|
---|
871 | } INTNETTRUNKTYPE;
|
---|
872 |
|
---|
873 | /** @name IntNetR0Open flags.
|
---|
874 | *
|
---|
875 | * The desired policy options must be specified explicitly, if omitted it is
|
---|
876 | * understood that whatever is current or default is fine with the caller.
|
---|
877 | *
|
---|
878 | * @todo Move the policies out of the flags, use three new parameters.
|
---|
879 | *
|
---|
880 | * @{ */
|
---|
881 | /** Share the MAC address with the host when sending something to the wire via the trunk.
|
---|
882 | * This is typically used when the trunk is a NetFlt for a wireless interface. */
|
---|
883 | #define INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE RT_BIT_32(0)
|
---|
884 | /** Require that the current security and promiscuous policies of the network
|
---|
885 | * is exactly as the ones specified in this open network request.
|
---|
886 | *
|
---|
887 | * Use this with INTNET_OPEN_FLAGS_REQUIRE_AS_RESTRICTIVE_POLICIES to prevent
|
---|
888 | * restrictions from being lifted. If no further policy changes are desired,
|
---|
889 | * apply the relevant _FIXED flags. */
|
---|
890 | #define INTNET_OPEN_FLAGS_REQUIRE_EXACT RT_BIT_32(1)
|
---|
891 | /** Require that the security and promiscuous policies of the network is at
|
---|
892 | * least as restrictive as specified this request specifies and prevent them
|
---|
893 | * being lifted later on. */
|
---|
894 | #define INTNET_OPEN_FLAGS_REQUIRE_AS_RESTRICTIVE_POLICIES RT_BIT_32(2)
|
---|
895 |
|
---|
896 | /** Network access policy: Fixed if set, changable if clear. */
|
---|
897 | #define INTNET_OPEN_FLAGS_ACCESS_FIXED RT_BIT_32(3)
|
---|
898 | /** Network access policy: Public network. */
|
---|
899 | #define INTNET_OPEN_FLAGS_ACCESS_PUBLIC RT_BIT_32(4)
|
---|
900 | /** Network access policy: Restricted network. */
|
---|
901 | #define INTNET_OPEN_FLAGS_ACCESS_RESTRICTED RT_BIT_32(5)
|
---|
902 |
|
---|
903 | /** Promiscuous mode policy: Is it fixed or changable by new participants? */
|
---|
904 | #define INTNET_OPEN_FLAGS_PROMISC_FIXED RT_BIT_32(6)
|
---|
905 | /** Promiscuous mode policy: Allow the clients to request it. */
|
---|
906 | #define INTNET_OPEN_FLAGS_PROMISC_ALLOW_CLIENTS RT_BIT_32(7)
|
---|
907 | /** Promiscuous mode policy: Deny the clients from requesting it. */
|
---|
908 | #define INTNET_OPEN_FLAGS_PROMISC_DENY_CLIENTS RT_BIT_32(8)
|
---|
909 | /** Promiscuous mode policy: Allow the trunk-host to request it. */
|
---|
910 | #define INTNET_OPEN_FLAGS_PROMISC_ALLOW_TRUNK_HOST RT_BIT_32(9)
|
---|
911 | /** Promiscuous mode policy: Deny the trunk-host from requesting it. */
|
---|
912 | #define INTNET_OPEN_FLAGS_PROMISC_DENY_TRUNK_HOST RT_BIT_32(10)
|
---|
913 | /** Promiscuous mode policy: Allow the trunk-wire to request it. */
|
---|
914 | #define INTNET_OPEN_FLAGS_PROMISC_ALLOW_TRUNK_WIRE RT_BIT_32(11)
|
---|
915 | /** Promiscuous mode policy: Deny the trunk-wire from requesting it. */
|
---|
916 | #define INTNET_OPEN_FLAGS_PROMISC_DENY_TRUNK_WIRE RT_BIT_32(12)
|
---|
917 |
|
---|
918 | /** Interface policies: Is it fixed or changable (by admin).
|
---|
919 | * @note Per interface, not network wide. */
|
---|
920 | #define INTNET_OPEN_FLAGS_IF_FIXED RT_BIT_32(13)
|
---|
921 | /** Interface promiscuous mode policy: Allow the interface to request it. */
|
---|
922 | #define INTNET_OPEN_FLAGS_IF_PROMISC_ALLOW RT_BIT_32(14)
|
---|
923 | /** Interface promiscuous mode policy: Deny the interface from requesting it. */
|
---|
924 | #define INTNET_OPEN_FLAGS_IF_PROMISC_DENY RT_BIT_32(15)
|
---|
925 | /** Interface promiscuous mode policy: See unrelated trunk traffic. */
|
---|
926 | #define INTNET_OPEN_FLAGS_IF_PROMISC_SEE_TRUNK RT_BIT_32(16)
|
---|
927 | /** Interface promiscuous mode policy: No unrelated trunk traffic visible. */
|
---|
928 | #define INTNET_OPEN_FLAGS_IF_PROMISC_NO_TRUNK RT_BIT_32(17)
|
---|
929 |
|
---|
930 | /** Trunk policy: Fixed if set, changable if clear.
|
---|
931 | * @remarks The DISABLED options are considered more restrictive by
|
---|
932 | * INTNET_OPEN_FLAGS_REQUIRE_AS_RESTRICTIVE_POLICIES. */
|
---|
933 | #define INTNET_OPEN_FLAGS_TRUNK_FIXED RT_BIT_32(18)
|
---|
934 | /** Trunk policy: The host end should be enabled. */
|
---|
935 | #define INTNET_OPEN_FLAGS_TRUNK_HOST_ENABLED RT_BIT_32(19)
|
---|
936 | /** Trunk policy: The host end should be disabled. */
|
---|
937 | #define INTNET_OPEN_FLAGS_TRUNK_HOST_DISABLED RT_BIT_32(20)
|
---|
938 | /** Trunk policy: The host should only see packets destined for it. */
|
---|
939 | #define INTNET_OPEN_FLAGS_TRUNK_HOST_CHASTE_MODE RT_BIT_32(21)
|
---|
940 | /** Trunk policy: The host should see all packets. */
|
---|
941 | #define INTNET_OPEN_FLAGS_TRUNK_HOST_PROMISC_MODE RT_BIT_32(22)
|
---|
942 | /** Trunk policy: The wire end should be enabled. */
|
---|
943 | #define INTNET_OPEN_FLAGS_TRUNK_WIRE_ENABLED RT_BIT_32(23)
|
---|
944 | /** Trunk policy: The wire end should be disabled. */
|
---|
945 | #define INTNET_OPEN_FLAGS_TRUNK_WIRE_DISABLED RT_BIT_32(24)
|
---|
946 | /** Trunk policy: The wire should only see packets destined for it. */
|
---|
947 | #define INTNET_OPEN_FLAGS_TRUNK_WIRE_CHASTE_MODE RT_BIT_32(25)
|
---|
948 | /** Trunk policy: The wire should see all packets. */
|
---|
949 | #define INTNET_OPEN_FLAGS_TRUNK_WIRE_PROMISC_MODE RT_BIT_32(26)
|
---|
950 |
|
---|
951 | /** Used to enable host specific workarounds.
|
---|
952 | *
|
---|
953 | * On darwin this will clear ip_tos in DHCP packets when
|
---|
954 | * INTNET_OPEN_FLAGS_SHARED_MAC_ON_WIRE is also set. */
|
---|
955 | #define INTNET_OPEN_FLAGS_WORKAROUND_1 RT_BIT_32(31)
|
---|
956 |
|
---|
957 |
|
---|
958 | /** The mask of valid flags. */
|
---|
959 | #define INTNET_OPEN_FLAGS_MASK UINT32_C(0x83ffffff)
|
---|
960 | /** The mask of all flags use to fix (lock) settings. */
|
---|
961 | #define INTNET_OPEN_FLAGS_FIXED_MASK \
|
---|
962 | ( INTNET_OPEN_FLAGS_ACCESS_FIXED \
|
---|
963 | | INTNET_OPEN_FLAGS_PROMISC_FIXED \
|
---|
964 | | INTNET_OPEN_FLAGS_IF_FIXED \
|
---|
965 | | INTNET_OPEN_FLAGS_TRUNK_FIXED )
|
---|
966 |
|
---|
967 | /** The mask of all policy pairs. */
|
---|
968 | #define INTNET_OPEN_FLAGS_PAIR_MASK \
|
---|
969 | ( INTNET_OPEN_FLAGS_ACCESS_PUBLIC | INTNET_OPEN_FLAGS_ACCESS_RESTRICTED \
|
---|
970 | | INTNET_OPEN_FLAGS_PROMISC_ALLOW_CLIENTS | INTNET_OPEN_FLAGS_PROMISC_DENY_CLIENTS \
|
---|
971 | | INTNET_OPEN_FLAGS_PROMISC_ALLOW_TRUNK_HOST | INTNET_OPEN_FLAGS_PROMISC_DENY_TRUNK_HOST \
|
---|
972 | | INTNET_OPEN_FLAGS_PROMISC_ALLOW_TRUNK_WIRE | INTNET_OPEN_FLAGS_PROMISC_DENY_TRUNK_WIRE \
|
---|
973 | | INTNET_OPEN_FLAGS_IF_PROMISC_ALLOW | INTNET_OPEN_FLAGS_IF_PROMISC_DENY \
|
---|
974 | | INTNET_OPEN_FLAGS_IF_PROMISC_SEE_TRUNK | INTNET_OPEN_FLAGS_IF_PROMISC_NO_TRUNK \
|
---|
975 | | INTNET_OPEN_FLAGS_TRUNK_HOST_ENABLED | INTNET_OPEN_FLAGS_TRUNK_HOST_DISABLED \
|
---|
976 | | INTNET_OPEN_FLAGS_TRUNK_HOST_PROMISC_MODE | INTNET_OPEN_FLAGS_TRUNK_HOST_CHASTE_MODE \
|
---|
977 | | INTNET_OPEN_FLAGS_TRUNK_WIRE_ENABLED | INTNET_OPEN_FLAGS_TRUNK_WIRE_DISABLED \
|
---|
978 | | INTNET_OPEN_FLAGS_TRUNK_WIRE_PROMISC_MODE | INTNET_OPEN_FLAGS_TRUNK_WIRE_CHASTE_MODE \
|
---|
979 | )
|
---|
980 | /** The mask of all relaxed policy bits. */
|
---|
981 | #define INTNET_OPEN_FLAGS_RELAXED_MASK \
|
---|
982 | ( INTNET_OPEN_FLAGS_ACCESS_PUBLIC \
|
---|
983 | | INTNET_OPEN_FLAGS_PROMISC_ALLOW_CLIENTS \
|
---|
984 | | INTNET_OPEN_FLAGS_PROMISC_ALLOW_TRUNK_HOST \
|
---|
985 | | INTNET_OPEN_FLAGS_PROMISC_ALLOW_TRUNK_WIRE \
|
---|
986 | | INTNET_OPEN_FLAGS_IF_PROMISC_ALLOW \
|
---|
987 | | INTNET_OPEN_FLAGS_IF_PROMISC_SEE_TRUNK \
|
---|
988 | | INTNET_OPEN_FLAGS_TRUNK_HOST_ENABLED \
|
---|
989 | | INTNET_OPEN_FLAGS_TRUNK_WIRE_PROMISC_MODE \
|
---|
990 | | INTNET_OPEN_FLAGS_TRUNK_WIRE_ENABLED \
|
---|
991 | | INTNET_OPEN_FLAGS_TRUNK_WIRE_PROMISC_MODE \
|
---|
992 | )
|
---|
993 | /** The mask of all strict policy bits. */
|
---|
994 | #define INTNET_OPEN_FLAGS_STRICT_MASK \
|
---|
995 | ( INTNET_OPEN_FLAGS_ACCESS_RESTRICTED \
|
---|
996 | | INTNET_OPEN_FLAGS_PROMISC_DENY_CLIENTS \
|
---|
997 | | INTNET_OPEN_FLAGS_PROMISC_DENY_TRUNK_HOST \
|
---|
998 | | INTNET_OPEN_FLAGS_PROMISC_DENY_TRUNK_WIRE \
|
---|
999 | | INTNET_OPEN_FLAGS_IF_PROMISC_DENY \
|
---|
1000 | | INTNET_OPEN_FLAGS_IF_PROMISC_NO_TRUNK \
|
---|
1001 | | INTNET_OPEN_FLAGS_TRUNK_HOST_DISABLED \
|
---|
1002 | | INTNET_OPEN_FLAGS_TRUNK_HOST_CHASTE_MODE \
|
---|
1003 | | INTNET_OPEN_FLAGS_TRUNK_WIRE_DISABLED \
|
---|
1004 | | INTNET_OPEN_FLAGS_TRUNK_WIRE_CHASTE_MODE \
|
---|
1005 | )
|
---|
1006 | /** @} */
|
---|
1007 |
|
---|
1008 | /** The maximum length of a network name. */
|
---|
1009 | #define INTNET_MAX_NETWORK_NAME 128
|
---|
1010 |
|
---|
1011 | /** The maximum length of a trunk name. */
|
---|
1012 | #define INTNET_MAX_TRUNK_NAME 64
|
---|
1013 |
|
---|
1014 |
|
---|
1015 | /**
|
---|
1016 | * Request buffer for IntNetR0OpenReq / VMMR0_DO_INTNET_OPEN.
|
---|
1017 | * @see IntNetR0Open.
|
---|
1018 | */
|
---|
1019 | typedef struct INTNETOPENREQ
|
---|
1020 | {
|
---|
1021 | /** The request header. */
|
---|
1022 | SUPVMMR0REQHDR Hdr;
|
---|
1023 | /** Alternative to passing the taking the session from the VM handle.
|
---|
1024 | * Either use this member or use the VM handle, don't do both. */
|
---|
1025 | PSUPDRVSESSION pSession;
|
---|
1026 | /** The network name. (input) */
|
---|
1027 | char szNetwork[INTNET_MAX_NETWORK_NAME];
|
---|
1028 | /** What to connect to the trunk port. (input)
|
---|
1029 | * This is specific to the trunk type below. */
|
---|
1030 | char szTrunk[INTNET_MAX_TRUNK_NAME];
|
---|
1031 | /** The type of trunk link (NAT, Filter, TAP, etc). (input) */
|
---|
1032 | INTNETTRUNKTYPE enmTrunkType;
|
---|
1033 | /** Flags, see INTNET_OPEN_FLAGS_*. (input) */
|
---|
1034 | uint32_t fFlags;
|
---|
1035 | /** The size of the send buffer. (input) */
|
---|
1036 | uint32_t cbSend;
|
---|
1037 | /** The size of the receive buffer. (input) */
|
---|
1038 | uint32_t cbRecv;
|
---|
1039 | /** The handle to the network interface. (output) */
|
---|
1040 | INTNETIFHANDLE hIf;
|
---|
1041 | } INTNETOPENREQ;
|
---|
1042 | /** Pointer to an IntNetR0OpenReq / VMMR0_DO_INTNET_OPEN request buffer. */
|
---|
1043 | typedef INTNETOPENREQ *PINTNETOPENREQ;
|
---|
1044 |
|
---|
1045 | INTNETR0DECL(int) IntNetR0OpenReq(PSUPDRVSESSION pSession, PINTNETOPENREQ pReq);
|
---|
1046 |
|
---|
1047 |
|
---|
1048 | /**
|
---|
1049 | * Request buffer for IntNetR0IfCloseReq / VMMR0_DO_INTNET_IF_CLOSE.
|
---|
1050 | * @see IntNetR0IfClose.
|
---|
1051 | */
|
---|
1052 | typedef struct INTNETIFCLOSEREQ
|
---|
1053 | {
|
---|
1054 | /** The request header. */
|
---|
1055 | SUPVMMR0REQHDR Hdr;
|
---|
1056 | /** Alternative to passing the taking the session from the VM handle.
|
---|
1057 | * Either use this member or use the VM handle, don't do both. */
|
---|
1058 | PSUPDRVSESSION pSession;
|
---|
1059 | /** The handle to the network interface. */
|
---|
1060 | INTNETIFHANDLE hIf;
|
---|
1061 | } INTNETIFCLOSEREQ;
|
---|
1062 | /** Pointer to an IntNetR0IfCloseReq / VMMR0_DO_INTNET_IF_CLOSE request
|
---|
1063 | * buffer. */
|
---|
1064 | typedef INTNETIFCLOSEREQ *PINTNETIFCLOSEREQ;
|
---|
1065 |
|
---|
1066 | INTNETR0DECL(int) IntNetR0IfCloseReq(PSUPDRVSESSION pSession, PINTNETIFCLOSEREQ pReq);
|
---|
1067 |
|
---|
1068 |
|
---|
1069 | /**
|
---|
1070 | * Request buffer for IntNetR0IfGetRing3BufferReq /
|
---|
1071 | * VMMR0_DO_INTNET_IF_GET_BUFFER_PTRS.
|
---|
1072 | * @see IntNetR0IfGetRing3Buffer.
|
---|
1073 | */
|
---|
1074 | typedef struct INTNETIFGETBUFFERPTRSREQ
|
---|
1075 | {
|
---|
1076 | /** The request header. */
|
---|
1077 | SUPVMMR0REQHDR Hdr;
|
---|
1078 | /** Alternative to passing the taking the session from the VM handle.
|
---|
1079 | * Either use this member or use the VM handle, don't do both. */
|
---|
1080 | PSUPDRVSESSION pSession;
|
---|
1081 | /** Handle to the interface. */
|
---|
1082 | INTNETIFHANDLE hIf;
|
---|
1083 | /** The pointer to the ring-3 buffer. (output) */
|
---|
1084 | R3PTRTYPE(PINTNETBUF) pRing3Buf;
|
---|
1085 | /** The pointer to the ring-0 buffer. (output) */
|
---|
1086 | R0PTRTYPE(PINTNETBUF) pRing0Buf;
|
---|
1087 | } INTNETIFGETBUFFERPTRSREQ;
|
---|
1088 | /** Pointer to an IntNetR0IfGetRing3BufferReq /
|
---|
1089 | * VMMR0_DO_INTNET_IF_GET_BUFFER_PTRS request buffer. */
|
---|
1090 | typedef INTNETIFGETBUFFERPTRSREQ *PINTNETIFGETBUFFERPTRSREQ;
|
---|
1091 |
|
---|
1092 | INTNETR0DECL(int) IntNetR0IfGetBufferPtrsReq(PSUPDRVSESSION pSession, PINTNETIFGETBUFFERPTRSREQ pReq);
|
---|
1093 |
|
---|
1094 |
|
---|
1095 | /**
|
---|
1096 | * Request buffer for IntNetR0IfSetPromiscuousModeReq /
|
---|
1097 | * VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE.
|
---|
1098 | * @see IntNetR0IfSetPromiscuousMode.
|
---|
1099 | */
|
---|
1100 | typedef struct INTNETIFSETPROMISCUOUSMODEREQ
|
---|
1101 | {
|
---|
1102 | /** The request header. */
|
---|
1103 | SUPVMMR0REQHDR Hdr;
|
---|
1104 | /** Alternative to passing the taking the session from the VM handle.
|
---|
1105 | * Either use this member or use the VM handle, don't do both. */
|
---|
1106 | PSUPDRVSESSION pSession;
|
---|
1107 | /** Handle to the interface. */
|
---|
1108 | INTNETIFHANDLE hIf;
|
---|
1109 | /** The new promiscuous mode. */
|
---|
1110 | bool fPromiscuous;
|
---|
1111 | } INTNETIFSETPROMISCUOUSMODEREQ;
|
---|
1112 | /** Pointer to an IntNetR0IfSetPromiscuousModeReq /
|
---|
1113 | * VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE request buffer. */
|
---|
1114 | typedef INTNETIFSETPROMISCUOUSMODEREQ *PINTNETIFSETPROMISCUOUSMODEREQ;
|
---|
1115 |
|
---|
1116 | INTNETR0DECL(int) IntNetR0IfSetPromiscuousModeReq(PSUPDRVSESSION pSession, PINTNETIFSETPROMISCUOUSMODEREQ pReq);
|
---|
1117 |
|
---|
1118 |
|
---|
1119 | /**
|
---|
1120 | * Request buffer for IntNetR0IfSetMacAddressReq /
|
---|
1121 | * VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS.
|
---|
1122 | * @see IntNetR0IfSetMacAddress.
|
---|
1123 | */
|
---|
1124 | typedef struct INTNETIFSETMACADDRESSREQ
|
---|
1125 | {
|
---|
1126 | /** The request header. */
|
---|
1127 | SUPVMMR0REQHDR Hdr;
|
---|
1128 | /** Alternative to passing the taking the session from the VM handle.
|
---|
1129 | * Either use this member or use the VM handle, don't do both. */
|
---|
1130 | PSUPDRVSESSION pSession;
|
---|
1131 | /** Handle to the interface. */
|
---|
1132 | INTNETIFHANDLE hIf;
|
---|
1133 | /** The new MAC address. */
|
---|
1134 | RTMAC Mac;
|
---|
1135 | } INTNETIFSETMACADDRESSREQ;
|
---|
1136 | /** Pointer to an IntNetR0IfSetMacAddressReq /
|
---|
1137 | * VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS request buffer. */
|
---|
1138 | typedef INTNETIFSETMACADDRESSREQ *PINTNETIFSETMACADDRESSREQ;
|
---|
1139 |
|
---|
1140 | INTNETR0DECL(int) IntNetR0IfSetMacAddressReq(PSUPDRVSESSION pSession, PINTNETIFSETMACADDRESSREQ pReq);
|
---|
1141 |
|
---|
1142 |
|
---|
1143 | /**
|
---|
1144 | * Request buffer for IntNetR0IfSetActiveReq / VMMR0_DO_INTNET_IF_SET_ACTIVE.
|
---|
1145 | * @see IntNetR0IfSetActive.
|
---|
1146 | */
|
---|
1147 | typedef struct INTNETIFSETACTIVEREQ
|
---|
1148 | {
|
---|
1149 | /** The request header. */
|
---|
1150 | SUPVMMR0REQHDR Hdr;
|
---|
1151 | /** Alternative to passing the taking the session from the VM handle.
|
---|
1152 | * Either use this member or use the VM handle, don't do both. */
|
---|
1153 | PSUPDRVSESSION pSession;
|
---|
1154 | /** Handle to the interface. */
|
---|
1155 | INTNETIFHANDLE hIf;
|
---|
1156 | /** The new state. */
|
---|
1157 | bool fActive;
|
---|
1158 | } INTNETIFSETACTIVEREQ;
|
---|
1159 | /** Pointer to an IntNetR0IfSetActiveReq / VMMR0_DO_INTNET_IF_SET_ACTIVE
|
---|
1160 | * request buffer. */
|
---|
1161 | typedef INTNETIFSETACTIVEREQ *PINTNETIFSETACTIVEREQ;
|
---|
1162 |
|
---|
1163 | INTNETR0DECL(int) IntNetR0IfSetActiveReq(PSUPDRVSESSION pSession, PINTNETIFSETACTIVEREQ pReq);
|
---|
1164 |
|
---|
1165 |
|
---|
1166 | /**
|
---|
1167 | * Request buffer for IntNetR0IfSendReq / VMMR0_DO_INTNET_IF_SEND.
|
---|
1168 | * @see IntNetR0IfSend.
|
---|
1169 | */
|
---|
1170 | typedef struct INTNETIFSENDREQ
|
---|
1171 | {
|
---|
1172 | /** The request header. */
|
---|
1173 | SUPVMMR0REQHDR Hdr;
|
---|
1174 | /** Alternative to passing the taking the session from the VM handle.
|
---|
1175 | * Either use this member or use the VM handle, don't do both. */
|
---|
1176 | PSUPDRVSESSION pSession;
|
---|
1177 | /** Handle to the interface. */
|
---|
1178 | INTNETIFHANDLE hIf;
|
---|
1179 | } INTNETIFSENDREQ;
|
---|
1180 | /** Pointer to an IntNetR0IfSend() argument package. */
|
---|
1181 | typedef INTNETIFSENDREQ *PINTNETIFSENDREQ;
|
---|
1182 |
|
---|
1183 | INTNETR0DECL(int) IntNetR0IfSendReq(PSUPDRVSESSION pSession, PINTNETIFSENDREQ pReq);
|
---|
1184 |
|
---|
1185 |
|
---|
1186 | /**
|
---|
1187 | * Request buffer for IntNetR0IfWaitReq / VMMR0_DO_INTNET_IF_WAIT.
|
---|
1188 | * @see IntNetR0IfWait.
|
---|
1189 | */
|
---|
1190 | typedef struct INTNETIFWAITREQ
|
---|
1191 | {
|
---|
1192 | /** The request header. */
|
---|
1193 | SUPVMMR0REQHDR Hdr;
|
---|
1194 | /** Alternative to passing the taking the session from the VM handle.
|
---|
1195 | * Either use this member or use the VM handle, don't do both. */
|
---|
1196 | PSUPDRVSESSION pSession;
|
---|
1197 | /** Handle to the interface. */
|
---|
1198 | INTNETIFHANDLE hIf;
|
---|
1199 | /** The number of milliseconds to wait. */
|
---|
1200 | uint32_t cMillies;
|
---|
1201 | } INTNETIFWAITREQ;
|
---|
1202 | /** Pointer to an IntNetR0IfWaitReq / VMMR0_DO_INTNET_IF_WAIT request buffer. */
|
---|
1203 | typedef INTNETIFWAITREQ *PINTNETIFWAITREQ;
|
---|
1204 |
|
---|
1205 | INTNETR0DECL(int) IntNetR0IfWaitReq(PSUPDRVSESSION pSession, PINTNETIFWAITREQ pReq);
|
---|
1206 |
|
---|
1207 |
|
---|
1208 | /**
|
---|
1209 | * Request buffer for IntNetR0IfAbortWaitReq / VMMR0_DO_INTNET_IF_ABORT_WAIT.
|
---|
1210 | * @see IntNetR0IfAbortWait.
|
---|
1211 | */
|
---|
1212 | typedef struct INTNETIFABORTWAITREQ
|
---|
1213 | {
|
---|
1214 | /** The request header. */
|
---|
1215 | SUPVMMR0REQHDR Hdr;
|
---|
1216 | /** Alternative to passing the taking the session from the VM handle.
|
---|
1217 | * Either use this member or use the VM handle, don't do both. */
|
---|
1218 | PSUPDRVSESSION pSession;
|
---|
1219 | /** Handle to the interface. */
|
---|
1220 | INTNETIFHANDLE hIf;
|
---|
1221 | /** Set this to fend off all future IntNetR0Wait calls. */
|
---|
1222 | bool fNoMoreWaits;
|
---|
1223 | } INTNETIFABORTWAITREQ;
|
---|
1224 | /** Pointer to an IntNetR0IfAbortWaitReq / VMMR0_DO_INTNET_IF_ABORT_WAIT
|
---|
1225 | * request buffer. */
|
---|
1226 | typedef INTNETIFABORTWAITREQ *PINTNETIFABORTWAITREQ;
|
---|
1227 |
|
---|
1228 | INTNETR0DECL(int) IntNetR0IfAbortWaitReq(PSUPDRVSESSION pSession, PINTNETIFABORTWAITREQ pReq);
|
---|
1229 |
|
---|
1230 |
|
---|
1231 | #if defined(IN_RING0) || defined(IN_INTNET_TESTCASE)
|
---|
1232 | /** @name
|
---|
1233 | * @{
|
---|
1234 | */
|
---|
1235 |
|
---|
1236 | INTNETR0DECL(int) IntNetR0Init(void);
|
---|
1237 | INTNETR0DECL(void) IntNetR0Term(void);
|
---|
1238 | INTNETR0DECL(int) IntNetR0Open(PSUPDRVSESSION pSession, const char *pszNetwork,
|
---|
1239 | INTNETTRUNKTYPE enmTrunkType, const char *pszTrunk, uint32_t fFlags,
|
---|
1240 | uint32_t cbSend, uint32_t cbRecv, PINTNETIFHANDLE phIf);
|
---|
1241 | INTNETR0DECL(uint32_t) IntNetR0GetNetworkCount(void);
|
---|
1242 |
|
---|
1243 | INTNETR0DECL(int) IntNetR0IfClose(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession);
|
---|
1244 | INTNETR0DECL(int) IntNetR0IfGetBufferPtrs(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession,
|
---|
1245 | R3PTRTYPE(PINTNETBUF) *ppRing3Buf, R0PTRTYPE(PINTNETBUF) *ppRing0Buf);
|
---|
1246 | INTNETR0DECL(int) IntNetR0IfSetPromiscuousMode(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, bool fPromiscuous);
|
---|
1247 | INTNETR0DECL(int) IntNetR0IfSetMacAddress(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, PCRTMAC pMac);
|
---|
1248 | INTNETR0DECL(int) IntNetR0IfSetActive(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, bool fActive);
|
---|
1249 | INTNETR0DECL(int) IntNetR0IfSend(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession);
|
---|
1250 | INTNETR0DECL(int) IntNetR0IfWait(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, uint32_t cMillies);
|
---|
1251 | INTNETR0DECL(int) IntNetR0IfAbortWait(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession);
|
---|
1252 |
|
---|
1253 | /** @} */
|
---|
1254 | #endif /* IN_RING0 */
|
---|
1255 |
|
---|
1256 | RT_C_DECLS_END
|
---|
1257 |
|
---|
1258 | #endif
|
---|