VirtualBox

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

Last change on this file since 78267 was 76576, checked in by vboxsync, 6 years ago

NetworkServices: scm header guard alignment.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1/* $Id: ClientId.h 76576 2019-01-01 06:05:25Z 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 "Defs.h"
25#include <iprt/net.h>
26#include "DhcpOptions.h"
27
28/*
29 * Client is identified by either the Client ID option it sends or its
30 * chaddr, i.e. MAC address.
31 */
32class ClientId
33{
34 RTMAC m_mac;
35 OptClientId m_id;
36
37public:
38 ClientId()
39 : m_mac(), m_id() {}
40 ClientId(const RTMAC &macParam, const OptClientId &idParam)
41 : m_mac(macParam), m_id(idParam) {}
42
43 const RTMAC &mac() const { return m_mac; }
44 const OptClientId &id() const { return m_id; }
45
46public:
47 static void registerFormat(); /* %R[id] */
48
49private:
50 static bool g_fFormatRegistered;
51 static DECLCALLBACK(size_t) rtStrFormat(
52 PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
53 const char *pszType, void const *pvValue,
54 int cchWidth, int cchPrecision, unsigned fFlags,
55 void *pvUser);
56
57private:
58 friend bool operator==(const ClientId &l, const ClientId &r);
59 friend bool operator<(const ClientId &l, const ClientId &r);
60};
61
62bool operator==(const ClientId &l, const ClientId &r);
63bool operator<(const ClientId &l, const ClientId &r);
64
65inline bool operator!=(const ClientId &l, const ClientId &r)
66{
67 return !(l == r);
68}
69
70#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