This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[kai/samba.git] / source3 / rpc_parse / parse_wks.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Paul Ashton                       1997.
7  *  
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *  
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *  
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #include "includes.h"
24
25 /*******************************************************************
26  Init
27  ********************************************************************/
28
29 void init_wks_q_query_info(WKS_Q_QUERY_INFO *q_u,
30                                 char *server, uint16 switch_value)  
31 {
32         DEBUG(5,("init_wks_q_query_info\n"));
33
34         init_buf_unistr2(&q_u->uni_srv_name, &q_u->ptr_srv_name, server);
35         q_u->switch_value = switch_value;
36 }
37
38 /*******************************************************************
39  Reads or writes a WKS_Q_QUERY_INFO structure.
40 ********************************************************************/
41
42 BOOL wks_io_q_query_info(char *desc, WKS_Q_QUERY_INFO *q_u, prs_struct *ps, int depth)
43 {
44         if (q_u == NULL)
45                 return False;
46
47         prs_debug(ps, depth, desc, "wks_io_q_query_info");
48         depth++;
49
50         if(!prs_align(ps))
51                 return False;
52
53         if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
54                 return False;
55         if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
56                 return False;
57         if(!prs_align(ps))
58                 return False;
59
60         if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
61                 return False;
62         if(!prs_align(ps))
63                 return False;
64
65         return True;
66 }
67
68 /*******************************************************************
69  wks_info_100
70  ********************************************************************/
71
72 void init_wks_info_100(WKS_INFO_100 *inf,
73                                 uint32 platform_id, uint32 ver_major, uint32 ver_minor,
74                                 char *my_name, char *domain_name)
75 {
76         DEBUG(5,("Init WKS_INFO_100: %d\n", __LINE__));
77
78         inf->platform_id = platform_id; /* 0x0000 01f4 - unknown */
79         inf->ver_major   = ver_major;   /* os major version */
80         inf->ver_minor   = ver_minor;   /* os minor version */
81
82         init_buf_unistr2(&inf->uni_compname, &inf->ptr_compname, my_name    );
83         init_buf_unistr2(&inf->uni_lan_grp, &inf->ptr_lan_grp, domain_name);
84 }
85
86 /*******************************************************************
87  Reads or writes a WKS_INFO_100 structure.
88 ********************************************************************/
89
90 static BOOL wks_io_wks_info_100(char *desc, WKS_INFO_100 *inf, prs_struct *ps, int depth)
91 {
92         if (inf == NULL)
93                 return False;
94
95         prs_debug(ps, depth, desc, "wks_io_wks_info_100");
96         depth++;
97
98         if(!prs_align(ps))
99                 return False;
100
101         if(!prs_uint32("platform_id ", ps, depth, &inf->platform_id)) /* 0x0000 01f4 - unknown */
102                 return False;
103         if(!prs_uint32("ptr_compname", ps, depth, &inf->ptr_compname)) /* pointer to computer name */
104                 return False;
105         if(!prs_uint32("ptr_lan_grp ", ps, depth, &inf->ptr_lan_grp)) /* pointer to LAN group name */
106                 return False;
107         if(!prs_uint32("ver_major   ", ps, depth, &inf->ver_major)) /* 4 - major os version */
108                 return False;
109         if(!prs_uint32("ver_minor   ", ps, depth, &inf->ver_minor)) /* 0 - minor os version */
110                 return False;
111
112         if(!smb_io_unistr2("", &inf->uni_compname, inf->ptr_compname, ps, depth))
113                 return False;
114         if(!prs_align(ps))
115                 return False;
116
117         if(!smb_io_unistr2("", &inf->uni_lan_grp, inf->ptr_lan_grp , ps, depth))
118                 return False;
119         if(!prs_align(ps))
120                 return False;
121
122         return True;
123 }
124
125 /*******************************************************************
126  Inits WKS_R_QUERY_INFO.
127
128  only supports info level 100 at the moment.
129
130  ********************************************************************/
131
132 void init_wks_r_query_info(WKS_R_QUERY_INFO *r_u,
133                            uint32 switch_value, WKS_INFO_100 *wks100,
134                            NTSTATUS status)  
135 {
136         DEBUG(5,("init_wks_r_unknown_0: %d\n", __LINE__));
137
138         r_u->switch_value = switch_value;  /* same as in request */
139
140         r_u->ptr_1     = 1;          /* pointer 1 */
141         r_u->wks100    = wks100;
142
143         r_u->status    = status;
144 }
145
146 /*******************************************************************
147  Reads or writes a structure.
148 ********************************************************************/
149
150 BOOL wks_io_r_query_info(char *desc, WKS_R_QUERY_INFO *r_u, prs_struct *ps, int depth)
151 {
152         if (r_u == NULL)
153                 return False;
154
155         prs_debug(ps, depth, desc, "wks_io_r_query_info");
156         depth++;
157
158         if(!prs_align(ps))
159                 return False;
160
161         if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value)) /* level 100 (0x64) */
162                 return False;
163         if(!prs_align(ps))
164                 return False;
165
166         if(!prs_uint32("ptr_1       ", ps, depth, &r_u->ptr_1)) /* pointer 1 */
167                 return False;
168         if(!wks_io_wks_info_100("inf", r_u->wks100, ps, depth))
169                 return False;
170
171         if(!prs_ntstatus("status      ", ps, depth, &r_u->status))
172                 return False;
173
174         return True;
175 }