Add the number of common data blocks to the protocol.
authorHolger Hetterich <hhetter@novell.com>
Tue, 2 Feb 2010 19:04:40 +0000 (20:04 +0100)
committerJim McDonough <jmcd@samba.org>
Tue, 16 Mar 2010 13:52:10 +0000 (09:52 -0400)
Always send the number of common data blocks first. This way, we
can make the protocol backwards compatible. A receiver running with
an older subprotocol can just ignore if a newer sender sends more
common data.

Add a few remarks to the marshalling function. Add two #define lines
defining the protocol subrelease number and the number of common
data blocks to the header file.

source3/modules/vfs_smb_traffic_analyzer.c
source3/modules/vfs_smb_traffic_analyzer.h

index 7d7332e1b959fc00e68daab122817369fc869dd5..1718185c35199430b8f99b2dbbf134f717e254eb 100644 (file)
@@ -170,19 +170,25 @@ static char *smb_traffic_analyzer_create_string( struct tm *tm, \
        /*
         * first create the data that is transfered with any VFS op
         * These are, in the following order:
-        * number of data to come [6 in v2.0]
+        *(0) number of data to come [6 in v2.0]
         * 1.vfs_operation identifier
         * 2.username
         * 3.user-SID
-        * 4.affected file + full path
+        * 4.affected share
         * 5.domain
         * 6.timestamp
         */
 
-       opstr = talloc_asprintf(talloc_tos(), "%i", vfs_operation);
+       /* number of common data blocks to come */
+       opstr = talloc_asprintf(talloc_tos(), "%i", SMBTA_COMMON_DATA_COUNT);
        len = strlen(opstr);
        buf = talloc_asprintf(talloc_tos(), "%04u%s", len, opstr);
 
+       /* vfs operation identifier */
+       opstr = talloc_asprintf(talloc_tos(), "%i", vfs_operation);
+       len = strlen(opstr);
+       buf = talloc_asprintf_append(talloc_tos(), "%04u%s", len, opstr);
+
        /*
         * Handle anonymization. In protocol v2, we have to anonymize
         * both the SID and the username.
@@ -215,16 +221,21 @@ static char *smb_traffic_analyzer_create_string( struct tm *tm, \
                sidstr = usersid;
        }
 
+       /* username */
        len = strlen( userstr );
        buf = talloc_asprintf_append(buf, "%04u%s", len, userstr);
+       /* user SID */
        len = strlen( sidstr );
        buf = talloc_asprintf_append(buf, "%04u%s", len, sidstr);
+       /* affected share */
        len = strlen( handle->conn->connectpath );
        buf = talloc_asprintf_append( buf, "%04u%s", len, \
                handle->conn->connectpath );
+       /* user's domain */
        len = strlen( pdb_get_domain(handle->conn->server_info->sam_account) );
        buf = talloc_asprintf_append( buf, "%04u%s", len, \
                pdb_get_domain(handle->conn->server_info->sam_account) );
+       /* time stamp */
        timestr = talloc_asprintf(talloc_tos(), \
                "%04d-%02d-%02d %02d:%02d:%02d.%03d", \
                tm->tm_year+1900, \
@@ -236,7 +247,8 @@ static char *smb_traffic_analyzer_create_string( struct tm *tm, \
                (int)seconds);
        len = strlen( timestr );
        buf = talloc_asprintf_append( buf, "%04u%s", len, timestr);
-       
+
+       /* data blocks depending on the VFS function */ 
        va_start( ap, count );
        while ( count-- ) {
                arg = va_arg( ap, char * );
@@ -270,6 +282,13 @@ static void smb_traffic_analyzer_send_data(vfs_handle_struct *handle,
        const char *protocol_version = NULL;
        bool Write = false;
        size_t len;
+
+       /*
+        * The state flags are part of the header
+        * and are descripted in the protocol description
+        * in vfs_smb_traffic_analyzer.h. They begin at byte
+        * 03 of the header.
+        */
        char state_flags[9] = "000000\0";
 
        SMB_VFS_HANDLE_GET_DATA(handle, rf_sock, struct refcounted_sock, return);
index 7a3c358a0e57a20aa0a21f692da820087e630afb..f3d902754e650144ee02eb5787ed74460fd2c7c2 100644 (file)
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-
-/*
- * Protocol V2.0 definition
- *
-/
-
 /**
  * Protocol version 2.0 description
  *
  *
  */
 
+/* Protocol subrelease number */
+#define SMBTA_SUBRELEASE 0
+
+/*
+ * Every data block sends a number of blocks sending common data
+ * we send the number of "common data blocks" to come very first
+ * so that if the receiver is using an older version of the protocol
+ * it knows which blocks it can ignore.
+ */
+#define SMBTA_COMMON_DATA_COUNT 6
 
 /*
  * VFS Functions identifier table. In protocol version 2, every vfs