/*
 *    PROJECT:      dvs
 *    SUBSYSTEM:    net
 *    MODULE:       dtcp.h
 *
 *    File:         $RCSfile: dtcp.h,v $
 *    Revision:     $Revision: 1.3 $
 *    Date:         $Date: 1995/03/10 17:09:52 $
 *    Author:       $Author: john $
 *    RCS Ident:    $Id: dtcp.h,v 1.3 1995/03/10 17:09:52 john Exp $
 *
 *    FUNCTION:
 *    header file for host independant socket access.
 *
 *    $Log: dtcp.h,v $
 * Revision 1.3  1995/03/10  17:09:52  john
 * *** empty log message ***
 *
 * Revision 1.2  1995/01/13  16:09:46  jeff
 * ci for new build system.
 *
 * Revision 1.1  1994/12/05  09:33:35  jeff
 * First post-manager check in.
 *
 *
 * Copyright (c) 1994 Division Ltd.
 *
 * All Rights Reserved.
 *
 * This Document may not, in whole or in part, be copied,
 * photocopied, reproduced, translated, or reduced to any
 * electronic medium or machine readable form without prior
 * written consent from Division Ltd.
 */
#ifndef __DTCP_H
#define __DTCP_H

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#ifdef _IRIX5
#include <bstring.h>
#endif
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netdb.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/file.h>

# ifdef __cplusplus
extern "C" {
# endif


#if defined ( _SYSV42)
#ifdef _DVS_AGENT
#define TCP_TLI

#else
#define TCP_BSD
#endif
#else
#if defined (_HPUX)  || defined (_IRIX)
#define TCP_BSD
#else
#error Undefined system type
#endif
#endif

#ifdef TCP_TLI
#include <tiuser.h>
#include <stropts.h>

#define  dsock_open			dsock_tli_open
#define  dsock_bind_listen		dsock_tli_bind_listen
#define  dsock_buffer_size		dsock_tli_buffer_size
#define  dsock_select_io		dsock_tli_select_io
#define  dsock_async_io			dsock_tli_async_io
#define  dsock_async_signal		dsock_tli_async_signal
#define  dsock_allow_broadcast  	dsock_tli_allow_broadcast
#define  dsock_set_timeout		dsock_tli_set_timeout
#define  dsock_sendto 			dsock_tli_sendto
#define  dsock_recvfrom 		dsock_tli_recvfrom
#define  dsock_send 			dsock_tli_send
#define  dsock_recv 			dsock_tli_recv
#define  dsock_getFirst_socket 		dsock_tli_getFirst_socket
#define  dsock_getNext_socket 		dsock_tli_getNext_socket
#define  dsock_connect			dsock_tli_connect
#define  dsock_connect_addr		dsock_tli_connect_addr
#define  dsock_listen_accept		dsock_tli_listen_accept
#define  dsock_acceptClose		dsock_tli_acceptClose
#define  dsock_recvConnect		dsock_tli_recvConnect
#define  dsock_enableAsyncWrite		dsock_tli_enableAsyncWrite
#define  dsock_disableAsyncWrite	dsock_tli_diableAsyncWrite
#define  dsock_close			dsock_tli_close
#define dsock_error			dsock_tli_error
#define dsock_errno			dsock_tli_errno
#endif

#include <dsys/divtypes.h>

#define DTCP_UDP	0x00000001
#define DTCP_TCP	0x00000002

#define DTCP_INET	0x00000001
#define DTCP_UNIX	0x00000002

#define DTCP_READ	1
#define DTCP_WRITE	2
#define DTCP_EXCEPTION	3
#define DTCP_ERR	4
#define DTCP_HUP	5

#define DTCP_LISTEN	-2
#define DTCP_CONNECT	-3
#define DTCP_DATA	-4
#define DTCP_EXDATA	-5
#define DTCP_DISCONNECT	-6
#define DTCP_ERROR	-7
#define DTCP_UDERR	-8
#define DTCP_ORDREL	-9
#define DTCP_TIMEOUT	-10


void dsockVersion(FILE *fp);
int dsock_open(int family, int type);
int dsock_bind_listen(int sock, int family, int inet_addr, short *port, int qlength);
int dsock_buffer_size(int sock, int bufferSize);
void dsock_select_io(int sock);
int dsock_async_io(int sock);
int dsock_async_signal(void);
int dsock_allow_broadcast (int sock);
void dsock_set_timeout(struct timeval *t);
int dsock_sendto (int sock, void *msg, int size, struct sockaddr_in *dst);
int dsock_recvfrom (int sock, void *msg, int size, struct sockaddr_in *from);
int dsock_send (int sock, void *msg, int size);
int dsock_recv (int sock, void *msg, int size);
int dsock_getFirst_socket (int *ioType);
int dsock_getNext_socket (int *ioType);
int dsock_connect(int sock, struct sockaddr_in *dst);
int dsock_connect_addr(int sock, int family, int inet_addr, short *port );
int dsock_listen_accept(int sock, struct sockaddr_in *addr);
int dsock_acceptClose(int fd);
int dsock_recvConnect(int fd);
int dsock_enableAsyncWrite(int fd);
int dsock_disableAsyncWrite(int fd);
int dsock_close(int fd);


void dsock_error(char *string);
int32 dsock_flipWord(int32 value);
int16 dsock_flipShort(int16 value);

extern int dsock_errno;


# ifdef __cplusplus
}
# endif
#endif /* DTCP_H */
