2 * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 * Extensively modified by Motonori Shindo (mshindo@mshindo.net) for more
22 * complete PPP support.
25 /* \summary: Point to Point Protocol (PPP) printer */
29 * o resolve XXX as much as possible
38 #include "netdissect-stdinc.h"
41 #include <net/slcompress.h>
42 #include <net/if_ppp.h>
47 #include "netdissect.h"
49 #include "addrtoname.h"
52 #include "ethertype.h"
54 #include "netdissect-alloc.h"
57 * The following constants are defined by IANA. Please refer to
58 * http://www.isi.edu/in-notes/iana/assignments/ppp-numbers
59 * for the up-to-date information.
62 /* Protocol Codes defined in ppp.h */
64 static const struct tok ppptype2str
[] = {
68 { PPP_DECNET
, "DECNET" },
69 { PPP_APPLE
, "APPLE" },
71 { PPP_VJC
, "VJC IP" },
72 { PPP_VJNC
, "VJNC IP" },
73 { PPP_BRPDU
, "BRPDU" },
75 { PPP_VINES
, "VINES" },
76 { PPP_MPLS_UCAST
, "MPLS" },
77 { PPP_MPLS_MCAST
, "MPLS" },
78 { PPP_COMP
, "Compressed"},
82 { PPP_HELLO
, "HELLO" },
83 { PPP_LUXCOM
, "LUXCOM" },
86 { PPP_OSICP
, "OSICP" },
88 { PPP_DECNETCP
, "DECNETCP" },
89 { PPP_APPLECP
, "APPLECP" },
90 { PPP_IPXCP
, "IPXCP" },
91 { PPP_STIICP
, "STIICP" },
92 { PPP_VINESCP
, "VINESCP" },
93 { PPP_IPV6CP
, "IP6CP" },
94 { PPP_MPLSCP
, "MPLSCP" },
101 { PPP_SPAP
, "SPAP" },
102 { PPP_SPAP_OLD
, "Old-SPAP" },
103 { PPP_BACP
, "BACP" },
105 { PPP_MPCP
, "MLPPP-CP" },
110 /* Control Protocols (LCP/IPCP/CCP etc.) Codes defined in RFC 1661 */
112 #define CPCODES_VEXT 0 /* Vendor-Specific (RFC2153) */
113 #define CPCODES_CONF_REQ 1 /* Configure-Request */
114 #define CPCODES_CONF_ACK 2 /* Configure-Ack */
115 #define CPCODES_CONF_NAK 3 /* Configure-Nak */
116 #define CPCODES_CONF_REJ 4 /* Configure-Reject */
117 #define CPCODES_TERM_REQ 5 /* Terminate-Request */
118 #define CPCODES_TERM_ACK 6 /* Terminate-Ack */
119 #define CPCODES_CODE_REJ 7 /* Code-Reject */
120 #define CPCODES_PROT_REJ 8 /* Protocol-Reject (LCP only) */
121 #define CPCODES_ECHO_REQ 9 /* Echo-Request (LCP only) */
122 #define CPCODES_ECHO_RPL 10 /* Echo-Reply (LCP only) */
123 #define CPCODES_DISC_REQ 11 /* Discard-Request (LCP only) */
124 #define CPCODES_ID 12 /* Identification (LCP only) RFC1570 */
125 #define CPCODES_TIME_REM 13 /* Time-Remaining (LCP only) RFC1570 */
126 #define CPCODES_RESET_REQ 14 /* Reset-Request (CCP only) RFC1962 */
127 #define CPCODES_RESET_REP 15 /* Reset-Reply (CCP only) */
129 static const struct tok cpcodes
[] = {
130 {CPCODES_VEXT
, "Vendor-Extension"}, /* RFC2153 */
131 {CPCODES_CONF_REQ
, "Conf-Request"},
132 {CPCODES_CONF_ACK
, "Conf-Ack"},
133 {CPCODES_CONF_NAK
, "Conf-Nack"},
134 {CPCODES_CONF_REJ
, "Conf-Reject"},
135 {CPCODES_TERM_REQ
, "Term-Request"},
136 {CPCODES_TERM_ACK
, "Term-Ack"},
137 {CPCODES_CODE_REJ
, "Code-Reject"},
138 {CPCODES_PROT_REJ
, "Prot-Reject"},
139 {CPCODES_ECHO_REQ
, "Echo-Request"},
140 {CPCODES_ECHO_RPL
, "Echo-Reply"},
141 {CPCODES_DISC_REQ
, "Disc-Req"},
142 {CPCODES_ID
, "Ident"}, /* RFC1570 */
143 {CPCODES_TIME_REM
, "Time-Rem"}, /* RFC1570 */
144 {CPCODES_RESET_REQ
, "Reset-Req"}, /* RFC1962 */
145 {CPCODES_RESET_REP
, "Reset-Ack"}, /* RFC1962 */
149 /* LCP Config Options */
151 #define LCPOPT_VEXT 0
153 #define LCPOPT_ACCM 2
157 #define LCPOPT_DEP6 6
159 #define LCPOPT_ACFC 8
160 #define LCPOPT_FCSALT 9
161 #define LCPOPT_SDP 10
162 #define LCPOPT_NUMMODE 11
163 #define LCPOPT_DEP12 12
164 #define LCPOPT_CBACK 13
165 #define LCPOPT_DEP14 14
166 #define LCPOPT_DEP15 15
167 #define LCPOPT_DEP16 16
168 #define LCPOPT_MLMRRU 17
169 #define LCPOPT_MLSSNHF 18
170 #define LCPOPT_MLED 19
171 #define LCPOPT_PROP 20
172 #define LCPOPT_DCEID 21
173 #define LCPOPT_MPP 22
175 #define LCPOPT_LCPAOPT 24
176 #define LCPOPT_COBS 25
178 #define LCPOPT_MLHF 27
179 #define LCPOPT_I18N 28
180 #define LCPOPT_SDLOS 29
181 #define LCPOPT_PPPMUX 30
183 static const char *lcpconfopts
[] = {
184 "Vend-Ext", /* (0) */
187 "Auth-Prot", /* (3) */
188 "Qual-Prot", /* (4) */
189 "Magic-Num", /* (5) */
190 "deprecated(6)", /* used to be a Quality Protocol */
195 "Num-Mode", /* (11) */
196 "deprecated(12)", /* used to be a Multi-Link-Procedure*/
197 "Call-Back", /* (13) */
198 "deprecated(14)", /* used to be a Connect-Time */
199 "deprecated(15)", /* used to be a Compund-Frames */
200 "deprecated(16)", /* used to be a Nominal-Data-Encap */
202 "12-Bit seq #", /* (18) */
203 "End-Disc", /* (19) */
204 "Proprietary", /* (20) */
207 "Link-Disc", /* (23) */
208 "LCP-Auth-Opt", /* (24) */
210 "Prefix-elision", /* (26) */
211 "Multilink-header-Form",/* (27) */
213 "SDL-over-SONET/SDH", /* (29) */
214 "PPP-Muxing", /* (30) */
217 #define NUM_LCPOPTS (sizeof(lcpconfopts) / sizeof(lcpconfopts[0]))
219 /* ECP - to be supported */
221 /* CCP Config Options */
223 #define CCPOPT_OUI 0 /* RFC1962 */
224 #define CCPOPT_PRED1 1 /* RFC1962 */
225 #define CCPOPT_PRED2 2 /* RFC1962 */
226 #define CCPOPT_PJUMP 3 /* RFC1962 */
227 /* 4-15 unassigned */
228 #define CCPOPT_HPPPC 16 /* RFC1962 */
229 #define CCPOPT_STACLZS 17 /* RFC1974 */
230 #define CCPOPT_MPPC 18 /* RFC2118 */
231 #define CCPOPT_GFZA 19 /* RFC1962 */
232 #define CCPOPT_V42BIS 20 /* RFC1962 */
233 #define CCPOPT_BSDCOMP 21 /* RFC1977 */
235 #define CCPOPT_LZSDCP 23 /* RFC1967 */
236 #define CCPOPT_MVRCA 24 /* RFC1975 */
237 #define CCPOPT_DEC 25 /* RFC1976 */
238 #define CCPOPT_DEFLATE 26 /* RFC1979 */
239 /* 27-254 unassigned */
240 #define CCPOPT_RESV 255 /* RFC1962 */
242 static const struct tok ccpconfopts_values
[] = {
243 { CCPOPT_OUI
, "OUI" },
244 { CCPOPT_PRED1
, "Pred-1" },
245 { CCPOPT_PRED2
, "Pred-2" },
246 { CCPOPT_PJUMP
, "Puddle" },
247 { CCPOPT_HPPPC
, "HP-PPC" },
248 { CCPOPT_STACLZS
, "Stac-LZS" },
249 { CCPOPT_MPPC
, "MPPC" },
250 { CCPOPT_GFZA
, "Gand-FZA" },
251 { CCPOPT_V42BIS
, "V.42bis" },
252 { CCPOPT_BSDCOMP
, "BSD-Comp" },
253 { CCPOPT_LZSDCP
, "LZS-DCP" },
254 { CCPOPT_MVRCA
, "MVRCA" },
255 { CCPOPT_DEC
, "DEC" },
256 { CCPOPT_DEFLATE
, "Deflate" },
257 { CCPOPT_RESV
, "Reserved"},
261 /* BACP Config Options */
263 #define BACPOPT_FPEER 1 /* RFC2125 */
265 static const struct tok bacconfopts_values
[] = {
266 { BACPOPT_FPEER
, "Favored-Peer" },
271 /* SDCP - to be supported */
273 /* IPCP Config Options */
274 #define IPCPOPT_2ADDR 1 /* RFC1172, RFC1332 (deprecated) */
275 #define IPCPOPT_IPCOMP 2 /* RFC1332 */
276 #define IPCPOPT_ADDR 3 /* RFC1332 */
277 #define IPCPOPT_MOBILE4 4 /* RFC2290 */
278 #define IPCPOPT_PRIDNS 129 /* RFC1877 */
279 #define IPCPOPT_PRINBNS 130 /* RFC1877 */
280 #define IPCPOPT_SECDNS 131 /* RFC1877 */
281 #define IPCPOPT_SECNBNS 132 /* RFC1877 */
283 static const struct tok ipcpopt_values
[] = {
284 { IPCPOPT_2ADDR
, "IP-Addrs" },
285 { IPCPOPT_IPCOMP
, "IP-Comp" },
286 { IPCPOPT_ADDR
, "IP-Addr" },
287 { IPCPOPT_MOBILE4
, "Home-Addr" },
288 { IPCPOPT_PRIDNS
, "Pri-DNS" },
289 { IPCPOPT_PRINBNS
, "Pri-NBNS" },
290 { IPCPOPT_SECDNS
, "Sec-DNS" },
291 { IPCPOPT_SECNBNS
, "Sec-NBNS" },
295 #define IPCPOPT_IPCOMP_HDRCOMP 0x61 /* rfc3544 */
296 #define IPCPOPT_IPCOMP_MINLEN 14
298 static const struct tok ipcpopt_compproto_values
[] = {
299 { PPP_VJC
, "VJ-Comp" },
300 { IPCPOPT_IPCOMP_HDRCOMP
, "IP Header Compression" },
304 static const struct tok ipcpopt_compproto_subopt_values
[] = {
305 { 1, "RTP-Compression" },
306 { 2, "Enhanced RTP-Compression" },
310 /* IP6CP Config Options */
313 static const struct tok ip6cpopt_values
[] = {
314 { IP6CP_IFID
, "Interface-ID" },
318 /* ATCP - to be supported */
319 /* OSINLCP - to be supported */
320 /* BVCP - to be supported */
321 /* BCP - to be supported */
322 /* IPXCP - to be supported */
323 /* MPLSCP - to be supported */
325 /* Auth Algorithms */
327 /* 0-4 Reserved (RFC1994) */
328 #define AUTHALG_CHAPMD5 5 /* RFC1994 */
329 #define AUTHALG_MSCHAP1 128 /* RFC2433 */
330 #define AUTHALG_MSCHAP2 129 /* RFC2795 */
332 static const struct tok authalg_values
[] = {
333 { AUTHALG_CHAPMD5
, "MD5" },
334 { AUTHALG_MSCHAP1
, "MS-CHAPv1" },
335 { AUTHALG_MSCHAP2
, "MS-CHAPv2" },
339 /* FCS Alternatives - to be supported */
341 /* Multilink Endpoint Discriminator (RFC1717) */
342 #define MEDCLASS_NULL 0 /* Null Class */
343 #define MEDCLASS_LOCAL 1 /* Locally Assigned */
344 #define MEDCLASS_IPV4 2 /* Internet Protocol (IPv4) */
345 #define MEDCLASS_MAC 3 /* IEEE 802.1 global MAC address */
346 #define MEDCLASS_MNB 4 /* PPP Magic Number Block */
347 #define MEDCLASS_PSNDN 5 /* Public Switched Network Director Number */
349 /* PPP LCP Callback */
350 #define CALLBACK_AUTH 0 /* Location determined by user auth */
351 #define CALLBACK_DSTR 1 /* Dialing string */
352 #define CALLBACK_LID 2 /* Location identifier */
353 #define CALLBACK_E164 3 /* E.164 number */
354 #define CALLBACK_X500 4 /* X.500 distinguished name */
355 #define CALLBACK_CBCP 6 /* Location is determined during CBCP nego */
357 static const struct tok ppp_callback_values
[] = {
358 { CALLBACK_AUTH
, "UserAuth" },
359 { CALLBACK_DSTR
, "DialString" },
360 { CALLBACK_LID
, "LocalID" },
361 { CALLBACK_E164
, "E.164" },
362 { CALLBACK_X500
, "X.500" },
363 { CALLBACK_CBCP
, "CBCP" },
374 static const struct tok chapcode_values
[] = {
375 { CHAP_CHAL
, "Challenge" },
376 { CHAP_RESP
, "Response" },
377 { CHAP_SUCC
, "Success" },
378 { CHAP_FAIL
, "Fail" },
388 static const struct tok papcode_values
[] = {
389 { PAP_AREQ
, "Auth-Req" },
390 { PAP_AACK
, "Auth-ACK" },
391 { PAP_ANAK
, "Auth-NACK" },
396 #define BAP_CALLREQ 1
397 #define BAP_CALLRES 2
405 static u_int
print_lcp_config_options(netdissect_options
*, const u_char
*p
, u_int
);
406 static u_int
print_ipcp_config_options(netdissect_options
*, const u_char
*p
, u_int
);
407 static u_int
print_ip6cp_config_options(netdissect_options
*, const u_char
*p
, u_int
);
408 static u_int
print_ccp_config_options(netdissect_options
*, const u_char
*p
, u_int
);
409 static u_int
print_bacp_config_options(netdissect_options
*, const u_char
*p
, u_int
);
410 static void handle_ppp(netdissect_options
*, u_int proto
, const u_char
*p
, u_int length
);
412 /* generic Control Protocol (e.g. LCP, IPCP, CCP, etc.) handler */
414 handle_ctrl_proto(netdissect_options
*ndo
,
415 u_int proto
, const u_char
*pptr
, u_int length
)
419 u_int (*pfunc
)(netdissect_options
*, const u_char
*, u_int
);
425 typestr
= tok2str(ppptype2str
, "unknown ctrl-proto (0x%04x)", proto
);
426 ND_PRINT("%s, ", typestr
);
428 if (length
< 4) /* FIXME weak boundary checking */
432 code
= EXTRACT_U_1(tptr
);
435 ND_PRINT("%s (0x%02x), id %u, length %u",
436 tok2str(cpcodes
, "Unknown Opcode",code
),
438 EXTRACT_U_1(tptr
), /* ID */
446 len
= EXTRACT_BE_U_2(tptr
);
450 ND_PRINT("\n\tencoded length %u (< 4))", len
);
455 ND_PRINT("\n\tencoded length %u (> packet length %u))", len
, length
);
460 ND_PRINT("\n\tencoded length %u (=Option(s) length %u)", len
, len
- 4);
463 return; /* there may be a NULL confreq etc. */
465 if (ndo
->ndo_vflag
> 1)
466 print_unknown_data(ndo
, pptr
- 2, "\n\t", 6);
474 ND_PRINT("\n\t Magic-Num 0x%08x", EXTRACT_BE_U_4(tptr
));
477 ND_PRINT(" Vendor: %s (%u)",
478 tok2str(oui_values
,"Unknown",EXTRACT_BE_U_3(tptr
)),
479 EXTRACT_BE_U_3(tptr
));
480 /* XXX: need to decode Kind and Value(s)? */
482 case CPCODES_CONF_REQ
:
483 case CPCODES_CONF_ACK
:
484 case CPCODES_CONF_NAK
:
485 case CPCODES_CONF_REJ
:
486 tlen
= len
- 4; /* Code(1), Identifier(1) and Length(2) */
490 pfunc
= print_lcp_config_options
;
493 pfunc
= print_ipcp_config_options
;
496 pfunc
= print_ip6cp_config_options
;
499 pfunc
= print_ccp_config_options
;
502 pfunc
= print_bacp_config_options
;
506 * No print routine for the options for
513 if (pfunc
== NULL
) /* catch the above null pointer if unknown CP */
516 if ((advance
= (*pfunc
)(ndo
, tptr
, len
)) == 0)
518 if (tlen
< advance
) {
519 ND_PRINT(" [remaining options length %u < %u]",
521 nd_print_invalid(ndo
);
529 case CPCODES_TERM_REQ
:
530 case CPCODES_TERM_ACK
:
531 /* XXX: need to decode Data? */
533 case CPCODES_CODE_REJ
:
534 /* XXX: need to decode Rejected-Packet? */
536 case CPCODES_PROT_REJ
:
540 ND_PRINT("\n\t Rejected %s Protocol (0x%04x)",
541 tok2str(ppptype2str
,"unknown", EXTRACT_BE_U_2(tptr
)),
542 EXTRACT_BE_U_2(tptr
));
543 /* XXX: need to decode Rejected-Information? - hexdump for now */
545 ND_PRINT("\n\t Rejected Packet");
546 print_unknown_data(ndo
, tptr
+ 2, "\n\t ", len
- 2);
549 case CPCODES_ECHO_REQ
:
550 case CPCODES_ECHO_RPL
:
551 case CPCODES_DISC_REQ
:
555 ND_PRINT("\n\t Magic-Num 0x%08x", EXTRACT_BE_U_4(tptr
));
556 /* XXX: need to decode Data? - hexdump for now */
558 ND_PRINT("\n\t -----trailing data-----");
559 ND_TCHECK_LEN(tptr
+ 4, len
- 8);
560 print_unknown_data(ndo
, tptr
+ 4, "\n\t ", len
- 8);
567 ND_PRINT("\n\t Magic-Num 0x%08x", EXTRACT_BE_U_4(tptr
));
568 /* RFC 1661 says this is intended to be human readable */
570 ND_PRINT("\n\t Message\n\t ");
571 if (nd_printn(ndo
, tptr
+ 4, len
- 4, ndo
->ndo_snapend
))
575 case CPCODES_TIME_REM
:
579 ND_PRINT("\n\t Magic-Num 0x%08x", EXTRACT_BE_U_4(tptr
));
580 ND_TCHECK_4(tptr
+ 4);
581 ND_PRINT(", Seconds-Remaining %us", EXTRACT_BE_U_4(tptr
+ 4));
582 /* XXX: need to decode Message? */
585 /* XXX this is dirty but we do not get the
586 * original pointer passed to the begin
588 if (ndo
->ndo_vflag
<= 1)
589 print_unknown_data(ndo
, pptr
- 2, "\n\t ", length
+ 2);
595 ND_PRINT("[|%s]", typestr
);
598 /* LCP config options */
600 print_lcp_config_options(netdissect_options
*ndo
,
601 const u_char
*p
, u_int length
)
608 opt
= EXTRACT_U_1(p
);
609 len
= EXTRACT_U_1(p
+ 1);
613 if (opt
< NUM_LCPOPTS
)
614 ND_PRINT("\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
615 lcpconfopts
[opt
], opt
, len
);
617 ND_PRINT("\n\tunknown LCP option 0x%02x", opt
);
620 if (opt
< NUM_LCPOPTS
)
621 ND_PRINT("\n\t %s Option (0x%02x), length %u", lcpconfopts
[opt
], opt
, len
);
623 ND_PRINT("\n\tunknown LCP option 0x%02x", opt
);
630 ND_PRINT(" (length bogus, should be >= 6)");
634 ND_PRINT(": Vendor: %s (%u)",
635 tok2str(oui_values
,"Unknown",EXTRACT_BE_U_3(p
+ 2)),
636 EXTRACT_BE_U_3(p
+ 2));
639 ND_PRINT(", kind: 0x%02x", EXTRACT_U_1(p
+ 5));
640 ND_PRINT(", Value: 0x");
641 for (i
= 0; i
< len
- 6; i
++) {
642 ND_TCHECK_1(p
+ 6 + i
);
643 ND_PRINT("%02x", EXTRACT_U_1(p
+ 6 + i
));
649 ND_PRINT(" (length bogus, should be = 4)");
653 ND_PRINT(": %u", EXTRACT_BE_U_2(p
+ 2));
657 ND_PRINT(" (length bogus, should be = 6)");
661 ND_PRINT(": 0x%08x", EXTRACT_BE_U_4(p
+ 2));
665 ND_PRINT(" (length bogus, should be >= 4)");
669 ND_PRINT(": %s", tok2str(ppptype2str
, "Unknown Auth Proto (0x04x)", EXTRACT_BE_U_2(p
+ 2)));
671 switch (EXTRACT_BE_U_2(p
+ 2)) {
674 ND_PRINT(", %s", tok2str(authalg_values
, "Unknown Auth Alg %u", EXTRACT_U_1(p
+ 4)));
676 case PPP_PAP
: /* fall through */
682 print_unknown_data(ndo
, p
, "\n\t", len
);
687 ND_PRINT(" (length bogus, should be >= 4)");
691 if (EXTRACT_BE_U_2(p
+ 2) == PPP_LQM
)
694 ND_PRINT(": unknown");
698 ND_PRINT(" (length bogus, should be = 6)");
702 ND_PRINT(": 0x%08x", EXTRACT_BE_U_4(p
+ 2));
710 ND_PRINT(" (length bogus, should be = 4)");
714 ND_PRINT(": 0x%04x", EXTRACT_BE_U_2(p
+ 2));
718 ND_PRINT(" (length bogus, should be >= 3)");
723 ND_PRINT(": Callback Operation %s (%u)",
724 tok2str(ppp_callback_values
, "Unknown", EXTRACT_U_1(p
+ 2)),
729 ND_PRINT(" (length bogus, should be = 4)");
733 ND_PRINT(": %u", EXTRACT_BE_U_2(p
+ 2));
737 ND_PRINT(" (length bogus, should be >= 3)");
741 switch (EXTRACT_U_1(p
+ 2)) { /* class */
746 ND_PRINT(": Local"); /* XXX */
750 ND_PRINT(" (length bogus, should be = 7)");
754 ND_PRINT(": IPv4 %s", ipaddr_string(ndo
, p
+ 3));
758 ND_PRINT(" (length bogus, should be = 9)");
762 ND_PRINT(": MAC %s", etheraddr_string(ndo
, p
+ 3));
765 ND_PRINT(": Magic-Num-Block"); /* XXX */
768 ND_PRINT(": PSNDN"); /* XXX */
771 ND_PRINT(": Unknown class %u", EXTRACT_U_1(p
+ 2));
776 /* XXX: to be supported */
801 * Unknown option; dump it as raw bytes now if we're
802 * not going to do so below.
804 if (ndo
->ndo_vflag
< 2)
805 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2);
809 if (ndo
->ndo_vflag
> 1)
810 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2); /* exclude TLV header */
820 static const struct tok ppp_ml_flag_values
[] = {
827 handle_mlppp(netdissect_options
*ndo
,
828 const u_char
*p
, u_int length
)
834 ND_PRINT("[|mlppp]");
837 if (!ND_TTEST_2(p
)) {
838 ND_PRINT("[|mlppp]");
842 ND_PRINT("seq 0x%03x, Flags [%s], length %u",
843 (EXTRACT_BE_U_2(p
))&0x0fff, /* only support 12-Bit sequence space for now */
844 bittok2str(ppp_ml_flag_values
, "none", EXTRACT_U_1(p
) & 0xc0),
850 handle_chap(netdissect_options
*ndo
,
851 const u_char
*p
, u_int length
)
854 u_int val_size
, name_size
, msg_size
;
862 } else if (length
< 4) {
864 ND_PRINT("[|chap 0x%02x]", EXTRACT_U_1(p
));
869 code
= EXTRACT_U_1(p
);
870 ND_PRINT("CHAP, %s (0x%02x)",
871 tok2str(chapcode_values
,"unknown",code
),
876 ND_PRINT(", id %u", EXTRACT_U_1(p
)); /* ID */
880 len
= EXTRACT_BE_U_2(p
);
884 * Note that this is a generic CHAP decoding routine. Since we
885 * don't know which flavor of CHAP (i.e. CHAP-MD5, MS-CHAPv1,
886 * MS-CHAPv2) is used at this point, we can't decode packet
887 * specifically to each algorithms. Instead, we simply decode
888 * the GCD (Gratest Common Denominator) for all algorithms.
893 if (length
- (p
- p0
) < 1)
896 val_size
= EXTRACT_U_1(p
); /* value size */
898 if (length
- (p
- p0
) < val_size
)
900 ND_PRINT(", Value ");
901 for (i
= 0; i
< val_size
; i
++) {
903 ND_PRINT("%02x", EXTRACT_U_1(p
));
906 name_size
= len
- (p
- p0
);
908 for (i
= 0; i
< name_size
; i
++) {
910 fn_print_char(ndo
, EXTRACT_U_1(p
));
916 msg_size
= len
- (p
- p0
);
918 for (i
= 0; i
< msg_size
; i
++) {
920 fn_print_char(ndo
, EXTRACT_U_1(p
));
931 /* PAP (see RFC 1334) */
933 handle_pap(netdissect_options
*ndo
,
934 const u_char
*p
, u_int length
)
937 u_int peerid_len
, passwd_len
, msg_len
;
945 } else if (length
< 4) {
947 ND_PRINT("[|pap 0x%02x]", EXTRACT_U_1(p
));
952 code
= EXTRACT_U_1(p
);
953 ND_PRINT("PAP, %s (0x%02x)",
954 tok2str(papcode_values
, "unknown", code
),
959 ND_PRINT(", id %u", EXTRACT_U_1(p
)); /* ID */
963 len
= EXTRACT_BE_U_2(p
);
967 ND_PRINT(", length %u > packet size", len
);
971 if (length
< (size_t)(p
- p0
)) {
972 ND_PRINT(", length %u < PAP header length", length
);
978 /* A valid Authenticate-Request is 6 or more octets long. */
981 if (length
- (p
- p0
) < 1)
984 peerid_len
= EXTRACT_U_1(p
); /* Peer-ID Length */
986 if (length
- (p
- p0
) < peerid_len
)
989 for (i
= 0; i
< peerid_len
; i
++) {
991 fn_print_char(ndo
, EXTRACT_U_1(p
));
995 if (length
- (p
- p0
) < 1)
998 passwd_len
= EXTRACT_U_1(p
); /* Password Length */
1000 if (length
- (p
- p0
) < passwd_len
)
1002 ND_PRINT(", Name ");
1003 for (i
= 0; i
< passwd_len
; i
++) {
1005 fn_print_char(ndo
, EXTRACT_U_1(p
));
1011 /* Although some implementations ignore truncation at
1012 * this point and at least one generates a truncated
1013 * packet, RFC 1334 section 2.2.2 clearly states that
1014 * both AACK and ANAK are at least 5 bytes long.
1018 if (length
- (p
- p0
) < 1)
1021 msg_len
= EXTRACT_U_1(p
); /* Msg-Length */
1023 if (length
- (p
- p0
) < msg_len
)
1026 for (i
= 0; i
< msg_len
; i
++) {
1028 fn_print_char(ndo
, EXTRACT_U_1(p
));
1041 handle_bap(netdissect_options
*ndo _U_
,
1042 const u_char
*p _U_
, u_int length _U_
)
1044 /* XXX: to be supported!! */
1048 /* IPCP config options */
1050 print_ipcp_config_options(netdissect_options
*ndo
,
1051 const u_char
*p
, u_int length
)
1054 u_int compproto
, ipcomp_subopttotallen
, ipcomp_subopt
, ipcomp_suboptlen
;
1059 opt
= EXTRACT_U_1(p
);
1060 len
= EXTRACT_U_1(p
+ 1);
1064 ND_PRINT("\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
1065 tok2str(ipcpopt_values
,"unknown",opt
),
1071 ND_PRINT("\n\t %s Option (0x%02x), length %u",
1072 tok2str(ipcpopt_values
,"unknown",opt
),
1077 case IPCPOPT_2ADDR
: /* deprecated */
1079 ND_PRINT(" (length bogus, should be = 10)");
1083 ND_PRINT(": src %s, dst %s",
1084 ipaddr_string(ndo
, p
+ 2),
1085 ipaddr_string(ndo
, p
+ 6));
1087 case IPCPOPT_IPCOMP
:
1089 ND_PRINT(" (length bogus, should be >= 4)");
1093 compproto
= EXTRACT_BE_U_2(p
+ 2);
1095 ND_PRINT(": %s (0x%02x):",
1096 tok2str(ipcpopt_compproto_values
, "Unknown", compproto
),
1099 switch (compproto
) {
1101 /* XXX: VJ-Comp parameters should be decoded */
1103 case IPCPOPT_IPCOMP_HDRCOMP
:
1104 if (len
< IPCPOPT_IPCOMP_MINLEN
) {
1105 ND_PRINT(" (length bogus, should be >= %u)",
1106 IPCPOPT_IPCOMP_MINLEN
);
1110 ND_TCHECK_LEN(p
+ 2, IPCPOPT_IPCOMP_MINLEN
);
1111 ND_PRINT("\n\t TCP Space %u, non-TCP Space %u"
1112 ", maxPeriod %u, maxTime %u, maxHdr %u",
1113 EXTRACT_BE_U_2(p
+ 4),
1114 EXTRACT_BE_U_2(p
+ 6),
1115 EXTRACT_BE_U_2(p
+ 8),
1116 EXTRACT_BE_U_2(p
+ 10),
1117 EXTRACT_BE_U_2(p
+ 12));
1119 /* suboptions present ? */
1120 if (len
> IPCPOPT_IPCOMP_MINLEN
) {
1121 ipcomp_subopttotallen
= len
- IPCPOPT_IPCOMP_MINLEN
;
1122 p
+= IPCPOPT_IPCOMP_MINLEN
;
1124 ND_PRINT("\n\t Suboptions, length %u", ipcomp_subopttotallen
);
1126 while (ipcomp_subopttotallen
>= 2) {
1128 ipcomp_subopt
= EXTRACT_U_1(p
);
1129 ipcomp_suboptlen
= EXTRACT_U_1(p
+ 1);
1132 if (ipcomp_subopt
== 0 ||
1133 ipcomp_suboptlen
== 0 )
1136 /* XXX: just display the suboptions for now */
1137 ND_PRINT("\n\t\t%s Suboption #%u, length %u",
1138 tok2str(ipcpopt_compproto_subopt_values
,
1143 if (ipcomp_subopttotallen
< ipcomp_suboptlen
) {
1144 ND_PRINT(" [remaining suboptions length %u < %u]",
1145 ipcomp_subopttotallen
, ipcomp_suboptlen
);
1146 nd_print_invalid(ndo
);
1149 ipcomp_subopttotallen
-= ipcomp_suboptlen
;
1150 p
+= ipcomp_suboptlen
;
1159 case IPCPOPT_ADDR
: /* those options share the same format - fall through */
1160 case IPCPOPT_MOBILE4
:
1161 case IPCPOPT_PRIDNS
:
1162 case IPCPOPT_PRINBNS
:
1163 case IPCPOPT_SECDNS
:
1164 case IPCPOPT_SECNBNS
:
1166 ND_PRINT(" (length bogus, should be = 6)");
1170 ND_PRINT(": %s", ipaddr_string(ndo
, p
+ 2));
1174 * Unknown option; dump it as raw bytes now if we're
1175 * not going to do so below.
1177 if (ndo
->ndo_vflag
< 2)
1178 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2);
1181 if (ndo
->ndo_vflag
> 1)
1182 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2); /* exclude TLV header */
1186 ND_PRINT("[|ipcp]");
1190 /* IP6CP config options */
1192 print_ip6cp_config_options(netdissect_options
*ndo
,
1193 const u_char
*p
, u_int length
)
1200 opt
= EXTRACT_U_1(p
);
1201 len
= EXTRACT_U_1(p
+ 1);
1205 ND_PRINT("\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
1206 tok2str(ip6cpopt_values
,"unknown",opt
),
1212 ND_PRINT("\n\t %s Option (0x%02x), length %u",
1213 tok2str(ip6cpopt_values
,"unknown",opt
),
1220 ND_PRINT(" (length bogus, should be = 10)");
1224 ND_PRINT(": %04x:%04x:%04x:%04x",
1225 EXTRACT_BE_U_2(p
+ 2),
1226 EXTRACT_BE_U_2(p
+ 4),
1227 EXTRACT_BE_U_2(p
+ 6),
1228 EXTRACT_BE_U_2(p
+ 8));
1232 * Unknown option; dump it as raw bytes now if we're
1233 * not going to do so below.
1235 if (ndo
->ndo_vflag
< 2)
1236 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2);
1239 if (ndo
->ndo_vflag
> 1)
1240 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2); /* exclude TLV header */
1245 ND_PRINT("[|ip6cp]");
1250 /* CCP config options */
1252 print_ccp_config_options(netdissect_options
*ndo
,
1253 const u_char
*p
, u_int length
)
1260 opt
= EXTRACT_U_1(p
);
1261 len
= EXTRACT_U_1(p
+ 1);
1265 ND_PRINT("\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
1266 tok2str(ccpconfopts_values
, "Unknown", opt
),
1272 ND_PRINT("\n\t %s Option (0x%02x), length %u",
1273 tok2str(ccpconfopts_values
, "Unknown", opt
),
1278 case CCPOPT_BSDCOMP
:
1280 ND_PRINT(" (length bogus, should be >= 3)");
1284 ND_PRINT(": Version: %u, Dictionary Bits: %u",
1285 EXTRACT_U_1(p
+ 2) >> 5,
1286 EXTRACT_U_1(p
+ 2) & 0x1f);
1290 ND_PRINT(" (length bogus, should be >= 4)");
1294 ND_PRINT(": Features: %u, PxP: %s, History: %u, #CTX-ID: %u",
1295 (EXTRACT_U_1(p
+ 2) & 0xc0) >> 6,
1296 (EXTRACT_U_1(p
+ 2) & 0x20) ? "Enabled" : "Disabled",
1297 EXTRACT_U_1(p
+ 2) & 0x1f,
1298 EXTRACT_U_1(p
+ 3));
1300 case CCPOPT_DEFLATE
:
1302 ND_PRINT(" (length bogus, should be >= 4)");
1306 ND_PRINT(": Window: %uK, Method: %s (0x%x), MBZ: %u, CHK: %u",
1307 (EXTRACT_U_1(p
+ 2) & 0xf0) >> 4,
1308 ((EXTRACT_U_1(p
+ 2) & 0x0f) == 8) ? "zlib" : "unknown",
1309 EXTRACT_U_1(p
+ 2) & 0x0f,
1310 (EXTRACT_U_1(p
+ 3) & 0xfc) >> 2,
1311 EXTRACT_U_1(p
+ 3) & 0x03);
1314 /* XXX: to be supported */
1321 case CCPOPT_STACLZS
:
1332 * Unknown option; dump it as raw bytes now if we're
1333 * not going to do so below.
1335 if (ndo
->ndo_vflag
< 2)
1336 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2);
1339 if (ndo
->ndo_vflag
> 1)
1340 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2); /* exclude TLV header */
1349 /* BACP config options */
1351 print_bacp_config_options(netdissect_options
*ndo
,
1352 const u_char
*p
, u_int length
)
1359 opt
= EXTRACT_U_1(p
);
1360 len
= EXTRACT_U_1(p
+ 1);
1364 ND_PRINT("\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
1365 tok2str(bacconfopts_values
, "Unknown", opt
),
1371 ND_PRINT("\n\t %s Option (0x%02x), length %u",
1372 tok2str(bacconfopts_values
, "Unknown", opt
),
1379 ND_PRINT(" (length bogus, should be = 6)");
1383 ND_PRINT(": Magic-Num 0x%08x", EXTRACT_BE_U_4(p
+ 2));
1387 * Unknown option; dump it as raw bytes now if we're
1388 * not going to do so below.
1390 if (ndo
->ndo_vflag
< 2)
1391 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2);
1394 if (ndo
->ndo_vflag
> 1)
1395 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2); /* exclude TLV header */
1400 ND_PRINT("[|bacp]");
1405 ppp_hdlc(netdissect_options
*ndo
,
1406 const u_char
*p
, u_int length
)
1416 b
= (u_char
*)nd_malloc(ndo
, length
);
1421 * Unescape all the data into a temporary, private, buffer.
1422 * Do this so that we dont overwrite the original packet
1425 for (s
= p
, t
= b
, i
= length
; i
!= 0 && ND_TTEST_1(s
); i
--) {
1429 if (i
<= 1 || !ND_TTEST_1(s
))
1432 c
= EXTRACT_U_1(s
) ^ 0x20;
1439 * Change the end pointer, so bounds checks work.
1441 se
= ndo
->ndo_snapend
;
1442 ndo
->ndo_snapend
= t
;
1445 /* now lets guess about the payload codepoint format */
1448 proto
= EXTRACT_U_1(b
); /* start with a one-octet codepoint guess */
1452 ip_print(ndo
, b
+ 1, length
- 1);
1455 ip6_print(ndo
, b
+ 1, length
- 1);
1457 default: /* no luck - try next guess */
1463 proto
= EXTRACT_BE_U_2(b
); /* next guess - load two octets */
1466 case (PPP_ADDRESS
<< 8 | PPP_CONTROL
): /* looks like a PPP frame */
1469 proto
= EXTRACT_BE_U_2(b
+ 2); /* load the PPP proto-id */
1470 handle_ppp(ndo
, proto
, b
+ 4, length
- 4);
1472 default: /* last guess - proto must be a PPP proto-id */
1473 handle_ppp(ndo
, proto
, b
+ 2, length
- 2);
1478 ndo
->ndo_snapend
= se
;
1482 ndo
->ndo_snapend
= se
;
1483 nd_print_trunc(ndo
);
1489 handle_ppp(netdissect_options
*ndo
,
1490 u_int proto
, const u_char
*p
, u_int length
)
1492 if ((proto
& 0xff00) == 0x7e00) { /* is this an escape code ? */
1493 ppp_hdlc(ndo
, p
- 1, length
);
1498 case PPP_LCP
: /* fall through */
1505 handle_ctrl_proto(ndo
, proto
, p
, length
);
1508 handle_mlppp(ndo
, p
, length
);
1511 handle_chap(ndo
, p
, length
);
1514 handle_pap(ndo
, p
, length
);
1516 case PPP_BAP
: /* XXX: not yet completed */
1517 handle_bap(ndo
, p
, length
);
1519 case ETHERTYPE_IP
: /*XXX*/
1522 ip_print(ndo
, p
, length
);
1524 case ETHERTYPE_IPV6
: /*XXX*/
1526 ip6_print(ndo
, p
, length
);
1528 case ETHERTYPE_IPX
: /*XXX*/
1530 ipx_print(ndo
, p
, length
);
1533 isoclns_print(ndo
, p
, length
);
1535 case PPP_MPLS_UCAST
:
1536 case PPP_MPLS_MCAST
:
1537 mpls_print(ndo
, p
, length
);
1540 ND_PRINT("compressed PPP data");
1543 ND_PRINT("%s ", tok2str(ppptype2str
, "unknown PPP protocol (0x%04x)", proto
));
1544 print_unknown_data(ndo
, p
, "\n\t", length
);
1549 /* Standard PPP printer */
1551 ppp_print(netdissect_options
*ndo
,
1552 const u_char
*p
, u_int length
)
1554 u_int proto
,ppp_header
;
1555 u_int olen
= length
; /* _o_riginal length */
1558 ndo
->ndo_protocol
= "ppp";
1560 * Here, we assume that p points to the Address and Control
1561 * field (if they present).
1566 ppp_header
= EXTRACT_BE_U_2(p
);
1568 switch(ppp_header
) {
1569 case (PPP_WITHDIRECTION_IN
<< 8 | PPP_CONTROL
):
1570 if (ndo
->ndo_eflag
) ND_PRINT("In ");
1575 case (PPP_WITHDIRECTION_OUT
<< 8 | PPP_CONTROL
):
1576 if (ndo
->ndo_eflag
) ND_PRINT("Out ");
1581 case (PPP_ADDRESS
<< 8 | PPP_CONTROL
):
1582 p
+= 2; /* ACFC not used */
1594 if (EXTRACT_U_1(p
) % 2) {
1595 proto
= EXTRACT_U_1(p
); /* PFC is used */
1601 proto
= EXTRACT_BE_U_2(p
);
1608 ND_PRINT("%s (0x%04x), length %u: ",
1609 tok2str(ppptype2str
, "unknown", proto
),
1613 handle_ppp(ndo
, proto
, p
, length
);
1616 nd_print_trunc(ndo
);
1621 /* PPP I/F printer */
1623 ppp_if_print(netdissect_options
*ndo
,
1624 const struct pcap_pkthdr
*h
, const u_char
*p
)
1626 u_int length
= h
->len
;
1627 u_int caplen
= h
->caplen
;
1629 ndo
->ndo_protocol
= "ppp_if";
1630 if (caplen
< PPP_HDRLEN
) {
1631 nd_print_trunc(ndo
);
1637 * XXX: seems to assume that there are 2 octets prepended to an
1638 * actual PPP frame. The 1st octet looks like Input/Output flag
1639 * while 2nd octet is unknown, at least to me
1640 * (mshindo@mshindo.net).
1642 * That was what the original tcpdump code did.
1644 * FreeBSD's "if_ppp.c" *does* set the first octet to 1 for outbound
1645 * packets and 0 for inbound packets - but only if the
1646 * protocol field has the 0x8000 bit set (i.e., it's a network
1647 * control protocol); it does so before running the packet through
1648 * "bpf_filter" to see if it should be discarded, and to see
1649 * if we should update the time we sent the most recent packet...
1651 * ...but it puts the original address field back after doing
1654 * NetBSD's "if_ppp.c" doesn't set the first octet in that fashion.
1656 * I don't know if any PPP implementation handed up to a BPF
1657 * device packets with the first octet being 1 for outbound and
1658 * 0 for inbound packets, so I (guy@alum.mit.edu) don't know
1659 * whether that ever needs to be checked or not.
1661 * Note that NetBSD has a DLT_PPP_SERIAL, which it uses for PPP,
1662 * and its tcpdump appears to assume that the frame always
1663 * begins with an address field and a control field, and that
1664 * the address field might be 0x0f or 0x8f, for Cisco
1665 * point-to-point with HDLC framing as per section 4.3.1 of RFC
1666 * 1547, as well as 0xff, for PPP in HDLC-like framing as per
1669 * (Is the Cisco framing in question what DLT_C_HDLC, in
1673 ND_PRINT("%c %4d %02x ", EXTRACT_U_1(p
) ? 'O' : 'I',
1674 length
, EXTRACT_U_1(p
+ 1));
1677 ppp_print(ndo
, p
, length
);
1683 * PPP I/F printer to use if we know that RFC 1662-style PPP in HDLC-like
1684 * framing, or Cisco PPP with HDLC framing as per section 4.3.1 of RFC 1547,
1685 * is being used (i.e., we don't check for PPP_ADDRESS and PPP_CONTROL,
1686 * discard them *if* those are the first two octets, and parse the remaining
1687 * packet as a PPP packet, as "ppp_print()" does).
1689 * This handles, for example, DLT_PPP_SERIAL in NetBSD.
1692 ppp_hdlc_if_print(netdissect_options
*ndo
,
1693 const struct pcap_pkthdr
*h
, const u_char
*p
)
1695 u_int length
= h
->len
;
1696 u_int caplen
= h
->caplen
;
1700 ndo
->ndo_protocol
= "ppp_hdlc_if";
1702 nd_print_trunc(ndo
);
1706 switch (EXTRACT_U_1(p
)) {
1710 nd_print_trunc(ndo
);
1715 ND_PRINT("%02x %02x %u ", EXTRACT_U_1(p
),
1716 EXTRACT_U_1(p
+ 1), length
);
1721 proto
= EXTRACT_BE_U_2(p
);
1725 ND_PRINT("%s: ", tok2str(ppptype2str
, "unknown PPP protocol (0x%04x)", proto
));
1727 handle_ppp(ndo
, proto
, p
, length
);
1732 return (chdlc_if_print(ndo
, h
, p
));
1736 nd_print_trunc(ndo
);
1741 ND_PRINT("%02x %02x %u ", EXTRACT_U_1(p
),
1742 EXTRACT_U_1(p
+ 1), length
);
1747 * XXX - NetBSD's "ppp_netbsd_serial_if_print()" treats
1748 * the next two octets as an Ethernet type; does that
1751 ND_PRINT("unknown addr %02x; ctrl %02x", EXTRACT_U_1(p
),
1752 EXTRACT_U_1(p
+ 1));
1759 #define PPP_BSDI_HDRLEN 24
1761 /* BSD/OS specific PPP printer */
1763 ppp_bsdos_if_print(netdissect_options
*ndo _U_
,
1764 const struct pcap_pkthdr
*h _U_
, const u_char
*p _U_
)
1768 u_int length
= h
->len
;
1769 u_int caplen
= h
->caplen
;
1775 ndo
->ndo_protocol
= "ppp_bsdos_if";
1776 if (caplen
< PPP_BSDI_HDRLEN
) {
1777 nd_print_trunc(ndo
);
1784 if (EXTRACT_U_1(p
) == PPP_ADDRESS
&&
1785 EXTRACT_U_1(p
+ 1) == PPP_CONTROL
) {
1787 ND_PRINT("%02x %02x ", EXTRACT_U_1(p
),
1788 EXTRACT_U_1(p
+ 1));
1794 ND_PRINT("%u ", length
);
1795 /* Retrieve the protocol type */
1796 if (EXTRACT_U_1(p
) & 01) {
1797 /* Compressed protocol field */
1798 ptype
= EXTRACT_U_1(p
);
1800 ND_PRINT("%02x ", ptype
);
1804 /* Un-compressed protocol field */
1805 ptype
= EXTRACT_BE_U_2(p
);
1807 ND_PRINT("%04x ", ptype
);
1814 ND_PRINT("%c ", EXTRACT_U_1(p
+ SLC_DIR
) ? 'O' : 'I');
1815 llhl
= EXTRACT_U_1(p
+ SLC_LLHL
);
1817 /* link level header */
1818 struct ppp_header
*ph
;
1820 q
= p
+ SLC_BPFHDRLEN
;
1821 ph
= (struct ppp_header
*)q
;
1822 if (ph
->phdr_addr
== PPP_ADDRESS
1823 && ph
->phdr_ctl
== PPP_CONTROL
) {
1825 ND_PRINT("%02x %02x ", EXTRACT_U_1(q
),
1826 EXTRACT_U_1(q
+ 1));
1827 ptype
= EXTRACT_BE_U_2(&ph
->phdr_type
);
1828 if (ndo
->ndo_eflag
&& (ptype
== PPP_VJC
|| ptype
== PPP_VJNC
)) {
1829 ND_PRINT("%s ", tok2str(ppptype2str
,
1830 "proto-#%u", ptype
));
1833 if (ndo
->ndo_eflag
) {
1835 for (i
= 0; i
< llhl
; i
++)
1836 ND_PRINT("%02x", EXTRACT_U_1(q
+ i
));
1842 ND_PRINT("%u ", length
);
1843 if (EXTRACT_U_1(p
+ SLC_CHL
)) {
1844 q
= p
+ SLC_BPFHDRLEN
+ llhl
;
1848 ptype
= vjc_print(ndo
, q
, ptype
);
1849 hdrlength
= PPP_BSDI_HDRLEN
;
1853 ip_print(ndo
, p
, length
);
1856 ip6_print(ndo
, p
, length
);
1858 case PPP_MPLS_UCAST
:
1859 case PPP_MPLS_MCAST
:
1860 mpls_print(ndo
, p
, length
);
1865 ptype
= vjc_print(ndo
, q
, ptype
);
1866 hdrlength
= PPP_BSDI_HDRLEN
;
1870 ip_print(ndo
, p
, length
);
1873 ip6_print(ndo
, p
, length
);
1875 case PPP_MPLS_UCAST
:
1876 case PPP_MPLS_MCAST
:
1877 mpls_print(ndo
, p
, length
);
1882 if (ndo
->ndo_eflag
) {
1884 for (i
= 0; i
< llhl
; i
++)
1886 EXTRACT_U_1(q
+ i
));
1893 hdrlength
= PPP_BSDI_HDRLEN
;
1896 length
-= hdrlength
;
1901 ip_print(p
, length
);
1904 ip6_print(ndo
, p
, length
);
1906 case PPP_MPLS_UCAST
:
1907 case PPP_MPLS_MCAST
:
1908 mpls_print(ndo
, p
, length
);
1911 ND_PRINT("%s ", tok2str(ppptype2str
, "unknown PPP protocol (0x%04x)", ptype
));
1917 #endif /* __bsdi__ */