home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / include / netat / sysglue.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-30  |  5.3 KB  |  191 lines

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