libcli/util: add struct tstream_context to tstream_read_pdu_blob_full_fn_t
authorRalph Boehme <slow@samba.org>
Wed, 21 Sep 2016 21:24:45 +0000 (14:24 -0700)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 25 Oct 2023 22:23:38 +0000 (22:23 +0000)
Add struct tstream_context to tstream_read_pdu_blob_full_fn_t and update
all callers of tstream_read_pdu_blob_send() to use the correct callback.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
12 files changed:
libcli/ldap/ldap_message.c
libcli/ldap/ldap_message.h
libcli/util/tstream.c
libcli/util/tstream.h
source4/dns_server/dns_server.c
source4/kdc/kdc-proxy.c
source4/kdc/kdc-server.c
source4/ldap_server/ldap_server.c
source4/libcli/wrepl/winsrepl.c
source4/ntp_signd/ntp_signd.c
source4/torture/ntp/ntp_signd.c
source4/wrepl_server/wrepl_in_connection.c

index 3099086b05bfb5727449e6c643ad0ba0541eb69e..1a537e8144cc66eec38696cb9b2b2030ac02ef3a 100644 (file)
@@ -1650,7 +1650,10 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data,
   return NT_STATUS_OK if a blob has enough bytes in it to be a full
   ldap packet. Set packet_size if true.
 */
