No subject
Sun Sep 6 16:29:27 MDT 2009
2009 13:10:53 +0200=0ASubject: [PATCH] Created an enum for identifying VFS =
functions in the upcoming protocol v2.=0A Converted the existing VFS =
functions to use the identifier, and set the=0A read/write bool used in =
protocol v1 accordingly, also ignore any other=0A VFS functions except =
read/write/pread/pwrite in v1.=0A Added a first new VFS function for =
mkdir, which I use for testing and=0A implementing both the sender and =
receiver for v2.=0A=0A---=0A source3/modules/vfs_smb_traffic_analyzer.c | =
48 ++++++++++++++++++++++++---=0A 1 files changed, 42 insertions(+), 6 =
deletions(-)=0A=0Adiff --git a/source3/modules/vfs_smb_traffic_analyzer.c =
b/source3/modules/vfs_smb_traffic_analyzer.c=0Aindex 6861835..889e413 =
100644=0A--- a/source3/modules/vfs_smb_traffic_analyzer.c=0A+++ b/source3/m=
odules/vfs_smb_traffic_analyzer.c=0A@@ -27,6 +27,17 @@ enum sock_type =
{INTERNET_SOCKET =3D 0, UNIX_DOMAIN_SOCKET};=0A =0A #define LOCAL_PATHNAME =
"/var/tmp/stadsocket"=0A =0A+/* VFS Functions identifier table. In =
protocol version 2, every vfs */=0A+/* function is given a unique id. =
*/=0A+enum vfs_id {=0A+ =
vfs_id_read,=0A+ vfs_id_write,=0A+ vfs_id_pread,=0A+ =
vfs_id_pwrite,=0A+ vfs_id_mkdir=0A+};=0A+=0A+=0A static int vfs_smb_tr=
affic_analyzer_debug_level =3D DBGC_VFS;=0A =0A static enum sock_type =
smb_traffic_analyzer_connMode(vfs_handle_struct *handle)=0A@@ -155,7 =
+166,7 @@ struct refcounted_sock {=0A static void smb_traffic_analyzer_send=
_data(vfs_handle_struct *handle,=0A =
ssize_t result,=0A const char =
*file_name,=0A- bool Write)=0A+ =
enum vfs_id vfs_operation )=0A {=0A struct refcounted_s=
ock *rf_sock =3D NULL;=0A struct timeval tv;=0A@@ -167,6 +178,7 @@ =
static void smb_traffic_analyzer_send_data(vfs_handle_struct *handle,=0A =
const char *anon_prefix =3D NULL;=0A const char *total_anonymization =
=3D NULL;=0A const char *protocol_version =3D NULL;=0A+ bool Write =
=3D false;=0A size_t len;=0A =0A SMB_VFS_HANDLE_GET_DATA(handle, =
rf_sock, struct refcounted_sock, return);=0A@@ -218,6 +230,16 @@ static =
void smb_traffic_analyzer_send_data(vfs_handle_struct *handle,=0A =
"protocol_version", NULL );=0A =0A if ( protocol_version =3D=3D NULL =
|| strcmp( protocol_version,"V1") =3D=3D 0) {=0A+=0A+ /* in case =
of protocol v1, ignore any vfs operations */=0A+ /* except =
read,pread,write,pwrite, and set the "Write" */=0A+ /* bool =
accordingly. */=0A+=0A+ if =
( vfs_operation > vfs_id_pwrite ) return;=0A+=0A+ if ( =
vfs_operation <=3D vfs_id_pread ) Write=3Dfalse;=0A+ =
else Write=3Dtrue;=0A+=0A str =3D talloc_asprintf(talloc_tos(=
),=0A "V1,%u,\"%s\",\"%s\",\"%c\",\"%s\",\"%s\","=0A =
"\"%04d-%02d-%02d %02d:%02d:%02d.%03d\"\n",=0A@@ -342,7 +364,20 @@ =
static int smb_traffic_analyzer_connect(struct vfs_handle_struct =
*handle,=0A return SMB_VFS_NEXT_CONNECT(handle, service, user);=0A =
}=0A =0A-/* VFS Functions: write, read, pread, pwrite for now */=0A+/* VFS =
Functions */=0A+=0A+static int smb_traffic_analyzer_mkdir(vfs_handle_struct=
*handle, \=0A+ const char *path, mode_t mode)=0A+{=0A+ =
int result;=0A+ result =3D SMB_VFS_NEXT_MKDIR(handle, path, mode);=0A+ =
DEBUG(10, ("smb_traffic_analyzer_mkdir: MKDIR: %s\n", path));=0A+ =
smb_traffic_analyzer_send_data(handle,=0A+ result,=0A+=
path,=0A+ vfs_id_mkdir);=0A+ =
return result;=0A+}=0A =0A static ssize_t smb_traffic_analyzer_read(vfs_han=
dle_struct *handle, \=0A files_struct *fsp, =
void *data, size_t n)=0A@@ -355,7 +390,7 @@ static ssize_t smb_traffic_anal=
yzer_read(vfs_handle_struct *handle, \=0A smb_traffic_analyzer_send_d=
ata(handle,=0A result,=0A fsp->fsp_na=
me->base_name,=0A- false);=0A+ =
vfs_id_read);=0A return result;=0A }=0A =0A@@ -373,7 +408,7 @@ =
static ssize_t smb_traffic_analyzer_pread(vfs_handle_struct *handle, \=0A =
smb_traffic_analyzer_send_data(handle,=0A result,=0A =
fsp->fsp_name->base_name,=0A- =
false);=0A+ vfs_id_pread);=0A =0A return result;=0A =
}=0A@@ -391,7 +426,7 @@ static ssize_t smb_traffic_analyzer_write(vfs_handl=
e_struct *handle, \=0A smb_traffic_analyzer_send_data(handle,=0A =
result,=0A fsp->fsp_name->base_name,=0A- =
true);=0A+ vfs_id_write);=0A return =
result;=0A }=0A =0A@@ -407,7 +442,7 @@ static ssize_t smb_traffic_analyzer_=
pwrite(vfs_handle_struct *handle, \=0A smb_traffic_analyzer_send_data(hand=
le,=0A result,=0A fsp->fsp_name->base=
_name,=0A- true);=0A+ vfs_id_pwri=
te);=0A return result;=0A }=0A =0A@@ -417,6 +452,7 @@ static =
struct vfs_fn_pointers vfs_smb_traffic_analyzer_fns =3D {=0A .pread =3D =
smb_traffic_analyzer_pread,=0A .write =3D smb_traffic_analyzer_write,=0A =
.pwrite =3D smb_traffic_analyzer_pwrite,=0A+ .mkdir =3D smb_traffic_anal=
yzer_mkdir=0A };=0A =0A /* Module initialization */=0A-- =0A1.6.0.2=0A=0A
--=__Part3C17C8C2.0__=--
More information about the samba-technical
mailing list