diff options
author | Marcin Siodelski <marcin@isc.org> | 2015-02-09 21:09:22 +0100 |
---|---|---|
committer | Marcin Siodelski <marcin@isc.org> | 2015-02-09 21:09:22 +0100 |
commit | 543c155050c88e0607e96b6a52867bd71b2dd66a (patch) | |
tree | d7f438f49b1c959e1366b1097d18a23cea1a8dab /src/lib/dhcpsrv/cfg_iface.h | |
parent | [3604] Use new interface configuration format where applicable. (diff) | |
download | kea-543c155050c88e0607e96b6a52867bd71b2dd66a.tar.xz kea-543c155050c88e0607e96b6a52867bd71b2dd66a.zip |
[3604] Allow for configuration of the socket type for DHCPv4.
Diffstat (limited to 'src/lib/dhcpsrv/cfg_iface.h')
-rw-r--r-- | src/lib/dhcpsrv/cfg_iface.h | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/src/lib/dhcpsrv/cfg_iface.h b/src/lib/dhcpsrv/cfg_iface.h index bf3113b008..72b450aff5 100644 --- a/src/lib/dhcpsrv/cfg_iface.h +++ b/src/lib/dhcpsrv/cfg_iface.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2015 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 @@ -51,6 +51,14 @@ public: isc::Exception(file, line, what) { }; }; +/// @brief Exception thrown when invalid socket type has been specified +/// for the given family. +class InvalidSocketType : public Exception { +public: + InvalidSocketType(const char* file, size_t line, const char* what) : + isc::Exception(file, line, what) { }; +}; + /// @brief Represents selection of interfaces for DHCP server. /// /// This class manages selection of interfaces on which the DHCP server is @@ -63,7 +71,22 @@ public: /// instructs the server to listen on all available interfaces. /// /// Once interfaces have been specified the sockets (either IPv4 or IPv6) -/// can be opened by calling @c CfgIface::openSockets function. +/// can be opened by calling @c CfgIface::openSockets function. Kea +/// offers configuration parameters to control the types of sockets to be +/// opened by the DHCPv4 server. In small deployments it is requires that +/// the server can handle messages from the directly connected clients +/// which don't have an address yet. Unicasting the response to such +/// client is possible by the use of raw sockets. In larger deployments +/// it is often the case that whole traffic is received via relays, and +/// in such case the use of datagram sockets is preferred. The type of the +/// sockets to be opened is specified using one of the +/// @c CfgIface::useSocketType method variants. The @c CfgIface::SocketType +/// enumeration specifies the possible values. The @c CfgIface::SOCKET_DEFAULT +/// is a default setting of the @c CfgIface and it indicates that the +/// @c IfaceMgr should continue using the currently used sockets' type. +/// This is mostly used for unit testing to avoid modifying fake +/// configurations of the @c IfaceMgr. In the real case, one of the +/// remaining values should be used. /// /// @warning This class makes use of the AF_INET and AF_INET6 family literals, /// but it doesn't verify that the address family value passed as @c uint16_t @@ -71,6 +94,17 @@ public: /// guarantee that the address family value is correct. class CfgIface { public: + + /// @brief Socket type used by the DHCPv4 server. + enum SocketType { + /// Default socket type, mainly used for testing. + SOCKET_DEFAULT, + /// Raw socket, used for direct DHCPv4 traffic. + SOCKET_RAW, + /// Datagram socket, i.e. IP/UDP socket. + SOCKET_DGRAM + }; + /// @brief Keyword used to enable all interfaces. /// /// This keyword can be used instead of the interface name to specify @@ -143,6 +177,32 @@ public: /// @c CfgIface::use has been already called for this interface. void use(const uint16_t family, const std::string& iface_name); + /// @brief Sets the specified socket type to be used by the server. + /// + /// @param family Address family (AF_INET or AF_INET6). + /// @param socket_type Socket type. + /// + /// @throw InvalidSocketType if the unsupported socket type has been + /// specified for the address family. Currently, the socket type + /// can only be selected for the AF_INET family. + void useSocketType(const uint16_t family, const SocketType& socket_type); + + /// @brief Sets the specified socket type specified in textual format. + /// + /// The following names of the socket types are currently supported, and + /// can be passed in the @c socket_type parameter: + /// - raw - for raw sockets, + /// - datagram - for the datagram sockets, + /// + /// @param family Address family (AF_INET or AF_INET6) + /// @param socket_type_name Socket type in the textual format. + /// + /// @throw InvalidSocketType if the unsupported socket type has been + /// specified for the address family. Currently, the socket type + /// can only be selected for the AF_INET family. + void useSocketType(const uint16_t family, + const std::string& socket_type_name); + /// @brief Equality operator. /// /// @param other Object to be compared with this object. @@ -204,6 +264,9 @@ private: /// @brief A booolean value which indicates that the wildcard interface name /// has been specified (*). bool wildcard_used_; + + /// @brief A type of the sockets used by the DHCP server. + SocketType socket_type_; }; } |