141c99275SPeter Avalos /*
241c99275SPeter Avalos * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
341c99275SPeter Avalos * The Regents of the University of California. All rights reserved.
441c99275SPeter Avalos *
541c99275SPeter Avalos * Redistribution and use in source and binary forms, with or without
641c99275SPeter Avalos * modification, are permitted provided that: (1) source code distributions
741c99275SPeter Avalos * retain the above copyright notice and this paragraph in its entirety, (2)
841c99275SPeter Avalos * distributions including binary code include the above copyright notice and
941c99275SPeter Avalos * this paragraph in its entirety in the documentation or other materials
1041c99275SPeter Avalos * provided with the distribution, and (3) all advertising materials mentioning
1141c99275SPeter Avalos * features or use of this software display the following acknowledgement:
1241c99275SPeter Avalos * ``This product includes software developed by the University of California,
1341c99275SPeter Avalos * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
1441c99275SPeter Avalos * the University nor the names of its contributors may be used to endorse
1541c99275SPeter Avalos * or promote products derived from this software without specific prior
1641c99275SPeter Avalos * written permission.
1741c99275SPeter Avalos * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
1841c99275SPeter Avalos * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
1941c99275SPeter Avalos * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2041c99275SPeter Avalos *
2141c99275SPeter Avalos * Extensively modified by Motonori Shindo (mshindo@mshindo.net) for more
2241c99275SPeter Avalos * complete PPP support.
2341c99275SPeter Avalos */
2441c99275SPeter Avalos
25411677aeSAaron LI /* \summary: Point to Point Protocol (PPP) printer */
26411677aeSAaron LI
2741c99275SPeter Avalos /*
2841c99275SPeter Avalos * TODO:
2941c99275SPeter Avalos * o resolve XXX as much as possible
3041c99275SPeter Avalos * o MP support
3141c99275SPeter Avalos * o BAP support
3241c99275SPeter Avalos */
3341c99275SPeter Avalos
3441c99275SPeter Avalos #ifdef HAVE_CONFIG_H
35*ed775ee7SAntonio Huete Jimenez #include <config.h>
3641c99275SPeter Avalos #endif
3741c99275SPeter Avalos
38*ed775ee7SAntonio Huete Jimenez #include "netdissect-stdinc.h"
3941c99275SPeter Avalos
4041c99275SPeter Avalos #ifdef __bsdi__
4141c99275SPeter Avalos #include <net/slcompress.h>
4241c99275SPeter Avalos #include <net/if_ppp.h>
4341c99275SPeter Avalos #endif
4441c99275SPeter Avalos
45411677aeSAaron LI #include "netdissect.h"
4641c99275SPeter Avalos #include "extract.h"
4741c99275SPeter Avalos #include "addrtoname.h"
4841c99275SPeter Avalos #include "ppp.h"
4941c99275SPeter Avalos #include "chdlc.h"
5041c99275SPeter Avalos #include "ethertype.h"
5141c99275SPeter Avalos #include "oui.h"
52*ed775ee7SAntonio Huete Jimenez #include "netdissect-alloc.h"
5341c99275SPeter Avalos
5441c99275SPeter Avalos /*
55*ed775ee7SAntonio Huete Jimenez * The following constants are defined by IANA. Please refer to
56*ed775ee7SAntonio Huete Jimenez * https://www.isi.edu/in-notes/iana/assignments/ppp-numbers
5741c99275SPeter Avalos * for the up-to-date information.
5841c99275SPeter Avalos */
5941c99275SPeter Avalos
6041c99275SPeter Avalos /* Protocol Codes defined in ppp.h */
6141c99275SPeter Avalos
62411677aeSAaron LI static const struct tok ppptype2str[] = {
6341c99275SPeter Avalos { PPP_IP, "IP" },
6441c99275SPeter Avalos { PPP_OSI, "OSI" },
6541c99275SPeter Avalos { PPP_NS, "NS" },
6641c99275SPeter Avalos { PPP_DECNET, "DECNET" },
6741c99275SPeter Avalos { PPP_APPLE, "APPLE" },
6841c99275SPeter Avalos { PPP_IPX, "IPX" },
6941c99275SPeter Avalos { PPP_VJC, "VJC IP" },
7041c99275SPeter Avalos { PPP_VJNC, "VJNC IP" },
7141c99275SPeter Avalos { PPP_BRPDU, "BRPDU" },
7241c99275SPeter Avalos { PPP_STII, "STII" },
7341c99275SPeter Avalos { PPP_VINES, "VINES" },
7441c99275SPeter Avalos { PPP_MPLS_UCAST, "MPLS" },
7541c99275SPeter Avalos { PPP_MPLS_MCAST, "MPLS" },
7641c99275SPeter Avalos { PPP_COMP, "Compressed"},
7741c99275SPeter Avalos { PPP_ML, "MLPPP"},
7841c99275SPeter Avalos { PPP_IPV6, "IP6"},
7941c99275SPeter Avalos
8041c99275SPeter Avalos { PPP_HELLO, "HELLO" },
8141c99275SPeter Avalos { PPP_LUXCOM, "LUXCOM" },
8241c99275SPeter Avalos { PPP_SNS, "SNS" },
8341c99275SPeter Avalos { PPP_IPCP, "IPCP" },
8441c99275SPeter Avalos { PPP_OSICP, "OSICP" },
8541c99275SPeter Avalos { PPP_NSCP, "NSCP" },
8641c99275SPeter Avalos { PPP_DECNETCP, "DECNETCP" },
8741c99275SPeter Avalos { PPP_APPLECP, "APPLECP" },
8841c99275SPeter Avalos { PPP_IPXCP, "IPXCP" },
8941c99275SPeter Avalos { PPP_STIICP, "STIICP" },
9041c99275SPeter Avalos { PPP_VINESCP, "VINESCP" },
9141c99275SPeter Avalos { PPP_IPV6CP, "IP6CP" },
9241c99275SPeter Avalos { PPP_MPLSCP, "MPLSCP" },
9341c99275SPeter Avalos
9441c99275SPeter Avalos { PPP_LCP, "LCP" },
9541c99275SPeter Avalos { PPP_PAP, "PAP" },
9641c99275SPeter Avalos { PPP_LQM, "LQM" },
9741c99275SPeter Avalos { PPP_CHAP, "CHAP" },
9841c99275SPeter Avalos { PPP_EAP, "EAP" },
9941c99275SPeter Avalos { PPP_SPAP, "SPAP" },
10041c99275SPeter Avalos { PPP_SPAP_OLD, "Old-SPAP" },
10141c99275SPeter Avalos { PPP_BACP, "BACP" },
10241c99275SPeter Avalos { PPP_BAP, "BAP" },
10341c99275SPeter Avalos { PPP_MPCP, "MLPPP-CP" },
104411677aeSAaron LI { PPP_CCP, "CCP" },
10541c99275SPeter Avalos { 0, NULL }
10641c99275SPeter Avalos };
10741c99275SPeter Avalos
10841c99275SPeter Avalos /* Control Protocols (LCP/IPCP/CCP etc.) Codes defined in RFC 1661 */
10941c99275SPeter Avalos
11041c99275SPeter Avalos #define CPCODES_VEXT 0 /* Vendor-Specific (RFC2153) */
11141c99275SPeter Avalos #define CPCODES_CONF_REQ 1 /* Configure-Request */
11241c99275SPeter Avalos #define CPCODES_CONF_ACK 2 /* Configure-Ack */
11341c99275SPeter Avalos #define CPCODES_CONF_NAK 3 /* Configure-Nak */
11441c99275SPeter Avalos #define CPCODES_CONF_REJ 4 /* Configure-Reject */
11541c99275SPeter Avalos #define CPCODES_TERM_REQ 5 /* Terminate-Request */
11641c99275SPeter Avalos #define CPCODES_TERM_ACK 6 /* Terminate-Ack */
11741c99275SPeter Avalos #define CPCODES_CODE_REJ 7 /* Code-Reject */
11841c99275SPeter Avalos #define CPCODES_PROT_REJ 8 /* Protocol-Reject (LCP only) */
11941c99275SPeter Avalos #define CPCODES_ECHO_REQ 9 /* Echo-Request (LCP only) */
12041c99275SPeter Avalos #define CPCODES_ECHO_RPL 10 /* Echo-Reply (LCP only) */
12141c99275SPeter Avalos #define CPCODES_DISC_REQ 11 /* Discard-Request (LCP only) */
12241c99275SPeter Avalos #define CPCODES_ID 12 /* Identification (LCP only) RFC1570 */
12341c99275SPeter Avalos #define CPCODES_TIME_REM 13 /* Time-Remaining (LCP only) RFC1570 */
12441c99275SPeter Avalos #define CPCODES_RESET_REQ 14 /* Reset-Request (CCP only) RFC1962 */
12541c99275SPeter Avalos #define CPCODES_RESET_REP 15 /* Reset-Reply (CCP only) */
12641c99275SPeter Avalos
127411677aeSAaron LI static const struct tok cpcodes[] = {
12841c99275SPeter Avalos {CPCODES_VEXT, "Vendor-Extension"}, /* RFC2153 */
12941c99275SPeter Avalos {CPCODES_CONF_REQ, "Conf-Request"},
13041c99275SPeter Avalos {CPCODES_CONF_ACK, "Conf-Ack"},
13141c99275SPeter Avalos {CPCODES_CONF_NAK, "Conf-Nack"},
13241c99275SPeter Avalos {CPCODES_CONF_REJ, "Conf-Reject"},
13341c99275SPeter Avalos {CPCODES_TERM_REQ, "Term-Request"},
13441c99275SPeter Avalos {CPCODES_TERM_ACK, "Term-Ack"},
13541c99275SPeter Avalos {CPCODES_CODE_REJ, "Code-Reject"},
13641c99275SPeter Avalos {CPCODES_PROT_REJ, "Prot-Reject"},
13741c99275SPeter Avalos {CPCODES_ECHO_REQ, "Echo-Request"},
13841c99275SPeter Avalos {CPCODES_ECHO_RPL, "Echo-Reply"},
13941c99275SPeter Avalos {CPCODES_DISC_REQ, "Disc-Req"},
14041c99275SPeter Avalos {CPCODES_ID, "Ident"}, /* RFC1570 */
14141c99275SPeter Avalos {CPCODES_TIME_REM, "Time-Rem"}, /* RFC1570 */
14241c99275SPeter Avalos {CPCODES_RESET_REQ, "Reset-Req"}, /* RFC1962 */
14341c99275SPeter Avalos {CPCODES_RESET_REP, "Reset-Ack"}, /* RFC1962 */
14441c99275SPeter Avalos {0, NULL}
14541c99275SPeter Avalos };
14641c99275SPeter Avalos
14741c99275SPeter Avalos /* LCP Config Options */
14841c99275SPeter Avalos
14941c99275SPeter Avalos #define LCPOPT_VEXT 0
15041c99275SPeter Avalos #define LCPOPT_MRU 1
15141c99275SPeter Avalos #define LCPOPT_ACCM 2
15241c99275SPeter Avalos #define LCPOPT_AP 3
15341c99275SPeter Avalos #define LCPOPT_QP 4
15441c99275SPeter Avalos #define LCPOPT_MN 5
15541c99275SPeter Avalos #define LCPOPT_DEP6 6
15641c99275SPeter Avalos #define LCPOPT_PFC 7
15741c99275SPeter Avalos #define LCPOPT_ACFC 8
15841c99275SPeter Avalos #define LCPOPT_FCSALT 9
15941c99275SPeter Avalos #define LCPOPT_SDP 10
16041c99275SPeter Avalos #define LCPOPT_NUMMODE 11
16141c99275SPeter Avalos #define LCPOPT_DEP12 12
16241c99275SPeter Avalos #define LCPOPT_CBACK 13
16341c99275SPeter Avalos #define LCPOPT_DEP14 14
16441c99275SPeter Avalos #define LCPOPT_DEP15 15
16541c99275SPeter Avalos #define LCPOPT_DEP16 16
16641c99275SPeter Avalos #define LCPOPT_MLMRRU 17
16741c99275SPeter Avalos #define LCPOPT_MLSSNHF 18
16841c99275SPeter Avalos #define LCPOPT_MLED 19
16941c99275SPeter Avalos #define LCPOPT_PROP 20
17041c99275SPeter Avalos #define LCPOPT_DCEID 21
17141c99275SPeter Avalos #define LCPOPT_MPP 22
17241c99275SPeter Avalos #define LCPOPT_LD 23
17341c99275SPeter Avalos #define LCPOPT_LCPAOPT 24
17441c99275SPeter Avalos #define LCPOPT_COBS 25
17541c99275SPeter Avalos #define LCPOPT_PE 26
17641c99275SPeter Avalos #define LCPOPT_MLHF 27
17741c99275SPeter Avalos #define LCPOPT_I18N 28
17841c99275SPeter Avalos #define LCPOPT_SDLOS 29
17941c99275SPeter Avalos #define LCPOPT_PPPMUX 30
18041c99275SPeter Avalos
18141c99275SPeter Avalos static const char *lcpconfopts[] = {
18241c99275SPeter Avalos "Vend-Ext", /* (0) */
18341c99275SPeter Avalos "MRU", /* (1) */
18441c99275SPeter Avalos "ACCM", /* (2) */
18541c99275SPeter Avalos "Auth-Prot", /* (3) */
18641c99275SPeter Avalos "Qual-Prot", /* (4) */
18741c99275SPeter Avalos "Magic-Num", /* (5) */
18841c99275SPeter Avalos "deprecated(6)", /* used to be a Quality Protocol */
18941c99275SPeter Avalos "PFC", /* (7) */
19041c99275SPeter Avalos "ACFC", /* (8) */
19141c99275SPeter Avalos "FCS-Alt", /* (9) */
19241c99275SPeter Avalos "SDP", /* (10) */
19341c99275SPeter Avalos "Num-Mode", /* (11) */
19441c99275SPeter Avalos "deprecated(12)", /* used to be a Multi-Link-Procedure*/
19541c99275SPeter Avalos "Call-Back", /* (13) */
19641c99275SPeter Avalos "deprecated(14)", /* used to be a Connect-Time */
19741c99275SPeter Avalos "deprecated(15)", /* used to be a Compund-Frames */
19841c99275SPeter Avalos "deprecated(16)", /* used to be a Nominal-Data-Encap */
19941c99275SPeter Avalos "MRRU", /* (17) */
20041c99275SPeter Avalos "12-Bit seq #", /* (18) */
20141c99275SPeter Avalos "End-Disc", /* (19) */
20241c99275SPeter Avalos "Proprietary", /* (20) */
20341c99275SPeter Avalos "DCE-Id", /* (21) */
20441c99275SPeter Avalos "MP+", /* (22) */
20541c99275SPeter Avalos "Link-Disc", /* (23) */
20641c99275SPeter Avalos "LCP-Auth-Opt", /* (24) */
20741c99275SPeter Avalos "COBS", /* (25) */
20841c99275SPeter Avalos "Prefix-elision", /* (26) */
20941c99275SPeter Avalos "Multilink-header-Form",/* (27) */
21041c99275SPeter Avalos "I18N", /* (28) */
21141c99275SPeter Avalos "SDL-over-SONET/SDH", /* (29) */
21241c99275SPeter Avalos "PPP-Muxing", /* (30) */
21341c99275SPeter Avalos };
21441c99275SPeter Avalos
215*ed775ee7SAntonio Huete Jimenez #define NUM_LCPOPTS (sizeof(lcpconfopts) / sizeof(lcpconfopts[0]))
216*ed775ee7SAntonio Huete Jimenez
21741c99275SPeter Avalos /* ECP - to be supported */
21841c99275SPeter Avalos
21941c99275SPeter Avalos /* CCP Config Options */
22041c99275SPeter Avalos
22141c99275SPeter Avalos #define CCPOPT_OUI 0 /* RFC1962 */
22241c99275SPeter Avalos #define CCPOPT_PRED1 1 /* RFC1962 */
22341c99275SPeter Avalos #define CCPOPT_PRED2 2 /* RFC1962 */
22441c99275SPeter Avalos #define CCPOPT_PJUMP 3 /* RFC1962 */
22541c99275SPeter Avalos /* 4-15 unassigned */
22641c99275SPeter Avalos #define CCPOPT_HPPPC 16 /* RFC1962 */
22741c99275SPeter Avalos #define CCPOPT_STACLZS 17 /* RFC1974 */
22841c99275SPeter Avalos #define CCPOPT_MPPC 18 /* RFC2118 */
22941c99275SPeter Avalos #define CCPOPT_GFZA 19 /* RFC1962 */
23041c99275SPeter Avalos #define CCPOPT_V42BIS 20 /* RFC1962 */
23141c99275SPeter Avalos #define CCPOPT_BSDCOMP 21 /* RFC1977 */
23241c99275SPeter Avalos /* 22 unassigned */
23341c99275SPeter Avalos #define CCPOPT_LZSDCP 23 /* RFC1967 */
23441c99275SPeter Avalos #define CCPOPT_MVRCA 24 /* RFC1975 */
23541c99275SPeter Avalos #define CCPOPT_DEC 25 /* RFC1976 */
23641c99275SPeter Avalos #define CCPOPT_DEFLATE 26 /* RFC1979 */
23741c99275SPeter Avalos /* 27-254 unassigned */
23841c99275SPeter Avalos #define CCPOPT_RESV 255 /* RFC1962 */
23941c99275SPeter Avalos
240411677aeSAaron LI static const struct tok ccpconfopts_values[] = {
24141c99275SPeter Avalos { CCPOPT_OUI, "OUI" },
24241c99275SPeter Avalos { CCPOPT_PRED1, "Pred-1" },
24341c99275SPeter Avalos { CCPOPT_PRED2, "Pred-2" },
24441c99275SPeter Avalos { CCPOPT_PJUMP, "Puddle" },
24541c99275SPeter Avalos { CCPOPT_HPPPC, "HP-PPC" },
24641c99275SPeter Avalos { CCPOPT_STACLZS, "Stac-LZS" },
24741c99275SPeter Avalos { CCPOPT_MPPC, "MPPC" },
24841c99275SPeter Avalos { CCPOPT_GFZA, "Gand-FZA" },
24941c99275SPeter Avalos { CCPOPT_V42BIS, "V.42bis" },
25041c99275SPeter Avalos { CCPOPT_BSDCOMP, "BSD-Comp" },
25141c99275SPeter Avalos { CCPOPT_LZSDCP, "LZS-DCP" },
25241c99275SPeter Avalos { CCPOPT_MVRCA, "MVRCA" },
25341c99275SPeter Avalos { CCPOPT_DEC, "DEC" },
25441c99275SPeter Avalos { CCPOPT_DEFLATE, "Deflate" },
25541c99275SPeter Avalos { CCPOPT_RESV, "Reserved"},
25641c99275SPeter Avalos {0, NULL}
25741c99275SPeter Avalos };
25841c99275SPeter Avalos
25941c99275SPeter Avalos /* BACP Config Options */
26041c99275SPeter Avalos
26141c99275SPeter Avalos #define BACPOPT_FPEER 1 /* RFC2125 */
26241c99275SPeter Avalos
263411677aeSAaron LI static const struct tok bacconfopts_values[] = {
26441c99275SPeter Avalos { BACPOPT_FPEER, "Favored-Peer" },
26541c99275SPeter Avalos {0, NULL}
26641c99275SPeter Avalos };
26741c99275SPeter Avalos
26841c99275SPeter Avalos
26941c99275SPeter Avalos /* SDCP - to be supported */
27041c99275SPeter Avalos
27141c99275SPeter Avalos /* IPCP Config Options */
27241c99275SPeter Avalos #define IPCPOPT_2ADDR 1 /* RFC1172, RFC1332 (deprecated) */
27341c99275SPeter Avalos #define IPCPOPT_IPCOMP 2 /* RFC1332 */
27441c99275SPeter Avalos #define IPCPOPT_ADDR 3 /* RFC1332 */
27541c99275SPeter Avalos #define IPCPOPT_MOBILE4 4 /* RFC2290 */
27641c99275SPeter Avalos #define IPCPOPT_PRIDNS 129 /* RFC1877 */
27741c99275SPeter Avalos #define IPCPOPT_PRINBNS 130 /* RFC1877 */
27841c99275SPeter Avalos #define IPCPOPT_SECDNS 131 /* RFC1877 */
27941c99275SPeter Avalos #define IPCPOPT_SECNBNS 132 /* RFC1877 */
28041c99275SPeter Avalos
281411677aeSAaron LI static const struct tok ipcpopt_values[] = {
28241c99275SPeter Avalos { IPCPOPT_2ADDR, "IP-Addrs" },
28341c99275SPeter Avalos { IPCPOPT_IPCOMP, "IP-Comp" },
28441c99275SPeter Avalos { IPCPOPT_ADDR, "IP-Addr" },
28541c99275SPeter Avalos { IPCPOPT_MOBILE4, "Home-Addr" },
28641c99275SPeter Avalos { IPCPOPT_PRIDNS, "Pri-DNS" },
28741c99275SPeter Avalos { IPCPOPT_PRINBNS, "Pri-NBNS" },
28841c99275SPeter Avalos { IPCPOPT_SECDNS, "Sec-DNS" },
28941c99275SPeter Avalos { IPCPOPT_SECNBNS, "Sec-NBNS" },
29041c99275SPeter Avalos { 0, NULL }
29141c99275SPeter Avalos };
29241c99275SPeter Avalos
29341c99275SPeter Avalos #define IPCPOPT_IPCOMP_HDRCOMP 0x61 /* rfc3544 */
29441c99275SPeter Avalos #define IPCPOPT_IPCOMP_MINLEN 14
29541c99275SPeter Avalos
296411677aeSAaron LI static const struct tok ipcpopt_compproto_values[] = {
29741c99275SPeter Avalos { PPP_VJC, "VJ-Comp" },
29841c99275SPeter Avalos { IPCPOPT_IPCOMP_HDRCOMP, "IP Header Compression" },
29941c99275SPeter Avalos { 0, NULL }
30041c99275SPeter Avalos };
30141c99275SPeter Avalos
302411677aeSAaron LI static const struct tok ipcpopt_compproto_subopt_values[] = {
30341c99275SPeter Avalos { 1, "RTP-Compression" },
30441c99275SPeter Avalos { 2, "Enhanced RTP-Compression" },
30541c99275SPeter Avalos { 0, NULL }
30641c99275SPeter Avalos };
30741c99275SPeter Avalos
30841c99275SPeter Avalos /* IP6CP Config Options */
30941c99275SPeter Avalos #define IP6CP_IFID 1
31041c99275SPeter Avalos
311411677aeSAaron LI static const struct tok ip6cpopt_values[] = {
31241c99275SPeter Avalos { IP6CP_IFID, "Interface-ID" },
31341c99275SPeter Avalos { 0, NULL }
31441c99275SPeter Avalos };
31541c99275SPeter Avalos
31641c99275SPeter Avalos /* ATCP - to be supported */
31741c99275SPeter Avalos /* OSINLCP - to be supported */
31841c99275SPeter Avalos /* BVCP - to be supported */
31941c99275SPeter Avalos /* BCP - to be supported */
32041c99275SPeter Avalos /* IPXCP - to be supported */
32141c99275SPeter Avalos /* MPLSCP - to be supported */
32241c99275SPeter Avalos
32341c99275SPeter Avalos /* Auth Algorithms */
32441c99275SPeter Avalos
32541c99275SPeter Avalos /* 0-4 Reserved (RFC1994) */
32641c99275SPeter Avalos #define AUTHALG_CHAPMD5 5 /* RFC1994 */
32741c99275SPeter Avalos #define AUTHALG_MSCHAP1 128 /* RFC2433 */
32841c99275SPeter Avalos #define AUTHALG_MSCHAP2 129 /* RFC2795 */
32941c99275SPeter Avalos
330411677aeSAaron LI static const struct tok authalg_values[] = {
33141c99275SPeter Avalos { AUTHALG_CHAPMD5, "MD5" },
33241c99275SPeter Avalos { AUTHALG_MSCHAP1, "MS-CHAPv1" },
33341c99275SPeter Avalos { AUTHALG_MSCHAP2, "MS-CHAPv2" },
33441c99275SPeter Avalos { 0, NULL }
33541c99275SPeter Avalos };
33641c99275SPeter Avalos
33741c99275SPeter Avalos /* FCS Alternatives - to be supported */
33841c99275SPeter Avalos
33941c99275SPeter Avalos /* Multilink Endpoint Discriminator (RFC1717) */
34041c99275SPeter Avalos #define MEDCLASS_NULL 0 /* Null Class */
34141c99275SPeter Avalos #define MEDCLASS_LOCAL 1 /* Locally Assigned */
34241c99275SPeter Avalos #define MEDCLASS_IPV4 2 /* Internet Protocol (IPv4) */
34341c99275SPeter Avalos #define MEDCLASS_MAC 3 /* IEEE 802.1 global MAC address */
34441c99275SPeter Avalos #define MEDCLASS_MNB 4 /* PPP Magic Number Block */
34541c99275SPeter Avalos #define MEDCLASS_PSNDN 5 /* Public Switched Network Director Number */
34641c99275SPeter Avalos
34741c99275SPeter Avalos /* PPP LCP Callback */
34841c99275SPeter Avalos #define CALLBACK_AUTH 0 /* Location determined by user auth */
34941c99275SPeter Avalos #define CALLBACK_DSTR 1 /* Dialing string */
35041c99275SPeter Avalos #define CALLBACK_LID 2 /* Location identifier */
35141c99275SPeter Avalos #define CALLBACK_E164 3 /* E.164 number */
35241c99275SPeter Avalos #define CALLBACK_X500 4 /* X.500 distinguished name */
35341c99275SPeter Avalos #define CALLBACK_CBCP 6 /* Location is determined during CBCP nego */
35441c99275SPeter Avalos
355411677aeSAaron LI static const struct tok ppp_callback_values[] = {
35641c99275SPeter Avalos { CALLBACK_AUTH, "UserAuth" },
35741c99275SPeter Avalos { CALLBACK_DSTR, "DialString" },
35841c99275SPeter Avalos { CALLBACK_LID, "LocalID" },
35941c99275SPeter Avalos { CALLBACK_E164, "E.164" },
36041c99275SPeter Avalos { CALLBACK_X500, "X.500" },
36141c99275SPeter Avalos { CALLBACK_CBCP, "CBCP" },
36241c99275SPeter Avalos { 0, NULL }
36341c99275SPeter Avalos };
36441c99275SPeter Avalos
36541c99275SPeter Avalos /* CHAP */
36641c99275SPeter Avalos
36741c99275SPeter Avalos #define CHAP_CHAL 1
36841c99275SPeter Avalos #define CHAP_RESP 2
36941c99275SPeter Avalos #define CHAP_SUCC 3
37041c99275SPeter Avalos #define CHAP_FAIL 4
37141c99275SPeter Avalos
372411677aeSAaron LI static const struct tok chapcode_values[] = {
37341c99275SPeter Avalos { CHAP_CHAL, "Challenge" },
37441c99275SPeter Avalos { CHAP_RESP, "Response" },
37541c99275SPeter Avalos { CHAP_SUCC, "Success" },
37641c99275SPeter Avalos { CHAP_FAIL, "Fail" },
37741c99275SPeter Avalos { 0, NULL}
37841c99275SPeter Avalos };
37941c99275SPeter Avalos
38041c99275SPeter Avalos /* PAP */
38141c99275SPeter Avalos
38241c99275SPeter Avalos #define PAP_AREQ 1
38341c99275SPeter Avalos #define PAP_AACK 2
38441c99275SPeter Avalos #define PAP_ANAK 3
38541c99275SPeter Avalos
386411677aeSAaron LI static const struct tok papcode_values[] = {
38741c99275SPeter Avalos { PAP_AREQ, "Auth-Req" },
38841c99275SPeter Avalos { PAP_AACK, "Auth-ACK" },
38941c99275SPeter Avalos { PAP_ANAK, "Auth-NACK" },
39041c99275SPeter Avalos { 0, NULL }
39141c99275SPeter Avalos };
39241c99275SPeter Avalos
39341c99275SPeter Avalos /* BAP */
39441c99275SPeter Avalos #define BAP_CALLREQ 1
39541c99275SPeter Avalos #define BAP_CALLRES 2
39641c99275SPeter Avalos #define BAP_CBREQ 3
39741c99275SPeter Avalos #define BAP_CBRES 4
39841c99275SPeter Avalos #define BAP_LDQREQ 5
39941c99275SPeter Avalos #define BAP_LDQRES 6
40041c99275SPeter Avalos #define BAP_CSIND 7
40141c99275SPeter Avalos #define BAP_CSRES 8
40241c99275SPeter Avalos
403*ed775ee7SAntonio Huete Jimenez static u_int print_lcp_config_options(netdissect_options *, const u_char *p, u_int);
404*ed775ee7SAntonio Huete Jimenez static u_int print_ipcp_config_options(netdissect_options *, const u_char *p, u_int);
405*ed775ee7SAntonio Huete Jimenez static u_int print_ip6cp_config_options(netdissect_options *, const u_char *p, u_int);
406*ed775ee7SAntonio Huete Jimenez static u_int print_ccp_config_options(netdissect_options *, const u_char *p, u_int);
407*ed775ee7SAntonio Huete Jimenez static u_int print_bacp_config_options(netdissect_options *, const u_char *p, u_int);
408*ed775ee7SAntonio Huete Jimenez static void handle_ppp(netdissect_options *, u_int proto, const u_char *p, u_int length);
40941c99275SPeter Avalos
41041c99275SPeter Avalos /* generic Control Protocol (e.g. LCP, IPCP, CCP, etc.) handler */
41141c99275SPeter Avalos static void
handle_ctrl_proto(netdissect_options * ndo,u_int proto,const u_char * pptr,u_int length)412411677aeSAaron LI handle_ctrl_proto(netdissect_options *ndo,
413*ed775ee7SAntonio Huete Jimenez u_int proto, const u_char *pptr, u_int length)
41441c99275SPeter Avalos {
41541c99275SPeter Avalos const char *typestr;
41641c99275SPeter Avalos u_int code, len;
417*ed775ee7SAntonio Huete Jimenez u_int (*pfunc)(netdissect_options *, const u_char *, u_int);
418*ed775ee7SAntonio Huete Jimenez u_int tlen, advance;
41941c99275SPeter Avalos const u_char *tptr;
42041c99275SPeter Avalos
42141c99275SPeter Avalos tptr=pptr;
42241c99275SPeter Avalos
42341c99275SPeter Avalos typestr = tok2str(ppptype2str, "unknown ctrl-proto (0x%04x)", proto);
424*ed775ee7SAntonio Huete Jimenez ND_PRINT("%s, ", typestr);
42541c99275SPeter Avalos
42641c99275SPeter Avalos if (length < 4) /* FIXME weak boundary checking */
42741c99275SPeter Avalos goto trunc;
428*ed775ee7SAntonio Huete Jimenez ND_TCHECK_2(tptr);
42941c99275SPeter Avalos
430*ed775ee7SAntonio Huete Jimenez code = GET_U_1(tptr);
431*ed775ee7SAntonio Huete Jimenez tptr++;
43241c99275SPeter Avalos
433*ed775ee7SAntonio Huete Jimenez ND_PRINT("%s (0x%02x), id %u, length %u",
43441c99275SPeter Avalos tok2str(cpcodes, "Unknown Opcode",code),
43541c99275SPeter Avalos code,
436*ed775ee7SAntonio Huete Jimenez GET_U_1(tptr), /* ID */
437*ed775ee7SAntonio Huete Jimenez length + 2);
438*ed775ee7SAntonio Huete Jimenez tptr++;
43941c99275SPeter Avalos
440411677aeSAaron LI if (!ndo->ndo_vflag)
44141c99275SPeter Avalos return;
44241c99275SPeter Avalos
443*ed775ee7SAntonio Huete Jimenez len = GET_BE_U_2(tptr);
44441c99275SPeter Avalos tptr += 2;
44541c99275SPeter Avalos
446*ed775ee7SAntonio Huete Jimenez if (len < 4) {
447*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\tencoded length %u (< 4))", len);
448*ed775ee7SAntonio Huete Jimenez return;
449*ed775ee7SAntonio Huete Jimenez }
450*ed775ee7SAntonio Huete Jimenez
451*ed775ee7SAntonio Huete Jimenez if (len > length) {
452*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\tencoded length %u (> packet length %u))", len, length);
453*ed775ee7SAntonio Huete Jimenez return;
454*ed775ee7SAntonio Huete Jimenez }
455*ed775ee7SAntonio Huete Jimenez length = len;
456*ed775ee7SAntonio Huete Jimenez
457*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\tencoded length %u (=Option(s) length %u)", len, len - 4);
458*ed775ee7SAntonio Huete Jimenez
459*ed775ee7SAntonio Huete Jimenez if (length == 4)
460*ed775ee7SAntonio Huete Jimenez return; /* there may be a NULL confreq etc. */
46141c99275SPeter Avalos
462411677aeSAaron LI if (ndo->ndo_vflag > 1)
463411677aeSAaron LI print_unknown_data(ndo, pptr - 2, "\n\t", 6);
46441c99275SPeter Avalos
46541c99275SPeter Avalos
46641c99275SPeter Avalos switch (code) {
46741c99275SPeter Avalos case CPCODES_VEXT:
46841c99275SPeter Avalos if (length < 11)
46941c99275SPeter Avalos break;
470*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t Magic-Num 0x%08x", GET_BE_U_4(tptr));
47141c99275SPeter Avalos tptr += 4;
472*ed775ee7SAntonio Huete Jimenez ND_PRINT(" Vendor: %s (%u)",
473*ed775ee7SAntonio Huete Jimenez tok2str(oui_values,"Unknown",GET_BE_U_3(tptr)),
474*ed775ee7SAntonio Huete Jimenez GET_BE_U_3(tptr));
47541c99275SPeter Avalos /* XXX: need to decode Kind and Value(s)? */
47641c99275SPeter Avalos break;
47741c99275SPeter Avalos case CPCODES_CONF_REQ:
47841c99275SPeter Avalos case CPCODES_CONF_ACK:
47941c99275SPeter Avalos case CPCODES_CONF_NAK:
48041c99275SPeter Avalos case CPCODES_CONF_REJ:
481*ed775ee7SAntonio Huete Jimenez tlen = len - 4; /* Code(1), Identifier(1) and Length(2) */
48241c99275SPeter Avalos do {
48341c99275SPeter Avalos switch (proto) {
48441c99275SPeter Avalos case PPP_LCP:
48541c99275SPeter Avalos pfunc = print_lcp_config_options;
48641c99275SPeter Avalos break;
48741c99275SPeter Avalos case PPP_IPCP:
48841c99275SPeter Avalos pfunc = print_ipcp_config_options;
48941c99275SPeter Avalos break;
49041c99275SPeter Avalos case PPP_IPV6CP:
49141c99275SPeter Avalos pfunc = print_ip6cp_config_options;
49241c99275SPeter Avalos break;
49341c99275SPeter Avalos case PPP_CCP:
49441c99275SPeter Avalos pfunc = print_ccp_config_options;
49541c99275SPeter Avalos break;
49641c99275SPeter Avalos case PPP_BACP:
49741c99275SPeter Avalos pfunc = print_bacp_config_options;
49841c99275SPeter Avalos break;
49941c99275SPeter Avalos default:
50041c99275SPeter Avalos /*
50141c99275SPeter Avalos * No print routine for the options for
50241c99275SPeter Avalos * this protocol.
50341c99275SPeter Avalos */
50441c99275SPeter Avalos pfunc = NULL;
50541c99275SPeter Avalos break;
50641c99275SPeter Avalos }
50741c99275SPeter Avalos
50841c99275SPeter Avalos if (pfunc == NULL) /* catch the above null pointer if unknown CP */
50941c99275SPeter Avalos break;
51041c99275SPeter Avalos
511*ed775ee7SAntonio Huete Jimenez if ((advance = (*pfunc)(ndo, tptr, len)) == 0)
51241c99275SPeter Avalos break;
513*ed775ee7SAntonio Huete Jimenez if (tlen < advance) {
514*ed775ee7SAntonio Huete Jimenez ND_PRINT(" [remaining options length %u < %u]",
515*ed775ee7SAntonio Huete Jimenez tlen, advance);
516*ed775ee7SAntonio Huete Jimenez nd_print_invalid(ndo);
517*ed775ee7SAntonio Huete Jimenez break;
518*ed775ee7SAntonio Huete Jimenez }
519*ed775ee7SAntonio Huete Jimenez tlen -= advance;
520*ed775ee7SAntonio Huete Jimenez tptr += advance;
521*ed775ee7SAntonio Huete Jimenez } while (tlen != 0);
52241c99275SPeter Avalos break;
52341c99275SPeter Avalos
52441c99275SPeter Avalos case CPCODES_TERM_REQ:
52541c99275SPeter Avalos case CPCODES_TERM_ACK:
52641c99275SPeter Avalos /* XXX: need to decode Data? */
52741c99275SPeter Avalos break;
52841c99275SPeter Avalos case CPCODES_CODE_REJ:
52941c99275SPeter Avalos /* XXX: need to decode Rejected-Packet? */
53041c99275SPeter Avalos break;
53141c99275SPeter Avalos case CPCODES_PROT_REJ:
53241c99275SPeter Avalos if (length < 6)
53341c99275SPeter Avalos break;
534*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t Rejected %s Protocol (0x%04x)",
535*ed775ee7SAntonio Huete Jimenez tok2str(ppptype2str,"unknown", GET_BE_U_2(tptr)),
536*ed775ee7SAntonio Huete Jimenez GET_BE_U_2(tptr));
53741c99275SPeter Avalos /* XXX: need to decode Rejected-Information? - hexdump for now */
53841c99275SPeter Avalos if (len > 6) {
539*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t Rejected Packet");
540411677aeSAaron LI print_unknown_data(ndo, tptr + 2, "\n\t ", len - 2);
54141c99275SPeter Avalos }
54241c99275SPeter Avalos break;
54341c99275SPeter Avalos case CPCODES_ECHO_REQ:
54441c99275SPeter Avalos case CPCODES_ECHO_RPL:
54541c99275SPeter Avalos case CPCODES_DISC_REQ:
54641c99275SPeter Avalos if (length < 8)
54741c99275SPeter Avalos break;
548*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t Magic-Num 0x%08x", GET_BE_U_4(tptr));
54941c99275SPeter Avalos /* XXX: need to decode Data? - hexdump for now */
55041c99275SPeter Avalos if (len > 8) {
551*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t -----trailing data-----");
552*ed775ee7SAntonio Huete Jimenez ND_TCHECK_LEN(tptr + 4, len - 8);
553411677aeSAaron LI print_unknown_data(ndo, tptr + 4, "\n\t ", len - 8);
55441c99275SPeter Avalos }
55541c99275SPeter Avalos break;
55641c99275SPeter Avalos case CPCODES_ID:
55741c99275SPeter Avalos if (length < 8)
55841c99275SPeter Avalos break;
559*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t Magic-Num 0x%08x", GET_BE_U_4(tptr));
56041c99275SPeter Avalos /* RFC 1661 says this is intended to be human readable */
56141c99275SPeter Avalos if (len > 8) {
562*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t Message\n\t ");
563*ed775ee7SAntonio Huete Jimenez if (nd_printn(ndo, tptr + 4, len - 4, ndo->ndo_snapend))
564411677aeSAaron LI goto trunc;
56541c99275SPeter Avalos }
56641c99275SPeter Avalos break;
56741c99275SPeter Avalos case CPCODES_TIME_REM:
56841c99275SPeter Avalos if (length < 12)
56941c99275SPeter Avalos break;
570*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t Magic-Num 0x%08x", GET_BE_U_4(tptr));
571*ed775ee7SAntonio Huete Jimenez ND_PRINT(", Seconds-Remaining %us", GET_BE_U_4(tptr + 4));
57241c99275SPeter Avalos /* XXX: need to decode Message? */
57341c99275SPeter Avalos break;
57441c99275SPeter Avalos default:
57541c99275SPeter Avalos /* XXX this is dirty but we do not get the
57641c99275SPeter Avalos * original pointer passed to the begin
57741c99275SPeter Avalos * the PPP packet */
578411677aeSAaron LI if (ndo->ndo_vflag <= 1)
579411677aeSAaron LI print_unknown_data(ndo, pptr - 2, "\n\t ", length + 2);
58041c99275SPeter Avalos break;
58141c99275SPeter Avalos }
58241c99275SPeter Avalos return;
58341c99275SPeter Avalos
58441c99275SPeter Avalos trunc:
585*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|%s]", typestr);
58641c99275SPeter Avalos }
58741c99275SPeter Avalos
58841c99275SPeter Avalos /* LCP config options */
589*ed775ee7SAntonio Huete Jimenez static u_int
print_lcp_config_options(netdissect_options * ndo,const u_char * p,u_int length)590411677aeSAaron LI print_lcp_config_options(netdissect_options *ndo,
591*ed775ee7SAntonio Huete Jimenez const u_char *p, u_int length)
59241c99275SPeter Avalos {
593*ed775ee7SAntonio Huete Jimenez u_int opt, len;
59441c99275SPeter Avalos
59541c99275SPeter Avalos if (length < 2)
59641c99275SPeter Avalos return 0;
597*ed775ee7SAntonio Huete Jimenez ND_TCHECK_2(p);
598*ed775ee7SAntonio Huete Jimenez opt = GET_U_1(p);
599*ed775ee7SAntonio Huete Jimenez len = GET_U_1(p + 1);
60041c99275SPeter Avalos if (length < len)
60141c99275SPeter Avalos return 0;
60241c99275SPeter Avalos if (len < 2) {
603*ed775ee7SAntonio Huete Jimenez if (opt < NUM_LCPOPTS)
604*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
605*ed775ee7SAntonio Huete Jimenez lcpconfopts[opt], opt, len);
60641c99275SPeter Avalos else
607*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\tunknown LCP option 0x%02x", opt);
60841c99275SPeter Avalos return 0;
60941c99275SPeter Avalos }
610*ed775ee7SAntonio Huete Jimenez if (opt < NUM_LCPOPTS)
611*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t %s Option (0x%02x), length %u", lcpconfopts[opt], opt, len);
61241c99275SPeter Avalos else {
613*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\tunknown LCP option 0x%02x", opt);
61441c99275SPeter Avalos return len;
61541c99275SPeter Avalos }
61641c99275SPeter Avalos
61741c99275SPeter Avalos switch (opt) {
61841c99275SPeter Avalos case LCPOPT_VEXT:
619411677aeSAaron LI if (len < 6) {
620*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be >= 6)");
621411677aeSAaron LI return len;
622411677aeSAaron LI }
623*ed775ee7SAntonio Huete Jimenez ND_PRINT(": Vendor: %s (%u)",
624*ed775ee7SAntonio Huete Jimenez tok2str(oui_values,"Unknown",GET_BE_U_3(p + 2)),
625*ed775ee7SAntonio Huete Jimenez GET_BE_U_3(p + 2));
62641c99275SPeter Avalos #if 0
627*ed775ee7SAntonio Huete Jimenez ND_PRINT(", kind: 0x%02x", GET_U_1(p + 5));
628*ed775ee7SAntonio Huete Jimenez ND_PRINT(", Value: 0x");
62941c99275SPeter Avalos for (i = 0; i < len - 6; i++) {
630*ed775ee7SAntonio Huete Jimenez ND_PRINT("%02x", GET_U_1(p + 6 + i));
63141c99275SPeter Avalos }
63241c99275SPeter Avalos #endif
63341c99275SPeter Avalos break;
63441c99275SPeter Avalos case LCPOPT_MRU:
635411677aeSAaron LI if (len != 4) {
636*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be = 4)");
637411677aeSAaron LI return len;
63841c99275SPeter Avalos }
639*ed775ee7SAntonio Huete Jimenez ND_PRINT(": %u", GET_BE_U_2(p + 2));
64041c99275SPeter Avalos break;
64141c99275SPeter Avalos case LCPOPT_ACCM:
642411677aeSAaron LI if (len != 6) {
643*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be = 6)");
644411677aeSAaron LI return len;
64541c99275SPeter Avalos }
646*ed775ee7SAntonio Huete Jimenez ND_PRINT(": 0x%08x", GET_BE_U_4(p + 2));
64741c99275SPeter Avalos break;
64841c99275SPeter Avalos case LCPOPT_AP:
649411677aeSAaron LI if (len < 4) {
650*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be >= 4)");
651411677aeSAaron LI return len;
652411677aeSAaron LI }
653*ed775ee7SAntonio Huete Jimenez ND_PRINT(": %s",
654*ed775ee7SAntonio Huete Jimenez tok2str(ppptype2str, "Unknown Auth Proto (0x04x)", GET_BE_U_2(p + 2)));
65541c99275SPeter Avalos
656*ed775ee7SAntonio Huete Jimenez switch (GET_BE_U_2(p + 2)) {
65741c99275SPeter Avalos case PPP_CHAP:
658*ed775ee7SAntonio Huete Jimenez ND_PRINT(", %s",
659*ed775ee7SAntonio Huete Jimenez tok2str(authalg_values, "Unknown Auth Alg %u", GET_U_1(p + 4)));
66041c99275SPeter Avalos break;
66141c99275SPeter Avalos case PPP_PAP: /* fall through */
66241c99275SPeter Avalos case PPP_EAP:
66341c99275SPeter Avalos case PPP_SPAP:
66441c99275SPeter Avalos case PPP_SPAP_OLD:
66541c99275SPeter Avalos break;
66641c99275SPeter Avalos default:
667411677aeSAaron LI print_unknown_data(ndo, p, "\n\t", len);
66841c99275SPeter Avalos }
66941c99275SPeter Avalos break;
67041c99275SPeter Avalos case LCPOPT_QP:
671411677aeSAaron LI if (len < 4) {
672*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be >= 4)");
673411677aeSAaron LI return 0;
67441c99275SPeter Avalos }
675*ed775ee7SAntonio Huete Jimenez if (GET_BE_U_2(p + 2) == PPP_LQM)
676*ed775ee7SAntonio Huete Jimenez ND_PRINT(": LQR");
677411677aeSAaron LI else
678*ed775ee7SAntonio Huete Jimenez ND_PRINT(": unknown");
67941c99275SPeter Avalos break;
68041c99275SPeter Avalos case LCPOPT_MN:
681411677aeSAaron LI if (len != 6) {
682*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be = 6)");
683411677aeSAaron LI return 0;
68441c99275SPeter Avalos }
685*ed775ee7SAntonio Huete Jimenez ND_PRINT(": 0x%08x", GET_BE_U_4(p + 2));
68641c99275SPeter Avalos break;
68741c99275SPeter Avalos case LCPOPT_PFC:
68841c99275SPeter Avalos break;
68941c99275SPeter Avalos case LCPOPT_ACFC:
69041c99275SPeter Avalos break;
69141c99275SPeter Avalos case LCPOPT_LD:
692411677aeSAaron LI if (len != 4) {
693*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be = 4)");
694411677aeSAaron LI return 0;
69541c99275SPeter Avalos }
696*ed775ee7SAntonio Huete Jimenez ND_PRINT(": 0x%04x", GET_BE_U_2(p + 2));
69741c99275SPeter Avalos break;
69841c99275SPeter Avalos case LCPOPT_CBACK:
699411677aeSAaron LI if (len < 3) {
700*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be >= 3)");
701411677aeSAaron LI return 0;
702411677aeSAaron LI }
703*ed775ee7SAntonio Huete Jimenez ND_PRINT(": ");
704*ed775ee7SAntonio Huete Jimenez ND_PRINT(": Callback Operation %s (%u)",
705*ed775ee7SAntonio Huete Jimenez tok2str(ppp_callback_values, "Unknown", GET_U_1(p + 2)),
706*ed775ee7SAntonio Huete Jimenez GET_U_1(p + 2));
70741c99275SPeter Avalos break;
70841c99275SPeter Avalos case LCPOPT_MLMRRU:
709411677aeSAaron LI if (len != 4) {
710*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be = 4)");
711411677aeSAaron LI return 0;
71241c99275SPeter Avalos }
713*ed775ee7SAntonio Huete Jimenez ND_PRINT(": %u", GET_BE_U_2(p + 2));
71441c99275SPeter Avalos break;
71541c99275SPeter Avalos case LCPOPT_MLED:
716411677aeSAaron LI if (len < 3) {
717*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be >= 3)");
718411677aeSAaron LI return 0;
719411677aeSAaron LI }
720*ed775ee7SAntonio Huete Jimenez switch (GET_U_1(p + 2)) { /* class */
72141c99275SPeter Avalos case MEDCLASS_NULL:
722*ed775ee7SAntonio Huete Jimenez ND_PRINT(": Null");
72341c99275SPeter Avalos break;
72441c99275SPeter Avalos case MEDCLASS_LOCAL:
725*ed775ee7SAntonio Huete Jimenez ND_PRINT(": Local"); /* XXX */
72641c99275SPeter Avalos break;
72741c99275SPeter Avalos case MEDCLASS_IPV4:
728411677aeSAaron LI if (len != 7) {
729*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be = 7)");
730411677aeSAaron LI return 0;
731411677aeSAaron LI }
732*ed775ee7SAntonio Huete Jimenez ND_PRINT(": IPv4 %s", GET_IPADDR_STRING(p + 3));
73341c99275SPeter Avalos break;
73441c99275SPeter Avalos case MEDCLASS_MAC:
735411677aeSAaron LI if (len != 9) {
736*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be = 9)");
737411677aeSAaron LI return 0;
738411677aeSAaron LI }
739*ed775ee7SAntonio Huete Jimenez ND_PRINT(": MAC %s", GET_ETHERADDR_STRING(p + 3));
74041c99275SPeter Avalos break;
74141c99275SPeter Avalos case MEDCLASS_MNB:
742*ed775ee7SAntonio Huete Jimenez ND_PRINT(": Magic-Num-Block"); /* XXX */
74341c99275SPeter Avalos break;
74441c99275SPeter Avalos case MEDCLASS_PSNDN:
745*ed775ee7SAntonio Huete Jimenez ND_PRINT(": PSNDN"); /* XXX */
746411677aeSAaron LI break;
747411677aeSAaron LI default:
748*ed775ee7SAntonio Huete Jimenez ND_PRINT(": Unknown class %u", GET_U_1(p + 2));
74941c99275SPeter Avalos break;
75041c99275SPeter Avalos }
75141c99275SPeter Avalos break;
75241c99275SPeter Avalos
75341c99275SPeter Avalos /* XXX: to be supported */
75441c99275SPeter Avalos #if 0
75541c99275SPeter Avalos case LCPOPT_DEP6:
75641c99275SPeter Avalos case LCPOPT_FCSALT:
75741c99275SPeter Avalos case LCPOPT_SDP:
75841c99275SPeter Avalos case LCPOPT_NUMMODE:
75941c99275SPeter Avalos case LCPOPT_DEP12:
76041c99275SPeter Avalos case LCPOPT_DEP14:
76141c99275SPeter Avalos case LCPOPT_DEP15:
76241c99275SPeter Avalos case LCPOPT_DEP16:
76341c99275SPeter Avalos case LCPOPT_MLSSNHF:
76441c99275SPeter Avalos case LCPOPT_PROP:
76541c99275SPeter Avalos case LCPOPT_DCEID:
76641c99275SPeter Avalos case LCPOPT_MPP:
76741c99275SPeter Avalos case LCPOPT_LCPAOPT:
76841c99275SPeter Avalos case LCPOPT_COBS:
76941c99275SPeter Avalos case LCPOPT_PE:
77041c99275SPeter Avalos case LCPOPT_MLHF:
77141c99275SPeter Avalos case LCPOPT_I18N:
77241c99275SPeter Avalos case LCPOPT_SDLOS:
77341c99275SPeter Avalos case LCPOPT_PPPMUX:
77441c99275SPeter Avalos break;
77541c99275SPeter Avalos #endif
77641c99275SPeter Avalos default:
777411677aeSAaron LI /*
778411677aeSAaron LI * Unknown option; dump it as raw bytes now if we're
779411677aeSAaron LI * not going to do so below.
780411677aeSAaron LI */
781411677aeSAaron LI if (ndo->ndo_vflag < 2)
782*ed775ee7SAntonio Huete Jimenez print_unknown_data(ndo, p + 2, "\n\t ", len - 2);
78341c99275SPeter Avalos break;
78441c99275SPeter Avalos }
78541c99275SPeter Avalos
786411677aeSAaron LI if (ndo->ndo_vflag > 1)
787*ed775ee7SAntonio Huete Jimenez print_unknown_data(ndo, p + 2, "\n\t ", len - 2); /* exclude TLV header */
78841c99275SPeter Avalos
78941c99275SPeter Avalos return len;
79041c99275SPeter Avalos
79141c99275SPeter Avalos trunc:
792*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|lcp]");
79341c99275SPeter Avalos return 0;
79441c99275SPeter Avalos }
79541c99275SPeter Avalos
79641c99275SPeter Avalos /* ML-PPP*/
797411677aeSAaron LI static const struct tok ppp_ml_flag_values[] = {
79841c99275SPeter Avalos { 0x80, "begin" },
79941c99275SPeter Avalos { 0x40, "end" },
80041c99275SPeter Avalos { 0, NULL }
80141c99275SPeter Avalos };
80241c99275SPeter Avalos
80341c99275SPeter Avalos static void
handle_mlppp(netdissect_options * ndo,const u_char * p,u_int length)804411677aeSAaron LI handle_mlppp(netdissect_options *ndo,
805*ed775ee7SAntonio Huete Jimenez const u_char *p, u_int length)
806411677aeSAaron LI {
807411677aeSAaron LI if (!ndo->ndo_eflag)
808*ed775ee7SAntonio Huete Jimenez ND_PRINT("MLPPP, ");
80941c99275SPeter Avalos
810411677aeSAaron LI if (length < 2) {
811*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|mlppp]");
812411677aeSAaron LI return;
813411677aeSAaron LI }
814*ed775ee7SAntonio Huete Jimenez if (!ND_TTEST_2(p)) {
815*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|mlppp]");
816411677aeSAaron LI return;
817411677aeSAaron LI }
81841c99275SPeter Avalos
819*ed775ee7SAntonio Huete Jimenez ND_PRINT("seq 0x%03x, Flags [%s], length %u",
820*ed775ee7SAntonio Huete Jimenez (GET_BE_U_2(p))&0x0fff,
821*ed775ee7SAntonio Huete Jimenez /* only support 12-Bit sequence space for now */
822*ed775ee7SAntonio Huete Jimenez bittok2str(ppp_ml_flag_values, "none", GET_U_1(p) & 0xc0),
823*ed775ee7SAntonio Huete Jimenez length);
82441c99275SPeter Avalos }
82541c99275SPeter Avalos
82641c99275SPeter Avalos /* CHAP */
82741c99275SPeter Avalos static void
handle_chap(netdissect_options * ndo,const u_char * p,u_int length)828411677aeSAaron LI handle_chap(netdissect_options *ndo,
829*ed775ee7SAntonio Huete Jimenez const u_char *p, u_int length)
83041c99275SPeter Avalos {
83141c99275SPeter Avalos u_int code, len;
832*ed775ee7SAntonio Huete Jimenez u_int val_size, name_size, msg_size;
83341c99275SPeter Avalos const u_char *p0;
834*ed775ee7SAntonio Huete Jimenez u_int i;
83541c99275SPeter Avalos
83641c99275SPeter Avalos p0 = p;
83741c99275SPeter Avalos if (length < 1) {
838*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|chap]");
83941c99275SPeter Avalos return;
84041c99275SPeter Avalos } else if (length < 4) {
841*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|chap 0x%02x]", GET_U_1(p));
84241c99275SPeter Avalos return;
84341c99275SPeter Avalos }
84441c99275SPeter Avalos
845*ed775ee7SAntonio Huete Jimenez code = GET_U_1(p);
846*ed775ee7SAntonio Huete Jimenez ND_PRINT("CHAP, %s (0x%02x)",
84741c99275SPeter Avalos tok2str(chapcode_values,"unknown",code),
848*ed775ee7SAntonio Huete Jimenez code);
84941c99275SPeter Avalos p++;
85041c99275SPeter Avalos
851*ed775ee7SAntonio Huete Jimenez ND_PRINT(", id %u", GET_U_1(p)); /* ID */
85241c99275SPeter Avalos p++;
85341c99275SPeter Avalos
854*ed775ee7SAntonio Huete Jimenez len = GET_BE_U_2(p);
85541c99275SPeter Avalos p += 2;
85641c99275SPeter Avalos
85741c99275SPeter Avalos /*
85841c99275SPeter Avalos * Note that this is a generic CHAP decoding routine. Since we
85941c99275SPeter Avalos * don't know which flavor of CHAP (i.e. CHAP-MD5, MS-CHAPv1,
86041c99275SPeter Avalos * MS-CHAPv2) is used at this point, we can't decode packet
86141c99275SPeter Avalos * specifically to each algorithms. Instead, we simply decode
86241c99275SPeter Avalos * the GCD (Gratest Common Denominator) for all algorithms.
86341c99275SPeter Avalos */
86441c99275SPeter Avalos switch (code) {
86541c99275SPeter Avalos case CHAP_CHAL:
86641c99275SPeter Avalos case CHAP_RESP:
86741c99275SPeter Avalos if (length - (p - p0) < 1)
86841c99275SPeter Avalos return;
869*ed775ee7SAntonio Huete Jimenez val_size = GET_U_1(p); /* value size */
87041c99275SPeter Avalos p++;
87141c99275SPeter Avalos if (length - (p - p0) < val_size)
87241c99275SPeter Avalos return;
873*ed775ee7SAntonio Huete Jimenez ND_PRINT(", Value ");
87441c99275SPeter Avalos for (i = 0; i < val_size; i++) {
875*ed775ee7SAntonio Huete Jimenez ND_PRINT("%02x", GET_U_1(p));
876*ed775ee7SAntonio Huete Jimenez p++;
87741c99275SPeter Avalos }
878*ed775ee7SAntonio Huete Jimenez name_size = len - (u_int)(p - p0);
879*ed775ee7SAntonio Huete Jimenez ND_PRINT(", Name ");
88041c99275SPeter Avalos for (i = 0; i < name_size; i++) {
881*ed775ee7SAntonio Huete Jimenez fn_print_char(ndo, GET_U_1(p));
882*ed775ee7SAntonio Huete Jimenez p++;
88341c99275SPeter Avalos }
88441c99275SPeter Avalos break;
88541c99275SPeter Avalos case CHAP_SUCC:
88641c99275SPeter Avalos case CHAP_FAIL:
887*ed775ee7SAntonio Huete Jimenez msg_size = len - (u_int)(p - p0);
888*ed775ee7SAntonio Huete Jimenez ND_PRINT(", Msg ");
88941c99275SPeter Avalos for (i = 0; i< msg_size; i++) {
890*ed775ee7SAntonio Huete Jimenez fn_print_char(ndo, GET_U_1(p));
891*ed775ee7SAntonio Huete Jimenez p++;
89241c99275SPeter Avalos }
89341c99275SPeter Avalos break;
89441c99275SPeter Avalos }
89541c99275SPeter Avalos }
89641c99275SPeter Avalos
89741c99275SPeter Avalos /* PAP (see RFC 1334) */
89841c99275SPeter Avalos static void
handle_pap(netdissect_options * ndo,const u_char * p,u_int length)899411677aeSAaron LI handle_pap(netdissect_options *ndo,
900*ed775ee7SAntonio Huete Jimenez const u_char *p, u_int length)
90141c99275SPeter Avalos {
90241c99275SPeter Avalos u_int code, len;
903*ed775ee7SAntonio Huete Jimenez u_int peerid_len, passwd_len, msg_len;
90441c99275SPeter Avalos const u_char *p0;
905*ed775ee7SAntonio Huete Jimenez u_int i;
90641c99275SPeter Avalos
90741c99275SPeter Avalos p0 = p;
90841c99275SPeter Avalos if (length < 1) {
909*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|pap]");
91041c99275SPeter Avalos return;
91141c99275SPeter Avalos } else if (length < 4) {
912*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|pap 0x%02x]", GET_U_1(p));
91341c99275SPeter Avalos return;
91441c99275SPeter Avalos }
91541c99275SPeter Avalos
916*ed775ee7SAntonio Huete Jimenez code = GET_U_1(p);
917*ed775ee7SAntonio Huete Jimenez ND_PRINT("PAP, %s (0x%02x)",
91841c99275SPeter Avalos tok2str(papcode_values, "unknown", code),
919*ed775ee7SAntonio Huete Jimenez code);
92041c99275SPeter Avalos p++;
92141c99275SPeter Avalos
922*ed775ee7SAntonio Huete Jimenez ND_PRINT(", id %u", GET_U_1(p)); /* ID */
92341c99275SPeter Avalos p++;
92441c99275SPeter Avalos
925*ed775ee7SAntonio Huete Jimenez len = GET_BE_U_2(p);
92641c99275SPeter Avalos p += 2;
92741c99275SPeter Avalos
928*ed775ee7SAntonio Huete Jimenez if (len > length) {
929*ed775ee7SAntonio Huete Jimenez ND_PRINT(", length %u > packet size", len);
93041c99275SPeter Avalos return;
93141c99275SPeter Avalos }
93241c99275SPeter Avalos length = len;
933*ed775ee7SAntonio Huete Jimenez if (length < (size_t)(p - p0)) {
934*ed775ee7SAntonio Huete Jimenez ND_PRINT(", length %u < PAP header length", length);
93541c99275SPeter Avalos return;
93641c99275SPeter Avalos }
93741c99275SPeter Avalos
93841c99275SPeter Avalos switch (code) {
93941c99275SPeter Avalos case PAP_AREQ:
940411677aeSAaron LI /* A valid Authenticate-Request is 6 or more octets long. */
941411677aeSAaron LI if (len < 6)
942411677aeSAaron LI goto trunc;
94341c99275SPeter Avalos if (length - (p - p0) < 1)
94441c99275SPeter Avalos return;
945*ed775ee7SAntonio Huete Jimenez peerid_len = GET_U_1(p); /* Peer-ID Length */
94641c99275SPeter Avalos p++;
94741c99275SPeter Avalos if (length - (p - p0) < peerid_len)
94841c99275SPeter Avalos return;
949*ed775ee7SAntonio Huete Jimenez ND_PRINT(", Peer ");
95041c99275SPeter Avalos for (i = 0; i < peerid_len; i++) {
951*ed775ee7SAntonio Huete Jimenez fn_print_char(ndo, GET_U_1(p));
952*ed775ee7SAntonio Huete Jimenez p++;
95341c99275SPeter Avalos }
95441c99275SPeter Avalos
95541c99275SPeter Avalos if (length - (p - p0) < 1)
95641c99275SPeter Avalos return;
957*ed775ee7SAntonio Huete Jimenez passwd_len = GET_U_1(p); /* Password Length */
95841c99275SPeter Avalos p++;
95941c99275SPeter Avalos if (length - (p - p0) < passwd_len)
96041c99275SPeter Avalos return;
961*ed775ee7SAntonio Huete Jimenez ND_PRINT(", Name ");
96241c99275SPeter Avalos for (i = 0; i < passwd_len; i++) {
963*ed775ee7SAntonio Huete Jimenez fn_print_char(ndo, GET_U_1(p));
964*ed775ee7SAntonio Huete Jimenez p++;
96541c99275SPeter Avalos }
96641c99275SPeter Avalos break;
96741c99275SPeter Avalos case PAP_AACK:
96841c99275SPeter Avalos case PAP_ANAK:
969411677aeSAaron LI /* Although some implementations ignore truncation at
970411677aeSAaron LI * this point and at least one generates a truncated
971411677aeSAaron LI * packet, RFC 1334 section 2.2.2 clearly states that
972411677aeSAaron LI * both AACK and ANAK are at least 5 bytes long.
973411677aeSAaron LI */
974411677aeSAaron LI if (len < 5)
975411677aeSAaron LI goto trunc;
97641c99275SPeter Avalos if (length - (p - p0) < 1)
97741c99275SPeter Avalos return;
978*ed775ee7SAntonio Huete Jimenez msg_len = GET_U_1(p); /* Msg-Length */
97941c99275SPeter Avalos p++;
98041c99275SPeter Avalos if (length - (p - p0) < msg_len)
98141c99275SPeter Avalos return;
982*ed775ee7SAntonio Huete Jimenez ND_PRINT(", Msg ");
98341c99275SPeter Avalos for (i = 0; i< msg_len; i++) {
984*ed775ee7SAntonio Huete Jimenez fn_print_char(ndo, GET_U_1(p));
985*ed775ee7SAntonio Huete Jimenez p++;
98641c99275SPeter Avalos }
98741c99275SPeter Avalos break;
98841c99275SPeter Avalos }
98941c99275SPeter Avalos return;
99041c99275SPeter Avalos
99141c99275SPeter Avalos trunc:
992*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|pap]");
99341c99275SPeter Avalos }
99441c99275SPeter Avalos
99541c99275SPeter Avalos /* BAP */
99641c99275SPeter Avalos static void
handle_bap(netdissect_options * ndo _U_,const u_char * p _U_,u_int length _U_)997411677aeSAaron LI handle_bap(netdissect_options *ndo _U_,
998*ed775ee7SAntonio Huete Jimenez const u_char *p _U_, u_int length _U_)
99941c99275SPeter Avalos {
100041c99275SPeter Avalos /* XXX: to be supported!! */
100141c99275SPeter Avalos }
100241c99275SPeter Avalos
100341c99275SPeter Avalos
100441c99275SPeter Avalos /* IPCP config options */
1005*ed775ee7SAntonio Huete Jimenez static u_int
print_ipcp_config_options(netdissect_options * ndo,const u_char * p,u_int length)1006411677aeSAaron LI print_ipcp_config_options(netdissect_options *ndo,
1007*ed775ee7SAntonio Huete Jimenez const u_char *p, u_int length)
100841c99275SPeter Avalos {
1009*ed775ee7SAntonio Huete Jimenez u_int opt, len;
101041c99275SPeter Avalos u_int compproto, ipcomp_subopttotallen, ipcomp_subopt, ipcomp_suboptlen;
101141c99275SPeter Avalos
101241c99275SPeter Avalos if (length < 2)
101341c99275SPeter Avalos return 0;
1014*ed775ee7SAntonio Huete Jimenez ND_TCHECK_2(p);
1015*ed775ee7SAntonio Huete Jimenez opt = GET_U_1(p);
1016*ed775ee7SAntonio Huete Jimenez len = GET_U_1(p + 1);
101741c99275SPeter Avalos if (length < len)
101841c99275SPeter Avalos return 0;
101941c99275SPeter Avalos if (len < 2) {
1020*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
102141c99275SPeter Avalos tok2str(ipcpopt_values,"unknown",opt),
102241c99275SPeter Avalos opt,
1023*ed775ee7SAntonio Huete Jimenez len);
102441c99275SPeter Avalos return 0;
102541c99275SPeter Avalos }
102641c99275SPeter Avalos
1027*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t %s Option (0x%02x), length %u",
102841c99275SPeter Avalos tok2str(ipcpopt_values,"unknown",opt),
102941c99275SPeter Avalos opt,
1030*ed775ee7SAntonio Huete Jimenez len);
103141c99275SPeter Avalos
103241c99275SPeter Avalos switch (opt) {
103341c99275SPeter Avalos case IPCPOPT_2ADDR: /* deprecated */
1034411677aeSAaron LI if (len != 10) {
1035*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be = 10)");
1036411677aeSAaron LI return len;
1037411677aeSAaron LI }
1038*ed775ee7SAntonio Huete Jimenez ND_PRINT(": src %s, dst %s",
1039*ed775ee7SAntonio Huete Jimenez GET_IPADDR_STRING(p + 2),
1040*ed775ee7SAntonio Huete Jimenez GET_IPADDR_STRING(p + 6));
104141c99275SPeter Avalos break;
104241c99275SPeter Avalos case IPCPOPT_IPCOMP:
1043411677aeSAaron LI if (len < 4) {
1044*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be >= 4)");
1045411677aeSAaron LI return 0;
1046411677aeSAaron LI }
1047*ed775ee7SAntonio Huete Jimenez compproto = GET_BE_U_2(p + 2);
104841c99275SPeter Avalos
1049*ed775ee7SAntonio Huete Jimenez ND_PRINT(": %s (0x%02x):",
105041c99275SPeter Avalos tok2str(ipcpopt_compproto_values, "Unknown", compproto),
1051*ed775ee7SAntonio Huete Jimenez compproto);
105241c99275SPeter Avalos
105341c99275SPeter Avalos switch (compproto) {
105441c99275SPeter Avalos case PPP_VJC:
105541c99275SPeter Avalos /* XXX: VJ-Comp parameters should be decoded */
105641c99275SPeter Avalos break;
105741c99275SPeter Avalos case IPCPOPT_IPCOMP_HDRCOMP:
1058411677aeSAaron LI if (len < IPCPOPT_IPCOMP_MINLEN) {
1059*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be >= %u)",
1060*ed775ee7SAntonio Huete Jimenez IPCPOPT_IPCOMP_MINLEN);
1061411677aeSAaron LI return 0;
1062411677aeSAaron LI }
106341c99275SPeter Avalos
1064*ed775ee7SAntonio Huete Jimenez ND_TCHECK_LEN(p + 2, IPCPOPT_IPCOMP_MINLEN);
1065*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t TCP Space %u, non-TCP Space %u"
106641c99275SPeter Avalos ", maxPeriod %u, maxTime %u, maxHdr %u",
1067*ed775ee7SAntonio Huete Jimenez GET_BE_U_2(p + 4),
1068*ed775ee7SAntonio Huete Jimenez GET_BE_U_2(p + 6),
1069*ed775ee7SAntonio Huete Jimenez GET_BE_U_2(p + 8),
1070*ed775ee7SAntonio Huete Jimenez GET_BE_U_2(p + 10),
1071*ed775ee7SAntonio Huete Jimenez GET_BE_U_2(p + 12));
107241c99275SPeter Avalos
107341c99275SPeter Avalos /* suboptions present ? */
107441c99275SPeter Avalos if (len > IPCPOPT_IPCOMP_MINLEN) {
107541c99275SPeter Avalos ipcomp_subopttotallen = len - IPCPOPT_IPCOMP_MINLEN;
107641c99275SPeter Avalos p += IPCPOPT_IPCOMP_MINLEN;
107741c99275SPeter Avalos
1078*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t Suboptions, length %u", ipcomp_subopttotallen);
107941c99275SPeter Avalos
108041c99275SPeter Avalos while (ipcomp_subopttotallen >= 2) {
1081*ed775ee7SAntonio Huete Jimenez ND_TCHECK_2(p);
1082*ed775ee7SAntonio Huete Jimenez ipcomp_subopt = GET_U_1(p);
1083*ed775ee7SAntonio Huete Jimenez ipcomp_suboptlen = GET_U_1(p + 1);
108441c99275SPeter Avalos
108541c99275SPeter Avalos /* sanity check */
108641c99275SPeter Avalos if (ipcomp_subopt == 0 ||
108741c99275SPeter Avalos ipcomp_suboptlen == 0 )
108841c99275SPeter Avalos break;
108941c99275SPeter Avalos
109041c99275SPeter Avalos /* XXX: just display the suboptions for now */
1091*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t\t%s Suboption #%u, length %u",
109241c99275SPeter Avalos tok2str(ipcpopt_compproto_subopt_values,
109341c99275SPeter Avalos "Unknown",
109441c99275SPeter Avalos ipcomp_subopt),
109541c99275SPeter Avalos ipcomp_subopt,
1096*ed775ee7SAntonio Huete Jimenez ipcomp_suboptlen);
1097*ed775ee7SAntonio Huete Jimenez if (ipcomp_subopttotallen < ipcomp_suboptlen) {
1098*ed775ee7SAntonio Huete Jimenez ND_PRINT(" [remaining suboptions length %u < %u]",
1099*ed775ee7SAntonio Huete Jimenez ipcomp_subopttotallen, ipcomp_suboptlen);
1100*ed775ee7SAntonio Huete Jimenez nd_print_invalid(ndo);
1101*ed775ee7SAntonio Huete Jimenez break;
1102*ed775ee7SAntonio Huete Jimenez }
110341c99275SPeter Avalos ipcomp_subopttotallen -= ipcomp_suboptlen;
110441c99275SPeter Avalos p += ipcomp_suboptlen;
110541c99275SPeter Avalos }
110641c99275SPeter Avalos }
110741c99275SPeter Avalos break;
110841c99275SPeter Avalos default:
110941c99275SPeter Avalos break;
111041c99275SPeter Avalos }
111141c99275SPeter Avalos break;
111241c99275SPeter Avalos
111341c99275SPeter Avalos case IPCPOPT_ADDR: /* those options share the same format - fall through */
111441c99275SPeter Avalos case IPCPOPT_MOBILE4:
111541c99275SPeter Avalos case IPCPOPT_PRIDNS:
111641c99275SPeter Avalos case IPCPOPT_PRINBNS:
111741c99275SPeter Avalos case IPCPOPT_SECDNS:
111841c99275SPeter Avalos case IPCPOPT_SECNBNS:
1119411677aeSAaron LI if (len != 6) {
1120*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be = 6)");
1121411677aeSAaron LI return 0;
1122411677aeSAaron LI }
1123*ed775ee7SAntonio Huete Jimenez ND_PRINT(": %s", GET_IPADDR_STRING(p + 2));
112441c99275SPeter Avalos break;
112541c99275SPeter Avalos default:
1126411677aeSAaron LI /*
1127411677aeSAaron LI * Unknown option; dump it as raw bytes now if we're
1128411677aeSAaron LI * not going to do so below.
1129411677aeSAaron LI */
1130411677aeSAaron LI if (ndo->ndo_vflag < 2)
1131*ed775ee7SAntonio Huete Jimenez print_unknown_data(ndo, p + 2, "\n\t ", len - 2);
113241c99275SPeter Avalos break;
113341c99275SPeter Avalos }
1134411677aeSAaron LI if (ndo->ndo_vflag > 1)
1135*ed775ee7SAntonio Huete Jimenez print_unknown_data(ndo, p + 2, "\n\t ", len - 2); /* exclude TLV header */
113641c99275SPeter Avalos return len;
113741c99275SPeter Avalos
113841c99275SPeter Avalos trunc:
1139*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|ipcp]");
114041c99275SPeter Avalos return 0;
114141c99275SPeter Avalos }
114241c99275SPeter Avalos
114341c99275SPeter Avalos /* IP6CP config options */
1144*ed775ee7SAntonio Huete Jimenez static u_int
print_ip6cp_config_options(netdissect_options * ndo,const u_char * p,u_int length)1145411677aeSAaron LI print_ip6cp_config_options(netdissect_options *ndo,
1146*ed775ee7SAntonio Huete Jimenez const u_char *p, u_int length)
114741c99275SPeter Avalos {
1148*ed775ee7SAntonio Huete Jimenez u_int opt, len;
114941c99275SPeter Avalos
115041c99275SPeter Avalos if (length < 2)
115141c99275SPeter Avalos return 0;
1152*ed775ee7SAntonio Huete Jimenez ND_TCHECK_2(p);
1153*ed775ee7SAntonio Huete Jimenez opt = GET_U_1(p);
1154*ed775ee7SAntonio Huete Jimenez len = GET_U_1(p + 1);
115541c99275SPeter Avalos if (length < len)
115641c99275SPeter Avalos return 0;
115741c99275SPeter Avalos if (len < 2) {
1158*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
115941c99275SPeter Avalos tok2str(ip6cpopt_values,"unknown",opt),
116041c99275SPeter Avalos opt,
1161*ed775ee7SAntonio Huete Jimenez len);
116241c99275SPeter Avalos return 0;
116341c99275SPeter Avalos }
116441c99275SPeter Avalos
1165*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t %s Option (0x%02x), length %u",
116641c99275SPeter Avalos tok2str(ip6cpopt_values,"unknown",opt),
116741c99275SPeter Avalos opt,
1168*ed775ee7SAntonio Huete Jimenez len);
116941c99275SPeter Avalos
117041c99275SPeter Avalos switch (opt) {
117141c99275SPeter Avalos case IP6CP_IFID:
1172411677aeSAaron LI if (len != 10) {
1173*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be = 10)");
1174411677aeSAaron LI return len;
1175411677aeSAaron LI }
1176*ed775ee7SAntonio Huete Jimenez ND_TCHECK_8(p + 2);
1177*ed775ee7SAntonio Huete Jimenez ND_PRINT(": %04x:%04x:%04x:%04x",
1178*ed775ee7SAntonio Huete Jimenez GET_BE_U_2(p + 2),
1179*ed775ee7SAntonio Huete Jimenez GET_BE_U_2(p + 4),
1180*ed775ee7SAntonio Huete Jimenez GET_BE_U_2(p + 6),
1181*ed775ee7SAntonio Huete Jimenez GET_BE_U_2(p + 8));
118241c99275SPeter Avalos break;
118341c99275SPeter Avalos default:
1184411677aeSAaron LI /*
1185411677aeSAaron LI * Unknown option; dump it as raw bytes now if we're
1186411677aeSAaron LI * not going to do so below.
1187411677aeSAaron LI */
1188411677aeSAaron LI if (ndo->ndo_vflag < 2)
1189*ed775ee7SAntonio Huete Jimenez print_unknown_data(ndo, p + 2, "\n\t ", len - 2);
119041c99275SPeter Avalos break;
119141c99275SPeter Avalos }
1192411677aeSAaron LI if (ndo->ndo_vflag > 1)
1193*ed775ee7SAntonio Huete Jimenez print_unknown_data(ndo, p + 2, "\n\t ", len - 2); /* exclude TLV header */
119441c99275SPeter Avalos
119541c99275SPeter Avalos return len;
119641c99275SPeter Avalos
119741c99275SPeter Avalos trunc:
1198*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|ip6cp]");
119941c99275SPeter Avalos return 0;
120041c99275SPeter Avalos }
120141c99275SPeter Avalos
120241c99275SPeter Avalos
120341c99275SPeter Avalos /* CCP config options */
1204*ed775ee7SAntonio Huete Jimenez static u_int
print_ccp_config_options(netdissect_options * ndo,const u_char * p,u_int length)1205411677aeSAaron LI print_ccp_config_options(netdissect_options *ndo,
1206*ed775ee7SAntonio Huete Jimenez const u_char *p, u_int length)
120741c99275SPeter Avalos {
1208*ed775ee7SAntonio Huete Jimenez u_int opt, len;
120941c99275SPeter Avalos
121041c99275SPeter Avalos if (length < 2)
121141c99275SPeter Avalos return 0;
1212*ed775ee7SAntonio Huete Jimenez ND_TCHECK_2(p);
1213*ed775ee7SAntonio Huete Jimenez opt = GET_U_1(p);
1214*ed775ee7SAntonio Huete Jimenez len = GET_U_1(p + 1);
121541c99275SPeter Avalos if (length < len)
121641c99275SPeter Avalos return 0;
121741c99275SPeter Avalos if (len < 2) {
1218*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
121941c99275SPeter Avalos tok2str(ccpconfopts_values, "Unknown", opt),
122041c99275SPeter Avalos opt,
1221*ed775ee7SAntonio Huete Jimenez len);
122241c99275SPeter Avalos return 0;
122341c99275SPeter Avalos }
122441c99275SPeter Avalos
1225*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t %s Option (0x%02x), length %u",
122641c99275SPeter Avalos tok2str(ccpconfopts_values, "Unknown", opt),
122741c99275SPeter Avalos opt,
1228*ed775ee7SAntonio Huete Jimenez len);
122941c99275SPeter Avalos
123041c99275SPeter Avalos switch (opt) {
1231411677aeSAaron LI case CCPOPT_BSDCOMP:
1232411677aeSAaron LI if (len < 3) {
1233*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be >= 3)");
1234411677aeSAaron LI return len;
1235411677aeSAaron LI }
1236*ed775ee7SAntonio Huete Jimenez ND_PRINT(": Version: %u, Dictionary Bits: %u",
1237*ed775ee7SAntonio Huete Jimenez GET_U_1(p + 2) >> 5,
1238*ed775ee7SAntonio Huete Jimenez GET_U_1(p + 2) & 0x1f);
1239411677aeSAaron LI break;
1240411677aeSAaron LI case CCPOPT_MVRCA:
1241411677aeSAaron LI if (len < 4) {
1242*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be >= 4)");
1243411677aeSAaron LI return len;
1244411677aeSAaron LI }
1245*ed775ee7SAntonio Huete Jimenez ND_PRINT(": Features: %u, PxP: %s, History: %u, #CTX-ID: %u",
1246*ed775ee7SAntonio Huete Jimenez (GET_U_1(p + 2) & 0xc0) >> 6,
1247*ed775ee7SAntonio Huete Jimenez (GET_U_1(p + 2) & 0x20) ? "Enabled" : "Disabled",
1248*ed775ee7SAntonio Huete Jimenez GET_U_1(p + 2) & 0x1f,
1249*ed775ee7SAntonio Huete Jimenez GET_U_1(p + 3));
1250411677aeSAaron LI break;
1251411677aeSAaron LI case CCPOPT_DEFLATE:
1252411677aeSAaron LI if (len < 4) {
1253*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be >= 4)");
1254411677aeSAaron LI return len;
1255411677aeSAaron LI }
1256*ed775ee7SAntonio Huete Jimenez ND_PRINT(": Window: %uK, Method: %s (0x%x), MBZ: %u, CHK: %u",
1257*ed775ee7SAntonio Huete Jimenez (GET_U_1(p + 2) & 0xf0) >> 4,
1258*ed775ee7SAntonio Huete Jimenez ((GET_U_1(p + 2) & 0x0f) == 8) ? "zlib" : "unknown",
1259*ed775ee7SAntonio Huete Jimenez GET_U_1(p + 2) & 0x0f,
1260*ed775ee7SAntonio Huete Jimenez (GET_U_1(p + 3) & 0xfc) >> 2,
1261*ed775ee7SAntonio Huete Jimenez GET_U_1(p + 3) & 0x03);
1262411677aeSAaron LI break;
1263411677aeSAaron LI
1264411677aeSAaron LI /* XXX: to be supported */
1265411677aeSAaron LI #if 0
126641c99275SPeter Avalos case CCPOPT_OUI:
126741c99275SPeter Avalos case CCPOPT_PRED1:
126841c99275SPeter Avalos case CCPOPT_PRED2:
126941c99275SPeter Avalos case CCPOPT_PJUMP:
127041c99275SPeter Avalos case CCPOPT_HPPPC:
127141c99275SPeter Avalos case CCPOPT_STACLZS:
127241c99275SPeter Avalos case CCPOPT_MPPC:
127341c99275SPeter Avalos case CCPOPT_GFZA:
127441c99275SPeter Avalos case CCPOPT_V42BIS:
127541c99275SPeter Avalos case CCPOPT_LZSDCP:
127641c99275SPeter Avalos case CCPOPT_DEC:
127741c99275SPeter Avalos case CCPOPT_RESV:
1278411677aeSAaron LI break;
1279411677aeSAaron LI #endif
128041c99275SPeter Avalos default:
1281411677aeSAaron LI /*
1282411677aeSAaron LI * Unknown option; dump it as raw bytes now if we're
1283411677aeSAaron LI * not going to do so below.
1284411677aeSAaron LI */
1285411677aeSAaron LI if (ndo->ndo_vflag < 2)
1286*ed775ee7SAntonio Huete Jimenez print_unknown_data(ndo, p + 2, "\n\t ", len - 2);
128741c99275SPeter Avalos break;
128841c99275SPeter Avalos }
1289411677aeSAaron LI if (ndo->ndo_vflag > 1)
1290*ed775ee7SAntonio Huete Jimenez print_unknown_data(ndo, p + 2, "\n\t ", len - 2); /* exclude TLV header */
129141c99275SPeter Avalos
129241c99275SPeter Avalos return len;
129341c99275SPeter Avalos
129441c99275SPeter Avalos trunc:
1295*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|ccp]");
129641c99275SPeter Avalos return 0;
129741c99275SPeter Avalos }
129841c99275SPeter Avalos
129941c99275SPeter Avalos /* BACP config options */
1300*ed775ee7SAntonio Huete Jimenez static u_int
print_bacp_config_options(netdissect_options * ndo,const u_char * p,u_int length)1301411677aeSAaron LI print_bacp_config_options(netdissect_options *ndo,
1302*ed775ee7SAntonio Huete Jimenez const u_char *p, u_int length)
130341c99275SPeter Avalos {
1304*ed775ee7SAntonio Huete Jimenez u_int opt, len;
130541c99275SPeter Avalos
130641c99275SPeter Avalos if (length < 2)
130741c99275SPeter Avalos return 0;
1308*ed775ee7SAntonio Huete Jimenez ND_TCHECK_2(p);
1309*ed775ee7SAntonio Huete Jimenez opt = GET_U_1(p);
1310*ed775ee7SAntonio Huete Jimenez len = GET_U_1(p + 1);
131141c99275SPeter Avalos if (length < len)
131241c99275SPeter Avalos return 0;
131341c99275SPeter Avalos if (len < 2) {
1314*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
131541c99275SPeter Avalos tok2str(bacconfopts_values, "Unknown", opt),
131641c99275SPeter Avalos opt,
1317*ed775ee7SAntonio Huete Jimenez len);
131841c99275SPeter Avalos return 0;
131941c99275SPeter Avalos }
132041c99275SPeter Avalos
1321*ed775ee7SAntonio Huete Jimenez ND_PRINT("\n\t %s Option (0x%02x), length %u",
132241c99275SPeter Avalos tok2str(bacconfopts_values, "Unknown", opt),
132341c99275SPeter Avalos opt,
1324*ed775ee7SAntonio Huete Jimenez len);
132541c99275SPeter Avalos
132641c99275SPeter Avalos switch (opt) {
132741c99275SPeter Avalos case BACPOPT_FPEER:
1328411677aeSAaron LI if (len != 6) {
1329*ed775ee7SAntonio Huete Jimenez ND_PRINT(" (length bogus, should be = 6)");
1330411677aeSAaron LI return len;
1331411677aeSAaron LI }
1332*ed775ee7SAntonio Huete Jimenez ND_PRINT(": Magic-Num 0x%08x", GET_BE_U_4(p + 2));
133341c99275SPeter Avalos break;
133441c99275SPeter Avalos default:
1335411677aeSAaron LI /*
1336411677aeSAaron LI * Unknown option; dump it as raw bytes now if we're
1337411677aeSAaron LI * not going to do so below.
1338411677aeSAaron LI */
1339411677aeSAaron LI if (ndo->ndo_vflag < 2)
1340*ed775ee7SAntonio Huete Jimenez print_unknown_data(ndo, p + 2, "\n\t ", len - 2);
134141c99275SPeter Avalos break;
134241c99275SPeter Avalos }
1343411677aeSAaron LI if (ndo->ndo_vflag > 1)
1344*ed775ee7SAntonio Huete Jimenez print_unknown_data(ndo, p + 2, "\n\t ", len - 2); /* exclude TLV header */
134541c99275SPeter Avalos
134641c99275SPeter Avalos return len;
134741c99275SPeter Avalos
134841c99275SPeter Avalos trunc:
1349*ed775ee7SAntonio Huete Jimenez ND_PRINT("[|bacp]");
135041c99275SPeter Avalos return 0;
135141c99275SPeter Avalos }
135241c99275SPeter Avalos
1353*ed775ee7SAntonio Huete Jimenez /*
1354*ed775ee7SAntonio Huete Jimenez * Un-escape RFC 1662 PPP in HDLC-like framing, with octet escapes.
1355*ed775ee7SAntonio Huete Jimenez * The length argument is the on-the-wire length, not the captured
1356*ed775ee7SAntonio Huete Jimenez * length; we can only un-escape the captured part.
1357*ed775ee7SAntonio Huete Jimenez */
135841c99275SPeter Avalos static void
ppp_hdlc(netdissect_options * ndo,const u_char * p,u_int length)1359411677aeSAaron LI ppp_hdlc(netdissect_options *ndo,
1360*ed775ee7SAntonio Huete Jimenez const u_char *p, u_int length)
136141c99275SPeter Avalos {
1362*ed775ee7SAntonio Huete Jimenez u_int caplen = ND_BYTES_AVAILABLE_AFTER(p);
1363411677aeSAaron LI u_char *b, *t, c;
1364411677aeSAaron LI const u_char *s;
1365*ed775ee7SAntonio Huete Jimenez u_int i, proto;
136641c99275SPeter Avalos const void *se;
136741c99275SPeter Avalos
1368*ed775ee7SAntonio Huete Jimenez if (caplen == 0)
1369411677aeSAaron LI return;
1370411677aeSAaron LI
1371*ed775ee7SAntonio Huete Jimenez if (length == 0)
1372*ed775ee7SAntonio Huete Jimenez return;
1373*ed775ee7SAntonio Huete Jimenez
1374*ed775ee7SAntonio Huete Jimenez b = (u_char *)nd_malloc(ndo, caplen);
137541c99275SPeter Avalos if (b == NULL)
137641c99275SPeter Avalos return;
137741c99275SPeter Avalos
137841c99275SPeter Avalos /*
137941c99275SPeter Avalos * Unescape all the data into a temporary, private, buffer.
1380*ed775ee7SAntonio Huete Jimenez * Do this so that we don't overwrite the original packet
138141c99275SPeter Avalos * contents.
138241c99275SPeter Avalos */
1383*ed775ee7SAntonio Huete Jimenez for (s = p, t = b, i = caplen; i != 0; i--) {
1384*ed775ee7SAntonio Huete Jimenez c = GET_U_1(s);
1385*ed775ee7SAntonio Huete Jimenez s++;
138641c99275SPeter Avalos if (c == 0x7d) {
1387*ed775ee7SAntonio Huete Jimenez if (i <= 1)
1388411677aeSAaron LI break;
138941c99275SPeter Avalos i--;
1390*ed775ee7SAntonio Huete Jimenez c = GET_U_1(s) ^ 0x20;
1391*ed775ee7SAntonio Huete Jimenez s++;
139241c99275SPeter Avalos }
139341c99275SPeter Avalos *t++ = c;
139441c99275SPeter Avalos }
139541c99275SPeter Avalos
1396*ed775ee7SAntonio Huete Jimenez /*
1397*ed775ee7SAntonio Huete Jimenez * Change the end pointer, so bounds checks work.
1398*ed775ee7SAntonio Huete Jimenez */
1399411677aeSAaron LI se = ndo->ndo_snapend;
1400411677aeSAaron LI ndo->ndo_snapend = t;
1401*ed775ee7SAntonio Huete Jimenez length = ND_BYTES_AVAILABLE_AFTER(b);
140241c99275SPeter Avalos
140341c99275SPeter Avalos /* now lets guess about the payload codepoint format */
1404411677aeSAaron LI if (length < 1)
1405411677aeSAaron LI goto trunc;
1406*ed775ee7SAntonio Huete Jimenez proto = GET_U_1(b); /* start with a one-octet codepoint guess */
140741c99275SPeter Avalos
140841c99275SPeter Avalos switch (proto) {
140941c99275SPeter Avalos case PPP_IP:
1410411677aeSAaron LI ip_print(ndo, b + 1, length - 1);
141141c99275SPeter Avalos goto cleanup;
141241c99275SPeter Avalos case PPP_IPV6:
1413411677aeSAaron LI ip6_print(ndo, b + 1, length - 1);
141441c99275SPeter Avalos goto cleanup;
141541c99275SPeter Avalos default: /* no luck - try next guess */
141641c99275SPeter Avalos break;
141741c99275SPeter Avalos }
141841c99275SPeter Avalos
1419411677aeSAaron LI if (length < 2)
1420411677aeSAaron LI goto trunc;
1421*ed775ee7SAntonio Huete Jimenez proto = GET_BE_U_2(b); /* next guess - load two octets */
142241c99275SPeter Avalos
142341c99275SPeter Avalos switch (proto) {
142441c99275SPeter Avalos case (PPP_ADDRESS << 8 | PPP_CONTROL): /* looks like a PPP frame */
1425411677aeSAaron LI if (length < 4)
1426411677aeSAaron LI goto trunc;
1427*ed775ee7SAntonio Huete Jimenez proto = GET_BE_U_2(b + 2); /* load the PPP proto-id */
1428411677aeSAaron LI handle_ppp(ndo, proto, b + 4, length - 4);
142941c99275SPeter Avalos break;
143041c99275SPeter Avalos default: /* last guess - proto must be a PPP proto-id */
1431411677aeSAaron LI handle_ppp(ndo, proto, b + 2, length - 2);
143241c99275SPeter Avalos break;
143341c99275SPeter Avalos }
143441c99275SPeter Avalos
143541c99275SPeter Avalos cleanup:
1436411677aeSAaron LI ndo->ndo_snapend = se;
143741c99275SPeter Avalos return;
1438411677aeSAaron LI
1439411677aeSAaron LI trunc:
1440411677aeSAaron LI ndo->ndo_snapend = se;
1441*ed775ee7SAntonio Huete Jimenez nd_print_trunc(ndo);
144241c99275SPeter Avalos }
144341c99275SPeter Avalos
144441c99275SPeter Avalos
144541c99275SPeter Avalos /* PPP */
144641c99275SPeter Avalos static void
handle_ppp(netdissect_options * ndo,u_int proto,const u_char * p,u_int length)1447411677aeSAaron LI handle_ppp(netdissect_options *ndo,
1448*ed775ee7SAntonio Huete Jimenez u_int proto, const u_char *p, u_int length)
144941c99275SPeter Avalos {
145041c99275SPeter Avalos if ((proto & 0xff00) == 0x7e00) { /* is this an escape code ? */
1451411677aeSAaron LI ppp_hdlc(ndo, p - 1, length);
145241c99275SPeter Avalos return;
145341c99275SPeter Avalos }
145441c99275SPeter Avalos
145541c99275SPeter Avalos switch (proto) {
145641c99275SPeter Avalos case PPP_LCP: /* fall through */
145741c99275SPeter Avalos case PPP_IPCP:
145841c99275SPeter Avalos case PPP_OSICP:
145941c99275SPeter Avalos case PPP_MPLSCP:
146041c99275SPeter Avalos case PPP_IPV6CP:
146141c99275SPeter Avalos case PPP_CCP:
146241c99275SPeter Avalos case PPP_BACP:
1463411677aeSAaron LI handle_ctrl_proto(ndo, proto, p, length);
146441c99275SPeter Avalos break;
146541c99275SPeter Avalos case PPP_ML:
1466411677aeSAaron LI handle_mlppp(ndo, p, length);
146741c99275SPeter Avalos break;
146841c99275SPeter Avalos case PPP_CHAP:
1469411677aeSAaron LI handle_chap(ndo, p, length);
147041c99275SPeter Avalos break;
147141c99275SPeter Avalos case PPP_PAP:
1472411677aeSAaron LI handle_pap(ndo, p, length);
147341c99275SPeter Avalos break;
147441c99275SPeter Avalos case PPP_BAP: /* XXX: not yet completed */
1475411677aeSAaron LI handle_bap(ndo, p, length);
147641c99275SPeter Avalos break;
147741c99275SPeter Avalos case ETHERTYPE_IP: /*XXX*/
147841c99275SPeter Avalos case PPP_VJNC:
147941c99275SPeter Avalos case PPP_IP:
1480411677aeSAaron LI ip_print(ndo, p, length);
148141c99275SPeter Avalos break;
148241c99275SPeter Avalos case ETHERTYPE_IPV6: /*XXX*/
148341c99275SPeter Avalos case PPP_IPV6:
1484411677aeSAaron LI ip6_print(ndo, p, length);
148541c99275SPeter Avalos break;
148641c99275SPeter Avalos case ETHERTYPE_IPX: /*XXX*/
148741c99275SPeter Avalos case PPP_IPX:
1488411677aeSAaron LI ipx_print(ndo, p, length);
148941c99275SPeter Avalos break;
149041c99275SPeter Avalos case PPP_OSI:
1491411677aeSAaron LI isoclns_print(ndo, p, length);
149241c99275SPeter Avalos break;
149341c99275SPeter Avalos case PPP_MPLS_UCAST:
149441c99275SPeter Avalos case PPP_MPLS_MCAST:
1495411677aeSAaron LI mpls_print(ndo, p, length);
149641c99275SPeter Avalos break;
149741c99275SPeter Avalos case PPP_COMP:
1498*ed775ee7SAntonio Huete Jimenez ND_PRINT("compressed PPP data");
149941c99275SPeter Avalos break;
150041c99275SPeter Avalos default:
1501*ed775ee7SAntonio Huete Jimenez ND_PRINT("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto));
1502411677aeSAaron LI print_unknown_data(ndo, p, "\n\t", length);
150341c99275SPeter Avalos break;
150441c99275SPeter Avalos }
150541c99275SPeter Avalos }
150641c99275SPeter Avalos
150741c99275SPeter Avalos /* Standard PPP printer */
150841c99275SPeter Avalos u_int
ppp_print(netdissect_options * ndo,const u_char * p,u_int length)1509411677aeSAaron LI ppp_print(netdissect_options *ndo,
1510*ed775ee7SAntonio Huete Jimenez const u_char *p, u_int length)
151141c99275SPeter Avalos {
151241c99275SPeter Avalos u_int proto,ppp_header;
151341c99275SPeter Avalos u_int olen = length; /* _o_riginal length */
151441c99275SPeter Avalos u_int hdr_len = 0;
151541c99275SPeter Avalos
1516*ed775ee7SAntonio Huete Jimenez ndo->ndo_protocol = "ppp";
151741c99275SPeter Avalos /*
151841c99275SPeter Avalos * Here, we assume that p points to the Address and Control
151941c99275SPeter Avalos * field (if they present).
152041c99275SPeter Avalos */
152141c99275SPeter Avalos if (length < 2)
152241c99275SPeter Avalos goto trunc;
1523*ed775ee7SAntonio Huete Jimenez ppp_header = GET_BE_U_2(p);
152441c99275SPeter Avalos
152541c99275SPeter Avalos switch(ppp_header) {
1526*ed775ee7SAntonio Huete Jimenez case (PPP_PPPD_IN << 8 | PPP_CONTROL):
1527*ed775ee7SAntonio Huete Jimenez if (ndo->ndo_eflag) ND_PRINT("In ");
152841c99275SPeter Avalos p += 2;
152941c99275SPeter Avalos length -= 2;
153041c99275SPeter Avalos hdr_len += 2;
153141c99275SPeter Avalos break;
1532*ed775ee7SAntonio Huete Jimenez case (PPP_PPPD_OUT << 8 | PPP_CONTROL):
1533*ed775ee7SAntonio Huete Jimenez if (ndo->ndo_eflag) ND_PRINT("Out ");
153441c99275SPeter Avalos p += 2;
153541c99275SPeter Avalos length -= 2;
153641c99275SPeter Avalos hdr_len += 2;
153741c99275SPeter Avalos break;
153841c99275SPeter Avalos case (PPP_ADDRESS << 8 | PPP_CONTROL):
153941c99275SPeter Avalos p += 2; /* ACFC not used */
154041c99275SPeter Avalos length -= 2;
154141c99275SPeter Avalos hdr_len += 2;
154241c99275SPeter Avalos break;
154341c99275SPeter Avalos
154441c99275SPeter Avalos default:
154541c99275SPeter Avalos break;
154641c99275SPeter Avalos }
154741c99275SPeter Avalos
154841c99275SPeter Avalos if (length < 2)
154941c99275SPeter Avalos goto trunc;
1550*ed775ee7SAntonio Huete Jimenez if (GET_U_1(p) % 2) {
1551*ed775ee7SAntonio Huete Jimenez proto = GET_U_1(p); /* PFC is used */
155241c99275SPeter Avalos p++;
155341c99275SPeter Avalos length--;
155441c99275SPeter Avalos hdr_len++;
155541c99275SPeter Avalos } else {
1556*ed775ee7SAntonio Huete Jimenez proto = GET_BE_U_2(p);
155741c99275SPeter Avalos p += 2;
155841c99275SPeter Avalos length -= 2;
155941c99275SPeter Avalos hdr_len += 2;
156041c99275SPeter Avalos }
156141c99275SPeter Avalos
1562411677aeSAaron LI if (ndo->ndo_eflag)
1563*ed775ee7SAntonio Huete Jimenez ND_PRINT("%s (0x%04x), length %u: ",
156441c99275SPeter Avalos tok2str(ppptype2str, "unknown", proto),
156541c99275SPeter Avalos proto,
1566*ed775ee7SAntonio Huete Jimenez olen);
156741c99275SPeter Avalos
1568411677aeSAaron LI handle_ppp(ndo, proto, p, length);
156941c99275SPeter Avalos return (hdr_len);
157041c99275SPeter Avalos trunc:
1571*ed775ee7SAntonio Huete Jimenez nd_print_trunc(ndo);
157241c99275SPeter Avalos return (0);
157341c99275SPeter Avalos }
157441c99275SPeter Avalos
157541c99275SPeter Avalos
157641c99275SPeter Avalos /* PPP I/F printer */
1577*ed775ee7SAntonio Huete Jimenez void
ppp_if_print(netdissect_options * ndo,const struct pcap_pkthdr * h,const u_char * p)1578411677aeSAaron LI ppp_if_print(netdissect_options *ndo,
1579*ed775ee7SAntonio Huete Jimenez const struct pcap_pkthdr *h, const u_char *p)
158041c99275SPeter Avalos {
1581*ed775ee7SAntonio Huete Jimenez u_int length = h->len;
1582*ed775ee7SAntonio Huete Jimenez u_int caplen = h->caplen;
158341c99275SPeter Avalos
1584*ed775ee7SAntonio Huete Jimenez ndo->ndo_protocol = "ppp";
158541c99275SPeter Avalos if (caplen < PPP_HDRLEN) {
1586*ed775ee7SAntonio Huete Jimenez nd_print_trunc(ndo);
1587*ed775ee7SAntonio Huete Jimenez ndo->ndo_ll_hdr_len += caplen;
1588*ed775ee7SAntonio Huete Jimenez return;
158941c99275SPeter Avalos }
1590*ed775ee7SAntonio Huete Jimenez ndo->ndo_ll_hdr_len += PPP_HDRLEN;
159141c99275SPeter Avalos
159241c99275SPeter Avalos #if 0
159341c99275SPeter Avalos /*
159441c99275SPeter Avalos * XXX: seems to assume that there are 2 octets prepended to an
159541c99275SPeter Avalos * actual PPP frame. The 1st octet looks like Input/Output flag
159641c99275SPeter Avalos * while 2nd octet is unknown, at least to me
159741c99275SPeter Avalos * (mshindo@mshindo.net).
159841c99275SPeter Avalos *
159941c99275SPeter Avalos * That was what the original tcpdump code did.
160041c99275SPeter Avalos *
160141c99275SPeter Avalos * FreeBSD's "if_ppp.c" *does* set the first octet to 1 for outbound
160241c99275SPeter Avalos * packets and 0 for inbound packets - but only if the
160341c99275SPeter Avalos * protocol field has the 0x8000 bit set (i.e., it's a network
160441c99275SPeter Avalos * control protocol); it does so before running the packet through
160541c99275SPeter Avalos * "bpf_filter" to see if it should be discarded, and to see
160641c99275SPeter Avalos * if we should update the time we sent the most recent packet...
160741c99275SPeter Avalos *
160841c99275SPeter Avalos * ...but it puts the original address field back after doing
160941c99275SPeter Avalos * so.
161041c99275SPeter Avalos *
161141c99275SPeter Avalos * NetBSD's "if_ppp.c" doesn't set the first octet in that fashion.
161241c99275SPeter Avalos *
161341c99275SPeter Avalos * I don't know if any PPP implementation handed up to a BPF
161441c99275SPeter Avalos * device packets with the first octet being 1 for outbound and
161541c99275SPeter Avalos * 0 for inbound packets, so I (guy@alum.mit.edu) don't know
161641c99275SPeter Avalos * whether that ever needs to be checked or not.
161741c99275SPeter Avalos *
161841c99275SPeter Avalos * Note that NetBSD has a DLT_PPP_SERIAL, which it uses for PPP,
161941c99275SPeter Avalos * and its tcpdump appears to assume that the frame always
162041c99275SPeter Avalos * begins with an address field and a control field, and that
162141c99275SPeter Avalos * the address field might be 0x0f or 0x8f, for Cisco
162241c99275SPeter Avalos * point-to-point with HDLC framing as per section 4.3.1 of RFC
162341c99275SPeter Avalos * 1547, as well as 0xff, for PPP in HDLC-like framing as per
162441c99275SPeter Avalos * RFC 1662.
162541c99275SPeter Avalos *
162641c99275SPeter Avalos * (Is the Cisco framing in question what DLT_C_HDLC, in
162741c99275SPeter Avalos * BSD/OS, is?)
162841c99275SPeter Avalos */
1629411677aeSAaron LI if (ndo->ndo_eflag)
1630*ed775ee7SAntonio Huete Jimenez ND_PRINT("%c %4d %02x ", GET_U_1(p) ? 'O' : 'I',
1631*ed775ee7SAntonio Huete Jimenez length, GET_U_1(p + 1));
163241c99275SPeter Avalos #endif
163341c99275SPeter Avalos
1634411677aeSAaron LI ppp_print(ndo, p, length);
163541c99275SPeter Avalos }
163641c99275SPeter Avalos
163741c99275SPeter Avalos /*
163841c99275SPeter Avalos * PPP I/F printer to use if we know that RFC 1662-style PPP in HDLC-like
163941c99275SPeter Avalos * framing, or Cisco PPP with HDLC framing as per section 4.3.1 of RFC 1547,
164041c99275SPeter Avalos * is being used (i.e., we don't check for PPP_ADDRESS and PPP_CONTROL,
164141c99275SPeter Avalos * discard them *if* those are the first two octets, and parse the remaining
164241c99275SPeter Avalos * packet as a PPP packet, as "ppp_print()" does).
164341c99275SPeter Avalos *
164441c99275SPeter Avalos * This handles, for example, DLT_PPP_SERIAL in NetBSD.
164541c99275SPeter Avalos */
1646*ed775ee7SAntonio Huete Jimenez void
ppp_hdlc_if_print(netdissect_options * ndo,const struct pcap_pkthdr * h,const u_char * p)1647411677aeSAaron LI ppp_hdlc_if_print(netdissect_options *ndo,
1648*ed775ee7SAntonio Huete Jimenez const struct pcap_pkthdr *h, const u_char *p)
164941c99275SPeter Avalos {
1650*ed775ee7SAntonio Huete Jimenez u_int length = h->len;
1651*ed775ee7SAntonio Huete Jimenez u_int caplen = h->caplen;
165241c99275SPeter Avalos u_int proto;
165341c99275SPeter Avalos u_int hdrlen = 0;
165441c99275SPeter Avalos
1655*ed775ee7SAntonio Huete Jimenez ndo->ndo_protocol = "ppp_hdlc";
165641c99275SPeter Avalos if (caplen < 2) {
1657*ed775ee7SAntonio Huete Jimenez nd_print_trunc(ndo);
1658*ed775ee7SAntonio Huete Jimenez ndo->ndo_ll_hdr_len += caplen;
1659*ed775ee7SAntonio Huete Jimenez return;
166041c99275SPeter Avalos }
166141c99275SPeter Avalos
1662*ed775ee7SAntonio Huete Jimenez switch (GET_U_1(p)) {
166341c99275SPeter Avalos
166441c99275SPeter Avalos case PPP_ADDRESS:
166541c99275SPeter Avalos if (caplen < 4) {
1666*ed775ee7SAntonio Huete Jimenez nd_print_trunc(ndo);
1667*ed775ee7SAntonio Huete Jimenez ndo->ndo_ll_hdr_len += caplen;
1668*ed775ee7SAntonio Huete Jimenez return;
166941c99275SPeter Avalos }
167041c99275SPeter Avalos
1671411677aeSAaron LI if (ndo->ndo_eflag)
1672*ed775ee7SAntonio Huete Jimenez ND_PRINT("%02x %02x %u ", GET_U_1(p),
1673*ed775ee7SAntonio Huete Jimenez GET_U_1(p + 1), length);
167441c99275SPeter Avalos p += 2;
167541c99275SPeter Avalos length -= 2;
167641c99275SPeter Avalos hdrlen += 2;
167741c99275SPeter Avalos
1678*ed775ee7SAntonio Huete Jimenez proto = GET_BE_U_2(p);
167941c99275SPeter Avalos p += 2;
168041c99275SPeter Avalos length -= 2;
168141c99275SPeter Avalos hdrlen += 2;
1682*ed775ee7SAntonio Huete Jimenez ND_PRINT("%s: ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto));
168341c99275SPeter Avalos
1684411677aeSAaron LI handle_ppp(ndo, proto, p, length);
168541c99275SPeter Avalos break;
168641c99275SPeter Avalos
168741c99275SPeter Avalos case CHDLC_UNICAST:
168841c99275SPeter Avalos case CHDLC_BCAST:
1689*ed775ee7SAntonio Huete Jimenez chdlc_if_print(ndo, h, p);
1690*ed775ee7SAntonio Huete Jimenez return;
169141c99275SPeter Avalos
169241c99275SPeter Avalos default:
1693411677aeSAaron LI if (caplen < 4) {
1694*ed775ee7SAntonio Huete Jimenez nd_print_trunc(ndo);
1695*ed775ee7SAntonio Huete Jimenez ndo->ndo_ll_hdr_len += caplen;
1696*ed775ee7SAntonio Huete Jimenez return;
1697411677aeSAaron LI }
1698411677aeSAaron LI
1699411677aeSAaron LI if (ndo->ndo_eflag)
1700*ed775ee7SAntonio Huete Jimenez ND_PRINT("%02x %02x %u ", GET_U_1(p),
1701*ed775ee7SAntonio Huete Jimenez GET_U_1(p + 1), length);
170241c99275SPeter Avalos p += 2;
170341c99275SPeter Avalos hdrlen += 2;
170441c99275SPeter Avalos
170541c99275SPeter Avalos /*
170641c99275SPeter Avalos * XXX - NetBSD's "ppp_netbsd_serial_if_print()" treats
170741c99275SPeter Avalos * the next two octets as an Ethernet type; does that
170841c99275SPeter Avalos * ever happen?
170941c99275SPeter Avalos */
1710*ed775ee7SAntonio Huete Jimenez ND_PRINT("unknown addr %02x; ctrl %02x", GET_U_1(p),
1711*ed775ee7SAntonio Huete Jimenez GET_U_1(p + 1));
171241c99275SPeter Avalos break;
171341c99275SPeter Avalos }
171441c99275SPeter Avalos
1715*ed775ee7SAntonio Huete Jimenez ndo->ndo_ll_hdr_len += hdrlen;
171641c99275SPeter Avalos }
171741c99275SPeter Avalos
171841c99275SPeter Avalos #define PPP_BSDI_HDRLEN 24
171941c99275SPeter Avalos
172041c99275SPeter Avalos /* BSD/OS specific PPP printer */
1721*ed775ee7SAntonio Huete Jimenez void
ppp_bsdos_if_print(netdissect_options * ndo,const struct pcap_pkthdr * h _U_,const u_char * p _U_)1722*ed775ee7SAntonio Huete Jimenez ppp_bsdos_if_print(netdissect_options *ndo,
1723*ed775ee7SAntonio Huete Jimenez const struct pcap_pkthdr *h _U_, const u_char *p _U_)
172441c99275SPeter Avalos {
1725*ed775ee7SAntonio Huete Jimenez u_int hdrlength;
172641c99275SPeter Avalos #ifdef __bsdi__
1727*ed775ee7SAntonio Huete Jimenez u_int length = h->len;
1728*ed775ee7SAntonio Huete Jimenez u_int caplen = h->caplen;
1729411677aeSAaron LI uint16_t ptype;
1730*ed775ee7SAntonio Huete Jimenez uint8_t llhl;
173141c99275SPeter Avalos const u_char *q;
1732*ed775ee7SAntonio Huete Jimenez u_int i;
173341c99275SPeter Avalos
1734*ed775ee7SAntonio Huete Jimenez ndo->ndo_protocol = "ppp_bsdos";
173541c99275SPeter Avalos if (caplen < PPP_BSDI_HDRLEN) {
1736*ed775ee7SAntonio Huete Jimenez nd_print_trunc(ndo);
1737*ed775ee7SAntonio Huete Jimenez ndo->ndo_ll_hdr_len += caplen;
1738*ed775ee7SAntonio Huete Jimenez return;
173941c99275SPeter Avalos }
174041c99275SPeter Avalos
174141c99275SPeter Avalos hdrlength = 0;
174241c99275SPeter Avalos
174341c99275SPeter Avalos #if 0
1744*ed775ee7SAntonio Huete Jimenez if (GET_U_1(p) == PPP_ADDRESS &&
1745*ed775ee7SAntonio Huete Jimenez GET_U_1(p + 1) == PPP_CONTROL) {
1746411677aeSAaron LI if (ndo->ndo_eflag)
1747*ed775ee7SAntonio Huete Jimenez ND_PRINT("%02x %02x ", GET_U_1(p),
1748*ed775ee7SAntonio Huete Jimenez GET_U_1(p + 1));
174941c99275SPeter Avalos p += 2;
175041c99275SPeter Avalos hdrlength = 2;
175141c99275SPeter Avalos }
175241c99275SPeter Avalos
1753411677aeSAaron LI if (ndo->ndo_eflag)
1754*ed775ee7SAntonio Huete Jimenez ND_PRINT("%u ", length);
175541c99275SPeter Avalos /* Retrieve the protocol type */
1756*ed775ee7SAntonio Huete Jimenez if (GET_U_1(p) & 01) {
175741c99275SPeter Avalos /* Compressed protocol field */
1758*ed775ee7SAntonio Huete Jimenez ptype = GET_U_1(p);
1759411677aeSAaron LI if (ndo->ndo_eflag)
1760*ed775ee7SAntonio Huete Jimenez ND_PRINT("%02x ", ptype);
176141c99275SPeter Avalos p++;
176241c99275SPeter Avalos hdrlength += 1;
176341c99275SPeter Avalos } else {
176441c99275SPeter Avalos /* Un-compressed protocol field */
1765*ed775ee7SAntonio Huete Jimenez ptype = GET_BE_U_2(p);
1766411677aeSAaron LI if (ndo->ndo_eflag)
1767*ed775ee7SAntonio Huete Jimenez ND_PRINT("%04x ", ptype);
176841c99275SPeter Avalos p += 2;
176941c99275SPeter Avalos hdrlength += 2;
177041c99275SPeter Avalos }
177141c99275SPeter Avalos #else
177241c99275SPeter Avalos ptype = 0; /*XXX*/
1773411677aeSAaron LI if (ndo->ndo_eflag)
1774*ed775ee7SAntonio Huete Jimenez ND_PRINT("%c ", GET_U_1(p + SLC_DIR) ? 'O' : 'I');
1775*ed775ee7SAntonio Huete Jimenez llhl = GET_U_1(p + SLC_LLHL);
1776*ed775ee7SAntonio Huete Jimenez if (llhl) {
177741c99275SPeter Avalos /* link level header */
177841c99275SPeter Avalos struct ppp_header *ph;
177941c99275SPeter Avalos
178041c99275SPeter Avalos q = p + SLC_BPFHDRLEN;
178141c99275SPeter Avalos ph = (struct ppp_header *)q;
178241c99275SPeter Avalos if (ph->phdr_addr == PPP_ADDRESS
178341c99275SPeter Avalos && ph->phdr_ctl == PPP_CONTROL) {
1784411677aeSAaron LI if (ndo->ndo_eflag)
1785*ed775ee7SAntonio Huete Jimenez ND_PRINT("%02x %02x ", GET_U_1(q),
1786*ed775ee7SAntonio Huete Jimenez GET_U_1(q + 1));
1787*ed775ee7SAntonio Huete Jimenez ptype = GET_BE_U_2(&ph->phdr_type);
1788411677aeSAaron LI if (ndo->ndo_eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) {
1789*ed775ee7SAntonio Huete Jimenez ND_PRINT("%s ", tok2str(ppptype2str,
1790*ed775ee7SAntonio Huete Jimenez "proto-#%u", ptype));
179141c99275SPeter Avalos }
179241c99275SPeter Avalos } else {
1793411677aeSAaron LI if (ndo->ndo_eflag) {
1794*ed775ee7SAntonio Huete Jimenez ND_PRINT("LLH=[");
1795*ed775ee7SAntonio Huete Jimenez for (i = 0; i < llhl; i++)
1796*ed775ee7SAntonio Huete Jimenez ND_PRINT("%02x", GET_U_1(q + i));
1797*ed775ee7SAntonio Huete Jimenez ND_PRINT("] ");
179841c99275SPeter Avalos }
179941c99275SPeter Avalos }
180041c99275SPeter Avalos }
1801411677aeSAaron LI if (ndo->ndo_eflag)
1802*ed775ee7SAntonio Huete Jimenez ND_PRINT("%u ", length);
1803*ed775ee7SAntonio Huete Jimenez if (GET_U_1(p + SLC_CHL)) {
1804*ed775ee7SAntonio Huete Jimenez q = p + SLC_BPFHDRLEN + llhl;
180541c99275SPeter Avalos
180641c99275SPeter Avalos switch (ptype) {
180741c99275SPeter Avalos case PPP_VJC:
1808411677aeSAaron LI ptype = vjc_print(ndo, q, ptype);
180941c99275SPeter Avalos hdrlength = PPP_BSDI_HDRLEN;
181041c99275SPeter Avalos p += hdrlength;
181141c99275SPeter Avalos switch (ptype) {
181241c99275SPeter Avalos case PPP_IP:
1813411677aeSAaron LI ip_print(ndo, p, length);
181441c99275SPeter Avalos break;
181541c99275SPeter Avalos case PPP_IPV6:
1816411677aeSAaron LI ip6_print(ndo, p, length);
181741c99275SPeter Avalos break;
181841c99275SPeter Avalos case PPP_MPLS_UCAST:
181941c99275SPeter Avalos case PPP_MPLS_MCAST:
1820411677aeSAaron LI mpls_print(ndo, p, length);
182141c99275SPeter Avalos break;
182241c99275SPeter Avalos }
182341c99275SPeter Avalos goto printx;
182441c99275SPeter Avalos case PPP_VJNC:
1825411677aeSAaron LI ptype = vjc_print(ndo, q, ptype);
182641c99275SPeter Avalos hdrlength = PPP_BSDI_HDRLEN;
182741c99275SPeter Avalos p += hdrlength;
182841c99275SPeter Avalos switch (ptype) {
182941c99275SPeter Avalos case PPP_IP:
1830411677aeSAaron LI ip_print(ndo, p, length);
183141c99275SPeter Avalos break;
183241c99275SPeter Avalos case PPP_IPV6:
1833411677aeSAaron LI ip6_print(ndo, p, length);
183441c99275SPeter Avalos break;
183541c99275SPeter Avalos case PPP_MPLS_UCAST:
183641c99275SPeter Avalos case PPP_MPLS_MCAST:
1837411677aeSAaron LI mpls_print(ndo, p, length);
183841c99275SPeter Avalos break;
183941c99275SPeter Avalos }
184041c99275SPeter Avalos goto printx;
184141c99275SPeter Avalos default:
1842411677aeSAaron LI if (ndo->ndo_eflag) {
1843*ed775ee7SAntonio Huete Jimenez ND_PRINT("CH=[");
1844*ed775ee7SAntonio Huete Jimenez for (i = 0; i < llhl; i++)
1845*ed775ee7SAntonio Huete Jimenez ND_PRINT("%02x",
1846*ed775ee7SAntonio Huete Jimenez GET_U_1(q + i));
1847*ed775ee7SAntonio Huete Jimenez ND_PRINT("] ");
184841c99275SPeter Avalos }
184941c99275SPeter Avalos break;
185041c99275SPeter Avalos }
185141c99275SPeter Avalos }
185241c99275SPeter Avalos
185341c99275SPeter Avalos hdrlength = PPP_BSDI_HDRLEN;
185441c99275SPeter Avalos #endif
185541c99275SPeter Avalos
185641c99275SPeter Avalos length -= hdrlength;
185741c99275SPeter Avalos p += hdrlength;
185841c99275SPeter Avalos
185941c99275SPeter Avalos switch (ptype) {
186041c99275SPeter Avalos case PPP_IP:
186141c99275SPeter Avalos ip_print(p, length);
186241c99275SPeter Avalos break;
186341c99275SPeter Avalos case PPP_IPV6:
1864411677aeSAaron LI ip6_print(ndo, p, length);
186541c99275SPeter Avalos break;
186641c99275SPeter Avalos case PPP_MPLS_UCAST:
186741c99275SPeter Avalos case PPP_MPLS_MCAST:
1868411677aeSAaron LI mpls_print(ndo, p, length);
186941c99275SPeter Avalos break;
187041c99275SPeter Avalos default:
1871*ed775ee7SAntonio Huete Jimenez ND_PRINT("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", ptype));
187241c99275SPeter Avalos }
187341c99275SPeter Avalos
187441c99275SPeter Avalos printx:
187541c99275SPeter Avalos #else /* __bsdi */
187641c99275SPeter Avalos hdrlength = 0;
187741c99275SPeter Avalos #endif /* __bsdi__ */
1878*ed775ee7SAntonio Huete Jimenez ndo->ndo_ll_hdr_len += hdrlength;
187941c99275SPeter Avalos }
1880