diff --git a/include/envoy/network/listen_socket.h b/include/envoy/network/listen_socket.h index 532ad5c4ba05..b8ba4700ee75 100644 --- a/include/envoy/network/listen_socket.h +++ b/include/envoy/network/listen_socket.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "envoy/common/pure.h" #include "envoy/network/address.h" @@ -30,36 +31,40 @@ class Socket { */ virtual void close() PURE; + enum class SocketState { PreBind, PostBind }; + /** * Visitor class for setting socket options. */ - class Options { + class Option { public: - virtual ~Options() {} + virtual ~Option() {} /** * @param socket the socket on which to apply options. + * @param state the current state of the socket. Significant for options that can only be + * set for some particular state of the socket. * @return true if succeeded, false otherwise. */ - virtual bool setOptions(Socket& socket) const PURE; + virtual bool setOption(Socket& socket, SocketState state) const PURE; /** - * @return bits that can be used to separate connections based on the options. Should return - * zero if connections with different options can be pooled together. This is limited - * to 32 bits to allow these bits to be efficiently combined into a larger hash key - * used in connection pool lookups. + * @param vector of bytes to which the option should append hash key data that will be used + * to separate connections based on the option. Any data already in the key vector must + * not be modified. */ - virtual uint32_t hashKey() const PURE; + virtual void hashKey(std::vector& key) const PURE; }; - typedef std::shared_ptr OptionsSharedPtr; + typedef std::unique_ptr