aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.h
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2024-05-30 13:38:26 +0200
committerVasil Dimov <vd@FreeBSD.org>2024-06-14 14:23:50 +0200
commit1245d1388b003c46092937def7041917aecec8de (patch)
tree8bb7b3137483cd1a9bf0f3b24dbc547cb4bf0a1c /src/netbase.h
parent0b94fb87206616e475566c3667cbaad0e9faa5b0 (diff)
downloadbitcoin-1245d1388b003c46092937def7041917aecec8de.tar.xz
netbase: extend CreateSock() to support creating arbitrary sockets
Allow the callers of `CreateSock()` to pass all 3 arguments to the `socket(2)` syscall. This makes it possible to create sockets of any domain/type/protocol.
Diffstat (limited to 'src/netbase.h')
-rw-r--r--src/netbase.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/netbase.h b/src/netbase.h
index 321c288f67..8ef6c28996 100644
--- a/src/netbase.h
+++ b/src/netbase.h
@@ -262,16 +262,18 @@ CService LookupNumeric(const std::string& name, uint16_t portDefault = 0, DNSLoo
CSubNet LookupSubNet(const std::string& subnet_str);
/**
- * Create a TCP or UNIX socket in the given address family.
- * @param[in] address_family to use for the socket.
+ * Create a real socket from the operating system.
+ * @param[in] domain Communications domain, first argument to the socket(2) syscall.
+ * @param[in] type Type of the socket, second argument to the socket(2) syscall.
+ * @param[in] protocol The particular protocol to be used with the socket, third argument to the socket(2) syscall.
* @return pointer to the created Sock object or unique_ptr that owns nothing in case of failure
*/
-std::unique_ptr<Sock> CreateSockOS(sa_family_t address_family);
+std::unique_ptr<Sock> CreateSockOS(int domain, int type, int protocol);
/**
* Socket factory. Defaults to `CreateSockOS()`, but can be overridden by unit tests.
*/
-extern std::function<std::unique_ptr<Sock>(const sa_family_t&)> CreateSock;
+extern std::function<std::unique_ptr<Sock>(int, int, int)> CreateSock;
/**
* Create a socket and try to connect to the specified service.