#ifndef lint
static const char rcsid[] =
-"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.21 2002-12-19 09:39:14 guy Exp $ (LBL)";
+"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.22 2003-06-13 05:55:22 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
};
#define PPPOE_HDRLEN 6
+#define MAXTAGPRINT 80
u_int
pppoe_if_print(const struct pcap_pkthdr *h, register const u_char *p)
printf(" [ses 0x%x]", pppoe_sessionid);
}
- if (pppoe_payload + pppoe_length < snapend) {
-#if 0
- const u_char *x = pppoe_payload + pppoe_length;
+ if (pppoe_payload + pppoe_length < snapend && snapend-pppoe_payload+14 > 64) {
+ /* (small packets are probably just padded up to the ethernet
+ minimum of 64 bytes) */
printf(" [length %d (%d extra bytes)]",
pppoe_length, snapend - pppoe_payload - pppoe_length);
- default_print(x, snapend - x);
-#endif
+#if RESPECT_PAYLOAD_LENGTH
snapend = pppoe_payload+pppoe_length;
+#else
+ /* Actual PPPoE implementations appear to ignore the payload
+ length and use the full ethernet frame anyways */
+ pppoe_length = snapend-pppoe_payload;
+#endif
+
}
if (pppoe_code) {
/* p points to tag_value */
if (tag_len) {
- int isascii = 1;
+ unsigned isascii = 0, isgarbage = 0;
const u_char *v = p;
u_short l;
-
- for (v = p; v < p + tag_len; v++)
- if (*v >= 127 || *v < 32) {
- isascii = 0;
- break;
+ char tag_str[MAXTAGPRINT];
+ unsigned tag_str_len = 0;
+
+ for (v = p; v < p + tag_len && tag_str_len < MAXTAGPRINT-1; v++)
+ if (*v >= 32 && *v < 127) {
+ tag_str[tag_str_len++] = *v;
+ isascii++;
+ } else {
+ tag_str[tag_str_len++] = '.';
+ isgarbage++;
}
+ tag_str[tag_str_len] = 0;
- /* TODO print UTF8 decoded text */
- if (isascii) {
- l = (tag_len < 80 ? tag_len : 80);
+ if (isascii > isgarbage) {
printf(" [%s \"%*.*s\"]",
- tok2str(pppoetag2str, "TAG-0x%x", tag_type),
- l, l, p);
- } else
- printf(" [%s UTF8]",
- tok2str(pppoetag2str, "TAG-0x%x", tag_type));
+ tok2str(pppoetag2str, "TAG-0x%x", tag_type),
+ tag_str_len, tag_str_len, tag_str);
+ } else {
+ /* Print hex, not fast to abuse printf but this doesn't get used much */
+ printf(" [%s 0x", tok2str(pppoetag2str, "TAG-0x%x", tag_type));
+ for (v=p; v<p+tag_len; v++) {
+ printf("%02.2X", *v);
+ }
+ printf("]");
+ }
+
+
} else
printf(" [%s]", tok2str(pppoetag2str,
"TAG-0x%x", tag_type));