31 #include <sys/types.h> 34 #include "platform.hpp" 38 #ifndef ZMQ_HAVE_WINDOWS 39 #include <sys/socket.h> 40 #include <netinet/in.h> 51 uint8_t *methods_, uint8_t num_methods_)
54 for (uint8_t i = 0; i < num_methods_; i++)
59 : bytes_encoded (0), bytes_written (0)
132 uint8_t command_, std::string hostname_, uint16_t port_)
133 : command (command_), hostname (hostname_), port (port_)
139 : bytes_encoded (0), bytes_written (0)
146 unsigned char *ptr =
buf;
151 #if defined ZMQ_HAVE_OPENVMS && defined __ia64 && __INITIAL_POINTER_SIZE == 64 152 __addrinfo64 hints, *res = NULL;
154 addrinfo hints, *res = NULL;
157 memset (&hints, 0,
sizeof hints);
160 hints.ai_flags = AI_NUMERICHOST;
162 const int rc = getaddrinfo (req.
hostname.c_str (), NULL, &hints, &res);
163 if (rc == 0 && res->ai_family == AF_INET) {
164 struct sockaddr_in *sockaddr_in =
165 reinterpret_cast <
struct sockaddr_in *> (res->ai_addr);
167 memcpy (ptr, &sockaddr_in->sin_addr, 4);
171 if (rc == 0 && res->ai_family == AF_INET6) {
172 struct sockaddr_in6 *sockaddr_in6 =
173 reinterpret_cast <
struct sockaddr_in6 *> (res->ai_addr);
175 memcpy (ptr, &sockaddr_in6->sin6_addr, 16);
180 *ptr++ = (
unsigned char) req.
hostname.size ();
188 *ptr++ = req.
port / 256;
189 *ptr++ = req.
port % 256;
215 uint8_t response_code_, std::string address_, uint16_t port_)
216 : response_code (response_code_),
address (address_), port (port_)
230 const uint8_t atyp =
buf [3];
231 zmq_assert (atyp == 0x01 || atyp == 0x03 || atyp == 0x04);
253 const uint8_t atyp =
buf [3];
254 if (atyp != 0x01 && atyp != 0x03 && atyp != 0x04)
266 const uint8_t atyp =
buf [3];
267 zmq_assert (atyp == 0x01 || atyp == 0x03 || atyp == 0x04);
274 return bytes_read == 22;
void encode(const socks_request_t &req)
bool message_ready() const
int8_t buf[4+UINT8_MAX+1+2]
bool has_pending_data() const
uint8_t buf[4+UINT8_MAX+1+2]
bool message_ready() const
void encode(const socks_greeting_t &greeting_)
socks_greeting_encoder_t()
int tcp_write(fd_t s_, const void *data_, size_t size_)
socks_choice_t(uint8_t method_)
bool has_pending_data() const
socks_request_t(uint8_t command_, std::string hostname_, uint16_t port_)
socks_response_decoder_t()
uint8_t methods[UINT8_MAX]
socks_greeting_t(uint8_t method)
int tcp_read(fd_t s_, void *data_, size_t size_)
socks_response_t(uint8_t response_code_, std::string address_, uint16_t port_)
socks_request_encoder_t()
socks_response_t decode()
const std::string hostname