Commit 87f58c5d authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3316] Use OptionVendorClass to encapsulate DHCPv4 option 124.

parent 2027fa4c
......@@ -400,6 +400,14 @@ OptionDefinition::haveVendor6Format() const {
return (getType() == OPT_UINT32_TYPE && !getEncapsulatedSpace().empty());
}
bool
OptionDefinition::haveVendorClass4Format() const {
return (haveType(OPT_RECORD_TYPE) &&
(record_fields_.size() == 2) &&
(record_fields_[0] == OPT_UINT32_TYPE) &&
(record_fields_[1] == OPT_BINARY_TYPE));
}
bool
OptionDefinition::haveVendorClass6Format() const {
return (haveType(OPT_RECORD_TYPE) &&
......@@ -669,7 +677,10 @@ OptionDefinition::factorySpecialFormatOption(Option::Universe u,
} else {
if ((getCode() == DHO_FQDN) && haveFqdn4Format()) {
return (OptionPtr(new Option4ClientFqdn(begin, end)));
// V-I VendorClass
} else if ((getCode() == DHO_VIVCO_SUBOPTIONS) &&
haveVendorClass4Format()) {
return (OptionPtr(new OptionVendorClass(Option::V4, begin, end)));
} else if (getCode() == DHO_VIVSO_SUBOPTIONS && haveVendor4Format()) {
// Vendor-Specific Information.
return (OptionPtr(new OptionVendor(Option::V4, begin, end)));
......
// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -324,6 +324,11 @@ public:
/// Vendor-Specific Information %Option.
bool haveVendor6Format() const;
/// @brief Check if the option has format of DHCPv4 V-I Vendor Class option.
///
/// @return true if the option has the format of DHCPv4 Vendor Class option.
bool haveVendorClass4Format() const;
/// @brief Check if the option has format of DHCPv6 Vendor Class option.
///
/// @return true if option has the format of DHCPv6 Vendor Class option.
......
// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -67,6 +67,11 @@ struct OptionDefParams {
RECORD_DECL(FQDN_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE, OPT_UINT8_TYPE,
OPT_FQDN_TYPE);
// V-I Vendor Class record fields.
//
// Opaque data is represented here by the binary data field.
RECORD_DECL(VIVCO_RECORDS, OPT_UINT32_TYPE, OPT_BINARY_TYPE);
/// @brief Definitions of standard DHCPv4 options.
const OptionDefParams OPTION_DEF_PARAMS4[] = {
{ "subnet-mask", DHO_SUBNET_MASK, OPT_IPV4_ADDRESS_TYPE, false, NO_RECORD_DEF, "" },
......@@ -191,8 +196,8 @@ const OptionDefParams OPTION_DEF_PARAMS4[] = {
// dedicated classes to handle them. Until that happens
// let's treat them as 'binary' options.
{ "domain-search", DHO_DOMAIN_SEARCH, OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
{ "vivco-suboptions", DHO_VIVCO_SUBOPTIONS,
OPT_BINARY_TYPE, false, NO_RECORD_DEF, "" },
{ "vivco-suboptions", DHO_VIVCO_SUBOPTIONS, OPT_RECORD_TYPE,
false, RECORD_DEF(VIVCO_RECORDS), "" },
{ "vivso-suboptions", DHO_VIVSO_SUBOPTIONS, OPT_BINARY_TYPE,
false, NO_RECORD_DEF, "" }
......
// Copyright (C) 2011-2013 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -942,8 +942,14 @@ TEST_F(LibDhcpTest, stdOptionDefs4) {
LibDhcpTest::testStdOptionDefs4(DHO_DOMAIN_SEARCH, begin, end,
typeid(Option));
LibDhcpTest::testStdOptionDefs4(DHO_VIVCO_SUBOPTIONS, begin, end,
typeid(Option));
// V-I Vendor option requires specially crafted data.
const char vivco_data[] = {
1, 2, 3, 4, // enterprise id
3, 1, 2, 3 // first byte is opaque data length, the rest is opaque data
};
std::vector<uint8_t> vivco_buf(vivco_data, vivco_data + sizeof(vivco_data));
LibDhcpTest::testStdOptionDefs4(DHO_VIVCO_SUBOPTIONS, vivco_buf.begin(),
vivco_buf.end(), typeid(OptionVendorClass));
LibDhcpTest::testStdOptionDefs4(DHO_VIVSO_SUBOPTIONS, begin, end,
typeid(OptionVendor));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment