VirtualBox

source: vbox/trunk/src/VBox/NetworkServices/Dhcpd/DHCPD.h@ 79563

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

Dhcpd: Went over the Dhcpd and related code adding comments and doing some exception vetting. bugref:9288

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1/* $Id: DHCPD.h 79563 2019-07-06 01:22:56Z vboxsync $ */
2/** @file
3 * DHCP server - protocol logic
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_DHCPD_h
19#define VBOX_INCLUDED_SRC_Dhcpd_DHCPD_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include "DhcpdInternal.h"
25#include <iprt/cpp/ministring.h>
26#include "Config.h"
27#include "DhcpMessage.h"
28#include "Db.h"
29
30
31/**
32 * The core of the DHCP server.
33 *
34 * This class is feed DhcpClientMessages that VBoxNetDhcpd has picked up from
35 * the network. After processing a message it returns the appropriate response
36 * (if any) which VBoxNetDhcpd sends out.
37 */
38class DHCPD
39{
40 /** The DHCP configuration. */
41 const Config *m_pConfig;
42 /** The lease database filename. */
43 RTCString m_strLeasesFilename;
44 /** The lease database. */
45 Db m_db;
46
47public:
48 DHCPD();
49
50 int init(const Config *) RT_NOEXCEPT;
51
52 DhcpServerMessage *process(const std::unique_ptr<DhcpClientMessage> &req) RT_NOEXCEPT
53 {
54 if (req.get() != NULL)
55 return process(*req.get());
56 return NULL;
57 }
58
59 DhcpServerMessage *process(DhcpClientMessage &req) RT_NOEXCEPT;
60
61private:
62 /** @name DHCP message processing methods
63 * @{ */
64 DhcpServerMessage *i_doDiscover(DhcpClientMessage &req);
65 DhcpServerMessage *i_doRequest(DhcpClientMessage &req);
66 DhcpServerMessage *i_doInform(DhcpClientMessage &req);
67 DhcpServerMessage *i_doDecline(const DhcpClientMessage &req) RT_NOEXCEPT;
68 DhcpServerMessage *i_doRelease(const DhcpClientMessage &req) RT_NOEXCEPT;
69
70 DhcpServerMessage *i_createMessage(int type, DhcpClientMessage &req);
71 /** @} */
72
73 /** @name Lease database handling
74 * @{ */
75 int i_loadLeases() RT_NOEXCEPT;
76 void i_saveLeases() RT_NOEXCEPT;
77 /** @} */
78};
79
80#endif /* !VBOX_INCLUDED_SRC_Dhcpd_DHCPD_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