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 | */
|
---|
32 | class ClientId
|
---|
33 | {
|
---|
34 | RTMAC m_mac;
|
---|
35 | OptClientId m_id;
|
---|
36 |
|
---|
37 | public:
|
---|
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 |
|
---|
46 | public:
|
---|
47 | static void registerFormat(); /* %R[id] */
|
---|
48 |
|
---|
49 | private:
|
---|
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 |
|
---|
57 | private:
|
---|
58 | friend bool operator==(const ClientId &l, const ClientId &r);
|
---|
59 | friend bool operator<(const ClientId &l, const ClientId &r);
|
---|
60 | };
|
---|
61 |
|
---|
62 | bool operator==(const ClientId &l, const ClientId &r);
|
---|
63 | bool operator<(const ClientId &l, const ClientId &r);
|
---|
64 |
|
---|
65 | inline bool operator!=(const ClientId &l, const ClientId &r)
|
---|
66 | {
|
---|
67 | return !(l == r);
|
---|
68 | }
|
---|
69 |
|
---|
70 | #endif /* !VBOX_INCLUDED_SRC_Dhcpd_ClientId_h */
|
---|