2 * tcp.h interface to MCS's TCP routines
6 #ifdef SUPPORT_OPENTRANSPORT
7 #include <OpenTransport.h>
8 #include <OpenTptInternet.h>
9 #endif /* SUPPORT_OPENTRANSPORT */
10 #include "MacTCPCommonTypes.h"
11 #include "AddressXlation.h"
13 #include "GetMyIPAddr.h"
16 #define TCP_BUFSIZ 8192
17 #endif /* TCP_BUFSIZ */
19 typedef struct tcpstream {
20 StreamPtr tcps_sptr; /* stream pointer for MacTCP TCP PB calls */
21 #ifdef SUPPORT_OPENTRANSPORT
22 EndpointRef tcps_ep; /* OpenTransport end point */
23 #endif /* SUPPORT_OPENTRANSPORT */
24 short tcps_data; /* count of packets on read queue */
25 short drefnum; /* driver ref num, for convenience */
26 Boolean tcps_connected; /* true if connection was made */
27 Boolean tcps_terminated; /* true if connection no longer exists */
28 #ifdef SUPPORT_OPENTRANSPORT
29 InetHost tcps_remoteaddr; /* Address of our peer */
30 InetPort tcps_remoteport; /* Port number of our peer */
31 #endif /* SUPPORT_OPENTRANSPORT */
32 unsigned char *tcps_buffer; /* buffer given over to system to use */
33 struct tcpstream *tcps_next; /* next one in chain */
34 TCPNotifyUPP tcps_notifyupp; /* universal proc pointer for notify routine */
35 } tcpstream, *tcpstreamptr;
38 * the Unix-y struct timeval
41 long tv_sec; /* seconds */
42 long tv_usec; /* and microseconds */
45 #ifdef SUPPORT_OPENTRANSPORT
47 typedef UInt32 ip_addr;
48 typedef UInt16 tcp_port;
49 #endif /* SUPPORT_OPENTRANSPORT */
51 #define TCP_IS_TERMINATED( tsp ) (tsp)->tcps_terminated
56 #ifdef SUPPORT_OPENTRANSPORT
57 OSStatus tcp_init(void);
58 void tcp_shutdown(void);
59 Boolean tcp_have_opentransport( void );
60 #endif /* SUPPORT_OPENTRANSPORT */
61 tcpstream *tcpopen( unsigned char * buf, long buflen );
62 tcp_port tcpconnect( tcpstream *s, ip_addr addr, tcp_port port );
63 short tcpclose( tcpstream *s );
64 long tcpread( tcpstream *s, byte timeout, unsigned char * rbuf,
65 unsigned short rbuflen, DialogPtr dlp );
66 long tcpwrite( tcpstream *s, unsigned char * wbuf, unsigned short wbuflen );
67 short tcpselect( tcpstream *s, struct timeval * timeout );
68 short tcpreadready( tcpstream *tsp );
69 short tcpgetpeername( tcpstream * tsp, ip_addr *addrp, tcp_port *portp );
71 #ifdef SUPPORT_OPENTRANSPORT
72 short gethostinfobyname( char *host, InetHostInfo *hip );
73 short gethostinfobyaddr(InetHost addr, InetHostInfo *hip );
74 short ipaddr2str( InetHost ipaddr, char *addrstr );
75 #else /* SUPPORT_OPENTRANSPORT */
76 short gethostinfobyname( char *host, struct hostInfo *hip );
77 short gethostinfobyaddr( ip_addr addr, struct hostInfo *hip );
78 short ipaddr2str( ip_addr ipaddr, char *addrstr );
79 #endif /* SUPPORT_OPENTRANSPORT */