summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-08-10 18:47:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:57:49 -0500
commit2c7c48017b59d666927f6702ac148bf2ccface07 (patch)
tree9359fbd4a819aa1d64c92f0ca5df49363a9098e5 /source4/build/pidl
parente079b4fce1c1f819292d45d52cb8c4b5a89de70f (diff)
downloadsamba-2c7c48017b59d666927f6702ac148bf2ccface07.tar.gz
samba-2c7c48017b59d666927f6702ac148bf2ccface07.tar.bz2
samba-2c7c48017b59d666927f6702ac148bf2ccface07.zip
r1701: Bugfixes to Tim's ethereal parser generator
(This used to be commit 8cd33b6cce6aaf8e819001d52bc77659b4116be9)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/eparser.pm24
-rw-r--r--source4/build/pidl/packet-dcerpc-eparser.c35
-rw-r--r--source4/build/pidl/packet-dcerpc-eparser.h14
3 files changed, 59 insertions, 14 deletions
diff --git a/source4/build/pidl/eparser.pm b/source4/build/pidl/eparser.pm
index c175cdb41f..d84f17ef29 100644
--- a/source4/build/pidl/eparser.pm
+++ b/source4/build/pidl/eparser.pm
@@ -2,6 +2,7 @@
# Samba4 parser generator for IDL structures
# Copyright tridge@samba.org 2000-2003
# Copyright tpot@samba.org 2001,2004
+# Copyright jelmer@samba.org 2004
# released under the GNU GPL
package IdlEParser;
@@ -238,7 +239,7 @@ sub ParseArrayPull($$)
pidl "\tif ($size > $alloc_size) {\n";
pidl "\t\tproto_tree_add_text(tree, ndr->tvb, ndr->offset, 0, \"Bad conformant size (%u should be %u)\", $alloc_size, $size);\n";
pidl "\t\tif (check_col(ndr->pinfo->cinfo, COL_INFO))\n";
- pidl "\t\t\tcol_append_fstr(ndr->pinfo->cinfo, COL_INFO, \", Bad conformant size\", $alloc_size, $size);\n";
+ pidl "\t\t\tcol_append_fstr(ndr->pinfo->cinfo, COL_INFO, \", Bad conformant size (%u should be %u)\", $alloc_size, $size);\n";
pidl "\t}\n";
} elsif (!util::is_inline_array($e)) {
# if ($var_prefix =~ /^r->out/ && $size =~ /^\*r->in/) {
@@ -300,7 +301,6 @@ sub ParseElementPullSwitch($$$)
if (!defined $utype ||
!util::has_property($utype->{DATA}, "nodiscriminant")) {
my $e2 = find_sibling($e, $switch);
- pidl "\tguint16 _level;\n";
pidl "\tif (($ndr_flags) & NDR_SCALARS) {\n";
pidl "\t\tndr_pull_level(ndr, tree, hf_level, &_level);\n";
pidl "\t}\n";
@@ -421,7 +421,7 @@ sub ParseStructPull($)
my($struct) = shift;
my $conform_e;
- pidl "\tguint32 _offset, _length;\n";
+ pidl "\tguint32 _U_ _offset, _U_ _length, _U_ _level;\n";
for my $e (@{$struct->{ELEMENTS}}) {
if (util::is_builtin_type($e->{TYPE})) {
@@ -562,6 +562,7 @@ sub ParseUnionPull($)
pidl "\t}\n";
pidl "\tndr_pull_struct_end(ndr);\n";
pidl "done:\n";
+ pidl "return;\n";
end_flags($e);
}
@@ -569,13 +570,13 @@ sub ParseUnionPull($)
# parse a enum - pull side
sub ParseEnumPull($)
{
- my $e = shift;
+ my $enum = shift;
my $name;
my $ndx = 0;
- for my $e (@{$e->{ELEMENTS}}) {
- if ($e =~ /([a-zA-Z_]+)=([0-9]+)/) {
+ for my $e (@{$enum->{ELEMENTS}}) {
+ if ($e =~ /([a-zA-Z0-9_]+)=([0-9x]+)/) {
$name = $1;
$ndx = $2;
} else {
@@ -650,8 +651,9 @@ sub ParseFunctionElementPull($$)
if (util::array_size($e)) {
if (util::need_wire_pointer($e)) {
- pidl "\tndr_pull_ptr(ndr, &ptr_$e->{NAME});\n";
+ pidl "\tndr_pull_ptr(ndr, tree, hf_ptr, &ptr_$e->{NAME});\n";
pidl "\tif (ptr_$e->{NAME}) {\n";
+ pidl "\t\tguint32 " . find_size_var($e, util::array_size($e)) . ";\n";
} elsif ($inout eq "out" && util::has_property($e, "ref")) {
pidl "\tif (r->$inout.$e->{NAME}) {\n";
} else {
@@ -694,7 +696,7 @@ sub ParseFunctionPull($)
pidl $static . "int $fn->{NAME}_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n";
pidl "{\n";
pidl "\tstruct e_ndr_pull *ndr = ndr_pull_init(tvb, offset, pinfo, drep);\n";
- pidl "\tguint32 _offset, _length;\n";
+ pidl "\tguint32 _U_ _offset, _U_ _length, _U_ _level;\n";
# declare any internal pointers we need
foreach my $e (@{$fn->{DATA}}) {
@@ -754,7 +756,7 @@ sub ParseFunctionPull($)
}
if ($fn->{RETURN_TYPE} && $fn->{RETURN_TYPE} ne "void") {
- pidl "\tndr_pull_$fn->{RETURN_TYPE}(ndr, tree, hf_rc);\n";
+ pidl "\tndr_pull_$fn->{RETURN_TYPE}(ndr, tree, hf_rc, NULL);\n";
}
pidl "\toffset = ndr->offset;\n";
@@ -781,7 +783,7 @@ sub FunctionTable($)
return;
}
- pidl "static dcerpc_sub_dissector dcerpc_dissectors[] = {\n";
+ pidl "static dcerpc_sub_dissector dcerpc_" . $interface->{NAME} . "_dissectors[] = {\n";
my $num = 0;
foreach my $d (@{$data}) {
if ($d->{TYPE} eq "FUNCTION") {
@@ -1098,7 +1100,7 @@ sub Parse($$)
pidl "{\n";
pidl "\tdcerpc_init_uuid(proto_dcerpc_$module, ett_dcerpc_$module, \n";
pidl "\t\t&uuid_dcerpc_$module, ver_dcerpc_$module, \n";
- pidl "\t\tdcerpc_dissectors, hf_opnum);\n";
+ pidl "\t\tdcerpc_" . $module . "_dissectors, hf_opnum);\n";
pidl "}\n";
} else {
diff --git a/source4/build/pidl/packet-dcerpc-eparser.c b/source4/build/pidl/packet-dcerpc-eparser.c
index c1b6e4378c..bef5d82646 100644
--- a/source4/build/pidl/packet-dcerpc-eparser.c
+++ b/source4/build/pidl/packet-dcerpc-eparser.c
@@ -57,11 +57,18 @@ void ndr_pull_level(struct e_ndr_pull *ndr, proto_tree *tree, int hf,
tree, ndr->drep, hf, data);
}
-void ndr_pull_NTSTATUS(struct e_ndr_pull *ndr, proto_tree *tree, int hf)
+void ndr_pull_NTSTATUS(struct e_ndr_pull *ndr, proto_tree *tree, int hf, gNTSTATUS *data)
{
ndr->offset = dissect_ntstatus(
ndr->tvb, ndr->offset, ndr->pinfo,
- tree, ndr->drep, hf, NULL);
+ tree, ndr->drep, hf, data);
+}
+
+void ndr_pull_WERROR(struct e_ndr_pull *ndr, proto_tree *tree, int hf, gWERROR *data)
+{
+ ndr->offset = dissect_werror(
+ ndr->tvb, ndr->offset, ndr->pinfo,
+ tree, ndr->drep, hf, data);
}
void ndr_pull_uint8(struct e_ndr_pull *ndr, proto_tree *tree, int hf,
@@ -104,6 +111,18 @@ void ndr_pull_uint64(struct e_ndr_pull *ndr, proto_tree *tree, int hf,
tree, ndr->drep, hf, data);
}
+void ndr_pull_DATA_BLOB(struct e_ndr_pull *ndr, proto_tree *tree, int hf, gDATA_BLOB *h)
+{
+ guint32 len1, ofs, len2;
+ char *data;
+
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return;
+ }
+
+ /* FIXME */
+}
+
void ndr_pull_string(struct e_ndr_pull *ndr, proto_tree *tree, int ndr_flags)
{
guint32 len1, ofs, len2;
@@ -511,6 +530,18 @@ void ndr_pull_array_uint8(struct e_ndr_pull *ndr, proto_tree *tree, int hf,
}
}
+void ndr_pull_array_uint16(struct e_ndr_pull *ndr, proto_tree *tree, int hf,
+ int ndr_flags, guint32 n)
+{
+ guint32 i;
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return;
+ }
+ for (i=0;i<n;i++) {
+ ndr_pull_uint16(ndr, tree, hf, NULL);
+ }
+}
+
void ndr_pull_array_uint32(struct e_ndr_pull *ndr, proto_tree *tree, int hf,
int ndr_flags, guint32 n)
{
diff --git a/source4/build/pidl/packet-dcerpc-eparser.h b/source4/build/pidl/packet-dcerpc-eparser.h
index 6c51ccd708..b4cff95b8e 100644
--- a/source4/build/pidl/packet-dcerpc-eparser.h
+++ b/source4/build/pidl/packet-dcerpc-eparser.h
@@ -52,8 +52,17 @@ struct ndr_ofs_list {
struct ndr_ofs_list *next;
};
+
typedef long long gNTTIME;
typedef long long gHYPER_T;
+typedef guint32 gNTSTATUS;
+typedef guint32 gWERROR;
+
+typedef struct
+{
+ int foobar;
+ /* FIXME */
+} gDATA_BLOB;
#include "packet-dcerpc-proto.h"
@@ -64,7 +73,8 @@ struct e_ndr_pull *ndr_pull_init(tvbuff_t *tvb, int offset, packet_info *pinfo,
void ndr_pull_free(struct e_ndr_pull *ndr);
void ndr_pull_ptr(struct e_ndr_pull *ndr, proto_tree *tree, int hf, guint32 *ptr);
void ndr_pull_level(struct e_ndr_pull *ndr, proto_tree *tree, int hf, gint16 *data);
-void ndr_pull_NTSTATUS(struct e_ndr_pull *ndr, proto_tree *tree, int hf);
+void ndr_pull_NTSTATUS(struct e_ndr_pull *ndr, proto_tree *tree, int hf, gNTSTATUS *data);
+void ndr_pull_WERROR(struct e_ndr_pull *ndr, proto_tree *tree, int hf, gWERROR *data);
void ndr_pull_uint8(struct e_ndr_pull *ndr, proto_tree *tree, int hf, guint8 *data);
void ndr_pull_uint16(struct e_ndr_pull *ndr, proto_tree *tree, int hf, guint16 *data);
void ndr_pull_uint32(struct e_ndr_pull *ndr, proto_tree *tree, int hf, guint32 *data);
@@ -82,6 +92,7 @@ void ndr_pull_NTTIME(struct e_ndr_pull *ndr, proto_tree *tree, int hf, gNTTIME *
void ndr_pull_HYPER_T(struct e_ndr_pull *ndr, proto_tree *tree, int hf, gHYPER_T *data);
void ndr_pull_int64(struct e_ndr_pull *ndr, proto_tree *tree, int hf, gint64 *data);
void ndr_pull_uint64(struct e_ndr_pull *ndr, proto_tree *tree, int hf, guint64 *data);
+void ndr_pull_DATA_BLOB(struct e_ndr_pull *ndr, proto_tree *tree, int hf, gDATA_BLOB *blob);
void ndr_pull_string(struct e_ndr_pull *ndr, proto_tree *tree, int ndr_flags);
void ndr_pull_dom_sid2(struct e_ndr_pull *ndr, proto_tree *tree, int flags);
@@ -102,6 +113,7 @@ int lsa_dissect_POLICY_DNS_DOMAIN_INFO(tvbuff_t tvb, int offset,
guint8 *drep);
void ndr_pull_array_uint8(struct e_ndr_pull *ndr, proto_tree *tree, int hf, int ndr_flags, guint32 n);
+void ndr_pull_array_uint16(struct e_ndr_pull *ndr, proto_tree *tree, int hf, int ndr_flags, guint32 n);
void ndr_pull_array_uint32(struct e_ndr_pull *ndr, proto_tree *tree, int hf, int ndr_flags, guint32 n);
void ndr_pull_array(struct e_ndr_pull *ndr, proto_tree *tree, int ndr_flags,