home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / detk45he.zip / sys / socket.h < prev    next >
Text File  |  1999-05-11  |  18KB  |  427 lines

  1. /*
  2.  * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
  3.  *      The Regents of the University of California.  All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *      This product includes software developed by the University of
  16.  *      California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *      @(#)socket.h    8.6 (Berkeley) 5/3/95
  34.  */
  35.  
  36. #ifndef _SYS_SOCKET_H_
  37. #define _SYS_SOCKET_H_
  38.  
  39. #ifdef TCPV40HDRS
  40. #include <stack16\sys\socket.h>
  41. #else
  42. /*
  43.  * Definitions related to sockets: types, address families, options.
  44.  */
  45.  
  46. /*
  47.  * Types
  48.  */
  49. #define SOCK_STREAM     1               /* stream socket */
  50. #define SOCK_DGRAM      2               /* datagram socket */
  51. #define SOCK_RAW        3               /* raw-protocol interface */
  52. #define SOCK_RDM        4               /* reliably-delivered message */
  53. #define SOCK_SEQPACKET  5               /* sequenced packet stream */
  54.  
  55. /*
  56.  * Option flags per-socket.
  57.  */
  58. #define SO_DEBUG        0x0001          /* turn on debugging info recording */
  59. #define SO_ACCEPTCONN   0x0002          /* socket has had listen() */
  60. #define SO_REUSEADDR    0x0004          /* allow local address reuse */
  61. #define SO_KEEPALIVE    0x0008          /* keep connections alive */
  62. #define SO_DONTROUTE    0x0010          /* just use interface addresses */
  63. #define SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */
  64. #define SO_USELOOPBACK  0x0040          /* bypass hardware when possible */
  65. #define SO_LINGER       0x0080          /* linger on close if data present */
  66. #define SO_OOBINLINE    0x0100          /* leave received OOB data in line */
  67. #define SO_L_BROADCAST  0x0200          /* limited broadcast sent on all IFs*/
  68. #define SO_RCV_SHUTDOWN 0x0400          /* set if shut down called for rcv */
  69. #define SO_SND_SHUTDOWN 0x0800          /* set if shutdown called for send */
  70. #define SO_REUSEPORT    0x1000          /* allow local address & port reuse */
  71. #define SO_TTCP         0x2000          /* allow t/tcp on socket */
  72.  
  73. /*
  74.  * Additional options, not kept in so_options.
  75.  */
  76. #define SO_SNDBUF       0x1001          /* send buffer size */
  77. #define SO_RCVBUF       0x1002          /* receive buffer size */
  78. #define SO_SNDLOWAT     0x1003          /* send low-water mark */
  79. #define SO_RCVLOWAT     0x1004          /* receive low-water mark */
  80. #define SO_SNDTIMEO     0x1005          /* send timeout */
  81. #define SO_RCVTIMEO     0x1006          /* receive timeout */
  82. #define SO_ERROR        0x1007          /* get error status and clear */
  83. #define SO_TYPE         0x1008          /* get socket type */
  84. #define SO_OPTIONS      0x1010          /* get socket options */
  85.  
  86. /*
  87.  * Structure used for manipulating linger option.
  88.  */
  89. struct  linger {
  90.         long_int l_onoff;               /* option on/off */
  91.         long_int l_linger;              /* linger time in seconds */
  92. };
  93.  
  94. /*
  95.  * Level number for (get/set)sockopt() to apply to socket itself.
  96.  */
  97. #define SOL_SOCKET      0xffff          /* options for socket level */
  98.  
  99. /*
  100.  * Address families.
  101.  */
  102. #define AF_UNSPEC       0               /* unspecified */
  103. #define AF_LOCAL        1               /* local to host (pipes, portals) */
  104. #define AF_UNIX         AF_LOCAL        /* backward compatibility */
  105. #define AF_OS2          AF_UNIX
  106. #define AF_INET         2               /* internetwork: UDP, TCP, etc. */
  107. #define AF_IMPLINK      3               /* arpanet imp addresses */
  108. #define AF_PUP          4               /* pup protocols: e.g. BSP */
  109. #define AF_CHAOS        5               /* mit CHAOS protocols */
  110. #define AF_NS           6               /* XEROX NS protocols */
  111. #define AF_ISO          7               /* ISO protocols */
  112. #define AF_OSI          AF_ISO
  113. #define AF_ECMA         8               /* european computer manufacturers */
  114. #define AF_DATAKIT      9               /* datakit protocols */
  115. #define AF_CCITT        10              /* CCITT protocols, X.25 etc */
  116. #define AF_SNA          11              /* IBM SNA */
  117. #define AF_DECnet       12              /* DECnet */
  118. #define AF_DLI          13              /* DEC Direct data link interface */
  119. #define AF_LAT          14              /* LAT */
  120. #define AF_HYLINK       15              /* NSC Hyperchannel */
  121. #define AF_APPLETALK    16              /* Apple Talk */
  122. #define AF_NB           17              /* Netbios */
  123. #define AF_NETBIOS      AF_NB
  124. #define AF_LINK         18              /* Link layer interface */
  125. #define pseudo_AF_XTP   19              /* eXpress Transfer Protocol (no AF) */
  126. #define AF_COIP         20              /* connection-oriented IP, aka ST II */
  127. #define AF_CNT          21              /* Computer Network Technology */
  128. #define pseudo_AF_RTIP  22              /* Help Identify RTIP packets */
  129. #define AF_IPX          23              /* Novell Internet Protocol */
  130. #define AF_SIP          24              /* Simple Internet Protocol */
  131. #define AF_INET6        24
  132. #define pseudo_AF_PIP   25              /* Help Identify PIP packets */
  133. #define AF_ROUTE        39              /* Internal Routing Protocol */
  134. #define AF_FWIP         40              /* firewall support */
  135. #define AF_IPSEC        41              /* IPSEC and encryption techniques */
  136. #define AF_DES          42              /* DES */
  137. #define AF_MD5          43
  138. #define AF_CDMF         44
  139.  
  140. #define AF_MAX          45
  141.  
  142. /*
  143.  * Structure used by kernel to store most
  144.  * addresses.
  145.  */
  146. struct sockaddr {
  147.         u_char  sa_len;                 /* total length */
  148.         u_char  sa_family;              /* address family */
  149.         char    sa_data[14];            /* actually longer; address value */
  150. };
  151.  
  152. /*
  153.  * Structure used by kernel to pass protocol
  154.  * information in raw sockets.
  155.  */
  156. struct sockproto {
  157.         u_short sp_family;              /* address family */
  158.         u_short sp_protocol;            /* protocol */
  159. };
  160.  
  161. /*
  162.  * Protocol families, same as address families for now.
  163.  */
  164. #define PF_UNSPEC       AF_UNSPEC
  165. #define PF_LOCAL        AF_LOCAL
  166. #define PF_UNIX         PF_LOCAL        /* backward compatibility */
  167. #define PF_OS2          PF_UNIX
  168. #define PF_INET         AF_INET
  169. #define PF_IMPLINK      AF_IMPLINK
  170. #define PF_PUP          AF_PUP
  171. #define PF_CHAOS        AF_CHAOS
  172. #define PF_NS           AF_NS
  173. #define PF_ISO          AF_ISO
  174. #define PF_OSI          AF_OSI
  175. #define PF_ECMA         AF_ECMA
  176. #define PF_DATAKIT      AF_DATAKIT
  177. #define PF_CCITT        AF_CCITT
  178. #define PF_SNA          AF_SNA
  179. #define PF_DECnet       AF_DECnet
  180. #define PF_DLI          AF_DLI
  181. #define PF_LAT          AF_LAT
  182. #define PF_HYLINK       AF_HYLINK
  183. #define PF_APPLETALK    AF_APPLETALK
  184. #define PF_NETBIOS      AF_NB
  185. #define PF_NB           AF_NB
  186. #define PF_ROUTE        AF_ROUTE
  187. #define PF_LINK         AF_LINK
  188. #define PF_XTP          pseudo_AF_XTP   /* really just proto family, no AF */
  189. #define PF_COIP         AF_COIP
  190. #define PF_CNT          AF_CNT
  191. #define PF_SIP          AF_SIP
  192. #define PF_INET6        AF_INET6
  193. #define PF_IPX          AF_IPX          /* same format as AF_NS */
  194. #define PF_RTIP         pseudo_AF_FTIP  /* same format as AF_INET */
  195. #define PF_PIP          pseudo_AF_PIP
  196.  
  197. #define PF_MAX          AF_MAX
  198.  
  199. /*
  200.  * Definitions for network related sysctl, CTL_NET.
  201.  *
  202.  * Second level is protocol family.
  203.  * Third level is protocol number.
  204.  *
  205.  * Further levels are defined by the individual families below.
  206.  */
  207. #define NET_MAXID       AF_MAX
  208.  
  209. #define CTL_NET_NAMES { \
  210.         { 0, 0 }, \
  211.         { "local", CTLTYPE_NODE }, \
  212.         { "inet", CTLTYPE_NODE }, \
  213.         { "implink", CTLTYPE_NODE }, \
  214.         { "pup", CTLTYPE_NODE }, \
  215.         { "chaos", CTLTYPE_NODE }, \
  216.         { "xerox_ns", CTLTYPE_NODE }, \
  217.         { "iso", CTLTYPE_NODE }, \
  218.         { "emca", CTLTYPE_NODE }, \
  219.         { "datakit", CTLTYPE_NODE }, \
  220.         { "ccitt", CTLTYPE_NODE }, \
  221.         { "ibm_sna", CTLTYPE_NODE }, \
  222.         { "decnet", CTLTYPE_NODE }, \
  223.         { "dec_dli", CTLTYPE_NODE }, \
  224.         { "lat", CTLTYPE_NODE }, \
  225.         { "hylink", CTLTYPE_NODE }, \
  226.         { "appletalk", CTLTYPE_NODE }, \
  227.         { "netbios", CTLTYPE_NODE }, \
  228.         { "route", CTLTYPE_NODE }, \
  229.         { "link_layer", CTLTYPE_NODE }, \
  230.         { "xtp", CTLTYPE_NODE }, \
  231.         { "coip", CTLTYPE_NODE }, \
  232.         { "cnt", CTLTYPE_NODE }, \
  233.         { "rtip", CTLTYPE_NODE }, \
  234.         { "ipx", CTLTYPE_NODE }, \
  235.         { "sip", CTLTYPE_NODE }, \
  236.         { "pip", CTLTYPE_NODE }, \
  237. }
  238.  
  239. /*
  240.  * PF_ROUTE - Routing table
  241.  *
  242.  * Three additional levels are defined:
  243.  *      Fourth: address family, 0 is wildcard
  244.  *      Fifth: type of info, defined below
  245.  *      Sixth: flag(s) to mask with for NET_RT_FLAGS
  246.  */
  247. #define NET_RT_DUMP     1               /* dump; may limit to a.f. */
  248. #define NET_RT_FLAGS    2               /* by flags, e.g. RESOLVING */
  249. #define NET_RT_IFLIST   3               /* survey interface list */
  250. #define NET_RT_MAXID    4
  251.  
  252. #define CTL_NET_RT_NAMES { \
  253.         { 0, 0 }, \
  254.         { "dump", CTLTYPE_STRUCT }, \
  255.         { "flags", CTLTYPE_STRUCT }, \
  256.         { "iflist", CTLTYPE_STRUCT }, \
  257. }
  258.  
  259. /*
  260.  * Maximum queue length specifiable by listen.
  261.  */
  262. #define SOMAXCONN       1024
  263.  
  264. /*
  265.  * Message header for recvmsg and sendmsg calls.
  266.  * Used value-result for recvmsg, value only for sendmsg.
  267.  */
  268. struct msghdr {
  269.         caddr_t msg_name;               /* optional address */
  270.         u_int   msg_namelen;            /* size of address */
  271.         struct  iovec *msg_iov;         /* scatter/gather array */
  272.         u_int   msg_iovlen;             /* # elements in msg_iov */
  273.         caddr_t msg_control;            /* ancillary data, see below */
  274.         u_int   msg_controllen;         /* ancillary data buffer len */
  275.         long_int msg_flags;             /* flags on received message */
  276. };
  277.  
  278. #define MSG_OOB         0x1             /* process out-of-band data */
  279. #define MSG_PEEK        0x2             /* peek at incoming message */
  280. #define MSG_DONTROUTE   0x4             /* send without using routing tables */
  281. #define MSG_FULLREAD    0x8             /* send without using routing tables */
  282. #define MSG_EOR         0x10            /* data completes record */
  283. #define MSG_TRUNC       0x20            /* data discarded before delivery */
  284. #define MSG_CTRUNC      0x40            /* control data lost before delivery */
  285. #define MSG_WAITALL     0x80            /* wait for full request or error */
  286. #define MSG_DONTWAIT    0x100           /* this message should be nonblocking */
  287. #ifdef TTCP
  288. #define MSG_EOF         0x200
  289. #endif
  290. #define MSG_MAPIO       0x400           /* mem mapped io */
  291. #define MSG_CLOSE       0x800           /* close connection after succesful send_file */
  292.  
  293. /*
  294.  * Header for ancillary data objects in msg_control buffer.
  295.  * Used for additional information with/about a datagram
  296.  * not expressible by flags.  The format is a sequence
  297.  * of message elements headed by cmsghdr structures.
  298.  */
  299. struct cmsghdr {
  300.         u_int   cmsg_len;               /* data byte count, including hdr */
  301.         int     cmsg_level;             /* originating protocol */
  302.         int     cmsg_type;              /* protocol-specific type */
  303. /* followed by  u_char  cmsg_data[]; */
  304. };
  305.  
  306. /* given pointer to struct cmsghdr, return pointer to data */
  307. #define CMSG_DATA(cmsg)         ((u_char *)((cmsg) + 1))
  308.  
  309. /* given pointer to struct cmsghdr, return pointer to next cmsghdr */
  310. #define CMSG_NXTHDR(mhdr, cmsg) \
  311.         (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
  312.             (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
  313.             (struct cmsghdr *)NULL : \
  314.             (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
  315.  
  316. #define CMSG_FIRSTHDR(mhdr)     ((struct cmsghdr *)(mhdr)->msg_control)
  317.  
  318. /* "Socket"-level control message types: */
  319. #define SCM_RIGHTS      0x01            /* access rights (array of int) */
  320.  
  321. /*
  322.  * 4.3 compat sockaddr, move to compat file later
  323.  */
  324. struct osockaddr {
  325.         u_short sa_family;              /* address family */
  326.         char    sa_data[14];            /* up to 14 bytes of direct address */
  327. };
  328.  
  329. /*
  330.  * 4.3-compat message header (move to compat file later).
  331.  */
  332. struct omsghdr {
  333.         caddr_t msg_name;               /* optional address */
  334.         int     msg_namelen;            /* size of address */
  335.         struct  iovec *msg_iov;         /* scatter/gather array */
  336.         int     msg_iovlen;             /* # elements in msg_iov */
  337.         caddr_t msg_accrights;          /* access rights sent/received */
  338.         int     msg_accrightslen;
  339. };
  340.  
  341. /*
  342.  * send_file parameter structure
  343.  */
  344. struct sf_parms {
  345.         void   *header_data;      /* ptr to header data */
  346.         size_t header_length;     /* size of header data */
  347.         int    file_handle;       /* file handle to send from */
  348.         size_t file_size;         /* size of file */
  349.         int    file_offset;       /* byte offset in file to send from */
  350.         size_t file_bytes;        /* bytes of file to be sent */
  351.         void   *trailer_data;     /* ptr to trailer data */
  352.         size_t trailer_length;    /* size of trailer data */
  353.         size_t bytes_sent;        /* bytes sent in this send_file call */
  354. };
  355.  
  356. #ifndef KERNEL
  357.  
  358. #include <sys/cdefs.h>
  359.  
  360. __BEGIN_DECLS
  361. int _System accept __TCPPROTO((int, struct sockaddr *, int *));
  362. int _System accept_and_recv __TCPPROTO((long, long*, struct sockaddr *, long*, struct sockaddr*, long*, caddr_t, size_t));
  363. int _System bind __TCPPROTO((int, const struct sockaddr *, int));
  364. int _System connect __TCPPROTO((int, const struct sockaddr *, int));
  365. int _System getpeername __TCPPROTO((int, struct sockaddr *, int *));
  366. int _System getsockname __TCPPROTO((int, struct sockaddr *, int *));
  367. int _System getsockopt __TCPPROTO((int, int, int, void *, int *));
  368. int _System listen __TCPPROTO((int, int));
  369. ssize_t _System recv __TCPPROTO((int, void *, size_t, int));
  370. ssize_t _System recvfrom __TCPPROTO((int, void *, size_t, int, struct sockaddr *, int *));
  371. ssize_t _System recvmsg __TCPPROTO((int, struct msghdr *, int));
  372. ssize_t _System send __TCPPROTO((int, const void *, size_t, int));
  373. ssize_t _System sendto __TCPPROTO((int, const void *, size_t, int, const struct sockaddr *, int));
  374. ssize_t _System sendmsg __TCPPROTO((int, const struct msghdr *, int));
  375. ssize_t _System send_file __TCPPROTO((int *, struct sf_parms *, int ));
  376. int _System setsockopt __TCPPROTO((int, int, int, const void *, int));
  377. int _System shutdown __TCPPROTO((int, int));
  378. int _System socket __TCPPROTO((int, int, int));
  379. int _System socketpair __TCPPROTO((int, int, int, int *));
  380.  
  381. /* OS/2 additions */
  382. int _System sock_init __TCPPROTO((void));
  383. int _System sock_errno __TCPPROTO((void));
  384. void _System psock_errno __TCPPROTO((const char *));
  385. char * _System sock_strerror __TCPPROTO((int));
  386. int _System soabort __TCPPROTO((int));
  387. int _System so_cancel __TCPPROTO((int));
  388. int _System getinetversion __TCPPROTO((char *));
  389. void _System addsockettolist __TCPPROTO((int));
  390. int _System removesocketfromlist __TCPPROTO((int));
  391. /*int _System removesocketfromlist __TCPPROTO((long *));*/  /*changed on 09-30-98 for corresponding change in sockets.c file*/
  392.  
  393. /* SOCKS additions */
  394. int _System Raccept __TCPPROTO((int, struct sockaddr *, int *));
  395. int _System Rbind __TCPPROTO((int, struct sockaddr *, int, struct sockaddr *));
  396. int _System Rconnect __TCPPROTO((int, const struct sockaddr *, int));
  397. int _System Rgetsockname __TCPPROTO((int, struct sockaddr *, int *));
  398. int _System Rlisten __TCPPROTO((int, int));
  399. __END_DECLS
  400.  
  401.  
  402. /* more OS/2 stuff */
  403.  
  404. #define MT_FREE         0       /* should be on free list */
  405. #define MT_DATA         1       /* dynamic (data) allocation */
  406. #define MT_HEADER       2       /* packet header */
  407. #define MT_SOCKET       3       /* socket structure */
  408. #define MT_PCB          4       /* protocol control block */
  409. #define MT_RTABLE       5       /* routing tables */
  410. #define MT_HTABLE       6       /* IMP host tables */
  411. #define MT_ATABLE       7       /* address resolution tables */
  412. #define MT_SONAME       8       /* socket name */
  413. #define MT_ZOMBIE       9       /* zombie proc status */
  414. #define MT_SOOPTS       10      /* socket options */
  415. #define MT_FTABLE       11      /* fragment reassembly header */
  416. #define MT_RIGHTS       12      /* access rights */
  417. #define MT_IFADDR       13      /* interface address */
  418.  
  419. struct sostats {
  420.   short count;
  421.   short socketdata[13*MAXSOCKETS];
  422. };
  423. #endif /* !KERNEL */
  424.  
  425. #endif /* TCPV40HDRS */
  426. #endif /* !_SYS_SOCKET_H_ */
  427.