summaryrefslogtreecommitdiff
path: root/source3/rpc_parse
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-03-11 21:11:04 +0000
committerJeremy Allison <jra@samba.org>1998-03-11 21:11:04 +0000
commitfdeea341ed1bae670382e45eb731db1b5838ad21 (patch)
treebdbc5138a9340bdbd5c12cee243e6acfb2e64daf /source3/rpc_parse
parent4c6230afd2f144322c07c7e4c46147d3e5d2ddde (diff)
downloadsamba-fdeea341ed1bae670382e45eb731db1b5838ad21.tar.gz
samba-fdeea341ed1bae670382e45eb731db1b5838ad21.tar.bz2
samba-fdeea341ed1bae670382e45eb731db1b5838ad21.zip
"For I have laboured mightily on Luke's code, and hath broken
all I saw" - the book of Jeremy, chapter 1 :-). So here is the mega-merge of the NTDOM branch server code. It doesn't include the new client side pieces, we'll look at that later. This should give the same functionality, server wise, as the NTDOM branch does, only merged into the main branch. Any fixes to domain controler functionality should be added to the main branch, not the NTDOM branch. This code compiles without warnings on gcc2.8, but will need further testing before we are sure all the working functionality of the NTDOM server branch has been correctly carried over. I hereby declare the server side of the NTDOM branch dead (and all who sail in her :-). Jeremy. (This used to be commit 118ba4d77a33248e762a2cf843fb7cbc906ee6e7)
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r--source3/rpc_parse/parse_lsa.c567
-rw-r--r--source3/rpc_parse/parse_misc.c981
-rw-r--r--source3/rpc_parse/parse_net.c1147
-rw-r--r--source3/rpc_parse/parse_prs.c290
-rw-r--r--source3/rpc_parse/parse_reg.c335
-rw-r--r--source3/rpc_parse/parse_rpc.c528
-rw-r--r--source3/rpc_parse/parse_samr.c2796
-rw-r--r--source3/rpc_parse/parse_srv.c1528
-rw-r--r--source3/rpc_parse/parse_wks.c146
9 files changed, 8318 insertions, 0 deletions
diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c
new file mode 100644
index 0000000000..6eb42fc749
--- /dev/null
+++ b/source3/rpc_parse/parse_lsa.c
@@ -0,0 +1,567 @@
+/*
+ * Unix SMB/Netbios implementation.
+ * Version 1.9.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "includes.h"
+#include "nterr.h"
+
+extern int DEBUGLEVEL;
+
+
+/*******************************************************************
+creates a LSA_TRANS_NAME structure.
+********************************************************************/
+void make_lsa_trans_name(LSA_TRANS_NAME *trn, uint32 sid_name_use, char *name, uint32 idx)
+{
+ int len_name = strlen(name);
+
+ trn->sid_name_use = sid_name_use;
+ make_uni_hdr(&(trn->hdr_name), len_name, len_name, len_name != 0);
+ make_unistr2(&(trn->uni_name), name, len_name);
+ trn->domain_idx = idx;
+}
+
+/*******************************************************************
+reads or writes a LSA_TRANS_NAME structure.
+********************************************************************/
+void lsa_io_trans_name(char *desc, LSA_TRANS_NAME *trn, prs_struct *ps, int depth)
+{
+ if (trn == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_trans_name");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("sid_name_use", ps, depth, &(trn->sid_name_use));
+
+ smb_io_unihdr ("hdr_name", &(trn->hdr_name), ps, depth);
+ smb_io_unistr2("uni_name", &(trn->uni_name), trn->hdr_name.buffer, ps, depth);
+
+ prs_uint32("domain_idx ", ps, depth, &(trn->domain_idx ));
+}
+
+/*******************************************************************
+reads or writes a DOM_R_REF structure.
+********************************************************************/
+void lsa_io_dom_r_ref(char *desc, DOM_R_REF *r_r, prs_struct *ps, int depth)
+{
+ int i;
+
+ prs_debug(ps, depth, desc, "smb_io_dom_r_ref");
+ depth++;
+
+ if (r_r == NULL) return;
+
+ prs_align(ps);
+
+ prs_uint32("undoc_buffer ", ps, depth, &(r_r->undoc_buffer)); /* undocumented buffer pointer. */
+ prs_uint32("num_ref_doms_1 ", ps, depth, &(r_r->num_ref_doms_1)); /* num referenced domains? */
+ prs_uint32("buffer_dom_name", ps, depth, &(r_r->buffer_dom_name)); /* undocumented domain name buffer pointer. */
+ prs_uint32("max_entries ", ps, depth, &(r_r->max_entries)); /* 32 - max number of entries */
+ prs_uint32("num_ref_doms_2 ", ps, depth, &(r_r->num_ref_doms_2)); /* 4 - num referenced domains? */
+
+ smb_io_unihdr2("", &(r_r->hdr_dom_name), ps, depth); /* domain name unicode string header */
+
+ for (i = 0; i < r_r->num_ref_doms_1-1; i++)
+ {
+ smb_io_unihdr2("", &(r_r->hdr_ref_dom[i]), ps, depth);
+ }
+
+ smb_io_unistr("", &(r_r->uni_dom_name), ps, depth); /* domain name unicode string */
+
+ for (i = 0; i < r_r->num_ref_doms_2; i++)
+ {
+ smb_io_dom_sid2("", &(r_r->ref_dom[i]), ps, depth); /* referenced domain SIDs */
+ }
+}
+
+/*******************************************************************
+makes an LSA_OBJ_ATTR structure.
+********************************************************************/
+void make_lsa_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, uint32 sec_qos)
+{
+ if (attr == NULL) return;
+
+ DEBUG(5,("make_lsa_obj_attr\n"));
+
+ attr->len = 0x18; /* length of object attribute block, in bytes */
+ attr->ptr_root_dir = 0;
+ attr->ptr_obj_name = 0;
+ attr->attributes = attributes;
+ attr->ptr_sec_desc = 0;
+ attr->sec_qos = sec_qos;
+}
+
+/*******************************************************************
+reads or writes an LSA_OBJ_ATTR structure.
+********************************************************************/
+void lsa_io_obj_attr(char *desc, LSA_OBJ_ATTR *attr, prs_struct *ps, int depth)
+{
+ int start;
+
+ if (attr == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_obj_attr");
+ depth++;
+
+ prs_align(ps);
+
+ start = ps->offset;
+
+ /* these pointers had _better_ be zero, because we don't know
+ what they point to!
+ */
+ prs_uint32("len" , ps, depth, &(attr->len )); /* 0x18 - length (in bytes) inc. the length field. */
+ prs_uint32("ptr_root_dir", ps, depth, &(attr->ptr_root_dir)); /* 0 - root directory (pointer) */
+ prs_uint32("ptr_obj_name", ps, depth, &(attr->ptr_obj_name)); /* 0 - object name (pointer) */
+ prs_uint32("attributes" , ps, depth, &(attr->attributes )); /* 0 - attributes (undocumented) */
+ prs_uint32("ptr_sec_desc", ps, depth, &(attr->ptr_sec_desc)); /* 0 - security descriptior (pointer) */
+ prs_uint32("sec_qos" , ps, depth, &(attr->sec_qos )); /* 0 - security quality of service */
+
+ if (attr->len != ps->offset - start)
+ {
+ DEBUG(3,("lsa_io_obj_attr: length %lx does not match size %lx\n",
+ attr->len, ps->offset - start));
+ }
+}
+/*******************************************************************
+makes an LSA_Q_OPEN_POL structure.
+********************************************************************/
+void make_q_open_pol(LSA_Q_OPEN_POL *r_q, char *server_name,
+ uint32 attributes, uint32 sec_qos,
+ uint32 desired_access)
+{
+ if (r_q == NULL) return;
+
+ DEBUG(5,("make_open_pol\n"));
+
+ r_q->ptr = 1; /* undocumented pointer */
+
+ make_unistr2 (&(r_q->uni_server_name), server_name, strlen(server_name));
+ make_lsa_obj_attr(&(r_q->attr ), attributes, sec_qos);
+
+ r_q->des_access = desired_access;
+}
+
+/*******************************************************************
+reads or writes an LSA_Q_OPEN_POL structure.
+********************************************************************/
+void lsa_io_q_open_pol(char *desc, LSA_Q_OPEN_POL *r_q, prs_struct *ps, int depth)
+{
+ if (r_q == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_q_open_pol");
+ depth++;
+
+ prs_uint32("ptr ", ps, depth, &(r_q->ptr ));
+
+ smb_io_unistr2 ("", &(r_q->uni_server_name), r_q->ptr, ps, depth);
+ lsa_io_obj_attr("", &(r_q->attr ), ps, depth);
+
+ prs_uint32("des_access", ps, depth, &(r_q->des_access));
+}
+
+/*******************************************************************
+reads or writes an LSA_R_OPEN_POL structure.
+********************************************************************/
+void lsa_io_r_open_pol(char *desc, LSA_R_OPEN_POL *r_p, prs_struct *ps, int depth)
+{
+ if (r_p == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_r_open_pol");
+ depth++;
+
+
+ smb_io_pol_hnd("", &(r_p->pol), ps, depth);
+
+ prs_uint32("status", ps, depth, &(r_p->status));
+}
+
+/*******************************************************************
+makes an LSA_Q_QUERY_INFO structure.
+********************************************************************/
+void make_q_query(LSA_Q_QUERY_INFO *q_q, POLICY_HND *hnd, uint16 info_class)
+{
+ if (q_q == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_q_query\n"));
+
+ memcpy(&(q_q->pol), hnd, sizeof(q_q->pol));
+
+ q_q->info_class = info_class;
+}
+
+/*******************************************************************
+reads or writes an LSA_Q_QUERY_INFO structure.
+********************************************************************/
+void lsa_io_q_query(char *desc, LSA_Q_QUERY_INFO *q_q, prs_struct *ps, int depth)
+{
+ if (q_q == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_q_query");
+ depth++;
+
+ smb_io_pol_hnd("", &(q_q->pol), ps, depth);
+
+ prs_uint16("info_class", ps, depth, &(q_q->info_class));
+}
+
+/*******************************************************************
+reads or writes an LSA_Q_ENUM_TRUST_DOM structure.
+********************************************************************/
+void lsa_io_q_enum_trust_dom(char *desc, LSA_Q_ENUM_TRUST_DOM *q_e, prs_struct *ps, int depth)
+{
+ if (q_e == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_q_enum_trust_dom");
+ depth++;
+
+
+ smb_io_pol_hnd("", &(q_e->pol), ps, depth);
+
+ prs_uint32("enum_context ", ps, depth, &(q_e->enum_context ));
+ prs_uint32("preferred_len", ps, depth, &(q_e->preferred_len));
+}
+
+/*******************************************************************
+makes an LSA_R_ENUM_TRUST_DOM structure.
+********************************************************************/
+void make_r_enum_trust_dom(LSA_R_ENUM_TRUST_DOM *r_e,
+ uint32 enum_context, char *domain_name, char *domain_sid,
+ uint32 status)
+{
+ if (r_e == NULL) return;
+
+ DEBUG(5,("make_r_enum_trust_dom\n"));
+
+ r_e->enum_context = enum_context;
+
+ if (status == 0)
+ {
+ int len_domain_name = strlen(domain_name);
+
+ r_e->num_domains = 1;
+ r_e->ptr_enum_domains = 1;
+ r_e->num_domains2 = 1;
+
+ make_uni_hdr2(&(r_e->hdr_domain_name ), len_domain_name, len_domain_name, 4);
+ make_unistr2 (&(r_e->uni_domain_name ), domain_name, len_domain_name);
+ make_dom_sid2(&(r_e->other_domain_sid), domain_sid);
+ }
+ else
+ {
+ r_e->num_domains = 0;
+ r_e->ptr_enum_domains = 0;
+ }
+
+ r_e->status = status;
+}
+
+/*******************************************************************
+reads or writes an LSA_R_ENUM_TRUST_DOM structure.
+********************************************************************/
+void lsa_io_r_enum_trust_dom(char *desc, LSA_R_ENUM_TRUST_DOM *r_e, prs_struct *ps, int depth)
+{
+ if (r_e == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom");
+ depth++;
+
+ prs_uint32("enum_context ", ps, depth, &(r_e->enum_context ));
+ prs_uint32("num_domains ", ps, depth, &(r_e->num_domains ));
+ prs_uint32("ptr_enum_domains", ps, depth, &(r_e->ptr_enum_domains));
+
+ if (r_e->ptr_enum_domains != 0)
+ {
+ prs_uint32("num_domains2", ps, depth, &(r_e->num_domains2));
+ smb_io_unihdr2 ("", &(r_e->hdr_domain_name ), ps, depth);
+ smb_io_unistr2 ("", &(r_e->uni_domain_name ), r_e->hdr_domain_name.buffer, ps, depth);
+ smb_io_dom_sid2("", &(r_e->other_domain_sid), ps, depth);
+ }
+
+ prs_uint32("status", ps, depth, &(r_e->status));
+}
+
+/*******************************************************************
+makes an LSA_Q_CLOSE structure.
+********************************************************************/
+void make_lsa_q_close(LSA_Q_CLOSE *q_c, POLICY_HND *hnd)
+{
+ if (q_c == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_lsa_q_close\n"));
+
+ memcpy(&(q_c->pol), hnd, sizeof(q_c->pol));
+}
+
+
+/*******************************************************************
+reads or writes an LSA_Q_CLOSE structure.
+********************************************************************/
+void lsa_io_q_close(char *desc, LSA_Q_CLOSE *q_c, prs_struct *ps, int depth)
+{
+ if (q_c == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_q_close");
+ depth++;
+
+ smb_io_pol_hnd("", &(q_c->pol), ps, depth);
+}
+
+/*******************************************************************
+makes an LSA_R_CLOSE structure.
+********************************************************************/
+void make_lsa_r_close(LSA_R_CLOSE *q_r, POLICY_HND *hnd)
+{
+ if (q_r == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_lsa_r_close\n"));
+
+ memcpy(&(q_r->pol), hnd, sizeof(q_r->pol));
+}
+
+
+/*******************************************************************
+reads or writes an LSA_R_CLOSE structure.
+********************************************************************/
+void lsa_io_r_close(char *desc, LSA_R_CLOSE *r_c, prs_struct *ps, int depth)
+{
+ if (r_c == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_r_close");
+ depth++;
+
+ smb_io_pol_hnd("", &(r_c->pol), ps, depth);
+
+ prs_uint32("status", ps, depth, &(r_c->status));
+}
+
+/*******************************************************************
+reads or writes an LSA_Q_QUERY_INFO structure.
+********************************************************************/
+void lsa_io_r_query(char *desc, LSA_R_QUERY_INFO *r_q, prs_struct *ps, int depth)
+{
+ if (r_q == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_r_query");
+ depth++;
+
+ prs_uint32("undoc_buffer", ps, depth, &(r_q->undoc_buffer));
+
+ if (r_q->undoc_buffer != 0)
+ {
+ prs_uint16("info_class", ps, depth, &(r_q->info_class));
+
+ switch (r_q->info_class)
+ {
+ case 3:
+ {
+ smb_io_dom_query_3("", &(r_q->dom.id3), ps, depth);
+ break;
+ }
+ case 5:
+ {
+ smb_io_dom_query_5("", &(r_q->dom.id3), ps, depth);
+ break;
+ }
+ default:
+ {
+ /* PANIC! */
+ break;
+ }
+ }
+ }
+
+ prs_uint32("status", ps, depth, &(r_q->status));
+}
+
+/*******************************************************************
+reads or writes a LSA_SID_ENUM structure.
+********************************************************************/
+void lsa_io_sid_enum(char *desc, LSA_SID_ENUM *sen, prs_struct *ps, int depth)
+{
+ int i;
+
+ if (sen == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_sid_enum");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries ", ps, depth, &(sen->num_entries));
+ prs_uint32("ptr_sid_enum", ps, depth, &(sen->ptr_sid_enum));
+ prs_uint32("num_entries2", ps, depth, &(sen->num_entries2));
+
+ for (i = 0; i < sen->num_entries; i++)
+ {
+ fstring temp;
+ sprintf(temp, "ptr_sid[%d]", i);
+ prs_uint32(temp, ps, depth, &(sen->ptr_sid[i])); /* domain SID pointers to be looked up. */
+ }
+
+ for (i = 0; i < sen->num_entries; i++)
+ {
+ fstring temp;
+ sprintf(temp, "sid[%d]", i);
+ smb_io_dom_sid2(temp, &(sen->sid[i]), ps, depth); /* domain SIDs to be looked up. */
+ }
+}
+
+/*******************************************************************
+reads or writes a LSA_Q_LOOKUP_SIDS structure.
+********************************************************************/
+void lsa_io_q_lookup_sids(char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps, int depth)
+{
+ if (q_s == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd ("pol_hnd", &(q_s->pol_hnd), ps, depth); /* policy handle */
+ lsa_io_sid_enum ("sids ", &(q_s->sids ), ps, depth); /* sids to be looked up */
+ lsa_io_trans_names ("names ", &(q_s->names ), ps, depth); /* translated names */
+ smb_io_lookup_level("switch ", &(q_s->level ), ps, depth); /* lookup level */
+
+ prs_uint32("mapped_count", ps, depth, &(q_s->mapped_count));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void lsa_io_trans_names(char *desc, LSA_TRANS_NAME_ENUM *trn, prs_struct *ps, int depth)
+{
+ int i;
+ int i2;
+
+ if (trn == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_trans_names");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries ", ps, depth, &(trn->num_entries));
+ prs_uint32("ptr_trans_names", ps, depth, &(trn->ptr_trans_names));
+ prs_uint32("num_entries2 ", ps, depth, &(trn->num_entries2));
+
+ for (i = 0; i < trn->num_entries; i++)
+ {
+ fstring temp;
+ sprintf(temp, "ptr_name[%d] ", i);
+ prs_uint32(temp, ps, depth, &(trn->ptr_name[i])); /* pointer to translated name */
+ }
+
+ for (i = 0; i < trn->num_entries2; i++)
+ {
+ if (trn->ptr_name[i] != 0)
+ {
+ fstring temp;
+ sprintf(temp, "name[%d] ", i);
+ lsa_io_trans_name(temp, &(trn->name[i2]), ps, depth); /* translated name */
+ i2++;
+ }
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void lsa_io_r_lookup_sids(char *desc, LSA_R_LOOKUP_SIDS *r_s, prs_struct *ps, int depth)
+{
+ if (r_s == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids");
+ depth++;
+
+ prs_align(ps);
+
+ lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth); /* domain reference info */
+ lsa_io_trans_names("names ", r_s->names , ps, depth); /* translated names */
+
+ prs_uint32("mapped_count", ps, depth, &(r_s->mapped_count));
+
+ prs_uint32("status ", ps, depth, &(r_s->status));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void lsa_io_q_lookup_rids(char *desc, LSA_Q_LOOKUP_RIDS *q_r, prs_struct *ps, int depth)
+{
+ int i;
+
+ if (q_r == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_q_lookup_rids");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("", &(q_r->pol_hnd), ps, depth); /* policy handle */
+
+ prs_uint32("num_entries ", ps, depth, &(q_r->num_entries));
+ prs_uint32("num_entries2 ", ps, depth, &(q_r->num_entries2));
+ prs_uint32("buffer_dom_sid ", ps, depth, &(q_r->buffer_dom_sid)); /* undocumented domain SID buffer pointer */
+ prs_uint32("buffer_dom_name", ps, depth, &(q_r->buffer_dom_name)); /* undocumented domain name buffer pointer */
+
+ for (i = 0; i < q_r->num_entries; i++)
+ {
+ smb_io_dom_name("", &(q_r->lookup_name[i]), ps, depth); /* names to be looked up */
+ }
+
+ prs_uint8s (False, "undoc ", ps, depth, q_r->undoc, UNKNOWN_LEN);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void lsa_io_r_lookup_rids(char *desc, LSA_R_LOOKUP_RIDS *r_r, prs_struct *ps, int depth)
+{
+ int i;
+
+ if (r_r == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_r_lookup_rids");
+ depth++;
+
+ prs_align(ps);
+
+ lsa_io_dom_r_ref("", &(r_r->dom_ref), ps, depth); /* domain reference info */
+
+ prs_uint32("num_entries ", ps, depth, &(r_r->num_entries));
+ prs_uint32("undoc_buffer", ps, depth, &(r_r->undoc_buffer));
+ prs_uint32("num_entries2", ps, depth, &(r_r->num_entries2));
+
+ for (i = 0; i < r_r->num_entries2; i++)
+ {
+ smb_io_dom_rid2("", &(r_r->dom_rid[i]), ps, depth); /* domain RIDs being looked up */
+ }
+
+ prs_uint32("num_entries3", ps, depth, &(r_r->num_entries3));
+
+ prs_uint32("status ", ps, depth, &(r_r->status));
+}
+
diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c
new file mode 100644
index 0000000000..225754903f
--- /dev/null
+++ b/source3/rpc_parse/parse_misc.c
@@ -0,0 +1,981 @@
+
+/*
+ * Unix SMB/Netbios implementation.
+ * Version 1.9.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include "includes.h"
+
+extern int DEBUGLEVEL;
+
+
+
+/*******************************************************************
+reads or writes a UTIME type.
+********************************************************************/
+void smb_io_utime(char *desc, UTIME *t, prs_struct *ps, int depth)
+{
+ if (t == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_utime");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32 ("time", ps, depth, &(t->time));
+}
+
+/*******************************************************************
+reads or writes an NTTIME structure.
+********************************************************************/
+void smb_io_time(char *desc, NTTIME *nttime, prs_struct *ps, int depth)
+{
+ if (nttime == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_time");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("low ", ps, depth, &(nttime->low )); /* low part */
+ prs_uint32("high", ps, depth, &(nttime->high)); /* high part */
+}
+
+/*******************************************************************
+reads or writes a LOOKUP_LEVEL structure.
+********************************************************************/
+void smb_io_lookup_level(char *desc, LOOKUP_LEVEL *level, prs_struct *ps, int depth)
+{
+ if (level == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_lookup_level");
+ depth++;
+
+ prs_align(ps);
+ prs_uint16("value", ps, depth, &(level->value));
+ prs_align(ps);
+}
+
+/*******************************************************************
+gets an enumeration handle from an ENUM_HND structure.
+********************************************************************/
+uint32 get_enum_hnd(ENUM_HND *enh)
+{
+ return (enh && enh->ptr_hnd != 0) ? enh->handle : 0;
+}
+
+/*******************************************************************
+makes an ENUM_HND structure.
+********************************************************************/
+void make_enum_hnd(ENUM_HND *enh, uint32 hnd)
+{
+ if (enh == NULL) return;
+
+ DEBUG(5,("smb_io_enum_hnd\n"));
+
+ enh->ptr_hnd = (hnd != 0) ? 1 : 0;
+ enh->handle = hnd;
+}
+
+/*******************************************************************
+reads or writes an ENUM_HND structure.
+********************************************************************/
+void smb_io_enum_hnd(char *desc, ENUM_HND *hnd, prs_struct *ps, int depth)
+{
+ if (hnd == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_enum_hnd");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_hnd", ps, depth, &(hnd->ptr_hnd)); /* pointer */
+ if (hnd->ptr_hnd != 0)
+ {
+ prs_uint32("handle ", ps, depth, &(hnd->handle )); /* enum handle */
+ }
+}
+
+/*******************************************************************
+creates a DOM_SID structure.
+
+BIG NOTE: this function only does SIDS where the identauth is not >= 2^32
+identauth >= 2^32 can be detected because it will be specified in hex
+
+********************************************************************/
+void make_dom_sid(DOM_SID *sid, char *str_sid)
+{
+ pstring domsid;
+ int identauth;
+ char *p;
+
+ if (sid == NULL) return;
+
+ if (domsid == NULL)
+ {
+ DEBUG(4,("netlogon domain SID: none\n"));
+ sid->sid_rev_num = 0;
+ sid->num_auths = 0;
+ return;
+ }
+
+ pstrcpy(domsid, str_sid);
+
+ DEBUG(4,("make_dom_sid %d SID: %s\n", __LINE__, domsid));
+
+ /* assume, but should check, that domsid starts "S-" */
+ p = strtok(domsid+2,"-");
+ sid->sid_rev_num = atoi(p);
+
+ /* identauth in decimal should be < 2^32 */
+ /* identauth in hex should be >= 2^32 */
+ identauth = atoi(strtok(0,"-"));
+
+ DEBUG(4,("netlogon rev %d\n", sid->sid_rev_num));
+ DEBUG(4,("netlogon %s ia %d\n", p, identauth));
+
+ sid->id_auth[0] = 0;
+ sid->id_auth[1] = 0;
+ sid->id_auth[2] = (identauth & 0xff000000) >> 24;
+ sid->id_auth[3] = (identauth & 0x00ff0000) >> 16;
+ sid->id_auth[4] = (identauth & 0x0000ff00) >> 8;
+ sid->id_auth[5] = (identauth & 0x000000ff);
+
+ sid->num_auths = 0;
+
+ while ((p = strtok(0, "-")) != NULL && sid->num_auths < MAXSUBAUTHS)
+ {
+ sid->sub_auths[sid->num_auths++] = atoi(p);
+ }
+
+ DEBUG(4,("make_dom_sid: %d SID: %s\n", __LINE__, domsid));
+}
+
+/*******************************************************************
+reads or writes a DOM_SID structure.
+********************************************************************/
+void smb_io_dom_sid(char *desc, DOM_SID *sid, prs_struct *ps, int depth)
+{
+ int i;
+
+ if (sid == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_dom_sid");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint8 ("sid_rev_num", ps, depth, &(sid->sid_rev_num));
+ prs_uint8 ("num_auths ", ps, depth, &(sid->num_auths));
+
+ for (i = 0; i < 6; i++)
+ {
+ fstring tmp;
+ sprintf(tmp, "id_auth[%d] ", i);
+ prs_uint8 (tmp, ps, depth, &(sid->id_auth[i]));
+ }
+
+ /* oops! XXXX should really issue a warning here... */
+ if (sid->num_auths > MAXSUBAUTHS) sid->num_auths = MAXSUBAUTHS;
+
+ prs_uint32s(False, "sub_auths ", ps, depth, sid->sub_auths, sid->num_auths);
+}
+
+/*******************************************************************
+creates a DOM_SID2 structure.
+********************************************************************/
+void make_dom_sid2(DOM_SID2 *sid, char *str_sid)
+{
+ make_dom_sid(&(sid->sid), str_sid);
+ sid->num_auths = sid->sid.num_auths;
+}
+
+/*******************************************************************
+reads or writes a DOM_SID2 structure.
+********************************************************************/
+void smb_io_dom_sid2(char *desc, DOM_SID2 *sid, prs_struct *ps, int depth)
+{
+ if (sid == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_dom_sid2");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_auths", ps, depth, &(sid->num_auths));
+
+ smb_io_dom_sid("sid", &(sid->sid), ps, depth);
+}
+
+/*******************************************************************
+creates a STRHDR structure.
+********************************************************************/
+void make_str_hdr(STRHDR *hdr, int max_len, int len, uint32 buffer)
+{
+ hdr->str_max_len = max_len;
+ hdr->str_str_len = len;
+ hdr->buffer = buffer;
+}
+
+/*******************************************************************
+reads or writes a STRHDR structure.
+********************************************************************/
+void smb_io_strhdr(char *desc, STRHDR *hdr, prs_struct *ps, int depth)
+{
+ if (hdr == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_strhdr");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint16("str_str_len", ps, depth, &(hdr->str_str_len));
+ prs_uint16("str_max_len", ps, depth, &(hdr->str_max_len));
+ prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
+
+ /* oops! XXXX maybe issue a warning that this is happening... */
+ if (hdr->str_max_len > MAX_STRINGLEN) hdr->str_max_len = MAX_STRINGLEN;
+ if (hdr->str_str_len > MAX_STRINGLEN) hdr->str_str_len = MAX_STRINGLEN;
+}
+
+/*******************************************************************
+creates a UNIHDR structure.
+********************************************************************/
+void make_uni_hdr(UNIHDR *hdr, int max_len, int len, uint32 buffer)
+{
+ hdr->uni_max_len = 2 * max_len;
+ hdr->uni_str_len = 2 * len;
+ hdr->buffer = buffer;
+}
+
+/*******************************************************************
+reads or writes a UNIHDR structure.
+********************************************************************/
+void smb_io_unihdr(char *desc, UNIHDR *hdr, prs_struct *ps, int depth)
+{
+ if (hdr == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_unihdr");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint16("uni_str_len", ps, depth, &(hdr->uni_str_len));
+ prs_uint16("uni_max_len", ps, depth, &(hdr->uni_max_len));
+ prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
+
+ /* oops! XXXX maybe issue a warning that this is happening... */
+ if (hdr->uni_max_len > MAX_UNISTRLEN) hdr->uni_max_len = MAX_UNISTRLEN;
+ if (hdr->uni_str_len > MAX_UNISTRLEN) hdr->uni_str_len = MAX_UNISTRLEN;
+}
+
+/*******************************************************************
+creates a UNIHDR2 structure.
+********************************************************************/
+void make_uni_hdr2(UNIHDR2 *hdr, int max_len, int len, uint16 terminate)
+{
+ make_uni_hdr(&(hdr->unihdr), max_len, len, terminate);
+ hdr->buffer = len > 0 ? 1 : 0;
+}
+
+/*******************************************************************
+reads or writes a UNIHDR2 structure.
+********************************************************************/
+void smb_io_unihdr2(char *desc, UNIHDR2 *hdr2, prs_struct *ps, int depth)
+{
+ if (hdr2 == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_unihdr2");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_unihdr("hdr", &(hdr2->unihdr), ps, depth);
+ prs_uint32("buffer", ps, depth, &(hdr2->buffer));
+}
+
+/*******************************************************************
+creates a UNISTR structure.
+********************************************************************/
+void make_unistr(UNISTR *str, char *buf)
+{
+ /* store the string (null-terminated copy) */
+ struni2(str->buffer, buf);
+}
+
+/*******************************************************************
+reads or writes a UNISTR structure.
+XXXX NOTE: UNISTR structures NEED to be null-terminated.
+********************************************************************/
+void smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int depth)
+{
+ if (uni == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_unistr");
+ depth++;
+
+ prs_align(ps);
+ prs_unistr("unistr", ps, depth, uni);
+}
+
+/*******************************************************************
+creates a UNINOTSTR2 structure.
+********************************************************************/
+void make_uninotstr2(UNINOTSTR2 *str, char *buf, int len)
+{
+ /* set up string lengths. add one if string is not null-terminated */
+ str->uni_max_len = (len+1)*2;
+ str->undoc = 0;
+ str->uni_buf_len = (len+1)*2;
+
+ /* store the string (null-terminated copy) */
+ struni2(str->buffer, buf);
+}
+
+/*******************************************************************
+reads or writes a UNINOTSTR2 structure.
+XXXX NOTE: UNISTR2 structures need NOT be null-terminated.
+ the uni_str_len member tells you how long the string is;
+ the uni_max_len member tells you how large the buffer is.
+********************************************************************/
+void smb_io_uninotstr2(char *desc, UNINOTSTR2 *uni2, uint32 buffer, prs_struct *ps, int depth)
+{
+ if (uni2 == NULL) return;
+
+ if (buffer)
+ {
+ prs_debug(ps, depth, desc, "smb_io_uninotstr2");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("uni_max_len", ps, depth, &(uni2->uni_max_len));
+ prs_uint32("undoc ", ps, depth, &(uni2->undoc ));
+ prs_uint32("uni_buf_len", ps, depth, &(uni2->uni_buf_len));
+
+ /* oops! XXXX maybe issue a warning that this is happening... */
+ if (uni2->uni_max_len > MAX_UNISTRLEN) uni2->uni_max_len = MAX_UNISTRLEN;
+ if (uni2->uni_buf_len > MAX_UNISTRLEN) uni2->uni_buf_len = MAX_UNISTRLEN;
+
+ /* buffer advanced by indicated length of string
+ NOT by searching for null-termination */
+ prs_uninotstr2(True, "buffer ", ps, depth, uni2);
+ }
+ else
+ {
+ prs_debug(ps, depth, desc, "smb_io_uninotstr2 - NULL");
+ depth++;
+ bzero(uni2, sizeof(*uni2));
+ }
+}
+
+/*******************************************************************
+creates a UNISTR2 structure: sets up the buffer, too
+********************************************************************/
+void make_buf_unistr2(UNISTR2 *str, uint32 *ptr, char *buf)
+{
+ if (buf != NULL)
+ {
+ *ptr = 1;
+ make_unistr2(str, buf, strlen(buf));
+ }
+ else
+ {
+ *ptr = 0;
+ make_unistr2(str, "", 0);
+ }
+}
+
+/*******************************************************************
+copies a UNISTR2 structure.
+********************************************************************/
+void copy_unistr2(UNISTR2 *str, UNISTR2 *from)
+{
+ /* set up string lengths. add one if string is not null-terminated */
+ str->uni_max_len = from->uni_max_len;
+ str->undoc = from->undoc;
+ str->uni_str_len = from->uni_str_len;
+
+ /* copy the string */
+ memcpy(str->buffer, from->buffer, sizeof(from->buffer));
+}
+
+/*******************************************************************
+creates a STRING2 structure.
+********************************************************************/
+void make_string2(STRING2 *str, char *buf, int len)
+{
+ /* set up string lengths. add one if string is not null-terminated */
+ str->str_max_len = len+1;
+ str->undoc = 0;
+ str->str_str_len = len+1;
+
+ /* store the string */
+ memcpy(str->buffer, buf, len);
+}
+
+/*******************************************************************
+reads or writes a STRING2 structure.
+XXXX NOTE: STRING2 structures need NOT be null-terminated.
+ the str_str_len member tells you how long the string is;
+ the str_max_len member tells you how large the buffer is.
+********************************************************************/
+void smb_io_string2(char *desc, STRING2 *str2, uint32 buffer, prs_struct *ps, int depth)
+{
+ if (str2 == NULL) return;
+
+ if (buffer)
+ {
+ prs_debug(ps, depth, desc, "smb_io_string2");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("str_max_len", ps, depth, &(str2->str_max_len));
+ prs_uint32("undoc ", ps, depth, &(str2->undoc ));
+ prs_uint32("str_str_len", ps, depth, &(str2->str_str_len));
+
+ /* oops! XXXX maybe issue a warning that this is happening... */
+ if (str2->str_max_len > MAX_STRINGLEN) str2->str_max_len = MAX_STRINGLEN;
+ if (str2->str_str_len > MAX_STRINGLEN) str2->str_str_len = MAX_STRINGLEN;
+
+ /* buffer advanced by indicated length of string
+ NOT by searching for null-termination */
+ prs_string2(True, "buffer ", ps, depth, str2);
+ }
+ else
+ {
+ prs_debug(ps, depth, desc, "smb_io_string2 - NULL");
+ depth++;
+ bzero(str2, sizeof(*str2));
+ }
+}
+
+/*******************************************************************
+creates a UNISTR2 structure.
+********************************************************************/
+void make_unistr2(UNISTR2 *str, char *buf, int len)
+{
+ /* set up string lengths. add one if string is not null-terminated */
+ str->uni_max_len = len+1;
+ str->undoc = 0;
+ str->uni_str_len = len+1;
+
+ /* store the string (null-terminated 8 bit chars into 16 bit chars) */
+ struni2(str->buffer, buf);
+}
+
+/*******************************************************************
+reads or writes a UNISTR2 structure.
+XXXX NOTE: UNISTR2 structures need NOT be null-terminated.
+ the uni_str_len member tells you how long the string is;
+ the uni_max_len member tells you how large the buffer is.
+********************************************************************/
+void smb_io_unistr2(char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct *ps, int depth)
+{
+ if (uni2 == NULL) return;
+
+ if (buffer)
+ {
+ prs_debug(ps, depth, desc, "smb_io_unistr2");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("uni_max_len", ps, depth, &(uni2->uni_max_len));
+ prs_uint32("undoc ", ps, depth, &(uni2->undoc ));
+ prs_uint32("uni_str_len", ps, depth, &(uni2->uni_str_len));
+
+ /* oops! XXXX maybe issue a warning that this is happening... */
+ if (uni2->uni_max_len > MAX_UNISTRLEN) uni2->uni_max_len = MAX_UNISTRLEN;
+ if (uni2->uni_str_len > MAX_UNISTRLEN) uni2->uni_str_len = MAX_UNISTRLEN;
+
+ /* buffer advanced by indicated length of string
+ NOT by searching for null-termination */
+ prs_unistr2(True, "buffer ", ps, depth, uni2);
+ }
+ else
+ {
+ prs_debug(ps, depth, desc, "smb_io_unistr2 - NULL");
+ depth++;
+ bzero(uni2, sizeof(*uni2));
+ }
+}
+
+/*******************************************************************
+creates a DOM_RID2 structure.
+********************************************************************/
+void make_dom_rid2(DOM_RID2 *rid2, uint32 rid)
+{
+ rid2->type = 0x5;
+ rid2->undoc = 0x5;
+ rid2->rid = rid;
+ rid2->rid_idx = 0;
+}
+
+/*******************************************************************
+reads or writes a DOM_RID2 structure.
+********************************************************************/
+void smb_io_dom_rid2(char *desc, DOM_RID2 *rid2, prs_struct *ps, int depth)
+{
+ if (rid2 == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_dom_rid2");
+ depth++;
+
+ prs_align(ps);
+
+ /* should be value 5, so enforce it */
+ rid2->type = 5;
+
+ /* should be value 5, so enforce it */
+ rid2->undoc = 5;
+
+ prs_uint32("type ", ps, depth, &(rid2->type));
+ prs_uint32("undoc ", ps, depth, &(rid2->undoc ));
+ prs_uint32("rid ", ps, depth, &(rid2->rid ));
+ prs_uint32("rid_idx", ps, depth, &(rid2->rid_idx ));
+}
+
+/*******************************************************************
+creates a DOM_RID3 structure.
+********************************************************************/
+void make_dom_rid3(DOM_RID3 *rid3, uint32 rid)
+{
+ rid3->rid = rid;
+ rid3->type1 = 0x1;
+ rid3->ptr_type = 0x1; /* non-zero, basically. */
+ rid3->type2 = 0x1;
+}
+
+/*******************************************************************
+reads or writes a DOM_RID3 structure.
+********************************************************************/
+void smb_io_dom_rid3(char *desc, DOM_RID3 *rid3, prs_struct *ps, int depth)
+{
+ if (rid3 == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_dom_rid3");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("rid ", ps, depth, &(rid3->rid ));
+ prs_uint32("type1 ", ps, depth, &(rid3->type1 ));
+ prs_uint32("ptr_type", ps, depth, &(rid3->ptr_type));
+ prs_uint32("type2 ", ps, depth, &(rid3->type2 ));
+}
+
+/*******************************************************************
+creates a DOM_RID4 structure.
+********************************************************************/
+void make_dom_rid4(DOM_RID4 *rid4, uint16 unknown, uint16 attr, uint32 rid)
+{
+ rid4->unknown = unknown;
+ rid4->attr = attr;
+ rid4->rid = rid;
+}
+
+/*******************************************************************
+reads or writes a DOM_RID4 structure.
+********************************************************************/
+void smb_io_dom_rid4(char *desc, DOM_RID4 *rid4, prs_struct *ps, int depth)
+{
+ if (rid4 == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_dom_rid4. XXXX !check size of unknown! XXXX");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("unknown", ps, depth, &(rid4->unknown));
+ prs_uint16("attr ", ps, depth, &(rid4->attr ));
+ prs_uint32("rid ", ps, depth, &(rid4->rid ));
+}
+
+/*******************************************************************
+makes a DOM_CLNT_SRV structure.
+********************************************************************/
+void make_clnt_srv(DOM_CLNT_SRV *log, char *logon_srv, char *comp_name)
+{
+ if (log == NULL) return;
+
+ DEBUG(5,("make_clnt_srv: %d\n", __LINE__));
+
+ if (logon_srv != NULL)
+ {
+ log->undoc_buffer = 1;
+ make_unistr2(&(log->uni_logon_srv), logon_srv, strlen(logon_srv));
+ }
+ else
+ {
+ log->undoc_buffer = 0;
+ }
+
+ if (comp_name != NULL)
+ {
+ log->undoc_buffer2 = 1;
+ make_unistr2(&(log->uni_comp_name), comp_name, strlen(comp_name));
+ }
+ else
+ {
+ log->undoc_buffer2 = 0;
+ }
+}
+
+/*******************************************************************
+reads or writes a DOM_CLNT_SRV structure.
+********************************************************************/
+void smb_io_clnt_srv(char *desc, DOM_CLNT_SRV *log, prs_struct *ps, int depth)
+{
+ if (log == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_clnt_srv");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("undoc_buffer ", ps, depth, &(log->undoc_buffer ));
+ if (log->undoc_buffer != 0)
+ {
+ smb_io_unistr2("unistr2", &(log->uni_logon_srv), log->undoc_buffer, ps, depth);
+ }
+
+ prs_align(ps);
+
+ prs_uint32("undoc_buffer2", ps, depth, &(log->undoc_buffer2));
+ if (log->undoc_buffer2 != 0)
+ {
+ smb_io_unistr2("unistr2", &(log->uni_comp_name), log->undoc_buffer2, ps, depth);
+ }
+}
+
+/*******************************************************************
+makes a DOM_LOG_INFO structure.
+********************************************************************/
+void make_log_info(DOM_LOG_INFO *log, char *logon_srv, char *acct_name,
+ uint16 sec_chan, char *comp_name)
+{
+ if (log == NULL) return;
+
+ DEBUG(5,("make_log_info %d\n", __LINE__));
+
+ log->undoc_buffer = 1;
+
+ make_unistr2(&(log->uni_logon_srv), logon_srv, strlen(logon_srv));
+ make_unistr2(&(log->uni_acct_name), acct_name, strlen(acct_name));
+
+ log->sec_chan = sec_chan;
+
+ make_unistr2(&(log->uni_comp_name), comp_name, strlen(comp_name));
+}
+
+/*******************************************************************
+reads or writes a DOM_LOG_INFO structure.
+********************************************************************/
+void smb_io_log_info(char *desc, DOM_LOG_INFO *log, prs_struct *ps, int depth)
+{
+ if (log == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_log_info");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("undoc_buffer", ps, depth, &(log->undoc_buffer));
+
+ smb_io_unistr2("unistr2", &(log->uni_logon_srv), True, ps, depth);
+ smb_io_unistr2("unistr2", &(log->uni_acct_name), True, ps, depth);
+
+ prs_uint16("sec_chan", ps, depth, &(log->sec_chan));
+
+ smb_io_unistr2("unistr2", &(log->uni_comp_name), True, ps, depth);
+}
+
+/*******************************************************************
+reads or writes a DOM_CHAL structure.
+********************************************************************/
+void smb_io_chal(char *desc, DOM_CHAL *chal, prs_struct *ps, int depth)
+{
+ if (chal == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_chal");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint8s (False, "data", ps, depth, chal->data, 8);
+}
+
+/*******************************************************************
+reads or writes a DOM_CRED structure.
+********************************************************************/
+void smb_io_cred(char *desc, DOM_CRED *cred, prs_struct *ps, int depth)
+{
+ if (cred == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_cred");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_chal ("", &(cred->challenge), ps, depth);
+ smb_io_utime("", &(cred->timestamp), ps, depth);
+}
+
+/*******************************************************************
+makes a DOM_CLNT_INFO2 structure.
+********************************************************************/
+void make_clnt_info2(DOM_CLNT_INFO2 *clnt,
+ char *logon_srv, char *comp_name,
+ DOM_CRED *clnt_cred)
+{
+ if (clnt == NULL) return;
+
+ DEBUG(5,("make_clnt_info: %d\n", __LINE__));
+
+ make_clnt_srv(&(clnt->login), logon_srv, comp_name);
+
+ if (clnt_cred != NULL)
+ {
+ clnt->ptr_cred = 1;
+ memcpy(&(clnt->cred), clnt_cred, sizeof(clnt->cred));
+ }
+ else
+ {
+ clnt->ptr_cred = 0;
+ }
+}
+
+/*******************************************************************
+reads or writes a DOM_CLNT_INFO2 structure.
+********************************************************************/
+void smb_io_clnt_info2(char *desc, DOM_CLNT_INFO2 *clnt, prs_struct *ps, int depth)
+{
+ if (clnt == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_clnt_info2");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_clnt_srv("", &(clnt->login), ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("ptr_cred", ps, depth, &(clnt->ptr_cred));
+ smb_io_cred ("", &(clnt->cred ), ps, depth);
+}
+
+/*******************************************************************
+makes a DOM_CLNT_INFO structure.
+********************************************************************/
+void make_clnt_info(DOM_CLNT_INFO *clnt,
+ char *logon_srv, char *acct_name,
+ uint16 sec_chan, char *comp_name,
+ DOM_CRED *cred)
+{
+ if (clnt == NULL || cred == NULL) return;
+
+ DEBUG(5,("make_clnt_info\n"));
+
+ make_log_info(&(clnt->login), logon_srv, acct_name, sec_chan, comp_name);
+ memcpy(&(clnt->cred), cred, sizeof(clnt->cred));
+}
+
+/*******************************************************************
+reads or writes a DOM_CLNT_INFO structure.
+********************************************************************/
+void smb_io_clnt_info(char *desc, DOM_CLNT_INFO *clnt, prs_struct *ps, int depth)
+{
+ if (clnt == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_clnt_info");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_log_info("", &(clnt->login), ps, depth);
+ smb_io_cred ("", &(clnt->cred ), ps, depth);
+}
+
+/*******************************************************************
+makes a DOM_LOGON_ID structure.
+********************************************************************/
+void make_logon_id(DOM_LOGON_ID *log, uint32 log_id_low, uint32 log_id_high)
+{
+ if (log == NULL) return;
+
+ DEBUG(5,("make_logon_id: %d\n", __LINE__));
+
+ log->low = log_id_low;
+ log->high = log_id_high;
+}
+
+/*******************************************************************
+reads or writes a DOM_LOGON_ID structure.
+********************************************************************/
+void smb_io_logon_id(char *desc, DOM_LOGON_ID *log, prs_struct *ps, int depth)
+{
+ if (log == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_logon_id");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("low ", ps, depth, &(log->low ));
+ prs_uint32("high", ps, depth, &(log->high));
+}
+
+/*******************************************************************
+makes an ARC4_OWF structure.
+********************************************************************/
+void make_arc4_owf(ARC4_OWF *hash, uint8 data[16])
+{
+ if (hash == NULL) return;
+
+ DEBUG(5,("make_arc4_owf: %d\n", __LINE__));
+
+ if (data != NULL)
+ {
+ memcpy(hash->data, data, sizeof(hash->data));
+ }
+ else
+ {
+ bzero(hash->data, sizeof(hash->data));
+ }
+}
+
+/*******************************************************************
+reads or writes an ARC4_OWF structure.
+********************************************************************/
+void smb_io_arc4_owf(char *desc, ARC4_OWF *hash, prs_struct *ps, int depth)
+{
+ if (hash == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_arc4_owf");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint8s (False, "data", ps, depth, hash->data, 16);
+}
+
+/*******************************************************************
+reads or writes a DOM_GID structure.
+********************************************************************/
+void smb_io_gid(char *desc, DOM_GID *gid, prs_struct *ps, int depth)
+{
+ if (gid == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_gid");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("g_rid", ps, depth, &(gid->g_rid));
+ prs_uint32("attr ", ps, depth, &(gid->attr ));
+}
+
+/*******************************************************************
+reads or writes an POLICY_HND structure.
+********************************************************************/
+void smb_io_pol_hnd(char *desc, POLICY_HND *pol, prs_struct *ps, int depth)
+{
+ if (pol == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_pol_hnd");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint8s (False, "data", ps, depth, pol->data, POL_HND_SIZE);
+}
+
+/*******************************************************************
+reads or writes a dom query structure.
+********************************************************************/
+void smb_io_dom_query_3(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
+{
+ smb_io_dom_query("", d_q, ps, depth);
+}
+
+/*******************************************************************
+reads or writes a dom query structure.
+********************************************************************/
+void smb_io_dom_query_5(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
+{
+ smb_io_dom_query("", d_q, ps, depth);
+}
+
+/*******************************************************************
+reads or writes a dom query structure.
+********************************************************************/
+void smb_io_dom_query(char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth)
+{
+ if (d_q == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_dom_query");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint16("uni_dom_max_len", ps, depth, &(d_q->uni_dom_max_len)); /* domain name string length * 2 */
+ prs_uint16("uni_dom_str_len", ps, depth, &(d_q->uni_dom_str_len)); /* domain name string length * 2 */
+
+ prs_uint32("buffer_dom_name", ps, depth, &(d_q->buffer_dom_name)); /* undocumented domain name string buffer pointer */
+ prs_uint32("buffer_dom_sid ", ps, depth, &(d_q->buffer_dom_sid )); /* undocumented domain SID string buffer pointer */
+
+ smb_io_unistr2("unistr2", &(d_q->uni_domain_name), d_q->buffer_dom_name, ps, depth); /* domain name (unicode string) */
+
+ if (d_q->buffer_dom_sid != 0)
+ {
+ smb_io_dom_sid2("", &(d_q->dom_sid), ps, depth); /* domain SID */
+ }
+ else
+ {
+ bzero(&(d_q->dom_sid), sizeof(d_q->dom_sid));
+ }
+}
+
+/*******************************************************************
+reads or writes a DOM_NAME structure.
+********************************************************************/
+void smb_io_dom_name(char *desc, DOM_NAME *name, prs_struct *ps, int depth)
+{
+ if (name == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_dom_name");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("uni_str_len", ps, depth, &(name->uni_str_len));
+
+ /* don't know if len is specified by uni_str_len member... */
+ /* assume unicode string is unicode-null-terminated, instead */
+
+ smb_io_unistr("", &(name->str), ps, depth);
+}
+
+
diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c
new file mode 100644
index 0000000000..69d6ac08ed
--- /dev/null
+++ b/source3/rpc_parse/parse_net.c
@@ -0,0 +1,1147 @@
+/*
+ * Unix SMB/Netbios implementation.
+ * Version 1.9.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "includes.h"
+#include "nterr.h"
+
+extern int DEBUGLEVEL;
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void net_io_neg_flags(char *desc, NEG_FLAGS *neg, prs_struct *ps, int depth)
+{
+ if (neg == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_neg_flags");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("neg_flags", ps, depth, &(neg->neg_flags));
+}
+
+/*******************************************************************
+creates a NETLOGON_INFO_3 structure.
+********************************************************************/
+void make_netinfo_3(NETLOGON_INFO_3 *info, uint32 flags, uint32 logon_attempts)
+{
+ info->flags = flags;
+ info->logon_attempts = logon_attempts;
+ info->reserved_1 = 0x0;
+ info->reserved_2 = 0x0;
+ info->reserved_3 = 0x0;
+ info->reserved_4 = 0x0;
+ info->reserved_5 = 0x0;
+}
+
+/*******************************************************************
+reads or writes a NETLOGON_INFO_3 structure.
+********************************************************************/
+void net_io_netinfo_3(char *desc, NETLOGON_INFO_3 *info, prs_struct *ps, int depth)
+{
+ if (info == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_netinfo_3");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("flags ", ps, depth, &(info->flags ));
+ prs_uint32("logon_attempts", ps, depth, &(info->logon_attempts));
+ prs_uint32("reserved_1 ", ps, depth, &(info->reserved_1 ));
+ prs_uint32("reserved_2 ", ps, depth, &(info->reserved_2 ));
+ prs_uint32("reserved_3 ", ps, depth, &(info->reserved_3 ));
+ prs_uint32("reserved_4 ", ps, depth, &(info->reserved_4 ));
+ prs_uint32("reserved_5 ", ps, depth, &(info->reserved_5 ));
+}
+
+
+/*******************************************************************
+creates a NETLOGON_INFO_1 structure.
+********************************************************************/
+void make_netinfo_1(NETLOGON_INFO_1 *info, uint32 flags, uint32 pdc_status)
+{
+ info->flags = flags;
+ info->pdc_status = pdc_status;
+}
+
+/*******************************************************************
+reads or writes a NETLOGON_INFO_1 structure.
+********************************************************************/
+void net_io_netinfo_1(char *desc, NETLOGON_INFO_1 *info, prs_struct *ps, int depth)
+{
+ if (info == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_netinfo_1");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("flags ", ps, depth, &(info->flags ));
+ prs_uint32("pdc_status", ps, depth, &(info->pdc_status));
+}
+
+/*******************************************************************
+creates a NETLOGON_INFO_2 structure.
+********************************************************************/
+void make_netinfo_2(NETLOGON_INFO_2 *info, uint32 flags, uint32 pdc_status,
+ uint32 tc_status, char *trusted_dc_name)
+{
+ int len_dc_name = strlen(trusted_dc_name);
+ info->flags = flags;
+ info->pdc_status = pdc_status;
+ info->ptr_trusted_dc_name = 1;
+ info->tc_status = tc_status;
+
+ if (trusted_dc_name != NULL)
+ {
+ make_unistr2(&(info->uni_trusted_dc_name), trusted_dc_name, len_dc_name);
+ }
+ else
+ {
+ make_unistr2(&(info->uni_trusted_dc_name), "", 1);
+ }
+}
+
+/*******************************************************************
+reads or writes a NETLOGON_INFO_2 structure.
+********************************************************************/
+void net_io_netinfo_2(char *desc, NETLOGON_INFO_2 *info, prs_struct *ps, int depth)
+{
+ if (info == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_netinfo_2");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("flags ", ps, depth, &(info->flags ));
+ prs_uint32("pdc_status ", ps, depth, &(info->pdc_status ));
+ prs_uint32("ptr_trusted_dc_name", ps, depth, &(info->ptr_trusted_dc_name));
+ prs_uint32("tc_status ", ps, depth, &(info->tc_status ));
+
+ if (info->ptr_trusted_dc_name != 0)
+ {
+ smb_io_unistr2("unistr2", &(info->uni_trusted_dc_name), info->ptr_trusted_dc_name, ps, depth);
+ }
+
+ prs_align(ps);
+}
+
+/*******************************************************************
+makes an NET_Q_LOGON_CTRL2 structure.
+********************************************************************/
+void make_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, char *server_name,
+ uint32 function_code)
+{
+ if (q_l == NULL) return;
+
+ DEBUG(5,("make_q_logon_ctrl2\n"));
+
+ q_l->ptr = 1; /* undocumented pointer */
+ make_unistr2 (&(q_l->uni_server_name), server_name, strlen(server_name));
+
+ q_l->function_code = function_code; /* should only be 0x1 */
+ q_l->query_level = function_code; /* should only be 0x1 */
+ q_l->switch_value = function_code; /* should only be 0x1 */
+}
+
+/*******************************************************************
+reads or writes an NET_Q_LOGON_CTRL2 structure.
+********************************************************************/
+void net_io_q_logon_ctrl2(char *desc, NET_Q_LOGON_CTRL2 *q_l, prs_struct *ps, int depth)
+{
+ if (q_l == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_q_logon_ctrl2");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr ", ps, depth, &(q_l->ptr ));
+
+ smb_io_unistr2 ("", &(q_l->uni_server_name), q_l->ptr, ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("function_code", ps, depth, &(q_l->function_code));
+ prs_uint32("query_level ", ps, depth, &(q_l->query_level ));
+ prs_uint32("switch_value ", ps, depth, &(q_l->switch_value ));
+}
+
+/*******************************************************************
+makes an NET_R_LOGON_CTRL2 structure.
+********************************************************************/
+void make_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level,
+ uint32 flags, uint32 pdc_status, uint32 logon_attempts,
+ uint32 tc_status, char *trusted_domain_name)
+{
+ if (r_l == NULL) return;
+
+ DEBUG(5,("make_r_logon_ctrl2\n"));
+
+ r_l->switch_value = query_level; /* should only be 0x1 */
+
+ switch (query_level)
+ {
+ case 1:
+ {
+ r_l->ptr = 1; /* undocumented pointer */
+ make_netinfo_1(&(r_l->logon.info1), flags, pdc_status);
+ r_l->status = 0;
+
+ break;
+ }
+ case 2:
+ {
+ r_l->ptr = 1; /* undocumented pointer */
+ make_netinfo_2(&(r_l->logon.info2), flags, pdc_status,
+ tc_status, trusted_domain_name);
+ r_l->status = 0;
+
+ break;
+ }
+ case 3:
+ {
+ r_l->ptr = 1; /* undocumented pointer */
+ make_netinfo_3(&(r_l->logon.info3), flags, logon_attempts);
+ r_l->status = 0;
+
+ break;
+ }
+ default:
+ {
+ DEBUG(2,("make_r_logon_ctrl2: unsupported switch value %d\n",
+ r_l->switch_value));
+ r_l->ptr = 0; /* undocumented pointer */
+
+ /* take a guess at an error code... */
+ r_l->status = NT_STATUS_INVALID_INFO_CLASS;
+
+ break;
+ }
+ }
+}
+
+/*******************************************************************
+reads or writes an NET_R_LOGON_CTRL2 structure.
+********************************************************************/
+void net_io_r_logon_ctrl2(char *desc, NET_R_LOGON_CTRL2 *r_l, prs_struct *ps, int depth)
+{
+ if (r_l == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_r_logon_ctrl2");
+ depth++;
+
+ prs_uint32("switch_value ", ps, depth, &(r_l->switch_value ));
+ prs_uint32("ptr ", ps, depth, &(r_l->ptr ));
+
+ if (r_l->ptr != 0)
+ {
+ switch (r_l->switch_value)
+ {
+ case 1:
+ {
+ net_io_netinfo_1("", &(r_l->logon.info1), ps, depth);
+ break;
+ }
+ case 2:
+ {
+ net_io_netinfo_2("", &(r_l->logon.info2), ps, depth);
+ break;
+ }
+ case 3:
+ {
+ net_io_netinfo_3("", &(r_l->logon.info3), ps, depth);
+ break;
+ }
+ default:
+ {
+ DEBUG(2,("net_io_r_logon_ctrl2: unsupported switch value %d\n",
+ r_l->switch_value));
+ break;
+ }
+ }
+ }
+
+ prs_uint32("status ", ps, depth, &(r_l->status ));
+}
+
+/*******************************************************************
+makes an NET_R_TRUST_DOM_LIST structure.
+********************************************************************/
+void make_r_trust_dom(NET_R_TRUST_DOM_LIST *r_t,
+ uint32 num_doms, char *dom_name)
+{
+ int i = 0;
+
+ if (r_t == NULL) return;
+
+ DEBUG(5,("make_r_trust_dom\n"));
+
+ for (i = 0; i < MAX_TRUST_DOMS; i++)
+ {
+ r_t->uni_trust_dom_name[i].uni_str_len = 0;
+ r_t->uni_trust_dom_name[i].uni_max_len = 0;
+ }
+ if (num_doms > MAX_TRUST_DOMS) num_doms = MAX_TRUST_DOMS;
+
+ for (i = 0; i < num_doms; i++)
+ {
+ fstring domain_name;
+ fstrcpy(domain_name, dom_name);
+ strupper(domain_name);
+ make_unistr2(&(r_t->uni_trust_dom_name[i]), domain_name, strlen(domain_name));
+ /* the use of UNISTR2 here is non-standard. */
+ r_t->uni_trust_dom_name[i].undoc = 0x1;
+ }
+
+ r_t->status = 0;
+}
+
+/*******************************************************************
+reads or writes an NET_R_TRUST_DOM_LIST structure.
+********************************************************************/
+void net_io_r_trust_dom(char *desc, NET_R_TRUST_DOM_LIST *r_t, prs_struct *ps, int depth)
+{
+ int i;
+ if (r_t == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_r_trust_dom");
+ depth++;
+
+ for (i = 0; i < MAX_TRUST_DOMS; i++)
+ {
+ if (r_t->uni_trust_dom_name[i].uni_str_len == 0) break;
+ smb_io_unistr2("", &(r_t->uni_trust_dom_name[i]), True, ps, depth);
+ }
+
+ prs_uint32("status", ps, depth, &(r_t->status));
+}
+
+/*******************************************************************
+makes an NET_Q_TRUST_DOM_LIST structure.
+********************************************************************/
+void make_q_trust_dom(NET_Q_TRUST_DOM_LIST *q_l, char *server_name,
+ uint32 function_code)
+{
+ if (q_l == NULL) return;
+
+ DEBUG(5,("make_q_trust_dom\n"));
+
+ make_unistr2 (&(q_l->uni_server_name), server_name, strlen(server_name));
+
+ q_l->function_code = function_code; /* should only be 0x31 */
+}
+
+/*******************************************************************
+reads or writes an NET_Q_TRUST_DOM_LIST structure.
+********************************************************************/
+void net_io_q_trust_dom(char *desc, NET_Q_TRUST_DOM_LIST *q_l, prs_struct *ps, int depth)
+{
+ if (q_l == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_q_trust_dom");
+ depth++;
+
+ prs_uint32("ptr ", ps, depth, &(q_l->ptr ));
+ smb_io_unistr2 ("", &(q_l->uni_server_name), q_l->ptr, ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("function_code", ps, depth, &(q_l->function_code));
+}
+
+/*******************************************************************
+makes an NET_Q_REQ_CHAL structure.
+********************************************************************/
+void make_q_req_chal(NET_Q_REQ_CHAL *q_c,
+ char *logon_srv, char *logon_clnt,
+ DOM_CHAL *clnt_chal)
+{
+ if (q_c == NULL) return;
+
+ DEBUG(5,("make_q_req_chal: %d\n", __LINE__));
+
+ q_c->undoc_buffer = 1; /* don't know what this buffer is */
+
+ make_unistr2(&(q_c->uni_logon_srv ), logon_srv , strlen(logon_srv ));
+ make_unistr2(&(q_c->uni_logon_clnt), logon_clnt, strlen(logon_clnt));
+
+ memcpy(q_c->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
+
+ DEBUG(5,("make_q_req_chal: %d\n", __LINE__));
+}
+
+/*******************************************************************
+reads or writes an NET_Q_REQ_CHAL structure.
+********************************************************************/
+void net_io_q_req_chal(char *desc, NET_Q_REQ_CHAL *q_c, prs_struct *ps, int depth)
+{
+ int old_align;
+ if (q_c == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_q_req_chal");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("undoc_buffer", ps, depth, &(q_c->undoc_buffer));
+
+ smb_io_unistr2("", &(q_c->uni_logon_srv), True, ps, depth); /* logon server unicode string */
+ smb_io_unistr2("", &(q_c->uni_logon_clnt), True, ps, depth); /* logon client unicode string */
+
+ old_align = ps->align;
+ ps->align = 0;
+ /* client challenge is _not_ aligned after the unicode strings */
+ smb_io_chal("", &(q_c->clnt_chal), ps, depth); /* client challenge */
+ ps->align = old_align;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void net_io_r_req_chal(char *desc, NET_R_REQ_CHAL *r_c, prs_struct *ps, int depth)
+{
+ if (r_c == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_r_req_chal");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_chal("", &(r_c->srv_chal), ps, depth); /* server challenge */
+
+ prs_uint32("status", ps, depth, &(r_c->status));
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void make_q_auth_2(NET_Q_AUTH_2 *q_a,
+ char *logon_srv, char *acct_name, uint16 sec_chan, char *comp_name,
+ DOM_CHAL *clnt_chal, uint32 clnt_flgs)
+{
+ if (q_a == NULL) return;
+
+ DEBUG(5,("make_q_auth_2: %d\n", __LINE__));
+
+ make_log_info(&(q_a->clnt_id), logon_srv, acct_name, sec_chan, comp_name);
+ memcpy(q_a->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
+ q_a->clnt_flgs.neg_flags = clnt_flgs;
+
+ DEBUG(5,("make_q_auth_2: %d\n", __LINE__));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void net_io_q_auth_2(char *desc, NET_Q_AUTH_2 *q_a, prs_struct *ps, int depth)
+{
+ int old_align;
+ if (q_a == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_q_auth_2");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_log_info ("", &(q_a->clnt_id), ps, depth); /* client identification info */
+ /* client challenge is _not_ aligned */
+ old_align = ps->align;
+ ps->align = 0;
+ smb_io_chal ("", &(q_a->clnt_chal), ps, depth); /* client-calculated credentials */
+ ps->align = old_align;
+ net_io_neg_flags("", &(q_a->clnt_flgs), ps, depth);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void net_io_r_auth_2(char *desc, NET_R_AUTH_2 *r_a, prs_struct *ps, int depth)
+{
+ if (r_a == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_r_auth_2");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_chal ("", &(r_a->srv_chal), ps, depth); /* server challenge */
+ net_io_neg_flags("", &(r_a->srv_flgs), ps, depth);
+
+ prs_uint32("status", ps, depth, &(r_a->status));
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void make_q_srv_pwset(NET_Q_SRV_PWSET *q_s, char sess_key[16],
+ char *logon_srv, char *acct_name, uint16 sec_chan, char *comp_name,
+ DOM_CRED *cred, char nt_cypher[16])
+{
+ if (q_s == NULL || cred == NULL) return;
+
+ DEBUG(5,("make_q_srv_pwset\n"));
+
+ make_clnt_info(&(q_s->clnt_id), logon_srv, acct_name, sec_chan, comp_name, cred);
+
+ memcpy(q_s->pwd, nt_cypher, sizeof(q_s->pwd));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void net_io_q_srv_pwset(char *desc, NET_Q_SRV_PWSET *q_s, prs_struct *ps, int depth)
+{
+ if (q_s == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_q_srv_pwset");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_clnt_info("", &(q_s->clnt_id), ps, depth); /* client identification/authentication info */
+ prs_uint8s (False, "pwd", ps, depth, q_s->pwd, 16); /* new password - undocumented */
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void net_io_r_srv_pwset(char *desc, NET_R_SRV_PWSET *r_s, prs_struct *ps, int depth)
+{
+ if (r_s == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_r_srv_pwset");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_cred("", &(r_s->srv_cred), ps, depth); /* server challenge */
+
+ prs_uint32("status", ps, depth, &(r_s->status));
+}
+
+
+/*************************************************************************
+ make DOM_SID2 array from a string containing multiple sids
+ *************************************************************************/
+static int make_dom_sid2s(char *sids_str, DOM_SID2 *sids, int max_sids)
+{
+ char *ptr;
+ pstring s2;
+ int count;
+
+ DEBUG(4,("make_dom_sid2s: %s\n", sids_str));
+
+ if (sids_str == NULL || *sids_str == 0) return 0;
+
+ for (count = 0, ptr = sids_str; next_token(&ptr, s2, NULL) && count < max_sids; count++)
+ {
+ make_dom_sid2(&sids[count], s2);
+ }
+
+ return count;
+}
+
+/*******************************************************************
+makes a NET_ID_INFO_1 structure.
+********************************************************************/
+void make_id_info1(NET_ID_INFO_1 *id, char *domain_name,
+ uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high,
+ char *user_name, char *wksta_name,
+ char sess_key[16],
+ unsigned char lm_cypher[16], unsigned char nt_cypher[16])
+{
+ int len_domain_name = strlen(domain_name);
+ int len_user_name = strlen(user_name );
+ int len_wksta_name = strlen(wksta_name );
+
+ unsigned char arc4_lm_owf[16];
+ unsigned char arc4_nt_owf[16];
+
+ if (id == NULL) return;
+
+ DEBUG(5,("make_id_info1: %d\n", __LINE__));
+
+ id->ptr_id_info1 = 1;
+
+ make_uni_hdr(&(id->hdr_domain_name), len_domain_name, len_domain_name, 4);
+
+ id->param_ctrl = param_ctrl;
+ make_logon_id(&(id->logon_id), log_id_low, log_id_high);
+
+ make_uni_hdr(&(id->hdr_user_name ), len_user_name , len_user_name , 4);
+ make_uni_hdr(&(id->hdr_wksta_name ), len_wksta_name , len_wksta_name , 4);
+
+#ifdef USE_ARCFOUR
+
+ if (lm_cypher && nt_cypher)
+ {
+ void arcfour(uint8 key[16], uint8 out[16], uint8 in[16]);
+ unsigned char arc4_key[16];
+#ifdef DEBUG_PASSWORD
+ DEBUG(100,("lm cypher:"));
+ dump_data(100, lm_cypher, 16);
+
+ DEBUG(100,("nt cypher:"));
+ dump_data(100, nt_cypher, 16);
+#endif
+
+ memset(arc4_key, 0, 16);
+ memcpy(arc4_key, sess_key, 16);
+
+ arcfour(arc4_key, arc4_lm_owf, lm_cypher);
+ arcfour(arc4_key, arc4_nt_owf, nt_cypher);
+
+#ifdef DEBUG_PASSWORD
+ DEBUG(100,("arcfour encrypt of lm owf password:"));
+ dump_data(100, arc4_lm_owf, 16);
+
+ DEBUG(100,("arcfour encrypt of nt owf password:"));
+ dump_data(100, arc4_nt_owf, 16);
+#endif
+ /* set up pointers to cypher blocks */
+ lm_cypher = arc4_lm_owf;
+ nt_cypher = arc4_nt_owf;
+ }
+
+#else
+
+ if (lm_cypher)
+ {
+ /* oops. can only send what-ever-it-is direct */
+ memcpy(arc4_lm_owf, lm_cypher, 16);
+ lm_cypher = arc4_lm_owf;
+ }
+ if (nt_cypher)
+ {
+ /* oops. can only send what-ever-it-is direct */
+ memcpy(arc4_nt_owf, nt_cypher, 16);
+ nt_cypher = arc4_nt_owf;
+ }
+
+#endif
+
+ make_arc4_owf(&(id->arc4_lm_owf), lm_cypher);
+ make_arc4_owf(&(id->arc4_nt_owf), nt_cypher);
+
+ make_unistr2(&(id->uni_domain_name), domain_name, len_domain_name);
+ make_unistr2(&(id->uni_user_name ), user_name , len_user_name );
+ make_unistr2(&(id->uni_wksta_name ), wksta_name , len_wksta_name );
+}
+
+/*******************************************************************
+reads or writes an NET_ID_INFO_1 structure.
+********************************************************************/
+void net_io_id_info1(char *desc, NET_ID_INFO_1 *id, prs_struct *ps, int depth)
+{
+ if (id == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_id_info1");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_id_info1", ps, depth, &(id->ptr_id_info1));
+
+ if (id->ptr_id_info1 != 0)
+ {
+ smb_io_unihdr("unihdr", &(id->hdr_domain_name), ps, depth);
+
+ prs_uint32("param_ctrl", ps, depth, &(id->param_ctrl));
+ smb_io_logon_id("", &(id->logon_id), ps, depth);
+
+ smb_io_unihdr("unihdr", &(id->hdr_user_name ), ps, depth);
+ smb_io_unihdr("unihdr", &(id->hdr_wksta_name ), ps, depth);
+
+ smb_io_arc4_owf("", &(id->arc4_lm_owf), ps, depth);
+ smb_io_arc4_owf("", &(id->arc4_nt_owf), ps, depth);
+
+ smb_io_unistr2("unistr2", &(id->uni_domain_name), id->hdr_domain_name.buffer, ps, depth);
+ smb_io_unistr2("unistr2", &(id->uni_user_name ), id->hdr_user_name.buffer, ps, depth);
+ smb_io_unistr2("unistr2", &(id->uni_wksta_name ), id->hdr_wksta_name.buffer, ps, depth);
+ }
+}
+
+/*******************************************************************
+makes a NET_ID_INFO_2 structure.
+********************************************************************/
+void make_id_info2(NET_ID_INFO_2 *id, char *domain_name,
+ uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high,
+ char *user_name, char *wksta_name,
+ unsigned char lm_challenge[8],
+ unsigned char lm_chal_resp[24],
+ unsigned char nt_chal_resp[24])
+{
+ int len_domain_name = strlen(domain_name);
+ int len_user_name = strlen(user_name );
+ int len_wksta_name = strlen(wksta_name );
+
+ unsigned char arc4_lm_owf[24];
+ unsigned char arc4_nt_owf[24];
+
+ if (id == NULL) return;
+
+ DEBUG(5,("make_id_info2: %d\n", __LINE__));
+
+ id->ptr_id_info2 = 1;
+
+ make_uni_hdr(&(id->hdr_domain_name), len_domain_name, len_domain_name, 4);
+
+ id->param_ctrl = param_ctrl;
+ make_logon_id(&(id->logon_id), log_id_low, log_id_high);
+
+ make_uni_hdr(&(id->hdr_user_name ), len_user_name , len_user_name , 4);
+ make_uni_hdr(&(id->hdr_wksta_name ), len_wksta_name , len_wksta_name , 4);
+
+ if (nt_chal_resp)
+ {
+ /* oops. can only send what-ever-it-is direct */
+ memcpy(arc4_nt_owf, nt_chal_resp, 24);
+ nt_chal_resp = arc4_nt_owf;
+ }
+ if (lm_chal_resp)
+ {
+ /* oops. can only send what-ever-it-is direct */
+ memcpy(arc4_lm_owf, lm_chal_resp, 24);
+ lm_chal_resp = arc4_lm_owf;
+ }
+
+ memcpy(&(id->lm_chal), lm_challenge, sizeof(id->lm_chal));
+ make_str_hdr(&(id->hdr_nt_chal_resp), 24, 24, nt_chal_resp != NULL ? 1 : 0);
+ make_str_hdr(&(id->hdr_lm_chal_resp), 24, 24, lm_chal_resp != NULL ? 1 : 0);
+
+ make_unistr2(&(id->uni_domain_name), domain_name, len_domain_name);
+ make_unistr2(&(id->uni_user_name ), user_name , len_user_name );
+ make_unistr2(&(id->uni_wksta_name ), wksta_name , len_wksta_name );
+
+ make_string2(&(id->nt_chal_resp ), nt_chal_resp , nt_chal_resp != NULL ? 24 : 0);
+ make_string2(&(id->lm_chal_resp ), lm_chal_resp , lm_chal_resp != NULL ? 24 : 0);
+}
+
+/*******************************************************************
+reads or writes an NET_ID_INFO_1 structure.
+********************************************************************/
+void net_io_id_info2(char *desc, NET_ID_INFO_2 *id, prs_struct *ps, int depth)
+{
+ if (id == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_id_info2");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_id_info2", ps, depth, &(id->ptr_id_info2));
+
+ if (id->ptr_id_info2 != 0)
+ {
+ smb_io_unihdr("unihdr", &(id->hdr_domain_name), ps, depth);
+
+ prs_uint32("param_ctrl", ps, depth, &(id->param_ctrl));
+ smb_io_logon_id("", &(id->logon_id), ps, depth);
+
+ smb_io_unihdr("unihdr", &(id->hdr_user_name ), ps, depth);
+ smb_io_unihdr("unihdr", &(id->hdr_wksta_name ), ps, depth);
+
+ prs_uint8s (False, "lm_chal", ps, depth, id->lm_chal, 8); /* lm 8 byte challenge */
+
+ smb_io_strhdr("hdr_nt_chal_resp", &(id->hdr_nt_chal_resp ), ps, depth);
+ smb_io_strhdr("hdr_lm_chal_resp", &(id->hdr_lm_chal_resp ), ps, depth);
+
+ smb_io_unistr2("uni_domain_name", &(id->uni_domain_name), id->hdr_domain_name .buffer, ps, depth);
+ smb_io_unistr2("uni_user_name ", &(id->uni_user_name ), id->hdr_user_name .buffer, ps, depth);
+ smb_io_unistr2("uni_wksta_name ", &(id->uni_wksta_name ), id->hdr_wksta_name .buffer, ps, depth);
+ smb_io_string2("nt_chal_resp" , &(id->nt_chal_resp) , id->hdr_nt_chal_resp.buffer, ps, depth);
+ smb_io_string2("lm_chal_resp" , &(id->lm_chal_resp) , id->hdr_lm_chal_resp.buffer, ps, depth);
+ }
+}
+
+
+/*******************************************************************
+makes a DOM_SAM_INFO structure.
+********************************************************************/
+void make_sam_info(DOM_SAM_INFO *sam,
+ char *logon_srv, char *comp_name, DOM_CRED *clnt_cred,
+ DOM_CRED *rtn_cred, uint16 logon_level,
+ NET_ID_INFO_CTR *ctr, uint16 validation_level)
+{
+ if (sam == NULL) return;
+
+ DEBUG(5,("make_sam_info: %d\n", __LINE__));
+
+ make_clnt_info2(&(sam->client), logon_srv, comp_name, clnt_cred);
+
+ if (rtn_cred != NULL)
+ {
+ sam->ptr_rtn_cred = 1;
+ memcpy(&(sam->rtn_cred), rtn_cred, sizeof(sam->rtn_cred));
+ }
+ else
+ {
+ sam->ptr_rtn_cred = 0;
+ }
+
+ sam->logon_level = logon_level;
+ sam->ctr = ctr;
+ sam->validation_level = validation_level;
+}
+
+/*******************************************************************
+reads or writes a DOM_SAM_INFO structure.
+********************************************************************/
+void net_io_id_info_ctr(char *desc, NET_ID_INFO_CTR *ctr, prs_struct *ps, int depth)
+{
+ if (ctr == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_sam_info");
+ depth++;
+
+ /* don't 4-byte align here! */
+
+ prs_uint16("switch_value ", ps, depth, &(ctr->switch_value));
+
+ switch (ctr->switch_value)
+ {
+ case 1:
+ {
+ net_io_id_info1("", &(ctr->auth.id1), ps, depth);
+ break;
+ }
+ case 2:
+ {
+ net_io_id_info2("", &(ctr->auth.id2), ps, depth);
+ break;
+ }
+ default:
+ {
+ /* PANIC! */
+ DEBUG(4,("smb_io_sam_info: unknown switch_value!\n"));
+ break;
+ }
+ }
+}
+
+/*******************************************************************
+reads or writes a DOM_SAM_INFO structure.
+********************************************************************/
+void smb_io_sam_info(char *desc, DOM_SAM_INFO *sam, prs_struct *ps, int depth)
+{
+ if (sam == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_sam_info");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_clnt_info2("", &(sam->client ), ps, depth);
+
+ prs_uint32("ptr_rtn_cred ", ps, depth, &(sam->ptr_rtn_cred));
+ smb_io_cred ("", &(sam->rtn_cred), ps, depth);
+
+ prs_uint16("logon_level ", ps, depth, &(sam->logon_level ));
+
+ if (sam->logon_level != 0 && sam->ctr != NULL)
+ {
+ net_io_id_info_ctr("logon_info", sam->ctr, ps, depth);
+ }
+
+ prs_uint16("validation_level", ps, depth, &(sam->validation_level));
+}
+
+/*************************************************************************
+ make_net_user_info3
+ *************************************************************************/
+void make_net_user_info3(NET_USER_INFO_3 *usr,
+
+ NTTIME *logon_time,
+ NTTIME *logoff_time,
+ NTTIME *kickoff_time,
+ NTTIME *pass_last_set_time,
+ NTTIME *pass_can_change_time,
+ NTTIME *pass_must_change_time,
+
+ char *user_name,
+ char *full_name,
+ char *logon_script,
+ char *profile_path,
+ char *home_dir,
+ char *dir_drive,
+
+ uint16 logon_count,
+ uint16 bad_pw_count,
+
+ uint32 user_id,
+ uint32 group_id,
+ uint32 num_groups,
+ DOM_GID *gids,
+ uint32 user_flgs,
+
+ char sess_key[16],
+
+ char *logon_srv,
+ char *logon_dom,
+
+ char *dom_sid,
+ char *other_sids)
+{
+ /* only cope with one "other" sid, right now. */
+ /* need to count the number of space-delimited sids */
+ int i;
+ int num_other_sids = 0;
+
+ int len_user_name = strlen(user_name );
+ int len_full_name = strlen(full_name );
+ int len_logon_script = strlen(logon_script);
+ int len_profile_path = strlen(profile_path);
+ int len_home_dir = strlen(home_dir );
+ int len_dir_drive = strlen(dir_drive );
+
+ int len_logon_srv = strlen(logon_srv);
+ int len_logon_dom = strlen(logon_dom);
+
+ usr->ptr_user_info = 1; /* yes, we're bothering to put USER_INFO data here */
+
+ usr->logon_time = *logon_time;
+ usr->logoff_time = *logoff_time;
+ usr->kickoff_time = *kickoff_time;
+ usr->pass_last_set_time = *pass_last_set_time;
+ usr->pass_can_change_time = *pass_can_change_time;
+ usr->pass_must_change_time = *pass_must_change_time;
+
+ make_uni_hdr(&(usr->hdr_user_name ), len_user_name , len_user_name , 4);
+ make_uni_hdr(&(usr->hdr_full_name ), len_full_name , len_full_name , 4);
+ make_uni_hdr(&(usr->hdr_logon_script), len_logon_script, len_logon_script, 4);
+ make_uni_hdr(&(usr->hdr_profile_path), len_profile_path, len_profile_path, 4);
+ make_uni_hdr(&(usr->hdr_home_dir ), len_home_dir , len_home_dir , 4);
+ make_uni_hdr(&(usr->hdr_dir_drive ), len_dir_drive , len_dir_drive , 4);
+
+ usr->logon_count = logon_count;
+ usr->bad_pw_count = bad_pw_count;
+
+ usr->user_id = user_id;
+ usr->group_id = group_id;
+ usr->num_groups = num_groups;
+ usr->buffer_groups = 1; /* indicates fill in groups, below, even if there are none */
+ usr->user_flgs = user_flgs;
+
+ if (sess_key != NULL)
+ {
+ memcpy(usr->user_sess_key, sess_key, sizeof(usr->user_sess_key));
+ }
+ else
+ {
+ bzero(usr->user_sess_key, sizeof(usr->user_sess_key));
+ }
+
+ make_uni_hdr(&(usr->hdr_logon_srv), len_logon_srv, len_logon_srv, 4);
+ make_uni_hdr(&(usr->hdr_logon_dom), len_logon_dom, len_logon_dom, 4);
+
+ usr->buffer_dom_id = dom_sid ? 1 : 0; /* yes, we're bothering to put a domain SID in */
+
+ bzero(usr->padding, sizeof(usr->padding));
+
+ num_other_sids = make_dom_sid2s(other_sids, usr->other_sids, LSA_MAX_SIDS);
+
+ usr->num_other_sids = num_other_sids;
+ usr->buffer_other_sids = num_other_sids != 0 ? 1 : 0;
+
+ make_unistr2(&(usr->uni_user_name ), user_name , len_user_name );
+ make_unistr2(&(usr->uni_full_name ), full_name , len_full_name );
+ make_unistr2(&(usr->uni_logon_script), logon_script, len_logon_script);
+ make_unistr2(&(usr->uni_profile_path), profile_path, len_profile_path);
+ make_unistr2(&(usr->uni_home_dir ), home_dir , len_home_dir );
+ make_unistr2(&(usr->uni_dir_drive ), dir_drive , len_dir_drive );
+
+ usr->num_groups2 = num_groups;
+ for (i = 0; i < num_groups; i++)
+ {
+ usr->gids[i] = gids[i];
+ }
+
+ make_unistr2(&(usr->uni_logon_srv), logon_srv, len_logon_srv);
+ make_unistr2(&(usr->uni_logon_dom), logon_dom, len_logon_dom);
+
+ make_dom_sid2(&(usr->dom_sid), dom_sid);
+ /* "other" sids are set up above */
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void net_io_user_info3(char *desc, NET_USER_INFO_3 *usr, prs_struct *ps, int depth)
+{
+ int i;
+
+ if (usr == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_lsa_user_info");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_user_info ", ps, depth, &(usr->ptr_user_info));
+
+ if (usr->ptr_user_info != 0)
+ {
+ smb_io_time("time", &(usr->logon_time) , ps, depth); /* logon time */
+ smb_io_time("time", &(usr->logoff_time) , ps, depth); /* logoff time */
+ smb_io_time("time", &(usr->kickoff_time) , ps, depth); /* kickoff time */
+ smb_io_time("time", &(usr->pass_last_set_time) , ps, depth); /* password last set time */
+ smb_io_time("time", &(usr->pass_can_change_time) , ps, depth); /* password can change time */
+ smb_io_time("time", &(usr->pass_must_change_time), ps, depth); /* password must change time */
+
+ smb_io_unihdr("unihdr", &(usr->hdr_user_name) , ps, depth); /* username unicode string header */
+ smb_io_unihdr("unihdr", &(usr->hdr_full_name) , ps, depth); /* user's full name unicode string header */
+ smb_io_unihdr("unihdr", &(usr->hdr_logon_script), ps, depth); /* logon script unicode string header */
+ smb_io_unihdr("unihdr", &(usr->hdr_profile_path), ps, depth); /* profile path unicode string header */
+ smb_io_unihdr("unihdr", &(usr->hdr_home_dir) , ps, depth); /* home directory unicode string header */
+ smb_io_unihdr("unihdr", &(usr->hdr_dir_drive) , ps, depth); /* home directory drive unicode string header */
+
+ prs_uint16("logon_count ", ps, depth, &(usr->logon_count )); /* logon count */
+ prs_uint16("bad_pw_count ", ps, depth, &(usr->bad_pw_count)); /* bad password count */
+
+ prs_uint32("user_id ", ps, depth, &(usr->user_id )); /* User ID */
+ prs_uint32("group_id ", ps, depth, &(usr->group_id )); /* Group ID */
+ prs_uint32("num_groups ", ps, depth, &(usr->num_groups )); /* num groups */
+ prs_uint32("buffer_groups ", ps, depth, &(usr->buffer_groups)); /* undocumented buffer pointer to groups. */
+ prs_uint32("user_flgs ", ps, depth, &(usr->user_flgs )); /* user flags */
+
+ prs_uint8s (False, "user_sess_key", ps, depth, usr->user_sess_key, 16); /* unused user session key */
+
+ smb_io_unihdr("unihdr", &(usr->hdr_logon_srv), ps, depth); /* logon server unicode string header */
+ smb_io_unihdr("unihdr", &(usr->hdr_logon_dom), ps, depth); /* logon domain unicode string header */
+
+ prs_uint32("buffer_dom_id ", ps, depth, &(usr->buffer_dom_id)); /* undocumented logon domain id pointer */
+ prs_uint8s (False, "padding ", ps, depth, usr->padding, 40); /* unused padding bytes? */
+
+ prs_uint32("num_other_sids", ps, depth, &(usr->num_other_sids)); /* 0 - num_sids */
+ prs_uint32("buffer_other_sids", ps, depth, &(usr->buffer_other_sids)); /* NULL - undocumented pointer to SIDs. */
+
+ smb_io_unistr2("unistr2", &(usr->uni_user_name) , usr->hdr_user_name .buffer, ps, depth); /* username unicode string */
+ smb_io_unistr2("unistr2", &(usr->uni_full_name) , usr->hdr_full_name .buffer, ps, depth); /* user's full name unicode string */
+ smb_io_unistr2("unistr2", &(usr->uni_logon_script), usr->hdr_logon_script.buffer, ps, depth); /* logon script unicode string */
+ smb_io_unistr2("unistr2", &(usr->uni_profile_path), usr->hdr_profile_path.buffer, ps, depth); /* profile path unicode string */
+ smb_io_unistr2("unistr2", &(usr->uni_home_dir) , usr->hdr_home_dir .buffer, ps, depth); /* home directory unicode string */
+ smb_io_unistr2("unistr2", &(usr->uni_dir_drive) , usr->hdr_dir_drive .buffer, ps, depth); /* home directory drive unicode string */
+
+ prs_align(ps);
+ prs_uint32("num_groups2 ", ps, depth, &(usr->num_groups2)); /* num groups */
+ for (i = 0; i < usr->num_groups2; i++)
+ {
+ smb_io_gid("", &(usr->gids[i]), ps, depth); /* group info */
+ }
+
+ smb_io_unistr2("unistr2", &( usr->uni_logon_srv), usr->hdr_logon_srv.buffer, ps, depth); /* logon server unicode string */
+ smb_io_unistr2("unistr2", &( usr->uni_logon_dom), usr->hdr_logon_srv.buffer, ps, depth); /* logon domain unicode string */
+
+ smb_io_dom_sid2("", &(usr->dom_sid), ps, depth); /* domain SID */
+
+ for (i = 0; i < usr->num_other_sids; i++)
+ {
+ smb_io_dom_sid2("", &(usr->other_sids[i]), ps, depth); /* other domain SIDs */
+ }
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void net_io_q_sam_logon(char *desc, NET_Q_SAM_LOGON *q_l, prs_struct *ps, int depth)
+{
+ if (q_l == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_q_sam_logon");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_sam_info("", &(q_l->sam_id), ps, depth); /* domain SID */
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void net_io_r_sam_logon(char *desc, NET_R_SAM_LOGON *r_l, prs_struct *ps, int depth)
+{
+ if (r_l == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_r_sam_logon");
+ depth++;
+
+ prs_uint32("buffer_creds", ps, depth, &(r_l->buffer_creds)); /* undocumented buffer pointer */
+ smb_io_cred("", &(r_l->srv_creds), ps, depth); /* server credentials. server time stamp appears to be ignored. */
+
+ prs_uint16("switch_value", ps, depth, &(r_l->switch_value));
+ prs_align(ps);
+
+ if (r_l->switch_value != 0)
+ {
+ net_io_user_info3("", r_l->user, ps, depth);
+ }
+
+ prs_uint32("auth_resp ", ps, depth, &(r_l->auth_resp)); /* 1 - Authoritative response; 0 - Non-Auth? */
+
+ prs_uint32("status ", ps, depth, &(r_l->status));
+
+ prs_align(ps);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void net_io_q_sam_logoff(char *desc, NET_Q_SAM_LOGOFF *q_l, prs_struct *ps, int depth)
+{
+ if (q_l == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_q_sam_logoff");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_sam_info("", &(q_l->sam_id), ps, depth); /* domain SID */
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void net_io_r_sam_logoff(char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps, int depth)
+{
+ if (r_l == NULL) return;
+
+ prs_debug(ps, depth, desc, "net_io_r_sam_logoff");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("buffer_creds", ps, depth, &(r_l->buffer_creds)); /* undocumented buffer pointer */
+ smb_io_cred("", &(r_l->srv_creds), ps, depth); /* server credentials. server time stamp appears to be ignored. */
+
+ prs_uint32("status ", ps, depth, &(r_l->status));
+}
+
+
diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c
new file mode 100644
index 0000000000..799bd1cc94
--- /dev/null
+++ b/source3/rpc_parse/parse_prs.c
@@ -0,0 +1,290 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Samba memory buffer functions
+ Copyright (C) Andrew Tridgell 1992-1997
+ Copyright (C) Luke Kenneth Casson Leighton 1996-1997
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+extern int DEBUGLEVEL;
+
+#include "includes.h"
+
+
+/*******************************************************************
+ debug output for parsing info.
+
+ XXXX side-effect of this function is to increase the debug depth XXXX
+
+ ********************************************************************/
+void prs_debug(prs_struct *ps, int depth, char *desc, char *fn_name)
+{
+ DEBUG(5+depth, ("%s%06x %s %s\n", tab_depth(depth), ps->offset, fn_name, desc));
+}
+
+/*******************************************************************
+ initialise a parse structure
+ ********************************************************************/
+void prs_init(prs_struct *ps, uint32 size,
+ uint8 align, uint32 margin,
+ BOOL io)
+{
+ ps->io = io;
+ ps->align = align;
+ ps->offset = 0;
+
+ ps->data = NULL;
+ mem_buf_init(&(ps->data), margin);
+
+ if (size != 0)
+ {
+ mem_alloc_data(ps->data, size);
+ ps->data->offset.start = 0;
+ ps->data->offset.end = 0xffffffff;
+ }
+}
+
+/*******************************************************************
+ initialise a parse structure
+ ********************************************************************/
+void prs_mem_free(prs_struct *ps)
+{
+ mem_buf_free(&(ps->data));
+}
+
+/*******************************************************************
+ align a pointer to a multiple of align_offset bytes. looks like it
+ will work for offsets of 0, 2 and 4...
+ ********************************************************************/
+void prs_align(prs_struct *ps)
+{
+ int mod = ps->offset & (ps->align-1);
+ if (ps->align != 0 && mod != 0)
+ {
+ ps->offset += ps->align - mod;
+ }
+}
+
+/*******************************************************************
+ attempt, if appropriate, to grow a data buffer.
+
+ depends on the data stream mode (io)
+ ********************************************************************/
+BOOL prs_grow(prs_struct *ps)
+{
+ return mem_grow_data(&(ps->data), ps->io, ps->offset);
+}
+
+
+/*******************************************************************
+ stream a uint8
+ ********************************************************************/
+BOOL prs_uint8(char *name, prs_struct *ps, int depth, uint8 *data8)
+{
+ char *q = mem_data(&(ps->data), ps->offset);
+ if (q == NULL) return False;
+
+ DBG_RW_CVAL(name, depth, ps->offset, ps->io, q, *data8)
+ ps->offset += 1;
+
+ return True;
+}
+
+/*******************************************************************
+ stream a uint16
+ ********************************************************************/
+BOOL prs_uint16(char *name, prs_struct *ps, int depth, uint16 *data16)
+{
+ char *q = mem_data(&(ps->data), ps->offset);
+ if (q == NULL) return False;
+
+ DBG_RW_SVAL(name, depth, ps->offset, ps->io, q, *data16)
+ ps->offset += 2;
+
+ return True;
+}
+
+/*******************************************************************
+ stream a uint32
+ ********************************************************************/
+BOOL prs_uint32(char *name, prs_struct *ps, int depth, uint32 *data32)
+{
+ char *q = mem_data(&(ps->data), ps->offset);
+ if (q == NULL) return False;
+
+ DBG_RW_IVAL(name, depth, ps->offset, ps->io, q, *data32)
+ ps->offset += 4;
+
+ return True;
+}
+
+
+/******************************************************************
+ stream an array of uint8s. length is number of uint8s
+ ********************************************************************/
+BOOL prs_uint8s(BOOL charmode, char *name, prs_struct *ps, int depth, uint8 *data8s, int len)
+{
+ char *q = mem_data(&(ps->data), ps->offset);
+ if (q == NULL) return False;
+
+ DBG_RW_PCVAL(charmode, name, depth, ps->offset, ps->io, q, data8s, len)
+ ps->offset += len;
+
+ return True;
+}
+
+/******************************************************************
+ stream an array of uint16s. length is number of uint16s
+ ********************************************************************/
+BOOL prs_uint16s(BOOL charmode, char *name, prs_struct *ps, int depth, uint16 *data16s, int len)
+{
+ char *q = mem_data(&(ps->data), ps->offset);
+ if (q == NULL) return False;
+
+ DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, q, data16s, len)
+ ps->offset += len * sizeof(uint16);
+
+ return True;
+}
+
+/******************************************************************
+ stream an array of uint32s. length is number of uint32s
+ ********************************************************************/
+BOOL prs_uint32s(BOOL charmode, char *name, prs_struct *ps, int depth, uint32 *data32s, int len)
+{
+ char *q = mem_data(&(ps->data), ps->offset);
+ if (q == NULL) return False;
+
+ DBG_RW_PIVAL(charmode, name, depth, ps->offset, ps->io, q, data32s, len)
+ ps->offset += len * sizeof(uint32);
+
+ return True;
+}
+
+/******************************************************************
+ stream a "not" unicode string, length/buffer specified separately,
+ in byte chars
+ ********************************************************************/
+BOOL prs_uninotstr2(BOOL charmode, char *name, prs_struct *ps, int depth, UNINOTSTR2 *str)
+{
+ char *q = mem_data(&(ps->data), ps->offset);
+ if (q == NULL) return False;
+
+ DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, q, str->buffer, str->uni_max_len)
+ ps->offset += str->uni_buf_len;
+
+ return True;
+}
+
+/******************************************************************
+ stream a string, length/buffer specified separately,
+ in uint8 chars.
+ ********************************************************************/
+BOOL prs_string2(BOOL charmode, char *name, prs_struct *ps, int depth, STRING2 *str)
+{
+ char *q = mem_data(&(ps->data), ps->offset);
+ if (q == NULL) return False;
+
+ DBG_RW_PCVAL(charmode, name, depth, ps->offset, ps->io, q, str->buffer, str->str_max_len)
+ ps->offset += str->str_str_len * sizeof(uint8);
+
+ return True;
+}
+
+/******************************************************************
+ stream a unicode string, length/buffer specified separately,
+ in uint16 chars.
+ ********************************************************************/
+BOOL prs_unistr2(BOOL charmode, char *name, prs_struct *ps, int depth, UNISTR2 *str)
+{
+ char *q = mem_data(&(ps->data), ps->offset);
+ if (q == NULL) return False;
+
+ DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, q, str->buffer, str->uni_max_len)
+ ps->offset += str->uni_str_len * sizeof(uint16);
+
+ return True;
+}
+
+/*******************************************************************
+ stream a unicode null-terminated string
+ ********************************************************************/
+BOOL prs_unistr(char *name, prs_struct *ps, int depth, UNISTR *str)
+{
+ char *q = mem_data(&(ps->data), ps->offset);
+ int i = 0;
+ uint8 *start = (uint8*)q;
+
+ if (q == NULL) return False;
+
+ do
+ {
+ RW_SVAL(ps->io, q, str->buffer[i],0);
+ q += 2;
+ i++;
+
+ } while ((i < sizeof(str->buffer) / sizeof(str->buffer[0])) &&
+ (str->buffer[i] != 0));
+
+ ps->offset += i*2;
+
+ dump_data(5+depth, start, ps->offset);
+
+ return True;
+}
+
+/*******************************************************************
+ stream a null-terminated string. len is strlen, and therefore does
+ not include the null-termination character.
+
+ len == 0 indicates variable length string
+ (up to max size of pstring - 1024 chars).
+
+ ********************************************************************/
+BOOL prs_string(char *name, prs_struct *ps, int depth, char *str, uint16 len)
+{
+ char *q = mem_data(&(ps->data), ps->offset);
+ uint8 *start = (uint8*)q;
+ int i = -1; /* start off at zero after 1st i++ */
+
+ if (q == NULL) return False;
+
+ do
+ {
+ i++;
+
+ if (i < len || len == 0)
+ {
+ RW_CVAL(ps->io, q, str[i],0);
+ }
+ else
+ {
+ uint8 dummy = 0;
+ RW_CVAL(ps->io, q, dummy,0);
+ }
+
+ q++;
+
+ } while (i < sizeof(pstring) && (len == 0 ? str[i] != 0 : i < len) );
+
+ ps->offset += i+1;
+
+ dump_data(5+depth, start, ps->offset);
+
+ return True;
+}
+
diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c
new file mode 100644
index 0000000000..d278b75f5d
--- /dev/null
+++ b/source3/rpc_parse/parse_reg.c
@@ -0,0 +1,335 @@
+/*
+ * Unix SMB/Netbios implementation.
+ * Version 1.9.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include "includes.h"
+
+extern int DEBUGLEVEL;
+
+
+/*******************************************************************
+creates a structure.
+********************************************************************/
+void make_reg_q_open_policy(REG_Q_OPEN_POLICY *r_q,
+ uint16 unknown_0, uint32 level, uint16 unknown_1)
+{
+ r_q->ptr = 1;
+ r_q->unknown_0 = unknown_0;
+ r_q->level = level;
+ r_q->unknown_1 = unknown_1;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void reg_io_q_open_policy(char *desc, REG_Q_OPEN_POLICY *r_q, prs_struct *ps, int depth)
+{
+ if (r_q == NULL) return;
+
+ prs_debug(ps, depth, desc, "reg_io_q_open_policy");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr ", ps, depth, &(r_q->ptr ));
+ if (r_q->ptr != 0)
+ {
+ prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0));
+ prs_uint32("level ", ps, depth, &(r_q->level ));
+ prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1));
+ }
+}
+
+
+/*******************************************************************
+creates a structure.
+********************************************************************/
+void make_reg_r_open_policy(REG_R_OPEN_POLICY *r_r,
+ POLICY_HND *pol, uint32 status)
+{
+ if (r_r == NULL) return;
+
+ memcpy(&(r_r->pol), pol, sizeof(r_r->pol));
+ r_r->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void reg_io_r_open_policy(char *desc, REG_R_OPEN_POLICY *r_r, prs_struct *ps, int depth)
+{
+ if (r_r == NULL) return;
+
+ prs_debug(ps, depth, desc, "reg_io_r_open_policy");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("", &(r_r->pol), ps, depth);
+
+ prs_uint32("status", ps, depth, &(r_r->status));
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void reg_io_q_close(char *desc, REG_Q_CLOSE *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "reg_io_q_unknown_1");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("", &(q_u->pol), ps, depth);
+ prs_align(ps);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void reg_io_r_close(char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "reg_io_r_unknown_1");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("", &(r_u->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+/*******************************************************************
+creates a structure.
+********************************************************************/
+void make_reg_q_info(REG_Q_INFO *r_q,
+ POLICY_HND *pol, char *product_type,
+ NTTIME *prod_time, uint8 major_version, uint8 minor_version,
+ uint32 unknown)
+{
+ int type_len = strlen(product_type);
+
+ memcpy(&(r_q->pol), pol, sizeof(r_q->pol));
+ make_uni_hdr(&(r_q->hdr_type), type_len, type_len, 1);
+ make_unistr2(&(r_q->uni_type), product_type, type_len);
+
+ r_q->ptr1 = 1;
+ memcpy(&(r_q->time), prod_time, sizeof(r_q->time));
+ r_q->major_version1 = major_version;
+ r_q->minor_version1 = minor_version;
+ bzero(&(r_q->pad1), sizeof(r_q->pad1));
+
+ r_q->ptr2 = 1;
+ r_q->major_version2 = major_version;
+ r_q->minor_version2 = minor_version;
+ bzero(&(r_q->pad2), sizeof(r_q->pad2));
+
+ r_q->ptr3 = 1;
+ r_q->unknown = unknown;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void reg_io_q_info(char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth)
+{
+ if (r_q == NULL) return;
+
+ prs_debug(ps, depth, desc, "reg_io_q_info");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("", &(r_q->pol), ps, depth);
+ smb_io_unihdr ("", &(r_q->hdr_type), ps, depth);
+ smb_io_unistr2("", &(r_q->uni_type), r_q->hdr_type.buffer, ps, depth);
+
+ prs_uint32("ptr1", ps, depth, &(r_q->ptr1));
+
+ if (r_q->ptr1 != 0)
+ {
+ smb_io_time("", &(r_q->time), ps, depth);
+ prs_uint8 ("major_version1", ps, depth, &(r_q->major_version1));
+ prs_uint8 ("minor_version1", ps, depth, &(r_q->minor_version1));
+ prs_uint8s(False, "pad1", ps, depth, r_q->pad1, sizeof(r_q->pad1));
+ }
+
+ prs_uint32("ptr2", ps, depth, &(r_q->ptr2));
+
+ if (r_q->ptr2 != 0)
+ {
+ prs_uint8 ("major_version2", ps, depth, &(r_q->major_version2));
+ prs_uint8 ("minor_version2", ps, depth, &(r_q->minor_version2));
+ prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2));
+ }
+
+ prs_uint32("ptr3", ps, depth, &(r_q->ptr3));
+
+ if (r_q->ptr3 != 0)
+ {
+ prs_uint32("unknown", ps, depth, &(r_q->unknown));
+ }
+}
+
+
+/*******************************************************************
+creates a structure.
+********************************************************************/
+void make_reg_r_info(REG_R_INFO *r_r,
+ uint32 level, char *os_type,
+ uint32 unknown_0, uint32 unknown_1,
+ uint32 status)
+{
+ int type_len = strlen(os_type);
+
+ r_r->ptr1 = 1;
+ r_r->level = level;
+
+ r_r->ptr_type = 1;
+ make_uninotstr2(&(r_r->uni_type), os_type, type_len);
+
+ r_r->ptr2 = 1;
+ r_r->unknown_0 = unknown_0;
+
+ r_r->ptr3 = 1;
+ r_r->unknown_1 = unknown_1;
+
+ r_r->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth)
+{
+ if (r_r == NULL) return;
+
+ prs_debug(ps, depth, desc, "reg_io_r_info");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr1", ps, depth, &(r_r->ptr1));
+
+ if (r_r->ptr1 != 0)
+ {
+ prs_uint32("level", ps, depth, &(r_r->level));
+
+ prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type));
+ smb_io_uninotstr2("", &(r_r->uni_type), r_r->ptr_type, ps, depth);
+ prs_align(ps);
+
+ prs_uint32("ptr2", ps, depth, &(r_r->ptr2));
+
+ if (r_r->ptr2 != 0)
+ {
+ prs_uint32("unknown_0", ps, depth, &(r_r->unknown_0));
+ }
+
+ prs_uint32("ptr3", ps, depth, &(r_r->ptr3));
+
+ if (r_r->ptr3 != 0)
+ {
+ prs_uint32("unknown_1", ps, depth, &(r_r->unknown_1));
+ }
+ }
+
+ prs_uint32("status", ps, depth, &(r_r->status));
+}
+
+
+/*******************************************************************
+creates a structure.
+********************************************************************/
+void make_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q,
+ POLICY_HND *pol, char *name,
+ uint32 unknown_0, uint32 unknown_1, uint16 unknown_2)
+{
+ int len_name = strlen(name);
+
+ memcpy(&(r_q->pol), pol, sizeof(r_q->pol));
+
+ make_uni_hdr(&(r_q->hdr_name), len_name, len_name, 1);
+ make_unistr2(&(r_q->uni_name), name, len_name);
+
+ r_q->unknown_0 = unknown_0;
+ r_q->unknown_1 = unknown_1;
+ r_q->unknown_2 = unknown_2;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void reg_io_q_open_entry(char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth)
+{
+ if (r_q == NULL) return;
+
+ prs_debug(ps, depth, desc, "reg_io_q_entry");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("", &(r_q->pol), ps, depth);
+ smb_io_unihdr ("", &(r_q->hdr_name), ps, depth);
+ smb_io_unistr2("", &(r_q->uni_name), r_q->hdr_name.buffer, ps, depth);
+
+ prs_uint32("unknown_0", ps, depth, &(r_q->unknown_0));
+ prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1));
+ prs_uint16("unknown_2", ps, depth, &(r_q->unknown_2));
+}
+
+
+/*******************************************************************
+creates a structure.
+********************************************************************/
+void make_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
+ POLICY_HND *pol, uint32 status)
+{
+ if (r_r == NULL) return;
+
+ memcpy(&(r_r->pol), pol, sizeof(r_r->pol));
+ r_r->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void reg_io_r_open_entry(char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth)
+{
+ if (r_r == NULL) return;
+
+ prs_debug(ps, depth, desc, "reg_io_r_open_entry");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("", &(r_r->pol), ps, depth);
+
+ prs_uint32("status", ps, depth, &(r_r->status));
+}
+
diff --git a/source3/rpc_parse/parse_rpc.c b/source3/rpc_parse/parse_rpc.c
new file mode 100644
index 0000000000..b025d3f1c8
--- /dev/null
+++ b/source3/rpc_parse/parse_rpc.c
@@ -0,0 +1,528 @@
+
+/*
+ * Unix SMB/Netbios implementation.
+ * Version 1.9.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include "includes.h"
+
+extern int DEBUGLEVEL;
+
+
+/*******************************************************************
+interface/version dce/rpc pipe identification
+********************************************************************/
+
+#define TRANS_SYNT_V2 \
+{ \
+ { \
+ 0x04, 0x5d, 0x88, 0x8a, \
+ 0xeb, 0x1c, 0xc9, 0x11, \
+ 0x9f, 0xe8, 0x08, 0x00, \
+ 0x2b, 0x10, 0x48, 0x60 \
+ }, 0x02 \
+} \
+
+#define SYNT_NETLOGON_V2 \
+{ \
+ { \
+ 0x04, 0x5d, 0x88, 0x8a, \
+ 0xeb, 0x1c, 0xc9, 0x11, \
+ 0x9f, 0xe8, 0x08, 0x00, \
+ 0x2b, 0x10, 0x48, 0x60 \
+ }, 0x02 \
+} \
+
+#define SYNT_WKSSVC_V1 \
+{ \
+ { \
+ 0x98, 0xd0, 0xff, 0x6b, \
+ 0x12, 0xa1, 0x10, 0x36, \
+ 0x98, 0x33, 0x46, 0xc3, \
+ 0xf8, 0x7e, 0x34, 0x5a \
+ }, 0x01 \
+} \
+
+#define SYNT_SRVSVC_V3 \
+{ \
+ { \
+ 0xc8, 0x4f, 0x32, 0x4b, \
+ 0x70, 0x16, 0xd3, 0x01, \
+ 0x12, 0x78, 0x5a, 0x47, \
+ 0xbf, 0x6e, 0xe1, 0x88 \
+ }, 0x03 \
+} \
+
+#define SYNT_LSARPC_V0 \
+{ \
+ { \
+ 0x78, 0x57, 0x34, 0x12, \
+ 0x34, 0x12, 0xcd, 0xab, \
+ 0xef, 0x00, 0x01, 0x23, \
+ 0x45, 0x67, 0x89, 0xab \
+ }, 0x00 \
+} \
+
+#define SYNT_SAMR_V1 \
+{ \
+ { \
+ 0x78, 0x57, 0x34, 0x12, \
+ 0x34, 0x12, 0xcd, 0xab, \
+ 0xef, 0x00, 0x01, 0x23, \
+ 0x45, 0x67, 0x89, 0xac \
+ }, 0x01 \
+} \
+
+#define SYNT_NETLOGON_V1 \
+{ \
+ { \
+ 0x78, 0x56, 0x34, 0x12, \
+ 0x34, 0x12, 0xcd, 0xab, \
+ 0xef, 0x00, 0x01, 0x23, \
+ 0x45, 0x67, 0xcf, 0xfb \
+ }, 0x01 \
+} \
+
+#define SYNT_WINREG_V1 \
+{ \
+ { \
+ 0x01, 0xd0, 0x8c, 0x33, \
+ 0x44, 0x22, 0xf1, 0x31, \
+ 0xaa, 0xaa, 0x90, 0x00, \
+ 0x38, 0x00, 0x10, 0x03 \
+ }, 0x01 \
+} \
+
+#define SYNT_NONE_V0 \
+{ \
+ { \
+ 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00 \
+ }, 0x00 \
+} \
+
+/* pipe string names */
+#define PIPE_SRVSVC "\\PIPE\\srvsvc"
+#define PIPE_SAMR "\\PIPE\\samr"
+#define PIPE_WINREG "\\PIPE\\winreg"
+#define PIPE_WKSSVC "\\PIPE\\wkssvc"
+#define PIPE_NETLOGON "\\PIPE\\NETLOGON"
+#define PIPE_NTLSA "\\PIPE\\ntlsa"
+#define PIPE_NTSVCS "\\PIPE\\ntsvcs"
+#define PIPE_LSASS "\\PIPE\\lsass"
+#define PIPE_LSARPC "\\PIPE\\lsarpc"
+
+struct pipe_id_info pipe_names [] =
+{
+ /* client pipe , abstract syntax , server pipe , transfer syntax */
+ { PIPE_LSARPC , SYNT_LSARPC_V0 , PIPE_LSASS , TRANS_SYNT_V2 },
+ { PIPE_SAMR , SYNT_SAMR_V1 , PIPE_LSASS , TRANS_SYNT_V2 },
+ { PIPE_NETLOGON, SYNT_NETLOGON_V1, PIPE_LSASS , TRANS_SYNT_V2 },
+ { PIPE_SRVSVC , SYNT_SRVSVC_V3 , PIPE_NTSVCS , TRANS_SYNT_V2 },
+ { PIPE_WKSSVC , SYNT_WKSSVC_V1 , PIPE_NTSVCS , TRANS_SYNT_V2 },
+ { PIPE_WINREG , SYNT_WINREG_V1 , PIPE_WINREG , TRANS_SYNT_V2 },
+ { NULL , SYNT_NONE_V0 , NULL , SYNT_NONE_V0 }
+};
+
+/*******************************************************************
+creates an RPC_HDR structure.
+********************************************************************/
+void make_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags,
+ uint32 call_id, int data_len, int auth_len)
+{
+ if (hdr == NULL) return;
+
+ hdr->major = 5; /* RPC version 5 */
+ hdr->minor = 0; /* minor version 0 */
+ hdr->pkt_type = pkt_type; /* RPC packet type */
+ hdr->flags = flags; /* dce/rpc flags */
+ hdr->pack_type = 0x10; /* packed data representation */
+ hdr->frag_len = data_len; /* fragment length, fill in later */
+ hdr->auth_len = auth_len; /* authentication length */
+ hdr->call_id = call_id; /* call identifier - match incoming RPC */
+}
+
+/*******************************************************************
+reads or writes an RPC_HDR structure.
+********************************************************************/
+void smb_io_rpc_hdr(char *desc, RPC_HDR *rpc, prs_struct *ps, int depth)
+{
+ if (rpc == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_rpc_hdr");
+ depth++;
+
+ prs_uint8 ("major ", ps, depth, &(rpc->major));
+ prs_uint8 ("minor ", ps, depth, &(rpc->minor));
+ prs_uint8 ("pkt_type ", ps, depth, &(rpc->pkt_type));
+ prs_uint8 ("flags ", ps, depth, &(rpc->flags));
+ prs_uint32("pack_type ", ps, depth, &(rpc->pack_type));
+ prs_uint16("frag_len ", ps, depth, &(rpc->frag_len));
+ prs_uint16("auth_len ", ps, depth, &(rpc->auth_len));
+ prs_uint32("call_id ", ps, depth, &(rpc->call_id));
+}
+
+/*******************************************************************
+creates an RPC_IFACE structure.
+********************************************************************/
+void make_rpc_iface(RPC_IFACE *ifc, char data[16], uint32 version)
+{
+ if (ifc == NULL || data == NULL) return;
+
+ memcpy(ifc->data, data, sizeof(ifc->data)); /* 16 bytes of number */
+ ifc->version = version; /* the interface number */
+}
+
+/*******************************************************************
+reads or writes an RPC_IFACE structure.
+********************************************************************/
+void smb_io_rpc_iface(char *desc, RPC_IFACE *ifc, prs_struct *ps, int depth)
+{
+ if (ifc == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_rpc_iface");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint8s (False, "data ", ps, depth, ifc->data, sizeof(ifc->data));
+ prs_uint32 ( "version", ps, depth, &(ifc->version));
+}
+
+/*******************************************************************
+creates an RPC_ADDR_STR structure.
+********************************************************************/
+void make_rpc_addr_str(RPC_ADDR_STR *str, char *name)
+{
+ if (str == NULL || name == NULL) return;
+
+ str->len = strlen(name) + 1;
+ fstrcpy(str->str, name);
+}
+
+/*******************************************************************
+reads or writes an RPC_ADDR_STR structure.
+********************************************************************/
+void smb_io_rpc_addr_str(char *desc, RPC_ADDR_STR *str, prs_struct *ps, int depth)
+{
+ if (str == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_rpc_addr_str");
+ depth++;
+ prs_align(ps);
+
+ prs_uint16 ( "len", ps, depth, &(str->len));
+ prs_uint8s (True, "str", ps, depth, (uchar*)str->str, str->len);
+}
+
+/*******************************************************************
+creates an RPC_HDR_BBA structure.
+********************************************************************/
+void make_rpc_hdr_bba(RPC_HDR_BBA *bba, uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid)
+{
+ if (bba == NULL) return;
+
+ bba->max_tsize = max_tsize; /* maximum transmission fragment size (0x1630) */
+ bba->max_rsize = max_rsize; /* max receive fragment size (0x1630) */
+ bba->assoc_gid = assoc_gid; /* associated group id (0x0) */
+}
+
+/*******************************************************************
+reads or writes an RPC_HDR_BBA structure.
+********************************************************************/
+void smb_io_rpc_hdr_bba(char *desc, RPC_HDR_BBA *rpc, prs_struct *ps, int depth)
+{
+ if (rpc == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_rpc_hdr_bba");
+ depth++;
+
+ prs_uint16("max_tsize", ps, depth, &(rpc->max_tsize));
+ prs_uint16("max_rsize", ps, depth, &(rpc->max_rsize));
+ prs_uint32("assoc_gid", ps, depth, &(rpc->assoc_gid));
+}
+
+/*******************************************************************
+creates an RPC_HDR_RB structure.
+********************************************************************/
+void make_rpc_hdr_rb(RPC_HDR_RB *rpc,
+ uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
+ uint32 num_elements, uint16 context_id, uint8 num_syntaxes,
+ RPC_IFACE *abstract, RPC_IFACE *transfer)
+{
+ if (rpc == NULL) return;
+
+ make_rpc_hdr_bba(&(rpc->bba), max_tsize, max_rsize, assoc_gid);
+
+ rpc->num_elements = num_elements ; /* the number of elements (0x1) */
+ rpc->context_id = context_id ; /* presentation context identifier (0x0) */
+ rpc->num_syntaxes = num_syntaxes ; /* the number of syntaxes (has always been 1?)(0x1) */
+
+ /* num and vers. of interface client is using */
+ memcpy(&(rpc->abstract), abstract, sizeof(rpc->abstract));
+
+ /* num and vers. of interface to use for replies */
+ memcpy(&(rpc->transfer), transfer, sizeof(rpc->transfer));
+}
+
+/*******************************************************************
+reads or writes an RPC_HDR_RB structure.
+********************************************************************/
+void smb_io_rpc_hdr_rb(char *desc, RPC_HDR_RB *rpc, prs_struct *ps, int depth)
+{
+ if (rpc == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_rpc_hdr_rb");
+ depth++;
+
+ smb_io_rpc_hdr_bba("", &(rpc->bba), ps, depth);
+
+ prs_uint32("num_elements", ps, depth, &(rpc->num_elements));
+ prs_uint16("context_id ", ps, depth, &(rpc->context_id ));
+ prs_uint8 ("num_syntaxes", ps, depth, &(rpc->num_syntaxes));
+
+ smb_io_rpc_iface("", &(rpc->abstract), ps, depth);
+ smb_io_rpc_iface("", &(rpc->transfer), ps, depth);
+}
+
+/*******************************************************************
+creates an RPC_RESULTS structure.
+
+lkclXXXX only one reason at the moment!
+
+********************************************************************/
+void make_rpc_results(RPC_RESULTS *res,
+ uint8 num_results, uint16 result, uint16 reason)
+{
+ if (res == NULL) return;
+
+ res->num_results = num_results; /* the number of results (0x01) */
+ res->result = result ; /* result (0x00 = accept) */
+ res->reason = reason ; /* reason (0x00 = no reason specified) */
+}
+
+/*******************************************************************
+reads or writes an RPC_RESULTS structure.
+
+lkclXXXX only one reason at the moment!
+
+********************************************************************/
+void smb_io_rpc_results(char *desc, RPC_RESULTS *res, prs_struct *ps, int depth)
+{
+ if (res == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_rpc_results");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint8 ("num_results", ps, depth, &(res->num_results));
+
+ prs_align(ps);
+
+ prs_uint16("result ", ps, depth, &(res->result ));
+ prs_uint16("reason ", ps, depth, &(res->reason ));
+}
+
+/*******************************************************************
+creates an RPC_HDR_BA structure.
+
+lkclXXXX only one reason at the moment!
+
+********************************************************************/
+void make_rpc_hdr_ba(RPC_HDR_BA *rpc,
+ uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
+ char *pipe_addr,
+ uint8 num_results, uint16 result, uint16 reason,
+ RPC_IFACE *transfer)
+{
+ if (rpc == NULL || transfer == NULL || pipe_addr == NULL) return;
+
+ make_rpc_hdr_bba (&(rpc->bba ), max_tsize, max_rsize, assoc_gid);
+ make_rpc_addr_str(&(rpc->addr), pipe_addr);
+ make_rpc_results (&(rpc->res ), num_results, result, reason);
+
+ /* the transfer syntax from the request */
+ memcpy(&(rpc->transfer), transfer, sizeof(rpc->transfer));
+}
+
+/*******************************************************************
+reads or writes an RPC_HDR_BA structure.
+********************************************************************/
+void smb_io_rpc_hdr_ba(char *desc, RPC_HDR_BA *rpc, prs_struct *ps, int depth)
+{
+ if (rpc == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_rpc_hdr_ba");
+ depth++;
+
+ smb_io_rpc_hdr_bba ("", &(rpc->bba) , ps, depth);
+ smb_io_rpc_addr_str("", &(rpc->addr) , ps, depth);
+ smb_io_rpc_results ("", &(rpc->res) , ps, depth);
+ smb_io_rpc_iface ("", &(rpc->transfer), ps, depth);
+}
+
+/*******************************************************************
+creates an RPC_HDR_RR structure.
+********************************************************************/
+void make_rpc_hdr_rr(RPC_HDR_RR *hdr, uint32 data_len, uint8 opnum)
+{
+ if (hdr == NULL) return;
+
+ hdr->alloc_hint = data_len - 0x18; /* allocation hint */
+ hdr->context_id = 0; /* presentation context identifier */
+ hdr->cancel_count = 0; /* cancel count */
+ hdr->opnum = opnum; /* opnum */
+ hdr->reserved = 0; /* 0 - reserved */
+}
+
+/*******************************************************************
+reads or writes an RPC_HDR_RR structure.
+********************************************************************/
+void smb_io_rpc_hdr_rr(char *desc, RPC_HDR_RR *rpc, prs_struct *ps, int depth)
+{
+ if (rpc == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_rpc_hdr_rr");
+ depth++;
+
+ prs_uint32("alloc_hint", ps, depth, &(rpc->alloc_hint));
+ prs_uint8 ("context_id", ps, depth, &(rpc->context_id));
+ prs_uint8 ("cancel_ct ", ps, depth, &(rpc->cancel_count));
+ prs_uint8 ("opnum ", ps, depth, &(rpc->opnum));
+ prs_uint8 ("reserved ", ps, depth, &(rpc->reserved));
+}
+
+/*******************************************************************
+creates an RPC_AUTH_NTLMSSP_REQ structure.
+********************************************************************/
+void make_rpc_auth_ntlmssp_req(RPC_AUTH_NTLMSSP_REQ *req,
+ fstring ntlmssp_str, uint32 ntlmssp_ver,
+ uint32 unknown_0, fstring myname, fstring domain)
+{
+ int len_myname = strlen(myname);
+ int len_domain = strlen(domain);
+
+ if (req == NULL) return;
+
+ fstrcpy(req->ntlmssp_str, ntlmssp_str); /* "NTLMSSP" */
+ req->ntlmssp_ver = ntlmssp_ver; /* 0x0000 0001 */
+
+ req->unknown_0 = unknown_0 ; /* 0x00b2b3 */
+ make_str_hdr(&req->hdr_myname, len_myname, len_myname, 1);
+ make_str_hdr(&req->hdr_domain, len_domain, len_domain, 1);
+
+ fstrcpy(req->myname, myname);
+ fstrcpy(req->domain, domain);
+}
+
+/*******************************************************************
+reads or writes an RPC_AUTH_NTLMSSP_REQ structure.
+********************************************************************/
+void smb_io_rpc_auth_ntlmssp_req(char *desc, RPC_AUTH_NTLMSSP_REQ *req, prs_struct *ps, int depth)
+{
+ if (req == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_req");
+ depth++;
+
+ prs_string("ntlmssp_str", ps, depth, req->ntlmssp_str, 0); /* "NTLMSSP" */
+ prs_uint32("ntlmssp_ver", ps, depth, &(req->ntlmssp_ver ));
+
+ prs_uint32("unknown_0 ", ps, depth, &(req->unknown_0 ));
+ smb_io_strhdr("hdr_myname", &(req->hdr_myname), ps, depth);
+ smb_io_strhdr("hdr_domain", &(req->hdr_domain), ps, depth);
+
+ prs_string("myname", ps, depth, req->myname, req->hdr_myname.str_str_len);
+ prs_string("domain", ps, depth, req->domain, req->hdr_domain.str_str_len);
+}
+
+/*******************************************************************
+creates an RPC_AUTH_NTLMSSP_RESP structure.
+********************************************************************/
+void make_rpc_auth_ntlmssp_resp(RPC_AUTH_NTLMSSP_RESP *rsp,
+ uint8 auth_type, uint8 auth_level, uint8 stub_type_len,
+ fstring ntlmssp_str, uint32 ntlmssp_ver,
+ uint32 unknown_1, uint32 unknown_2, uint32 unknown_3,
+ uint8 data[16])
+{
+ if (rsp == NULL) return;
+
+ rsp->auth_type = auth_type; /* nt lm ssp 0x0a */
+ rsp->auth_level = auth_level; /* 0x06 */
+ rsp->stub_type_len = stub_type_len; /* dunno. */
+ rsp->padding = 0; /* padding */
+
+ rsp->ptr_0 = 1; /* non-zero pointer to something */
+
+ fstrcpy(rsp->ntlmssp_str, ntlmssp_str); /* "NTLMSSP" */
+ rsp->ntlmssp_ver = ntlmssp_ver; /* 0x0000 0002 */
+
+ rsp->unknown_1 = unknown_1; /* 0x0000 0000 */
+ rsp->unknown_2 = unknown_2; /* 0x00b2b3 */
+ rsp->unknown_3 = unknown_3; /* 0x0082b1 */
+
+ memcpy(rsp->data, data, sizeof(rsp->data)); /* 0x10 bytes of something, 8 of which are zeros */
+}
+
+/*******************************************************************
+reads or writes an RPC_AUTH_NTLMSSP_RESP structure.
+********************************************************************/
+void smb_io_rpc_auth_ntlmssp_resp(char *desc, RPC_AUTH_NTLMSSP_RESP *rsp, prs_struct *ps, int depth)
+{
+ if (rsp == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_resp");
+ depth++;
+
+ prs_uint8("auth_type", ps, depth, &(rsp->auth_type)); /* nt lm ssp 0x0a */
+ prs_uint8("auth_level", ps, depth, &(rsp->auth_level));/* 0x06 */
+ prs_uint8("stub_type_len", ps, depth, &(rsp->stub_type_len));
+ prs_uint8("padding", ps, depth, &(rsp->padding));
+
+ prs_uint32("ptr_0", ps, depth, &(rsp->ptr_0 )); /* non-zero pointer to something */
+
+ prs_string("ntlmssp_str", ps, depth, rsp->ntlmssp_str, 0); /* "NTLMSSP" */
+ prs_uint32("ntlmssp_ver", ps, depth, &(rsp->ntlmssp_ver )); /* 0x0000 0002 */
+
+ prs_uint32("unknown_1", ps, depth, &(rsp->unknown_1)); /* 0x0000 0000 */
+ prs_uint32("unknown_2", ps, depth, &(rsp->unknown_2)); /* 0x00b2b3 */
+ prs_uint32("unknown_3", ps, depth, &(rsp->unknown_3)); /* 0x0082b1 */
+
+ prs_uint8s (False, "data", ps, depth, rsp->data, sizeof(rsp->data));
+}
+
+#if 0
+
+/* attached to the end of encrypted rpc requests and responses */
+/* RPC_AUTH_NTLMSSP_CHK */
+typedef struct rpc_auth_ntlmssp_chk_info
+{
+ uint32 ver; /* 0x1 */
+ uint8 data[12];
+
+} RPC_AUTH_NTLMSSP_CHK;
+
+#endif /* 0 */
+
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
new file mode 100644
index 0000000000..a72769d9c0
--- /dev/null
+++ b/source3/rpc_parse/parse_samr.c
@@ -0,0 +1,2796 @@
+/*
+ * Unix SMB/Netbios implementation.
+ * Version 1.9.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include "includes.h"
+
+extern int DEBUGLEVEL;
+
+
+/*******************************************************************
+makes a SAMR_Q_CLOSE_HND structure.
+********************************************************************/
+void make_samr_q_close_hnd(SAMR_Q_CLOSE_HND *q_c, POLICY_HND *hnd)
+{
+ if (q_c == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_samr_q_close_hnd\n"));
+
+ memcpy(&(q_c->pol), hnd, sizeof(q_c->pol));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
+ prs_align(ps);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(r_u->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void make_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN *q_u,
+ POLICY_HND *connect_pol, uint32 rid, char *sid)
+{
+ if (q_u == NULL) return;
+
+ DEBUG(5,("samr_make_q_open_domain\n"));
+
+ memcpy(&q_u->connect_pol, connect_pol, sizeof(q_u->connect_pol));
+ q_u->rid = rid;
+ make_dom_sid2(&(q_u->dom_sid), sid);
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_open_domain");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("connect_pol", &(q_u->connect_pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("rid", ps, depth, &(q_u->rid));
+
+ smb_io_dom_sid2("sid", &(q_u->dom_sid), ps, depth);
+ prs_align(ps);
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_open_domain");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("domain_pol", &(r_u->domain_pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void make_samr_q_unknown_8(SAMR_Q_UNKNOWN_8 *q_u,
+ POLICY_HND *domain_pol, uint16 switch_value)
+{
+ if (q_u == NULL) return;
+
+ DEBUG(5,("samr_make_q_unknown_8\n"));
+
+ memcpy(&q_u->domain_pol, domain_pol, sizeof(q_u->domain_pol));
+ q_u->switch_value = switch_value;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_unknown_8(char *desc, SAMR_Q_UNKNOWN_8 *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_unknown_8");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("domain_pol", &(q_u->domain_pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint16("switch_value", ps, depth, &(q_u->switch_value));
+ prs_align(ps);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void make_samr_q_unknown_3(SAMR_Q_UNKNOWN_3 *q_u,
+ POLICY_HND *user_pol, uint16 switch_value)
+{
+ if (q_u == NULL) return;
+
+ DEBUG(5,("samr_make_q_unknown_3\n"));
+
+ memcpy(&q_u->user_pol, user_pol, sizeof(q_u->user_pol));
+ q_u->switch_value = switch_value;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_unknown_3(char *desc, SAMR_Q_UNKNOWN_3 *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_unknown_3");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("user_pol", &(q_u->user_pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint16("switch_value", ps, depth, &(q_u->switch_value));
+ prs_align(ps);
+}
+
+/*******************************************************************
+ makes a DOM_SID3 structure.
+
+ calculate length by adding up the size of the components.
+ ********************************************************************/
+void make_dom_sid3(DOM_SID3 *sid3, uint16 unk_0, uint16 unk_1, char *sid)
+{
+ if (sid3 == NULL) return;
+
+ make_dom_sid(&(sid3->sid), sid);
+ sid3->len = 2 + 8 + sid3->sid.num_auths * 4;
+}
+
+/*******************************************************************
+reads or writes a SAM_SID3 structure.
+
+this one's odd, because the length (in bytes) is specified at the beginning.
+the length _includes_ the length of the length, too :-)
+
+********************************************************************/
+void sam_io_dom_sid3(char *desc, DOM_SID3 *sid3, prs_struct *ps, int depth)
+{
+ if (sid3 == NULL) return;
+
+ prs_debug(ps, depth, desc, "sam_io_dom_sid3");
+ depth++;
+
+ prs_uint16("len", ps, depth, &(sid3->len));
+ prs_align(ps);
+ smb_io_dom_sid("", &(sid3->sid), ps, depth);
+}
+
+/*******************************************************************
+makes a SAMR_R_UNKNOWN3 structure.
+
+unknown_2 : 0x0001
+unknown_3 : 0x8004
+
+unknown_4,5 : 0x0000 0014
+
+unknown_6 : 0x0002
+unknown_7 : 0x5800 or 0x0070
+
+********************************************************************/
+void make_sam_sid_stuff(SAM_SID_STUFF *stf,
+ uint16 unknown_2, uint16 unknown_3,
+ uint32 unknown_4, uint16 unknown_6, uint16 unknown_7,
+ int num_sid3s, DOM_SID3 sid3[MAX_SAM_SIDS])
+{
+ stf->unknown_2 = unknown_2;
+ stf->unknown_3 = unknown_3;
+
+ bzero(stf->padding1, sizeof(stf->padding1));
+
+ stf->unknown_4 = unknown_4;
+ stf->unknown_5 = unknown_4;
+
+ stf->unknown_6 = unknown_6;
+ stf->unknown_7 = unknown_7;
+
+ stf->num_sids = num_sid3s;
+
+ stf->padding2 = 0x0000;
+
+ memcpy(stf->sid, sid3, sizeof(DOM_SID3) * num_sid3s);
+}
+
+/*******************************************************************
+reads or writes a SAM_SID_STUFF structure.
+********************************************************************/
+void sam_io_sid_stuff(char *desc, SAM_SID_STUFF *stf, prs_struct *ps, int depth)
+{
+ int i;
+
+ if (stf == NULL) return;
+
+ DEBUG(5,("make_sam_sid_stuff\n"));
+
+ prs_uint16("unknown_2", ps, depth, &(stf->unknown_2));
+ prs_uint16("unknown_3", ps, depth, &(stf->unknown_3));
+
+ prs_uint8s(False, "padding1", ps, depth, stf->padding1, sizeof(stf->padding1));
+
+ prs_uint32("unknown_4", ps, depth, &(stf->unknown_4));
+ prs_uint32("unknown_5", ps, depth, &(stf->unknown_5));
+ prs_uint16("unknown_6", ps, depth, &(stf->unknown_6));
+ prs_uint16("unknown_7", ps, depth, &(stf->unknown_7));
+
+ prs_uint32("num_sids ", ps, depth, &(stf->num_sids ));
+ prs_uint16("padding2 ", ps, depth, &(stf->padding2 ));
+
+ for (i = 0; i < stf->num_sids; i++)
+ {
+ sam_io_dom_sid3("", &(stf->sid[i]), ps, depth);
+ }
+}
+
+/*******************************************************************
+reads or writes a SAMR_R_UNKNOWN3 structure.
+********************************************************************/
+void make_samr_r_unknown_3(SAMR_R_UNKNOWN_3 *r_u,
+ uint16 unknown_2, uint16 unknown_3,
+ uint32 unknown_4, uint16 unknown_6, uint16 unknown_7,
+ int num_sid3s, DOM_SID3 sid3[MAX_SAM_SIDS],
+ uint32 status)
+{
+ if (r_u == NULL) return;
+
+ DEBUG(5,("samr_make_r_unknown_3\n"));
+
+ r_u->ptr_0 = 0;
+ r_u->ptr_1 = 0;
+
+ if (status == 0x0)
+ {
+ r_u->ptr_0 = 1;
+ r_u->ptr_1 = 1;
+ make_sam_sid_stuff(&(r_u->sid_stuff), unknown_2, unknown_3,
+ unknown_4, unknown_6, unknown_7,
+ num_sid3s, sid3);
+ }
+
+ r_u->status = status;
+}
+
+
+/*******************************************************************
+reads or writes a SAMR_R_UNKNOWN_3 structure.
+
+this one's odd, because the daft buggers use a different mechanism
+for writing out the array of sids. they put the number of sids in
+only one place: they've calculated the length of each sid and jumped
+by that amount. then, retrospectively, the length of the whole buffer
+is put at the beginning of the data stream.
+
+wierd.
+
+********************************************************************/
+void samr_io_r_unknown_3(char *desc, SAMR_R_UNKNOWN_3 *r_u, prs_struct *ps, int depth)
+{
+ int ptr_len0;
+ int ptr_len1;
+ int ptr_sid_stuff = 0;
+
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_unknown_3");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_0 ", ps, depth, &(r_u->ptr_0 ));
+
+ if (ps->io)
+ {
+ /* reading. do the length later */
+ prs_uint32("sid_stuff_len0", ps, depth, &(r_u->sid_stuff_len0));
+ }
+ else
+ {
+ /* storing */
+ ptr_len0 = ps->offset; ps->offset += 4;
+ }
+
+ if (r_u->ptr_0 != 0)
+ {
+ prs_uint32("ptr_1 ", ps, depth, &(r_u->ptr_1 ));
+ if (ps->io)
+ {
+ /* reading. do the length later */
+ prs_uint32("sid_stuff_len1", ps, depth, &(r_u->sid_stuff_len1));
+ }
+ else
+ {
+ /* storing */
+ ptr_len1 = ps->offset; ps->offset += 4;
+ }
+
+ if (r_u->ptr_1 != 0)
+ {
+ ptr_sid_stuff = ps->offset;
+ sam_io_sid_stuff("", &(r_u->sid_stuff), ps, depth);
+ }
+ }
+
+ if (!(ps->io)) /* storing not reading. do the length, now. */
+ {
+ if (ptr_sid_stuff != 0)
+ {
+ uint32 sid_stuff_len = ps->offset - ptr_sid_stuff;
+ int old_len = ps->offset;
+
+ ps->offset = ptr_len0;
+ prs_uint32("sid_stuff_len0", ps, depth, &sid_stuff_len);
+
+ ps->offset = ptr_len1;
+ prs_uint32("sid_stuff_len1", ps, depth, &sid_stuff_len);
+
+ ps->offset = old_len;
+ }
+ }
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+
+/*******************************************************************
+makes a SAM_STR1 structure.
+********************************************************************/
+void make_sam_str1(SAM_STR1 *sam, char *sam_acct, char *sam_name, char *sam_desc)
+{
+ int len_sam_acct = sam_acct != NULL ? strlen(sam_acct) : 0;
+ int len_sam_name = sam_name != NULL ? strlen(sam_name) : 0;
+ int len_sam_desc = sam_desc != NULL ? strlen(sam_desc) : 0;
+
+ if (sam == NULL) return;
+
+ DEBUG(5,("make_sam_str1: %d\n", __LINE__));
+
+ make_unistr2(&(sam->uni_acct_name), sam_acct, len_sam_acct);
+ make_unistr2(&(sam->uni_full_name), sam_name, len_sam_name);
+ make_unistr2(&(sam->uni_acct_desc), sam_desc, len_sam_desc);
+}
+
+/*******************************************************************
+reads or writes a SAM_STR1 structure.
+********************************************************************/
+void sam_io_sam_str1(char *desc, SAM_STR1 *sam, uint32 acct_buf, uint32 name_buf, uint32 desc_buf, prs_struct *ps, int depth)
+{
+ if (sam == NULL) return;
+
+ prs_debug(ps, depth, desc, "sam_io_sam_str1");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_unistr2("unistr2", &(sam->uni_acct_name), acct_buf, ps, depth); /* account name unicode string */
+ smb_io_unistr2("unistr2", &(sam->uni_full_name), name_buf, ps, depth); /* full name unicode string */
+ smb_io_unistr2("unistr2", &(sam->uni_acct_desc), desc_buf, ps, depth); /* account description unicode string */
+}
+
+/*******************************************************************
+makes a SAM_ENTRY1 structure.
+********************************************************************/
+void make_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
+ uint32 len_sam_name, uint32 len_sam_full, uint32 len_sam_desc,
+ uint32 rid_user, uint16 acb_info)
+{
+ if (sam == NULL) return;
+
+ DEBUG(5,("make_sam_entry2: %d\n", __LINE__));
+
+ sam->user_idx = user_idx;
+ sam->rid_user = rid_user;
+ sam->acb_info = acb_info;
+ sam->pad = 0;
+
+ make_uni_hdr(&(sam->hdr_acct_name), len_sam_name, len_sam_name, len_sam_name != 0);
+ make_uni_hdr(&(sam->hdr_user_name), len_sam_full, len_sam_full, len_sam_full != 0);
+ make_uni_hdr(&(sam->hdr_user_desc), len_sam_desc, len_sam_desc, len_sam_desc != 0);
+}
+
+/*******************************************************************
+reads or writes a SAM_ENTRY1 structure.
+********************************************************************/
+void sam_io_sam_entry1(char *desc, SAM_ENTRY1 *sam, prs_struct *ps, int depth)
+{
+ if (sam == NULL) return;
+
+ prs_debug(ps, depth, desc, "sam_io_sam_entry2");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("user_idx ", ps, depth, &(sam->user_idx ));
+
+ prs_uint32("rid_user ", ps, depth, &(sam->rid_user ));
+ prs_uint16("acb_info ", ps, depth, &(sam->acb_info ));
+ prs_uint16("pad ", ps, depth, &(sam->pad ));
+
+ smb_io_unihdr("unihdr", &(sam->hdr_acct_name), ps, depth); /* account name unicode string header */
+ smb_io_unihdr("unihdr", &(sam->hdr_user_name), ps, depth); /* account name unicode string header */
+ smb_io_unihdr("unihdr", &(sam->hdr_user_desc), ps, depth); /* account name unicode string header */
+}
+
+/*******************************************************************
+makes a SAM_STR2 structure.
+********************************************************************/
+void make_sam_str2(SAM_STR2 *sam, char *sam_acct, char *sam_desc)
+{
+ int len_sam_acct = sam_acct != NULL ? strlen(sam_acct) : 0;
+ int len_sam_desc = sam_desc != NULL ? strlen(sam_desc) : 0;
+
+ if (sam == NULL) return;
+
+ DEBUG(5,("make_sam_str2: %d\n", __LINE__));
+
+ make_unistr2(&(sam->uni_srv_name), sam_acct, len_sam_acct);
+ make_unistr2(&(sam->uni_srv_desc), sam_desc, len_sam_desc);
+}
+
+/*******************************************************************
+reads or writes a SAM_STR2 structure.
+********************************************************************/
+void sam_io_sam_str2(char *desc, SAM_STR2 *sam, uint32 acct_buf, uint32 desc_buf, prs_struct *ps, int depth)
+{
+ if (sam == NULL) return;
+
+ prs_debug(ps, depth, desc, "sam_io_sam_str2");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_unistr2("unistr2", &(sam->uni_srv_name), acct_buf, ps, depth); /* account name unicode string */
+ smb_io_unistr2("unistr2", &(sam->uni_srv_desc), desc_buf, ps, depth); /* account description unicode string */
+}
+
+/*******************************************************************
+makes a SAM_ENTRY2 structure.
+********************************************************************/
+void make_sam_entry2(SAM_ENTRY2 *sam, uint32 user_idx,
+ uint32 len_sam_name, uint32 len_sam_desc,
+ uint32 rid_user, uint16 acb_info)
+{
+ if (sam == NULL) return;
+
+ DEBUG(5,("make_sam_entry2: %d\n", __LINE__));
+
+ sam->user_idx = user_idx;
+ sam->rid_user = rid_user;
+ sam->acb_info = acb_info;
+ sam->pad = 0;
+
+ make_uni_hdr(&(sam->hdr_srv_name), len_sam_name, len_sam_name, len_sam_name != 0);
+ make_uni_hdr(&(sam->hdr_srv_desc), len_sam_desc, len_sam_desc, len_sam_desc != 0);
+}
+
+/*******************************************************************
+reads or writes a SAM_ENTRY2 structure.
+********************************************************************/
+void sam_io_sam_entry2(char *desc, SAM_ENTRY2 *sam, prs_struct *ps, int depth)
+{
+ if (sam == NULL) return;
+
+ prs_debug(ps, depth, desc, "sam_io_sam_entry2");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("user_idx ", ps, depth, &(sam->user_idx ));
+
+ prs_uint32("rid_user ", ps, depth, &(sam->rid_user ));
+ prs_uint16("acb_info ", ps, depth, &(sam->acb_info ));
+ prs_uint16("pad ", ps, depth, &(sam->pad ));
+
+ smb_io_unihdr("unihdr", &(sam->hdr_srv_name), ps, depth); /* account name unicode string header */
+ smb_io_unihdr("unihdr", &(sam->hdr_srv_desc), ps, depth); /* account name unicode string header */
+}
+
+/*******************************************************************
+makes a SAM_STR3 structure.
+********************************************************************/
+void make_sam_str3(SAM_STR3 *sam, char *grp_acct, char *grp_desc)
+{
+ int len_grp_acct = strlen(grp_acct);
+ int len_grp_desc = strlen(grp_desc);
+
+ if (sam == NULL) return;
+
+ DEBUG(5,("make_sam_str3: %d\n", __LINE__));
+
+ make_unistr2(&(sam->uni_grp_name), grp_acct, len_grp_acct);
+ make_unistr2(&(sam->uni_grp_desc), grp_desc, len_grp_desc);
+}
+
+/*******************************************************************
+reads or writes a SAM_STR3 structure.
+********************************************************************/
+void sam_io_sam_str3(char *desc, SAM_STR3 *sam, uint32 acct_buf, uint32 desc_buf, prs_struct *ps, int depth)
+{
+ if (sam == NULL) return;
+
+ prs_debug(ps, depth, desc, "sam_io_sam_str3");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_unistr2("unistr2", &(sam->uni_grp_name), acct_buf, ps, depth); /* account name unicode string */
+ smb_io_unistr2("unistr2", &(sam->uni_grp_desc), desc_buf, ps, depth); /* account description unicode string */
+}
+
+/*******************************************************************
+makes a SAM_ENTRY3 structure.
+********************************************************************/
+void make_sam_entry3(SAM_ENTRY3 *sam, uint32 grp_idx,
+ uint32 len_grp_name, uint32 len_grp_desc, uint32 rid_grp)
+{
+ if (sam == NULL) return;
+
+ DEBUG(5,("make_sam_entry3: %d\n", __LINE__));
+
+ sam->grp_idx = grp_idx;
+ sam->rid_grp = rid_grp;
+ sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
+
+ make_uni_hdr(&(sam->hdr_grp_name), len_grp_name, len_grp_name, len_grp_name != 0);
+ make_uni_hdr(&(sam->hdr_grp_desc), len_grp_desc, len_grp_desc, len_grp_desc != 0);
+}
+
+/*******************************************************************
+reads or writes a SAM_ENTRY3 structure.
+********************************************************************/
+void sam_io_sam_entry3(char *desc, SAM_ENTRY3 *sam, prs_struct *ps, int depth)
+{
+ if (sam == NULL) return;
+
+ prs_debug(ps, depth, desc, "sam_io_sam_entry3");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("grp_idx", ps, depth, &(sam->grp_idx));
+
+ prs_uint32("rid_grp", ps, depth, &(sam->rid_grp));
+ prs_uint32("attr ", ps, depth, &(sam->attr ));
+
+ smb_io_unihdr("unihdr", &(sam->hdr_grp_name), ps, depth); /* account name unicode string header */
+ smb_io_unihdr("unihdr", &(sam->hdr_grp_desc), ps, depth); /* account name unicode string header */
+}
+
+/*******************************************************************
+makes a SAM_ENTRY structure.
+********************************************************************/
+void make_sam_entry(SAM_ENTRY *sam, uint32 len_sam_name, uint32 rid)
+{
+ if (sam == NULL) return;
+
+ DEBUG(5,("make_sam_entry: %d\n", __LINE__));
+
+ sam->rid = rid;
+ make_uni_hdr(&(sam->hdr_name), len_sam_name, len_sam_name, len_sam_name != 0);
+}
+
+/*******************************************************************
+reads or writes a SAM_ENTRY structure.
+********************************************************************/
+void sam_io_sam_entry(char *desc, SAM_ENTRY *sam, prs_struct *ps, int depth)
+{
+ if (sam == NULL) return;
+
+ prs_debug(ps, depth, desc, "sam_io_sam_entry");
+ depth++;
+
+ prs_align(ps);
+ prs_uint32("rid", ps, depth, &(sam->rid ));
+ smb_io_unihdr("unihdr", &(sam->hdr_name), ps, depth); /* account name unicode string header */
+}
+
+/*******************************************************************
+makes a SAMR_Q_ENUM_DOM_USERS structure.
+********************************************************************/
+void make_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_e, POLICY_HND *pol,
+ uint16 req_num_entries, uint16 unk_0,
+ uint16 acb_mask, uint16 unk_1, uint32 size)
+{
+ if (q_e == NULL || pol == NULL) return;
+
+ DEBUG(5,("make_q_enum_dom_users\n"));
+
+ memcpy(&(q_e->pol), pol, sizeof(*pol));
+
+ q_e->req_num_entries = req_num_entries; /* zero indicates lots */
+ q_e->unknown_0 = unk_0; /* this gets returned in the response */
+ q_e->acb_mask = acb_mask;
+ q_e->unknown_1 = unk_1;
+ q_e->max_size = size;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS *q_e, prs_struct *ps, int depth)
+{
+ if (q_e == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(q_e->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint16("req_num_entries", ps, depth, &(q_e->req_num_entries));
+ prs_uint16("unknown_0 ", ps, depth, &(q_e->unknown_0 ));
+
+ prs_uint16("acb_mask ", ps, depth, &(q_e->acb_mask ));
+ prs_uint16("unknown_1 ", ps, depth, &(q_e->unknown_1 ));
+
+ prs_uint32("max_size ", ps, depth, &(q_e->max_size ));
+
+ prs_align(ps);
+}
+
+
+/*******************************************************************
+makes a SAMR_R_ENUM_DOM_USERS structure.
+********************************************************************/
+void make_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS *r_u,
+ uint16 total_num_entries, uint16 unk_0,
+ uint32 num_sam_entries, SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES], uint32 status)
+{
+ int i;
+
+ if (r_u == NULL) return;
+
+ DEBUG(5,("make_samr_r_enum_dom_users\n"));
+
+ if (num_sam_entries >= MAX_SAM_ENTRIES)
+ {
+ num_sam_entries = MAX_SAM_ENTRIES;
+ DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
+ }
+
+ r_u->total_num_entries = total_num_entries;
+ r_u->unknown_0 = unk_0;
+
+ if (total_num_entries > 0)
+ {
+ r_u->ptr_entries1 = 1;
+ r_u->ptr_entries2 = 1;
+ r_u->num_entries2 = num_sam_entries;
+ r_u->num_entries3 = num_sam_entries;
+
+ for (i = 0; i < num_sam_entries; i++)
+ {
+ make_sam_entry(&(r_u->sam[i]),
+ pass[i].uni_user_name.uni_str_len,
+ pass[i].user_rid);
+
+ copy_unistr2(&(r_u->uni_acct_name[i]), &(pass[i].uni_user_name));
+ }
+
+ r_u->num_entries4 = num_sam_entries;
+ }
+ else
+ {
+ r_u->ptr_entries1 = 0;
+ r_u->num_entries2 = num_sam_entries;
+ r_u->ptr_entries2 = 1;
+ }
+
+ r_u->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS *r_u, prs_struct *ps, int depth)
+{
+ int i;
+
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint16("total_num_entries", ps, depth, &(r_u->total_num_entries));
+ prs_uint16("unknown_0 ", ps, depth, &(r_u->unknown_0 ));
+ prs_uint32("ptr_entries1", ps, depth, &(r_u->ptr_entries1));
+
+ if (r_u->total_num_entries != 0 && r_u->ptr_entries1 != 0)
+ {
+ prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
+ prs_uint32("ptr_entries2", ps, depth, &(r_u->ptr_entries2));
+ prs_uint32("num_entries3", ps, depth, &(r_u->num_entries3));
+
+ for (i = 0; i < r_u->num_entries2; i++)
+ {
+ prs_grow(ps);
+ sam_io_sam_entry("", &(r_u->sam[i]), ps, depth);
+ }
+
+ for (i = 0; i < r_u->num_entries2; i++)
+ {
+ prs_grow(ps);
+ smb_io_unistr2("", &(r_u->uni_acct_name[i]), r_u->sam[i].hdr_name.buffer, ps, depth);
+ }
+
+ prs_align(ps);
+
+ prs_uint32("num_entries4", ps, depth, &(r_u->num_entries4));
+ }
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+/*******************************************************************
+makes a SAMR_Q_ENUM_DOM_ALIASES structure.
+********************************************************************/
+void make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol, uint32 size)
+{
+ if (q_e == NULL || pol == NULL) return;
+
+ DEBUG(5,("make_q_enum_dom_aliases\n"));
+
+ memcpy(&(q_e->pol), pol, sizeof(*pol));
+
+ q_e->unknown_0 = 0;
+ q_e->max_size = size;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES *q_e, prs_struct *ps, int depth)
+{
+ if (q_e == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(q_e->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("unknown_0", ps, depth, &(q_e->unknown_0));
+ prs_uint32("max_size ", ps, depth, &(q_e->max_size ));
+
+ prs_align(ps);
+}
+
+
+/*******************************************************************
+makes a SAMR_R_ENUM_DOM_ALIASES structure.
+********************************************************************/
+void make_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
+ uint32 num_sam_entries, SAM_USER_INFO_21 grps[MAX_SAM_ENTRIES],
+ uint32 status)
+{
+ int i;
+
+ if (r_u == NULL) return;
+
+ DEBUG(5,("make_samr_r_enum_dom_aliases\n"));
+
+ if (num_sam_entries >= MAX_SAM_ENTRIES)
+ {
+ num_sam_entries = MAX_SAM_ENTRIES;
+ DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
+ }
+
+ r_u->num_entries = num_sam_entries;
+
+ if (num_sam_entries > 0)
+ {
+ r_u->ptr_entries = 1;
+ r_u->num_entries2 = num_sam_entries;
+ r_u->ptr_entries2 = 1;
+ r_u->num_entries3 = num_sam_entries;
+
+ for (i = 0; i < num_sam_entries; i++)
+ {
+ make_sam_entry(&(r_u->sam[i]),
+ grps[i].uni_user_name.uni_str_len,
+ grps[i].user_rid);
+
+ copy_unistr2(&(r_u->uni_grp_name[i]), &(grps[i].uni_user_name));
+ }
+
+ r_u->num_entries4 = num_sam_entries;
+ }
+ else
+ {
+ r_u->ptr_entries = 0;
+ }
+
+ r_u->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES *r_u, prs_struct *ps, int depth)
+{
+ int i;
+
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries", ps, depth, &(r_u->num_entries));
+ prs_uint32("ptr_entries", ps, depth, &(r_u->ptr_entries));
+
+ if (r_u->num_entries != 0 && r_u->ptr_entries != 0)
+ {
+ prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
+ prs_uint32("ptr_entries2", ps, depth, &(r_u->ptr_entries2));
+ prs_uint32("num_entries3", ps, depth, &(r_u->num_entries3));
+
+ for (i = 0; i < r_u->num_entries; i++)
+ {
+ sam_io_sam_entry("", &(r_u->sam[i]), ps, depth);
+ }
+
+ for (i = 0; i < r_u->num_entries; i++)
+ {
+ smb_io_unistr2("", &(r_u->uni_grp_name[i]), r_u->sam[i].hdr_name.buffer, ps, depth);
+ }
+
+ prs_align(ps);
+
+ prs_uint32("num_entries4", ps, depth, &(r_u->num_entries4));
+ }
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+/*******************************************************************
+makes a SAMR_Q_QUERY_DISPINFO structure.
+********************************************************************/
+void make_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_e, POLICY_HND *pol,
+ uint16 switch_level, uint32 start_idx, uint32 size)
+{
+ if (q_e == NULL || pol == NULL) return;
+
+ DEBUG(5,("make_q_query_dispinfo\n"));
+
+ memcpy(&(q_e->pol), pol, sizeof(*pol));
+
+ q_e->switch_level = switch_level;
+
+ q_e->unknown_0 = 0;
+ q_e->start_idx = start_idx;
+ q_e->unknown_1 = 0x000007d0;
+ q_e->max_size = size;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO *q_e, prs_struct *ps, int depth)
+{
+ if (q_e == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(q_e->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint16("switch_level", ps, depth, &(q_e->switch_level));
+ prs_uint16("unknown_0 ", ps, depth, &(q_e->unknown_0 ));
+ prs_uint32("start_idx ", ps, depth, &(q_e->start_idx ));
+ prs_uint32("unknown_1 ", ps, depth, &(q_e->unknown_1 ));
+ prs_uint32("max_size ", ps, depth, &(q_e->max_size ));
+
+ prs_align(ps);
+}
+
+
+/*******************************************************************
+makes a SAM_INFO_2 structure.
+********************************************************************/
+void make_sam_info_2(SAM_INFO_2 *sam, uint32 acb_mask,
+ uint32 start_idx, uint32 num_sam_entries,
+ SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
+{
+ int i;
+ int entries_added;
+
+ if (sam == NULL) return;
+
+ DEBUG(5,("make_sam_info_2\n"));
+
+ if (num_sam_entries >= MAX_SAM_ENTRIES)
+ {
+ num_sam_entries = MAX_SAM_ENTRIES;
+ DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
+ }
+
+ for (i = start_idx, entries_added = 0; i < num_sam_entries; i++)
+ {
+ if (IS_BITS_SET_ALL(pass[i].acb_info, acb_mask))
+ {
+ make_sam_entry2(&(sam->sam[entries_added]),
+ start_idx + entries_added + 1,
+ pass[i].uni_user_name.uni_str_len,
+ pass[i].uni_acct_desc.uni_str_len,
+ pass[i].user_rid,
+ pass[i].acb_info);
+
+ copy_unistr2(&(sam->str[entries_added].uni_srv_name), &(pass[i].uni_user_name));
+ copy_unistr2(&(sam->str[entries_added].uni_srv_desc), &(pass[i].uni_acct_desc));
+
+ entries_added++;
+ }
+
+ sam->num_entries = entries_added;
+ sam->ptr_entries = 1;
+ sam->num_entries2 = entries_added;
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void sam_io_sam_info_2(char *desc, SAM_INFO_2 *sam, prs_struct *ps, int depth)
+{
+ int i;
+
+ if (sam == NULL) return;
+
+ prs_debug(ps, depth, desc, "sam_io_sam_info_2");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries ", ps, depth, &(sam->num_entries ));
+ prs_uint32("ptr_entries ", ps, depth, &(sam->ptr_entries ));
+
+ prs_uint32("num_entries2 ", ps, depth, &(sam->num_entries2 ));
+
+ for (i = 0; i < sam->num_entries; i++)
+ {
+ sam_io_sam_entry2("", &(sam->sam[i]), ps, depth);
+ }
+
+ for (i = 0; i < sam->num_entries; i++)
+ {
+ sam_io_sam_str2 ("", &(sam->str[i]),
+ sam->sam[i].hdr_srv_name.buffer,
+ sam->sam[i].hdr_srv_desc.buffer,
+ ps, depth);
+ }
+}
+
+
+/*******************************************************************
+makes a SAM_INFO_1 structure.
+********************************************************************/
+void make_sam_info_1(SAM_INFO_1 *sam, uint32 acb_mask,
+ uint32 start_idx, uint32 num_sam_entries,
+ SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES])
+{
+ int i;
+ int entries_added;
+
+ if (sam == NULL) return;
+
+ DEBUG(5,("make_sam_info_1\n"));
+
+ if (num_sam_entries >= MAX_SAM_ENTRIES)
+ {
+ num_sam_entries = MAX_SAM_ENTRIES;
+ DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
+ }
+
+ for (i = start_idx, entries_added = 0; i < num_sam_entries; i++)
+ {
+ if (IS_BITS_SET_ALL(pass[i].acb_info, acb_mask))
+ {
+ make_sam_entry1(&(sam->sam[entries_added]),
+ start_idx + entries_added + 1,
+ pass[i].uni_user_name.uni_str_len,
+ pass[i].uni_full_name.uni_str_len,
+ pass[i].uni_acct_desc.uni_str_len,
+ pass[i].user_rid,
+ pass[i].acb_info);
+
+ copy_unistr2(&(sam->str[entries_added].uni_acct_name), &(pass[i].uni_user_name));
+ copy_unistr2(&(sam->str[entries_added].uni_full_name), &(pass[i].uni_full_name));
+ copy_unistr2(&(sam->str[entries_added].uni_acct_desc), &(pass[i].uni_acct_desc));
+
+ entries_added++;
+ }
+ }
+
+ sam->num_entries = entries_added;
+ sam->ptr_entries = 1;
+ sam->num_entries2 = entries_added;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void sam_io_sam_info_1(char *desc, SAM_INFO_1 *sam, prs_struct *ps, int depth)
+{
+ int i;
+
+ if (sam == NULL) return;
+
+ prs_debug(ps, depth, desc, "sam_io_sam_info_1");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries ", ps, depth, &(sam->num_entries ));
+ prs_uint32("ptr_entries ", ps, depth, &(sam->ptr_entries ));
+
+ prs_uint32("num_entries2 ", ps, depth, &(sam->num_entries2 ));
+
+ for (i = 0; i < sam->num_entries; i++)
+ {
+ sam_io_sam_entry1("", &(sam->sam[i]), ps, depth);
+ }
+
+ for (i = 0; i < sam->num_entries; i++)
+ {
+ sam_io_sam_str1 ("", &(sam->str[i]),
+ sam->sam[i].hdr_acct_name.buffer,
+ sam->sam[i].hdr_user_name.buffer,
+ sam->sam[i].hdr_user_desc.buffer,
+ ps, depth);
+ }
+}
+
+
+/*******************************************************************
+makes a SAMR_R_QUERY_DISPINFO structure.
+********************************************************************/
+void make_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO *r_u,
+ uint16 switch_level, SAM_INFO_CTR *ctr, uint32 status)
+{
+ if (r_u == NULL) return;
+
+ DEBUG(5,("make_samr_r_query_dispinfo\n"));
+
+ if (status == 0x0)
+ {
+ r_u->unknown_0 = 0x0000001;
+ r_u->unknown_1 = 0x0000001;
+ }
+ else
+ {
+ r_u->unknown_0 = 0x0;
+ r_u->unknown_1 = 0x0;
+ }
+
+ r_u->switch_level = switch_level;
+ r_u->ctr = ctr;
+ r_u->status = status;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("unknown_0 ", ps, depth, &(r_u->unknown_0 ));
+ prs_uint32("unknown_1 ", ps, depth, &(r_u->unknown_1 ));
+ prs_uint16("switch_level ", ps, depth, &(r_u->switch_level ));
+
+ prs_align(ps);
+
+ switch (r_u->switch_level)
+ {
+ case 0x1:
+ {
+ sam_io_sam_info_1("users", r_u->ctr->sam.info1, ps, depth);
+ break;
+ }
+ case 0x2:
+ {
+ sam_io_sam_info_2("servers", r_u->ctr->sam.info2, ps, depth);
+ break;
+ }
+ default:
+ {
+ DEBUG(5,("samr_io_r_query_dispinfo: unknown switch value\n"));
+ break;
+ }
+ }
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+
+/*******************************************************************
+makes a SAMR_Q_ENUM_DOM_GROUPS structure.
+********************************************************************/
+void make_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol,
+ uint16 switch_level, uint32 start_idx, uint32 size)
+{
+ if (q_e == NULL || pol == NULL) return;
+
+ DEBUG(5,("make_q_enum_dom_groups\n"));
+
+ memcpy(&(q_e->pol), pol, sizeof(*pol));
+
+ q_e->switch_level = switch_level;
+
+ q_e->unknown_0 = 0;
+ q_e->start_idx = start_idx;
+ q_e->unknown_1 = 0x000007d0;
+ q_e->max_size = size;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS *q_e, prs_struct *ps, int depth)
+{
+ if (q_e == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(q_e->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint16("switch_level", ps, depth, &(q_e->switch_level));
+ prs_uint16("unknown_0 ", ps, depth, &(q_e->unknown_0 ));
+ prs_uint32("start_idx ", ps, depth, &(q_e->start_idx ));
+ prs_uint32("unknown_1 ", ps, depth, &(q_e->unknown_1 ));
+ prs_uint32("max_size ", ps, depth, &(q_e->max_size ));
+
+ prs_align(ps);
+}
+
+
+/*******************************************************************
+makes a SAMR_R_ENUM_DOM_GROUPS structure.
+********************************************************************/
+void make_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS *r_u,
+ uint32 start_idx, uint32 num_sam_entries,
+ SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES],
+ uint32 status)
+{
+ int i;
+ int entries_added;
+
+ if (r_u == NULL) return;
+
+ DEBUG(5,("make_samr_r_enum_dom_groups\n"));
+
+ if (num_sam_entries >= MAX_SAM_ENTRIES)
+ {
+ num_sam_entries = MAX_SAM_ENTRIES;
+ DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
+ }
+
+ if (status == 0x0)
+ {
+ for (i = start_idx, entries_added = 0; i < num_sam_entries; i++)
+ {
+ make_sam_entry3(&(r_u->sam[entries_added]),
+ start_idx + entries_added + 1,
+ pass[i].uni_user_name.uni_str_len,
+ pass[i].uni_acct_desc.uni_str_len,
+ pass[i].user_rid);
+
+ copy_unistr2(&(r_u->str[entries_added].uni_grp_name), &(pass[i].uni_user_name));
+ copy_unistr2(&(r_u->str[entries_added].uni_grp_desc), &(pass[i].uni_acct_desc));
+
+ entries_added++;
+ }
+
+ if (entries_added > 0)
+ {
+ r_u->unknown_0 = 0x0000492;
+ r_u->unknown_1 = 0x000049a;
+ }
+ else
+ {
+ r_u->unknown_0 = 0x0;
+ r_u->unknown_1 = 0x0;
+ }
+ r_u->switch_level = 3;
+ r_u->num_entries = entries_added;
+ r_u->ptr_entries = 1;
+ r_u->num_entries2 = entries_added;
+ }
+ else
+ {
+ r_u->switch_level = 0;
+ }
+
+ r_u->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS *r_u, prs_struct *ps, int depth)
+{
+ int i;
+
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("unknown_0 ", ps, depth, &(r_u->unknown_0 ));
+ prs_uint32("unknown_1 ", ps, depth, &(r_u->unknown_1 ));
+ prs_uint32("switch_level ", ps, depth, &(r_u->switch_level ));
+
+ if (r_u->switch_level != 0)
+ {
+ prs_uint32("num_entries ", ps, depth, &(r_u->num_entries ));
+ prs_uint32("ptr_entries ", ps, depth, &(r_u->ptr_entries ));
+
+ prs_uint32("num_entries2 ", ps, depth, &(r_u->num_entries2 ));
+
+ for (i = 0; i < r_u->num_entries; i++)
+ {
+ sam_io_sam_entry3("", &(r_u->sam[i]), ps, depth);
+ }
+
+ for (i = 0; i < r_u->num_entries; i++)
+ {
+ sam_io_sam_str3 ("", &(r_u->str[i]),
+ r_u->sam[i].hdr_grp_name.buffer,
+ r_u->sam[i].hdr_grp_desc.buffer,
+ ps, depth);
+ }
+ }
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+
+/*******************************************************************
+makes a SAMR_Q_QUERY_ALIASINFO structure.
+********************************************************************/
+void make_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_e,
+ POLICY_HND *pol,
+ uint16 switch_level)
+{
+ if (q_e == NULL || pol == NULL) return;
+
+ DEBUG(5,("make_q_query_aliasinfo\n"));
+
+ memcpy(&(q_e->pol), pol, sizeof(*pol));
+
+ q_e->switch_level = switch_level;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO *q_e, prs_struct *ps, int depth)
+{
+ if (q_e == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(q_e->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint16("switch_level", ps, depth, &(q_e->switch_level));
+}
+
+
+/*******************************************************************
+makes a SAMR_R_QUERY_ALIASINFO structure.
+********************************************************************/
+void make_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *r_u,
+ uint16 switch_value, char *acct_desc,
+ uint32 status)
+{
+ if (r_u == NULL) return;
+
+ DEBUG(5,("make_samr_r_query_aliasinfo\n"));
+
+ r_u->ptr = 0;
+
+ if (status == 0)
+ {
+ r_u->switch_value = switch_value;
+
+ switch (switch_value)
+ {
+ case 3:
+ {
+ int acct_len = acct_desc ? strlen(acct_desc) : 0;
+
+ r_u->ptr = 1;
+
+ make_uni_hdr(&(r_u->alias.info3.hdr_acct_desc), acct_len , acct_len, acct_desc ? 1 : 0);
+ make_unistr2(&(r_u->alias.info3.uni_acct_desc), acct_desc, acct_len);
+
+ break;
+ }
+
+ default:
+ {
+ DEBUG(4,("make_samr_r_query_aliasinfo: unsupported switch level\n"));
+ break;
+ }
+ }
+ }
+
+ r_u->status = status;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr ", ps, depth, &(r_u->ptr ));
+
+ if (r_u->ptr != 0)
+ {
+ prs_uint16("switch_value", ps, depth, &(r_u->switch_value));
+ prs_align(ps);
+
+ if (r_u->switch_value != 0)
+ {
+ switch (r_u->switch_value)
+ {
+ case 3:
+ {
+ smb_io_unihdr ("", &(r_u->alias.info3.hdr_acct_desc), ps, depth);
+ smb_io_unistr2("", &(r_u->alias.info3.uni_acct_desc), r_u->alias.info3.hdr_acct_desc.buffer, ps, depth);
+ break;
+ }
+ default:
+ {
+ DEBUG(4,("samr_io_r_query_aliasinfo: unsupported switch level\n"));
+ break;
+ }
+ }
+ }
+ }
+
+ prs_align(ps);
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+/*******************************************************************
+reads or writes a SAMR_Q_LOOKUP_IDS structure.
+********************************************************************/
+void samr_io_q_lookup_ids(char *desc, SAMR_Q_LOOKUP_IDS *q_u, prs_struct *ps, int depth)
+{
+ fstring tmp;
+ int i;
+
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_lookup_ids");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("num_sids1", ps, depth, &(q_u->num_sids1));
+ prs_uint32("ptr ", ps, depth, &(q_u->ptr ));
+ prs_uint32("num_sids2", ps, depth, &(q_u->num_sids2));
+
+ for (i = 0; i < q_u->num_sids2; i++)
+ {
+ sprintf(tmp, "ptr[%02d]", i);
+ prs_uint32(tmp, ps, depth, &(q_u->ptr_sid[i]));
+ }
+
+ for (i = 0; i < q_u->num_sids2; i++)
+ {
+ if (q_u->ptr_sid[i] != 0)
+ {
+ sprintf(tmp, "sid[%02d]", i);
+ smb_io_dom_sid2(tmp, &(q_u->sid[i]), ps, depth);
+ }
+ }
+
+ prs_align(ps);
+}
+
+
+/*******************************************************************
+makes a SAMR_R_LOOKUP_IDS structure.
+********************************************************************/
+void make_samr_r_lookup_ids(SAMR_R_LOOKUP_IDS *r_u,
+ uint32 num_rids, uint32 *rid, uint32 status)
+{
+ int i;
+ if (r_u == NULL) return;
+
+ DEBUG(5,("make_samr_r_lookup_ids\n"));
+
+ if (status == 0x0)
+ {
+ r_u->num_entries = num_rids;
+ r_u->ptr = 1;
+ r_u->num_entries2 = num_rids;
+
+ for (i = 0; i < num_rids; i++)
+ {
+ r_u->rid[i] = rid[i];
+ }
+ }
+ else
+ {
+ r_u->num_entries = 0;
+ r_u->ptr = 0;
+ r_u->num_entries2 = 0;
+ }
+
+ r_u->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_lookup_ids(char *desc, SAMR_R_LOOKUP_IDS *r_u, prs_struct *ps, int depth)
+{
+ fstring tmp;
+ int i;
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_lookup_ids");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries", ps, depth, &(r_u->num_entries));
+ prs_uint32("ptr ", ps, depth, &(r_u->ptr ));
+ prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
+
+ if (r_u->num_entries != 0)
+ {
+
+ for (i = 0; i < r_u->num_entries2; i++)
+ {
+ sprintf(tmp, "rid[%02d]", i);
+ prs_uint32(tmp, ps, depth, &(r_u->rid[i]));
+ }
+ }
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES *q_u, prs_struct *ps, int depth)
+{
+ int i;
+
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("num_rids1", ps, depth, &(q_u->num_rids1));
+ prs_uint32("rid ", ps, depth, &(q_u->rid ));
+ prs_uint32("ptr ", ps, depth, &(q_u->ptr ));
+ prs_uint32("num_rids2", ps, depth, &(q_u->num_rids2));
+
+ for (i = 0; i < q_u->num_rids2; i++)
+ {
+ smb_io_unihdr ("", &(q_u->hdr_user_name[i]), ps, depth);
+ }
+ for (i = 0; i < q_u->num_rids2; i++)
+ {
+ smb_io_unistr2("", &(q_u->uni_user_name[i]), q_u->hdr_user_name[i].buffer, ps, depth);
+ }
+
+ prs_align(ps);
+}
+
+
+/*******************************************************************
+makes a SAMR_R_LOOKUP_NAMES structure.
+********************************************************************/
+void make_samr_r_lookup_names(SAMR_R_LOOKUP_NAMES *r_u,
+ uint32 num_rids, uint32 *rid, uint32 status)
+{
+ int i;
+ if (r_u == NULL) return;
+
+ DEBUG(5,("make_samr_r_lookup_names\n"));
+
+ if (status == 0x0)
+ {
+ r_u->num_entries = num_rids;
+ r_u->undoc_buffer = 1;
+ r_u->num_entries2 = num_rids;
+
+ for (i = 0; i < num_rids; i++)
+ {
+ make_dom_rid3(&(r_u->dom_rid[i]), rid[i]);
+ }
+
+ r_u->num_entries3 = num_rids;
+ }
+ else
+ {
+ r_u->num_entries = 0;
+ r_u->undoc_buffer = 0;
+ r_u->num_entries2 = 0;
+ r_u->num_entries3 = 0;
+ }
+
+ r_u->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES *r_u, prs_struct *ps, int depth)
+{
+ int i;
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries ", ps, depth, &(r_u->num_entries ));
+ prs_uint32("undoc_buffer", ps, depth, &(r_u->undoc_buffer));
+ prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
+
+ if (r_u->num_entries != 0)
+ {
+ for (i = 0; i < r_u->num_entries2; i++)
+ {
+ smb_io_dom_rid3("", &(r_u->dom_rid[i]), ps, depth);
+ }
+
+ }
+
+ prs_uint32("num_entries3", ps, depth, &(r_u->num_entries3));
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+/*******************************************************************
+makes a SAMR_Q_UNKNOWN_12 structure.
+********************************************************************/
+void make_samr_q_unknown_12(SAMR_Q_UNKNOWN_12 *q_u,
+ POLICY_HND *pol, uint32 rid,
+ uint32 num_gids, uint32 *gid)
+{
+ int i;
+ if (q_u == NULL) return;
+
+ DEBUG(5,("make_samr_r_unknwon_12\n"));
+
+ memcpy(&(q_u->pol), pol, sizeof(*pol));
+
+ q_u->num_gids1 = num_gids;
+ q_u->rid = rid;
+ q_u->ptr = 0;
+ q_u->num_gids2 = num_gids;
+
+ for (i = 0; i < num_gids; i++)
+ {
+ q_u->gid[i] = gid[i];
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_unknown_12(char *desc, SAMR_Q_UNKNOWN_12 *q_u, prs_struct *ps, int depth)
+{
+ int i;
+ fstring tmp;
+
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_unknown_12");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("num_gids1", ps, depth, &(q_u->num_gids1));
+ prs_uint32("rid ", ps, depth, &(q_u->rid ));
+ prs_uint32("ptr ", ps, depth, &(q_u->ptr ));
+ prs_uint32("num_gids2", ps, depth, &(q_u->num_gids2));
+
+ for (i = 0; i < q_u->num_gids2; i++)
+ {
+ sprintf(tmp, "gid[%02d] ", i);
+ prs_uint32(tmp, ps, depth, &(q_u->gid[i]));
+ }
+
+ prs_align(ps);
+}
+
+
+/*******************************************************************
+makes a SAMR_R_UNKNOWN_12 structure.
+********************************************************************/
+void make_samr_r_unknown_12(SAMR_R_UNKNOWN_12 *r_u,
+ uint32 num_aliases, fstring *als_name, uint32 *num_als_usrs,
+ uint32 status)
+{
+ int i;
+ if (r_u == NULL || als_name == NULL || num_als_usrs == NULL) return;
+
+ DEBUG(5,("make_samr_r_unknown_12\n"));
+
+ if (status == 0x0)
+ {
+ r_u->num_aliases1 = num_aliases;
+ r_u->ptr_aliases = 1;
+ r_u->num_aliases2 = num_aliases;
+
+ r_u->num_als_usrs1 = num_aliases;
+ r_u->ptr_als_usrs = 1;
+ r_u->num_als_usrs2 = num_aliases;
+
+ for (i = 0; i < num_aliases; i++)
+ {
+ int als_len = als_name[i] != NULL ? strlen(als_name[i]) : 0;
+ make_uni_hdr(&(r_u->hdr_als_name[i]), als_len , als_len, als_name[i] ? 1 : 0);
+ make_unistr2(&(r_u->uni_als_name[i]), als_name[i], als_len);
+ r_u->num_als_usrs[i] = num_als_usrs[i];
+ }
+ }
+ else
+ {
+ r_u->num_aliases1 = num_aliases;
+ r_u->ptr_aliases = 0;
+ r_u->num_aliases2 = num_aliases;
+
+ r_u->num_als_usrs1 = num_aliases;
+ r_u->ptr_als_usrs = 0;
+ r_u->num_als_usrs2 = num_aliases;
+ }
+
+ r_u->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_unknown_12(char *desc, SAMR_R_UNKNOWN_12 *r_u, prs_struct *ps, int depth)
+{
+ int i;
+ fstring tmp;
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_unknown_12");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_aliases1", ps, depth, &(r_u->num_aliases1));
+ prs_uint32("ptr_aliases ", ps, depth, &(r_u->ptr_aliases ));
+ prs_uint32("num_aliases2", ps, depth, &(r_u->num_aliases2));
+
+ if (r_u->ptr_aliases != 0 && r_u->num_aliases1 != 0)
+ {
+ for (i = 0; i < r_u->num_aliases2; i++)
+ {
+ sprintf(tmp, "als_hdr[%02d] ", i);
+ smb_io_unihdr ("", &(r_u->hdr_als_name[i]), ps, depth);
+ }
+ for (i = 0; i < r_u->num_aliases2; i++)
+ {
+ sprintf(tmp, "als_str[%02d] ", i);
+ smb_io_unistr2("", &(r_u->uni_als_name[i]), r_u->hdr_als_name[i].buffer, ps, depth);
+ }
+ }
+
+ prs_align(ps);
+
+ prs_uint32("num_als_usrs1", ps, depth, &(r_u->num_als_usrs1));
+ prs_uint32("ptr_als_usrs ", ps, depth, &(r_u->ptr_als_usrs ));
+ prs_uint32("num_als_usrs2", ps, depth, &(r_u->num_als_usrs2));
+
+ if (r_u->ptr_als_usrs != 0 && r_u->num_als_usrs1 != 0)
+ {
+ for (i = 0; i < r_u->num_als_usrs2; i++)
+ {
+ sprintf(tmp, "als_usrs[%02d] ", i);
+ prs_uint32(tmp, ps, depth, &(r_u->num_als_usrs[i]));
+ }
+ }
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void make_samr_q_open_user(SAMR_Q_OPEN_USER *q_u,
+ POLICY_HND *pol,
+ uint32 unk_0, uint32 rid)
+{
+ if (q_u == NULL) return;
+
+ DEBUG(5,("samr_make_q_open_user\n"));
+
+ memcpy(&q_u->domain_pol, pol, sizeof(q_u->domain_pol));
+
+ q_u->unknown_0 = unk_0;
+ q_u->user_rid = rid;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_open_user");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("domain_pol", &(q_u->domain_pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("unknown_0", ps, depth, &(q_u->unknown_0));
+ prs_uint32("user_rid ", ps, depth, &(q_u->user_rid ));
+
+ prs_align(ps);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_open_user");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("user_pol", &(r_u->user_pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+
+/*******************************************************************
+makes a SAMR_Q_QUERY_USERGROUPS structure.
+********************************************************************/
+void make_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u,
+ POLICY_HND *hnd)
+{
+ if (q_u == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_samr_q_query_usergroups\n"));
+
+ memcpy(&(q_u->pol), hnd, sizeof(q_u->pol));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
+ prs_align(ps);
+}
+
+/*******************************************************************
+makes a SAMR_R_QUERY_USERGROUPS structure.
+********************************************************************/
+void make_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS *r_u,
+ uint32 num_gids, DOM_GID *gid, uint32 status)
+{
+ if (r_u == NULL) return;
+
+ DEBUG(5,("make_samr_r_query_usergroups\n"));
+
+ if (status == 0x0)
+ {
+ r_u->ptr_0 = 1;
+ r_u->num_entries = num_gids;
+ r_u->ptr_1 = 1;
+ r_u->num_entries2 = num_gids;
+
+ r_u->gid = gid;
+
+#if 0
+ int i;
+ for (i = 0; i < num_gids && i < LSA_MAX_GROUPS; i++)
+ {
+ r_u->gid[i].g_rid = gid[i].g_rid;
+ r_u->gid[i].attr = gid[i].attr ;
+ }
+#endif
+
+ }
+ else
+ {
+ r_u->ptr_0 = 0;
+ r_u->num_entries = 0;
+ r_u->ptr_1 = 0;
+ }
+
+ r_u->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS *r_u, prs_struct *ps, int depth)
+{
+ int i;
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_0 ", ps, depth, &(r_u->ptr_0 ));
+
+ if (r_u->ptr_0 != 0)
+ {
+ prs_uint32("num_entries ", ps, depth, &(r_u->num_entries));
+ prs_uint32("ptr_1 ", ps, depth, &(r_u->ptr_1 ));
+
+ if (r_u->num_entries != 0)
+ {
+ prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
+
+ for (i = 0; i < r_u->num_entries2; i++)
+ {
+ smb_io_gid("", &(r_u->gid[i]), ps, depth);
+ }
+ }
+ }
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+/*******************************************************************
+makes a SAMR_Q_QUERY_USERINFO structure.
+********************************************************************/
+void make_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u,
+ POLICY_HND *hnd, uint16 switch_value)
+{
+ if (q_u == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_samr_q_query_userinfo\n"));
+
+ memcpy(&(q_u->pol), hnd, sizeof(q_u->pol));
+ q_u->switch_value = switch_value;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint16("switch_value", ps, depth, &(q_u->switch_value)); /* 0x0015 or 0x0011 */
+
+ prs_align(ps);
+}
+
+/*******************************************************************
+reads or writes a LOGON_HRS structure.
+********************************************************************/
+void sam_io_logon_hrs(char *desc, LOGON_HRS *hrs, prs_struct *ps, int depth)
+{
+ if (hrs == NULL) return;
+
+ prs_debug(ps, depth, desc, "sam_io_logon_hrs");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32 ( "len ", ps, depth, &(hrs->len ));
+
+ if (hrs->len > 64)
+ {
+ DEBUG(5,("sam_io_logon_hrs: truncating length\n"));
+ hrs->len = 64;
+ }
+
+ prs_uint8s (False, "hours", ps, depth, hrs->hours, hrs->len);
+}
+
+/*******************************************************************
+makes a SAM_USER_INFO_11 structure.
+********************************************************************/
+void make_sam_user_info11(SAM_USER_INFO_11 *usr,
+ NTTIME *expiry,
+ char *mach_acct,
+ uint32 rid_user,
+ uint32 rid_group,
+ uint16 acct_ctrl)
+
+{
+ int len_mach_acct;
+ if (usr == NULL || expiry == NULL || mach_acct == NULL) return;
+
+ DEBUG(5,("make_samr_r_unknown_24\n"));
+
+ len_mach_acct = strlen(mach_acct);
+
+ memcpy(&(usr->expiry),expiry, sizeof(usr->expiry)); /* expiry time or something? */
+ bzero(usr->padding_1, sizeof(usr->padding_1)); /* 0 - padding 24 bytes */
+
+ make_uni_hdr(&(usr->hdr_mach_acct), len_mach_acct, len_mach_acct, 4); /* unicode header for machine account */
+ usr->padding_2 = 0; /* 0 - padding 4 bytes */
+
+ usr->ptr_1 = 1; /* pointer */
+ bzero(usr->padding_3, sizeof(usr->padding_3)); /* 0 - padding 32 bytes */
+ usr->padding_4 = 0; /* 0 - padding 4 bytes */
+
+ usr->ptr_2 = 1; /* pointer */
+ usr->padding_5 = 0; /* 0 - padding 4 bytes */
+
+ usr->ptr_3 = 1; /* pointer */
+ bzero(usr->padding_6, sizeof(usr->padding_6)); /* 0 - padding 32 bytes */
+
+ usr->rid_user = rid_user;
+ usr->rid_group = rid_group;
+
+ usr->acct_ctrl = acct_ctrl;
+ usr->unknown_3 = 0x0000;
+
+ usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
+ usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
+
+ bzero(usr->padding_7, sizeof(usr->padding_7)); /* 0 - padding 16 bytes */
+ usr->padding_8 = 0; /* 0 - padding 4 bytes */
+
+ make_unistr2(&(usr->uni_mach_acct), mach_acct, len_mach_acct); /* unicode string for machine account */
+
+ bzero(usr->padding_9, sizeof(usr->padding_9)); /* 0 - padding 48 bytes */
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void sam_io_user_info11(char *desc, SAM_USER_INFO_11 *usr, prs_struct *ps, int depth)
+{
+ if (usr == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_unknown_24");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint8s (False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0));
+
+ smb_io_time("time", &(usr->expiry), ps, depth);
+
+ prs_uint8s (False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1));
+
+ smb_io_unihdr ("unihdr", &(usr->hdr_mach_acct), ps, depth);
+ prs_uint32( "padding_2", ps, depth, &(usr->padding_2));
+
+ prs_uint32( "ptr_1 ", ps, depth, &(usr->ptr_1 ));
+ prs_uint8s (False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3));
+ prs_uint32( "padding_4", ps, depth, &(usr->padding_4));
+
+ prs_uint32( "ptr_2 ", ps, depth, &(usr->ptr_2 ));
+ prs_uint32( "padding_5", ps, depth, &(usr->padding_5));
+
+ prs_uint32( "ptr_3 ", ps, depth, &(usr->ptr_3 ));
+ prs_uint8s (False, "padding_6", ps, depth, usr->padding_6, sizeof(usr->padding_6));
+
+ prs_uint32( "rid_user ", ps, depth, &(usr->rid_user ));
+ prs_uint32( "rid_group", ps, depth, &(usr->rid_group));
+ prs_uint16( "acct_ctrl", ps, depth, &(usr->acct_ctrl));
+ prs_uint16( "unknown_3", ps, depth, &(usr->unknown_3));
+ prs_uint16( "unknown_4", ps, depth, &(usr->unknown_4));
+ prs_uint16( "unknown_5", ps, depth, &(usr->unknown_5));
+
+ prs_uint8s (False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7));
+ prs_uint32( "padding_8", ps, depth, &(usr->padding_8));
+
+ smb_io_unistr2("unistr2", &(usr->uni_mach_acct), True, ps, depth);
+ prs_align(ps);
+
+ prs_uint8s (False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9));
+}
+
+/*************************************************************************
+ make_sam_user_info21
+
+ unknown_3 = 0x00ff ffff
+ unknown_5 = 0x0002 0000
+ unknown_6 = 0x0000 04ec
+
+ *************************************************************************/
+void make_sam_user_info21(SAM_USER_INFO_21 *usr,
+
+ NTTIME *logon_time,
+ NTTIME *logoff_time,
+ NTTIME *kickoff_time,
+ NTTIME *pass_last_set_time,
+ NTTIME *pass_can_change_time,
+ NTTIME *pass_must_change_time,
+
+ char *user_name,
+ char *full_name,
+ char *home_dir,
+ char *dir_drive,
+ char *logon_script,
+ char *profile_path,
+ char *description,
+ char *workstations,
+ char *unknown_str,
+ char *munged_dial,
+
+ uint32 user_rid,
+ uint32 group_rid,
+ uint16 acb_info,
+
+ uint32 unknown_3,
+ uint16 logon_divs,
+ LOGON_HRS *hrs,
+ uint32 unknown_5,
+ uint32 unknown_6)
+{
+ int len_user_name = user_name != NULL ? strlen(user_name ) : 0;
+ int len_full_name = full_name != NULL ? strlen(full_name ) : 0;
+ int len_home_dir = home_dir != NULL ? strlen(home_dir ) : 0;
+ int len_dir_drive = dir_drive != NULL ? strlen(dir_drive ) : 0;
+ int len_logon_script = logon_script != NULL ? strlen(logon_script) : 0;
+ int len_profile_path = profile_path != NULL ? strlen(profile_path) : 0;
+ int len_description = description != NULL ? strlen(description ) : 0;
+ int len_workstations = workstations != NULL ? strlen(workstations) : 0;
+ int len_unknown_str = unknown_str != NULL ? strlen(unknown_str ) : 0;
+ int len_munged_dial = munged_dial != NULL ? strlen(munged_dial ) : 0;
+
+ usr->logon_time = *logon_time;
+ usr->logoff_time = *logoff_time;
+ usr->kickoff_time = *kickoff_time;
+ usr->pass_last_set_time = *pass_last_set_time;
+ usr->pass_can_change_time = *pass_can_change_time;
+ usr->pass_must_change_time = *pass_must_change_time;
+
+ make_uni_hdr(&(usr->hdr_user_name ), len_user_name , len_user_name , len_user_name != 0);
+ make_uni_hdr(&(usr->hdr_full_name ), len_full_name , len_full_name , len_full_name != 0);
+ make_uni_hdr(&(usr->hdr_home_dir ), len_home_dir , len_home_dir , len_home_dir != 0);
+ make_uni_hdr(&(usr->hdr_dir_drive ), len_dir_drive , len_dir_drive , len_dir_drive != 0);
+ make_uni_hdr(&(usr->hdr_logon_script), len_logon_script, len_logon_script, len_logon_script != 0);
+ make_uni_hdr(&(usr->hdr_profile_path), len_profile_path, len_profile_path, len_profile_path != 0);
+ make_uni_hdr(&(usr->hdr_acct_desc ), len_description , len_description , len_description != 0);
+ make_uni_hdr(&(usr->hdr_workstations), len_workstations, len_workstations, len_workstations != 0);
+ make_uni_hdr(&(usr->hdr_unknown_str ), len_unknown_str , len_unknown_str , len_workstations != 0);
+ make_uni_hdr(&(usr->hdr_munged_dial ), len_munged_dial , len_munged_dial , len_workstations != 0);
+
+ bzero(usr->nt_pwd, sizeof(usr->nt_pwd));
+ bzero(usr->lm_pwd, sizeof(usr->lm_pwd));
+
+ usr->user_rid = user_rid;
+ usr->group_rid = group_rid;
+ usr->acb_info = acb_info;
+ usr->unknown_3 = unknown_3; /* 0x00ff ffff */
+
+ usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
+ usr->ptr_logon_hrs = hrs ? 1 : 0;
+ usr->unknown_5 = unknown_5; /* 0x0002 0000 */
+
+ bzero(usr->padding1, sizeof(usr->padding1));
+
+ make_unistr2(&(usr->uni_user_name ), user_name , len_user_name );
+ make_unistr2(&(usr->uni_full_name ), full_name , len_full_name );
+ make_unistr2(&(usr->uni_home_dir ), home_dir , len_home_dir );
+ make_unistr2(&(usr->uni_dir_drive ), dir_drive , len_dir_drive );
+ make_unistr2(&(usr->uni_logon_script), logon_script, len_logon_script);
+ make_unistr2(&(usr->uni_profile_path), profile_path, len_profile_path);
+ make_unistr2(&(usr->uni_acct_desc ), description , len_description );
+ make_unistr2(&(usr->uni_workstations), workstations, len_workstations);
+ make_unistr2(&(usr->uni_unknown_str ), unknown_str , len_unknown_str );
+ make_unistr2(&(usr->uni_munged_dial ), munged_dial , len_munged_dial );
+
+ usr->unknown_6 = unknown_6; /* 0x0000 04ec */
+ usr->padding4 = 0;
+
+ if (hrs)
+ {
+ memcpy(&(usr->logon_hrs), hrs, sizeof(usr->logon_hrs));
+ }
+ else
+ {
+ memset(&(usr->logon_hrs), 0xff, sizeof(usr->logon_hrs));
+ }
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void sam_io_user_info21(char *desc, SAM_USER_INFO_21 *usr, prs_struct *ps, int depth)
+{
+ if (usr == NULL) return;
+
+ prs_debug(ps, depth, desc, "lsa_io_user_info");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_time("logon_time ", &(usr->logon_time) , ps, depth);
+ smb_io_time("logoff_time ", &(usr->logoff_time) , ps, depth);
+ smb_io_time("kickoff_time ", &(usr->kickoff_time) , ps, depth);
+ smb_io_time("pass_last_set_time ", &(usr->pass_last_set_time) , ps, depth);
+ smb_io_time("pass_can_change_time ", &(usr->pass_can_change_time) , ps, depth);
+ smb_io_time("pass_must_change_time", &(usr->pass_must_change_time), ps, depth);
+
+ smb_io_unihdr("hdr_user_name ", &(usr->hdr_user_name) , ps, depth); /* username unicode string header */
+ smb_io_unihdr("hdr_full_name ", &(usr->hdr_full_name) , ps, depth); /* user's full name unicode string header */
+ smb_io_unihdr("hdr_home_dir ", &(usr->hdr_home_dir) , ps, depth); /* home directory unicode string header */
+ smb_io_unihdr("hdr_dir_drive ", &(usr->hdr_dir_drive) , ps, depth); /* home directory drive */
+ smb_io_unihdr("hdr_logon_script", &(usr->hdr_logon_script), ps, depth); /* logon script unicode string header */
+ smb_io_unihdr("hdr_profile_path", &(usr->hdr_profile_path), ps, depth); /* profile path unicode string header */
+ smb_io_unihdr("hdr_acct_desc ", &(usr->hdr_acct_desc ) , ps, depth); /* account description */
+ smb_io_unihdr("hdr_workstations", &(usr->hdr_workstations), ps, depth); /* workstations user can log on from */
+ smb_io_unihdr("hdr_unknown_str ", &(usr->hdr_unknown_str ), ps, depth); /* unknown string */
+ smb_io_unihdr("hdr_munged_dial ", &(usr->hdr_munged_dial ), ps, depth); /* workstations user can log on from */
+
+ prs_uint8s (False, "lm_pwd ", ps, depth, usr->lm_pwd , sizeof(usr->lm_pwd ));
+ prs_uint8s (False, "nt_pwd ", ps, depth, usr->nt_pwd , sizeof(usr->nt_pwd ));
+
+ prs_uint32("user_rid ", ps, depth, &(usr->user_rid )); /* User ID */
+ prs_uint32("group_rid ", ps, depth, &(usr->group_rid )); /* Group ID */
+ prs_uint16("acb_info ", ps, depth, &(usr->acb_info )); /* Group ID */
+ prs_align(ps);
+
+ prs_uint32("unknown_3 ", ps, depth, &(usr->unknown_3 ));
+ prs_uint16("logon_divs ", ps, depth, &(usr->logon_divs )); /* logon divisions per week */
+ prs_align(ps);
+ prs_uint32("ptr_logon_hrs ", ps, depth, &(usr->ptr_logon_hrs));
+ prs_uint32("unknown_5 ", ps, depth, &(usr->unknown_5 ));
+
+ prs_uint8s (False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1));
+
+ /* here begins pointed-to data */
+
+ smb_io_unistr2("uni_user_name ", &(usr->uni_user_name) , usr->hdr_user_name .buffer, ps, depth); /* username unicode string */
+ smb_io_unistr2("uni_full_name ", &(usr->uni_full_name) , usr->hdr_full_name .buffer, ps, depth); /* user's full name unicode string */
+ smb_io_unistr2("uni_home_dir ", &(usr->uni_home_dir) , usr->hdr_home_dir .buffer, ps, depth); /* home directory unicode string */
+ smb_io_unistr2("uni_dir_drive ", &(usr->uni_dir_drive) , usr->hdr_dir_drive .buffer, ps, depth); /* home directory drive unicode string */
+ smb_io_unistr2("uni_logon_script", &(usr->uni_logon_script), usr->hdr_logon_script.buffer, ps, depth); /* logon script unicode string */
+ smb_io_unistr2("uni_profile_path", &(usr->uni_profile_path), usr->hdr_profile_path.buffer, ps, depth); /* profile path unicode string */
+ smb_io_unistr2("uni_acct_desc ", &(usr->uni_acct_desc ), usr->hdr_acct_desc .buffer, ps, depth); /* user description unicode string */
+ smb_io_unistr2("uni_workstations", &(usr->uni_workstations), usr->hdr_workstations.buffer, ps, depth); /* worksations user can log on from */
+ smb_io_unistr2("uni_unknown_str ", &(usr->uni_unknown_str ), usr->hdr_unknown_str .buffer, ps, depth); /* unknown string */
+ smb_io_unistr2("uni_munged_dial ", &(usr->uni_munged_dial ), usr->hdr_munged_dial .buffer, ps, depth); /* worksations user can log on from */
+
+ prs_uint32("unknown_6 ", ps, depth, &(usr->unknown_6 ));
+ prs_uint32("padding4 ", ps, depth, &(usr->padding4 ));
+
+ if (usr->ptr_logon_hrs)
+ {
+ sam_io_logon_hrs("logon_hrs", &(usr->logon_hrs) , ps, depth);
+ }
+}
+
+
+/*******************************************************************
+makes a SAMR_R_QUERY_USERINFO structure.
+********************************************************************/
+void make_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO *r_u,
+ uint16 switch_value, void *info, uint32 status)
+
+{
+ if (r_u == NULL || info == NULL) return;
+
+ DEBUG(5,("make_samr_r_query_userinfo\n"));
+
+ r_u->ptr = 0;
+ r_u->switch_value = 0;
+
+ if (status == 0)
+ {
+ r_u->switch_value = switch_value;
+
+ switch (switch_value)
+ {
+ case 0x10:
+ {
+ r_u->ptr = 1;
+ r_u->info.id10 = (SAM_USER_INFO_10*)info;
+
+ break;
+ }
+
+ case 0x11:
+ {
+ r_u->ptr = 1;
+ r_u->info.id11 = (SAM_USER_INFO_11*)info;
+
+ break;
+ }
+
+ case 21:
+ {
+ r_u->ptr = 1;
+ r_u->info.id21 = (SAM_USER_INFO_21*)info;
+
+ break;
+ }
+
+ default:
+ {
+ DEBUG(4,("make_samr_r_query_aliasinfo: unsupported switch level\n"));
+ break;
+ }
+ }
+ }
+
+ r_u->status = status; /* return status */
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr ", ps, depth, &(r_u->ptr ));
+ prs_uint16("switch_value", ps, depth, &(r_u->switch_value));
+ prs_align(ps);
+
+ if (r_u->ptr != 0 && r_u->switch_value != 0)
+ {
+ switch (r_u->switch_value)
+ {
+/*
+ case 0x10:
+ {
+ if (r_u->info.id10 != NULL)
+ {
+ sam_io_user_info10("", r_u->info.id10, ps, depth);
+ }
+ else
+ {
+ DEBUG(2,("samr_io_r_query_userinfo: info pointer not initialised\n"));
+ return NULL;
+ }
+ break;
+ }
+ case 0x11:
+ {
+ if (r_u->info.id11 != NULL)
+ {
+ sam_io_user_info11("", r_u->info.id11, ps, depth);
+ }
+ else
+ {
+ DEBUG(2,("samr_io_r_query_userinfo: info pointer not initialised\n"));
+ return NULL;
+ }
+ break;
+ }
+*/
+ case 21:
+ {
+ if (r_u->info.id21 != NULL)
+ {
+ sam_io_user_info21("", r_u->info.id21, ps, depth);
+ }
+ else
+ {
+ DEBUG(2,("samr_io_r_query_userinfo: info pointer not initialised\n"));
+ return;
+ }
+ break;
+ }
+ default:
+ {
+ DEBUG(2,("samr_io_r_query_userinfo: unknown switch level\n"));
+ break;
+ }
+
+ }
+ }
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+
+/*******************************************************************
+makes a SAMR_Q_UNKNOWN_21 structure.
+********************************************************************/
+void make_samr_q_unknown_21(SAMR_Q_UNKNOWN_21 *q_c,
+ POLICY_HND *hnd, uint16 unk_1, uint16 unk_2)
+{
+ if (q_c == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_samr_q_unknown_21\n"));
+
+ memcpy(&(q_c->group_pol), hnd, sizeof(q_c->group_pol));
+ q_c->unknown_1 = unk_1;
+ q_c->unknown_2 = unk_2;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_unknown_21(char *desc, SAMR_Q_UNKNOWN_21 *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_unknown_21");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("group_pol", &(q_u->group_pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint16("unknown_1", ps, depth, &(q_u->unknown_1));
+ prs_uint16("unknown_2", ps, depth, &(q_u->unknown_2));
+}
+
+/*******************************************************************
+makes a SAMR_Q_UNKNOWN_13 structure.
+********************************************************************/
+void make_samr_q_unknown_13(SAMR_Q_UNKNOWN_13 *q_c,
+ POLICY_HND *hnd, uint16 unk_1, uint16 unk_2)
+{
+ if (q_c == NULL || hnd == NULL) return;
+
+ DEBUG(5,("make_samr_q_unknown_13\n"));
+
+ memcpy(&(q_c->alias_pol), hnd, sizeof(q_c->alias_pol));
+ q_c->unknown_1 = unk_1;
+ q_c->unknown_2 = unk_2;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_unknown_13(char *desc, SAMR_Q_UNKNOWN_13 *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_unknown_13");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("alias_pol", &(q_u->alias_pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint16("unknown_1", ps, depth, &(q_u->unknown_1));
+ prs_uint16("unknown_2", ps, depth, &(q_u->unknown_2));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_unknown_32(char *desc, SAMR_Q_UNKNOWN_32 *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_unknown_32");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
+ prs_align(ps);
+
+ smb_io_unihdr ("", &(q_u->hdr_mach_acct), ps, depth);
+ smb_io_unistr2("", &(q_u->uni_mach_acct), q_u->hdr_mach_acct.buffer, ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("acct_ctrl", ps, depth, &(q_u->acct_ctrl));
+ prs_uint16("unknown_1", ps, depth, &(q_u->unknown_1));
+ prs_uint16("unknown_2", ps, depth, &(q_u->unknown_2));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_unknown_32(char *desc, SAMR_R_UNKNOWN_32 *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_unknown_32");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(r_u->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+
+/*******************************************************************
+makes a SAMR_Q_CONNECT structure.
+********************************************************************/
+void make_samr_q_connect(SAMR_Q_CONNECT *q_u,
+ char *srv_name, uint32 unknown_0)
+{
+ int len_srv_name = strlen(srv_name);
+
+ if (q_u == NULL) return;
+
+ DEBUG(5,("make_q_connect\n"));
+
+ /* make PDC server name \\server */
+ make_unistr2(&(q_u->uni_srv_name), srv_name, len_srv_name);
+
+ /* example values: 0x0000 0002 */
+ q_u->unknown_0 = unknown_0;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_connect(char *desc, SAMR_Q_CONNECT *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_connect");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_srv_name", ps, depth, &(q_u->ptr_srv_name));
+ smb_io_unistr2("", &(q_u->uni_srv_name), q_u->ptr_srv_name, ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("unknown_0 ", ps, depth, &(q_u->unknown_0 ));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_connect(char *desc, SAMR_R_CONNECT *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_connect");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("connect_pol", &(r_u->connect_pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+/*******************************************************************
+makes a SAMR_Q_OPEN_ALIAS structure.
+********************************************************************/
+void make_samr_q_open_alias(SAMR_Q_OPEN_ALIAS *q_u,
+ uint32 unknown_0, uint32 rid)
+{
+ if (q_u == NULL) return;
+
+ DEBUG(5,("make_q_open_alias\n"));
+
+ /* example values: 0x0000 0008 */
+ q_u->unknown_0 = unknown_0;
+
+ q_u->rid_alias = rid;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_open_alias");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("unknown_0", ps, depth, &(q_u->unknown_0));
+ prs_uint32("rid_alias", ps, depth, &(q_u->rid_alias));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_open_alias");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("pol", &(r_u->pol), ps, depth);
+ prs_align(ps);
+
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+/*******************************************************************
+makes a SAMR_Q_UNKNOWN_38 structure.
+********************************************************************/
+void make_samr_q_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, char *srv_name)
+{
+ int len_srv_name = strlen(srv_name);
+
+ if (q_u == NULL) return;
+
+ DEBUG(5,("make_q_unknown_38\n"));
+
+ q_u->ptr = 1;
+ make_uni_hdr(&(q_u->hdr_srv_name), len_srv_name, len_srv_name, len_srv_name != 0);
+ make_unistr2(&(q_u->uni_srv_name), srv_name, len_srv_name);
+
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_q_unknown_38(char *desc, SAMR_Q_UNKNOWN_38 *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_q_unknown_38");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr", ps, depth, &(q_u->ptr));
+ if (q_u->ptr != 0)
+ {
+ smb_io_unihdr ("", &(q_u->hdr_srv_name), ps, depth);
+ smb_io_unistr2("", &(q_u->uni_srv_name), q_u->hdr_srv_name.buffer, ps, depth);
+ }
+}
+
+/*******************************************************************
+makes a SAMR_R_UNKNOWN_38 structure.
+********************************************************************/
+void make_samr_r_unknown_38(SAMR_R_UNKNOWN_38 *r_u,
+ uint16 level, uint32 status)
+{
+ if (r_u == NULL) return;
+
+ DEBUG(5,("make_r_unknown_38\n"));
+
+ r_u->level.value = level;
+ r_u->ptr_0 = 0;
+ r_u->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_io_r_unknown_38(char *desc, SAMR_R_UNKNOWN_38 *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_r_unknown_38");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_lookup_level("level ", &(r_u->level), ps, depth);
+ prs_uint32("ptr_0 ", ps, depth, &(r_u->ptr_0 ));
+ prs_uint32("status", ps, depth, &(r_u->status));
+}
+
+/*******************************************************************
+reads or writes a SAMR_ENC_PASSWD structure.
+********************************************************************/
+void samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD *pwd, prs_struct *ps, int depth)
+{
+ if (pwd == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_enc_passwd");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr", ps, depth, &(pwd->ptr));
+ prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass));
+}
+
+/*******************************************************************
+reads or writes a SAMR_ENC_HASH structure.
+********************************************************************/
+void samr_io_enc_hash(char *desc, SAMR_ENC_HASH *hsh, prs_struct *ps, int depth)
+{
+ if (hsh == NULL) return;
+
+ prs_debug(ps, depth, desc, "samr_io_enc_hash");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr ", ps, depth, &(hsh->ptr));
+ prs_uint8s(False, "hash", ps, depth, hsh->hash, sizeof(hsh->hash));
+}
+
+#if 0
+/* SAMR_Q_CHGPASSWD_USER */
+typedef struct q_samr_chgpasswd_user_info
+{
+ uint32 ptr_0;
+
+ UNIHDR hdr_server; /* server name unicode header */
+ UNISTR2 uni_server; /* server name unicode string */
+
+ UNIHDR hdr_user_name; /* username unicode string header */
+ UNISTR2 uni_user_name; /* username unicode string */
+
+ SAMR_ENC_PASSWD nt_newpass;
+ SAMR_ENC_HASH nt_oldhash;
+
+ uint32 unknown_1; /* seems to always contain 0001 */
+
+ SAMR_ENC_PASSWD lm_newpass;
+ SAMR_ENC_HASH lm_oldhash;
+
+} SAMR_Q_CHGPASSWD_USER;
+
+/* SAMR_R_CHGPASSWD_USER */
+typedef struct r_samr_chgpasswd_user_info
+{
+ uint32 result; /* 0 == OK, C000006A (NT_STATUS_WRONG_PASSWORD) */
+
+} SAMR_R_CHGPASSWD_USER;
+
+#endif /* 0 */
+
diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c
new file mode 100644
index 0000000000..959a6096aa
--- /dev/null
+++ b/source3/rpc_parse/parse_srv.c
@@ -0,0 +1,1528 @@
+
+/*
+ * Unix SMB/Netbios implementation.
+ * Version 1.9.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include "includes.h"
+
+extern int DEBUGLEVEL;
+
+
+/*******************************************************************
+ makes a SH_INFO_1_STR structure
+********************************************************************/
+void make_srv_share_info1_str(SH_INFO_1_STR *sh1, char *net_name, char *remark)
+{
+ if (sh1 == NULL) return;
+
+ DEBUG(5,("make_srv_share_info1_str\n"));
+
+ make_unistr2(&(sh1->uni_netname), net_name, strlen(net_name)+1);
+ make_unistr2(&(sh1->uni_remark ), remark , strlen(remark )+1);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_share_info1_str(char *desc, SH_INFO_1_STR *sh1, prs_struct *ps, int depth)
+{
+ if (sh1 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info1_str");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_unistr2("", &(sh1->uni_netname), True, ps, depth);
+ smb_io_unistr2("", &(sh1->uni_remark ), True, ps, depth);
+}
+
+/*******************************************************************
+ makes a SH_INFO_1 structure
+********************************************************************/
+void make_srv_share_info1(SH_INFO_1 *sh1, char *net_name, uint32 type, char *remark)
+{
+ if (sh1 == NULL) return;
+
+ DEBUG(5,("make_srv_share_info1: %s %8x %s\n", net_name, type, remark));
+
+ sh1->ptr_netname = net_name != NULL ? 1 : 0;
+ sh1->type = type;
+ sh1->ptr_remark = remark != NULL ? 1 : 0;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_share_info1(char *desc, SH_INFO_1 *sh1, prs_struct *ps, int depth)
+{
+ if (sh1 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info1");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_netname", ps, depth, &(sh1->ptr_netname));
+ prs_uint32("type ", ps, depth, &(sh1->type ));
+ prs_uint32("ptr_remark ", ps, depth, &(sh1->ptr_remark));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_srv_share_info_1(char *desc, SRV_SHARE_INFO_1 *ctr, prs_struct *ps, int depth)
+{
+ if (ctr == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_share_1_ctr");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries_read", ps, depth, &(ctr->num_entries_read));
+ prs_uint32("ptr_share_info", ps, depth, &(ctr->ptr_share_info));
+
+ if (ctr->ptr_share_info != 0)
+ {
+ int i;
+ int num_entries = ctr->num_entries_read;
+ if (num_entries > MAX_SHARE_ENTRIES)
+ {
+ num_entries = MAX_SHARE_ENTRIES; /* report this! */
+ }
+
+ prs_uint32("num_entries_read2", ps, depth, &(ctr->num_entries_read2));
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_share_info1("", &(ctr->info_1[i]), ps, depth);
+ }
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_share_info1_str("", &(ctr->info_1_str[i]), ps, depth);
+ }
+
+ prs_align(ps);
+ }
+}
+
+/*******************************************************************
+ makes a SH_INFO_2_STR structure
+********************************************************************/
+void make_srv_share_info2_str(SH_INFO_2_STR *sh2,
+ char *net_name, char *remark,
+ char *path, char *passwd)
+{
+ if (sh2 == NULL) return;
+
+ DEBUG(5,("make_srv_share_info2_str\n"));
+
+ make_unistr2(&(sh2->uni_netname), net_name, strlen(net_name)+1);
+ make_unistr2(&(sh2->uni_remark ), remark , strlen(remark )+1);
+ make_unistr2(&(sh2->uni_path ), path , strlen(path )+1);
+ make_unistr2(&(sh2->uni_passwd ), passwd , strlen(passwd )+1);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_share_info2_str(char *desc, SH_INFO_2_STR *sh2, prs_struct *ps, int depth)
+{
+ if (sh2 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info2_str");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_unistr2("", &(sh2->uni_netname), True, ps, depth);
+ smb_io_unistr2("", &(sh2->uni_remark ), True, ps, depth);
+ smb_io_unistr2("", &(sh2->uni_path ), True, ps, depth);
+ smb_io_unistr2("", &(sh2->uni_passwd ), True, ps, depth);
+}
+
+/*******************************************************************
+ makes a SH_INFO_2 structure
+********************************************************************/
+void make_srv_share_info2(SH_INFO_2 *sh2,
+ char *net_name, uint32 type, char *remark,
+ uint32 perms, uint32 max_uses, uint32 num_uses,
+ char *path, char *passwd)
+{
+ if (sh2 == NULL) return;
+
+ DEBUG(5,("make_srv_share_info2: %s %8x %s\n", net_name, type, remark));
+
+ sh2->ptr_netname = net_name != NULL ? 1 : 0;
+ sh2->type = type;
+ sh2->ptr_remark = remark != NULL ? 1 : 0;
+ sh2->perms = perms;
+ sh2->max_uses = max_uses;
+ sh2->num_uses = num_uses;
+ sh2->type = type;
+ sh2->ptr_path = path != NULL ? 1 : 0;
+ sh2->ptr_passwd = passwd != NULL ? 1 : 0;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_share_info2(char *desc, SH_INFO_2 *sh2, prs_struct *ps, int depth)
+{
+ if (sh2 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_share_info2");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_netname", ps, depth, &(sh2->ptr_netname));
+ prs_uint32("type ", ps, depth, &(sh2->type ));
+ prs_uint32("ptr_remark ", ps, depth, &(sh2->ptr_remark ));
+ prs_uint32("perms ", ps, depth, &(sh2->perms ));
+ prs_uint32("max_uses ", ps, depth, &(sh2->max_uses ));
+ prs_uint32("num_uses ", ps, depth, &(sh2->num_uses ));
+ prs_uint32("ptr_path ", ps, depth, &(sh2->ptr_path ));
+ prs_uint32("ptr_passwd ", ps, depth, &(sh2->ptr_passwd ));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_srv_share_info_2(char *desc, SRV_SHARE_INFO_2 *ctr, prs_struct *ps, int depth)
+{
+ if (ctr == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_share_2_ctr");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries_read", ps, depth, &(ctr->num_entries_read));
+ prs_uint32("ptr_share_info", ps, depth, &(ctr->ptr_share_info));
+
+ if (ctr->ptr_share_info != 0)
+ {
+ int i;
+ int num_entries = ctr->num_entries_read;
+ if (num_entries > MAX_SHARE_ENTRIES)
+ {
+ num_entries = MAX_SHARE_ENTRIES; /* report this! */
+ }
+
+ prs_uint32("num_entries_read2", ps, depth, &(ctr->num_entries_read2));
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_share_info2("", &(ctr->info_2[i]), ps, depth);
+ }
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_share_info2_str("", &(ctr->info_2_str[i]), ps, depth);
+ }
+
+ prs_align(ps);
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_srv_share_ctr(char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth)
+{
+ if (ctr == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_share_ctr");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("switch_value", ps, depth, &(ctr->switch_value));
+ prs_uint32("ptr_share_ctr", ps, depth, &(ctr->ptr_share_ctr));
+
+ if (ctr->ptr_share_ctr != 0)
+ {
+ switch (ctr->switch_value)
+ {
+ case 2:
+ {
+ srv_io_srv_share_info_2("", &(ctr->share.info2), ps, depth);
+ break;
+ }
+ case 1:
+ {
+ srv_io_srv_share_info_1("", &(ctr->share.info1), ps, depth);
+ break;
+ }
+ default:
+ {
+ DEBUG(5,("%s no share info at switch_value %d\n",
+ tab_depth(depth), ctr->switch_value));
+ break;
+ }
+ }
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void make_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n,
+ char *srv_name,
+ uint32 share_level, SRV_SHARE_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd)
+{
+ if (q_n == NULL || ctr == NULL || hnd == NULL) return;
+
+ q_n->ctr = ctr;
+
+ DEBUG(5,("make_q_net_share_enum\n"));
+
+ make_buf_unistr2(&(q_n->uni_srv_name), &(q_n->ptr_srv_name), srv_name);
+
+ q_n->share_level = share_level;
+ q_n->preferred_len = preferred_len;
+
+ memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_q_net_share_enum(char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_share_enum");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_srv_name", ps, depth, &(q_n->ptr_srv_name));
+ smb_io_unistr2("", &(q_n->uni_srv_name), True, ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("share_level", ps, depth, &(q_n->share_level ));
+
+ if (q_n->share_level != -1)
+ {
+ srv_io_srv_share_ctr("share_ctr", q_n->ctr, ps, depth);
+ }
+
+ prs_uint32("preferred_len", ps, depth, &(q_n->preferred_len));
+
+ smb_io_enum_hnd("enum_hnd", &(q_n->enum_hnd), ps, depth);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_r_net_share_enum(char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_share_enum");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("share_level", ps, depth, &(r_n->share_level));
+
+ if (r_n->share_level != 0)
+ {
+ srv_io_srv_share_ctr("share_ctr", r_n->ctr, ps, depth);
+ }
+
+ prs_uint32("total_entries", ps, depth, &(r_n->total_entries));
+ smb_io_enum_hnd("enum_hnd", &(r_n->enum_hnd), ps, depth);
+ prs_uint32("status ", ps, depth, &(r_n->status));
+}
+
+/*******************************************************************
+ makes a SESS_INFO_0_STR structure
+********************************************************************/
+void make_srv_sess_info0_str(SESS_INFO_0_STR *ss0, char *name)
+{
+ if (ss0 == NULL) return;
+
+ DEBUG(5,("make_srv_sess_info0_str\n"));
+
+ make_unistr2(&(ss0->uni_name), name, strlen(name));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_sess_info0_str(char *desc, SESS_INFO_0_STR *ss0, prs_struct *ps, int depth)
+{
+ if (ss0 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_sess_info0_str");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_unistr2("", &(ss0->uni_name), True, ps, depth);
+}
+
+/*******************************************************************
+ makes a SESS_INFO_0 structure
+********************************************************************/
+void make_srv_sess_info0(SESS_INFO_0 *ss0, char *name)
+{
+ if (ss0 == NULL) return;
+
+ DEBUG(5,("make_srv_sess_info0: %s\n", name));
+
+ ss0->ptr_name = name != NULL ? 1 : 0;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_sess_info0(char *desc, SESS_INFO_0 *ss0, prs_struct *ps, int depth)
+{
+ if (ss0 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_sess_info0");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_name", ps, depth, &(ss0->ptr_name));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_srv_sess_info_0(char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth)
+{
+ if (ss0 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries_read", ps, depth, &(ss0->num_entries_read));
+ prs_uint32("ptr_sess_info", ps, depth, &(ss0->ptr_sess_info));
+
+ if (ss0->ptr_sess_info != 0)
+ {
+ int i;
+ int num_entries = ss0->num_entries_read;
+ if (num_entries > MAX_SESS_ENTRIES)
+ {
+ num_entries = MAX_SESS_ENTRIES; /* report this! */
+ }
+
+ prs_uint32("num_entries_read2", ps, depth, &(ss0->num_entries_read2));
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_sess_info0("", &(ss0->info_0[i]), ps, depth);
+ }
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_sess_info0_str("", &(ss0->info_0_str[i]), ps, depth);
+ }
+
+ prs_align(ps);
+ }
+}
+
+/*******************************************************************
+ makes a SESS_INFO_1_STR structure
+********************************************************************/
+void make_srv_sess_info1_str(SESS_INFO_1_STR *ss1, char *name, char *user)
+{
+ if (ss1 == NULL) return;
+
+ DEBUG(5,("make_srv_sess_info1_str\n"));
+
+ make_unistr2(&(ss1->uni_name), name, strlen(name));
+ make_unistr2(&(ss1->uni_user), name, strlen(user));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_sess_info1_str(char *desc, SESS_INFO_1_STR *ss1, prs_struct *ps, int depth)
+{
+ if (ss1 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_sess_info1_str");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_unistr2("", &(ss1->uni_name), True, ps, depth);
+ smb_io_unistr2("", &(ss1->uni_user), True, ps, depth);
+}
+
+/*******************************************************************
+ makes a SESS_INFO_1 structure
+********************************************************************/
+void make_srv_sess_info1(SESS_INFO_1 *ss1,
+ char *name, char *user,
+ uint32 num_opens, uint32 open_time, uint32 idle_time,
+ uint32 user_flags)
+{
+ if (ss1 == NULL) return;
+
+ DEBUG(5,("make_srv_sess_info1: %s\n", name));
+
+ ss1->ptr_name = name != NULL ? 1 : 0;
+ ss1->ptr_user = user != NULL ? 1 : 0;
+
+ ss1->num_opens = num_opens;
+ ss1->open_time = open_time;
+ ss1->idle_time = idle_time;
+ ss1->user_flags = user_flags;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_sess_info1(char *desc, SESS_INFO_1 *ss1, prs_struct *ps, int depth)
+{
+ if (ss1 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_sess_info1");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_name ", ps, depth, &(ss1->ptr_name ));
+ prs_uint32("ptr_user ", ps, depth, &(ss1->ptr_user ));
+
+ prs_uint32("num_opens ", ps, depth, &(ss1->num_opens ));
+ prs_uint32("open_time ", ps, depth, &(ss1->open_time ));
+ prs_uint32("idle_time ", ps, depth, &(ss1->idle_time ));
+ prs_uint32("user_flags", ps, depth, &(ss1->user_flags));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_srv_sess_info_1(char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth)
+{
+ if (ss1 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries_read", ps, depth, &(ss1->num_entries_read));
+ prs_uint32("ptr_sess_info", ps, depth, &(ss1->ptr_sess_info));
+
+ if (ss1->ptr_sess_info != 0)
+ {
+ int i;
+ int num_entries = ss1->num_entries_read;
+ if (num_entries > MAX_SESS_ENTRIES)
+ {
+ num_entries = MAX_SESS_ENTRIES; /* report this! */
+ }
+
+ prs_uint32("num_entries_read2", ps, depth, &(ss1->num_entries_read2));
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_sess_info1("", &(ss1->info_1[i]), ps, depth);
+ }
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_sess_info1_str("", &(ss1->info_1_str[i]), ps, depth);
+ }
+
+ prs_align(ps);
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_srv_sess_ctr(char *desc, SRV_SESS_INFO_CTR *ctr, prs_struct *ps, int depth)
+{
+ if (ctr == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("switch_value", ps, depth, &(ctr->switch_value));
+ prs_uint32("ptr_sess_ctr", ps, depth, &(ctr->ptr_sess_ctr));
+
+ if (ctr->ptr_sess_ctr != 0)
+ {
+ switch (ctr->switch_value)
+ {
+ case 0:
+ {
+ srv_io_srv_sess_info_0("", &(ctr->sess.info0), ps, depth);
+ break;
+ }
+ case 1:
+ {
+ srv_io_srv_sess_info_1("", &(ctr->sess.info1), ps, depth);
+ break;
+ }
+ default:
+ {
+ DEBUG(5,("%s no session info at switch_value %d\n",
+ tab_depth(depth), ctr->switch_value));
+ break;
+ }
+ }
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void make_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n,
+ char *srv_name, char *qual_name,
+ uint32 sess_level, SRV_SESS_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd)
+{
+ if (q_n == NULL || ctr == NULL || hnd == NULL) return;
+
+ q_n->ctr = ctr;
+
+ DEBUG(5,("make_q_net_sess_enum\n"));
+
+ make_buf_unistr2(&(q_n->uni_srv_name), &(q_n->ptr_srv_name), srv_name);
+ make_buf_unistr2(&(q_n->uni_qual_name), &(q_n->ptr_qual_name), qual_name);
+
+ q_n->sess_level = sess_level;
+ q_n->preferred_len = preferred_len;
+
+ memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_q_net_sess_enum(char *desc, SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_srv_name", ps, depth, &(q_n->ptr_srv_name));
+ smb_io_unistr2("", &(q_n->uni_srv_name), True, ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("ptr_qual_name", ps, depth, &(q_n->ptr_qual_name));
+ smb_io_unistr2("", &(q_n->uni_qual_name), True, ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("sess_level", ps, depth, &(q_n->sess_level ));
+
+ if (q_n->sess_level != -1)
+ {
+ srv_io_srv_sess_ctr("sess_ctr", q_n->ctr, ps, depth);
+ }
+
+ prs_uint32("preferred_len", ps, depth, &(q_n->preferred_len));
+
+ smb_io_enum_hnd("enum_hnd", &(q_n->enum_hnd), ps, depth);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_r_net_sess_enum(char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("sess_level", ps, depth, &(r_n->sess_level));
+
+ if (r_n->sess_level != -1)
+ {
+ srv_io_srv_sess_ctr("sess_ctr", r_n->ctr, ps, depth);
+ }
+
+ prs_uint32("total_entries", ps, depth, &(r_n->total_entries));
+ smb_io_enum_hnd("enum_hnd", &(r_n->enum_hnd), ps, depth);
+ prs_uint32("status ", ps, depth, &(r_n->status));
+}
+
+/*******************************************************************
+ makes a CONN_INFO_0 structure
+********************************************************************/
+void make_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
+{
+ if (ss0 == NULL) return;
+
+ DEBUG(5,("make_srv_conn_info0\n"));
+
+ ss0->id = id;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_conn_info0(char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth)
+{
+ if (ss0 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_conn_info0");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("id", ps, depth, &(ss0->id));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_srv_conn_info_0(char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
+{
+ if (ss0 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries_read", ps, depth, &(ss0->num_entries_read));
+ prs_uint32("ptr_conn_info", ps, depth, &(ss0->ptr_conn_info));
+
+ if (ss0->ptr_conn_info != 0)
+ {
+ int i;
+ int num_entries = ss0->num_entries_read;
+ if (num_entries > MAX_CONN_ENTRIES)
+ {
+ num_entries = MAX_CONN_ENTRIES; /* report this! */
+ }
+
+ prs_uint32("num_entries_read2", ps, depth, &(ss0->num_entries_read2));
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_conn_info0("", &(ss0->info_0[i]), ps, depth);
+ }
+
+ prs_align(ps);
+ }
+}
+
+/*******************************************************************
+ makes a CONN_INFO_1_STR structure
+********************************************************************/
+void make_srv_conn_info1_str(CONN_INFO_1_STR *ss1, char *usr_name, char *net_name)
+{
+ if (ss1 == NULL) return;
+
+ DEBUG(5,("make_srv_conn_info1_str\n"));
+
+ make_unistr2(&(ss1->uni_usr_name), usr_name, strlen(usr_name));
+ make_unistr2(&(ss1->uni_net_name), net_name, strlen(net_name));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_conn_info1_str(char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
+{
+ if (ss1 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_unistr2("", &(ss1->uni_usr_name), True, ps, depth);
+ smb_io_unistr2("", &(ss1->uni_net_name), True, ps, depth);
+}
+
+/*******************************************************************
+ makes a CONN_INFO_1 structure
+********************************************************************/
+void make_srv_conn_info1(CONN_INFO_1 *ss1,
+ uint32 id, uint32 type,
+ uint32 num_opens, uint32 num_users, uint32 open_time,
+ char *usr_name, char *net_name)
+{
+ if (ss1 == NULL) return;
+
+ DEBUG(5,("make_srv_conn_info1: %s %s\n", usr_name, net_name));
+
+ ss1->id = id ;
+ ss1->type = type ;
+ ss1->num_opens = num_opens ;
+ ss1->num_users = num_users;
+ ss1->open_time = open_time;
+
+ ss1->ptr_usr_name = usr_name != NULL ? 1 : 0;
+ ss1->ptr_net_name = net_name != NULL ? 1 : 0;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_conn_info1(char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth)
+{
+ if (ss1 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_conn_info1");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("id ", ps, depth, &(ss1->id ));
+ prs_uint32("type ", ps, depth, &(ss1->type ));
+ prs_uint32("num_opens ", ps, depth, &(ss1->num_opens ));
+ prs_uint32("num_users ", ps, depth, &(ss1->num_users ));
+ prs_uint32("open_time ", ps, depth, &(ss1->open_time ));
+
+ prs_uint32("ptr_usr_name", ps, depth, &(ss1->ptr_usr_name));
+ prs_uint32("ptr_net_name", ps, depth, &(ss1->ptr_net_name));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_srv_conn_info_1(char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
+{
+ if (ss1 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries_read", ps, depth, &(ss1->num_entries_read));
+ prs_uint32("ptr_conn_info", ps, depth, &(ss1->ptr_conn_info));
+
+ if (ss1->ptr_conn_info != 0)
+ {
+ int i;
+ int num_entries = ss1->num_entries_read;
+ if (num_entries > MAX_CONN_ENTRIES)
+ {
+ num_entries = MAX_CONN_ENTRIES; /* report this! */
+ }
+
+ prs_uint32("num_entries_read2", ps, depth, &(ss1->num_entries_read2));
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_conn_info1("", &(ss1->info_1[i]), ps, depth);
+ }
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_conn_info1_str("", &(ss1->info_1_str[i]), ps, depth);
+ }
+
+ prs_align(ps);
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_srv_conn_ctr(char *desc, SRV_CONN_INFO_CTR *ctr, prs_struct *ps, int depth)
+{
+ if (ctr == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("switch_value", ps, depth, &(ctr->switch_value));
+ prs_uint32("ptr_conn_ctr", ps, depth, &(ctr->ptr_conn_ctr));
+
+ if (ctr->ptr_conn_ctr != 0)
+ {
+ switch (ctr->switch_value)
+ {
+ case 0:
+ {
+ srv_io_srv_conn_info_0("", &(ctr->conn.info0), ps, depth);
+ break;
+ }
+ case 1:
+ {
+ srv_io_srv_conn_info_1("", &(ctr->conn.info1), ps, depth);
+ break;
+ }
+ default:
+ {
+ DEBUG(5,("%s no connection info at switch_value %d\n",
+ tab_depth(depth), ctr->switch_value));
+ break;
+ }
+ }
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void make_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n,
+ char *srv_name, char *qual_name,
+ uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd)
+{
+ if (q_n == NULL || ctr == NULL || hnd == NULL) return;
+
+ q_n->ctr = ctr;
+
+ DEBUG(5,("make_q_net_conn_enum\n"));
+
+ make_buf_unistr2(&(q_n->uni_srv_name ), &(q_n->ptr_srv_name ), srv_name );
+ make_buf_unistr2(&(q_n->uni_qual_name), &(q_n->ptr_qual_name), qual_name);
+
+ q_n->conn_level = conn_level;
+ q_n->preferred_len = preferred_len;
+
+ memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_q_net_conn_enum(char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_srv_name ", ps, depth, &(q_n->ptr_srv_name));
+ smb_io_unistr2("", &(q_n->uni_srv_name), q_n->ptr_srv_name, ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("ptr_qual_name", ps, depth, &(q_n->ptr_qual_name));
+ smb_io_unistr2("", &(q_n->uni_qual_name), q_n->ptr_qual_name, ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("conn_level", ps, depth, &(q_n->conn_level ));
+
+ if (q_n->conn_level != -1)
+ {
+ srv_io_srv_conn_ctr("conn_ctr", q_n->ctr, ps, depth);
+ }
+
+ prs_uint32("preferred_len", ps, depth, &(q_n->preferred_len));
+
+ smb_io_enum_hnd("enum_hnd", &(q_n->enum_hnd), ps, depth);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_r_net_conn_enum(char *desc, SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("conn_level", ps, depth, &(r_n->conn_level));
+
+ if (r_n->conn_level != -1)
+ {
+ srv_io_srv_conn_ctr("conn_ctr", r_n->ctr, ps, depth);
+ }
+
+ prs_uint32("total_entries", ps, depth, &(r_n->total_entries));
+ smb_io_enum_hnd("enum_hnd", &(r_n->enum_hnd), ps, depth);
+ prs_uint32("status ", ps, depth, &(r_n->status));
+}
+
+/*******************************************************************
+ makes a FILE_INFO_3_STR structure
+********************************************************************/
+void make_srv_file_info3_str(FILE_INFO_3_STR *fi3, char *user_name, char *path_name)
+{
+ if (fi3 == NULL) return;
+
+ DEBUG(5,("make_srv_file_info3_str\n"));
+
+ make_unistr2(&(fi3->uni_path_name), path_name, strlen(path_name)+1);
+ make_unistr2(&(fi3->uni_user_name), user_name, strlen(user_name)+1);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_file_info3_str(char *desc, FILE_INFO_3_STR *sh1, prs_struct *ps, int depth)
+{
+ if (sh1 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_file_info3_str");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_unistr2("", &(sh1->uni_path_name), True, ps, depth);
+ smb_io_unistr2("", &(sh1->uni_user_name), True, ps, depth);
+}
+
+/*******************************************************************
+ makes a FILE_INFO_3 structure
+********************************************************************/
+void make_srv_file_info3(FILE_INFO_3 *fl3,
+ uint32 id, uint32 perms, uint32 num_locks,
+ char *path_name, char *user_name)
+{
+ if (fl3 == NULL) return;
+
+ DEBUG(5,("make_srv_file_info3: %s %s\n", path_name, user_name));
+
+ fl3->id = id;
+ fl3->perms = perms;
+ fl3->num_locks = num_locks;
+
+ fl3->ptr_path_name = path_name != NULL ? 1 : 0;
+ fl3->ptr_user_name = user_name != NULL ? 1 : 0;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_file_info3(char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth)
+{
+ if (fl3 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_file_info3");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("id ", ps, depth, &(fl3->id ));
+ prs_uint32("perms ", ps, depth, &(fl3->perms ));
+ prs_uint32("num_locks ", ps, depth, &(fl3->num_locks ));
+ prs_uint32("ptr_path_name", ps, depth, &(fl3->ptr_path_name));
+ prs_uint32("ptr_user_name", ps, depth, &(fl3->ptr_user_name));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_srv_file_info_3(char *desc, SRV_FILE_INFO_3 *fl3, prs_struct *ps, int depth)
+{
+ if (fl3 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_file_3_fl3");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("num_entries_read", ps, depth, &(fl3->num_entries_read));
+ prs_uint32("ptr_file_fl3", ps, depth, &(fl3->ptr_file_info));
+ if (fl3->ptr_file_info != 0)
+ {
+ int i;
+ int num_entries = fl3->num_entries_read;
+ if (num_entries > MAX_FILE_ENTRIES)
+ {
+ num_entries = MAX_FILE_ENTRIES; /* report this! */
+ }
+
+ prs_uint32("num_entries_read2", ps, depth, &(fl3->num_entries_read2));
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_file_info3("", &(fl3->info_3[i]), ps, depth);
+ }
+
+ for (i = 0; i < num_entries; i++)
+ {
+ prs_grow(ps);
+ srv_io_file_info3_str("", &(fl3->info_3_str[i]), ps, depth);
+ }
+
+ prs_align(ps);
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_srv_file_ctr(char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth)
+{
+ if (ctr == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("switch_value", ps, depth, &(ctr->switch_value));
+ prs_uint32("ptr_file_ctr", ps, depth, &(ctr->ptr_file_ctr));
+
+ if (ctr->ptr_file_ctr != 0)
+ {
+ switch (ctr->switch_value)
+ {
+ case 3:
+ {
+ srv_io_srv_file_info_3("", &(ctr->file.info3), ps, depth);
+ break;
+ }
+ default:
+ {
+ DEBUG(5,("%s no file info at switch_value %d\n",
+ tab_depth(depth), ctr->switch_value));
+ break;
+ }
+ }
+ }
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void make_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n,
+ char *srv_name, char *qual_name,
+ uint32 file_level, SRV_FILE_INFO_CTR *ctr,
+ uint32 preferred_len,
+ ENUM_HND *hnd)
+{
+ if (q_n == NULL || ctr == NULL || hnd == NULL) return;
+
+ q_n->ctr = ctr;
+
+ DEBUG(5,("make_q_net_file_enum\n"));
+
+ make_buf_unistr2(&(q_n->uni_srv_name), &(q_n->ptr_srv_name), srv_name);
+ make_buf_unistr2(&(q_n->uni_qual_name), &(q_n->ptr_qual_name), qual_name);
+
+ q_n->file_level = file_level;
+ q_n->preferred_len = preferred_len;
+
+ memcpy(&(q_n->enum_hnd), hnd, sizeof(*hnd));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_q_net_file_enum(char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_srv_name", ps, depth, &(q_n->ptr_srv_name));
+ smb_io_unistr2("", &(q_n->uni_srv_name), True, ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("ptr_qual_name", ps, depth, &(q_n->ptr_qual_name));
+ smb_io_unistr2("", &(q_n->uni_qual_name), True, ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("file_level", ps, depth, &(q_n->file_level ));
+
+ if (q_n->file_level != -1)
+ {
+ srv_io_srv_file_ctr("file_ctr", q_n->ctr, ps, depth);
+ }
+
+ prs_uint32("preferred_len", ps, depth, &(q_n->preferred_len));
+
+ smb_io_enum_hnd("enum_hnd", &(q_n->enum_hnd), ps, depth);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_r_net_file_enum(char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("file_level", ps, depth, &(r_n->file_level));
+
+ if (r_n->file_level != 0)
+ {
+ srv_io_srv_file_ctr("file_ctr", r_n->ctr, ps, depth);
+ }
+
+ prs_uint32("total_entries", ps, depth, &(r_n->total_entries));
+ smb_io_enum_hnd("enum_hnd", &(r_n->enum_hnd), ps, depth);
+ prs_uint32("status ", ps, depth, &(r_n->status));
+}
+
+/*******************************************************************
+ makes a SRV_INFO_101 structure.
+ ********************************************************************/
+void make_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, char *name,
+ uint32 ver_major, uint32 ver_minor,
+ uint32 srv_type, char *comment)
+{
+ if (sv101 == NULL) return;
+
+ DEBUG(5,("make_srv_info_101\n"));
+
+ sv101->platform_id = platform_id;
+ make_buf_unistr2(&(sv101->uni_name ), &(sv101->ptr_name ) , name );
+ sv101->ver_major = ver_major;
+ sv101->ver_minor = ver_minor;
+ sv101->srv_type = srv_type;
+ make_buf_unistr2(&(sv101->uni_comment ), &(sv101->ptr_comment) , comment );
+}
+
+
+/*******************************************************************
+ reads or writes a SRV_INFO_101 structure.
+ ********************************************************************/
+void srv_io_info_101(char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth)
+{
+ if (sv101 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_info_101");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("platform_id ", ps, depth, &(sv101->platform_id ));
+ prs_uint32("ptr_name ", ps, depth, &(sv101->ptr_name ));
+ prs_uint32("ver_major ", ps, depth, &(sv101->ver_major ));
+ prs_uint32("ver_minor ", ps, depth, &(sv101->ver_minor ));
+ prs_uint32("srv_type ", ps, depth, &(sv101->srv_type ));
+ prs_uint32("ptr_comment ", ps, depth, &(sv101->ptr_comment ));
+
+ prs_align(ps);
+
+ smb_io_unistr2("uni_name ", &(sv101->uni_name ), True, ps, depth);
+ smb_io_unistr2("uni_comment ", &(sv101->uni_comment ), True, ps, depth);
+}
+
+/*******************************************************************
+ makes a SRV_INFO_102 structure.
+ ********************************************************************/
+void make_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, char *name,
+ char *comment, uint32 ver_major, uint32 ver_minor,
+ uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
+ uint32 announce, uint32 ann_delta, uint32 licenses,
+ char *usr_path)
+{
+ if (sv102 == NULL) return;
+
+ DEBUG(5,("make_srv_info_102\n"));
+
+ sv102->platform_id = platform_id;
+ make_buf_unistr2(&(sv102->uni_name ), &(sv102->ptr_name ), name );
+ sv102->ver_major = ver_major;
+ sv102->ver_minor = ver_minor;
+ sv102->srv_type = srv_type;
+ make_buf_unistr2(&(sv102->uni_comment ), &(sv102->ptr_comment ), comment );
+
+ /* same as 101 up to here */
+
+ sv102->users = users;
+ sv102->disc = disc;
+ sv102->hidden = hidden;
+ sv102->announce = announce;
+ sv102->ann_delta =ann_delta;
+ sv102->licenses = licenses;
+ make_buf_unistr2(&(sv102->uni_usr_path), &(sv102->ptr_usr_path), usr_path);
+}
+
+
+/*******************************************************************
+ reads or writes a SRV_INFO_102 structure.
+ ********************************************************************/
+void srv_io_info_102(char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth)
+{
+ if (sv102 == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_info102");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("platform_id ", ps, depth, &(sv102->platform_id ));
+ prs_uint32("ptr_name ", ps, depth, &(sv102->ptr_name ));
+ prs_uint32("ver_major ", ps, depth, &(sv102->ver_major ));
+ prs_uint32("ver_minor ", ps, depth, &(sv102->ver_minor ));
+ prs_uint32("srv_type ", ps, depth, &(sv102->srv_type ));
+ prs_uint32("ptr_comment ", ps, depth, &(sv102->ptr_comment ));
+
+ /* same as 101 up to here */
+
+ prs_uint32("users ", ps, depth, &(sv102->users ));
+ prs_uint32("disc ", ps, depth, &(sv102->disc ));
+ prs_uint32("hidden ", ps, depth, &(sv102->hidden ));
+ prs_uint32("announce ", ps, depth, &(sv102->announce ));
+ prs_uint32("ann_delta ", ps, depth, &(sv102->ann_delta ));
+ prs_uint32("licenses ", ps, depth, &(sv102->licenses ));
+ prs_uint32("ptr_usr_path", ps, depth, &(sv102->ptr_usr_path));
+
+ smb_io_unistr2("uni_name ", &(sv102->uni_name ), True, ps, depth);
+ prs_align(ps);
+ smb_io_unistr2("uni_comment ", &(sv102->uni_comment ), True, ps, depth);
+ prs_align(ps);
+ smb_io_unistr2("uni_usr_path", &(sv102->uni_usr_path), True, ps, depth);
+}
+
+/*******************************************************************
+ reads or writes a SRV_INFO_102 structure.
+ ********************************************************************/
+void srv_io_info_ctr(char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
+{
+ if (ctr == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_info_ctr");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("switch_value", ps, depth, &(ctr->switch_value));
+ prs_uint32("ptr_srv_ctr ", ps, depth, &(ctr->ptr_srv_ctr ));
+
+ if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL)
+ {
+ switch (ctr->switch_value)
+ {
+ case 101:
+ {
+ srv_io_info_101("sv101", &(ctr->srv.sv101), ps, depth);
+ break;
+ }
+ case 102:
+ {
+ srv_io_info_102("sv102", &(ctr->srv.sv102), ps, depth);
+ break;
+ }
+ default:
+ {
+ DEBUG(5,("%s% no server info at switch_value %d\n",
+ tab_depth(depth), ctr->switch_value));
+ break;
+ }
+ }
+ }
+}
+
+/*******************************************************************
+ makes a SRV_Q_NET_SRV_GET_INFO structure.
+ ********************************************************************/
+void make_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
+ char *server_name, uint32 switch_value)
+{
+ if (srv == NULL) return;
+
+ DEBUG(5,("make_srv_q_net_srv_get_info\n"));
+
+ make_buf_unistr2(&(srv->uni_srv_name), &(srv->ptr_srv_name), server_name);
+
+ srv->switch_value = switch_value;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_q_net_srv_get_info(char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_srv_name ", ps, depth, &(q_n->ptr_srv_name));
+ smb_io_unistr2("", &(q_n->uni_srv_name), True, ps, depth);
+
+ prs_align(ps);
+
+ prs_uint32("switch_value ", ps, depth, &(q_n->switch_value));
+}
+
+/*******************************************************************
+ makes a SRV_R_NET_SRV_GET_INFO structure.
+ ********************************************************************/
+void make_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
+ uint32 switch_value, SRV_INFO_CTR *ctr, uint32 status)
+{
+ if (srv == NULL) return;
+
+ DEBUG(5,("make_srv_r_net_srv_get_info\n"));
+
+ srv->ctr = ctr;
+
+ if (status == 0x0)
+ {
+ srv->ctr->switch_value = switch_value;
+ srv->ctr->ptr_srv_ctr = 1;
+ }
+ else
+ {
+ srv->ctr->switch_value = 0;
+ srv->ctr->ptr_srv_ctr = 0;
+ }
+
+ srv->status = status;
+}
+
+/*******************************************************************
+ reads or writes a structure.
+ ********************************************************************/
+void srv_io_r_net_srv_get_info(char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
+ depth++;
+
+ prs_align(ps);
+
+ srv_io_info_ctr("ctr", r_n->ctr, ps, depth);
+
+ prs_uint32("status ", ps, depth, &(r_n->status ));
+}
+
+
+/*******************************************************************
+ makes a SRV_Q_NET_SRV_SET_INFO structure.
+ ********************************************************************/
+void make_srv_q_net_srv_set_info(SRV_Q_NET_SRV_SET_INFO *srv,
+ uint32 switch_value, SRV_INFO_CTR *ctr)
+{
+ if (srv == NULL) return;
+
+ DEBUG(5,("make_srv_r_net_srv_set_info\n"));
+
+ srv->ctr = ctr;
+
+ srv->ctr->switch_value = switch_value;
+ srv->ctr->ptr_srv_ctr = 1;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void srv_io_q_net_srv_set_info(char *desc, SRV_Q_NET_SRV_SET_INFO *q_n, prs_struct *ps, int depth)
+{
+ if (q_n == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_srv_name ", ps, depth, &(q_n->ptr_srv_name));
+ smb_io_unistr2("", &(q_n->uni_srv_name), True, ps, depth);
+
+ prs_align(ps);
+
+ srv_io_info_ctr("ctr", q_n->ctr, ps, depth);
+}
+
+/*******************************************************************
+ makes a SRV_R_NET_SRV_SET_INFO structure.
+ ********************************************************************/
+void make_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv,
+ uint32 switch_value, SRV_INFO_CTR *ctr, uint32 status)
+{
+ if (srv == NULL) return;
+
+ DEBUG(5,("make_srv_r_net_srv_set_info\n"));
+
+ if (status == 0x0)
+ {
+ srv->switch_value = switch_value;
+ }
+ else
+ {
+ srv->switch_value = 0;
+ }
+
+ srv->status = status;
+}
+
+/*******************************************************************
+ reads or writes a structure.
+ ********************************************************************/
+void srv_io_r_net_srv_set_info(char *desc, SRV_R_NET_SRV_SET_INFO *r_n, prs_struct *ps, int depth)
+{
+ if (r_n == NULL) return;
+
+ prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("switch_value", ps, depth, &(r_n->switch_value));
+ prs_uint32("status ", ps, depth, &(r_n->status ));
+}
+
+
diff --git a/source3/rpc_parse/parse_wks.c b/source3/rpc_parse/parse_wks.c
new file mode 100644
index 0000000000..694acb5eec
--- /dev/null
+++ b/source3/rpc_parse/parse_wks.c
@@ -0,0 +1,146 @@
+
+/*
+ * Unix SMB/Netbios implementation.
+ * Version 1.9.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include "includes.h"
+
+extern int DEBUGLEVEL;
+
+
+/*******************************************************************
+ make_wks_q_query_info
+ ********************************************************************/
+void make_wks_q_query_info(WKS_Q_QUERY_INFO *q_u,
+ char *server, uint16 switch_value)
+{
+ DEBUG(5,("make_wks_q_query_info: %d\n", __LINE__));
+
+ make_buf_unistr2(&(q_u->uni_srv_name), &(q_u->ptr_srv_name), server);
+ q_u->switch_value = switch_value;
+
+}
+
+/*******************************************************************
+reads or writes a WKS_Q_QUERY_INFO structure.
+********************************************************************/
+void wks_io_q_query_info(char *desc, WKS_Q_QUERY_INFO *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "wks_io_q_query_info");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("ptr_srv_name", ps, depth, &(q_u->ptr_srv_name));
+ smb_io_unistr2("", &(q_u->uni_srv_name), q_u->ptr_srv_name, ps, depth);
+ prs_align(ps);
+
+ prs_uint16("switch_value", ps, depth, &(q_u->switch_value));
+ prs_align(ps);
+}
+
+/*******************************************************************
+ wks_info_100
+ ********************************************************************/
+void make_wks_info_100(WKS_INFO_100 *inf,
+ uint32 platform_id, uint32 ver_major, uint32 ver_minor,
+ char *my_name, char *domain_name)
+{
+ DEBUG(5,("WKS_INFO_100: %d\n", __LINE__));
+
+ inf->platform_id = platform_id; /* 0x0000 01f4 - unknown */
+ inf->ver_major = ver_major; /* os major version */
+ inf->ver_minor = ver_minor; /* os minor version */
+
+ make_buf_unistr2(&(inf->uni_compname), &(inf->ptr_compname), my_name );
+ make_buf_unistr2(&(inf->uni_lan_grp ), &(inf->ptr_lan_grp ), domain_name);
+}
+
+/*******************************************************************
+reads or writes a WKS_INFO_100 structure.
+********************************************************************/
+void wks_io_wks_info_100(char *desc, WKS_INFO_100 *inf, prs_struct *ps, int depth)
+{
+ if (inf == NULL) return;
+
+ prs_debug(ps, depth, desc, "wks_io_wks_info_100");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("platform_id ", ps, depth, &(inf->platform_id )); /* 0x0000 01f4 - unknown */
+ prs_uint32("ptr_compname", ps, depth, &(inf->ptr_compname)); /* pointer to computer name */
+ prs_uint32("ptr_lan_grp ", ps, depth, &(inf->ptr_lan_grp )); /* pointer to LAN group name */
+ prs_uint32("ver_major ", ps, depth, &(inf->ver_major )); /* 4 - major os version */
+ prs_uint32("ver_minor ", ps, depth, &(inf->ver_minor )); /* 0 - minor os version */
+
+ smb_io_unistr2("", &(inf->uni_compname), inf->ptr_compname, ps, depth);
+ prs_align(ps);
+
+ smb_io_unistr2("", &(inf->uni_lan_grp ), inf->ptr_lan_grp , ps, depth);
+ prs_align(ps);
+}
+
+/*******************************************************************
+ make_wks_r_query_info
+
+ only supports info level 100 at the moment.
+
+ ********************************************************************/
+void make_wks_r_query_info(WKS_R_QUERY_INFO *r_u,
+ uint32 switch_value, WKS_INFO_100 *wks100,
+ int status)
+{
+ DEBUG(5,("make_wks_r_unknown_0: %d\n", __LINE__));
+
+ r_u->switch_value = switch_value; /* same as in request */
+
+ r_u->ptr_1 = 1; /* pointer 1 */
+ r_u->wks100 = wks100;
+
+ r_u->status = status;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void wks_io_r_query_info(char *desc, WKS_R_QUERY_INFO *r_u, prs_struct *ps, int depth)
+{
+ if (r_u == NULL) return;
+
+ prs_debug(ps, depth, desc, "wks_io_r_query_info");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint16("switch_value", ps, depth, &(r_u->switch_value)); /* level 100 (0x64) */
+ prs_align(ps);
+
+ prs_uint32("ptr_1 ", ps, depth, &(r_u->ptr_1 )); /* pointer 1 */
+ wks_io_wks_info_100("inf", r_u->wks100, ps, depth);
+
+ prs_uint32("status ", ps, depth, &(r_u->status));
+}
+