|
Wired Networking
2.0
Objective-C implementation of the Wired 2.0 protocol
|
00001 /* $Id$ */ 00002 00003 /* 00004 * Copyright (c) 2008-2009 Axel Andersson 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 1. Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 2. Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00017 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00018 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00019 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 00020 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00021 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00022 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00023 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00024 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00025 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00026 * POSSIBILITY OF SUCH DAMAGE. 00027 */ 00028 00029 #import <WiredNetworking/WIP7Message.h> 00030 00031 enum _WIP7Options { 00032 WIP7CompressionDeflate = WI_P7_COMPRESSION_DEFLATE, 00033 WIP7EncryptionRSA_AES128_SHA1 = WI_P7_ENCRYPTION_RSA_AES128_SHA1, 00034 WIP7EncryptionRSA_AES192_SHA1 = WI_P7_ENCRYPTION_RSA_AES192_SHA1, 00035 WIP7EncryptionRSA_AES256_SHA1 = WI_P7_ENCRYPTION_RSA_AES256_SHA1, 00036 WIP7EncryptionRSA_BF128_SHA1 = WI_P7_ENCRYPTION_RSA_BF128_SHA1, 00037 WIP7EncryptionRSA_3DES192_SHA1 = WI_P7_ENCRYPTION_RSA_3DES192_SHA1, 00038 WIP7ChecksumSHA1 = WI_P7_CHECKSUM_SHA1, 00039 WIP7All = WI_P7_ALL 00040 }; 00041 typedef enum _WIP7Options WIP7Options; 00042 00043 00044 @class WIError, WIP7Message, WIP7Spec, WISocket; 00045 00046 @interface WIP7Socket : WIObject { 00047 id delegate; 00048 00049 WISocket *_socket; 00050 WIP7Spec *_spec; 00051 00052 WIError *_readTimeoutError; 00053 00054 wi_p7_socket_t *_p7Socket; 00055 } 00056 00057 - (id)initWithSocket:(WISocket *)socket spec:(WIP7Spec *)spec; 00058 00059 - (void)setDelegate:(id)delegate; 00060 - (id)delegate; 00061 00062 - (WISocket *)socket; 00063 - (wi_p7_socket_t *)P7Socket; 00064 - (WIP7Spec *)spec; 00065 - (NSUInteger)options; 00066 - (WIP7Serialization)serialization; 00067 - (NSString *)remoteProtocolName; 00068 - (NSString *)remoteProtocolVersion; 00069 - (BOOL)usesEncryption; 00070 - (NSString *)cipherName; 00071 - (NSUInteger)cipherBits; 00072 - (BOOL)usesCompression; 00073 - (double)compressionRatio; 00074 00075 - (BOOL)verifyMessage:(WIP7Message *)message error:(WIError **)error; 00076 00077 - (BOOL)connectWithOptions:(NSUInteger)options serialization:(WIP7Serialization)serialization username:(NSString *)username password:(NSString *)password timeout:(NSTimeInterval)timeout error:(WIError **)error; 00078 - (BOOL)acceptWithOptions:(NSUInteger)options timeout:(NSTimeInterval)timeout error:(WIError **)error; 00079 - (void)close; 00080 00081 - (BOOL)writeMessage:(WIP7Message *)message timeout:(NSTimeInterval)timeout error:(WIError **)error; 00082 - (WIP7Message *)readMessageWithTimeout:(NSTimeInterval)timeout error:(WIError **)error; 00083 - (BOOL)writeOOBData:(const void *)data length:(NSUInteger)length timeout:(NSTimeInterval)timeout error:(WIError **)error; 00084 - (NSInteger)readOOBData:(void **)data timeout:(NSTimeInterval)timeout error:(WIError **)error; 00085 00086 @end 00087 00088 00089 @interface NSObject(WIP7SocketDelegate) 00090 00091 - (void)P7Socket:(WIP7Socket *)socket readMessage:(WIP7Message *)message; 00092 - (void)P7Socket:(WIP7Socket *)socket wroteMessage:(WIP7Message *)message; 00093 00094 @end