home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / sys / socket.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-22  |  10.0 KB  |  295 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1992 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon 
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    socket.h,v $
  29.  * Revision 2.1  92/04/21  17:17:05  rwd
  30.  * BSDSS
  31.  * 
  32.  *
  33.  */
  34.  
  35. /*
  36.  * Copyright (c) 1982,1985,1986,1988 Regents of the University of California.
  37.  * All rights reserved.
  38.  *
  39.  * Redistribution and use in source and binary forms, with or without
  40.  * modification, are permitted provided that the following conditions
  41.  * are met:
  42.  * 1. Redistributions of source code must retain the above copyright
  43.  *    notice, this list of conditions and the following disclaimer.
  44.  * 2. Redistributions in binary form must reproduce the above copyright
  45.  *    notice, this list of conditions and the following disclaimer in the
  46.  *    documentation and/or other materials provided with the distribution.
  47.  * 3. All advertising materials mentioning features or use of this software
  48.  *    must display the following acknowledgement:
  49.  *    This product includes software developed by the University of
  50.  *    California, Berkeley and its contributors.
  51.  * 4. Neither the name of the University nor the names of its contributors
  52.  *    may be used to endorse or promote products derived from this software
  53.  *    without specific prior written permission.
  54.  *
  55.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  56.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  57.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  58.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  59.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  60.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  61.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  62.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  63.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  64.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  65.  * SUCH DAMAGE.
  66.  *
  67.  *    @(#)socket.h    7.13 (Berkeley) 4/20/91
  68.  */
  69.  
  70. /*
  71.  * Definitions related to sockets: types, address families, options.
  72.  */
  73.  
  74. /*
  75.  * Types
  76.  */
  77. #define    SOCK_STREAM    1        /* stream socket */
  78. #define    SOCK_DGRAM    2        /* datagram socket */
  79. #define    SOCK_RAW    3        /* raw-protocol interface */
  80. #define    SOCK_RDM    4        /* reliably-delivered message */
  81. #define    SOCK_SEQPACKET    5        /* sequenced packet stream */
  82.  
  83. /*
  84.  * Option flags per-socket.
  85.  */
  86. #define    SO_DEBUG    0x0001        /* turn on debugging info recording */
  87. #define    SO_ACCEPTCONN    0x0002        /* socket has had listen() */
  88. #define    SO_REUSEADDR    0x0004        /* allow local address reuse */
  89. #define    SO_KEEPALIVE    0x0008        /* keep connections alive */
  90. #define    SO_DONTROUTE    0x0010        /* just use interface addresses */
  91. #define    SO_BROADCAST    0x0020        /* permit sending of broadcast msgs */
  92. #define    SO_USELOOPBACK    0x0040        /* bypass hardware when possible */
  93. #define    SO_LINGER    0x0080        /* linger on close if data present */
  94. #define    SO_OOBINLINE    0x0100        /* leave received OOB data in line */
  95.  
  96. /*
  97.  * Additional options, not kept in so_options.
  98.  */
  99. #define SO_SNDBUF    0x1001        /* send buffer size */
  100. #define SO_RCVBUF    0x1002        /* receive buffer size */
  101. #define SO_SNDLOWAT    0x1003        /* send low-water mark */
  102. #define SO_RCVLOWAT    0x1004        /* receive low-water mark */
  103. #define SO_SNDTIMEO    0x1005        /* send timeout */
  104. #define SO_RCVTIMEO    0x1006        /* receive timeout */
  105. #define    SO_ERROR    0x1007        /* get error status and clear */
  106. #define    SO_TYPE        0x1008        /* get socket type */
  107.  
  108. /*
  109.  * Structure used for manipulating linger option.
  110.  */
  111. struct    linger {
  112.     int    l_onoff;        /* option on/off */
  113.     int    l_linger;        /* linger time */
  114. };
  115.  
  116. /*
  117.  * Level number for (get/set)sockopt() to apply to socket itself.
  118.  */
  119. #define    SOL_SOCKET    0xffff        /* options for socket level */
  120.  
  121. /*
  122.  * Address families.
  123.  */
  124. #define    AF_UNSPEC    0        /* unspecified */
  125. #define    AF_UNIX        1        /* local to host (pipes, portals) */
  126. #define    AF_INET        2        /* internetwork: UDP, TCP, etc. */
  127. #define    AF_IMPLINK    3        /* arpanet imp addresses */
  128. #define    AF_PUP        4        /* pup protocols: e.g. BSP */
  129. #define    AF_CHAOS    5        /* mit CHAOS protocols */
  130. #define    AF_NS        6        /* XEROX NS protocols */
  131. #define    AF_ISO        7        /* ISO protocols */
  132. #define    AF_OSI        AF_ISO
  133. #define    AF_ECMA        8        /* european computer manufacturers */
  134. #define    AF_DATAKIT    9        /* datakit protocols */
  135. #define    AF_CCITT    10        /* CCITT protocols, X.25 etc */
  136. #define    AF_SNA        11        /* IBM SNA */
  137. #define AF_DECnet    12        /* DECnet */
  138. #define AF_DLI        13        /* DEC Direct data link interface */
  139. #define AF_LAT        14        /* LAT */
  140. #define    AF_HYLINK    15        /* NSC Hyperchannel */
  141. #define    AF_APPLETALK    16        /* Apple Talk */
  142. #define    AF_ROUTE    17        /* Internal Routing Protocol */
  143. #define    AF_LINK        18        /* Link layer interface */
  144. #define    pseudo_AF_XTP    19        /* eXpress Transfer Protocol (no AF) */
  145.  
  146. #define    AF_MAX        20
  147.  
  148. /*
  149.  * Structure used by kernel to store most
  150.  * addresses.
  151.  */
  152. struct sockaddr {
  153.     u_char    sa_len;            /* total length */
  154.     u_char    sa_family;        /* address family */
  155.     char    sa_data[14];        /* actually longer; address value */
  156. };
  157.  
  158. /*
  159.  * Structure used by kernel to pass protocol
  160.  * information in raw sockets.
  161.  */
  162. struct sockproto {
  163.     u_short    sp_family;        /* address family */
  164.     u_short    sp_protocol;        /* protocol */
  165. };
  166.  
  167. /*
  168.  * Protocol families, same as address families for now.
  169.  */
  170. #define    PF_UNSPEC    AF_UNSPEC
  171. #define    PF_UNIX        AF_UNIX
  172. #define    PF_INET        AF_INET
  173. #define    PF_IMPLINK    AF_IMPLINK
  174. #define    PF_PUP        AF_PUP
  175. #define    PF_CHAOS    AF_CHAOS
  176. #define    PF_NS        AF_NS
  177. #define    PF_ISO        AF_ISO
  178. #define    PF_OSI        AF_ISO
  179. #define    PF_ECMA        AF_ECMA
  180. #define    PF_DATAKIT    AF_DATAKIT
  181. #define    PF_CCITT    AF_CCITT
  182. #define    PF_SNA        AF_SNA
  183. #define PF_DECnet    AF_DECnet
  184. #define PF_DLI        AF_DLI
  185. #define PF_LAT        AF_LAT
  186. #define    PF_HYLINK    AF_HYLINK
  187. #define    PF_APPLETALK    AF_APPLETALK
  188. #define    PF_ROUTE    AF_ROUTE
  189. #define    PF_LINK        AF_LINK
  190. #define    PF_XTP        pseudo_AF_XTP    /* really just proto family, no AF */
  191.  
  192. #define    PF_MAX        AF_MAX
  193.  
  194. /*
  195.  * Maximum queue length specifiable by listen.
  196.  */
  197. #define    SOMAXCONN    5
  198.  
  199. /*
  200.  * Message header for recvmsg and sendmsg calls.
  201.  * Used value-result for recvmsg, value only for sendmsg.
  202.  */
  203. struct msghdr {
  204.     caddr_t    msg_name;        /* optional address */
  205.     u_int    msg_namelen;        /* size of address */
  206.     struct    iovec *msg_iov;        /* scatter/gather array */
  207.     u_int    msg_iovlen;        /* # elements in msg_iov */
  208.     caddr_t    msg_control;        /* ancillary data, see below */
  209.     u_int    msg_controllen;        /* ancillary data buffer len */
  210.     int    msg_flags;        /* flags on received message */
  211. };
  212.  
  213. #define    MSG_OOB        0x1        /* process out-of-band data */
  214. #define    MSG_PEEK    0x2        /* peek at incoming message */
  215. #define    MSG_DONTROUTE    0x4        /* send without using routing tables */
  216. #define    MSG_EOR        0x8        /* data completes record */
  217. #define    MSG_TRUNC    0x10        /* data discarded before delivery */
  218. #define    MSG_CTRUNC    0x20        /* control data lost before delivery */
  219. #define    MSG_WAITALL    0x40        /* wait for full request or error */
  220.  
  221. /*
  222.  * Header for ancillary data objects in msg_control buffer.
  223.  * Used for additional information with/about a datagram
  224.  * not expressible by flags.  The format is a sequence
  225.  * of message elements headed by cmsghdr structures.
  226.  */
  227. struct cmsghdr {
  228.     u_int    cmsg_len;        /* data byte count, including hdr */
  229.     int    cmsg_level;        /* originating protocol */
  230.     int    cmsg_type;        /* protocol-specific type */
  231. /* followed by    u_char  cmsg_data[]; */
  232. };
  233.  
  234. /* given pointer to struct adatahdr, return pointer to data */
  235. #define    CMSG_DATA(cmsg)        ((u_char *)((cmsg) + 1))
  236.  
  237. /* given pointer to struct adatahdr, return pointer to next adatahdr */
  238. #define    CMSG_NXTHDR(mhdr, cmsg)    \
  239.     (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
  240.         (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
  241.         (struct cmsghdr *)NULL : \
  242.         (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
  243.  
  244. #define    CMSG_FIRSTHDR(mhdr)    ((struct cmsghdr *)(mhdr)->msg_control)
  245.  
  246. /* "Socket"-level control message types: */
  247. #define    SCM_RIGHTS    0x01        /* access rights (array of int) */
  248.  
  249. /*
  250.  * 4.3 compat sockaddr, move to compat file later
  251.  */
  252. struct osockaddr {
  253.     u_short    sa_family;        /* address family */
  254.     char    sa_data[14];        /* up to 14 bytes of direct address */
  255. };
  256.  
  257. /*
  258.  * 4.3-compat message header (move to compat file later).
  259.  */
  260. struct omsghdr {
  261.     caddr_t    msg_name;        /* optional address */
  262.     int    msg_namelen;        /* size of address */
  263.     struct    iovec *msg_iov;        /* scatter/gather array */
  264.     int    msg_iovlen;        /* # elements in msg_iov */
  265.     caddr_t    msg_accrights;        /* access rights sent/received */
  266.     int    msg_accrightslen;
  267. };
  268.  
  269. #ifndef    KERNEL
  270.  
  271. #include <sys/cdefs.h>
  272.  
  273. __BEGIN_DECLS
  274. int    accept __P((int, struct sockaddr *, int *));
  275. int    bind __P((int, const struct sockaddr *, int));
  276. int    connect __P((int, const struct sockaddr *, int));
  277. int    getpeername __P((int, struct sockaddr *, int *));
  278. int    getsockname __P((int, struct sockaddr *, int *));
  279. int    getsockopt __P((int, int, int, void *, int *));
  280. int    listen __P((int, int));
  281. int    recv __P((int, void *, int, int));
  282. int    recvfrom __P((int, void *, int, int,
  283.         struct sockaddr *, int *));
  284. int    recvmsg __P((int, struct msghdr *, int));
  285. int    send __P((int, const void *, int, int));
  286. int    sendto __P((int, const void *, int, int, const struct sockaddr *, int));
  287. int    sendmsg __P((int, const struct msghdr *, int));
  288. int    setsockopt __P((int, int, int, const void *, int));
  289. int    shutdown __P((int, int));
  290. int    socket __P((int, int, int));
  291. int    socketpair __P((int, int, int, int *));
  292. __END_DECLS
  293.  
  294. #endif    /* !KERNEL */
  295.