]> git.saurik.com Git - apple/xnu.git/blob - bsd/netat/sysglue.h
321712a2b07f1f5414fe871f335a7905c6cad735
[apple/xnu.git] / bsd / netat / sysglue.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * Title: sysglue.h - AppleTalk protocol to Unix System V/streams interface
32 *
33 * Facility: AppleTalk Protocol Execution Environment
34 *
35 * Author: Gregory Burns, Creation Date: Jun-3-1988
36 *
37 * History:
38 * X01-001 Gregory Burns 3-Jun-1988
39 * Initial Creation.
40 *
41 */
42
43 #ifndef _NETAT_SYSGLUE_H_
44 #define _NETAT_SYSGLUE_H_
45 #include <sys/appleapiopts.h>
46 #include <sys/cdefs.h>
47
48 #ifdef __APPLE_API_OBSOLETE
49
50 /*
51 The following is originally from netat/h/localglue.h, which was
52 included in netat/h/sysglue.h:
53 */
54
55 typedef struct {
56 int ic_cmd;
57 int ic_timout;
58 int ic_len;
59 char *ic_dp;
60 } ioccmd_t;
61
62 #ifdef KERNEL
63 #ifdef KERNEL_PRIVATE
64
65 /* LP64 version of ioccmd_t. all pointers
66 * grow when we're dealing with a 64-bit process.
67 * WARNING - keep in sync with ioccmd_t
68 */
69 #if __DARWIN_ALIGN_NATURAL
70 #pragma options align=natural
71 #endif
72
73 typedef struct {
74 int ic_cmd;
75 int ic_timout;
76 int ic_len;
77 user_addr_t ic_dp;
78 } user_ioccmd_t;
79
80 #if __DARWIN_ALIGN_NATURAL
81 #pragma options align=reset
82 #endif
83
84 #endif // KERNEL_PRIVATE
85 #endif // KERNEL
86
87 typedef struct {
88 int ioc_cmd;
89 void *ioc_cr;
90 int ioc_id;
91 int ioc_count;
92 int ioc_error;
93 int ioc_rval;
94 void *ioc_private;
95 int ioc_filler[4];
96 } ioc_t;
97
98 /*
99 * Want these definitions outside the KERNEL define for admin
100 * program access.
101 */
102 #ifdef _AIX
103 #define MSG_DATA 0x00
104 #define MSG_PROTO 0x01
105 #define MSG_IOCTL 0x0e
106 #define MSG_ERROR 0x8a
107 #define MSG_HANGUP 0x89
108 #define MSG_IOCACK 0x81
109 #define MSG_IOCNAK 0x82
110 #define MSG_CTL 0x0d
111 #else
112 /* ### LD 5/3/97 MacOSX porting note:
113 * Cannot use MSG_DATA = 0, because MT_FREE is defined as 0
114 * and the sanity check in m_free cause a panic.
115 */
116
117 #define MSG_DATA (MT_MAX - 1)
118 #define MSG_PROTO (MT_MAX - 2)
119 #define MSG_IOCTL (MT_MAX - 3)
120 #define MSG_ERROR (MT_MAX - 4)
121 #define MSG_HANGUP (MT_MAX - 5)
122 #define MSG_IOCACK (MT_MAX - 6)
123 #define MSG_IOCNAK (MT_MAX - 7)
124 #define MSG_CTL (MT_MAX - 8)
125 #endif
126
127 #ifdef KERNEL
128 #ifdef KERNEL_PRIVATE
129
130 #define SYS_HZ HZ /* Number of clock (SYS_SETTIMER) ticks per second */
131 #define HZ hz /* HZ ticks definition used throughout AppleTalk */
132
133 /* returned when the operation is not possible at this
134 * time (ie when starting up or shutting down.
135 * right now, uses ESHUTDOWN because ENOTREADY is not defined
136 * in MacOSX. Need to find a better Error code ###LD
137 */
138 #define ENOTREADY ESHUTDOWN
139
140 /* T_MPSAFE is used only in atp_open. I suspect it's a
141 * trick to accelerate local atp transactions.
142 */
143 #define T_MPSAFE 0
144
145 #define INTERRUPTIBLE 1
146 #define POLLIN 0x0001
147 #define POLLOUT 0x0002
148 #define POLLPRI 0x0004
149 #define POLLMSG 0x0080
150 #define POLLSYNC 0x8000
151 #define POLLMSG 0x0080
152
153 /*
154 * Define a new Data Type for file. it was DTYPE_OTHER for
155 * AIX, for MacOSX there is no such define so defines
156 * DTYPE_ATALK
157 */
158
159 #define DTYPE_ATALK -1
160
161 #define AT_WR_OFFSET 38
162 #ifndef EVENT_NULL
163 #define EVENT_NULL -1
164 #define LOCK_HANDLER 2
165 #endif
166 typedef int atevent_t;
167
168 typedef int atlock_t;
169 typedef int *atomic_p;
170 #define ATLOCKINIT(a) (a = (atlock_t) EVENT_NULL)
171 #define ATDISABLE(l, a)
172 #define ATENABLE(l, a)
173 #define ATEVENTINIT(a) (a = (atevent_t) EVENT_NULL)
174 #define DDP_OUTPUT(m) ddp_putmsg(0,m)
175 #define StaticProc static
176
177 #define PRI_LO 1
178 #define PRI_MED 2
179 #define PRI_HI 3
180
181 typedef struct mbuf gbuf_t;
182
183 /* prototypes for the gbuf routines */
184
185 struct mbuf *m_lgbuf_alloc(int size, int wait);
186 gbuf_t *gbuf_alloc_wait(int size, int wait);
187 gbuf_t *gbuf_copym(gbuf_t *mlist);
188 gbuf_t *gbuf_strip(gbuf_t *m);
189 int gbuf_freel(gbuf_t *m);
190 void gbuf_linkb(gbuf_t *m1, gbuf_t *m2);
191 void gbuf_linkpkt(gbuf_t *m1, gbuf_t *m2);
192 int gbuf_msgsize(gbuf_t *m);
193
194 #define gbuf_cont(m) m->m_next
195 #define gbuf_next(m) m->m_nextpkt
196 #define gbuf_rptr(m) m->m_data
197 #define gbuf_rinc(m,len) {m->m_data += len; m->m_len -= len;}
198 #define gbuf_rdec(m,len) {m->m_data -= len; m->m_len += len;}
199 #define gbuf_wptr(m) (m->m_data + m->m_len)
200 #define gbuf_winc(m,len) (m->m_len += len)
201 #define gbuf_wdec(m,len) (m->m_len -= len)
202 #define gbuf_wset(m,len) (m->m_len = len)
203 #define gbuf_type(m) m->m_type
204 #define gbuf_len(m) m->m_len
205
206 #define gbuf_alloc(size, pri) (gbuf_alloc_wait(size, FALSE))
207 #define gbuf_copym(mlist) ((gbuf_t *)copy_pkt(mlist, -1))
208
209 #define gbuf_prepend(m,len) M_PREPEND(m,len,M_DONTWAIT)
210 #define gbuf_freem(mlist) m_freem((struct mbuf *)mlist)
211 #define gbuf_freeb(m) (void)m_free((struct mbuf *)m)
212 #define gbuf_set_type(m, mtype) MCHTYPE(m, mtype)
213
214 /* Duplicate a single mbuf, attaching existing external storage. */
215 #define gbuf_dupb_wait(m, wait) ((gbuf_t *)m_copym(m, 0, gbuf_len(m), (wait)? M_WAIT: M_DONTWAIT))
216 #define gbuf_dupb(m) (gbuf_dupb_wait(m, FALSE))
217 /* Duplicate an mbuf chain, attaching existing external storage. */
218 #define gbuf_dupm(mlist) ((gbuf_t *)copy_pkt(mlist, -1))
219 /* *** was ((gbuf_t *)m_copym(mlist, 0, M_COPYALL, M_DONTWAIT)) *** */
220
221 #undef timeoutcf
222 #undef timeout
223 #undef untimeout
224
225 #endif /* KERNEL_PRIVATE */
226 #endif /* KERNEL */
227 #endif /* __APPLE_API_OBSOLETE */
228 #endif /* _NETAT_SYSGLUE_H_ */