VirtualBox

source: vbox/trunk/src/VBox/NetworkServices/Dhcpd/Config.h@ 79514

Last change on this file since 79514 was 79514, checked in by vboxsync, 5 years ago

Dhcpd: Eliminated use of std::string (probably my mistake in the original code). Various other cleanups. bugref:9288

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/* $Id: Config.h 79514 2019-07-04 08:01:58Z vboxsync $ */
2/** @file
3 * DHCP server - server configuration
4 */
5
6/*
7 * Copyright (C) 2017-2019 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 VBOX_INCLUDED_SRC_Dhcpd_Config_h
19#define VBOX_INCLUDED_SRC_Dhcpd_Config_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <iprt/types.h>
25#include <iprt/net.h>
26#include <iprt/cpp/xml.h>
27#include <iprt/cpp/ministring.h>
28
29#include <VBox/intnet.h>
30
31
32#include "Defs.h"
33#include "DhcpOptions.h"
34#include "ClientId.h"
35
36
37class Config
38{
39 /** XXX: TODO: also store fixed address assignments, etc? */
40 typedef std::map<RTMAC, optmap_t> vmmap_t;
41
42 RTCString m_strHome; /* path of ~/.VirtualBox or equivalent */
43
44 RTCString m_strNetwork;
45 RTCString m_strBaseName; /* m_strNetwork sanitized to be usable in a path component */
46
47 RTCString m_strTrunk;
48 INTNETTRUNKTYPE m_enmTrunkType;
49
50 RTMAC m_MacAddress;
51
52 RTNETADDRIPV4 m_IPv4Address;
53 RTNETADDRIPV4 m_IPv4Netmask;
54
55 RTNETADDRIPV4 m_IPv4PoolFirst;
56 RTNETADDRIPV4 m_IPv4PoolLast;
57
58 optmap_t m_GlobalOptions;
59 vmmap_t m_VMMap;
60
61private:
62 Config();
63
64 int init();
65 int homeInit();
66 int logInit();
67 int complete();
68
69public: /* factory methods */
70 static Config *hardcoded(); /* for testing */
71 static Config *create(int argc, char **argv); /* --config */
72 static Config *compat(int argc, char **argv); /* old VBoxNetDHCP flags */
73
74public: /* accessors */
75 const RTCString &getHome() const { return m_strHome; }
76
77 const RTCString &getNetwork() const { return m_strNetwork; }
78 void setNetwork(const RTCString &aStrNetwork);
79
80 const RTCString &getBaseName() const { return m_strBaseName; }
81 const RTCString &getTrunk() const { return m_strTrunk; }
82 INTNETTRUNKTYPE getTrunkType() const { return m_enmTrunkType; }
83
84 const RTMAC &getMacAddress() const { return m_MacAddress; }
85
86 RTNETADDRIPV4 getIPv4Address() const { return m_IPv4Address; }
87 RTNETADDRIPV4 getIPv4Netmask() const { return m_IPv4Netmask; }
88
89 RTNETADDRIPV4 getIPv4PoolFirst() const { return m_IPv4PoolFirst; }
90 RTNETADDRIPV4 getIPv4PoolLast() const { return m_IPv4PoolLast; }
91
92public:
93 optmap_t getOptions(const OptParameterRequest &reqOpts, const ClientId &id,
94 const OptVendorClassId &vendor = OptVendorClassId()) const;
95
96private:
97 static Config *read(const char *pszFileName);
98 void parseConfig(const xml::ElementNode *root);
99 void parseServer(const xml::ElementNode *server);
100 void parseGlobalOptions(const xml::ElementNode *options);
101 void parseVMConfig(const xml::ElementNode *config);
102 void parseOption(const xml::ElementNode *option, optmap_t &optmap);
103
104 int parseMACAddress(RTMAC &aMac, const RTCString &aStr);
105 int parseClientId(OptClientId &aId, const RTCString &aStr);
106
107 void sanitizeBaseName();
108};
109
110#endif /* !VBOX_INCLUDED_SRC_Dhcpd_Config_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