1 /* conflux.h -- generated by Trunnel v1.5.3.
2 * https://gitweb.torproject.org/trunnel.git
3 * You probably shouldn't edit this file.
5 #ifndef TRUNNEL_CONFLUX_H
6 #define TRUNNEL_CONFLUX_H
11 #define CONFLUX_UX_NO_OPINION 0
12 #define CONFLUX_UX_MIN_LATENCY 1
13 #define CONFLUX_UX_LOW_MEM_LATENCY 2
14 #define CONFLUX_UX_HIGH_THROUGHPUT 3
15 #define CONFLUX_UX_LOW_MEM_THROUGHPUT 4
16 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_CONFLUX_LINK)
17 struct trn_cell_conflux_link_st
{
19 TRUNNEL_DYNARRAY_HEAD(, uint8_t) payload
;
20 uint8_t trunnel_error_code_
;
23 typedef struct trn_cell_conflux_link_st trn_cell_conflux_link_t
;
24 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_CONFLUX_LINK_PAYLOAD_V1)
25 struct trn_cell_conflux_link_payload_v1_st
{
27 uint64_t last_seqno_sent
;
28 uint64_t last_seqno_recv
;
30 uint8_t trunnel_error_code_
;
33 typedef struct trn_cell_conflux_link_payload_v1_st trn_cell_conflux_link_payload_v1_t
;
34 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_CONFLUX_LINKED)
35 struct trn_cell_conflux_linked_st
{
37 TRUNNEL_DYNARRAY_HEAD(, uint8_t) payload
;
38 uint8_t trunnel_error_code_
;
41 typedef struct trn_cell_conflux_linked_st trn_cell_conflux_linked_t
;
42 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_CONFLUX_LINKED_ACK)
43 struct trn_cell_conflux_linked_ack_st
{
44 TRUNNEL_DYNARRAY_HEAD(, uint8_t) payload
;
45 uint8_t trunnel_error_code_
;
48 typedef struct trn_cell_conflux_linked_ack_st trn_cell_conflux_linked_ack_t
;
49 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_CONFLUX_SWITCH)
50 struct trn_cell_conflux_switch_st
{
52 uint8_t trunnel_error_code_
;
55 typedef struct trn_cell_conflux_switch_st trn_cell_conflux_switch_t
;
56 /** Return a newly allocated trn_cell_conflux_link with all elements
59 trn_cell_conflux_link_t
*trn_cell_conflux_link_new(void);
60 /** Release all storage held by the trn_cell_conflux_link in 'victim'.
61 * (Do nothing if 'victim' is NULL.)
63 void trn_cell_conflux_link_free(trn_cell_conflux_link_t
*victim
);
64 /** Try to parse a trn_cell_conflux_link from the buffer in 'input',
65 * using up to 'len_in' bytes from the input buffer. On success,
66 * return the number of bytes consumed and set *output to the newly
67 * allocated trn_cell_conflux_link_t. On failure, return -2 if the
68 * input appears truncated, and -1 if the input is otherwise invalid.
70 ssize_t
trn_cell_conflux_link_parse(trn_cell_conflux_link_t
**output
, const uint8_t *input
, const size_t len_in
);
71 /** Return the number of bytes we expect to need to encode the
72 * trn_cell_conflux_link in 'obj'. On failure, return a negative
73 * value. Note that this value may be an overestimate, and can even be
74 * an underestimate for certain unencodeable objects.
76 ssize_t
trn_cell_conflux_link_encoded_len(const trn_cell_conflux_link_t
*obj
);
77 /** Try to encode the trn_cell_conflux_link from 'input' into the
78 * buffer at 'output', using up to 'avail' bytes of the output buffer.
79 * On success, return the number of bytes used. On failure, return -2
80 * if the buffer was not long enough, and -1 if the input was invalid.
82 ssize_t
trn_cell_conflux_link_encode(uint8_t *output
, size_t avail
, const trn_cell_conflux_link_t
*input
);
83 /** Check whether the internal state of the trn_cell_conflux_link in
84 * 'obj' is consistent. Return NULL if it is, and a short message if
87 const char *trn_cell_conflux_link_check(const trn_cell_conflux_link_t
*obj
);
88 /** Clear any errors that were set on the object 'obj' by its setter
89 * functions. Return true iff errors were cleared.
91 int trn_cell_conflux_link_clear_errors(trn_cell_conflux_link_t
*obj
);
92 /** Return the value of the version field of the
93 * trn_cell_conflux_link_t in 'inp'
95 uint8_t trn_cell_conflux_link_get_version(const trn_cell_conflux_link_t
*inp
);
96 /** Set the value of the version field of the trn_cell_conflux_link_t
97 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
98 * code on 'inp' on failure.
100 int trn_cell_conflux_link_set_version(trn_cell_conflux_link_t
*inp
, uint8_t val
);
101 /** Return the length of the dynamic array holding the payload field
102 * of the trn_cell_conflux_link_t in 'inp'.
104 size_t trn_cell_conflux_link_getlen_payload(const trn_cell_conflux_link_t
*inp
);
105 /** Return the element at position 'idx' of the dynamic array field
106 * payload of the trn_cell_conflux_link_t in 'inp'.
108 uint8_t trn_cell_conflux_link_get_payload(trn_cell_conflux_link_t
*inp
, size_t idx
);
109 /** As trn_cell_conflux_link_get_payload, but take and return a const
112 uint8_t trn_cell_conflux_link_getconst_payload(const trn_cell_conflux_link_t
*inp
, size_t idx
);
113 /** Change the element at position 'idx' of the dynamic array field
114 * payload of the trn_cell_conflux_link_t in 'inp', so that it will
115 * hold the value 'elt'.
117 int trn_cell_conflux_link_set_payload(trn_cell_conflux_link_t
*inp
, size_t idx
, uint8_t elt
);
118 /** Append a new element 'elt' to the dynamic array field payload of
119 * the trn_cell_conflux_link_t in 'inp'.
121 int trn_cell_conflux_link_add_payload(trn_cell_conflux_link_t
*inp
, uint8_t elt
);
122 /** Return a pointer to the variable-length array field payload of
125 uint8_t * trn_cell_conflux_link_getarray_payload(trn_cell_conflux_link_t
*inp
);
126 /** As trn_cell_conflux_link_get_payload, but take and return a const
129 const uint8_t * trn_cell_conflux_link_getconstarray_payload(const trn_cell_conflux_link_t
*inp
);
130 /** Change the length of the variable-length array field payload of
131 * 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
132 * return -1 and set the error code on 'inp' on failure.
134 int trn_cell_conflux_link_setlen_payload(trn_cell_conflux_link_t
*inp
, size_t newlen
);
135 /** Return a newly allocated trn_cell_conflux_link_payload_v1 with all
136 * elements set to zero.
138 trn_cell_conflux_link_payload_v1_t
*trn_cell_conflux_link_payload_v1_new(void);
139 /** Release all storage held by the trn_cell_conflux_link_payload_v1
140 * in 'victim'. (Do nothing if 'victim' is NULL.)
142 void trn_cell_conflux_link_payload_v1_free(trn_cell_conflux_link_payload_v1_t
*victim
);
143 /** Try to parse a trn_cell_conflux_link_payload_v1 from the buffer in
144 * 'input', using up to 'len_in' bytes from the input buffer. On
145 * success, return the number of bytes consumed and set *output to the
146 * newly allocated trn_cell_conflux_link_payload_v1_t. On failure,
147 * return -2 if the input appears truncated, and -1 if the input is
150 ssize_t
trn_cell_conflux_link_payload_v1_parse(trn_cell_conflux_link_payload_v1_t
**output
, const uint8_t *input
, const size_t len_in
);
151 /** Return the number of bytes we expect to need to encode the
152 * trn_cell_conflux_link_payload_v1 in 'obj'. On failure, return a
153 * negative value. Note that this value may be an overestimate, and
154 * can even be an underestimate for certain unencodeable objects.
156 ssize_t
trn_cell_conflux_link_payload_v1_encoded_len(const trn_cell_conflux_link_payload_v1_t
*obj
);
157 /** Try to encode the trn_cell_conflux_link_payload_v1 from 'input'
158 * into the buffer at 'output', using up to 'avail' bytes of the
159 * output buffer. On success, return the number of bytes used. On
160 * failure, return -2 if the buffer was not long enough, and -1 if the
163 ssize_t
trn_cell_conflux_link_payload_v1_encode(uint8_t *output
, size_t avail
, const trn_cell_conflux_link_payload_v1_t
*input
);
164 /** Check whether the internal state of the
165 * trn_cell_conflux_link_payload_v1 in 'obj' is consistent. Return
166 * NULL if it is, and a short message if it is not.
168 const char *trn_cell_conflux_link_payload_v1_check(const trn_cell_conflux_link_payload_v1_t
*obj
);
169 /** Clear any errors that were set on the object 'obj' by its setter
170 * functions. Return true iff errors were cleared.
172 int trn_cell_conflux_link_payload_v1_clear_errors(trn_cell_conflux_link_payload_v1_t
*obj
);
173 /** Return the (constant) length of the array holding the nonce field
174 * of the trn_cell_conflux_link_payload_v1_t in 'inp'.
176 size_t trn_cell_conflux_link_payload_v1_getlen_nonce(const trn_cell_conflux_link_payload_v1_t
*inp
);
177 /** Return the element at position 'idx' of the fixed array field
178 * nonce of the trn_cell_conflux_link_payload_v1_t in 'inp'.
180 uint8_t trn_cell_conflux_link_payload_v1_get_nonce(trn_cell_conflux_link_payload_v1_t
*inp
, size_t idx
);
181 /** As trn_cell_conflux_link_payload_v1_get_nonce, but take and return
184 uint8_t trn_cell_conflux_link_payload_v1_getconst_nonce(const trn_cell_conflux_link_payload_v1_t
*inp
, size_t idx
);
185 /** Change the element at position 'idx' of the fixed array field
186 * nonce of the trn_cell_conflux_link_payload_v1_t in 'inp', so that
187 * it will hold the value 'elt'.
189 int trn_cell_conflux_link_payload_v1_set_nonce(trn_cell_conflux_link_payload_v1_t
*inp
, size_t idx
, uint8_t elt
);
190 /** Return a pointer to the 32-element array field nonce of 'inp'.
192 uint8_t * trn_cell_conflux_link_payload_v1_getarray_nonce(trn_cell_conflux_link_payload_v1_t
*inp
);
193 /** As trn_cell_conflux_link_payload_v1_get_nonce, but take and return
196 const uint8_t * trn_cell_conflux_link_payload_v1_getconstarray_nonce(const trn_cell_conflux_link_payload_v1_t
*inp
);
197 /** Return the value of the last_seqno_sent field of the
198 * trn_cell_conflux_link_payload_v1_t in 'inp'
200 uint64_t trn_cell_conflux_link_payload_v1_get_last_seqno_sent(const trn_cell_conflux_link_payload_v1_t
*inp
);
201 /** Set the value of the last_seqno_sent field of the
202 * trn_cell_conflux_link_payload_v1_t in 'inp' to 'val'. Return 0 on
203 * success; return -1 and set the error code on 'inp' on failure.
205 int trn_cell_conflux_link_payload_v1_set_last_seqno_sent(trn_cell_conflux_link_payload_v1_t
*inp
, uint64_t val
);
206 /** Return the value of the last_seqno_recv field of the
207 * trn_cell_conflux_link_payload_v1_t in 'inp'
209 uint64_t trn_cell_conflux_link_payload_v1_get_last_seqno_recv(const trn_cell_conflux_link_payload_v1_t
*inp
);
210 /** Set the value of the last_seqno_recv field of the
211 * trn_cell_conflux_link_payload_v1_t in 'inp' to 'val'. Return 0 on
212 * success; return -1 and set the error code on 'inp' on failure.
214 int trn_cell_conflux_link_payload_v1_set_last_seqno_recv(trn_cell_conflux_link_payload_v1_t
*inp
, uint64_t val
);
215 /** Return the value of the desired_ux field of the
216 * trn_cell_conflux_link_payload_v1_t in 'inp'
218 uint8_t trn_cell_conflux_link_payload_v1_get_desired_ux(const trn_cell_conflux_link_payload_v1_t
*inp
);
219 /** Set the value of the desired_ux field of the
220 * trn_cell_conflux_link_payload_v1_t in 'inp' to 'val'. Return 0 on
221 * success; return -1 and set the error code on 'inp' on failure.
223 int trn_cell_conflux_link_payload_v1_set_desired_ux(trn_cell_conflux_link_payload_v1_t
*inp
, uint8_t val
);
224 /** Return a newly allocated trn_cell_conflux_linked with all elements
227 trn_cell_conflux_linked_t
*trn_cell_conflux_linked_new(void);
228 /** Release all storage held by the trn_cell_conflux_linked in
229 * 'victim'. (Do nothing if 'victim' is NULL.)
231 void trn_cell_conflux_linked_free(trn_cell_conflux_linked_t
*victim
);
232 /** Try to parse a trn_cell_conflux_linked from the buffer in 'input',
233 * using up to 'len_in' bytes from the input buffer. On success,
234 * return the number of bytes consumed and set *output to the newly
235 * allocated trn_cell_conflux_linked_t. On failure, return -2 if the
236 * input appears truncated, and -1 if the input is otherwise invalid.
238 ssize_t
trn_cell_conflux_linked_parse(trn_cell_conflux_linked_t
**output
, const uint8_t *input
, const size_t len_in
);
239 /** Return the number of bytes we expect to need to encode the
240 * trn_cell_conflux_linked in 'obj'. On failure, return a negative
241 * value. Note that this value may be an overestimate, and can even be
242 * an underestimate for certain unencodeable objects.
244 ssize_t
trn_cell_conflux_linked_encoded_len(const trn_cell_conflux_linked_t
*obj
);
245 /** Try to encode the trn_cell_conflux_linked from 'input' into the
246 * buffer at 'output', using up to 'avail' bytes of the output buffer.
247 * On success, return the number of bytes used. On failure, return -2
248 * if the buffer was not long enough, and -1 if the input was invalid.
250 ssize_t
trn_cell_conflux_linked_encode(uint8_t *output
, size_t avail
, const trn_cell_conflux_linked_t
*input
);
251 /** Check whether the internal state of the trn_cell_conflux_linked in
252 * 'obj' is consistent. Return NULL if it is, and a short message if
255 const char *trn_cell_conflux_linked_check(const trn_cell_conflux_linked_t
*obj
);
256 /** Clear any errors that were set on the object 'obj' by its setter
257 * functions. Return true iff errors were cleared.
259 int trn_cell_conflux_linked_clear_errors(trn_cell_conflux_linked_t
*obj
);
260 /** Return the value of the version field of the
261 * trn_cell_conflux_linked_t in 'inp'
263 uint8_t trn_cell_conflux_linked_get_version(const trn_cell_conflux_linked_t
*inp
);
264 /** Set the value of the version field of the
265 * trn_cell_conflux_linked_t in 'inp' to 'val'. Return 0 on success;
266 * return -1 and set the error code on 'inp' on failure.
268 int trn_cell_conflux_linked_set_version(trn_cell_conflux_linked_t
*inp
, uint8_t val
);
269 /** Return the length of the dynamic array holding the payload field
270 * of the trn_cell_conflux_linked_t in 'inp'.
272 size_t trn_cell_conflux_linked_getlen_payload(const trn_cell_conflux_linked_t
*inp
);
273 /** Return the element at position 'idx' of the dynamic array field
274 * payload of the trn_cell_conflux_linked_t in 'inp'.
276 uint8_t trn_cell_conflux_linked_get_payload(trn_cell_conflux_linked_t
*inp
, size_t idx
);
277 /** As trn_cell_conflux_linked_get_payload, but take and return a
280 uint8_t trn_cell_conflux_linked_getconst_payload(const trn_cell_conflux_linked_t
*inp
, size_t idx
);
281 /** Change the element at position 'idx' of the dynamic array field
282 * payload of the trn_cell_conflux_linked_t in 'inp', so that it will
283 * hold the value 'elt'.
285 int trn_cell_conflux_linked_set_payload(trn_cell_conflux_linked_t
*inp
, size_t idx
, uint8_t elt
);
286 /** Append a new element 'elt' to the dynamic array field payload of
287 * the trn_cell_conflux_linked_t in 'inp'.
289 int trn_cell_conflux_linked_add_payload(trn_cell_conflux_linked_t
*inp
, uint8_t elt
);
290 /** Return a pointer to the variable-length array field payload of
293 uint8_t * trn_cell_conflux_linked_getarray_payload(trn_cell_conflux_linked_t
*inp
);
294 /** As trn_cell_conflux_linked_get_payload, but take and return a
297 const uint8_t * trn_cell_conflux_linked_getconstarray_payload(const trn_cell_conflux_linked_t
*inp
);
298 /** Change the length of the variable-length array field payload of
299 * 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
300 * return -1 and set the error code on 'inp' on failure.
302 int trn_cell_conflux_linked_setlen_payload(trn_cell_conflux_linked_t
*inp
, size_t newlen
);
303 /** Return a newly allocated trn_cell_conflux_linked_ack with all
304 * elements set to zero.
306 trn_cell_conflux_linked_ack_t
*trn_cell_conflux_linked_ack_new(void);
307 /** Release all storage held by the trn_cell_conflux_linked_ack in
308 * 'victim'. (Do nothing if 'victim' is NULL.)
310 void trn_cell_conflux_linked_ack_free(trn_cell_conflux_linked_ack_t
*victim
);
311 /** Try to parse a trn_cell_conflux_linked_ack from the buffer in
312 * 'input', using up to 'len_in' bytes from the input buffer. On
313 * success, return the number of bytes consumed and set *output to the
314 * newly allocated trn_cell_conflux_linked_ack_t. On failure, return
315 * -2 if the input appears truncated, and -1 if the input is otherwise
318 ssize_t
trn_cell_conflux_linked_ack_parse(trn_cell_conflux_linked_ack_t
**output
, const uint8_t *input
, const size_t len_in
);
319 /** Return the number of bytes we expect to need to encode the
320 * trn_cell_conflux_linked_ack in 'obj'. On failure, return a negative
321 * value. Note that this value may be an overestimate, and can even be
322 * an underestimate for certain unencodeable objects.
324 ssize_t
trn_cell_conflux_linked_ack_encoded_len(const trn_cell_conflux_linked_ack_t
*obj
);
325 /** Try to encode the trn_cell_conflux_linked_ack from 'input' into
326 * the buffer at 'output', using up to 'avail' bytes of the output
327 * buffer. On success, return the number of bytes used. On failure,
328 * return -2 if the buffer was not long enough, and -1 if the input
331 ssize_t
trn_cell_conflux_linked_ack_encode(uint8_t *output
, size_t avail
, const trn_cell_conflux_linked_ack_t
*input
);
332 /** Check whether the internal state of the
333 * trn_cell_conflux_linked_ack in 'obj' is consistent. Return NULL if
334 * it is, and a short message if it is not.
336 const char *trn_cell_conflux_linked_ack_check(const trn_cell_conflux_linked_ack_t
*obj
);
337 /** Clear any errors that were set on the object 'obj' by its setter
338 * functions. Return true iff errors were cleared.
340 int trn_cell_conflux_linked_ack_clear_errors(trn_cell_conflux_linked_ack_t
*obj
);
341 /** Return the length of the dynamic array holding the payload field
342 * of the trn_cell_conflux_linked_ack_t in 'inp'.
344 size_t trn_cell_conflux_linked_ack_getlen_payload(const trn_cell_conflux_linked_ack_t
*inp
);
345 /** Return the element at position 'idx' of the dynamic array field
346 * payload of the trn_cell_conflux_linked_ack_t in 'inp'.
348 uint8_t trn_cell_conflux_linked_ack_get_payload(trn_cell_conflux_linked_ack_t
*inp
, size_t idx
);
349 /** As trn_cell_conflux_linked_ack_get_payload, but take and return a
352 uint8_t trn_cell_conflux_linked_ack_getconst_payload(const trn_cell_conflux_linked_ack_t
*inp
, size_t idx
);
353 /** Change the element at position 'idx' of the dynamic array field
354 * payload of the trn_cell_conflux_linked_ack_t in 'inp', so that it
355 * will hold the value 'elt'.
357 int trn_cell_conflux_linked_ack_set_payload(trn_cell_conflux_linked_ack_t
*inp
, size_t idx
, uint8_t elt
);
358 /** Append a new element 'elt' to the dynamic array field payload of
359 * the trn_cell_conflux_linked_ack_t in 'inp'.
361 int trn_cell_conflux_linked_ack_add_payload(trn_cell_conflux_linked_ack_t
*inp
, uint8_t elt
);
362 /** Return a pointer to the variable-length array field payload of
365 uint8_t * trn_cell_conflux_linked_ack_getarray_payload(trn_cell_conflux_linked_ack_t
*inp
);
366 /** As trn_cell_conflux_linked_ack_get_payload, but take and return a
369 const uint8_t * trn_cell_conflux_linked_ack_getconstarray_payload(const trn_cell_conflux_linked_ack_t
*inp
);
370 /** Change the length of the variable-length array field payload of
371 * 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
372 * return -1 and set the error code on 'inp' on failure.
374 int trn_cell_conflux_linked_ack_setlen_payload(trn_cell_conflux_linked_ack_t
*inp
, size_t newlen
);
375 /** Return a newly allocated trn_cell_conflux_switch with all elements
378 trn_cell_conflux_switch_t
*trn_cell_conflux_switch_new(void);
379 /** Release all storage held by the trn_cell_conflux_switch in
380 * 'victim'. (Do nothing if 'victim' is NULL.)
382 void trn_cell_conflux_switch_free(trn_cell_conflux_switch_t
*victim
);
383 /** Try to parse a trn_cell_conflux_switch from the buffer in 'input',
384 * using up to 'len_in' bytes from the input buffer. On success,
385 * return the number of bytes consumed and set *output to the newly
386 * allocated trn_cell_conflux_switch_t. On failure, return -2 if the
387 * input appears truncated, and -1 if the input is otherwise invalid.
389 ssize_t
trn_cell_conflux_switch_parse(trn_cell_conflux_switch_t
**output
, const uint8_t *input
, const size_t len_in
);
390 /** Return the number of bytes we expect to need to encode the
391 * trn_cell_conflux_switch in 'obj'. On failure, return a negative
392 * value. Note that this value may be an overestimate, and can even be
393 * an underestimate for certain unencodeable objects.
395 ssize_t
trn_cell_conflux_switch_encoded_len(const trn_cell_conflux_switch_t
*obj
);
396 /** Try to encode the trn_cell_conflux_switch from 'input' into the
397 * buffer at 'output', using up to 'avail' bytes of the output buffer.
398 * On success, return the number of bytes used. On failure, return -2
399 * if the buffer was not long enough, and -1 if the input was invalid.
401 ssize_t
trn_cell_conflux_switch_encode(uint8_t *output
, size_t avail
, const trn_cell_conflux_switch_t
*input
);
402 /** Check whether the internal state of the trn_cell_conflux_switch in
403 * 'obj' is consistent. Return NULL if it is, and a short message if
406 const char *trn_cell_conflux_switch_check(const trn_cell_conflux_switch_t
*obj
);
407 /** Clear any errors that were set on the object 'obj' by its setter
408 * functions. Return true iff errors were cleared.
410 int trn_cell_conflux_switch_clear_errors(trn_cell_conflux_switch_t
*obj
);
411 /** Return the value of the seqnum field of the
412 * trn_cell_conflux_switch_t in 'inp'
414 uint32_t trn_cell_conflux_switch_get_seqnum(const trn_cell_conflux_switch_t
*inp
);
415 /** Set the value of the seqnum field of the trn_cell_conflux_switch_t
416 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
417 * code on 'inp' on failure.
419 int trn_cell_conflux_switch_set_seqnum(trn_cell_conflux_switch_t
*inp
, uint32_t val
);