summaryrefslogtreecommitdiffstats
path: root/source/aparser
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>2000-05-27 10:18:36 +0000
committerLuke Leighton <lkcl@samba.org>2000-05-27 10:18:36 +0000
commit7db13bd53807f65a16442d2765a9d2f7ab792b4f (patch)
tree7dab23061082666d78cb43ca0baa63aa002c5df1 /source/aparser
parent9422719ab4c35e4ce3199b62dd632433bf391283 (diff)
downloadsamba-7db13bd53807f65a16442d2765a9d2f7ab792b4f.tar.gz
samba-7db13bd53807f65a16442d2765a9d2f7ab792b4f.tar.xz
samba-7db13bd53807f65a16442d2765a9d2f7ab792b4f.zip
SMBnttrans. modified io_uint8s to return address of actual data instead
of a copy, on unmarshalling. removed fstring, made it io_string, did same thing. io_string() and io_wstring() should be wrapped in a STRING typedef which is bit-switched on FLG2:Unicode.
Diffstat (limited to 'source/aparser')
-rw-r--r--source/aparser/cifs.struct108
-rw-r--r--source/aparser/parser.c65
-rw-r--r--source/aparser/parser.h5
-rw-r--r--source/aparser/templates/prs_uint8s.tpl2
-rw-r--r--source/aparser/templates/prs_uint8s_fixed.tpl2
5 files changed, 132 insertions, 50 deletions
diff --git a/source/aparser/cifs.struct b/source/aparser/cifs.struct
index f1603809dfa..554bb82a99e 100644
--- a/source/aparser/cifs.struct
+++ b/source/aparser/cifs.struct
@@ -28,7 +28,7 @@ typedef struct {
typedef struct {
uint8 tag2;
- fstring protocol;
+ string protocol;
} BUF2;
typedef struct {
@@ -64,11 +64,11 @@ typedef struct {
USHORT Reserved; /* MBZ */
USHORT ByteCount; /* Count of data bytes */
UCHAR Challenge[ChallengeLength]; /* The challenge */
- fstring PrimaryDomain; /* The server's primary domain */
+ string PrimaryDomain; /* The server's primary domain */
uint16 bcount;
uint8 chal[8];
- fstring domain;
+ string domain;
} R_NEGPROT_12;
typedef struct {
@@ -101,7 +101,7 @@ typedef struct {
/* security package if CAP_EXTENDED_SECURITY is */
/* on in the Capabilities field; else challenge */
/* for CIFS challenge/response authentication. */
- fstring OemDomainName; /*The name of the domain (in OEM chars); not */
+ string OemDomainName; /*The name of the domain (in OEM chars); not */
/* present if CAP_EXTENDED_SECURITY is on in the */
/* Capabilities field */
} R_NEGPROT_17;
@@ -165,9 +165,9 @@ typedef struct {
uint16 bcount;
uint8 password[pwlen];
- fstring domain;
- fstring os;
- fstring server;
+ string domain;
+ string os;
+ string server;
} Q_SESSION_SETUP_ANDX_10;
@@ -185,10 +185,10 @@ typedef struct {
uint16 bcount;
uint8 password[pwlen];
uint8 upassword[upwlen];
- fstring user;
- fstring domain;
- fstring os;
- fstring server;
+ string user;
+ string domain;
+ string os;
+ string server;
} Q_SESSION_SETUP_ANDX_13;
@@ -206,8 +206,8 @@ typedef struct {
uint16 passlen;
uint16 bcount;
uint8 password[passlen];
- fstring path;
- fstring device;
+ string path;
+ string device;
} Q_TCON_ANDX_4;
typedef struct _Q_TCON_ANDX {
@@ -221,7 +221,7 @@ typedef struct {
ANDX_INFO andx;
uint16 vwv2;
uint16 bcount;
- fstring share;
+ string share;
} R_TCON_ANDX_3;
typedef struct _R_TCON_ANDX {
@@ -236,9 +236,9 @@ typedef struct {
uint16 action;
uint16 count;
- fstring os;
- fstring server;
- fstring domain;
+ string os;
+ string server;
+ string domain;
} R_SESSION_SETUP_ANDX_10;
typedef struct _R_SESSION_SETUP_ANDX {
@@ -555,6 +555,71 @@ typedef struct _Q_WRITE_ANDX {
} Q_WRITE_ANDX;
+
+typedef struct _Q_NTTRANS_19 {
+ UCHAR MaxSetupCount; /* Max setup words to return */
+ USHORT Reserved;
+ ULONG TotalParameterCount; /* Total parameter bytes being sent */
+ ULONG TotalDataCount; /* Total data bytes being sent */
+ ULONG MaxParameterCount; /* Max parameter bytes to return */
+ ULONG MaxDataCount; /* Max data bytes to return */
+ ULONG ParameterCount; /* Parameter bytes sent this buffer */
+ ULONG ParameterOffset; /* Offset (from header start) to */
+ /* Parameters */
+ ULONG DataCount; /* Data bytes sent this buffer */
+ ULONG DataOffset; /* Offset (from header start) to data */
+ UCHAR SetupCount; /* Count of setup words */
+ USHORT Function; /* The transaction function code */
+ UCHAR Buffer[1];
+ USHORT Setup[SetupCount]; /* Setup words */
+ USHORT ByteCount; /* Count of data bytes */
+ UCHAR Pad1; /* Pad to LONG */
+ UCHAR Parameters[ParameterCount];/* Parameter bytes */
+ UCHAR Pad2; /* Pad to LONG */
+ UCHAR Data[DataCount]; /* Data bytes */
+
+} Q_NTTRANS_19;
+
+typedef struct _Q_NTTRANS {
+ uint8 wcount;
+ union ctr[wcount] {
+ case 19 Q_NTTRANS_19 q19;
+ }
+} Q_NTTRANS;
+
+typedef struct _R_NTTRANS_18 {
+ UCHAR Reserved[3];
+ ULONG TotalParameterCount; /* Total parameter bytes being sent */
+ ULONG TotalDataCount; /* Total data bytes being sent */
+ ULONG ParameterCount; /* Parameter bytes sent this buffer */
+ ULONG ParameterOffset; /* Offset (from header start) to */
+ /* Parameters */
+ ULONG ParameterDisplacement; /* Specifies the offset from the start */
+ /* of the overall parameter block to */
+ /* the parameter bytes that are */
+ /* contained in this message */
+ ULONG DataCount; /* Data bytes sent this buffer */
+ ULONG DataOffset; /* Offset (from header start) to data */
+ ULONG DataDisplacement; /* Specifies the offset from the start */
+ /* of the overall data block to the */
+ /* data bytes that are contained in */
+ /* this message. */
+ UCHAR SetupCount; /* Count of setup words */
+ USHORT Setup[SetupCount]; /* Setup words */
+ USHORT ByteCount; /* Count of data bytes */
+ UCHAR Pad1; /* Pad to LONG */
+ UCHAR Parameters[ParameterCount]; /* Parameter bytes */
+ UCHAR Pad2; /* Pad to SHORT or LONG */
+ UCHAR Data[DataCount]; /* Data bytes */
+} R_NTTRANS_18;
+
+typedef struct _R_NTTRANS {
+ uint8 wcount;
+ union ctr[wcount] {
+ case 18 R_NTTRANS_18 q18;
+ }
+} R_NTTRANS;
+
typedef struct _Q_TRANS2_15 {
USHORT TotalParameterCount; /* Total parameter bytes being sent */
USHORT TotalDataCount; /* Total data bytes being sent */
@@ -575,7 +640,7 @@ typedef struct _Q_TRANS2_15 {
UCHAR Reserved3; /* Reserved (pad above to word) */
USHORT Setup[SetupCount]; /* Setup words (# = SetupWordCount) */
USHORT ByteCount; /* Count of data bytes */
- fstring Name; /* Must be NULL */
+ string Name; /* Must be NULL */
UCHAR Pad[]; /* Pad to SHORT or LONG */
UCHAR Parameters[ParameterCount];/* Parameter bytes (# = ParameterCount) */
UCHAR Pad1[]; /* Pad to SHORT or LONG */
@@ -610,7 +675,7 @@ typedef struct _Q_TRANS_16 {
UCHAR Reserved3; /* Reserved (pad above to word) */
USHORT Setup[SetupCount]; /* Setup words (# = SetupWordCount) */
USHORT ByteCount; /* Count of data bytes */
- fstring Name; /* Must be NULL */
+ string Name; /* Must be NULL */
UCHAR Pad[]; /* Pad to SHORT or LONG */
UCHAR Parameters[ParameterCount];/* Parameter bytes (# = ParameterCount) */
UCHAR Pad1[]; /* Pad to SHORT or LONG */
@@ -628,6 +693,7 @@ typedef struct _Q_TRANS {
typedef struct _R_TRANS_10 {
USHORT TotalParameterCount;/* Total parameter bytes being sent */
USHORT TotalDataCount; /* Total data bytes being sent */
+ USHORT Reserved2;
USHORT ParameterCount; /* Parameter bytes sent this buffer */
USHORT ParameterOffset; /* Offset (from header start) to */
/* Parameters */
@@ -647,7 +713,7 @@ typedef struct _R_TRANS_10 {
USHORT ByteCount; /* Count of data bytes */
UCHAR Pad1; /* Pad to LONG */
UCHAR Parameters[ParameterCount];/* Parameter bytes */
- UCHAR Pad2; /* Pad to SHORT or LONG */
+ /*UCHAR Pad2; Pad to SHORT or LONG */
UCHAR Data[DataCount]; /* Data bytes */
} R_TRANS_10;
@@ -730,6 +796,7 @@ typedef struct _R_SMB {
case 115 R_SESSION_SETUP_ANDX r115;
case 117 R_TCON_ANDX r117;
case 128 R_DSKATTR r128;
+ case 160 R_NTTRANS r160;
}
} R_SMB;
@@ -750,6 +817,7 @@ typedef struct _Q_SMB {
case 115 Q_SESSION_SETUP_ANDX q115;
case 117 Q_TCON_ANDX q117;
case 128 Q_DSKATTR q128;
+ case 160 Q_NTTRANS q160;
}
} Q_SMB;
diff --git a/source/aparser/parser.c b/source/aparser/parser.c
index 289cf95c7bb..098cc575402 100644
--- a/source/aparser/parser.c
+++ b/source/aparser/parser.c
@@ -325,40 +325,44 @@ BOOL io_pointer(char *desc, prs_struct *ps, int depth, void **p, unsigned flags)
/*******************************************************************
Stream a null-terminated string.
********************************************************************/
-BOOL io_fstring(char *name, prs_struct *ps, int depth, fstring *str, unsigned flags)
+BOOL io_string(char *name, prs_struct *ps, int depth, char **str, unsigned flags)
{
char *q;
uint8 *start;
int i;
- int len = sizeof(fstring)-1;
+ size_t len;
if (!(flags & PARSE_SCALARS)) return True;
- if (MARSHALLING(ps)) {
- len = MIN(len, strlen(*str));
- }
-
- start = (uint8*)q;
-
- for(i = 0; i < len; i++) {
- q = prs_mem_get(ps, 1);
- if (q == NULL)
+ if (UNMARSHALLING(ps)) {
+ *str = prs_mem_get(ps, 0);
+ if (*str == NULL)
return False;
-
- RW_CVAL(ps->io, q, (*str)[i],0);
- if ((*str)[i] == 0)
- break;
- ps->data_offset++;
+ len = strlen(*str);
+ ps->data_offset += len + 1;
}
+ else
+ {
+ len = strlen(*str);
+ start = (uint8*)q;
+
+ for(i = 0; i < len; i++) {
+ q = prs_mem_get(ps, 1);
+ if (q == NULL)
+ return False;
+
+ RW_CVAL(ps->io, q, (*str)[i],0);
+ if ((*str)[i] == 0)
+ break;
+ ps->data_offset++;
+ }
- /* The terminating null. */
- (*str)[i] = '\0';
-
- if (MARSHALLING(ps)) {
+ /* The terminating null. */
+ (*str)[i] = '\0';
RW_CVAL(ps->io, q, (*str)[i], 0);
- }
- ps->data_offset++;
+ ps->data_offset++;
+ }
DEBUG(5,("%s %s: %s\n", tab_depth(depth), name, *str));
return True;
@@ -367,19 +371,28 @@ BOOL io_fstring(char *name, prs_struct *ps, int depth, fstring *str, unsigned fl
/******************************************************************
do IO on a byte array
********************************************************************/
-BOOL io_uint8s(char *name, prs_struct *ps, int depth, uint8 *data8s, int len, unsigned flags)
+BOOL io_uint8s(char *name, prs_struct *ps, int depth, uint8 **data8s, int len, unsigned flags)
{
char *q;
+ size_t num_bytes = len * sizeof(uint8);
if (!(flags & PARSE_SCALARS)) return True;
if (!prs_align(ps, 2)) return False;
- q = prs_mem_get(ps, len * sizeof(uint8));
+ q = prs_mem_get(ps, num_bytes);
if (q == NULL) return False;
- DBG_RW_PCVAL(True, name, depth, ps->data_offset, ps->io, q, data8s, len)
- ps->data_offset += (len * sizeof(uint8));
+ if (MARSHALLING(ps))
+ {
+ DBG_RW_PCVAL(True, name, depth, ps->data_offset, ps->io, q, *data8s, len)
+ }
+ else
+ {
+ *data8s = q;
+ dump_data(depth+5, q, num_bytes);
+ }
+ ps->data_offset += num_bytes;
return True;
}
diff --git a/source/aparser/parser.h b/source/aparser/parser.h
index 51234d3dea0..4e9a75e7041 100644
--- a/source/aparser/parser.h
+++ b/source/aparser/parser.h
@@ -27,6 +27,7 @@ typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned short wchar;
typedef unsigned uint32;
+typedef char *string;
#ifndef _PSTRING
@@ -77,7 +78,7 @@ BOOL io_uint32(char *name, prs_struct *ps, int depth, uint32 *data32, unsigned f
BOOL io_uint16(char *name, prs_struct *ps, int depth, uint16 *data16, unsigned flags);
BOOL io_uint8(char *name, prs_struct *ps, int depth, uint8 *data8, unsigned flags);
BOOL io_pointer(char *desc, prs_struct *ps, int depth, void **p, unsigned flags);
-BOOL io_fstring(char *name, prs_struct *ps, int depth, fstring *str, unsigned flags);
+BOOL io_string(char *name, prs_struct *ps, int depth, char **str, unsigned flags);
BOOL io_wstring(char *name, prs_struct *ps, int depth, uint16 *data16s, int len, unsigned flags);
-BOOL io_uint8s(char *name, prs_struct *ps, int depth, uint8 *data8s, int len, unsigned flags);
+BOOL io_uint8s(char *name, prs_struct *ps, int depth, uint8 **data8s, int len, unsigned flags);
diff --git a/source/aparser/templates/prs_uint8s.tpl b/source/aparser/templates/prs_uint8s.tpl
index cfc4bab1d27..e5f82670d02 100644
--- a/source/aparser/templates/prs_uint8s.tpl
+++ b/source/aparser/templates/prs_uint8s.tpl
@@ -1,2 +1,2 @@
if (!io_alloc("@ELEM@", ps, (void **)&il->@ELEM@, sizeof(*(il->@ELEM@))*il->@ARRAY_LEN@)) goto fail;
- if (!io_uint8s("@ELEM@", ps, depth+1, il->@ELEM@, il->@ARRAY_LEN@, @FLAGS@)) goto fail;
+ if (!io_uint8s("@ELEM@", ps, depth+1, &il->@ELEM@, il->@ARRAY_LEN@, @FLAGS@)) goto fail;
diff --git a/source/aparser/templates/prs_uint8s_fixed.tpl b/source/aparser/templates/prs_uint8s_fixed.tpl
index c8f55811309..f752fa6c84a 100644
--- a/source/aparser/templates/prs_uint8s_fixed.tpl
+++ b/source/aparser/templates/prs_uint8s_fixed.tpl
@@ -1,2 +1,2 @@
if (!io_alloc("@ELEM@", ps, (void **)&il->@ELEM@, sizeof(*(il->@ELEM@))*@ARRAY_LEN@)) goto fail;
- if (!io_uint8s("@ELEM@", ps, depth+1, il->@ELEM@, @ARRAY_LEN@, @FLAGS@)) goto fail;
+ if (!io_uint8s("@ELEM@", ps, depth+1, &il->@ELEM@, @ARRAY_LEN@, @FLAGS@)) goto fail;