summaryrefslogtreecommitdiffstats
path: root/source4/libcli/raw
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-05-25 10:42:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:52:55 -0500
commitc31e144a2d7cb24b866bf95cb27da80f8728c857 (patch)
tree09543f8160eaccf0d978bfa48f85213876ea63dd /source4/libcli/raw
parent04bc1c416a75cb33a0989551651f451c2f91c008 (diff)
downloadsamba-c31e144a2d7cb24b866bf95cb27da80f8728c857.tar.gz
samba-c31e144a2d7cb24b866bf95cb27da80f8728c857.tar.xz
samba-c31e144a2d7cb24b866bf95cb27da80f8728c857.zip
r23138: added a raw interface for SMBecho operations
(This used to be commit 590c6c21db5abd436441a9af62ee65436d6f1222)
Diffstat (limited to 'source4/libcli/raw')
-rw-r--r--source4/libcli/raw/clitransport.c68
-rw-r--r--source4/libcli/raw/interfaces.h18
2 files changed, 86 insertions, 0 deletions
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index ea2aa880b6..71c87e631a 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -593,3 +593,71 @@ void smbcli_transport_send(struct smbcli_request *req)
talloc_set_destructor(req, smbcli_request_destructor);
}
+
+
+/****************************************************************************
+ Send an SMBecho (async send)
+*****************************************************************************/
+struct smbcli_request *smb_raw_echo_send(struct smbcli_transport *transport,
+ struct smb_echo *p)
+{
+ struct smbcli_request *req;
+
+ req = smbcli_request_setup_transport(transport, SMBecho, 1, p->in.size);
+ if (!req) return NULL;
+
+ SSVAL(req->out.vwv, VWV(0), p->in.repeat_count);
+
+ memcpy(req->out.data, p->in.data, p->in.size);
+
+ ZERO_STRUCT(p->out);
+
+ if (!smbcli_request_send(req)) {
+ smbcli_request_destroy(req);
+ return NULL;
+ }
+
+ return req;
+}
+
+/****************************************************************************
+ raw echo interface (async recv)
+****************************************************************************/
+NTSTATUS smb_raw_echo_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
+ struct smb_echo *p)
+{
+ if (!smbcli_request_receive(req) ||
+ smbcli_request_is_error(req)) {
+ goto failed;
+ }
+
+ SMBCLI_CHECK_WCT(req, 1);
+ p->out.count++;
+ p->out.sequence_number = SVAL(req->in.vwv, VWV(0));
+ p->out.size = req->in.data_size;
+ talloc_free(p->out.data);
+ p->out.data = talloc_size(mem_ctx, p->out.size);
+ NT_STATUS_HAVE_NO_MEMORY(p->out.data);
+
+ if (!smbcli_raw_pull_data(req, req->in.data, p->out.size, p->out.data)) {
+ req->status = NT_STATUS_BUFFER_TOO_SMALL;
+ }
+
+ if (p->out.count == p->in.repeat_count) {
+ return smbcli_request_destroy(req);
+ }
+
+ return NT_STATUS_OK;
+
+failed:
+ return smbcli_request_destroy(req);
+}
+
+/****************************************************************************
+ Send a echo (sync interface)
+*****************************************************************************/
+NTSTATUS smb_raw_echo(struct smbcli_transport *transport, struct smb_echo *p)
+{
+ struct smbcli_request *req = smb_raw_echo_send(transport, p);
+ return smbcli_request_simple_recv(req);
+}
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index d0c3ab2d15..93d8dd2c20 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -2614,4 +2614,22 @@ union smb_search_close {
} findclose;
};
+
+/*
+ struct for SMBecho call
+*/
+struct smb_echo {
+ struct {
+ uint16_t repeat_count;
+ uint16_t size;
+ uint8_t *data;
+ } in;
+ struct {
+ uint16_t count;
+ uint16_t sequence_number;
+ uint16_t size;
+ uint8_t *data;
+ } out;
+};
+
#endif /* __LIBCLI_RAW_INTERFACES_H__ */