#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.73 2002-09-14 23:06:10 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.74 2002-09-15 00:56:25 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
{ PPP_CHAP, "CHAP" },
{ PPP_BACP, "BACP" },
{ PPP_BAP, "BAP" },
- { PPP_MP, "MP" },
+ { PPP_MP, "PPP" },
{ 0, NULL }
};
/* generic Control Protocol (e.g. LCP, IPCP, CCP, etc.) handler */
static void
-handle_ctrl_proto(u_int proto, const u_char *p, int length)
+handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
{
u_int code, len;
int (*pfunc)(const u_char *, int);
int x, j;
+ const u_char *tptr;
- if (length < 1) {
- printf("[|%s]",
- tok2str(ppptype2str, "unknown protocol 0x%04x", proto));
- return;
- } else if (length < 4) {
- printf("[|%s 0x%02x]",
- tok2str(ppptype2str, "unknown protocol 0x%04x", proto),
- *p);
+ tptr=pptr;
+
+ if (!vflag) /* omit the proto id as we already have printed it */
+ printf("%s: ",tok2str(ppptype2str, "unknown", proto));
+
+ if (length < 4) /* FIXME weak boundary checking */
return;
- }
- code = *p++;
+ code = *tptr++;
printf("%s (%u)",
- tok2str(cpcodes, "unknown opcode 0x%02x",code),
- *p++); /* ID */
+ tok2str(cpcodes, "Unknown Opcode 0x%02x",code),
+ *tptr++); /* ID */
- len = EXTRACT_16BITS(p);
- p += 2;
+ len = EXTRACT_16BITS(tptr);
+ tptr += 2;
if (length <= 4)
return; /* there may be a NULL confreq etc. */
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]);
+ printf(", Magic-Num=%08x", EXTRACT_32BITS(tptr));
+ tptr += 4;
+ printf(" OUI=%02x%02x%02x", tptr[0], tptr[1], tptr[2]);
/* XXX: need to decode Kind and Value(s)? */
break;
case CPCODES_CONF_REQ:
pfunc = NULL;
break;
}
- if ((j = (*pfunc)(p, len)) == 0)
+ if ((j = (*pfunc)(tptr, len)) == 0)
break;
x -= j;
- p += j;
+ tptr += j;
} while (x > 0);
break;
case CPCODES_PROT_REJ:
if (length < 6)
break;
- printf(", Rejected-Protocol=%04x", EXTRACT_16BITS(p));
+ printf(", Rejected-Protocol=%04x", EXTRACT_16BITS(tptr));
/* XXX: need to decode Rejected-Information? */
break;
case CPCODES_ECHO_REQ:
case CPCODES_ID:
if (length < 8)
break;
- printf(", Magic-Num=%08x", EXTRACT_32BITS(p));
+ printf(", Magic-Num=%08x", EXTRACT_32BITS(tptr));
/* 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(", Magic-Num=%08x", EXTRACT_32BITS(tptr));
+ printf(" Seconds-Remaining=%u", EXTRACT_32BITS(tptr + 4));
/* XXX: need to decode Message? */
break;
default:
- print_unknown_data(p,"\n\t",len);
+ /* XXX this is dirty but we do not get the
+ * original pointer passed to the begin
+ * the PPP packet */
+ if (!vflag)
+ print_unknown_data(pptr-2,"\n\t",length+2);
break;
}
+
+ if (vflag)
+ print_unknown_data(pptr-2,"\n\t",length+2);
}
/* LCP config options */
mpls_print(p, length);
break;
default:
- break;
+ if (!vflag)
+ printf("unknown PPP protocol (0x%04x)", proto);
+ break;
}
}
ppp_print(register const u_char *p, u_int length)
{
u_int proto;
- u_int full_length = length;
+ u_int olen = length; /* _o_riginal length */
u_int hdr_len = 0;
/*
hdr_len += 2;
}
- printf("%s, length: %u : ",
- tok2str(ppptype2str, "unknown-0x%04x", proto),
- full_length);
+ if (vflag)
+ printf("PPP-%s (length: %u): ",
+ tok2str(ppptype2str, "unknown (0x%04x)", proto),
+ olen);
handle_ppp(proto, p, length);
return (hdr_len);
proto = EXTRACT_16BITS(p);
p += 2;
length -= 2;
- printf("%s: ", tok2str(ppptype2str, "unknown-0x%04x", proto));
+ printf("%s: ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto));
handle_ppp(proto, p, length);
break;
mpls_print(p, length);
break;
default:
- printf("%s ", tok2str(ppptype2str, "unknown protocol 0x%04x", ptype));
+ printf("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", ptype));
}
printx: