diff options
author | Holger Hetterich <hhetter@novell.com> | 2009-09-22 20:01:35 +0200 |
---|---|---|
committer | Jim McDonough <jmcd@samba.org> | 2010-03-16 09:52:08 -0400 |
commit | e959bdcca4c6c879520f7f2734550c472f99836a (patch) | |
tree | 972f51cca84a45932a4fb5c2563913b04c149aec /source3/modules | |
parent | dcff7d367248ec7ecf59c4f423a81b8816799ec5 (diff) | |
download | samba-e959bdcca4c6c879520f7f2734550c472f99836a.tar.gz samba-e959bdcca4c6c879520f7f2734550c472f99836a.tar.bz2 samba-e959bdcca4c6c879520f7f2734550c472f99836a.zip |
The format of data we are sending over the network will be flexible when sending over the network in protocol v2. To be able to do this, we create a new va-list function that is creating the buffer to send. Also it makes it easier for the receiver to parse the data; it sends an initial header containing the full length of the buffer to be send. For the individual strings, it sends sub headers containing the length of the upcoming substring to be send. With the header-data-header-data [..] structure we don't need to quote the sub strings finally enabling having all possible character sets in filenames etc..
In the sending function, implement mkdir to actually send it's data
for testing.
Diffstat (limited to 'source3/modules')
-rw-r--r-- | source3/modules/vfs_smb_traffic_analyzer.c | 78 |
1 files changed, 74 insertions, 4 deletions
diff --git a/source3/modules/vfs_smb_traffic_analyzer.c b/source3/modules/vfs_smb_traffic_analyzer.c index 15197c179b..f460515d89 100644 --- a/source3/modules/vfs_smb_traffic_analyzer.c +++ b/source3/modules/vfs_smb_traffic_analyzer.c @@ -168,7 +168,7 @@ static int smb_traffic_analyzer_connect_unix_socket(vfs_handle_struct *handle, return sock; } -/* Private data allowing shared connection sockets. */ +/* Private data allowing shared connection sockets. */ struct refcounted_sock { struct refcounted_sock *next, *prev; @@ -178,7 +178,60 @@ struct refcounted_sock { unsigned int ref_count; }; -/* Send data over a socket */ + +/* The marshaller for the protocol version 2. */ +static char *smb_traffic_analyzer_create_string( struct tm *tm, \ + int seconds, vfs_handle_struct *handle, \ + char *username, int count, ... ) +{ + + va_list ap; + char *arg = NULL; + char *str = NULL; + int len; + char *header = NULL; + char *buf = NULL; + char *timestr = NULL; + + /* first create the data that is transfered with any VFS op */ + len = strlen( username ); + buf = talloc_asprintf(talloc_tos(),"%04u%s", len, username); + len = strlen( handle->conn->connectpath ); + buf = talloc_asprintf_append( buf, "%04u%s", len, \ + handle->conn->connectpath ); + 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) ); + timestr = talloc_asprintf(talloc_tos(), \ + "%04d-%02d-%02d %02d:%02d:%02d.%03d", \ + tm->tm_year+1900, \ + tm->tm_mon+1, \ + tm->tm_mday, \ + tm->tm_hour, \ + tm->tm_min, \ + tm->tm_sec, \ + (int)seconds); + len = strlen( timestr ); + buf = talloc_asprintf_append( buf, "%04u%s", len, timestr); + + va_start( ap, count ); + while ( count-- ) { + arg = va_arg( ap, char * ); + /* protocol v2 sends a four byte string */ + /* as a header to each block, including */ + /* the numbers of bytes to come in the */ + /* next string. */ + len = strlen( arg ); + buf = talloc_asprintf_append( buf, "%04u%s", len, arg); + } + va_end( ap ); + + /* now create the protocol v2 header. */ + len = strlen( buf ); + str = talloc_asprintf_append( str, "V2,%017u%s", len, buf); + DEBUG(10, ("smb_traffic_analyzer_create_string: %s\n",str)); + return str; +} static void smb_traffic_analyzer_send_data(vfs_handle_struct *handle, void *data, @@ -275,8 +328,25 @@ static void smb_traffic_analyzer_send_data(vfs_handle_struct *handle, tm->tm_sec, (int)seconds); } else if ( strcmp( protocol_version, "V2") == 0) { - /* protocol version 2 */ - /* in development */ + + switch( vfs_operation ) { + case vfs_id_mkdir: ; + struct mkdir_data *s_data = \ + (struct mkdir_data *) data; + str = smb_traffic_analyzer_create_string( tm, \ + seconds, handle, username, \ + 3, s_data->path, \ + talloc_asprintf( talloc_tos(), "%u", \ + s_data->mode), \ + talloc_asprintf( talloc_tos(), "%u", \ + s_data->result )); + break; + default: + DEBUG(1, ("smb_traffic_analyzer: error! " + "wrong VFS operation id detected!\n")); + return; + } + } else { DEBUG(1, ("smb_traffic_analyzer_send_data_socket: " "error, unkown protocol given!\n")); |