/*
  * This version is for use with STREAMS under SunOS 4.x,
- * DEC Alpha OSF/1, AIX 4.x, and SVR4 systems including Solaris 2.
+ * Digital UNIX, AIX 4.x, and SVR4 systems including Solaris 2.
  *
- * $Id: bsd-comp.c,v 1.18 1996/01/18 03:12:53 paulus Exp $
+ * $Id: bsd-comp.c,v 1.19 1996/06/26 00:53:15 paulus Exp $
  */
 
 #ifdef AIX4
 #endif
 #endif
 
-#ifdef OSF1
+#ifdef __osf__
 #undef FIRST
 #undef LAST
 #define BSD_LITTLE_ENDIAN
     if (opt_len != 3 || options[0] != CI_BSD_COMPRESS || options[1] != 3
        || BSD_VERSION(options[2]) != BSD_CURRENT_VERSION)
        return NULL;
+
     bits = BSD_NBITS(options[2]);
     switch (bits) {
     case 9:                    /* needs 82152 for both directions */
 
     maxmaxcode = MAXCODE(bits);
     newlen = sizeof(*db) + (hsize-1) * (sizeof(db->dict[0]));
+#ifdef __osf__
+    db = (struct bsd_db *) ALLOC_SLEEP(newlen);
+#else
     db = (struct bsd_db *) ALLOC_NOSLEEP(newlen);
+#endif
     if (!db)
        return NULL;
     bzero(db, sizeof(*db) - sizeof(db->dict));
     if (!decomp) {
        db->lens = NULL;
     } else {
+#ifdef __osf__
+       db->lens = (u_short *) ALLOC_SLEEP((maxmaxcode+1) * sizeof(db->lens[0]));
+#else
        db->lens = (u_short *) ALLOC_NOSLEEP((maxmaxcode+1) * sizeof(db->lens[0]));
+#endif
        if (!db->lens) {
            FREE(db, newlen);
            return NULL;
 
  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
  * OR MODIFICATIONS.
  *
- * $Id: deflate.c,v 1.2 1996/04/04 02:44:56 paulus Exp $
+ * $Id: deflate.c,v 1.3 1996/06/26 00:53:16 paulus Exp $
  */
 
 #ifdef AIX4
 
 #define PACKETPTR      mblk_t *
 #include <net/ppp-comp.h>
+
+#ifdef __osf__
+#include "zlib.h"
+#else
 #include "common/zlib.h"
+#endif
 
 #if DO_DEFLATE
 
 
 #define DEFLATE_OVHD   2               /* Deflate overhead/packet */
 
-static void    *zalloc __P((void *, u_int items, u_int size));
-static void    zfree __P((void *, void *ptr, u_int nb));
+static void    *z_alloc __P((void *, u_int items, u_int size));
+static void    z_free __P((void *, void *ptr, u_int nb));
 static void    *z_comp_alloc __P((u_char *options, int opt_len));
 static void    *z_decomp_alloc __P((u_char *options, int opt_len));
 static void    z_comp_free __P((void *state));
  * Space allocation and freeing routines for use by zlib routines.
  */
 static void *
-zalloc(notused, items, size)
+z_alloc(notused, items, size)
     void *notused;
     u_int items, size;
 {
+#ifdef __osf__
+    return ALLOC_SLEEP(items * size);
+#else
     return ALLOC_NOSLEEP(items * size);
+#endif
 }
 
 static void
-zfree(notused, ptr, nbytes)
+z_free(notused, ptr, nbytes)
     void *notused;
     void *ptr;
     u_int nbytes;
        return NULL;
 
     state->strm.next_in = NULL;
-    state->strm.zalloc = (alloc_func) zalloc;
-    state->strm.zfree = (free_func) zfree;
+    state->strm.zalloc = (alloc_func) z_alloc;
+    state->strm.zfree = (free_func) z_free;
     if (deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION, DEFLATE_METHOD_VAL,
                     -w_size, 8, Z_DEFAULT_STRATEGY, DEFLATE_OVHD+2) != Z_OK) {
        FREE(state, sizeof(*state));
        return NULL;
 
     state->strm.next_out = NULL;
-    state->strm.zalloc = (alloc_func) zalloc;
-    state->strm.zfree = (free_func) zfree;
+    state->strm.zalloc = (alloc_func) z_alloc;
+    state->strm.zfree = (free_func) z_free;
     if (inflateInit2(&state->strm, -w_size) != Z_OK) {
        FREE(state, sizeof(*state));
        return NULL;
 
  * Miscellaneous definitions for PPP STREAMS modules.
  */
 
-#if defined(osf) || defined(__osf__)
-#define OSF1
-#endif
-
 /*
  * Macros for allocating and freeing kernel memory.
  */
 #define ALLOC_SLEEP(n)         kmem_alloc((n), KM_SLEEP)
 #define ALLOC_NOSLEEP(n)       kmem_alloc((n), KM_NOSLEEP)
 #define FREE(p, n)             kmem_free((p), (n))
+#define NOTSUSER()             (suser()? 0: EPERM)
 #endif
 
 #ifdef SUNOS4
 #define ALLOC_SLEEP(n)         kmem_alloc((n), KMEM_SLEEP)
 #define ALLOC_NOSLEEP(n)       kmem_alloc((n), KMEM_NOSLEEP)
 #define FREE(p, n)             kmem_free((p), (n))
+#define NOTSUSER()             (suser()? 0: EPERM)
 #endif /* SunOS 4 */
 
-#ifdef OSF1
-#include <kern/kalloc.h>       /* OSF/1 */
+#ifdef __osf__
+#include <sys/malloc.h>
+
+/* caution: this mirrors macros in sys/malloc.h, and uses interfaces
+ * which are subject to change.
+ * The problems are that:
+ *     - the official MALLOC macro wants the lhs of the assignment as an argument,
+ *      and it takes care of the assignment itself (yuck.)
+ *     - PPP insists on using "FREE" which conflicts with a macro of the same name.
+ *
+ */
+#ifdef BUCKETINDX /* V2.0 */
+#define ALLOC_SLEEP(n)         (void *)malloc((u_long)(n), BUCKETP(n), M_DEVBUF, M_WAITOK)
+#define ALLOC_NOSLEEP(n)       (void *)malloc((u_long)(n), BUCKETP(n), M_DEVBUF, M_NOWAIT)
+#else
+#define ALLOC_SLEEP(n)         (void *)malloc((u_long)(n), BUCKETINDEX(n), M_DEVBUF, M_WAITOK)
+#define ALLOC_NOSLEEP(n)       (void *)malloc((u_long)(n), BUCKETINDEX(n), M_DEVBUF, M_NOWAIT)
+#endif
+
+#ifdef FREE
 #undef FREE
-#define ALLOC_SLEEP(n)         kalloc((n))
-#define ALLOC_NOSLEEP(n)       kalloc((n))
-#define FREE(p, n)             kfree((p), (n))
-#endif /* OSF/1 */
+#endif
+#define FREE(p, n)             free((void *)(p), M_DEVBUF)
+
+#define NO_DLPI 1
+
+#ifndef IFT_PPP
+#define IFT_PPP 0x17
+#endif
+
+#include <sys/proc.h>
+#define NOTSUSER()             (suser(u.u_procp->p_rcred, &u.u_acflag) ? EPERM : 0)
+
+#include "ppp_osf.h"
+
+#endif /* __osf__ */
 
 #ifdef AIX4
 #define ALLOC_SLEEP(n)         xmalloc((n), 0, pinned_heap)    /* AIX V4.x */
 #define ALLOC_NOSLEEP(n)       xmalloc((n), 0, pinned_heap)    /* AIX V4.x */
 #define FREE(p, n)             xmfree((p), pinned_heap)
+#define NOTSUSER()             (suser()? 0: EPERM)
 #endif /* AIX */
 
 /*
  * Macros for printing debugging stuff.
  */
 #ifdef DEBUG
-#ifdef SVR4
+#if defined(SVR4) || defined(__osf__)
 #define DPRINT(f)              cmn_err(CE_CONT, f)
 #define DPRINT1(f, a1)         cmn_err(CE_CONT, f, a1)
 #define DPRINT2(f, a1, a2)     cmn_err(CE_CONT, f, a1, a2)
 #ifndef SVR4
 typedef unsigned char uchar_t;
 typedef unsigned short ushort_t;
+#ifndef __osf__
 typedef int minor_t;
 #endif
+#endif
 
 /*
  * If we don't have multithreading support, define substitutes.
 #define OPEN_ERROR(x)          { u.u_error = (x); return OPENFAIL; }
 #define DRV_OPEN_OK(dev)       return (dev)
 
-#ifdef OSF1
-#include <sys/proc.h>
-#define NOTSUSER()     (suser(u.u_procp->p_rcred, &u.u_acflag))
-#else
-#define NOTSUSER()     (suser()? 0: EPERM)
-#endif
-
 #endif /* SVR4 */
 
  */
 
 /*
- * This version is used under SunOS 4.x, DEC Alpha OSF/1, AIX 4.x,
+ * This version is used under SunOS 4.x, Digital UNIX, AIX 4.x,
  * and SVR4 systems including Solaris 2.
  *
- * $Id: vjcompress.c,v 1.8 1996/05/24 07:04:26 paulus Exp $
+ * $Id: vjcompress.c,v 1.9 1996/06/26 00:53:17 paulus Exp $
  */
 
 #include <sys/types.h>
 #endif
 #endif
 
-#ifdef OSF1
+#ifdef __osf__
 #include <net/net_globals.h>
 #endif
 #include <netinet/in.h>
 #define ovbcopy bcopy
 #endif
 
-#ifdef OSF1
+#ifdef __osf__
 #define getip_hl(base) (((base).ip_vhl)&0xf)
 #define getth_off(base)        ((((base).th_xoff)&0xf0)>>4)