Commit e7237625 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3604] Addressed remaining review comments.

parent 5cae53ef
......@@ -202,6 +202,20 @@ CfgIface::socketTypeToText() const {
isc_throw(Unexpected, "unsupported socket type " << socket_type_);
}
CfgIface::SocketType
CfgIface::textToSocketType(const std::string& socket_type_name) const {
if (socket_type_name == "udp") {
return (SOCKET_UDP);
} else if (socket_type_name == "raw") {
return (SOCKET_RAW);
} else {
isc_throw(InvalidSocketType, "unsupported socket type '"
<< socket_type_name << "'");
}
}
void
CfgIface::use(const uint16_t family, const std::string& iface_name) {
// The interface name specified may have two formats, e.g.:
......@@ -363,18 +377,7 @@ CfgIface::useSocketType(const uint16_t family,
void
CfgIface::useSocketType(const uint16_t family,
const std::string& socket_type_name) {
SocketType socket_type;
if (socket_type_name == "udp") {
socket_type = SOCKET_UDP;
} else if (socket_type_name == "raw") {
socket_type = SOCKET_RAW;
} else {
isc_throw(InvalidSocketType, "unsupported socket type '"
<< socket_type_name << "'");
}
useSocketType(family, socket_type);
useSocketType(family, textToSocketType(socket_type_name));
}
} // end of isc::dhcp namespace
......
......@@ -174,6 +174,10 @@ public:
/// @brief Sets the specified socket type to be used by the server.
///
/// Supported socket types for DHCPv4 are:
/// - @c SOCKET_RAW
/// - @c SOCKET_UDP
///
/// @param family Address family (AF_INET or AF_INET6).
/// @param socket_type Socket type.
///
......@@ -201,6 +205,13 @@ public:
/// @brief Returns the socket type in the textual format.
std::string socketTypeToText() const;
/// @brief Converts the socket type in the textual format to the type
/// represented by the @c SocketType.
///
/// @throw InvalidSocketType if the specified value of the @c socket_type_name
/// is invalid.
SocketType textToSocketType(const std::string& socket_type_name) const;
/// @brief Equality operator.
///
/// @param other Object to be compared with this object.
......
......@@ -25,7 +25,7 @@ using namespace isc::data;
namespace isc {
namespace dhcp {
InterfaceListConfigParser::InterfaceListConfigParser(const int protocol)
InterfaceListConfigParser::InterfaceListConfigParser(const uint16_t protocol)
: protocol_(protocol) {
}
......@@ -50,7 +50,7 @@ InterfaceListConfigParser::commit() {
// Nothing to do.
}
IfacesConfigParser::IfacesConfigParser(const int protocol)
IfacesConfigParser::IfacesConfigParser(const uint16_t protocol)
: protocol_(protocol) {
}
......
......@@ -34,9 +34,7 @@ public:
/// @brief Constructor
///
/// @param protocol AF_INET for DHCPv4 and AF_INET6 for DHCPv6.
///
/// @throw BadValue if supplied parameter name is not "interface"
InterfaceListConfigParser(const int protocol);
InterfaceListConfigParser(const uint16_t protocol);
/// @brief Parses a list of interface names.
///
......@@ -59,7 +57,7 @@ public:
private:
/// @brief AF_INET for DHCPv4 and AF_INET6 for DHCPv6.
int protocol_;
uint16_t protocol_;
};
......@@ -82,7 +80,7 @@ public:
/// @brief Constructor
///
/// @param protocol AF_INET for DHCPv4 and AF_INET6 for DHCPv6.
IfacesConfigParser(const int protocol);
IfacesConfigParser(const uint16_t protocol);
/// @brief Parses generic parameters in "interfaces-config".
///
......
Markdown is supported
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