1 | /* $Id: VBoxNetBaseService.h 49735 2013-11-30 02:08:42Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxNetUDP - IntNet Client Library.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2011 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 ___VBoxNetBaseService_h___
|
---|
19 | #define ___VBoxNetBaseService_h___
|
---|
20 |
|
---|
21 | #include <iprt/critsect.h>
|
---|
22 |
|
---|
23 |
|
---|
24 | class VBoxNetHlpUDPService
|
---|
25 | {
|
---|
26 | public:
|
---|
27 | virtual int hlpUDPBroadcast(unsigned uSrcPort, unsigned uDstPort,
|
---|
28 | void const *pvData, size_t cbData) const = 0;
|
---|
29 | };
|
---|
30 |
|
---|
31 |
|
---|
32 | # ifndef BASE_SERVICES_ONLY
|
---|
33 | class VBoxNetBaseService: public VBoxNetHlpUDPService
|
---|
34 | {
|
---|
35 | public:
|
---|
36 | VBoxNetBaseService(const std::string& aName, const std::string& aNetworkName);
|
---|
37 | virtual ~VBoxNetBaseService();
|
---|
38 | int parseArgs(int argc, char **argv);
|
---|
39 | int tryGoOnline(void);
|
---|
40 | void shutdown(void);
|
---|
41 | int syncEnter();
|
---|
42 | int syncLeave();
|
---|
43 | int waitForIntNetEvent(int cMillis);
|
---|
44 | int sendBufferOnWire(PCINTNETSEG pSg, int cSg, size_t cbBuffer);
|
---|
45 | void flushWire();
|
---|
46 |
|
---|
47 | virtual int hlpUDPBroadcast(unsigned uSrcPort, unsigned uDstPort,
|
---|
48 | void const *pvData, size_t cbData) const;
|
---|
49 | virtual void usage(void) = 0;
|
---|
50 | virtual int run(void) = 0;
|
---|
51 | virtual int parseOpt(int rc, const RTGETOPTUNION& getOptVal) = 0;
|
---|
52 | virtual int processFrame(void *, size_t) = 0;
|
---|
53 | virtual int processGSO(PCPDMNETWORKGSO, size_t) = 0;
|
---|
54 | virtual int processUDP(void *, size_t) = 0;
|
---|
55 |
|
---|
56 |
|
---|
57 | virtual int init(void);
|
---|
58 | virtual bool isMainNeeded() const;
|
---|
59 |
|
---|
60 | protected:
|
---|
61 | const std::string getName() const;
|
---|
62 | void setName(const std::string&);
|
---|
63 |
|
---|
64 | const std::string getNetwork() const;
|
---|
65 | void setNetwork(const std::string&);
|
---|
66 |
|
---|
67 | const RTMAC getMacAddress() const;
|
---|
68 | void setMacAddress(const RTMAC&);
|
---|
69 |
|
---|
70 | const RTNETADDRIPV4 getIpv4Address() const;
|
---|
71 | void setIpv4Address(const RTNETADDRIPV4&);
|
---|
72 |
|
---|
73 | const RTNETADDRIPV4 getIpv4Netmask() const;
|
---|
74 | void setIpv4Netmask(const RTNETADDRIPV4&);
|
---|
75 |
|
---|
76 | uint32_t getSendBufSize() const;
|
---|
77 | void setSendBufSize(uint32_t);
|
---|
78 |
|
---|
79 | uint32_t getRecvBufSize() const;
|
---|
80 | void setRecvBufSize(uint32_t);
|
---|
81 |
|
---|
82 | int32_t getVerbosityLevel() const;
|
---|
83 | void setVerbosityLevel(int32_t);
|
---|
84 |
|
---|
85 | void addCommandLineOption(const PRTGETOPTDEF);
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * Print debug message depending on the m_cVerbosity level.
|
---|
89 | *
|
---|
90 | * @param iMinLevel The minimum m_cVerbosity level for this message.
|
---|
91 | * @param fMsg Whether to dump parts for the current DHCP message.
|
---|
92 | * @param pszFmt The message format string.
|
---|
93 | * @param ... Optional arguments.
|
---|
94 | */
|
---|
95 | void debugPrint(int32_t iMinLevel, bool fMsg, const char *pszFmt, ...) const;
|
---|
96 | virtual void debugPrintV(int32_t iMinLevel, bool fMsg, const char *pszFmt, va_list va) const;
|
---|
97 |
|
---|
98 | void doReceiveLoop();
|
---|
99 |
|
---|
100 |
|
---|
101 | protected:
|
---|
102 | /* VirtualBox instance */
|
---|
103 | ComPtr<IVirtualBox> virtualbox;
|
---|
104 |
|
---|
105 | private:
|
---|
106 | struct Data;
|
---|
107 | Data *m;
|
---|
108 |
|
---|
109 | private:
|
---|
110 | PRTGETOPTDEF getOptionsPtr();
|
---|
111 | };
|
---|
112 | # endif
|
---|
113 | #endif
|
---|