*/
/*
- * This version is for use with STREAMS under SunOS 4.x.
+ * This version is for use with STREAMS under SunOS 4.x,
+ * DEC Alpha OSF/1, and AIX 4.x.
*
- * $Id: bsd-comp.c,v 1.7 1994/11/30 05:29:36 paulus Exp $
+ * $Id: bsd-comp.c,v 1.8 1994/12/08 00:35:33 paulus Exp $
*/
+#ifdef __aix4__
+#include <net/net_globals.h>
+#endif
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stream.h>
-#include <sys/kmem_alloc.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/ppp_defs.h>
#include <net/ppp_str.h>
+#ifdef sun
+#include <sys/kmem_alloc.h>
+#define ALLOCATE(n) kmem_alloc((n), KMEM_NOSLEEP)
+#define FREE(p, n) kmem_free((p), (n))
+#endif
+
+#ifdef __osf__
+#include <kern/kalloc.h>
+#define ALLOCATE(n) kalloc((n))
+#define FREE(p, n) kfree((p), (n))
+#endif
+
+#ifdef __aix4__
+#define ALLOCATE(n) xmalloc((n), 0, pinned_heap)
+#define FREE(p, n) xmfree((p), pinned_heap)
+#endif
+
#define PACKETPTR mblk_t *
#include <net/ppp-comp.h>
maxmaxcode = MAXCODE(bits);
newlen = sizeof(*db) + (hsize-1) * (sizeof(db->dict[0]));
- db = (struct bsd_db *) kmem_alloc(newlen, KMEM_NOSLEEP);
+ db = (struct bsd_db *) ALLOCATE(newlen);
if (!db)
return NULL;
bzero(db, sizeof(*db) - sizeof(db->dict));
if (!decomp) {
db->lens = NULL;
} else {
- db->lens = (u_short *) kmem_alloc((maxmaxcode+1) * sizeof(db->lens[0]),
- KMEM_NOSLEEP);
+ db->lens = (u_short *) ALLOCATE((maxmaxcode+1) * sizeof(db->lens[0]));
if (!db->lens) {
- kmem_free(db, newlen);
+ FREE(db, newlen);
return NULL;
}
}
struct bsd_db *db = (struct bsd_db *) state;
if (db->lens)
- kmem_free(db->lens, (db->maxmaxcode+1) * sizeof(db->lens[0]));
- kmem_free(db, db->totlen);
+ FREE(db->lens, (db->maxmaxcode+1) * sizeof(db->lens[0]));
+ FREE(db, db->totlen);
}
static void *
* so that the entire packet being decompressed doesn't have
* to be in contiguous memory (just the compressed header).
*
- * $Id: vjcompress.c,v 1.3 1994/11/30 05:31:00 paulus Exp $
+ * $Id: vjcompress.c,v 1.4 1994/12/08 00:35:33 paulus Exp $
*/
#include <sys/types.h>
#include <sys/param.h>
+
+#ifdef __osf__
+#include <net/net_globals.h>
+#endif
#include <netinet/in.h>
+
+#ifdef __aix4__
+#define _NETINET_IN_SYSTM_H_
+typedef u_long n_long;
+#else
#include <netinet/in_systm.h>
+#endif
+
#include <netinet/ip.h>
#include <netinet/tcp.h>
#define ovbcopy bcopy
#endif
+#ifdef __osf__
+#define getip_hl(base) (((base).ip_vhl)&0xf)
+#define getth_off(base) ((((base).th_xoff)&0xf0)>>4)
+
+#else
+#define getip_hl(base) ((base).ip_hl)
+#define getth_off(base) ((base).th_off)
+#endif
+
void
vj_compress_init(comp, max_state)
struct vjcompress *comp;
(f) = htonl(ntohl(f) + ((cp[1] << 8) | cp[2])); \
cp += 3; \
} else { \
- (f) = htonl(ntohl(f) + (u_long)*cp++); \
+ (f) = htonl(ntohl(f) + (u_int32_t)*cp++); \
} \
}
(f) = htons(ntohs(f) + ((cp[1] << 8) | cp[2])); \
cp += 3; \
} else { \
- (f) = htons(ntohs(f) + (u_long)*cp++); \
+ (f) = htons(ntohs(f) + (u_int32_t)*cp++); \
} \
}
(f) = htons((cp[1] << 8) | cp[2]); \
cp += 3; \
} else { \
- (f) = htons((u_long)*cp++); \
+ (f) = htons((u_int32_t)*cp++); \
} \
}
u_char **vjhdrp;
{
register struct cstate *cs = comp->last_cs->cs_next;
- register u_int hlen = ip->ip_hl;
+ register u_int hlen = getip_hl(*ip);
register struct tcphdr *oth;
register struct tcphdr *th;
register u_int deltaS, deltaA;
INCR(vjs_packets);
if (ip->ip_src.s_addr != cs->cs_ip.ip_src.s_addr ||
ip->ip_dst.s_addr != cs->cs_ip.ip_dst.s_addr ||
- *(int *)th != ((int *)&cs->cs_ip)[cs->cs_ip.ip_hl]) {
+ *(int *)th != ((int *)&cs->cs_ip)[getip_hl(cs->cs_ip)]) {
/*
* Wasn't the first -- search for it.
*
INCR(vjs_searches);
if (ip->ip_src.s_addr == cs->cs_ip.ip_src.s_addr
&& ip->ip_dst.s_addr == cs->cs_ip.ip_dst.s_addr
- && *(int *)th == ((int *)&cs->cs_ip)[cs->cs_ip.ip_hl])
+ && *(int *)th == ((int *)&cs->cs_ip)[getip_hl(cs->cs_ip)])
goto found;
} while (cs != lastcs);
*/
INCR(vjs_misses);
comp->last_cs = lcs;
- hlen += th->th_off;
+ hlen += getth_off(*th);
hlen <<= 2;
if (hlen > mlen)
return (TYPE_IP);
*/
oth = (struct tcphdr *)&((int *)&cs->cs_ip)[hlen];
deltaS = hlen;
- hlen += th->th_off;
+ hlen += getth_off(*th);
hlen <<= 2;
if (hlen > mlen)
return (TYPE_IP);
if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] ||
((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] ||
((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4] ||
- th->th_off != oth->th_off ||
+ getth_off(*th) != getth_off(*oth) ||
(deltaS > 5 && BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) ||
- (th->th_off > 5 && BCMP(th + 1, oth + 1, (th->th_off - 5) << 2)))
+ (getth_off(*th) > 5 && BCMP(th + 1, oth + 1, (getth_off(*th) - 5) << 2)))
goto uncompressed;
/*
cs = &comp->rstate[comp->last_recv = ip->ip_p];
comp->flags &=~ VJF_TOSS;
ip->ip_p = IPPROTO_TCP;
- hlen = ip->ip_hl;
- hlen += ((struct tcphdr *)&((int *)ip)[hlen])->th_off;
+ hlen = getip_hl(*ip);
+ hlen += getth_off(*((struct tcphdr *)&((int *)ip)[hlen]));
hlen <<= 2;
BCOPY(ip, &cs->cs_ip, hlen);
cs->cs_hlen = hlen;
}
}
cs = &comp->rstate[comp->last_recv];
- hlen = cs->cs_ip.ip_hl << 2;
+ hlen = getip_hl(cs->cs_ip) << 2;
th = (struct tcphdr *)&((u_char *)&cs->cs_ip)[hlen];
th->th_sum = htons((*cp << 8) | cp[1]);
cp += 2;