Add context for libcli_resolve.
[samba-svnmirror.git] / source / libcli / raw / libcliraw.h
index b00af846b77a13319ff7ded12550cee55f1f7dc9..6c97e61f047325834e275079621d3e474c1d6944 100644 (file)
@@ -1,14 +1,13 @@
 /*
    Unix SMB/CIFS implementation.
    SMB parameters and setup
-   Copyright (C) Andrew Tridgell 1992-1998
-   Copyright (C) Luke Kenneth Casson Leighton 1996-1998
-   Copyright (C) Jeremy Allison 1998
+
+   Copyright (C) Andrew Tridgell 2002-2004
    Copyright (C) James Myers 2003 <myersjj@samba.org>
 
    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 "request.h"
+#ifndef __LIBCLI_RAW_H__
+#define __LIBCLI_RAW_H__
+
+#include "libcli/raw/request.h"
+#include "librpc/gen_ndr/nbt.h"
 
 struct smbcli_tree;  /* forward declare */
 struct smbcli_request;  /* forward declare */
 struct smbcli_session;  /* forward declare */
 struct smbcli_transport;  /* forward declare */
 
+struct resolve_context;
+struct cli_credentials;
+
+/* default timeout for all smb requests */
+#define SMB_REQUEST_TIMEOUT 60
+
 /* context that will be and has been negotiated between the client and server */
 struct smbcli_negotiate {
        /* 
@@ -62,24 +70,20 @@ struct smbcli_negotiate {
        
 /* this is the context for a SMB socket associated with the socket itself */
 struct smbcli_socket {
-       struct ipv4_addr dest_ip;
-       /* dest hostname (which may or may not be a DNS name) */
-       char *hostname;
+       struct socket_context *sock;
 
-       /* the port used */
+       /* what port we ended up connected to */
        int port;
-       
-       struct socket_context *sock;
 
-       /* a count of the number of packets we have received. We
-        * actually only care about zero/non-zero at this stage */
-       uint_t pkt_count;
+       /* the hostname we connected to */
+       const char *hostname;
 
-       /* the network address of the client */
-       char *client_addr;
-       
-       /* timeout for socket operations in milliseconds. */
-       int timeout;
+       /* the event handle for waiting for socket IO */
+       struct {
+               struct event_context *ctx;
+               struct fd_event *fde;
+               struct timed_event *te;
+       } event;
 };
 
 /*
@@ -92,6 +96,7 @@ struct smbcli_options {
        uint_t use_spnego:1;
        uint32_t max_xmit;
        uint16_t max_mux;
+       int request_timeout;
 };
 
 /* this is the context for the client transport layer */
@@ -124,12 +129,8 @@ struct smbcli_transport {
 
        /* the error fields from the last message */
        struct {
-               enum {ETYPE_NONE, ETYPE_DOS, ETYPE_NT, ETYPE_SOCKET, ETYPE_NBT} etype;
+               enum {ETYPE_NONE, ETYPE_SMB, ETYPE_SOCKET, ETYPE_NBT} etype;
                union {
-                       struct {
-                               uint8_t eclass;
-                               uint16_t ecode;
-                       } dos;
                        NTSTATUS nt_status;
                        enum {SOCKET_READ_TIMEOUT,
                              SOCKET_READ_EOF,
@@ -142,36 +143,21 @@ struct smbcli_transport {
 
        struct {
                /* a oplock break request handler */
-               BOOL (*handler)(struct smbcli_transport *transport, 
+               bool (*handler)(struct smbcli_transport *transport, 
                                uint16_t tid, uint16_t fnum, uint8_t level, void *private);
                /* private data passed to the oplock handler */
                void *private;
        } oplock;
 
-       /* a list of async requests that are pending for send on this connection */
-       struct smbcli_request *pending_send;
-
        /* a list of async requests that are pending for receive on this connection */
        struct smbcli_request *pending_recv;
 
        /* remember the called name - some sub-protocols require us to
           know the server name */
-       struct nmb_name called;
-
-       /* a buffer for partially received SMB packets. */
-       struct {
-               uint8_t header[NBT_HDR_SIZE];
-               size_t req_size;
-               size_t received;
-               uint8_t *buffer;
-       } recv_buffer;
+       struct nbt_name called;
 
-       /* the event handle for waiting for socket IO */
-       struct {
-               struct event_context *ctx;
-               struct fd_event *fde;
-               struct timed_event *te;
-       } event;
+       /* context of the stream -> packet parser */
+       struct packet_context *packet;
 };
 
 /* this is the context for the user */
@@ -215,7 +201,6 @@ struct smbcli_tree {
   a client request moves between the following 4 states.
 */
 enum smbcli_request_state {SMBCLI_REQUEST_INIT, /* we are creating the request */
-                       SMBCLI_REQUEST_SEND, /* the request is in the outgoing socket Q */
                        SMBCLI_REQUEST_RECV, /* we are waiting for a matching reply */
                        SMBCLI_REQUEST_DONE, /* the request is finished */
                        SMBCLI_REQUEST_ERROR}; /* a packet or transport level error has occurred */
@@ -247,6 +232,9 @@ struct smbcli_request {
        /* the sequence number of this packet - used for signing */
        uint_t seq_num;
 
+       /* list of ntcancel request for this requests */
+       struct smbcli_request *ntcancel;
+
        /* set if this is a one-way request, meaning we are not
           expecting a reply from the server. */
        uint_t one_way_request:1;
@@ -286,3 +274,8 @@ struct smbcli_request {
       req->status = NT_STATUS_INVALID_PARAMETER; \
       goto failed; \
 }
+
+#include "libcli/raw/interfaces.h" 
+#include "libcli/raw/raw_proto.h"
+
+#endif /* __LIBCLI_RAW__H__ */