r23792: convert Samba4 to GPLv3
[kai/samba-autobuild/.git] / source4 / librpc / rpc / dcerpc_smb.c
index 1eead06a48a1ed6604e3e1a1da98429ab45384c2..6b43de3358ace0020b7c7bfd0ceec5398bcaa338 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,
@@ -17,8 +17,7 @@
    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"
@@ -40,7 +39,7 @@ struct smb_private {
 */
 static void pipe_dead(struct dcerpc_connection *c, NTSTATUS status)
 {
-       struct smb_private *smb = c->transport.private;
+       struct smb_private *smb = c->transport.private_data;
 
        if (smb->dead) {
                return;
@@ -85,7 +84,7 @@ static void smb_read_callback(struct smbcli_request *req)
        NTSTATUS status;
 
        state = talloc_get_type(req->async.private, struct smb_read_state);
-       smb = talloc_get_type(state->c->transport.private, struct smb_private);
+       smb = talloc_get_type(state->c->transport.private_data, struct smb_private);
        io = state->io;
 
        status = smb_raw_read_recv(state->req, io);
@@ -142,7 +141,7 @@ static void smb_read_callback(struct smbcli_request *req)
 */
 static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLOB *blob)
 {
-       struct smb_private *smb = c->transport.private;
+       struct smb_private *smb = c->transport.private_data;
        union smb_read *io;
        struct smb_read_state *state;
        struct smbcli_request *req;
@@ -198,7 +197,7 @@ static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLO
 */
 static NTSTATUS send_read_request(struct dcerpc_connection *c)
 {
-       struct smb_private *smb = c->transport.private;
+       struct smb_private *smb = c->transport.private_data;
 
        if (smb->dead) {
                return NT_STATUS_CONNECTION_DISCONNECTED;
@@ -250,7 +249,7 @@ static void smb_trans_callback(struct smbcli_request *req)
 */
 static NTSTATUS smb_send_trans_request(struct dcerpc_connection *c, DATA_BLOB *blob)
 {
-        struct smb_private *smb = c->transport.private;
+        struct smb_private *smb = c->transport.private_data;
         struct smb_trans2 *trans;
         uint16_t setup[2];
        struct smb_trans_state *state;
@@ -313,7 +312,7 @@ static void smb_write_callback(struct smbcli_request *req)
 */
 static NTSTATUS smb_send_request(struct dcerpc_connection *c, DATA_BLOB *blob, BOOL trigger_read)
 {
-       struct smb_private *smb = c->transport.private;
+       struct smb_private *smb = c->transport.private_data;
        union smb_write io;
        struct smbcli_request *req;
 
@@ -357,7 +356,7 @@ static NTSTATUS smb_send_request(struct dcerpc_connection *c, DATA_BLOB *blob, B
 */
 static NTSTATUS smb_shutdown_pipe(struct dcerpc_connection *c, NTSTATUS status)
 {
-       struct smb_private *smb = c->transport.private;
+       struct smb_private *smb = c->transport.private_data;
        union smb_close io;
        struct smbcli_request *req;
 
@@ -383,7 +382,7 @@ static NTSTATUS smb_shutdown_pipe(struct dcerpc_connection *c, NTSTATUS status)
 */
 static const char *smb_peer_name(struct dcerpc_connection *c)
 {
-       struct smb_private *smb = c->transport.private;
+       struct smb_private *smb = c->transport.private_data;
        return smb->server_name;
 }
 
@@ -392,7 +391,7 @@ static const char *smb_peer_name(struct dcerpc_connection *c)
 */
 static const char *smb_target_hostname(struct dcerpc_connection *c)
 {
-       struct smb_private *smb = talloc_get_type(c->transport.private, struct smb_private);
+       struct smb_private *smb = talloc_get_type(c->transport.private_data, struct smb_private);
        return smb->tree->session->transport->socket->hostname;
 }
 
@@ -401,7 +400,7 @@ static const char *smb_target_hostname(struct dcerpc_connection *c)
 */
 static NTSTATUS smb_session_key(struct dcerpc_connection *c, DATA_BLOB *session_key)
 {
-       struct smb_private *smb = c->transport.private;
+       struct smb_private *smb = c->transport.private_data;
 
        if (smb->tree->session->user_session_key.data) {
                *session_key = smb->tree->session->user_session_key;
@@ -504,7 +503,7 @@ static void pipe_open_recv(struct smbcli_request *req)
          fill in the transport methods
        */
        c->transport.transport       = NCACN_NP;
-       c->transport.private         = NULL;
+       c->transport.private_data    = NULL;
        c->transport.shutdown_pipe   = smb_shutdown_pipe;
        c->transport.peer_name       = smb_peer_name;
        c->transport.target_hostname = smb_target_hostname;
@@ -526,7 +525,7 @@ static void pipe_open_recv(struct smbcli_request *req)
        if (composite_nomem(smb->server_name, ctx)) return;
        smb->dead       = false;
 
-       c->transport.private = smb;
+       c->transport.private_data = smb;
 
        composite_done(ctx);
 }
@@ -556,8 +555,23 @@ struct smbcli_tree *dcerpc_smb_tree(struct dcerpc_connection *c)
 
        if (c->transport.transport != NCACN_NP) return NULL;
 
-       smb = talloc_get_type(c->transport.private, struct smb_private);
+       smb = talloc_get_type(c->transport.private_data, struct smb_private);
        if (!smb) return NULL;
 
        return smb->tree;
 }
+
+/*
+  return the SMB fnum used for a dcerpc over SMB pipe (hack for torture operations)
+*/
+uint16_t dcerpc_smb_fnum(struct dcerpc_connection *c)
+{
+       struct smb_private *smb;
+
+       if (c->transport.transport != NCACN_NP) return 0;
+
+       smb = talloc_get_type(c->transport.private_data, struct smb_private);
+       if (!smb) return 0;
+
+       return smb->fnum;
+}