home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / socket.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  8.6 KB  |  291 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef    _SYS_SOCKET_H
  11. #define    _SYS_SOCKET_H
  12.  
  13. #ident    "@(#)/usr/include/sys/socket.h.sl 1.1 4.0 12/08/90 35525 AT&T-USL"
  14.  
  15. /*
  16.  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  17.  *         PROPRIETARY NOTICE (Combined)
  18.  * 
  19.  * This source code is unpublished proprietary information
  20.  * constituting, or derived under license from AT&T's UNIX(r) System V.
  21.  * In addition, portions of such source code were derived from Berkeley
  22.  * 4.3 BSD under license from the Regents of the University of
  23.  * California.
  24.  * 
  25.  * 
  26.  * 
  27.  *         Copyright Notice 
  28.  * 
  29.  * Notice of copyright on this source code product does not indicate 
  30.  * publication.
  31.  * 
  32.  *     (c) 1986,1987,1988,1989  Sun Microsystems, Inc
  33.  *     (c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
  34.  *               All rights reserved.
  35.  *  
  36.  */
  37.  
  38. #ifndef _KERNEL
  39. #include <sys/netconfig.h>
  40. #endif
  41.  
  42. /*
  43.  * Definitions related to sockets: types, address families, options.
  44.  */
  45.  
  46. #ifndef NC_TPI_CLTS
  47. #define NC_TPI_CLTS    1        /* must agree with netconfig.h */
  48. #define NC_TPI_COTS    2        /* must agree with netconfig.h */
  49. #define NC_TPI_COTS_ORD    3        /* must agree with netconfig.h */
  50. #define    NC_TPI_RAW    4        /* must agree with netconfig.h */
  51. #endif /* !NC_TPI_CLTS */
  52.  
  53. /*
  54.  * Types
  55.  */
  56. #define    SOCK_STREAM    NC_TPI_COTS    /* stream socket */
  57. #define    SOCK_DGRAM    NC_TPI_CLTS    /* datagram socket */
  58. #define    SOCK_RAW    NC_TPI_RAW    /* raw-protocol interface */
  59. #define    SOCK_RDM    5        /* reliably-delivered message */
  60. #define    SOCK_SEQPACKET    6        /* sequenced packet stream */
  61.  
  62. /*
  63.  * Option flags per-socket.
  64.  */
  65. #define    SO_DEBUG    0x0001        /* turn on debugging info recording */
  66. #define    SO_ACCEPTCONN    0x0002        /* socket has had listen() */
  67. #define    SO_REUSEADDR    0x0004        /* allow local address reuse */
  68. #define    SO_KEEPALIVE    0x0008        /* keep connections alive */
  69. #define    SO_DONTROUTE    0x0010        /* just use interface addresses */
  70. #define    SO_BROADCAST    0x0020        /* permit sending of broadcast msgs */
  71. #define    SO_USELOOPBACK    0x0040        /* bypass hardware when possible */
  72. #define    SO_LINGER    0x0080        /* linger on close if data present */
  73. #define    SO_OOBINLINE    0x0100        /* leave received OOB data in line */
  74. #define SO_ORDREL    0x0200        /* give use orderly release */
  75. #define SO_IMASOCKET    0x0400        /* use socket semantics */
  76.  
  77. /*
  78.  * N.B.: The following definition is present only for compatibility
  79.  * with release 3.0.  It will disappear in later releases.
  80.  */
  81. #define    SO_DONTLINGER    (~SO_LINGER)    /* ~SO_LINGER */
  82.  
  83. /*
  84.  * Additional options, not kept in so_options.
  85.  */
  86. #define    SO_SNDBUF    0x1001        /* send buffer size */
  87. #define    SO_RCVBUF    0x1002        /* receive buffer size */
  88. #define    SO_SNDLOWAT    0x1003        /* send low-water mark */
  89. #define    SO_RCVLOWAT    0x1004        /* receive low-water mark */
  90. #define    SO_SNDTIMEO    0x1005        /* send timeout */
  91. #define    SO_RCVTIMEO    0x1006        /* receive timeout */
  92. #define    SO_ERROR    0x1007        /* get error status and clear */
  93. #define    SO_TYPE        0x1008        /* get socket type */
  94. #define SO_PROTOTYPE    0x1009        /* get/set protocol type */
  95.  
  96. /*
  97.  * Structure used for manipulating linger option.
  98.  */
  99. struct    linger {
  100.     int    l_onoff;        /* option on/off */
  101.     int    l_linger;        /* linger time */
  102. };
  103.  
  104. /*
  105.  * Level number for (get/set)sockopt() to apply to socket itself.
  106.  */
  107. #define    SOL_SOCKET    0xffff        /* options for socket level */
  108.  
  109. /*
  110.  * Address families.
  111.  */
  112. #define AF_UNSPEC       0        /* unspecified */
  113. #define AF_UNIX         1        /* local to host (pipes, portals) */
  114. #define AF_INET         2        /* internetwork: UDP, TCP, etc. */
  115. #define AF_IMPLINK      3        /* arpanet imp addresses */
  116. #define AF_PUP          4        /* pup protocols: e.g. BSP */
  117. #define AF_CHAOS        5        /* mit CHAOS protocols */
  118. #define AF_NS           6        /* XEROX NS protocols */
  119. #define AF_NBS          7        /* nbs protocols */
  120. #define AF_ECMA         8        /* european computer manufacturers */
  121. #define AF_DATAKIT      9        /* datakit protocols */
  122. #define AF_CCITT        10        /* CCITT protocols, X.25 etc */
  123. #define AF_SNA          11        /* IBM SNA */
  124. #define AF_DECnet       12        /* DECnet */
  125. #define AF_DLI          13        /* Direct data link interface */
  126. #define AF_LAT          14        /* LAT */
  127. #define AF_HYLINK       15        /* NSC Hyperchannel */
  128. #define AF_APPLETALK    16        /* Apple Talk */
  129. #define AF_NIT          17        /* Network Interface Tap */
  130. #define AF_802          18        /* IEEE 802.2, also ISO 8802 */
  131. #define AF_OSI          19        /* umbrella for all families used
  132. #define AF_X25          20        /* CCITT X.25 in particular */
  133. #define AF_OSINET       21        /* AFI = 47, IDI = 4 */
  134. #define AF_GOSIP        22        /* U.S. Government OSI */
  135. #define    AF_MAX        22
  136.  
  137. /*
  138.  * Structure used by kernel to store most
  139.  * addresses.
  140.  */
  141. struct sockaddr {
  142.     u_short    sa_family;        /* address family */
  143.     char    sa_data[14];        /* up to 14 bytes of direct address */
  144. };
  145.  
  146. /*
  147.  * Structure used by kernel to pass protocol
  148.  * information in raw sockets.
  149.  */
  150. struct sockproto {
  151.     u_short    sp_family;        /* address family */
  152.     u_short    sp_protocol;        /* protocol */
  153. };
  154.  
  155. /*
  156.  * Protocol families, same as address families for now.
  157.  */
  158. #define    PF_UNSPEC    AF_UNSPEC
  159. #define    PF_UNIX        AF_UNIX
  160. #define    PF_INET        AF_INET
  161. #define    PF_IMPLINK    AF_IMPLINK
  162. #define    PF_PUP        AF_PUP
  163. #define    PF_CHAOS    AF_CHAOS
  164. #define    PF_NS        AF_NS
  165. #define    PF_NBS        AF_NBS
  166. #define    PF_ECMA        AF_ECMA
  167. #define    PF_DATAKIT    AF_DATAKIT
  168. #define    PF_CCITT    AF_CCITT
  169. #define    PF_SNA        AF_SNA
  170. #define    PF_DECnet    AF_DECnet
  171. #define    PF_DLI        AF_DLI
  172. #define    PF_LAT        AF_LAT
  173. #define    PF_HYLINK    AF_HYLINK
  174. #define    PF_APPLETALK    AF_APPLETALK
  175. #define    PF_NIT        AF_NIT
  176. #define    PF_802        AF_802
  177. #define    PF_OSI        AF_OSI
  178. #define    PF_X25        AF_X25
  179. #define    PF_OSINET    AF_OSINET
  180. #define    PF_GOSIP    AF_GOSIP
  181.  
  182. #define    PF_MAX        AF_MAX
  183.  
  184. /*
  185.  * Maximum queue length specifiable by listen.
  186.  */
  187. #define    SOMAXCONN    5
  188.  
  189. /*
  190.  * Message header for recvmsg and sendmsg calls.
  191.  */
  192. struct msghdr {
  193.     caddr_t    msg_name;        /* optional address */
  194.     int    msg_namelen;        /* size of address */
  195.     struct    iovec *msg_iov;        /* scatter/gather array */
  196.     int    msg_iovlen;        /* # elements in msg_iov */
  197.     caddr_t    msg_accrights;        /* access rights sent/received */
  198.     int    msg_accrightslen;
  199. };
  200.  
  201. #define    MSG_OOB        0x1        /* process out-of-band data */
  202. #define    MSG_PEEK    0x2        /* peek at incoming message */
  203. #define    MSG_DONTROUTE    0x4        /* send without using routing tables */
  204.  
  205. #define    MSG_MAXIOVLEN    16
  206.  
  207. /*
  208.  * An option specification consists of an opthdr, followed by the value of
  209.  * the option.  An options buffer contains one or more options.  The len
  210.  * field of opthdr specifies the length of the option value in bytes.  This
  211.  * length must be a multiple of sizeof(long) (use OPTLEN macro).
  212.  */
  213.  
  214. struct opthdr {
  215.     long            level;    /* protocol level affected */
  216.     long            name;    /* option to modify */
  217.     long            len;    /* length of option value */
  218. };
  219.  
  220. #define OPTLEN(x) ((((x) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
  221. #define OPTVAL(opt) ((char *)(opt + 1))
  222.  
  223. /*
  224.  * the optdefault structure is used for internal tables of option default
  225.  * values.
  226.  */
  227. struct optdefault {
  228.     int             optname;/* the option */
  229.     char           *val;    /* ptr to default value */
  230.     int             len;    /* length of value */
  231. };
  232.  
  233. /*
  234.  * the opproc structure is used to build tables of options processing
  235.  * functions for dooptions().
  236.  */
  237. struct opproc {
  238.     int             level;    /* options level this function handles */
  239.     int             (*func) ();    /* the function */
  240. };
  241.  
  242. /*
  243.  * This structure is used to encode pseudo system calls
  244.  */
  245. struct socksysreq {
  246.     int             args[7];
  247. };
  248.  
  249. /*
  250.  * This structure is used for adding new protocols to the list supported by
  251.  * sockets.
  252.  */
  253.  
  254. struct socknewproto {
  255.     int             family;    /* address family (AF_INET, etc.) */
  256.     int             type;    /* protocol type (SOCK_STREAM, etc.) */
  257.     int             proto;    /* per family proto number */
  258.     dev_t           dev;    /* major/minor to use (must be a clone) */
  259.     int             flags;    /* protosw flags */
  260. };
  261.  
  262.  
  263. /* defines for user/kernel interface */
  264.  
  265. #if (INTEL == 31) || (ATT == 31)
  266. #define SOCKETSYS    88    /* MUST BE CHANGED DEPENDING ON OS/SYSENT.C!! */
  267. #else
  268. #define SOCKETSYS    83    /* MUST BE CHANGED DEPENDING ON OS/SYSENT.C!! */
  269. #endif
  270.  
  271. #define  SO_ACCEPT    1
  272. #define  SO_BIND    2
  273. #define  SO_CONNECT    3
  274. #define  SO_GETPEERNAME    4
  275. #define  SO_GETSOCKNAME    5
  276. #define  SO_GETSOCKOPT    6
  277. #define  SO_LISTEN    7
  278. #define  SO_RECV    8
  279. #define  SO_RECVFROM    9
  280. #define  SO_SEND    10
  281. #define  SO_SENDTO    11
  282. #define  SO_SETSOCKOPT    12
  283. #define  SO_SHUTDOWN    13
  284. #define  SO_SOCKET    14
  285. #define  SO_SOCKPOLL    15
  286. #define  SO_GETIPDOMAIN    16
  287. #define  SO_SETIPDOMAIN    17
  288. #define  SO_ADJTIME    18
  289.  
  290. #endif    /* _SYS_SOCKET_H */
  291.