1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright (c) 1993, 1999 by Sun Microsystems, Inc.
24*0Sstevel@tonic-gate * All rights reserved.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate #pragma ident "%W% %E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate #include <sys/types.h>
30*0Sstevel@tonic-gate #include <sys/errno.h>
31*0Sstevel@tonic-gate #include <setjmp.h>
32*0Sstevel@tonic-gate #include <limits.h>
33*0Sstevel@tonic-gate #include <netinet/in.h>
34*0Sstevel@tonic-gate #include <string.h>
35*0Sstevel@tonic-gate
36*0Sstevel@tonic-gate #include <rpc/types.h>
37*0Sstevel@tonic-gate #include <rpc/rpc.h>
38*0Sstevel@tonic-gate #include <rpc/xdr.h>
39*0Sstevel@tonic-gate #include <rpc/auth.h>
40*0Sstevel@tonic-gate #include <rpc/clnt.h>
41*0Sstevel@tonic-gate #include <rpc/rpc_msg.h>
42*0Sstevel@tonic-gate #include <fw.h>
43*0Sstevel@tonic-gate #include <fw_rpc.h>
44*0Sstevel@tonic-gate #include "snoop.h"
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gate extern char *dlc_header;
47*0Sstevel@tonic-gate extern jmp_buf xdr_err;
48*0Sstevel@tonic-gate
49*0Sstevel@tonic-gate static char *procnames_short[] = {
50*0Sstevel@tonic-gate "Null", /* 0 */
51*0Sstevel@tonic-gate "INVOKE", /* 1 */
52*0Sstevel@tonic-gate "MORE", /* 2 */
53*0Sstevel@tonic-gate "KILL", /* 3 */
54*0Sstevel@tonic-gate };
55*0Sstevel@tonic-gate
56*0Sstevel@tonic-gate static char *procnames_long[] = {
57*0Sstevel@tonic-gate "Null procedure", /* 0 */
58*0Sstevel@tonic-gate "Invoke operation", /* 1 */
59*0Sstevel@tonic-gate "More data", /* 2 */
60*0Sstevel@tonic-gate "Kill operation", /* 3 */
61*0Sstevel@tonic-gate };
62*0Sstevel@tonic-gate
63*0Sstevel@tonic-gate #define MAXPROC 3
64*0Sstevel@tonic-gate
65*0Sstevel@tonic-gate enum Rec_type {
66*0Sstevel@tonic-gate REC_TYPE_NORM = 0,
67*0Sstevel@tonic-gate REC_TYPE_EOR = 1,
68*0Sstevel@tonic-gate REC_TYPE_EOF = 2
69*0Sstevel@tonic-gate };
70*0Sstevel@tonic-gate typedef enum Rec_type Rec_type;
71*0Sstevel@tonic-gate
72*0Sstevel@tonic-gate void
interpret_solarnet_fw(int flags,int type,int xid,int vers,int proc,char * data,int len)73*0Sstevel@tonic-gate interpret_solarnet_fw(
74*0Sstevel@tonic-gate int flags,
75*0Sstevel@tonic-gate int type,
76*0Sstevel@tonic-gate int xid,
77*0Sstevel@tonic-gate int vers,
78*0Sstevel@tonic-gate int proc,
79*0Sstevel@tonic-gate char *data,
80*0Sstevel@tonic-gate int len)
81*0Sstevel@tonic-gate {
82*0Sstevel@tonic-gate char *line;
83*0Sstevel@tonic-gate char buff[CTXTLEN + 1];
84*0Sstevel@tonic-gate ulong_t thresh;
85*0Sstevel@tonic-gate char op[CTXTLEN + 1];
86*0Sstevel@tonic-gate bool_t b;
87*0Sstevel@tonic-gate Fw_err e;
88*0Sstevel@tonic-gate Rec_type rt;
89*0Sstevel@tonic-gate int new_row = 1, row = 0;
90*0Sstevel@tonic-gate
91*0Sstevel@tonic-gate if (proc < 0 || proc > MAXPROC)
92*0Sstevel@tonic-gate return;
93*0Sstevel@tonic-gate
94*0Sstevel@tonic-gate if (flags & F_SUM) {
95*0Sstevel@tonic-gate if (setjmp(xdr_err)) {
96*0Sstevel@tonic-gate return;
97*0Sstevel@tonic-gate }
98*0Sstevel@tonic-gate
99*0Sstevel@tonic-gate line = get_sum_line();
100*0Sstevel@tonic-gate
101*0Sstevel@tonic-gate if (type == CALL) {
102*0Sstevel@tonic-gate (void) sprintf(line,
103*0Sstevel@tonic-gate "SOLARNET C %s",
104*0Sstevel@tonic-gate procnames_short[proc]);
105*0Sstevel@tonic-gate line += strlen(line);
106*0Sstevel@tonic-gate
107*0Sstevel@tonic-gate switch (proc) {
108*0Sstevel@tonic-gate case FW_INVOKE:
109*0Sstevel@tonic-gate (void) sprintf(line, " %s",
110*0Sstevel@tonic-gate getxdr_string(buff, CTXTLEN));
111*0Sstevel@tonic-gate line += strlen(line);
112*0Sstevel@tonic-gate (void) sprintf(line, "/%s",
113*0Sstevel@tonic-gate getxdr_string(buff, CTXTLEN));
114*0Sstevel@tonic-gate line += strlen(line);
115*0Sstevel@tonic-gate getxdr_string(buff, CTXTLEN);
116*0Sstevel@tonic-gate if (strlen(buff) != 0) {
117*0Sstevel@tonic-gate (void) sprintf(line, ".%s", buff);
118*0Sstevel@tonic-gate line += strlen(line);
119*0Sstevel@tonic-gate }
120*0Sstevel@tonic-gate (void) getxdr_string(buff, CTXTLEN);
121*0Sstevel@tonic-gate thresh = getxdr_u_long();
122*0Sstevel@tonic-gate if (thresh == ULONG_MAX)
123*0Sstevel@tonic-gate (void) sprintf(line, " (all)");
124*0Sstevel@tonic-gate else
125*0Sstevel@tonic-gate (void) sprintf(line, " %lu", thresh);
126*0Sstevel@tonic-gate line += strlen(line);
127*0Sstevel@tonic-gate (void) getxdr_context(buff, CTXTLEN);
128*0Sstevel@tonic-gate break;
129*0Sstevel@tonic-gate case FW_MORE:
130*0Sstevel@tonic-gate (void) getxdr_context(buff, CTXTLEN);
131*0Sstevel@tonic-gate sscanf(buff, "%*s %*s %s.%*s", op);
132*0Sstevel@tonic-gate op[strlen(op)-1] = '\0';
133*0Sstevel@tonic-gate (void) sprintf(line, " %s", op);
134*0Sstevel@tonic-gate line += strlen(line);
135*0Sstevel@tonic-gate thresh = getxdr_u_long();
136*0Sstevel@tonic-gate if (thresh == ULONG_MAX)
137*0Sstevel@tonic-gate (void) sprintf(line, " (all)");
138*0Sstevel@tonic-gate else
139*0Sstevel@tonic-gate (void) sprintf(line, " %lu", thresh);
140*0Sstevel@tonic-gate line += strlen(line);
141*0Sstevel@tonic-gate break;
142*0Sstevel@tonic-gate case FW_KILL:
143*0Sstevel@tonic-gate (void) getxdr_context(buff, CTXTLEN);
144*0Sstevel@tonic-gate sscanf(buff, "%*s %*s %s.%*s", op);
145*0Sstevel@tonic-gate op[strlen(op)-1] = '\0';
146*0Sstevel@tonic-gate (void) sprintf(line, " %s", op);
147*0Sstevel@tonic-gate line += strlen(line);
148*0Sstevel@tonic-gate break;
149*0Sstevel@tonic-gate default:
150*0Sstevel@tonic-gate break;
151*0Sstevel@tonic-gate }
152*0Sstevel@tonic-gate
153*0Sstevel@tonic-gate check_retransmit(line, xid);
154*0Sstevel@tonic-gate } else {
155*0Sstevel@tonic-gate (void) sprintf(line, "SOLARNET R %s",
156*0Sstevel@tonic-gate procnames_short[proc]);
157*0Sstevel@tonic-gate line += strlen(line);
158*0Sstevel@tonic-gate b = getxdr_bool();
159*0Sstevel@tonic-gate if (b) {
160*0Sstevel@tonic-gate e = getxdr_enum();
161*0Sstevel@tonic-gate if (e == FW_ERR_FW)
162*0Sstevel@tonic-gate sprintf(line, " FW");
163*0Sstevel@tonic-gate else if (e == FW_ERR_OP)
164*0Sstevel@tonic-gate sprintf(line, " OP");
165*0Sstevel@tonic-gate else
166*0Sstevel@tonic-gate sprintf(line, " NOERR");
167*0Sstevel@tonic-gate line += strlen(line);
168*0Sstevel@tonic-gate if (e != FW_ERR_NONE) {
169*0Sstevel@tonic-gate sprintf(line, " %lu", getxdr_u_long());
170*0Sstevel@tonic-gate line += strlen(line);
171*0Sstevel@tonic-gate (void) getxdr_bool();
172*0Sstevel@tonic-gate sprintf(line, " %s",
173*0Sstevel@tonic-gate getxdr_string(buff, CTXTLEN));
174*0Sstevel@tonic-gate line += strlen(line);
175*0Sstevel@tonic-gate }
176*0Sstevel@tonic-gate } else {
177*0Sstevel@tonic-gate sprintf(line, " Success");
178*0Sstevel@tonic-gate line += strlen(line);
179*0Sstevel@tonic-gate }
180*0Sstevel@tonic-gate b = getxdr_bool();
181*0Sstevel@tonic-gate if (b) {
182*0Sstevel@tonic-gate sprintf(line, " %lu rows", getxdr_u_long());
183*0Sstevel@tonic-gate line += strlen(line);
184*0Sstevel@tonic-gate } else {
185*0Sstevel@tonic-gate sprintf(line, " (No output)");
186*0Sstevel@tonic-gate line += strlen(line);
187*0Sstevel@tonic-gate }
188*0Sstevel@tonic-gate }
189*0Sstevel@tonic-gate }
190*0Sstevel@tonic-gate
191*0Sstevel@tonic-gate if ((flags & F_DTAIL)) {
192*0Sstevel@tonic-gate show_header("SOLARNET: ", "Solarnet Administration Service",
193*0Sstevel@tonic-gate len);
194*0Sstevel@tonic-gate show_space();
195*0Sstevel@tonic-gate if (setjmp(xdr_err)) {
196*0Sstevel@tonic-gate return;
197*0Sstevel@tonic-gate }
198*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "Proc = %d (%s)", proc,
199*0Sstevel@tonic-gate procnames_long[proc]);
200*0Sstevel@tonic-gate if (type == CALL) {
201*0Sstevel@tonic-gate switch (proc) {
202*0Sstevel@tonic-gate case FW_INVOKE:
203*0Sstevel@tonic-gate (void) showxdr_string(CTXTLEN, "Category: %s");
204*0Sstevel@tonic-gate (void) showxdr_string(CTXTLEN, "Operation: %s");
205*0Sstevel@tonic-gate (void) showxdr_string(CTXTLEN, "Version: %s");
206*0Sstevel@tonic-gate (void) showxdr_string(CTXTLEN, "Locale: %s");
207*0Sstevel@tonic-gate (void) showxdr_u_long("Threshold: %lu rows");
208*0Sstevel@tonic-gate (void) showxdr_context("Context: %s");
209*0Sstevel@tonic-gate b = getxdr_bool();
210*0Sstevel@tonic-gate if (!b) {
211*0Sstevel@tonic-gate sprintf(get_line(0, 0),
212*0Sstevel@tonic-gate "No input arguments");
213*0Sstevel@tonic-gate break;
214*0Sstevel@tonic-gate }
215*0Sstevel@tonic-gate thresh = showxdr_u_long("Input rows = %lu");
216*0Sstevel@tonic-gate (void) getxdr_bool();
217*0Sstevel@tonic-gate do {
218*0Sstevel@tonic-gate rt = getxdr_enum();
219*0Sstevel@tonic-gate if (rt == REC_TYPE_NORM) {
220*0Sstevel@tonic-gate if (new_row) {
221*0Sstevel@tonic-gate sprintf(get_line(0, 0),
222*0Sstevel@tonic-gate "Row %d", ++row);
223*0Sstevel@tonic-gate new_row = 0;
224*0Sstevel@tonic-gate }
225*0Sstevel@tonic-gate (void) getxdr_string(buff,
226*0Sstevel@tonic-gate CTXTLEN);
227*0Sstevel@tonic-gate (void) getxdr_string(op,
228*0Sstevel@tonic-gate CTXTLEN);
229*0Sstevel@tonic-gate sprintf(get_line(0, 0),
230*0Sstevel@tonic-gate "\t%s = %s", buff, op);
231*0Sstevel@tonic-gate } else if (rt == REC_TYPE_EOR) {
232*0Sstevel@tonic-gate new_row = 1;
233*0Sstevel@tonic-gate }
234*0Sstevel@tonic-gate } while (rt != REC_TYPE_EOF);
235*0Sstevel@tonic-gate break;
236*0Sstevel@tonic-gate case FW_MORE:
237*0Sstevel@tonic-gate (void) showxdr_context("Context: %s");
238*0Sstevel@tonic-gate (void) showxdr_u_long("Threshold: %lu rows");
239*0Sstevel@tonic-gate break;
240*0Sstevel@tonic-gate case FW_KILL:
241*0Sstevel@tonic-gate (void) showxdr_context("Context: %s");
242*0Sstevel@tonic-gate break;
243*0Sstevel@tonic-gate default:
244*0Sstevel@tonic-gate break;
245*0Sstevel@tonic-gate }
246*0Sstevel@tonic-gate } else {
247*0Sstevel@tonic-gate b = getxdr_bool();
248*0Sstevel@tonic-gate if (b) {
249*0Sstevel@tonic-gate e = getxdr_enum();
250*0Sstevel@tonic-gate if (e == FW_ERR_FW) {
251*0Sstevel@tonic-gate showxdr_u_long(
252*0Sstevel@tonic-gate "Framework error code %lu");
253*0Sstevel@tonic-gate } else if (e == FW_ERR_OP) {
254*0Sstevel@tonic-gate showxdr_u_long(
255*0Sstevel@tonic-gate "Operation error code %lu");
256*0Sstevel@tonic-gate } else {
257*0Sstevel@tonic-gate showxdr_u_long("No error %*lu");
258*0Sstevel@tonic-gate }
259*0Sstevel@tonic-gate (void) getxdr_bool();
260*0Sstevel@tonic-gate (void) getxdr_string(buff, CTXTLEN);
261*0Sstevel@tonic-gate if (e != FW_ERR_NONE) {
262*0Sstevel@tonic-gate sprintf(get_line(0, 0),
263*0Sstevel@tonic-gate "Error message: %s", buff);
264*0Sstevel@tonic-gate } else {
265*0Sstevel@tonic-gate }
266*0Sstevel@tonic-gate } else {
267*0Sstevel@tonic-gate sprintf(get_line(0, 0),
268*0Sstevel@tonic-gate "Operation was successful");
269*0Sstevel@tonic-gate }
270*0Sstevel@tonic-gate b = getxdr_bool();
271*0Sstevel@tonic-gate if (b) {
272*0Sstevel@tonic-gate showxdr_u_long("Output rows: %lu");
273*0Sstevel@tonic-gate (void) getxdr_bool();
274*0Sstevel@tonic-gate do {
275*0Sstevel@tonic-gate rt = getxdr_enum();
276*0Sstevel@tonic-gate if (rt == REC_TYPE_NORM) {
277*0Sstevel@tonic-gate if (new_row) {
278*0Sstevel@tonic-gate sprintf(get_line(0, 0),
279*0Sstevel@tonic-gate "Row %d", ++row);
280*0Sstevel@tonic-gate new_row = 0;
281*0Sstevel@tonic-gate }
282*0Sstevel@tonic-gate (void) getxdr_string(buff,
283*0Sstevel@tonic-gate CTXTLEN);
284*0Sstevel@tonic-gate (void) getxdr_string(op,
285*0Sstevel@tonic-gate CTXTLEN);
286*0Sstevel@tonic-gate sprintf(get_line(0, 0),
287*0Sstevel@tonic-gate "\t%s = %s", buff, op);
288*0Sstevel@tonic-gate } else if (rt == REC_TYPE_EOR) {
289*0Sstevel@tonic-gate new_row = 1;
290*0Sstevel@tonic-gate }
291*0Sstevel@tonic-gate } while (rt != REC_TYPE_EOF);
292*0Sstevel@tonic-gate } else {
293*0Sstevel@tonic-gate sprintf(get_line(0, 0), "No output");
294*0Sstevel@tonic-gate }
295*0Sstevel@tonic-gate }
296*0Sstevel@tonic-gate show_trailer();
297*0Sstevel@tonic-gate }
298*0Sstevel@tonic-gate
299*0Sstevel@tonic-gate }
300