summaryrefslogtreecommitdiffstats
path: root/source/aparser
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>2000-05-28 20:05:30 +0000
committerLuke Leighton <lkcl@samba.org>2000-05-28 20:05:30 +0000
commitd8d15b275592e3a4e60ac502f4672672534e1fc7 (patch)
tree640998bed46d4870b39a41b17c19704554ee46d1 /source/aparser
parentc919f803434a138f48eb26f122fc09425eb24d58 (diff)
downloadsamba-d8d15b275592e3a4e60ac502f4672672534e1fc7.tar.gz
samba-d8d15b275592e3a4e60ac502f4672672534e1fc7.tar.xz
samba-d8d15b275592e3a4e60ac502f4672672534e1fc7.zip
more SMBtrans, SMBnttrans stuff.
Diffstat (limited to 'source/aparser')
-rw-r--r--source/aparser/cifs.struct217
-rw-r--r--source/aparser/parsefn.awk36
-rw-r--r--source/aparser/parser.c45
-rw-r--r--source/aparser/parser.h2
4 files changed, 276 insertions, 24 deletions
diff --git a/source/aparser/cifs.struct b/source/aparser/cifs.struct
index 8230dbdb340..c50810b4acd 100644
--- a/source/aparser/cifs.struct
+++ b/source/aparser/cifs.struct
@@ -2,6 +2,7 @@ module cifs
#define BOOL uint32
#define UCHAR uint8
+#define WCHAR uint16
#define USHORT uint16
#define LONG uint32
#define ULONG uint32
@@ -66,9 +67,6 @@ typedef struct {
UCHAR Challenge[ChallengeLength]; /* The challenge */
string PrimaryDomain; /* The server's primary domain */
- uint16 bcount;
- uint8 chal[8];
- string domain;
} R_NEGPROT_12;
typedef struct {
@@ -331,7 +329,7 @@ typedef struct {
typedef struct {
USHORT Pid; /* PID of process "owning" lock */
- USHORT Pad; /* Pad to DWORD align (mbz) */
+ .align4 0;
ULONG OffsetHigh; /* Offset to bytes to [un]lock (high) */
ULONG OffsetLow; /* Offset to bytes to [un]lock (low) */
ULONG LengthHigh; /* Number of bytes to [un]lock (high) */
@@ -573,9 +571,9 @@ typedef struct _Q_NTTRANS_19 {
UCHAR Buffer[1];
USHORT Setup[SetupCount]; /* Setup words */
USHORT ByteCount; /* Count of data bytes */
- UCHAR Pad1; /* Pad to LONG */
+ .align4 0;
UCHAR Parameters[ParameterCount];/* Parameter bytes */
- UCHAR Pad2; /* Pad to LONG */
+ .align4 0;
UCHAR Data[DataCount]; /* Data bytes */
} Q_NTTRANS_19;
@@ -607,9 +605,9 @@ typedef struct _R_NTTRANS_18 {
UCHAR SetupCount; /* Count of setup words */
USHORT Setup[SetupCount]; /* Setup words */
USHORT ByteCount; /* Count of data bytes */
- UCHAR Pad1; /* Pad to LONG */
+ .align4 0;
UCHAR Parameters[ParameterCount]; /* Parameter bytes */
- UCHAR Pad2; /* Pad to SHORT or LONG */
+ .align4 0;
UCHAR Data[DataCount]; /* Data bytes */
} R_NTTRANS_18;
@@ -618,8 +616,96 @@ typedef struct _R_NTTRANS {
union ctr[wcount] {
case 18 R_NTTRANS_18 q18;
}
+ .align4 2;
} R_NTTRANS;
+/*Setup[0] Transaction2 Value Description */
+/*Subcommand Code */
+/*=============================== ===== ============================= */
+
+#define TRANS2_OPEN2 0x00 /* Create file with extended attributes */
+#define TRANS2_FIND_FIRST2 0x01 /* Begin search for files */
+#define TRANS2_FIND_NEXT2 0x02 /* Resume search for files */
+#define TRANS2_QUERY_FS_INFO 0x03 /* Get file system information
+#define TRANS2_RESERVED4 0x04 /* Reserved */
+#define TRANS2_QUERY_PATH_INFO 0x05 /* Get information about a named file or directory */
+#define TRANS2_SET_PATH_INFO 0x06 /* Set information about a named file or directory */
+#define TRANS2_QUERY_FILE_INFO 0x07 /* Get information about a handle */
+#define TRANS2_SET_FILE_INFO 0x08 /* Set information by handle */
+#define TRANS2_FSCTL 0x09 /* Not implemented by NT server */
+#define TRANS2_IOCTL2 0x0A /* Not implemented by NT server */
+#define TRANS2_FIND_NOTIFY_FIRST 0x0B /* Not implemented by NT server */
+#define TRANS2_FIND_NOTIFY_NEXT 0x0C /* Not implemented by NT server */
+#define TRANS2_CREATE_DIRECTORY 0x0D /* Create directory with extended attributes */
+#define TRANS2_SESSION_SETUP 0x0E /* Session setup with extended security information */
+#define TRANS2_GET_DFS_REFERRAL 0x10 /* Get a DFS referral */
+#define TRANS2_REPORT_DFS_INCONSISTENCY 0x11 /* Report a DFS knowledge inconsistency */
+
+typedef struct {
+ USHORT InformationLevel; /* Level of information requested */
+} TRANS2_QUERY_FS_INFO_STRUCT;
+
+#define SMB_INFO_STANDARD 1
+#define SMB_INFO_QUERY_EA_SIZE 2
+#define SMB_SET_FILE_BASIC_INFO 0x101
+#define SMB_SET_FILE_DISPOSITION_INFO 0x102
+#define SMB_SET_FILE_ALLOCATION_INFO 0x103
+#define SMB_SET_FILE_END_OF_FILE_INFO 0x104
+
+
+typedef struct {
+ hyper CreationTime;
+ hyper LastAccessTime;
+ hyper LastWriteTime;
+ hyper ChangeTime;
+ USHORT Attributes;
+ .align4 0;
+} SMB_QUERY_FILE_BASIC_INFO_STRUCT;
+
+
+typedef struct {
+ ULONG fs_atr;
+ LONG max_len_filename;
+ ULONG length;
+ uint8 fs[length];
+ .align4 2;
+} SMB_QUERY_FS_ATTRIBUTE_INFO_STRUCT;
+
+#define FILE_CASE_SENSITIVE_SEARCH 0x00000001
+#define FILE_CASE_PRESERVED_NAMES 0x00000002
+#define FILE_PRSISTENT_ACLS 0x00000004
+#define FILE_FILE_COMPRESSION 0x00000008
+#define FILE_VOLUME_QUOTAS 0x00000010
+#define FILE_DEVICE_IS_MOUNTED 0x00000020
+#define FILE_VOLUME_IS_COMPRESSED 0x00008000
+
+typedef struct {
+ USHORT Fid;
+ USHORT InformationLevel;
+ USHORT Reserved;
+ .align4 0;
+
+ union ctr[InformationLevel] {
+ case 0x101 SMB_QUERY_FILE_BASIC_INFO_STRUCT t101;
+ }
+
+} TRANS2_SET_FILE_INFO_STRUCT;
+
+typedef struct {
+ USHORT InformationLevel; /* Level of information requested */
+ ULONG Reserved; /* Must be zero */
+ string FileName; /* File or directory name */
+} TRANS2_QUERY_PATH_INFO_STRUCT;
+
+typedef struct {
+ USHORT SearchAttributes;
+ USHORT SearchCount;
+ USHORT Flags;
+ USHORT InformationLevel;
+ ULONG SearchStorageType;
+ string FileName;
+} TRANS2_FIND_FIRST2_STRUCT;
+
typedef struct _Q_TRANS2_15 {
USHORT TotalParameterCount; /* Total parameter bytes being sent */
USHORT TotalDataCount; /* Total data bytes being sent */
@@ -640,11 +726,13 @@ typedef struct _Q_TRANS2_15 {
UCHAR Reserved3; /* Reserved (pad above to word) */
USHORT Setup[SetupCount]; /* Setup words (# = SetupWordCount) */
USHORT ByteCount; /* Count of data bytes */
- 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 */
- UCHAR Data[DataCount]; /* Data bytes (# = DataCount) */
+ .align4 0;
+ union ctr[Setup[0]] {
+ case 1 TRANS2_FIND_FIRST2_STRUCT t1;
+ case 3 TRANS2_QUERY_FS_INFO_STRUCT t3;
+ case 5 TRANS2_QUERY_PATH_INFO_STRUCT t5;
+ case 8 TRANS2_SET_FILE_INFO_STRUCT t8;
+ }
} Q_TRANS2_15;
@@ -655,6 +743,100 @@ typedef struct _Q_TRANS2 {
}
} Q_TRANS2;
+typedef struct {
+ ULONG NextEntryOffset;
+ ULONG FileIndex;
+ hyper CreationTime;
+ hyper LastAccessTime;
+ hyper LastWriteTime;
+ hyper ChangeTime;
+ hyper EndOfFile;
+ hyper AllocationSize;
+ ULONG ExtFileAttributes;
+ ULONG FileNameLength;
+ ULONG EaSize;
+ UCHAR ShortNameLength;
+ UCHAR Reserved;
+ uint8 ShortName[24];
+ UCHAR FileName[FileNameLength];
+ .align4 2;
+} SMB_FIND_FILE_BOTH_DIRECTORY_INFO;
+
+typedef struct {
+ .align2 0;
+} R_TRANS2_D0;
+
+typedef struct {
+ .align4 2;
+} R_TRANS2_P0;
+
+typedef struct {
+ USHORT Reserved;
+} R_TRANS2_P2;
+
+typedef struct {
+ USHORT Sid; /* Search handle */
+ USHORT SearchCount; /* Number of entries returned */
+ USHORT EndOfSearch; /* Was last entry returned? */
+ USHORT EaErrorOffset; /* Offset into EA list if EA error */
+ USHORT LastNameOffset; /* Offset into data to file name of last */
+ /* entry, if server needs it to resume */
+ /* search; else 0 */
+ .align4 2;
+ SMB_FIND_FILE_BOTH_DIRECTORY_INFO i104[SearchCount];
+} R_TRANS2_FIND_FIRST2_STRUCT;
+
+typedef struct {
+ SMB_QUERY_FILE_BASIC_INFO_STRUCT i101;
+ .align4 2;
+} R_TRANS2_FILE_BASIC_STRUCT;
+
+typedef struct _R_TRANS2_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 */
+ USHORT ParameterDisplacement; /* Specifies the offset from the start */
+ /* of the overall parameter block to */
+ /* the parameter bytes that are */
+ /* contained in this message */
+ USHORT DataCount; /* Data bytes sent this buffer */
+ USHORT DataOffset; /* Offset (from header start) to data */
+ USHORT 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 */
+ UCHAR Reserved3; /* Reserved (pad above to word) */
+ USHORT Setup[SetupCount]; /* Setup words */
+ USHORT ByteCount; /* Count of data bytes */
+ .align4 2;
+ union pctr[ParameterCount] {
+ case 0 R_TRANS2_P0 p0;
+ case 2 R_TRANS2_P2 p2;
+ case 10 R_TRANS2_FIND_FIRST2_STRUCT r10;
+ }
+ union dctr[DataCount] {
+ case 0 R_TRANS2_D0 d0;
+ case 0x24 R_TRANS2_FILE_BASIC_STRUCT r24;
+ case 0x14 SMB_QUERY_FS_ATTRIBUTE_INFO_STRUCT r14;
+ }
+} R_TRANS2_10;
+
+typedef struct {
+ USHORT ByteCount; /* Count of data bytes */
+} R_TRANS2_0;
+
+typedef struct _R_TRANS2 {
+ uint8 wcount;
+ union ctr[wcount] {
+ case 0 R_TRANS2_0 q0;
+ case 10 R_TRANS2_10 q10;
+ }
+} R_TRANS2;
+
typedef struct _Q_TRANS_16 {
USHORT TotalParameterCount; /* Total parameter bytes being sent */
USHORT TotalDataCount; /* Total data bytes being sent */
@@ -676,9 +858,9 @@ typedef struct _Q_TRANS_16 {
USHORT Setup[SetupCount]; /* Setup words (# = SetupWordCount) */
USHORT ByteCount; /* Count of data bytes */
string Name; /* Must be NULL */
- UCHAR Pad[]; /* Pad to SHORT or LONG */
+ .align4 0;
UCHAR Parameters[ParameterCount];/* Parameter bytes (# = ParameterCount) */
- UCHAR Pad1[]; /* Pad to SHORT or LONG */
+ .align4 0;
UCHAR Data[DataCount]; /* Data bytes (# = DataCount) */
} Q_TRANS_16;
@@ -711,9 +893,9 @@ typedef struct _R_TRANS_10 {
UCHAR Reserved3; /* Reserved (pad above to word) */
USHORT Setup[SetupCount]; /* Setup words */
USHORT ByteCount; /* Count of data bytes */
- UCHAR Pad1; /* Pad to LONG */
+ .align4 0;
UCHAR Parameters[ParameterCount];/* Parameter bytes */
- /*UCHAR Pad2; Pad to SHORT or LONG */
+ .align4 0;
UCHAR Data[DataCount]; /* Data bytes */
} R_TRANS_10;
@@ -807,6 +989,7 @@ typedef struct _R_SMB {
case 45 R_OPEN_ANDX r45;
case 46 R_READ_ANDX r46;
case 47 R_WRITE_ANDX r47;
+ case 50 R_TRANS2 q50;
case 113 R_TDIS r113;
case 114 R_NEGPROT r114;
case 115 R_SESSION_SETUP_ANDX r115;
diff --git a/source/aparser/parsefn.awk b/source/aparser/parsefn.awk
index 8d8f8103192..f4fb65dd072 100644
--- a/source/aparser/parsefn.awk
+++ b/source/aparser/parsefn.awk
@@ -105,6 +105,22 @@ function parse_scalar(f, v, elnum, flags)
}
}
+function parse_align2(f, v, elnum, flags,
+ LOCAL, elem)
+{
+ elem = elements[elnum, "elem"];
+ v["OFFSET"] = elem_name(v, elem);
+ print_template(f, "prs_align2.tpl", v);
+}
+
+function parse_align4(f, v, elnum, flags,
+ LOCAL, elem)
+{
+ elem = elements[elnum, "elem"];
+ v["OFFSET"] = elem_name(v, elem);
+ print_template(f, "prs_align4.tpl", v);
+}
+
function parse_pointer(f, v, elnum, flags,
LOCAL, elem)
{
@@ -116,7 +132,13 @@ function parse_pointer(f, v, elnum, flags,
function parse_scalars(f, v, elnum, flags)
{
- if (elements[elnum, "ptr"] == "1") {
+ if (elements[elnum, "type"] == ".align2") {
+ parse_align2(f, v, elnum, flags);
+ }
+ else if (elements[elnum, "type"] == ".align4") {
+ parse_align4(f, v, elnum, flags);
+ }
+ else if (elements[elnum, "ptr"] == "1") {
parse_pointer(f, v, elnum, flags);
} else {
parse_scalar(f, v, elnum, flags);
@@ -129,7 +151,10 @@ function parse_buffers(f, v, elnum, flags,
elem = elements[elnum, "elem"];
type = elements[elnum, "type"];
v["ELEM"] = elem_name(v, elem);
- if (elements[elnum, "ptr"] == "1") {
+ if (elements[elnum, "type"] == ".align2") {
+ }
+ else if (elements[elnum, "type"] == ".align4") {
+ } else if (elements[elnum, "ptr"] == "1") {
print_template(f, "ifptr_start.tpl", v);
parse_scalar(f, v, elnum, "PARSE_SCALARS|PARSE_BUFFERS");
print_template(f, "ifptr_end.tpl", v);
@@ -167,7 +192,12 @@ function struct_parser(f, v, struct_num,
parse_buffers(f, v, structs[struct_num, i], "PARSE_BUFFERS");
}
- print_template(f, "fn_end.tpl", v);
+ if (i > 0) {
+ print_template(f, "fn_end.tpl", v);
+ }
+ else {
+ print_template(f, "fn_end0.tpl", v);
+ }
}
function produce_parsers(f,
diff --git a/source/aparser/parser.c b/source/aparser/parser.c
index 098cc575402..000f361f264 100644
--- a/source/aparser/parser.c
+++ b/source/aparser/parser.c
@@ -167,12 +167,47 @@ void prs_debug(prs_struct *ps, int depth, char *desc, char *fn_name)
zeros.
********************************************************************/
-BOOL prs_align(prs_struct *ps, int align)
+BOOL io_align2(prs_struct *ps, int offset)
{
- uint32 mod = ps->data_offset & (align-1);
+ uint32 mod = (ps->data_offset + offset) & (2-1);
+
+ if (mod != 0) {
+ uint32 extra_space = (2 - mod);
+ if(!prs_grow(ps, extra_space))
+ return False;
+ memset(&ps->data_p[ps->data_offset], '\0', (size_t)extra_space);
+ ps->data_offset += extra_space;
+ }
+
+ return True;
+}
+
+BOOL io_align4(prs_struct *ps, int offset)
+{
+ uint32 mod = (ps->data_offset + offset) & (4-1);
+
+ if (mod != 0) {
+ uint32 extra_space = (4 - mod);
+ if(!prs_grow(ps, extra_space))
+ return False;
+ memset(&ps->data_p[ps->data_offset], '\0', (size_t)extra_space);
+ ps->data_offset += extra_space;
+ }
return True;
+}
+/*******************************************************************
+ Align a the data_len to a multiple of align bytes - filling with
+ zeros.
+ ********************************************************************/
+
+BOOL prs_align(prs_struct *ps, int align)
+{
+ uint32 mod = ps->data_offset & (align-1);
+
+ return True; /* HACK! */
+
if (align != 0 && mod != 0) {
uint32 extra_space = (align - mod);
if(!prs_grow(ps, extra_space))
@@ -331,6 +366,7 @@ BOOL io_string(char *name, prs_struct *ps, int depth, char **str, unsigned flags
uint8 *start;
int i;
size_t len;
+ int start_offset = ps->data_offset;
if (!(flags & PARSE_SCALARS)) return True;
@@ -364,7 +400,8 @@ BOOL io_string(char *name, prs_struct *ps, int depth, char **str, unsigned flags
ps->data_offset++;
}
- DEBUG(5,("%s %s: %s\n", tab_depth(depth), name, *str));
+ DEBUG(5,("%s%04x %s: %s\n", tab_depth(depth),
+ start_offset, name, *str));
return True;
}
@@ -412,7 +449,7 @@ BOOL io_wstring(char *name, prs_struct *ps, int depth, uint16 *data16s, int len,
q = prs_mem_get(ps, len * sizeof(uint16));
if (q == NULL) return False;
- DBG_RW_PSVAL(True, name, depth, ps->data_offset, ps->io, ps->bigendian_data, q, data16s, len)
+ DBG_RW_PSVAL(False, name, depth, ps->data_offset, ps->io, ps->bigendian_data, q, data16s, len)
ps->data_offset += (len * sizeof(uint16));
return True;
diff --git a/source/aparser/parser.h b/source/aparser/parser.h
index 4e9a75e7041..a06242debbd 100644
--- a/source/aparser/parser.h
+++ b/source/aparser/parser.h
@@ -70,6 +70,8 @@ char *prs_mem_get(prs_struct *ps, uint32 extra_size);
BOOL prs_init(prs_struct *ps, uint32 size, BOOL io);
void prs_debug(prs_struct *ps, int depth, char *desc, char *fn_name);
BOOL prs_align(prs_struct *ps, int align);
+BOOL io_align4(prs_struct *ps, int align);
+BOOL io_align2(prs_struct *ps, int align);
void print_asc(int level, unsigned char *buf,int len);
BOOL prs_read(prs_struct *ps, int fd, size_t len, int timeout);
void dump_data(int level,char *buf1,int len);