VirtualBox

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

Last change on this file since 95259 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

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