VirtualBox

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

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

Main/NATNetwork+NATEngine: simplify settings handling greatly by directly using the structs without tedious translation

  • 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 60786 2016-05-02 13:00:02Z 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}
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 ~NATNetworkServiceRunner(){}
52};
53
54class ATL_NO_VTABLE NATNetwork :
55 public NATNetworkWrap
56{
57public:
58
59 DECLARE_EMPTY_CTOR_DTOR(NATNetwork)
60
61 HRESULT FinalConstruct();
62 void FinalRelease();
63
64 HRESULT init(VirtualBox *aVirtualBox, com::Utf8Str aName);
65 HRESULT i_loadSettings(const settings::NATNetwork &data);
66 void uninit();
67 HRESULT i_saveSettings(settings::NATNetwork &data);
68
69private:
70
71 // Wrapped INATNetwork properties
72 HRESULT getNetworkName(com::Utf8Str &aNetworkName);
73 HRESULT setNetworkName(const com::Utf8Str &aNetworkName);
74 HRESULT getEnabled(BOOL *aEnabled);
75 HRESULT setEnabled(BOOL aEnabled);
76 HRESULT getNetwork(com::Utf8Str &aNetwork);
77 HRESULT setNetwork(const com::Utf8Str &aNetwork);
78 HRESULT getGateway(com::Utf8Str &aGateway);
79 HRESULT getIPv6Enabled(BOOL *aIPv6Enabled);
80 HRESULT setIPv6Enabled(BOOL aIPv6Enabled);
81 HRESULT getIPv6Prefix(com::Utf8Str &aIPv6Prefix);
82 HRESULT setIPv6Prefix(const com::Utf8Str &aIPv6Prefix);
83 HRESULT getAdvertiseDefaultIPv6RouteEnabled(BOOL *aAdvertiseDefaultIPv6RouteEnabled);
84 HRESULT setAdvertiseDefaultIPv6RouteEnabled(BOOL aAdvertiseDefaultIPv6RouteEnabled);
85 HRESULT getNeedDhcpServer(BOOL *aNeedDhcpServer);
86 HRESULT setNeedDhcpServer(BOOL aNeedDhcpServer);
87 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
88 HRESULT getPortForwardRules4(std::vector<com::Utf8Str> &aPortForwardRules4);
89 HRESULT getLocalMappings(std::vector<com::Utf8Str> &aLocalMappings);
90 HRESULT getLoopbackIp6(LONG *aLoopbackIp6);
91 HRESULT setLoopbackIp6(LONG aLoopbackIp6);
92 HRESULT getPortForwardRules6(std::vector<com::Utf8Str> &aPortForwardRules6);
93
94 // wrapped INATNetwork methods
95 HRESULT addLocalMapping(const com::Utf8Str &aHostid,
96 LONG aOffset);
97 HRESULT addPortForwardRule(BOOL aIsIpv6,
98 const com::Utf8Str &aRuleName,
99 NATProtocol_T aProto,
100 const com::Utf8Str &aHostIP,
101 USHORT aHostPort,
102 const com::Utf8Str &aGuestIP,
103 USHORT aGuestPort);
104 HRESULT removePortForwardRule(BOOL aISipv6,
105 const com::Utf8Str &aRuleName);
106 HRESULT start(const com::Utf8Str &aTrunkType);
107 HRESULT stop();
108
109 // Internal methods
110 int i_recalculateIpv4AddressAssignments();
111 int i_findFirstAvailableOffset(ADDRESSLOOKUPTYPE, uint32_t *);
112 int i_recalculateIPv6Prefix();
113
114 void i_getPortForwardRulesFromMap(std::vector<Utf8Str> &aPortForwardRules, settings::NATRulesMap &aRules);
115
116 struct Data;
117 Data *m;
118};
119
120#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