VirtualBox

source: vbox/trunk/src/VBox/Main/include/DHCPServerRunner.h@ 27908

Last change on this file since 27908 was 26163, checked in by vboxsync, 15 years ago

PDM: s/pUsbReg/pReg/g (2nd try, backed out r57176)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1/* $Id: DHCPServerRunner.h 26163 2010-02-02 18:58:33Z vboxsync $ */
2/** @file
3 * VirtualBox Main - interface for VBox DHCP server
4 */
5
6/*
7 * Copyright (C) 2009 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21#include <iprt/err.h>
22#include <iprt/types.h>
23#include <iprt/string.h>
24#include <iprt/mem.h>
25#include <VBox/com/string.h>
26
27typedef enum
28{
29 DHCPCFG_NAME = 1,
30 DHCPCFG_NETNAME,
31 DHCPCFG_TRUNKTYPE,
32 DHCPCFG_TRUNKNAME,
33 DHCPCFG_MACADDRESS,
34 DHCPCFG_IPADDRESS,
35 DHCPCFG_LEASEDB,
36 DHCPCFG_VERBOSE,
37 DHCPCFG_GATEWAY,
38 DHCPCFG_LOWERIP,
39 DHCPCFG_UPPERIP,
40 DHCPCFG_NETMASK,
41 DHCPCFG_HELP,
42 DHCPCFG_VERSION,
43 DHCPCFG_BEGINCONFIG,
44 DHCPCFG_NOTOPT_MAXVAL
45}DHCPCFG;
46
47#define TRUNKTYPE_WHATEVER "whatever"
48#define TRUNKTYPE_NETFLT "netflt"
49#define TRUNKTYPE_NETADP "netadp"
50#define TRUNKTYPE_SRVNAT "srvnat"
51
52class DHCPServerRunner
53{
54public:
55 DHCPServerRunner();
56 ~DHCPServerRunner() { stop(); /* don't leave abandoned servers */}
57
58 int setOption(DHCPCFG opt, const char *val, bool enabled)
59 {
60 if(opt == 0 || opt >= DHCPCFG_NOTOPT_MAXVAL)
61 return VERR_INVALID_PARAMETER;
62 if(isRunning())
63 return VERR_INVALID_STATE;
64
65#ifdef RT_OS_WINDOWS
66 if (val && *val)
67 {
68 mOptions[opt] = "\"";
69 mOptions[opt].append(val);
70 mOptions[opt].append("\"");
71 }
72 else
73#endif
74 {
75 mOptions[opt] = val;
76 }
77 mOptionEnabled[opt] = enabled;
78 return VINF_SUCCESS;
79 }
80
81 int setOption(DHCPCFG opt, const com::Utf8Str &val, bool enabled)
82 {
83 return setOption(opt, val.c_str(), enabled);
84 }
85
86 int start();
87 int stop();
88 bool isRunning();
89
90 void detachFromServer();
91private:
92 com::Utf8Str mOptions[DHCPCFG_NOTOPT_MAXVAL];
93 bool mOptionEnabled[DHCPCFG_NOTOPT_MAXVAL];
94 RTPROCESS mProcess;
95};
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