home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcp30tkt.zip / PGMG1.ZIP / INCLUDE / SYS / SOCKET.H < prev    next >
Text File  |  1995-12-04  |  8KB  |  213 lines

  1. #ifndef __SOCKET_32H
  2. #define __SOCKET_32H
  3.  
  4. /*
  5.  * Copyright (c) 1982, 1985, 1986 Regents of the University of California.
  6.  * All rights reserved.
  7.  *
  8.  * Redistribution and use in source and binary forms are permitted
  9.  * provided that this notice is preserved and that due credit is given
  10.  * to the University of California at Berkeley. The name of the University
  11.  * may not be used to endorse or promote products derived from this
  12.  * software without specific prior written permission. This software
  13.  * is provided ``as is'' without express or implied warranty.
  14.  *
  15.  *      @(#)socket.h    7.2 (Berkeley) 12/30/87
  16.  */
  17.  
  18. /*
  19.  * Definitions related to sockets: types, address families, options.
  20.  */
  21.  
  22. /*
  23.  * Types
  24.  */
  25. #define SOCK_STREAM     1               /* stream socket */
  26. #define SOCK_DGRAM      2               /* datagram socket */
  27. #define SOCK_RAW        3               /* raw-protocol interface */
  28. #define SOCK_RDM        4               /* reliably-delivered message */
  29. #define SOCK_SEQPACKET  5               /* sequenced packet stream */
  30.  
  31. /*
  32.  * Option flags per-socket.
  33.  */
  34. #define SO_DEBUG        0x0001          /* turn on debugging info recording */
  35. #define SO_ACCEPTCONN   0x0002          /* socket has had listen() */
  36. #define SO_REUSEADDR    0x0004          /* allow local address reuse */
  37. #define SO_KEEPALIVE    0x0008          /* keep connections alive */
  38. #define SO_DONTROUTE    0x0010          /* just use interface addresses */
  39. #define SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */
  40. #define SO_USELOOPBACK  0x0040          /* bypass hardware when possible */
  41. #define SO_LINGER       0x0080          /* linger on close if data present */
  42. #define SO_OOBINLINE    0x0100          /* leave received OOB data in line */
  43.  
  44. /*
  45.  * Additional options, not kept in so_options.
  46.  */
  47. #define SO_SNDBUF       0x1001          /* send buffer size */
  48. #define SO_RCVBUF       0x1002          /* receive buffer size */
  49. #define SO_SNDLOWAT     0x1003          /* send low-water mark */
  50. #define SO_RCVLOWAT     0x1004          /* receive low-water mark */
  51. #define SO_SNDTIMEO     0x1005          /* send timeout */
  52. #define SO_RCVTIMEO     0x1006          /* receive timeout */
  53. #define SO_ERROR        0x1007          /* get error status and clear */
  54. #define SO_TYPE         0x1008          /* get socket type */
  55.  
  56. /*
  57.  * Structure used for manipulating linger option.
  58.  */
  59. struct  linger {
  60.         int     l_onoff;                /* option on/off */
  61.         int     l_linger;               /* linger time */
  62. };
  63.  
  64. /*
  65.  * Level number for (get/set)sockopt() to apply to socket itself.
  66.  */
  67. #define SOL_SOCKET      0xffff          /* options for socket level */
  68.  
  69. /*
  70.  * Address families.
  71.  */
  72. #define AF_UNSPEC       0               /* unspecified */
  73. #define AF_UNIX         1               /* local to host (pipes, portals) */
  74. #define AF_INET         2               /* internetwork: UDP, TCP, etc. */
  75. #define AF_IMPLINK      3               /* arpanet imp addresses */
  76. #define AF_PUP          4               /* pup protocols: e.g. BSP */
  77. #define AF_CHAOS        5               /* mit CHAOS protocols */
  78. #define AF_NS           6               /* XEROX NS protocols */
  79. #define AF_NBS          7               /* nbs protocols */
  80. #define AF_ECMA         8               /* european computer manufacturers */
  81. #define AF_DATAKIT      9               /* datakit protocols */
  82. #define AF_CCITT        10              /* CCITT protocols, X.25 etc */
  83. #define AF_SNA          11              /* IBM SNA */
  84. #define AF_DECnet       12              /* DECnet */
  85. #define AF_DLI          13              /* Direct data link interface */
  86. #define AF_LAT          14              /* LAT */
  87. #define AF_HYLINK       15              /* NSC Hyperchannel */
  88. #define AF_APPLETALK    16              /* Apple Talk */
  89.  
  90. #define AF_OS2          AF_UNIX
  91.  
  92. #define AF_NB           17              /* Netbios */
  93. #define AF_NETBIOS      AF_NB
  94.  
  95. #define AF_MAX          18
  96.  
  97.  
  98. /*
  99.  * Structure used by kernel to store most
  100.  * addresses.
  101.  */
  102. struct sockaddr {
  103.         unsigned short sa_family;              /* address family */
  104.         char    sa_data[14];            /* up to 14 bytes of direct address */
  105. };
  106.  
  107. /*
  108.  * Structure used by kernel to pass protocol
  109.  * information in raw sockets.
  110.  */
  111. struct sockproto {
  112.         unsigned short sp_family;              /* address family */
  113.         unsigned short sp_protocol;            /* protocol */
  114. };
  115.  
  116. /*
  117.  * Protocol families, same as address families for now.
  118.  */
  119. #define PF_UNSPEC       AF_UNSPEC
  120. #define PF_UNIX         AF_UNIX
  121. #define PF_INET         AF_INET
  122. #define PF_IMPLINK      AF_IMPLINK
  123. #define PF_PUP          AF_PUP
  124. #define PF_CHAOS        AF_CHAOS
  125. #define PF_NS           AF_NS
  126. #define PF_NBS          AF_NBS
  127. #define PF_ECMA         AF_ECMA
  128. #define PF_DATAKIT      AF_DATAKIT
  129. #define PF_CCITT        AF_CCITT
  130. #define PF_SNA          AF_SNA
  131. #define PF_DECnet       AF_DECnet
  132. #define PF_DLI          AF_DLI
  133. #define PF_LAT          AF_LAT
  134. #define PF_HYLINK       AF_HYLINK
  135. #define PF_APPLETALK    AF_APPLETALK
  136. #define PF_NETBIOS      AF_NB
  137. #define PF_NB           AF_NB
  138. #define PF_OS2          PF_UNIX
  139. #define PF_MAX          AF_MAX
  140.  
  141. /*
  142.  * Maximum queue length specifiable by listen.
  143.  */
  144. #define SOMAXCONN       5
  145.  
  146. struct iovec {
  147.         char *  iov_base;
  148.         int     iov_len;
  149. };
  150.  
  151. /*
  152.  * Message header for recvmsg and sendmsg calls.
  153.  */
  154. struct msghdr {
  155.         char * msg_name;               /* optional address */
  156.         int msg_namelen;            /* size of address */
  157.         struct  iovec *  msg_iov;         /* scatter/gather array */
  158.         int   msg_iovlen;             /* # elements in msg_iov */
  159.         char *  msg_accrights;          /* access rights sent/received */
  160.         int   msg_accrightslen;
  161. };
  162.  
  163. struct uio {
  164.         struct  iovec *uio_iov;
  165.         int     uio_iovcnt;
  166.         off_t   uio_offset;
  167.         int     uio_segflg;
  168.         int     uio_resid;
  169. };
  170. enum    uio_rw { UIO_READ, UIO_WRITE };
  171. #define FREAD  1
  172. #define FWRITE 2
  173.  
  174. #define MSG_OOB         0x1             /* process out-of-band data */
  175. #define MSG_PEEK        0x2             /* peek at incoming message */
  176. #define MSG_DONTROUTE   0x4             /* send without using routing tables */
  177. #define MSG_FULLREAD    0x8             /* send without using routing tables */
  178.  
  179. #define MSG_MAXIOVLEN   16
  180.  
  181. int _System accept( int, struct sockaddr *, int * );
  182. int _System bind( int, struct sockaddr *, int );
  183. int _System connect( int, struct sockaddr *, int );
  184. int _System gethostid(void);
  185. int _System getpeername( int, struct sockaddr *, int * );
  186. int _System getsockname( int, struct sockaddr *, int * );
  187. int _System getsockopt( int, int, int, char *, int * );
  188. int _System ioctl(int, int, char *, int);
  189. int _System listen( int, int);
  190. int _System recvmsg( int, struct msghdr * , int);
  191. int _System recv( int, char *, int, int );
  192. int _System recvfrom(int, char *, int, int, struct sockaddr *, int * );
  193. #ifndef BSD_SELECT
  194. int _System select( int *, int, int, int, long );
  195. #endif
  196. int _System send( int, char *, int, int );
  197. int _System sendmsg( int, struct msghdr * , int);
  198. int _System sendto( int, char *, int, int, struct sockaddr *, int);
  199. int _System setsockopt( int, int, int, char *, int );
  200. int _System sock_init( void );
  201. int _System sock_errno( void );
  202. void _System psock_errno( char * );
  203. int _System socket( int, int, int );
  204. int _System soclose( int );
  205. int _System soabort(int);
  206. int _System so_cancel(int);
  207. int _System readv(int, struct iovec * , int);
  208. int _System writev(int, struct iovec* , int);
  209. int _System shutdown(int, int);
  210. int _System getinetversion(char *);
  211.  
  212. #endif /* __SOCKET_32H */
  213.