congestion_control.h (3004B)
1 /* congestion_control.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_CONGESTION_CONTROL_H 6 #define TRUNNEL_CONGESTION_CONTROL_H 7 8 #include <stdint.h> 9 #include "trunnel.h" 10 11 #define TRUNNEL_EXT_TYPE_CC_FIELD_REQUEST 1 12 #define TRUNNEL_EXT_TYPE_CC_FIELD_RESPONSE 2 13 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_EXTENSION_FIELD_CC) 14 struct trn_extension_field_cc_st { 15 uint8_t sendme_inc; 16 uint8_t trunnel_error_code_; 17 }; 18 #endif 19 typedef struct trn_extension_field_cc_st trn_extension_field_cc_t; 20 /** Return a newly allocated trn_extension_field_cc with all elements 21 * set to zero. 22 */ 23 trn_extension_field_cc_t *trn_extension_field_cc_new(void); 24 /** Release all storage held by the trn_extension_field_cc in 25 * 'victim'. (Do nothing if 'victim' is NULL.) 26 */ 27 void trn_extension_field_cc_free(trn_extension_field_cc_t *victim); 28 /** Try to parse a trn_extension_field_cc from the buffer in 'input', 29 * using up to 'len_in' bytes from the input buffer. On success, 30 * return the number of bytes consumed and set *output to the newly 31 * allocated trn_extension_field_cc_t. On failure, return -2 if the 32 * input appears truncated, and -1 if the input is otherwise invalid. 33 */ 34 ssize_t trn_extension_field_cc_parse(trn_extension_field_cc_t **output, const uint8_t *input, const size_t len_in); 35 /** Return the number of bytes we expect to need to encode the 36 * trn_extension_field_cc in 'obj'. On failure, return a negative 37 * value. Note that this value may be an overestimate, and can even be 38 * an underestimate for certain unencodeable objects. 39 */ 40 ssize_t trn_extension_field_cc_encoded_len(const trn_extension_field_cc_t *obj); 41 /** Try to encode the trn_extension_field_cc from 'input' into the 42 * buffer at 'output', using up to 'avail' bytes of the output buffer. 43 * On success, return the number of bytes used. On failure, return -2 44 * if the buffer was not long enough, and -1 if the input was invalid. 45 */ 46 ssize_t trn_extension_field_cc_encode(uint8_t *output, size_t avail, const trn_extension_field_cc_t *input); 47 /** Check whether the internal state of the trn_extension_field_cc in 48 * 'obj' is consistent. Return NULL if it is, and a short message if 49 * it is not. 50 */ 51 const char *trn_extension_field_cc_check(const trn_extension_field_cc_t *obj); 52 /** Clear any errors that were set on the object 'obj' by its setter 53 * functions. Return true iff errors were cleared. 54 */ 55 int trn_extension_field_cc_clear_errors(trn_extension_field_cc_t *obj); 56 /** Return the value of the sendme_inc field of the 57 * trn_extension_field_cc_t in 'inp' 58 */ 59 uint8_t trn_extension_field_cc_get_sendme_inc(const trn_extension_field_cc_t *inp); 60 /** Set the value of the sendme_inc field of the 61 * trn_extension_field_cc_t in 'inp' to 'val'. Return 0 on success; 62 * return -1 and set the error code on 'inp' on failure. 63 */ 64 int trn_extension_field_cc_set_sendme_inc(trn_extension_field_cc_t *inp, uint8_t val); 65 66 67 #endif