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.:
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
/// @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.
///
/// @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.
namespace isc {
namespace dhcp {
-InterfaceListConfigParser::InterfaceListConfigParser(const int protocol)
+InterfaceListConfigParser::InterfaceListConfigParser(const uint16_t protocol)
: protocol_(protocol) {
}
// Nothing to do.
}
-IfacesConfigParser::IfacesConfigParser(const int protocol)
+IfacesConfigParser::IfacesConfigParser(const uint16_t protocol)
: protocol_(protocol) {
}
/// @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.
///
private:
/// @brief AF_INET for DHCPv4 and AF_INET6 for DHCPv6.
- int protocol_;
+ uint16_t protocol_;
};
/// @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".
///