cell_establish_intro.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. /* cell_establish_intro.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_CELL_ESTABLISH_INTRO_H
  6. #define TRUNNEL_CELL_ESTABLISH_INTRO_H
  7. #include <stdint.h>
  8. #include "trunnel.h"
  9. struct trn_cell_extension_st;
  10. #define TRUNNEL_SHA3_256_LEN 32
  11. #define TRUNNEL_CELL_EXTENSION_TYPE_DOS 1
  12. #define TRUNNEL_DOS_PARAM_TYPE_INTRO2_RATE_PER_SEC 1
  13. #define TRUNNEL_DOS_PARAM_TYPE_INTRO2_BURST_PER_SEC 2
  14. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_EXTENSION_DOS_PARAM)
  15. struct trn_cell_extension_dos_param_st {
  16. uint8_t type;
  17. uint64_t value;
  18. uint8_t trunnel_error_code_;
  19. };
  20. #endif
  21. typedef struct trn_cell_extension_dos_param_st trn_cell_extension_dos_param_t;
  22. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_ESTABLISH_INTRO)
  23. struct trn_cell_establish_intro_st {
  24. const uint8_t *start_cell;
  25. uint8_t auth_key_type;
  26. uint16_t auth_key_len;
  27. TRUNNEL_DYNARRAY_HEAD(, uint8_t) auth_key;
  28. struct trn_cell_extension_st *extensions;
  29. const uint8_t *end_mac_fields;
  30. uint8_t handshake_mac[TRUNNEL_SHA3_256_LEN];
  31. const uint8_t *end_sig_fields;
  32. uint16_t sig_len;
  33. TRUNNEL_DYNARRAY_HEAD(, uint8_t) sig;
  34. uint8_t trunnel_error_code_;
  35. };
  36. #endif
  37. typedef struct trn_cell_establish_intro_st trn_cell_establish_intro_t;
  38. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_EXTENSION_DOS)
  39. struct trn_cell_extension_dos_st {
  40. uint8_t n_params;
  41. TRUNNEL_DYNARRAY_HEAD(, struct trn_cell_extension_dos_param_st *) params;
  42. uint8_t trunnel_error_code_;
  43. };
  44. #endif
  45. typedef struct trn_cell_extension_dos_st trn_cell_extension_dos_t;
  46. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_INTRO_ESTABLISHED)
  47. struct trn_cell_intro_established_st {
  48. struct trn_cell_extension_st *extensions;
  49. uint8_t trunnel_error_code_;
  50. };
  51. #endif
  52. typedef struct trn_cell_intro_established_st trn_cell_intro_established_t;
  53. /** Return a newly allocated trn_cell_extension_dos_param with all
  54. * elements set to zero.
  55. */
  56. trn_cell_extension_dos_param_t *trn_cell_extension_dos_param_new(void);
  57. /** Release all storage held by the trn_cell_extension_dos_param in
  58. * 'victim'. (Do nothing if 'victim' is NULL.)
  59. */
  60. void trn_cell_extension_dos_param_free(trn_cell_extension_dos_param_t *victim);
  61. /** Try to parse a trn_cell_extension_dos_param from the buffer in
  62. * 'input', using up to 'len_in' bytes from the input buffer. On
  63. * success, return the number of bytes consumed and set *output to the
  64. * newly allocated trn_cell_extension_dos_param_t. On failure, return
  65. * -2 if the input appears truncated, and -1 if the input is otherwise
  66. * invalid.
  67. */
  68. ssize_t trn_cell_extension_dos_param_parse(trn_cell_extension_dos_param_t **output, const uint8_t *input, const size_t len_in);
  69. /** Return the number of bytes we expect to need to encode the
  70. * trn_cell_extension_dos_param in 'obj'. On failure, return a
  71. * negative value. Note that this value may be an overestimate, and
  72. * can even be an underestimate for certain unencodeable objects.
  73. */
  74. ssize_t trn_cell_extension_dos_param_encoded_len(const trn_cell_extension_dos_param_t *obj);
  75. /** Try to encode the trn_cell_extension_dos_param from 'input' into
  76. * the buffer at 'output', using up to 'avail' bytes of the output
  77. * buffer. On success, return the number of bytes used. On failure,
  78. * return -2 if the buffer was not long enough, and -1 if the input
  79. * was invalid.
  80. */
  81. ssize_t trn_cell_extension_dos_param_encode(uint8_t *output, size_t avail, const trn_cell_extension_dos_param_t *input);
  82. /** Check whether the internal state of the
  83. * trn_cell_extension_dos_param in 'obj' is consistent. Return NULL if
  84. * it is, and a short message if it is not.
  85. */
  86. const char *trn_cell_extension_dos_param_check(const trn_cell_extension_dos_param_t *obj);
  87. /** Clear any errors that were set on the object 'obj' by its setter
  88. * functions. Return true iff errors were cleared.
  89. */
  90. int trn_cell_extension_dos_param_clear_errors(trn_cell_extension_dos_param_t *obj);
  91. /** Return the value of the type field of the
  92. * trn_cell_extension_dos_param_t in 'inp'
  93. */
  94. uint8_t trn_cell_extension_dos_param_get_type(const trn_cell_extension_dos_param_t *inp);
  95. /** Set the value of the type field of the
  96. * trn_cell_extension_dos_param_t in 'inp' to 'val'. Return 0 on
  97. * success; return -1 and set the error code on 'inp' on failure.
  98. */
  99. int trn_cell_extension_dos_param_set_type(trn_cell_extension_dos_param_t *inp, uint8_t val);
  100. /** Return the value of the value field of the
  101. * trn_cell_extension_dos_param_t in 'inp'
  102. */
  103. uint64_t trn_cell_extension_dos_param_get_value(const trn_cell_extension_dos_param_t *inp);
  104. /** Set the value of the value field of the
  105. * trn_cell_extension_dos_param_t in 'inp' to 'val'. Return 0 on
  106. * success; return -1 and set the error code on 'inp' on failure.
  107. */
  108. int trn_cell_extension_dos_param_set_value(trn_cell_extension_dos_param_t *inp, uint64_t val);
  109. /** Return a newly allocated trn_cell_establish_intro with all
  110. * elements set to zero.
  111. */
  112. trn_cell_establish_intro_t *trn_cell_establish_intro_new(void);
  113. /** Release all storage held by the trn_cell_establish_intro in
  114. * 'victim'. (Do nothing if 'victim' is NULL.)
  115. */
  116. void trn_cell_establish_intro_free(trn_cell_establish_intro_t *victim);
  117. /** Try to parse a trn_cell_establish_intro from the buffer in
  118. * 'input', using up to 'len_in' bytes from the input buffer. On
  119. * success, return the number of bytes consumed and set *output to the
  120. * newly allocated trn_cell_establish_intro_t. On failure, return -2
  121. * if the input appears truncated, and -1 if the input is otherwise
  122. * invalid.
  123. */
  124. ssize_t trn_cell_establish_intro_parse(trn_cell_establish_intro_t **output, const uint8_t *input, const size_t len_in);
  125. /** Return the number of bytes we expect to need to encode the
  126. * trn_cell_establish_intro in 'obj'. On failure, return a negative
  127. * value. Note that this value may be an overestimate, and can even be
  128. * an underestimate for certain unencodeable objects.
  129. */
  130. ssize_t trn_cell_establish_intro_encoded_len(const trn_cell_establish_intro_t *obj);
  131. /** Try to encode the trn_cell_establish_intro from 'input' into the
  132. * buffer at 'output', using up to 'avail' bytes of the output buffer.
  133. * On success, return the number of bytes used. On failure, return -2
  134. * if the buffer was not long enough, and -1 if the input was invalid.
  135. */
  136. ssize_t trn_cell_establish_intro_encode(uint8_t *output, size_t avail, const trn_cell_establish_intro_t *input);
  137. /** Check whether the internal state of the trn_cell_establish_intro
  138. * in 'obj' is consistent. Return NULL if it is, and a short message
  139. * if it is not.
  140. */
  141. const char *trn_cell_establish_intro_check(const trn_cell_establish_intro_t *obj);
  142. /** Clear any errors that were set on the object 'obj' by its setter
  143. * functions. Return true iff errors were cleared.
  144. */
  145. int trn_cell_establish_intro_clear_errors(trn_cell_establish_intro_t *obj);
  146. /** Return the position for start_cell when we parsed this object
  147. */
  148. const uint8_t * trn_cell_establish_intro_get_start_cell(const trn_cell_establish_intro_t *inp);
  149. /** Return the value of the auth_key_type field of the
  150. * trn_cell_establish_intro_t in 'inp'
  151. */
  152. uint8_t trn_cell_establish_intro_get_auth_key_type(const trn_cell_establish_intro_t *inp);
  153. /** Set the value of the auth_key_type field of the
  154. * trn_cell_establish_intro_t in 'inp' to 'val'. Return 0 on success;
  155. * return -1 and set the error code on 'inp' on failure.
  156. */
  157. int trn_cell_establish_intro_set_auth_key_type(trn_cell_establish_intro_t *inp, uint8_t val);
  158. /** Return the value of the auth_key_len field of the
  159. * trn_cell_establish_intro_t in 'inp'
  160. */
  161. uint16_t trn_cell_establish_intro_get_auth_key_len(const trn_cell_establish_intro_t *inp);
  162. /** Set the value of the auth_key_len field of the
  163. * trn_cell_establish_intro_t in 'inp' to 'val'. Return 0 on success;
  164. * return -1 and set the error code on 'inp' on failure.
  165. */
  166. int trn_cell_establish_intro_set_auth_key_len(trn_cell_establish_intro_t *inp, uint16_t val);
  167. /** Return the length of the dynamic array holding the auth_key field
  168. * of the trn_cell_establish_intro_t in 'inp'.
  169. */
  170. size_t trn_cell_establish_intro_getlen_auth_key(const trn_cell_establish_intro_t *inp);
  171. /** Return the element at position 'idx' of the dynamic array field
  172. * auth_key of the trn_cell_establish_intro_t in 'inp'.
  173. */
  174. uint8_t trn_cell_establish_intro_get_auth_key(trn_cell_establish_intro_t *inp, size_t idx);
  175. /** As trn_cell_establish_intro_get_auth_key, but take and return a
  176. * const pointer
  177. */
  178. uint8_t trn_cell_establish_intro_getconst_auth_key(const trn_cell_establish_intro_t *inp, size_t idx);
  179. /** Change the element at position 'idx' of the dynamic array field
  180. * auth_key of the trn_cell_establish_intro_t in 'inp', so that it
  181. * will hold the value 'elt'.
  182. */
  183. int trn_cell_establish_intro_set_auth_key(trn_cell_establish_intro_t *inp, size_t idx, uint8_t elt);
  184. /** Append a new element 'elt' to the dynamic array field auth_key of
  185. * the trn_cell_establish_intro_t in 'inp'.
  186. */
  187. int trn_cell_establish_intro_add_auth_key(trn_cell_establish_intro_t *inp, uint8_t elt);
  188. /** Return a pointer to the variable-length array field auth_key of
  189. * 'inp'.
  190. */
  191. uint8_t * trn_cell_establish_intro_getarray_auth_key(trn_cell_establish_intro_t *inp);
  192. /** As trn_cell_establish_intro_get_auth_key, but take and return a
  193. * const pointer
  194. */
  195. const uint8_t * trn_cell_establish_intro_getconstarray_auth_key(const trn_cell_establish_intro_t *inp);
  196. /** Change the length of the variable-length array field auth_key of
  197. * 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
  198. * return -1 and set the error code on 'inp' on failure.
  199. */
  200. int trn_cell_establish_intro_setlen_auth_key(trn_cell_establish_intro_t *inp, size_t newlen);
  201. /** Return the value of the extensions field of the
  202. * trn_cell_establish_intro_t in 'inp'
  203. */
  204. struct trn_cell_extension_st * trn_cell_establish_intro_get_extensions(trn_cell_establish_intro_t *inp);
  205. /** As trn_cell_establish_intro_get_extensions, but take and return a
  206. * const pointer
  207. */
  208. const struct trn_cell_extension_st * trn_cell_establish_intro_getconst_extensions(const trn_cell_establish_intro_t *inp);
  209. /** Set the value of the extensions field of the
  210. * trn_cell_establish_intro_t in 'inp' to 'val'. Free the old value if
  211. * any. Steals the referenceto 'val'.Return 0 on success; return -1
  212. * and set the error code on 'inp' on failure.
  213. */
  214. int trn_cell_establish_intro_set_extensions(trn_cell_establish_intro_t *inp, struct trn_cell_extension_st *val);
  215. /** As trn_cell_establish_intro_set_extensions, but does not free the
  216. * previous value.
  217. */
  218. int trn_cell_establish_intro_set0_extensions(trn_cell_establish_intro_t *inp, struct trn_cell_extension_st *val);
  219. /** Return the position for end_mac_fields when we parsed this object
  220. */
  221. const uint8_t * trn_cell_establish_intro_get_end_mac_fields(const trn_cell_establish_intro_t *inp);
  222. /** Return the (constant) length of the array holding the
  223. * handshake_mac field of the trn_cell_establish_intro_t in 'inp'.
  224. */
  225. size_t trn_cell_establish_intro_getlen_handshake_mac(const trn_cell_establish_intro_t *inp);
  226. /** Return the element at position 'idx' of the fixed array field
  227. * handshake_mac of the trn_cell_establish_intro_t in 'inp'.
  228. */
  229. uint8_t trn_cell_establish_intro_get_handshake_mac(trn_cell_establish_intro_t *inp, size_t idx);
  230. /** As trn_cell_establish_intro_get_handshake_mac, but take and return
  231. * a const pointer
  232. */
  233. uint8_t trn_cell_establish_intro_getconst_handshake_mac(const trn_cell_establish_intro_t *inp, size_t idx);
  234. /** Change the element at position 'idx' of the fixed array field
  235. * handshake_mac of the trn_cell_establish_intro_t in 'inp', so that
  236. * it will hold the value 'elt'.
  237. */
  238. int trn_cell_establish_intro_set_handshake_mac(trn_cell_establish_intro_t *inp, size_t idx, uint8_t elt);
  239. /** Return a pointer to the TRUNNEL_SHA3_256_LEN-element array field
  240. * handshake_mac of 'inp'.
  241. */
  242. uint8_t * trn_cell_establish_intro_getarray_handshake_mac(trn_cell_establish_intro_t *inp);
  243. /** As trn_cell_establish_intro_get_handshake_mac, but take and return
  244. * a const pointer
  245. */
  246. const uint8_t * trn_cell_establish_intro_getconstarray_handshake_mac(const trn_cell_establish_intro_t *inp);
  247. /** Return the position for end_sig_fields when we parsed this object
  248. */
  249. const uint8_t * trn_cell_establish_intro_get_end_sig_fields(const trn_cell_establish_intro_t *inp);
  250. /** Return the value of the sig_len field of the
  251. * trn_cell_establish_intro_t in 'inp'
  252. */
  253. uint16_t trn_cell_establish_intro_get_sig_len(const trn_cell_establish_intro_t *inp);
  254. /** Set the value of the sig_len field of the
  255. * trn_cell_establish_intro_t in 'inp' to 'val'. Return 0 on success;
  256. * return -1 and set the error code on 'inp' on failure.
  257. */
  258. int trn_cell_establish_intro_set_sig_len(trn_cell_establish_intro_t *inp, uint16_t val);
  259. /** Return the length of the dynamic array holding the sig field of
  260. * the trn_cell_establish_intro_t in 'inp'.
  261. */
  262. size_t trn_cell_establish_intro_getlen_sig(const trn_cell_establish_intro_t *inp);
  263. /** Return the element at position 'idx' of the dynamic array field
  264. * sig of the trn_cell_establish_intro_t in 'inp'.
  265. */
  266. uint8_t trn_cell_establish_intro_get_sig(trn_cell_establish_intro_t *inp, size_t idx);
  267. /** As trn_cell_establish_intro_get_sig, but take and return a const
  268. * pointer
  269. */
  270. uint8_t trn_cell_establish_intro_getconst_sig(const trn_cell_establish_intro_t *inp, size_t idx);
  271. /** Change the element at position 'idx' of the dynamic array field
  272. * sig of the trn_cell_establish_intro_t in 'inp', so that it will
  273. * hold the value 'elt'.
  274. */
  275. int trn_cell_establish_intro_set_sig(trn_cell_establish_intro_t *inp, size_t idx, uint8_t elt);
  276. /** Append a new element 'elt' to the dynamic array field sig of the
  277. * trn_cell_establish_intro_t in 'inp'.
  278. */
  279. int trn_cell_establish_intro_add_sig(trn_cell_establish_intro_t *inp, uint8_t elt);
  280. /** Return a pointer to the variable-length array field sig of 'inp'.
  281. */
  282. uint8_t * trn_cell_establish_intro_getarray_sig(trn_cell_establish_intro_t *inp);
  283. /** As trn_cell_establish_intro_get_sig, but take and return a const
  284. * pointer
  285. */
  286. const uint8_t * trn_cell_establish_intro_getconstarray_sig(const trn_cell_establish_intro_t *inp);
  287. /** Change the length of the variable-length array field sig of 'inp'
  288. * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
  289. * -1 and set the error code on 'inp' on failure.
  290. */
  291. int trn_cell_establish_intro_setlen_sig(trn_cell_establish_intro_t *inp, size_t newlen);
  292. /** Return a newly allocated trn_cell_extension_dos with all elements
  293. * set to zero.
  294. */
  295. trn_cell_extension_dos_t *trn_cell_extension_dos_new(void);
  296. /** Release all storage held by the trn_cell_extension_dos in
  297. * 'victim'. (Do nothing if 'victim' is NULL.)
  298. */
  299. void trn_cell_extension_dos_free(trn_cell_extension_dos_t *victim);
  300. /** Try to parse a trn_cell_extension_dos from the buffer in 'input',
  301. * using up to 'len_in' bytes from the input buffer. On success,
  302. * return the number of bytes consumed and set *output to the newly
  303. * allocated trn_cell_extension_dos_t. On failure, return -2 if the
  304. * input appears truncated, and -1 if the input is otherwise invalid.
  305. */
  306. ssize_t trn_cell_extension_dos_parse(trn_cell_extension_dos_t **output, const uint8_t *input, const size_t len_in);
  307. /** Return the number of bytes we expect to need to encode the
  308. * trn_cell_extension_dos in 'obj'. On failure, return a negative
  309. * value. Note that this value may be an overestimate, and can even be
  310. * an underestimate for certain unencodeable objects.
  311. */
  312. ssize_t trn_cell_extension_dos_encoded_len(const trn_cell_extension_dos_t *obj);
  313. /** Try to encode the trn_cell_extension_dos from 'input' into the
  314. * buffer at 'output', using up to 'avail' bytes of the output buffer.
  315. * On success, return the number of bytes used. On failure, return -2
  316. * if the buffer was not long enough, and -1 if the input was invalid.
  317. */
  318. ssize_t trn_cell_extension_dos_encode(uint8_t *output, size_t avail, const trn_cell_extension_dos_t *input);
  319. /** Check whether the internal state of the trn_cell_extension_dos in
  320. * 'obj' is consistent. Return NULL if it is, and a short message if
  321. * it is not.
  322. */
  323. const char *trn_cell_extension_dos_check(const trn_cell_extension_dos_t *obj);
  324. /** Clear any errors that were set on the object 'obj' by its setter
  325. * functions. Return true iff errors were cleared.
  326. */
  327. int trn_cell_extension_dos_clear_errors(trn_cell_extension_dos_t *obj);
  328. /** Return the value of the n_params field of the
  329. * trn_cell_extension_dos_t in 'inp'
  330. */
  331. uint8_t trn_cell_extension_dos_get_n_params(const trn_cell_extension_dos_t *inp);
  332. /** Set the value of the n_params field of the
  333. * trn_cell_extension_dos_t in 'inp' to 'val'. Return 0 on success;
  334. * return -1 and set the error code on 'inp' on failure.
  335. */
  336. int trn_cell_extension_dos_set_n_params(trn_cell_extension_dos_t *inp, uint8_t val);
  337. /** Return the length of the dynamic array holding the params field of
  338. * the trn_cell_extension_dos_t in 'inp'.
  339. */
  340. size_t trn_cell_extension_dos_getlen_params(const trn_cell_extension_dos_t *inp);
  341. /** Return the element at position 'idx' of the dynamic array field
  342. * params of the trn_cell_extension_dos_t in 'inp'.
  343. */
  344. struct trn_cell_extension_dos_param_st * trn_cell_extension_dos_get_params(trn_cell_extension_dos_t *inp, size_t idx);
  345. /** As trn_cell_extension_dos_get_params, but take and return a const
  346. * pointer
  347. */
  348. const struct trn_cell_extension_dos_param_st * trn_cell_extension_dos_getconst_params(const trn_cell_extension_dos_t *inp, size_t idx);
  349. /** Change the element at position 'idx' of the dynamic array field
  350. * params of the trn_cell_extension_dos_t in 'inp', so that it will
  351. * hold the value 'elt'. Free the previous value, if any.
  352. */
  353. int trn_cell_extension_dos_set_params(trn_cell_extension_dos_t *inp, size_t idx, struct trn_cell_extension_dos_param_st * elt);
  354. /** As trn_cell_extension_dos_set_params, but does not free the
  355. * previous value.
  356. */
  357. int trn_cell_extension_dos_set0_params(trn_cell_extension_dos_t *inp, size_t idx, struct trn_cell_extension_dos_param_st * elt);
  358. /** Append a new element 'elt' to the dynamic array field params of
  359. * the trn_cell_extension_dos_t in 'inp'.
  360. */
  361. int trn_cell_extension_dos_add_params(trn_cell_extension_dos_t *inp, struct trn_cell_extension_dos_param_st * elt);
  362. /** Return a pointer to the variable-length array field params of
  363. * 'inp'.
  364. */
  365. struct trn_cell_extension_dos_param_st * * trn_cell_extension_dos_getarray_params(trn_cell_extension_dos_t *inp);
  366. /** As trn_cell_extension_dos_get_params, but take and return a const
  367. * pointer
  368. */
  369. const struct trn_cell_extension_dos_param_st * const * trn_cell_extension_dos_getconstarray_params(const trn_cell_extension_dos_t *inp);
  370. /** Change the length of the variable-length array field params of
  371. * 'inp' to 'newlen'.Fill extra elements with NULL; free removed
  372. * elements. Return 0 on success; return -1 and set the error code on
  373. * 'inp' on failure.
  374. */
  375. int trn_cell_extension_dos_setlen_params(trn_cell_extension_dos_t *inp, size_t newlen);
  376. /** Return a newly allocated trn_cell_intro_established with all
  377. * elements set to zero.
  378. */
  379. trn_cell_intro_established_t *trn_cell_intro_established_new(void);
  380. /** Release all storage held by the trn_cell_intro_established in
  381. * 'victim'. (Do nothing if 'victim' is NULL.)
  382. */
  383. void trn_cell_intro_established_free(trn_cell_intro_established_t *victim);
  384. /** Try to parse a trn_cell_intro_established from the buffer in
  385. * 'input', using up to 'len_in' bytes from the input buffer. On
  386. * success, return the number of bytes consumed and set *output to the
  387. * newly allocated trn_cell_intro_established_t. On failure, return -2
  388. * if the input appears truncated, and -1 if the input is otherwise
  389. * invalid.
  390. */
  391. ssize_t trn_cell_intro_established_parse(trn_cell_intro_established_t **output, const uint8_t *input, const size_t len_in);
  392. /** Return the number of bytes we expect to need to encode the
  393. * trn_cell_intro_established in 'obj'. On failure, return a negative
  394. * value. Note that this value may be an overestimate, and can even be
  395. * an underestimate for certain unencodeable objects.
  396. */
  397. ssize_t trn_cell_intro_established_encoded_len(const trn_cell_intro_established_t *obj);
  398. /** Try to encode the trn_cell_intro_established from 'input' into the
  399. * buffer at 'output', using up to 'avail' bytes of the output buffer.
  400. * On success, return the number of bytes used. On failure, return -2
  401. * if the buffer was not long enough, and -1 if the input was invalid.
  402. */
  403. ssize_t trn_cell_intro_established_encode(uint8_t *output, size_t avail, const trn_cell_intro_established_t *input);
  404. /** Check whether the internal state of the trn_cell_intro_established
  405. * in 'obj' is consistent. Return NULL if it is, and a short message
  406. * if it is not.
  407. */
  408. const char *trn_cell_intro_established_check(const trn_cell_intro_established_t *obj);
  409. /** Clear any errors that were set on the object 'obj' by its setter
  410. * functions. Return true iff errors were cleared.
  411. */
  412. int trn_cell_intro_established_clear_errors(trn_cell_intro_established_t *obj);
  413. /** Return the value of the extensions field of the
  414. * trn_cell_intro_established_t in 'inp'
  415. */
  416. struct trn_cell_extension_st * trn_cell_intro_established_get_extensions(trn_cell_intro_established_t *inp);
  417. /** As trn_cell_intro_established_get_extensions, but take and return
  418. * a const pointer
  419. */
  420. const struct trn_cell_extension_st * trn_cell_intro_established_getconst_extensions(const trn_cell_intro_established_t *inp);
  421. /** Set the value of the extensions field of the
  422. * trn_cell_intro_established_t in 'inp' to 'val'. Free the old value
  423. * if any. Steals the referenceto 'val'.Return 0 on success; return -1
  424. * and set the error code on 'inp' on failure.
  425. */
  426. int trn_cell_intro_established_set_extensions(trn_cell_intro_established_t *inp, struct trn_cell_extension_st *val);
  427. /** As trn_cell_intro_established_set_extensions, but does not free
  428. * the previous value.
  429. */
  430. int trn_cell_intro_established_set0_extensions(trn_cell_intro_established_t *inp, struct trn_cell_extension_st *val);
  431. #endif