From: Stefan Metzmacher Date: Thu, 3 Apr 2025 15:14:32 +0000 (+0200) Subject: s3:lib: split out open_socket_in_protocol() X-Git-Tag: tevent-0.17.0~284 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=681a6377817ad5744d7d9d281dc8fa62c258f7e1;p=thirdparty%2Fsamba.git s3:lib: split out open_socket_in_protocol() This will be useful if we want to listen on IPPROTO_QUIC sockets. Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke --- diff --git a/source3/include/proto.h b/source3/include/proto.h index 75270c1a025..ba1238ea27b 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -483,6 +483,12 @@ NTSTATUS receive_smb_raw(int fd, unsigned int timeout, size_t maxlen, size_t *p_len); +int open_socket_in_protocol( + int type, + int protocol, + const struct sockaddr_storage *paddr, + uint16_t port, + bool rebind); int open_socket_in( int type, const struct sockaddr_storage *paddr, diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 5b4d7f12cef..910e7fd75e1 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -241,8 +241,9 @@ NTSTATUS receive_smb_raw(int fd, char *buffer, size_t buflen, unsigned int timeo * Return sock or -errno */ -int open_socket_in( +int open_socket_in_protocol( int type, + int protocol, const struct sockaddr_storage *paddr, uint16_t port, bool rebind) @@ -271,7 +272,7 @@ int open_socket_in( goto fail; } - sock = socket(addr.u.ss.ss_family, type, 0 ); + sock = socket(addr.u.ss.ss_family, type, protocol); if (sock == -1) { ret = -errno; DBG_DEBUG("socket() failed: %s\n", strerror(errno)); @@ -353,6 +354,15 @@ fail: return ret; } +int open_socket_in( + int type, + const struct sockaddr_storage *paddr, + uint16_t port, + bool rebind) +{ + return open_socket_in_protocol(type, 0, paddr, port, rebind); +} + struct open_socket_out_state { int fd; struct tevent_context *ev;