]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/clAppUtils/ioSock.h
Security-57336.1.9.tar.gz
[apple/security.git] / SecurityTests / clxutils / clAppUtils / ioSock.h
1 /*
2 * ioSock.h - socket-based I/O routines for SecureTransport tests
3 */
4
5 #ifndef _IO_SOCK_H_
6 #define _IO_SOCK_H_
7
8 #include <MacTypes.h>
9 #include <Security/SecureTransport.h>
10 #include <sys/types.h>
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 /*
17 * Opaque reference to an Open Transport connection.
18 */
19 typedef int otSocket;
20
21 /*
22 * info about a peer returned from MakeServerConnection() and
23 * AcceptClientConnection().
24 */
25 typedef struct
26 { UInt32 ipAddr;
27 int port;
28 } PeerSpec;
29
30 /*
31 * Ont-time only init.
32 */
33 void initSslOt();
34
35 /*
36 * Connect to server.
37 */
38 extern OSStatus MakeServerConnection(
39 const char *hostName,
40 int port,
41 int nonBlocking, // 0 or 1
42 otSocket *socketNo, // RETURNED
43 PeerSpec *peer); // RETURNED
44
45 /*
46 * Set up an otSocket to listen for client connections. Call once, then
47 * use multiple AcceptClientConnection calls.
48 */
49 OSStatus ListenForClients(
50 int port,
51 int nonBlocking, // 0 or 1
52 otSocket *socketNo); // RETURNED
53
54 /*
55 * Accept a client connection. Call endpointShutdown() for each successful;
56 * return from this function.
57 */
58 OSStatus AcceptClientConnection(
59 otSocket listenSock, // obtained from ListenForClients
60 otSocket *acceptSock, // RETURNED
61 PeerSpec *peer); // RETURNED
62
63 /*
64 * Shut down a connection.
65 */
66 void endpointShutdown(
67 otSocket socket);
68
69 /*
70 * R/W. Called out from SSL.
71 */
72 OSStatus SocketRead(
73 SSLConnectionRef connection,
74 void *data, /* owned by
75 * caller, data
76 * RETURNED */
77 size_t *dataLength); /* IN/OUT */
78
79 OSStatus SocketWrite(
80 SSLConnectionRef connection,
81 const void *data,
82 size_t *dataLength); /* IN/OUT */
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 #endif /* _IO_SOCK_H_ */