]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_utilities/lib/socks++5.h
2 * Copyright (c) 2000-2001,2004,2011,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 // socks++5 - version 5 Socks protocol
28 #ifndef _H_SOCKSPLUSPLUS5
29 #define _H_SOCKSPLUSPLUS5
35 namespace IPPlusPlus
{
39 typedef unsigned char Byte
;
42 class Server
: public SocksServer
{
44 Server(const IPSockAddress
&s
) : SocksServer(5, s
) { }
46 virtual void connect(SocksClientSocket
&me
, const IPSockAddress
&peer
);
47 virtual void connect(SocksClientSocket
&me
, const Host
&host
, IPPort port
);
48 virtual void bind(SocksServerSocket
&me
, const IPAddress
&peer
, IPPort port
);
49 virtual void receive(SocksServerSocket
&me
, SocksClientSocket
&receiver
);
52 void open(Socket
&s
, Support
&me
);
56 // request code (message field outbound)
58 socksConnect
= 1, // connect (outbound)
59 socksBind
= 2, // bind (single inbound)
60 socksUDP
= 3 // UDP associate (not implemented)
63 // reply code (message field inbound)
73 socksAddressNotSupported
= 8
76 // authentication type (in setup request)
77 enum AuthenticationType
{
78 socksAuthPublic
= 0, // anonymous access
79 socksAuthGSSAPI
= 1, // GSSAPI (yuk)
80 socksAuthUsername
= 2, // username/password
81 socksAuthNoneAcceptable
= 0xff // can't help you there...
84 // address types (inbound/outbound)
93 // A Message object contains a single request or reply of the Socks5 protocol.
94 // Since some of the data is dynamically sized, we have to fudge a bit. The static
95 // layout corresponds to IPv4 addresses, the common case. The object itself is big
96 // enough for all cases.
99 Byte version
; // Socks version
100 Byte message
; // message/reply
101 Byte reserved
; // not used (zero)
102 Byte addressType
; // address type
103 IPAddress addr
; // address starts here (IPv4 case)
104 // following fields dynamically located if (addressType != socksIPv4)
105 IPPort port
; // port field IF addr is IPv4
106 Byte pad
[256-sizeof(IPAddress
)-sizeof(IPPort
)]; // enough room for type 3 addresses (256 bytes)
108 // the following fields are not part of the message data
109 size_t length
; // calculated length of message (bytes, starting at version)
111 Message(Command cmd
, IPAddress addr
, IPPort port
); // type 1 request
112 Message(Command cmd
, const char *hostname
, IPPort port
); // type 3 request
113 void send(Socket
&s
); // send request
115 Message(Socket
&socket
); // receive (type 1 only)
117 IPSockAddress
address() const { return IPSockAddress(addr
, ntohs(port
)); }
121 } // end namespace Socks
122 } // end namespace IPPlusPlus
123 } // end namespace Security
125 #endif //_H_SOCKSPLUSPLUS5