VirtualBox

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

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

Dhcpd: Went over the Db and IPv4Pool code adding comments and and such. 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: ClientId.h 79529 2019-07-04 18:17:50Z vboxsync $ */
2/** @file
3 * DHCP server - client identifier
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_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 ClientId(const RTMAC &a_mac, const OptClientId &a_id)
44 : m_mac(a_mac), m_id(a_id)
45 {}
46 ClientId(const ClientId &a_rThat)
47 : m_mac(a_rThat.m_mac), m_id(a_rThat.m_id)
48 {}
49 ClientId &operator=(const ClientId &a_rThat)
50 {
51 m_mac = a_rThat.m_mac;
52 m_id = a_rThat.m_id;
53 return *this;
54 }
55
56 const RTMAC &mac() const { return m_mac; }
57 const OptClientId &id() const { return m_id; }
58
59 /** @name String formatting of %R[id].
60 * @{ */
61 static void registerFormat();
62private:
63 static DECLCALLBACK(size_t) rtStrFormat(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char *pszType,
64 void const *pvValue, int cchWidth, int cchPrecision, unsigned fFlags, void *pvUser);
65 static bool g_fFormatRegistered;
66 /** @} */
67
68 friend bool operator==(const ClientId &l, const ClientId &r);
69 friend bool operator<(const ClientId &l, const ClientId &r);
70};
71
72bool operator==(const ClientId &l, const ClientId &r);
73bool operator<(const ClientId &l, const ClientId &r);
74
75inline bool operator!=(const ClientId &l, const ClientId &r)
76{
77 return !(l == r);
78}
79
80#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