VirtualBox

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

Last change on this file since 28800 was 28800, checked in by vboxsync, 14 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1/* $Id: DHCPServerRunner.h 28800 2010-04-27 08:22:32Z 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#include <iprt/mem.h>
21#include <VBox/com/string.h>
22
23typedef enum
24{
25 DHCPCFG_NAME = 1,
26 DHCPCFG_NETNAME,
27 DHCPCFG_TRUNKTYPE,
28 DHCPCFG_TRUNKNAME,
29 DHCPCFG_MACADDRESS,
30 DHCPCFG_IPADDRESS,
31 DHCPCFG_LEASEDB,
32 DHCPCFG_VERBOSE,
33 DHCPCFG_GATEWAY,
34 DHCPCFG_LOWERIP,
35 DHCPCFG_UPPERIP,
36 DHCPCFG_NETMASK,
37 DHCPCFG_HELP,
38 DHCPCFG_VERSION,
39 DHCPCFG_BEGINCONFIG,
40 DHCPCFG_NOTOPT_MAXVAL
41}DHCPCFG;
42
43#define TRUNKTYPE_WHATEVER "whatever"
44#define TRUNKTYPE_NETFLT "netflt"
45#define TRUNKTYPE_NETADP "netadp"
46#define TRUNKTYPE_SRVNAT "srvnat"
47
48class DHCPServerRunner
49{
50public:
51 DHCPServerRunner();
52 ~DHCPServerRunner() { stop(); /* don't leave abandoned servers */}
53
54 int setOption(DHCPCFG opt, const char *val, bool enabled)
55 {
56 if(opt == 0 || opt >= DHCPCFG_NOTOPT_MAXVAL)
57 return VERR_INVALID_PARAMETER;
58 if(isRunning())
59 return VERR_INVALID_STATE;
60
61#ifdef RT_OS_WINDOWS
62 if (val && *val)
63 {
64 mOptions[opt] = "\"";
65 mOptions[opt].append(val);
66 mOptions[opt].append("\"");
67 }
68 else
69#endif
70 {
71 mOptions[opt] = val;
72 }
73 mOptionEnabled[opt] = enabled;
74 return VINF_SUCCESS;
75 }
76
77 int setOption(DHCPCFG opt, const com::Utf8Str &val, bool enabled)
78 {
79 return setOption(opt, val.c_str(), enabled);
80 }
81
82 int start();
83 int stop();
84 bool isRunning();
85
86 void detachFromServer();
87private:
88 com::Utf8Str mOptions[DHCPCFG_NOTOPT_MAXVAL];
89 bool mOptionEnabled[DHCPCFG_NOTOPT_MAXVAL];
90 RTPROCESS mProcess;
91};
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