X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/80e2389990082500d76eb566d4946be3e786c3ef..d8f41ccd20de16f8ebe2ccc84d47bf1cb2b26bbb:/SecurityTests/clxutils/clAppUtils/ioSock.h diff --git a/SecurityTests/clxutils/clAppUtils/ioSock.h b/SecurityTests/clxutils/clAppUtils/ioSock.h new file mode 100644 index 00000000..c01f8f11 --- /dev/null +++ b/SecurityTests/clxutils/clAppUtils/ioSock.h @@ -0,0 +1,88 @@ +/* + * ioSock.h - socket-based I/O routines for SecureTransport tests + */ + +#ifndef _IO_SOCK_H_ +#define _IO_SOCK_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Opaque reference to an Open Transport connection. + */ +typedef int otSocket; + +/* + * info about a peer returned from MakeServerConnection() and + * AcceptClientConnection(). + */ +typedef struct +{ UInt32 ipAddr; + int port; +} PeerSpec; + +/* + * Ont-time only init. + */ +void initSslOt(); + +/* + * Connect to server. + */ +extern OSStatus MakeServerConnection( + const char *hostName, + int port, + int nonBlocking, // 0 or 1 + otSocket *socketNo, // RETURNED + PeerSpec *peer); // RETURNED + +/* + * Set up an otSocket to listen for client connections. Call once, then + * use multiple AcceptClientConnection calls. + */ +OSStatus ListenForClients( + int port, + int nonBlocking, // 0 or 1 + otSocket *socketNo); // RETURNED + +/* + * Accept a client connection. Call endpointShutdown() for each successful; + * return from this function. + */ +OSStatus AcceptClientConnection( + otSocket listenSock, // obtained from ListenForClients + otSocket *acceptSock, // RETURNED + PeerSpec *peer); // RETURNED + +/* + * Shut down a connection. + */ +void endpointShutdown( + otSocket socket); + +/* + * R/W. Called out from SSL. + */ +OSStatus SocketRead( + SSLConnectionRef connection, + void *data, /* owned by + * caller, data + * RETURNED */ + size_t *dataLength); /* IN/OUT */ + +OSStatus SocketWrite( + SSLConnectionRef connection, + const void *data, + size_t *dataLength); /* IN/OUT */ + +#ifdef __cplusplus +} +#endif + +#endif /* _IO_SOCK_H_ */