first pass at updating head branch to be to be the same as the SAMBA_2_0 branch
[gd/samba/.git] / source / rpc_parse / parse_wks.c
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 /*******************************************************************
31  Init
32  ********************************************************************/
33
34 void init_wks_q_query_info(WKS_Q_QUERY_INFO *q_u,
35                                 char *server, uint16 switch_value)  
36 {
37         DEBUG(5,("init_wks_q_query_info\n"));
38
39         init_buf_unistr2(&q_u->uni_srv_name, &q_u->ptr_srv_name, server);
40         q_u->switch_value = switch_value;
41 }
42
43 /*******************************************************************
44  Reads or writes a WKS_Q_QUERY_INFO structure.
45 ********************************************************************/
46
47 BOOL wks_io_q_query_info(char *desc, WKS_Q_QUERY_INFO *q_u, prs_struct *ps, int depth)
48 {
49         if (q_u == NULL)
50                 return False;
51
52         prs_debug(ps, depth, desc, "wks_io_q_query_info");
53         depth++;
54
55         if(!prs_align(ps))
56                 return False;
57
58         if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
59                 return False;
60         if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
61                 return False;
62         if(!prs_align(ps))
63                 return False;
64
65         if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
66                 return False;
67         if(!prs_align(ps))
68                 return False;
69
70         return True;
71 }
72
73 /*******************************************************************
74  wks_info_100
75  ********************************************************************/
76
77 void init_wks_info_100(WKS_INFO_100 *inf,
78                                 uint32 platform_id, uint32 ver_major, uint32 ver_minor,
79                                 char *my_name, char *domain_name)
80 {
81         DEBUG(5,("Init WKS_INFO_100: %d\n", __LINE__));
82
83         inf->platform_id = platform_id; /* 0x0000 01f4 - unknown */
84         inf->ver_major   = ver_major;   /* os major version */
85         inf->ver_minor   = ver_minor;   /* os minor version */
86
87         init_buf_unistr2(&inf->uni_compname, &inf->ptr_compname, my_name    );
88         init_buf_unistr2(&inf->uni_lan_grp, &inf->ptr_lan_grp, domain_name);
89 }
90
91 /*******************************************************************
92  Reads or writes a WKS_INFO_100 structure.
93 ********************************************************************/
94
95 static BOOL wks_io_wks_info_100(char *desc, WKS_INFO_100 *inf, prs_struct *ps, int depth)
96 {
97         if (inf == NULL)
98                 return False;
99
100         prs_debug(ps, depth, desc, "wks_io_wks_info_100");
101         depth++;
102
103         if(!prs_align(ps))
104                 return False;
105
106         if(!prs_uint32("platform_id ", ps, depth, &inf->platform_id)) /* 0x0000 01f4 - unknown */
107                 return False;
108         if(!prs_uint32("ptr_compname", ps, depth, &inf->ptr_compname)) /* pointer to computer name */
109                 return False;
110         if(!prs_uint32("ptr_lan_grp ", ps, depth, &inf->ptr_lan_grp)) /* pointer to LAN group name */
111                 return False;
112         if(!prs_uint32("ver_major   ", ps, depth, &inf->ver_major)) /* 4 - major os version */
113                 return False;
114         if(!prs_uint32("ver_minor   ", ps, depth, &inf->ver_minor)) /* 0 - minor os version */
115                 return False;
116
117         if(!smb_io_unistr2("", &inf->uni_compname, inf->ptr_compname, ps, depth))
118                 return False;
119         if(!prs_align(ps))
120                 return False;
121
122         if(!smb_io_unistr2("", &inf->uni_lan_grp, inf->ptr_lan_grp , ps, depth))
123                 return False;
124         if(!prs_align(ps))
125                 return False;
126
127         return True;
128 }
129
130 /*******************************************************************
131  Inits WKS_R_QUERY_INFO.
132
133  only supports info level 100 at the moment.
134
135  ********************************************************************/
136
137 void init_wks_r_query_info(WKS_R_QUERY_INFO *r_u,
138                                 uint32 switch_value, WKS_INFO_100 *wks100,
139                                 int status)  
140 {
141         DEBUG(5,("init_wks_r_unknown_0: %d\n", __LINE__));
142
143         r_u->switch_value = switch_value;  /* same as in request */
144
145         r_u->ptr_1     = 1;          /* pointer 1 */
146         r_u->wks100    = wks100;
147
148         r_u->status    = status;
149 }
150
151 /*******************************************************************
152  Reads or writes a structure.
153 ********************************************************************/
154
155 BOOL wks_io_r_query_info(char *desc, WKS_R_QUERY_INFO *r_u, prs_struct *ps, int depth)
156 {
157         if (r_u == NULL)
158                 return False;
159
160         prs_debug(ps, depth, desc, "wks_io_r_query_info");
161         depth++;
162
163         if(!prs_align(ps))
164                 return False;
165
166         if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value)) /* level 100 (0x64) */
167                 return False;
168         if(!prs_align(ps))
169                 return False;
170
171         if(!prs_uint32("ptr_1       ", ps, depth, &r_u->ptr_1)) /* pointer 1 */
172                 return False;
173         if(!wks_io_wks_info_100("inf", r_u->wks100, ps, depth))
174                 return False;
175
176         if(!prs_uint32("status      ", ps, depth, &r_u->status))
177                 return False;
178
179         return True;
180 }