Add padding negotiation trunnel output.

Co-authored-by: George Kadianakis <desnacked@riseup.net>
This commit is contained in:
Mike Perry
2018-10-23 19:51:35 +00:00
committed by George Kadianakis
parent 659a4f06d4
commit 4ca1df6b32
4 changed files with 795 additions and 4 deletions
+549
View File
@@ -0,0 +1,549 @@
/* circpad_negotiation.c -- generated by Trunnel v1.5.2.
* https://gitweb.torproject.org/trunnel.git
* You probably shouldn't edit this file.
*/
#include <stdlib.h>
#include "trunnel-impl.h"
#include "circpad_negotiation.h"
#define TRUNNEL_SET_ERROR_CODE(obj) \
do { \
(obj)->trunnel_error_code_ = 1; \
} while (0)
#if defined(__COVERITY__) || defined(__clang_analyzer__)
/* If we're running a static analysis tool, we don't want it to complain
* that some of our remaining-bytes checks are dead-code. */
int circpadnegotiation_deadcode_dummy__ = 0;
#define OR_DEADCODE_DUMMY || circpadnegotiation_deadcode_dummy__
#else
#define OR_DEADCODE_DUMMY
#endif
#define CHECK_REMAINING(nbytes, label) \
do { \
if (remaining < (nbytes) OR_DEADCODE_DUMMY) { \
goto label; \
} \
} while (0)
circpad_negotiate_t *
circpad_negotiate_new(void)
{
circpad_negotiate_t *val = trunnel_calloc(1, sizeof(circpad_negotiate_t));
if (NULL == val)
return NULL;
val->command = CIRCPAD_COMMAND_START;
return val;
}
/** Release all storage held inside 'obj', but do not free 'obj'.
*/
static void
circpad_negotiate_clear(circpad_negotiate_t *obj)
{
(void) obj;
}
void
circpad_negotiate_free(circpad_negotiate_t *obj)
{
if (obj == NULL)
return;
circpad_negotiate_clear(obj);
trunnel_memwipe(obj, sizeof(circpad_negotiate_t));
trunnel_free_(obj);
}
uint8_t
circpad_negotiate_get_version(const circpad_negotiate_t *inp)
{
return inp->version;
}
int
circpad_negotiate_set_version(circpad_negotiate_t *inp, uint8_t val)
{
if (! ((val == 0))) {
TRUNNEL_SET_ERROR_CODE(inp);
return -1;
}
inp->version = val;
return 0;
}
uint8_t
circpad_negotiate_get_command(const circpad_negotiate_t *inp)
{
return inp->command;
}
int
circpad_negotiate_set_command(circpad_negotiate_t *inp, uint8_t val)
{
if (! ((val == CIRCPAD_COMMAND_START || val == CIRCPAD_COMMAND_STOP))) {
TRUNNEL_SET_ERROR_CODE(inp);
return -1;
}
inp->command = val;
return 0;
}
uint8_t
circpad_negotiate_get_machine_type(const circpad_negotiate_t *inp)
{
return inp->machine_type;
}
int
circpad_negotiate_set_machine_type(circpad_negotiate_t *inp, uint8_t val)
{
inp->machine_type = val;
return 0;
}
uint8_t
circpad_negotiate_get_echo_request(const circpad_negotiate_t *inp)
{
return inp->echo_request;
}
int
circpad_negotiate_set_echo_request(circpad_negotiate_t *inp, uint8_t val)
{
if (! ((val == 0 || val == 1))) {
TRUNNEL_SET_ERROR_CODE(inp);
return -1;
}
inp->echo_request = val;
return 0;
}
const char *
circpad_negotiate_check(const circpad_negotiate_t *obj)
{
if (obj == NULL)
return "Object was NULL";
if (obj->trunnel_error_code_)
return "A set function failed on this object";
if (! (obj->version == 0))
return "Integer out of bounds";
if (! (obj->command == CIRCPAD_COMMAND_START || obj->command == CIRCPAD_COMMAND_STOP))
return "Integer out of bounds";
if (! (obj->echo_request == 0 || obj->echo_request == 1))
return "Integer out of bounds";
return NULL;
}
ssize_t
circpad_negotiate_encoded_len(const circpad_negotiate_t *obj)
{
ssize_t result = 0;
if (NULL != circpad_negotiate_check(obj))
return -1;
/* Length of u8 version IN [0] */
result += 1;
/* Length of u8 command IN [CIRCPAD_COMMAND_START, CIRCPAD_COMMAND_STOP] */
result += 1;
/* Length of u8 machine_type */
result += 1;
/* Length of u8 echo_request IN [0, 1] */
result += 1;
return result;
}
int
circpad_negotiate_clear_errors(circpad_negotiate_t *obj)
{
int r = obj->trunnel_error_code_;
obj->trunnel_error_code_ = 0;
return r;
}
ssize_t
circpad_negotiate_encode(uint8_t *output, const size_t avail, const circpad_negotiate_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 = circpad_negotiate_encoded_len(obj);
#endif
if (NULL != (msg = circpad_negotiate_check(obj)))
goto check_failed;
#ifdef TRUNNEL_CHECK_ENCODED_LEN
trunnel_assert(encoded_len >= 0);
#endif
/* Encode u8 version IN [0] */
trunnel_assert(written <= avail);
if (avail - written < 1)
goto truncated;
trunnel_set_uint8(ptr, (obj->version));
written += 1; ptr += 1;
/* Encode u8 command IN [CIRCPAD_COMMAND_START, CIRCPAD_COMMAND_STOP] */
trunnel_assert(written <= avail);
if (avail - written < 1)
goto truncated;
trunnel_set_uint8(ptr, (obj->command));
written += 1; ptr += 1;
/* Encode u8 machine_type */
trunnel_assert(written <= avail);
if (avail - written < 1)
goto truncated;
trunnel_set_uint8(ptr, (obj->machine_type));
written += 1; ptr += 1;
/* Encode u8 echo_request IN [0, 1] */
trunnel_assert(written <= avail);
if (avail - written < 1)
goto truncated;
trunnel_set_uint8(ptr, (obj->echo_request));
written += 1; ptr += 1;
trunnel_assert(ptr == output + written);
#ifdef TRUNNEL_CHECK_ENCODED_LEN
{
trunnel_assert(encoded_len >= 0);
trunnel_assert((size_t)encoded_len == written);
}
#endif
return written;
truncated:
result = -2;
goto fail;
check_failed:
(void)msg;
result = -1;
goto fail;
fail:
trunnel_assert(result < 0);
return result;
}
/** As circpad_negotiate_parse(), but do not allocate the output
* object.
*/
static ssize_t
circpad_negotiate_parse_into(circpad_negotiate_t *obj, const uint8_t *input, const size_t len_in)
{
const uint8_t *ptr = input;
size_t remaining = len_in;
ssize_t result = 0;
(void)result;
/* Parse u8 version IN [0] */
CHECK_REMAINING(1, truncated);
obj->version = (trunnel_get_uint8(ptr));
remaining -= 1; ptr += 1;
if (! (obj->version == 0))
goto fail;
/* Parse u8 command IN [CIRCPAD_COMMAND_START, CIRCPAD_COMMAND_STOP] */
CHECK_REMAINING(1, truncated);
obj->command = (trunnel_get_uint8(ptr));
remaining -= 1; ptr += 1;
if (! (obj->command == CIRCPAD_COMMAND_START || obj->command == CIRCPAD_COMMAND_STOP))
goto fail;
/* Parse u8 machine_type */
CHECK_REMAINING(1, truncated);
obj->machine_type = (trunnel_get_uint8(ptr));
remaining -= 1; ptr += 1;
/* Parse u8 echo_request IN [0, 1] */
CHECK_REMAINING(1, truncated);
obj->echo_request = (trunnel_get_uint8(ptr));
remaining -= 1; ptr += 1;
if (! (obj->echo_request == 0 || obj->echo_request == 1))
goto fail;
trunnel_assert(ptr + remaining == input + len_in);
return len_in - remaining;
truncated:
return -2;
fail:
result = -1;
return result;
}
ssize_t
circpad_negotiate_parse(circpad_negotiate_t **output, const uint8_t *input, const size_t len_in)
{
ssize_t result;
*output = circpad_negotiate_new();
if (NULL == *output)
return -1;
result = circpad_negotiate_parse_into(*output, input, len_in);
if (result < 0) {
circpad_negotiate_free(*output);
*output = NULL;
}
return result;
}
circpad_negotiated_t *
circpad_negotiated_new(void)
{
circpad_negotiated_t *val = trunnel_calloc(1, sizeof(circpad_negotiated_t));
if (NULL == val)
return NULL;
val->command = CIRCPAD_COMMAND_START;
val->response = CIRCPAD_RESPONSE_ERR;
return val;
}
/** Release all storage held inside 'obj', but do not free 'obj'.
*/
static void
circpad_negotiated_clear(circpad_negotiated_t *obj)
{
(void) obj;
}
void
circpad_negotiated_free(circpad_negotiated_t *obj)
{
if (obj == NULL)
return;
circpad_negotiated_clear(obj);
trunnel_memwipe(obj, sizeof(circpad_negotiated_t));
trunnel_free_(obj);
}
uint8_t
circpad_negotiated_get_version(const circpad_negotiated_t *inp)
{
return inp->version;
}
int
circpad_negotiated_set_version(circpad_negotiated_t *inp, uint8_t val)
{
if (! ((val == 0))) {
TRUNNEL_SET_ERROR_CODE(inp);
return -1;
}
inp->version = val;
return 0;
}
uint8_t
circpad_negotiated_get_command(const circpad_negotiated_t *inp)
{
return inp->command;
}
int
circpad_negotiated_set_command(circpad_negotiated_t *inp, uint8_t val)
{
if (! ((val == CIRCPAD_COMMAND_START || val == CIRCPAD_COMMAND_STOP))) {
TRUNNEL_SET_ERROR_CODE(inp);
return -1;
}
inp->command = val;
return 0;
}
uint8_t
circpad_negotiated_get_response(const circpad_negotiated_t *inp)
{
return inp->response;
}
int
circpad_negotiated_set_response(circpad_negotiated_t *inp, uint8_t val)
{
if (! ((val == CIRCPAD_RESPONSE_ERR || val == CIRCPAD_RESPONSE_OK))) {
TRUNNEL_SET_ERROR_CODE(inp);
return -1;
}
inp->response = val;
return 0;
}
uint8_t
circpad_negotiated_get_machine_type(const circpad_negotiated_t *inp)
{
return inp->machine_type;
}
int
circpad_negotiated_set_machine_type(circpad_negotiated_t *inp, uint8_t val)
{
inp->machine_type = val;
return 0;
}
const char *
circpad_negotiated_check(const circpad_negotiated_t *obj)
{
if (obj == NULL)
return "Object was NULL";
if (obj->trunnel_error_code_)
return "A set function failed on this object";
if (! (obj->version == 0))
return "Integer out of bounds";
if (! (obj->command == CIRCPAD_COMMAND_START || obj->command == CIRCPAD_COMMAND_STOP))
return "Integer out of bounds";
if (! (obj->response == CIRCPAD_RESPONSE_ERR || obj->response == CIRCPAD_RESPONSE_OK))
return "Integer out of bounds";
return NULL;
}
ssize_t
circpad_negotiated_encoded_len(const circpad_negotiated_t *obj)
{
ssize_t result = 0;
if (NULL != circpad_negotiated_check(obj))
return -1;
/* Length of u8 version IN [0] */
result += 1;
/* Length of u8 command IN [CIRCPAD_COMMAND_START, CIRCPAD_COMMAND_STOP] */
result += 1;
/* Length of u8 response IN [CIRCPAD_RESPONSE_ERR, CIRCPAD_RESPONSE_OK] */
result += 1;
/* Length of u8 machine_type */
result += 1;
return result;
}
int
circpad_negotiated_clear_errors(circpad_negotiated_t *obj)
{
int r = obj->trunnel_error_code_;
obj->trunnel_error_code_ = 0;
return r;
}
ssize_t
circpad_negotiated_encode(uint8_t *output, const size_t avail, const circpad_negotiated_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 = circpad_negotiated_encoded_len(obj);
#endif
if (NULL != (msg = circpad_negotiated_check(obj)))
goto check_failed;
#ifdef TRUNNEL_CHECK_ENCODED_LEN
trunnel_assert(encoded_len >= 0);
#endif
/* Encode u8 version IN [0] */
trunnel_assert(written <= avail);
if (avail - written < 1)
goto truncated;
trunnel_set_uint8(ptr, (obj->version));
written += 1; ptr += 1;
/* Encode u8 command IN [CIRCPAD_COMMAND_START, CIRCPAD_COMMAND_STOP] */
trunnel_assert(written <= avail);
if (avail - written < 1)
goto truncated;
trunnel_set_uint8(ptr, (obj->command));
written += 1; ptr += 1;
/* Encode u8 response IN [CIRCPAD_RESPONSE_ERR, CIRCPAD_RESPONSE_OK] */
trunnel_assert(written <= avail);
if (avail - written < 1)
goto truncated;
trunnel_set_uint8(ptr, (obj->response));
written += 1; ptr += 1;
/* Encode u8 machine_type */
trunnel_assert(written <= avail);
if (avail - written < 1)
goto truncated;
trunnel_set_uint8(ptr, (obj->machine_type));
written += 1; ptr += 1;
trunnel_assert(ptr == output + written);
#ifdef TRUNNEL_CHECK_ENCODED_LEN
{
trunnel_assert(encoded_len >= 0);
trunnel_assert((size_t)encoded_len == written);
}
#endif
return written;
truncated:
result = -2;
goto fail;
check_failed:
(void)msg;
result = -1;
goto fail;
fail:
trunnel_assert(result < 0);
return result;
}
/** As circpad_negotiated_parse(), but do not allocate the output
* object.
*/
static ssize_t
circpad_negotiated_parse_into(circpad_negotiated_t *obj, const uint8_t *input, const size_t len_in)
{
const uint8_t *ptr = input;
size_t remaining = len_in;
ssize_t result = 0;
(void)result;
/* Parse u8 version IN [0] */
CHECK_REMAINING(1, truncated);
obj->version = (trunnel_get_uint8(ptr));
remaining -= 1; ptr += 1;
if (! (obj->version == 0))
goto fail;
/* Parse u8 command IN [CIRCPAD_COMMAND_START, CIRCPAD_COMMAND_STOP] */
CHECK_REMAINING(1, truncated);
obj->command = (trunnel_get_uint8(ptr));
remaining -= 1; ptr += 1;
if (! (obj->command == CIRCPAD_COMMAND_START || obj->command == CIRCPAD_COMMAND_STOP))
goto fail;
/* Parse u8 response IN [CIRCPAD_RESPONSE_ERR, CIRCPAD_RESPONSE_OK] */
CHECK_REMAINING(1, truncated);
obj->response = (trunnel_get_uint8(ptr));
remaining -= 1; ptr += 1;
if (! (obj->response == CIRCPAD_RESPONSE_ERR || obj->response == CIRCPAD_RESPONSE_OK))
goto fail;
/* Parse u8 machine_type */
CHECK_REMAINING(1, truncated);
obj->machine_type = (trunnel_get_uint8(ptr));
remaining -= 1; ptr += 1;
trunnel_assert(ptr + remaining == input + len_in);
return len_in - remaining;
truncated:
return -2;
fail:
result = -1;
return result;
}
ssize_t
circpad_negotiated_parse(circpad_negotiated_t **output, const uint8_t *input, const size_t len_in)
{
ssize_t result;
*output = circpad_negotiated_new();
if (NULL == *output)
return -1;
result = circpad_negotiated_parse_into(*output, input, len_in);
if (result < 0) {
circpad_negotiated_free(*output);
*output = NULL;
}
return result;
}
+195
View File
@@ -0,0 +1,195 @@
/* circpad_negotiation.h -- generated by Trunnel v1.5.2.
* https://gitweb.torproject.org/trunnel.git
* You probably shouldn't edit this file.
*/
#ifndef TRUNNEL_CIRCPAD_NEGOTIATION_H
#define TRUNNEL_CIRCPAD_NEGOTIATION_H
#include <stdint.h>
#include "trunnel.h"
#define CIRCPAD_COMMAND_STOP 1
#define CIRCPAD_COMMAND_START 2
#define CIRCPAD_RESPONSE_OK 1
#define CIRCPAD_RESPONSE_ERR 2
#define CIRCPAD_MACHINE_CIRC_SETUP 1
/**
* This command tells the relay to alter its min and max netflow
* timeout range values, and send padding at that rate (resuming
* if stopped). */
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CIRCPAD_NEGOTIATE)
struct circpad_negotiate_st {
uint8_t version;
uint8_t command;
/** Machine type is left unbounded because we can specify
* new machines in the consensus */
uint8_t machine_type;
/** If true, send a relay_drop reply.. */
uint8_t echo_request;
uint8_t trunnel_error_code_;
};
#endif
typedef struct circpad_negotiate_st circpad_negotiate_t;
/**
* This command tells the relay to alter its min and max netflow
* timeout range values, and send padding at that rate (resuming
* if stopped). */
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CIRCPAD_NEGOTIATED)
struct circpad_negotiated_st {
uint8_t version;
uint8_t command;
uint8_t response;
/** Machine type is left unbounded because we can specify
* new machines in the consensus */
uint8_t machine_type;
uint8_t trunnel_error_code_;
};
#endif
typedef struct circpad_negotiated_st circpad_negotiated_t;
/** Return a newly allocated circpad_negotiate with all elements set
* to zero.
*/
circpad_negotiate_t *circpad_negotiate_new(void);
/** Release all storage held by the circpad_negotiate in 'victim'. (Do
* nothing if 'victim' is NULL.)
*/
void circpad_negotiate_free(circpad_negotiate_t *victim);
/** Try to parse a circpad_negotiate 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
* circpad_negotiate_t. On failure, return -2 if the input appears
* truncated, and -1 if the input is otherwise invalid.
*/
ssize_t circpad_negotiate_parse(circpad_negotiate_t **output, const uint8_t *input, const size_t len_in);
/** Return the number of bytes we expect to need to encode the
* circpad_negotiate 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 circpad_negotiate_encoded_len(const circpad_negotiate_t *obj);
/** Try to encode the circpad_negotiate 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 circpad_negotiate_encode(uint8_t *output, size_t avail, const circpad_negotiate_t *input);
/** Check whether the internal state of the circpad_negotiate in 'obj'
* is consistent. Return NULL if it is, and a short message if it is
* not.
*/
const char *circpad_negotiate_check(const circpad_negotiate_t *obj);
/** Clear any errors that were set on the object 'obj' by its setter
* functions. Return true iff errors were cleared.
*/
int circpad_negotiate_clear_errors(circpad_negotiate_t *obj);
/** Return the value of the version field of the circpad_negotiate_t
* in 'inp'
*/
uint8_t circpad_negotiate_get_version(const circpad_negotiate_t *inp);
/** Set the value of the version field of the circpad_negotiate_t in
* 'inp' to 'val'. Return 0 on success; return -1 and set the error
* code on 'inp' on failure.
*/
int circpad_negotiate_set_version(circpad_negotiate_t *inp, uint8_t val);
/** Return the value of the command field of the circpad_negotiate_t
* in 'inp'
*/
uint8_t circpad_negotiate_get_command(const circpad_negotiate_t *inp);
/** Set the value of the command field of the circpad_negotiate_t in
* 'inp' to 'val'. Return 0 on success; return -1 and set the error
* code on 'inp' on failure.
*/
int circpad_negotiate_set_command(circpad_negotiate_t *inp, uint8_t val);
/** Return the value of the machine_type field of the
* circpad_negotiate_t in 'inp'
*/
uint8_t circpad_negotiate_get_machine_type(const circpad_negotiate_t *inp);
/** Set the value of the machine_type field of the circpad_negotiate_t
* in 'inp' to 'val'. Return 0 on success; return -1 and set the error
* code on 'inp' on failure.
*/
int circpad_negotiate_set_machine_type(circpad_negotiate_t *inp, uint8_t val);
/** Return the value of the echo_request field of the
* circpad_negotiate_t in 'inp'
*/
uint8_t circpad_negotiate_get_echo_request(const circpad_negotiate_t *inp);
/** Set the value of the echo_request field of the circpad_negotiate_t
* in 'inp' to 'val'. Return 0 on success; return -1 and set the error
* code on 'inp' on failure.
*/
int circpad_negotiate_set_echo_request(circpad_negotiate_t *inp, uint8_t val);
/** Return a newly allocated circpad_negotiated with all elements set
* to zero.
*/
circpad_negotiated_t *circpad_negotiated_new(void);
/** Release all storage held by the circpad_negotiated in 'victim'.
* (Do nothing if 'victim' is NULL.)
*/
void circpad_negotiated_free(circpad_negotiated_t *victim);
/** Try to parse a circpad_negotiated 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 circpad_negotiated_t. On failure, return -2 if the input
* appears truncated, and -1 if the input is otherwise invalid.
*/
ssize_t circpad_negotiated_parse(circpad_negotiated_t **output, const uint8_t *input, const size_t len_in);
/** Return the number of bytes we expect to need to encode the
* circpad_negotiated 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 circpad_negotiated_encoded_len(const circpad_negotiated_t *obj);
/** Try to encode the circpad_negotiated 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 circpad_negotiated_encode(uint8_t *output, size_t avail, const circpad_negotiated_t *input);
/** Check whether the internal state of the circpad_negotiated in
* 'obj' is consistent. Return NULL if it is, and a short message if
* it is not.
*/
const char *circpad_negotiated_check(const circpad_negotiated_t *obj);
/** Clear any errors that were set on the object 'obj' by its setter
* functions. Return true iff errors were cleared.
*/
int circpad_negotiated_clear_errors(circpad_negotiated_t *obj);
/** Return the value of the version field of the circpad_negotiated_t
* in 'inp'
*/
uint8_t circpad_negotiated_get_version(const circpad_negotiated_t *inp);
/** Set the value of the version field of the circpad_negotiated_t in
* 'inp' to 'val'. Return 0 on success; return -1 and set the error
* code on 'inp' on failure.
*/
int circpad_negotiated_set_version(circpad_negotiated_t *inp, uint8_t val);
/** Return the value of the command field of the circpad_negotiated_t
* in 'inp'
*/
uint8_t circpad_negotiated_get_command(const circpad_negotiated_t *inp);
/** Set the value of the command field of the circpad_negotiated_t in
* 'inp' to 'val'. Return 0 on success; return -1 and set the error
* code on 'inp' on failure.
*/
int circpad_negotiated_set_command(circpad_negotiated_t *inp, uint8_t val);
/** Return the value of the response field of the circpad_negotiated_t
* in 'inp'
*/
uint8_t circpad_negotiated_get_response(const circpad_negotiated_t *inp);
/** Set the value of the response field of the circpad_negotiated_t in
* 'inp' to 'val'. Return 0 on success; return -1 and set the error
* code on 'inp' on failure.
*/
int circpad_negotiated_set_response(circpad_negotiated_t *inp, uint8_t val);
/** Return the value of the machine_type field of the
* circpad_negotiated_t in 'inp'
*/
uint8_t circpad_negotiated_get_machine_type(const circpad_negotiated_t *inp);
/** Set the value of the machine_type field of the
* circpad_negotiated_t in 'inp' to 'val'. Return 0 on success; return
* -1 and set the error code on 'inp' on failure.
*/
int circpad_negotiated_set_machine_type(circpad_negotiated_t *inp, uint8_t val);
#endif
+44
View File
@@ -0,0 +1,44 @@
/* These are the padding negotiation commands */
const CIRCPAD_COMMAND_STOP = 1;
const CIRCPAD_COMMAND_START = 2;
/* Responses to commands */
const CIRCPAD_RESPONSE_OK = 1;
const CIRCPAD_RESPONSE_ERR = 2;
/* Built-in machine types */
/* 1) Machine that obscures circuit setup */
const CIRCPAD_MACHINE_CIRC_SETUP = 1;
/**
* This command tells the relay to alter its min and max netflow
* timeout range values, and send padding at that rate (resuming
* if stopped). */
struct circpad_negotiate {
u8 version IN [0];
u8 command IN [CIRCPAD_COMMAND_START, CIRCPAD_COMMAND_STOP];
/** Machine type is left unbounded because we can specify
* new machines in the consensus */
u8 machine_type;
/** If true, send a relay_drop reply.. */
// FIXME-MP-AP: Maybe we just say to transition to the first state
// here instead.. Also what about delay before responding?
u8 echo_request IN [0,1];
};
/**
* This command tells the relay to alter its min and max netflow
* timeout range values, and send padding at that rate (resuming
* if stopped). */
struct circpad_negotiated {
u8 version IN [0];
u8 command IN [CIRCPAD_COMMAND_START, CIRCPAD_COMMAND_STOP];
u8 response IN [CIRCPAD_RESPONSE_OK, CIRCPAD_RESPONSE_ERR];
/** Machine type is left unbounded because we can specify
* new machines in the consensus */
u8 machine_type;
};
+7 -4
View File
@@ -11,7 +11,8 @@ TRUNNELINPUTS = \
src/trunnel/link_handshake.trunnel \
src/trunnel/pwbox.trunnel \
src/trunnel/channelpadding_negotiation.trunnel \
src/trunner/socks5.trunnel
src/trunnel/socks5.trunnel \
src/trunnel/circpad_negotiation.trunnel
TRUNNELSOURCES = \
src/ext/trunnel/trunnel.c \
@@ -23,8 +24,9 @@ TRUNNELSOURCES = \
src/trunnel/hs/cell_introduce1.c \
src/trunnel/hs/cell_rendezvous.c \
src/trunnel/channelpadding_negotiation.c \
src/trunnel/socks5.c \
src/trunnel/netinfo.c
src/trunnel/socks5.c \
src/trunnel/netinfo.c \
src/trunnel/circpad_negotiation.c
TRUNNELHEADERS = \
src/ext/trunnel/trunnel.h \
@@ -39,7 +41,8 @@ TRUNNELHEADERS = \
src/trunnel/hs/cell_rendezvous.h \
src/trunnel/channelpadding_negotiation.h \
src/trunnel/socks5.h \
src/trunnel/netinfo.h
src/trunnel/netinfo.h \
src/trunnel/circpad_negotiation.h
src_trunnel_libor_trunnel_a_SOURCES = $(TRUNNELSOURCES)
src_trunnel_libor_trunnel_a_CPPFLAGS = \