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"
56 * The following constatns are defined by IANA. Please refer to
57 * http://www.isi.edu/in-notes/iana/assignments/ppp-numbers
58 * for the up-to-date information.
61 /* Protocol Codes defined in ppp.h */
63 static const struct tok ppptype2str
[] = {
67 { PPP_DECNET
, "DECNET" },
68 { PPP_APPLE
, "APPLE" },
70 { PPP_VJC
, "VJC IP" },
71 { PPP_VJNC
, "VJNC IP" },
72 { PPP_BRPDU
, "BRPDU" },
74 { PPP_VINES
, "VINES" },
75 { PPP_MPLS_UCAST
, "MPLS" },
76 { PPP_MPLS_MCAST
, "MPLS" },
77 { PPP_COMP
, "Compressed"},
81 { PPP_HELLO
, "HELLO" },
82 { PPP_LUXCOM
, "LUXCOM" },
85 { PPP_OSICP
, "OSICP" },
87 { PPP_DECNETCP
, "DECNETCP" },
88 { PPP_APPLECP
, "APPLECP" },
89 { PPP_IPXCP
, "IPXCP" },
90 { PPP_STIICP
, "STIICP" },
91 { PPP_VINESCP
, "VINESCP" },
92 { PPP_IPV6CP
, "IP6CP" },
93 { PPP_MPLSCP
, "MPLSCP" },
100 { PPP_SPAP
, "SPAP" },
101 { PPP_SPAP_OLD
, "Old-SPAP" },
102 { PPP_BACP
, "BACP" },
104 { PPP_MPCP
, "MLPPP-CP" },
109 /* Control Protocols (LCP/IPCP/CCP etc.) Codes defined in RFC 1661 */
111 #define CPCODES_VEXT 0 /* Vendor-Specific (RFC2153) */
112 #define CPCODES_CONF_REQ 1 /* Configure-Request */
113 #define CPCODES_CONF_ACK 2 /* Configure-Ack */
114 #define CPCODES_CONF_NAK 3 /* Configure-Nak */
115 #define CPCODES_CONF_REJ 4 /* Configure-Reject */
116 #define CPCODES_TERM_REQ 5 /* Terminate-Request */
117 #define CPCODES_TERM_ACK 6 /* Terminate-Ack */
118 #define CPCODES_CODE_REJ 7 /* Code-Reject */
119 #define CPCODES_PROT_REJ 8 /* Protocol-Reject (LCP only) */
120 #define CPCODES_ECHO_REQ 9 /* Echo-Request (LCP only) */
121 #define CPCODES_ECHO_RPL 10 /* Echo-Reply (LCP only) */
122 #define CPCODES_DISC_REQ 11 /* Discard-Request (LCP only) */
123 #define CPCODES_ID 12 /* Identification (LCP only) RFC1570 */
124 #define CPCODES_TIME_REM 13 /* Time-Remaining (LCP only) RFC1570 */
125 #define CPCODES_RESET_REQ 14 /* Reset-Request (CCP only) RFC1962 */
126 #define CPCODES_RESET_REP 15 /* Reset-Reply (CCP only) */
128 static const struct tok cpcodes
[] = {
129 {CPCODES_VEXT
, "Vendor-Extension"}, /* RFC2153 */
130 {CPCODES_CONF_REQ
, "Conf-Request"},
131 {CPCODES_CONF_ACK
, "Conf-Ack"},
132 {CPCODES_CONF_NAK
, "Conf-Nack"},
133 {CPCODES_CONF_REJ
, "Conf-Reject"},
134 {CPCODES_TERM_REQ
, "Term-Request"},
135 {CPCODES_TERM_ACK
, "Term-Ack"},
136 {CPCODES_CODE_REJ
, "Code-Reject"},
137 {CPCODES_PROT_REJ
, "Prot-Reject"},
138 {CPCODES_ECHO_REQ
, "Echo-Request"},
139 {CPCODES_ECHO_RPL
, "Echo-Reply"},
140 {CPCODES_DISC_REQ
, "Disc-Req"},
141 {CPCODES_ID
, "Ident"}, /* RFC1570 */
142 {CPCODES_TIME_REM
, "Time-Rem"}, /* RFC1570 */
143 {CPCODES_RESET_REQ
, "Reset-Req"}, /* RFC1962 */
144 {CPCODES_RESET_REP
, "Reset-Ack"}, /* RFC1962 */
148 /* LCP Config Options */
150 #define LCPOPT_VEXT 0
152 #define LCPOPT_ACCM 2
156 #define LCPOPT_DEP6 6
158 #define LCPOPT_ACFC 8
159 #define LCPOPT_FCSALT 9
160 #define LCPOPT_SDP 10
161 #define LCPOPT_NUMMODE 11
162 #define LCPOPT_DEP12 12
163 #define LCPOPT_CBACK 13
164 #define LCPOPT_DEP14 14
165 #define LCPOPT_DEP15 15
166 #define LCPOPT_DEP16 16
167 #define LCPOPT_MLMRRU 17
168 #define LCPOPT_MLSSNHF 18
169 #define LCPOPT_MLED 19
170 #define LCPOPT_PROP 20
171 #define LCPOPT_DCEID 21
172 #define LCPOPT_MPP 22
174 #define LCPOPT_LCPAOPT 24
175 #define LCPOPT_COBS 25
177 #define LCPOPT_MLHF 27
178 #define LCPOPT_I18N 28
179 #define LCPOPT_SDLOS 29
180 #define LCPOPT_PPPMUX 30
182 static const char *lcpconfopts
[] = {
183 "Vend-Ext", /* (0) */
186 "Auth-Prot", /* (3) */
187 "Qual-Prot", /* (4) */
188 "Magic-Num", /* (5) */
189 "deprecated(6)", /* used to be a Quality Protocol */
194 "Num-Mode", /* (11) */
195 "deprecated(12)", /* used to be a Multi-Link-Procedure*/
196 "Call-Back", /* (13) */
197 "deprecated(14)", /* used to be a Connect-Time */
198 "deprecated(15)", /* used to be a Compund-Frames */
199 "deprecated(16)", /* used to be a Nominal-Data-Encap */
201 "12-Bit seq #", /* (18) */
202 "End-Disc", /* (19) */
203 "Proprietary", /* (20) */
206 "Link-Disc", /* (23) */
207 "LCP-Auth-Opt", /* (24) */
209 "Prefix-elision", /* (26) */
210 "Multilink-header-Form",/* (27) */
212 "SDL-over-SONET/SDH", /* (29) */
213 "PPP-Muxing", /* (30) */
216 #define NUM_LCPOPTS (sizeof lcpconfopts / sizeof lcpconfopts[0])
218 /* ECP - to be supported */
220 /* CCP Config Options */
222 #define CCPOPT_OUI 0 /* RFC1962 */
223 #define CCPOPT_PRED1 1 /* RFC1962 */
224 #define CCPOPT_PRED2 2 /* RFC1962 */
225 #define CCPOPT_PJUMP 3 /* RFC1962 */
226 /* 4-15 unassigned */
227 #define CCPOPT_HPPPC 16 /* RFC1962 */
228 #define CCPOPT_STACLZS 17 /* RFC1974 */
229 #define CCPOPT_MPPC 18 /* RFC2118 */
230 #define CCPOPT_GFZA 19 /* RFC1962 */
231 #define CCPOPT_V42BIS 20 /* RFC1962 */
232 #define CCPOPT_BSDCOMP 21 /* RFC1977 */
234 #define CCPOPT_LZSDCP 23 /* RFC1967 */
235 #define CCPOPT_MVRCA 24 /* RFC1975 */
236 #define CCPOPT_DEC 25 /* RFC1976 */
237 #define CCPOPT_DEFLATE 26 /* RFC1979 */
238 /* 27-254 unassigned */
239 #define CCPOPT_RESV 255 /* RFC1962 */
241 static const struct tok ccpconfopts_values
[] = {
242 { CCPOPT_OUI
, "OUI" },
243 { CCPOPT_PRED1
, "Pred-1" },
244 { CCPOPT_PRED2
, "Pred-2" },
245 { CCPOPT_PJUMP
, "Puddle" },
246 { CCPOPT_HPPPC
, "HP-PPC" },
247 { CCPOPT_STACLZS
, "Stac-LZS" },
248 { CCPOPT_MPPC
, "MPPC" },
249 { CCPOPT_GFZA
, "Gand-FZA" },
250 { CCPOPT_V42BIS
, "V.42bis" },
251 { CCPOPT_BSDCOMP
, "BSD-Comp" },
252 { CCPOPT_LZSDCP
, "LZS-DCP" },
253 { CCPOPT_MVRCA
, "MVRCA" },
254 { CCPOPT_DEC
, "DEC" },
255 { CCPOPT_DEFLATE
, "Deflate" },
256 { CCPOPT_RESV
, "Reserved"},
260 /* BACP Config Options */
262 #define BACPOPT_FPEER 1 /* RFC2125 */
264 static const struct tok bacconfopts_values
[] = {
265 { BACPOPT_FPEER
, "Favored-Peer" },
270 /* SDCP - to be supported */
272 /* IPCP Config Options */
273 #define IPCPOPT_2ADDR 1 /* RFC1172, RFC1332 (deprecated) */
274 #define IPCPOPT_IPCOMP 2 /* RFC1332 */
275 #define IPCPOPT_ADDR 3 /* RFC1332 */
276 #define IPCPOPT_MOBILE4 4 /* RFC2290 */
277 #define IPCPOPT_PRIDNS 129 /* RFC1877 */
278 #define IPCPOPT_PRINBNS 130 /* RFC1877 */
279 #define IPCPOPT_SECDNS 131 /* RFC1877 */
280 #define IPCPOPT_SECNBNS 132 /* RFC1877 */
282 static const struct tok ipcpopt_values
[] = {
283 { IPCPOPT_2ADDR
, "IP-Addrs" },
284 { IPCPOPT_IPCOMP
, "IP-Comp" },
285 { IPCPOPT_ADDR
, "IP-Addr" },
286 { IPCPOPT_MOBILE4
, "Home-Addr" },
287 { IPCPOPT_PRIDNS
, "Pri-DNS" },
288 { IPCPOPT_PRINBNS
, "Pri-NBNS" },
289 { IPCPOPT_SECDNS
, "Sec-DNS" },
290 { IPCPOPT_SECNBNS
, "Sec-NBNS" },
294 #define IPCPOPT_IPCOMP_HDRCOMP 0x61 /* rfc3544 */
295 #define IPCPOPT_IPCOMP_MINLEN 14
297 static const struct tok ipcpopt_compproto_values
[] = {
298 { PPP_VJC
, "VJ-Comp" },
299 { IPCPOPT_IPCOMP_HDRCOMP
, "IP Header Compression" },
303 static const struct tok ipcpopt_compproto_subopt_values
[] = {
304 { 1, "RTP-Compression" },
305 { 2, "Enhanced RTP-Compression" },
309 /* IP6CP Config Options */
312 static const struct tok ip6cpopt_values
[] = {
313 { IP6CP_IFID
, "Interface-ID" },
317 /* ATCP - to be supported */
318 /* OSINLCP - to be supported */
319 /* BVCP - to be supported */
320 /* BCP - to be supported */
321 /* IPXCP - to be supported */
322 /* MPLSCP - to be supported */
324 /* Auth Algorithms */
326 /* 0-4 Reserved (RFC1994) */
327 #define AUTHALG_CHAPMD5 5 /* RFC1994 */
328 #define AUTHALG_MSCHAP1 128 /* RFC2433 */
329 #define AUTHALG_MSCHAP2 129 /* RFC2795 */
331 static const struct tok authalg_values
[] = {
332 { AUTHALG_CHAPMD5
, "MD5" },
333 { AUTHALG_MSCHAP1
, "MS-CHAPv1" },
334 { AUTHALG_MSCHAP2
, "MS-CHAPv2" },
338 /* FCS Alternatives - to be supported */
340 /* Multilink Endpoint Discriminator (RFC1717) */
341 #define MEDCLASS_NULL 0 /* Null Class */
342 #define MEDCLASS_LOCAL 1 /* Locally Assigned */
343 #define MEDCLASS_IPV4 2 /* Internet Protocol (IPv4) */
344 #define MEDCLASS_MAC 3 /* IEEE 802.1 global MAC address */
345 #define MEDCLASS_MNB 4 /* PPP Magic Number Block */
346 #define MEDCLASS_PSNDN 5 /* Public Switched Network Director Number */
348 /* PPP LCP Callback */
349 #define CALLBACK_AUTH 0 /* Location determined by user auth */
350 #define CALLBACK_DSTR 1 /* Dialing string */
351 #define CALLBACK_LID 2 /* Location identifier */
352 #define CALLBACK_E164 3 /* E.164 number */
353 #define CALLBACK_X500 4 /* X.500 distinguished name */
354 #define CALLBACK_CBCP 6 /* Location is determined during CBCP nego */
356 static const struct tok ppp_callback_values
[] = {
357 { CALLBACK_AUTH
, "UserAuth" },
358 { CALLBACK_DSTR
, "DialString" },
359 { CALLBACK_LID
, "LocalID" },
360 { CALLBACK_E164
, "E.164" },
361 { CALLBACK_X500
, "X.500" },
362 { CALLBACK_CBCP
, "CBCP" },
373 static const struct tok chapcode_values
[] = {
374 { CHAP_CHAL
, "Challenge" },
375 { CHAP_RESP
, "Response" },
376 { CHAP_SUCC
, "Success" },
377 { CHAP_FAIL
, "Fail" },
387 static const struct tok papcode_values
[] = {
388 { PAP_AREQ
, "Auth-Req" },
389 { PAP_AACK
, "Auth-ACK" },
390 { PAP_ANAK
, "Auth-NACK" },
395 #define BAP_CALLREQ 1
396 #define BAP_CALLRES 2
404 static u_int
print_lcp_config_options(netdissect_options
*, const u_char
*p
, u_int
);
405 static u_int
print_ipcp_config_options(netdissect_options
*, const u_char
*p
, u_int
);
406 static u_int
print_ip6cp_config_options(netdissect_options
*, const u_char
*p
, u_int
);
407 static u_int
print_ccp_config_options(netdissect_options
*, const u_char
*p
, u_int
);
408 static u_int
print_bacp_config_options(netdissect_options
*, const u_char
*p
, u_int
);
409 static void handle_ppp(netdissect_options
*, u_int proto
, const u_char
*p
, u_int length
);
411 /* generic Control Protocol (e.g. LCP, IPCP, CCP, etc.) handler */
413 handle_ctrl_proto(netdissect_options
*ndo
,
414 u_int proto
, const u_char
*pptr
, u_int length
)
418 u_int (*pfunc
)(netdissect_options
*, const u_char
*, u_int
);
424 typestr
= tok2str(ppptype2str
, "unknown ctrl-proto (0x%04x)", proto
);
425 ND_PRINT((ndo
, "%s, ", typestr
));
427 if (length
< 4) /* FIXME weak boundary checking */
431 code
= EXTRACT_U_1(tptr
);
434 ND_PRINT((ndo
, "%s (0x%02x), id %u, length %u",
435 tok2str(cpcodes
, "Unknown Opcode",code
),
437 EXTRACT_U_1(tptr
), /* ID */
445 len
= EXTRACT_BE_U_2(tptr
);
449 ND_PRINT((ndo
, "\n\tencoded length %u (< 4))", len
));
454 ND_PRINT((ndo
, "\n\tencoded length %u (> packet length %u))", len
, length
));
459 ND_PRINT((ndo
, "\n\tencoded length %u (=Option(s) length %u)", len
, len
- 4));
462 return; /* there may be a NULL confreq etc. */
464 if (ndo
->ndo_vflag
> 1)
465 print_unknown_data(ndo
, pptr
- 2, "\n\t", 6);
473 ND_PRINT((ndo
, "\n\t Magic-Num 0x%08x", EXTRACT_BE_U_4(tptr
)));
476 ND_PRINT((ndo
, " Vendor: %s (%u)",
477 tok2str(oui_values
,"Unknown",EXTRACT_BE_U_3(tptr
)),
478 EXTRACT_BE_U_3(tptr
)));
479 /* XXX: need to decode Kind and Value(s)? */
481 case CPCODES_CONF_REQ
:
482 case CPCODES_CONF_ACK
:
483 case CPCODES_CONF_NAK
:
484 case CPCODES_CONF_REJ
:
485 x
= len
- 4; /* Code(1), Identifier(1) and Length(2) */
489 pfunc
= print_lcp_config_options
;
492 pfunc
= print_ipcp_config_options
;
495 pfunc
= print_ip6cp_config_options
;
498 pfunc
= print_ccp_config_options
;
501 pfunc
= print_bacp_config_options
;
505 * No print routine for the options for
512 if (pfunc
== NULL
) /* catch the above null pointer if unknown CP */
515 if ((j
= (*pfunc
)(ndo
, tptr
, len
)) == 0)
522 case CPCODES_TERM_REQ
:
523 case CPCODES_TERM_ACK
:
524 /* XXX: need to decode Data? */
526 case CPCODES_CODE_REJ
:
527 /* XXX: need to decode Rejected-Packet? */
529 case CPCODES_PROT_REJ
:
533 ND_PRINT((ndo
, "\n\t Rejected %s Protocol (0x%04x)",
534 tok2str(ppptype2str
,"unknown", EXTRACT_BE_U_2(tptr
)),
535 EXTRACT_BE_U_2(tptr
)));
536 /* XXX: need to decode Rejected-Information? - hexdump for now */
538 ND_PRINT((ndo
, "\n\t Rejected Packet"));
539 print_unknown_data(ndo
, tptr
+ 2, "\n\t ", len
- 2);
542 case CPCODES_ECHO_REQ
:
543 case CPCODES_ECHO_RPL
:
544 case CPCODES_DISC_REQ
:
548 ND_PRINT((ndo
, "\n\t Magic-Num 0x%08x", EXTRACT_BE_U_4(tptr
)));
549 /* XXX: need to decode Data? - hexdump for now */
551 ND_PRINT((ndo
, "\n\t -----trailing data-----"));
552 ND_TCHECK2(tptr
[4], len
- 8);
553 print_unknown_data(ndo
, tptr
+ 4, "\n\t ", len
- 8);
560 ND_PRINT((ndo
, "\n\t Magic-Num 0x%08x", EXTRACT_BE_U_4(tptr
)));
561 /* RFC 1661 says this is intended to be human readable */
563 ND_PRINT((ndo
, "\n\t Message\n\t "));
564 if (fn_printn(ndo
, tptr
+ 4, len
- 4, ndo
->ndo_snapend
))
568 case CPCODES_TIME_REM
:
572 ND_PRINT((ndo
, "\n\t Magic-Num 0x%08x", EXTRACT_BE_U_4(tptr
)));
573 ND_TCHECK_4(tptr
+ 4);
574 ND_PRINT((ndo
, ", Seconds-Remaining %us", EXTRACT_BE_U_4(tptr
+ 4)));
575 /* XXX: need to decode Message? */
578 /* XXX this is dirty but we do not get the
579 * original pointer passed to the begin
581 if (ndo
->ndo_vflag
<= 1)
582 print_unknown_data(ndo
, pptr
- 2, "\n\t ", length
+ 2);
588 ND_PRINT((ndo
, "[|%s]", typestr
));
591 /* LCP config options */
593 print_lcp_config_options(netdissect_options
*ndo
,
594 const u_char
*p
, u_int length
)
601 opt
= EXTRACT_U_1(p
);
602 len
= EXTRACT_U_1(p
+ 1);
606 if (opt
< NUM_LCPOPTS
)
607 ND_PRINT((ndo
, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
608 lcpconfopts
[opt
], opt
, len
));
610 ND_PRINT((ndo
, "\n\tunknown LCP option 0x%02x", opt
));
613 if (opt
< NUM_LCPOPTS
)
614 ND_PRINT((ndo
, "\n\t %s Option (0x%02x), length %u", lcpconfopts
[opt
], opt
, len
));
616 ND_PRINT((ndo
, "\n\tunknown LCP option 0x%02x", opt
));
623 ND_PRINT((ndo
, " (length bogus, should be >= 6)"));
627 ND_PRINT((ndo
, ": Vendor: %s (%u)",
628 tok2str(oui_values
,"Unknown",EXTRACT_BE_U_3(p
+ 2)),
629 EXTRACT_BE_U_3(p
+ 2)));
632 ND_PRINT((ndo
, ", kind: 0x%02x", EXTRACT_U_1(p
+ 5)));
633 ND_PRINT((ndo
, ", Value: 0x"));
634 for (i
= 0; i
< len
- 6; i
++) {
635 ND_TCHECK_1(p
+ 6 + i
);
636 ND_PRINT((ndo
, "%02x", EXTRACT_U_1(p
+ 6 + i
)));
642 ND_PRINT((ndo
, " (length bogus, should be = 4)"));
646 ND_PRINT((ndo
, ": %u", EXTRACT_BE_U_2(p
+ 2)));
650 ND_PRINT((ndo
, " (length bogus, should be = 6)"));
654 ND_PRINT((ndo
, ": 0x%08x", EXTRACT_BE_U_4(p
+ 2)));
658 ND_PRINT((ndo
, " (length bogus, should be >= 4)"));
662 ND_PRINT((ndo
, ": %s", tok2str(ppptype2str
, "Unknown Auth Proto (0x04x)", EXTRACT_BE_U_2(p
+ 2))));
664 switch (EXTRACT_BE_U_2(p
+ 2)) {
667 ND_PRINT((ndo
, ", %s", tok2str(authalg_values
, "Unknown Auth Alg %u", EXTRACT_U_1(p
+ 4))));
669 case PPP_PAP
: /* fall through */
675 print_unknown_data(ndo
, p
, "\n\t", len
);
680 ND_PRINT((ndo
, " (length bogus, should be >= 4)"));
684 if (EXTRACT_BE_U_2(p
+ 2) == PPP_LQM
)
685 ND_PRINT((ndo
, ": LQR"));
687 ND_PRINT((ndo
, ": unknown"));
691 ND_PRINT((ndo
, " (length bogus, should be = 6)"));
695 ND_PRINT((ndo
, ": 0x%08x", EXTRACT_BE_U_4(p
+ 2)));
703 ND_PRINT((ndo
, " (length bogus, should be = 4)"));
707 ND_PRINT((ndo
, ": 0x%04x", EXTRACT_BE_U_2(p
+ 2)));
711 ND_PRINT((ndo
, " (length bogus, should be >= 3)"));
714 ND_PRINT((ndo
, ": "));
716 ND_PRINT((ndo
, ": Callback Operation %s (%u)",
717 tok2str(ppp_callback_values
, "Unknown", EXTRACT_U_1(p
+ 2)),
718 EXTRACT_U_1(p
+ 2)));
722 ND_PRINT((ndo
, " (length bogus, should be = 4)"));
726 ND_PRINT((ndo
, ": %u", EXTRACT_BE_U_2(p
+ 2)));
730 ND_PRINT((ndo
, " (length bogus, should be >= 3)"));
734 switch (EXTRACT_U_1(p
+ 2)) { /* class */
736 ND_PRINT((ndo
, ": Null"));
739 ND_PRINT((ndo
, ": Local")); /* XXX */
743 ND_PRINT((ndo
, " (length bogus, should be = 7)"));
747 ND_PRINT((ndo
, ": IPv4 %s", ipaddr_string(ndo
, p
+ 3)));
751 ND_PRINT((ndo
, " (length bogus, should be = 9)"));
755 ND_PRINT((ndo
, ": MAC %s", etheraddr_string(ndo
, p
+ 3)));
758 ND_PRINT((ndo
, ": Magic-Num-Block")); /* XXX */
761 ND_PRINT((ndo
, ": PSNDN")); /* XXX */
764 ND_PRINT((ndo
, ": Unknown class %u", EXTRACT_U_1(p
+ 2)));
769 /* XXX: to be supported */
794 * Unknown option; dump it as raw bytes now if we're
795 * not going to do so below.
797 if (ndo
->ndo_vflag
< 2)
798 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2);
802 if (ndo
->ndo_vflag
> 1)
803 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2); /* exclude TLV header */
808 ND_PRINT((ndo
, "[|lcp]"));
813 static const struct tok ppp_ml_flag_values
[] = {
820 handle_mlppp(netdissect_options
*ndo
,
821 const u_char
*p
, u_int length
)
824 ND_PRINT((ndo
, "MLPPP, "));
827 ND_PRINT((ndo
, "[|mlppp]"));
830 if (!ND_TTEST_2(p
)) {
831 ND_PRINT((ndo
, "[|mlppp]"));
835 ND_PRINT((ndo
, "seq 0x%03x, Flags [%s], length %u",
836 (EXTRACT_BE_U_2(p
))&0x0fff, /* only support 12-Bit sequence space for now */
837 bittok2str(ppp_ml_flag_values
, "none", EXTRACT_U_1(p
) & 0xc0),
843 handle_chap(netdissect_options
*ndo
,
844 const u_char
*p
, u_int length
)
847 u_int val_size
, name_size
, msg_size
;
853 ND_PRINT((ndo
, "[|chap]"));
855 } else if (length
< 4) {
857 ND_PRINT((ndo
, "[|chap 0x%02x]", EXTRACT_U_1(p
)));
862 code
= EXTRACT_U_1(p
);
863 ND_PRINT((ndo
, "CHAP, %s (0x%02x)",
864 tok2str(chapcode_values
,"unknown",code
),
869 ND_PRINT((ndo
, ", id %u", EXTRACT_U_1(p
))); /* ID */
873 len
= EXTRACT_BE_U_2(p
);
877 * Note that this is a generic CHAP decoding routine. Since we
878 * don't know which flavor of CHAP (i.e. CHAP-MD5, MS-CHAPv1,
879 * MS-CHAPv2) is used at this point, we can't decode packet
880 * specifically to each algorithms. Instead, we simply decode
881 * the GCD (Gratest Common Denominator) for all algorithms.
886 if (length
- (p
- p0
) < 1)
889 val_size
= EXTRACT_U_1(p
); /* value size */
891 if (length
- (p
- p0
) < val_size
)
893 ND_PRINT((ndo
, ", Value "));
894 for (i
= 0; i
< val_size
; i
++) {
896 ND_PRINT((ndo
, "%02x", EXTRACT_U_1(p
)));
899 name_size
= len
- (p
- p0
);
900 ND_PRINT((ndo
, ", Name "));
901 for (i
= 0; i
< name_size
; i
++) {
903 safeputchar(ndo
, EXTRACT_U_1(p
));
909 msg_size
= len
- (p
- p0
);
910 ND_PRINT((ndo
, ", Msg "));
911 for (i
= 0; i
< msg_size
; i
++) {
913 safeputchar(ndo
, EXTRACT_U_1(p
));
921 ND_PRINT((ndo
, "[|chap]"));
924 /* PAP (see RFC 1334) */
926 handle_pap(netdissect_options
*ndo
,
927 const u_char
*p
, u_int length
)
930 u_int peerid_len
, passwd_len
, msg_len
;
936 ND_PRINT((ndo
, "[|pap]"));
938 } else if (length
< 4) {
940 ND_PRINT((ndo
, "[|pap 0x%02x]", EXTRACT_U_1(p
)));
945 code
= EXTRACT_U_1(p
);
946 ND_PRINT((ndo
, "PAP, %s (0x%02x)",
947 tok2str(papcode_values
, "unknown", code
),
952 ND_PRINT((ndo
, ", id %u", EXTRACT_U_1(p
))); /* ID */
956 len
= EXTRACT_BE_U_2(p
);
960 ND_PRINT((ndo
, ", length %u > packet size", len
));
964 if (length
< (size_t)(p
- p0
)) {
965 ND_PRINT((ndo
, ", length %u < PAP header length", length
));
971 /* A valid Authenticate-Request is 6 or more octets long. */
974 if (length
- (p
- p0
) < 1)
977 peerid_len
= EXTRACT_U_1(p
); /* Peer-ID Length */
979 if (length
- (p
- p0
) < peerid_len
)
981 ND_PRINT((ndo
, ", Peer "));
982 for (i
= 0; i
< peerid_len
; i
++) {
984 safeputchar(ndo
, EXTRACT_U_1(p
));
988 if (length
- (p
- p0
) < 1)
991 passwd_len
= EXTRACT_U_1(p
); /* Password Length */
993 if (length
- (p
- p0
) < passwd_len
)
995 ND_PRINT((ndo
, ", Name "));
996 for (i
= 0; i
< passwd_len
; i
++) {
998 safeputchar(ndo
, EXTRACT_U_1(p
));
1004 /* Although some implementations ignore truncation at
1005 * this point and at least one generates a truncated
1006 * packet, RFC 1334 section 2.2.2 clearly states that
1007 * both AACK and ANAK are at least 5 bytes long.
1011 if (length
- (p
- p0
) < 1)
1014 msg_len
= EXTRACT_U_1(p
); /* Msg-Length */
1016 if (length
- (p
- p0
) < msg_len
)
1018 ND_PRINT((ndo
, ", Msg "));
1019 for (i
= 0; i
< msg_len
; i
++) {
1021 safeputchar(ndo
, EXTRACT_U_1(p
));
1029 ND_PRINT((ndo
, "[|pap]"));
1034 handle_bap(netdissect_options
*ndo _U_
,
1035 const u_char
*p _U_
, u_int length _U_
)
1037 /* XXX: to be supported!! */
1041 /* IPCP config options */
1043 print_ipcp_config_options(netdissect_options
*ndo
,
1044 const u_char
*p
, u_int length
)
1047 u_int compproto
, ipcomp_subopttotallen
, ipcomp_subopt
, ipcomp_suboptlen
;
1052 opt
= EXTRACT_U_1(p
);
1053 len
= EXTRACT_U_1(p
+ 1);
1057 ND_PRINT((ndo
, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
1058 tok2str(ipcpopt_values
,"unknown",opt
),
1064 ND_PRINT((ndo
, "\n\t %s Option (0x%02x), length %u",
1065 tok2str(ipcpopt_values
,"unknown",opt
),
1070 case IPCPOPT_2ADDR
: /* deprecated */
1072 ND_PRINT((ndo
, " (length bogus, should be = 10)"));
1076 ND_PRINT((ndo
, ": src %s, dst %s",
1077 ipaddr_string(ndo
, p
+ 2),
1078 ipaddr_string(ndo
, p
+ 6)));
1080 case IPCPOPT_IPCOMP
:
1082 ND_PRINT((ndo
, " (length bogus, should be >= 4)"));
1086 compproto
= EXTRACT_BE_U_2(p
+ 2);
1088 ND_PRINT((ndo
, ": %s (0x%02x):",
1089 tok2str(ipcpopt_compproto_values
, "Unknown", compproto
),
1092 switch (compproto
) {
1094 /* XXX: VJ-Comp parameters should be decoded */
1096 case IPCPOPT_IPCOMP_HDRCOMP
:
1097 if (len
< IPCPOPT_IPCOMP_MINLEN
) {
1098 ND_PRINT((ndo
, " (length bogus, should be >= %u)",
1099 IPCPOPT_IPCOMP_MINLEN
));
1103 ND_TCHECK2(*(p
+ 2), IPCPOPT_IPCOMP_MINLEN
);
1104 ND_PRINT((ndo
, "\n\t TCP Space %u, non-TCP Space %u" \
1105 ", maxPeriod %u, maxTime %u, maxHdr %u",
1106 EXTRACT_BE_U_2(p
+ 4),
1107 EXTRACT_BE_U_2(p
+ 6),
1108 EXTRACT_BE_U_2(p
+ 8),
1109 EXTRACT_BE_U_2(p
+ 10),
1110 EXTRACT_BE_U_2(p
+ 12)));
1112 /* suboptions present ? */
1113 if (len
> IPCPOPT_IPCOMP_MINLEN
) {
1114 ipcomp_subopttotallen
= len
- IPCPOPT_IPCOMP_MINLEN
;
1115 p
+= IPCPOPT_IPCOMP_MINLEN
;
1117 ND_PRINT((ndo
, "\n\t Suboptions, length %u", ipcomp_subopttotallen
));
1119 while (ipcomp_subopttotallen
>= 2) {
1121 ipcomp_subopt
= EXTRACT_U_1(p
);
1122 ipcomp_suboptlen
= EXTRACT_U_1(p
+ 1);
1125 if (ipcomp_subopt
== 0 ||
1126 ipcomp_suboptlen
== 0 )
1129 /* XXX: just display the suboptions for now */
1130 ND_PRINT((ndo
, "\n\t\t%s Suboption #%u, length %u",
1131 tok2str(ipcpopt_compproto_subopt_values
,
1137 ipcomp_subopttotallen
-= ipcomp_suboptlen
;
1138 p
+= ipcomp_suboptlen
;
1147 case IPCPOPT_ADDR
: /* those options share the same format - fall through */
1148 case IPCPOPT_MOBILE4
:
1149 case IPCPOPT_PRIDNS
:
1150 case IPCPOPT_PRINBNS
:
1151 case IPCPOPT_SECDNS
:
1152 case IPCPOPT_SECNBNS
:
1154 ND_PRINT((ndo
, " (length bogus, should be = 6)"));
1158 ND_PRINT((ndo
, ": %s", ipaddr_string(ndo
, p
+ 2)));
1162 * Unknown option; dump it as raw bytes now if we're
1163 * not going to do so below.
1165 if (ndo
->ndo_vflag
< 2)
1166 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2);
1169 if (ndo
->ndo_vflag
> 1)
1170 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2); /* exclude TLV header */
1174 ND_PRINT((ndo
, "[|ipcp]"));
1178 /* IP6CP config options */
1180 print_ip6cp_config_options(netdissect_options
*ndo
,
1181 const u_char
*p
, u_int length
)
1188 opt
= EXTRACT_U_1(p
);
1189 len
= EXTRACT_U_1(p
+ 1);
1193 ND_PRINT((ndo
, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
1194 tok2str(ip6cpopt_values
,"unknown",opt
),
1200 ND_PRINT((ndo
, "\n\t %s Option (0x%02x), length %u",
1201 tok2str(ip6cpopt_values
,"unknown",opt
),
1208 ND_PRINT((ndo
, " (length bogus, should be = 10)"));
1212 ND_PRINT((ndo
, ": %04x:%04x:%04x:%04x",
1213 EXTRACT_BE_U_2(p
+ 2),
1214 EXTRACT_BE_U_2(p
+ 4),
1215 EXTRACT_BE_U_2(p
+ 6),
1216 EXTRACT_BE_U_2(p
+ 8)));
1220 * Unknown option; dump it as raw bytes now if we're
1221 * not going to do so below.
1223 if (ndo
->ndo_vflag
< 2)
1224 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2);
1227 if (ndo
->ndo_vflag
> 1)
1228 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2); /* exclude TLV header */
1233 ND_PRINT((ndo
, "[|ip6cp]"));
1238 /* CCP config options */
1240 print_ccp_config_options(netdissect_options
*ndo
,
1241 const u_char
*p
, u_int length
)
1248 opt
= EXTRACT_U_1(p
);
1249 len
= EXTRACT_U_1(p
+ 1);
1253 ND_PRINT((ndo
, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
1254 tok2str(ccpconfopts_values
, "Unknown", opt
),
1260 ND_PRINT((ndo
, "\n\t %s Option (0x%02x), length %u",
1261 tok2str(ccpconfopts_values
, "Unknown", opt
),
1266 case CCPOPT_BSDCOMP
:
1268 ND_PRINT((ndo
, " (length bogus, should be >= 3)"));
1272 ND_PRINT((ndo
, ": Version: %u, Dictionary Bits: %u",
1273 EXTRACT_U_1(p
+ 2) >> 5,
1274 EXTRACT_U_1(p
+ 2) & 0x1f));
1278 ND_PRINT((ndo
, " (length bogus, should be >= 4)"));
1282 ND_PRINT((ndo
, ": Features: %u, PxP: %s, History: %u, #CTX-ID: %u",
1283 (EXTRACT_U_1(p
+ 2) & 0xc0) >> 6,
1284 (EXTRACT_U_1(p
+ 2) & 0x20) ? "Enabled" : "Disabled",
1285 EXTRACT_U_1(p
+ 2) & 0x1f,
1286 EXTRACT_U_1(p
+ 3)));
1288 case CCPOPT_DEFLATE
:
1290 ND_PRINT((ndo
, " (length bogus, should be >= 4)"));
1294 ND_PRINT((ndo
, ": Window: %uK, Method: %s (0x%x), MBZ: %u, CHK: %u",
1295 (EXTRACT_U_1(p
+ 2) & 0xf0) >> 4,
1296 ((EXTRACT_U_1(p
+ 2) & 0x0f) == 8) ? "zlib" : "unknown",
1297 EXTRACT_U_1(p
+ 2) & 0x0f,
1298 (EXTRACT_U_1(p
+ 3) & 0xfc) >> 2,
1299 EXTRACT_U_1(p
+ 3) & 0x03));
1302 /* XXX: to be supported */
1309 case CCPOPT_STACLZS
:
1320 * Unknown option; dump it as raw bytes now if we're
1321 * not going to do so below.
1323 if (ndo
->ndo_vflag
< 2)
1324 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2);
1327 if (ndo
->ndo_vflag
> 1)
1328 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2); /* exclude TLV header */
1333 ND_PRINT((ndo
, "[|ccp]"));
1337 /* BACP config options */
1339 print_bacp_config_options(netdissect_options
*ndo
,
1340 const u_char
*p
, u_int length
)
1347 opt
= EXTRACT_U_1(p
);
1348 len
= EXTRACT_U_1(p
+ 1);
1352 ND_PRINT((ndo
, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
1353 tok2str(bacconfopts_values
, "Unknown", opt
),
1359 ND_PRINT((ndo
, "\n\t %s Option (0x%02x), length %u",
1360 tok2str(bacconfopts_values
, "Unknown", opt
),
1367 ND_PRINT((ndo
, " (length bogus, should be = 6)"));
1371 ND_PRINT((ndo
, ": Magic-Num 0x%08x", EXTRACT_BE_U_4(p
+ 2)));
1375 * Unknown option; dump it as raw bytes now if we're
1376 * not going to do so below.
1378 if (ndo
->ndo_vflag
< 2)
1379 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2);
1382 if (ndo
->ndo_vflag
> 1)
1383 print_unknown_data(ndo
, p
+ 2, "\n\t ", len
- 2); /* exclude TLV header */
1388 ND_PRINT((ndo
, "[|bacp]"));
1393 ppp_hdlc(netdissect_options
*ndo
,
1394 const u_char
*p
, u_int length
)
1404 b
= (u_char
*)malloc(length
);
1409 * Unescape all the data into a temporary, private, buffer.
1410 * Do this so that we dont overwrite the original packet
1413 for (s
= p
, t
= b
, i
= length
; i
!= 0 && ND_TTEST(*s
); i
--) {
1417 if (i
<= 1 || !ND_TTEST_1(s
))
1420 c
= EXTRACT_U_1(s
) ^ 0x20;
1427 * Change the end pointer, so bounds checks work.
1429 se
= ndo
->ndo_snapend
;
1430 ndo
->ndo_snapend
= t
;
1433 /* now lets guess about the payload codepoint format */
1436 proto
= EXTRACT_U_1(b
); /* start with a one-octet codepoint guess */
1440 ip_print(ndo
, b
+ 1, length
- 1);
1443 ip6_print(ndo
, b
+ 1, length
- 1);
1445 default: /* no luck - try next guess */
1451 proto
= EXTRACT_BE_U_2(b
); /* next guess - load two octets */
1454 case (PPP_ADDRESS
<< 8 | PPP_CONTROL
): /* looks like a PPP frame */
1457 proto
= EXTRACT_BE_U_2(b
+ 2); /* load the PPP proto-id */
1458 handle_ppp(ndo
, proto
, b
+ 4, length
- 4);
1460 default: /* last guess - proto must be a PPP proto-id */
1461 handle_ppp(ndo
, proto
, b
+ 2, length
- 2);
1466 ndo
->ndo_snapend
= se
;
1471 ndo
->ndo_snapend
= se
;
1473 ND_PRINT((ndo
, "[|ppp]"));
1479 handle_ppp(netdissect_options
*ndo
,
1480 u_int proto
, const u_char
*p
, u_int length
)
1482 if ((proto
& 0xff00) == 0x7e00) { /* is this an escape code ? */
1483 ppp_hdlc(ndo
, p
- 1, length
);
1488 case PPP_LCP
: /* fall through */
1495 handle_ctrl_proto(ndo
, proto
, p
, length
);
1498 handle_mlppp(ndo
, p
, length
);
1501 handle_chap(ndo
, p
, length
);
1504 handle_pap(ndo
, p
, length
);
1506 case PPP_BAP
: /* XXX: not yet completed */
1507 handle_bap(ndo
, p
, length
);
1509 case ETHERTYPE_IP
: /*XXX*/
1512 ip_print(ndo
, p
, length
);
1514 case ETHERTYPE_IPV6
: /*XXX*/
1516 ip6_print(ndo
, p
, length
);
1518 case ETHERTYPE_IPX
: /*XXX*/
1520 ipx_print(ndo
, p
, length
);
1523 isoclns_print(ndo
, p
, length
);
1525 case PPP_MPLS_UCAST
:
1526 case PPP_MPLS_MCAST
:
1527 mpls_print(ndo
, p
, length
);
1530 ND_PRINT((ndo
, "compressed PPP data"));
1533 ND_PRINT((ndo
, "%s ", tok2str(ppptype2str
, "unknown PPP protocol (0x%04x)", proto
)));
1534 print_unknown_data(ndo
, p
, "\n\t", length
);
1539 /* Standard PPP printer */
1541 ppp_print(netdissect_options
*ndo
,
1542 register const u_char
*p
, u_int length
)
1544 u_int proto
,ppp_header
;
1545 u_int olen
= length
; /* _o_riginal length */
1549 * Here, we assume that p points to the Address and Control
1550 * field (if they present).
1555 ppp_header
= EXTRACT_BE_U_2(p
);
1557 switch(ppp_header
) {
1558 case (PPP_WITHDIRECTION_IN
<< 8 | PPP_CONTROL
):
1559 if (ndo
->ndo_eflag
) ND_PRINT((ndo
, "In "));
1564 case (PPP_WITHDIRECTION_OUT
<< 8 | PPP_CONTROL
):
1565 if (ndo
->ndo_eflag
) ND_PRINT((ndo
, "Out "));
1570 case (PPP_ADDRESS
<< 8 | PPP_CONTROL
):
1571 p
+= 2; /* ACFC not used */
1583 if (EXTRACT_U_1(p
) % 2) {
1584 proto
= EXTRACT_U_1(p
); /* PFC is used */
1590 proto
= EXTRACT_BE_U_2(p
);
1597 ND_PRINT((ndo
, "%s (0x%04x), length %u: ",
1598 tok2str(ppptype2str
, "unknown", proto
),
1602 handle_ppp(ndo
, proto
, p
, length
);
1605 ND_PRINT((ndo
, "[|ppp]"));
1610 /* PPP I/F printer */
1612 ppp_if_print(netdissect_options
*ndo
,
1613 const struct pcap_pkthdr
*h
, register const u_char
*p
)
1615 register u_int length
= h
->len
;
1616 register u_int caplen
= h
->caplen
;
1618 if (caplen
< PPP_HDRLEN
) {
1619 ND_PRINT((ndo
, "[|ppp]"));
1625 * XXX: seems to assume that there are 2 octets prepended to an
1626 * actual PPP frame. The 1st octet looks like Input/Output flag
1627 * while 2nd octet is unknown, at least to me
1628 * (mshindo@mshindo.net).
1630 * That was what the original tcpdump code did.
1632 * FreeBSD's "if_ppp.c" *does* set the first octet to 1 for outbound
1633 * packets and 0 for inbound packets - but only if the
1634 * protocol field has the 0x8000 bit set (i.e., it's a network
1635 * control protocol); it does so before running the packet through
1636 * "bpf_filter" to see if it should be discarded, and to see
1637 * if we should update the time we sent the most recent packet...
1639 * ...but it puts the original address field back after doing
1642 * NetBSD's "if_ppp.c" doesn't set the first octet in that fashion.
1644 * I don't know if any PPP implementation handed up to a BPF
1645 * device packets with the first octet being 1 for outbound and
1646 * 0 for inbound packets, so I (guy@alum.mit.edu) don't know
1647 * whether that ever needs to be checked or not.
1649 * Note that NetBSD has a DLT_PPP_SERIAL, which it uses for PPP,
1650 * and its tcpdump appears to assume that the frame always
1651 * begins with an address field and a control field, and that
1652 * the address field might be 0x0f or 0x8f, for Cisco
1653 * point-to-point with HDLC framing as per section 4.3.1 of RFC
1654 * 1547, as well as 0xff, for PPP in HDLC-like framing as per
1657 * (Is the Cisco framing in question what DLT_C_HDLC, in
1661 ND_PRINT((ndo
, "%c %4d %02x ", EXTRACT_U_1(p
) ? 'O' : 'I',
1662 length
, EXTRACT_U_1(p
+ 1)));
1665 ppp_print(ndo
, p
, length
);
1671 * PPP I/F printer to use if we know that RFC 1662-style PPP in HDLC-like
1672 * framing, or Cisco PPP with HDLC framing as per section 4.3.1 of RFC 1547,
1673 * is being used (i.e., we don't check for PPP_ADDRESS and PPP_CONTROL,
1674 * discard them *if* those are the first two octets, and parse the remaining
1675 * packet as a PPP packet, as "ppp_print()" does).
1677 * This handles, for example, DLT_PPP_SERIAL in NetBSD.
1680 ppp_hdlc_if_print(netdissect_options
*ndo
,
1681 const struct pcap_pkthdr
*h
, register const u_char
*p
)
1683 register u_int length
= h
->len
;
1684 register u_int caplen
= h
->caplen
;
1689 ND_PRINT((ndo
, "[|ppp]"));
1693 switch (EXTRACT_U_1(p
)) {
1696 if (caplen
< 4 || length
< 4) {
1697 ND_PRINT((ndo
, "[|ppp]"));
1702 ND_PRINT((ndo
, "%02x %02x %u ", EXTRACT_U_1(p
),
1703 EXTRACT_U_1(p
+ 1), length
));
1708 proto
= EXTRACT_BE_U_2(p
);
1712 ND_PRINT((ndo
, "%s: ", tok2str(ppptype2str
, "unknown PPP protocol (0x%04x)", proto
)));
1714 handle_ppp(ndo
, proto
, p
, length
);
1719 return (chdlc_if_print(ndo
, h
, p
));
1723 ND_PRINT((ndo
, "[|ppp]"));
1728 ND_PRINT((ndo
, "%02x %02x %d ", EXTRACT_U_1(p
),
1729 EXTRACT_U_1(p
+ 1), length
));
1734 * XXX - NetBSD's "ppp_netbsd_serial_if_print()" treats
1735 * the next two octets as an Ethernet type; does that
1738 ND_PRINT((ndo
, "unknown addr %02x; ctrl %02x", EXTRACT_U_1(p
),
1739 EXTRACT_U_1(p
+ 1)));
1746 #define PPP_BSDI_HDRLEN 24
1748 /* BSD/OS specific PPP printer */
1750 ppp_bsdos_if_print(netdissect_options
*ndo _U_
,
1751 const struct pcap_pkthdr
*h _U_
, register const u_char
*p _U_
)
1753 register u_int hdrlength
;
1755 register u_int length
= h
->len
;
1756 register u_int caplen
= h
->caplen
;
1762 if (caplen
< PPP_BSDI_HDRLEN
) {
1763 ND_PRINT((ndo
, "[|ppp]"));
1770 if (EXTRACT_U_1(p
) == PPP_ADDRESS
&&
1771 EXTRACT_U_1(p
+ 1) == PPP_CONTROL
) {
1773 ND_PRINT((ndo
, "%02x %02x ", EXTRACT_U_1(p
),
1774 EXTRACT_U_1(p
+ 1)));
1780 ND_PRINT((ndo
, "%d ", length
));
1781 /* Retrieve the protocol type */
1782 if (EXTRACT_U_1(p
) & 01) {
1783 /* Compressed protocol field */
1784 ptype
= EXTRACT_U_1(p
);
1786 ND_PRINT((ndo
, "%02x ", ptype
));
1790 /* Un-compressed protocol field */
1791 ptype
= EXTRACT_BE_U_2(p
);
1793 ND_PRINT((ndo
, "%04x ", ptype
));
1800 ND_PRINT((ndo
, "%c ", EXTRACT_U_1(p
+ SLC_DIR
) ? 'O' : 'I'));
1801 llhl
= EXTRACT_U_1(p
+ SLC_LLHL
);
1803 /* link level header */
1804 struct ppp_header
*ph
;
1806 q
= p
+ SLC_BPFHDRLEN
;
1807 ph
= (struct ppp_header
*)q
;
1808 if (ph
->phdr_addr
== PPP_ADDRESS
1809 && ph
->phdr_ctl
== PPP_CONTROL
) {
1811 ND_PRINT((ndo
, "%02x %02x ", EXTRACT_U_1(q
),
1812 EXTRACT_U_1(q
+ 1)));
1813 ptype
= EXTRACT_BE_U_2(&ph
->phdr_type
);
1814 if (ndo
->ndo_eflag
&& (ptype
== PPP_VJC
|| ptype
== PPP_VJNC
)) {
1815 ND_PRINT((ndo
, "%s ", tok2str(ppptype2str
,
1816 "proto-#%d", ptype
)));
1819 if (ndo
->ndo_eflag
) {
1820 ND_PRINT((ndo
, "LLH=["));
1821 for (i
= 0; i
< llhl
; i
++)
1822 ND_PRINT((ndo
, "%02x", EXTRACT_U_1(q
+ i
)));
1823 ND_PRINT((ndo
, "] "));
1828 ND_PRINT((ndo
, "%d ", length
));
1829 if (EXTRACT_U_1(p
+ SLC_CHL
)) {
1830 q
= p
+ SLC_BPFHDRLEN
+ llhl
;
1834 ptype
= vjc_print(ndo
, q
, ptype
);
1835 hdrlength
= PPP_BSDI_HDRLEN
;
1839 ip_print(ndo
, p
, length
);
1842 ip6_print(ndo
, p
, length
);
1844 case PPP_MPLS_UCAST
:
1845 case PPP_MPLS_MCAST
:
1846 mpls_print(ndo
, p
, length
);
1851 ptype
= vjc_print(ndo
, q
, ptype
);
1852 hdrlength
= PPP_BSDI_HDRLEN
;
1856 ip_print(ndo
, p
, length
);
1859 ip6_print(ndo
, p
, length
);
1861 case PPP_MPLS_UCAST
:
1862 case PPP_MPLS_MCAST
:
1863 mpls_print(ndo
, p
, length
);
1868 if (ndo
->ndo_eflag
) {
1869 ND_PRINT((ndo
, "CH=["));
1870 for (i
= 0; i
< llhl
; i
++)
1871 ND_PRINT((ndo
, "%02x",
1872 EXTRACT_U_1(q
+ i
)));
1873 ND_PRINT((ndo
, "] "));
1879 hdrlength
= PPP_BSDI_HDRLEN
;
1882 length
-= hdrlength
;
1887 ip_print(p
, length
);
1890 ip6_print(ndo
, p
, length
);
1892 case PPP_MPLS_UCAST
:
1893 case PPP_MPLS_MCAST
:
1894 mpls_print(ndo
, p
, length
);
1897 ND_PRINT((ndo
, "%s ", tok2str(ppptype2str
, "unknown PPP protocol (0x%04x)", ptype
)));
1903 #endif /* __bsdi__ */
1910 * c-style: whitesmith