-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
network: socket and address build cleanup (#12710)
- split socket interface from socket - add default socket interface library - move io handle to default socket interface library from address Signed-off-by: Florin Coras <[email protected]>
- Loading branch information
1 parent
d16164b
commit a1a68ab
Showing
17 changed files
with
104 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#pragma once | ||
|
||
#include "envoy/common/platform.h" | ||
#include "envoy/common/pure.h" | ||
#include "envoy/network/socket.h" | ||
|
||
namespace Envoy { | ||
namespace Network { | ||
class SocketInterface { | ||
public: | ||
virtual ~SocketInterface() = default; | ||
|
||
/** | ||
* Low level api to create a socket in the underlying host stack. Does not create a | ||
* @ref Network::SocketImpl | ||
* @param type type of socket requested | ||
* @param addr_type type of address used with the socket | ||
* @param version IP version if address type is IP | ||
* @param socket_v6only if the socket is ipv6 version only | ||
* @return @ref Network::IoHandlePtr that wraps the underlying socket file descriptor | ||
*/ | ||
virtual IoHandlePtr socket(Socket::Type type, Address::Type addr_type, Address::IpVersion version, | ||
bool socket_v6only) const PURE; | ||
|
||
/** | ||
* Low level api to create a socket in the underlying host stack. Does not create an | ||
* @ref Network::SocketImpl | ||
* @param socket_type type of socket requested | ||
* @param addr address that is gleaned for address type and version if needed | ||
* @return @ref Network::IoHandlePtr that wraps the underlying socket file descriptor | ||
*/ | ||
virtual IoHandlePtr socket(Socket::Type socket_type, | ||
const Address::InstanceConstSharedPtr addr) const PURE; | ||
|
||
/** | ||
* Wrap socket file descriptor in IoHandle | ||
* @param fd socket file descriptor to be wrapped | ||
* @return @ref Network::IoHandlePtr that wraps the socket file descriptor | ||
*/ | ||
virtual IoHandlePtr socket(os_fd_t fd) PURE; | ||
|
||
/** | ||
* Returns true if the given family is supported on this machine. | ||
* @param domain the IP family. | ||
*/ | ||
virtual bool ipFamilySupported(int domain) PURE; | ||
}; | ||
|
||
using SocketInterfacePtr = std::unique_ptr<SocketInterface>; | ||
|
||
/** | ||
* Create IoHandle for given address | ||
* @param type type of socket to be requested | ||
* @param addr address that is gleaned for address type, version and socket interface name | ||
* @return @ref Network::IoHandlePtr that wraps the underlying socket file descriptor | ||
*/ | ||
static inline IoHandlePtr ioHandleForAddr(Socket::Type type, | ||
const Address::InstanceConstSharedPtr addr) { | ||
return addr->socketInterface().socket(type, addr); | ||
} | ||
|
||
} // namespace Network | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters