VirtualBox

source: vbox/trunk/src/VBox/NetworkServices/NetLib/IntNetIf.h@ 97009

Last change on this file since 97009 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1/* $Id: IntNetIf.h 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * IntNetIf - Convenience class implementing an IntNet connection.
4 */
5
6/*
7 * Copyright (C) 2009-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VBOX_INCLUDED_SRC_NetLib_IntNetIf_h
29#define VBOX_INCLUDED_SRC_NetLib_IntNetIf_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <iprt/cdefs.h>
35
36#include <iprt/initterm.h>
37#include <iprt/cpp/ministring.h>
38
39#include <VBox/sup.h>
40#include <VBox/vmm/vmm.h>
41#include <VBox/intnet.h>
42
43
44/**
45 * Convenience class implementing an IntNet connection.
46 */
47class IntNetIf
48{
49public:
50 /**
51 * User input callback function.
52 *
53 * @param pvUser The user specified argument.
54 * @param pvFrame The pointer to the frame data.
55 * @param cbFrame The length of the frame data.
56 */
57 typedef DECLCALLBACKTYPE(void, FNINPUT,(void *pvUser, void *pvFrame, uint32_t cbFrame));
58
59 /** Pointer to the user input callback function. */
60 typedef FNINPUT *PFNINPUT;
61
62 /**
63 * User GSO input callback function.
64 *
65 * @param pvUser The user specified argument.
66 * @param pcGso The pointer to the GSO context.
67 * @param cbFrame The length of the GSO data.
68 */
69 typedef DECLCALLBACKTYPE(void, FNINPUTGSO,(void *pvUser, PCPDMNETWORKGSO pcGso, uint32_t cbFrame));
70
71 /** Pointer to the user GSO input callback function. */
72 typedef FNINPUTGSO *PFNINPUTGSO;
73
74
75 /**
76 * An output frame in the send ring buffer.
77 *
78 * Obtained with getOutputFrame(). Caller should copy frame
79 * contents to pvFrame and pass the frame structure to ifOutput()
80 * to be sent to the network.
81 */
82 struct Frame {
83 PINTNETHDR pHdr;
84 void *pvFrame;
85 };
86
87
88private:
89 PSUPDRVSESSION m_pSession;
90 INTNETIFHANDLE m_hIf;
91 PINTNETBUF m_pIfBuf;
92
93 PFNINPUT m_pfnInput;
94 void *m_pvUser;
95
96 PFNINPUTGSO m_pfnInputGSO;
97 void *m_pvUserGSO;
98
99public:
100 IntNetIf();
101 ~IntNetIf();
102
103 int init(const RTCString &strNetwork,
104 INTNETTRUNKTYPE enmTrunkType = kIntNetTrunkType_WhateverNone,
105 const RTCString &strTrunk = RTCString());
106 void uninit();
107
108 int setInputCallback(PFNINPUT pfnInput, void *pvUser);
109 int setInputGSOCallback(PFNINPUTGSO pfnInputGSO, void *pvUser);
110
111 int ifSetPromiscuous(bool fPromiscuous = true);
112
113 int ifPump();
114 int ifAbort();
115
116 int getOutputFrame(Frame &rFrame, size_t cbFrame);
117 int ifOutput(Frame &rFrame);
118
119 int ifClose();
120
121private:
122 int r3Init();
123 void r3Fini();
124
125 int vmmInit();
126
127 int ifOpen(const RTCString &strNetwork,
128 INTNETTRUNKTYPE enmTrunkType,
129 const RTCString &strTrunk);
130 int ifGetBuf();
131 int ifActivate();
132
133 int ifWait(uint32_t cMillies = RT_INDEFINITE_WAIT);
134 int ifProcessInput();
135
136 int ifFlush();
137};
138
139#endif /* !VBOX_INCLUDED_SRC_NetLib_IntNetIf_h */
Note: See TracBrowser for help on using the repository browser.

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