
******************************************************

            PROPRIETARY PROGRAM MATERIAL

THIS MATERIAL IS PROPRIETARY TO UNISYS CORPORATION
AND IS NOT TO BE REPRODUCED, USED OR DISCLOSED EXCEPT 
IN ACCORDANCE WITH PROGRAM LICENSE OR UPON WRITTEN
AUTHORIZATION OF UNISYS CORPORATION.

COPYRIGHT  (C)  1991 Unisys CORPORATION


 *  This file is modified from usrincludesyssocket.h on 
 *  Unisys U 6000  System V  Apr 1987 
 *
 * Definitions related to sockets: types, address families, options.
 * 
 ******************************************************


include syssocompat.h

ifndef __SOCKET_H__
define __SOCKET_H__

*
 * Types
 *
define	SOCK_STREAM	1		* stream socket *
define	SOCK_DGRAM	2		* datagram socket *
*
 * Address families.
 *
define	AF_UNSPEC	0		* unspecified *
define	AF_INET		2		* internetwork: UDP, TCP, etc. *
define	AF_MAX		17

*
 * Structure used for addresses.
 *
struct sockaddr {
	u_short	sa_family;		* address family *
	char	sa_data[14];		* up to 14 bytes of direct address *
};

*
 * Protocol families, same as address families for now.
 *
define	PF_UNSPEC	AF_UNSPEC
define	PF_INET		AF_INET
define	PF_MAX		12

*
 * Maximum queue length specifiable by listen.
 *
define	SOMAXCONN	1        *only 1 connection allowed for first pass. *

define MSG_NOOP	0x00
define	MSG_NOPUSH	0x10	* CTOS TCP inhibit push on send *
define	MSG_NOBLOCK	0x20	* CTOS TCP non blocking recv *
define	MSG_TCPREQ	0x40	* CTOS TCP request received by user *
define	MSG_UDPREQ	MSG_TCPREQ
define	MSG_POSTREQ	0x80	* make sure CTOS TCP request posted *

define MAXHOSTNAMELEN 64   

* Definitios for setting and getting options *

define SOL_SOCKET	0xffff	* Options for socket level *

define UDP_MAXSEG  0x0006  * UDP Maximum segment size *


*
 * Socket State Definitions
 *
 * Bit map masks used as follows:
 *
 * |F E D C|B A 9 8|7 6 5 4|3 2 1 0|
 * |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
 *                \ \ \ \ \ \ \ \ \______ AVAILABLE
 *                 \ \ \ \ \ \ \ \_______ ALLOCATED
 *                  \ \ \ \ \ \ \________ LISTENING
 *                   \ \ \ \ \ \_________ ACCEPTING
 *                    \ \ \ \ \__________ BOUND
 *                     \ \ \ \___________ CONNECTED
 *                      \ \ \____________ TCP
 *                       \ \_____________ UDP
 *                        \______________ IOPENDING
 * The high 7 bits are not used.
 *
 *

define AVAILABLE		0x0001
define ALLOCATED		0x0002
define LISTENING		0x0004
define ACCEPTING		0x0008
define BOUND			0x0010
define CONNECTED		0x0020
define TCPSOCK			0x0040
define UDPSOCK			0x0080
define IOPENDING		0x0100


define TCPALLOC		(TCPSOCK | ALLOCATED)
define TCPBOUND		(TCPSOCK | BOUND)
define TCPLISTEN		(TCPSOCK | LISTENING)
define TCPACCEPT		(TCPSOCK | ACCEPTING)
define TCPCONNECT		(TCPSOCK | CONNECTED)
define ANYTCPSTATE		TCPSOCK
define UDPALLOC		(UDPSOCK | ALLOCATED)
define UDPBOUND		(UDPSOCK | BOUND)
define ANYUDPSTATE		UDPSOCK
define ANYSTATE		0xFFFF




********************* CTOS Socket functions ********************

typedef struct  struct_carbonitesocket{
	int ver;
	int fh;
	int state;
	int lport;
	int sig;
}CARBONITESOCKET;

int PlmFar(accept) 
	(int handle, struct sockaddr_in FARPTR client, int FARPTR clientlen);

