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