VirtualBox

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

Last change on this file since 93444 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

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