Implement raw SMBtrans by backending the SMBtrans2 send code. Receive is
authorTim Potter <tpot@samba.org>
Tue, 28 Oct 2003 10:17:05 +0000 (10:17 +0000)
committerTim Potter <tpot@samba.org>
Tue, 28 Oct 2003 10:17:05 +0000 (10:17 +0000)
the same for trans and trans2.
(This used to be commit 7d21af3fdf6cf5144a41021425179ca2bba553b3)

source4/include/smb_interfaces.h
source4/libcli/raw/rawtrans.c

index 9ac9f418eab9368433def85f2777633b37e0e5d8..5f9667990087316c69ccc1c7823058a92bdfc54d 100644 (file)
@@ -1600,7 +1600,7 @@ struct smb_copy {
 };
 
 
-/* struct for transact2 call */
+/* struct for transact/transact2 call */
 struct smb_trans2 {
        struct {
                uint16 max_param;
@@ -1610,6 +1610,7 @@ struct smb_trans2 {
                uint32 timeout;
                uint8  setup_count;
                uint16 *setup;
+               char *trans_name; /* SMBtrans only */
                DATA_BLOB params;
                DATA_BLOB data;
        } in;
index f8076f71339794351187523aa8e06ca78b4a6481..f31b1eaf7e453bdcd68cddd93b3ca7be4ed57055 100644 (file)
@@ -194,20 +194,32 @@ failed:
        return cli_request_destroy(req);
 }
 
+NTSTATUS smb_raw_trans_recv(struct cli_request *req,
+                            TALLOC_CTX *mem_ctx,
+                            struct smb_trans2 *parms)
+{
+       return smb_raw_trans2_recv(req, mem_ctx, parms);
+}
 
 /****************************************************************************
- trans2 raw async interface - only BLOBs used in this interface.
-note that this doesn't yet support multi-part requests
+ trans/trans2 raw async interface - only BLOBs used in this interface.
+ note that this doesn't yet support multi-part requests
 ****************************************************************************/
-struct cli_request *smb_raw_trans2_send(struct cli_tree *tree,
-                                       struct smb_trans2 *parms)
+struct cli_request *smb_raw_trans_send_backend(struct cli_tree *tree,
+                                              struct smb_trans2 *parms,
+                                              uint8 command)
 {
-       uint8 command = SMBtrans2;
        int wct = 14 + parms->in.setup_count;
        struct cli_request *req; 
        char *outdata,*outparam;
        int i;
-       const int padding = 3;
+       int padding;
+       size_t namelen = 0;
+
+       if (command == SMBtrans)
+               padding = 1;
+       else
+               padding = 3;
        
        req = cli_request_setup(tree, command, wct, padding);
        if (!req) {
@@ -231,9 +243,12 @@ struct cli_request *smb_raw_trans2_send(struct cli_tree *tree,
        SIVAL(req->out.vwv,VWV(6),parms->in.timeout);
        SSVAL(req->out.vwv,VWV(8),0); /* reserved */
        SSVAL(req->out.vwv,VWV(9),parms->in.params.length);
-       SSVAL(req->out.vwv,VWV(10),PTR_DIFF(outparam,req->out.hdr));
+       if (command == SMBtrans && parms->in.trans_name)
+               namelen = cli_req_append_string(req, parms->in.trans_name, 
+                                               STR_TERMINATE);
+       SSVAL(req->out.vwv,VWV(10),PTR_DIFF(outparam,req->out.hdr)+namelen);
        SSVAL(req->out.vwv,VWV(11),parms->in.data.length);
-       SSVAL(req->out.vwv,VWV(12),PTR_DIFF(outdata,req->out.hdr));
+       SSVAL(req->out.vwv,VWV(12),PTR_DIFF(outdata,req->out.hdr)+namelen);
        SSVAL(req->out.vwv,VWV(13),parms->in.setup_count);
        for (i=0;i<parms->in.setup_count;i++)   {
                SSVAL(req->out.vwv,VWV(14)+i*2,parms->in.setup[i]);
@@ -253,6 +268,23 @@ struct cli_request *smb_raw_trans2_send(struct cli_tree *tree,
        return req;
 }
 
+/****************************************************************************
+ trans/trans2 raw async interface - only BLOBs used in this interface.
+note that this doesn't yet support multi-part requests
+****************************************************************************/
+
+struct cli_request *smb_raw_trans_send(struct cli_tree *tree,
+                                      struct smb_trans2 *parms)
+{
+       return smb_raw_trans_send_backend(tree, parms, SMBtrans);
+}
+
+struct cli_request *smb_raw_trans2_send(struct cli_tree *tree,
+                                      struct smb_trans2 *parms)
+{
+       return smb_raw_trans_send_backend(tree, parms, SMBtrans2);
+}
+
 /*
   trans2 synchronous blob interface
 */
@@ -267,6 +299,19 @@ NTSTATUS smb_raw_trans2(struct cli_tree *tree,
 }
 
 
+/*
+  trans synchronous blob interface
+*/
+NTSTATUS smb_raw_trans(struct cli_tree *tree,
+                      TALLOC_CTX *mem_ctx,
+                      struct smb_trans2 *parms)
+{
+       struct cli_request *req;
+       req = smb_raw_trans_send(tree, parms);
+       if (!req) return NT_STATUS_UNSUCCESSFUL;
+       return smb_raw_trans_recv(req, mem_ctx, parms);
+}
+
 /****************************************************************************
   receive a SMB nttrans response allocating the necessary memory
   ****************************************************************************/