VirtualBox

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

Last change on this file since 63470 was 61009, checked in by vboxsync, 8 years ago

Main: big settings cleanup and writing optimization. Moved constructors/equality/default checks into the .cpp file, and write only settings which aren't at the default value. Greatly reduces the effort needed to write everything out, especially when a lot of snapshots have to be dealt with. Move the storage controllers to the hardware settings, where they always belonged. No change to the XML file (yet). Lots of settings related cleanups in the API code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/* $Id: NATNetworkImpl.h 61009 2016-05-17 17:18:29Z vboxsync $ */
2/** @file
3 * INATNetwork implementation header, lives in VBoxSVC.
4 */
5
6/*
7 * Copyright (C) 2006-2016 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#include "VBoxEvents.h"
21#include "NATNetworkWrap.h"
22
23#ifdef VBOX_WITH_HOSTNETIF_API
24struct NETIFINFO;
25#endif
26
27namespace settings
28{
29 struct NATNetwork;
30 struct NATRule;
31 typedef std::map<com::Utf8Str, NATRule> NATRulesMap;
32}
33
34#ifdef RT_OS_WINDOWS
35# define NATSR_EXECUTABLE_NAME "VBoxNetNAT.exe"
36#else
37# define NATSR_EXECUTABLE_NAME "VBoxNetNAT"
38#endif
39
40enum ADDRESSLOOKUPTYPE
41{
42 ADDR_GATEWAY,
43 ADDR_DHCP,
44 ADDR_DHCPLOWERIP,
45 ADDR_ANY
46};
47
48class NATNetworkServiceRunner: public NetworkServiceRunner
49{
50public:
51 NATNetworkServiceRunner(): NetworkServiceRunner(NATSR_EXECUTABLE_NAME){}
52 ~NATNetworkServiceRunner(){}
53};
54
55class ATL_NO_VTABLE NATNetwork :
56 public NATNetworkWrap
57{
58public:
59
60 DECLARE_EMPTY_CTOR_DTOR(NATNetwork)
61
62 HRESULT FinalConstruct();
63 void FinalRelease();
64
65 HRESULT init(VirtualBox *aVirtualBox, com::Utf8Str aName);
66 HRESULT i_loadSettings(const settings::NATNetwork &data);
67 void uninit();
68 HRESULT i_saveSettings(settings::NATNetwork &data);
69
70private:
71
72 // Wrapped INATNetwork properties
73 HRESULT getNetworkName(com::Utf8Str &aNetworkName);
74 HRESULT setNetworkName(const com::Utf8Str &aNetworkName);
75 HRESULT getEnabled(BOOL *aEnabled);
76 HRESULT setEnabled(BOOL aEnabled);
77 HRESULT getNetwork(com::Utf8Str &aNetwork);
78 HRESULT setNetwork(const com::Utf8Str &aNetwork);
79 HRESULT getGateway(com::Utf8Str &aGateway);
80 HRESULT getIPv6Enabled(BOOL *aIPv6Enabled);
81 HRESULT setIPv6Enabled(BOOL aIPv6Enabled);
82 HRESULT getIPv6Prefix(com::Utf8Str &aIPv6Prefix);
83 HRESULT setIPv6Prefix(const com::Utf8Str &aIPv6Prefix);
84 HRESULT getAdvertiseDefaultIPv6RouteEnabled(BOOL *aAdvertiseDefaultIPv6RouteEnabled);
85 HRESULT setAdvertiseDefaultIPv6RouteEnabled(BOOL aAdvertiseDefaultIPv6RouteEnabled);
86 HRESULT getNeedDhcpServer(BOOL *aNeedDhcpServer);
87 HRESULT setNeedDhcpServer(BOOL aNeedDhcpServer);
88 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
89 HRESULT getPortForwardRules4(std::vector<com::Utf8Str> &aPortForwardRules4);
90 HRESULT getLocalMappings(std::vector<com::Utf8Str> &aLocalMappings);
91 HRESULT getLoopbackIp6(LONG *aLoopbackIp6);
92 HRESULT setLoopbackIp6(LONG aLoopbackIp6);
93 HRESULT getPortForwardRules6(std::vector<com::Utf8Str> &aPortForwardRules6);
94
95 // wrapped INATNetwork methods
96 HRESULT addLocalMapping(const com::Utf8Str &aHostid,
97 LONG aOffset);
98 HRESULT addPortForwardRule(BOOL aIsIpv6,
99 const com::Utf8Str &aRuleName,
100 NATProtocol_T aProto,
101 const com::Utf8Str &aHostIP,
102 USHORT aHostPort,
103 const com::Utf8Str &aGuestIP,
104 USHORT aGuestPort);
105 HRESULT removePortForwardRule(BOOL aISipv6,
106 const com::Utf8Str &aRuleName);
107 HRESULT start(const com::Utf8Str &aTrunkType);
108 HRESULT stop();
109
110 // Internal methods
111 int i_recalculateIpv4AddressAssignments();
112 int i_findFirstAvailableOffset(ADDRESSLOOKUPTYPE, uint32_t *);
113 int i_recalculateIPv6Prefix();
114
115 void i_getPortForwardRulesFromMap(std::vector<Utf8Str> &aPortForwardRules, settings::NATRulesMap &aRules);
116
117 struct Data;
118 Data *m;
119};
120
121#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