X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=modules%2Fvjcompress.c;h=2507573eedbfe215e1e7b50738147957d8cc3043;hp=ef2c9c487fb619985b7a604f9b10bd5d00d6f999;hb=031ccaeb1dd0343d7b10990f49be6a9f4e82a7dc;hpb=5079a982cc7f44cf230df1bec5520cbb9f5631ad diff --git a/modules/vjcompress.c b/modules/vjcompress.c index ef2c9c4..2507573 100644 --- a/modules/vjcompress.c +++ b/modules/vjcompress.c @@ -23,19 +23,33 @@ * Modified June 1993 by Paul Mackerras, paulus@cs.anu.edu.au, * so that the entire packet being decompressed doesn't have * to be in contiguous memory (just the compressed header). + */ + +/* + * This version is used under SunOS 4.x, DEC Alpha OSF/1, AIX 4.x, + * and SVR4 systems including Solaris 2. * - * $Id: vjcompress.c,v 1.4 1994/12/08 00:35:33 paulus Exp $ + * $Id: vjcompress.c,v 1.7 1995/12/11 02:57:49 paulus Exp $ */ #include #include -#ifdef __osf__ +#ifdef SVR4 +#ifndef __GNUC__ +#include /* for ntohl, etc. */ +#else +/* make sure we don't get the gnu "fixed" one! */ +#include "/usr/include/sys/byteorder.h" +#endif +#endif + +#ifdef OSF1 #include #endif #include -#ifdef __aix4__ +#ifdef AIX4 #define _NETINET_IN_SYSTM_H_ typedef u_long n_long; #else @@ -61,7 +75,7 @@ typedef u_long n_long; #define ovbcopy bcopy #endif -#ifdef __osf__ +#ifdef OSF1 #define getip_hl(base) (((base).ip_vhl)&0xf) #define getth_off(base) ((((base).th_xoff)&0xf0)>>4) @@ -121,19 +135,23 @@ vj_compress_init(comp, max_state) #define DECODEL(f) { \ if (*cp == 0) {\ - (f) = htonl(ntohl(f) + ((cp[1] << 8) | cp[2])); \ + u_int32_t tmp = ntohl(f) + ((cp[1] << 8) | cp[2]); \ + (f) = htonl(tmp); \ cp += 3; \ } else { \ - (f) = htonl(ntohl(f) + (u_int32_t)*cp++); \ + u_int32_t tmp = ntohl(f) + (u_int32_t)*cp++; \ + (f) = htonl(tmp); \ } \ } #define DECODES(f) { \ if (*cp == 0) {\ - (f) = htons(ntohs(f) + ((cp[1] << 8) | cp[2])); \ + u_short tmp = ntohs(f) + ((cp[1] << 8) | cp[2]); \ + (f) = htons(tmp); \ cp += 3; \ } else { \ - (f) = htons(ntohs(f) + (u_int32_t)*cp++); \ + u_short tmp = ntohs(f) + (u_int32_t)*cp++; \ + (f) = htons(tmp); \ } \ } @@ -460,6 +478,7 @@ vj_uncompress_tcp(buf, buflen, total_len, comp, hdrp, hlenp) register struct cstate *cs; register u_short *bp; register u_int vjlen; + register u_int32_t tmp; INCR(vjs_compressedin); cp = buf; @@ -494,15 +513,19 @@ vj_uncompress_tcp(buf, buflen, total_len, comp, hdrp, hlenp) switch (changes & SPECIALS_MASK) { case SPECIAL_I: { - register u_int i = ntohs(cs->cs_ip.ip_len) - cs->cs_hlen; - th->th_ack = htonl(ntohl(th->th_ack) + i); - th->th_seq = htonl(ntohl(th->th_seq) + i); + register u_int32_t i = ntohs(cs->cs_ip.ip_len) - cs->cs_hlen; + /* some compilers can't nest inline assembler.. */ + tmp = ntohl(th->th_ack) + i; + th->th_ack = htonl(tmp); + tmp = ntohl(th->th_seq) + i; + th->th_seq = htonl(tmp); } break; case SPECIAL_D: - th->th_seq = htonl(ntohl(th->th_seq) + ntohs(cs->cs_ip.ip_len) - - cs->cs_hlen); + /* some compilers can't nest inline assembler.. */ + tmp = ntohl(th->th_seq) + ntohs(cs->cs_ip.ip_len) - cs->cs_hlen; + th->th_seq = htonl(tmp); break; default: @@ -521,8 +544,10 @@ vj_uncompress_tcp(buf, buflen, total_len, comp, hdrp, hlenp) } if (changes & NEW_I) { DECODES(cs->cs_ip.ip_id); - } else - cs->cs_ip.ip_id = htons(ntohs(cs->cs_ip.ip_id) + 1); + } else { + cs->cs_ip.ip_id = ntohs(cs->cs_ip.ip_id) + 1; + cs->cs_ip.ip_id = htons(cs->cs_ip.ip_id); + } /* * At this point, cp points to the first byte of data in the