1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2001-2002 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #include <stdio.h>
30*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
31*7c478bd9Sstevel@tonic-gate #include <string.h>
32*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
33*7c478bd9Sstevel@tonic-gate #include <sys/socket.h>
34*7c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
35*7c478bd9Sstevel@tonic-gate #include <net/ppp_defs.h>
36*7c478bd9Sstevel@tonic-gate #include <net/ppp-comp.h>
37*7c478bd9Sstevel@tonic-gate #include <net/if.h>
38*7c478bd9Sstevel@tonic-gate #include <netinet/in.h>
39*7c478bd9Sstevel@tonic-gate #include <netinet/if_ether.h>
40*7c478bd9Sstevel@tonic-gate #include <arpa/inet.h>
41*7c478bd9Sstevel@tonic-gate #include "snoop.h"
42*7c478bd9Sstevel@tonic-gate #include "snoop_ppp.h"
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate static int interpret_ppp_cp(int, uchar_t *, int, ppp_protoinfo_t *);
45*7c478bd9Sstevel@tonic-gate static int interpret_cp_options(uchar_t *, int, ppp_protoinfo_t *);
46*7c478bd9Sstevel@tonic-gate static int interpret_ppp_chap(int, uchar_t *, int, ppp_protoinfo_t *);
47*7c478bd9Sstevel@tonic-gate static int interpret_ppp_pap(int, uchar_t *, int, ppp_protoinfo_t *);
48*7c478bd9Sstevel@tonic-gate static int interpret_ppp_lqr(int, uchar_t *, int, ppp_protoinfo_t *);
49*7c478bd9Sstevel@tonic-gate static ppp_protoinfo_t *ppp_getprotoinfo(uint16_t);
50*7c478bd9Sstevel@tonic-gate static cp_optinfo_t *ppp_getoptinfo(cp_optinfo_t *, uint16_t);
51*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_vendor;
52*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_mru;
53*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_accm;
54*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_authproto;
55*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_qualproto;
56*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_magicnum;
57*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_fcs;
58*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_sdp;
59*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_nummode;
60*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_callback;
61*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_mrru;
62*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_epdisc;
63*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_dce;
64*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_linkdisc;
65*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_i18n;
66*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_ipaddresses;
67*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_ipcompproto;
68*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_ipaddress;
69*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_mobileipv4;
70*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_ifaceid;
71*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_ipv6compproto;
72*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_compoui;
73*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_bsdcomp;
74*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_staclzs;
75*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_mppc;
76*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_gandalf;
77*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_lzsdcp;
78*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_magnalink;
79*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_deflate;
80*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_encroui;
81*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_dese;
82*7c478bd9Sstevel@tonic-gate static optformat_func_t opt_format_muxpid;
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate /*
85*7c478bd9Sstevel@tonic-gate  * Many strings below are initialized with "Unknown".
86*7c478bd9Sstevel@tonic-gate  */
87*7c478bd9Sstevel@tonic-gate static char unknown_string[] = "Unknown";
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate /*
90*7c478bd9Sstevel@tonic-gate  * Each known PPP protocol has an associated ppp_protoinfo_t in this array.
91*7c478bd9Sstevel@tonic-gate  * Even if we can't decode the protocol (interpret_proto() == NULL),
92*7c478bd9Sstevel@tonic-gate  * interpret_ppp() will at least print the protocol's name.  There is no
93*7c478bd9Sstevel@tonic-gate  * dependency on the ordering of the entries in this array.  They have been
94*7c478bd9Sstevel@tonic-gate  * ordered such that the most commonly used protocols are near the front.
95*7c478bd9Sstevel@tonic-gate  * The array is delimited by a last entry of protocol of type
96*7c478bd9Sstevel@tonic-gate  * PPP_PROTO_UNKNOWN.
97*7c478bd9Sstevel@tonic-gate  */
98*7c478bd9Sstevel@tonic-gate static ppp_protoinfo_t protoinfo_array[] = {
99*7c478bd9Sstevel@tonic-gate 	{ PPP_IP,	"IP",		interpret_ip,	NULL,	NULL },
100*7c478bd9Sstevel@tonic-gate 	{ PPP_IPV6,	"IPv6",		interpret_ipv6,	NULL,	NULL },
101*7c478bd9Sstevel@tonic-gate 	{ PPP_COMP,	"Compressed Data",	NULL,	NULL,	NULL },
102*7c478bd9Sstevel@tonic-gate 	{ PPP_OSI,	"OSI",			NULL,	NULL,	NULL },
103*7c478bd9Sstevel@tonic-gate 	{ PPP_AT,	"AppleTalk",		NULL,	NULL,	NULL },
104*7c478bd9Sstevel@tonic-gate 	{ PPP_IPX,	"IPX",			NULL,	NULL,	NULL },
105*7c478bd9Sstevel@tonic-gate 	{ PPP_VJC_COMP,	"VJ Compressed TCP",    NULL,	NULL,	NULL },
106*7c478bd9Sstevel@tonic-gate 	{ PPP_VJC_UNCOMP, "VJ Uncompressed TCP", NULL,	NULL,	NULL },
107*7c478bd9Sstevel@tonic-gate 	{ PPP_BRIDGE,	"Bridging",		NULL,	NULL,	NULL },
108*7c478bd9Sstevel@tonic-gate 	{ PPP_802HELLO,	"802.1d Hello",		NULL,	NULL,	NULL },
109*7c478bd9Sstevel@tonic-gate 	{ PPP_MP,	"MP",			NULL,	NULL,	NULL },
110*7c478bd9Sstevel@tonic-gate 	{ PPP_ENCRYPT,	"Encryption",		NULL,	NULL,	NULL },
111*7c478bd9Sstevel@tonic-gate 	{ PPP_ENCRYPTFRAG, "Individual Link Encryption", NULL,	NULL,	NULL },
112*7c478bd9Sstevel@tonic-gate 	{ PPP_MUX,	"PPP Muxing",		NULL,	NULL,	NULL },
113*7c478bd9Sstevel@tonic-gate 	{ PPP_COMPFRAG,	"Single Link Compressed Data",	NULL,	NULL,	NULL },
114*7c478bd9Sstevel@tonic-gate 	{ PPP_FULLHDR,	"IP Compression",	NULL,	NULL,	NULL },
115*7c478bd9Sstevel@tonic-gate 	{ PPP_COMPTCP,	"IP Compression",	NULL,	NULL,	NULL },
116*7c478bd9Sstevel@tonic-gate 	{ PPP_COMPNONTCP, "IP Compression",	NULL,	NULL,	NULL },
117*7c478bd9Sstevel@tonic-gate 	{ PPP_COMPUDP8,	"IP Compression",	NULL,	NULL,	NULL },
118*7c478bd9Sstevel@tonic-gate 	{ PPP_COMPRTP8,	"IP Compression",	NULL,	NULL,	NULL },
119*7c478bd9Sstevel@tonic-gate 	{ PPP_COMPTCPND, "IP Compression",	NULL,	NULL,	NULL },
120*7c478bd9Sstevel@tonic-gate 	{ PPP_COMPSTATE, "IP Compression",	NULL,	NULL,	NULL },
121*7c478bd9Sstevel@tonic-gate 	{ PPP_COMPUDP16, "IP Compression",	NULL,	NULL,	NULL },
122*7c478bd9Sstevel@tonic-gate 	{ PPP_COMPRTP16, "IP Compression",	NULL,	NULL,	NULL },
123*7c478bd9Sstevel@tonic-gate 	{ PPP_MPLS,	"MPLS",			NULL,	NULL,	NULL },
124*7c478bd9Sstevel@tonic-gate 	{ PPP_MPLSMC,	"MPLS M/C",		NULL,	NULL,	NULL },
125*7c478bd9Sstevel@tonic-gate 	{ PPP_LQR,	"LQR",		interpret_ppp_lqr,	"PPP-LQR:  ",
126*7c478bd9Sstevel@tonic-gate 	    "Link Quality Report" },
127*7c478bd9Sstevel@tonic-gate 	{ PPP_LCP,	"LCP",		interpret_ppp_cp,	"PPP-LCP:  ",
128*7c478bd9Sstevel@tonic-gate 	    "Link Control Protocol" },
129*7c478bd9Sstevel@tonic-gate 	{ PPP_IPCP,	"IPCP",		interpret_ppp_cp,	"PPP-IPCP: ",
130*7c478bd9Sstevel@tonic-gate 	    "IP Control Protocol" },
131*7c478bd9Sstevel@tonic-gate 	{ PPP_IPV6CP,	"IPV6CP",	interpret_ppp_cp,	"PPP-IPV6CP:  ",
132*7c478bd9Sstevel@tonic-gate 	    "IPv6 Control Protocol" },
133*7c478bd9Sstevel@tonic-gate 	{ PPP_CCP,	"CCP",		interpret_ppp_cp,	"PPP-CCP:  ",
134*7c478bd9Sstevel@tonic-gate 	    "Compression Control Protocol" },
135*7c478bd9Sstevel@tonic-gate 	{ PPP_CCPFRAG,	"CCP-Link",	interpret_ppp_cp, "PPP-CCP-Link:  ",
136*7c478bd9Sstevel@tonic-gate 	    "Per-Link Compression Control Protocol" },
137*7c478bd9Sstevel@tonic-gate 	{ PPP_ECP,	"ECP",		interpret_ppp_cp,	"PPP-ECP:  ",
138*7c478bd9Sstevel@tonic-gate 	    "Encryption Control Protocol" },
139*7c478bd9Sstevel@tonic-gate 	{ PPP_ECPFRAG,	"ECP-Link",	interpret_ppp_cp, "PPP-ECP-Link:  ",
140*7c478bd9Sstevel@tonic-gate 	    "Per-Link Encryption Control Protocol" },
141*7c478bd9Sstevel@tonic-gate 	{ PPP_MPLSCP,	"MPLSCP",		NULL,	NULL,	NULL },
142*7c478bd9Sstevel@tonic-gate 	{ PPP_OSINLCP,	"OSINLCP",		NULL,	NULL,	NULL },
143*7c478bd9Sstevel@tonic-gate 	{ PPP_ATCP,	"ATCP",			NULL,	NULL,	NULL },
144*7c478bd9Sstevel@tonic-gate 	{ PPP_IPXCP,	"IPXCP",		NULL,	NULL,	NULL },
145*7c478bd9Sstevel@tonic-gate 	{ PPP_BACP,	"BACP",			NULL,	NULL,	NULL },
146*7c478bd9Sstevel@tonic-gate 	{ PPP_BCP,	"BCP",			NULL,	NULL,	NULL },
147*7c478bd9Sstevel@tonic-gate 	{ PPP_CBCP,	"CBCP",			NULL,	NULL,	NULL },
148*7c478bd9Sstevel@tonic-gate 	{ PPP_BAP,	"BAP",			NULL,	NULL,	NULL },
149*7c478bd9Sstevel@tonic-gate 	{ PPP_CHAP,	"CHAP",		interpret_ppp_chap,	"CHAP:  ",
150*7c478bd9Sstevel@tonic-gate 	    "Challenge Handshake Authentication Protocl" },
151*7c478bd9Sstevel@tonic-gate 	{ PPP_PAP,	"PAP",		interpret_ppp_pap,	"PAP:   ",
152*7c478bd9Sstevel@tonic-gate 	    "Password Authentication Protocol" },
153*7c478bd9Sstevel@tonic-gate 	{ PPP_EAP,	"EAP",			NULL,	NULL,	NULL },
154*7c478bd9Sstevel@tonic-gate 	{ 0,		unknown_string,		NULL,	NULL,	NULL }
155*7c478bd9Sstevel@tonic-gate };
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate static cp_optinfo_t lcp_optinfo[] = {
158*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_VENDOR,	"Vendor-Specific",		6,
159*7c478bd9Sstevel@tonic-gate 	    opt_format_vendor },
160*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_MRU,		"Maximum-Receive-Unit",		4,
161*7c478bd9Sstevel@tonic-gate 	    opt_format_mru },
162*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_ASYNCMAP,	"Async-Control-Character-Map",	6,
163*7c478bd9Sstevel@tonic-gate 	    opt_format_accm },
164*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_AUTHTYPE,	"Authentication-Protocol",	4,
165*7c478bd9Sstevel@tonic-gate 	    opt_format_authproto },
166*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_QUALITY,	"Quality-Protocol",		4,
167*7c478bd9Sstevel@tonic-gate 	    opt_format_qualproto },
168*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_MAGICNUMBER,	"Magic-Number",			6,
169*7c478bd9Sstevel@tonic-gate 	    opt_format_magicnum },
170*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_PCOMPRESSION,	"Protocol-Field-Compression",	2,	NULL },
171*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_ACCOMPRESSION, "Address-and-Control-Field-Compression", 2,
172*7c478bd9Sstevel@tonic-gate 	    NULL },
173*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_FCSALTERN,	"FCS-Alternative",		3,
174*7c478bd9Sstevel@tonic-gate 	    opt_format_fcs },
175*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_SELFDESCPAD,	"Self-Describing-Padding",	3,
176*7c478bd9Sstevel@tonic-gate 	    opt_format_sdp },
177*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_NUMBERED,	"Numbered-Mode",		3,
178*7c478bd9Sstevel@tonic-gate 	    opt_format_nummode },
179*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_MULTILINKPROC, "Multi-Link-Procedure",	2,	NULL },
180*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_CALLBACK,	"Callback",			3,
181*7c478bd9Sstevel@tonic-gate 	    opt_format_callback },
182*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_CONNECTTIME,	"Connect-Time",			2,	NULL },
183*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_COMPOUNDFRAMES, "Compound-Frames",		2,	NULL },
184*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_DATAENCAP,	"Nominal-Data-Encapsulation",	2,	NULL },
185*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_MRRU,		"Multilink-MRRU",		4,
186*7c478bd9Sstevel@tonic-gate 	    opt_format_mrru },
187*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_SSNHF,	"Multilink-Short-Sequence-Number-Header-Format",
188*7c478bd9Sstevel@tonic-gate 	    2, NULL },
189*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_EPDISC,	"Multilink-Endpoint-Discriminator",	3,
190*7c478bd9Sstevel@tonic-gate 	    opt_format_epdisc },
191*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_DCEIDENT,	"DCE-Identifier",		3,
192*7c478bd9Sstevel@tonic-gate 	    opt_format_dce },
193*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_MLPLUSPROC,	"Multi-Link-Plus-Procedure",	2,	NULL },
194*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_LINKDISC,	"Link Discriminator for BACP",	4,
195*7c478bd9Sstevel@tonic-gate 	    opt_format_linkdisc },
196*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_AUTH,		"LCP-Authentication-Option",	2,	NULL },
197*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_COBS,		"COBS",				2,	NULL },
198*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_PFXELISION,	"Prefix elision",		2,	NULL },
199*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_MPHDRFMT,	"Multilink header format",	2,	NULL },
200*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_I18N,		"Internationalization",		6,
201*7c478bd9Sstevel@tonic-gate 	    opt_format_i18n },
202*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_SDL,		"Simple Data Link on SONET/SDH", 2,	NULL },
203*7c478bd9Sstevel@tonic-gate 	{ OPT_LCP_MUXING,	"Old PPP Multiplexing",		2,	NULL },
204*7c478bd9Sstevel@tonic-gate 	{ 0,			unknown_string,			0,	NULL }
205*7c478bd9Sstevel@tonic-gate };
206*7c478bd9Sstevel@tonic-gate 
207*7c478bd9Sstevel@tonic-gate static cp_optinfo_t ipcp_optinfo[] = {
208*7c478bd9Sstevel@tonic-gate 	{ OPT_IPCP_ADDRS,	"IP-Addresses",			10,
209*7c478bd9Sstevel@tonic-gate 	    opt_format_ipaddresses },
210*7c478bd9Sstevel@tonic-gate 	{ OPT_IPCP_COMPRESSTYPE, "IP-Compression-Protocol",	4,
211*7c478bd9Sstevel@tonic-gate 	    opt_format_ipcompproto },
212*7c478bd9Sstevel@tonic-gate 	{ OPT_IPCP_ADDR,	"IP-Address",			6,
213*7c478bd9Sstevel@tonic-gate 	    opt_format_ipaddress },
214*7c478bd9Sstevel@tonic-gate 	{ OPT_IPCP_MOBILEIPV4,	"Mobile-IPv4",			6,
215*7c478bd9Sstevel@tonic-gate 	    opt_format_mobileipv4 },
216*7c478bd9Sstevel@tonic-gate 	{ OPT_IPCP_DNS1,	"Primary DNS Address",		6,
217*7c478bd9Sstevel@tonic-gate 	    opt_format_ipaddress },
218*7c478bd9Sstevel@tonic-gate 	{ OPT_IPCP_NBNS1,	"Primary NBNS Address",		6,
219*7c478bd9Sstevel@tonic-gate 	    opt_format_ipaddress },
220*7c478bd9Sstevel@tonic-gate 	{ OPT_IPCP_DNS2,	"Secondary DNS Address", 	6,
221*7c478bd9Sstevel@tonic-gate 	    opt_format_ipaddress },
222*7c478bd9Sstevel@tonic-gate 	{ OPT_IPCP_NBNS2,	"Secondary NBNS Address",	6,
223*7c478bd9Sstevel@tonic-gate 	    opt_format_ipaddress },
224*7c478bd9Sstevel@tonic-gate 	{ OPT_IPCP_SUBNET,	"IP-Subnet",			6,
225*7c478bd9Sstevel@tonic-gate 	    opt_format_ipaddress },
226*7c478bd9Sstevel@tonic-gate 	{ 0,			unknown_string,			0,	NULL }
227*7c478bd9Sstevel@tonic-gate };
228*7c478bd9Sstevel@tonic-gate 
229*7c478bd9Sstevel@tonic-gate static cp_optinfo_t ipv6cp_optinfo[] = {
230*7c478bd9Sstevel@tonic-gate 	{ OPT_IPV6CP_IFACEID,	"Interface-Identifier",		10,
231*7c478bd9Sstevel@tonic-gate 	    opt_format_ifaceid },
232*7c478bd9Sstevel@tonic-gate 	{ OPT_IPV6CP_COMPRESSTYPE, "IPv6-Compression-Protocol",	4,
233*7c478bd9Sstevel@tonic-gate 	    opt_format_ipv6compproto },
234*7c478bd9Sstevel@tonic-gate 	{ 0,			unknown_string,			0,	NULL }
235*7c478bd9Sstevel@tonic-gate };
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate static cp_optinfo_t ccp_optinfo[] = {
238*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_PROPRIETARY,	"Proprietary Compression OUI",	6,
239*7c478bd9Sstevel@tonic-gate 	    opt_format_compoui },
240*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_PREDICTOR1,	"Predictor type 1",		2,	NULL },
241*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_PREDICTOR2,	"Predictor type 2",		2,	NULL },
242*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_PUDDLEJUMP,	"Puddle Jumper",		2,	NULL },
243*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_HPPPC,	"Hewlett-Packard PPC",		2,	NULL },
244*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_STACLZS,	"Stac Electronics LZS",		5,
245*7c478bd9Sstevel@tonic-gate 	    opt_format_staclzs },
246*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_MPPC,		"Microsoft PPC",		6,
247*7c478bd9Sstevel@tonic-gate 	    opt_format_mppc },
248*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_GANDALFFZA,	"Gandalf FZA",			3,
249*7c478bd9Sstevel@tonic-gate 	    opt_format_gandalf },
250*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_V42BIS,	"V.42bis compression",		2,
251*7c478bd9Sstevel@tonic-gate 	    NULL },
252*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_BSDCOMP,	"BSD LZW Compress",		3,
253*7c478bd9Sstevel@tonic-gate 	    opt_format_bsdcomp },
254*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_LZSDCP,	"LZS-DCP",			6,
255*7c478bd9Sstevel@tonic-gate 	    opt_format_lzsdcp },
256*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_MAGNALINK,	"Magnalink",			4,
257*7c478bd9Sstevel@tonic-gate 	    opt_format_magnalink },
258*7c478bd9Sstevel@tonic-gate 	{ OPT_CCP_DEFLATE,	"Deflate",			4,
259*7c478bd9Sstevel@tonic-gate 	    opt_format_deflate },
260*7c478bd9Sstevel@tonic-gate 	{ 0,			unknown_string,			0,	NULL }
261*7c478bd9Sstevel@tonic-gate };
262*7c478bd9Sstevel@tonic-gate 
263*7c478bd9Sstevel@tonic-gate static cp_optinfo_t ecp_optinfo[] = {
264*7c478bd9Sstevel@tonic-gate 	{ OPT_ECP_PROPRIETARY,	"Proprietary Encryption OUI",	6,
265*7c478bd9Sstevel@tonic-gate 	    opt_format_encroui },
266*7c478bd9Sstevel@tonic-gate 	{ OPT_ECP_DESE,		"DESE",				10,
267*7c478bd9Sstevel@tonic-gate 	    opt_format_dese },
268*7c478bd9Sstevel@tonic-gate 	{ OPT_ECP_3DESE,	"3DESE",			10,
269*7c478bd9Sstevel@tonic-gate 	    opt_format_dese },
270*7c478bd9Sstevel@tonic-gate 	{ OPT_ECP_DESEBIS,	"DESE-bis",			10,
271*7c478bd9Sstevel@tonic-gate 	    opt_format_dese },
272*7c478bd9Sstevel@tonic-gate 	{ 0,			unknown_string,			0,	NULL }
273*7c478bd9Sstevel@tonic-gate };
274*7c478bd9Sstevel@tonic-gate 
275*7c478bd9Sstevel@tonic-gate static cp_optinfo_t muxcp_optinfo[] = {
276*7c478bd9Sstevel@tonic-gate 	{ OPT_MUXCP_DEFAULTPID,	"Default PID",			4,
277*7c478bd9Sstevel@tonic-gate 	    opt_format_muxpid },
278*7c478bd9Sstevel@tonic-gate 	{ 0,			unknown_string,			0,	NULL }
279*7c478bd9Sstevel@tonic-gate };
280*7c478bd9Sstevel@tonic-gate 
281*7c478bd9Sstevel@tonic-gate static char *cp_codearray[] = {
282*7c478bd9Sstevel@tonic-gate 	"(Vendor Specific)",
283*7c478bd9Sstevel@tonic-gate 	"(Configure-Request)",
284*7c478bd9Sstevel@tonic-gate 	"(Configure-Ack)",
285*7c478bd9Sstevel@tonic-gate 	"(Configure-Nak)",
286*7c478bd9Sstevel@tonic-gate 	"(Configure-Reject)",
287*7c478bd9Sstevel@tonic-gate 	"(Terminate-Request)",
288*7c478bd9Sstevel@tonic-gate 	"(Terminate-Ack)",
289*7c478bd9Sstevel@tonic-gate 	"(Code-Reject)",
290*7c478bd9Sstevel@tonic-gate 	"(Protocol-Reject)",
291*7c478bd9Sstevel@tonic-gate 	"(Echo-Request)",
292*7c478bd9Sstevel@tonic-gate 	"(Echo-Reply)",
293*7c478bd9Sstevel@tonic-gate 	"(Discard-Request)",
294*7c478bd9Sstevel@tonic-gate 	"(Identification)",
295*7c478bd9Sstevel@tonic-gate 	"(Time-Remaining)",
296*7c478bd9Sstevel@tonic-gate 	"(Reset-Request)",
297*7c478bd9Sstevel@tonic-gate 	"(Reset-Ack)"
298*7c478bd9Sstevel@tonic-gate };
299*7c478bd9Sstevel@tonic-gate #define	MAX_CPCODE	((sizeof (cp_codearray) / sizeof (char *)) - 1)
300*7c478bd9Sstevel@tonic-gate 
301*7c478bd9Sstevel@tonic-gate static char *pap_codearray[] = {
302*7c478bd9Sstevel@tonic-gate 	"(Unknown)",
303*7c478bd9Sstevel@tonic-gate 	"(Authenticate-Request)",
304*7c478bd9Sstevel@tonic-gate 	"(Authenticate-Ack)",
305*7c478bd9Sstevel@tonic-gate 	"(Authenticate-Nak)"
306*7c478bd9Sstevel@tonic-gate };
307*7c478bd9Sstevel@tonic-gate #define	MAX_PAPCODE	((sizeof (pap_codearray) / sizeof (char *)) - 1)
308*7c478bd9Sstevel@tonic-gate 
309*7c478bd9Sstevel@tonic-gate static char *chap_codearray[] = {
310*7c478bd9Sstevel@tonic-gate 	"(Unknown)",
311*7c478bd9Sstevel@tonic-gate 	"(Challenge)",
312*7c478bd9Sstevel@tonic-gate 	"(Response)",
313*7c478bd9Sstevel@tonic-gate 	"(Success)",
314*7c478bd9Sstevel@tonic-gate 	"(Failure)"
315*7c478bd9Sstevel@tonic-gate };
316*7c478bd9Sstevel@tonic-gate #define	MAX_CHAPCODE	((sizeof (chap_codearray) / sizeof (char *)) - 1)
317*7c478bd9Sstevel@tonic-gate 
318*7c478bd9Sstevel@tonic-gate 
319*7c478bd9Sstevel@tonic-gate int
interpret_ppp(int flags,uchar_t * data,int len)320*7c478bd9Sstevel@tonic-gate interpret_ppp(int flags, uchar_t *data, int len)
321*7c478bd9Sstevel@tonic-gate {
322*7c478bd9Sstevel@tonic-gate 	uint16_t protocol;
323*7c478bd9Sstevel@tonic-gate 	ppp_protoinfo_t *protoinfo;
324*7c478bd9Sstevel@tonic-gate 	uchar_t *payload = data;
325*7c478bd9Sstevel@tonic-gate 
326*7c478bd9Sstevel@tonic-gate 	if (len < 2)
327*7c478bd9Sstevel@tonic-gate 		return (len);
328*7c478bd9Sstevel@tonic-gate 
329*7c478bd9Sstevel@tonic-gate 	GETINT16(protocol, payload);
330*7c478bd9Sstevel@tonic-gate 	len -= sizeof (uint16_t);
331*7c478bd9Sstevel@tonic-gate 
332*7c478bd9Sstevel@tonic-gate 	protoinfo = ppp_getprotoinfo(protocol);
333*7c478bd9Sstevel@tonic-gate 
334*7c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
335*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_sum_line(),
336*7c478bd9Sstevel@tonic-gate 		    "PPP Protocol=0x%x (%s)", protocol, protoinfo->name);
337*7c478bd9Sstevel@tonic-gate 	} else { /* F_DTAIL */
338*7c478bd9Sstevel@tonic-gate 		show_header("PPP:    ", "Point-to-Point Protocol", len);
339*7c478bd9Sstevel@tonic-gate 		show_space();
340*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Protocol = 0x%x (%s)",
341*7c478bd9Sstevel@tonic-gate 		    protocol, protoinfo->name);
342*7c478bd9Sstevel@tonic-gate 		show_space();
343*7c478bd9Sstevel@tonic-gate 	}
344*7c478bd9Sstevel@tonic-gate 
345*7c478bd9Sstevel@tonic-gate 	if (protoinfo->interpret_proto != NULL) {
346*7c478bd9Sstevel@tonic-gate 		len = protoinfo->interpret_proto(flags, payload, len,
347*7c478bd9Sstevel@tonic-gate 		    protoinfo);
348*7c478bd9Sstevel@tonic-gate 	}
349*7c478bd9Sstevel@tonic-gate 
350*7c478bd9Sstevel@tonic-gate 	return (len);
351*7c478bd9Sstevel@tonic-gate }
352*7c478bd9Sstevel@tonic-gate 
353*7c478bd9Sstevel@tonic-gate /*
354*7c478bd9Sstevel@tonic-gate  * interpret_ppp_cp() - Interpret PPP control protocols.  It is convenient
355*7c478bd9Sstevel@tonic-gate  * to do some of the decoding of these protocols in a common function since
356*7c478bd9Sstevel@tonic-gate  * they share packet formats.  This function expects to receive data
357*7c478bd9Sstevel@tonic-gate  * starting with the code field.
358*7c478bd9Sstevel@tonic-gate  */
359*7c478bd9Sstevel@tonic-gate static int
interpret_ppp_cp(int flags,uchar_t * data,int len,ppp_protoinfo_t * protoinfo)360*7c478bd9Sstevel@tonic-gate interpret_ppp_cp(int flags, uchar_t *data, int len, ppp_protoinfo_t *protoinfo)
361*7c478bd9Sstevel@tonic-gate {
362*7c478bd9Sstevel@tonic-gate 	uint8_t code;
363*7c478bd9Sstevel@tonic-gate 	uint8_t id;
364*7c478bd9Sstevel@tonic-gate 	char *codestr;
365*7c478bd9Sstevel@tonic-gate 	uint16_t length;
366*7c478bd9Sstevel@tonic-gate 	uchar_t *datap = data;
367*7c478bd9Sstevel@tonic-gate 
368*7c478bd9Sstevel@tonic-gate 	if (len < sizeof (ppp_pkt_t))
369*7c478bd9Sstevel@tonic-gate 		return (len);
370*7c478bd9Sstevel@tonic-gate 
371*7c478bd9Sstevel@tonic-gate 	GETINT8(code, datap);
372*7c478bd9Sstevel@tonic-gate 	GETINT8(id, datap);
373*7c478bd9Sstevel@tonic-gate 	GETINT16(length, datap);
374*7c478bd9Sstevel@tonic-gate 
375*7c478bd9Sstevel@tonic-gate 	len -= sizeof (ppp_pkt_t);
376*7c478bd9Sstevel@tonic-gate 
377*7c478bd9Sstevel@tonic-gate 	if (code <= MAX_CPCODE)
378*7c478bd9Sstevel@tonic-gate 		codestr = cp_codearray[code];
379*7c478bd9Sstevel@tonic-gate 	else
380*7c478bd9Sstevel@tonic-gate 		codestr = "";
381*7c478bd9Sstevel@tonic-gate 
382*7c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
383*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_sum_line(),
384*7c478bd9Sstevel@tonic-gate 		    "%s%s", protoinfo->prefix, codestr);
385*7c478bd9Sstevel@tonic-gate 	} else { /* (flags & F_DTAIL) */
386*7c478bd9Sstevel@tonic-gate 		show_header(protoinfo->prefix, protoinfo->description, len);
387*7c478bd9Sstevel@tonic-gate 		show_space();
388*7c478bd9Sstevel@tonic-gate 
389*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Code = %d %s", code, codestr);
390*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Identifier = %d", id);
391*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Length = %d", length);
392*7c478bd9Sstevel@tonic-gate 
393*7c478bd9Sstevel@tonic-gate 		show_space();
394*7c478bd9Sstevel@tonic-gate 
395*7c478bd9Sstevel@tonic-gate 		len = MIN(len, length - sizeof (ppp_pkt_t));
396*7c478bd9Sstevel@tonic-gate 		if (len == 0)
397*7c478bd9Sstevel@tonic-gate 			return (len);
398*7c478bd9Sstevel@tonic-gate 
399*7c478bd9Sstevel@tonic-gate 		switch (code) {
400*7c478bd9Sstevel@tonic-gate 		case CODE_VENDOR: {
401*7c478bd9Sstevel@tonic-gate 			uint32_t magicnum;
402*7c478bd9Sstevel@tonic-gate 			uint32_t oui;
403*7c478bd9Sstevel@tonic-gate 			char *ouistr;
404*7c478bd9Sstevel@tonic-gate 			uint8_t kind;
405*7c478bd9Sstevel@tonic-gate 
406*7c478bd9Sstevel@tonic-gate 			if (len < sizeof (magicnum) + sizeof (oui))
407*7c478bd9Sstevel@tonic-gate 				return (len);
408*7c478bd9Sstevel@tonic-gate 
409*7c478bd9Sstevel@tonic-gate 			GETINT32(magicnum, datap);
410*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Magic-Number = 0x%08x",
411*7c478bd9Sstevel@tonic-gate 			    magicnum);
412*7c478bd9Sstevel@tonic-gate 
413*7c478bd9Sstevel@tonic-gate 			GETINT32(oui, datap);
414*7c478bd9Sstevel@tonic-gate 			kind = oui & 0x000000ff;
415*7c478bd9Sstevel@tonic-gate 			oui >>= 8;
416*7c478bd9Sstevel@tonic-gate 
417*7c478bd9Sstevel@tonic-gate 			ouistr = ether_ouiname(oui);
418*7c478bd9Sstevel@tonic-gate 			if (ouistr == NULL)
419*7c478bd9Sstevel@tonic-gate 				ouistr = unknown_string;
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "OUI = 0x%06x (%s)",
422*7c478bd9Sstevel@tonic-gate 			    oui, ouistr);
423*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Kind = %d", kind);
424*7c478bd9Sstevel@tonic-gate 			show_space();
425*7c478bd9Sstevel@tonic-gate 			break;
426*7c478bd9Sstevel@tonic-gate 		}
427*7c478bd9Sstevel@tonic-gate 
428*7c478bd9Sstevel@tonic-gate 		case CODE_CONFREQ:
429*7c478bd9Sstevel@tonic-gate 		case CODE_CONFACK:
430*7c478bd9Sstevel@tonic-gate 		case CODE_CONFNAK:
431*7c478bd9Sstevel@tonic-gate 		case CODE_CONFREJ:
432*7c478bd9Sstevel@tonic-gate 			/*
433*7c478bd9Sstevel@tonic-gate 			 * The above all contain protocol specific
434*7c478bd9Sstevel@tonic-gate 			 * configuration options.  Parse these options.
435*7c478bd9Sstevel@tonic-gate 			 */
436*7c478bd9Sstevel@tonic-gate 			interpret_cp_options(datap, len, protoinfo);
437*7c478bd9Sstevel@tonic-gate 			break;
438*7c478bd9Sstevel@tonic-gate 
439*7c478bd9Sstevel@tonic-gate 		case CODE_TERMREQ:
440*7c478bd9Sstevel@tonic-gate 		case CODE_TERMACK:
441*7c478bd9Sstevel@tonic-gate 			/*
442*7c478bd9Sstevel@tonic-gate 			 * The arbitrary data in these two packet types
443*7c478bd9Sstevel@tonic-gate 			 * is almost always plain text.  Print it as such.
444*7c478bd9Sstevel@tonic-gate 			 */
445*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Data = %.*s",
446*7c478bd9Sstevel@tonic-gate 			    length - sizeof (ppp_pkt_t), datap);
447*7c478bd9Sstevel@tonic-gate 			show_space();
448*7c478bd9Sstevel@tonic-gate 			break;
449*7c478bd9Sstevel@tonic-gate 
450*7c478bd9Sstevel@tonic-gate 		case CODE_CODEREJ:
451*7c478bd9Sstevel@tonic-gate 			/*
452*7c478bd9Sstevel@tonic-gate 			 * What follows is the rejected control protocol
453*7c478bd9Sstevel@tonic-gate 			 * packet, starting with the code field.
454*7c478bd9Sstevel@tonic-gate 			 * Conveniently, we can call interpret_ppp_cp() to
455*7c478bd9Sstevel@tonic-gate 			 * decode this.
456*7c478bd9Sstevel@tonic-gate 			 */
457*7c478bd9Sstevel@tonic-gate 			prot_nest_prefix = protoinfo->prefix;
458*7c478bd9Sstevel@tonic-gate 			interpret_ppp_cp(flags, datap, len, protoinfo);
459*7c478bd9Sstevel@tonic-gate 			prot_nest_prefix = "";
460*7c478bd9Sstevel@tonic-gate 			break;
461*7c478bd9Sstevel@tonic-gate 
462*7c478bd9Sstevel@tonic-gate 		case CODE_PROTREJ:
463*7c478bd9Sstevel@tonic-gate 			/*
464*7c478bd9Sstevel@tonic-gate 			 * We don't print the rejected-protocol field
465*7c478bd9Sstevel@tonic-gate 			 * explicitely.  Instead, we cheat and pretend that
466*7c478bd9Sstevel@tonic-gate 			 * the rejected-protocol field is actually the
467*7c478bd9Sstevel@tonic-gate 			 * protocol field in the included PPP packet.  This
468*7c478bd9Sstevel@tonic-gate 			 * way, we can invoke interpret_ppp() and have it
469*7c478bd9Sstevel@tonic-gate 			 * treat the included packet normally.
470*7c478bd9Sstevel@tonic-gate 			 */
471*7c478bd9Sstevel@tonic-gate 			prot_nest_prefix = protoinfo->prefix;
472*7c478bd9Sstevel@tonic-gate 			interpret_ppp(flags, datap, len);
473*7c478bd9Sstevel@tonic-gate 			prot_nest_prefix = "";
474*7c478bd9Sstevel@tonic-gate 			break;
475*7c478bd9Sstevel@tonic-gate 
476*7c478bd9Sstevel@tonic-gate 		case CODE_ECHOREQ:
477*7c478bd9Sstevel@tonic-gate 		case CODE_ECHOREP:
478*7c478bd9Sstevel@tonic-gate 		case CODE_DISCREQ:
479*7c478bd9Sstevel@tonic-gate 		case CODE_IDENT:
480*7c478bd9Sstevel@tonic-gate 		case CODE_TIMEREMAIN: {
481*7c478bd9Sstevel@tonic-gate 			uint32_t magicnum;
482*7c478bd9Sstevel@tonic-gate 			char *message_label = "Identification = %.*s";
483*7c478bd9Sstevel@tonic-gate 
484*7c478bd9Sstevel@tonic-gate 			if (len < sizeof (uint32_t))
485*7c478bd9Sstevel@tonic-gate 				break;
486*7c478bd9Sstevel@tonic-gate 
487*7c478bd9Sstevel@tonic-gate 			GETINT32(magicnum, datap);
488*7c478bd9Sstevel@tonic-gate 			len -= sizeof (uint32_t);
489*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Magic-Number = 0x%08x",
490*7c478bd9Sstevel@tonic-gate 			    magicnum);
491*7c478bd9Sstevel@tonic-gate 			/*
492*7c478bd9Sstevel@tonic-gate 			 * Unless this is an identification or
493*7c478bd9Sstevel@tonic-gate 			 * time-remaining packet, arbitrary data follows
494*7c478bd9Sstevel@tonic-gate 			 * the magic number field.  The user can take a
495*7c478bd9Sstevel@tonic-gate 			 * look at the hex dump for enlightenment.
496*7c478bd9Sstevel@tonic-gate 			 */
497*7c478bd9Sstevel@tonic-gate 			if (code == CODE_TIMEREMAIN) {
498*7c478bd9Sstevel@tonic-gate 				uint32_t timeremaining;
499*7c478bd9Sstevel@tonic-gate 
500*7c478bd9Sstevel@tonic-gate 				if (len < sizeof (uint32_t))
501*7c478bd9Sstevel@tonic-gate 					break;
502*7c478bd9Sstevel@tonic-gate 
503*7c478bd9Sstevel@tonic-gate 				message_label = "Message = %.*s";
504*7c478bd9Sstevel@tonic-gate 
505*7c478bd9Sstevel@tonic-gate 				GETINT32(timeremaining, datap);
506*7c478bd9Sstevel@tonic-gate 				len -= sizeof (uint32_t);
507*7c478bd9Sstevel@tonic-gate 				(void) sprintf(get_line(0, 0),
508*7c478bd9Sstevel@tonic-gate 				    "Seconds Remaining = %d", timeremaining);
509*7c478bd9Sstevel@tonic-gate 			}
510*7c478bd9Sstevel@tonic-gate 
511*7c478bd9Sstevel@tonic-gate 			if (code == CODE_IDENT || code == CODE_TIMEREMAIN) {
512*7c478bd9Sstevel@tonic-gate 				if (len == 0)
513*7c478bd9Sstevel@tonic-gate 					break;
514*7c478bd9Sstevel@tonic-gate 
515*7c478bd9Sstevel@tonic-gate 				(void) sprintf(get_line(0, 0), message_label,
516*7c478bd9Sstevel@tonic-gate 				    len, datap);
517*7c478bd9Sstevel@tonic-gate 			}
518*7c478bd9Sstevel@tonic-gate 			show_space();
519*7c478bd9Sstevel@tonic-gate 			break;
520*7c478bd9Sstevel@tonic-gate 		}
521*7c478bd9Sstevel@tonic-gate 
522*7c478bd9Sstevel@tonic-gate 		/*
523*7c478bd9Sstevel@tonic-gate 		 * Reset-Request and Reset-Ack contain arbitrary data which
524*7c478bd9Sstevel@tonic-gate 		 * the user can sift through using the -x option.
525*7c478bd9Sstevel@tonic-gate 		 */
526*7c478bd9Sstevel@tonic-gate 		case CODE_RESETREQ:
527*7c478bd9Sstevel@tonic-gate 		case CODE_RESETACK:
528*7c478bd9Sstevel@tonic-gate 		default:
529*7c478bd9Sstevel@tonic-gate 			break;
530*7c478bd9Sstevel@tonic-gate 		}
531*7c478bd9Sstevel@tonic-gate 	}
532*7c478bd9Sstevel@tonic-gate 	return (len);
533*7c478bd9Sstevel@tonic-gate }
534*7c478bd9Sstevel@tonic-gate 
535*7c478bd9Sstevel@tonic-gate 
536*7c478bd9Sstevel@tonic-gate /*
537*7c478bd9Sstevel@tonic-gate  * interpret_cp_options() decodes control protocol configuration options.
538*7c478bd9Sstevel@tonic-gate  * Since each control protocol has a different set of options whose type
539*7c478bd9Sstevel@tonic-gate  * numbers overlap, the protoinfo parameter is used to get a handle on
540*7c478bd9Sstevel@tonic-gate  * which option set to use for decoding.
541*7c478bd9Sstevel@tonic-gate  */
542*7c478bd9Sstevel@tonic-gate static int
interpret_cp_options(uchar_t * optptr,int len,ppp_protoinfo_t * protoinfo)543*7c478bd9Sstevel@tonic-gate interpret_cp_options(uchar_t *optptr, int len, ppp_protoinfo_t *protoinfo)
544*7c478bd9Sstevel@tonic-gate {
545*7c478bd9Sstevel@tonic-gate 	cp_optinfo_t *optinfo;
546*7c478bd9Sstevel@tonic-gate 	cp_optinfo_t *optinfo_ptr;
547*7c478bd9Sstevel@tonic-gate 	uint8_t optlen;
548*7c478bd9Sstevel@tonic-gate 	uint8_t opttype;
549*7c478bd9Sstevel@tonic-gate 
550*7c478bd9Sstevel@tonic-gate 	switch (protoinfo->proto) {
551*7c478bd9Sstevel@tonic-gate 	case PPP_LCP:
552*7c478bd9Sstevel@tonic-gate 		optinfo = lcp_optinfo;
553*7c478bd9Sstevel@tonic-gate 		break;
554*7c478bd9Sstevel@tonic-gate 	case PPP_IPCP:
555*7c478bd9Sstevel@tonic-gate 		optinfo = ipcp_optinfo;
556*7c478bd9Sstevel@tonic-gate 		break;
557*7c478bd9Sstevel@tonic-gate 	case PPP_IPV6CP:
558*7c478bd9Sstevel@tonic-gate 		optinfo = ipv6cp_optinfo;
559*7c478bd9Sstevel@tonic-gate 		break;
560*7c478bd9Sstevel@tonic-gate 	case PPP_CCP:
561*7c478bd9Sstevel@tonic-gate 		optinfo = ccp_optinfo;
562*7c478bd9Sstevel@tonic-gate 		break;
563*7c478bd9Sstevel@tonic-gate 	case PPP_ECP:
564*7c478bd9Sstevel@tonic-gate 		optinfo = ecp_optinfo;
565*7c478bd9Sstevel@tonic-gate 		break;
566*7c478bd9Sstevel@tonic-gate 	case PPP_MUXCP:
567*7c478bd9Sstevel@tonic-gate 		optinfo = muxcp_optinfo;
568*7c478bd9Sstevel@tonic-gate 		break;
569*7c478bd9Sstevel@tonic-gate 	default:
570*7c478bd9Sstevel@tonic-gate 		return (len);
571*7c478bd9Sstevel@tonic-gate 		break;
572*7c478bd9Sstevel@tonic-gate 	}
573*7c478bd9Sstevel@tonic-gate 
574*7c478bd9Sstevel@tonic-gate 	if (len >= 2) {
575*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "%s Configuration Options",
576*7c478bd9Sstevel@tonic-gate 		    protoinfo->name);
577*7c478bd9Sstevel@tonic-gate 		show_space();
578*7c478bd9Sstevel@tonic-gate 	}
579*7c478bd9Sstevel@tonic-gate 
580*7c478bd9Sstevel@tonic-gate 	while (len >= 2) {
581*7c478bd9Sstevel@tonic-gate 		GETINT8(opttype, optptr);
582*7c478bd9Sstevel@tonic-gate 		GETINT8(optlen, optptr);
583*7c478bd9Sstevel@tonic-gate 
584*7c478bd9Sstevel@tonic-gate 		optinfo_ptr = ppp_getoptinfo(optinfo, opttype);
585*7c478bd9Sstevel@tonic-gate 
586*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Option Type = %d (%s)", opttype,
587*7c478bd9Sstevel@tonic-gate 		    optinfo_ptr->opt_name);
588*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Option Length = %d", optlen);
589*7c478bd9Sstevel@tonic-gate 
590*7c478bd9Sstevel@tonic-gate 		/*
591*7c478bd9Sstevel@tonic-gate 		 * Don't continue if there isn't enough data to
592*7c478bd9Sstevel@tonic-gate 		 * contain this option, or if this type of option
593*7c478bd9Sstevel@tonic-gate 		 * should contain more data than the length field
594*7c478bd9Sstevel@tonic-gate 		 * claims there is.
595*7c478bd9Sstevel@tonic-gate 		 */
596*7c478bd9Sstevel@tonic-gate 		if (optlen > len || optlen < optinfo_ptr->opt_minsize) {
597*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0),
598*7c478bd9Sstevel@tonic-gate 			    "Warning: Incomplete Option");
599*7c478bd9Sstevel@tonic-gate 			show_space();
600*7c478bd9Sstevel@tonic-gate 			break;
601*7c478bd9Sstevel@tonic-gate 		}
602*7c478bd9Sstevel@tonic-gate 
603*7c478bd9Sstevel@tonic-gate 		if (optinfo_ptr->opt_formatdata != NULL) {
604*7c478bd9Sstevel@tonic-gate 			optinfo_ptr->opt_formatdata(optptr,
605*7c478bd9Sstevel@tonic-gate 			    MIN(optlen - 2, len - 2));
606*7c478bd9Sstevel@tonic-gate 		}
607*7c478bd9Sstevel@tonic-gate 
608*7c478bd9Sstevel@tonic-gate 		len -= optlen;
609*7c478bd9Sstevel@tonic-gate 		optptr += optlen - 2;
610*7c478bd9Sstevel@tonic-gate 
611*7c478bd9Sstevel@tonic-gate 		show_space();
612*7c478bd9Sstevel@tonic-gate 	}
613*7c478bd9Sstevel@tonic-gate 
614*7c478bd9Sstevel@tonic-gate 	return (len);
615*7c478bd9Sstevel@tonic-gate }
616*7c478bd9Sstevel@tonic-gate 
617*7c478bd9Sstevel@tonic-gate static int
interpret_ppp_chap(int flags,uchar_t * data,int len,ppp_protoinfo_t * protoinfo)618*7c478bd9Sstevel@tonic-gate interpret_ppp_chap(int flags, uchar_t *data, int len,
619*7c478bd9Sstevel@tonic-gate     ppp_protoinfo_t *protoinfo)
620*7c478bd9Sstevel@tonic-gate {
621*7c478bd9Sstevel@tonic-gate 	uint8_t code;
622*7c478bd9Sstevel@tonic-gate 	uint8_t id;
623*7c478bd9Sstevel@tonic-gate 	char *codestr;
624*7c478bd9Sstevel@tonic-gate 	uint16_t length;
625*7c478bd9Sstevel@tonic-gate 	int lengthleft;
626*7c478bd9Sstevel@tonic-gate 	uchar_t *datap = data;
627*7c478bd9Sstevel@tonic-gate 
628*7c478bd9Sstevel@tonic-gate 
629*7c478bd9Sstevel@tonic-gate 	if (len < sizeof (ppp_pkt_t))
630*7c478bd9Sstevel@tonic-gate 		return (len);
631*7c478bd9Sstevel@tonic-gate 
632*7c478bd9Sstevel@tonic-gate 	GETINT8(code, datap);
633*7c478bd9Sstevel@tonic-gate 	GETINT8(id, datap);
634*7c478bd9Sstevel@tonic-gate 	GETINT8(length, datap);
635*7c478bd9Sstevel@tonic-gate 
636*7c478bd9Sstevel@tonic-gate 	if (code <= MAX_CHAPCODE)
637*7c478bd9Sstevel@tonic-gate 		codestr = chap_codearray[code];
638*7c478bd9Sstevel@tonic-gate 	else
639*7c478bd9Sstevel@tonic-gate 		codestr = "";
640*7c478bd9Sstevel@tonic-gate 
641*7c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
642*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_sum_line(),
643*7c478bd9Sstevel@tonic-gate 		    "%s%s", protoinfo->prefix, codestr);
644*7c478bd9Sstevel@tonic-gate 	} else { /* (flags & F_DTAIL) */
645*7c478bd9Sstevel@tonic-gate 		show_header(protoinfo->prefix, protoinfo->description, len);
646*7c478bd9Sstevel@tonic-gate 		show_space();
647*7c478bd9Sstevel@tonic-gate 
648*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Code = %d %s", code, codestr);
649*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Identifier = %d", id);
650*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Length = %d", length);
651*7c478bd9Sstevel@tonic-gate 
652*7c478bd9Sstevel@tonic-gate 		show_space();
653*7c478bd9Sstevel@tonic-gate 
654*7c478bd9Sstevel@tonic-gate 		if (len < length)
655*7c478bd9Sstevel@tonic-gate 			return (len);
656*7c478bd9Sstevel@tonic-gate 
657*7c478bd9Sstevel@tonic-gate 		lengthleft = len - sizeof (ppp_pkt_t);
658*7c478bd9Sstevel@tonic-gate 
659*7c478bd9Sstevel@tonic-gate 		switch (code) {
660*7c478bd9Sstevel@tonic-gate 		case CODE_CHALLENGE:
661*7c478bd9Sstevel@tonic-gate 		case CODE_RESPONSE: {
662*7c478bd9Sstevel@tonic-gate 			uint8_t value_size;
663*7c478bd9Sstevel@tonic-gate 			uint16_t peername_size;
664*7c478bd9Sstevel@tonic-gate 
665*7c478bd9Sstevel@tonic-gate 			if (lengthleft < sizeof (value_size))
666*7c478bd9Sstevel@tonic-gate 				break;
667*7c478bd9Sstevel@tonic-gate 
668*7c478bd9Sstevel@tonic-gate 			GETINT8(value_size, datap);
669*7c478bd9Sstevel@tonic-gate 			lengthleft -= sizeof (value_size);
670*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Value-Size = %d",
671*7c478bd9Sstevel@tonic-gate 			    value_size);
672*7c478bd9Sstevel@tonic-gate 
673*7c478bd9Sstevel@tonic-gate 			if (lengthleft < sizeof (peername_size))
674*7c478bd9Sstevel@tonic-gate 				break;
675*7c478bd9Sstevel@tonic-gate 			peername_size = MIN(length - sizeof (ppp_pkt_t) -
676*7c478bd9Sstevel@tonic-gate 			    value_size, lengthleft);
677*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Name = %.*s",
678*7c478bd9Sstevel@tonic-gate 			    peername_size, datap + value_size);
679*7c478bd9Sstevel@tonic-gate 
680*7c478bd9Sstevel@tonic-gate 			break;
681*7c478bd9Sstevel@tonic-gate 		}
682*7c478bd9Sstevel@tonic-gate 		case CODE_SUCCESS:
683*7c478bd9Sstevel@tonic-gate 		case CODE_FAILURE: {
684*7c478bd9Sstevel@tonic-gate 			uint16_t message_size = MIN(length - sizeof (ppp_pkt_t),
685*7c478bd9Sstevel@tonic-gate 			    lengthleft);
686*7c478bd9Sstevel@tonic-gate 
687*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Message = %.*s",
688*7c478bd9Sstevel@tonic-gate 			    message_size, datap);
689*7c478bd9Sstevel@tonic-gate 			break;
690*7c478bd9Sstevel@tonic-gate 		}
691*7c478bd9Sstevel@tonic-gate 		default:
692*7c478bd9Sstevel@tonic-gate 			break;
693*7c478bd9Sstevel@tonic-gate 		}
694*7c478bd9Sstevel@tonic-gate 	}
695*7c478bd9Sstevel@tonic-gate 
696*7c478bd9Sstevel@tonic-gate 	show_space();
697*7c478bd9Sstevel@tonic-gate 	len -= length;
698*7c478bd9Sstevel@tonic-gate 	return (len);
699*7c478bd9Sstevel@tonic-gate }
700*7c478bd9Sstevel@tonic-gate 
701*7c478bd9Sstevel@tonic-gate static int
interpret_ppp_pap(int flags,uchar_t * data,int len,ppp_protoinfo_t * protoinfo)702*7c478bd9Sstevel@tonic-gate interpret_ppp_pap(int flags, uchar_t *data, int len,
703*7c478bd9Sstevel@tonic-gate     ppp_protoinfo_t *protoinfo)
704*7c478bd9Sstevel@tonic-gate {
705*7c478bd9Sstevel@tonic-gate 	uint8_t code;
706*7c478bd9Sstevel@tonic-gate 	uint8_t id;
707*7c478bd9Sstevel@tonic-gate 	char *codestr;
708*7c478bd9Sstevel@tonic-gate 	uint16_t length;
709*7c478bd9Sstevel@tonic-gate 	int lengthleft;
710*7c478bd9Sstevel@tonic-gate 	uchar_t *datap = data;
711*7c478bd9Sstevel@tonic-gate 
712*7c478bd9Sstevel@tonic-gate 	if (len < sizeof (ppp_pkt_t))
713*7c478bd9Sstevel@tonic-gate 		return (len);
714*7c478bd9Sstevel@tonic-gate 
715*7c478bd9Sstevel@tonic-gate 	GETINT8(code, datap);
716*7c478bd9Sstevel@tonic-gate 	GETINT8(id, datap);
717*7c478bd9Sstevel@tonic-gate 	GETINT16(length, datap);
718*7c478bd9Sstevel@tonic-gate 
719*7c478bd9Sstevel@tonic-gate 	lengthleft = len - sizeof (ppp_pkt_t);
720*7c478bd9Sstevel@tonic-gate 
721*7c478bd9Sstevel@tonic-gate 	if (code <= MAX_PAPCODE)
722*7c478bd9Sstevel@tonic-gate 		codestr = pap_codearray[code];
723*7c478bd9Sstevel@tonic-gate 	else
724*7c478bd9Sstevel@tonic-gate 		codestr = "";
725*7c478bd9Sstevel@tonic-gate 
726*7c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
727*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_sum_line(),
728*7c478bd9Sstevel@tonic-gate 		    "%s%s", protoinfo->prefix, codestr);
729*7c478bd9Sstevel@tonic-gate 	} else { /* (flags & F_DTAIL) */
730*7c478bd9Sstevel@tonic-gate 		show_header(protoinfo->prefix, protoinfo->description, len);
731*7c478bd9Sstevel@tonic-gate 		show_space();
732*7c478bd9Sstevel@tonic-gate 
733*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Code = %d %s", code, codestr);
734*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Identifier = %d", id);
735*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Length = %d", length);
736*7c478bd9Sstevel@tonic-gate 
737*7c478bd9Sstevel@tonic-gate 		show_space();
738*7c478bd9Sstevel@tonic-gate 
739*7c478bd9Sstevel@tonic-gate 		if (len < length)
740*7c478bd9Sstevel@tonic-gate 			return (len);
741*7c478bd9Sstevel@tonic-gate 
742*7c478bd9Sstevel@tonic-gate 		switch (code) {
743*7c478bd9Sstevel@tonic-gate 		case CODE_AUTHREQ: {
744*7c478bd9Sstevel@tonic-gate 			uint8_t fieldlen;
745*7c478bd9Sstevel@tonic-gate 
746*7c478bd9Sstevel@tonic-gate 			if (lengthleft < sizeof (fieldlen))
747*7c478bd9Sstevel@tonic-gate 				break;
748*7c478bd9Sstevel@tonic-gate 			GETINT8(fieldlen, datap);
749*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Peer-Id Length = %d",
750*7c478bd9Sstevel@tonic-gate 			    fieldlen);
751*7c478bd9Sstevel@tonic-gate 			lengthleft -= sizeof (fieldlen);
752*7c478bd9Sstevel@tonic-gate 
753*7c478bd9Sstevel@tonic-gate 			if (lengthleft < fieldlen)
754*7c478bd9Sstevel@tonic-gate 				break;
755*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Peer-Id = %.*s",
756*7c478bd9Sstevel@tonic-gate 			    fieldlen, datap);
757*7c478bd9Sstevel@tonic-gate 			lengthleft -= fieldlen;
758*7c478bd9Sstevel@tonic-gate 
759*7c478bd9Sstevel@tonic-gate 			datap += fieldlen;
760*7c478bd9Sstevel@tonic-gate 
761*7c478bd9Sstevel@tonic-gate 			if (lengthleft < sizeof (fieldlen))
762*7c478bd9Sstevel@tonic-gate 				break;
763*7c478bd9Sstevel@tonic-gate 			GETINT8(fieldlen, datap);
764*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Password Length = %d",
765*7c478bd9Sstevel@tonic-gate 			    fieldlen);
766*7c478bd9Sstevel@tonic-gate 			lengthleft -= sizeof (fieldlen);
767*7c478bd9Sstevel@tonic-gate 
768*7c478bd9Sstevel@tonic-gate 			if (lengthleft < fieldlen)
769*7c478bd9Sstevel@tonic-gate 				break;
770*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Password = %.*s",
771*7c478bd9Sstevel@tonic-gate 			    fieldlen, datap);
772*7c478bd9Sstevel@tonic-gate 
773*7c478bd9Sstevel@tonic-gate 			break;
774*7c478bd9Sstevel@tonic-gate 		}
775*7c478bd9Sstevel@tonic-gate 		case CODE_AUTHACK:
776*7c478bd9Sstevel@tonic-gate 		case CODE_AUTHNAK: {
777*7c478bd9Sstevel@tonic-gate 			uint8_t msglen;
778*7c478bd9Sstevel@tonic-gate 
779*7c478bd9Sstevel@tonic-gate 			if (lengthleft < sizeof (msglen))
780*7c478bd9Sstevel@tonic-gate 				break;
781*7c478bd9Sstevel@tonic-gate 			GETINT8(msglen, datap);
782*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Msg-Length = %d",
783*7c478bd9Sstevel@tonic-gate 			    msglen);
784*7c478bd9Sstevel@tonic-gate 			lengthleft -= sizeof (msglen);
785*7c478bd9Sstevel@tonic-gate 
786*7c478bd9Sstevel@tonic-gate 			if (lengthleft < msglen)
787*7c478bd9Sstevel@tonic-gate 				break;
788*7c478bd9Sstevel@tonic-gate 			(void) sprintf(get_line(0, 0), "Message = %.*s",
789*7c478bd9Sstevel@tonic-gate 			    msglen, datap);
790*7c478bd9Sstevel@tonic-gate 
791*7c478bd9Sstevel@tonic-gate 			break;
792*7c478bd9Sstevel@tonic-gate 		}
793*7c478bd9Sstevel@tonic-gate 		default:
794*7c478bd9Sstevel@tonic-gate 			break;
795*7c478bd9Sstevel@tonic-gate 		}
796*7c478bd9Sstevel@tonic-gate 	}
797*7c478bd9Sstevel@tonic-gate 
798*7c478bd9Sstevel@tonic-gate 	show_space();
799*7c478bd9Sstevel@tonic-gate 	len -= length;
800*7c478bd9Sstevel@tonic-gate 	return (len);
801*7c478bd9Sstevel@tonic-gate }
802*7c478bd9Sstevel@tonic-gate 
803*7c478bd9Sstevel@tonic-gate 
804*7c478bd9Sstevel@tonic-gate static int
interpret_ppp_lqr(int flags,uchar_t * data,int len,ppp_protoinfo_t * protoinfo)805*7c478bd9Sstevel@tonic-gate interpret_ppp_lqr(int flags, uchar_t *data, int len,
806*7c478bd9Sstevel@tonic-gate     ppp_protoinfo_t *protoinfo)
807*7c478bd9Sstevel@tonic-gate {
808*7c478bd9Sstevel@tonic-gate 	lqr_pkt_t lqr_pkt;
809*7c478bd9Sstevel@tonic-gate 	if (len < sizeof (lqr_pkt_t))
810*7c478bd9Sstevel@tonic-gate 		return (len);
811*7c478bd9Sstevel@tonic-gate 
812*7c478bd9Sstevel@tonic-gate 	(void) memcpy(&lqr_pkt, data, sizeof (lqr_pkt_t));
813*7c478bd9Sstevel@tonic-gate 
814*7c478bd9Sstevel@tonic-gate 	if (flags & F_SUM) {
815*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_sum_line(), protoinfo->prefix);
816*7c478bd9Sstevel@tonic-gate 	} else { /* (flags & F_DTAIL) */
817*7c478bd9Sstevel@tonic-gate 		show_header(protoinfo->prefix, protoinfo->description, len);
818*7c478bd9Sstevel@tonic-gate 		show_space();
819*7c478bd9Sstevel@tonic-gate 
820*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Magic-Number =   0x%08x",
821*7c478bd9Sstevel@tonic-gate 		    ntohl(lqr_pkt.lqr_magic));
822*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "LastOutLQRs =    %d",
823*7c478bd9Sstevel@tonic-gate 		    ntohl(lqr_pkt.lqr_lastoutlqrs));
824*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "LastOutPackets = %d",
825*7c478bd9Sstevel@tonic-gate 		    ntohl(lqr_pkt.lqr_lastoutpackets));
826*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "LastOutOctets =  %d",
827*7c478bd9Sstevel@tonic-gate 		    ntohl(lqr_pkt.lqr_lastoutoctets));
828*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "PeerInLQRs =     %d",
829*7c478bd9Sstevel@tonic-gate 		    ntohl(lqr_pkt.lqr_peerinlqrs));
830*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "PeerInPackets =  %d",
831*7c478bd9Sstevel@tonic-gate 		    ntohl(lqr_pkt.lqr_peerinpackets));
832*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "PeerInDiscards = %d",
833*7c478bd9Sstevel@tonic-gate 		    ntohl(lqr_pkt.lqr_peerindiscards));
834*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "PeerInErrors =   %d",
835*7c478bd9Sstevel@tonic-gate 		    ntohl(lqr_pkt.lqr_peerinerrors));
836*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "PeerInOctets =   %d",
837*7c478bd9Sstevel@tonic-gate 		    ntohl(lqr_pkt.lqr_peerinoctets));
838*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "PeerOutLQRs =    %d",
839*7c478bd9Sstevel@tonic-gate 		    ntohl(lqr_pkt.lqr_peeroutlqrs));
840*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "PeerOutPackets = %d",
841*7c478bd9Sstevel@tonic-gate 		    ntohl(lqr_pkt.lqr_peeroutpackets));
842*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "PeerOutOctets =  %d",
843*7c478bd9Sstevel@tonic-gate 		    ntohl(lqr_pkt.lqr_peeroutoctets));
844*7c478bd9Sstevel@tonic-gate 
845*7c478bd9Sstevel@tonic-gate 		show_space();
846*7c478bd9Sstevel@tonic-gate 	}
847*7c478bd9Sstevel@tonic-gate 
848*7c478bd9Sstevel@tonic-gate 	len -= sizeof (lqr_pkt_t);
849*7c478bd9Sstevel@tonic-gate 	return (len);
850*7c478bd9Sstevel@tonic-gate }
851*7c478bd9Sstevel@tonic-gate 
852*7c478bd9Sstevel@tonic-gate static ppp_protoinfo_t *
ppp_getprotoinfo(uint16_t proto)853*7c478bd9Sstevel@tonic-gate ppp_getprotoinfo(uint16_t proto)
854*7c478bd9Sstevel@tonic-gate {
855*7c478bd9Sstevel@tonic-gate 	ppp_protoinfo_t *protoinfo_ptr = &protoinfo_array[0];
856*7c478bd9Sstevel@tonic-gate 
857*7c478bd9Sstevel@tonic-gate 	while (protoinfo_ptr->proto != proto && protoinfo_ptr->proto != 0) {
858*7c478bd9Sstevel@tonic-gate 		protoinfo_ptr++;
859*7c478bd9Sstevel@tonic-gate 	}
860*7c478bd9Sstevel@tonic-gate 
861*7c478bd9Sstevel@tonic-gate 	return (protoinfo_ptr);
862*7c478bd9Sstevel@tonic-gate }
863*7c478bd9Sstevel@tonic-gate 
864*7c478bd9Sstevel@tonic-gate 
865*7c478bd9Sstevel@tonic-gate static cp_optinfo_t *
ppp_getoptinfo(cp_optinfo_t optinfo_list[],uint16_t opt_type)866*7c478bd9Sstevel@tonic-gate ppp_getoptinfo(cp_optinfo_t optinfo_list[], uint16_t opt_type)
867*7c478bd9Sstevel@tonic-gate {
868*7c478bd9Sstevel@tonic-gate 	cp_optinfo_t *optinfo_ptr = &optinfo_list[0];
869*7c478bd9Sstevel@tonic-gate 
870*7c478bd9Sstevel@tonic-gate 	while (optinfo_ptr->opt_type != opt_type &&
871*7c478bd9Sstevel@tonic-gate 	    optinfo_ptr->opt_name != unknown_string) {
872*7c478bd9Sstevel@tonic-gate 		optinfo_ptr++;
873*7c478bd9Sstevel@tonic-gate 	}
874*7c478bd9Sstevel@tonic-gate 
875*7c478bd9Sstevel@tonic-gate 	return (optinfo_ptr);
876*7c478bd9Sstevel@tonic-gate }
877*7c478bd9Sstevel@tonic-gate 
878*7c478bd9Sstevel@tonic-gate 
879*7c478bd9Sstevel@tonic-gate /*
880*7c478bd9Sstevel@tonic-gate  * Below are the functions which parse control protocol configuration
881*7c478bd9Sstevel@tonic-gate  * options.  The first argument to these functions (optdata) points to the
882*7c478bd9Sstevel@tonic-gate  * first byte of the option after the length field.  The second argument
883*7c478bd9Sstevel@tonic-gate  * (size) is the number of bytes in the option after the length field
884*7c478bd9Sstevel@tonic-gate  * (length - 2).
885*7c478bd9Sstevel@tonic-gate  */
886*7c478bd9Sstevel@tonic-gate 
887*7c478bd9Sstevel@tonic-gate /*
888*7c478bd9Sstevel@tonic-gate  * The format of the Vendor-Specific option (rfc2153) is:
889*7c478bd9Sstevel@tonic-gate  *
890*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
891*7c478bd9Sstevel@tonic-gate  * |     Type      |    Length     |              OUI
892*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
893*7c478bd9Sstevel@tonic-gate  *        ...      |     Kind      |  Value(s) ...
894*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
895*7c478bd9Sstevel@tonic-gate  */
896*7c478bd9Sstevel@tonic-gate /*ARGSUSED1*/
897*7c478bd9Sstevel@tonic-gate static void
opt_format_vendor(uchar_t * optdata,uint8_t size)898*7c478bd9Sstevel@tonic-gate opt_format_vendor(uchar_t *optdata, uint8_t size)
899*7c478bd9Sstevel@tonic-gate {
900*7c478bd9Sstevel@tonic-gate 	uint32_t oui;
901*7c478bd9Sstevel@tonic-gate 	char *ouistr;
902*7c478bd9Sstevel@tonic-gate 	uint8_t kind;
903*7c478bd9Sstevel@tonic-gate 
904*7c478bd9Sstevel@tonic-gate 	GETINT32(oui, optdata);
905*7c478bd9Sstevel@tonic-gate 	kind = oui & 0x000000ff;
906*7c478bd9Sstevel@tonic-gate 	oui >>= 8;
907*7c478bd9Sstevel@tonic-gate 
908*7c478bd9Sstevel@tonic-gate 	ouistr = ether_ouiname(oui);
909*7c478bd9Sstevel@tonic-gate 	if (ouistr == NULL)
910*7c478bd9Sstevel@tonic-gate 		ouistr = unknown_string;
911*7c478bd9Sstevel@tonic-gate 
912*7c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "OUI = 0x%06x (%s)", oui, ouistr);
913*7c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "Kind = %d", kind);
914*7c478bd9Sstevel@tonic-gate }
915*7c478bd9Sstevel@tonic-gate 
916*7c478bd9Sstevel@tonic-gate /*
917*7c478bd9Sstevel@tonic-gate  * The format of the MRU option (rfc1661) is:
918*7c478bd9Sstevel@tonic-gate  *
919*7c478bd9Sstevel@tonic-gate  *  0                   1                   2                   3
920*7c478bd9Sstevel@tonic-gate  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
921*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
922*7c478bd9Sstevel@tonic-gate  * |     Type      |    Length     |      Maximum-Receive-Unit     |
923*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
924*7c478bd9Sstevel@tonic-gate  */
925*7c478bd9Sstevel@tonic-gate /*ARGSUSED1*/
926*7c478bd9Sstevel@tonic-gate static void
opt_format_mru(uchar_t * optdata,uint8_t size)927*7c478bd9Sstevel@tonic-gate opt_format_mru(uchar_t *optdata, uint8_t size)
928*7c478bd9Sstevel@tonic-gate {
929*7c478bd9Sstevel@tonic-gate 	uint16_t mru;
930*7c478bd9Sstevel@tonic-gate 
931*7c478bd9Sstevel@tonic-gate 	GETINT16(mru, optdata);
932*7c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "MRU = %d", mru);
933*7c478bd9Sstevel@tonic-gate }
934*7c478bd9Sstevel@tonic-gate 
935*7c478bd9Sstevel@tonic-gate /*
936*7c478bd9Sstevel@tonic-gate  * The format of the accm option (rfc1662) is:
937*7c478bd9Sstevel@tonic-gate  *
938*7c478bd9Sstevel@tonic-gate  *  0                   1                   2                   3
939*7c478bd9Sstevel@tonic-gate  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
940*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
941*7c478bd9Sstevel@tonic-gate  * |     Type      |    Length     |               ACCM
942*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
943*7c478bd9Sstevel@tonic-gate  *           ACCM (cont)           |
944*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
945*7c478bd9Sstevel@tonic-gate  */
946*7c478bd9Sstevel@tonic-gate /*ARGSUSED1*/
947*7c478bd9Sstevel@tonic-gate static void
opt_format_accm(uchar_t * optdata,uint8_t size)948*7c478bd9Sstevel@tonic-gate opt_format_accm(uchar_t *optdata, uint8_t size)
949*7c478bd9Sstevel@tonic-gate {
950*7c478bd9Sstevel@tonic-gate 	uint32_t accm;
951*7c478bd9Sstevel@tonic-gate 
952*7c478bd9Sstevel@tonic-gate 	GETINT32(accm, optdata);
953*7c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "ACCM = 0x%08x", accm);
954*7c478bd9Sstevel@tonic-gate }
955*7c478bd9Sstevel@tonic-gate 
956*7c478bd9Sstevel@tonic-gate /*
957*7c478bd9Sstevel@tonic-gate  * The format of the Authentication-Protocol option (rfc1661) is:
958*7c478bd9Sstevel@tonic-gate  *
959*7c478bd9Sstevel@tonic-gate  *  0                   1                   2                   3
960*7c478bd9Sstevel@tonic-gate  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
961*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
962*7c478bd9Sstevel@tonic-gate  * |     Type      |    Length     |     Authentication-Protocol   |
963*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
964*7c478bd9Sstevel@tonic-gate  * |    Data ...
965*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+
966*7c478bd9Sstevel@tonic-gate  *
967*7c478bd9Sstevel@tonic-gate  * For PAP (rfc1334), there is no data.  For CHAP (rfc1994), there is one
968*7c478bd9Sstevel@tonic-gate  * byte of data representing the algorithm.
969*7c478bd9Sstevel@tonic-gate  */
970*7c478bd9Sstevel@tonic-gate static void
opt_format_authproto(uchar_t * optdata,uint8_t size)971*7c478bd9Sstevel@tonic-gate opt_format_authproto(uchar_t *optdata, uint8_t size)
972*7c478bd9Sstevel@tonic-gate {
973*7c478bd9Sstevel@tonic-gate 	uint16_t proto;
974*7c478bd9Sstevel@tonic-gate 	ppp_protoinfo_t *auth_protoinfo;
975*7c478bd9Sstevel@tonic-gate 
976*7c478bd9Sstevel@tonic-gate 	GETINT16(proto, optdata);
977*7c478bd9Sstevel@tonic-gate 
978*7c478bd9Sstevel@tonic-gate 	auth_protoinfo = ppp_getprotoinfo(proto);
979*7c478bd9Sstevel@tonic-gate 
980*7c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "Protocol = 0x%x (%s)", proto,
981*7c478bd9Sstevel@tonic-gate 	    auth_protoinfo->name);
982*7c478bd9Sstevel@tonic-gate 
983*7c478bd9Sstevel@tonic-gate 	switch (proto) {
984*7c478bd9Sstevel@tonic-gate 	case PPP_CHAP: {
985*7c478bd9Sstevel@tonic-gate 		uint8_t algo;
986*7c478bd9Sstevel@tonic-gate 		char *algostr;
987*7c478bd9Sstevel@tonic-gate 
988*7c478bd9Sstevel@tonic-gate 		if (size < sizeof (proto) + sizeof (algo))
989*7c478bd9Sstevel@tonic-gate 			return;
990*7c478bd9Sstevel@tonic-gate 
991*7c478bd9Sstevel@tonic-gate 		GETINT8(algo, optdata);
992*7c478bd9Sstevel@tonic-gate 		switch (algo) {
993*7c478bd9Sstevel@tonic-gate 		case 5:
994*7c478bd9Sstevel@tonic-gate 			algostr = "CHAP with MD5";
995*7c478bd9Sstevel@tonic-gate 			break;
996*7c478bd9Sstevel@tonic-gate 		case 128:
997*7c478bd9Sstevel@tonic-gate 			algostr = "MS-CHAP";
998*7c478bd9Sstevel@tonic-gate 			break;
999*7c478bd9Sstevel@tonic-gate 		case 129:
1000*7c478bd9Sstevel@tonic-gate 			algostr = "MS-CHAP-2";
1001*7c478bd9Sstevel@tonic-gate 			break;
1002*7c478bd9Sstevel@tonic-gate 		default:
1003*7c478bd9Sstevel@tonic-gate 			algostr = unknown_string;
1004*7c478bd9Sstevel@tonic-gate 			break;
1005*7c478bd9Sstevel@tonic-gate 		}
1006*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Algorithm = %d (%s)", algo,
1007*7c478bd9Sstevel@tonic-gate 		    algostr);
1008*7c478bd9Sstevel@tonic-gate 		break;
1009*7c478bd9Sstevel@tonic-gate 	}
1010*7c478bd9Sstevel@tonic-gate 	default:
1011*7c478bd9Sstevel@tonic-gate 		break;
1012*7c478bd9Sstevel@tonic-gate 	}
1013*7c478bd9Sstevel@tonic-gate }
1014*7c478bd9Sstevel@tonic-gate 
1015*7c478bd9Sstevel@tonic-gate /*
1016*7c478bd9Sstevel@tonic-gate  * The format of the Quality Protocol option (rfc1661) is:
1017*7c478bd9Sstevel@tonic-gate  *
1018*7c478bd9Sstevel@tonic-gate  *  0                   1                   2                   3
1019*7c478bd9Sstevel@tonic-gate  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1020*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1021*7c478bd9Sstevel@tonic-gate  * |     Type      |    Length     |        Quality-Protocol       |
1022*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1023*7c478bd9Sstevel@tonic-gate  * |    Data ...
1024*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+
1025*7c478bd9Sstevel@tonic-gate  *
1026*7c478bd9Sstevel@tonic-gate  * For LQR, the data consists of a 4 byte reporting period.
1027*7c478bd9Sstevel@tonic-gate  */
1028*7c478bd9Sstevel@tonic-gate static void
opt_format_qualproto(uchar_t * optdata,uint8_t size)1029*7c478bd9Sstevel@tonic-gate opt_format_qualproto(uchar_t *optdata, uint8_t size)
1030*7c478bd9Sstevel@tonic-gate {
1031*7c478bd9Sstevel@tonic-gate 	uint16_t proto;
1032*7c478bd9Sstevel@tonic-gate 	ppp_protoinfo_t *qual_protoinfo;
1033*7c478bd9Sstevel@tonic-gate 
1034*7c478bd9Sstevel@tonic-gate 	GETINT16(proto, optdata);
1035*7c478bd9Sstevel@tonic-gate 
1036*7c478bd9Sstevel@tonic-gate 	qual_protoinfo = ppp_getprotoinfo(proto);
1037*7c478bd9Sstevel@tonic-gate 
1038*7c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "Protocol = 0x%x (%s)", proto,
1039*7c478bd9Sstevel@tonic-gate 	    qual_protoinfo->name);
1040*7c478bd9Sstevel@tonic-gate 
1041*7c478bd9Sstevel@tonic-gate 	switch (proto) {
1042*7c478bd9Sstevel@tonic-gate 	case PPP_LQR: {
1043*7c478bd9Sstevel@tonic-gate 		uint32_t reporting_period;
1044*7c478bd9Sstevel@tonic-gate 
1045*7c478bd9Sstevel@tonic-gate 		if (size < sizeof (proto) + sizeof (reporting_period))
1046*7c478bd9Sstevel@tonic-gate 			return;
1047*7c478bd9Sstevel@tonic-gate 
1048*7c478bd9Sstevel@tonic-gate 		GETINT32(reporting_period, optdata);
1049*7c478bd9Sstevel@tonic-gate 		(void) sprintf(get_line(0, 0), "Reporting-Period = %d",
1050*7c478bd9Sstevel@tonic-gate 		    reporting_period);
1051*7c478bd9Sstevel@tonic-gate 		break;
1052*7c478bd9Sstevel@tonic-gate 	}
1053*7c478bd9Sstevel@tonic-gate 	default:
1054*7c478bd9Sstevel@tonic-gate 		break;
1055*7c478bd9Sstevel@tonic-gate 	}
1056*7c478bd9Sstevel@tonic-gate }
1057*7c478bd9Sstevel@tonic-gate 
1058*7c478bd9Sstevel@tonic-gate /*
1059*7c478bd9Sstevel@tonic-gate  * The format of the Magic Number option (rfc1661) is:
1060*7c478bd9Sstevel@tonic-gate  *
1061*7c478bd9Sstevel@tonic-gate  *  0                   1                   2                   3
1062*7c478bd9Sstevel@tonic-gate  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1063*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1064*7c478bd9Sstevel@tonic-gate  * |     Type      |    Length     |          Magic-Number
1065*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1066*7c478bd9Sstevel@tonic-gate  *       Magic-Number (cont)       |
1067*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1068*7c478bd9Sstevel@tonic-gate  */
1069*7c478bd9Sstevel@tonic-gate /*ARGSUSED1*/
1070*7c478bd9Sstevel@tonic-gate static void
opt_format_magicnum(uchar_t * optdata,uint8_t size)1071*7c478bd9Sstevel@tonic-gate opt_format_magicnum(uchar_t *optdata, uint8_t size)
1072*7c478bd9Sstevel@tonic-gate {
1073*7c478bd9Sstevel@tonic-gate 	uint32_t magicnum;
1074*7c478bd9Sstevel@tonic-gate 
1075*7c478bd9Sstevel@tonic-gate 	GETINT32(magicnum, optdata);
1076*7c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "Magic Number = 0x%08x", magicnum);
1077*7c478bd9Sstevel@tonic-gate }
1078*7c478bd9Sstevel@tonic-gate 
1079*7c478bd9Sstevel@tonic-gate /*
1080*7c478bd9Sstevel@tonic-gate  * The format of the FCS-Alternatives option (rfc1570) is:
1081*7c478bd9Sstevel@tonic-gate  *
1082*7c478bd9Sstevel@tonic-gate  *  0                   1                   2
1083*7c478bd9Sstevel@tonic-gate  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
1084*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1085*7c478bd9Sstevel@tonic-gate  * |     Type      |    Length     |    Options    |
1086*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1087*7c478bd9Sstevel@tonic-gate  */
1088*7c478bd9Sstevel@tonic-gate /*ARGSUSED1*/
1089*7c478bd9Sstevel@tonic-gate static void
opt_format_fcs(uchar_t * optdata,uint8_t size)1090*7c478bd9Sstevel@tonic-gate opt_format_fcs(uchar_t *optdata, uint8_t size)
1091*7c478bd9Sstevel@tonic-gate {
1092*7c478bd9Sstevel@tonic-gate 	uint8_t options;
1093*7c478bd9Sstevel@tonic-gate 
1094*7c478bd9Sstevel@tonic-gate 	GETINT8(options, optdata);
1095*7c478bd9Sstevel@tonic-gate 
1096*7c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "Options = 0x%02x", options);
1097*7c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "     %s",
1098*7c478bd9Sstevel@tonic-gate 	    getflag(options, 0x01, "NULL FCS", ""));
1099*7c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "     %s",
1100*7c478bd9Sstevel@tonic-gate 	    getflag(options, 0x02, "CCITT 16-bit FCS", ""));
1101*7c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "     %s",
1102*7c478bd9Sstevel@tonic-gate 	    getflag(options, 0x04, "CCITT 32-bit FCS", ""));
1103*7c478bd9Sstevel@tonic-gate }
1104*7c478bd9Sstevel@tonic-gate 
1105*7c478bd9Sstevel@tonic-gate /*
1106*7c478bd9Sstevel@tonic-gate  * The format of the Self-Describing-Padding option (rfc1570) is:
1107*7c478bd9Sstevel@tonic-gate  *
1108*7c478bd9Sstevel@tonic-gate  *  0                   1                   2
1109*7c478bd9Sstevel@tonic-gate  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
1110*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1111*7c478bd9Sstevel@tonic-gate  * |     Type      |    Length     |    Maximum    |
1112*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1113*7c478bd9Sstevel@tonic-gate  */
1114*7c478bd9Sstevel@tonic-gate /*ARGSUSED1*/
1115*7c478bd9Sstevel@tonic-gate static void
opt_format_sdp(uchar_t * optdata,uint8_t size)1116*7c478bd9Sstevel@tonic-gate opt_format_sdp(uchar_t *optdata, uint8_t size)
1117*7c478bd9Sstevel@tonic-gate {
1118*7c478bd9Sstevel@tonic-gate 	uint8_t max;
1119*7c478bd9Sstevel@tonic-gate 
1120*7c478bd9Sstevel@tonic-gate 	GETINT8(max, optdata);
1121*7c478bd9Sstevel@tonic-gate 
1122*7c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(0, 0), "Maximum = %d", max);
1123*7c478bd9Sstevel@tonic-gate }
1124*7c478bd9Sstevel@tonic-gate 
1125*7c478bd9Sstevel@tonic-gate /*
1126*7c478bd9Sstevel@tonic-gate  * The format of the Numbered-Mode option (rfc1663) is:
1127*7c478bd9Sstevel@tonic-gate  *
1128*7c478bd9Sstevel@tonic-gate  *  0                   1                   2                   3
1129*7c478bd9Sstevel@tonic-gate  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1130*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1131*7c478bd9Sstevel@tonic-gate  * |     Type      |     Length    |    Window     |   Address...
1132*7c478bd9Sstevel@tonic-gate  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1133*7c478bd9Sstevel@tonic-gate  */
1134*7c478bd9Sstevel@tonic-gate /*ARGSUSED1*/
1135*7c478bd9Sstevel@tonic-gate static void
opt_format_nummode(uchar_t * optdata,uint8_t size)1136*7c478bd9Sstevel@tonic-gate opt_format_nummode(uchar_t *optdata, uint8_t size)
1137*7c478bd9Sstevel@tonic-gate {
1138