1 | /* $Id: NATNetworkServiceRunner.h 46970 2013-07-04 06:43:15Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Main - interface for VBox NAT Network service
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2010 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 | #include <iprt/err.h>
|
---|
18 | #include <iprt/types.h>
|
---|
19 | #include <iprt/string.h>
|
---|
20 | #include <iprt/mem.h>
|
---|
21 | #include <VBox/com/string.h>
|
---|
22 |
|
---|
23 | typedef enum
|
---|
24 | {
|
---|
25 | NATSCCFG_NAME = 1,
|
---|
26 | NATSCCFG_TRUNKTYPE,
|
---|
27 | NATSCCFG_MACADDRESS,
|
---|
28 | NATSCCFG_IPADDRESS,
|
---|
29 | NATSCCFG_NETMASK,
|
---|
30 | NATSCCFG_PORTFORWARD4,
|
---|
31 | NATSCCFG_PORTFORWARD6,
|
---|
32 | NATSCCFG_NOTOPT_MAXVAL
|
---|
33 | }NATSCCFG;
|
---|
34 |
|
---|
35 | #define TRUNKTYPE_WHATEVER "whatever"
|
---|
36 | #define TRUNKTYPE_SRVNAT "srvnat"
|
---|
37 |
|
---|
38 | class NATNetworkServiceRunner
|
---|
39 | {
|
---|
40 | public:
|
---|
41 | NATNetworkServiceRunner();
|
---|
42 | ~NATNetworkServiceRunner() { stop(); /* don't leave abandoned networks */}
|
---|
43 |
|
---|
44 | int setOption(NATSCCFG opt, const char *val, bool enabled)
|
---|
45 | {
|
---|
46 | if (opt == 0 || opt >= NATSCCFG_NOTOPT_MAXVAL)
|
---|
47 | return VERR_INVALID_PARAMETER;
|
---|
48 | if (isRunning())
|
---|
49 | return VERR_INVALID_STATE;
|
---|
50 |
|
---|
51 | mOptions[opt] = val;
|
---|
52 | mOptionEnabled[opt] = enabled;
|
---|
53 | return VINF_SUCCESS;
|
---|
54 | }
|
---|
55 |
|
---|
56 | int setOption(NATSCCFG opt, const com::Utf8Str &val, bool enabled)
|
---|
57 | {
|
---|
58 | return setOption(opt, val.c_str(), enabled);
|
---|
59 | }
|
---|
60 |
|
---|
61 | int start();
|
---|
62 | int stop();
|
---|
63 | bool isRunning();
|
---|
64 |
|
---|
65 | void detachFromServer();
|
---|
66 | private:
|
---|
67 | com::Utf8Str mOptions[NATSCCFG_NOTOPT_MAXVAL];
|
---|
68 | bool mOptionEnabled[NATSCCFG_NOTOPT_MAXVAL];
|
---|
69 | RTPROCESS mProcess;
|
---|
70 | };
|
---|