3 * Unix SMB/Netbios implementation.
5 * RPC Pipe client / server routines
6 * Copyright (C) Andrew Tridgell 1992-1997,
7 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
8 * Copyright (C) Paul Ashton 1997.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 extern int DEBUGLEVEL;
32 /*******************************************************************
33 reads or writes a UTIME type.
34 ********************************************************************/
35 static void smb_io_utime(char *desc, UTIME *t, prs_struct *ps, int depth)
37 if (t == NULL) return;
39 prs_debug(ps, depth, desc, "smb_io_utime");
44 prs_uint32 ("time", ps, depth, &(t->time));
47 /*******************************************************************
48 reads or writes an NTTIME structure.
49 ********************************************************************/
50 void smb_io_time(char *desc, NTTIME *nttime, prs_struct *ps, int depth)
52 if (nttime == NULL) return;
54 prs_debug(ps, depth, desc, "smb_io_time");
59 prs_uint32("low ", ps, depth, &(nttime->low )); /* low part */
60 prs_uint32("high", ps, depth, &(nttime->high)); /* high part */
63 /*******************************************************************
64 reads or writes a LOOKUP_LEVEL structure.
65 ********************************************************************/
66 void smb_io_lookup_level(char *desc, LOOKUP_LEVEL *level, prs_struct *ps, int depth)
68 if (level == NULL) return;
70 prs_debug(ps, depth, desc, "smb_io_lookup_level");
74 prs_uint16("value", ps, depth, &(level->value));
78 /*******************************************************************
79 gets an enumeration handle from an ENUM_HND structure.
80 ********************************************************************/
81 uint32 get_enum_hnd(ENUM_HND *enh)
83 return (enh && enh->ptr_hnd != 0) ? enh->handle : 0;
86 /*******************************************************************
87 makes an ENUM_HND structure.
88 ********************************************************************/
89 void make_enum_hnd(ENUM_HND *enh, uint32 hnd)
91 if (enh == NULL) return;
93 DEBUG(5,("smb_io_enum_hnd\n"));
95 enh->ptr_hnd = (hnd != 0) ? 1 : 0;
99 /*******************************************************************
100 reads or writes an ENUM_HND structure.
101 ********************************************************************/
102 void smb_io_enum_hnd(char *desc, ENUM_HND *hnd, prs_struct *ps, int depth)
104 if (hnd == NULL) return;
106 prs_debug(ps, depth, desc, "smb_io_enum_hnd");
111 prs_uint32("ptr_hnd", ps, depth, &(hnd->ptr_hnd)); /* pointer */
112 if (hnd->ptr_hnd != 0)
114 prs_uint32("handle ", ps, depth, &(hnd->handle )); /* enum handle */
118 /*******************************************************************
119 reads or writes a DOM_SID structure.
120 ********************************************************************/
121 BOOL smb_io_dom_sid(char *desc, DOM_SID *sid, prs_struct *ps, int depth)
125 if (sid == NULL) return False;
127 prs_debug(ps, depth, desc, "smb_io_dom_sid");
132 prs_uint8 ("sid_rev_num", ps, depth, &(sid->sid_rev_num));
133 prs_uint8 ("num_auths ", ps, depth, &(sid->num_auths));
135 for (i = 0; i < 6; i++)
138 slprintf(tmp, sizeof(tmp) - 1, "id_auth[%d] ", i);
139 prs_uint8 (tmp, ps, depth, &(sid->id_auth[i]));
142 /* oops! XXXX should really issue a warning here... */
143 if (sid->num_auths > MAXSUBAUTHS) sid->num_auths = MAXSUBAUTHS;
145 prs_uint32s(False, "sub_auths ", ps, depth, sid->sub_auths, sid->num_auths);
150 /*******************************************************************
151 creates a DOM_SID2 structure.
152 ********************************************************************/
153 void make_dom_sid2(DOM_SID2 *sid2, DOM_SID *sid)
156 sid2->num_auths = sid2->sid.num_auths;
159 /*******************************************************************
160 reads or writes a DOM_SID2 structure.
161 ********************************************************************/
162 void smb_io_dom_sid2(char *desc, DOM_SID2 *sid, prs_struct *ps, int depth)
164 if (sid == NULL) return;
166 prs_debug(ps, depth, desc, "smb_io_dom_sid2");
171 prs_uint32("num_auths", ps, depth, &(sid->num_auths));
173 smb_io_dom_sid("sid", &(sid->sid), ps, depth);
176 /*******************************************************************
177 creates a STRHDR structure.
178 ********************************************************************/
179 void make_str_hdr(STRHDR *hdr, int max_len, int len, uint32 buffer)
181 hdr->str_max_len = max_len;
182 hdr->str_str_len = len;
183 hdr->buffer = buffer;
186 /*******************************************************************
187 reads or writes a STRHDR structure.
188 ********************************************************************/
189 void smb_io_strhdr(char *desc, STRHDR *hdr, prs_struct *ps, int depth)
191 if (hdr == NULL) return;
193 prs_debug(ps, depth, desc, "smb_io_strhdr");
198 prs_uint16("str_str_len", ps, depth, &(hdr->str_str_len));
199 prs_uint16("str_max_len", ps, depth, &(hdr->str_max_len));
200 prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
202 /* oops! XXXX maybe issue a warning that this is happening... */
203 if (hdr->str_max_len > MAX_STRINGLEN) hdr->str_max_len = MAX_STRINGLEN;
204 if (hdr->str_str_len > MAX_STRINGLEN) hdr->str_str_len = MAX_STRINGLEN;
207 /*******************************************************************
208 creates a STRHDR2 structure.
209 ********************************************************************/
210 void make_strhdr2(STRHDR2 *hdr, uint32 max_len, uint32 len, uint32 buffer)
212 hdr->str_max_len = max_len;
213 hdr->str_str_len = len;
214 hdr->buffer = buffer;
217 /*******************************************************************
218 reads or writes a STRHDR2 structure.
219 ********************************************************************/
220 void smb_io_strhdr2(char *desc, STRHDR2 *hdr, prs_struct *ps, int depth)
222 if (hdr == NULL) return;
224 prs_debug(ps, depth, desc, "smb_io_strhdr");
229 prs_uint32("str_str_len", ps, depth, &(hdr->str_str_len));
230 prs_uint32("str_max_len", ps, depth, &(hdr->str_max_len));
231 prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
233 /* oops! XXXX maybe issue a warning that this is happening... */
234 if (hdr->str_max_len > MAX_STRINGLEN) hdr->str_max_len = MAX_STRINGLEN;
235 if (hdr->str_str_len > MAX_STRINGLEN) hdr->str_str_len = MAX_STRINGLEN;
238 /*******************************************************************
239 creates a UNIHDR structure.
240 ********************************************************************/
241 void make_uni_hdr(UNIHDR *hdr, int len)
243 hdr->uni_str_len = 2 * len;
244 hdr->uni_max_len = 2 * len;
245 hdr->buffer = len != 0 ? 1 : 0;
248 /*******************************************************************
249 reads or writes a UNIHDR structure.
250 ********************************************************************/
251 void smb_io_unihdr(char *desc, UNIHDR *hdr, prs_struct *ps, int depth)
253 if (hdr == NULL) return;
255 prs_debug(ps, depth, desc, "smb_io_unihdr");
260 prs_uint16("uni_str_len", ps, depth, &(hdr->uni_str_len));
261 prs_uint16("uni_max_len", ps, depth, &(hdr->uni_max_len));
262 prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
264 /* oops! XXXX maybe issue a warning that this is happening... */
265 if (hdr->uni_max_len > MAX_UNISTRLEN) hdr->uni_max_len = MAX_UNISTRLEN;
266 if (hdr->uni_str_len > MAX_UNISTRLEN) hdr->uni_str_len = MAX_UNISTRLEN;
269 /*******************************************************************
270 creates a BUFHDR structure.
271 ********************************************************************/
272 void make_buf_hdr(BUFHDR *hdr, int max_len, int len)
274 hdr->buf_max_len = max_len;
278 /*******************************************************************
279 prs_uint16 wrapper. call this and it sets up a pointer to where the
280 uint16 should be stored, or gets the size if reading
281 ********************************************************************/
282 void smb_io_hdrbuf_pre(char *desc, BUFHDR *hdr, prs_struct *ps, int depth, uint32 *offset)
284 (*offset) = ps->offset;
288 smb_io_hdrbuf(desc, hdr, ps, depth);
292 ps->offset += sizeof(uint32) * 2;
296 /*******************************************************************
297 smb_io_hdrbuf wrapper. call this and it retrospectively stores the size.
298 does nothing on reading, as that is already handled by ...._pre()
299 ********************************************************************/
300 void smb_io_hdrbuf_post(char *desc, BUFHDR *hdr, prs_struct *ps, int depth,
301 uint32 ptr_hdrbuf, uint32 max_len, uint32 len)
305 /* storing: go back and do a retrospective job. i hate this */
306 uint32 old_offset = ps->offset;
308 make_buf_hdr(hdr, max_len, len);
309 ps->offset = ptr_hdrbuf;
310 smb_io_hdrbuf(desc, hdr, ps, depth);
311 ps->offset = old_offset;
314 /*******************************************************************
315 reads or writes a BUFHDR structure.
316 ********************************************************************/
317 void smb_io_hdrbuf(char *desc, BUFHDR *hdr, prs_struct *ps, int depth)
319 if (hdr == NULL) return;
321 prs_debug(ps, depth, desc, "smb_io_hdrbuf");
326 prs_uint32("buf_max_len", ps, depth, &(hdr->buf_max_len));
327 prs_uint32("buf_len ", ps, depth, &(hdr->buf_len ));
329 /* oops! XXXX maybe issue a warning that this is happening... */
330 if (hdr->buf_max_len > MAX_BUFFERLEN) hdr->buf_max_len = MAX_BUFFERLEN;
331 if (hdr->buf_len > MAX_BUFFERLEN) hdr->buf_len = MAX_BUFFERLEN;
334 /*******************************************************************
335 creates a UNIHDR2 structure.
336 ********************************************************************/
337 void make_uni_hdr2(UNIHDR2 *hdr, int len)
339 make_uni_hdr(&(hdr->unihdr), len);
340 hdr->buffer = len > 0 ? 1 : 0;
343 /*******************************************************************
344 reads or writes a UNIHDR2 structure.
345 ********************************************************************/
346 void smb_io_unihdr2(char *desc, UNIHDR2 *hdr2, prs_struct *ps, int depth)
348 if (hdr2 == NULL) return;
350 prs_debug(ps, depth, desc, "smb_io_unihdr2");
355 smb_io_unihdr("hdr", &(hdr2->unihdr), ps, depth);
356 prs_uint32("buffer", ps, depth, &(hdr2->buffer));
359 /*******************************************************************
360 creates a UNISTR structure.
361 ********************************************************************/
362 void make_unistr(UNISTR *str, char *buf)
364 ascii_to_unistr(str->buffer, buf, sizeof(str->buffer)-1);
367 /*******************************************************************
368 reads or writes a UNISTR structure.
369 XXXX NOTE: UNISTR structures NEED to be null-terminated.
370 ********************************************************************/
371 void smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int depth)
373 if (uni == NULL) return;
375 prs_debug(ps, depth, desc, "smb_io_unistr");
378 prs_unistr("unistr", ps, depth, uni);
381 /*******************************************************************
382 creates a BUFFER3 structure from a uint32
383 ********************************************************************/
384 void make_buffer3_uint32(BUFFER3 *str, uint32 val)
388 /* set up string lengths. */
389 str->buf_max_len = sizeof(uint32);
390 str->buf_len = sizeof(uint32);
392 SIVAL(str->buffer, 0, val);
395 /*******************************************************************
396 creates a BUFFER3 structure.
397 ********************************************************************/
398 void make_buffer3_str(BUFFER3 *str, char *buf, int len)
402 /* set up string lengths. */
403 str->buf_max_len = len * 2;
404 str->buf_len = len * 2;
406 /* store the string (little endian buffer) */
407 ascii_to_unibuf(str->buffer, buf, str->buf_len);
410 /*******************************************************************
411 creates a BUFFER3 structure from a hex string.
412 ********************************************************************/
413 void make_buffer3_hex(BUFFER3 *str, char *buf)
416 str->buf_max_len = str->buf_len = strhex_to_str((char *)str->buffer, sizeof(str->buffer), buf);
419 /*******************************************************************
420 creates a BUFFER3 structure.
421 ********************************************************************/
422 void make_buffer3_bytes(BUFFER3 *str, uint8 *buf, int len)
426 /* max buffer size (allocated size) */
427 str->buf_max_len = len;
430 memcpy(str->buffer, buf, MIN(str->buf_len, sizeof(str->buffer)));
432 str->buf_len = buf != NULL ? len : 0;
435 /*******************************************************************
436 reads or writes a BUFFER3 structure.
437 the uni_max_len member tells you how large the buffer is.
438 the uni_str_len member tells you how much of the buffer is really used.
439 ********************************************************************/
440 void smb_io_buffer3(char *desc, BUFFER3 *buf3, prs_struct *ps, int depth)
442 if (buf3 == NULL) return;
444 prs_debug(ps, depth, desc, "smb_io_buffer3");
449 prs_uint32("uni_max_len", ps, depth, &(buf3->buf_max_len));
450 if (buf3->buf_max_len > MAX_UNISTRLEN) buf3->buf_max_len = MAX_UNISTRLEN;
452 prs_uint8s(True, "buffer ", ps, depth, buf3->buffer, buf3->buf_max_len);
454 prs_uint32("buf_len ", ps, depth, &(buf3->buf_len));
455 if (buf3->buf_len > MAX_UNISTRLEN) buf3->buf_len = MAX_UNISTRLEN;
458 /*******************************************************************
459 creates a BUFFER2 structure.
460 ********************************************************************/
461 void make_buffer2(BUFFER2 *str, const char *buf, int len)
465 /* set up string lengths. */
466 str->buf_max_len = len;
470 /* store the string (wide chars) */
471 ascii_to_unistr(str->buffer, buf, len);
474 /*******************************************************************
475 reads or writes a BUFFER2 structure.
476 the uni_max_len member tells you how large the buffer is.
477 the uni_str_len member tells you how much of the buffer is really used.
478 ********************************************************************/
479 void smb_io_buffer2(char *desc, BUFFER2 *buf2, uint32 buffer, prs_struct *ps, int depth)
481 if (buf2 == NULL) return;
485 prs_debug(ps, depth, desc, "smb_io_buffer2");
490 prs_uint32("buf_max_len", ps, depth, &(buf2->buf_max_len));
491 prs_uint32("undoc ", ps, depth, &(buf2->undoc ));
492 prs_uint32("buf_len ", ps, depth, &(buf2->buf_len));
494 /* oops! XXXX maybe issue a warning that this is happening... */
495 if (buf2->buf_max_len > MAX_UNISTRLEN) buf2->buf_max_len = MAX_UNISTRLEN;
496 if (buf2->buf_len > MAX_UNISTRLEN) buf2->buf_len = MAX_UNISTRLEN;
498 /* buffer advanced by indicated length of string
499 NOT by searching for null-termination */
500 prs_buffer2(True, "buffer ", ps, depth, buf2);
504 prs_debug(ps, depth, desc, "smb_io_buffer2 - NULL");
506 bzero(buf2, sizeof(*buf2));
510 /*******************************************************************
511 creates a UNISTR2 structure: sets up the buffer, too
512 ********************************************************************/
513 void make_buf_unistr2(UNISTR2 *str, uint32 *ptr, char *buf)
518 make_unistr2(str, buf, strlen(buf)+1);
523 make_unistr2(str, "", 0);
527 /*******************************************************************
528 copies a UNISTR2 structure.
529 ********************************************************************/
530 void copy_unistr2(UNISTR2 *str, UNISTR2 *from)
532 /* set up string lengths. add one if string is not null-terminated */
533 str->uni_max_len = from->uni_max_len;
534 str->undoc = from->undoc;
535 str->uni_str_len = from->uni_str_len;
537 /* copy the string */
538 memcpy(str->buffer, from->buffer, sizeof(from->buffer));
541 /*******************************************************************
542 creates a STRING2 structure.
543 ********************************************************************/
544 void make_string2(STRING2 *str, char *buf, int len)
546 /* set up string lengths. */
547 str->str_max_len = len;
549 str->str_str_len = len;
551 /* store the string */
553 memcpy(str->buffer, buf, len);
556 /*******************************************************************
557 reads or writes a STRING2 structure.
558 XXXX NOTE: STRING2 structures need NOT be null-terminated.
559 the str_str_len member tells you how long the string is;
560 the str_max_len member tells you how large the buffer is.
561 ********************************************************************/
562 void smb_io_string2(char *desc, STRING2 *str2, uint32 buffer, prs_struct *ps, int depth)
564 if (str2 == NULL) return;
568 prs_debug(ps, depth, desc, "smb_io_string2");
573 prs_uint32("str_max_len", ps, depth, &(str2->str_max_len));
574 prs_uint32("undoc ", ps, depth, &(str2->undoc ));
575 prs_uint32("str_str_len", ps, depth, &(str2->str_str_len));
577 /* oops! XXXX maybe issue a warning that this is happening... */
578 if (str2->str_max_len > MAX_STRINGLEN) str2->str_max_len = MAX_STRINGLEN;
579 if (str2->str_str_len > MAX_STRINGLEN) str2->str_str_len = MAX_STRINGLEN;
581 /* buffer advanced by indicated length of string
582 NOT by searching for null-termination */
583 prs_string2(True, "buffer ", ps, depth, str2);
587 prs_debug(ps, depth, desc, "smb_io_string2 - NULL");
589 bzero(str2, sizeof(*str2));
593 /*******************************************************************
594 creates a UNISTR2 structure.
595 ********************************************************************/
596 void make_unistr2(UNISTR2 *str, const char *buf, int len)
600 /* set up string lengths. */
601 str->uni_max_len = len;
603 str->uni_str_len = len;
605 /* store the string (wide chars) */
606 ascii_to_unistr(str->buffer, buf, len);
609 /*******************************************************************
610 reads or writes a UNISTR2 structure.
611 XXXX NOTE: UNISTR2 structures need NOT be null-terminated.
612 the uni_str_len member tells you how long the string is;
613 the uni_max_len member tells you how large the buffer is.
614 ********************************************************************/
615 void smb_io_unistr2(char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct *ps, int depth)
617 if (uni2 == NULL) return;
621 prs_debug(ps, depth, desc, "smb_io_unistr2");
626 prs_uint32("uni_max_len", ps, depth, &(uni2->uni_max_len));
627 prs_uint32("undoc ", ps, depth, &(uni2->undoc ));
628 prs_uint32("uni_str_len", ps, depth, &(uni2->uni_str_len));
630 /* oops! XXXX maybe issue a warning that this is happening... */
631 if (uni2->uni_max_len > MAX_UNISTRLEN) uni2->uni_max_len = MAX_UNISTRLEN;
632 if (uni2->uni_str_len > MAX_UNISTRLEN) uni2->uni_str_len = MAX_UNISTRLEN;
634 /* buffer advanced by indicated length of string
635 NOT by searching for null-termination */
636 prs_unistr2(True, "buffer ", ps, depth, uni2);
640 prs_debug(ps, depth, desc, "smb_io_unistr2 - NULL");
642 bzero(uni2, sizeof(*uni2));
646 /*******************************************************************
647 creates a DOM_RID2 structure.
648 ********************************************************************/
649 void make_dom_rid2(DOM_RID2 *rid2, uint32 rid, uint8 type, uint32 idx)
656 /*******************************************************************
657 reads or writes a DOM_RID2 structure.
658 ********************************************************************/
659 void smb_io_dom_rid2(char *desc, DOM_RID2 *rid2, prs_struct *ps, int depth)
661 if (rid2 == NULL) return;
663 prs_debug(ps, depth, desc, "smb_io_dom_rid2");
668 prs_uint8("type ", ps, depth, &(rid2->type));
670 prs_uint32("rid ", ps, depth, &(rid2->rid ));
671 prs_uint32("rid_idx", ps, depth, &(rid2->rid_idx ));
674 /*******************************************************************
675 creates a DOM_RID3 structure.
676 ********************************************************************/
677 void make_dom_rid3(DOM_RID3 *rid3, uint32 rid, uint8 type)
681 rid3->ptr_type = 0x1; /* non-zero, basically. */
686 /*******************************************************************
687 reads or writes a DOM_RID3 structure.
688 ********************************************************************/
689 void smb_io_dom_rid3(char *desc, DOM_RID3 *rid3, prs_struct *ps, int depth)
691 if (rid3 == NULL) return;
693 prs_debug(ps, depth, desc, "smb_io_dom_rid3");
698 prs_uint32("rid ", ps, depth, &(rid3->rid ));
699 prs_uint32("type1 ", ps, depth, &(rid3->type1 ));
700 prs_uint32("ptr_type", ps, depth, &(rid3->ptr_type));
701 prs_uint32("type2 ", ps, depth, &(rid3->type2 ));
702 prs_uint32("unk ", ps, depth, &(rid3->unk ));
705 /*******************************************************************
706 makes a DOM_CLNT_SRV structure.
707 ********************************************************************/
708 static void make_clnt_srv(DOM_CLNT_SRV *log, char *logon_srv, char *comp_name)
710 if (log == NULL) return;
712 DEBUG(5,("make_clnt_srv: %d\n", __LINE__));
714 if (logon_srv != NULL)
716 log->undoc_buffer = 1;
717 make_unistr2(&(log->uni_logon_srv), logon_srv, strlen(logon_srv)+1);
721 log->undoc_buffer = 0;
724 if (comp_name != NULL)
726 log->undoc_buffer2 = 1;
727 make_unistr2(&(log->uni_comp_name), comp_name, strlen(comp_name)+1);
731 log->undoc_buffer2 = 0;
735 /*******************************************************************
736 reads or writes a DOM_CLNT_SRV structure.
737 ********************************************************************/
738 static void smb_io_clnt_srv(char *desc, DOM_CLNT_SRV *log, prs_struct *ps, int depth)
740 if (log == NULL) return;
742 prs_debug(ps, depth, desc, "smb_io_clnt_srv");
747 prs_uint32("undoc_buffer ", ps, depth, &(log->undoc_buffer ));
748 if (log->undoc_buffer != 0)
750 smb_io_unistr2("unistr2", &(log->uni_logon_srv), log->undoc_buffer, ps, depth);
755 prs_uint32("undoc_buffer2", ps, depth, &(log->undoc_buffer2));
756 if (log->undoc_buffer2 != 0)
758 smb_io_unistr2("unistr2", &(log->uni_comp_name), log->undoc_buffer2, ps, depth);
762 /*******************************************************************
763 makes a DOM_LOG_INFO structure.
764 ********************************************************************/
765 void make_log_info(DOM_LOG_INFO *log,
766 const char *logon_srv, const char *acct_name,
767 uint16 sec_chan, const char *comp_name)
769 if (log == NULL) return;
771 DEBUG(5,("make_log_info %d\n", __LINE__));
773 log->undoc_buffer = 1;
775 make_unistr2(&(log->uni_logon_srv), logon_srv, strlen(logon_srv)+1);
776 make_unistr2(&(log->uni_acct_name), acct_name, strlen(acct_name)+1);
778 log->sec_chan = sec_chan;
780 make_unistr2(&(log->uni_comp_name), comp_name, strlen(comp_name)+1);
783 /*******************************************************************
784 reads or writes a DOM_LOG_INFO structure.
785 ********************************************************************/
786 void smb_io_log_info(char *desc, DOM_LOG_INFO *log, prs_struct *ps, int depth)
788 if (log == NULL) return;
790 prs_debug(ps, depth, desc, "smb_io_log_info");
795 prs_uint32("undoc_buffer", ps, depth, &(log->undoc_buffer));
797 smb_io_unistr2("unistr2", &(log->uni_logon_srv), True, ps, depth);
798 smb_io_unistr2("unistr2", &(log->uni_acct_name), True, ps, depth);
800 prs_uint16("sec_chan", ps, depth, &(log->sec_chan));
802 smb_io_unistr2("unistr2", &(log->uni_comp_name), True, ps, depth);
805 /*******************************************************************
806 reads or writes a DOM_CHAL structure.
807 ********************************************************************/
808 void smb_io_chal(char *desc, DOM_CHAL *chal, prs_struct *ps, int depth)
810 if (chal == NULL) return;
812 prs_debug(ps, depth, desc, "smb_io_chal");
817 prs_uint8s (False, "data", ps, depth, chal->data, 8);
820 /*******************************************************************
821 reads or writes a DOM_CRED structure.
822 ********************************************************************/
823 void smb_io_cred(char *desc, DOM_CRED *cred, prs_struct *ps, int depth)
825 if (cred == NULL) return;
827 prs_debug(ps, depth, desc, "smb_io_cred");
832 smb_io_chal ("", &(cred->challenge), ps, depth);
833 smb_io_utime("", &(cred->timestamp), ps, depth);
836 /*******************************************************************
837 makes a DOM_CLNT_INFO2 structure.
838 ********************************************************************/
839 void make_clnt_info2(DOM_CLNT_INFO2 *clnt,
840 char *logon_srv, char *comp_name,
843 if (clnt == NULL) return;
845 DEBUG(5,("make_clnt_info: %d\n", __LINE__));
847 make_clnt_srv(&(clnt->login), logon_srv, comp_name);
849 if (clnt_cred != NULL)
852 memcpy(&(clnt->cred), clnt_cred, sizeof(clnt->cred));
860 /*******************************************************************
861 reads or writes a DOM_CLNT_INFO2 structure.
862 ********************************************************************/
863 void smb_io_clnt_info2(char *desc, DOM_CLNT_INFO2 *clnt, prs_struct *ps, int depth)
865 if (clnt == NULL) return;
867 prs_debug(ps, depth, desc, "smb_io_clnt_info2");
872 smb_io_clnt_srv("", &(clnt->login), ps, depth);
876 prs_uint32("ptr_cred", ps, depth, &(clnt->ptr_cred));
877 smb_io_cred ("", &(clnt->cred ), ps, depth);
880 /*******************************************************************
881 makes a DOM_CLNT_INFO structure.
882 ********************************************************************/
883 void make_clnt_info(DOM_CLNT_INFO *clnt,
884 char *logon_srv, char *acct_name,
885 uint16 sec_chan, char *comp_name,
888 if (clnt == NULL || cred == NULL) return;
890 DEBUG(5,("make_clnt_info\n"));
892 make_log_info(&(clnt->login), logon_srv, acct_name, sec_chan, comp_name);
893 memcpy(&(clnt->cred), cred, sizeof(clnt->cred));
896 /*******************************************************************
897 reads or writes a DOM_CLNT_INFO structure.
898 ********************************************************************/
899 void smb_io_clnt_info(char *desc, DOM_CLNT_INFO *clnt, prs_struct *ps, int depth)
901 if (clnt == NULL) return;
903 prs_debug(ps, depth, desc, "smb_io_clnt_info");
908 smb_io_log_info("", &(clnt->login), ps, depth);
909 smb_io_cred ("", &(clnt->cred ), ps, depth);
912 /*******************************************************************
913 makes a DOM_LOGON_ID structure.
914 ********************************************************************/
915 void make_logon_id(DOM_LOGON_ID *log, uint32 log_id_low, uint32 log_id_high)
917 if (log == NULL) return;
919 DEBUG(5,("make_logon_id: %d\n", __LINE__));
921 log->low = log_id_low;
922 log->high = log_id_high;
925 /*******************************************************************
926 reads or writes a DOM_LOGON_ID structure.
927 ********************************************************************/
928 void smb_io_logon_id(char *desc, DOM_LOGON_ID *log, prs_struct *ps, int depth)
930 if (log == NULL) return;
932 prs_debug(ps, depth, desc, "smb_io_logon_id");
937 prs_uint32("low ", ps, depth, &(log->low ));
938 prs_uint32("high", ps, depth, &(log->high));
941 /*******************************************************************
942 makes an OWF_INFO structure.
943 ********************************************************************/
944 void make_owf_info(OWF_INFO *hash, uint8 data[16])
946 if (hash == NULL) return;
948 DEBUG(5,("make_owf_info: %d\n", __LINE__));
952 memcpy(hash->data, data, sizeof(hash->data));
956 bzero(hash->data, sizeof(hash->data));
960 /*******************************************************************
961 reads or writes an OWF_INFO structure.
962 ********************************************************************/
963 void smb_io_owf_info(char *desc, OWF_INFO *hash, prs_struct *ps, int depth)
965 if (hash == NULL) return;
967 prs_debug(ps, depth, desc, "smb_io_owf_info");
972 prs_uint8s (False, "data", ps, depth, hash->data, 16);
975 /*******************************************************************
976 reads or writes a DOM_GID structure.
977 ********************************************************************/
978 void smb_io_gid(char *desc, DOM_GID *gid, prs_struct *ps, int depth)
980 if (gid == NULL) return;
982 prs_debug(ps, depth, desc, "smb_io_gid");
987 prs_uint32("g_rid", ps, depth, &(gid->g_rid));
988 prs_uint32("attr ", ps, depth, &(gid->attr ));
991 /*******************************************************************
992 reads or writes an POLICY_HND structure.
993 ********************************************************************/
994 void smb_io_pol_hnd(char *desc, POLICY_HND *pol, prs_struct *ps, int depth)
996 if (pol == NULL) return;
998 prs_debug(ps, depth, desc, "smb_io_pol_hnd");
1003 prs_uint8s (False, "data", ps, depth, pol->data, POL_HND_SIZE);
1006 /*******************************************************************
1007 reads or writes a dom query structure.
1008 ********************************************************************/
1009 static void smb_io_dom_query(char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth)
1011 if (d_q == NULL) return;
1013 prs_debug(ps, depth, desc, "smb_io_dom_query");
1018 prs_uint16("uni_dom_max_len", ps, depth, &(d_q->uni_dom_max_len)); /* domain name string length * 2 */
1019 prs_uint16("uni_dom_str_len", ps, depth, &(d_q->uni_dom_str_len)); /* domain name string length * 2 */
1021 prs_uint32("buffer_dom_name", ps, depth, &(d_q->buffer_dom_name)); /* undocumented domain name string buffer pointer */
1022 prs_uint32("buffer_dom_sid ", ps, depth, &(d_q->buffer_dom_sid )); /* undocumented domain SID string buffer pointer */
1024 smb_io_unistr2("unistr2", &(d_q->uni_domain_name), d_q->buffer_dom_name, ps, depth); /* domain name (unicode string) */
1026 if (d_q->buffer_dom_sid != 0)
1028 smb_io_dom_sid2("", &(d_q->dom_sid), ps, depth); /* domain SID */
1032 bzero(&(d_q->dom_sid), sizeof(d_q->dom_sid));
1036 /*******************************************************************
1037 reads or writes a dom query structure.
1038 ********************************************************************/
1039 void smb_io_dom_query_3(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
1041 smb_io_dom_query("", d_q, ps, depth);
1044 /*******************************************************************
1045 reads or writes a dom query structure.
1046 ********************************************************************/
1047 void smb_io_dom_query_5(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
1049 smb_io_dom_query("", d_q, ps, depth);
1053 /*******************************************************************
1054 reads or writes a UNISTR3 structure.
1055 ********************************************************************/
1056 void smb_io_unistr3(char *desc, UNISTR3 *name, prs_struct *ps, int depth)
1058 if (name == NULL) return;
1060 prs_debug(ps, depth, desc, "smb_io_unistr3");
1065 prs_uint32("uni_str_len", ps, depth, &(name->uni_str_len));
1067 /* don't know if len is specified by uni_str_len member... */
1068 /* assume unicode string is unicode-null-terminated, instead */
1070 prs_unistr3(True, "unistr", name, ps, depth);