added wksinfo command to rpcclient, which don't work too good.
[kai/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  make_wks_q_query_info
32  ********************************************************************/
33 void make_wks_q_query_info(WKS_Q_QUERY_INFO *q_u,
34                                 char *server, uint16 switch_value)  
35 {
36         DEBUG(5,("make_wks_q_query_info\n"));
37
38         make_buf_unistr2(&(q_u->uni_srv_name), &(q_u->ptr_srv_name), server);
39         q_u->switch_value = switch_value;
40
41 }
42
43 /*******************************************************************
44 reads or writes a WKS_Q_QUERY_INFO structure.
45 ********************************************************************/
46 void wks_io_q_query_info(char *desc, WKS_Q_QUERY_INFO *q_u, prs_struct *ps, int depth)
47 {
48         if (q_u == NULL) return;
49
50         prs_debug(ps, depth, desc, "wks_io_q_query_info");
51         depth++;
52
53         prs_align(ps);
54
55         prs_uint32("ptr_srv_name", ps, depth, &(q_u->ptr_srv_name));
56         smb_io_unistr2("", &(q_u->uni_srv_name), q_u->ptr_srv_name, ps, depth); 
57         prs_align(ps);
58
59         prs_uint16("switch_value", ps, depth, &(q_u->switch_value));
60         prs_align(ps);
61 }
62
63 /*******************************************************************
64  wks_info_100
65  ********************************************************************/
66 void make_wks_info_100(WKS_INFO_100 *inf,
67                                 uint32 platform_id, uint32 ver_major, uint32 ver_minor,
68                                 char *my_name, char *domain_name)
69 {
70         DEBUG(5,("WKS_INFO_100: %d\n", __LINE__));
71
72         inf->platform_id = platform_id; /* 0x0000 01f4 - unknown */
73         inf->ver_major   = ver_major;   /* os major version */
74         inf->ver_minor   = ver_minor;   /* os minor version */
75
76         make_buf_unistr2(&(inf->uni_compname), &(inf->ptr_compname), my_name    );
77         make_buf_unistr2(&(inf->uni_lan_grp ), &(inf->ptr_lan_grp ), domain_name);
78 }
79
80 /*******************************************************************
81 reads or writes a WKS_INFO_100 structure.
82 ********************************************************************/
83 static void wks_io_wks_info_100(char *desc, WKS_INFO_100 *inf, prs_struct *ps, int depth)
84 {
85         if (inf == NULL) return;
86
87         prs_debug(ps, depth, desc, "wks_io_wks_info_100");
88         depth++;
89
90         prs_align(ps);
91
92         prs_uint32("platform_id ", ps, depth, &(inf->platform_id )); /* 0x0000 01f4 - unknown */
93         prs_uint32("ptr_compname", ps, depth, &(inf->ptr_compname)); /* pointer to computer name */
94         prs_uint32("ptr_lan_grp ", ps, depth, &(inf->ptr_lan_grp )); /* pointer to LAN group name */
95         prs_uint32("ver_major   ", ps, depth, &(inf->ver_major   )); /* 4 - major os version */
96         prs_uint32("ver_minor   ", ps, depth, &(inf->ver_minor   )); /* 0 - minor os version */
97
98         smb_io_unistr2("", &(inf->uni_compname), inf->ptr_compname, ps, depth); 
99         prs_align(ps);
100
101         smb_io_unistr2("", &(inf->uni_lan_grp ), inf->ptr_lan_grp , ps, depth); 
102         prs_align(ps);
103 }
104
105 /*******************************************************************
106  make_wks_r_query_info
107
108  only supports info level 100 at the moment.
109
110  ********************************************************************/
111 void make_wks_r_query_info(WKS_R_QUERY_INFO *r_u,
112                                 uint32 switch_value, WKS_INFO_100 *wks100,
113                                 int status)  
114 {
115         DEBUG(5,("make_wks_r_unknown_0: %d\n", __LINE__));
116
117         r_u->switch_value = switch_value;  /* same as in request */
118
119         r_u->ptr_1     = 1;          /* pointer 1 */
120         r_u->wks100    = wks100;
121
122         r_u->status    = status;
123 }
124
125 /*******************************************************************
126 reads or writes a structure.
127 ********************************************************************/
128 void wks_io_r_query_info(char *desc,  WKS_R_QUERY_INFO *r_u, prs_struct *ps, int depth)
129 {
130         if (r_u == NULL) return;
131
132         prs_debug(ps, depth, desc, "wks_io_r_query_info");
133         depth++;
134
135         prs_align(ps);
136
137         prs_uint16("switch_value", ps, depth, &(r_u->switch_value)); /* level 100 (0x64) */
138         prs_align(ps);
139
140         prs_uint32("ptr_1       ", ps, depth, &(r_u->ptr_1       )); /* pointer 1 */
141         wks_io_wks_info_100("inf", r_u->wks100, ps, depth);
142
143         prs_uint32("status      ", ps, depth, &(r_u->status));
144 }
145