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