summaryrefslogtreecommitdiff
path: root/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-03-26 19:21:20 +0000
committer <>2014-05-08 15:03:54 +0000
commitfb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch)
treec2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
parent58ed4748338f9466599adfc8a9171280ed99e23f (diff)
downloadVirtualBox-master.tar.gz
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h')
-rw-r--r--src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h144
1 files changed, 113 insertions, 31 deletions
diff --git a/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h b/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
index eab9a515..a551bc88 100644
--- a/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
+++ b/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -17,45 +17,127 @@
#ifndef ___VBoxNetBaseService_h___
#define ___VBoxNetBaseService_h___
-class VBoxNetBaseService
+
+#include <iprt/critsect.h>
+
+
+class VBoxNetHlpUDPService
{
public:
- VBoxNetBaseService();
+virtual int hlpUDPBroadcast(unsigned uSrcPort, unsigned uDstPort,
+ void const *pvData, size_t cbData) const = 0;
+};
+
+
+class VBoxNetLockee
+{
+public:
+ virtual int syncEnter() = 0;
+ virtual int syncLeave() = 0;
+};
+
+
+class VBoxNetALock
+{
+public:
+ VBoxNetALock(VBoxNetLockee *a_lck):m_lck(a_lck)
+ {
+ if (m_lck)
+ m_lck->syncEnter();
+ }
+
+ ~VBoxNetALock()
+ {
+ if (m_lck)
+ m_lck->syncLeave();
+ }
+
+private:
+ VBoxNetLockee *m_lck;
+};
+
+# ifndef BASE_SERVICES_ONLY
+class VBoxNetBaseService: public VBoxNetHlpUDPService, public VBoxNetLockee
+{
+public:
+ VBoxNetBaseService(const std::string& aName, const std::string& aNetworkName);
virtual ~VBoxNetBaseService();
int parseArgs(int argc, char **argv);
int tryGoOnline(void);
void shutdown(void);
+ int syncEnter();
+ int syncLeave();
+ int waitForIntNetEvent(int cMillis);
+ int sendBufferOnWire(PCINTNETSEG pSg, int cSg, size_t cbBuffer);
+ void flushWire();
+
+ virtual int hlpUDPBroadcast(unsigned uSrcPort, unsigned uDstPort,
+ void const *pvData, size_t cbData) const;
virtual void usage(void) = 0;
- virtual void run(void) = 0;
- virtual int init(void);
virtual int parseOpt(int rc, const RTGETOPTUNION& getOptVal) = 0;
+ virtual int processFrame(void *, size_t) = 0;
+ virtual int processGSO(PCPDMNETWORKGSO, size_t) = 0;
+ virtual int processUDP(void *, size_t) = 0;
- inline void debugPrint( int32_t iMinLevel, bool fMsg, const char *pszFmt, ...) const;
- void debugPrintV(int32_t iMinLevel, bool fMsg, const char *pszFmt, va_list va) const;
-public:
- /** @name The server configuration data members.
- * @{ */
- std::string m_Name;
- std::string m_Network;
- std::string m_TrunkName;
- INTNETTRUNKTYPE m_enmTrunkType;
- RTMAC m_MacAddress;
- RTNETADDRIPV4 m_Ipv4Address;
- /** @} */
- /** @name The network interface
- * @{ */
- PSUPDRVSESSION m_pSession;
- uint32_t m_cbSendBuf;
- uint32_t m_cbRecvBuf;
- INTNETIFHANDLE m_hIf; /**< The handle to the network interface. */
- PINTNETBUF m_pIfBuf; /**< Interface buffer. */
- std::vector<PRTGETOPTDEF> m_vecOptionDefs;
- /** @} */
- /** @name Debug stuff
- * @{ */
- int32_t m_cVerbosity;
-private:
+
+ virtual int init(void);
+ virtual int run(void);
+ virtual bool isMainNeeded() const;
+
+protected:
+ const std::string getName() const;
+ void setName(const std::string&);
+
+ const std::string getNetwork() const;
+ void setNetwork(const std::string&);
+
+ const RTMAC getMacAddress() const;
+ void setMacAddress(const RTMAC&);
+
+ const RTNETADDRIPV4 getIpv4Address() const;
+ void setIpv4Address(const RTNETADDRIPV4&);
+
+ const RTNETADDRIPV4 getIpv4Netmask() const;
+ void setIpv4Netmask(const RTNETADDRIPV4&);
+
+ uint32_t getSendBufSize() const;
+ void setSendBufSize(uint32_t);
+
+ uint32_t getRecvBufSize() const;
+ void setRecvBufSize(uint32_t);
+
+ int32_t getVerbosityLevel() const;
+ void setVerbosityLevel(int32_t);
+
+ void addCommandLineOption(const PRTGETOPTDEF);
+
+ /**
+ * Print debug message depending on the m_cVerbosity level.
+ *
+ * @param iMinLevel The minimum m_cVerbosity level for this message.
+ * @param fMsg Whether to dump parts for the current DHCP message.
+ * @param pszFmt The message format string.
+ * @param ... Optional arguments.
+ */
+ void debugPrint(int32_t iMinLevel, bool fMsg, const char *pszFmt, ...) const;
+ virtual void debugPrintV(int32_t iMinLevel, bool fMsg, const char *pszFmt, va_list va) const;
+
+ private:
+ void doReceiveLoop();
+
+ /** starts receiving thread and enter event polling loop. */
+ int startReceiveThreadAndEnterEventLoop();
+
+ protected:
+ /* VirtualBox instance */
+ ComPtr<IVirtualBox> virtualbox;
+
+ private:
+ struct Data;
+ Data *m;
+
+ private:
PRTGETOPTDEF getOptionsPtr();
- /** @} */
};
+# endif
#endif