1 | /* $Id: DHCPServerRunner.h 32056 2010-08-27 16:04:23Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Main - interface for VBox DHCP server
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009 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 | #ifndef VBOX_WITH_VRDP_MEMLEAK_DETECTOR
|
---|
21 | #include <iprt/mem.h>
|
---|
22 | #endif /* !VBOX_WITH_VRDP_MEMLEAK_DETECTOR */
|
---|
23 | #include <VBox/com/string.h>
|
---|
24 |
|
---|
25 | typedef enum
|
---|
26 | {
|
---|
27 | DHCPCFG_NAME = 1,
|
---|
28 | DHCPCFG_NETNAME,
|
---|
29 | DHCPCFG_TRUNKTYPE,
|
---|
30 | DHCPCFG_TRUNKNAME,
|
---|
31 | DHCPCFG_MACADDRESS,
|
---|
32 | DHCPCFG_IPADDRESS,
|
---|
33 | DHCPCFG_LEASEDB,
|
---|
34 | DHCPCFG_VERBOSE,
|
---|
35 | DHCPCFG_GATEWAY,
|
---|
36 | DHCPCFG_LOWERIP,
|
---|
37 | DHCPCFG_UPPERIP,
|
---|
38 | DHCPCFG_NETMASK,
|
---|
39 | DHCPCFG_HELP,
|
---|
40 | DHCPCFG_VERSION,
|
---|
41 | DHCPCFG_BEGINCONFIG,
|
---|
42 | DHCPCFG_NOTOPT_MAXVAL
|
---|
43 | }DHCPCFG;
|
---|
44 |
|
---|
45 | #define TRUNKTYPE_WHATEVER "whatever"
|
---|
46 | #define TRUNKTYPE_NETFLT "netflt"
|
---|
47 | #define TRUNKTYPE_NETADP "netadp"
|
---|
48 | #define TRUNKTYPE_SRVNAT "srvnat"
|
---|
49 |
|
---|
50 | class DHCPServerRunner
|
---|
51 | {
|
---|
52 | public:
|
---|
53 | DHCPServerRunner();
|
---|
54 | ~DHCPServerRunner() { stop(); /* don't leave abandoned servers */}
|
---|
55 |
|
---|
56 | int setOption(DHCPCFG opt, const char *val, bool enabled)
|
---|
57 | {
|
---|
58 | if(opt == 0 || opt >= DHCPCFG_NOTOPT_MAXVAL)
|
---|
59 | return VERR_INVALID_PARAMETER;
|
---|
60 | if(isRunning())
|
---|
61 | return VERR_INVALID_STATE;
|
---|
62 |
|
---|
63 | mOptions[opt] = val;
|
---|
64 | mOptionEnabled[opt] = enabled;
|
---|
65 | return VINF_SUCCESS;
|
---|
66 | }
|
---|
67 |
|
---|
68 | int setOption(DHCPCFG opt, const com::Utf8Str &val, bool enabled)
|
---|
69 | {
|
---|
70 | return setOption(opt, val.c_str(), enabled);
|
---|
71 | }
|
---|
72 |
|
---|
73 | int start();
|
---|
74 | int stop();
|
---|
75 | bool isRunning();
|
---|
76 |
|
---|
77 | void detachFromServer();
|
---|
78 | private:
|
---|
79 | com::Utf8Str mOptions[DHCPCFG_NOTOPT_MAXVAL];
|
---|
80 | bool mOptionEnabled[DHCPCFG_NOTOPT_MAXVAL];
|
---|
81 | RTPROCESS mProcess;
|
---|
82 | };
|
---|