| 1 | /* |
| 2 | ** CWTCPConnection.h |
| 3 | ** |
| 4 | ** Copyright (c) 2001-2007 Ludovic Marcotte |
| 5 | ** |
| 6 | ** Author: Ludovic Marcotte <[email protected]> |
| 7 | ** |
| 8 | ** This library is free software; you can redistribute it and/or |
| 9 | ** modify it under the terms of the GNU Lesser General Public |
| 10 | ** License as published by the Free Software Foundation; either |
| 11 | ** version 2.1 of the License, or (at your option) any later version. |
| 12 | ** |
| 13 | ** This library is distributed in the hope that it will be useful, |
| 14 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | ** Lesser General Public License for more details. |
| 17 | ** |
| 18 | ** You should have received a copy of the GNU General Public License |
| 19 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | |
| 22 | #ifndef _Pantomime_H_CWTCPConnection |
| 23 | #define _Pantomime_H_CWTCPConnection |
| 24 | |
| 25 | #include <Pantomime/CWConnection.h> |
| 26 | |
| 27 | #define id openssl_id |
| 28 | #define MD5 MDFIVE |
| 29 | #include <openssl/ssl.h> |
| 30 | #undef MD5 |
| 31 | #undef id |
| 32 | |
| 33 | #import <Foundation/NSObject.h> |
| 34 | |
| 35 | /*! |
| 36 | @class CWTCPConnection |
| 37 | @discussion This class, which implements the CWConnection protocol, |
| 38 | offers an elegant interface to a TCP connection. See |
| 39 | the documentation of the CWConnection protocol in order |
| 40 | to see all the methods one can use on an instance |
| 41 | of this class. Normally, you should never have to use |
| 42 | this class or one of its methods directly. |
| 43 | */ |
| 44 | @interface CWTCPConnection : NSObject <CWConnection> |
| 45 | { |
| 46 | @public |
| 47 | BOOL ssl_handshaking; |
| 48 | |
| 49 | @private |
| 50 | NSString *_name; |
| 51 | |
| 52 | unsigned int _connectionTimeout; |
| 53 | unsigned int _port; |
| 54 | int _fd; |
| 55 | |
| 56 | BOOL _dns_resolution_completed; |
| 57 | |
| 58 | SSL_CTX *_ctx; |
| 59 | SSL *_ssl; |
| 60 | } |
| 61 | |
| 62 | /*! |
| 63 | @method startSSL |
| 64 | @discussion This method is used to start the SSL handshaking |
| 65 | on an altready established TCP connection. |
| 66 | @result 0 on success, < 0 on error. |
| 67 | */ |
| 68 | - (int) startSSL; |
| 69 | |
| 70 | /*! |
| 71 | @method isSSL |
| 72 | @discussion This method is used to verify if the connection |
| 73 | TCP connection is using SSL or not. |
| 74 | @result YES if using SSL, NO otherwise. |
| 75 | */ |
| 76 | - (BOOL) isSSL; |
| 77 | |
| 78 | @end |
| 79 | |
| 80 | #endif // _Pantomime_H_CWTCPConnection |