* complete PPP support.
*/
-/* TODO:
- o resolve XXX as much as possible
- o MP support
- o BAP support
+/*
+ * TODO:
+ * o resolve XXX as much as possible
+ * o MP support
+ * o BAP support
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.40 2000-08-18 07:44:46 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.57 2000-12-04 06:47:18 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include <sys/param.h>
#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-struct mbuf;
-struct rtentry;
-#include <net/if.h>
+#ifdef __bsdi__
+#include <net/slcompress.h>
+#include <net/if_ppp.h>
+#endif
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
#include <stdio.h>
-#ifdef __bsdi__
-#include <net/slcompress.h>
-#include <net/if_ppp.h>
-#endif
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
#include "ppp.h"
+#include "chdlc.h"
+#include "ethertype.h"
-/* XXX This goes somewhere else. */
-#define PPP_HDRLEN 4
-
-/* The following constatns are defined by IANA. Please refer to
- http://www.isi.edu/in-notes/iana/assignments/ppp-numbers
- for the up-to-date information. */
+/*
+ * The following constatns are defined by IANA. Please refer to
+ * http://www.isi.edu/in-notes/iana/assignments/ppp-numbers
+ * for the up-to-date information.
+ */
/* Control Protocols (LCP/IPCP/CCP etc.) Codes */
static const char *lcpconfopts[] = {
"Vend-Ext", /* (0) */
- "MRU", /* (1) */
+ "MRU", /* (1) */
"ACCM", /* (2) */
"Auth-Prot", /* (3) */
"Qual-Prot", /* (4) */
static const char *ccpconfopts[] = {
"OUI", /* (0) */
- "Pred-1", /* (1) */
+ "Pred-1", /* (1) */
"Pred-2", /* (2) */
"Puddle", /* (3) */
"unassigned(4)", /* (4) */
/* Auth Algorithms */
-/* 0-4 Reserved (RFC1994) */
+/* 0-4 Reserved (RFC1994) */
#define AUTHALG_CHAPMD5 5 /* RFC1994 */
#define AUTHALG_MSCHAP1 128 /* RFC2433 */
#define AUTHALG_MSCHAP2 129 /* RFC2795 */
#define BAP_CSIND 7
#define BAP_CSRES 8
-static const char *ppp_protoname __P((u_int proto));
-static void handle_ctrl_proto __P((u_int proto,const u_char *p, int length));
-static void handle_chap __P((const u_char *p, int length));
-static void handle_pap __P((const u_char *p, int length));
-static void handle_bap __P((const u_char *p, int length));
-static int print_lcp_config_options __P((const u_char *p));
-static int print_ipcp_config_options __P((const u_char *p));
-static int print_ccp_config_options __P((const u_char *p));
-static int print_bacp_config_options __P((const u_char *p));
-static void handle_ppp __P((u_int proto, const u_char *p, int length));
+static const char *ppp_protoname (u_int proto);
+static void handle_ctrl_proto (u_int proto,const u_char *p, int length);
+static void handle_chap (const u_char *p, int length);
+static void handle_pap (const u_char *p, int length);
+static void handle_bap (const u_char *p, int length);
+static int print_lcp_config_options (const u_char *p, int);
+static int print_ipcp_config_options (const u_char *p, int);
+static int print_ccp_config_options (const u_char *p, int);
+static int print_bacp_config_options (const u_char *p, int);
+static void handle_ppp (u_int proto, const u_char *p, int length);
static const char *
ppp_protoname(u_int proto)
#ifdef PPP_XNS
case PPP_XNS: return "XNS";
#endif
-#ifdef PPP_IPX
case PPP_IPX: return "IPX";
-#endif
+ case PPP_VJC: return "VJC";
+ case PPP_VJNC: return "VJNC";
#ifdef PPP_COMP
case PPP_COMP: return "COMP";
#endif
-#ifdef PPP_IPCP
case PPP_IPCP: return "IPCP";
-#endif
-#ifdef PPP_IPV6CP
case PPP_IPV6CP: return "IPV6CP";
-#endif
-#ifdef PPP_IPXCP
case PPP_IPXCP: return "IPXCP";
-#endif
-#ifdef PPP_CCP
case PPP_CCP: return "CCP";
-#endif
-#ifdef PPP_LCP
case PPP_LCP: return "LCP";
-#endif
-#ifdef PPP_PAP
case PPP_PAP: return "PAP";
-#endif
#ifdef PPP_LQR
case PPP_LQR: return "LQR";
#endif
-#ifdef PPP_CHAP
case PPP_CHAP: return "CHAP";
-#endif
-#ifdef PPP_BACP
case PPP_BACP: return "BACP";
-#endif
-#ifdef PPP_BAP
case PPP_BAP: return "BAP";
-#endif
default:
snprintf(buf, sizeof(buf), "unknown-0x%04x", proto);
return buf;
handle_ctrl_proto(u_int proto, const u_char *p, int length)
{
u_int code, len;
- int (*pfunc)();
+ int (*pfunc)(const u_char *, int);
int x, j;
+ if (length < 1) {
+ printf("[|%s]", ppp_protoname(proto));
+ return;
+ } else if (length < 4) {
+ printf("[|%s 0x%02x]", ppp_protoname(proto), *p);
+ return;
+ }
+
code = *p;
if ((code >= CPCODES_MIN) && (code <= CPCODES_MAX))
printf("%s", cpcodes[code]);
len = EXTRACT_16BITS(p);
p += 2;
- if (len <= 4) {
- return; /* there may be a NULL confreq etc.*/
- }
-
+ if (length <= 4)
+ return; /* there may be a NULL confreq etc. */
+
switch (code) {
case CPCODES_VEXT:
+ if (length < 11)
+ break;
printf(", Magic-Num=%08x", EXTRACT_32BITS(p));
p += 4;
printf(" OUI=%02x%02x%02x", p[0], p[1], p[2]);
- /* XXX: need to decode Kind and Value(s)? */
+ /* XXX: need to decode Kind and Value(s)? */
break;
case CPCODES_CONF_REQ:
case CPCODES_CONF_ACK:
case PPP_BACP:
pfunc = print_bacp_config_options;
break;
+ default:
+ /*
+ * This should never happen, but we set
+ * "pfunc" to squelch uninitialized
+ * variable warnings from compilers.
+ */
+ pfunc = NULL;
+ break;
}
- if ((j = (*pfunc)(p)) == 0)
+ if ((j = (*pfunc)(p, len)) == 0)
break;
x -= j;
p += j;
/* XXX: need to decode Rejected-Packet? */
break;
case CPCODES_PROT_REJ:
+ if (length < 6)
+ break;
printf(", Rejected-Protocol=%04x", EXTRACT_16BITS(p));
/* XXX: need to decode Rejected-Information? */
break;
case CPCODES_ECHO_RPL:
case CPCODES_DISC_REQ:
case CPCODES_ID:
+ if (length < 8)
+ break;
printf(", Magic-Num=%08x", EXTRACT_32BITS(p));
/* XXX: need to decode Data? */
break;
case CPCODES_TIME_REM:
+ if (length < 12)
+ break;
printf(", Magic-Num=%08x", EXTRACT_32BITS(p));
- printf(" Seconds-Remaining=%u", EXTRACT_32BITS(p+4));
+ printf(" Seconds-Remaining=%u", EXTRACT_32BITS(p + 4));
/* XXX: need to decode Message? */
break;
default:
/* LCP config options */
static int
-print_lcp_config_options(const u_char *p)
+print_lcp_config_options(const u_char *p, int length)
{
- int len = p[1];
- int opt = p[0];
- int i;
-
+ int len, opt;
+
+ if (length < 2)
+ return 0;
+ len = p[1];
+ opt = p[0];
+ if (length < len)
+ return 0;
if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
printf(", %s", lcpconfopts[opt]);
+ else {
+ printf(", unknwhown-%d", opt);
+ return len;
+ }
switch (opt) {
case LCPOPT_VEXT:
if (len >= 6) {
printf(" OUI=%02x%02x%02x", p[2], p[3], p[4]);
-#if 0
+#if 0
printf(" kind=%02x", p[5]);
printf(" val=")
- for (i=0; i<len-6; i++) {
- printf("%02x", p[6+i]);
+ for (i = 0; i < len - 6; i++) {
+ printf("%02x", p[6 + i]);
}
#endif
}
break;
case LCPOPT_MRU:
if (len == 4)
- printf("=%u", EXTRACT_16BITS(p+2));
+ printf("=%u", EXTRACT_16BITS(p + 2));
break;
case LCPOPT_ACCM:
if (len == 6)
- printf("=%08x", EXTRACT_32BITS(p+2));
+ printf("=%08x", EXTRACT_32BITS(p + 2));
break;
case LCPOPT_AP:
if (len >= 4) {
break;
case LCPOPT_MN:
if (len == 6)
- printf("=%08x", EXTRACT_32BITS(p+2));
+ printf("=%08x", EXTRACT_32BITS(p + 2));
break;
case LCPOPT_PFC:
break;
break;
case LCPOPT_LD:
if (len == 4)
- printf("=%04x", EXTRACT_16BITS(p+2));
+ printf("=%04x", EXTRACT_16BITS(p + 2));
break;
case LCPOPT_CBACK:
+ if (len < 3)
+ break;
switch (p[2]) { /* Operation */
case CALLBACK_AUTH:
printf(" UserAuth");
}
break;
case LCPOPT_MLMRRU:
- if (len == 4)
- printf("=%u", EXTRACT_16BITS(p+2));
+ if (len == 4)
+ printf("=%u", EXTRACT_16BITS(p + 2));
break;
case LCPOPT_MLED:
+ if (len < 3)
+ break;
switch (p[2]) { /* class */
case MEDCLASS_NULL:
printf(" Null");
printf(" Local"); /* XXX */
break;
case MEDCLASS_IPV4:
+ if (len != 7)
+ break;
printf(" IPv4=%s", ipaddr_string(p + 3));
break;
case MEDCLASS_MAC:
+ if (len != 9)
+ break;
printf(" MAC=%02x:%02x:%02x:%02x:%02x:%02x",
p[3], p[4], p[5], p[6], p[7], p[8]);
break;
break;
/* XXX: to be supported */
-#if 0
+#if 0
case LCPOPT_DEP6:
case LCPOPT_FCSALT:
case LCPOPT_SDP:
handle_chap(const u_char *p, int length)
{
u_int code, len;
- int val_size, name_size, msg_size;
+ int val_size, name_size, msg_size;
+ const u_char *p0;
int i;
+ p0 = p;
+ if (length < 1) {
+ printf("[|chap]");
+ return;
+ } else if (length < 4) {
+ printf("[|chap 0x%02x]", *p);
+ return;
+ }
+
code = *p;
if ((code >= CHAP_CODEMIN) && (code <= CHAP_CODEMAX))
printf("%s", chapcode[code - 1]);
len = EXTRACT_16BITS(p);
p += 2;
- /* Note that this is a generic CHAP decoding routine. Since we
- don't know which flavor of CHAP (i.e. CHAP-MD5, MS-CHAPv1,
- MS-CHAPv2) is used at this point, we can't decode packet
- specifically to each algorithms. Instead, we simply decode
- the GCD (Gratest Common Denominator) for all algorithms. */
-
+ /*
+ * Note that this is a generic CHAP decoding routine. Since we
+ * don't know which flavor of CHAP (i.e. CHAP-MD5, MS-CHAPv1,
+ * MS-CHAPv2) is used at this point, we can't decode packet
+ * specifically to each algorithms. Instead, we simply decode
+ * the GCD (Gratest Common Denominator) for all algorithms.
+ */
switch (code) {
case CHAP_CHAL:
case CHAP_RESP:
+ if (length - (p - p0) < 1)
+ return;
val_size = *p; /* value size */
p++;
+ if (length - (p - p0) < val_size)
+ return;
printf(", Value=");
- for (i = 0; i < val_size; i++)
+ for (i = 0; i < val_size; i++)
printf("%02x", *p++);
- name_size = len - val_size - 5;
+ name_size = len - (p - p0);
printf(", Name=");
- for (i = 0; i < name_size; i++) {
- if (isprint(*p))
- printf("%c", *p);
- else
- printf("\\%03o", *p);
- p++;
- }
+ for (i = 0; i < name_size; i++)
+ safeputchar(*p++);
break;
case CHAP_SUCC:
case CHAP_FAIL:
- msg_size = len - 4;
+ msg_size = len - (p - p0);
printf(", Msg=");
- for (i = 0; i< msg_size; i++) {
- if (isprint(*p))
- printf("%c", *p);
- else
- printf("\\%03o", *p);
- p++;
- }
+ for (i = 0; i< msg_size; i++)
+ safeputchar(*p++);
break;
}
}
-/* PAP */
+/* PAP (see RFC 1334) */
static void
handle_pap(const u_char *p, int length)
{
u_int code, len;
- int peerid_len, passwd_len, msg_len;
+ int peerid_len, passwd_len, msg_len;
+ const u_char *p0;
int i;
+ p0 = p;
+ if (length < 1) {
+ printf("[|pap]");
+ return;
+ } else if (length < 4) {
+ printf("[|pap 0x%02x]", *p);
+ return;
+ }
+
code = *p;
if ((code >= PAP_CODEMIN) && (code <= PAP_CODEMAX))
printf("%s", papcode[code - 1]);
switch (code) {
case PAP_AREQ:
+ if (length - (p - p0) < 1)
+ return;
peerid_len = *p; /* Peer-ID Length */
p++;
+ if (length - (p - p0) < peerid_len)
+ return;
printf(", Peer=");
- for (i = 0; i < peerid_len; i++) {
- if (isprint(*p))
- printf("%c", *p);
- else
- printf("\\%03o", *p);
- p++;
- }
+ for (i = 0; i < peerid_len; i++)
+ safeputchar(*p++);
+
+ if (length - (p - p0) < 1)
+ return;
passwd_len = *p; /* Password Length */
p++;
+ if (length - (p - p0) < passwd_len)
+ return;
printf(", Name=");
- for (i = 0; i < passwd_len; i++) {
- if (isprint(*p))
- printf("%c", *p);
- else
- printf("\\%03o", *p);
- p++;
- }
+ for (i = 0; i < passwd_len; i++)
+ safeputchar(*p++);
break;
case PAP_AACK:
case PAP_ANAK:
+ if (length - (p - p0) < 1)
+ return;
msg_len = *p; /* Msg-Length */
p++;
+ if (length - (p - p0) < msg_len)
+ return;
printf(", Msg=");
- for (i = 0; i< msg_len; i++) {
- if (isprint(*p))
- printf("%c", *p);
- else
- printf("\\%03o", *p);
- p++;
- }
+ for (i = 0; i< msg_len; i++)
+ safeputchar(*p++);
break;
}
+ return;
}
/* BAP */
/* IPCP config options */
static int
-print_ipcp_config_options(const u_char *p)
+print_ipcp_config_options(const u_char *p, int length)
{
- int len = p[1];
- int opt = p[0];
-
+ int len, opt;
+
+ if (length < 2)
+ return 0;
+ len = p[1];
+ opt = p[0];
+ if (length < len)
+ return 0;
switch (opt) {
case IPCPOPT_2ADDR: /* deprecated */
+ if (len != 10)
+ goto invlen;
printf(", IP-Addrs src=%s dst=%s",
- ipaddr_string(p + 2),
+ ipaddr_string(p + 2),
ipaddr_string(p + 6));
- break;
+ break;
case IPCPOPT_IPCOMP:
+ if (len < 4)
+ goto invlen;
printf(", IP-Comp");
- if (EXTRACT_16BITS(p+2) == PPP_VJC) {
+ if (EXTRACT_16BITS(p + 2) == PPP_VJC) {
printf(" VJ-Comp");
/* XXX: VJ-Comp parameters should be decoded */
- } else {
- printf(" unknown-comp-proto=%04x",
- EXTRACT_16BITS(p+2));
- }
+ } else
+ printf(" unknown-comp-proto=%04x", EXTRACT_16BITS(p + 2));
break;
case IPCPOPT_ADDR:
+ if (len != 6)
+ goto invlen;
printf(", IP-Addr=%s", ipaddr_string(p + 2));
break;
case IPCPOPT_MOBILE4:
+ if (len != 6)
+ goto invlen;
printf(", Home-Addr=%s", ipaddr_string(p + 2));
break;
case IPCPOPT_PRIDNS:
+ if (len != 6)
+ goto invlen;
printf(", Pri-DNS=%s", ipaddr_string(p + 2));
break;
case IPCPOPT_PRINBNS:
+ if (len != 6)
+ goto invlen;
printf(", Pri-NBNS=%s", ipaddr_string(p + 2));
break;
case IPCPOPT_SECDNS:
+ if (len != 6)
+ goto invlen;
printf(", Sec-DNS=%s", ipaddr_string(p + 2));
break;
case IPCPOPT_SECNBNS:
+ if (len != 6)
+ goto invlen;
printf(", Sec-NBNS=%s", ipaddr_string(p + 2));
break;
default:
break;
}
return len;
+
+invlen:
+ printf(", invalid-length-%d", opt);
+ return 0;
}
/* CCP config options */
static int
-print_ccp_config_options(const u_char *p)
+print_ccp_config_options(const u_char *p, int length)
{
- int len = p[1];
- int opt = p[0];
-
+ int len, opt;
+
+ if (length < 2)
+ return 0;
+ len = p[1];
+ opt = p[0];
+ if (length < len)
+ return 0;
if ((opt >= CCPOPT_MIN) && (opt <= CCPOPT_MAX))
printf(", %s", ccpconfopts[opt]);
#if 0 /* XXX */
/* BACP config options */
static int
-print_bacp_config_options(const u_char *p)
+print_bacp_config_options(const u_char *p, int length)
{
- int len = p[1];
- int opt = p[0];
-
+ int len, opt;
+
+ if (length < 2)
+ return 0;
+ len = p[1];
+ opt = p[0];
+ if (length < len)
+ return 0;
if (opt == BACPOPT_FPEER) {
printf(", Favored-Peer");
- printf(" Magic-Num=%08x", EXTRACT_32BITS(p+2));
+ printf(" Magic-Num=%08x", EXTRACT_32BITS(p + 2));
} else {
printf(", unknown-option-%d", opt);
- }
+ }
return len;
}
ip6_print(p, length);
break;
#endif
+ case ETHERTYPE_IPX: /*XXX*/
+ case PPP_IPX:
+ ipx_print(p, length);
+ break;
}
}
ppp_print(register const u_char *p, u_int length)
{
u_int proto;
+ u_int full_length = length;
- /* Here, we assume that p points to the Address and Control
- field (if they present). */
-
- if (*p == PPP_ADDRESS && *(p+1) == PPP_CONTROL) {
+ /*
+ * Here, we assume that p points to the Address and Control
+ * field (if they present).
+ */
+ if (length < 2)
+ goto trunc;
+ if (*p == PPP_ADDRESS && *(p + 1) == PPP_CONTROL) {
p += 2; /* ACFC not used */
length -= 2;
}
-
- if (*p % 2) {
+
+ if (length < 2)
+ goto trunc;
+ if (*p % 2) {
proto = *p; /* PFC is used */
p++;
- length--;
+ length--;
} else {
proto = EXTRACT_16BITS(p);
p += 2;
length -= 2;
}
- printf("%s: ", ppp_protoname(proto));
+ printf("%s %d: ", ppp_protoname(proto), full_length);
handle_ppp(proto, p, length);
+ return;
+trunc:
+ printf("[|ppp]");
}
{
register u_int length = h->len;
register u_int caplen = h->caplen;
- const struct ip *ip;
- u_int proto;
ts_print(&h->ts);
printf("[|ppp]");
goto out;
}
-
+
/*
* Some printers want to get back at the link level addresses,
* and/or check that they're not walking off the end of the packet.
snapend = p + caplen;
#if 0
- /* XXX: seems to assume that there are 2 octets prepended to an
- actual PPP frame. The 1st octet looks like Input/Output flag
- while 2nd octet is unknown, at least to me
-
+ /*
+ * XXX: seems to assume that there are 2 octets prepended to an
+ * actual PPP frame. The 1st octet looks like Input/Output flag
+ * while 2nd octet is unknown, at least to me
+ *
+ * That was what the original tcpdump code did.
+ *
+ * FreeBSD's "if_ppp.c" *does* set the first octet to 1 for outbound
+ * packets and 0 for inbound packets - but only if the
+ * protocol field has the 0x8000 bit set (i.e., it's a network
+ * control protocol); it does so before running the packet through
+ * "bpf_filter" to see if it should be discarded, and to see
+ * if we should update the time we sent the most recent packet...
+ *
+ * ...but it puts the original address field back after doing
+ * so.
+ *
+ * NetBSD's "if_ppp.c" doesn't set the first octet in that fashion.
+ *
+ * I don't know if any PPP implementation handed up to a BPF
+ * device packets with the first octet being 1 for outbound and
+ * whether that ever needs to be checked or not.
+ *
+ * Note that NetBSD has a DLT_PPP_SERIAL, which it uses for PPP,
+ * and its tcpdump appears to assume that the frame always
+ * begins with an address field and a control field, and that
+ * the address field might be 0x0f or 0x8f, for Cisco
+ * point-to-point with HDLC framing as per section 4.3.1 of RFC
+ * 1547, as well as 0xff, for PPP in HDLC-like framing as per
+ * RFC 1662.
+ *
+ * (Is the Cisco framing in question what DLT_C_HDLC, in
+ * BSD/OS, is?)
+ */
if (eflag)
printf("%c %4d %02x ", p[0] ? 'O' : 'I', length, p[1]);
#endif
putchar('\n');
}
+/*
+ * PPP I/F printer to use if we know that RFC 1662-style PPP in HDLC-like
+ * framing, or Cisco PPP with HDLC framing as per section 4.3.1 of RFC 1547,
+ * is being used (i.e., we don't check for PPP_ADDRESS and PPP_CONTROL,
+ * discard them *if* those are the first two octets, and parse the remaining
+ * packet as a PPP packet, as "ppp_print()" does).
+ *
+ * This handles, for example, DLT_PPP_SERIAL in NetBSD.
+ */
+void
+ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
+ register const u_char *p)
+{
+ register u_int length = h->len;
+ register u_int caplen = h->caplen;
+ u_int proto;
+
+ if (caplen < 2) {
+ printf("[|ppp]");
+ goto out;
+ }
+
+ /*
+ * Some printers want to get back at the link level addresses,
+ * and/or check that they're not walking off the end of the packet.
+ * Rather than pass them all the way down, we set these globals.
+ */
+ packetp = p;
+ snapend = p + caplen;
+
+ switch (p[0]) {
+
+ case PPP_ADDRESS:
+ if (caplen < 4) {
+ printf("[|ppp]");
+ goto out;
+ }
+
+ ts_print(&h->ts);
+ if (eflag)
+ printf("%02x %02x %d ", p[0], p[1], length);
+ p += 2;
+ length -= 2;
+
+ proto = EXTRACT_16BITS(p);
+ p += 2;
+ length -= 2;
+ printf("%s: ", ppp_protoname(proto));
+
+ handle_ppp(proto, p, length);
+ break;
+
+ case CHDLC_UNICAST:
+ case CHDLC_BCAST:
+ /*
+ * Have the Cisco HDLC print routine do all the work.
+ */
+ chdlc_if_print(user, h, p);
+ return;
+
+ default:
+ ts_print(&h->ts);
+ if (eflag)
+ printf("%02x %02x %d ", p[0], p[1], length);
+ p += 2;
+ length -= 2;
+
+ /*
+ * XXX - NetBSD's "ppp_netbsd_serial_if_print()" treats
+ * the next two octets as an Ethernet type; does that
+ * ever happen?
+ */
+ printf("unknown addr %02x; ctrl %02x", p[0], p[1]);
+ break;
+ }
+
+ if (xflag)
+ default_print(p, caplen);
+out:
+ putchar('\n');
+}
+
struct tok ppptype2str[] = {
#if 0
if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) {
- if (eflag)
+ if (eflag)
printf("%02x %02x ", p[0], p[1]);
p += 2;
hdrlength = 2;
}
- if (eflag)
+ if (eflag)
printf("%d ", length);
/* Retrieve the protocol type */
if (*p & 01) {
/* Compressed protocol field */
ptype = *p;
- if (eflag)
+ if (eflag)
printf("%02x ", ptype);
p++;
hdrlength += 1;
} else {
/* Un-compressed protocol field */
ptype = ntohs(*(u_int16_t *)p);
- if (eflag)
+ if (eflag)
printf("%04x ", ptype);
p += 2;
hdrlength += 2;
ph = (struct ppp_header *)q;
if (ph->phdr_addr == PPP_ADDRESS
&& ph->phdr_ctl == PPP_CONTROL) {
- if (eflag)
+ if (eflag)
printf("%02x %02x ", q[0], q[1]);
ptype = ntohs(ph->phdr_type);
if (eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) {
printf("] ");
}
}
- if (eflag)
- printf("%d ", length);
}
+ if (eflag)
+ printf("%d ", length);
if (p[SLC_CHL]) {
q = p + SLC_BPFHDRLEN + p[SLC_LLHL];