channelpadding_negotiation.h (4490B)
1 /* channelpadding_negotiation.h -- generated by Trunnel v1.5.3. 2 * https://gitweb.torproject.org/trunnel.git 3 * You probably shouldn't edit this file. 4 */ 5 #ifndef TRUNNEL_CHANNELPADDING_NEGOTIATION_H 6 #define TRUNNEL_CHANNELPADDING_NEGOTIATION_H 7 8 #include <stdint.h> 9 #include "trunnel.h" 10 11 #define CHANNELPADDING_COMMAND_STOP 1 12 #define CHANNELPADDING_COMMAND_START 2 13 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CHANNELPADDING_NEGOTIATE) 14 struct channelpadding_negotiate_st { 15 uint8_t version; 16 uint8_t command; 17 uint16_t ito_low_ms; 18 uint16_t ito_high_ms; 19 uint8_t trunnel_error_code_; 20 }; 21 #endif 22 typedef struct channelpadding_negotiate_st channelpadding_negotiate_t; 23 /** Return a newly allocated channelpadding_negotiate with all 24 * elements set to zero. 25 */ 26 channelpadding_negotiate_t *channelpadding_negotiate_new(void); 27 /** Release all storage held by the channelpadding_negotiate in 28 * 'victim'. (Do nothing if 'victim' is NULL.) 29 */ 30 void channelpadding_negotiate_free(channelpadding_negotiate_t *victim); 31 /** Try to parse a channelpadding_negotiate from the buffer in 32 * 'input', using up to 'len_in' bytes from the input buffer. On 33 * success, return the number of bytes consumed and set *output to the 34 * newly allocated channelpadding_negotiate_t. On failure, return -2 35 * if the input appears truncated, and -1 if the input is otherwise 36 * invalid. 37 */ 38 ssize_t channelpadding_negotiate_parse(channelpadding_negotiate_t **output, const uint8_t *input, const size_t len_in); 39 /** Return the number of bytes we expect to need to encode the 40 * channelpadding_negotiate in 'obj'. On failure, return a negative 41 * value. Note that this value may be an overestimate, and can even be 42 * an underestimate for certain unencodeable objects. 43 */ 44 ssize_t channelpadding_negotiate_encoded_len(const channelpadding_negotiate_t *obj); 45 /** Try to encode the channelpadding_negotiate from 'input' into the 46 * buffer at 'output', using up to 'avail' bytes of the output buffer. 47 * On success, return the number of bytes used. On failure, return -2 48 * if the buffer was not long enough, and -1 if the input was invalid. 49 */ 50 ssize_t channelpadding_negotiate_encode(uint8_t *output, size_t avail, const channelpadding_negotiate_t *input); 51 /** Check whether the internal state of the channelpadding_negotiate 52 * in 'obj' is consistent. Return NULL if it is, and a short message 53 * if it is not. 54 */ 55 const char *channelpadding_negotiate_check(const channelpadding_negotiate_t *obj); 56 /** Clear any errors that were set on the object 'obj' by its setter 57 * functions. Return true iff errors were cleared. 58 */ 59 int channelpadding_negotiate_clear_errors(channelpadding_negotiate_t *obj); 60 /** Return the value of the version field of the 61 * channelpadding_negotiate_t in 'inp' 62 */ 63 uint8_t channelpadding_negotiate_get_version(const channelpadding_negotiate_t *inp); 64 /** Set the value of the version field of the 65 * channelpadding_negotiate_t in 'inp' to 'val'. Return 0 on success; 66 * return -1 and set the error code on 'inp' on failure. 67 */ 68 int channelpadding_negotiate_set_version(channelpadding_negotiate_t *inp, uint8_t val); 69 /** Return the value of the command field of the 70 * channelpadding_negotiate_t in 'inp' 71 */ 72 uint8_t channelpadding_negotiate_get_command(const channelpadding_negotiate_t *inp); 73 /** Set the value of the command field of the 74 * channelpadding_negotiate_t in 'inp' to 'val'. Return 0 on success; 75 * return -1 and set the error code on 'inp' on failure. 76 */ 77 int channelpadding_negotiate_set_command(channelpadding_negotiate_t *inp, uint8_t val); 78 /** Return the value of the ito_low_ms field of the 79 * channelpadding_negotiate_t in 'inp' 80 */ 81 uint16_t channelpadding_negotiate_get_ito_low_ms(const channelpadding_negotiate_t *inp); 82 /** Set the value of the ito_low_ms field of the 83 * channelpadding_negotiate_t in 'inp' to 'val'. Return 0 on success; 84 * return -1 and set the error code on 'inp' on failure. 85 */ 86 int channelpadding_negotiate_set_ito_low_ms(channelpadding_negotiate_t *inp, uint16_t val); 87 /** Return the value of the ito_high_ms field of the 88 * channelpadding_negotiate_t in 'inp' 89 */ 90 uint16_t channelpadding_negotiate_get_ito_high_ms(const channelpadding_negotiate_t *inp); 91 /** Set the value of the ito_high_ms field of the 92 * channelpadding_negotiate_t in 'inp' to 'val'. Return 0 on success; 93 * return -1 and set the error code on 'inp' on failure. 94 */ 95 int channelpadding_negotiate_set_ito_high_ms(channelpadding_negotiate_t *inp, uint16_t val); 96 97 98 #endif