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 void smb_io_dom_sid(char *desc, DOM_SID *sid, prs_struct *ps, int depth)
125 if (sid == NULL) return;
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);
148 /*******************************************************************
149 creates a DOM_SID2 structure.
150 ********************************************************************/
151 void make_dom_sid2(DOM_SID2 *sid2, DOM_SID *sid)
153 sid_copy(&sid2->sid, sid);
154 sid2->num_auths = sid2->sid.num_auths;
157 /*******************************************************************
158 reads or writes a DOM_SID2 structure.
159 ********************************************************************/
160 void smb_io_dom_sid2(char *desc, DOM_SID2 *sid, prs_struct *ps, int depth)
162 if (sid == NULL) return;
164 prs_debug(ps, depth, desc, "smb_io_dom_sid2");
169 prs_uint32("num_auths", ps, depth, &(sid->num_auths));
171 smb_io_dom_sid("sid", &(sid->sid), ps, depth);
174 /*******************************************************************
175 creates a STRHDR structure.
176 ********************************************************************/
177 void make_str_hdr(STRHDR *hdr, int max_len, int len, uint32 buffer)
179 hdr->str_max_len = max_len;
180 hdr->str_str_len = len;
181 hdr->buffer = buffer;
184 /*******************************************************************
185 reads or writes a STRHDR structure.
186 ********************************************************************/
187 void smb_io_strhdr(char *desc, STRHDR *hdr, prs_struct *ps, int depth)
189 if (hdr == NULL) return;
191 prs_debug(ps, depth, desc, "smb_io_strhdr");
196 prs_uint16("str_str_len", ps, depth, &(hdr->str_str_len));
197 prs_uint16("str_max_len", ps, depth, &(hdr->str_max_len));
198 prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
200 /* oops! XXXX maybe issue a warning that this is happening... */
201 if (hdr->str_max_len > MAX_STRINGLEN) hdr->str_max_len = MAX_STRINGLEN;
202 if (hdr->str_str_len > MAX_STRINGLEN) hdr->str_str_len = MAX_STRINGLEN;
205 /*******************************************************************
206 creates a UNIHDR structure.
207 ********************************************************************/
208 void make_uni_hdr(UNIHDR *hdr, int max_len, int len, uint32 buffer)
210 hdr->uni_str_len = 2 * len;
211 hdr->uni_max_len = 2 * max_len;
212 hdr->buffer = buffer;
215 /*******************************************************************
216 reads or writes a UNIHDR structure.
217 ********************************************************************/
218 void smb_io_unihdr(char *desc, UNIHDR *hdr, prs_struct *ps, int depth)
220 if (hdr == NULL) return;
222 prs_debug(ps, depth, desc, "smb_io_unihdr");
227 prs_uint16("uni_str_len", ps, depth, &(hdr->uni_str_len));
228 prs_uint16("uni_max_len", ps, depth, &(hdr->uni_max_len));
229 prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
231 /* oops! XXXX maybe issue a warning that this is happening... */
232 if (hdr->uni_max_len > MAX_UNISTRLEN) hdr->uni_max_len = MAX_UNISTRLEN;
233 if (hdr->uni_str_len > MAX_UNISTRLEN) hdr->uni_str_len = MAX_UNISTRLEN;
236 /*******************************************************************
237 creates a BUFHDR structure.
238 ********************************************************************/
239 void make_buf_hdr(BUFHDR *hdr, int max_len, int len)
241 hdr->buf_max_len = max_len;
245 /*******************************************************************
246 prs_uint16 wrapper. call this and it sets up a pointer to where the
247 uint16 should be stored, or gets the size if reading
248 ********************************************************************/
249 void smb_io_hdrbuf_pre(char *desc, BUFHDR *hdr, prs_struct *ps, int depth, uint32 *offset)
251 (*offset) = ps->offset;
255 smb_io_hdrbuf(desc, hdr, ps, depth);
259 ps->offset += sizeof(uint32) * 2;
263 /*******************************************************************
264 smb_io_hdrbuf wrapper. call this and it retrospectively stores the size.
265 does nothing on reading, as that is already handled by ...._pre()
266 ********************************************************************/
267 void smb_io_hdrbuf_post(char *desc, BUFHDR *hdr, prs_struct *ps, int depth,
268 uint32 ptr_hdrbuf, uint32 max_len, uint32 len)
272 /* storing: go back and do a retrospective job. i hate this */
273 uint32 old_offset = ps->offset;
275 make_buf_hdr(hdr, max_len, len);
276 ps->offset = ptr_hdrbuf;
277 smb_io_hdrbuf(desc, hdr, ps, depth);
278 ps->offset = old_offset;
281 /*******************************************************************
282 reads or writes a BUFHDR structure.
283 ********************************************************************/
284 void smb_io_hdrbuf(char *desc, BUFHDR *hdr, prs_struct *ps, int depth)
286 if (hdr == NULL) return;
288 prs_debug(ps, depth, desc, "smb_io_hdrbuf");
293 prs_uint32("buf_max_len", ps, depth, &(hdr->buf_max_len));
294 prs_uint32("buf_len ", ps, depth, &(hdr->buf_len ));
296 /* oops! XXXX maybe issue a warning that this is happening... */
297 if (hdr->buf_max_len > MAX_BUFFERLEN) hdr->buf_max_len = MAX_BUFFERLEN;
298 if (hdr->buf_len > MAX_BUFFERLEN) hdr->buf_len = MAX_BUFFERLEN;
301 /*******************************************************************
302 creates a UNIHDR2 structure.
303 ********************************************************************/
304 void make_uni_hdr2(UNIHDR2 *hdr, int max_len, int len, uint16 terminate)
306 make_uni_hdr(&(hdr->unihdr), max_len, len, terminate);
307 hdr->buffer = len > 0 ? 1 : 0;
310 /*******************************************************************
311 reads or writes a UNIHDR2 structure.
312 ********************************************************************/
313 void smb_io_unihdr2(char *desc, UNIHDR2 *hdr2, prs_struct *ps, int depth)
315 if (hdr2 == NULL) return;
317 prs_debug(ps, depth, desc, "smb_io_unihdr2");
322 smb_io_unihdr("hdr", &(hdr2->unihdr), ps, depth);
323 prs_uint32("buffer", ps, depth, &(hdr2->buffer));
326 /*******************************************************************
327 creates a UNISTR structure.
328 ********************************************************************/
329 void make_unistr(UNISTR *str, char *buf)
331 /* store the string (null-terminated copy) */
332 struni2(str->buffer, buf);
335 /*******************************************************************
336 reads or writes a UNISTR structure.
337 XXXX NOTE: UNISTR structures NEED to be null-terminated.
338 ********************************************************************/
339 void smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int depth)
341 if (uni == NULL) return;
343 prs_debug(ps, depth, desc, "smb_io_unistr");
347 prs_unistr("unistr", ps, depth, uni);
350 /*******************************************************************
351 creates a BUFFER3 structure from a uint32
352 ********************************************************************/
353 void make_buffer3_uint32(BUFFER3 *str, uint32 val)
357 /* set up string lengths. */
358 str->buf_max_len = sizeof(uint32);
359 str->buf_len = sizeof(uint32);
361 SIVAL(str->buffer, 0, val);
364 /*******************************************************************
365 creates a BUFFER3 structure.
366 ********************************************************************/
367 void make_buffer3_str(BUFFER3 *str, char *buf, int len)
371 /* set up string lengths. */
372 str->buf_max_len = len * 2;
373 str->buf_len = len * 2;
375 /* store the string (null-terminated 8 bit chars into 16 bit chars) */
376 struni2((uint16*)str->buffer, buf);
379 /*******************************************************************
380 creates a BUFFER3 structure from a hex string.
381 ********************************************************************/
382 void make_buffer3_hex(BUFFER3 *str, char *buf)
385 str->buf_max_len = str->buf_len = strhex_to_str((char *)str->buffer, sizeof(str->buffer), buf);
388 /*******************************************************************
389 creates a BUFFER3 structure.
390 ********************************************************************/
391 void make_buffer3_bytes(BUFFER3 *str, uint8 *buf, int len)
395 /* max buffer size (allocated size) */
396 str->buf_max_len = len;
399 memcpy(str->buffer, buf, MIN(str->buf_len, sizeof(str->buffer)));
401 str->buf_len = buf != NULL ? len : 0;
404 /*******************************************************************
405 reads or writes a BUFFER3 structure.
406 the uni_max_len member tells you how large the buffer is.
407 the uni_str_len member tells you how much of the buffer is really used.
408 ********************************************************************/
409 void smb_io_buffer3(char *desc, BUFFER3 *buf3, prs_struct *ps, int depth)
411 if (buf3 == NULL) return;
413 prs_debug(ps, depth, desc, "smb_io_buffer3");
418 prs_uint32("uni_max_len", ps, depth, &(buf3->buf_max_len));
419 if (buf3->buf_max_len > MAX_UNISTRLEN) buf3->buf_max_len = MAX_UNISTRLEN;
421 prs_uint8s(True, "buffer ", ps, depth, buf3->buffer, buf3->buf_max_len);
423 prs_uint32("buf_len ", ps, depth, &(buf3->buf_len));
424 if (buf3->buf_len > MAX_UNISTRLEN) buf3->buf_len = MAX_UNISTRLEN;
427 /*******************************************************************
428 creates a BUFFER2 structure.
429 ********************************************************************/
430 void make_buffer2(BUFFER2 *str, uint8 *buf, int len)
434 /* max buffer size (allocated size) */
435 str->buf_max_len = len;
437 str->buf_len = buf != NULL ? len : 0;
441 memcpy(str->buffer, buf, MIN(str->buf_len, sizeof(str->buffer)));
445 /*******************************************************************
446 reads or writes a BUFFER2 structure.
447 the uni_max_len member tells you how large the buffer is.
448 the uni_str_len member tells you how much of the buffer is really used.
449 ********************************************************************/
450 void smb_io_buffer2(char *desc, BUFFER2 *buf2, uint32 buffer, prs_struct *ps, int depth)
452 if (buf2 == NULL) return;
456 prs_debug(ps, depth, desc, "smb_io_buffer2");
461 prs_uint32("buf_max_len", ps, depth, &(buf2->buf_max_len));
462 prs_uint32("undoc ", ps, depth, &(buf2->undoc ));
463 prs_uint32("buf_len ", ps, depth, &(buf2->buf_len));
465 /* oops! XXXX maybe issue a warning that this is happening... */
466 if (buf2->buf_max_len > MAX_UNISTRLEN) buf2->buf_max_len = MAX_UNISTRLEN;
467 if (buf2->buf_len > MAX_UNISTRLEN) buf2->buf_len = MAX_UNISTRLEN;
469 /* buffer advanced by indicated length of string
470 NOT by searching for null-termination */
471 prs_buffer2(True, "buffer ", ps, depth, buf2);
475 prs_debug(ps, depth, desc, "smb_io_buffer2 - NULL");
477 bzero(buf2, sizeof(*buf2));
481 /*******************************************************************
482 creates a UNISTR2 structure: sets up the buffer, too
483 ********************************************************************/
484 void make_buf_unistr2(UNISTR2 *str, uint32 *ptr, char *buf)
489 make_unistr2(str, buf, strlen(buf)+1);
494 make_unistr2(str, "", 0);
498 /*******************************************************************
499 copies a UNISTR2 structure.
500 ********************************************************************/
501 void copy_unistr2(UNISTR2 *str, UNISTR2 *from)
503 /* set up string lengths. add one if string is not null-terminated */
504 str->uni_max_len = from->uni_max_len;
505 str->undoc = from->undoc;
506 str->uni_str_len = from->uni_str_len;
508 /* copy the string */
509 memcpy(str->buffer, from->buffer, sizeof(from->buffer));
512 /*******************************************************************
513 creates a STRING2 structure.
514 ********************************************************************/
515 void make_string2(STRING2 *str, char *buf, int len)
517 /* set up string lengths. */
518 str->str_max_len = len;
520 str->str_str_len = len;
522 /* store the string */
524 memcpy(str->buffer, buf, len);
527 /*******************************************************************
528 reads or writes a STRING2 structure.
529 XXXX NOTE: STRING2 structures need NOT be null-terminated.
530 the str_str_len member tells you how long the string is;
531 the str_max_len member tells you how large the buffer is.
532 ********************************************************************/
533 void smb_io_string2(char *desc, STRING2 *str2, uint32 buffer, prs_struct *ps, int depth)
535 if (str2 == NULL) return;
539 prs_debug(ps, depth, desc, "smb_io_string2");
544 prs_uint32("str_max_len", ps, depth, &(str2->str_max_len));
545 prs_uint32("undoc ", ps, depth, &(str2->undoc ));
546 prs_uint32("str_str_len", ps, depth, &(str2->str_str_len));
548 /* oops! XXXX maybe issue a warning that this is happening... */
549 if (str2->str_max_len > MAX_STRINGLEN) str2->str_max_len = MAX_STRINGLEN;
550 if (str2->str_str_len > MAX_STRINGLEN) str2->str_str_len = MAX_STRINGLEN;
552 /* buffer advanced by indicated length of string
553 NOT by searching for null-termination */
554 prs_string2(True, "buffer ", ps, depth, str2);
558 prs_debug(ps, depth, desc, "smb_io_string2 - NULL");
560 bzero(str2, sizeof(*str2));
564 /*******************************************************************
565 creates a UNISTR2 structure.
566 ********************************************************************/
567 void make_unistr2(UNISTR2 *str, char *buf, int len)
571 /* set up string lengths. */
572 str->uni_max_len = len;
574 str->uni_str_len = len;
576 /* store the string (null-terminated 8 bit chars into 16 bit chars) */
577 struni2(str->buffer, buf);
580 /*******************************************************************
581 reads or writes a UNISTR2 structure.
582 XXXX NOTE: UNISTR2 structures need NOT be null-terminated.
583 the uni_str_len member tells you how long the string is;
584 the uni_max_len member tells you how large the buffer is.
585 ********************************************************************/
586 void smb_io_unistr2(char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct *ps, int depth)
588 if (uni2 == NULL) return;
592 prs_debug(ps, depth, desc, "smb_io_unistr2");
597 prs_uint32("uni_max_len", ps, depth, &(uni2->uni_max_len));
598 prs_uint32("undoc ", ps, depth, &(uni2->undoc ));
599 prs_uint32("uni_str_len", ps, depth, &(uni2->uni_str_len));
601 /* oops! XXXX maybe issue a warning that this is happening... */
602 if (uni2->uni_max_len > MAX_UNISTRLEN) uni2->uni_max_len = MAX_UNISTRLEN;
603 if (uni2->uni_str_len > MAX_UNISTRLEN) uni2->uni_str_len = MAX_UNISTRLEN;
605 /* buffer advanced by indicated length of string
606 NOT by searching for null-termination */
607 prs_unistr2(True, "buffer ", ps, depth, uni2);
611 prs_debug(ps, depth, desc, "smb_io_unistr2 - NULL");
613 bzero(uni2, sizeof(*uni2));
617 /*******************************************************************
618 creates a DOM_RID2 structure.
619 ********************************************************************/
620 void make_dom_rid2(DOM_RID2 *rid2, uint32 rid, uint8 type, uint32 idx)
627 /*******************************************************************
628 reads or writes a DOM_RID2 structure.
629 ********************************************************************/
630 void smb_io_dom_rid2(char *desc, DOM_RID2 *rid2, prs_struct *ps, int depth)
632 if (rid2 == NULL) return;
634 prs_debug(ps, depth, desc, "smb_io_dom_rid2");
639 prs_uint8("type ", ps, depth, &(rid2->type));
641 prs_uint32("rid ", ps, depth, &(rid2->rid ));
642 prs_uint32("rid_idx", ps, depth, &(rid2->rid_idx ));
645 /*******************************************************************
646 creates a DOM_RID3 structure.
647 ********************************************************************/
648 void make_dom_rid3(DOM_RID3 *rid3, uint32 rid, uint8 type)
652 rid3->ptr_type = 0x1; /* non-zero, basically. */
657 /*******************************************************************
658 reads or writes a DOM_RID3 structure.
659 ********************************************************************/
660 void smb_io_dom_rid3(char *desc, DOM_RID3 *rid3, prs_struct *ps, int depth)
662 if (rid3 == NULL) return;
664 prs_debug(ps, depth, desc, "smb_io_dom_rid3");
669 prs_uint32("rid ", ps, depth, &(rid3->rid ));
670 prs_uint32("type1 ", ps, depth, &(rid3->type1 ));
671 prs_uint32("ptr_type", ps, depth, &(rid3->ptr_type));
672 prs_uint32("type2 ", ps, depth, &(rid3->type2 ));
673 prs_uint32("unk ", ps, depth, &(rid3->unk ));
676 /*******************************************************************
677 creates a DOM_RID4 structure.
678 ********************************************************************/
679 void make_dom_rid4(DOM_RID4 *rid4, uint16 unknown, uint16 attr, uint32 rid)
681 rid4->unknown = unknown;
686 /*******************************************************************
687 makes a DOM_CLNT_SRV structure.
688 ********************************************************************/
689 static void make_clnt_srv(DOM_CLNT_SRV *log, char *logon_srv, char *comp_name)
691 if (log == NULL) return;
693 DEBUG(5,("make_clnt_srv: %d\n", __LINE__));
695 if (logon_srv != NULL)
697 log->undoc_buffer = 1;
698 make_unistr2(&(log->uni_logon_srv), logon_srv, strlen(logon_srv)+1);
702 log->undoc_buffer = 0;
705 if (comp_name != NULL)
707 log->undoc_buffer2 = 1;
708 make_unistr2(&(log->uni_comp_name), comp_name, strlen(comp_name)+1);
712 log->undoc_buffer2 = 0;
716 /*******************************************************************
717 reads or writes a DOM_CLNT_SRV structure.
718 ********************************************************************/
719 static void smb_io_clnt_srv(char *desc, DOM_CLNT_SRV *log, prs_struct *ps, int depth)
721 if (log == NULL) return;
723 prs_debug(ps, depth, desc, "smb_io_clnt_srv");
728 prs_uint32("undoc_buffer ", ps, depth, &(log->undoc_buffer ));
729 if (log->undoc_buffer != 0)
731 smb_io_unistr2("unistr2", &(log->uni_logon_srv), log->undoc_buffer, ps, depth);
736 prs_uint32("undoc_buffer2", ps, depth, &(log->undoc_buffer2));
737 if (log->undoc_buffer2 != 0)
739 smb_io_unistr2("unistr2", &(log->uni_comp_name), log->undoc_buffer2, ps, depth);
743 /*******************************************************************
744 makes a DOM_LOG_INFO structure.
745 ********************************************************************/
746 void make_log_info(DOM_LOG_INFO *log, char *logon_srv, char *acct_name,
747 uint16 sec_chan, char *comp_name)
749 if (log == NULL) return;
751 DEBUG(5,("make_log_info %d\n", __LINE__));
753 log->undoc_buffer = 1;
755 make_unistr2(&(log->uni_logon_srv), logon_srv, strlen(logon_srv)+1);
756 make_unistr2(&(log->uni_acct_name), acct_name, strlen(acct_name)+1);
758 log->sec_chan = sec_chan;
760 make_unistr2(&(log->uni_comp_name), comp_name, strlen(comp_name)+1);
763 /*******************************************************************
764 reads or writes a DOM_LOG_INFO structure.
765 ********************************************************************/
766 void smb_io_log_info(char *desc, DOM_LOG_INFO *log, prs_struct *ps, int depth)
768 if (log == NULL) return;
770 prs_debug(ps, depth, desc, "smb_io_log_info");
775 prs_uint32("undoc_buffer", ps, depth, &(log->undoc_buffer));
777 smb_io_unistr2("unistr2", &(log->uni_logon_srv), True, ps, depth);
778 smb_io_unistr2("unistr2", &(log->uni_acct_name), True, ps, depth);
780 prs_uint16("sec_chan", ps, depth, &(log->sec_chan));
782 smb_io_unistr2("unistr2", &(log->uni_comp_name), True, ps, depth);
785 /*******************************************************************
786 reads or writes a DOM_CHAL structure.
787 ********************************************************************/
788 void smb_io_chal(char *desc, DOM_CHAL *chal, prs_struct *ps, int depth)
790 if (chal == NULL) return;
792 prs_debug(ps, depth, desc, "smb_io_chal");
797 prs_uint8s (False, "data", ps, depth, chal->data, 8);
800 /*******************************************************************
801 reads or writes a DOM_CRED structure.
802 ********************************************************************/
803 void smb_io_cred(char *desc, DOM_CRED *cred, prs_struct *ps, int depth)
805 if (cred == NULL) return;
807 prs_debug(ps, depth, desc, "smb_io_cred");
812 smb_io_chal ("", &(cred->challenge), ps, depth);
813 smb_io_utime("", &(cred->timestamp), ps, depth);
816 /*******************************************************************
817 makes a DOM_CLNT_INFO2 structure.
818 ********************************************************************/
819 void make_clnt_info2(DOM_CLNT_INFO2 *clnt,
820 char *logon_srv, char *comp_name,
823 if (clnt == NULL) return;
825 DEBUG(5,("make_clnt_info: %d\n", __LINE__));
827 make_clnt_srv(&(clnt->login), logon_srv, comp_name);
829 if (clnt_cred != NULL)
832 memcpy(&(clnt->cred), clnt_cred, sizeof(clnt->cred));
840 /*******************************************************************
841 reads or writes a DOM_CLNT_INFO2 structure.
842 ********************************************************************/
843 void smb_io_clnt_info2(char *desc, DOM_CLNT_INFO2 *clnt, prs_struct *ps, int depth)
845 if (clnt == NULL) return;
847 prs_debug(ps, depth, desc, "smb_io_clnt_info2");
852 smb_io_clnt_srv("", &(clnt->login), ps, depth);
856 prs_uint32("ptr_cred", ps, depth, &(clnt->ptr_cred));
857 smb_io_cred ("", &(clnt->cred ), ps, depth);
860 /*******************************************************************
861 makes a DOM_CLNT_INFO structure.
862 ********************************************************************/
863 void make_clnt_info(DOM_CLNT_INFO *clnt,
864 char *logon_srv, char *acct_name,
865 uint16 sec_chan, char *comp_name,
868 if (clnt == NULL || cred == NULL) return;
870 DEBUG(5,("make_clnt_info\n"));
872 make_log_info(&(clnt->login), logon_srv, acct_name, sec_chan, comp_name);
873 memcpy(&(clnt->cred), cred, sizeof(clnt->cred));
876 /*******************************************************************
877 reads or writes a DOM_CLNT_INFO structure.
878 ********************************************************************/
879 void smb_io_clnt_info(char *desc, DOM_CLNT_INFO *clnt, prs_struct *ps, int depth)
881 if (clnt == NULL) return;
883 prs_debug(ps, depth, desc, "smb_io_clnt_info");
888 smb_io_log_info("", &(clnt->login), ps, depth);
889 smb_io_cred ("", &(clnt->cred ), ps, depth);
892 /*******************************************************************
893 makes a DOM_LOGON_ID structure.
894 ********************************************************************/
895 void make_logon_id(DOM_LOGON_ID *log, uint32 log_id_low, uint32 log_id_high)
897 if (log == NULL) return;
899 DEBUG(5,("make_logon_id: %d\n", __LINE__));
901 log->low = log_id_low;
902 log->high = log_id_high;
905 /*******************************************************************
906 reads or writes a DOM_LOGON_ID structure.
907 ********************************************************************/
908 void smb_io_logon_id(char *desc, DOM_LOGON_ID *log, prs_struct *ps, int depth)
910 if (log == NULL) return;
912 prs_debug(ps, depth, desc, "smb_io_logon_id");
917 prs_uint32("low ", ps, depth, &(log->low ));
918 prs_uint32("high", ps, depth, &(log->high));
921 /*******************************************************************
922 makes an OWF_INFO structure.
923 ********************************************************************/
924 void make_owf_info(OWF_INFO *hash, uint8 data[16])
926 if (hash == NULL) return;
928 DEBUG(5,("make_owf_info: %d\n", __LINE__));
932 memcpy(hash->data, data, sizeof(hash->data));
936 bzero(hash->data, sizeof(hash->data));
940 /*******************************************************************
941 reads or writes an OWF_INFO structure.
942 ********************************************************************/
943 void smb_io_owf_info(char *desc, OWF_INFO *hash, prs_struct *ps, int depth)
945 if (hash == NULL) return;
947 prs_debug(ps, depth, desc, "smb_io_owf_info");
952 prs_uint8s (False, "data", ps, depth, hash->data, 16);
955 /*******************************************************************
956 reads or writes a DOM_GID structure.
957 ********************************************************************/
958 void smb_io_gid(char *desc, DOM_GID *gid, prs_struct *ps, int depth)
960 if (gid == NULL) return;
962 prs_debug(ps, depth, desc, "smb_io_gid");
967 prs_uint32("g_rid", ps, depth, &(gid->g_rid));
968 prs_uint32("attr ", ps, depth, &(gid->attr ));
971 /*******************************************************************
972 reads or writes an POLICY_HND structure.
973 ********************************************************************/
974 void smb_io_pol_hnd(char *desc, POLICY_HND *pol, prs_struct *ps, int depth)
976 if (pol == NULL) return;
978 prs_debug(ps, depth, desc, "smb_io_pol_hnd");
983 prs_uint8s (False, "data", ps, depth, pol->data, POL_HND_SIZE);
986 /*******************************************************************
987 reads or writes a dom query structure.
988 ********************************************************************/
989 static void smb_io_dom_query(char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth)
991 if (d_q == NULL) return;
993 prs_debug(ps, depth, desc, "smb_io_dom_query");
998 prs_uint16("uni_dom_max_len", ps, depth, &(d_q->uni_dom_max_len)); /* domain name string length * 2 */
999 prs_uint16("uni_dom_str_len", ps, depth, &(d_q->uni_dom_str_len)); /* domain name string length * 2 */
1001 prs_uint32("buffer_dom_name", ps, depth, &(d_q->buffer_dom_name)); /* undocumented domain name string buffer pointer */
1002 prs_uint32("buffer_dom_sid ", ps, depth, &(d_q->buffer_dom_sid )); /* undocumented domain SID string buffer pointer */
1004 smb_io_unistr2("unistr2", &(d_q->uni_domain_name), d_q->buffer_dom_name, ps, depth); /* domain name (unicode string) */
1006 if (d_q->buffer_dom_sid != 0)
1008 smb_io_dom_sid2("", &(d_q->dom_sid), ps, depth); /* domain SID */
1012 bzero(&(d_q->dom_sid), sizeof(d_q->dom_sid));
1016 /*******************************************************************
1017 reads or writes a dom query structure.
1018 ********************************************************************/
1019 void smb_io_dom_query_3(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
1021 smb_io_dom_query("", d_q, ps, depth);
1024 /*******************************************************************
1025 reads or writes a dom query structure.
1026 ********************************************************************/
1027 void smb_io_dom_query_5(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
1029 smb_io_dom_query("", d_q, ps, depth);
1033 /*******************************************************************
1034 reads or writes a UNISTR3 structure.
1035 ********************************************************************/
1036 void smb_io_unistr3(char *desc, UNISTR3 *name, prs_struct *ps, int depth)
1038 if (name == NULL) return;
1040 prs_debug(ps, depth, desc, "smb_io_unistr3");
1045 prs_uint32("uni_str_len", ps, depth, &(name->uni_str_len));
1047 /* don't know if len is specified by uni_str_len member... */
1048 /* assume unicode string is unicode-null-terminated, instead */
1050 prs_unistr3(True, "unistr", name, ps, depth);