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 ascii_to_unistr(str->buffer, buf, sizeof(str->buffer));
334 /*******************************************************************
335 reads or writes a UNISTR structure.
336 XXXX NOTE: UNISTR structures NEED to be null-terminated.
337 ********************************************************************/
338 void smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int depth)
340 if (uni == NULL) return;
342 prs_debug(ps, depth, desc, "smb_io_unistr");
345 prs_unistr("unistr", ps, depth, uni);
348 /*******************************************************************
349 creates a BUFFER3 structure from a uint32
350 ********************************************************************/
351 void make_buffer3_uint32(BUFFER3 *str, uint32 val)
355 /* set up string lengths. */
356 str->buf_max_len = sizeof(uint32);
357 str->buf_len = sizeof(uint32);
359 SIVAL(str->buffer, 0, val);
362 /*******************************************************************
363 creates a BUFFER3 structure.
364 ********************************************************************/
365 void make_buffer3_str(BUFFER3 *str, char *buf, int len)
369 /* set up string lengths. */
370 str->buf_max_len = len * 2;
371 str->buf_len = len * 2;
373 /* store the string (little endian buffer) */
374 ascii_to_unibuf(str->buffer, buf, str->buf_len);
377 /*******************************************************************
378 creates a BUFFER3 structure from a hex string.
379 ********************************************************************/
380 void make_buffer3_hex(BUFFER3 *str, char *buf)
383 str->buf_max_len = str->buf_len = strhex_to_str((char *)str->buffer, sizeof(str->buffer), buf);
386 /*******************************************************************
387 creates a BUFFER3 structure.
388 ********************************************************************/
389 void make_buffer3_bytes(BUFFER3 *str, uint8 *buf, int len)
393 /* max buffer size (allocated size) */
394 str->buf_max_len = len;
397 memcpy(str->buffer, buf, MIN(str->buf_len, sizeof(str->buffer)));
399 str->buf_len = buf != NULL ? len : 0;
402 /*******************************************************************
403 reads or writes a BUFFER3 structure.
404 the uni_max_len member tells you how large the buffer is.
405 the uni_str_len member tells you how much of the buffer is really used.
406 ********************************************************************/
407 void smb_io_buffer3(char *desc, BUFFER3 *buf3, prs_struct *ps, int depth)
409 if (buf3 == NULL) return;
411 prs_debug(ps, depth, desc, "smb_io_buffer3");
416 prs_uint32("uni_max_len", ps, depth, &(buf3->buf_max_len));
417 if (buf3->buf_max_len > MAX_UNISTRLEN) buf3->buf_max_len = MAX_UNISTRLEN;
419 prs_uint8s(True, "buffer ", ps, depth, buf3->buffer, buf3->buf_max_len);
421 prs_uint32("buf_len ", ps, depth, &(buf3->buf_len));
422 if (buf3->buf_len > MAX_UNISTRLEN) buf3->buf_len = MAX_UNISTRLEN;
425 /*******************************************************************
426 creates a BUFFER2 structure.
427 ********************************************************************/
428 void make_buffer2(BUFFER2 *str, uint8 *buf, int len)
432 /* max buffer size (allocated size) */
433 str->buf_max_len = len;
435 str->buf_len = buf != NULL ? len : 0;
439 memcpy(str->buffer, buf, MIN(str->buf_len, sizeof(str->buffer)));
443 /*******************************************************************
444 reads or writes a BUFFER2 structure.
445 the uni_max_len member tells you how large the buffer is.
446 the uni_str_len member tells you how much of the buffer is really used.
447 ********************************************************************/
448 void smb_io_buffer2(char *desc, BUFFER2 *buf2, uint32 buffer, prs_struct *ps, int depth)
450 if (buf2 == NULL) return;
454 prs_debug(ps, depth, desc, "smb_io_buffer2");
459 prs_uint32("buf_max_len", ps, depth, &(buf2->buf_max_len));
460 prs_uint32("undoc ", ps, depth, &(buf2->undoc ));
461 prs_uint32("buf_len ", ps, depth, &(buf2->buf_len));
463 /* oops! XXXX maybe issue a warning that this is happening... */
464 if (buf2->buf_max_len > MAX_UNISTRLEN) buf2->buf_max_len = MAX_UNISTRLEN;
465 if (buf2->buf_len > MAX_UNISTRLEN) buf2->buf_len = MAX_UNISTRLEN;
467 /* buffer advanced by indicated length of string
468 NOT by searching for null-termination */
469 prs_buffer2(True, "buffer ", ps, depth, buf2);
473 prs_debug(ps, depth, desc, "smb_io_buffer2 - NULL");
475 bzero(buf2, sizeof(*buf2));
479 /*******************************************************************
480 creates a UNISTR2 structure: sets up the buffer, too
481 ********************************************************************/
482 void make_buf_unistr2(UNISTR2 *str, uint32 *ptr, char *buf)
487 make_unistr2(str, buf, strlen(buf)+1);
492 make_unistr2(str, "", 0);
496 /*******************************************************************
497 copies a UNISTR2 structure.
498 ********************************************************************/
499 void copy_unistr2(UNISTR2 *str, UNISTR2 *from)
501 /* set up string lengths. add one if string is not null-terminated */
502 str->uni_max_len = from->uni_max_len;
503 str->undoc = from->undoc;
504 str->uni_str_len = from->uni_str_len;
506 /* copy the string */
507 memcpy(str->buffer, from->buffer, sizeof(from->buffer));
510 /*******************************************************************
511 creates a STRING2 structure.
512 ********************************************************************/
513 void make_string2(STRING2 *str, char *buf, int len)
515 /* set up string lengths. */
516 str->str_max_len = len;
518 str->str_str_len = len;
520 /* store the string */
522 memcpy(str->buffer, buf, len);
525 /*******************************************************************
526 reads or writes a STRING2 structure.
527 XXXX NOTE: STRING2 structures need NOT be null-terminated.
528 the str_str_len member tells you how long the string is;
529 the str_max_len member tells you how large the buffer is.
530 ********************************************************************/
531 void smb_io_string2(char *desc, STRING2 *str2, uint32 buffer, prs_struct *ps, int depth)
533 if (str2 == NULL) return;
537 prs_debug(ps, depth, desc, "smb_io_string2");
542 prs_uint32("str_max_len", ps, depth, &(str2->str_max_len));
543 prs_uint32("undoc ", ps, depth, &(str2->undoc ));
544 prs_uint32("str_str_len", ps, depth, &(str2->str_str_len));
546 /* oops! XXXX maybe issue a warning that this is happening... */
547 if (str2->str_max_len > MAX_STRINGLEN) str2->str_max_len = MAX_STRINGLEN;
548 if (str2->str_str_len > MAX_STRINGLEN) str2->str_str_len = MAX_STRINGLEN;
550 /* buffer advanced by indicated length of string
551 NOT by searching for null-termination */
552 prs_string2(True, "buffer ", ps, depth, str2);
556 prs_debug(ps, depth, desc, "smb_io_string2 - NULL");
558 bzero(str2, sizeof(*str2));
562 /*******************************************************************
563 creates a UNISTR2 structure.
564 ********************************************************************/
565 void make_unistr2(UNISTR2 *str, const char *buf, int len)
569 /* set up string lengths. */
570 str->uni_max_len = len;
572 str->uni_str_len = len;
574 /* store the string (wide chars) */
575 ascii_to_unistr(str->buffer, buf, len);
578 /*******************************************************************
579 reads or writes a UNISTR2 structure.
580 XXXX NOTE: UNISTR2 structures need NOT be null-terminated.
581 the uni_str_len member tells you how long the string is;
582 the uni_max_len member tells you how large the buffer is.
583 ********************************************************************/
584 void smb_io_unistr2(char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct *ps, int depth)
586 if (uni2 == NULL) return;
590 prs_debug(ps, depth, desc, "smb_io_unistr2");
595 prs_uint32("uni_max_len", ps, depth, &(uni2->uni_max_len));
596 prs_uint32("undoc ", ps, depth, &(uni2->undoc ));
597 prs_uint32("uni_str_len", ps, depth, &(uni2->uni_str_len));
599 /* oops! XXXX maybe issue a warning that this is happening... */
600 if (uni2->uni_max_len > MAX_UNISTRLEN) uni2->uni_max_len = MAX_UNISTRLEN;
601 if (uni2->uni_str_len > MAX_UNISTRLEN) uni2->uni_str_len = MAX_UNISTRLEN;
603 /* buffer advanced by indicated length of string
604 NOT by searching for null-termination */
605 prs_unistr2(True, "buffer ", ps, depth, uni2);
609 prs_debug(ps, depth, desc, "smb_io_unistr2 - NULL");
611 bzero(uni2, sizeof(*uni2));
615 /*******************************************************************
616 creates a DOM_RID2 structure.
617 ********************************************************************/
618 void make_dom_rid2(DOM_RID2 *rid2, uint32 rid, uint8 type, uint32 idx)
625 /*******************************************************************
626 reads or writes a DOM_RID2 structure.
627 ********************************************************************/
628 void smb_io_dom_rid2(char *desc, DOM_RID2 *rid2, prs_struct *ps, int depth)
630 if (rid2 == NULL) return;
632 prs_debug(ps, depth, desc, "smb_io_dom_rid2");
637 prs_uint8("type ", ps, depth, &(rid2->type));
639 prs_uint32("rid ", ps, depth, &(rid2->rid ));
640 prs_uint32("rid_idx", ps, depth, &(rid2->rid_idx ));
643 /*******************************************************************
644 creates a DOM_RID3 structure.
645 ********************************************************************/
646 void make_dom_rid3(DOM_RID3 *rid3, uint32 rid, uint8 type)
650 rid3->ptr_type = 0x1; /* non-zero, basically. */
655 /*******************************************************************
656 reads or writes a DOM_RID3 structure.
657 ********************************************************************/
658 void smb_io_dom_rid3(char *desc, DOM_RID3 *rid3, prs_struct *ps, int depth)
660 if (rid3 == NULL) return;
662 prs_debug(ps, depth, desc, "smb_io_dom_rid3");
667 prs_uint32("rid ", ps, depth, &(rid3->rid ));
668 prs_uint32("type1 ", ps, depth, &(rid3->type1 ));
669 prs_uint32("ptr_type", ps, depth, &(rid3->ptr_type));
670 prs_uint32("type2 ", ps, depth, &(rid3->type2 ));
671 prs_uint32("unk ", ps, depth, &(rid3->unk ));
674 /*******************************************************************
675 creates a DOM_RID4 structure.
676 ********************************************************************/
677 void make_dom_rid4(DOM_RID4 *rid4, uint16 unknown, uint16 attr, uint32 rid)
679 rid4->unknown = unknown;
684 /*******************************************************************
685 makes a DOM_CLNT_SRV structure.
686 ********************************************************************/
687 static void make_clnt_srv(DOM_CLNT_SRV *log, char *logon_srv, char *comp_name)
689 if (log == NULL) return;
691 DEBUG(5,("make_clnt_srv: %d\n", __LINE__));
693 if (logon_srv != NULL)
695 log->undoc_buffer = 1;
696 make_unistr2(&(log->uni_logon_srv), logon_srv, strlen(logon_srv)+1);
700 log->undoc_buffer = 0;
703 if (comp_name != NULL)
705 log->undoc_buffer2 = 1;
706 make_unistr2(&(log->uni_comp_name), comp_name, strlen(comp_name)+1);
710 log->undoc_buffer2 = 0;
714 /*******************************************************************
715 reads or writes a DOM_CLNT_SRV structure.
716 ********************************************************************/
717 static void smb_io_clnt_srv(char *desc, DOM_CLNT_SRV *log, prs_struct *ps, int depth)
719 if (log == NULL) return;
721 prs_debug(ps, depth, desc, "smb_io_clnt_srv");
726 prs_uint32("undoc_buffer ", ps, depth, &(log->undoc_buffer ));
727 if (log->undoc_buffer != 0)
729 smb_io_unistr2("unistr2", &(log->uni_logon_srv), log->undoc_buffer, ps, depth);
734 prs_uint32("undoc_buffer2", ps, depth, &(log->undoc_buffer2));
735 if (log->undoc_buffer2 != 0)
737 smb_io_unistr2("unistr2", &(log->uni_comp_name), log->undoc_buffer2, ps, depth);
741 /*******************************************************************
742 makes a DOM_LOG_INFO structure.
743 ********************************************************************/
744 void make_log_info(DOM_LOG_INFO *log, char *logon_srv, char *acct_name,
745 uint16 sec_chan, char *comp_name)
747 if (log == NULL) return;
749 DEBUG(5,("make_log_info %d\n", __LINE__));
751 log->undoc_buffer = 1;
753 make_unistr2(&(log->uni_logon_srv), logon_srv, strlen(logon_srv)+1);
754 make_unistr2(&(log->uni_acct_name), acct_name, strlen(acct_name)+1);
756 log->sec_chan = sec_chan;
758 make_unistr2(&(log->uni_comp_name), comp_name, strlen(comp_name)+1);
761 /*******************************************************************
762 reads or writes a DOM_LOG_INFO structure.
763 ********************************************************************/
764 void smb_io_log_info(char *desc, DOM_LOG_INFO *log, prs_struct *ps, int depth)
766 if (log == NULL) return;
768 prs_debug(ps, depth, desc, "smb_io_log_info");
773 prs_uint32("undoc_buffer", ps, depth, &(log->undoc_buffer));
775 smb_io_unistr2("unistr2", &(log->uni_logon_srv), True, ps, depth);
776 smb_io_unistr2("unistr2", &(log->uni_acct_name), True, ps, depth);
778 prs_uint16("sec_chan", ps, depth, &(log->sec_chan));
780 smb_io_unistr2("unistr2", &(log->uni_comp_name), True, ps, depth);
783 /*******************************************************************
784 reads or writes a DOM_CHAL structure.
785 ********************************************************************/
786 void smb_io_chal(char *desc, DOM_CHAL *chal, prs_struct *ps, int depth)
788 if (chal == NULL) return;
790 prs_debug(ps, depth, desc, "smb_io_chal");
795 prs_uint8s (False, "data", ps, depth, chal->data, 8);
798 /*******************************************************************
799 reads or writes a DOM_CRED structure.
800 ********************************************************************/
801 void smb_io_cred(char *desc, DOM_CRED *cred, prs_struct *ps, int depth)
803 if (cred == NULL) return;
805 prs_debug(ps, depth, desc, "smb_io_cred");
810 smb_io_chal ("", &(cred->challenge), ps, depth);
811 smb_io_utime("", &(cred->timestamp), ps, depth);
814 /*******************************************************************
815 makes a DOM_CLNT_INFO2 structure.
816 ********************************************************************/
817 void make_clnt_info2(DOM_CLNT_INFO2 *clnt,
818 char *logon_srv, char *comp_name,
821 if (clnt == NULL) return;
823 DEBUG(5,("make_clnt_info: %d\n", __LINE__));
825 make_clnt_srv(&(clnt->login), logon_srv, comp_name);
827 if (clnt_cred != NULL)
830 memcpy(&(clnt->cred), clnt_cred, sizeof(clnt->cred));
838 /*******************************************************************
839 reads or writes a DOM_CLNT_INFO2 structure.
840 ********************************************************************/
841 void smb_io_clnt_info2(char *desc, DOM_CLNT_INFO2 *clnt, prs_struct *ps, int depth)
843 if (clnt == NULL) return;
845 prs_debug(ps, depth, desc, "smb_io_clnt_info2");
850 smb_io_clnt_srv("", &(clnt->login), ps, depth);
854 prs_uint32("ptr_cred", ps, depth, &(clnt->ptr_cred));
855 smb_io_cred ("", &(clnt->cred ), ps, depth);
858 /*******************************************************************
859 makes a DOM_CLNT_INFO structure.
860 ********************************************************************/
861 void make_clnt_info(DOM_CLNT_INFO *clnt,
862 char *logon_srv, char *acct_name,
863 uint16 sec_chan, char *comp_name,
866 if (clnt == NULL || cred == NULL) return;
868 DEBUG(5,("make_clnt_info\n"));
870 make_log_info(&(clnt->login), logon_srv, acct_name, sec_chan, comp_name);
871 memcpy(&(clnt->cred), cred, sizeof(clnt->cred));
874 /*******************************************************************
875 reads or writes a DOM_CLNT_INFO structure.
876 ********************************************************************/
877 void smb_io_clnt_info(char *desc, DOM_CLNT_INFO *clnt, prs_struct *ps, int depth)
879 if (clnt == NULL) return;
881 prs_debug(ps, depth, desc, "smb_io_clnt_info");
886 smb_io_log_info("", &(clnt->login), ps, depth);
887 smb_io_cred ("", &(clnt->cred ), ps, depth);
890 /*******************************************************************
891 makes a DOM_LOGON_ID structure.
892 ********************************************************************/
893 void make_logon_id(DOM_LOGON_ID *log, uint32 log_id_low, uint32 log_id_high)
895 if (log == NULL) return;
897 DEBUG(5,("make_logon_id: %d\n", __LINE__));
899 log->low = log_id_low;
900 log->high = log_id_high;
903 /*******************************************************************
904 reads or writes a DOM_LOGON_ID structure.
905 ********************************************************************/
906 void smb_io_logon_id(char *desc, DOM_LOGON_ID *log, prs_struct *ps, int depth)
908 if (log == NULL) return;
910 prs_debug(ps, depth, desc, "smb_io_logon_id");
915 prs_uint32("low ", ps, depth, &(log->low ));
916 prs_uint32("high", ps, depth, &(log->high));
919 /*******************************************************************
920 makes an OWF_INFO structure.
921 ********************************************************************/
922 void make_owf_info(OWF_INFO *hash, uint8 data[16])
924 if (hash == NULL) return;
926 DEBUG(5,("make_owf_info: %d\n", __LINE__));
930 memcpy(hash->data, data, sizeof(hash->data));
934 bzero(hash->data, sizeof(hash->data));
938 /*******************************************************************
939 reads or writes an OWF_INFO structure.
940 ********************************************************************/
941 void smb_io_owf_info(char *desc, OWF_INFO *hash, prs_struct *ps, int depth)
943 if (hash == NULL) return;
945 prs_debug(ps, depth, desc, "smb_io_owf_info");
950 prs_uint8s (False, "data", ps, depth, hash->data, 16);
953 /*******************************************************************
954 reads or writes a DOM_GID structure.
955 ********************************************************************/
956 void smb_io_gid(char *desc, DOM_GID *gid, prs_struct *ps, int depth)
958 if (gid == NULL) return;
960 prs_debug(ps, depth, desc, "smb_io_gid");
965 prs_uint32("g_rid", ps, depth, &(gid->g_rid));
966 prs_uint32("attr ", ps, depth, &(gid->attr ));
969 /*******************************************************************
970 reads or writes an POLICY_HND structure.
971 ********************************************************************/
972 void smb_io_pol_hnd(char *desc, POLICY_HND *pol, prs_struct *ps, int depth)
974 if (pol == NULL) return;
976 prs_debug(ps, depth, desc, "smb_io_pol_hnd");
981 prs_uint8s (False, "data", ps, depth, pol->data, POL_HND_SIZE);
984 /*******************************************************************
985 reads or writes a dom query structure.
986 ********************************************************************/
987 static void smb_io_dom_query(char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth)
989 if (d_q == NULL) return;
991 prs_debug(ps, depth, desc, "smb_io_dom_query");
996 prs_uint16("uni_dom_max_len", ps, depth, &(d_q->uni_dom_max_len)); /* domain name string length * 2 */
997 prs_uint16("uni_dom_str_len", ps, depth, &(d_q->uni_dom_str_len)); /* domain name string length * 2 */
999 prs_uint32("buffer_dom_name", ps, depth, &(d_q->buffer_dom_name)); /* undocumented domain name string buffer pointer */
1000 prs_uint32("buffer_dom_sid ", ps, depth, &(d_q->buffer_dom_sid )); /* undocumented domain SID string buffer pointer */
1002 smb_io_unistr2("unistr2", &(d_q->uni_domain_name), d_q->buffer_dom_name, ps, depth); /* domain name (unicode string) */
1004 if (d_q->buffer_dom_sid != 0)
1006 smb_io_dom_sid2("", &(d_q->dom_sid), ps, depth); /* domain SID */
1010 bzero(&(d_q->dom_sid), sizeof(d_q->dom_sid));
1014 /*******************************************************************
1015 reads or writes a dom query structure.
1016 ********************************************************************/
1017 void smb_io_dom_query_3(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
1019 smb_io_dom_query("", d_q, ps, depth);
1022 /*******************************************************************
1023 reads or writes a dom query structure.
1024 ********************************************************************/
1025 void smb_io_dom_query_5(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
1027 smb_io_dom_query("", d_q, ps, depth);
1031 /*******************************************************************
1032 reads or writes a UNISTR3 structure.
1033 ********************************************************************/
1034 void smb_io_unistr3(char *desc, UNISTR3 *name, prs_struct *ps, int depth)
1036 if (name == NULL) return;
1038 prs_debug(ps, depth, desc, "smb_io_unistr3");
1043 prs_uint32("uni_str_len", ps, depth, &(name->uni_str_len));
1045 /* don't know if len is specified by uni_str_len member... */
1046 /* assume unicode string is unicode-null-terminated, instead */
1048 prs_unistr3(True, "unistr", name, ps, depth);