VirtualBox

source: vbox/trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h@ 103068

Last change on this file since 103068 was 98103, checked in by vboxsync, 20 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
RevLine 
[27856]1/* $Id: VBoxNetBaseService.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBoxNetUDP - IntNet Client Library.
4 */
5
6/*
[98103]7 * Copyright (C) 2009-2023 Oracle and/or its affiliates.
[27856]8 *
[96407]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
[27856]26 */
27
[76576]28#ifndef VBOX_INCLUDED_SRC_NetLib_VBoxNetBaseService_h
29#define VBOX_INCLUDED_SRC_NetLib_VBoxNetBaseService_h
[76525]30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
[47019]33
[44824]34#include <iprt/critsect.h>
[49735]35
36
37class VBoxNetHlpUDPService
[27856]38{
39public:
[84364]40 virtual ~VBoxNetHlpUDPService() { /* Make VC++ 19.2 happy. */ }
41 virtual int hlpUDPBroadcast(unsigned uSrcPort, unsigned uDstPort, void const *pvData, size_t cbData) const = 0;
[49735]42};
43
44
[49842]45class VBoxNetLockee
46{
47public:
[84364]48 virtual ~VBoxNetLockee() { /* Make VC++ 19.2 happy. */ }
[49842]49 virtual int syncEnter() = 0;
50 virtual int syncLeave() = 0;
51};
52
53
54class VBoxNetALock
55{
56public:
[84364]57 VBoxNetALock(VBoxNetLockee *a_lck) : m_lck(a_lck)
[49842]58 {
59 if (m_lck)
60 m_lck->syncEnter();
61 }
62
63 ~VBoxNetALock()
64 {
65 if (m_lck)
66 m_lck->syncLeave();
67 }
68
69private:
70 VBoxNetLockee *m_lck;
71};
72
[50213]73# ifndef BASE_SERVICES_ONLY
[84364]74class VBoxNetBaseService : public VBoxNetHlpUDPService, public VBoxNetLockee
[49735]75{
76public:
77 VBoxNetBaseService(const std::string& aName, const std::string& aNetworkName);
[27856]78 virtual ~VBoxNetBaseService();
79 int parseArgs(int argc, char **argv);
80 int tryGoOnline(void);
81 void shutdown(void);
[49735]82 int syncEnter();
83 int syncLeave();
[44824]84 int waitForIntNetEvent(int cMillis);
[54723]85 int abortWait();
[63267]86 int sendBufferOnWire(PCINTNETSEG paSegs, size_t cSegs, size_t cbBuffer);
[44824]87 void flushWire();
[47019]88
[49735]89 virtual int hlpUDPBroadcast(unsigned uSrcPort, unsigned uDstPort,
90 void const *pvData, size_t cbData) const;
[27856]91 virtual void usage(void) = 0;
[39557]92 virtual int parseOpt(int rc, const RTGETOPTUNION& getOptVal) = 0;
[49735]93 virtual int processFrame(void *, size_t) = 0;
94 virtual int processGSO(PCPDMNETWORKGSO, size_t) = 0;
95 virtual int processUDP(void *, size_t) = 0;
[27856]96
[49735]97
[47019]98 virtual int init(void);
[49842]99 virtual int run(void);
[49735]100 virtual bool isMainNeeded() const;
[47019]101
102protected:
[55365]103 const std::string getServiceName() const;
104 void setServiceName(const std::string&);
[49735]105
[55365]106 const std::string getNetworkName() const;
107 void setNetworkName(const std::string&);
[49735]108
109 const RTMAC getMacAddress() const;
110 void setMacAddress(const RTMAC&);
111
112 const RTNETADDRIPV4 getIpv4Address() const;
113 void setIpv4Address(const RTNETADDRIPV4&);
114
115 const RTNETADDRIPV4 getIpv4Netmask() const;
116 void setIpv4Netmask(const RTNETADDRIPV4&);
117
118 uint32_t getSendBufSize() const;
119 void setSendBufSize(uint32_t);
120
121 uint32_t getRecvBufSize() const;
122 void setRecvBufSize(uint32_t);
123
124 int32_t getVerbosityLevel() const;
125 void setVerbosityLevel(int32_t);
126
[87450]127 void addCommandLineOption(PCRTGETOPTDEF);
[49735]128
[47019]129 /**
130 * Print debug message depending on the m_cVerbosity level.
131 *
132 * @param iMinLevel The minimum m_cVerbosity level for this message.
133 * @param fMsg Whether to dump parts for the current DHCP message.
134 * @param pszFmt The message format string.
135 * @param ... Optional arguments.
136 */
[49735]137 void debugPrint(int32_t iMinLevel, bool fMsg, const char *pszFmt, ...) const;
[47019]138 virtual void debugPrintV(int32_t iMinLevel, bool fMsg, const char *pszFmt, va_list va) const;
139
[49842]140 private:
[49735]141 void doReceiveLoop();
142
[49842]143 /** starts receiving thread and enter event polling loop. */
144 int startReceiveThreadAndEnterEventLoop();
145
146 protected:
[49735]147 /* VirtualBox instance */
148 ComPtr<IVirtualBox> virtualbox;
[54700]149 ComPtr<IVirtualBoxClient> virtualboxClient;
[49735]150
[49842]151 private:
[49735]152 struct Data;
153 Data *m;
154
[49842]155 private:
[39557]156 PRTGETOPTDEF getOptionsPtr();
[27856]157};
[49735]158# endif
[76576]159#endif /* !VBOX_INCLUDED_SRC_NetLib_VBoxNetBaseService_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle
ContactPrivacy/Do Not Sell My InfoTerms of Use