X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppdump%2Fpppdump.c;h=130300a17d348046dbc4a81100f8fbfcf3d9f0a5;hb=HEAD;hp=a65a152a917bef424fc74b89591b1763923da995;hpb=d1506f182ba87dd019a9d5594f6acea17a77577f;p=ppp.git diff --git a/pppdump/pppdump.c b/pppdump/pppdump.c index a65a152..8a3a7e9 100644 --- a/pppdump/pppdump.c +++ b/pppdump/pppdump.c @@ -23,7 +23,7 @@ * 4. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by Paul Mackerras - * ". + * ". * * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY @@ -35,9 +35,10 @@ */ #include #include +#include #include #include -#include "ppp_defs.h" + #include "ppp-comp.h" int hexmode; @@ -53,6 +54,12 @@ int tot_sent, tot_rcvd; extern int optind; extern char *optarg; +void dumplog(); +void dumpppp(); +void show_time(); +void handle_ccp(); + +int main(ac, av) int ac; char **av; @@ -105,6 +112,7 @@ main(ac, av) exit(0); } +void dumplog(f) FILE *f; { @@ -183,7 +191,7 @@ dumplog(f) show_time(f, c); break; default: - printf("?%.2x\n"); + printf("?%.2x\n", c); } } } @@ -225,6 +233,7 @@ static u_short fcstab[256] = { 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 }; +#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]) struct pkt { int cnt; @@ -244,6 +253,7 @@ struct pkt { unsigned char dbuf[8192]; +void dumpppp(f) FILE *f; { @@ -287,6 +297,10 @@ dumpppp(f) printf("%s aborted packet:\n ", dir); q = " "; } + if (pkt->cnt >= sizeof(pkt->buf)) { + printf("%s over-long packet truncated:\n ", dir); + q = " "; + } nb = pkt->cnt; p = pkt->buf; pkt->cnt = 0; @@ -311,7 +325,7 @@ dumpppp(f) ++r; ++r; if (endp - r > mru) - printf(" ERROR: length (%d) > MRU (%d)\n", + printf(" ERROR: length (%zd) > MRU (%d)\n", endp - r, mru); if (decompress && fcs == PPP_GOODFCS) { /* See if this is a CCP or compressed packet */ @@ -390,7 +404,8 @@ dumpppp(f) c ^= 0x20; pkt->esc = 0; } - pkt->buf[pkt->cnt++] = c; + if (pkt->cnt < sizeof(pkt->buf)) + pkt->buf[pkt->cnt++] = c; break; } } @@ -412,7 +427,7 @@ dumpppp(f) show_time(f, c); break; default: - printf("?%.2x\n"); + printf("?%.2x\n", c); } } } @@ -429,6 +444,7 @@ struct compressor *compressors[] = { NULL }; +void handle_ccp(cp, dp, len) struct pkt *cp; u_char *dp; @@ -485,6 +501,7 @@ handle_ccp(cp, dp, len) } } +void show_time(f, c) FILE *f; int c;