home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / samba-1.9.18p7.tar.gz / samba-1.9.18p7.tar / samba-1.9.18p7 / source / rpc_pipes / samrparse.c < prev    next >
C/C++ Source or Header  |  1997-11-06  |  16KB  |  466 lines

  1.  
  2. /* 
  3.  *  Unix SMB/Netbios implementation.
  4.  *  Version 1.9.
  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.
  9.  *  
  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.
  14.  *  
  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.
  19.  *  
  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.
  23.  */
  24.  
  25.  
  26. #include "../includes.h"
  27.  
  28. extern int DEBUGLEVEL;
  29.  
  30. #ifdef NTDOMAIN
  31.  
  32. /*******************************************************************
  33. reads or writes a structure.
  34. ********************************************************************/
  35. char* samr_io_q_close(BOOL io, SAMR_Q_CLOSE *q_u, char *q, char *base, int align, int depth)
  36. {
  37.     if (q_u == NULL) return NULL;
  38.  
  39.     DEBUG(5,("%s%04x samr_io_q_unknown_1\n", tab_depth(depth), PTR_DIFF(q, base)));
  40.     depth++;
  41.  
  42.     q = align_offset(q, base, align);
  43.  
  44.     q = smb_io_pol_hnd(io, &(q_u->pol), q, base, align, depth); 
  45.     q = align_offset(q, base, align);
  46.  
  47.     return q;
  48. }
  49.  
  50. /*******************************************************************
  51. reads or writes a structure.
  52. ********************************************************************/
  53. char* samr_io_r_close(BOOL io, SAMR_R_CLOSE *r_u, char *q, char *base, int align, int depth)
  54. {
  55.     if (r_u == NULL) return NULL;
  56.  
  57.     DEBUG(5,("%s%04x samr_io_r_unknown_1\n", tab_depth(depth), PTR_DIFF(q, base)));
  58.     depth++;
  59.  
  60.     q = align_offset(q, base, align);
  61.  
  62.     q = smb_io_pol_hnd(io, &(r_u->pol), q, base, align, depth); 
  63.     q = align_offset(q, base, align);
  64.  
  65.     DBG_RW_IVAL("status", depth, base, io, q, r_u->status); q += 4;
  66.  
  67.     return q;
  68. }
  69.  
  70.  
  71. /*******************************************************************
  72. reads or writes a structure.
  73. ********************************************************************/
  74. char* samr_io_q_open_secret(BOOL io, SAMR_Q_OPEN_SECRET *q_u, char *q, char *base, int align, int depth)
  75. {
  76.     if (q_u == NULL) return NULL;
  77.  
  78.     DEBUG(5,("%s%04x samr_io_q_open_secret\n", tab_depth(depth), PTR_DIFF(q, base)));
  79.     depth++;
  80.  
  81.     q = align_offset(q, base, align);
  82.  
  83.     q = smb_io_pol_hnd(io, &(q_u->pol), q, base, align, depth); 
  84.     q = align_offset(q, base, align);
  85.  
  86.     DBG_RW_IVAL("unknown_0", depth, base, io, q, q_u->unknown_0); q += 4;
  87.  
  88.     q = smb_io_dom_sid(io, &(q_u->dom_sid), q, base, align, depth); 
  89.     q = align_offset(q, base, align);
  90.  
  91.     return q;
  92. }
  93.  
  94.  
  95. /*******************************************************************
  96. reads or writes a structure.
  97. ********************************************************************/
  98. char* samr_io_r_open_secret(BOOL io, SAMR_R_OPEN_SECRET *r_u, char *q, char *base, int align, int depth)
  99. {
  100.     if (r_u == NULL) return NULL;
  101.  
  102.     DEBUG(5,("%s%04x samr_io_r_open_secret\n", tab_depth(depth), PTR_DIFF(q, base)));
  103.     depth++;
  104.  
  105.     q = align_offset(q, base, align);
  106.  
  107.     q = smb_io_pol_hnd(io, &(r_u->pol), q, base, align, depth); 
  108.     q = align_offset(q, base, align);
  109.  
  110.     DBG_RW_IVAL("status", depth, base, io, q, r_u->status); q += 4;
  111.  
  112.     return q;
  113. }
  114.  
  115.  
  116. /*******************************************************************
  117. reads or writes a structure.
  118. ********************************************************************/
  119. char* samr_io_q_lookup_rids(BOOL io, SAMR_Q_LOOKUP_RIDS *q_u, char *q, char *base, int align, int depth)
  120. {
  121.     if (q_u == NULL) return NULL;
  122.  
  123.     DEBUG(5,("%s%04x samr_io_q_lookup_rids\n", tab_depth(depth), PTR_DIFF(q, base)));
  124.     depth++;
  125.  
  126.     q = align_offset(q, base, align);
  127.  
  128.     q = smb_io_pol_hnd(io, &(q_u->pol), q, base, align, depth); 
  129.     q = align_offset(q, base, align);
  130.  
  131.     DBG_RW_IVAL("num_rids1", depth, base, io, q, q_u->num_rids1); q += 4;
  132.     DBG_RW_IVAL("rid      ", depth, base, io, q, q_u->rid      ); q += 4;
  133.     DBG_RW_IVAL("ptr      ", depth, base, io, q, q_u->ptr      ); q += 4;
  134.     DBG_RW_IVAL("num_rids2", depth, base, io, q, q_u->num_rids2); q += 4;
  135.  
  136.     q = smb_io_unihdr (io, &(q_u->hdr_mach_acct), q, base, align, depth); 
  137.     q = smb_io_unistr2(io, &(q_u->uni_mach_acct), q, base, align, depth); 
  138.  
  139.     q = align_offset(q, base, align);
  140.  
  141.     return q;
  142. }
  143.  
  144.  
  145. /*******************************************************************
  146. makes a SAMR_R_LOOKUP_RIDS structure.
  147. ********************************************************************/
  148. void make_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS *r_u,
  149.         uint32 num_rids, uint32 rid, uint32 status)
  150. {
  151.     if (r_u == NULL) return;
  152.  
  153.     DEBUG(5,("make_samr_r_lookup_rids\n"));
  154.  
  155.     r_u->num_entries  = num_rids;
  156.     r_u->undoc_buffer = 0x156488;
  157.     r_u->num_entries2 = num_rids;
  158.  
  159.     make_dom_rid3(&(r_u->dom_rid[0]), rid);
  160.  
  161.     r_u->num_entries3 = num_rids;
  162.  
  163.     r_u->status = status;
  164. }
  165.  
  166. /*******************************************************************
  167. reads or writes a structure.
  168. ********************************************************************/
  169. char* samr_io_r_lookup_rids(BOOL io, SAMR_R_LOOKUP_RIDS *r_u, char *q, char *base, int align, int depth)
  170. {
  171.     if (r_u == NULL) return NULL;
  172.  
  173.     DEBUG(5,("%s%04x samr_io_r_lookup_rids\n", tab_depth(depth), PTR_DIFF(q, base)));
  174.     depth++;
  175.  
  176.     q = align_offset(q, base, align);
  177.  
  178.     DBG_RW_IVAL("num_entries ", depth, base, io, q, r_u->num_entries ); q += 4;
  179.     DBG_RW_IVAL("undoc_buffer", depth, base, io, q, r_u->undoc_buffer); q += 4;
  180.     DBG_RW_IVAL("num_entries2", depth, base, io, q, r_u->num_entries2); q += 4;
  181.  
  182.     q = smb_io_dom_rid3(io, &(r_u->dom_rid[0]), q, base, align, depth);
  183.  
  184.     DBG_RW_IVAL("num_entries3", depth, base, io, q, r_u->num_entries3); q += 4;
  185.  
  186.     DBG_RW_IVAL("status", depth, base, io, q, r_u->status); q += 4;
  187.  
  188.     return q;
  189. }
  190.  
  191. /*******************************************************************
  192. reads or writes a structure.
  193. ********************************************************************/
  194. char* samr_io_q_unknown_22(BOOL io, SAMR_Q_UNKNOWN_22 *q_u, char *q, char *base, int align, int depth)
  195. {
  196.     if (q_u == NULL) return NULL;
  197.  
  198.     DEBUG(5,("%s%04x samr_io_q_unknown_22\n", tab_depth(depth), PTR_DIFF(q, base)));
  199.     depth++;
  200.  
  201.     q = align_offset(q, base, align);
  202.  
  203.     q = smb_io_pol_hnd(io, &(q_u->pol), q, base, align, depth); 
  204.     q = align_offset(q, base, align);
  205.  
  206.     DBG_RW_IVAL("unknown_id_0", depth, base, io, q, q_u->unknown_id_0); q += 4;
  207.  
  208.     q = align_offset(q, base, align);
  209.  
  210.     return q;
  211. }
  212.  
  213. /*******************************************************************
  214. reads or writes a structure.
  215. ********************************************************************/
  216. char* samr_io_r_unknown_22(BOOL io, SAMR_R_UNKNOWN_22 *r_u, char *q, char *base, int align, int depth)
  217. {
  218.     if (r_u == NULL) return NULL;
  219.  
  220.     DEBUG(5,("%s%04x samr_io_r_unknown_22\n", tab_depth(depth), PTR_DIFF(q, base)));
  221.     depth++;
  222.  
  223.     q = align_offset(q, base, align);
  224.  
  225.     q = smb_io_pol_hnd(io, &(r_u->pol), q, base, align, depth); 
  226.     q = align_offset(q, base, align);
  227.  
  228.     DBG_RW_IVAL("status", depth, base, io, q, r_u->status); q += 4;
  229.  
  230.     return q;
  231. }
  232.  
  233.  
  234. /*******************************************************************
  235. reads or writes a structure.
  236. ********************************************************************/
  237. char* samr_io_q_unknown_24(BOOL io, SAMR_Q_UNKNOWN_24 *q_u, char *q, char *base, int align, int depth)
  238. {
  239.     if (q_u == NULL) return NULL;
  240.  
  241.     DEBUG(5,("%s%04x samr_io_q_unknown_24\n", tab_depth(depth), PTR_DIFF(q, base)));
  242.     depth++;
  243.  
  244.     q = align_offset(q, base, align);
  245.  
  246.     q = smb_io_pol_hnd(io, &(q_u->pol), q, base, align, depth); 
  247.     q = align_offset(q, base, align);
  248.  
  249.     DBG_RW_SVAL("unknown_0", depth, base, io, q, q_u->unknown_0); q += 2; /* 0x0015 or 0x0011 */
  250.  
  251.     q = align_offset(q, base, align);
  252.  
  253.     return q;
  254. }
  255.  
  256. /*******************************************************************
  257. makes a SAMR_R_UNKNOWN_24 structure.
  258. ********************************************************************/
  259. void make_samr_r_unknown_24(SAMR_R_UNKNOWN_24 *r_u,
  260.                 uint16 unknown_0, NTTIME *expiry, char *mach_acct,
  261.                 uint32 unknown_id_0, uint32 status)
  262.                 
  263. {
  264.     int len_mach_acct;
  265.     if (r_u == NULL || mach_acct == NULL) return;
  266.  
  267.     DEBUG(5,("make_samr_r_unknown_24\n"));
  268.  
  269.     len_mach_acct = strlen(mach_acct);
  270.  
  271.     r_u->ptr          = 1;            /* pointer */
  272.     r_u->unknown_0    = unknown_0;    /* 0x0015 or 0x0011 - 16 bit unknown */
  273.     r_u->unknown_1    = 0x8b73;       /* 0x8b73 - 16 bit unknown */
  274.     bzero(r_u->padding_0, sizeof(r_u->padding_0)); /* 0 - padding 16 bytes */
  275.     memcpy(&(r_u->expiry),expiry, sizeof(r_u->expiry)); /* expiry time or something? */
  276.     bzero(r_u->padding_1, sizeof(r_u->padding_1)); /* 0 - padding 24 bytes */
  277.  
  278.     make_uni_hdr(&(r_u->hdr_mach_acct), len_mach_acct, len_mach_acct, 4);  /* unicode header for machine account */
  279.     r_u->padding_2 = 0;               /* 0 - padding 4 bytes */
  280.  
  281.     r_u->ptr_1        = 1;            /* pointer */
  282.     bzero(r_u->padding_3, sizeof(r_u->padding_3)); /* 0 - padding 32 bytes */
  283.     r_u->padding_4    = 0;            /* 0 - padding 4 bytes */
  284.  
  285.     r_u->ptr_2        = 1;            /* pointer */
  286.     r_u->padding_5    = 0;            /* 0 - padding 4 bytes */
  287.  
  288.     r_u->ptr_3        = 1;          /* pointer */
  289.     bzero(r_u->padding_6, sizeof(r_u->padding_6)); /* 0 - padding 32 bytes */
  290.  
  291.     r_u->unknown_id_0 = unknown_id_0; /* unknown id associated with pol hnd */
  292.     r_u->unknown_2    = 0x201;        /* 0x0201      - 16 bit unknown */
  293.     r_u->unknown_3    = 0x00000080;   /* 0x0000 0080 - 32 bit unknown */
  294.     r_u->unknown_4    = 0x003f;       /* 0x003f      - 16 bit unknown */
  295.     r_u->unknown_5    = 0x003c;       /* 0x003c      - 16 bit unknown */
  296.  
  297.     bzero(r_u->padding_7, sizeof(r_u->padding_7)); /* 0 - padding 16 bytes */
  298.     r_u->padding_8    = 0;            /* 0 - padding 4 bytes */
  299.     
  300.     make_unistr2(&(r_u->uni_mach_acct), mach_acct, len_mach_acct);  /* unicode string for machine account */
  301.  
  302.     bzero(r_u->padding_9, sizeof(r_u->padding_9)); /* 0 - padding 48 bytes */
  303.  
  304.     r_u->status = status;         /* return status */
  305. }
  306.  
  307. /*******************************************************************
  308. reads or writes a structure.
  309. ********************************************************************/
  310. char* samr_io_r_unknown_24(BOOL io, SAMR_R_UNKNOWN_24 *r_u, char *q, char *base, int align, int depth)
  311. {
  312.     if (r_u == NULL) return NULL;
  313.  
  314.     DEBUG(5,("%s%04x samr_io_r_unknown_24\n", tab_depth(depth), PTR_DIFF(q, base)));
  315.     depth++;
  316.  
  317.     q = align_offset(q, base, align);
  318.  
  319.     DBG_RW_IVAL("ptr         ", depth, base, io, q, r_u->ptr         ); q += 4;
  320.     DBG_RW_SVAL("unknown_0   ", depth, base, io, q, r_u->unknown_0   ); q += 2;
  321.     DBG_RW_SVAL("unknown_1   ", depth, base, io, q, r_u->unknown_1   ); q += 2;
  322.     DBG_RW_PCVAL(False, "padding_0   ", depth, base, io, q, r_u->padding_0   , sizeof(r_u->padding_0)); q += sizeof(r_u->padding_0);
  323.  
  324.     q = smb_io_time(io, &(r_u->expiry), q, base, align, depth); 
  325.     DBG_RW_PCVAL(False, "padding_1   ", depth, base, io, q, r_u->padding_1   , sizeof(r_u->padding_1)); q += sizeof(r_u->padding_1);
  326.  
  327.     q = smb_io_unihdr (io, &(r_u->hdr_mach_acct), q, base, align, depth); 
  328.     DBG_RW_IVAL("padding_2   ", depth, base, io, q, r_u->padding_2   ); q += 4;
  329.  
  330.     DBG_RW_IVAL("ptr_1       ", depth, base, io, q, r_u->ptr_1       ); q += 4;
  331.     DBG_RW_PCVAL(False, "padding_3   ", depth, base, io, q, r_u->padding_3   , sizeof(r_u->padding_3)); q += sizeof(r_u->padding_3);
  332.     DBG_RW_IVAL("padding_4   ", depth, base, io, q, r_u->padding_4   ); q += 4;
  333.  
  334.     DBG_RW_IVAL("ptr_2       ", depth, base, io, q, r_u->ptr_2       ); q += 4;
  335.     DBG_RW_IVAL("padding_5   ", depth, base, io, q, r_u->padding_5   ); q += 4;
  336.  
  337.     DBG_RW_IVAL("ptr_3       ", depth, base, io, q, r_u->ptr_3       ); q += 4;
  338.     DBG_RW_PCVAL(False, "padding_6   ", depth, base, io, q, r_u->padding_6   , sizeof(r_u->padding_6)); q += sizeof(r_u->padding_6);
  339.  
  340.     DBG_RW_IVAL("unknown_id_0", depth, base, io, q, r_u->unknown_id_0); q += 4;
  341.     DBG_RW_SVAL("unknown_2   ", depth, base, io, q, r_u->unknown_2   ); q += 2;
  342.     DBG_RW_IVAL("unknown_3   ", depth, base, io, q, r_u->unknown_3   ); q += 4;
  343.     DBG_RW_SVAL("unknown_4   ", depth, base, io, q, r_u->unknown_4   ); q += 2;
  344.     DBG_RW_SVAL("unknown_5   ", depth, base, io, q, r_u->unknown_5   ); q += 2;
  345.  
  346.     DBG_RW_PCVAL(False, "padding_7   ", depth, base, io, q, r_u->padding_7   , sizeof(r_u->padding_7)); q += sizeof(r_u->padding_7);
  347.     DBG_RW_IVAL("padding_8   ", depth, base, io, q, r_u->padding_8   ); q += 4;
  348.     
  349.     q = smb_io_unistr2(io, &(r_u->uni_mach_acct), q, base, align, depth); 
  350.     q = align_offset(q, base, align);
  351.  
  352.     DBG_RW_PCVAL(False, "padding_9   ", depth, base, io, q, r_u->padding_9   , sizeof(r_u->padding_9)); q += sizeof(r_u->padding_9);
  353.  
  354.     DBG_RW_IVAL("status", depth, base, io, q, r_u->status); q += 4;
  355.  
  356.     return q;
  357. }
  358.  
  359.  
  360. /*******************************************************************
  361. reads or writes a structure.
  362. ********************************************************************/
  363. char* samr_io_q_unknown_32(BOOL io, SAMR_Q_UNKNOWN_32 *q_u, char *q, char *base, int align, int depth)
  364. {
  365.     if (q_u == NULL) return NULL;
  366.  
  367.     DEBUG(5,("%s%04x samr_io_q_unknown_32\n", tab_depth(depth), PTR_DIFF(q, base)));
  368.     depth++;
  369.  
  370.     q = align_offset(q, base, align);
  371.  
  372.     q = smb_io_pol_hnd(io, &(q_u->pol), q, base, align, depth); 
  373.     q = align_offset(q, base, align);
  374.  
  375.     q = smb_io_unihdr (io, &(q_u->hdr_mach_acct), q, base, align, depth); 
  376.     q = smb_io_unistr2(io, &(q_u->uni_mach_acct), q, base, align, depth); 
  377.  
  378.     q = align_offset(q, base, align);
  379.  
  380.     DBG_RW_IVAL("unknown_0", depth, base, io, q, q_u->unknown_0); q += 4;
  381.     DBG_RW_SVAL("unknown_1", depth, base, io, q, q_u->unknown_1); q += 2;
  382.     DBG_RW_SVAL("unknown_2", depth, base, io, q, q_u->unknown_2); q += 2;
  383.  
  384.     return q;
  385. }
  386.  
  387. /*******************************************************************
  388. reads or writes a structure.
  389. ********************************************************************/
  390. char* samr_io_r_unknown_32(BOOL io, SAMR_R_UNKNOWN_32 *r_u, char *q, char *base, int align, int depth)
  391. {
  392.     if (r_u == NULL) return NULL;
  393.  
  394.     DEBUG(5,("%s%04x samr_io_r_unknown_32\n", tab_depth(depth), PTR_DIFF(q, base)));
  395.     depth++;
  396.  
  397.     q = align_offset(q, base, align);
  398.  
  399.     q = smb_io_pol_hnd(io, &(r_u->pol), q, base, align, depth); 
  400.     q = align_offset(q, base, align);
  401.  
  402.     DBG_RW_IVAL("status", depth, base, io, q, r_u->status); q += 4;
  403.  
  404.     return q;
  405. }
  406.  
  407. /*******************************************************************
  408. reads or writes a structure.
  409. ********************************************************************/
  410. char* samr_io_q_open_policy(BOOL io, SAMR_Q_OPEN_POLICY *q_u, char *q, char *base, int align, int depth)
  411. {
  412.     if (q_u == NULL) return NULL;
  413.  
  414.     DEBUG(5,("%s%04x samr_io_q_open_policy\n", tab_depth(depth), PTR_DIFF(q, base)));
  415.     depth++;
  416.  
  417.     q = align_offset(q, base, align);
  418.  
  419.     DBG_RW_IVAL("ptr_srv_name", depth, base, io, q, q_u->ptr_srv_name); q += 4;
  420.     q = smb_io_unistr2(io, &(q_u->uni_srv_name), q, base, align, depth); 
  421.  
  422.     q = align_offset(q, base, align);
  423.  
  424.     DBG_RW_IVAL("unknown_0   ", depth, base, io, q, q_u->unknown_0   ); q += 4;
  425.  
  426.     return q;
  427. }
  428.  
  429. /*******************************************************************
  430. reads or writes a structure.
  431. ********************************************************************/
  432. char* samr_io_r_open_policy(BOOL io, SAMR_R_OPEN_POLICY *r_u, char *q, char *base, int align, int depth)
  433. {
  434.     if (r_u == NULL) return NULL;
  435.  
  436.     DEBUG(5,("%s%04x samr_io_r_open_policy\n", tab_depth(depth), PTR_DIFF(q, base)));
  437.     depth++;
  438.  
  439.     q = align_offset(q, base, align);
  440.  
  441.     q = smb_io_pol_hnd(io, &(r_u->pol), q, base, align, depth); 
  442.     q = align_offset(q, base, align);
  443.  
  444.     DBG_RW_IVAL("status", depth, base, io, q, r_u->status); q += 4;
  445.  
  446.     return q;
  447. }
  448.  
  449. #if 0
  450. /*******************************************************************
  451. reads or writes a structure.
  452. ********************************************************************/
  453.  char* lsa_io_(BOOL io, *, char *q, char *base, int align, int depth)
  454. {
  455.     if (== NULL) return NULL;
  456.  
  457.     q = align_offset(q, base, align);
  458.     
  459.     DBG_RW_IVAL("", depth, base, io, q, ); q += 4;
  460.  
  461.     return q;
  462. }
  463. #endif
  464.  
  465. #endif
  466.