summaryrefslogtreecommitdiff
path: root/source3/aparser
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-05-16 12:43:53 +0000
committerAndrew Tridgell <tridge@samba.org>2000-05-16 12:43:53 +0000
commit128026c9a2de83a8ac6214e733fa871440c6b77f (patch)
treefca86e76f0020a2b16549cb0ab2a9dae29d61ac6 /source3/aparser
parentf3a3a05ade784ff6906e5c8b132c9440a8db44e5 (diff)
downloadsamba-128026c9a2de83a8ac6214e733fa871440c6b77f.tar.gz
samba-128026c9a2de83a8ac6214e733fa871440c6b77f.tar.bz2
samba-128026c9a2de83a8ac6214e733fa871440c6b77f.zip
added the ".trailer" type, to mark where a packet turns into a trailer
this now gives us enough to parse complete function calls, including the return values (This used to be commit ca8f1e92adf3603ad15f73277576cc9178bb4d74)
Diffstat (limited to 'source3/aparser')
-rw-r--r--source3/aparser/Makefile2
-rw-r--r--source3/aparser/header.awk1
-rw-r--r--source3/aparser/parsefn.awk16
-rw-r--r--source3/aparser/spool.struct80
-rw-r--r--source3/aparser/srvsvc.struct53
-rw-r--r--source3/aparser/vluke.c3
6 files changed, 97 insertions, 58 deletions
diff --git a/source3/aparser/Makefile b/source3/aparser/Makefile
index 160b11155a..ebf3a9bcde 100644
--- a/source3/aparser/Makefile
+++ b/source3/aparser/Makefile
@@ -7,7 +7,7 @@ AWKPROGS=dump.awk harness.awk header.awk parsefn.awk main.awk parsetree.awk temp
all: test.h vluke
test.h : $(AWKPROGS)
- igawk -f main.awk spool.struct
+ igawk -f main.awk srvsvc.struct
vluke: test.h $(OBJ)
$(CC) $(CFLAGS) -o vluke $(OBJ)
diff --git a/source3/aparser/header.awk b/source3/aparser/header.awk
index 406335c930..24232bacf0 100644
--- a/source3/aparser/header.awk
+++ b/source3/aparser/header.awk
@@ -13,6 +13,7 @@ function header_element(f, elnum,
LOCAL, type)
{
type=elements[elnum, "type"];
+ if (substr(type,1,1) == ".") return;
xprintf(f,"\t%s %s;\n", type, header_elstring(elnum));
}
diff --git a/source3/aparser/parsefn.awk b/source3/aparser/parsefn.awk
index 68f08618a6..3f1e3e8093 100644
--- a/source3/aparser/parsefn.awk
+++ b/source3/aparser/parsefn.awk
@@ -27,6 +27,7 @@ function parse_element(f, v, elnum, flags,
LOCAL, type, elem)
{
type = elements[elnum, "type"];
+ if (substr(type,1,1) == ".") return;
elem = elements[elnum, "elem"];
if (elements[elnum,"ptr"] == "") {
v["PTR"] = "\\&";
@@ -117,24 +118,33 @@ function parse_buffers(f, v, elnum, flags,
}
function struct_parser(f, v, struct_num,
- LOCAL, i)
+ LOCAL, i, n1)
{
v["STRUCTNAME"] = structs[struct_num, "name"];
v["FUNCNAME"] = "io_" v["STRUCTNAME"];
print_template(f, "fn_start.tpl", v);
+ for (n1=0;n1<structs[struct_num, "num_elems"];n1++) {
+ if (elements[structs[struct_num, n1], "type"] == ".trailer") break;
+ }
+
# first all the structure pointers, scalars and arrays
- for (i=0;i<structs[struct_num, "num_elems"];i++) {
+ for (i=0;i<n1;i++) {
parse_scalars(f, v, structs[struct_num, i], "PARSE_SCALARS");
}
print_template(f, "fn_mid.tpl", v);
# now the buffers
- for (i=0;i<structs[struct_num, "num_elems"];i++) {
+ for (i=0;i<n1;i++) {
parse_buffers(f, v, structs[struct_num, i], "PARSE_BUFFERS");
}
+ # and any trailers
+ for (i=n1;i<structs[struct_num, "num_elems"];i++) {
+ parse_buffers(f, v, structs[struct_num, i], "PARSE_SCALARS");
+ }
+
print_template(f, "fn_end.tpl", v);
}
diff --git a/source3/aparser/spool.struct b/source3/aparser/spool.struct
index 43f50ba1d6..77f3226b5b 100644
--- a/source3/aparser/spool.struct
+++ b/source3/aparser/spool.struct
@@ -1,11 +1,16 @@
module spool
-test R_GETPRINTERDRIVER2
+test PRINTER_DRIVER_INFO_LEVEL_6
struct BUFFER5 {
uint32 buf_len;
uint16 buffer[buf_len];
};
+struct BUFFERP {
+ uint32 buf_len;
+ BUFFER5 *buf;
+};
+
struct UNISTR2 {
uint32 max_len;
uint32 undoc;
@@ -13,9 +18,14 @@ struct UNISTR2 {
uint16 buffer[str_len];
};
-struct UINT64_S {
- uint32 low;
- uint32 high;
+struct LPWSTR {
+ UNISTR2 *str;
+};
+
+struct VERSION {
+ uint32 version;
+ uint32 build;
+ uint32 osversion;
};
struct NTTIME {
@@ -23,42 +33,42 @@ struct NTTIME {
uint32 high;
};
+struct DWORD {
+ uint32 x;
+};
+
struct PRINTER_DRIVER_INFO_LEVEL_3 {
- uint32 cversion;
- UNISTR2 *name;
- UNISTR2 *environment;
- UNISTR2 *driverpath;
- UNISTR2 *datafile;
- UNISTR2 *configfile;
- UNISTR2 *helpfile;
- UNISTR2 *monitorname;
- UNISTR2 *defaultdatatype;
- uint32 dependentfiles_len;
- BUFFER5 *dependentfiles;
+ DWORD cversion;
+ LPWSTR name;
+ LPWSTR environment;
+ LPWSTR driverpath;
+ LPWSTR datafile;
+ LPWSTR configfile;
+ LPWSTR helpfile;
+ LPWSTR monitorname;
+ LPWSTR defaultdatatype;
+ BUFFERP dependentfiles;
};
struct PRINTER_DRIVER_INFO_LEVEL_6 {
- uint32 dummy1;
- uint32 version;
- UNISTR2 *name;
- UNISTR2 *environment;
- UNISTR2 *driverpath;
- UNISTR2 *datafile;
- UNISTR2 *configfile;
- UNISTR2 *helpfile;
- UNISTR2 *monitorname;
- UNISTR2 *defaultdatatype;
- uint32 dependentfiles_len;
- BUFFER5 *dependentfiles;
- uint32 previousnames_len;
- BUFFER5 *previousnames;
+ DWORD dummy1;
+ DWORD version;
+ LPWSTR name;
+ LPWSTR environment;
+ LPWSTR driverpath;
+ LPWSTR datafile;
+ LPWSTR configfile;
+ LPWSTR helpfile;
+ LPWSTR monitorname;
+ LPWSTR defaultdatatype;
+ BUFFERP dependentfiles;
+ BUFFERP previousnames;
NTTIME driverdate;
- UINT64_S driverversion;
- uint32 dummy4;
- UNISTR2 *mfgname;
- UNISTR2 *oemurl;
- UNISTR2 *hardwareid;
- UNISTR2 *provider;
+ VERSION driverversion;
+ LPWSTR mfgname;
+ LPWSTR oemurl;
+ LPWSTR hardwareid;
+ LPWSTR provider;
};
diff --git a/source3/aparser/srvsvc.struct b/source3/aparser/srvsvc.struct
index 61e67c4f4a..44d88944cb 100644
--- a/source3/aparser/srvsvc.struct
+++ b/source3/aparser/srvsvc.struct
@@ -1,5 +1,5 @@
module srvsvc
-test SRV_R_NET_SHARE_ENUM
+test SRV_R_NET_SERVER_INFO
struct UNISTR2 {
uint32 max_len;
@@ -8,26 +8,41 @@ struct UNISTR2 {
uint16 buffer[str_len];
};
+struct LPWSTR {
+ UNISTR2 *str;
+};
+
/* function 15 */
struct SRV_SHARE_INFO_1 {
- UNISTR2 *uni_netname;
+ LPWSTR uni_netname;
uint32 type;
- UNISTR2 *uni_remark;
+ LPWSTR uni_remark;
};
-struct SHARE_ENUM {
- uint32 level;
- uint32 num_entries;
- union info[level] {
- case 1 SRV_SHARE_INFO_1 entries[num_entries];
- }
+struct SRV_SHARE_INFO_2 {
+ LPWSTR uni_netname;
+ uint32 type;
+ LPWSTR uni_remark;
+ uint32 perms;
+ uint32 max_uses;
+ uint32 num_uses;
+ LPWSTR path;
+ LPWSTR passwd;
};
struct SRV_R_NET_SHARE_ENUM {
uint32 level;
- uint32 dummy;
- SHARE_ENUM *shares;
- uint32 *num_entries;
+ uint32 level2;
+ uint32 *ret_count;
+ uint32 num_entries;
+ union *info[level] {
+ case 1 SRV_SHARE_INFO_1 info1[num_entries];
+ case 2 SRV_SHARE_INFO_2 info2[num_entries];
+ }
+ .trailer;
+ uint32 count;
+ uint32 status1;
+ uint32 status2;
};
@@ -35,32 +50,32 @@ struct SRV_R_NET_SHARE_ENUM {
/* function 21 */
struct SERVER_INFO_100 {
uint32 dwPlatformID;
- UNISTR2 *pszName;
+ LPWSTR pszName;
};
struct SERVER_INFO_101 {
uint32 dwPlatformID;
- UNISTR2 *pszName;
+ LPWSTR pszName;
uint32 dwVerMajor;
uint32 dwVerMinor;
uint32 dwType;
- UNISTR2 *pszComment;
+ LPWSTR pszComment;
};
struct SERVER_INFO_102 {
uint32 dwPlatformID;
- UNISTR2 *pszName;
+ LPWSTR pszName;
uint32 dwVerMajor;
uint32 dwVerMinor;
uint32 dwType;
- UNISTR2 *pszComment;
+ LPWSTR pszComment;
uint32 dwUsers;
uint32 lDisc;
uint32 bHidden;
uint32 dwAnnounce;
uint32 dwAnnDelta;
uint32 dwLicenses;
- UNISTR2 *pszUserPath;
+ LPWSTR pszUserPath;
};
struct SRV_R_NET_SERVER_INFO {
@@ -70,4 +85,6 @@ struct SRV_R_NET_SERVER_INFO {
case 101 SERVER_INFO_101 *sv101;
case 102 SERVER_INFO_102 *sv102;
}
+ .trailer;
+ uint32 status;
};
diff --git a/source3/aparser/vluke.c b/source3/aparser/vluke.c
index 312eeceb2c..f5612a773d 100644
--- a/source3/aparser/vluke.c
+++ b/source3/aparser/vluke.c
@@ -33,7 +33,8 @@ int main(int argc, char *argv[])
ps.io = UNMARSHALL;
il = (TEST_STRUCT *)malloc(sizeof(*il));
ret = TEST_FUNC(desc, &ps, 1, il, PARSE_SCALARS|PARSE_BUFFERS);
- printf("\nret=%s\n\n\n", ret?"OK":"Bad");
+ printf("\nret=%s\n", ret?"OK":"Bad");
+ printf("Trailer is %d bytes\n\n", ps.grow_size - ps.data_offset);
dump_data(0, ps.data_p, ps.grow_size);
return !ret;
}