4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <sys/types.h>
33 #include <sys/socket.h>
34 #include <sys/sysmacros.h>
35 #include <net/ppp_defs.h>
36 #include <net/ppp-comp.h>
38 #include <netinet/in.h>
39 #include <netinet/if_ether.h>
40 #include <arpa/inet.h>
42 #include "snoop_ppp.h"
44 static int interpret_ppp_cp(int, uchar_t
*, int, ppp_protoinfo_t
*);
45 static int interpret_cp_options(uchar_t
*, int, ppp_protoinfo_t
*);
46 static int interpret_ppp_chap(int, uchar_t
*, int, ppp_protoinfo_t
*);
47 static int interpret_ppp_pap(int, uchar_t
*, int, ppp_protoinfo_t
*);
48 static int interpret_ppp_lqr(int, uchar_t
*, int, ppp_protoinfo_t
*);
49 static ppp_protoinfo_t
*ppp_getprotoinfo(uint16_t);
50 static cp_optinfo_t
*ppp_getoptinfo(cp_optinfo_t
*, uint16_t);
51 static optformat_func_t opt_format_vendor
;
52 static optformat_func_t opt_format_mru
;
53 static optformat_func_t opt_format_accm
;
54 static optformat_func_t opt_format_authproto
;
55 static optformat_func_t opt_format_qualproto
;
56 static optformat_func_t opt_format_magicnum
;
57 static optformat_func_t opt_format_fcs
;
58 static optformat_func_t opt_format_sdp
;
59 static optformat_func_t opt_format_nummode
;
60 static optformat_func_t opt_format_callback
;
61 static optformat_func_t opt_format_mrru
;
62 static optformat_func_t opt_format_epdisc
;
63 static optformat_func_t opt_format_dce
;
64 static optformat_func_t opt_format_linkdisc
;
65 static optformat_func_t opt_format_i18n
;
66 static optformat_func_t opt_format_ipaddresses
;
67 static optformat_func_t opt_format_ipcompproto
;
68 static optformat_func_t opt_format_ipaddress
;
69 static optformat_func_t opt_format_mobileipv4
;
70 static optformat_func_t opt_format_ifaceid
;
71 static optformat_func_t opt_format_ipv6compproto
;
72 static optformat_func_t opt_format_compoui
;
73 static optformat_func_t opt_format_bsdcomp
;
74 static optformat_func_t opt_format_staclzs
;
75 static optformat_func_t opt_format_mppc
;
76 static optformat_func_t opt_format_gandalf
;
77 static optformat_func_t opt_format_lzsdcp
;
78 static optformat_func_t opt_format_magnalink
;
79 static optformat_func_t opt_format_deflate
;
80 static optformat_func_t opt_format_encroui
;
81 static optformat_func_t opt_format_dese
;
82 static optformat_func_t opt_format_muxpid
;
85 * Many strings below are initialized with "Unknown".
87 static char unknown_string
[] = "Unknown";
90 * Each known PPP protocol has an associated ppp_protoinfo_t in this array.
91 * Even if we can't decode the protocol (interpret_proto() == NULL),
92 * interpret_ppp() will at least print the protocol's name. There is no
93 * dependency on the ordering of the entries in this array. They have been
94 * ordered such that the most commonly used protocols are near the front.
95 * The array is delimited by a last entry of protocol of type
98 static ppp_protoinfo_t protoinfo_array
[] = {
99 { PPP_IP
, "IP", interpret_ip
, NULL
, NULL
},
100 { PPP_IPV6
, "IPv6", interpret_ipv6
, NULL
, NULL
},
101 { PPP_COMP
, "Compressed Data", NULL
, NULL
, NULL
},
102 { PPP_OSI
, "OSI", NULL
, NULL
, NULL
},
103 { PPP_AT
, "AppleTalk", NULL
, NULL
, NULL
},
104 { PPP_IPX
, "IPX", NULL
, NULL
, NULL
},
105 { PPP_VJC_COMP
, "VJ Compressed TCP", NULL
, NULL
, NULL
},
106 { PPP_VJC_UNCOMP
, "VJ Uncompressed TCP", NULL
, NULL
, NULL
},
107 { PPP_BRIDGE
, "Bridging", NULL
, NULL
, NULL
},
108 { PPP_802HELLO
, "802.1d Hello", NULL
, NULL
, NULL
},
109 { PPP_MP
, "MP", NULL
, NULL
, NULL
},
110 { PPP_ENCRYPT
, "Encryption", NULL
, NULL
, NULL
},
111 { PPP_ENCRYPTFRAG
, "Individual Link Encryption", NULL
, NULL
, NULL
},
112 { PPP_MUX
, "PPP Muxing", NULL
, NULL
, NULL
},
113 { PPP_COMPFRAG
, "Single Link Compressed Data", NULL
, NULL
, NULL
},
114 { PPP_FULLHDR
, "IP Compression", NULL
, NULL
, NULL
},
115 { PPP_COMPTCP
, "IP Compression", NULL
, NULL
, NULL
},
116 { PPP_COMPNONTCP
, "IP Compression", NULL
, NULL
, NULL
},
117 { PPP_COMPUDP8
, "IP Compression", NULL
, NULL
, NULL
},
118 { PPP_COMPRTP8
, "IP Compression", NULL
, NULL
, NULL
},
119 { PPP_COMPTCPND
, "IP Compression", NULL
, NULL
, NULL
},
120 { PPP_COMPSTATE
, "IP Compression", NULL
, NULL
, NULL
},
121 { PPP_COMPUDP16
, "IP Compression", NULL
, NULL
, NULL
},
122 { PPP_COMPRTP16
, "IP Compression", NULL
, NULL
, NULL
},
123 { PPP_MPLS
, "MPLS", NULL
, NULL
, NULL
},
124 { PPP_MPLSMC
, "MPLS M/C", NULL
, NULL
, NULL
},
125 { PPP_LQR
, "LQR", interpret_ppp_lqr
, "PPP-LQR: ",
126 "Link Quality Report" },
127 { PPP_LCP
, "LCP", interpret_ppp_cp
, "PPP-LCP: ",
128 "Link Control Protocol" },
129 { PPP_IPCP
, "IPCP", interpret_ppp_cp
, "PPP-IPCP: ",
130 "IP Control Protocol" },
131 { PPP_IPV6CP
, "IPV6CP", interpret_ppp_cp
, "PPP-IPV6CP: ",
132 "IPv6 Control Protocol" },
133 { PPP_CCP
, "CCP", interpret_ppp_cp
, "PPP-CCP: ",
134 "Compression Control Protocol" },
135 { PPP_CCPFRAG
, "CCP-Link", interpret_ppp_cp
, "PPP-CCP-Link: ",
136 "Per-Link Compression Control Protocol" },
137 { PPP_ECP
, "ECP", interpret_ppp_cp
, "PPP-ECP: ",
138 "Encryption Control Protocol" },
139 { PPP_ECPFRAG
, "ECP-Link", interpret_ppp_cp
, "PPP-ECP-Link: ",
140 "Per-Link Encryption Control Protocol" },
141 { PPP_MPLSCP
, "MPLSCP", NULL
, NULL
, NULL
},
142 { PPP_OSINLCP
, "OSINLCP", NULL
, NULL
, NULL
},
143 { PPP_ATCP
, "ATCP", NULL
, NULL
, NULL
},
144 { PPP_IPXCP
, "IPXCP", NULL
, NULL
, NULL
},
145 { PPP_BACP
, "BACP", NULL
, NULL
, NULL
},
146 { PPP_BCP
, "BCP", NULL
, NULL
, NULL
},
147 { PPP_CBCP
, "CBCP", NULL
, NULL
, NULL
},
148 { PPP_BAP
, "BAP", NULL
, NULL
, NULL
},
149 { PPP_CHAP
, "CHAP", interpret_ppp_chap
, "CHAP: ",
150 "Challenge Handshake Authentication Protocl" },
151 { PPP_PAP
, "PAP", interpret_ppp_pap
, "PAP: ",
152 "Password Authentication Protocol" },
153 { PPP_EAP
, "EAP", NULL
, NULL
, NULL
},
154 { 0, unknown_string
, NULL
, NULL
, NULL
}
157 static cp_optinfo_t lcp_optinfo
[] = {
158 { OPT_LCP_VENDOR
, "Vendor-Specific", 6,
160 { OPT_LCP_MRU
, "Maximum-Receive-Unit", 4,
162 { OPT_LCP_ASYNCMAP
, "Async-Control-Character-Map", 6,
164 { OPT_LCP_AUTHTYPE
, "Authentication-Protocol", 4,
165 opt_format_authproto
},
166 { OPT_LCP_QUALITY
, "Quality-Protocol", 4,
167 opt_format_qualproto
},
168 { OPT_LCP_MAGICNUMBER
, "Magic-Number", 6,
169 opt_format_magicnum
},
170 { OPT_LCP_PCOMPRESSION
, "Protocol-Field-Compression", 2, NULL
},
171 { OPT_LCP_ACCOMPRESSION
, "Address-and-Control-Field-Compression", 2,
173 { OPT_LCP_FCSALTERN
, "FCS-Alternative", 3,
175 { OPT_LCP_SELFDESCPAD
, "Self-Describing-Padding", 3,
177 { OPT_LCP_NUMBERED
, "Numbered-Mode", 3,
178 opt_format_nummode
},
179 { OPT_LCP_MULTILINKPROC
, "Multi-Link-Procedure", 2, NULL
},
180 { OPT_LCP_CALLBACK
, "Callback", 3,
181 opt_format_callback
},
182 { OPT_LCP_CONNECTTIME
, "Connect-Time", 2, NULL
},
183 { OPT_LCP_COMPOUNDFRAMES
, "Compound-Frames", 2, NULL
},
184 { OPT_LCP_DATAENCAP
, "Nominal-Data-Encapsulation", 2, NULL
},
185 { OPT_LCP_MRRU
, "Multilink-MRRU", 4,
187 { OPT_LCP_SSNHF
, "Multilink-Short-Sequence-Number-Header-Format",
189 { OPT_LCP_EPDISC
, "Multilink-Endpoint-Discriminator", 3,
191 { OPT_LCP_DCEIDENT
, "DCE-Identifier", 3,
193 { OPT_LCP_MLPLUSPROC
, "Multi-Link-Plus-Procedure", 2, NULL
},
194 { OPT_LCP_LINKDISC
, "Link Discriminator for BACP", 4,
195 opt_format_linkdisc
},
196 { OPT_LCP_AUTH
, "LCP-Authentication-Option", 2, NULL
},
197 { OPT_LCP_COBS
, "COBS", 2, NULL
},
198 { OPT_LCP_PFXELISION
, "Prefix elision", 2, NULL
},
199 { OPT_LCP_MPHDRFMT
, "Multilink header format", 2, NULL
},
200 { OPT_LCP_I18N
, "Internationalization", 6,
202 { OPT_LCP_SDL
, "Simple Data Link on SONET/SDH", 2, NULL
},
203 { OPT_LCP_MUXING
, "Old PPP Multiplexing", 2, NULL
},
204 { 0, unknown_string
, 0, NULL
}
207 static cp_optinfo_t ipcp_optinfo
[] = {
208 { OPT_IPCP_ADDRS
, "IP-Addresses", 10,
209 opt_format_ipaddresses
},
210 { OPT_IPCP_COMPRESSTYPE
, "IP-Compression-Protocol", 4,
211 opt_format_ipcompproto
},
212 { OPT_IPCP_ADDR
, "IP-Address", 6,
213 opt_format_ipaddress
},
214 { OPT_IPCP_MOBILEIPV4
, "Mobile-IPv4", 6,
215 opt_format_mobileipv4
},
216 { OPT_IPCP_DNS1
, "Primary DNS Address", 6,
217 opt_format_ipaddress
},
218 { OPT_IPCP_NBNS1
, "Primary NBNS Address", 6,
219 opt_format_ipaddress
},
220 { OPT_IPCP_DNS2
, "Secondary DNS Address", 6,
221 opt_format_ipaddress
},
222 { OPT_IPCP_NBNS2
, "Secondary NBNS Address", 6,
223 opt_format_ipaddress
},
224 { OPT_IPCP_SUBNET
, "IP-Subnet", 6,
225 opt_format_ipaddress
},
226 { 0, unknown_string
, 0, NULL
}
229 static cp_optinfo_t ipv6cp_optinfo
[] = {
230 { OPT_IPV6CP_IFACEID
, "Interface-Identifier", 10,
231 opt_format_ifaceid
},
232 { OPT_IPV6CP_COMPRESSTYPE
, "IPv6-Compression-Protocol", 4,
233 opt_format_ipv6compproto
},
234 { 0, unknown_string
, 0, NULL
}
237 static cp_optinfo_t ccp_optinfo
[] = {
238 { OPT_CCP_PROPRIETARY
, "Proprietary Compression OUI", 6,
239 opt_format_compoui
},
240 { OPT_CCP_PREDICTOR1
, "Predictor type 1", 2, NULL
},
241 { OPT_CCP_PREDICTOR2
, "Predictor type 2", 2, NULL
},
242 { OPT_CCP_PUDDLEJUMP
, "Puddle Jumper", 2, NULL
},
243 { OPT_CCP_HPPPC
, "Hewlett-Packard PPC", 2, NULL
},
244 { OPT_CCP_STACLZS
, "Stac Electronics LZS", 5,
245 opt_format_staclzs
},
246 { OPT_CCP_MPPC
, "Microsoft PPC", 6,
248 { OPT_CCP_GANDALFFZA
, "Gandalf FZA", 3,
249 opt_format_gandalf
},
250 { OPT_CCP_V42BIS
, "V.42bis compression", 2,
252 { OPT_CCP_BSDCOMP
, "BSD LZW Compress", 3,
253 opt_format_bsdcomp
},
254 { OPT_CCP_LZSDCP
, "LZS-DCP", 6,
256 { OPT_CCP_MAGNALINK
, "Magnalink", 4,
257 opt_format_magnalink
},
258 { OPT_CCP_DEFLATE
, "Deflate", 4,
259 opt_format_deflate
},
260 { 0, unknown_string
, 0, NULL
}
263 static cp_optinfo_t ecp_optinfo
[] = {
264 { OPT_ECP_PROPRIETARY
, "Proprietary Encryption OUI", 6,
265 opt_format_encroui
},
266 { OPT_ECP_DESE
, "DESE", 10,
268 { OPT_ECP_3DESE
, "3DESE", 10,
270 { OPT_ECP_DESEBIS
, "DESE-bis", 10,
272 { 0, unknown_string
, 0, NULL
}
275 static cp_optinfo_t muxcp_optinfo
[] = {
276 { OPT_MUXCP_DEFAULTPID
, "Default PID", 4,
278 { 0, unknown_string
, 0, NULL
}
281 static char *cp_codearray
[] = {
283 "(Configure-Request)",
286 "(Configure-Reject)",
287 "(Terminate-Request)",
299 #define MAX_CPCODE ((sizeof (cp_codearray) / sizeof (char *)) - 1)
301 static char *pap_codearray
[] = {
303 "(Authenticate-Request)",
304 "(Authenticate-Ack)",
307 #define MAX_PAPCODE ((sizeof (pap_codearray) / sizeof (char *)) - 1)
309 static char *chap_codearray
[] = {
316 #define MAX_CHAPCODE ((sizeof (chap_codearray) / sizeof (char *)) - 1)
320 interpret_ppp(int flags
, uchar_t
*data
, int len
)
323 ppp_protoinfo_t
*protoinfo
;
324 uchar_t
*payload
= data
;
329 GETINT16(protocol
, payload
);
330 len
-= sizeof (uint16_t);
332 protoinfo
= ppp_getprotoinfo(protocol
);
335 (void) sprintf(get_sum_line(),
336 "PPP Protocol=0x%x (%s)", protocol
, protoinfo
->name
);
337 } else { /* F_DTAIL */
338 show_header("PPP: ", "Point-to-Point Protocol", len
);
340 (void) sprintf(get_line(0, 0), "Protocol = 0x%x (%s)",
341 protocol
, protoinfo
->name
);
345 if (protoinfo
->interpret_proto
!= NULL
) {
346 len
= protoinfo
->interpret_proto(flags
, payload
, len
,
354 * interpret_ppp_cp() - Interpret PPP control protocols. It is convenient
355 * to do some of the decoding of these protocols in a common function since
356 * they share packet formats. This function expects to receive data
357 * starting with the code field.
360 interpret_ppp_cp(int flags
, uchar_t
*data
, int len
, ppp_protoinfo_t
*protoinfo
)
366 uchar_t
*datap
= data
;
368 if (len
< sizeof (ppp_pkt_t
))
371 GETINT8(code
, datap
);
373 GETINT16(length
, datap
);
375 len
-= sizeof (ppp_pkt_t
);
377 if (code
<= MAX_CPCODE
)
378 codestr
= cp_codearray
[code
];
383 (void) sprintf(get_sum_line(),
384 "%s%s", protoinfo
->prefix
, codestr
);
385 } else { /* (flags & F_DTAIL) */
386 show_header(protoinfo
->prefix
, protoinfo
->description
, len
);
389 (void) sprintf(get_line(0, 0), "Code = %d %s", code
, codestr
);
390 (void) sprintf(get_line(0, 0), "Identifier = %d", id
);
391 (void) sprintf(get_line(0, 0), "Length = %d", length
);
395 len
= MIN(len
, length
- sizeof (ppp_pkt_t
));
406 if (len
< sizeof (magicnum
) + sizeof (oui
))
409 GETINT32(magicnum
, datap
);
410 (void) sprintf(get_line(0, 0), "Magic-Number = 0x%08x",
413 GETINT32(oui
, datap
);
414 kind
= oui
& 0x000000ff;
417 ouistr
= ether_ouiname(oui
);
419 ouistr
= unknown_string
;
421 (void) sprintf(get_line(0, 0), "OUI = 0x%06x (%s)",
423 (void) sprintf(get_line(0, 0), "Kind = %d", kind
);
433 * The above all contain protocol specific
434 * configuration options. Parse these options.
436 interpret_cp_options(datap
, len
, protoinfo
);
442 * The arbitrary data in these two packet types
443 * is almost always plain text. Print it as such.
445 (void) sprintf(get_line(0, 0), "Data = %.*s",
446 length
- sizeof (ppp_pkt_t
), datap
);
452 * What follows is the rejected control protocol
453 * packet, starting with the code field.
454 * Conveniently, we can call interpret_ppp_cp() to
457 prot_nest_prefix
= protoinfo
->prefix
;
458 interpret_ppp_cp(flags
, datap
, len
, protoinfo
);
459 prot_nest_prefix
= "";
464 * We don't print the rejected-protocol field
465 * explicitely. Instead, we cheat and pretend that
466 * the rejected-protocol field is actually the
467 * protocol field in the included PPP packet. This
468 * way, we can invoke interpret_ppp() and have it
469 * treat the included packet normally.
471 prot_nest_prefix
= protoinfo
->prefix
;
472 interpret_ppp(flags
, datap
, len
);
473 prot_nest_prefix
= "";
480 case CODE_TIMEREMAIN
: {
482 char *message_label
= "Identification = %.*s";
484 if (len
< sizeof (uint32_t))
487 GETINT32(magicnum
, datap
);
488 len
-= sizeof (uint32_t);
489 (void) sprintf(get_line(0, 0), "Magic-Number = 0x%08x",
492 * Unless this is an identification or
493 * time-remaining packet, arbitrary data follows
494 * the magic number field. The user can take a
495 * look at the hex dump for enlightenment.
497 if (code
== CODE_TIMEREMAIN
) {
498 uint32_t timeremaining
;
500 if (len
< sizeof (uint32_t))
503 message_label
= "Message = %.*s";
505 GETINT32(timeremaining
, datap
);
506 len
-= sizeof (uint32_t);
507 (void) sprintf(get_line(0, 0),
508 "Seconds Remaining = %d", timeremaining
);
511 if (code
== CODE_IDENT
|| code
== CODE_TIMEREMAIN
) {
515 (void) sprintf(get_line(0, 0), message_label
,
523 * Reset-Request and Reset-Ack contain arbitrary data which
524 * the user can sift through using the -x option.
537 * interpret_cp_options() decodes control protocol configuration options.
538 * Since each control protocol has a different set of options whose type
539 * numbers overlap, the protoinfo parameter is used to get a handle on
540 * which option set to use for decoding.
543 interpret_cp_options(uchar_t
*optptr
, int len
, ppp_protoinfo_t
*protoinfo
)
545 cp_optinfo_t
*optinfo
;
546 cp_optinfo_t
*optinfo_ptr
;
550 switch (protoinfo
->proto
) {
552 optinfo
= lcp_optinfo
;
555 optinfo
= ipcp_optinfo
;
558 optinfo
= ipv6cp_optinfo
;
561 optinfo
= ccp_optinfo
;
564 optinfo
= ecp_optinfo
;
567 optinfo
= muxcp_optinfo
;
575 (void) sprintf(get_line(0, 0), "%s Configuration Options",
581 GETINT8(opttype
, optptr
);
582 GETINT8(optlen
, optptr
);
584 optinfo_ptr
= ppp_getoptinfo(optinfo
, opttype
);
586 (void) sprintf(get_line(0, 0), "Option Type = %d (%s)", opttype
,
587 optinfo_ptr
->opt_name
);
588 (void) sprintf(get_line(0, 0), "Option Length = %d", optlen
);
591 * Don't continue if there isn't enough data to
592 * contain this option, or if this type of option
593 * should contain more data than the length field
596 if (optlen
> len
|| optlen
< optinfo_ptr
->opt_minsize
) {
597 (void) sprintf(get_line(0, 0),
598 "Warning: Incomplete Option");
603 if (optinfo_ptr
->opt_formatdata
!= NULL
) {
604 optinfo_ptr
->opt_formatdata(optptr
,
605 MIN(optlen
- 2, len
- 2));
609 optptr
+= optlen
- 2;
618 interpret_ppp_chap(int flags
, uchar_t
*data
, int len
,
619 ppp_protoinfo_t
*protoinfo
)
626 uchar_t
*datap
= data
;
629 if (len
< sizeof (ppp_pkt_t
))
632 GETINT8(code
, datap
);
634 GETINT8(length
, datap
);
636 if (code
<= MAX_CHAPCODE
)
637 codestr
= chap_codearray
[code
];
642 (void) sprintf(get_sum_line(),
643 "%s%s", protoinfo
->prefix
, codestr
);
644 } else { /* (flags & F_DTAIL) */
645 show_header(protoinfo
->prefix
, protoinfo
->description
, len
);
648 (void) sprintf(get_line(0, 0), "Code = %d %s", code
, codestr
);
649 (void) sprintf(get_line(0, 0), "Identifier = %d", id
);
650 (void) sprintf(get_line(0, 0), "Length = %d", length
);
657 lengthleft
= len
- sizeof (ppp_pkt_t
);
661 case CODE_RESPONSE
: {
663 uint16_t peername_size
;
665 if (lengthleft
< sizeof (value_size
))
668 GETINT8(value_size
, datap
);
669 lengthleft
-= sizeof (value_size
);
670 (void) sprintf(get_line(0, 0), "Value-Size = %d",
673 if (lengthleft
< sizeof (peername_size
))
675 peername_size
= MIN(length
- sizeof (ppp_pkt_t
) -
676 value_size
, lengthleft
);
677 (void) sprintf(get_line(0, 0), "Name = %.*s",
678 peername_size
, datap
+ value_size
);
684 uint16_t message_size
= MIN(length
- sizeof (ppp_pkt_t
),
687 (void) sprintf(get_line(0, 0), "Message = %.*s",
688 message_size
, datap
);
702 interpret_ppp_pap(int flags
, uchar_t
*data
, int len
,
703 ppp_protoinfo_t
*protoinfo
)
710 uchar_t
*datap
= data
;
712 if (len
< sizeof (ppp_pkt_t
))
715 GETINT8(code
, datap
);
717 GETINT16(length
, datap
);
719 lengthleft
= len
- sizeof (ppp_pkt_t
);
721 if (code
<= MAX_PAPCODE
)
722 codestr
= pap_codearray
[code
];
727 (void) sprintf(get_sum_line(),
728 "%s%s", protoinfo
->prefix
, codestr
);
729 } else { /* (flags & F_DTAIL) */
730 show_header(protoinfo
->prefix
, protoinfo
->description
, len
);
733 (void) sprintf(get_line(0, 0), "Code = %d %s", code
, codestr
);
734 (void) sprintf(get_line(0, 0), "Identifier = %d", id
);
735 (void) sprintf(get_line(0, 0), "Length = %d", length
);
746 if (lengthleft
< sizeof (fieldlen
))
748 GETINT8(fieldlen
, datap
);
749 (void) sprintf(get_line(0, 0), "Peer-Id Length = %d",
751 lengthleft
-= sizeof (fieldlen
);
753 if (lengthleft
< fieldlen
)
755 (void) sprintf(get_line(0, 0), "Peer-Id = %.*s",
757 lengthleft
-= fieldlen
;
761 if (lengthleft
< sizeof (fieldlen
))
763 GETINT8(fieldlen
, datap
);
764 (void) sprintf(get_line(0, 0), "Password Length = %d",
766 lengthleft
-= sizeof (fieldlen
);
768 if (lengthleft
< fieldlen
)
770 (void) sprintf(get_line(0, 0), "Password = %.*s",
779 if (lengthleft
< sizeof (msglen
))
781 GETINT8(msglen
, datap
);
782 (void) sprintf(get_line(0, 0), "Msg-Length = %d",
784 lengthleft
-= sizeof (msglen
);
786 if (lengthleft
< msglen
)
788 (void) sprintf(get_line(0, 0), "Message = %.*s",
805 interpret_ppp_lqr(int flags
, uchar_t
*data
, int len
,
806 ppp_protoinfo_t
*protoinfo
)
809 if (len
< sizeof (lqr_pkt_t
))
812 (void) memcpy(&lqr_pkt
, data
, sizeof (lqr_pkt_t
));
815 (void) sprintf(get_sum_line(), protoinfo
->prefix
);
816 } else { /* (flags & F_DTAIL) */
817 show_header(protoinfo
->prefix
, protoinfo
->description
, len
);
820 (void) sprintf(get_line(0, 0), "Magic-Number = 0x%08x",
821 ntohl(lqr_pkt
.lqr_magic
));
822 (void) sprintf(get_line(0, 0), "LastOutLQRs = %d",
823 ntohl(lqr_pkt
.lqr_lastoutlqrs
));
824 (void) sprintf(get_line(0, 0), "LastOutPackets = %d",
825 ntohl(lqr_pkt
.lqr_lastoutpackets
));
826 (void) sprintf(get_line(0, 0), "LastOutOctets = %d",
827 ntohl(lqr_pkt
.lqr_lastoutoctets
));
828 (void) sprintf(get_line(0, 0), "PeerInLQRs = %d",
829 ntohl(lqr_pkt
.lqr_peerinlqrs
));
830 (void) sprintf(get_line(0, 0), "PeerInPackets = %d",
831 ntohl(lqr_pkt
.lqr_peerinpackets
));
832 (void) sprintf(get_line(0, 0), "PeerInDiscards = %d",
833 ntohl(lqr_pkt
.lqr_peerindiscards
));
834 (void) sprintf(get_line(0, 0), "PeerInErrors = %d",
835 ntohl(lqr_pkt
.lqr_peerinerrors
));
836 (void) sprintf(get_line(0, 0), "PeerInOctets = %d",
837 ntohl(lqr_pkt
.lqr_peerinoctets
));
838 (void) sprintf(get_line(0, 0), "PeerOutLQRs = %d",
839 ntohl(lqr_pkt
.lqr_peeroutlqrs
));
840 (void) sprintf(get_line(0, 0), "PeerOutPackets = %d",
841 ntohl(lqr_pkt
.lqr_peeroutpackets
));
842 (void) sprintf(get_line(0, 0), "PeerOutOctets = %d",
843 ntohl(lqr_pkt
.lqr_peeroutoctets
));
848 len
-= sizeof (lqr_pkt_t
);
852 static ppp_protoinfo_t
*
853 ppp_getprotoinfo(uint16_t proto
)
855 ppp_protoinfo_t
*protoinfo_ptr
= &protoinfo_array
[0];
857 while (protoinfo_ptr
->proto
!= proto
&& protoinfo_ptr
->proto
!= 0) {
861 return (protoinfo_ptr
);
865 static cp_optinfo_t
*
866 ppp_getoptinfo(cp_optinfo_t optinfo_list
[], uint16_t opt_type
)
868 cp_optinfo_t
*optinfo_ptr
= &optinfo_list
[0];
870 while (optinfo_ptr
->opt_type
!= opt_type
&&
871 optinfo_ptr
->opt_name
!= unknown_string
) {
875 return (optinfo_ptr
);
880 * Below are the functions which parse control protocol configuration
881 * options. The first argument to these functions (optdata) points to the
882 * first byte of the option after the length field. The second argument
883 * (size) is the number of bytes in the option after the length field
888 * The format of the Vendor-Specific option (rfc2153) is:
890 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
891 * | Type | Length | OUI
892 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
893 * ... | Kind | Value(s) ...
894 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
898 opt_format_vendor(uchar_t
*optdata
, uint8_t size
)
904 GETINT32(oui
, optdata
);
905 kind
= oui
& 0x000000ff;
908 ouistr
= ether_ouiname(oui
);
910 ouistr
= unknown_string
;
912 (void) sprintf(get_line(0, 0), "OUI = 0x%06x (%s)", oui
, ouistr
);
913 (void) sprintf(get_line(0, 0), "Kind = %d", kind
);
917 * The format of the MRU option (rfc1661) is:
920 * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
922 * | Type | Length | Maximum-Receive-Unit |
923 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
927 opt_format_mru(uchar_t
*optdata
, uint8_t size
)
931 GETINT16(mru
, optdata
);
932 (void) sprintf(get_line(0, 0), "MRU = %d", mru
);
936 * The format of the accm option (rfc1662) is:
939 * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
941 * | Type | Length | ACCM
942 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
944 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
948 opt_format_accm(uchar_t
*optdata
, uint8_t size
)
952 GETINT32(accm
, optdata
);
953 (void) sprintf(get_line(0, 0), "ACCM = 0x%08x", accm
);
957 * The format of the Authentication-Protocol option (rfc1661) is:
960 * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
962 * | Type | Length | Authentication-Protocol |
963 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
967 * For PAP (rfc1334), there is no data. For CHAP (rfc1994), there is one
968 * byte of data representing the algorithm.
971 opt_format_authproto(uchar_t
*optdata
, uint8_t size
)
974 ppp_protoinfo_t
*auth_protoinfo
;
976 GETINT16(proto
, optdata
);
978 auth_protoinfo
= ppp_getprotoinfo(proto
);
980 (void) sprintf(get_line(0, 0), "Protocol = 0x%x (%s)", proto
,
981 auth_protoinfo
->name
);
988 if (size
< sizeof (proto
) + sizeof (algo
))
991 GETINT8(algo
, optdata
);
994 algostr
= "CHAP with MD5";
1000 algostr
= "MS-CHAP-2";
1003 algostr
= unknown_string
;
1006 (void) sprintf(get_line(0, 0), "Algorithm = %d (%s)", algo
,
1016 * The format of the Quality Protocol option (rfc1661) is:
1019 * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1021 * | Type | Length | Quality-Protocol |
1022 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1026 * For LQR, the data consists of a 4 byte reporting period.
1029 opt_format_qualproto(uchar_t
*optdata
, uint8_t size
)
1032 ppp_protoinfo_t
*qual_protoinfo
;
1034 GETINT16(proto
, optdata
);
1036 qual_protoinfo
= ppp_getprotoinfo(proto
);
1038 (void) sprintf(get_line(0, 0), "Protocol = 0x%x (%s)", proto
,
1039 qual_protoinfo
->name
);
1043 uint32_t reporting_period
;
1045 if (size
< sizeof (proto
) + sizeof (reporting_period
))
1048 GETINT32(reporting_period
, optdata
);
1049 (void) sprintf(get_line(0, 0), "Reporting-Period = %d",
1059 * The format of the Magic Number option (rfc1661) is:
1062 * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1064 * | Type | Length | Magic-Number
1065 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1066 * Magic-Number (cont) |
1067 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1071 opt_format_magicnum(uchar_t
*optdata
, uint8_t size
)
1075 GETINT32(magicnum
, optdata
);
1076 (void) sprintf(get_line(0, 0), "Magic Number = 0x%08x", magicnum
);
1080 * The format of the FCS-Alternatives option (rfc1570) is:
1083 * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1085 * | Type | Length | Options |
1086 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1090 opt_format_fcs(uchar_t
*optdata
, uint8_t size
)
1094 GETINT8(options
, optdata
);
1096 (void) sprintf(get_line(0, 0), "Options = 0x%02x", options
);
1097 (void) sprintf(get_line(0, 0), " %s",
1098 getflag(options
, 0x01, "NULL FCS", ""));
1099 (void) sprintf(get_line(0, 0), " %s",
1100 getflag(options
, 0x02, "CCITT 16-bit FCS", ""));
1101 (void) sprintf(get_line(0, 0), " %s",
1102 getflag(options
, 0x04, "CCITT 32-bit FCS", ""));
1106 * The format of the Self-Describing-Padding option (rfc1570) is:
1109 * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1111 * | Type | Length | Maximum |
1112 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1116 opt_format_sdp(uchar_t
*optdata
, uint8_t size
)
1120 GETINT8(max
, optdata
);
1122 (void) sprintf(get_line(0, 0), "Maximum = %d", max
);
1126 * The format of the Numbered-Mode option (rfc1663) is:
1129 * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1131 * | Type | Length | Window | Address...
1132 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1136 opt_format_nummode(uchar_t
*optdata
, uint8_t size
)
1140 GETINT8(window
, optdata
);
1141 (void) sprintf(get_line(0, 0), "Window = %d", window
);
1145 * The format of the Callback option (rfc1570) is:
1148 * 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
1149 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1150 * | Type | Length | Operation | Message ...
1151 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1154 opt_format_callback(uchar_t
*optdata
, uint8_t size
)
1159 GETINT8(operation
, optdata
);
1160 switch (operation
) {
1162 opstr
= "User Authentication";
1165 opstr
= "Dialing String";
1168 opstr
= "Location Identifier";
1171 opstr
= "E.164 Number";
1174 opstr
= "X.500 Distinguished Name";
1177 opstr
= "CBCP Negotiation";
1180 opstr
= unknown_string
;
1184 (void) sprintf(get_line(0, 0), "Operation = %d (%s)", operation
, opstr
);
1186 if (size
> sizeof (operation
)) {
1187 (void) sprintf(get_line(0, 0), "Message = %.*s",
1188 size
- sizeof (operation
), optdata
);
1193 * The format of the Multilink-MRRU option (rfc1990) is:
1196 * 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
1197 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1198 * | Type = 17 | Length = 4 | Max-Receive-Reconstructed-Unit|
1199 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1203 opt_format_mrru(uchar_t
*optdata
, uint8_t size
)
1207 GETINT16(mrru
, optdata
);
1208 (void) sprintf(get_line(0, 0), "MRRU = %d", mrru
);
1212 * The format of the Endpoint Discriminator option (rfc1990) is:
1215 * 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
1216 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1217 * | Type = 19 | Length | Class | Address ...
1218 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1221 opt_format_epdisc(uchar_t
*optdata
, uint8_t size
)
1225 uint8_t addrlen
= size
- sizeof (class);
1228 GETINT8(class, optdata
);
1232 classstr
= "Null Class";
1235 classstr
= "Locally Assigned Address";
1238 classstr
= "IPv4 Address";
1241 classstr
= "IEE 802.1 Global MAC Address";
1244 classstr
= "PPP Magic-Number Block";
1247 classstr
= "Public Switched Network Directory Number";
1250 classstr
= unknown_string
;
1254 (void) sprintf(get_line(0, 0), "Address Class = %d (%s)", class,
1260 addr
= (char *)malloc(addrlen
);
1261 (void) memcpy(addr
, optdata
, addrlen
);
1264 char addrstr
[INET_ADDRSTRLEN
];
1266 if (addrlen
!= sizeof (in_addr_t
))
1268 if (inet_ntop(AF_INET
, addr
, addrstr
, INET_ADDRSTRLEN
) !=
1270 (void) sprintf(get_line(0, 0), "Address = %s", addrstr
);
1277 if (addrlen
!= sizeof (struct ether_addr
))
1279 if ((addrstr
= ether_ntoa((struct ether_addr
*)addr
)) != NULL
) {
1280 (void) sprintf(get_line(0, 0), "Address = %s", addrstr
);
1286 * For this case, the address is supposed to be a plain
1287 * text telephone number.
1289 (void) sprintf(get_line(0, 0), "Address = %.*s", addrlen
,
1300 * The DCE identifier option has the following format (from rfc1976):
1303 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
1304 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1305 * | Type | Length | Mode |
1306 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1310 opt_format_dce(uchar_t
*optdata
, uint8_t size
)
1315 GETINT8(mode
, optdata
);
1318 modestr
= "No Additional Negotiation";
1321 modestr
= "Full PPP Negotiation and State Machine";
1324 modestr
= unknown_string
;
1327 (void) sprintf(get_line(0, 0), "Mode = %d (%s)", mode
, modestr
);
1331 * The format of the Link Discriminator option (rfc2125) is:
1334 * 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
1335 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1336 * | Type | Length | Link Discriminator |
1337 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1341 opt_format_linkdisc(uchar_t
*optdata
, uint8_t size
)
1345 GETINT16(discrim
, optdata
);
1347 (void) sprintf(get_line(0, 0), "Link Discriminator = %d", discrim
);
1352 * The format of the Internationalization option (rfc2484) is:
1355 * 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
1356 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1357 * | Type | Length | MIBenum
1358 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1359 * MIBenum (cont) | Language-Tag...
1360 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1363 opt_format_i18n(uchar_t
*optdata
, uint8_t size
)
1368 taglen
= size
- sizeof (mibenum
);
1370 GETINT32(mibenum
, optdata
);
1371 (void) sprintf(get_line(0, 0), "MIBenum = %d", mibenum
);
1374 (void) sprintf(get_line(0, 0), "Language Tag = %.*s", taglen
,
1380 * The format of the obsolete IP-Addresses option (rfc1172) is:
1383 * 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
1384 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1385 * | Type | Length | Source-IP-Address
1386 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1387 * Source-IP-Address (cont) | Destination-IP-Address
1388 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1389 * Destination-IP-Address (cont) |
1390 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1394 opt_format_ipaddresses(uchar_t
*optdata
, uint8_t size
)
1397 char addrstr
[INET_ADDRSTRLEN
];
1399 (void) memcpy(&addr
, optdata
, sizeof (in_addr_t
));
1400 if (inet_ntop(AF_INET
, &addr
, addrstr
, INET_ADDRSTRLEN
) != NULL
) {
1401 (void) sprintf(get_line(0, 0), "Source Address = %s",
1405 optdata
+= sizeof (in_addr_t
);
1407 (void) memcpy(&addr
, optdata
, sizeof (in_addr_t
));
1408 if (inet_ntop(AF_INET
, &addr
, addrstr
, INET_ADDRSTRLEN
) != NULL
) {
1409 (void) sprintf(get_line(0, 0), "Destination Address = %s",
1415 * The format of the IP-Compression-Protocol option (rfc1332) is:
1418 * 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
1419 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1420 * | Type | Length | IP-Compression-Protocol |
1421 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1425 * For VJ Compressed TCP/IP, data consists of:
1427 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1428 * | Max-Slot-Id | Comp-Slot-Id |
1429 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1431 * For IPHC (rfc2509), data consists of:
1433 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1434 * | TCP_SPACE | NON_TCP_SPACE |
1435 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1436 * | F_MAX_PERIOD | F_MAX_TIME |
1437 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1438 * | MAX_HEADER | suboptions...
1439 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1442 opt_format_ipcompproto(uchar_t
*optdata
, uint8_t size
)
1445 ppp_protoinfo_t
*comp_protoinfo
;
1447 GETINT16(proto
, optdata
);
1449 comp_protoinfo
= ppp_getprotoinfo(proto
);
1451 (void) sprintf(get_line(0, 0), "Protocol = 0x%x (%s)", proto
,
1452 comp_protoinfo
->name
);
1455 case PPP_VJC_COMP
: {
1459 if (size
< sizeof (proto
) + sizeof (maxslotid
) +
1460 sizeof (compslotid
))
1463 GETINT8(maxslotid
, optdata
);
1464 GETINT8(compslotid
, optdata
);
1465 (void) sprintf(get_line(0, 0), "Max-Slot-Id = %d", maxslotid
);
1466 (void) sprintf(get_line(0, 0), "Comp-Slot Flag = 0x%x",
1472 uint16_t non_tcp_space
;
1473 uint16_t f_max_period
;
1474 uint16_t f_max_time
;
1475 uint16_t max_header
;
1477 if (size
< sizeof (proto
) + sizeof (tcp_space
) +
1478 sizeof (non_tcp_space
) + sizeof (f_max_period
) +
1479 sizeof (f_max_time
) + sizeof (max_header
))
1482 GETINT16(tcp_space
, optdata
);
1483 GETINT16(non_tcp_space
, optdata
);
1484 GETINT16(f_max_period
, optdata
);
1485 GETINT16(f_max_time
, optdata
);
1486 GETINT16(max_header
, optdata
);
1488 (void) sprintf(get_line(0, 0), "TCP_SPACE = %d", tcp_space
);
1489 (void) sprintf(get_line(0, 0), "NON_TCP_SPACE = %d",
1491 (void) sprintf(get_line(0, 0), "F_MAX_PERIOD = %d",
1493 (void) sprintf(get_line(0, 0), "F_MAX_TIME = %d", f_max_time
);
1494 (void) sprintf(get_line(0, 0), "MAX_HEADER = %d octets",
1503 * The format of the IP-Address option (rfc1332) is:
1506 * 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
1507 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1508 * | Type | Length | IP-Address
1509 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1510 * IP-Address (cont) |
1511 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1515 opt_format_ipaddress(uchar_t
*optdata
, uint8_t size
)
1518 char addrstr
[INET_ADDRSTRLEN
];
1520 (void) memcpy(&ipaddr
, optdata
, sizeof (in_addr_t
));
1521 if (inet_ntop(AF_INET
, &ipaddr
, addrstr
, INET_ADDRSTRLEN
) != NULL
) {
1522 (void) sprintf(get_line(0, 0), "Address = %s", addrstr
);
1527 * The format of the Mobile-IPv4 option (rfc2290) is:
1530 * 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
1531 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1532 * | Type | Length | Mobile Node's ...
1533 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1534 * ... Home Address |
1535 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1539 opt_format_mobileipv4(uchar_t
*optdata
, uint8_t size
)
1542 char addrstr
[INET_ADDRSTRLEN
];
1544 (void) memcpy(&ipaddr
, optdata
, sizeof (in_addr_t
));
1545 if (inet_ntop(AF_INET
, &ipaddr
, addrstr
, INET_ADDRSTRLEN
) != NULL
) {
1546 (void) sprintf(get_line(0, 0),
1547 "Mobile Node's Home Address = %s", addrstr
);
1552 * The format of the Interface-Identifier option (rfc2472) is:
1555 * 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
1556 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1557 * | Type | Length | Interface-Identifier (MS Bytes)
1558 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1559 * Interface-Identifier (cont)
1560 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1561 * Interface-Identifier (LS Bytes) |
1562 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1566 opt_format_ifaceid(uchar_t
*optdata
, uint8_t size
)
1569 char idstr
[INET6_ADDRSTRLEN
];
1571 (void) memset(&id
, 0, sizeof (in6_addr_t
));
1572 (void) memcpy(&id
.s6_addr
[8], optdata
, 8);
1574 if (inet_ntop(AF_INET6
, &id
, idstr
, INET6_ADDRSTRLEN
) != NULL
) {
1575 (void) sprintf(get_line(0, 0), "Interface ID = %s", idstr
);
1580 * The format of the IPv6-Compression-Protocol option (rfc2472) is:
1583 * 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
1584 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1585 * | Type | Length | IPv6-Compression-Protocol |
1586 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1591 opt_format_ipv6compproto(uchar_t
*optdata
, uint8_t size
)
1594 ppp_protoinfo_t
*comp_protoinfo
;
1596 GETINT16(proto
, optdata
);
1598 comp_protoinfo
= ppp_getprotoinfo(proto
);
1600 (void) sprintf(get_line(0, 0), "Protocol = 0x%x (%s)", proto
,
1601 comp_protoinfo
->name
);
1606 uint16_t non_tcp_space
;
1607 uint16_t f_max_period
;
1608 uint16_t f_max_time
;
1609 uint16_t max_header
;
1611 if (size
< sizeof (proto
) + sizeof (tcp_space
) +
1612 sizeof (non_tcp_space
) + sizeof (f_max_period
) +
1613 sizeof (f_max_time
) + sizeof (max_header
))
1616 GETINT16(tcp_space
, optdata
);
1617 GETINT16(non_tcp_space
, optdata
);
1618 GETINT16(f_max_period
, optdata
);
1619 GETINT16(f_max_time
, optdata
);
1620 GETINT16(max_header
, optdata
);
1622 (void) sprintf(get_line(0, 0), "TCP_SPACE = %d", tcp_space
);
1623 (void) sprintf(get_line(0, 0), "NON_TCP_SPACE = %d",
1625 (void) sprintf(get_line(0, 0), "F_MAX_PERIOD = %d",
1627 (void) sprintf(get_line(0, 0), "F_MAX_TIME = %d", f_max_time
);
1628 (void) sprintf(get_line(0, 0), "MAX_HEADER = %d octets",
1637 * The format of the Proprietary Compression OUI option (rfc1962) is:
1640 * 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
1641 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1642 * | Type | Length | OUI ...
1643 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1644 * OUI | Subtype | Values...
1645 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
1649 opt_format_compoui(uchar_t
*optdata
, uint8_t size
)
1655 GETINT32(oui
, optdata
);
1656 subtype
= oui
& 0x000000ff;
1659 ouistr
= ether_ouiname(oui
);
1661 ouistr
= unknown_string
;
1662 (void) sprintf(get_line(0, 0), "OUI = 0x%06x (%s)", oui
, ouistr
);
1663 (void) sprintf(get_line(0, 0), "Subtype = 0x%x", subtype
);
1667 * The format of the Stac LZS configuration option (rfc1974) is:
1670 * 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
1671 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1672 * | Type | Length | History Count |
1673 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1679 opt_format_staclzs(uchar_t
*optdata
, uint8_t size
)
1684 GETINT16(hcount
, optdata
);
1685 GETINT8(cmode
, optdata
);
1689 (void) sprintf(get_line(0, 0), "History Count = %d", hcount
);
1690 (void) sprintf(get_line(0, 0), "Check Mode = %d", cmode
);
1694 * The format of MPPC configuration option (rfc2118) is:
1697 * 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
1698 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1699 * | Type | Length | Supported Bits |
1700 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1701 * | Supported Bits |
1702 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1706 opt_format_mppc(uchar_t
*optdata
, uint8_t size
)
1710 GETINT32(sb
, optdata
);
1712 (void) sprintf(get_line(0, 0), "Supported Bits = 0x%x", sb
);
1716 * The format of the Gandalf FZA configuration option (rfc1993) is:
1718 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1719 * | Type | Length | History | Version ...
1720 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1724 opt_format_gandalf(uchar_t
*optdata
, uint8_t size
)
1728 GETINT8(history
, optdata
);
1729 (void) sprintf(get_line(0, 0), "Maximum History Size = %d bits",
1734 * The format of the BSD Compress configuration option (rfc1977) is:
1737 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
1738 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1739 * | Type | Length | Vers| Dict |
1740 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1744 opt_format_bsdcomp(uchar_t
*optdata
, uint8_t size
)
1749 GETINT8(codesize
, optdata
);
1751 version
= codesize
>> 5;
1754 (void) sprintf(get_line(0, 0), "Version = 0x%x", version
);
1755 (void) sprintf(get_line(0, 0), "Maximum Code Size = %d bits", codesize
);
1759 * The format of the LZS-DCP configuration option (rfc1967) is:
1762 * 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
1763 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1764 * | Type | Length | History Count |
1765 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1766 * | Check Mode | Process Mode |
1767 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1771 opt_format_lzsdcp(uchar_t
*optdata
, uint8_t size
)
1777 GETINT16(history
, optdata
);
1778 (void) sprintf(get_line(0, 0), "History Count = %d", history
);
1781 GETINT8(mode
, optdata
);
1790 modestr
= "Sequence Number";
1793 modestr
= "Sequence Number + LCB (default)";
1796 modestr
= unknown_string
;
1799 (void) sprintf(get_line(0, 0), "Check Mode = %d (%s)", mode
, modestr
);
1802 GETINT8(mode
, optdata
);
1805 modestr
= "None (default)";
1808 modestr
= "Process-Uncompressed";
1811 modestr
= unknown_string
;
1814 (void) sprintf(get_line(0, 0), "Process Mode = %d (%s)", mode
, modestr
);
1819 * The format of the Magnalink configuration option (rfc1975) is:
1822 * 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
1823 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1824 * | Type | Length |FE |P| History | # Contexts |
1825 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1829 opt_format_magnalink(uchar_t
*optdata
, uint8_t size
)
1836 GETINT8(history
, optdata
);
1837 GETINT8(contexts
, optdata
);
1839 features
= history
>> 6;
1840 pflag
= (history
>> 5) & 0x01;
1843 (void) sprintf(get_line(0, 0), "Features = 0x%d", features
);
1844 (void) sprintf(get_line(0, 0), "Packet Flag = %d", pflag
);
1845 (void) sprintf(get_line(0, 0), "History Size = %d", history
);
1846 (void) sprintf(get_line(0, 0), "Contexts = %d", contexts
);
1850 * The format of the Deflate configuration option (rfc1979) is:
1853 * 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
1854 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1855 * | Type | Length |Window | Method| MBZ |Chk|
1856 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1860 opt_format_deflate(uchar_t
*optdata
, uint8_t size
)
1866 GETINT8(method
, optdata
);
1867 window
= method
>> 4;
1870 GETINT8(chk
, optdata
);
1873 (void) sprintf(get_line(0, 0), "Maximum Window Size = %d", window
);
1874 (void) sprintf(get_line(0, 0), "Compression Method = 0x%x", method
);
1875 (void) sprintf(get_line(0, 0), "Check Method = 0x%x", chk
);
1879 * The format of the Proprietary Encryption OUI option (rfc1968) is:
1882 * 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
1883 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1884 * | Type | Length | OUI ...
1885 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1886 * OUI | Subtype | Values...
1887 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
1891 opt_format_encroui(uchar_t
*optdata
, uint8_t size
)
1897 GETINT32(oui
, optdata
);
1898 subtype
= oui
& 0x000000ff;
1901 ouistr
= ether_ouiname(oui
);
1903 ouistr
= unknown_string
;
1904 (void) sprintf(get_line(0, 0), "OUI = 0x%06x (%s)", oui
, ouistr
);
1905 (void) sprintf(get_line(0, 0), "Subtype = 0x%x", subtype
);
1909 * The format of the DESE, DESE-bis, and 3DESE configuration options
1910 * (rfc1969, rfc2419, and rfc2420) are:
1913 * 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
1914 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1915 * | Type = 3 | Length | Initial Nonce ...
1916 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1920 opt_format_dese(uchar_t
*optdata
, uint8_t size
)
1922 (void) sprintf(get_line(0, 0),
1923 "Initial Nonce = 0x%02x%02x%02x%02x%02x%02x%02x%02x",
1924 optdata
[0], optdata
[1], optdata
[2], optdata
[3], optdata
[4],
1925 optdata
[5], optdata
[6], optdata
[7]);
1929 * The format of the PPPMux Default Protocol Id option
1930 * (draft-ietf-pppext-pppmux-02.txt) is:
1933 * 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
1934 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1935 * | Type = 1 | Length = 4 | Default PID |
1936 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1940 opt_format_muxpid(uchar_t
*optdata
, uint8_t size
)
1944 GETINT16(defpid
, optdata
);
1945 (void) sprintf(get_line(0, 0), "Default PID = %d", defpid
);