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_SID structure.
151 BIG NOTE: this function only does SIDS where the identauth is not >= 2^32
152 identauth >= 2^32 can be detected because it will be specified in hex
154 ********************************************************************/
155 void make_dom_sid(DOM_SID *sid, char *str_sid)
161 if (sid == NULL) return;
165 DEBUG(4,("netlogon domain SID: none\n"));
166 sid->sid_rev_num = 0;
171 pstrcpy(domsid, str_sid);
173 DEBUG(4,("make_dom_sid %d SID: %s\n", __LINE__, domsid));
175 /* assume, but should check, that domsid starts "S-" */
176 p = strtok(domsid+2,"-");
177 sid->sid_rev_num = atoi(p);
179 /* identauth in decimal should be < 2^32 */
180 /* identauth in hex should be >= 2^32 */
181 identauth = atoi(strtok(0,"-"));
183 DEBUG(4,("netlogon rev %d\n", sid->sid_rev_num));
184 DEBUG(4,("netlogon %s ia %d\n", p, identauth));
188 sid->id_auth[2] = (identauth & 0xff000000) >> 24;
189 sid->id_auth[3] = (identauth & 0x00ff0000) >> 16;
190 sid->id_auth[4] = (identauth & 0x0000ff00) >> 8;
191 sid->id_auth[5] = (identauth & 0x000000ff);
195 while ((p = strtok(0, "-")) != NULL && sid->num_auths < MAXSUBAUTHS)
197 sid->sub_auths[sid->num_auths++] = atoi(p);
200 DEBUG(4,("make_dom_sid: %d SID: %s\n", __LINE__, domsid));
202 /*******************************************************************
203 creates a DOM_SID2 structure.
204 ********************************************************************/
205 void make_dom_sid2(DOM_SID2 *sid2, DOM_SID *sid)
207 sid_copy(&sid2->sid, sid);
208 sid2->num_auths = sid2->sid.num_auths;
211 /*******************************************************************
212 reads or writes a DOM_SID2 structure.
213 ********************************************************************/
214 void smb_io_dom_sid2(char *desc, DOM_SID2 *sid, prs_struct *ps, int depth)
216 if (sid == NULL) return;
218 prs_debug(ps, depth, desc, "smb_io_dom_sid2");
223 prs_uint32("num_auths", ps, depth, &(sid->num_auths));
225 smb_io_dom_sid("sid", &(sid->sid), ps, depth);
228 /*******************************************************************
229 creates a STRHDR structure.
230 ********************************************************************/
231 void make_str_hdr(STRHDR *hdr, int max_len, int len, uint32 buffer)
233 hdr->str_max_len = max_len;
234 hdr->str_str_len = len;
235 hdr->buffer = buffer;
238 /*******************************************************************
239 reads or writes a STRHDR structure.
240 ********************************************************************/
241 void smb_io_strhdr(char *desc, STRHDR *hdr, prs_struct *ps, int depth)
243 if (hdr == NULL) return;
245 prs_debug(ps, depth, desc, "smb_io_strhdr");
250 prs_uint16("str_str_len", ps, depth, &(hdr->str_str_len));
251 prs_uint16("str_max_len", ps, depth, &(hdr->str_max_len));
252 prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
254 /* oops! XXXX maybe issue a warning that this is happening... */
255 if (hdr->str_max_len > MAX_STRINGLEN) hdr->str_max_len = MAX_STRINGLEN;
256 if (hdr->str_str_len > MAX_STRINGLEN) hdr->str_str_len = MAX_STRINGLEN;
259 /*******************************************************************
260 creates a UNIHDR structure.
261 ********************************************************************/
262 void make_uni_hdr(UNIHDR *hdr, int max_len, int len, uint32 buffer)
264 hdr->uni_str_len = 2 * len;
265 hdr->uni_max_len = 2 * max_len;
266 hdr->buffer = buffer;
269 /*******************************************************************
270 reads or writes a UNIHDR structure.
271 ********************************************************************/
272 void smb_io_unihdr(char *desc, UNIHDR *hdr, prs_struct *ps, int depth)
274 if (hdr == NULL) return;
276 prs_debug(ps, depth, desc, "smb_io_unihdr");
281 prs_uint16("uni_str_len", ps, depth, &(hdr->uni_str_len));
282 prs_uint16("uni_max_len", ps, depth, &(hdr->uni_max_len));
283 prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
285 /* oops! XXXX maybe issue a warning that this is happening... */
286 if (hdr->uni_max_len > MAX_UNISTRLEN) hdr->uni_max_len = MAX_UNISTRLEN;
287 if (hdr->uni_str_len > MAX_UNISTRLEN) hdr->uni_str_len = MAX_UNISTRLEN;
290 /*******************************************************************
291 creates a BUFHDR structure.
292 ********************************************************************/
293 void make_buf_hdr(BUFHDR *hdr, int max_len, int len)
295 hdr->buf_max_len = max_len;
299 /*******************************************************************
300 prs_uint16 wrapper. call this and it sets up a pointer to where the
301 uint16 should be stored, or gets the size if reading
302 ********************************************************************/
303 void smb_io_hdrbuf_pre(char *desc, BUFHDR *hdr, prs_struct *ps, int depth, uint32 *offset)
305 (*offset) = ps->offset;
309 smb_io_hdrbuf(desc, hdr, ps, depth);
313 ps->offset += sizeof(uint32) * 2;
317 /*******************************************************************
318 smb_io_hdrbuf wrapper. call this and it retrospectively stores the size.
319 does nothing on reading, as that is already handled by ...._pre()
320 ********************************************************************/
321 void smb_io_hdrbuf_post(char *desc, BUFHDR *hdr, prs_struct *ps, int depth,
322 uint32 ptr_hdrbuf, uint32 max_len, uint32 len)
326 /* storing: go back and do a retrospective job. i hate this */
327 uint32 old_offset = ps->offset;
329 make_buf_hdr(hdr, max_len, len);
330 ps->offset = ptr_hdrbuf;
331 smb_io_hdrbuf(desc, hdr, ps, depth);
332 ps->offset = old_offset;
335 /*******************************************************************
336 reads or writes a BUFHDR structure.
337 ********************************************************************/
338 void smb_io_hdrbuf(char *desc, BUFHDR *hdr, prs_struct *ps, int depth)
340 if (hdr == NULL) return;
342 prs_debug(ps, depth, desc, "smb_io_hdrbuf");
347 prs_uint32("buf_max_len", ps, depth, &(hdr->buf_max_len));
348 prs_uint32("buf_len ", ps, depth, &(hdr->buf_len ));
350 /* oops! XXXX maybe issue a warning that this is happening... */
351 if (hdr->buf_max_len > MAX_BUFFERLEN) hdr->buf_max_len = MAX_BUFFERLEN;
352 if (hdr->buf_len > MAX_BUFFERLEN) hdr->buf_len = MAX_BUFFERLEN;
355 /*******************************************************************
356 creates a UNIHDR2 structure.
357 ********************************************************************/
358 void make_uni_hdr2(UNIHDR2 *hdr, int max_len, int len, uint16 terminate)
360 make_uni_hdr(&(hdr->unihdr), max_len, len, terminate);
361 hdr->buffer = len > 0 ? 1 : 0;
364 /*******************************************************************
365 reads or writes a UNIHDR2 structure.
366 ********************************************************************/
367 void smb_io_unihdr2(char *desc, UNIHDR2 *hdr2, prs_struct *ps, int depth)
369 if (hdr2 == NULL) return;
371 prs_debug(ps, depth, desc, "smb_io_unihdr2");
376 smb_io_unihdr("hdr", &(hdr2->unihdr), ps, depth);
377 prs_uint32("buffer", ps, depth, &(hdr2->buffer));
380 /*******************************************************************
381 creates a UNISTR structure.
382 ********************************************************************/
383 void make_unistr(UNISTR *str, char *buf)
385 /* store the string (null-terminated copy) */
386 struni2(str->buffer, buf);
389 /*******************************************************************
390 reads or writes a UNISTR structure.
391 XXXX NOTE: UNISTR structures NEED to be null-terminated.
392 ********************************************************************/
393 void smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int depth)
395 if (uni == NULL) return;
397 prs_debug(ps, depth, desc, "smb_io_unistr");
401 prs_unistr("unistr", ps, depth, uni);
404 /*******************************************************************
405 creates a BUFFER3 structure from a uint32
406 ********************************************************************/
407 void make_buffer3_uint32(BUFFER3 *str, uint32 val)
411 /* set up string lengths. */
412 str->buf_max_len = sizeof(uint32);
413 str->buf_len = sizeof(uint32);
415 SIVAL(str->buffer, 0, val);
418 /*******************************************************************
419 creates a BUFFER3 structure.
420 ********************************************************************/
421 void make_buffer3_str(BUFFER3 *str, char *buf, int len)
425 /* set up string lengths. */
426 str->buf_max_len = len * 2;
427 str->buf_len = len * 2;
429 /* store the string (null-terminated 8 bit chars into 16 bit chars) */
430 struni2((uint16*)str->buffer, buf);
433 /*******************************************************************
434 creates a BUFFER3 structure from a hex string.
435 ********************************************************************/
436 void make_buffer3_hex(BUFFER3 *str, char *buf)
439 str->buf_max_len = str->buf_len = strhex_to_str((char *)str->buffer, sizeof(str->buffer), buf);
442 /*******************************************************************
443 creates a BUFFER3 structure.
444 ********************************************************************/
445 void make_buffer3_bytes(BUFFER3 *str, uint8 *buf, int len)
449 /* max buffer size (allocated size) */
450 str->buf_max_len = len;
453 memcpy(str->buffer, buf, MIN(str->buf_len, sizeof(str->buffer)));
455 str->buf_len = buf != NULL ? len : 0;
458 /*******************************************************************
459 reads or writes a BUFFER3 structure.
460 the uni_max_len member tells you how large the buffer is.
461 the uni_str_len member tells you how much of the buffer is really used.
462 ********************************************************************/
463 void smb_io_buffer3(char *desc, BUFFER3 *buf3, prs_struct *ps, int depth)
465 if (buf3 == NULL) return;
467 prs_debug(ps, depth, desc, "smb_io_buffer3");
472 prs_uint32("uni_max_len", ps, depth, &(buf3->buf_max_len));
473 if (buf3->buf_max_len > MAX_UNISTRLEN) buf3->buf_max_len = MAX_UNISTRLEN;
475 prs_uint8s(True, "buffer ", ps, depth, buf3->buffer, buf3->buf_max_len);
477 prs_uint32("buf_len ", ps, depth, &(buf3->buf_len));
478 if (buf3->buf_len > MAX_UNISTRLEN) buf3->buf_len = MAX_UNISTRLEN;
481 /*******************************************************************
482 creates a BUFFER2 structure.
483 ********************************************************************/
484 void make_buffer2(BUFFER2 *str, uint8 *buf, int len)
488 /* max buffer size (allocated size) */
489 str->buf_max_len = len;
491 str->buf_len = buf != NULL ? len : 0;
495 memcpy(str->buffer, buf, MIN(str->buf_len, sizeof(str->buffer)));
499 /*******************************************************************
500 reads or writes a BUFFER2 structure.
501 the uni_max_len member tells you how large the buffer is.
502 the uni_str_len member tells you how much of the buffer is really used.
503 ********************************************************************/
504 void smb_io_buffer2(char *desc, BUFFER2 *buf2, uint32 buffer, prs_struct *ps, int depth)
506 if (buf2 == NULL) return;
510 prs_debug(ps, depth, desc, "smb_io_buffer2");
515 prs_uint32("uni_max_len", ps, depth, &(buf2->buf_max_len));
516 prs_uint32("undoc ", ps, depth, &(buf2->undoc ));
517 prs_uint32("buf_len ", ps, depth, &(buf2->buf_len));
519 /* oops! XXXX maybe issue a warning that this is happening... */
520 if (buf2->buf_max_len > MAX_UNISTRLEN) buf2->buf_max_len = MAX_UNISTRLEN;
521 if (buf2->buf_len > MAX_UNISTRLEN) buf2->buf_len = MAX_UNISTRLEN;
523 /* buffer advanced by indicated length of string
524 NOT by searching for null-termination */
525 prs_buffer2(True, "buffer ", ps, depth, buf2);
529 prs_debug(ps, depth, desc, "smb_io_buffer2 - NULL");
531 bzero(buf2, sizeof(*buf2));
535 /*******************************************************************
536 creates a UNISTR2 structure: sets up the buffer, too
537 ********************************************************************/
538 void make_buf_unistr2(UNISTR2 *str, uint32 *ptr, char *buf)
543 make_unistr2(str, buf, strlen(buf)+1);
548 make_unistr2(str, "", 0);
552 /*******************************************************************
553 copies a UNISTR2 structure.
554 ********************************************************************/
555 void copy_unistr2(UNISTR2 *str, UNISTR2 *from)
557 /* set up string lengths. add one if string is not null-terminated */
558 str->uni_max_len = from->uni_max_len;
559 str->undoc = from->undoc;
560 str->uni_str_len = from->uni_str_len;
562 /* copy the string */
563 memcpy(str->buffer, from->buffer, sizeof(from->buffer));
566 /*******************************************************************
567 creates a STRING2 structure.
568 ********************************************************************/
569 void make_string2(STRING2 *str, char *buf, int len)
571 /* set up string lengths. */
572 str->str_max_len = len;
574 str->str_str_len = len;
576 /* store the string */
578 memcpy(str->buffer, buf, len);
581 /*******************************************************************
582 reads or writes a STRING2 structure.
583 XXXX NOTE: STRING2 structures need NOT be null-terminated.
584 the str_str_len member tells you how long the string is;
585 the str_max_len member tells you how large the buffer is.
586 ********************************************************************/
587 void smb_io_string2(char *desc, STRING2 *str2, uint32 buffer, prs_struct *ps, int depth)
589 if (str2 == NULL) return;
593 prs_debug(ps, depth, desc, "smb_io_string2");
598 prs_uint32("str_max_len", ps, depth, &(str2->str_max_len));
599 prs_uint32("undoc ", ps, depth, &(str2->undoc ));
600 prs_uint32("str_str_len", ps, depth, &(str2->str_str_len));
602 /* oops! XXXX maybe issue a warning that this is happening... */
603 if (str2->str_max_len > MAX_STRINGLEN) str2->str_max_len = MAX_STRINGLEN;
604 if (str2->str_str_len > MAX_STRINGLEN) str2->str_str_len = MAX_STRINGLEN;
606 /* buffer advanced by indicated length of string
607 NOT by searching for null-termination */
608 prs_string2(True, "buffer ", ps, depth, str2);
612 prs_debug(ps, depth, desc, "smb_io_string2 - NULL");
614 bzero(str2, sizeof(*str2));
618 /*******************************************************************
619 creates a UNISTR2 structure.
620 ********************************************************************/
621 void make_unistr2(UNISTR2 *str, char *buf, int len)
625 /* set up string lengths. */
626 str->uni_max_len = len;
628 str->uni_str_len = len;
630 /* store the string (null-terminated 8 bit chars into 16 bit chars) */
631 struni2(str->buffer, buf);
634 /*******************************************************************
635 reads or writes a UNISTR2 structure.
636 XXXX NOTE: UNISTR2 structures need NOT be null-terminated.
637 the uni_str_len member tells you how long the string is;
638 the uni_max_len member tells you how large the buffer is.
639 ********************************************************************/
640 void smb_io_unistr2(char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct *ps, int depth)
642 if (uni2 == NULL) return;
646 prs_debug(ps, depth, desc, "smb_io_unistr2");
651 prs_uint32("uni_max_len", ps, depth, &(uni2->uni_max_len));
652 prs_uint32("undoc ", ps, depth, &(uni2->undoc ));
653 prs_uint32("uni_str_len", ps, depth, &(uni2->uni_str_len));
655 /* oops! XXXX maybe issue a warning that this is happening... */
656 if (uni2->uni_max_len > MAX_UNISTRLEN) uni2->uni_max_len = MAX_UNISTRLEN;
657 if (uni2->uni_str_len > MAX_UNISTRLEN) uni2->uni_str_len = MAX_UNISTRLEN;
659 /* buffer advanced by indicated length of string
660 NOT by searching for null-termination */
661 prs_unistr2(True, "buffer ", ps, depth, uni2);
665 prs_debug(ps, depth, desc, "smb_io_unistr2 - NULL");
667 bzero(uni2, sizeof(*uni2));
671 /*******************************************************************
672 creates a DOM_RID2 structure.
673 ********************************************************************/
674 void make_dom_rid2(DOM_RID2 *rid2, uint32 rid, uint8 type)
681 /*******************************************************************
682 reads or writes a DOM_RID2 structure.
683 ********************************************************************/
684 void smb_io_dom_rid2(char *desc, DOM_RID2 *rid2, prs_struct *ps, int depth)
686 if (rid2 == NULL) return;
688 prs_debug(ps, depth, desc, "smb_io_dom_rid2");
693 prs_uint8("type ", ps, depth, &(rid2->type));
695 prs_uint32("rid ", ps, depth, &(rid2->rid ));
696 prs_uint32("rid_idx", ps, depth, &(rid2->rid_idx ));
699 /*******************************************************************
700 creates a DOM_RID3 structure.
701 ********************************************************************/
702 void make_dom_rid3(DOM_RID3 *rid3, uint32 rid, uint8 type)
706 rid3->ptr_type = 0x1; /* non-zero, basically. */
710 /*******************************************************************
711 reads or writes a DOM_RID3 structure.
712 ********************************************************************/
713 void smb_io_dom_rid3(char *desc, DOM_RID3 *rid3, prs_struct *ps, int depth)
715 if (rid3 == NULL) return;
717 prs_debug(ps, depth, desc, "smb_io_dom_rid3");
722 prs_uint32("rid ", ps, depth, &(rid3->rid ));
723 prs_uint32("type1 ", ps, depth, &(rid3->type1 ));
724 prs_uint32("ptr_type", ps, depth, &(rid3->ptr_type));
725 prs_uint32("type2 ", ps, depth, &(rid3->type2 ));
728 /*******************************************************************
729 creates a DOM_RID4 structure.
730 ********************************************************************/
731 void make_dom_rid4(DOM_RID4 *rid4, uint16 unknown, uint16 attr, uint32 rid)
733 rid4->unknown = unknown;
739 /*******************************************************************
740 makes a DOM_CLNT_SRV structure.
741 ********************************************************************/
742 static void make_clnt_srv(DOM_CLNT_SRV *log, char *logon_srv, char *comp_name)
744 if (log == NULL) return;
746 DEBUG(5,("make_clnt_srv: %d\n", __LINE__));
748 if (logon_srv != NULL)
750 log->undoc_buffer = 1;
751 make_unistr2(&(log->uni_logon_srv), logon_srv, strlen(logon_srv)+1);
755 log->undoc_buffer = 0;
758 if (comp_name != NULL)
760 log->undoc_buffer2 = 1;
761 make_unistr2(&(log->uni_comp_name), comp_name, strlen(comp_name)+1);
765 log->undoc_buffer2 = 0;
769 /*******************************************************************
770 reads or writes a DOM_CLNT_SRV structure.
771 ********************************************************************/
772 static void smb_io_clnt_srv(char *desc, DOM_CLNT_SRV *log, prs_struct *ps, int depth)
774 if (log == NULL) return;
776 prs_debug(ps, depth, desc, "smb_io_clnt_srv");
781 prs_uint32("undoc_buffer ", ps, depth, &(log->undoc_buffer ));
782 if (log->undoc_buffer != 0)
784 smb_io_unistr2("unistr2", &(log->uni_logon_srv), log->undoc_buffer, ps, depth);
789 prs_uint32("undoc_buffer2", ps, depth, &(log->undoc_buffer2));
790 if (log->undoc_buffer2 != 0)
792 smb_io_unistr2("unistr2", &(log->uni_comp_name), log->undoc_buffer2, ps, depth);
796 /*******************************************************************
797 makes a DOM_LOG_INFO structure.
798 ********************************************************************/
799 void make_log_info(DOM_LOG_INFO *log, char *logon_srv, char *acct_name,
800 uint16 sec_chan, char *comp_name)
802 if (log == NULL) return;
804 DEBUG(5,("make_log_info %d\n", __LINE__));
806 log->undoc_buffer = 1;
808 make_unistr2(&(log->uni_logon_srv), logon_srv, strlen(logon_srv)+1);
809 make_unistr2(&(log->uni_acct_name), acct_name, strlen(acct_name)+1);
811 log->sec_chan = sec_chan;
813 make_unistr2(&(log->uni_comp_name), comp_name, strlen(comp_name)+1);
816 /*******************************************************************
817 reads or writes a DOM_LOG_INFO structure.
818 ********************************************************************/
819 void smb_io_log_info(char *desc, DOM_LOG_INFO *log, prs_struct *ps, int depth)
821 if (log == NULL) return;
823 prs_debug(ps, depth, desc, "smb_io_log_info");
828 prs_uint32("undoc_buffer", ps, depth, &(log->undoc_buffer));
830 smb_io_unistr2("unistr2", &(log->uni_logon_srv), True, ps, depth);
831 smb_io_unistr2("unistr2", &(log->uni_acct_name), True, ps, depth);
833 prs_uint16("sec_chan", ps, depth, &(log->sec_chan));
835 smb_io_unistr2("unistr2", &(log->uni_comp_name), True, ps, depth);
838 /*******************************************************************
839 reads or writes a DOM_CHAL structure.
840 ********************************************************************/
841 void smb_io_chal(char *desc, DOM_CHAL *chal, prs_struct *ps, int depth)
843 if (chal == NULL) return;
845 prs_debug(ps, depth, desc, "smb_io_chal");
850 prs_uint8s (False, "data", ps, depth, chal->data, 8);
853 /*******************************************************************
854 reads or writes a DOM_CRED structure.
855 ********************************************************************/
856 void smb_io_cred(char *desc, DOM_CRED *cred, prs_struct *ps, int depth)
858 if (cred == NULL) return;
860 prs_debug(ps, depth, desc, "smb_io_cred");
865 smb_io_chal ("", &(cred->challenge), ps, depth);
866 smb_io_utime("", &(cred->timestamp), ps, depth);
869 /*******************************************************************
870 makes a DOM_CLNT_INFO2 structure.
871 ********************************************************************/
872 void make_clnt_info2(DOM_CLNT_INFO2 *clnt,
873 char *logon_srv, char *comp_name,
876 if (clnt == NULL) return;
878 DEBUG(5,("make_clnt_info: %d\n", __LINE__));
880 make_clnt_srv(&(clnt->login), logon_srv, comp_name);
882 if (clnt_cred != NULL)
885 memcpy(&(clnt->cred), clnt_cred, sizeof(clnt->cred));
893 /*******************************************************************
894 reads or writes a DOM_CLNT_INFO2 structure.
895 ********************************************************************/
896 void smb_io_clnt_info2(char *desc, DOM_CLNT_INFO2 *clnt, prs_struct *ps, int depth)
898 if (clnt == NULL) return;
900 prs_debug(ps, depth, desc, "smb_io_clnt_info2");
905 smb_io_clnt_srv("", &(clnt->login), ps, depth);
909 prs_uint32("ptr_cred", ps, depth, &(clnt->ptr_cred));
910 smb_io_cred ("", &(clnt->cred ), ps, depth);
913 /*******************************************************************
914 makes a DOM_CLNT_INFO structure.
915 ********************************************************************/
916 void make_clnt_info(DOM_CLNT_INFO *clnt,
917 char *logon_srv, char *acct_name,
918 uint16 sec_chan, char *comp_name,
921 if (clnt == NULL || cred == NULL) return;
923 DEBUG(5,("make_clnt_info\n"));
925 make_log_info(&(clnt->login), logon_srv, acct_name, sec_chan, comp_name);
926 memcpy(&(clnt->cred), cred, sizeof(clnt->cred));
929 /*******************************************************************
930 reads or writes a DOM_CLNT_INFO structure.
931 ********************************************************************/
932 void smb_io_clnt_info(char *desc, DOM_CLNT_INFO *clnt, prs_struct *ps, int depth)
934 if (clnt == NULL) return;
936 prs_debug(ps, depth, desc, "smb_io_clnt_info");
941 smb_io_log_info("", &(clnt->login), ps, depth);
942 smb_io_cred ("", &(clnt->cred ), ps, depth);
945 /*******************************************************************
946 makes a DOM_LOGON_ID structure.
947 ********************************************************************/
948 void make_logon_id(DOM_LOGON_ID *log, uint32 log_id_low, uint32 log_id_high)
950 if (log == NULL) return;
952 DEBUG(5,("make_logon_id: %d\n", __LINE__));
954 log->low = log_id_low;
955 log->high = log_id_high;
958 /*******************************************************************
959 reads or writes a DOM_LOGON_ID structure.
960 ********************************************************************/
961 void smb_io_logon_id(char *desc, DOM_LOGON_ID *log, prs_struct *ps, int depth)
963 if (log == NULL) return;
965 prs_debug(ps, depth, desc, "smb_io_logon_id");
970 prs_uint32("low ", ps, depth, &(log->low ));
971 prs_uint32("high", ps, depth, &(log->high));
974 /*******************************************************************
975 makes an OWF_INFO structure.
976 ********************************************************************/
977 void make_owf_info(OWF_INFO *hash, uint8 data[16])
979 if (hash == NULL) return;
981 DEBUG(5,("make_owf_info: %d\n", __LINE__));
985 memcpy(hash->data, data, sizeof(hash->data));
989 bzero(hash->data, sizeof(hash->data));
993 /*******************************************************************
994 reads or writes an OWF_INFO structure.
995 ********************************************************************/
996 void smb_io_owf_info(char *desc, OWF_INFO *hash, prs_struct *ps, int depth)
998 if (hash == NULL) return;
1000 prs_debug(ps, depth, desc, "smb_io_owf_info");
1005 prs_uint8s (False, "data", ps, depth, hash->data, 16);
1008 /*******************************************************************
1009 reads or writes a DOM_GID structure.
1010 ********************************************************************/
1011 void smb_io_gid(char *desc, DOM_GID *gid, prs_struct *ps, int depth)
1013 if (gid == NULL) return;
1015 prs_debug(ps, depth, desc, "smb_io_gid");
1020 prs_uint32("g_rid", ps, depth, &(gid->g_rid));
1021 prs_uint32("attr ", ps, depth, &(gid->attr ));
1024 /*******************************************************************
1025 reads or writes an POLICY_HND structure.
1026 ********************************************************************/
1027 void smb_io_pol_hnd(char *desc, POLICY_HND *pol, prs_struct *ps, int depth)
1029 if (pol == NULL) return;
1031 prs_debug(ps, depth, desc, "smb_io_pol_hnd");
1036 prs_uint8s (False, "data", ps, depth, pol->data, POL_HND_SIZE);
1039 /*******************************************************************
1040 reads or writes a dom query structure.
1041 ********************************************************************/
1042 static void smb_io_dom_query(char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth)
1044 if (d_q == NULL) return;
1046 prs_debug(ps, depth, desc, "smb_io_dom_query");
1051 prs_uint16("uni_dom_max_len", ps, depth, &(d_q->uni_dom_max_len)); /* domain name string length * 2 */
1052 prs_uint16("uni_dom_str_len", ps, depth, &(d_q->uni_dom_str_len)); /* domain name string length * 2 */
1054 prs_uint32("buffer_dom_name", ps, depth, &(d_q->buffer_dom_name)); /* undocumented domain name string buffer pointer */
1055 prs_uint32("buffer_dom_sid ", ps, depth, &(d_q->buffer_dom_sid )); /* undocumented domain SID string buffer pointer */
1057 smb_io_unistr2("unistr2", &(d_q->uni_domain_name), d_q->buffer_dom_name, ps, depth); /* domain name (unicode string) */
1059 if (d_q->buffer_dom_sid != 0)
1061 smb_io_dom_sid2("", &(d_q->dom_sid), ps, depth); /* domain SID */
1065 bzero(&(d_q->dom_sid), sizeof(d_q->dom_sid));
1069 /*******************************************************************
1070 reads or writes a dom query structure.
1071 ********************************************************************/
1072 void smb_io_dom_query_3(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
1074 smb_io_dom_query("", d_q, ps, depth);
1077 /*******************************************************************
1078 reads or writes a dom query structure.
1079 ********************************************************************/
1080 void smb_io_dom_query_5(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
1082 smb_io_dom_query("", d_q, ps, depth);
1086 /*******************************************************************
1087 reads or writes a UNISTR3 structure.
1088 ********************************************************************/
1089 void smb_io_unistr3(char *desc, UNISTR3 *name, prs_struct *ps, int depth)
1091 if (name == NULL) return;
1093 prs_debug(ps, depth, desc, "smb_io_unistr3");
1098 prs_uint32("uni_str_len", ps, depth, &(name->uni_str_len));
1100 /* don't know if len is specified by uni_str_len member... */
1101 /* assume unicode string is unicode-null-terminated, instead */
1103 prs_unistr3(True, "unistr", name, ps, depth);