-NTSTATUS ldap_full_packet(void *private_data, DATA_BLOB blob, size_t *packet_size)
+NTSTATUS ldap_full_packet(struct tstream_context *stream,
+                         void *private_data,
+                         DATA_BLOB blob,
+                         size_t *packet_size)
 {
        int ret;
 
index 19bfb99ac97c71c1693b73c38a5e9966d10f98fb..dcbd1e97d84d114cae35bee42aafc98c70789b93 100644 (file)
@@ -218,6 +218,7 @@ struct ldap_request_limits {
 };
 
 struct asn1_data;
+struct tstream_context;
 
 struct ldap_message *new_ldap_message(TALLOC_CTX *mem_ctx);
 NTSTATUS ldap_decode(struct asn1_data *data,
@@ -227,7 +228,10 @@ NTSTATUS ldap_decode(struct asn1_data *data,
 bool ldap_encode(struct ldap_message *msg,
                 const struct ldap_control_handler *control_handlers,
                 DATA_BLOB *result, TALLOC_CTX *mem_ctx);
-NTSTATUS ldap_full_packet(void *private_data, DATA_BLOB blob, size_t *packet_size);
+NTSTATUS ldap_full_packet(struct tstream_context *stream,
+                         void *private_data,
+                         DATA_BLOB blob,
+                         size_t *packet_size);
 
 bool asn1_read_OctetString_talloc(TALLOC_CTX *mem_ctx,
                                  struct asn1_data *data,
index b4317f23ade162966a0b3aa80997156363a55a5b..95e31cab34aa4095e57a75e69f2745bf1ef8f4af 100644 (file)
@@ -111,7 +111,8 @@ static void tstream_read_pdu_blob_done(struct tevent_req *subreq)
                return;
        }
 
-       status = state->caller.full_fn(state->caller.full_private,
+       status = state->caller.full_fn(state->caller.stream,
+                                      state->caller.full_private,
                                       state->pdu_blob, &pdu_size);
        if (NT_STATUS_IS_OK(status)) {
                tevent_req_done(req);
index 6d30e04c70adc9e579361cd47be433748ea7bdb0..cf66abe942bbc2cd6c1e46495be3ac09ecd45b19 100644 (file)
@@ -23,6 +23,8 @@
 /**
  * @brief The function which will report the size of the full pdu.
  *
+ * @param[in]  stream   The tstream_context to operate on
+ *
  * @param[in]  private_data Some private data which could be used.
  *
  * @param[in]  blob     The received blob to get the size from.
@@ -32,7 +34,8 @@
  * @return              NT_STATUS_OK on success, STATUS_MORE_ENTRIES if there
  *                      are more entries.
  */
-typedef NTSTATUS tstream_read_pdu_blob_full_fn_t(void *private_data,
+typedef NTSTATUS tstream_read_pdu_blob_full_fn_t(struct tstream_context *stream,
+                                                void *private_data,
                                                 DATA_BLOB blob,
                                                 size_t *packet_size);
 
index dd9916770a50588ea73831897f3fe00d284b6843..0a36c1c29e26647a3376384eb31cd5f5af097c5a 100644 (file)
@@ -374,13 +374,13 @@ static void dns_tcp_call_loop(struct tevent_req *subreq)
 
        /*
         * The dns tcp pdu's has the length as 2 byte (initial_read_size),
-        * packet_full_request_u16 provides the pdu length then.
+        * tstream_full_request_u16 provides the pdu length then.
         */
        subreq = tstream_read_pdu_blob_send(dns_conn,
                                            dns_conn->conn->event.ctx,
                                            dns_conn->tstream,
                                            2, /* initial_read_size */
-                                           packet_full_request_u16,
+                                           tstream_full_request_u16,
                                            dns_conn);
        if (subreq == NULL) {
                dns_tcp_terminate_connection(dns_conn, "dns_tcp_call_loop: "
@@ -500,13 +500,13 @@ static void dns_tcp_accept(struct stream_connection *conn)
 
        /*
         * The dns tcp pdu's has the length as 2 byte (initial_read_size),
-        * packet_full_request_u16 provides the pdu length then.
+        * tstream_full_request_u16 provides the pdu length then.
         */
        subreq = tstream_read_pdu_blob_send(dns_conn,
                                            dns_conn->conn->event.ctx,
                                            dns_conn->tstream,
                                            2, /* initial_read_size */
-                                           packet_full_request_u16,
+                                           tstream_full_request_u16,
                                            dns_conn);
        if (subreq == NULL) {
                dns_tcp_terminate_connection(dns_conn, "dns_tcp_accept: "
index 2b63b071d6bdb61403555500d5e231ebff3d2d9f..83d552a85a0a97824c0b54d1e148d922d3361eec 100644 (file)
@@ -516,7 +516,7 @@ static void kdc_tcp_proxy_connect_done(struct tevent_req *subreq)
                                            state->ev,
                                            state->proxy.stream,
                                            4, /* initial_read_size */
-                                           packet_full_request_u32,
+                                           tstream_full_request_u32,
                                            req);
        if (tevent_req_nomem(subreq, req)) {
                return;
index ba56f04e71b5ff89e6c37510b187d47c10ecf8d6..297d91e2716b9420466e56585ab088fc43f1ddf9 100644 (file)
@@ -349,13 +349,13 @@ static void kdc_tcp_call_loop(struct tevent_req *subreq)
 
        /*
         * The krb5 tcp pdu's has the length as 4 byte (initial_read_size),
-        * packet_full_request_u32 provides the pdu length then.
+        * tstream_full_request_u32 provides the pdu length then.
         */
        subreq = tstream_read_pdu_blob_send(kdc_conn,
                                            kdc_conn->conn->event.ctx,
                                            kdc_conn->tstream,
                                            4, /* initial_read_size */
-                                           packet_full_request_u32,
+                                           tstream_full_request_u32,
                                            kdc_conn);
        if (subreq == NULL) {
                kdc_tcp_terminate_connection(kdc_conn, "kdc_tcp_call_loop: "
@@ -416,13 +416,13 @@ static void kdc_tcp_call_proxy_done(struct tevent_req *subreq)
 
        /*
         * The krb5 tcp pdu's has the length as 4 byte (initial_read_size),
-        * packet_full_request_u32 provides the pdu length then.
+        * tstream_full_request_u32 provides the pdu length then.
         */
        subreq = tstream_read_pdu_blob_send(kdc_conn,
                                            kdc_conn->conn->event.ctx,
                                            kdc_conn->tstream,
                                            4, /* initial_read_size */
-                                           packet_full_request_u32,
+                                           tstream_full_request_u32,
                                            kdc_conn);
        if (subreq == NULL) {
                kdc_tcp_terminate_connection(kdc_conn, "kdc_tcp_call_proxy_done: "
@@ -505,13 +505,13 @@ static void kdc_tcp_accept(struct stream_connection *conn)
 
        /*
         * The krb5 tcp pdu's has the length as 4 byte (initial_read_size),
-        * packet_full_request_u32 provides the pdu length then.
+        * tstream_full_request_u32 provides the pdu length then.
         */
        subreq = tstream_read_pdu_blob_send(kdc_conn,
                                            kdc_conn->conn->event.ctx,
                                            kdc_conn->tstream,
                                            4, /* initial_read_size */
-                                           packet_full_request_u32,
+                                           tstream_full_request_u32,
                                            kdc_conn);
        if (subreq == NULL) {
                kdc_tcp_terminate_connection(kdc_conn, "kdc_tcp_accept: "
index 08acffc7d44520e8ac9919fc57e9d22547871de0..9c34c3e5712239e2944f8d0f3f1047892838834e 100644 (file)
@@ -449,6 +449,7 @@ static void ldapsrv_accept_tls_done(struct tevent_req *subreq)
 
 static void ldapsrv_call_read_done(struct tevent_req *subreq);
 static NTSTATUS ldapsrv_packet_check(
+       struct tstream_context *stream,
        void *private_data,
        DATA_BLOB blob,
        size_t *packet_size);
@@ -1660,6 +1661,7 @@ static int ldapsrv_check_packet_size(
  *
  */
 static NTSTATUS ldapsrv_packet_check(
+       struct tstream_context *stream,
        void *private_data,
        DATA_BLOB blob,
        size_t *packet_size)
@@ -1668,7 +1670,7 @@ static NTSTATUS ldapsrv_packet_check(
        struct ldapsrv_connection *conn = private_data;
        int result = LDB_SUCCESS;
 
-       ret = ldap_full_packet(private_data, blob, packet_size);
+       ret = ldap_full_packet(stream, private_data, blob, packet_size);
        if (!NT_STATUS_IS_OK(ret)) {
                return ret;
        }
index 001363dd2395c07fb5765f336676069dd53e1473..cf6c1f16d65b5c81d92001889c90acbab39a9ce5 100644 (file)
@@ -476,7 +476,7 @@ static void wrepl_request_writev_done(struct tevent_req *subreq)
                                            state->caller.ev,
                                            state->caller.wrepl_socket->stream,
                                            4, /* initial_read_size */
-                                           packet_full_request_u32,
+                                           tstream_full_request_u32,
                                            NULL);
        if (tevent_req_nomem(subreq, req)) {
                return;
index 4cf460fd2d92d7e99c45c1d69b9a3b5cf07ef688..e7ceba0f8a0db5c3930b6fbfcad0351159f44f9c 100644 (file)
@@ -398,13 +398,13 @@ static void ntp_signd_call_loop(struct tevent_req *subreq)
 
        /*
         * The NTP tcp pdu's has the length as 4 byte (initial_read_size),
-        * packet_full_request_u32 provides the pdu length then.
+        * tstream_full_request_u32 provides the pdu length then.
         */
        subreq = tstream_read_pdu_blob_send(ntp_signd_conn,
                                            ntp_signd_conn->conn->event.ctx,
                                            ntp_signd_conn->tstream,
                                            4, /* initial_read_size */
-                                           packet_full_request_u32,
+                                           tstream_full_request_u32,
                                            ntp_signd_conn);
        if (subreq == NULL) {
                ntp_signd_terminate_connection(ntp_signd_conn, "ntp_signd_call_loop: "
@@ -488,13 +488,13 @@ static void ntp_signd_accept(struct stream_connection *conn)
 
        /*
         * The NTP tcp pdu's has the length as 4 byte (initial_read_size),
-        * packet_full_request_u32 provides the pdu length then.
+        * tstream_full_request_u32 provides the pdu length then.
         */
        subreq = tstream_read_pdu_blob_send(ntp_signd_conn,
                                            ntp_signd_conn->conn->event.ctx,
                                            ntp_signd_conn->tstream,
                                            4, /* initial_read_size */
-                                           packet_full_request_u32,
+                                           tstream_full_request_u32,
                                            ntp_signd_conn);
        if (subreq == NULL) {
                ntp_signd_terminate_connection(ntp_signd_conn,
index 6d482bfdee16b35968470b90915f79f7fc6073d7..fd7da67c5518b26af3859ad48021ebe10496ce0d 100644 (file)
@@ -226,7 +226,7 @@ static bool test_ntp_signd(struct torture_context *tctx,
                                         tctx->ev,
                                         signd_client->tstream,
                                         4, /*initial_read_size */
-                                        packet_full_request_u32,
+                                        tstream_full_request_u32,
                                         NULL);
        torture_assert(tctx, req != NULL,
                       "Failed to setup a read for pdu_blob.");
index 1cdc40968e2d8a14ae97eb5b9710f89de15495db..571d65dde5498d8a299be0546e41a86581cedcb3 100644 (file)
@@ -161,13 +161,13 @@ static void wreplsrv_accept(struct stream_connection *conn)
 
        /*
         * The wrepl pdu's has the length as 4 byte (initial_read_size),
-        * packet_full_request_u32 provides the pdu length then.
+        * tstream_full_request_u32 provides the pdu length then.
         */
        subreq = tstream_read_pdu_blob_send(wrepl_conn,
                                            wrepl_conn->conn->event.ctx,
                                            wrepl_conn->tstream,
                                            4, /* initial_read_size */
-                                           packet_full_request_u32,
+                                           tstream_full_request_u32,
                                            wrepl_conn);
        if (subreq == NULL) {
                wreplsrv_terminate_in_connection(wrepl_conn, "wrepl_accept: "
@@ -269,7 +269,7 @@ noreply:
                                            wrepl_conn->conn->event.ctx,
                                            wrepl_conn->tstream,
                                            4, /* initial_read_size */
-                                           packet_full_request_u32,
+                                           tstream_full_request_u32,
                                            wrepl_conn);
        if (subreq == NULL) {
                wreplsrv_terminate_in_connection(wrepl_conn, "wreplsrv_call_loop: "
@@ -395,13 +395,13 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
 
        /*
         * The wrepl pdu's has the length as 4 byte (initial_read_size),
-        * packet_full_request_u32 provides the pdu length then.
+        * tstream_full_request_u32 provides the pdu length then.
         */
        subreq = tstream_read_pdu_blob_send(wrepl_in,
                                            wrepl_in->conn->event.ctx,
                                            wrepl_in->tstream,
                                            4, /* initial_read_size */
-                                           packet_full_request_u32,
+                                           tstream_full_request_u32,
                                            wrepl_in);
        if (subreq == NULL) {
                wreplsrv_terminate_in_connection(wrepl_in, "wreplsrv_in_connection_merge: "