]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:lib: pass 'protocol' to open_socket_out_send()
authorStefan Metzmacher <metze@samba.org>
Fri, 4 Apr 2025 11:33:31 +0000 (13:33 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 18 Apr 2025 10:17:29 +0000 (10:17 +0000)
For now this is always explicitly IPPROTO_TCP,
but that will change when we add support for IPPROTO_QUIC.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/include/proto.h
source3/lib/util_sock.c
source3/libsmb/smbsock_connect.c

index ba1238ea27b7c360b7c315ed2cfa75b66e273e72..016e0657bb30fa436063aeb7f286c4165aa889f6 100644 (file)
@@ -498,6 +498,7 @@ NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
                         int timeout, int *pfd);
 struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
                                        struct tevent_context *ev,
+                                       int protocol,
                                        const struct sockaddr_storage *pss,
                                        uint16_t port,
                                        int timeout);
index f7d85c2cf6e15b44002669d7e418b7db882d1a7a..d4f05b84ce966b4452e5c1e2565b54ca3516fda9 100644 (file)
@@ -404,6 +404,7 @@ static void open_socket_out_cleanup(struct tevent_req *req,
 
 struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
                                        struct tevent_context *ev,
+                                       int protocol,
                                        const struct sockaddr_storage *pss,
                                        uint16_t port,
                                        int timeout)
@@ -427,7 +428,7 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
        };
        state->port = port;
 
-       state->fd = socket(state->saddr.u.sa.sa_family, SOCK_STREAM, 0);
+       state->fd = socket(state->saddr.u.sa.sa_family, SOCK_STREAM, protocol);
        if (state->fd == -1) {
                status = map_nt_error_from_unix(errno);
                tevent_req_nterror(req, status);
@@ -539,7 +540,7 @@ NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
                goto fail;
        }
 
-       req = open_socket_out_send(frame, ev, pss, port, timeout);
+       req = open_socket_out_send(frame, ev, IPPROTO_TCP, pss, port, timeout);
        if (req == NULL) {
                goto fail;
        }
@@ -612,8 +613,12 @@ static void open_socket_out_defer_waited(struct tevent_req *subreq)
                return;
        }
 
-       subreq = open_socket_out_send(state, state->ev, &state->ss,
-                                     state->port, state->timeout);
+       subreq = open_socket_out_send(state,
+                                     state->ev,
+                                     IPPROTO_TCP,
+                                     &state->ss,
+                                     state->port,
+                                     state->timeout);
        if (tevent_req_nomem(subreq, req)) {
                return;
        }
index 7f0baadd368ae63d155ec83b29b1dcc504f40ac0..5486dd196fbddfe214a4230c8987365db2e2076c 100644 (file)
@@ -192,7 +192,12 @@ static struct tevent_req *nb_connect_send(TALLOC_CTX *mem_ctx,
 
        tevent_req_set_cleanup_fn(req, nb_connect_cleanup);
 
-       subreq = open_socket_out_send(state, ev, addr, NBT_SMB_PORT, 5000);
+       subreq = open_socket_out_send(state,
+                                     ev,
+                                     IPPROTO_TCP,
+                                     addr,
+                                     NBT_SMB_PORT,
+                                     5000);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -297,8 +302,12 @@ static void nb_connect_done(struct tevent_req *subreq)
                state->called_name = "*SMBSERVER";
                make_nmb_name(&state->called, state->called_name, 0x20);
 
-               subreq = open_socket_out_send(state, state->ev, state->addr,
-                                             NBT_SMB_PORT, 5000);
+               subreq = open_socket_out_send(state,
+                                             state->ev,
+                                             IPPROTO_TCP,
+                                             state->addr,
+                                             NBT_SMB_PORT,
+                                             5000);
                if (tevent_req_nomem(subreq, req)) {
                        return;
                }
@@ -393,7 +402,11 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
                return req;
        }
        if (port != 0) {
-               state->req_445 = open_socket_out_send(state, ev, addr, port,
+               state->req_445 = open_socket_out_send(state,
+                                                     ev,
+                                                     IPPROTO_TCP,
+                                                     addr,
+                                                     port,
                                                      5000);
                if (tevent_req_nomem(state->req_445, req)) {
                        return tevent_req_post(req, ev);
@@ -407,7 +420,12 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
         * port==0, try both
         */
 
-       state->req_445 = open_socket_out_send(state, ev, addr, TCP_SMB_PORT, 5000);
+       state->req_445 = open_socket_out_send(state,
+                                             ev,
+                                             IPPROTO_TCP,
+                                             addr,
+                                             TCP_SMB_PORT,
+                                             5000);
        if (tevent_req_nomem(state->req_445, req)) {
                return tevent_req_post(req, ev);
        }