]>
git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_utilities/socks++5.h
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // socks++5 - version 5 Socks protocol
22 #ifndef _H_SOCKSPLUSPLUS5
23 #define _H_SOCKSPLUSPLUS5
29 namespace IPPlusPlus
{
33 typedef unsigned char Byte
;
36 class Server
: public SocksServer
{
38 Server(const IPSockAddress
&s
) : SocksServer(5, s
) { }
40 virtual void connect(SocksClientSocket
&me
, const IPSockAddress
&peer
);
41 virtual void connect(SocksClientSocket
&me
, const Host
&host
, IPPort port
);
42 virtual void bind(SocksServerSocket
&me
, const IPAddress
&peer
, IPPort port
);
43 virtual void receive(SocksServerSocket
&me
, SocksClientSocket
&receiver
);
46 void open(Socket
&s
, Support
&me
);
50 // request code (message field outbound)
52 socksConnect
= 1, // connect (outbound)
53 socksBind
= 2, // bind (single inbound)
54 socksUDP
= 3 // UDP associate (not implemented)
57 // reply code (message field inbound)
67 socksAddressNotSupported
= 8
70 // authentication type (in setup request)
71 enum AuthenticationType
{
72 socksAuthPublic
= 0, // anonymous access
73 socksAuthGSSAPI
= 1, // GSSAPI (yuk)
74 socksAuthUsername
= 2, // username/password
75 socksAuthNoneAcceptable
= 0xff // can't help you there...
78 // address types (inbound/outbound)
87 // A Message object contains a single request or reply of the Socks5 protocol.
88 // Since some of the data is dynamically sized, we have to fudge a bit. The static
89 // layout corresponds to IPv4 addresses, the common case. The object itself is big
90 // enough for all cases.
93 Byte version
; // Socks version
94 Byte message
; // message/reply
95 Byte reserved
; // not used (zero)
96 Byte addressType
; // address type
97 IPAddress addr
; // address starts here (IPv4 case)
98 // following fields dynamically located if (addressType != socksIPv4)
99 IPPort port
; // port field IF addr is IPv4
100 Byte pad
[256-sizeof(IPAddress
)-sizeof(IPPort
)]; // enough room for type 3 addresses (256 bytes)
102 // the following fields are not part of the message data
103 size_t length
; // calculated length of message (bytes, starting at version)
105 Message(Command cmd
, IPAddress addr
, IPPort port
); // type 1 request
106 Message(Command cmd
, const char *hostname
, IPPort port
); // type 3 request
107 void send(Socket
&s
); // send request
109 Message(Socket
&socket
); // receive (type 1 only)
111 IPSockAddress
address() const { return IPSockAddress(addr
, ntohs(port
)); }
115 } // end namespace Socks
116 } // end namespace IPPlusPlus
117 } // end namespace Security
119 #endif //_H_SOCKSPLUSPLUS5