#ifndef TRUNNEL_SOCKS5_H
#define TRUNNEL_SOCKS5_H
#include <stdint.h>
#include "trunnel.h"
#define CMD_CONNECT 1
#define CMD_BIND 2
#define CMD_UDP_ASSOCIATE 3
#define CMD_RESOLVE 240
#define CMD_RESOLVE_PTR 241
#define ATYPE_IPV4 1
#define ATYPE_IPV6 4
#define ATYPE_DOMAINNAME 3
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_DOMAINNAME)
struct domainname_st {
uint8_t len;
trunnel_string_t name;
uint8_t trunnel_error_code_;
};
#endif
typedef struct domainname_st domainname_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS4_CLIENT_REQUEST)
struct socks4_client_request_st {
uint8_t version;
uint8_t command;
uint16_t port;
uint32_t addr;
char *username;
char *socks4a_addr_hostname;
uint8_t trunnel_error_code_;
};
#endif
typedef struct socks4_client_request_st socks4_client_request_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS4_SERVER_REPLY)
struct socks4_server_reply_st {
uint8_t version;
uint8_t status;
uint16_t port;
uint32_t addr;
uint8_t trunnel_error_code_;
};
#endif
typedef struct socks4_server_reply_st socks4_server_reply_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_CLIENT_USERPASS_AUTH)
struct socks5_client_userpass_auth_st {
uint8_t version;
uint8_t username_len;
trunnel_string_t username;
uint8_t passwd_len;
trunnel_string_t passwd;
uint8_t trunnel_error_code_;
};
#endif
typedef struct socks5_client_userpass_auth_st socks5_client_userpass_auth_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_CLIENT_VERSION)
struct socks5_client_version_st {
uint8_t version;
uint8_t n_methods;
TRUNNEL_DYNARRAY_HEAD(, uint8_t) methods;
uint8_t trunnel_error_code_;
};
#endif
typedef struct socks5_client_version_st socks5_client_version_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_SERVER_METHOD)
struct socks5_server_method_st {
uint8_t version;
uint8_t method;
uint8_t trunnel_error_code_;
};
#endif
typedef struct socks5_server_method_st socks5_server_method_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_SERVER_USERPASS_AUTH)
struct socks5_server_userpass_auth_st {
uint8_t version;
uint8_t status;
uint8_t trunnel_error_code_;
};
#endif
typedef struct socks5_server_userpass_auth_st socks5_server_userpass_auth_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_CLIENT_REQUEST)
struct socks5_client_request_st {
uint8_t version;
uint8_t command;
uint8_t reserved;
uint8_t atype;
uint32_t dest_addr_ipv4;
uint8_t dest_addr_ipv6[16];
struct domainname_st *dest_addr_domainname;
uint16_t dest_port;
uint8_t trunnel_error_code_;
};
#endif
typedef struct socks5_client_request_st socks5_client_request_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_SERVER_REPLY)
struct socks5_server_reply_st {
uint8_t version;
uint8_t reply;
uint8_t reserved;
uint8_t atype;
uint32_t bind_addr_ipv4;
uint8_t bind_addr_ipv6[16];
struct domainname_st *bind_addr_domainname;
uint16_t bind_port;
uint8_t trunnel_error_code_;
};
#endif
typedef struct socks5_server_reply_st socks5_server_reply_t;
domainname_t *domainname_new(void);
void domainname_free(domainname_t *victim);
ssize_t domainname_parse(domainname_t **output, const uint8_t *input, const size_t len_in);
ssize_t domainname_encoded_len(const domainname_t *obj);
ssize_t domainname_encode(uint8_t *output, size_t avail, const domainname_t *input);
const char *domainname_check(const domainname_t *obj);
int domainname_clear_errors(domainname_t *obj);
uint8_t domainname_get_len(const domainname_t *inp);
int domainname_set_len(domainname_t *inp, uint8_t val);
size_t domainname_getlen_name(const domainname_t *inp);
char domainname_get_name(domainname_t *inp, size_t idx);
char domainname_getconst_name(const domainname_t *inp, size_t idx);
int domainname_set_name(domainname_t *inp, size_t idx, char elt);
int domainname_add_name(domainname_t *inp, char elt);
char * domainname_getarray_name(domainname_t *inp);
const char * domainname_getconstarray_name(const domainname_t *inp);
int domainname_setlen_name(domainname_t *inp, size_t newlen);
const char * domainname_getstr_name(domainname_t *inp);
int domainname_setstr0_name(domainname_t *inp, const char *val, size_t len);
int domainname_setstr_name(domainname_t *inp, const char *val);
socks4_client_request_t *socks4_client_request_new(void);
void socks4_client_request_free(socks4_client_request_t *victim);
ssize_t socks4_client_request_parse(socks4_client_request_t **output, const uint8_t *input, const size_t len_in);
ssize_t socks4_client_request_encoded_len(const socks4_client_request_t *obj);
ssize_t socks4_client_request_encode(uint8_t *output, size_t avail, const socks4_client_request_t *input);
const char *socks4_client_request_check(const socks4_client_request_t *obj);
int socks4_client_request_clear_errors(socks4_client_request_t *obj);
uint8_t socks4_client_request_get_version(const socks4_client_request_t *inp);
int socks4_client_request_set_version(socks4_client_request_t *inp, uint8_t val);
uint8_t socks4_client_request_get_command(const socks4_client_request_t *inp);
int socks4_client_request_set_command(socks4_client_request_t *inp, uint8_t val);
uint16_t socks4_client_request_get_port(const socks4_client_request_t *inp);
int socks4_client_request_set_port(socks4_client_request_t *inp, uint16_t val);
uint32_t socks4_client_request_get_addr(const socks4_client_request_t *inp);
int socks4_client_request_set_addr(socks4_client_request_t *inp, uint32_t val);
const char * socks4_client_request_get_username(const socks4_client_request_t *inp);
int socks4_client_request_set_username(socks4_client_request_t *inp, const char *val);
const char * socks4_client_request_get_socks4a_addr_hostname(const socks4_client_request_t *inp);
int socks4_client_request_set_socks4a_addr_hostname(socks4_client_request_t *inp, const char *val);
socks4_server_reply_t *socks4_server_reply_new(void);
void socks4_server_reply_free(socks4_server_reply_t *victim);
ssize_t socks4_server_reply_parse(socks4_server_reply_t **output, const uint8_t *input, const size_t len_in);
ssize_t socks4_server_reply_encoded_len(const socks4_server_reply_t *obj);
ssize_t socks4_server_reply_encode(uint8_t *output, size_t avail, const socks4_server_reply_t *input);
const char *socks4_server_reply_check(const socks4_server_reply_t *obj);
int socks4_server_reply_clear_errors(socks4_server_reply_t *obj);
uint8_t socks4_server_reply_get_version(const socks4_server_reply_t *inp);
int socks4_server_reply_set_version(socks4_server_reply_t *inp, uint8_t val);
uint8_t socks4_server_reply_get_status(const socks4_server_reply_t *inp);
int socks4_server_reply_set_status(socks4_server_reply_t *inp, uint8_t val);
uint16_t socks4_server_reply_get_port(const socks4_server_reply_t *inp);
int socks4_server_reply_set_port(socks4_server_reply_t *inp, uint16_t val);
uint32_t socks4_server_reply_get_addr(const socks4_server_reply_t *inp);
int socks4_server_reply_set_addr(socks4_server_reply_t *inp, uint32_t val);
socks5_client_userpass_auth_t *socks5_client_userpass_auth_new(void);
void socks5_client_userpass_auth_free(socks5_client_userpass_auth_t *victim);
ssize_t socks5_client_userpass_auth_parse(socks5_client_userpass_auth_t **output, const uint8_t *input, const size_t len_in);
ssize_t socks5_client_userpass_auth_encoded_len(const socks5_client_userpass_auth_t *obj);
ssize_t socks5_client_userpass_auth_encode(uint8_t *output, size_t avail, const socks5_client_userpass_auth_t *input);
const char *socks5_client_userpass_auth_check(const socks5_client_userpass_auth_t *obj);
int socks5_client_userpass_auth_clear_errors(socks5_client_userpass_auth_t *obj);
uint8_t socks5_client_userpass_auth_get_version(const socks5_client_userpass_auth_t *inp);
int socks5_client_userpass_auth_set_version(socks5_client_userpass_auth_t *inp, uint8_t val);
uint8_t socks5_client_userpass_auth_get_username_len(const socks5_client_userpass_auth_t *inp);
int socks5_client_userpass_auth_set_username_len(socks5_client_userpass_auth_t *inp, uint8_t val);
size_t socks5_client_userpass_auth_getlen_username(const socks5_client_userpass_auth_t *inp);
char socks5_client_userpass_auth_get_username(socks5_client_userpass_auth_t *inp, size_t idx);
char socks5_client_userpass_auth_getconst_username(const socks5_client_userpass_auth_t *inp, size_t idx);
int socks5_client_userpass_auth_set_username(socks5_client_userpass_auth_t *inp, size_t idx, char elt);
int socks5_client_userpass_auth_add_username(socks5_client_userpass_auth_t *inp, char elt);
char * socks5_client_userpass_auth_getarray_username(socks5_client_userpass_auth_t *inp);
const char * socks5_client_userpass_auth_getconstarray_username(const socks5_client_userpass_auth_t *inp);
int socks5_client_userpass_auth_setlen_username(socks5_client_userpass_auth_t *inp, size_t newlen);
const char * socks5_client_userpass_auth_getstr_username(socks5_client_userpass_auth_t *inp);
int socks5_client_userpass_auth_setstr0_username(socks5_client_userpass_auth_t *inp, const char *val, size_t len);
int socks5_client_userpass_auth_setstr_username(socks5_client_userpass_auth_t *inp, const char *val);
uint8_t socks5_client_userpass_auth_get_passwd_len(const socks5_client_userpass_auth_t *inp);
int socks5_client_userpass_auth_set_passwd_len(socks5_client_userpass_auth_t *inp, uint8_t val);
size_t socks5_client_userpass_auth_getlen_passwd(const socks5_client_userpass_auth_t *inp);
char socks5_client_userpass_auth_get_passwd(socks5_client_userpass_auth_t *inp, size_t idx);
char socks5_client_userpass_auth_getconst_passwd(const socks5_client_userpass_auth_t *inp, size_t idx);
int socks5_client_userpass_auth_set_passwd(socks5_client_userpass_auth_t *inp, size_t idx, char elt);
int socks5_client_userpass_auth_add_passwd(socks5_client_userpass_auth_t *inp, char elt);
char * socks5_client_userpass_auth_getarray_passwd(socks5_client_userpass_auth_t *inp);
const char * socks5_client_userpass_auth_getconstarray_passwd(const socks5_client_userpass_auth_t *inp);
int socks5_client_userpass_auth_setlen_passwd(socks5_client_userpass_auth_t *inp, size_t newlen);
const char * socks5_client_userpass_auth_getstr_passwd(socks5_client_userpass_auth_t *inp);
int socks5_client_userpass_auth_setstr0_passwd(socks5_client_userpass_auth_t *inp, const char *val, size_t len);
int socks5_client_userpass_auth_setstr_passwd(socks5_client_userpass_auth_t *inp, const char *val);
socks5_client_version_t *socks5_client_version_new(void);
void socks5_client_version_free(socks5_client_version_t *victim);
ssize_t socks5_client_version_parse(socks5_client_version_t **output, const uint8_t *input, const size_t len_in);
ssize_t socks5_client_version_encoded_len(const socks5_client_version_t *obj);
ssize_t socks5_client_version_encode(uint8_t *output, size_t avail, const socks5_client_version_t *input);
const char *socks5_client_version_check(const socks5_client_version_t *obj);
int socks5_client_version_clear_errors(socks5_client_version_t *obj);
uint8_t socks5_client_version_get_version(const socks5_client_version_t *inp);
int socks5_client_version_set_version(socks5_client_version_t *inp, uint8_t val);
uint8_t socks5_client_version_get_n_methods(const socks5_client_version_t *inp);
int socks5_client_version_set_n_methods(socks5_client_version_t *inp, uint8_t val);
size_t socks5_client_version_getlen_methods(const socks5_client_version_t *inp);
uint8_t socks5_client_version_get_methods(socks5_client_version_t *inp, size_t idx);
uint8_t socks5_client_version_getconst_methods(const socks5_client_version_t *inp, size_t idx);
int socks5_client_version_set_methods(socks5_client_version_t *inp, size_t idx, uint8_t elt);
int socks5_client_version_add_methods(socks5_client_version_t *inp, uint8_t elt);
uint8_t * socks5_client_version_getarray_methods(socks5_client_version_t *inp);
const uint8_t * socks5_client_version_getconstarray_methods(const socks5_client_version_t *inp);
int socks5_client_version_setlen_methods(socks5_client_version_t *inp, size_t newlen);
socks5_server_method_t *socks5_server_method_new(void);
void socks5_server_method_free(socks5_server_method_t *victim);
ssize_t socks5_server_method_parse(socks5_server_method_t **output, const uint8_t *input, const size_t len_in);
ssize_t socks5_server_method_encoded_len(const socks5_server_method_t *obj);
ssize_t socks5_server_method_encode(uint8_t *output, size_t avail, const socks5_server_method_t *input);
const char *socks5_server_method_check(const socks5_server_method_t *obj);
int socks5_server_method_clear_errors(socks5_server_method_t *obj);
uint8_t socks5_server_method_get_version(const socks5_server_method_t *inp);
int socks5_server_method_set_version(socks5_server_method_t *inp, uint8_t val);
uint8_t socks5_server_method_get_method(const socks5_server_method_t *inp);
int socks5_server_method_set_method(socks5_server_method_t *inp, uint8_t val);
socks5_server_userpass_auth_t *socks5_server_userpass_auth_new(void);
void socks5_server_userpass_auth_free(socks5_server_userpass_auth_t *victim);
ssize_t socks5_server_userpass_auth_parse(socks5_server_userpass_auth_t **output, const uint8_t *input, const size_t len_in);
ssize_t socks5_server_userpass_auth_encoded_len(const socks5_server_userpass_auth_t *obj);
ssize_t socks5_server_userpass_auth_encode(uint8_t *output, size_t avail, const socks5_server_userpass_auth_t *input);
const char *socks5_server_userpass_auth_check(const socks5_server_userpass_auth_t *obj);
int socks5_server_userpass_auth_clear_errors(socks5_server_userpass_auth_t *obj);
uint8_t socks5_server_userpass_auth_get_version(const socks5_server_userpass_auth_t *inp);
int socks5_server_userpass_auth_set_version(socks5_server_userpass_auth_t *inp, uint8_t val);
uint8_t socks5_server_userpass_auth_get_status(const socks5_server_userpass_auth_t *inp);
int socks5_server_userpass_auth_set_status(socks5_server_userpass_auth_t *inp, uint8_t val);
socks5_client_request_t *socks5_client_request_new(void);
void socks5_client_request_free(socks5_client_request_t *victim);
ssize_t socks5_client_request_parse(socks5_client_request_t **output, const uint8_t *input, const size_t len_in);
ssize_t socks5_client_request_encoded_len(const socks5_client_request_t *obj);
ssize_t socks5_client_request_encode(uint8_t *output, size_t avail, const socks5_client_request_t *input);
const char *socks5_client_request_check(const socks5_client_request_t *obj);
int socks5_client_request_clear_errors(socks5_client_request_t *obj);
uint8_t socks5_client_request_get_version(const socks5_client_request_t *inp);
int socks5_client_request_set_version(socks5_client_request_t *inp, uint8_t val);
uint8_t socks5_client_request_get_command(const socks5_client_request_t *inp);
int socks5_client_request_set_command(socks5_client_request_t *inp, uint8_t val);
uint8_t socks5_client_request_get_reserved(const socks5_client_request_t *inp);
int socks5_client_request_set_reserved(socks5_client_request_t *inp, uint8_t val);
uint8_t socks5_client_request_get_atype(const socks5_client_request_t *inp);
int socks5_client_request_set_atype(socks5_client_request_t *inp, uint8_t val);
uint32_t socks5_client_request_get_dest_addr_ipv4(const socks5_client_request_t *inp);
int socks5_client_request_set_dest_addr_ipv4(socks5_client_request_t *inp, uint32_t val);
size_t socks5_client_request_getlen_dest_addr_ipv6(const socks5_client_request_t *inp);
uint8_t socks5_client_request_get_dest_addr_ipv6(socks5_client_request_t *inp, size_t idx);
uint8_t socks5_client_request_getconst_dest_addr_ipv6(const socks5_client_request_t *inp, size_t idx);
int socks5_client_request_set_dest_addr_ipv6(socks5_client_request_t *inp, size_t idx, uint8_t elt);
uint8_t * socks5_client_request_getarray_dest_addr_ipv6(socks5_client_request_t *inp);
const uint8_t * socks5_client_request_getconstarray_dest_addr_ipv6(const socks5_client_request_t *inp);
struct domainname_st * socks5_client_request_get_dest_addr_domainname(socks5_client_request_t *inp);
const struct domainname_st * socks5_client_request_getconst_dest_addr_domainname(const socks5_client_request_t *inp);
int socks5_client_request_set_dest_addr_domainname(socks5_client_request_t *inp, struct domainname_st *val);
int socks5_client_request_set0_dest_addr_domainname(socks5_client_request_t *inp, struct domainname_st *val);
uint16_t socks5_client_request_get_dest_port(const socks5_client_request_t *inp);
int socks5_client_request_set_dest_port(socks5_client_request_t *inp, uint16_t val);
socks5_server_reply_t *socks5_server_reply_new(void);
void socks5_server_reply_free(socks5_server_reply_t *victim);
ssize_t socks5_server_reply_parse(socks5_server_reply_t **output, const uint8_t *input, const size_t len_in);
ssize_t socks5_server_reply_encoded_len(const socks5_server_reply_t *obj);
ssize_t socks5_server_reply_encode(uint8_t *output, size_t avail, const socks5_server_reply_t *input);
const char *socks5_server_reply_check(const socks5_server_reply_t *obj);
int socks5_server_reply_clear_errors(socks5_server_reply_t *obj);
uint8_t socks5_server_reply_get_version(const socks5_server_reply_t *inp);
int socks5_server_reply_set_version(socks5_server_reply_t *inp, uint8_t val);
uint8_t socks5_server_reply_get_reply(const socks5_server_reply_t *inp);
int socks5_server_reply_set_reply(socks5_server_reply_t *inp, uint8_t val);
uint8_t socks5_server_reply_get_reserved(const socks5_server_reply_t *inp);
int socks5_server_reply_set_reserved(socks5_server_reply_t *inp, uint8_t val);
uint8_t socks5_server_reply_get_atype(const socks5_server_reply_t *inp);
int socks5_server_reply_set_atype(socks5_server_reply_t *inp, uint8_t val);
uint32_t socks5_server_reply_get_bind_addr_ipv4(const socks5_server_reply_t *inp);
int socks5_server_reply_set_bind_addr_ipv4(socks5_server_reply_t *inp, uint32_t val);
size_t socks5_server_reply_getlen_bind_addr_ipv6(const socks5_server_reply_t *inp);
uint8_t socks5_server_reply_get_bind_addr_ipv6(socks5_server_reply_t *inp, size_t idx);
uint8_t socks5_server_reply_getconst_bind_addr_ipv6(const socks5_server_reply_t *inp, size_t idx);
int socks5_server_reply_set_bind_addr_ipv6(socks5_server_reply_t *inp, size_t idx, uint8_t elt);
uint8_t * socks5_server_reply_getarray_bind_addr_ipv6(socks5_server_reply_t *inp);
const uint8_t * socks5_server_reply_getconstarray_bind_addr_ipv6(const socks5_server_reply_t *inp);
struct domainname_st * socks5_server_reply_get_bind_addr_domainname(socks5_server_reply_t *inp);
const struct domainname_st * socks5_server_reply_getconst_bind_addr_domainname(const socks5_server_reply_t *inp);
int socks5_server_reply_set_bind_addr_domainname(socks5_server_reply_t *inp, struct domainname_st *val);
int socks5_server_reply_set0_bind_addr_domainname(socks5_server_reply_t *inp, struct domainname_st *val);
uint16_t socks5_server_reply_get_bind_port(const socks5_server_reply_t *inp);
int socks5_server_reply_set_bind_port(socks5_server_reply_t *inp, uint16_t val);
#endif