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;
31 /*******************************************************************
32 reads or writes a BIGINT structure.
33 ********************************************************************/
34 BOOL smb_io_bigint(char *desc, BIGINT *bigint, prs_struct *ps, int depth)
36 if (bigint == NULL) return False;
38 prs_debug(ps, depth, desc, "smb_io_bigint");
43 prs_uint32("low ", ps, depth, &(bigint->low ));
44 prs_uint32("high", ps, depth, &(bigint->high));
49 /*******************************************************************
50 reads or writes a UTIME type.
51 ********************************************************************/
52 static BOOL smb_io_utime(char *desc, UTIME *t, prs_struct *ps, int depth)
54 if (t == NULL) return False;
56 prs_debug(ps, depth, desc, "smb_io_utime");
61 prs_uint32 ("time", ps, depth, &(t->time));
66 /*******************************************************************
67 reads or writes an NTTIME structure.
68 ********************************************************************/
69 BOOL smb_io_time(char *desc, NTTIME *nttime, prs_struct *ps, int depth)
71 if (nttime == NULL) return False;
73 prs_debug(ps, depth, desc, "smb_io_time");
78 prs_uint32("low ", ps, depth, &(nttime->low )); /* low part */
79 prs_uint32("high", ps, depth, &(nttime->high)); /* high part */
84 /*******************************************************************
85 reads or writes a LOOKUP_LEVEL structure.
86 ********************************************************************/
87 BOOL smb_io_lookup_level(char *desc, LOOKUP_LEVEL *level, prs_struct *ps, int depth)
89 if (level == NULL) return False;
91 prs_debug(ps, depth, desc, "smb_io_lookup_level");
95 prs_uint16("value", ps, depth, &(level->value));
101 /*******************************************************************
102 gets an enumeration handle from an ENUM_HND structure.
103 ********************************************************************/
104 uint32 get_enum_hnd(ENUM_HND *enh)
106 return (enh && enh->ptr_hnd != 0) ? enh->handle : 0;
111 /*******************************************************************
112 makes an ENUM_HND structure.
113 ********************************************************************/
114 BOOL make_enum_hnd(ENUM_HND *enh, uint32 hnd)
116 if (enh == NULL) return False;
118 DEBUG(5,("smb_io_enum_hnd\n"));
120 enh->ptr_hnd = (hnd != 0) ? 1 : 0;
126 /*******************************************************************
127 reads or writes an ENUM_HND structure.
128 ********************************************************************/
129 BOOL smb_io_enum_hnd(char *desc, ENUM_HND *hnd, prs_struct *ps, int depth)
131 if (hnd == NULL) return False;
133 prs_debug(ps, depth, desc, "smb_io_enum_hnd");
138 prs_uint32("ptr_hnd", ps, depth, &(hnd->ptr_hnd)); /* pointer */
139 if (hnd->ptr_hnd != 0)
141 prs_uint32("handle ", ps, depth, &(hnd->handle )); /* enum handle */
147 /*******************************************************************
148 reads or writes a DOM_SID structure.
149 ********************************************************************/
150 BOOL smb_io_dom_sid(char *desc, DOM_SID *sid, prs_struct *ps, int depth)
154 if (sid == NULL) return False;
156 prs_debug(ps, depth, desc, "smb_io_dom_sid");
161 prs_uint8 ("sid_rev_num", ps, depth, &(sid->sid_rev_num));
162 prs_uint8 ("num_auths ", ps, depth, &(sid->num_auths));
164 for (i = 0; i < 6; i++)
167 slprintf(tmp, sizeof(tmp) - 1, "id_auth[%d] ", i);
168 prs_uint8 (tmp, ps, depth, &(sid->id_auth[i]));
171 /* oops! XXXX should really issue a warning here... */
172 if (sid->num_auths > MAXSUBAUTHS) sid->num_auths = MAXSUBAUTHS;
174 prs_uint32s(False, "sub_auths ", ps, depth, sid->sub_auths, sid->num_auths);
179 /*******************************************************************
180 creates a DOM_SID2 structure.
181 ********************************************************************/
182 BOOL make_dom_sid2(DOM_SID2 *sid2, const DOM_SID *sid)
184 sid_copy(&sid2->sid, sid);
185 sid2->num_auths = sid2->sid.num_auths;
190 /*******************************************************************
191 reads or writes a DOM_SID2 structure.
192 ********************************************************************/
193 BOOL smb_io_dom_sid2(char *desc, DOM_SID2 *sid, prs_struct *ps, int depth)
195 if (sid == NULL) return False;
197 prs_debug(ps, depth, desc, "smb_io_dom_sid2");
202 prs_uint32("num_auths", ps, depth, &(sid->num_auths));
204 smb_io_dom_sid("sid", &(sid->sid), ps, depth);
209 /*******************************************************************
210 creates a STRHDR structure.
211 ********************************************************************/
212 BOOL make_str_hdr(STRHDR *hdr, int max_len, int len, uint32 buffer)
214 hdr->str_max_len = max_len;
215 hdr->str_str_len = len;
216 hdr->buffer = buffer;
221 /*******************************************************************
222 reads or writes a STRHDR structure.
223 ********************************************************************/
224 BOOL smb_io_strhdr(char *desc, STRHDR *hdr, prs_struct *ps, int depth)
226 if (hdr == NULL) return False;
228 prs_debug(ps, depth, desc, "smb_io_strhdr");
233 prs_uint16("str_str_len", ps, depth, &(hdr->str_str_len));
234 prs_uint16("str_max_len", ps, depth, &(hdr->str_max_len));
235 prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
237 /* oops! XXXX maybe issue a warning that this is happening... */
238 if (hdr->str_max_len > MAX_STRINGLEN) hdr->str_max_len = MAX_STRINGLEN;
239 if (hdr->str_str_len > MAX_STRINGLEN) hdr->str_str_len = MAX_STRINGLEN;
244 /*******************************************************************
245 creates a STRHDR2 structure.
246 ********************************************************************/
247 BOOL make_strhdr2(STRHDR2 *hdr, uint32 max_len, uint32 len, uint32 buffer)
249 hdr->str_max_len = max_len;
250 hdr->str_str_len = len;
251 hdr->buffer = buffer;
256 /*******************************************************************
257 reads or writes a STRHDR2 structure.
258 ********************************************************************/
259 BOOL smb_io_strhdr2(char *desc, STRHDR2 *hdr, prs_struct *ps, int depth)
261 if (hdr == NULL) return False;
263 prs_debug(ps, depth, desc, "smb_io_strhdr");
268 prs_uint32("str_str_len", ps, depth, &(hdr->str_str_len));
269 prs_uint32("str_max_len", ps, depth, &(hdr->str_max_len));
270 prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
272 /* oops! XXXX maybe issue a warning that this is happening... */
273 if (hdr->str_max_len > MAX_STRINGLEN) hdr->str_max_len = MAX_STRINGLEN;
274 if (hdr->str_str_len > MAX_STRINGLEN) hdr->str_str_len = MAX_STRINGLEN;
279 /*******************************************************************
280 creates a UNIHDR structure.
281 ********************************************************************/
282 BOOL make_uni_hdr(UNIHDR *hdr, int len)
284 hdr->uni_str_len = 2 * len;
285 hdr->uni_max_len = 2 * len;
286 hdr->buffer = len != 0 ? 1 : 0;
291 /*******************************************************************
292 reads or writes a UNIHDR structure.
293 ********************************************************************/
294 BOOL smb_io_unihdr(char *desc, UNIHDR *hdr, prs_struct *ps, int depth)
296 if (hdr == NULL) return False;
298 prs_debug(ps, depth, desc, "smb_io_unihdr");
303 prs_uint16("uni_str_len", ps, depth, &(hdr->uni_str_len));
304 prs_uint16("uni_max_len", ps, depth, &(hdr->uni_max_len));
305 prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
307 /* oops! XXXX maybe issue a warning that this is happening... */
308 if (hdr->uni_max_len > MAX_UNISTRLEN) hdr->uni_max_len = MAX_UNISTRLEN;
309 if (hdr->uni_str_len > MAX_UNISTRLEN) hdr->uni_str_len = MAX_UNISTRLEN;
314 /*******************************************************************
315 creates a BUFHDR structure.
316 ********************************************************************/
317 BOOL make_buf_hdr(BUFHDR *hdr, int max_len, int len)
319 hdr->buf_max_len = max_len;
325 /*******************************************************************
326 prs_uint16 wrapper. call this and it sets up a pointer to where the
327 uint16 should be stored, or gets the size if reading
328 ********************************************************************/
329 BOOL smb_io_hdrbuf_pre(char *desc, BUFHDR *hdr, prs_struct *ps, int depth, uint32 *offset)
331 (*offset) = ps->offset;
335 smb_io_hdrbuf(desc, hdr, ps, depth);
339 ps->offset += sizeof(uint32) * 2;
345 /*******************************************************************
346 smb_io_hdrbuf wrapper. call this and it retrospectively stores the size.
347 does nothing on reading, as that is already handled by ...._pre()
348 ********************************************************************/
349 BOOL smb_io_hdrbuf_post(char *desc, BUFHDR *hdr, prs_struct *ps, int depth,
350 uint32 ptr_hdrbuf, uint32 max_len, uint32 len)
354 /* storing: go back and do a retrospective job. i hate this */
355 uint32 old_offset = ps->offset;
357 make_buf_hdr(hdr, max_len, len);
358 ps->offset = ptr_hdrbuf;
359 smb_io_hdrbuf(desc, hdr, ps, depth);
360 ps->offset = old_offset;
366 /*******************************************************************
367 reads or writes a BUFHDR structure.
368 ********************************************************************/
369 BOOL smb_io_hdrbuf(char *desc, BUFHDR *hdr, prs_struct *ps, int depth)
371 if (hdr == NULL) return False;
373 prs_debug(ps, depth, desc, "smb_io_hdrbuf");
378 prs_uint32("buf_max_len", ps, depth, &(hdr->buf_max_len));
379 prs_uint32("buf_len ", ps, depth, &(hdr->buf_len ));
381 /* oops! XXXX maybe issue a warning that this is happening... */
382 if (hdr->buf_max_len > MAX_BUFFERLEN) hdr->buf_max_len = MAX_BUFFERLEN;
383 if (hdr->buf_len > MAX_BUFFERLEN) hdr->buf_len = MAX_BUFFERLEN;
388 /*******************************************************************
389 creates a BUFHDR2 structure.
390 ********************************************************************/
391 BOOL make_bufhdr2(BUFHDR2 *hdr, uint32 info_level, uint32 length, uint32 buffer)
393 hdr->info_level = info_level;
394 hdr->length = length;
395 hdr->buffer = buffer;
400 /*******************************************************************
401 reads or writes a BUFHDR2 structure.
402 ********************************************************************/
403 BOOL smb_io_bufhdr2(char *desc, BUFHDR2 *hdr, prs_struct *ps, int depth)
405 if (hdr == NULL) return False;
407 prs_debug(ps, depth, desc, "smb_io_bufhdr2");
411 prs_uint32("info_level", ps, depth, &(hdr->info_level));
412 prs_uint32("length ", ps, depth, &(hdr->length ));
413 prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
418 /*******************************************************************
419 creates a UNIHDR2 structure.
420 ********************************************************************/
421 BOOL make_uni_hdr2(UNIHDR2 *hdr, int len)
423 make_uni_hdr(&(hdr->unihdr), len);
424 hdr->buffer = len > 0 ? 1 : 0;
429 /*******************************************************************
430 reads or writes a UNIHDR2 structure.
431 ********************************************************************/
432 BOOL smb_io_unihdr2(char *desc, UNIHDR2 *hdr2, prs_struct *ps, int depth)
434 if (hdr2 == NULL) return False;
436 prs_debug(ps, depth, desc, "smb_io_unihdr2");
441 smb_io_unihdr("hdr", &(hdr2->unihdr), ps, depth);
442 prs_uint32("buffer", ps, depth, &(hdr2->buffer));
447 /*******************************************************************
448 creates a UNISTR structure.
449 ********************************************************************/
450 BOOL make_unistr(UNISTR *str, char *buf)
452 ascii_to_unistr(str->buffer, buf, sizeof(str->buffer)-1);
457 /*******************************************************************
458 reads or writes a UNISTR structure.
459 XXXX NOTE: UNISTR structures NEED to be null-terminated.
460 ********************************************************************/
461 BOOL smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int depth)
463 if (uni == NULL) return False;
465 prs_debug(ps, depth, desc, "smb_io_unistr");
468 prs_unistr("unistr", ps, depth, uni);
473 /*******************************************************************
474 creates a BUFFER3 structure from a uint32
475 ********************************************************************/
476 BOOL make_buffer3_uint32(BUFFER3 *str, uint32 val)
480 /* set up string lengths. */
481 str->buf_max_len = sizeof(uint32);
482 str->buf_len = sizeof(uint32);
484 SIVAL(str->buffer, 0, val);
489 /*******************************************************************
490 creates a BUFFER3 structure.
491 ********************************************************************/
492 BOOL make_buffer3_str(BUFFER3 *str, const char *buf, int len)
496 /* set up string lengths. */
497 str->buf_max_len = len * 2;
498 str->buf_len = len * 2;
500 /* store the string (little endian buffer) */
501 ascii_to_unibuf((char*)str->buffer, buf, str->buf_len);
506 /*******************************************************************
507 creates a BUFFER3 structure from a hex string.
508 ********************************************************************/
509 BOOL make_buffer3_hex(BUFFER3 *str, char *buf)
512 str->buf_max_len = str->buf_len = strhex_to_str((char *)str->buffer, sizeof(str->buffer), buf);
517 /*******************************************************************
518 creates a BUFFER3 structure.
519 ********************************************************************/
520 BOOL make_buffer3_bytes(BUFFER3 *str, uint8 *buf, int len)
524 /* max buffer size (allocated size) */
525 str->buf_max_len = len;
528 memcpy(str->buffer, buf, MIN(str->buf_len, sizeof(str->buffer)));
530 str->buf_len = buf != NULL ? len : 0;
535 /*******************************************************************
536 reads or writes a BUFFER3 structure.
537 the uni_max_len member tells you how large the buffer is.
538 the uni_str_len member tells you how much of the buffer is really used.
539 ********************************************************************/
540 BOOL smb_io_buffer3(char *desc, BUFFER3 *buf3, prs_struct *ps, int depth)
542 if (buf3 == NULL) return False;
544 prs_debug(ps, depth, desc, "smb_io_buffer3");
549 prs_uint32("uni_max_len", ps, depth, &(buf3->buf_max_len));
550 if (buf3->buf_max_len > MAX_UNISTRLEN) buf3->buf_max_len = MAX_UNISTRLEN;
552 prs_uint8s(True, "buffer ", ps, depth, buf3->buffer, buf3->buf_max_len);
554 prs_uint32("buf_len ", ps, depth, &(buf3->buf_len));
555 if (buf3->buf_len > MAX_UNISTRLEN) buf3->buf_len = MAX_UNISTRLEN;
560 /*******************************************************************
561 creates a BUFFER4 structure.
562 ********************************************************************/
563 BOOL make_buffer4_str(BUFFER4 *str, const char *buf, int len)
567 /* set up string lengths. */
568 str->buf_len = len * 2;
570 /* store the string (little endian buffer) */
571 ascii_to_unibuf((char*)str->buffer, buf, str->buf_len);
576 /*******************************************************************
577 reads or writes a BUFFER4 structure.
578 ********************************************************************/
579 BOOL smb_io_buffer4(char *desc, BUFFER4 *buf4, uint32 buffer, prs_struct *ps, int depth)
581 if ((buf4 == NULL) || (buffer == 0)) return False;
583 prs_debug(ps, depth, desc, "smb_io_buffer4");
587 prs_uint32("buf_len", ps, depth, &(buf4->buf_len));
589 if (buf4->buf_len > MAX_BUFFERLEN)
591 buf4->buf_len = MAX_BUFFERLEN;
594 prs_uint8s(True, "buffer", ps, depth, buf4->buffer, buf4->buf_len);
599 /*******************************************************************
600 initialise a BUFFER5 structure.
601 ********************************************************************/
602 BOOL init_buffer5(BUFFER5 **str)
606 buf5=(BUFFER5 *)malloc( sizeof(BUFFER5) );
615 /*******************************************************************
616 clear a BUFFER5 structure.
617 ********************************************************************/
618 BOOL clear_buffer5(BUFFER5 **str)
623 if (buf5->buffer != NULL )
633 /*******************************************************************
634 creates a BUFFER5 structure.
635 ********************************************************************/
636 BOOL make_buffer5(BUFFER5 *str, char *buf, int len)
639 /* max buffer size (allocated size) */
641 str->buffer = (uint16 *)malloc( sizeof(uint16) * len );
642 ascii_to_unistr(str->buffer, buf, len);
647 /*******************************************************************
648 reads or writes a BUFFER5 structure.
649 the buf_len member tells you how large the buffer is.
650 ********************************************************************/
651 BOOL smb_io_buffer5(char *desc, BUFFER5 *buf5, prs_struct *ps, int depth)
653 prs_debug(ps, depth, desc, "smb_io_buffer4");
656 if (buf5 == NULL) return False;
659 prs_uint32("buf_len", ps, depth, &(buf5->buf_len));
661 /* reading: alloc the buffer first */
664 buf5->buffer=(uint16 *)malloc( sizeof(uint16)*buf5->buf_len );
667 prs_uint16s(True, "buffer ", ps, depth, buf5->buffer, buf5->buf_len);
672 /*******************************************************************
673 creates a BUFFER2 structure.
674 ********************************************************************/
675 BOOL make_buffer2_multi(BUFFER2 *str, char *const* const buf, uint32 num)
678 char *dest = (char*)str->buffer;
679 size_t max_len = sizeof(str->buffer)-1;
683 str->buf_max_len = 0;
686 for (i = 0; i < num && max_len > 0; i++)
688 size_t len = buf[i] != NULL ? strlen(buf[i]) : 0;
690 str->buf_max_len += len * 2;
691 str->buf_len += len * 2;
693 ascii_to_unibuf(dest, buf[i], max_len);
696 max_len -= len * 2 + 2;
702 /*******************************************************************
703 creates a BUFFER2 structure.
704 ********************************************************************/
705 BOOL make_buffer2(BUFFER2 *str, const char *buf, int len)
709 /* set up string lengths. */
710 str->buf_max_len = str->buf_len = len * 2;
713 /* store the string */
714 ascii_to_unibuf((char*)str->buffer, buf,
715 MIN(str->buf_len, sizeof(str->buffer)-1));
720 /*******************************************************************
721 reads or writes a BUFFER2 structure.
722 the uni_max_len member tells you how large the buffer is.
723 the uni_str_len member tells you how much of the buffer is really used.
724 ********************************************************************/
725 BOOL smb_io_buffer2(char *desc, BUFFER2 *buf2, uint32 buffer, prs_struct *ps, int depth)
727 if (buf2 == NULL) return False;
731 prs_debug(ps, depth, desc, "smb_io_buffer2");
736 prs_uint32("buf_max_len", ps, depth, &(buf2->buf_max_len));
737 prs_uint32("undoc ", ps, depth, &(buf2->undoc ));
738 prs_uint32("buf_len ", ps, depth, &(buf2->buf_len));
740 /* oops! XXXX maybe issue a warning that this is happening... */
741 if (buf2->buf_max_len > MAX_UNISTRLEN) buf2->buf_max_len = MAX_UNISTRLEN;
742 if (buf2->buf_len > MAX_UNISTRLEN) buf2->buf_len = MAX_UNISTRLEN;
744 /* buffer advanced by indicated length of string
745 NOT by searching for null-termination */
746 prs_buffer2(True, "buffer ", ps, depth, buf2);
750 prs_debug(ps, depth, desc, "smb_io_buffer2 - NULL");
752 bzero(buf2, sizeof(*buf2));
758 /*******************************************************************
759 creates a UNISTR2 structure: sets up the buffer, too
760 ********************************************************************/
761 BOOL make_buf_unistr2(UNISTR2 *str, uint32 *ptr, const char *buf)
766 make_unistr2(str, buf, strlen(buf)+1);
771 make_unistr2(str, "", 0);
777 /*******************************************************************
778 creates a STRING2 structure.
779 ********************************************************************/
780 BOOL make_string2(STRING2 *str, const char *buf, int len)
782 /* set up string lengths. */
783 str->str_max_len = len;
785 str->str_str_len = len;
787 /* store the string */
790 memcpy(str->buffer, buf, len);
796 /*******************************************************************
797 creates a STRING2 structure: sets up the buffer, too
798 ********************************************************************/
799 BOOL make_buf_string2(STRING2 *str, uint32 *ptr, const char *buf)
804 make_string2(str, buf, strlen(buf)+1);
809 make_string2(str, "", 0);
815 /*******************************************************************
816 reads or writes a STRING2 structure.
817 XXXX NOTE: STRING2 structures need NOT be null-terminated.
818 the str_str_len member tells you how long the string is;
819 the str_max_len member tells you how large the buffer is.
820 ********************************************************************/
821 BOOL smb_io_string2(char *desc, STRING2 *str2, uint32 buffer, prs_struct *ps, int depth)
823 if (str2 == NULL) return False;
827 prs_debug(ps, depth, desc, "smb_io_string2");
832 prs_uint32("str_max_len", ps, depth, &(str2->str_max_len));
833 prs_uint32("undoc ", ps, depth, &(str2->undoc ));
834 prs_uint32("str_str_len", ps, depth, &(str2->str_str_len));
836 /* oops! XXXX maybe issue a warning that this is happening... */
837 if (str2->str_max_len > MAX_STRINGLEN) str2->str_max_len = MAX_STRINGLEN;
838 if (str2->str_str_len > MAX_STRINGLEN) str2->str_str_len = MAX_STRINGLEN;
840 /* buffer advanced by indicated length of string
841 NOT by searching for null-termination */
842 prs_string2(True, "buffer ", ps, depth, str2);
846 prs_debug(ps, depth, desc, "smb_io_string2 - NULL");
848 bzero(str2, sizeof(*str2));
854 /*******************************************************************
855 creates a UNISTR2 structure.
856 ********************************************************************/
857 BOOL make_unistr2(UNISTR2 *str, const char *buf, int len)
861 /* set up string lengths. */
862 str->uni_max_len = len;
864 str->uni_str_len = len;
866 /* store the string (wide chars) */
867 ascii_to_unistr(str->buffer, buf, len);
872 /*******************************************************************
873 reads or writes a UNISTR2 structure.
874 XXXX NOTE: UNISTR2 structures need NOT be null-terminated.
875 the uni_str_len member tells you how long the string is;
876 the uni_max_len member tells you how large the buffer is.
877 ********************************************************************/
878 BOOL smb_io_unistr2(char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct *ps, int depth)
880 if (uni2 == NULL) return False;
884 prs_debug(ps, depth, desc, "smb_io_unistr2");
889 prs_uint32("uni_max_len", ps, depth, &(uni2->uni_max_len));
890 prs_uint32("undoc ", ps, depth, &(uni2->undoc ));
891 prs_uint32("uni_str_len", ps, depth, &(uni2->uni_str_len));
893 /* oops! XXXX maybe issue a warning that this is happening... */
894 if (uni2->uni_max_len > MAX_UNISTRLEN) uni2->uni_max_len = MAX_UNISTRLEN;
895 if (uni2->uni_str_len > MAX_UNISTRLEN) uni2->uni_str_len = MAX_UNISTRLEN;
897 /* buffer advanced by indicated length of string
898 NOT by searching for null-termination */
899 prs_unistr2(True, "buffer ", ps, depth, uni2);
903 prs_debug(ps, depth, desc, "smb_io_unistr2 - NULL");
905 bzero(uni2, sizeof(*uni2));
911 /*******************************************************************
912 creates a DOM_RID2 structure.
913 ********************************************************************/
914 BOOL make_dom_rid2(DOM_RID2 *rid2, uint32 rid, uint8 type, uint32 idx)
923 /*******************************************************************
924 reads or writes a DOM_RID2 structure.
925 ********************************************************************/
926 BOOL smb_io_dom_rid2(char *desc, DOM_RID2 *rid2, prs_struct *ps, int depth)
928 if (rid2 == NULL) return False;
930 prs_debug(ps, depth, desc, "smb_io_dom_rid2");
935 prs_uint8("type ", ps, depth, &(rid2->type));
937 prs_uint32("rid ", ps, depth, &(rid2->rid ));
938 prs_uint32("rid_idx", ps, depth, &(rid2->rid_idx ));
943 /*******************************************************************
944 creates a DOM_RID3 structure.
945 ********************************************************************/
946 BOOL make_dom_rid3(DOM_RID3 *rid3, uint32 rid, uint8 type)
950 rid3->ptr_type = 0x1; /* non-zero, basically. */
957 /*******************************************************************
958 reads or writes a DOM_RID3 structure.
959 ********************************************************************/
960 BOOL smb_io_dom_rid3(char *desc, DOM_RID3 *rid3, prs_struct *ps, int depth)
962 if (rid3 == NULL) return False;
964 prs_debug(ps, depth, desc, "smb_io_dom_rid3");
969 prs_uint32("rid ", ps, depth, &(rid3->rid ));
970 prs_uint32("type1 ", ps, depth, &(rid3->type1 ));
971 prs_uint32("ptr_type", ps, depth, &(rid3->ptr_type));
972 prs_uint32("type2 ", ps, depth, &(rid3->type2 ));
973 prs_uint32("unk ", ps, depth, &(rid3->unk ));
978 /*******************************************************************
979 makes a DOM_CLNT_SRV structure.
980 ********************************************************************/
981 static BOOL make_clnt_srv(DOM_CLNT_SRV *log, char *logon_srv, char *comp_name)
983 if (log == NULL) return False;
985 DEBUG(5,("make_clnt_srv: %d\n", __LINE__));
987 if (logon_srv != NULL)
989 log->undoc_buffer = 1;
990 make_unistr2(&(log->uni_logon_srv), logon_srv, strlen(logon_srv)+1);
994 log->undoc_buffer = 0;
997 if (comp_name != NULL)
999 log->undoc_buffer2 = 1;
1000 make_unistr2(&(log->uni_comp_name), comp_name, strlen(comp_name)+1);
1004 log->undoc_buffer2 = 0;
1010 /*******************************************************************
1011 reads or writes a DOM_CLNT_SRV structure.
1012 ********************************************************************/
1013 static BOOL smb_io_clnt_srv(char *desc, DOM_CLNT_SRV *log, prs_struct *ps, int depth)
1015 if (log == NULL) return False;
1017 prs_debug(ps, depth, desc, "smb_io_clnt_srv");
1022 prs_uint32("undoc_buffer ", ps, depth, &(log->undoc_buffer ));
1023 if (log->undoc_buffer != 0)
1025 smb_io_unistr2("unistr2", &(log->uni_logon_srv), log->undoc_buffer, ps, depth);
1030 prs_uint32("undoc_buffer2", ps, depth, &(log->undoc_buffer2));
1031 if (log->undoc_buffer2 != 0)
1033 smb_io_unistr2("unistr2", &(log->uni_comp_name), log->undoc_buffer2, ps, depth);
1039 /*******************************************************************
1040 makes a DOM_LOG_INFO structure.
1041 ********************************************************************/
1042 BOOL make_log_info(DOM_LOG_INFO *log,
1043 const char *logon_srv, const char *acct_name,
1044 uint16 sec_chan, const char *comp_name)
1046 if (log == NULL) return False;
1048 DEBUG(5,("make_log_info %d\n", __LINE__));
1050 log->undoc_buffer = 1;
1052 make_unistr2(&(log->uni_logon_srv), logon_srv, strlen(logon_srv)+1);
1053 make_unistr2(&(log->uni_acct_name), acct_name, strlen(acct_name)+1);
1055 log->sec_chan = sec_chan;
1057 make_unistr2(&(log->uni_comp_name), comp_name, strlen(comp_name)+1);
1062 /*******************************************************************
1063 reads or writes a DOM_LOG_INFO structure.
1064 ********************************************************************/
1065 BOOL smb_io_log_info(char *desc, DOM_LOG_INFO *log, prs_struct *ps, int depth)
1067 if (log == NULL) return False;
1069 prs_debug(ps, depth, desc, "smb_io_log_info");
1074 prs_uint32("undoc_buffer", ps, depth, &(log->undoc_buffer));
1076 smb_io_unistr2("unistr2", &(log->uni_logon_srv), True, ps, depth);
1077 smb_io_unistr2("unistr2", &(log->uni_acct_name), True, ps, depth);
1079 prs_uint16("sec_chan", ps, depth, &(log->sec_chan));
1081 smb_io_unistr2("unistr2", &(log->uni_comp_name), True, ps, depth);
1086 /*******************************************************************
1087 reads or writes a DOM_CHAL structure.
1088 ********************************************************************/
1089 BOOL smb_io_chal(char *desc, DOM_CHAL *chal, prs_struct *ps, int depth)
1091 if (chal == NULL) return False;
1093 prs_debug(ps, depth, desc, "smb_io_chal");
1098 prs_uint8s (False, "data", ps, depth, chal->data, 8);
1103 /*******************************************************************
1104 reads or writes a DOM_CRED structure.
1105 ********************************************************************/
1106 BOOL smb_io_cred(char *desc, DOM_CRED *cred, prs_struct *ps, int depth)
1108 if (cred == NULL) return False;
1110 prs_debug(ps, depth, desc, "smb_io_cred");
1115 smb_io_chal ("", &(cred->challenge), ps, depth);
1116 smb_io_utime("", &(cred->timestamp), ps, depth);
1121 /*******************************************************************
1122 makes a DOM_CLNT_INFO2 structure.
1123 ********************************************************************/
1124 BOOL make_clnt_info2(DOM_CLNT_INFO2 *clnt,
1125 char *logon_srv, char *comp_name,
1126 DOM_CRED *clnt_cred)
1128 if (clnt == NULL) return False;
1130 DEBUG(5,("make_clnt_info: %d\n", __LINE__));
1132 make_clnt_srv(&(clnt->login), logon_srv, comp_name);
1134 if (clnt_cred != NULL)
1137 memcpy(&(clnt->cred), clnt_cred, sizeof(clnt->cred));
1147 /*******************************************************************
1148 reads or writes a DOM_CLNT_INFO2 structure.
1149 ********************************************************************/
1150 BOOL smb_io_clnt_info2(char *desc, DOM_CLNT_INFO2 *clnt, prs_struct *ps, int depth)
1152 if (clnt == NULL) return False;
1154 prs_debug(ps, depth, desc, "smb_io_clnt_info2");
1159 smb_io_clnt_srv("", &(clnt->login), ps, depth);
1163 prs_uint32("ptr_cred", ps, depth, &(clnt->ptr_cred));
1164 smb_io_cred ("", &(clnt->cred ), ps, depth);
1169 /*******************************************************************
1170 makes a DOM_CLNT_INFO structure.
1171 ********************************************************************/
1172 BOOL make_clnt_info(DOM_CLNT_INFO *clnt,
1173 char *logon_srv, char *acct_name,
1174 uint16 sec_chan, char *comp_name,
1177 if (clnt == NULL || cred == NULL) return False;
1179 DEBUG(5,("make_clnt_info\n"));
1181 make_log_info(&(clnt->login), logon_srv, acct_name, sec_chan, comp_name);
1182 memcpy(&(clnt->cred), cred, sizeof(clnt->cred));
1187 /*******************************************************************
1188 reads or writes a DOM_CLNT_INFO structure.
1189 ********************************************************************/
1190 BOOL smb_io_clnt_info(char *desc, DOM_CLNT_INFO *clnt, prs_struct *ps, int depth)
1192 if (clnt == NULL) return False;
1194 prs_debug(ps, depth, desc, "smb_io_clnt_info");
1199 smb_io_log_info("", &(clnt->login), ps, depth);
1200 smb_io_cred ("", &(clnt->cred ), ps, depth);
1205 /*******************************************************************
1206 makes an OWF_INFO structure.
1207 ********************************************************************/
1208 BOOL make_owf_info(OWF_INFO *hash, uint8 data[16])
1210 if (hash == NULL) return False;
1212 DEBUG(5,("make_owf_info: %d\n", __LINE__));
1216 memcpy(hash->data, data, sizeof(hash->data));
1220 bzero(hash->data, sizeof(hash->data));
1226 /*******************************************************************
1227 reads or writes an OWF_INFO structure.
1228 ********************************************************************/
1229 BOOL smb_io_owf_info(char *desc, OWF_INFO *hash, prs_struct *ps, int depth)
1231 if (hash == NULL) return False;
1233 prs_debug(ps, depth, desc, "smb_io_owf_info");
1238 prs_uint8s (False, "data", ps, depth, hash->data, 16);
1243 /*******************************************************************
1244 reads or writes a DOM_GID structure.
1245 ********************************************************************/
1246 BOOL smb_io_gid(char *desc, DOM_GID *gid, prs_struct *ps, int depth)
1248 if (gid == NULL) return False;
1250 prs_debug(ps, depth, desc, "smb_io_gid");
1255 prs_uint32("g_rid", ps, depth, &(gid->g_rid));
1256 prs_uint32("attr ", ps, depth, &(gid->attr ));
1261 /*******************************************************************
1262 reads or writes an POLICY_HND structure.
1263 ********************************************************************/
1264 BOOL smb_io_pol_hnd(char *desc, POLICY_HND *pol, prs_struct *ps, int depth)
1266 if (pol == NULL) return False;
1268 prs_debug(ps, depth, desc, "smb_io_pol_hnd");
1273 prs_uint8s (False, "data", ps, depth, pol->data, POL_HND_SIZE);
1278 /*******************************************************************
1279 reads or writes a dom query structure.
1280 ********************************************************************/
1281 static BOOL smb_io_dom_query(char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth)
1283 if (d_q == NULL) return False;
1285 prs_debug(ps, depth, desc, "smb_io_dom_query");
1290 prs_uint16("uni_dom_max_len", ps, depth, &(d_q->uni_dom_max_len)); /* domain name string length * 2 */
1291 prs_uint16("uni_dom_str_len", ps, depth, &(d_q->uni_dom_str_len)); /* domain name string length * 2 */
1293 prs_uint32("buffer_dom_name", ps, depth, &(d_q->buffer_dom_name)); /* undocumented domain name string buffer pointer */
1294 prs_uint32("buffer_dom_sid ", ps, depth, &(d_q->buffer_dom_sid )); /* undocumented domain SID string buffer pointer */
1296 smb_io_unistr2("unistr2", &(d_q->uni_domain_name), d_q->buffer_dom_name, ps, depth); /* domain name (unicode string) */
1300 if (d_q->buffer_dom_sid != 0)
1302 smb_io_dom_sid2("", &(d_q->dom_sid), ps, depth); /* domain SID */
1306 bzero(&(d_q->dom_sid), sizeof(d_q->dom_sid));
1312 /*******************************************************************
1313 reads or writes a dom query structure.
1314 ********************************************************************/
1315 BOOL smb_io_dom_query_3(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
1317 smb_io_dom_query("", d_q, ps, depth);
1322 /*******************************************************************
1323 reads or writes a dom query structure.
1324 ********************************************************************/
1325 BOOL smb_io_dom_query_5(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
1327 smb_io_dom_query("", d_q, ps, depth);
1333 /*******************************************************************
1334 reads or writes a UNISTR3 structure.
1335 ********************************************************************/
1336 BOOL smb_io_unistr3(char *desc, UNISTR3 *name, prs_struct *ps, int depth)
1338 if (name == NULL) return False;
1340 prs_debug(ps, depth, desc, "smb_io_unistr3");
1345 prs_uint32("uni_str_len", ps, depth, &(name->uni_str_len));
1347 /* don't know if len is specified by uni_str_len member... */
1348 /* assume unicode string is unicode-null-terminated, instead */
1350 prs_unistr3(True, "unistr", name, ps, depth);