Commit 75106a26 authored by rl1987's avatar rl1987 Committed by Nick Mathewson
Browse files

Fix type in socks5.trunnel

parent 853d9b86
......@@ -2838,10 +2838,10 @@ socks5_server_method_parse(socks5_server_method_t **output, const uint8_t *input
}
return result;
}
socks5_server_userpath_auth_t *
socks5_server_userpath_auth_new(void)
socks5_server_userpass_auth_t *
socks5_server_userpass_auth_new(void)
{
socks5_server_userpath_auth_t *val = trunnel_calloc(1, sizeof(socks5_server_userpath_auth_t));
socks5_server_userpass_auth_t *val = trunnel_calloc(1, sizeof(socks5_server_userpass_auth_t));
if (NULL == val)
return NULL;
val->version = 1;
......@@ -2851,28 +2851,28 @@ socks5_server_userpath_auth_new(void)
/** Release all storage held inside 'obj', but do not free 'obj'.
*/
static void
socks5_server_userpath_auth_clear(socks5_server_userpath_auth_t *obj)
socks5_server_userpass_auth_clear(socks5_server_userpass_auth_t *obj)
{
(void) obj;
}
void
socks5_server_userpath_auth_free(socks5_server_userpath_auth_t *obj)
socks5_server_userpass_auth_free(socks5_server_userpass_auth_t *obj)
{
if (obj == NULL)
return;
socks5_server_userpath_auth_clear(obj);
trunnel_memwipe(obj, sizeof(socks5_server_userpath_auth_t));
socks5_server_userpass_auth_clear(obj);
trunnel_memwipe(obj, sizeof(socks5_server_userpass_auth_t));
trunnel_free_(obj);
}
uint8_t
socks5_server_userpath_auth_get_version(const socks5_server_userpath_auth_t *inp)
socks5_server_userpass_auth_get_version(const socks5_server_userpass_auth_t *inp)
{
return inp->version;
}
int
socks5_server_userpath_auth_set_version(socks5_server_userpath_auth_t *inp, uint8_t val)
socks5_server_userpass_auth_set_version(socks5_server_userpass_auth_t *inp, uint8_t val)
{
if (! ((val == 1))) {
TRUNNEL_SET_ERROR_CODE(inp);
......@@ -2882,18 +2882,18 @@ socks5_server_userpath_auth_set_version(socks5_server_userpath_auth_t *inp, uint
return 0;
}
uint8_t
socks5_server_userpath_auth_get_status(const socks5_server_userpath_auth_t *inp)
socks5_server_userpass_auth_get_status(const socks5_server_userpass_auth_t *inp)
{
return inp->status;
}
int
socks5_server_userpath_auth_set_status(socks5_server_userpath_auth_t *inp, uint8_t val)
socks5_server_userpass_auth_set_status(socks5_server_userpass_auth_t *inp, uint8_t val)
{
inp->status = val;
return 0;
}
const char *
socks5_server_userpath_auth_check(const socks5_server_userpath_auth_t *obj)
socks5_server_userpass_auth_check(const socks5_server_userpass_auth_t *obj)
{
if (obj == NULL)
return "Object was NULL";
......@@ -2905,11 +2905,11 @@ socks5_server_userpath_auth_check(const socks5_server_userpath_auth_t *obj)
}
ssize_t
socks5_server_userpath_auth_encoded_len(const socks5_server_userpath_auth_t *obj)
socks5_server_userpass_auth_encoded_len(const socks5_server_userpass_auth_t *obj)
{
ssize_t result = 0;
if (NULL != socks5_server_userpath_auth_check(obj))
if (NULL != socks5_server_userpass_auth_check(obj))
return -1;
......@@ -2921,24 +2921,24 @@ socks5_server_userpath_auth_encoded_len(const socks5_server_userpath_auth_t *obj
return result;
}
int
socks5_server_userpath_auth_clear_errors(socks5_server_userpath_auth_t *obj)
socks5_server_userpass_auth_clear_errors(socks5_server_userpass_auth_t *obj)
{
int r = obj->trunnel_error_code_;
obj->trunnel_error_code_ = 0;
return r;
}
ssize_t
socks5_server_userpath_auth_encode(uint8_t *output, const size_t avail, const socks5_server_userpath_auth_t *obj)
socks5_server_userpass_auth_encode(uint8_t *output, const size_t avail, const socks5_server_userpass_auth_t *obj)
{
ssize_t result = 0;
size_t written = 0;
uint8_t *ptr = output;
const char *msg;
#ifdef TRUNNEL_CHECK_ENCODED_LEN
const ssize_t encoded_len = socks5_server_userpath_auth_encoded_len(obj);
const ssize_t encoded_len = socks5_server_userpass_auth_encoded_len(obj);
#endif
if (NULL != (msg = socks5_server_userpath_auth_check(obj)))
if (NULL != (msg = socks5_server_userpass_auth_check(obj)))
goto check_failed;
#ifdef TRUNNEL_CHECK_ENCODED_LEN
......@@ -2983,11 +2983,11 @@ socks5_server_userpath_auth_encode(uint8_t *output, const size_t avail, const so
return result;
}
/** As socks5_server_userpath_auth_parse(), but do not allocate the
/** As socks5_server_userpass_auth_parse(), but do not allocate the
* output object.
*/
static ssize_t
socks5_server_userpath_auth_parse_into(socks5_server_userpath_auth_t *obj, const uint8_t *input, const size_t len_in)
socks5_server_userpass_auth_parse_into(socks5_server_userpass_auth_t *obj, const uint8_t *input, const size_t len_in)
{
const uint8_t *ptr = input;
size_t remaining = len_in;
......@@ -3016,15 +3016,15 @@ socks5_server_userpath_auth_parse_into(socks5_server_userpath_auth_t *obj, const
}
ssize_t
socks5_server_userpath_auth_parse(socks5_server_userpath_auth_t **output, const uint8_t *input, const size_t len_in)
socks5_server_userpass_auth_parse(socks5_server_userpass_auth_t **output, const uint8_t *input, const size_t len_in)
{
ssize_t result;
*output = socks5_server_userpath_auth_new();
*output = socks5_server_userpass_auth_new();
if (NULL == *output)
return -1;
result = socks5_server_userpath_auth_parse_into(*output, input, len_in);
result = socks5_server_userpass_auth_parse_into(*output, input, len_in);
if (result < 0) {
socks5_server_userpath_auth_free(*output);
socks5_server_userpass_auth_free(*output);
*output = NULL;
}
return result;
......
......@@ -74,14 +74,14 @@ struct socks5_server_method_st {
};
#endif
typedef struct socks5_server_method_st socks5_server_method_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_SERVER_USERPATH_AUTH)
struct socks5_server_userpath_auth_st {
#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_userpath_auth_st socks5_server_userpath_auth_t;
typedef struct socks5_server_userpass_auth_st socks5_server_userpass_auth_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TOR_SOCKSAUTH_KEYVAL)
struct tor_socksauth_keyval_st {
uint16_t keylen;
......@@ -697,62 +697,62 @@ uint8_t socks5_server_method_get_method(const socks5_server_method_t *inp);
* code on 'inp' on failure.
*/
int socks5_server_method_set_method(socks5_server_method_t *inp, uint8_t val);
/** Return a newly allocated socks5_server_userpath_auth with all
/** Return a newly allocated socks5_server_userpass_auth with all
* elements set to zero.
*/
socks5_server_userpath_auth_t *socks5_server_userpath_auth_new(void);
/** Release all storage held by the socks5_server_userpath_auth in
socks5_server_userpass_auth_t *socks5_server_userpass_auth_new(void);
/** Release all storage held by the socks5_server_userpass_auth in
* 'victim'. (Do nothing if 'victim' is NULL.)
*/
void socks5_server_userpath_auth_free(socks5_server_userpath_auth_t *victim);
/** Try to parse a socks5_server_userpath_auth from the buffer in
void socks5_server_userpass_auth_free(socks5_server_userpass_auth_t *victim);
/** Try to parse a socks5_server_userpass_auth from the buffer in
* 'input', using up to 'len_in' bytes from the input buffer. On
* success, return the number of bytes consumed and set *output to the
* newly allocated socks5_server_userpath_auth_t. On failure, return
* newly allocated socks5_server_userpass_auth_t. On failure, return
* -2 if the input appears truncated, and -1 if the input is otherwise
* invalid.
*/
ssize_t socks5_server_userpath_auth_parse(socks5_server_userpath_auth_t **output, const uint8_t *input, const size_t len_in);
ssize_t socks5_server_userpass_auth_parse(socks5_server_userpass_auth_t **output, const uint8_t *input, const size_t len_in);
/** Return the number of bytes we expect to need to encode the
* socks5_server_userpath_auth in 'obj'. On failure, return a negative
* socks5_server_userpass_auth in 'obj'. On failure, return a negative
* value. Note that this value may be an overestimate, and can even be
* an underestimate for certain unencodeable objects.
*/
ssize_t socks5_server_userpath_auth_encoded_len(const socks5_server_userpath_auth_t *obj);
/** Try to encode the socks5_server_userpath_auth from 'input' into
ssize_t socks5_server_userpass_auth_encoded_len(const socks5_server_userpass_auth_t *obj);
/** Try to encode the socks5_server_userpass_auth from 'input' into
* the buffer at 'output', using up to 'avail' bytes of the output
* buffer. On success, return the number of bytes used. On failure,
* return -2 if the buffer was not long enough, and -1 if the input
* was invalid.
*/
ssize_t socks5_server_userpath_auth_encode(uint8_t *output, size_t avail, const socks5_server_userpath_auth_t *input);
ssize_t socks5_server_userpass_auth_encode(uint8_t *output, size_t avail, const socks5_server_userpass_auth_t *input);
/** Check whether the internal state of the
* socks5_server_userpath_auth in 'obj' is consistent. Return NULL if
* socks5_server_userpass_auth in 'obj' is consistent. Return NULL if
* it is, and a short message if it is not.
*/
const char *socks5_server_userpath_auth_check(const socks5_server_userpath_auth_t *obj);
const char *socks5_server_userpass_auth_check(const socks5_server_userpass_auth_t *obj);
/** Clear any errors that were set on the object 'obj' by its setter
* functions. Return true iff errors were cleared.
*/
int socks5_server_userpath_auth_clear_errors(socks5_server_userpath_auth_t *obj);
int socks5_server_userpass_auth_clear_errors(socks5_server_userpass_auth_t *obj);
/** Return the value of the version field of the
* socks5_server_userpath_auth_t in 'inp'
* socks5_server_userpass_auth_t in 'inp'
*/
uint8_t socks5_server_userpath_auth_get_version(const socks5_server_userpath_auth_t *inp);
uint8_t socks5_server_userpass_auth_get_version(const socks5_server_userpass_auth_t *inp);
/** Set the value of the version field of the
* socks5_server_userpath_auth_t in 'inp' to 'val'. Return 0 on
* socks5_server_userpass_auth_t in 'inp' to 'val'. Return 0 on
* success; return -1 and set the error code on 'inp' on failure.
*/
int socks5_server_userpath_auth_set_version(socks5_server_userpath_auth_t *inp, uint8_t val);
int socks5_server_userpass_auth_set_version(socks5_server_userpass_auth_t *inp, uint8_t val);
/** Return the value of the status field of the
* socks5_server_userpath_auth_t in 'inp'
* socks5_server_userpass_auth_t in 'inp'
*/
uint8_t socks5_server_userpath_auth_get_status(const socks5_server_userpath_auth_t *inp);
uint8_t socks5_server_userpass_auth_get_status(const socks5_server_userpass_auth_t *inp);
/** Set the value of the status field of the
* socks5_server_userpath_auth_t in 'inp' to 'val'. Return 0 on
* socks5_server_userpass_auth_t in 'inp' to 'val'. Return 0 on
* success; return -1 and set the error code on 'inp' on failure.
*/
int socks5_server_userpath_auth_set_status(socks5_server_userpath_auth_t *inp, uint8_t val);
int socks5_server_userpass_auth_set_status(socks5_server_userpass_auth_t *inp, uint8_t val);
/** Return a newly allocated tor_socksauth_keyval with all elements
* set to zero.
*/
......
......@@ -64,7 +64,7 @@ struct socks5_client_userpass_auth {
char passwd[passwd_len];
}
struct socks5_server_userpath_auth {
struct socks5_server_userpass_auth {
u8 version IN [1];
u8 status;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment