VirtualBox

source: vbox/trunk/src/VBox/NetworkServices/Dhcpd/ClientId.h@ 104302

Last change on this file since 104302 was 98103, checked in by vboxsync, 22 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/* $Id: ClientId.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * DHCP server - client identifier
4 */
5
6/*
7 * Copyright (C) 2017-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VBOX_INCLUDED_SRC_Dhcpd_ClientId_h
29#define VBOX_INCLUDED_SRC_Dhcpd_ClientId_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include "DhcpdInternal.h"
35#include <iprt/net.h>
36#include "DhcpOptions.h"
37
38/**
39 * A client is identified by either the Client ID option it sends or its chaddr,
40 * i.e. MAC address.
41 */
42class ClientId
43{
44 /** The mac address of the client. */
45 RTMAC m_mac;
46 /** The client ID. */
47 OptClientId m_id;
48
49public:
50 ClientId()
51 : m_mac(), m_id()
52 {}
53 /** @throws std::bad_alloc */
54 ClientId(const RTMAC &a_mac, const OptClientId &a_id)
55 : m_mac(a_mac), m_id(a_id)
56 {}
57 /** @throws std::bad_alloc */
58 ClientId(const ClientId &a_rThat)
59 : m_mac(a_rThat.m_mac), m_id(a_rThat.m_id)
60 {}
61 /** @throws std::bad_alloc */
62 ClientId &operator=(const ClientId &a_rThat)
63 {
64 m_mac = a_rThat.m_mac;
65 m_id = a_rThat.m_id;
66 return *this;
67 }
68
69 const RTMAC &mac() const RT_NOEXCEPT { return m_mac; }
70 const OptClientId &id() const RT_NOEXCEPT { return m_id; }
71
72 /** @name String formatting of %R[id].
73 * @{ */
74 static void registerFormat() RT_NOEXCEPT;
75private:
76 static DECLCALLBACK(size_t) rtStrFormat(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char *pszType,
77 void const *pvValue, int cchWidth, int cchPrecision, unsigned fFlags, void *pvUser);
78 static bool g_fFormatRegistered;
79 /** @} */
80
81 friend bool operator==(const ClientId &l, const ClientId &r) RT_NOEXCEPT;
82 friend bool operator<(const ClientId &l, const ClientId &r) RT_NOEXCEPT;
83};
84
85bool operator==(const ClientId &l, const ClientId &r) RT_NOEXCEPT;
86bool operator<(const ClientId &l, const ClientId &r) RT_NOEXCEPT;
87
88inline bool operator!=(const ClientId &l, const ClientId &r) RT_NOEXCEPT
89{
90 return !(l == r);
91}
92
93#endif /* !VBOX_INCLUDED_SRC_Dhcpd_ClientId_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