mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
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 commit is contained in:
@ -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)
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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];
|
||||
};
|
||||
|
||||
/* function 15 */
|
||||
struct SRV_SHARE_INFO_1 {
|
||||
UNISTR2 *uni_netname;
|
||||
uint32 type;
|
||||
UNISTR2 *uni_remark;
|
||||
struct LPWSTR {
|
||||
UNISTR2 *str;
|
||||
};
|
||||
|
||||
struct SHARE_ENUM {
|
||||
uint32 level;
|
||||
uint32 num_entries;
|
||||
union info[level] {
|
||||
case 1 SRV_SHARE_INFO_1 entries[num_entries];
|
||||
}
|
||||
/* function 15 */
|
||||
struct SRV_SHARE_INFO_1 {
|
||||
LPWSTR uni_netname;
|
||||
uint32 type;
|
||||
LPWSTR uni_remark;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user