r23792: convert Samba4 to GPLv3
[tprouty/samba.git] / source4 / libcli / raw / clitree.c
index f333cf7a98d3a46236ed33ffef586a86d963cfb7..a5217d74b2a1a6eb2c7d62372ad548f1387ab51d 100644 (file)
@@ -8,7 +8,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
 #include "libcli/raw/libcliraw.h"
-#include "libcli/composite/composite.h"
+#include "libcli/smb_composite/smb_composite.h"
 
 #define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \
        req = smbcli_request_setup(tree, cmd, wct, buflen); \
@@ -56,8 +55,8 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session,
 /****************************************************************************
  Send a tconX (async send)
 ****************************************************************************/
-struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, 
-                                            union smb_tcon *parms)
+struct smbcli_request *smb_raw_tcon_send(struct smbcli_tree *tree, 
+                                        union smb_tcon *parms)
 {
        struct smbcli_request *req = NULL;
 
@@ -79,6 +78,9 @@ struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree,
                smbcli_req_append_string(req, parms->tconx.in.path,   STR_TERMINATE | STR_UPPER);
                smbcli_req_append_string(req, parms->tconx.in.device, STR_TERMINATE | STR_ASCII);
                break;
+
+       case RAW_TCON_SMB2:
+               return NULL;
        }
 
        if (!smbcli_request_send(req)) {
@@ -92,8 +94,8 @@ struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree,
 /****************************************************************************
  Send a tconX (async recv)
 ****************************************************************************/
-NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, 
-                              union smb_tcon *parms)
+NTSTATUS smb_raw_tcon_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, 
+                          union smb_tcon *parms)
 {
        uint8_t *p;
 
@@ -125,6 +127,10 @@ NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
                p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.fs_type, 
                                         p, -1, STR_TERMINATE);
                break;
+
+       case RAW_TCON_SMB2:
+               req->status = NT_STATUS_INTERNAL_ERROR;
+               break;
        }
 
 failed:
@@ -134,11 +140,11 @@ failed:
 /****************************************************************************
  Send a tconX (sync interface)
 ****************************************************************************/
-NTSTATUS smb_tree_connect(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, 
-                         union smb_tcon *parms)
+NTSTATUS smb_raw_tcon(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, 
+                     union smb_tcon *parms)
 {
-       struct smbcli_request *req = smb_tree_connect_send(tree, parms);
-       return smb_tree_connect_recv(req, mem_ctx, parms);
+       struct smbcli_request *req = smb_raw_tcon_send(tree, parms);
+       return smb_raw_tcon_recv(req, mem_ctx, parms);
 }
 
 
@@ -153,7 +159,7 @@ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree)
        req = smbcli_request_setup(tree, SMBtdis, 0, 0);
 
        if (smbcli_request_send(req)) {
-               smbcli_request_receive(req);
+               (void) smbcli_request_receive(req);
        }
        return smbcli_request_destroy(req);
 }
@@ -164,28 +170,31 @@ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree)
 */
 NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
                                     struct smbcli_tree **ret_tree, 
-                                    const char *my_name, 
                                     const char *dest_host, int port,
                                     const char *service, const char *service_type,
-                                    struct cli_credentials *credentials)
+                                    struct cli_credentials *credentials,
+                                    struct event_context *ev)
 {
        struct smb_composite_connect io;
        NTSTATUS status;
+       TALLOC_CTX *tmp_ctx = talloc_new(parent_ctx);
+       if (!tmp_ctx) {
+               return NT_STATUS_NO_MEMORY;
+       }
 
        io.in.dest_host = dest_host;
        io.in.port = port;
-       io.in.called_name = strupper_talloc(parent_ctx, dest_host);
-       io.in.calling_name = strupper_talloc(parent_ctx, my_name);
+       io.in.called_name = strupper_talloc(tmp_ctx, dest_host);
        io.in.service = service;
        io.in.service_type = service_type;
-       io.in.domain = cli_credentials_get_domain(credentials);
-       io.in.user = cli_credentials_get_username(credentials);
-       io.in.password = cli_credentials_get_password(credentials);
+       io.in.credentials = credentials;
+       io.in.fallback_to_anonymous = False;
+       io.in.workgroup = lp_workgroup();
        
-       status = smb_composite_connect(&io, parent_ctx);
+       status = smb_composite_connect(&io, parent_ctx, ev);
        if (NT_STATUS_IS_OK(status)) {
                *ret_tree = io.out.tree;
        }
-
+       talloc_free(tmp_ctx);
        return status;
 }