home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / tcp / amitcp / amitcp-api-22.lha / AmiTCP-2.2 / netinclude / sys / socket.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-12  |  9.7 KB  |  304 lines

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