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