VirtualBox

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

Last change on this file since 90993 was 82968, checked in by vboxsync, 5 years 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.5 KB
Line 
1/* $Id: ClientId.h 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * DHCP server - client identifier
4 */
5
6/*
7 * Copyright (C) 2017-2020 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_ClientId_h
19#define VBOX_INCLUDED_SRC_Dhcpd_ClientId_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include "DhcpdInternal.h"
25#include <iprt/net.h>
26#include "DhcpOptions.h"
27
28/**
29 * A client is identified by either the Client ID option it sends or its chaddr,
30 * i.e. MAC address.
31 */
32class ClientId
33{
34 /** The mac address of the client. */
35 RTMAC m_mac;
36 /** The client ID. */
37 OptClientId m_id;
38
39public:
40 ClientId()
41 : m_mac(), m_id()
42 {}
43 /** @throws std::bad_alloc */
44 ClientId(const RTMAC &a_mac, const OptClientId &a_id)
45 : m_mac(a_mac), m_id(a_id)
46 {}
47 /** @throws std::bad_alloc */
48 ClientId(const ClientId &a_rThat)
49 : m_mac(a_rThat.m_mac), m_id(a_rThat.m_id)
50 {}
51 /** @throws std::bad_alloc */
52 ClientId &operator=(const ClientId &a_rThat)
53 {
54 m_mac = a_rThat.m_mac;
55 m_id = a_rThat.m_id;
56 return *this;
57 }
58
59 const RTMAC &mac() const RT_NOEXCEPT { return m_mac; }
60 const OptClientId &id() const RT_NOEXCEPT { return m_id; }
61
62 /** @name String formatting of %R[id].
63 * @{ */
64 static void registerFormat() RT_NOEXCEPT;
65private:
66 static DECLCALLBACK(size_t) rtStrFormat(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char *pszType,
67 void const *pvValue, int cchWidth, int cchPrecision, unsigned fFlags, void *pvUser);
68 static bool g_fFormatRegistered;
69 /** @} */
70
71 friend bool operator==(const ClientId &l, const ClientId &r) RT_NOEXCEPT;
72 friend bool operator<(const ClientId &l, const ClientId &r) RT_NOEXCEPT;
73};
74
75bool operator==(const ClientId &l, const ClientId &r) RT_NOEXCEPT;
76bool operator<(const ClientId &l, const ClientId &r) RT_NOEXCEPT;
77
78inline bool operator!=(const ClientId &l, const ClientId &r) RT_NOEXCEPT
79{
80 return !(l == r);
81}
82
83#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