diff options
author | Eivind Næss <eivnaes@yahoo.com> | 2022-05-29 22:14:08 -0700 |
---|---|---|
committer | Eivind Næss <eivnaes@yahoo.com> | 2022-07-15 15:25:39 -0700 |
commit | 199e97bae9c03f5cec5202a511b5c436aff05af9 (patch) | |
tree | aae67baaaf1116f72c7139201589bcde3f72af1a /pppdump | |
parent | 1d3327b87170d5d8db4a5ad06b465925cff4488a (diff) | |
download | ppp-199e97bae9c03f5cec5202a511b5c436aff05af9.tar.gz |
For Linux, use the Linux / Glibc based defines instead of included headers
This is to ensure compatibility with the OS you are compiling against and that
headers are maintained in upstream projects.
- Moved PPP_EAP and PPP_ECP into respective header files in lieu of not currently
existing in the linux/ppp_defs.h
- Unchained the top-level ${topsrc_dir}/include, this folder is included for
prosterity and may continue to exist on github, but in the future eliminated from
distribution
- Bogus upstream file in glibc for <net/if_ppp.h>, its content should be replaced
with a simple include to <linux/ppp-ioctl.h>. The lack of an appropriate ifreq
structure with ppp_stats or ppp_comp_stats, implementet that inline (and tested).
- Updated instances where PPP_FCS() macro would expand the fcstab, while PPP_GOODFCS
and PPP_INITFCS is provided in <linux/ppp_defs.h>, the latter is tied to a lookup
table. It's used in two places, so add the PPP_FCS macro where applicable.
Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
Diffstat (limited to 'pppdump')
-rw-r--r-- | pppdump/Makefile.am | 1 | ||||
-rw-r--r-- | pppdump/bsd-comp.c | 12 | ||||
-rw-r--r-- | pppdump/deflate.c | 10 | ||||
-rw-r--r-- | pppdump/pppdump.c | 3 |
4 files changed, 15 insertions, 11 deletions
diff --git a/pppdump/Makefile.am b/pppdump/Makefile.am index 2df7e0e..186f34e 100644 --- a/pppdump/Makefile.am +++ b/pppdump/Makefile.am @@ -2,7 +2,6 @@ sbin_PROGRAMS = pppdump dist_man8_MANS = pppdump.8 pppdump_SOURCES = pppdump.c bsd-comp.c deflate.c zlib.c -pppdump_CFLAGS = -I${top_srcdir}/include/net noinst_HEADERS = \ ppp-comp.h \ diff --git a/pppdump/bsd-comp.c b/pppdump/bsd-comp.c index 9d45f0b..7ad6289 100644 --- a/pppdump/bsd-comp.c +++ b/pppdump/bsd-comp.c @@ -46,7 +46,8 @@ #include <stddef.h> #include <stdlib.h> #include <string.h> -#include "ppp_defs.h" +#include <net/ppp_defs.h> + #include "ppp-comp.h" #if DO_BSD_COMPRESS @@ -250,14 +251,15 @@ bsd_comp_stats(void *state, struct compstat *stats) stats->comp_packets = db->comp_count; stats->inc_bytes = db->incomp_bytes; stats->inc_packets = db->incomp_count; - stats->ratio = db->in_count; + + u_int ratio = db->in_count; out = db->bytes_out; - if (stats->ratio <= 0x7fffff) - stats->ratio <<= 8; + if (ratio <= 0x7fffff) + ratio <<= 8; else out >>= 8; if (out != 0) - stats->ratio /= out; + stats->ratio = ratio / out; } /* diff --git a/pppdump/deflate.c b/pppdump/deflate.c index 5668a4d..0f090b2 100644 --- a/pppdump/deflate.c +++ b/pppdump/deflate.c @@ -41,7 +41,8 @@ #include <stddef.h> #include <stdlib.h> #include <string.h> -#include "ppp_defs.h" +#include <net/ppp_defs.h> + #include "ppp-comp.h" #include "zlib.h" @@ -115,12 +116,13 @@ z_comp_stats(void *arg, struct compstat *stats) *stats = state->stats; stats->ratio = stats->unc_bytes; out = stats->comp_bytes + stats->unc_bytes; - if (stats->ratio <= 0x7ffffff) - stats->ratio <<= 8; + u_int ratio = stats->ratio; + if (ratio <= 0x7ffffff) + ratio <<= 8; else out >>= 8; if (out != 0) - stats->ratio /= out; + stats->ratio = ratio / out; } /* diff --git a/pppdump/pppdump.c b/pppdump/pppdump.c index 130300a..8944ca5 100644 --- a/pppdump/pppdump.c +++ b/pppdump/pppdump.c @@ -38,7 +38,7 @@ #include <stdlib.h> #include <time.h> #include <sys/types.h> -#include "ppp_defs.h" +#include <net/ppp_defs.h> #include "ppp-comp.h" int hexmode; @@ -233,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; |