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) 2001 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 "%Z%%M% %I% %E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate #include <stdio.h>
30*0Sstevel@tonic-gate #include <string.h>
31*0Sstevel@tonic-gate #include <sys/types.h>
32*0Sstevel@tonic-gate #include <sys/socket.h>
33*0Sstevel@tonic-gate #include <sys/sysmacros.h>
34*0Sstevel@tonic-gate #include <netinet/in.h>
35*0Sstevel@tonic-gate #include <arpa/inet.h>
36*0Sstevel@tonic-gate #include <net/pppoe.h>
37*0Sstevel@tonic-gate #include "snoop.h"
38*0Sstevel@tonic-gate
39*0Sstevel@tonic-gate /*
40*0Sstevel@tonic-gate * These two macros extract the version and type fields respectively from
41*0Sstevel@tonic-gate * the first byte of the PPPoE header.
42*0Sstevel@tonic-gate */
43*0Sstevel@tonic-gate #define POE_VERS(x) (((x) >> 4) & 0x0f)
44*0Sstevel@tonic-gate #define POE_TYPE(x) ((x) & 0x0f)
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gate typedef void interpret_func_t(uint8_t *, uint16_t);
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gate typedef struct taginfo {
49*0Sstevel@tonic-gate char *tag_name;
50*0Sstevel@tonic-gate uint16_t tag_type;
51*0Sstevel@tonic-gate interpret_func_t *interpret_tagvalue;
52*0Sstevel@tonic-gate } taginfo_t;
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gate
55*0Sstevel@tonic-gate static char *pppoe_codetoname(int, boolean_t);
56*0Sstevel@tonic-gate static taginfo_t *pppoe_gettaginfo(uint16_t);
57*0Sstevel@tonic-gate static void print_hexdata(char *, uint8_t *, uint16_t);
58*0Sstevel@tonic-gate static void print_utf8string(char *, char *, uint16_t);
59*0Sstevel@tonic-gate static char *print_linetag(char *);
60*0Sstevel@tonic-gate static interpret_func_t interpret_tags;
61*0Sstevel@tonic-gate static interpret_func_t interpret_hexdata;
62*0Sstevel@tonic-gate static interpret_func_t interpret_service;
63*0Sstevel@tonic-gate static interpret_func_t interpret_access;
64*0Sstevel@tonic-gate static interpret_func_t interpret_cookie;
65*0Sstevel@tonic-gate static interpret_func_t interpret_vendor;
66*0Sstevel@tonic-gate static interpret_func_t interpret_relay;
67*0Sstevel@tonic-gate static interpret_func_t interpret_error;
68*0Sstevel@tonic-gate static interpret_func_t interpret_hurl;
69*0Sstevel@tonic-gate static interpret_func_t interpret_motm;
70*0Sstevel@tonic-gate static interpret_func_t interpret_rteadd;
71*0Sstevel@tonic-gate
72*0Sstevel@tonic-gate
73*0Sstevel@tonic-gate static taginfo_t taginfo_array[] = {
74*0Sstevel@tonic-gate { "End-Of-List", POETT_END, interpret_hexdata },
75*0Sstevel@tonic-gate { "Service-Name", POETT_SERVICE, interpret_service },
76*0Sstevel@tonic-gate { "AC-Name", POETT_ACCESS, interpret_access },
77*0Sstevel@tonic-gate { "Host-Uniq", POETT_UNIQ, interpret_hexdata },
78*0Sstevel@tonic-gate { "AC-Cookie", POETT_COOKIE, interpret_cookie },
79*0Sstevel@tonic-gate { "Vendor-Specific", POETT_VENDOR, interpret_vendor },
80*0Sstevel@tonic-gate { "Relay-Session-Id", POETT_RELAY, interpret_relay },
81*0Sstevel@tonic-gate { "Service-Name-Error", POETT_NAMERR, interpret_error },
82*0Sstevel@tonic-gate { "AC-System-Error", POETT_SYSERR, interpret_error },
83*0Sstevel@tonic-gate { "Generic-Error", POETT_GENERR, interpret_error },
84*0Sstevel@tonic-gate { "Multicast-Capable", POETT_MULTI, interpret_hexdata },
85*0Sstevel@tonic-gate { "Host-URL", POETT_HURL, interpret_hurl },
86*0Sstevel@tonic-gate { "Message-Of-The-Minute", POETT_MOTM, interpret_motm },
87*0Sstevel@tonic-gate { "IP-Route-Add", POETT_RTEADD, interpret_rteadd },
88*0Sstevel@tonic-gate { "Unknown TAG", 0, NULL }
89*0Sstevel@tonic-gate };
90*0Sstevel@tonic-gate
91*0Sstevel@tonic-gate
92*0Sstevel@tonic-gate int
interpret_pppoe(int flags,poep_t * poep,int len)93*0Sstevel@tonic-gate interpret_pppoe(int flags, poep_t *poep, int len)
94*0Sstevel@tonic-gate {
95*0Sstevel@tonic-gate uint8_t code = poep->poep_code;
96*0Sstevel@tonic-gate uint8_t *payload;
97*0Sstevel@tonic-gate
98*0Sstevel@tonic-gate if (len < sizeof (poep_t))
99*0Sstevel@tonic-gate return (len);
100*0Sstevel@tonic-gate
101*0Sstevel@tonic-gate payload = (uint8_t *)poep + sizeof (poep_t);
102*0Sstevel@tonic-gate
103*0Sstevel@tonic-gate if (flags & F_SUM) {
104*0Sstevel@tonic-gate (void) sprintf(get_sum_line(), "PPPoE %s",
105*0Sstevel@tonic-gate pppoe_codetoname(code, B_FALSE));
106*0Sstevel@tonic-gate } else { /* flags & F_DTAIL */
107*0Sstevel@tonic-gate show_header("PPPoE: ", "PPP Over Ethernet", len);
108*0Sstevel@tonic-gate show_space();
109*0Sstevel@tonic-gate
110*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
111*0Sstevel@tonic-gate "Version = %d", POE_VERS(poep->poep_version_type));
112*0Sstevel@tonic-gate
113*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
114*0Sstevel@tonic-gate "Type = %d", POE_TYPE(poep->poep_version_type));
115*0Sstevel@tonic-gate
116*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
117*0Sstevel@tonic-gate "Code = %d (%s)", code, pppoe_codetoname(code, B_TRUE));
118*0Sstevel@tonic-gate
119*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
120*0Sstevel@tonic-gate "Session Id = %d", ntohs(poep->poep_session_id));
121*0Sstevel@tonic-gate
122*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
123*0Sstevel@tonic-gate "Length = %d bytes", ntohs(poep->poep_length));
124*0Sstevel@tonic-gate
125*0Sstevel@tonic-gate show_space();
126*0Sstevel@tonic-gate
127*0Sstevel@tonic-gate len -= sizeof (poep_t);
128*0Sstevel@tonic-gate len = MIN(len, ntohs(poep->poep_length));
129*0Sstevel@tonic-gate
130*0Sstevel@tonic-gate if (poep->poep_code != 0 && poep->poep_length > 0) {
131*0Sstevel@tonic-gate interpret_tags(payload, len);
132*0Sstevel@tonic-gate }
133*0Sstevel@tonic-gate }
134*0Sstevel@tonic-gate
135*0Sstevel@tonic-gate if (poep->poep_code == 0) {
136*0Sstevel@tonic-gate return (interpret_ppp(flags, payload, len));
137*0Sstevel@tonic-gate }
138*0Sstevel@tonic-gate return (len);
139*0Sstevel@tonic-gate }
140*0Sstevel@tonic-gate
141*0Sstevel@tonic-gate
142*0Sstevel@tonic-gate /*
143*0Sstevel@tonic-gate * interpret_tags() prints PPPoE Discovery Stage TAGs in detail.
144*0Sstevel@tonic-gate */
145*0Sstevel@tonic-gate static void
interpret_tags(uint8_t * payload,uint16_t length)146*0Sstevel@tonic-gate interpret_tags(uint8_t *payload, uint16_t length)
147*0Sstevel@tonic-gate {
148*0Sstevel@tonic-gate uint8_t *tagptr = payload;
149*0Sstevel@tonic-gate uint16_t tag_length;
150*0Sstevel@tonic-gate uint16_t tag_type;
151*0Sstevel@tonic-gate uint8_t *tag_value;
152*0Sstevel@tonic-gate taginfo_t *tinfo;
153*0Sstevel@tonic-gate
154*0Sstevel@tonic-gate while (length >= POET_HDRLEN) {
155*0Sstevel@tonic-gate tag_type = POET_GET_TYPE(tagptr);
156*0Sstevel@tonic-gate tag_length = POET_GET_LENG(tagptr);
157*0Sstevel@tonic-gate
158*0Sstevel@tonic-gate tinfo = pppoe_gettaginfo(tag_type);
159*0Sstevel@tonic-gate
160*0Sstevel@tonic-gate show_header("PPPoE: ", tinfo->tag_name,
161*0Sstevel@tonic-gate tag_length + POET_HDRLEN);
162*0Sstevel@tonic-gate
163*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
164*0Sstevel@tonic-gate "Tag Type = %d", tag_type);
165*0Sstevel@tonic-gate
166*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
167*0Sstevel@tonic-gate "Tag Length = %d bytes", tag_length);
168*0Sstevel@tonic-gate
169*0Sstevel@tonic-gate length -= POET_HDRLEN;
170*0Sstevel@tonic-gate if (tag_length > length) {
171*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
172*0Sstevel@tonic-gate "Warning: Truncated Packet");
173*0Sstevel@tonic-gate show_space();
174*0Sstevel@tonic-gate break;
175*0Sstevel@tonic-gate }
176*0Sstevel@tonic-gate
177*0Sstevel@tonic-gate /*
178*0Sstevel@tonic-gate * unknown tags or tags which should always have 0 length
179*0Sstevel@tonic-gate * are not interpreted any further.
180*0Sstevel@tonic-gate */
181*0Sstevel@tonic-gate tag_value = POET_DATA(tagptr);
182*0Sstevel@tonic-gate if (tag_length != 0 && tinfo->interpret_tagvalue != NULL)
183*0Sstevel@tonic-gate tinfo->interpret_tagvalue(tag_value, tag_length);
184*0Sstevel@tonic-gate
185*0Sstevel@tonic-gate show_space();
186*0Sstevel@tonic-gate length -= tag_length;
187*0Sstevel@tonic-gate tagptr = POET_NEXT(tagptr);
188*0Sstevel@tonic-gate }
189*0Sstevel@tonic-gate }
190*0Sstevel@tonic-gate
191*0Sstevel@tonic-gate static char *
pppoe_codetoname(int code,boolean_t verbose)192*0Sstevel@tonic-gate pppoe_codetoname(int code, boolean_t verbose)
193*0Sstevel@tonic-gate {
194*0Sstevel@tonic-gate char *name;
195*0Sstevel@tonic-gate
196*0Sstevel@tonic-gate switch (code) {
197*0Sstevel@tonic-gate case POECODE_DATA:
198*0Sstevel@tonic-gate name = "Session";
199*0Sstevel@tonic-gate break;
200*0Sstevel@tonic-gate case POECODE_PADO:
201*0Sstevel@tonic-gate if (verbose)
202*0Sstevel@tonic-gate name = "Active Discovery Offer";
203*0Sstevel@tonic-gate else
204*0Sstevel@tonic-gate name = "PADO";
205*0Sstevel@tonic-gate break;
206*0Sstevel@tonic-gate case POECODE_PADI:
207*0Sstevel@tonic-gate if (verbose)
208*0Sstevel@tonic-gate name = "Active Discovery Initiation";
209*0Sstevel@tonic-gate else
210*0Sstevel@tonic-gate name = "PADI";
211*0Sstevel@tonic-gate break;
212*0Sstevel@tonic-gate case POECODE_PADR:
213*0Sstevel@tonic-gate if (verbose)
214*0Sstevel@tonic-gate name = "Active Discovery Request";
215*0Sstevel@tonic-gate else
216*0Sstevel@tonic-gate name = "PADR";
217*0Sstevel@tonic-gate break;
218*0Sstevel@tonic-gate case POECODE_PADS:
219*0Sstevel@tonic-gate if (verbose)
220*0Sstevel@tonic-gate name = "Active Discovery Session-Confirmation";
221*0Sstevel@tonic-gate else
222*0Sstevel@tonic-gate name = "PADS";
223*0Sstevel@tonic-gate break;
224*0Sstevel@tonic-gate case POECODE_PADT:
225*0Sstevel@tonic-gate if (verbose)
226*0Sstevel@tonic-gate name = "Active Discovery Terminate";
227*0Sstevel@tonic-gate else
228*0Sstevel@tonic-gate name = "PADT";
229*0Sstevel@tonic-gate break;
230*0Sstevel@tonic-gate case POECODE_PADM:
231*0Sstevel@tonic-gate if (verbose)
232*0Sstevel@tonic-gate name = "Active Discovery Message";
233*0Sstevel@tonic-gate else
234*0Sstevel@tonic-gate name = "PADM";
235*0Sstevel@tonic-gate break;
236*0Sstevel@tonic-gate case POECODE_PADN:
237*0Sstevel@tonic-gate if (verbose)
238*0Sstevel@tonic-gate name = "Active Discovery Network";
239*0Sstevel@tonic-gate else
240*0Sstevel@tonic-gate name = "PADN";
241*0Sstevel@tonic-gate break;
242*0Sstevel@tonic-gate default:
243*0Sstevel@tonic-gate name = "Unknown Code";
244*0Sstevel@tonic-gate }
245*0Sstevel@tonic-gate
246*0Sstevel@tonic-gate return (name);
247*0Sstevel@tonic-gate }
248*0Sstevel@tonic-gate
249*0Sstevel@tonic-gate static taginfo_t *
pppoe_gettaginfo(uint16_t type)250*0Sstevel@tonic-gate pppoe_gettaginfo(uint16_t type)
251*0Sstevel@tonic-gate {
252*0Sstevel@tonic-gate taginfo_t *taginfo_ptr = &taginfo_array[0];
253*0Sstevel@tonic-gate int i = 0;
254*0Sstevel@tonic-gate
255*0Sstevel@tonic-gate while (taginfo_ptr->tag_type != type &&
256*0Sstevel@tonic-gate taginfo_ptr->interpret_tagvalue != NULL) {
257*0Sstevel@tonic-gate taginfo_ptr = &taginfo_array[++i];
258*0Sstevel@tonic-gate }
259*0Sstevel@tonic-gate
260*0Sstevel@tonic-gate return (taginfo_ptr);
261*0Sstevel@tonic-gate }
262*0Sstevel@tonic-gate
263*0Sstevel@tonic-gate static void
interpret_hexdata(uint8_t * tag_value,uint16_t tag_length)264*0Sstevel@tonic-gate interpret_hexdata(uint8_t *tag_value, uint16_t tag_length)
265*0Sstevel@tonic-gate {
266*0Sstevel@tonic-gate char *endofline;
267*0Sstevel@tonic-gate
268*0Sstevel@tonic-gate endofline = print_linetag("Data = ");
269*0Sstevel@tonic-gate print_hexdata(endofline, tag_value, tag_length);
270*0Sstevel@tonic-gate }
271*0Sstevel@tonic-gate
272*0Sstevel@tonic-gate static void
interpret_service(uint8_t * tag_value,uint16_t tag_length)273*0Sstevel@tonic-gate interpret_service(uint8_t *tag_value, uint16_t tag_length)
274*0Sstevel@tonic-gate {
275*0Sstevel@tonic-gate char *endofline;
276*0Sstevel@tonic-gate
277*0Sstevel@tonic-gate endofline = print_linetag("Service Name = ");
278*0Sstevel@tonic-gate print_utf8string(endofline, (char *)tag_value, tag_length);
279*0Sstevel@tonic-gate }
280*0Sstevel@tonic-gate
281*0Sstevel@tonic-gate static void
interpret_access(uint8_t * tag_value,uint16_t tag_length)282*0Sstevel@tonic-gate interpret_access(uint8_t *tag_value, uint16_t tag_length)
283*0Sstevel@tonic-gate {
284*0Sstevel@tonic-gate char *endofline;
285*0Sstevel@tonic-gate
286*0Sstevel@tonic-gate endofline = print_linetag("AC Name = ");
287*0Sstevel@tonic-gate print_utf8string(endofline, (char *)tag_value, tag_length);
288*0Sstevel@tonic-gate }
289*0Sstevel@tonic-gate
290*0Sstevel@tonic-gate static void
interpret_cookie(uint8_t * tag_value,uint16_t tag_length)291*0Sstevel@tonic-gate interpret_cookie(uint8_t *tag_value, uint16_t tag_length)
292*0Sstevel@tonic-gate {
293*0Sstevel@tonic-gate char *endofline;
294*0Sstevel@tonic-gate
295*0Sstevel@tonic-gate endofline = print_linetag("Cookie = ");
296*0Sstevel@tonic-gate print_hexdata(endofline, tag_value, tag_length);
297*0Sstevel@tonic-gate }
298*0Sstevel@tonic-gate
299*0Sstevel@tonic-gate static void
interpret_vendor(uint8_t * tag_value,uint16_t tag_length)300*0Sstevel@tonic-gate interpret_vendor(uint8_t *tag_value, uint16_t tag_length)
301*0Sstevel@tonic-gate {
302*0Sstevel@tonic-gate uint8_t *vendor_data;
303*0Sstevel@tonic-gate uint32_t vendorid;
304*0Sstevel@tonic-gate char *endofline;
305*0Sstevel@tonic-gate
306*0Sstevel@tonic-gate vendorid = ntohl(*(uint32_t *)tag_value);
307*0Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
308*0Sstevel@tonic-gate "Vendor ID = %d", vendorid);
309*0Sstevel@tonic-gate
310*0Sstevel@tonic-gate if (tag_length > 4) {
311*0Sstevel@tonic-gate vendor_data = tag_value + 4;
312*0Sstevel@tonic-gate endofline = print_linetag("Vendor Data = ");
313*0Sstevel@tonic-gate print_hexdata(endofline, vendor_data, tag_length - 4);
314*0Sstevel@tonic-gate }
315*0Sstevel@tonic-gate }
316*0Sstevel@tonic-gate
317*0Sstevel@tonic-gate static void
interpret_relay(uint8_t * tag_value,uint16_t tag_length)318*0Sstevel@tonic-gate interpret_relay(uint8_t *tag_value, uint16_t tag_length)
319*0Sstevel@tonic-gate {
320*0Sstevel@tonic-gate char *endofline;
321*0Sstevel@tonic-gate
322*0Sstevel@tonic-gate endofline = print_linetag("ID = ");
323*0Sstevel@tonic-gate print_hexdata(endofline, tag_value, tag_length);
324*0Sstevel@tonic-gate }
325*0Sstevel@tonic-gate
326*0Sstevel@tonic-gate static void
interpret_error(uint8_t * tag_value,uint16_t tag_length)327*0Sstevel@tonic-gate interpret_error(uint8_t *tag_value, uint16_t tag_length)
328*0Sstevel@tonic-gate {
329*0Sstevel@tonic-gate char *endofline;
330*0Sstevel@tonic-gate
331*0Sstevel@tonic-gate endofline = print_linetag("Error = ");
332*0Sstevel@tonic-gate print_utf8string(endofline, (char *)tag_value, tag_length);
333*0Sstevel@tonic-gate }
334*0Sstevel@tonic-gate
335*0Sstevel@tonic-gate static void
interpret_hurl(uint8_t * tag_value,uint16_t tag_length)336*0Sstevel@tonic-gate interpret_hurl(uint8_t *tag_value, uint16_t tag_length)
337*0Sstevel@tonic-gate {
338*0Sstevel@tonic-gate char *endofline;
339*0Sstevel@tonic-gate
340*0Sstevel@tonic-gate endofline = print_linetag("URL = ");
341*0Sstevel@tonic-gate print_utf8string(endofline, (char *)tag_value, tag_length);
342*0Sstevel@tonic-gate }
343*0Sstevel@tonic-gate
344*0Sstevel@tonic-gate static void
interpret_motm(uint8_t * tag_value,uint16_t tag_length)345*0Sstevel@tonic-gate interpret_motm(uint8_t *tag_value, uint16_t tag_length)
346*0Sstevel@tonic-gate {
347*0Sstevel@tonic-gate char *endofline;
348*0Sstevel@tonic-gate
349*0Sstevel@tonic-gate endofline = print_linetag("Message = ");
350*0Sstevel@tonic-gate print_utf8string(endofline, (char *)tag_value, tag_length);
351*0Sstevel@tonic-gate }
352*0Sstevel@tonic-gate
353*0Sstevel@tonic-gate static void
interpret_rteadd(uint8_t * tag_value,uint16_t tag_length)354*0Sstevel@tonic-gate interpret_rteadd(uint8_t *tag_value, uint16_t tag_length)
355*0Sstevel@tonic-gate {
356*0Sstevel@tonic-gate char dest[INET_ADDRSTRLEN];
357*0Sstevel@tonic-gate char mask[INET_ADDRSTRLEN];
358*0Sstevel@tonic-gate char gateway[INET_ADDRSTRLEN];
359*0Sstevel@tonic-gate uint32_t metric;
360*0Sstevel@tonic-gate
361*0Sstevel@tonic-gate if (tag_length == 16) {
362*0Sstevel@tonic-gate (void) inet_ntop(AF_INET, tag_value, dest,
363*0Sstevel@tonic-gate INET_ADDRSTRLEN);
364*0Sstevel@tonic-gate (void) inet_ntop(AF_INET, &tag_value[4], mask,
365*0Sstevel@tonic-gate INET_ADDRSTRLEN);
366*0Sstevel@tonic-gate (void) inet_ntop(AF_INET, &tag_value[8], gateway,
367*0Sstevel@tonic-gate INET_ADDRSTRLEN);
368*0Sstevel@tonic-gate metric = ntohl(*(uint32_t *)&tag_value[12]);
369*0Sstevel@tonic-gate sprintf(get_line(0, 0),
370*0Sstevel@tonic-gate "Destination\tNetmask\tGateway\tMetric");
371*0Sstevel@tonic-gate sprintf(get_line(0, 0),
372*0Sstevel@tonic-gate "%s\t%s\t%s\t%d", dest, mask, gateway, metric);
373*0Sstevel@tonic-gate }
374*0Sstevel@tonic-gate }
375*0Sstevel@tonic-gate
376*0Sstevel@tonic-gate static void
print_hexdata(char * line,uint8_t * data,uint16_t length)377*0Sstevel@tonic-gate print_hexdata(char *line, uint8_t *data, uint16_t length)
378*0Sstevel@tonic-gate {
379*0Sstevel@tonic-gate uint16_t index = 0;
380*0Sstevel@tonic-gate
381*0Sstevel@tonic-gate line += sprintf(line, "0x");
382*0Sstevel@tonic-gate
383*0Sstevel@tonic-gate while (index < length) {
384*0Sstevel@tonic-gate line += sprintf(line, "%02x", data[index++]);
385*0Sstevel@tonic-gate }
386*0Sstevel@tonic-gate }
387*0Sstevel@tonic-gate
388*0Sstevel@tonic-gate static void
print_utf8string(char * firstline,char * string,uint16_t length)389*0Sstevel@tonic-gate print_utf8string(char *firstline, char *string, uint16_t length)
390*0Sstevel@tonic-gate {
391*0Sstevel@tonic-gate (void) sprintf(firstline, "%.*s", length, string);
392*0Sstevel@tonic-gate }
393*0Sstevel@tonic-gate
394*0Sstevel@tonic-gate static char *
print_linetag(char * string)395*0Sstevel@tonic-gate print_linetag(char *string)
396*0Sstevel@tonic-gate {
397*0Sstevel@tonic-gate char *line = get_line(0, 0);
398*0Sstevel@tonic-gate return (line + sprintf(line, string));
399*0Sstevel@tonic-gate }
400