]> git.ozlabs.org Git - ppp.git/blob - solaris/ppp_mod.h
Fixed compilation failure on Solaris due to new CHAP (missing chap-md5.o
[ppp.git] / solaris / ppp_mod.h
1 /*
2  * Miscellaneous definitions for PPP STREAMS modules.
3  */
4
5 /*
6  * Macros for allocating and freeing kernel memory.
7  */
8 #ifdef SVR4                     /* SVR4, including Solaris 2 */
9 #include <sys/kmem.h>
10 #define ALLOC_SLEEP(n)          kmem_alloc((n), KM_SLEEP)
11 #define ALLOC_NOSLEEP(n)        kmem_alloc((n), KM_NOSLEEP)
12 #define FREE(p, n)              kmem_free((p), (n))
13 #endif
14
15 #ifdef SUNOS4
16 #include <sys/kmem_alloc.h>     /* SunOS 4.x */
17 #define ALLOC_SLEEP(n)          kmem_alloc((n), KMEM_SLEEP)
18 #define ALLOC_NOSLEEP(n)        kmem_alloc((n), KMEM_NOSLEEP)
19 #define FREE(p, n)              kmem_free((p), (n))
20 #define NOTSUSER()              (suser()? 0: EPERM)
21 #define bcanputnext(q, band)    canputnext((q))
22 #endif /* SunOS 4 */
23
24 #ifdef __osf__
25 #include <sys/malloc.h>
26
27 /* caution: this mirrors macros in sys/malloc.h, and uses interfaces
28  * which are subject to change.
29  * The problems are that:
30  *     - the official MALLOC macro wants the lhs of the assignment as an argument,
31  *       and it takes care of the assignment itself (yuck.)
32  *     - PPP insists on using "FREE" which conflicts with a macro of the same name.
33  *
34  */
35 #ifdef BUCKETINDX /* V2.0 */
36 #define ALLOC_SLEEP(n)          (void *)malloc((u_long)(n), BUCKETP(n), M_DEVBUF, M_WAITOK)
37 #define ALLOC_NOSLEEP(n)        (void *)malloc((u_long)(n), BUCKETP(n), M_DEVBUF, M_NOWAIT)
38 #else
39 #define ALLOC_SLEEP(n)          (void *)malloc((u_long)(n), BUCKETINDEX(n), M_DEVBUF, M_WAITOK)
40 #define ALLOC_NOSLEEP(n)        (void *)malloc((u_long)(n), BUCKETINDEX(n), M_DEVBUF, M_NOWAIT)
41 #endif
42
43 #define bcanputnext(q, band)    canputnext((q))
44
45 #ifdef FREE
46 #undef FREE
47 #endif
48 #define FREE(p, n)              free((void *)(p), M_DEVBUF)
49
50 #define NO_DLPI 1
51
52 #ifndef IFT_PPP
53 #define IFT_PPP 0x17
54 #endif
55
56 #include <sys/proc.h>
57 #define NOTSUSER()              (suser(u.u_procp->p_rcred, &u.u_acflag) ? EPERM : 0)
58
59 /* #include "ppp_osf.h" */
60
61 #endif /* __osf__ */
62
63 #ifdef AIX4
64 #define ALLOC_SLEEP(n)          xmalloc((n), 0, pinned_heap)    /* AIX V4.x */
65 #define ALLOC_NOSLEEP(n)        xmalloc((n), 0, pinned_heap)    /* AIX V4.x */
66 #define FREE(p, n)              xmfree((p), pinned_heap)
67 #define NOTSUSER()              (suser()? 0: EPERM)
68 #endif /* AIX */
69
70 /*
71  * Macros for printing debugging stuff.
72  */
73 #ifdef DEBUG
74 #if defined(SVR4) || defined(__osf__)
75 #if defined(SNI)
76 #include <sys/strlog.h>
77 #define STRLOG_ID               4712
78 #define DPRINT(f)               strlog(STRLOG_ID, 0, 0, SL_TRACE, f)
79 #define DPRINT1(f, a1)          strlog(STRLOG_ID, 0, 0, SL_TRACE, f, a1)
80 #define DPRINT2(f, a1, a2)      strlog(STRLOG_ID, 0, 0, SL_TRACE, f, a1, a2)
81 #define DPRINT3(f, a1, a2, a3)  strlog(STRLOG_ID, 0, 0, SL_TRACE, f, a1, a2, a3)
82 #else
83 #define DPRINT(f)               cmn_err(CE_CONT, f)
84 #define DPRINT1(f, a1)          cmn_err(CE_CONT, f, a1)
85 #define DPRINT2(f, a1, a2)      cmn_err(CE_CONT, f, a1, a2)
86 #define DPRINT3(f, a1, a2, a3)  cmn_err(CE_CONT, f, a1, a2, a3)
87 #endif /* SNI */
88 #else
89 #define DPRINT(f)               printf(f)
90 #define DPRINT1(f, a1)          printf(f, a1)
91 #define DPRINT2(f, a1, a2)      printf(f, a1, a2)
92 #define DPRINT3(f, a1, a2, a3)  printf(f, a1, a2, a3)
93 #endif /* SVR4 or OSF */
94
95 #else
96 #define DPRINT(f)               0
97 #define DPRINT1(f, a1)          0
98 #define DPRINT2(f, a1, a2)      0
99 #define DPRINT3(f, a1, a2, a3)  0
100 #endif /* DEBUG */
101
102 #ifndef SVR4
103 typedef unsigned char uchar_t;
104 typedef unsigned short ushort_t;
105 #ifndef __osf__
106 typedef int minor_t;
107 #endif
108 #endif
109
110 /*
111  * If we don't have multithreading support, define substitutes.
112  */
113 #ifndef D_MP
114 # define qprocson(q)
115 # define qprocsoff(q)
116 # define put(q, mp)     ((*(q)->q_qinfo->qi_putp)((q), (mp)))
117 # define canputnext(q)  canput((q)->q_next)
118 # define qwriter(q, mp, func, scope)    (func)((q), (mp))
119 #endif
120
121 #ifdef D_MP
122 /* Use msgpullup if we have other multithreading support. */
123 #define PULLUP(mp, len)                         \
124     do {                                        \
125         mblk_t *np = msgpullup((mp), (len));    \
126         freemsg((mp));                          \
127         mp = np;                                \
128     } while (0)
129
130 #else
131 /* Use pullupmsg if we don't have any multithreading support. */
132 #define PULLUP(mp, len)                 \
133     do {                                \
134         if (!pullupmsg((mp), (len))) {  \
135             freemsg((mp));              \
136             mp = 0;                     \
137         }                               \
138     } while (0)
139 #endif
140
141 /*
142  * How to declare the open and close procedures for a module.
143  */
144 #ifdef SVR4
145 #define MOD_OPEN_DECL(name)     \
146 static int name __P((queue_t *, dev_t *, int, int, cred_t *))
147
148 #define MOD_CLOSE_DECL(name)    \
149 static int name __P((queue_t *, int, cred_t *))
150
151 #define MOD_OPEN(name)                          \
152 static int name(q, devp, flag, sflag, credp)    \
153     queue_t *q;                                 \
154     dev_t *devp;                                \
155     int flag, sflag;                            \
156     cred_t *credp;
157
158 #define MOD_CLOSE(name)         \
159 static int name(q, flag, credp) \
160     queue_t *q;                 \
161     int flag;                   \
162     cred_t *credp;
163
164 #define OPEN_ERROR(x)           return (x)
165 #define DRV_OPEN_OK(dev)        return 0
166
167 #define NOTSUSER()              (drv_priv(credp))
168
169 #else   /* not SVR4 */
170 #define MOD_OPEN_DECL(name)     \
171 static int name __P((queue_t *, int, int, int))
172
173 #define MOD_CLOSE_DECL(name)    \
174 static int name __P((queue_t *, int))
175
176 #define MOD_OPEN(name)          \
177 static int name(q, dev, flag, sflag)    \
178     queue_t *q;                         \
179     int dev;                            \
180     int flag, sflag;
181
182 #define MOD_CLOSE(name)         \
183 static int name(q, flag)        \
184     queue_t *q;                 \
185     int flag;
186
187 #define OPEN_ERROR(x)           { u.u_error = (x); return OPENFAIL; }
188 #define DRV_OPEN_OK(dev)        return (dev)
189
190 #endif  /* SVR4 */