Update geoip files to match ipfire location db, 2023/07/12.
[tor.git] / src / trunnel / flow_control_cells.h
blobb8108b9a248e2b5d815559ecd9793d455fa74e22
1 /* flow_control_cells.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_FLOW_CONTROL_CELLS_H
6 #define TRUNNEL_FLOW_CONTROL_CELLS_H
8 #include <stdint.h>
9 #include "trunnel.h"
11 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_XOFF_CELL)
12 struct xoff_cell_st {
13 uint8_t version;
14 uint8_t trunnel_error_code_;
16 #endif
17 typedef struct xoff_cell_st xoff_cell_t;
18 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_XON_CELL)
19 struct xon_cell_st {
20 uint8_t version;
21 uint32_t kbps_ewma;
22 uint8_t trunnel_error_code_;
24 #endif
25 typedef struct xon_cell_st xon_cell_t;
26 /** Return a newly allocated xoff_cell with all elements set to zero.
28 xoff_cell_t *xoff_cell_new(void);
29 /** Release all storage held by the xoff_cell in 'victim'. (Do nothing
30 * if 'victim' is NULL.)
32 void xoff_cell_free(xoff_cell_t *victim);
33 /** Try to parse a xoff_cell from the buffer in 'input', using up to
34 * 'len_in' bytes from the input buffer. On success, return the number
35 * of bytes consumed and set *output to the newly allocated
36 * xoff_cell_t. On failure, return -2 if the input appears truncated,
37 * and -1 if the input is otherwise invalid.
39 ssize_t xoff_cell_parse(xoff_cell_t **output, const uint8_t *input, const size_t len_in);
40 /** Return the number of bytes we expect to need to encode the
41 * xoff_cell in 'obj'. On failure, return a negative value. Note that
42 * this value may be an overestimate, and can even be an underestimate
43 * for certain unencodeable objects.
45 ssize_t xoff_cell_encoded_len(const xoff_cell_t *obj);
46 /** Try to encode the xoff_cell from 'input' into the buffer at
47 * 'output', using up to 'avail' bytes of the output buffer. On
48 * success, return the number of bytes used. On failure, return -2 if
49 * the buffer was not long enough, and -1 if the input was invalid.
51 ssize_t xoff_cell_encode(uint8_t *output, size_t avail, const xoff_cell_t *input);
52 /** Check whether the internal state of the xoff_cell in 'obj' is
53 * consistent. Return NULL if it is, and a short message if it is not.
55 const char *xoff_cell_check(const xoff_cell_t *obj);
56 /** Clear any errors that were set on the object 'obj' by its setter
57 * functions. Return true iff errors were cleared.
59 int xoff_cell_clear_errors(xoff_cell_t *obj);
60 /** Return the value of the version field of the xoff_cell_t in 'inp'
62 uint8_t xoff_cell_get_version(const xoff_cell_t *inp);
63 /** Set the value of the version field of the xoff_cell_t in 'inp' to
64 * 'val'. Return 0 on success; return -1 and set the error code on
65 * 'inp' on failure.
67 int xoff_cell_set_version(xoff_cell_t *inp, uint8_t val);
68 /** Return a newly allocated xon_cell with all elements set to zero.
70 xon_cell_t *xon_cell_new(void);
71 /** Release all storage held by the xon_cell in 'victim'. (Do nothing
72 * if 'victim' is NULL.)
74 void xon_cell_free(xon_cell_t *victim);
75 /** Try to parse a xon_cell from the buffer in 'input', using up to
76 * 'len_in' bytes from the input buffer. On success, return the number
77 * of bytes consumed and set *output to the newly allocated
78 * xon_cell_t. On failure, return -2 if the input appears truncated,
79 * and -1 if the input is otherwise invalid.
81 ssize_t xon_cell_parse(xon_cell_t **output, const uint8_t *input, const size_t len_in);
82 /** Return the number of bytes we expect to need to encode the
83 * xon_cell in 'obj'. On failure, return a negative value. Note that
84 * this value may be an overestimate, and can even be an underestimate
85 * for certain unencodeable objects.
87 ssize_t xon_cell_encoded_len(const xon_cell_t *obj);
88 /** Try to encode the xon_cell from 'input' into the buffer at
89 * 'output', using up to 'avail' bytes of the output buffer. On
90 * success, return the number of bytes used. On failure, return -2 if
91 * the buffer was not long enough, and -1 if the input was invalid.
93 ssize_t xon_cell_encode(uint8_t *output, size_t avail, const xon_cell_t *input);
94 /** Check whether the internal state of the xon_cell in 'obj' is
95 * consistent. Return NULL if it is, and a short message if it is not.
97 const char *xon_cell_check(const xon_cell_t *obj);
98 /** Clear any errors that were set on the object 'obj' by its setter
99 * functions. Return true iff errors were cleared.
101 int xon_cell_clear_errors(xon_cell_t *obj);
102 /** Return the value of the version field of the xon_cell_t in 'inp'
104 uint8_t xon_cell_get_version(const xon_cell_t *inp);
105 /** Set the value of the version field of the xon_cell_t in 'inp' to
106 * 'val'. Return 0 on success; return -1 and set the error code on
107 * 'inp' on failure.
109 int xon_cell_set_version(xon_cell_t *inp, uint8_t val);
110 /** Return the value of the kbps_ewma field of the xon_cell_t in 'inp'
112 uint32_t xon_cell_get_kbps_ewma(const xon_cell_t *inp);
113 /** Set the value of the kbps_ewma field of the xon_cell_t in 'inp' to
114 * 'val'. Return 0 on success; return -1 and set the error code on
115 * 'inp' on failure.
117 int xon_cell_set_kbps_ewma(xon_cell_t *inp, uint32_t val);
120 #endif