VirtualBox

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

Last change on this file since 86714 was 84364, checked in by vboxsync, 5 years ago

NetworkServices: Adjustments for VC++ 19.2. bugref:8489

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