namespace isc {
namespace dhcp {
-DHCPv4Exchange::DHCPv4Exchange(const AllocEnginePtr& alloc_engine,
+Dhcpv4Exchange::Dhcpv4Exchange(const AllocEnginePtr& alloc_engine,
const Pkt4Ptr& query)
: alloc_engine_(alloc_engine), query_(query), resp_(),
context_(new AllocEngine::ClientContext4()) {
};
void
-DHCPv4Exchange::initResponse() {
+Dhcpv4Exchange::initResponse() {
uint8_t resp_type = 0;
switch (getQuery()->getType()) {
case DHCPDISCOVER:
}
void
-DHCPv4Exchange::selectSubnet() {
+Dhcpv4Exchange::selectSubnet() {
context_->subnet_ = selectSubnet(query_);
}
Subnet4Ptr
-DHCPv4Exchange::selectSubnet(const Pkt4Ptr& query) {
+Dhcpv4Exchange::selectSubnet(const Pkt4Ptr& query) {
Subnet4Ptr subnet;
isc::dhcp::Subnet4Ptr
Dhcpv4Srv::selectSubnet(const Pkt4Ptr& question) {
- return (DHCPv4Exchange::selectSubnet(question));
+ return (Dhcpv4Exchange::selectSubnet(question));
}
Pkt4Ptr
}
void
-Dhcpv4Srv::copyDefaultFields(DHCPv4Exchange& ex) {
+Dhcpv4Srv::copyDefaultFields(Dhcpv4Exchange& ex) {
ex.getResponse()->setIface(ex.getQuery()->getIface());
ex.getResponse()->setIndex(ex.getQuery()->getIndex());
}
void
-Dhcpv4Srv::appendDefaultOptions(DHCPv4Exchange& ex) {
+Dhcpv4Srv::appendDefaultOptions(Dhcpv4Exchange& ex) {
// no-op at this time
}
void
-Dhcpv4Srv::appendServerID(DHCPv4Exchange& ex) {
+Dhcpv4Srv::appendServerID(Dhcpv4Exchange& 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.
}
void
-Dhcpv4Srv::appendRequestedOptions(DHCPv4Exchange& ex) {
+Dhcpv4Srv::appendRequestedOptions(Dhcpv4Exchange& ex) {
// Get the subnet relevant for the client. We will need it
// to get the options associated with it.
Subnet4Ptr subnet = ex.getContext()->subnet_;
}
void
-Dhcpv4Srv::appendRequestedVendorOptions(DHCPv4Exchange& ex) {
+Dhcpv4Srv::appendRequestedVendorOptions(Dhcpv4Exchange& 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.
void
-Dhcpv4Srv::appendBasicOptions(DHCPv4Exchange& ex) {
+Dhcpv4Srv::appendBasicOptions(Dhcpv4Exchange& ex) {
// Identify options that we always want to send to the
// client (if they are configured).
static const uint16_t required_options[] = {
}
void
-Dhcpv4Srv::processClientName(DHCPv4Exchange& ex) {
+Dhcpv4Srv::processClientName(Dhcpv4Exchange& 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.
}
void
-Dhcpv4Srv::processClientFqdnOption(DHCPv4Exchange& ex) {
+Dhcpv4Srv::processClientFqdnOption(Dhcpv4Exchange& ex) {
// Obtain the FQDN option from the client's message.
Option4ClientFqdnPtr fqdn = boost::dynamic_pointer_cast<
Option4ClientFqdn>(ex.getQuery()->getOption(DHO_FQDN));
}
void
-Dhcpv4Srv::processHostnameOption(DHCPv4Exchange& ex) {
+Dhcpv4Srv::processHostnameOption(Dhcpv4Exchange& ex) {
// Obtain the Hostname option from the client's message.
OptionStringPtr opt_hostname = boost::dynamic_pointer_cast<OptionString>
(ex.getQuery()->getOption(DHO_HOST_NAME));
}
void
-Dhcpv4Srv::assignLease(DHCPv4Exchange& ex) {
+Dhcpv4Srv::assignLease(Dhcpv4Exchange& ex) {
// Get the pointers to the query and the response messages.
Pkt4Ptr query = ex.getQuery();
Pkt4Ptr resp = ex.getResponse();
}
void
-Dhcpv4Srv::adjustIfaceData(DHCPv4Exchange& ex) {
+Dhcpv4Srv::adjustIfaceData(Dhcpv4Exchange& ex) {
adjustRemoteAddr(ex);
// Initialize the pointers to the client's message and the server's
}
void
-Dhcpv4Srv::adjustRemoteAddr(DHCPv4Exchange& ex) {
+Dhcpv4Srv::adjustRemoteAddr(Dhcpv4Exchange& ex) {
// Initialize the pointers to the client's message and the server's
// response.
Pkt4Ptr query = ex.getQuery();
Pkt4Ptr
Dhcpv4Srv::processDiscover(Pkt4Ptr& discover) {
- DHCPv4Exchange ex(alloc_engine_, discover);
+ Dhcpv4Exchange ex(alloc_engine_, discover);
sanityCheck(ex, FORBIDDEN);
Pkt4Ptr
Dhcpv4Srv::processRequest(Pkt4Ptr& request) {
- DHCPv4Exchange ex(alloc_engine_, request);
+ Dhcpv4Exchange ex(alloc_engine_, request);
/// @todo Uncomment this (see ticket #3116)
/// sanityCheck(ex, MANDATORY);
Pkt4Ptr
Dhcpv4Srv::processInform(Pkt4Ptr& inform) {
- DHCPv4Exchange ex(alloc_engine_, inform);
+ Dhcpv4Exchange ex(alloc_engine_, inform);
// DHCPINFORM MUST not include server identifier.
sanityCheck(ex, FORBIDDEN);
return (false);
}
return ((pkt->getLocalAddr() != IOAddress::IPV4_BCAST_ADDRESS()
- || DHCPv4Exchange::selectSubnet(pkt)));
+ || Dhcpv4Exchange::selectSubnet(pkt)));
}
bool
}
void
-Dhcpv4Srv::sanityCheck(const DHCPv4Exchange& ex, RequirementLevel serverid) {
+Dhcpv4Srv::sanityCheck(const Dhcpv4Exchange& ex, RequirementLevel serverid) {
OptionPtr server_id = ex.getQuery()->getOption(DHO_DHCP_SERVER_IDENTIFIER);
switch (serverid) {
case FORBIDDEN:
bool Dhcpv4Srv::classSpecificProcessing(const Pkt4Ptr& query, const Pkt4Ptr& rsp) {
- Subnet4Ptr subnet = DHCPv4Exchange::selectSubnet(query);
+ Subnet4Ptr subnet = Dhcpv4Exchange::selectSubnet(query);
if (!subnet) {
return (true);
}
/// 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 DHCPv4Exchange for each inbound message that it
+/// the instance of the @c Dhcpv4Exchange for each inbound message that it
/// accepts for processing.
///
-/// The use of the @c DHCPv4Exchange object as a central repository of
+/// The use of the @c Dhcpv4Exchange object as a central repository of
/// information about the message exchange simplifies the API of the
/// @c Dhcpv4Srv class.
///
///
/// @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 DHCPv4Exchange {
+class Dhcpv4Exchange {
public:
/// @brief Constructor.
///
/// @param alloc_engine Pointer to the instance of the Allocation Engine
/// used by the server.
/// @param query Pointer to the client message.
- DHCPv4Exchange(const AllocEnginePtr& alloc_engine, const Pkt4Ptr& query);
+ Dhcpv4Exchange(const AllocEnginePtr& alloc_engine, const Pkt4Ptr& query);
/// @brief Initializes the instance of the response message.
///
AllocEngine::ClientContext4Ptr context_;
};
-/// @brief Type representing the pointer to the @c DHCPv4Exchange.
-typedef boost::shared_ptr<DHCPv4Exchange> DHCPv4ExchangePtr;
+/// @brief Type representing the pointer to the @c Dhcpv4Exchange.
+typedef boost::shared_ptr<Dhcpv4Exchange> Dhcpv4ExchangePtr;
/// @brief DHCPv4 server service.
/// @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 DHCPv4Exchange& ex, RequirementLevel serverid);
+ static void sanityCheck(const Dhcpv4Exchange& ex, RequirementLevel serverid);
/// @brief Processes incoming DISCOVER and returns response.
///
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
- void copyDefaultFields(DHCPv4Exchange& ex);
+ void copyDefaultFields(Dhcpv4Exchange& ex);
/// @brief Appends options requested by client.
///
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
- void appendRequestedOptions(DHCPv4Exchange& ex);
+ void appendRequestedOptions(Dhcpv4Exchange& ex);
/// @brief Appends requested vendor options as requested by client.
///
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
- void appendRequestedVendorOptions(DHCPv4Exchange& ex);
+ void appendRequestedVendorOptions(Dhcpv4Exchange& ex);
/// @brief Assigns a lease and appends corresponding options
///
/// 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(DHCPv4Exchange& ex);
+ void assignLease(Dhcpv4Exchange& ex);
/// @brief Append basic options if they are not present.
///
/// - Domain Name.
///
/// @param ex DHCPv4 exchange holding the client's message to be checked.
- void appendBasicOptions(DHCPv4Exchange& ex);
+ void appendBasicOptions(Dhcpv4Exchange& ex);
/// @brief Processes Client FQDN and Hostname Options sent by a client.
///
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
- void processClientName(DHCPv4Exchange& ex);
+ void processClientName(Dhcpv4Exchange& ex);
/// @brief this is a prefix added to the contend of vendor-class option
///
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
- void processClientFqdnOption(DHCPv4Exchange& ex);
+ void processClientFqdnOption(Dhcpv4Exchange& ex);
/// @brief Process Hostname %Option sent by a client.
///
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
- void processHostnameOption(DHCPv4Exchange& ex);
+ void processHostnameOption(Dhcpv4Exchange& ex);
protected:
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
- void appendDefaultOptions(DHCPv4Exchange& ex);
+ void appendDefaultOptions(Dhcpv4Exchange& ex);
/// @brief Adds server identifier option to the server's response.
///
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
- static void appendServerID(DHCPv4Exchange& ex);
+ static void appendServerID(Dhcpv4Exchange& ex);
/// @brief Set IP/UDP and interface parameters for the DHCPv4 response.
///
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
- static void adjustIfaceData(DHCPv4Exchange& ex);
+ static void adjustIfaceData(Dhcpv4Exchange& ex);
/// @brief Sets remote addresses for outgoing packet.
///
///
/// @param ex The exchange holding both the client's message and the
/// server's response.
- static void adjustRemoteAddr(DHCPv4Exchange& ex);
+ static void adjustRemoteAddr(Dhcpv4Exchange& ex);
/// @brief converts server-id to text
/// Converts content of server-id option to a text representation, e.g.
req->setIndex(1);
// Create the exchange using the req.
- DHCPv4Exchange ex = createExchange(req);
+ Dhcpv4Exchange ex = createExchange(req);
Pkt4Ptr resp = ex.getResponse();
resp->setYiaddr(IOAddress("192.0.1.100"));
req->setIndex(1);
// Create the exchange using the req.
- DHCPv4Exchange ex = createExchange(req);
+ Dhcpv4Exchange ex = createExchange(req);
Pkt4Ptr resp = ex.getResponse();
// Let's extend the lease for the client in such a way that
req->setIndex(1);
// Create the exchange using the req.
- DHCPv4Exchange ex = createExchange(req);
+ Dhcpv4Exchange ex = createExchange(req);
Pkt4Ptr resp = ex.getResponse();
// Assign some new address for this client.
resp->setYiaddr(IOAddress("192.0.1.13"));
req->setFlags(Pkt4::FLAG_BROADCAST_MASK);
// Create the exchange using the req.
- DHCPv4Exchange ex = createExchange(req);
+ Dhcpv4Exchange ex = createExchange(req);
Pkt4Ptr resp = ex.getResponse();
// Assign some new address for this client.
req->setIndex(1);
// Create the exchange using the req.
- DHCPv4Exchange ex = createExchange(req);
+ Dhcpv4Exchange ex = createExchange(req);
Pkt4Ptr resp = ex.getResponse();
// Assign some new address for this client.
// a specified DHCPv4 message and the server identifier is correct.
TEST_F(Dhcpv4SrvTest, appendServerID) {
Pkt4Ptr query(new Pkt4(DHCPDISCOVER, 1234));
- DHCPv4Exchange ex = createExchange(query);
+ Dhcpv4Exchange ex = createExchange(query);
Pkt4Ptr response = ex.getResponse();
// Set a local address. It is required by the function under test
}
}
-DHCPv4Exchange
+Dhcpv4Exchange
Dhcpv4SrvTest::createExchange(const Pkt4Ptr& query) {
- return (DHCPv4Exchange(srv_.alloc_engine_, query));
+ return (Dhcpv4Exchange(srv_.alloc_engine_, query));
}
void configure(const std::string& config, NakedDhcpv4Srv& srv,
const bool commit = true);
- /// @brief Create @c DHCPv4Exchange from client's query.
- DHCPv4Exchange createExchange(const Pkt4Ptr& query);
+ /// @brief Create @c Dhcpv4Exchange from client's query.
+ Dhcpv4Exchange createExchange(const Pkt4Ptr& query);
/// @brief This function cleans up after the test.
virtual void TearDown();
answer.reset(new Pkt4(DHCPACK, 1234));
}
- DHCPv4Exchange ex = createExchange(query);
+ Dhcpv4Exchange ex = createExchange(query);
ASSERT_NO_THROW(srv_->processClientName(ex));
Option4ClientFqdnPtr fqdn = getClientFqdnOption(ex.getResponse());
answer.reset(new Pkt4(DHCPACK, 1234));
}
- DHCPv4Exchange ex = createExchange(query);
+ Dhcpv4Exchange ex = createExchange(query);
srv_->processClientName(ex);
OptionStringPtr hostname = getHostnameOption(ex.getResponse());
--- /dev/null
+{}
\ No newline at end of file