Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
a9566567
Commit
a9566567
authored
Mar 12, 2015
by
Marcin Siodelski
Browse files
[3688] Rename DHCPv4Exchange to Dhcpv4Exchange as a result of the review.
parent
d3892424
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/dhcp4_srv.cc
View file @
a9566567
...
...
@@ -84,7 +84,7 @@ Dhcp4Hooks Hooks;
namespace
isc
{
namespace
dhcp
{
D
HCP
v4Exchange
::
D
HCP
v4Exchange
(
const
AllocEnginePtr
&
alloc_engine
,
D
hcp
v4Exchange
::
D
hcp
v4Exchange
(
const
AllocEnginePtr
&
alloc_engine
,
const
Pkt4Ptr
&
query
)
:
alloc_engine_
(
alloc_engine
),
query_
(
query
),
resp_
(),
context_
(
new
AllocEngine
::
ClientContext4
())
{
...
...
@@ -104,7 +104,7 @@ DHCPv4Exchange::DHCPv4Exchange(const AllocEnginePtr& alloc_engine,
};
void
D
HCP
v4Exchange
::
initResponse
()
{
D
hcp
v4Exchange
::
initResponse
()
{
uint8_t
resp_type
=
0
;
switch
(
getQuery
()
->
getType
())
{
case
DHCPDISCOVER
:
...
...
@@ -123,12 +123,12 @@ DHCPv4Exchange::initResponse() {
}
void
D
HCP
v4Exchange
::
selectSubnet
()
{
D
hcp
v4Exchange
::
selectSubnet
()
{
context_
->
subnet_
=
selectSubnet
(
query_
);
}
Subnet4Ptr
D
HCP
v4Exchange
::
selectSubnet
(
const
Pkt4Ptr
&
query
)
{
D
hcp
v4Exchange
::
selectSubnet
(
const
Pkt4Ptr
&
query
)
{
Subnet4Ptr
subnet
;
...
...
@@ -233,7 +233,7 @@ Dhcpv4Srv::shutdown() {
isc
::
dhcp
::
Subnet4Ptr
Dhcpv4Srv
::
selectSubnet
(
const
Pkt4Ptr
&
question
)
{
return
(
D
HCP
v4Exchange
::
selectSubnet
(
question
));
return
(
D
hcp
v4Exchange
::
selectSubnet
(
question
));
}
Pkt4Ptr
...
...
@@ -617,7 +617,7 @@ Dhcpv4Srv::computeDhcid(const Lease4Ptr& lease) {
}
void
Dhcpv4Srv
::
copyDefaultFields
(
D
HCP
v4Exchange
&
ex
)
{
Dhcpv4Srv
::
copyDefaultFields
(
D
hcp
v4Exchange
&
ex
)
{
ex
.
getResponse
()
->
setIface
(
ex
.
getQuery
()
->
getIface
());
ex
.
getResponse
()
->
setIndex
(
ex
.
getQuery
()
->
getIndex
());
...
...
@@ -665,12 +665,12 @@ Dhcpv4Srv::copyDefaultFields(DHCPv4Exchange& ex) {
}
void
Dhcpv4Srv
::
appendDefaultOptions
(
D
HCP
v4Exchange
&
ex
)
{
Dhcpv4Srv
::
appendDefaultOptions
(
D
hcp
v4Exchange
&
ex
)
{
// no-op at this time
}
void
Dhcpv4Srv
::
appendServerID
(
D
HCP
v4Exchange
&
ex
)
{
Dhcpv4Srv
::
appendServerID
(
D
hcp
v4Exchange
&
ex
)
{
// The source address for the outbound message should have been set already.
// This is the address that to the best of the server's knowledge will be
// available from the client.
...
...
@@ -681,7 +681,7 @@ Dhcpv4Srv::appendServerID(DHCPv4Exchange& ex) {
}
void
Dhcpv4Srv
::
appendRequestedOptions
(
D
HCP
v4Exchange
&
ex
)
{
Dhcpv4Srv
::
appendRequestedOptions
(
D
hcp
v4Exchange
&
ex
)
{
// Get the subnet relevant for the client. We will need it
// to get the options associated with it.
Subnet4Ptr
subnet
=
ex
.
getContext
()
->
subnet_
;
...
...
@@ -719,7 +719,7 @@ Dhcpv4Srv::appendRequestedOptions(DHCPv4Exchange& ex) {
}
void
Dhcpv4Srv
::
appendRequestedVendorOptions
(
D
HCP
v4Exchange
&
ex
)
{
Dhcpv4Srv
::
appendRequestedVendorOptions
(
D
hcp
v4Exchange
&
ex
)
{
// Get the configured subnet suitable for the incoming packet.
Subnet4Ptr
subnet
=
ex
.
getContext
()
->
subnet_
;
// Leave if there is no subnet matching the incoming packet.
...
...
@@ -776,7 +776,7 @@ Dhcpv4Srv::appendRequestedVendorOptions(DHCPv4Exchange& ex) {
void
Dhcpv4Srv
::
appendBasicOptions
(
D
HCP
v4Exchange
&
ex
)
{
Dhcpv4Srv
::
appendBasicOptions
(
D
hcp
v4Exchange
&
ex
)
{
// Identify options that we always want to send to the
// client (if they are configured).
static
const
uint16_t
required_options
[]
=
{
...
...
@@ -809,7 +809,7 @@ Dhcpv4Srv::appendBasicOptions(DHCPv4Exchange& ex) {
}
void
Dhcpv4Srv
::
processClientName
(
D
HCP
v4Exchange
&
ex
)
{
Dhcpv4Srv
::
processClientName
(
D
hcp
v4Exchange
&
ex
)
{
// It is possible that client has sent both Client FQDN and Hostname
// option. In such case, server should prefer Client FQDN option and
// ignore the Hostname option.
...
...
@@ -842,7 +842,7 @@ Dhcpv4Srv::processClientName(DHCPv4Exchange& ex) {
}
void
Dhcpv4Srv
::
processClientFqdnOption
(
D
HCP
v4Exchange
&
ex
)
{
Dhcpv4Srv
::
processClientFqdnOption
(
D
hcp
v4Exchange
&
ex
)
{
// Obtain the FQDN option from the client's message.
Option4ClientFqdnPtr
fqdn
=
boost
::
dynamic_pointer_cast
<
Option4ClientFqdn
>
(
ex
.
getQuery
()
->
getOption
(
DHO_FQDN
));
...
...
@@ -887,7 +887,7 @@ Dhcpv4Srv::processClientFqdnOption(DHCPv4Exchange& ex) {
}
void
Dhcpv4Srv
::
processHostnameOption
(
D
HCP
v4Exchange
&
ex
)
{
Dhcpv4Srv
::
processHostnameOption
(
D
hcp
v4Exchange
&
ex
)
{
// Obtain the Hostname option from the client's message.
OptionStringPtr
opt_hostname
=
boost
::
dynamic_pointer_cast
<
OptionString
>
(
ex
.
getQuery
()
->
getOption
(
DHO_HOST_NAME
));
...
...
@@ -1041,7 +1041,7 @@ queueNameChangeRequest(const isc::dhcp_ddns::NameChangeType chg_type,
}
void
Dhcpv4Srv
::
assignLease
(
D
HCP
v4Exchange
&
ex
)
{
Dhcpv4Srv
::
assignLease
(
D
hcp
v4Exchange
&
ex
)
{
// Get the pointers to the query and the response messages.
Pkt4Ptr
query
=
ex
.
getQuery
();
Pkt4Ptr
resp
=
ex
.
getResponse
();
...
...
@@ -1313,7 +1313,7 @@ Dhcpv4Srv::assignLease(DHCPv4Exchange& ex) {
}
void
Dhcpv4Srv
::
adjustIfaceData
(
D
HCP
v4Exchange
&
ex
)
{
Dhcpv4Srv
::
adjustIfaceData
(
D
hcp
v4Exchange
&
ex
)
{
adjustRemoteAddr
(
ex
);
// Initialize the pointers to the client's message and the server's
...
...
@@ -1365,7 +1365,7 @@ Dhcpv4Srv::adjustIfaceData(DHCPv4Exchange& ex) {
}
void
Dhcpv4Srv
::
adjustRemoteAddr
(
D
HCP
v4Exchange
&
ex
)
{
Dhcpv4Srv
::
adjustRemoteAddr
(
D
hcp
v4Exchange
&
ex
)
{
// Initialize the pointers to the client's message and the server's
// response.
Pkt4Ptr
query
=
ex
.
getQuery
();
...
...
@@ -1468,7 +1468,7 @@ Dhcpv4Srv::getNetmaskOption(const Subnet4Ptr& subnet) {
Pkt4Ptr
Dhcpv4Srv
::
processDiscover
(
Pkt4Ptr
&
discover
)
{
D
HCP
v4Exchange
ex
(
alloc_engine_
,
discover
);
D
hcp
v4Exchange
ex
(
alloc_engine_
,
discover
);
sanityCheck
(
ex
,
FORBIDDEN
);
...
...
@@ -1514,7 +1514,7 @@ Dhcpv4Srv::processDiscover(Pkt4Ptr& discover) {
Pkt4Ptr
Dhcpv4Srv
::
processRequest
(
Pkt4Ptr
&
request
)
{
D
HCP
v4Exchange
ex
(
alloc_engine_
,
request
);
D
hcp
v4Exchange
ex
(
alloc_engine_
,
request
);
/// @todo Uncomment this (see ticket #3116)
/// sanityCheck(ex, MANDATORY);
...
...
@@ -1675,7 +1675,7 @@ Dhcpv4Srv::processDecline(Pkt4Ptr&) {
Pkt4Ptr
Dhcpv4Srv
::
processInform
(
Pkt4Ptr
&
inform
)
{
D
HCP
v4Exchange
ex
(
alloc_engine_
,
inform
);
D
hcp
v4Exchange
ex
(
alloc_engine_
,
inform
);
// DHCPINFORM MUST not include server identifier.
sanityCheck
(
ex
,
FORBIDDEN
);
...
...
@@ -1800,7 +1800,7 @@ Dhcpv4Srv::acceptDirectRequest(const Pkt4Ptr& pkt) const {
return
(
false
);
}
return
((
pkt
->
getLocalAddr
()
!=
IOAddress
::
IPV4_BCAST_ADDRESS
()
||
D
HCP
v4Exchange
::
selectSubnet
(
pkt
)));
||
D
hcp
v4Exchange
::
selectSubnet
(
pkt
)));
}
bool
...
...
@@ -1899,7 +1899,7 @@ Dhcpv4Srv::acceptServerId(const Pkt4Ptr& query) const {
}
void
Dhcpv4Srv
::
sanityCheck
(
const
D
HCP
v4Exchange
&
ex
,
RequirementLevel
serverid
)
{
Dhcpv4Srv
::
sanityCheck
(
const
D
hcp
v4Exchange
&
ex
,
RequirementLevel
serverid
)
{
OptionPtr
server_id
=
ex
.
getQuery
()
->
getOption
(
DHO_DHCP_SERVER_IDENTIFIER
);
switch
(
serverid
)
{
case
FORBIDDEN
:
...
...
@@ -2088,7 +2088,7 @@ void Dhcpv4Srv::classifyPacket(const Pkt4Ptr& pkt) {
bool
Dhcpv4Srv
::
classSpecificProcessing
(
const
Pkt4Ptr
&
query
,
const
Pkt4Ptr
&
rsp
)
{
Subnet4Ptr
subnet
=
D
HCP
v4Exchange
::
selectSubnet
(
query
);
Subnet4Ptr
subnet
=
D
hcp
v4Exchange
::
selectSubnet
(
query
);
if
(
!
subnet
)
{
return
(
true
);
}
...
...
src/bin/dhcp4/dhcp4_srv.h
View file @
a9566567
...
...
@@ -48,10 +48,10 @@ public:
/// This class represents the DHCPv4 message exchange. The message exchange
/// consists of the single client message, server response to this message
/// and the mechanisms to generate the server's response. The server creates
/// the instance of the @c D
HCP
v4Exchange for each inbound message that it
/// the instance of the @c D
hcp
v4Exchange for each inbound message that it
/// accepts for processing.
///
/// The use of the @c D
HCP
v4Exchange object as a central repository of
/// The use of the @c D
hcp
v4Exchange object as a central repository of
/// information about the message exchange simplifies the API of the
/// @c Dhcpv4Srv class.
///
...
...
@@ -62,7 +62,7 @@ public:
///
/// @todo This is the initial version of this class. In the future a lot of
/// code from the @c Dhcpv4Srv class will be migrated here.
class
D
HCP
v4Exchange
{
class
D
hcp
v4Exchange
{
public:
/// @brief Constructor.
///
...
...
@@ -75,7 +75,7 @@ public:
/// @param alloc_engine Pointer to the instance of the Allocation Engine
/// used by the server.
/// @param query Pointer to the client message.
D
HCP
v4Exchange
(
const
AllocEnginePtr
&
alloc_engine
,
const
Pkt4Ptr
&
query
);
D
hcp
v4Exchange
(
const
AllocEnginePtr
&
alloc_engine
,
const
Pkt4Ptr
&
query
);
/// @brief Initializes the instance of the response message.
///
...
...
@@ -137,8 +137,8 @@ private:
AllocEngine
::
ClientContext4Ptr
context_
;
};
/// @brief Type representing the pointer to the @c D
HCP
v4Exchange.
typedef
boost
::
shared_ptr
<
D
HCP
v4Exchange
>
D
HCP
v4ExchangePtr
;
/// @brief Type representing the pointer to the @c D
hcp
v4Exchange.
typedef
boost
::
shared_ptr
<
D
hcp
v4Exchange
>
D
hcp
v4ExchangePtr
;
/// @brief DHCPv4 server service.
...
...
@@ -375,7 +375,7 @@ protected:
/// @param ex DHCPv4 exchange holding the client's message to be checked.
/// @param serverid expectation regarding server-id option
/// @throw RFCViolation if any issues are detected
static
void
sanityCheck
(
const
D
HCP
v4Exchange
&
ex
,
RequirementLevel
serverid
);
static
void
sanityCheck
(
const
D
hcp
v4Exchange
&
ex
,
RequirementLevel
serverid
);
/// @brief Processes incoming DISCOVER and returns response.
///
...
...
@@ -427,7 +427,7 @@ protected:
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
void
copyDefaultFields
(
D
HCP
v4Exchange
&
ex
);
void
copyDefaultFields
(
D
hcp
v4Exchange
&
ex
);
/// @brief Appends options requested by client.
///
...
...
@@ -436,7 +436,7 @@ protected:
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
void
appendRequestedOptions
(
D
HCP
v4Exchange
&
ex
);
void
appendRequestedOptions
(
D
hcp
v4Exchange
&
ex
);
/// @brief Appends requested vendor options as requested by client.
///
...
...
@@ -448,7 +448,7 @@ protected:
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
void
appendRequestedVendorOptions
(
D
HCP
v4Exchange
&
ex
);
void
appendRequestedVendorOptions
(
D
hcp
v4Exchange
&
ex
);
/// @brief Assigns a lease and appends corresponding options
///
...
...
@@ -464,7 +464,7 @@ protected:
/// The response type in the @c ex object may be set to DHCPACK or DHCPNAK.
///
/// @param ex DHCPv4 exchange holding the client's message to be checked.
void
assignLease
(
D
HCP
v4Exchange
&
ex
);
void
assignLease
(
D
hcp
v4Exchange
&
ex
);
/// @brief Append basic options if they are not present.
///
...
...
@@ -476,7 +476,7 @@ protected:
/// - Domain Name.
///
/// @param ex DHCPv4 exchange holding the client's message to be checked.
void
appendBasicOptions
(
D
HCP
v4Exchange
&
ex
);
void
appendBasicOptions
(
D
hcp
v4Exchange
&
ex
);
/// @brief Processes Client FQDN and Hostname Options sent by a client.
///
...
...
@@ -515,7 +515,7 @@ protected:
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
void
processClientName
(
D
HCP
v4Exchange
&
ex
);
void
processClientName
(
D
hcp
v4Exchange
&
ex
);
/// @brief this is a prefix added to the contend of vendor-class option
///
...
...
@@ -536,7 +536,7 @@ private:
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
void
processClientFqdnOption
(
D
HCP
v4Exchange
&
ex
);
void
processClientFqdnOption
(
D
hcp
v4Exchange
&
ex
);
/// @brief Process Hostname %Option sent by a client.
///
...
...
@@ -548,7 +548,7 @@ private:
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
void
processHostnameOption
(
D
HCP
v4Exchange
&
ex
);
void
processHostnameOption
(
D
hcp
v4Exchange
&
ex
);
protected:
...
...
@@ -599,7 +599,7 @@ protected:
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
void
appendDefaultOptions
(
D
HCP
v4Exchange
&
ex
);
void
appendDefaultOptions
(
D
hcp
v4Exchange
&
ex
);
/// @brief Adds server identifier option to the server's response.
///
...
...
@@ -620,7 +620,7 @@ protected:
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
static
void
appendServerID
(
D
HCP
v4Exchange
&
ex
);
static
void
appendServerID
(
D
hcp
v4Exchange
&
ex
);
/// @brief Set IP/UDP and interface parameters for the DHCPv4 response.
///
...
...
@@ -655,7 +655,7 @@ protected:
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
static
void
adjustIfaceData
(
D
HCP
v4Exchange
&
ex
);
static
void
adjustIfaceData
(
D
hcp
v4Exchange
&
ex
);
/// @brief Sets remote addresses for outgoing packet.
///
...
...
@@ -675,7 +675,7 @@ protected:
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
static
void
adjustRemoteAddr
(
D
HCP
v4Exchange
&
ex
);
static
void
adjustRemoteAddr
(
D
hcp
v4Exchange
&
ex
);
/// @brief converts server-id to text
/// Converts content of server-id option to a text representation, e.g.
...
...
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
View file @
a9566567
...
...
@@ -87,7 +87,7 @@ TEST_F(Dhcpv4SrvTest, adjustIfaceDataRelay) {
req
->
setIndex
(
1
);
// Create the exchange using the req.
D
HCP
v4Exchange
ex
=
createExchange
(
req
);
D
hcp
v4Exchange
ex
=
createExchange
(
req
);
Pkt4Ptr
resp
=
ex
.
getResponse
();
resp
->
setYiaddr
(
IOAddress
(
"192.0.1.100"
));
...
...
@@ -164,7 +164,7 @@ TEST_F(Dhcpv4SrvTest, adjustIfaceDataRenew) {
req
->
setIndex
(
1
);
// Create the exchange using the req.
D
HCP
v4Exchange
ex
=
createExchange
(
req
);
D
hcp
v4Exchange
ex
=
createExchange
(
req
);
Pkt4Ptr
resp
=
ex
.
getResponse
();
// Let's extend the lease for the client in such a way that
...
...
@@ -228,7 +228,7 @@ TEST_F(Dhcpv4SrvTest, adjustIfaceDataSelect) {
req
->
setIndex
(
1
);
// Create the exchange using the req.
D
HCP
v4Exchange
ex
=
createExchange
(
req
);
D
hcp
v4Exchange
ex
=
createExchange
(
req
);
Pkt4Ptr
resp
=
ex
.
getResponse
();
// Assign some new address for this client.
resp
->
setYiaddr
(
IOAddress
(
"192.0.1.13"
));
...
...
@@ -312,7 +312,7 @@ TEST_F(Dhcpv4SrvTest, adjustIfaceDataBroadcast) {
req
->
setFlags
(
Pkt4
::
FLAG_BROADCAST_MASK
);
// Create the exchange using the req.
D
HCP
v4Exchange
ex
=
createExchange
(
req
);
D
hcp
v4Exchange
ex
=
createExchange
(
req
);
Pkt4Ptr
resp
=
ex
.
getResponse
();
// Assign some new address for this client.
...
...
@@ -369,7 +369,7 @@ TEST_F(Dhcpv4SrvTest, adjustIfaceDataInvalid) {
req
->
setIndex
(
1
);
// Create the exchange using the req.
D
HCP
v4Exchange
ex
=
createExchange
(
req
);
D
hcp
v4Exchange
ex
=
createExchange
(
req
);
Pkt4Ptr
resp
=
ex
.
getResponse
();
// Assign some new address for this client.
...
...
@@ -385,7 +385,7 @@ TEST_F(Dhcpv4SrvTest, adjustIfaceDataInvalid) {
// a specified DHCPv4 message and the server identifier is correct.
TEST_F
(
Dhcpv4SrvTest
,
appendServerID
)
{
Pkt4Ptr
query
(
new
Pkt4
(
DHCPDISCOVER
,
1234
));
D
HCP
v4Exchange
ex
=
createExchange
(
query
);
D
hcp
v4Exchange
ex
=
createExchange
(
query
);
Pkt4Ptr
response
=
ex
.
getResponse
();
// Set a local address. It is required by the function under test
...
...
src/bin/dhcp4/tests/dhcp4_test_utils.cc
View file @
a9566567
...
...
@@ -587,9 +587,9 @@ Dhcpv4SrvTest::configure(const std::string& config, NakedDhcpv4Srv& srv,
}
}
D
HCP
v4Exchange
D
hcp
v4Exchange
Dhcpv4SrvTest
::
createExchange
(
const
Pkt4Ptr
&
query
)
{
return
(
D
HCP
v4Exchange
(
srv_
.
alloc_engine_
,
query
));
return
(
D
hcp
v4Exchange
(
srv_
.
alloc_engine_
,
query
));
}
...
...
src/bin/dhcp4/tests/dhcp4_test_utils.h
View file @
a9566567
...
...
@@ -391,8 +391,8 @@ public:
void
configure
(
const
std
::
string
&
config
,
NakedDhcpv4Srv
&
srv
,
const
bool
commit
=
true
);
/// @brief Create @c D
HCP
v4Exchange from client's query.
D
HCP
v4Exchange
createExchange
(
const
Pkt4Ptr
&
query
);
/// @brief Create @c D
hcp
v4Exchange from client's query.
D
hcp
v4Exchange
createExchange
(
const
Pkt4Ptr
&
query
);
/// @brief This function cleans up after the test.
virtual
void
TearDown
();
...
...
src/bin/dhcp4/tests/fqdn_unittest.cc
View file @
a9566567
...
...
@@ -307,7 +307,7 @@ public:
answer
.
reset
(
new
Pkt4
(
DHCPACK
,
1234
));
}
D
HCP
v4Exchange
ex
=
createExchange
(
query
);
D
hcp
v4Exchange
ex
=
createExchange
(
query
);
ASSERT_NO_THROW
(
srv_
->
processClientName
(
ex
));
Option4ClientFqdnPtr
fqdn
=
getClientFqdnOption
(
ex
.
getResponse
());
...
...
@@ -357,7 +357,7 @@ public:
answer
.
reset
(
new
Pkt4
(
DHCPACK
,
1234
));
}
D
HCP
v4Exchange
ex
=
createExchange
(
query
);
D
hcp
v4Exchange
ex
=
createExchange
(
query
);
srv_
->
processClientName
(
ex
);
OptionStringPtr
hostname
=
getHostnameOption
(
ex
.
getResponse
());
...
...
src/bin/dhcp4/tests/test_config.json
0 → 100644
View file @
a9566567
{}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment