* 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.41 2000-08-18 07:53:35 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_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 */
/* 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 */
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:
break;
case CPCODES_TIME_REM:
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:
int len = p[1];
int opt = p[0];
int i;
-
+
if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
printf(", %s", lcpconfopts[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:
switch (p[2]) { /* Operation */
}
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:
switch (p[2]) { /* class */
break;
/* XXX: to be supported */
-#if 0
+#if 0
case LCPOPT_DEP6:
case LCPOPT_FCSALT:
case LCPOPT_SDP:
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:
val_size = *p; /* value size */
p++;
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;
printf(", Name=");
switch (opt) {
case IPCPOPT_2ADDR: /* deprecated */
printf(", IP-Addrs src=%s dst=%s",
- ipaddr_string(p + 2),
+ ipaddr_string(p + 2),
ipaddr_string(p + 6));
break;
case IPCPOPT_IPCOMP:
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:
printf(", IP-Addr=%s", ipaddr_string(p + 2));
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;
}
{
u_int proto;
- /* 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 (*p == PPP_ADDRESS && *(p + 1) == PPP_CONTROL) {
p += 2; /* ACFC not used */
length -= 2;
}
- if (*p % 2) {
+ if (*p % 2) {
proto = *p; /* PFC is used */
p++;
- length--;
+ length--;
} else {
proto = EXTRACT_16BITS(p);
p += 2;
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
+ */
if (eflag)
printf("%c %4d %02x ", p[0] ? 'O' : 'I', length, p[1]);
#endif
#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)
+ if (eflag)
printf("%d ", length);
}
if (p[SLC_CHL]) {