int PlmFar(bind) 
	(int handle, struct sockaddr_in FARPTR name, int namelen);

int PlmFar(connect) 
	(int handle, struct sockaddr_in FARPTR server, int serverlen);

int PlmFar(getsockstate) 
	(int sd);

int PlmFar(listen) 
	(int handle, int backlog);

int PlmFar(recv) 
	(int handle, char FARPTR buf, int len, int flags);

int PlmFar(sclose) 
	(int sd);

int PlmFar(shutdown) 
	(int handle, int how);

int PlmFar(socket) 
	(int d, int t, int p);

int PlmFar(ssend) 
	(int handle, char FARPTR msg, int len, int flags);

int PlmFar(whatsocket) 
	(char FARPTR p);

int PlmFar(setctostcpparams)(int handle, char FARPTR node, int t,char FARPTR  buf);
int PlmFar(setctossockexch)(int handle, int ex, char FARPTR FARPTR FARPTR exptr);
int PlmFar(freezesocket)(int s, CARBONITESOCKET FARPTR cs);
int PlmFar(thawsocket)(CARBONITESOCKET FARPTR cs);
int PlmFar(sendto) (int,char FARPTR ,int,int,struct sockaddr_in FARPTR ,int);
int PlmFar(recvfrom) (int,char FARPTR,int,int,struct sockaddr_in FARPTR ,int FARPTR );
int PlmFar(setctosudpparams) (int handle, char FARPTR node, int t, int flags);
int PlmFar(setctosparams) (char FARPTR node, int flags);  
int PlmFar(getctossockparams) (int s, int level, int parname,
								   char FARPTR parvalue, int FARPTR parlen);
int PlmFar(setctossockparams) (int s, int level, int parname,
								   char FARPTR parvalue, int FARPTR parlen);

define setctostcpexchange setctossockexch
define setctosudpexchange setctossockexch



define	EWOULDBLOCK	60218u		    * Operation would block *
define	E_WOULD_BLOCK EWOULDBLOCK

define	E_NOT_SOCK  60219u	        * Socket operation on nonsocket *
define	ENOTSOCK  E_NOT_SOCK

define E_SOCK_BADS	60220u	        * socket in incorrect state for this
                                        operation *
define ESOCKBADS E_SOCK_BADS
	
define E_SOCK_LIM	60221u   	    * no more sockets *
define ESOCKLIM E_SOCK_LIM	

define	E_MSG_SIZE	60222u		    * Message too long *
define EMSGSIZE     E_MSG_SIZE

define	EPROTOTYPE	60223u	        * Protocol wrong type for socket *
define	E_PROTO_TYPE EPROTOTYPE	

define	EPROTONOSUPPORT	60224u		* Protocol not supported *
define E_PROTO_NO_SUPPORT EPROTONOSUPPORT

define	EOPNOTSUPP	60225u   		* Operation not supported on socket *
define E_OP_NOT_SUPP EOPNOTSUPP

define	EPFNOSUPPORT	60226u   	* Protocol family not supported *
define E_PF_NO_SUPPORT EPFNOSUPPORT

define	EAFNOSUPPORT	60227u   	* Address family not supported by
                                       protocol family *
define E_AF_NO_SUPPORT EAFNOSUPPORT

define	ECONNREFUSED	60228u		* Connection refused *
define E_CONN_REFUSED ECONNREFUSED

define E_DIFF_BUFF	60229u   		* buff changed while request outstanding *
define EDIFFBUFF E_DIFF_BUFF	

define E_YOUR_REQ 	60230u	        * Recv has received a user request *
define EYOURREQ E_YOUR_REQ

define ESOCKTNOSUPPORT 60231u      * Socket type not supported *
define E_SOCKT_NO_SUPPORT ESOCKTNOSUPPORT

define ESYNTAX 60232u		        * Invalid request block *

define ESENDCACHED 60233u	        * UDP Datagram was cached *

define ETRUNCATION 60234u	        * UDP Datagram truncated *

define EINCOMPLETE 60235u	        * UDP Datagram incomplete *

define ESUMCHECKFAIL 60236u	    * UDP Datagram failed sumcheck*

define ESENDFAIL 60237u	        * Local UDP Datagram not delivered *

