VirtualBox

source: vbox/trunk/src/VBox/Main/include/NATNetworkImpl.h@ 49240

Last change on this file since 49240 was 49129, checked in by vboxsync, 11 years ago

Main/NATNetworkImpl.h: G/c drops NAT_XML_SERIALIZATION and do serialization unconditionally.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: NATNetworkImpl.h 49129 2013-10-16 11:51:55Z vboxsync $ */
2/** @file
3 * INATNetwork implementation header, lives in VBoxSVC.
4 */
5
6/*
7 * Copyright (C) 2006-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 ____H_H_NATNETWORKIMPL
19#define ____H_H_NATNETWORKIMPL
20
21#include "VirtualBoxBase.h"
22
23#ifdef VBOX_WITH_HOSTNETIF_API
24struct NETIFINFO;
25#endif
26
27namespace settings
28{
29 struct NATNetwork;
30 struct NATRule;
31}
32
33#ifdef RT_OS_WINDOWS
34# define NATSR_EXECUTABLE_NAME "VBoxNetNAT.exe"
35#else
36# define NATSR_EXECUTABLE_NAME "VBoxNetNAT"
37#endif
38
39enum ADDRESSLOOKUPTYPE
40{
41 ADDR_GATEWAY,
42 ADDR_DHCP,
43 ADDR_DHCPLOWERIP,
44 ADDR_ANY
45};
46
47class NATNetworkServiceRunner: public NetworkServiceRunner
48{
49public:
50 NATNetworkServiceRunner(): NetworkServiceRunner(NATSR_EXECUTABLE_NAME){}
51 virtual ~NATNetworkServiceRunner(){}
52};
53
54class ATL_NO_VTABLE NATNetwork :
55 public VirtualBoxBase,
56 VBOX_SCRIPTABLE_IMPL(INATNetwork)
57{
58public:
59
60 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(NATNetwork, INATNetwork)
61
62 DECLARE_NOT_AGGREGATABLE (NATNetwork)
63
64 DECLARE_PROTECT_FINAL_CONSTRUCT()
65
66 BEGIN_COM_MAP (NATNetwork)
67 VBOX_DEFAULT_INTERFACE_ENTRIES(INATNetwork)
68 END_COM_MAP()
69
70 DECLARE_EMPTY_CTOR_DTOR (NATNetwork)
71
72 HRESULT FinalConstruct();
73 void FinalRelease();
74
75 HRESULT init(VirtualBox *aVirtualBox,
76 IN_BSTR aName);
77
78
79 HRESULT init(VirtualBox *aVirtualBox,
80 const settings::NATNetwork &data);
81 HRESULT saveSettings(settings::NATNetwork &data);
82 void uninit();
83 // INATNetwork::EventSource
84 STDMETHOD(COMGETTER(EventSource))(IEventSource **IEventSource);
85 // INATNetwork properties
86 STDMETHOD(COMGETTER(Enabled))(BOOL *aEnabled);
87 STDMETHOD(COMSETTER(Enabled))(BOOL aEnabled);
88
89 STDMETHOD(COMGETTER(NetworkName))(BSTR *aName);
90 STDMETHOD(COMSETTER(NetworkName))(IN_BSTR aName);
91
92 STDMETHOD(COMGETTER(Gateway))(BSTR *aIPGateway);
93
94 STDMETHOD(COMGETTER(Network))(BSTR *aIPNetwork);
95 STDMETHOD(COMSETTER(Network))(IN_BSTR aIPNetwork);
96
97 STDMETHOD(COMGETTER(IPv6Enabled))(BOOL *aEnabled);
98 STDMETHOD(COMSETTER(IPv6Enabled))(BOOL aEnabled);
99
100 STDMETHOD(COMGETTER(IPv6Prefix))(BSTR *aName);
101 STDMETHOD(COMSETTER(IPv6Prefix))(IN_BSTR aName);
102
103 STDMETHOD(COMGETTER(AdvertiseDefaultIPv6RouteEnabled))(BOOL *aEnabled);
104 STDMETHOD(COMSETTER(AdvertiseDefaultIPv6RouteEnabled))(BOOL aEnabled);
105
106 STDMETHOD(COMGETTER(NeedDhcpServer))(BOOL *aEnabled);
107 STDMETHOD(COMSETTER(NeedDhcpServer))(BOOL aEnabled);
108
109 STDMETHOD(COMGETTER(LocalMappings))(ComSafeArrayOut(BSTR, aLocalMappings));
110 STDMETHOD(AddLocalMapping)(IN_BSTR aHostId, LONG aOffset);
111
112 STDMETHOD(COMGETTER(LoopbackIp6))(LONG *aLoopbackIp6);
113 STDMETHOD(COMSETTER(LoopbackIp6))(LONG aLoopbackIp6);
114
115 STDMETHOD(COMGETTER(PortForwardRules4))(ComSafeArrayOut(BSTR, aPortForwardRules4));
116 STDMETHOD(COMGETTER(PortForwardRules6))(ComSafeArrayOut(BSTR, aPortForwardRules6));
117
118 STDMETHOD(AddPortForwardRule)(BOOL aIsIpv6,
119 IN_BSTR aPortForwardRuleName,
120 NATProtocol_T aProto,
121 IN_BSTR aHostIp,
122 USHORT aHostPort,
123 IN_BSTR aGuestIp,
124 USHORT aGuestPort);
125 STDMETHOD(RemovePortForwardRule)(BOOL aIsIpv6, IN_BSTR aPortForwardRuleName);
126
127 STDMETHOD(Start)(IN_BSTR aTrunkType);
128 STDMETHOD(Stop)();
129
130private:
131 int recalculateIpv4AddressAssignments();
132 int findFirstAvailableOffset(ADDRESSLOOKUPTYPE, uint32_t *);
133
134 typedef std::map<Utf8Str, settings::NATRule> NATRuleMap;
135 typedef NATRuleMap::const_iterator constNATRuleMapIterator;
136
137 void GetPortForwardRulesFromMap(ComSafeArrayOut(BSTR, aPortForwardRules), NATRuleMap& aRules);
138 /** weak VirtualBox parent */
139 VirtualBox * const mVirtualBox;
140
141 const Bstr mName;
142 struct Data;
143 struct Data *m;
144
145};
146
147#endif // !____H_H_NATNETWORKIMPL
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