VirtualBox

source: vbox/trunk/include/VBox/intnet.h@ 38643

Last change on this file since 38643 was 37979, checked in by vboxsync, 13 years ago

IntNet: Work around DHCP issue on Mac OS X Lion GM when bridging wireless connections (ip_tos is cleared by someone and the checksum is written as little endian).

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

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