define EADDRINUSE		60238u		* The requested address is in use *
define E_ADDR_IN_USE EADDRINUSE

define EPREMATURETO 60239u	        * UDP Recvfrom timed out by the 
                                       system before user timeout *

define	ENOPROTOPAR 60240u		* The option is unknown at the given level *
	

define  E_NO_MSG_AVAIL  14		* NO message available *
define  ENOMSGAVAIL E_NO_MSG_AVAIL

define  E_NO_REQ_CODE   31		* No such request code *
define  ENOREQCODE E_NO_REQ_CODE

define  E_NOT_INSTALLED 33		* TCPIP system services not installed *
define  ENOTINSTALLED E_NOT_INSTALLED

define  E_NOSUCHSUBPARAM 2450  * No service installed for this rqCode* 	
define  E_NO_SUCH_SUB_PARAM  E_NOSUCHSUBPARAM

     ***** Errors generated by the TCP Transport Service *****

define  E_INV_RQ      58952u    * Invalid request              *
define  EINVRQ        E_INV_RQ 

define  E_BAD_MNG     58953u    * Bad TS management parameter  *
define  EBADMNG	   E_BAD_MNG

define  E_BAD_INDEX   58955u    * Invalid TS query index       *
define	 EBADINDEX	   E_BAD_INDEX

define  E_SBUF_BIG    58956u    * Send buffer too big          *
define  ESBUFBIG	   E_SBUF_BIG

define  E_RECV_TRUNC  58957u   * Receive message truncated    *
define  ERECVTRUNC    E_RECV_TRUNC

define  E_NO_RSRCS    58958u    * No TS resources for request  *
define  ENORSRCS	   E_NO_RSRCS

define  E_NOT_AVAIL   58959u    * No connection available      *
define  ENOTAVAIL     E_NOT_AVAIL

define  E_NO_HOST     58960u    * No such host name            *
define  ENOHOST	   E_NO_HOST

define  E_NO_ADDR     58961u    * No such host address         *
define  ENOADDR	   E_NO_ADDR

define  E_INV_SOCKET  58962u    * Invalid socket for open      *
define  EINVSOCKET    E_INV_SOCKET

define  E_REFUSED     58963u    * Connection refused by remote *
define  EREFUSED	   E_REFUSED

define  E_BAD_HANDLE  58964u    * No such connection handle    *
define  EBADHANDLE    E_BAD_HANDLE

define  E_NOT_OPEN    58965u    * Conn. is not in C_OPEN state *
define  ENOTOPEN      E_NOT_OPEN

define  E_CLOSED      58966u    * Conn. is in C_CLOSED state   *
define  ECLOSED       E_CLOSED

define  E_OPENING     58967u    * Conn. is in C_OPENING state  *
define  EOPENING      E_OPENING

define  E_CLOSING     58968u    * Conn. is in C_CLOSING state  *
define  ECLOSING      E_CLOSING

define  E_ABORTING    58969u    * Conn. is in C_ABORTING state *
define  EABORTING     E_ABORTING

define  E_ABORTED     58970u    * Conn. aborted by remote???   *
define  EABORTED      E_ABORTED

define  E_BADLEN      58971u    * Bad length in Send request   *
define  EBADLEN       E_BADLEN

define  E_TIMEOUT     58972u	* User timeout			*
define  ETIMEOUT      E_TIMEOUT

define  E_BAD_RANGE   58973u	* Bad security range		*
define  EBADRANGE     E_BAD_RANGE

define  E_BAD_PREC    58974u	* Precedence request unallowed *
define  EBADPREC      E_BAD_PREC

define  E_BAD_SEC     58975u	* Security request not allowed *
define  EBADSEC       E_BAD_SEC

define  E_EXISTS      58976u	* Connection already exists	*
define  EEXISTS       E_EXISTS

define  E_BAD_SYN     58977u	* Unexpected SYN received	*
define  EBADSYN       E_BAD_SYN

define  E_DUPLICATE   58978u	* Requested 'lcn' already used *
define  EDUPLICATE    E_DUPLICATE
				* i.e, Duplicate connection	*

endif __SOCKET_H__
************************  syssocket.h **************************************
